diff --git a/.gitignore b/.gitignore
index aacb1f2b..b4366fe6 100644
--- a/.gitignore
+++ b/.gitignore
@@ -24,6 +24,7 @@ website/node_modules
*.iml
*.test
*.iml
+.env
website/vendor
diff --git a/docs/data-sources/restconf.md b/docs/data-sources/yang.md
similarity index 54%
rename from docs/data-sources/restconf.md
rename to docs/data-sources/yang.md
index bd2133f1..dcb96e8c 100644
--- a/docs/data-sources/restconf.md
+++ b/docs/data-sources/yang.md
@@ -1,20 +1,20 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
-page_title: "iosxe_restconf Data Source - terraform-provider-iosxe"
+page_title: "iosxe_yang Data Source - terraform-provider-iosxe"
subcategory: "General"
description: |-
- This data source can retrieve one or more attributes via RESTCONF.
+ This data source can retrieve one or more attributes via YANG paths.
---
-# iosxe_restconf (Data Source)
+# iosxe_yang (Data Source)
-This data source can retrieve one or more attributes via RESTCONF.
+This data source can retrieve one or more attributes via YANG paths.
## Example Usage
```terraform
-data "iosxe_restconf" "example" {
- path = "Cisco-IOS-XE-native:native/banner/login"
+data "iosxe_yang" "example" {
+ path = "/Cisco-IOS-XE-native:native/banner/login"
}
```
@@ -23,7 +23,7 @@ data "iosxe_restconf" "example" {
### Required
-- `path` (String) A RESTCONF path, e.g. `openconfig-interfaces:interfaces`.
+- `path` (String) A YANG path, e.g. `openconfig-interfaces:interfaces`.
### Optional
diff --git a/docs/index.md b/docs/index.md
index be9af4a0..eac2b8fb 100644
--- a/docs/index.md
+++ b/docs/index.md
@@ -51,12 +51,15 @@ provider "iosxe" {
### Optional
- `devices` (Attributes List) This can be used to manage a list of devices from a single provider. All devices must use the same credentials. Each resource and data source has an optional attribute named `device`, which can then select a device by its name from this list. (see [below for nested schema](#nestedatt--devices))
+- `host` (String) Hostname or IP address of the Cisco IOS-XE device. Optionally a port can be added with `:port`. Default port is `443` for RESTCONF and `830` for NETCONF. This can also be set as the IOSXE_HOST environment variable.
- `insecure` (Boolean) Allow insecure HTTPS client. This can also be set as the IOSXE_INSECURE environment variable. Defaults to `true`.
- `lock_release_timeout` (Number) Number of seconds to wait for the device database lock to be released. This can also be set as the IOSXE_LOCK_RELEASE_TIMEOUT environment variable. Defaults to `120`.
- `password` (String, Sensitive) Password for the IOS-XE device. This can also be set as the IOSXE_PASSWORD environment variable.
+- `protocol` (String) Protocol to use for device communication. Either `restconf` (HTTPS) or `netconf` (SSH). This can also be set as the IOSXE_PROTOCOL environment variable. Defaults to `restconf`.
- `retries` (Number) Number of retries for REST API calls. This can also be set as the IOSXE_RETRIES environment variable. Defaults to `10`.
+- `reuse_connection` (Boolean) Keep NETCONF connections open between operations for better performance. When disabled, connections are closed and reopened for each operation. Only applies to NETCONF protocol. This can also be set as the IOSXE_REUSE_CONNECTION environment variable. Defaults to `true`.
- `selected_devices` (List of String) This can be used to select a list of devices to manage from the `devices` list. Selected devices will be managed while other devices will be skipped and their state will be frozen. This can be used to deploy changes to a subset of devices. Defaults to all devices.
-- `url` (String) URL of the Cisco IOS-XE device. Optionally a port can be added with `:12345`. The default port is `443`. This can also be set as the IOSXE_URL environment variable.
+- `url` (String, Deprecated) URL of the Cisco IOS-XE device for RESTCONF protocol. Optionally a port can be added with `:12345`. The default port is `443`. This can also be set as the IOSXE_URL environment variable. **Deprecated: Use `host` instead for protocol-agnostic configuration.**
- `username` (String) Username for the IOS-XE device. This can also be set as the IOSXE_USERNAME environment variable.
@@ -65,8 +68,9 @@ provider "iosxe" {
Required:
- `name` (String) Device name.
-- `url` (String) URL of the Cisco IOS-XE device.
Optional:
-- `managed` (Boolean) Enable or disable device management. This can be used to temporarily skip a device due to maintainance for example. Defaults to `true`.
\ No newline at end of file
+- `host` (String) Hostname or IP address of the Cisco IOS-XE device. Optionally a port can be added with `:port`.
+- `managed` (Boolean) Enable or disable device management. This can be used to temporarily skip a device due to maintainance for example. Defaults to `true`.
+- `url` (String, Deprecated) URL of the Cisco IOS-XE device for RESTCONF protocol. **Deprecated: Use `host` instead.**
\ No newline at end of file
diff --git a/docs/resources/restconf.md b/docs/resources/yang.md
similarity index 65%
rename from docs/resources/restconf.md
rename to docs/resources/yang.md
index d0d0f52b..8ba88a17 100644
--- a/docs/resources/restconf.md
+++ b/docs/resources/yang.md
@@ -1,27 +1,27 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
-page_title: "iosxe_restconf Resource - terraform-provider-iosxe"
+page_title: "iosxe_yang Resource - terraform-provider-iosxe"
subcategory: "General"
description: |-
- Manages IOS-XE objects via RESTCONF calls. This resource can only manage a single object. It is able to read the state and therefore reconcile configuration drift.
+ Manages IOS-XE objects via YANG paths. This resource can only manage a single object. It is able to read the state and therefore reconcile configuration drift.
---
-# iosxe_restconf (Resource)
+# iosxe_yang (Resource)
-Manages IOS-XE objects via RESTCONF calls. This resource can only manage a single object. It is able to read the state and therefore reconcile configuration drift.
+Manages IOS-XE objects via YANG paths. This resource can only manage a single object. It is able to read the state and therefore reconcile configuration drift.
## Example Usage
```terraform
-resource "iosxe_restconf" "simple" {
- path = "Cisco-IOS-XE-native:native/banner/login"
+resource "iosxe_yang" "simple" {
+ path = "/Cisco-IOS-XE-native:native/banner/login"
attributes = {
banner = "My Banner"
}
}
-resource "iosxe_restconf" "nested_list" {
- path = "Cisco-IOS-XE-native:native/ip"
+resource "iosxe_yang" "nested_list" {
+ path = "/Cisco-IOS-XE-native:native/ip"
attributes = {
source-route = "true"
}
@@ -42,7 +42,7 @@ resource "iosxe_restconf" "nested_list" {
### Required
-- `path` (String) A RESTCONF path, e.g. `openconfig-interfaces:interfaces`.
+- `path` (String) A YANG path, e.g. `openconfig-interfaces:interfaces`.
### Optional
@@ -75,5 +75,5 @@ Import is supported using the following syntax:
The [`terraform import` command](https://developer.hashicorp.com/terraform/cli/commands/import) can be used, for example:
```shell
-terraform import iosxe_restconf.example "Cisco-IOS-XE-native:native/banner/login"
+terraform import iosxe_yang.example "/Cisco-IOS-XE-native:native/banner/login"
```
diff --git a/examples/data-sources/iosxe_restconf/data-source.tf b/examples/data-sources/iosxe_restconf/data-source.tf
deleted file mode 100644
index 4bebba3a..00000000
--- a/examples/data-sources/iosxe_restconf/data-source.tf
+++ /dev/null
@@ -1,3 +0,0 @@
-data "iosxe_restconf" "example" {
- path = "Cisco-IOS-XE-native:native/banner/login"
-}
diff --git a/examples/data-sources/iosxe_yang/data-source.tf b/examples/data-sources/iosxe_yang/data-source.tf
new file mode 100644
index 00000000..8147a474
--- /dev/null
+++ b/examples/data-sources/iosxe_yang/data-source.tf
@@ -0,0 +1,3 @@
+data "iosxe_yang" "example" {
+ path = "/Cisco-IOS-XE-native:native/banner/login"
+}
diff --git a/examples/resources/iosxe_restconf/import.sh b/examples/resources/iosxe_restconf/import.sh
deleted file mode 100644
index e544288d..00000000
--- a/examples/resources/iosxe_restconf/import.sh
+++ /dev/null
@@ -1 +0,0 @@
-terraform import iosxe_restconf.example "Cisco-IOS-XE-native:native/banner/login"
diff --git a/examples/resources/iosxe_yang/import.sh b/examples/resources/iosxe_yang/import.sh
new file mode 100644
index 00000000..ddea6ad4
--- /dev/null
+++ b/examples/resources/iosxe_yang/import.sh
@@ -0,0 +1 @@
+terraform import iosxe_yang.example "/Cisco-IOS-XE-native:native/banner/login"
diff --git a/examples/resources/iosxe_restconf/resource.tf b/examples/resources/iosxe_yang/resource.tf
similarity index 55%
rename from examples/resources/iosxe_restconf/resource.tf
rename to examples/resources/iosxe_yang/resource.tf
index ebb53aac..2595eea2 100644
--- a/examples/resources/iosxe_restconf/resource.tf
+++ b/examples/resources/iosxe_yang/resource.tf
@@ -1,12 +1,12 @@
-resource "iosxe_restconf" "simple" {
- path = "Cisco-IOS-XE-native:native/banner/login"
+resource "iosxe_yang" "simple" {
+ path = "/Cisco-IOS-XE-native:native/banner/login"
attributes = {
banner = "My Banner"
}
}
-resource "iosxe_restconf" "nested_list" {
- path = "Cisco-IOS-XE-native:native/ip"
+resource "iosxe_yang" "nested_list" {
+ path = "/Cisco-IOS-XE-native:native/ip"
attributes = {
source-route = "true"
}
diff --git a/gen/definitions/aaa.yaml b/gen/definitions/aaa.yaml
index b32a6acc..60e76cba 100644
--- a/gen/definitions/aaa.yaml
+++ b/gen/definitions/aaa.yaml
@@ -1,6 +1,6 @@
---
name: AAA
-path: Cisco-IOS-XE-native:native/aaa
+path: /Cisco-IOS-XE-native:native/aaa
no_delete_attributes: true
doc_category: AAA
test_tags: [AAA]
@@ -158,7 +158,7 @@ attributes:
exclude_test: true
test_prerequisites:
- - path: Cisco-IOS-XE-native:native/vrf/definition=VRF1
+ - path: /Cisco-IOS-XE-native:native/vrf/definition[name=VRF1]
no_delete: true
attributes:
- name: name
diff --git a/gen/definitions/aaa_accounting.yaml b/gen/definitions/aaa_accounting.yaml
index 40c541d0..2dc2d491 100644
--- a/gen/definitions/aaa_accounting.yaml
+++ b/gen/definitions/aaa_accounting.yaml
@@ -1,6 +1,6 @@
---
name: AAA Accounting
-path: Cisco-IOS-XE-native:native/aaa/Cisco-IOS-XE-aaa:accounting
+path: /Cisco-IOS-XE-native:native/aaa/Cisco-IOS-XE-aaa:accounting
doc_category: AAA
attributes:
- yang_name: update/update-choice/newinfo/newinfo/periodic
diff --git a/gen/definitions/aaa_authentication.yaml b/gen/definitions/aaa_authentication.yaml
index d3ae8b06..557814ae 100644
--- a/gen/definitions/aaa_authentication.yaml
+++ b/gen/definitions/aaa_authentication.yaml
@@ -1,6 +1,6 @@
---
name: AAA Authentication
-path: Cisco-IOS-XE-native:native/aaa/Cisco-IOS-XE-aaa:authentication
+path: /Cisco-IOS-XE-native:native/aaa/Cisco-IOS-XE-aaa:authentication
doc_category: AAA
test_tags: [AAA]
attributes:
diff --git a/gen/definitions/aaa_authorization.yaml b/gen/definitions/aaa_authorization.yaml
index d608301c..2879af14 100644
--- a/gen/definitions/aaa_authorization.yaml
+++ b/gen/definitions/aaa_authorization.yaml
@@ -1,6 +1,6 @@
---
name: AAA Authorization
-path: Cisco-IOS-XE-native:native/aaa/Cisco-IOS-XE-aaa:authorization
+path: /Cisco-IOS-XE-native:native/aaa/Cisco-IOS-XE-aaa:authorization
doc_category: AAA
test_tags: [AAA]
attributes:
diff --git a/gen/definitions/access_list_extended.yaml b/gen/definitions/access_list_extended.yaml
index 7dc72e36..adf2073f 100644
--- a/gen/definitions/access_list_extended.yaml
+++ b/gen/definitions/access_list_extended.yaml
@@ -1,6 +1,6 @@
---
name: Access List Extended
-path: Cisco-IOS-XE-native:native/ip/access-list/Cisco-IOS-XE-acl:extended=%v
+path: /Cisco-IOS-XE-native:native/ip/access-list/Cisco-IOS-XE-acl:extended[name=%v]
no_delete_attributes: true
doc_category: System
attributes:
diff --git a/gen/definitions/access_list_role_based.yaml b/gen/definitions/access_list_role_based.yaml
index a59f521b..dd86723a 100644
--- a/gen/definitions/access_list_role_based.yaml
+++ b/gen/definitions/access_list_role_based.yaml
@@ -1,6 +1,6 @@
---
name: Access List Role Based
-path: Cisco-IOS-XE-native:native/ip/access-list/Cisco-IOS-XE-acl:role-based=%v
+path: /Cisco-IOS-XE-native:native/ip/access-list/Cisco-IOS-XE-acl:role-based[name=%v]
no_delete_attributes: true
doc_category: System
attributes:
diff --git a/gen/definitions/access_list_standard.yaml b/gen/definitions/access_list_standard.yaml
index 40e48f22..ead0a512 100644
--- a/gen/definitions/access_list_standard.yaml
+++ b/gen/definitions/access_list_standard.yaml
@@ -1,6 +1,6 @@
---
name: Access List Standard
-path: Cisco-IOS-XE-native:native/ip/access-list/Cisco-IOS-XE-acl:standard=%v
+path: /Cisco-IOS-XE-native:native/ip/access-list/Cisco-IOS-XE-acl:standard[name=%v]
no_delete_attributes: true
doc_category: System
attributes:
diff --git a/gen/definitions/arp.yaml b/gen/definitions/arp.yaml
index 07165a2d..436825a8 100644
--- a/gen/definitions/arp.yaml
+++ b/gen/definitions/arp.yaml
@@ -1,6 +1,6 @@
---
name: ARP
-path: Cisco-IOS-XE-native:native/ip/arp
+path: /Cisco-IOS-XE-native:native/ip/arp
doc_category: System
attributes:
- yang_name: incomplete/entries
diff --git a/gen/definitions/as_path_access_list.yaml b/gen/definitions/as_path_access_list.yaml
index f5679d6a..bb76acfe 100644
--- a/gen/definitions/as_path_access_list.yaml
+++ b/gen/definitions/as_path_access_list.yaml
@@ -1,6 +1,6 @@
---
name: AS Path Access List
-path: Cisco-IOS-XE-native:native/ip/as-path/Cisco-IOS-XE-bgp:access-list=%v
+path: /Cisco-IOS-XE-native:native/ip/as-path/Cisco-IOS-XE-bgp:access-list[name=%v]
no_delete_attributes: true
skip_minimum_test: true
doc_category: BGP
diff --git a/gen/definitions/banner.yaml b/gen/definitions/banner.yaml
index 1cda913a..8f548f65 100644
--- a/gen/definitions/banner.yaml
+++ b/gen/definitions/banner.yaml
@@ -1,6 +1,6 @@
---
name: Banner
-path: Cisco-IOS-XE-native:native/banner
+path: /Cisco-IOS-XE-native:native/banner
doc_category: System
attributes:
- yang_name: exec/banner
diff --git a/gen/definitions/bfd.yaml b/gen/definitions/bfd.yaml
index fc169716..4e2d2b3c 100644
--- a/gen/definitions/bfd.yaml
+++ b/gen/definitions/bfd.yaml
@@ -1,6 +1,6 @@
---
name: BFD
-path: Cisco-IOS-XE-native:native/bfd
+path: /Cisco-IOS-XE-native:native/bfd
doc_category: BFD
attributes:
- yang_name: Cisco-IOS-XE-bfd:map/ipv4-list-with-both-vrf/ipv4
diff --git a/gen/definitions/bfd_template_multi_hop.yaml b/gen/definitions/bfd_template_multi_hop.yaml
index 1040744b..f5467175 100644
--- a/gen/definitions/bfd_template_multi_hop.yaml
+++ b/gen/definitions/bfd_template_multi_hop.yaml
@@ -1,6 +1,6 @@
---
name: BFD Template Multi Hop
-path: Cisco-IOS-XE-native:native/bfd-template/Cisco-IOS-XE-bfd:multi-hop=%s
+path: /Cisco-IOS-XE-native:native/bfd-template/Cisco-IOS-XE-bfd:multi-hop[name=%s]
no_delete_attributes: true
doc_category: BFD
attributes:
diff --git a/gen/definitions/bfd_template_single_hop.yaml b/gen/definitions/bfd_template_single_hop.yaml
index 1ad4d667..eb700ed3 100644
--- a/gen/definitions/bfd_template_single_hop.yaml
+++ b/gen/definitions/bfd_template_single_hop.yaml
@@ -1,6 +1,6 @@
---
name: BFD Template Single Hop
-path: Cisco-IOS-XE-native:native/bfd-template/Cisco-IOS-XE-bfd:single-hop=%v
+path: /Cisco-IOS-XE-native:native/bfd-template/Cisco-IOS-XE-bfd:single-hop[name=%v]
no_delete_attributes: true
doc_category: BFD
attributes:
diff --git a/gen/definitions/bgp.yaml b/gen/definitions/bgp.yaml
index 189f6c17..625e49d5 100644
--- a/gen/definitions/bgp.yaml
+++ b/gen/definitions/bgp.yaml
@@ -1,6 +1,6 @@
---
name: BGP
-path: Cisco-IOS-XE-native:native/router/Cisco-IOS-XE-bgp:bgp=%v
+path: /Cisco-IOS-XE-native:native/router/Cisco-IOS-XE-bgp:bgp[id=%v]
doc_category: BGP
attributes:
- yang_name: id
@@ -21,7 +21,7 @@ attributes:
tf_name: router_id_ip
example: 172.16.255.1
test_prerequisites:
- - path: Cisco-IOS-XE-native:native/interface/Loopback=100
+ - path: /Cisco-IOS-XE-native:native/interface/Loopback[name=100]
attributes:
- name: name
value: 100
diff --git a/gen/definitions/bgp_address_family_ipv4.yaml b/gen/definitions/bgp_address_family_ipv4.yaml
index 051f6c23..8bd8ee29 100644
--- a/gen/definitions/bgp_address_family_ipv4.yaml
+++ b/gen/definitions/bgp_address_family_ipv4.yaml
@@ -1,6 +1,6 @@
---
name: BGP Address Family IPv4
-path: Cisco-IOS-XE-native:native/router/Cisco-IOS-XE-bgp:bgp=%v/address-family/no-vrf/ipv4=%s
+path: /Cisco-IOS-XE-native:native/router/Cisco-IOS-XE-bgp:bgp[id=%v]/address-family/no-vrf/ipv4[af-name=%s]
doc_category: BGP
attributes:
- yang_name: id
@@ -79,7 +79,7 @@ attributes:
example: 200
test_prerequisites:
- - path: Cisco-IOS-XE-native:native/router/Cisco-IOS-XE-bgp:bgp=65000
+ - path: /Cisco-IOS-XE-native:native/router/Cisco-IOS-XE-bgp:bgp[id=65000]
attributes:
- name: id
value: 65000
diff --git a/gen/definitions/bgp_address_family_ipv4_vrf.yaml b/gen/definitions/bgp_address_family_ipv4_vrf.yaml
index 7ee0dd6e..ced57cf4 100644
--- a/gen/definitions/bgp_address_family_ipv4_vrf.yaml
+++ b/gen/definitions/bgp_address_family_ipv4_vrf.yaml
@@ -1,6 +1,6 @@
---
name: BGP Address Family IPv4 VRF
-path: Cisco-IOS-XE-native:native/router/Cisco-IOS-XE-bgp:bgp=%v/address-family/with-vrf/ipv4=%s
+path: /Cisco-IOS-XE-native:native/router/Cisco-IOS-XE-bgp:bgp[id=%v]/address-family/with-vrf/ipv4[af-name=%s]
skip_minimum_test: true
doc_category: BGP
attributes:
@@ -112,7 +112,7 @@ attributes:
example: 200
test_prerequisites:
- - path: Cisco-IOS-XE-native:native/vrf/definition=VRF1
+ - path: /Cisco-IOS-XE-native:native/vrf/definition[name=VRF1]
no_delete: true
attributes:
- name: name
@@ -121,12 +121,12 @@ test_prerequisites:
value: 1:1
- name: address-family/ipv4
value: ""
- - path: Cisco-IOS-XE-native:native/router/Cisco-IOS-XE-bgp:bgp=65000
+ - path: /Cisco-IOS-XE-native:native/router/Cisco-IOS-XE-bgp:bgp[id=65000]
attributes:
- name: id
value: 65000
dependencies: [0]
- - path: Cisco-IOS-XE-native:native/interface/Loopback=101
+ - path: /Cisco-IOS-XE-native:native/interface/Loopback[name=101]
attributes:
- name: name
value: 101
diff --git a/gen/definitions/bgp_address_family_ipv6.yaml b/gen/definitions/bgp_address_family_ipv6.yaml
index 0044965c..dbc837e6 100644
--- a/gen/definitions/bgp_address_family_ipv6.yaml
+++ b/gen/definitions/bgp_address_family_ipv6.yaml
@@ -1,6 +1,6 @@
---
name: BGP Address Family IPv6
-path: Cisco-IOS-XE-native:native/router/Cisco-IOS-XE-bgp:bgp=%v/address-family/no-vrf/ipv6=%s
+path: /Cisco-IOS-XE-native:native/router/Cisco-IOS-XE-bgp:bgp[id=%v]/address-family/no-vrf/ipv6[af-name=%s]
doc_category: BGP
attributes:
- yang_name: id
@@ -27,11 +27,11 @@ attributes:
- yang_name: backdoor
example: true
test_prerequisites:
- - path: Cisco-IOS-XE-native:native/ipv6
+ - path: /Cisco-IOS-XE-native:native/ipv6
attributes:
- name: unicast-routing
value: ""
- - path: Cisco-IOS-XE-native:native/router/Cisco-IOS-XE-bgp:bgp=65000
+ - path: /Cisco-IOS-XE-native:native/router/Cisco-IOS-XE-bgp:bgp[id=65000]
attributes:
- name: id
value: 65000
diff --git a/gen/definitions/bgp_address_family_ipv6_vrf.yaml b/gen/definitions/bgp_address_family_ipv6_vrf.yaml
index 57ab184f..7eec8209 100644
--- a/gen/definitions/bgp_address_family_ipv6_vrf.yaml
+++ b/gen/definitions/bgp_address_family_ipv6_vrf.yaml
@@ -1,6 +1,6 @@
---
name: BGP Address Family IPv6 VRF
-path: Cisco-IOS-XE-native:native/router/Cisco-IOS-XE-bgp:bgp=%v/address-family/with-vrf/ipv6=%s
+path: /Cisco-IOS-XE-native:native/router/Cisco-IOS-XE-bgp:bgp[id=%v]/address-family/with-vrf/ipv6[af-name=%s]
skip_minimum_test: true
doc_category: BGP
attributes:
@@ -40,11 +40,11 @@ attributes:
- yang_name: evpn
example: false
test_prerequisites:
- - path: Cisco-IOS-XE-native:native/ipv6
+ - path: /Cisco-IOS-XE-native:native/ipv6
attributes:
- name: unicast-routing
value: ""
- - path: Cisco-IOS-XE-native:native/vrf/definition=VRF1
+ - path: /Cisco-IOS-XE-native:native/vrf/definition[name=VRF1]
no_delete: true
attributes:
- name: name
@@ -54,7 +54,7 @@ test_prerequisites:
- name: address-family/ipv6
value: ""
dependencies: [0]
- - path: Cisco-IOS-XE-native:native/router/Cisco-IOS-XE-bgp:bgp=65000
+ - path: /Cisco-IOS-XE-native:native/router/Cisco-IOS-XE-bgp:bgp[id=65000]
attributes:
- name: id
value: 65000
diff --git a/gen/definitions/bgp_address_family_l2vpn.yaml b/gen/definitions/bgp_address_family_l2vpn.yaml
index f189b1cd..c7dfb61e 100644
--- a/gen/definitions/bgp_address_family_l2vpn.yaml
+++ b/gen/definitions/bgp_address_family_l2vpn.yaml
@@ -1,6 +1,6 @@
---
name: BGP Address Family L2VPN
-path: Cisco-IOS-XE-native:native/router/Cisco-IOS-XE-bgp:bgp=%v/address-family/no-vrf/l2vpn=%s
+path: /Cisco-IOS-XE-native:native/router/Cisco-IOS-XE-bgp:bgp[id=%v]/address-family/no-vrf/l2vpn[af-name=%s]
doc_category: BGP
test_tags: [C9000V]
attributes:
@@ -10,7 +10,7 @@ attributes:
- yang_name: af-name
example: evpn
test_prerequisites:
- - path: Cisco-IOS-XE-native:native/router/Cisco-IOS-XE-bgp:bgp=65000
+ - path: /Cisco-IOS-XE-native:native/router/Cisco-IOS-XE-bgp:bgp[id=65000]
attributes:
- name: id
value: 65000
diff --git a/gen/definitions/bgp_ipv4_unicast_neighbor.yaml b/gen/definitions/bgp_ipv4_unicast_neighbor.yaml
index 1a7cc696..f4966531 100644
--- a/gen/definitions/bgp_ipv4_unicast_neighbor.yaml
+++ b/gen/definitions/bgp_ipv4_unicast_neighbor.yaml
@@ -1,6 +1,6 @@
---
name: BGP IPv4 Unicast Neighbor
-path: Cisco-IOS-XE-native:native/router/Cisco-IOS-XE-bgp:bgp=%v/address-family/no-vrf/ipv4=unicast/ipv4-unicast/neighbor=%s
+path: /Cisco-IOS-XE-native:native/router/Cisco-IOS-XE-bgp:bgp[id=%v]/address-family/no-vrf/ipv4[af-name=unicast]/ipv4-unicast/neighbor[id=%s]
doc_category: BGP
attributes:
- yang_name: id
@@ -37,23 +37,23 @@ attributes:
- yang_name: route-map-name
example: RM1
test_prerequisites:
- - path: Cisco-IOS-XE-native:native/router/Cisco-IOS-XE-bgp:bgp=65000
+ - path: /Cisco-IOS-XE-native:native/router/Cisco-IOS-XE-bgp:bgp[id=65000]
attributes:
- name: id
value: 65000
- - path: Cisco-IOS-XE-native:native/router/Cisco-IOS-XE-bgp:bgp=65000/address-family/no-vrf/ipv4=unicast
+ - path: /Cisco-IOS-XE-native:native/router/Cisco-IOS-XE-bgp:bgp[id=65000]/address-family/no-vrf/ipv4[af-name=unicast]
attributes:
- name: af-name
value: unicast
dependencies: [0]
- - path: Cisco-IOS-XE-native:native/router/Cisco-IOS-XE-bgp:bgp=65000/neighbor=3.3.3.3
+ - path: /Cisco-IOS-XE-native:native/router/Cisco-IOS-XE-bgp:bgp[id=65000]/neighbor[id=3.3.3.3]
attributes:
- name: id
value: 3.3.3.3
- name: remote-as
value: 65000
dependencies: [0]
- - path: Cisco-IOS-XE-native:native/interface/Loopback=100
+ - path: /Cisco-IOS-XE-native:native/interface/Loopback[name=100]
attributes:
- name: name
value: 100
diff --git a/gen/definitions/bgp_ipv4_unicast_vrf_neighbor.yaml b/gen/definitions/bgp_ipv4_unicast_vrf_neighbor.yaml
index 30a9dd10..a25a26ba 100644
--- a/gen/definitions/bgp_ipv4_unicast_vrf_neighbor.yaml
+++ b/gen/definitions/bgp_ipv4_unicast_vrf_neighbor.yaml
@@ -1,6 +1,6 @@
---
name: BGP IPv4 Unicast VRF Neighbor
-path: Cisco-IOS-XE-native:native/router/Cisco-IOS-XE-bgp:bgp=%v/address-family/with-vrf/ipv4=unicast/vrf=%s/ipv4-unicast/neighbor=%s
+path: /Cisco-IOS-XE-native:native/router/Cisco-IOS-XE-bgp:bgp[id=%v]/address-family/with-vrf/ipv4[af-name=unicast]/vrf[name=%s]/ipv4-unicast/neighbor[id=%s]
skip_minimum_test: true
doc_category: BGP
attributes:
@@ -142,7 +142,7 @@ attributes:
- yang_name: advertisement-interval
example: 300
test_prerequisites:
- - path: Cisco-IOS-XE-native:native/vrf/definition=VRF1
+ - path: /Cisco-IOS-XE-native:native/vrf/definition[name=VRF1]
no_delete: true
attributes:
- name: name
@@ -151,11 +151,11 @@ test_prerequisites:
value: 1:1
- name: address-family/ipv4
value: ""
- - path: Cisco-IOS-XE-native:native/router/Cisco-IOS-XE-bgp:bgp=65000
+ - path: /Cisco-IOS-XE-native:native/router/Cisco-IOS-XE-bgp:bgp[id=65000]
attributes:
- name: id
value: 65000
- - path: Cisco-IOS-XE-native:native/router/Cisco-IOS-XE-bgp:bgp=65000/address-family/with-vrf/ipv4=unicast
+ - path: /Cisco-IOS-XE-native:native/router/Cisco-IOS-XE-bgp:bgp[id=65000]/address-family/with-vrf/ipv4[af-name=unicast]
attributes:
- name: af-name
value: unicast
@@ -167,7 +167,7 @@ test_prerequisites:
- name: name
value: VRF1
dependencies: [0, 1]
- - path: Cisco-IOS-XE-native:native/interface/Loopback=100
+ - path: /Cisco-IOS-XE-native:native/interface/Loopback[name=100]
attributes:
- name: name
value: 100
diff --git a/gen/definitions/bgp_ipv6_unicast_neighbor.yaml b/gen/definitions/bgp_ipv6_unicast_neighbor.yaml
index f8fff687..f8fd41cd 100644
--- a/gen/definitions/bgp_ipv6_unicast_neighbor.yaml
+++ b/gen/definitions/bgp_ipv6_unicast_neighbor.yaml
@@ -1,6 +1,6 @@
---
name: BGP IPv6 Unicast Neighbor
-path: Cisco-IOS-XE-native:native/router/Cisco-IOS-XE-bgp:bgp=%v/address-family/no-vrf/ipv6=unicast/ipv6-unicast/neighbor=%s
+path: /Cisco-IOS-XE-native:native/router/Cisco-IOS-XE-bgp:bgp[id=%v]/address-family/no-vrf/ipv6[af-name=unicast]/ipv6-unicast/neighbor[id=%s]
doc_category: BGP
attributes:
- yang_name: id
@@ -37,27 +37,27 @@ attributes:
- yang_name: route-map-name
example: RM1
test_prerequisites:
- - path: Cisco-IOS-XE-native:native/ipv6
+ - path: /Cisco-IOS-XE-native:native/ipv6
attributes:
- name: unicast-routing
value: ""
- - path: Cisco-IOS-XE-native:native/router/Cisco-IOS-XE-bgp:bgp=65000
+ - path: /Cisco-IOS-XE-native:native/router/Cisco-IOS-XE-bgp:bgp[id=65000]
attributes:
- name: id
value: 65000
- - path: Cisco-IOS-XE-native:native/router/Cisco-IOS-XE-bgp:bgp=65000/address-family/no-vrf/ipv6=unicast
+ - path: /Cisco-IOS-XE-native:native/router/Cisco-IOS-XE-bgp:bgp[id=65000]/address-family/no-vrf/ipv6[af-name=unicast]
attributes:
- name: af-name
value: unicast
dependencies: [0, 1]
- - path: Cisco-IOS-XE-native:native/router/Cisco-IOS-XE-bgp:bgp=65000/neighbor=3.3.3.3
+ - path: /Cisco-IOS-XE-native:native/router/Cisco-IOS-XE-bgp:bgp[id=65000]/neighbor[id=3.3.3.3]
attributes:
- name: id
value: 3.3.3.3
- name: remote-as
value: 65000
dependencies: [0, 1]
- - path: Cisco-IOS-XE-native:native/interface/Loopback=100
+ - path: /Cisco-IOS-XE-native:native/interface/Loopback[name=100]
attributes:
- name: name
value: 100
diff --git a/gen/definitions/bgp_l2vpn_evpn_neighbor.yaml b/gen/definitions/bgp_l2vpn_evpn_neighbor.yaml
index 6d54a195..d8bc2832 100644
--- a/gen/definitions/bgp_l2vpn_evpn_neighbor.yaml
+++ b/gen/definitions/bgp_l2vpn_evpn_neighbor.yaml
@@ -1,6 +1,6 @@
---
name: BGP L2VPN EVPN Neighbor
-path: Cisco-IOS-XE-native:native/router/Cisco-IOS-XE-bgp:bgp=%v/address-family/no-vrf/l2vpn=evpn/l2vpn-evpn/neighbor=%s
+path: /Cisco-IOS-XE-native:native/router/Cisco-IOS-XE-bgp:bgp[id=%v]/address-family/no-vrf/l2vpn[af-name=evpn]/l2vpn-evpn/neighbor[id=%s]
doc_category: BGP
test_tags: [C9000V]
attributes:
@@ -24,16 +24,16 @@ attributes:
- yang_name: soft-reconfiguration
example: inbound
test_prerequisites:
- - path: Cisco-IOS-XE-native:native/router/Cisco-IOS-XE-bgp:bgp=65000
+ - path: /Cisco-IOS-XE-native:native/router/Cisco-IOS-XE-bgp:bgp[id=65000]
attributes:
- name: id
value: 65000
- - path: Cisco-IOS-XE-native:native/router/Cisco-IOS-XE-bgp:bgp=65000/address-family/no-vrf/l2vpn=evpn
+ - path: /Cisco-IOS-XE-native:native/router/Cisco-IOS-XE-bgp:bgp[id=65000]/address-family/no-vrf/l2vpn[af-name=evpn]
attributes:
- name: af-name
value: evpn
dependencies: [0]
- - path: Cisco-IOS-XE-native:native/router/Cisco-IOS-XE-bgp:bgp=65000/neighbor=3.3.3.3
+ - path: /Cisco-IOS-XE-native:native/router/Cisco-IOS-XE-bgp:bgp[id=65000]/neighbor[id=3.3.3.3]
attributes:
- name: id
value: 3.3.3.3
diff --git a/gen/definitions/bgp_neighbor.yaml b/gen/definitions/bgp_neighbor.yaml
index 3f7411e9..d36d4f9b 100644
--- a/gen/definitions/bgp_neighbor.yaml
+++ b/gen/definitions/bgp_neighbor.yaml
@@ -1,6 +1,6 @@
---
name: BGP Neighbor
-path: Cisco-IOS-XE-native:native/router/Cisco-IOS-XE-bgp:bgp=%v/neighbor=%s
+path: /Cisco-IOS-XE-native:native/router/Cisco-IOS-XE-bgp:bgp[id=%v]/neighbor[id=%s]
doc_category: BGP
skip_minimum_test: true
attributes:
@@ -100,11 +100,11 @@ attributes:
example: 10
exclude_test: true
test_prerequisites:
- - path: Cisco-IOS-XE-native:native/router/Cisco-IOS-XE-bgp:bgp=65000
+ - path: /Cisco-IOS-XE-native:native/router/Cisco-IOS-XE-bgp:bgp[id=65000]
attributes:
- name: id
value: 65000
- - path: Cisco-IOS-XE-native:native/interface/Loopback=100
+ - path: /Cisco-IOS-XE-native:native/interface/Loopback[name=100]
attributes:
- name: name
value: 100
diff --git a/gen/definitions/cdp.yaml b/gen/definitions/cdp.yaml
index 52221891..412674d0 100644
--- a/gen/definitions/cdp.yaml
+++ b/gen/definitions/cdp.yaml
@@ -1,6 +1,6 @@
---
name: CDP
-path: Cisco-IOS-XE-native:native/cdp
+path: /Cisco-IOS-XE-native:native/cdp
no_delete_attributes: true
doc_category: System
attributes:
diff --git a/gen/definitions/class_map.yaml b/gen/definitions/class_map.yaml
index 81895794..a0705b0f 100644
--- a/gen/definitions/class_map.yaml
+++ b/gen/definitions/class_map.yaml
@@ -1,6 +1,6 @@
---
name: Class Map
-path: Cisco-IOS-XE-native:native/policy/Cisco-IOS-XE-policy:class-map=%v
+path: /Cisco-IOS-XE-native:native/policy/Cisco-IOS-XE-policy:class-map[name=%v]
no_delete_attributes: true
doc_category: QoS
attributes:
diff --git a/gen/definitions/clock.yaml b/gen/definitions/clock.yaml
index dd422479..89c90c65 100644
--- a/gen/definitions/clock.yaml
+++ b/gen/definitions/clock.yaml
@@ -1,6 +1,6 @@
---
name: Clock
-path: Cisco-IOS-XE-native:native/clock
+path: /Cisco-IOS-XE-native:native/clock
doc_category: System
attributes:
- yang_name: calendar-valid
diff --git a/gen/definitions/community_list_expanded.yaml b/gen/definitions/community_list_expanded.yaml
index 2b83de8d..faa0bfaa 100644
--- a/gen/definitions/community_list_expanded.yaml
+++ b/gen/definitions/community_list_expanded.yaml
@@ -1,6 +1,6 @@
---
name: Community List Expanded
-path: Cisco-IOS-XE-native:native/ip/Cisco-IOS-XE-bgp:community-list/expanded=%v
+path: /Cisco-IOS-XE-native:native/ip/Cisco-IOS-XE-bgp:community-list/expanded[name=%v]
no_delete_attributes: true
skip_minimum_test: true
doc_category: BGP
diff --git a/gen/definitions/community_list_standard.yaml b/gen/definitions/community_list_standard.yaml
index 24783962..2ee35574 100644
--- a/gen/definitions/community_list_standard.yaml
+++ b/gen/definitions/community_list_standard.yaml
@@ -1,6 +1,6 @@
---
name: Community List Standard
-path: Cisco-IOS-XE-native:native/ip/Cisco-IOS-XE-bgp:community-list/standard=%v
+path: /Cisco-IOS-XE-native:native/ip/Cisco-IOS-XE-bgp:community-list/standard[name=%v]
no_delete_attributes: true
skip_minimum_test: true
doc_category: BGP
diff --git a/gen/definitions/crypto_ikev2.yaml b/gen/definitions/crypto_ikev2.yaml
index 845c819c..f157141c 100644
--- a/gen/definitions/crypto_ikev2.yaml
+++ b/gen/definitions/crypto_ikev2.yaml
@@ -1,6 +1,6 @@
---
name: Crypto IKEv2
-path: Cisco-IOS-XE-native:native/crypto/Cisco-IOS-XE-crypto:ikev2
+path: /Cisco-IOS-XE-native:native/crypto/Cisco-IOS-XE-crypto:ikev2
doc_category: Crypto
attributes:
- yang_name: nat/keepalive
diff --git a/gen/definitions/crypto_ikev2_keyring.yaml b/gen/definitions/crypto_ikev2_keyring.yaml
index c8d11a00..081e624e 100644
--- a/gen/definitions/crypto_ikev2_keyring.yaml
+++ b/gen/definitions/crypto_ikev2_keyring.yaml
@@ -1,6 +1,6 @@
---
name: Crypto IKEv2 Keyring
-path: Cisco-IOS-XE-native:native/crypto/Cisco-IOS-XE-crypto:ikev2/keyring=%v
+path: /Cisco-IOS-XE-native:native/crypto/Cisco-IOS-XE-crypto:ikev2/keyring[name=%v]
no_delete_attributes: true
doc_category: Crypto
attributes:
diff --git a/gen/definitions/crypto_ikev2_policy.yaml b/gen/definitions/crypto_ikev2_policy.yaml
index 14873d68..ea90455e 100644
--- a/gen/definitions/crypto_ikev2_policy.yaml
+++ b/gen/definitions/crypto_ikev2_policy.yaml
@@ -1,6 +1,6 @@
---
name: Crypto IKEv2 Policy
-path: Cisco-IOS-XE-native:native/crypto/Cisco-IOS-XE-crypto:ikev2/policy=%v
+path: /Cisco-IOS-XE-native:native/crypto/Cisco-IOS-XE-crypto:ikev2/policy[name=%v]
no_delete_attributes: true
doc_category: Crypto
attributes:
@@ -27,7 +27,7 @@ attributes:
example: proposal123
test_prerequisites:
- - path: Cisco-IOS-XE-native:native/crypto/Cisco-IOS-XE-crypto:ikev2/proposal=proposal123
+ - path: /Cisco-IOS-XE-native:native/crypto/Cisco-IOS-XE-crypto:ikev2/proposal[name=proposal123]
attributes:
- name: name
value: proposal123
diff --git a/gen/definitions/crypto_ikev2_profile.yaml b/gen/definitions/crypto_ikev2_profile.yaml
index 1d404347..b5086a7f 100644
--- a/gen/definitions/crypto_ikev2_profile.yaml
+++ b/gen/definitions/crypto_ikev2_profile.yaml
@@ -1,6 +1,6 @@
---
name: Crypto IKEv2 Profile
-path: Cisco-IOS-XE-native:native/crypto/Cisco-IOS-XE-crypto:ikev2/profile=%v
+path: /Cisco-IOS-XE-native:native/crypto/Cisco-IOS-XE-crypto:ikev2/profile[name=%v]
doc_category: Crypto
attributes:
- yang_name: name
@@ -68,11 +68,11 @@ attributes:
example: false
test_prerequisites:
- - path: Cisco-IOS-XE-native:native/crypto/Cisco-IOS-XE-crypto:ikev2/keyring=test
+ - path: /Cisco-IOS-XE-native:native/crypto/Cisco-IOS-XE-crypto:ikev2/keyring[name=test]
attributes:
- name: name
value: test
- - path: Cisco-IOS-XE-native:native/vrf/definition=VRF1
+ - path: /Cisco-IOS-XE-native:native/vrf/definition[name=VRF1]
no_delete: true
attributes:
- name: name
diff --git a/gen/definitions/crypto_ikev2_proposal.yaml b/gen/definitions/crypto_ikev2_proposal.yaml
index 1105195a..075c5e10 100644
--- a/gen/definitions/crypto_ikev2_proposal.yaml
+++ b/gen/definitions/crypto_ikev2_proposal.yaml
@@ -1,6 +1,6 @@
---
name: Crypto IKEv2 Proposal
-path: Cisco-IOS-XE-native:native/crypto/Cisco-IOS-XE-crypto:ikev2/proposal=%v
+path: /Cisco-IOS-XE-native:native/crypto/Cisco-IOS-XE-crypto:ikev2/proposal[name=%v]
no_delete_attributes: true
doc_category: Crypto
attributes:
diff --git a/gen/definitions/crypto_ipsec_profile.yaml b/gen/definitions/crypto_ipsec_profile.yaml
index 0937a1ca..647b89e8 100644
--- a/gen/definitions/crypto_ipsec_profile.yaml
+++ b/gen/definitions/crypto_ipsec_profile.yaml
@@ -1,6 +1,6 @@
---
name: Crypto IPSec Profile
-path: Cisco-IOS-XE-native:native/crypto/Cisco-IOS-XE-crypto:ipsec/profile=%v
+path: /Cisco-IOS-XE-native:native/crypto/Cisco-IOS-XE-crypto:ipsec/profile[name=%v]
no_delete_attributes: true
doc_category: Crypto
attributes:
@@ -17,7 +17,7 @@ attributes:
exclude_test: true
test_prerequisites:
- - path: Cisco-IOS-XE-native:native/crypto/Cisco-IOS-XE-crypto:ipsec/transform-set=TS1
+ - path: /Cisco-IOS-XE-native:native/crypto/Cisco-IOS-XE-crypto:ipsec/transform-set[tag=TS1]
attributes:
- name: tag
value: TS1
@@ -25,7 +25,7 @@ test_prerequisites:
value: esp-aes
- name: key-bit
value: 192
- - path: Cisco-IOS-XE-native:native/crypto/Cisco-IOS-XE-crypto:ikev2/profile=vpn300
+ - path: /Cisco-IOS-XE-native:native/crypto/Cisco-IOS-XE-crypto:ikev2/profile[name=vpn300]
attributes:
- name: name
value: vpn300
diff --git a/gen/definitions/crypto_ipsec_transform_set.yaml b/gen/definitions/crypto_ipsec_transform_set.yaml
index 205d2bf8..fbc902ac 100644
--- a/gen/definitions/crypto_ipsec_transform_set.yaml
+++ b/gen/definitions/crypto_ipsec_transform_set.yaml
@@ -1,6 +1,6 @@
---
name: Crypto IPSec Transform Set
-path: Cisco-IOS-XE-native:native/crypto/Cisco-IOS-XE-crypto:ipsec/transform-set=%s
+path: /Cisco-IOS-XE-native:native/crypto/Cisco-IOS-XE-crypto:ipsec/transform-set[tag=%s]
no_delete_attributes: true
doc_category: Crypto
attributes:
diff --git a/gen/definitions/crypto_pki.yaml b/gen/definitions/crypto_pki.yaml
index 6bfa4882..519600be 100644
--- a/gen/definitions/crypto_pki.yaml
+++ b/gen/definitions/crypto_pki.yaml
@@ -1,6 +1,6 @@
---
name: Crypto PKI
-path: Cisco-IOS-XE-native:native/crypto/Cisco-IOS-XE-crypto:pki
+path: /Cisco-IOS-XE-native:native/crypto/Cisco-IOS-XE-crypto:pki
doc_category: Crypto
test_tags: [CRYPTO_PKI]
attributes:
diff --git a/gen/definitions/cts.yaml b/gen/definitions/cts.yaml
index 95b7edc1..c2413646 100644
--- a/gen/definitions/cts.yaml
+++ b/gen/definitions/cts.yaml
@@ -1,6 +1,6 @@
---
name: CTS
-path: Cisco-IOS-XE-native:native/cts
+path: /Cisco-IOS-XE-native:native/cts
doc_category: CTS
test_tags: [C9000V]
attributes:
@@ -94,7 +94,7 @@ attributes:
exclude_test: true
test_prerequisites:
- - path: Cisco-IOS-XE-native:native/vrf/definition=VRF1
+ - path: /Cisco-IOS-XE-native:native/vrf/definition[name=VRF1]
no_delete: true
attributes:
- name: name
diff --git a/gen/definitions/device_sensor.yaml b/gen/definitions/device_sensor.yaml
index 99874b26..73d85dd5 100644
--- a/gen/definitions/device_sensor.yaml
+++ b/gen/definitions/device_sensor.yaml
@@ -1,6 +1,6 @@
---
name: Device Sensor
-path: Cisco-IOS-XE-native:native/Cisco-IOS-XE-device-sensor:device-sensor
+path: /Cisco-IOS-XE-native:native/Cisco-IOS-XE-device-sensor:device-sensor
test_tags: [C9000V]
doc_category: System
attributes:
diff --git a/gen/definitions/dhcp.yaml b/gen/definitions/dhcp.yaml
index b999a4af..7a4a7c99 100644
--- a/gen/definitions/dhcp.yaml
+++ b/gen/definitions/dhcp.yaml
@@ -1,6 +1,6 @@
---
name: DHCP
-path: Cisco-IOS-XE-native:native/ip/dhcp
+path: /Cisco-IOS-XE-native:native/ip/dhcp
doc_category: System
attributes:
- yang_name: Cisco-IOS-XE-dhcp:compatibility/suboption/link-selection
diff --git a/gen/definitions/dot1x.yaml b/gen/definitions/dot1x.yaml
index 83048cbd..9c2f2b32 100644
--- a/gen/definitions/dot1x.yaml
+++ b/gen/definitions/dot1x.yaml
@@ -1,6 +1,6 @@
---
name: Dot1x
-path: Cisco-IOS-XE-native:native/dot1x
+path: /Cisco-IOS-XE-native:native/dot1x
doc_category: System
attributes:
- yang_name: Cisco-IOS-XE-dot1x:auth-fail/eapol
diff --git a/gen/definitions/eem.yaml b/gen/definitions/eem.yaml
index 81ba265d..e2fcdaa0 100644
--- a/gen/definitions/eem.yaml
+++ b/gen/definitions/eem.yaml
@@ -1,6 +1,6 @@
---
name: EEM
-path: Cisco-IOS-XE-native:native/event/Cisco-IOS-XE-eem:manager
+path: /Cisco-IOS-XE-native:native/event/Cisco-IOS-XE-eem:manager
doc_category: System
no_delete: true
test_tags: ["IOSXE1715"]
diff --git a/gen/definitions/errdisable.yaml b/gen/definitions/errdisable.yaml
index 582d4746..9ee87637 100644
--- a/gen/definitions/errdisable.yaml
+++ b/gen/definitions/errdisable.yaml
@@ -1,6 +1,6 @@
---
name: Errdisable
-path: Cisco-IOS-XE-native:native/errdisable
+path: /Cisco-IOS-XE-native:native/errdisable
doc_category: System
attributes:
- yang_name: detect/cause/all
diff --git a/gen/definitions/evpn.yaml b/gen/definitions/evpn.yaml
index b71105d3..860f9917 100644
--- a/gen/definitions/evpn.yaml
+++ b/gen/definitions/evpn.yaml
@@ -1,6 +1,6 @@
---
name: EVPN
-path: Cisco-IOS-XE-native:native/l2vpn/Cisco-IOS-XE-l2vpn:evpn_cont/evpn
+path: /Cisco-IOS-XE-native:native/l2vpn/Cisco-IOS-XE-l2vpn:evpn_cont/evpn
test_tags: [C9000V]
doc_category: EVPN
attributes:
diff --git a/gen/definitions/evpn_instance.yaml b/gen/definitions/evpn_instance.yaml
index cfc5ed2a..65ffb2c8 100644
--- a/gen/definitions/evpn_instance.yaml
+++ b/gen/definitions/evpn_instance.yaml
@@ -1,6 +1,6 @@
---
name: EVPN Instance
-path: Cisco-IOS-XE-native:native/l2vpn/Cisco-IOS-XE-l2vpn:evpn_cont/evpn-instance/evpn/instance/instance=%v
+path: /Cisco-IOS-XE-native:native/l2vpn/Cisco-IOS-XE-l2vpn:evpn_cont/evpn-instance/evpn/instance/instance[evpn-instance-num=%v]
test_tags: [C9000V]
no_delete_attributes: true
skip_minimum_test: true
diff --git a/gen/definitions/flow_exporter.yaml b/gen/definitions/flow_exporter.yaml
index 9aff790e..f4b286a9 100644
--- a/gen/definitions/flow_exporter.yaml
+++ b/gen/definitions/flow_exporter.yaml
@@ -1,6 +1,6 @@
---
name: Flow Exporter
-path: Cisco-IOS-XE-native:native/flow/Cisco-IOS-XE-flow:exporter=%v
+path: /Cisco-IOS-XE-native:native/flow/Cisco-IOS-XE-flow:exporter[name=%v]
doc_category: Flow
attributes:
- yang_name: name
diff --git a/gen/definitions/flow_monitor.yaml b/gen/definitions/flow_monitor.yaml
index 144172da..3e3844b8 100644
--- a/gen/definitions/flow_monitor.yaml
+++ b/gen/definitions/flow_monitor.yaml
@@ -1,6 +1,6 @@
---
name: Flow Monitor
-path: Cisco-IOS-XE-native:native/flow/Cisco-IOS-XE-flow:monitor=%v
+path: /Cisco-IOS-XE-native:native/flow/Cisco-IOS-XE-flow:monitor[name=%v]
doc_category: Flow
attributes:
- yang_name: name
@@ -23,11 +23,11 @@ attributes:
tf_name: record
example: FNF1
test_prerequisites:
- - path: Cisco-IOS-XE-native:native/flow/Cisco-IOS-XE-flow:exporter=EXPORTER1
+ - path: /Cisco-IOS-XE-native:native/flow/Cisco-IOS-XE-flow:exporter[name=EXPORTER1]
attributes:
- name: name
value: EXPORTER1
- - path: Cisco-IOS-XE-native:native/flow/Cisco-IOS-XE-flow:record=FNF1
+ - path: /Cisco-IOS-XE-native:native/flow/Cisco-IOS-XE-flow:record[name=FNF1]
attributes:
- name: name
value: FNF1
\ No newline at end of file
diff --git a/gen/definitions/flow_record.yaml b/gen/definitions/flow_record.yaml
index 8a6f581b..9534a7ae 100644
--- a/gen/definitions/flow_record.yaml
+++ b/gen/definitions/flow_record.yaml
@@ -1,6 +1,6 @@
---
name: Flow Record
-path: Cisco-IOS-XE-native:native/flow/Cisco-IOS-XE-flow:record=%v
+path: /Cisco-IOS-XE-native:native/flow/Cisco-IOS-XE-flow:record[name=%v]
doc_category: Flow
attributes:
- yang_name: name
diff --git a/gen/definitions/interface_ethernet.yaml b/gen/definitions/interface_ethernet.yaml
index 5dcc6810..53d8bdaf 100644
--- a/gen/definitions/interface_ethernet.yaml
+++ b/gen/definitions/interface_ethernet.yaml
@@ -1,7 +1,7 @@
---
name: Interface Ethernet
-path: Cisco-IOS-XE-native:native/interface/%s=%v
-augment_path: Cisco-IOS-XE-native:native/interface/GigabitEthernet=%v
+path: /Cisco-IOS-XE-native:native/interface/%s[name=%v]
+augment_path: /Cisco-IOS-XE-native:native/interface/GigabitEthernet[name=%v]
wait: true
test_tags: [C8000V]
no_delete: true
@@ -527,18 +527,18 @@ attributes:
test_prerequisites:
- - path: Cisco-IOS-XE-native:native/vrf/definition=VRF1
+ - path: /Cisco-IOS-XE-native:native/vrf/definition[name=VRF1]
no_delete: true
attributes:
- name: name
value: VRF1
- name: address-family/ipv4
value: ""
- - path: Cisco-IOS-XE-native:native/policy/Cisco-IOS-XE-policy:policy-map=POLICY1
+ - path: /Cisco-IOS-XE-native:native/policy/Cisco-IOS-XE-policy:policy-map[name=POLICY1]
attributes:
- name: name
value: POLICY1
- - path: Cisco-IOS-XE-native:native/flow/Cisco-IOS-XE-flow:record=REC1
+ - path: /Cisco-IOS-XE-native:native/flow/Cisco-IOS-XE-flow:record[name=REC1]
attributes:
- name: name
value: REC1
@@ -546,14 +546,14 @@ test_prerequisites:
value: ""
- name: collect/interface/output
value: ""
- - path: Cisco-IOS-XE-native:native/flow/Cisco-IOS-XE-flow:monitor=MON1
+ - path: /Cisco-IOS-XE-native:native/flow/Cisco-IOS-XE-flow:monitor[name=MON1]
attributes:
- name: name
value: MON1
- name: record/type
value: REC1
dependencies: [2]
- - path: Cisco-IOS-XE-native:native/template/Cisco-IOS-XE-template:template_details=TEMP1
+ - path: /Cisco-IOS-XE-native:native/template/Cisco-IOS-XE-template:template_details[template_name=TEMP1]
attributes:
- name: template_name
value: TEMP1
diff --git a/gen/definitions/interface_loopback.yaml b/gen/definitions/interface_loopback.yaml
index 5ccdad45..0a749958 100644
--- a/gen/definitions/interface_loopback.yaml
+++ b/gen/definitions/interface_loopback.yaml
@@ -1,6 +1,6 @@
---
name: Interface Loopback
-path: Cisco-IOS-XE-native:native/interface/Loopback=%v
+path: /Cisco-IOS-XE-native:native/interface/Loopback[name=%v]
doc_category: Interface
attributes:
- yang_name: name
@@ -81,7 +81,7 @@ attributes:
example: 2147
test_prerequisites:
- - path: Cisco-IOS-XE-native:native/vrf/definition=VRF1
+ - path: /Cisco-IOS-XE-native:native/vrf/definition[name=VRF1]
no_delete: true
attributes:
- name: name
diff --git a/gen/definitions/interface_mpls.yaml b/gen/definitions/interface_mpls.yaml
index 7144bc52..c508f114 100644
--- a/gen/definitions/interface_mpls.yaml
+++ b/gen/definitions/interface_mpls.yaml
@@ -1,7 +1,7 @@
---
name: Interface MPLS
-path: Cisco-IOS-XE-native:native/interface/%s=%v/mpls
-augment_path: Cisco-IOS-XE-native:native/interface/GigabitEthernet=%v/mpls
+path: /Cisco-IOS-XE-native:native/interface/%s[name=%v]/mpls
+augment_path: /Cisco-IOS-XE-native:native/interface/GigabitEthernet[name=%v]/mpls
doc_category: MPLS
attributes:
- yang_name: type
@@ -33,7 +33,7 @@ attributes:
example: 1200
test_prerequisites:
- - path: Cisco-IOS-XE-native:native/interface/Loopback=1
+ - path: /Cisco-IOS-XE-native:native/interface/Loopback[name=1]
attributes:
- name: name
value: 1
diff --git a/gen/definitions/interface_nve.yaml b/gen/definitions/interface_nve.yaml
index 65b197e8..da555239 100644
--- a/gen/definitions/interface_nve.yaml
+++ b/gen/definitions/interface_nve.yaml
@@ -1,6 +1,6 @@
---
name: Interface NVE
-path: Cisco-IOS-XE-native:native/interface/nve=%v
+path: /Cisco-IOS-XE-native:native/interface/nve[name=%v]
test_tags: [C9000V]
doc_category: Interface
attributes:
diff --git a/gen/definitions/interface_ospf.yaml b/gen/definitions/interface_ospf.yaml
index 6c33b57e..5155a964 100644
--- a/gen/definitions/interface_ospf.yaml
+++ b/gen/definitions/interface_ospf.yaml
@@ -1,7 +1,7 @@
---
name: Interface OSPF
-path: Cisco-IOS-XE-native:native/interface/%s=%v/ip/Cisco-IOS-XE-ospf:router-ospf/ospf
-augment_path: Cisco-IOS-XE-native:native/interface/GigabitEthernet=%v/ip/Cisco-IOS-XE-ospf:router-ospf/ospf
+path: /Cisco-IOS-XE-native:native/interface/%s[name=%v]/ip/Cisco-IOS-XE-ospf:router-ospf/ospf
+augment_path: /Cisco-IOS-XE-native:native/interface/GigabitEthernet[name=%v]/ip/Cisco-IOS-XE-ospf:router-ospf/ospf
doc_category: OSPF
attributes:
- yang_name: type
@@ -88,11 +88,11 @@ attributes:
no_delete: true
test_prerequisites:
- - path: Cisco-IOS-XE-native:native/router/Cisco-IOS-XE-ospf:router-ospf/ospf/process-id=1
+ - path: /Cisco-IOS-XE-native:native/router/Cisco-IOS-XE-ospf:router-ospf/ospf/process-id[id=1]
attributes:
- name: id
value: 1
- - path: Cisco-IOS-XE-native:native/interface/Loopback=1
+ - path: /Cisco-IOS-XE-native:native/interface/Loopback[name=1]
attributes:
- name: name
value: 1
diff --git a/gen/definitions/interface_ospfv3.yaml b/gen/definitions/interface_ospfv3.yaml
index 3edf3661..06f951b9 100644
--- a/gen/definitions/interface_ospfv3.yaml
+++ b/gen/definitions/interface_ospfv3.yaml
@@ -1,7 +1,7 @@
---
name: Interface OSPFv3
-path: Cisco-IOS-XE-native:native/interface/%s=%v/Cisco-IOS-XE-ospfv3:ospfv3
-augment_path: Cisco-IOS-XE-native:native/interface/GigabitEthernet=%v/Cisco-IOS-XE-ospfv3:ospfv3
+path: /Cisco-IOS-XE-native:native/interface/%s[name=%v]/Cisco-IOS-XE-ospfv3:ospfv3
+augment_path: /Cisco-IOS-XE-native:native/interface/GigabitEthernet[name=%v]/Cisco-IOS-XE-ospfv3:ospfv3
doc_category: OSPF
attributes:
- yang_name: type
@@ -49,7 +49,7 @@ attributes:
example: 1000
test_prerequisites:
- - path: Cisco-IOS-XE-native:native/interface/Loopback=1
+ - path: /Cisco-IOS-XE-native:native/interface/Loopback[name=1]
attributes:
- name: name
value: 1
diff --git a/gen/definitions/interface_pim.yaml b/gen/definitions/interface_pim.yaml
index f7ed6829..f010b576 100644
--- a/gen/definitions/interface_pim.yaml
+++ b/gen/definitions/interface_pim.yaml
@@ -1,7 +1,7 @@
---
name: Interface PIM
-path: Cisco-IOS-XE-native:native/interface/%s=%v/ip/pim
-augment_path: Cisco-IOS-XE-native:native/interface/GigabitEthernet=%v/ip/pim
+path: /Cisco-IOS-XE-native:native/interface/%s[name=%v]/ip/pim
+augment_path: /Cisco-IOS-XE-native:native/interface/GigabitEthernet[name=%v]/ip/pim
no_delete: true
doc_category: Multicast
attributes:
@@ -54,7 +54,7 @@ attributes:
example: 10
test_prerequisites:
- - path: Cisco-IOS-XE-native:native/interface/Loopback=100
+ - path: /Cisco-IOS-XE-native:native/interface/Loopback[name=100]
attributes:
- name: name
value: 100
diff --git a/gen/definitions/interface_port_channel.yaml b/gen/definitions/interface_port_channel.yaml
index e4dbbea4..4f042423 100644
--- a/gen/definitions/interface_port_channel.yaml
+++ b/gen/definitions/interface_port_channel.yaml
@@ -1,6 +1,6 @@
---
name: Interface Port Channel
-path: Cisco-IOS-XE-native:native/interface/Port-channel=%v
+path: /Cisco-IOS-XE-native:native/interface/Port-channel[name=%v]
doc_category: Interface
attributes:
- yang_name: name
@@ -208,7 +208,7 @@ attributes:
exclude_test: true
test_prerequisites:
- - path: Cisco-IOS-XE-native:native/vrf/definition=VRF1
+ - path: /Cisco-IOS-XE-native:native/vrf/definition[name=VRF1]
no_delete: true
attributes:
- name: name
diff --git a/gen/definitions/interface_port_channel_subinterface.yaml b/gen/definitions/interface_port_channel_subinterface.yaml
index 8dfca639..424ad137 100644
--- a/gen/definitions/interface_port_channel_subinterface.yaml
+++ b/gen/definitions/interface_port_channel_subinterface.yaml
@@ -1,6 +1,6 @@
---
name: Interface Port Channel Subinterface
-path: Cisco-IOS-XE-native:native/interface/Port-channel-subinterface/Port-channel=%v
+path: /Cisco-IOS-XE-native:native/interface/Port-channel-subinterface/Port-channel[name=%v]
test_tags: [C8000V]
doc_category: Interface
attributes:
@@ -173,18 +173,18 @@ attributes:
test_tags: [C9000V]
test_prerequisites:
- - path: Cisco-IOS-XE-native:native/vrf/definition=VRF1
+ - path: /Cisco-IOS-XE-native:native/vrf/definition[name=VRF1]
no_delete: true
attributes:
- name: name
value: VRF1
- name: address-family/ipv4
value: ""
- - path: Cisco-IOS-XE-native:native/interface/Port-channel=10
+ - path: /Cisco-IOS-XE-native:native/interface/Port-channel[name=10]
attributes:
- name: name
value: 10
- - path: Cisco-IOS-XE-native:native/interface/Port-channel-subinterface/Port-channel=10.666
+ - path: /Cisco-IOS-XE-native:native/interface/Port-channel-subinterface/Port-channel[name=10.666]
attributes:
- name: name
value: "10.666"
diff --git a/gen/definitions/interface_switchport.yaml b/gen/definitions/interface_switchport.yaml
index 2e857d3e..406d59eb 100644
--- a/gen/definitions/interface_switchport.yaml
+++ b/gen/definitions/interface_switchport.yaml
@@ -1,7 +1,7 @@
---
name: Interface Switchport
-path: Cisco-IOS-XE-native:native/interface/%s=%v/switchport-config/switchport
-augment_path: Cisco-IOS-XE-native:native/interface/GigabitEthernet=%v/switchport-config/switchport
+path: /Cisco-IOS-XE-native:native/interface/%s[name=%v]/switchport-config/switchport
+augment_path: /Cisco-IOS-XE-native:native/interface/GigabitEthernet[name=%v]/switchport-config/switchport
test_tags: [C9000V]
doc_category: Switching
attributes:
diff --git a/gen/definitions/interface_tunnel.yaml b/gen/definitions/interface_tunnel.yaml
index e6ef2d9b..03bcb797 100644
--- a/gen/definitions/interface_tunnel.yaml
+++ b/gen/definitions/interface_tunnel.yaml
@@ -1,6 +1,6 @@
---
name: Interface Tunnel
-path: Cisco-IOS-XE-native:native/interface/Tunnel=%s
+path: /Cisco-IOS-XE-native:native/interface/Tunnel[name=%s]
doc_category: Interface
no_delete:
attributes:
@@ -161,7 +161,7 @@ attributes:
example: VRF1
test_prerequisites:
- - path: Cisco-IOS-XE-native:native/vrf/definition=VRF1
+ - path: /Cisco-IOS-XE-native:native/vrf/definition[name=VRF1]
no_delete: true
attributes:
- name: name
diff --git a/gen/definitions/interface_vlan.yaml b/gen/definitions/interface_vlan.yaml
index 8ff716f6..61ea8843 100644
--- a/gen/definitions/interface_vlan.yaml
+++ b/gen/definitions/interface_vlan.yaml
@@ -1,6 +1,6 @@
---
name: Interface VLAN
-path: Cisco-IOS-XE-native:native/interface/Vlan=%v
+path: /Cisco-IOS-XE-native:native/interface/Vlan[name=%v]
test_tags: [C9000V]
doc_category: Interface
attributes:
@@ -135,7 +135,7 @@ attributes:
example: 0000.dead.beef
test_prerequisites:
- - path: Cisco-IOS-XE-native:native/vrf/definition=VRF1
+ - path: /Cisco-IOS-XE-native:native/vrf/definition[name=VRF1]
no_delete: true
attributes:
- name: name
diff --git a/gen/definitions/license.yaml b/gen/definitions/license.yaml
index 949e0dc0..e9fd943b 100644
--- a/gen/definitions/license.yaml
+++ b/gen/definitions/license.yaml
@@ -1,6 +1,6 @@
---
name: License
-path: Cisco-IOS-XE-native:native/license
+path: /Cisco-IOS-XE-native:native/license
doc_category: System
test_tags: [LICENSE]
attributes:
diff --git a/gen/definitions/line.yaml b/gen/definitions/line.yaml
index 253d3ecd..0629f82c 100644
--- a/gen/definitions/line.yaml
+++ b/gen/definitions/line.yaml
@@ -1,6 +1,6 @@
---
name: Line
-path: Cisco-IOS-XE-native:native/line
+path: /Cisco-IOS-XE-native:native/line
doc_category: System
test_tags: [LINE]
attributes:
diff --git a/gen/definitions/lldp.yaml b/gen/definitions/lldp.yaml
index 2c1ac0a1..04af01a5 100644
--- a/gen/definitions/lldp.yaml
+++ b/gen/definitions/lldp.yaml
@@ -1,6 +1,6 @@
---
name: LLDP
-path: Cisco-IOS-XE-native:native/Cisco-IOS-XE-lldp:lldp
+path: /Cisco-IOS-XE-native:native/Cisco-IOS-XE-lldp:lldp
doc_category: System
attributes:
- yang_name: run
diff --git a/gen/definitions/logging.yaml b/gen/definitions/logging.yaml
index b357fd83..42824fd5 100644
--- a/gen/definitions/logging.yaml
+++ b/gen/definitions/logging.yaml
@@ -1,6 +1,6 @@
---
name: Logging
-path: Cisco-IOS-XE-native:native/logging
+path: /Cisco-IOS-XE-native:native/logging
no_delete: true
doc_category: Management
attributes:
@@ -236,7 +236,7 @@ attributes:
exclude_test: true
test_prerequisites:
- - path: Cisco-IOS-XE-native:native/vrf/definition=VRF1
+ - path: /Cisco-IOS-XE-native:native/vrf/definition[name=VRF1]
no_delete: true
attributes:
- name: name
@@ -245,7 +245,7 @@ test_prerequisites:
value: ""
- name: address-family/ipv6
value: ""
- - path: Cisco-IOS-XE-native:native/interface/Loopback=100
+ - path: /Cisco-IOS-XE-native:native/interface/Loopback[name=100]
attributes:
- name: name
value: 100
diff --git a/gen/definitions/mdt_subscription.yaml b/gen/definitions/mdt_subscription.yaml
index c9ecf36d..d66c2c68 100644
--- a/gen/definitions/mdt_subscription.yaml
+++ b/gen/definitions/mdt_subscription.yaml
@@ -1,6 +1,6 @@
---
name: MDT Subscription
-path: Cisco-IOS-XE-mdt-cfg:mdt-config-data/mdt-subscription=%s
+path: /Cisco-IOS-XE-mdt-cfg:mdt-config-data/mdt-subscription[subscription-id=%s]
no_delete_attributes: true
doc_category: MDT
attributes:
diff --git a/gen/definitions/msdp.yaml b/gen/definitions/msdp.yaml
index d8e0c6e5..33a5337c 100644
--- a/gen/definitions/msdp.yaml
+++ b/gen/definitions/msdp.yaml
@@ -1,6 +1,6 @@
---
name: MSDP
-path: Cisco-IOS-XE-native:native/ip/Cisco-IOS-XE-multicast:msdp
+path: /Cisco-IOS-XE-native:native/ip/Cisco-IOS-XE-multicast:msdp
doc_category: Multicast
attributes:
- yang_name: originator-id
@@ -70,21 +70,21 @@ attributes:
sensitive: true
example: Cisco123
test_prerequisites:
- - path: Cisco-IOS-XE-native:native/vrf/definition=VRF1
+ - path: /Cisco-IOS-XE-native:native/vrf/definition[name=VRF1]
no_delete: true
attributes:
- name: name
value: VRF1
- name: address-family/ipv4
value: ""
- - path: Cisco-IOS-XE-native:native/interface/Loopback=200
+ - path: /Cisco-IOS-XE-native:native/interface/Loopback[name=200]
attributes:
- name: name
value: 200
- name: vrf/forwarding
value: VRF1
dependencies: [0]
- - path: Cisco-IOS-XE-native:native/interface/Loopback=100
+ - path: /Cisco-IOS-XE-native:native/interface/Loopback[name=100]
attributes:
- name: name
value: 100
diff --git a/gen/definitions/nat.yaml b/gen/definitions/nat.yaml
index a34d14e5..bab63b02 100644
--- a/gen/definitions/nat.yaml
+++ b/gen/definitions/nat.yaml
@@ -1,6 +1,6 @@
---
name: NAT
-path: Cisco-IOS-XE-native:native/ip/Cisco-IOS-XE-nat:nat
+path: /Cisco-IOS-XE-native:native/ip/Cisco-IOS-XE-nat:nat
doc_category: System
test_tags: [C8000V]
attributes:
diff --git a/gen/definitions/ntp.yaml b/gen/definitions/ntp.yaml
index 32fc33e1..91441348 100644
--- a/gen/definitions/ntp.yaml
+++ b/gen/definitions/ntp.yaml
@@ -1,6 +1,6 @@
---
name: NTP
-path: Cisco-IOS-XE-native:native/ntp
+path: /Cisco-IOS-XE-native:native/ntp
doc_category: System
attributes:
- yang_name: Cisco-IOS-XE-ntp:authenticate
@@ -214,18 +214,18 @@ attributes:
example: 1
test_prerequisites:
- - path: Cisco-IOS-XE-native:native/vrf/definition=VRF1
+ - path: /Cisco-IOS-XE-native:native/vrf/definition[name=VRF1]
no_delete: true
attributes:
- name: name
value: VRF1
- name: address-family/ipv4
value: ""
- - path: Cisco-IOS-XE-native:native/ip/access-list/Cisco-IOS-XE-acl:standard=SACL1
+ - path: /Cisco-IOS-XE-native:native/ip/access-list/Cisco-IOS-XE-acl:standard[name=SACL1]
attributes:
- name: name
value: SACL1
- - path: Cisco-IOS-XE-native:native/interface/Loopback=1
+ - path: /Cisco-IOS-XE-native:native/interface/Loopback[name=1]
attributes:
- name: name
value: 1
diff --git a/gen/definitions/ospf.yaml b/gen/definitions/ospf.yaml
index 19dac80b..9ba1c598 100644
--- a/gen/definitions/ospf.yaml
+++ b/gen/definitions/ospf.yaml
@@ -1,6 +1,6 @@
---
name: OSPF
-path: Cisco-IOS-XE-native:native/router/Cisco-IOS-XE-ospf:router-ospf/ospf/process-id=%v
+path: /Cisco-IOS-XE-native:native/router/Cisco-IOS-XE-ospf:router-ospf/ospf/process-id[id=%v]
doc_category: OSPF
attributes:
- yang_name: id
diff --git a/gen/definitions/ospf_vrf.yaml b/gen/definitions/ospf_vrf.yaml
index 4737dd05..16af6ca9 100644
--- a/gen/definitions/ospf_vrf.yaml
+++ b/gen/definitions/ospf_vrf.yaml
@@ -1,6 +1,6 @@
---
name: OSPF VRF
-path: Cisco-IOS-XE-native:native/router/Cisco-IOS-XE-ospf:router-ospf/ospf/process-id-vrf=%v,%s
+path: /Cisco-IOS-XE-native:native/router/Cisco-IOS-XE-ospf:router-ospf/ospf/process-id-vrf[id=%v][vrf=%s]
doc_category: OSPF
attributes:
- yang_name: id
@@ -268,7 +268,7 @@ attributes:
example: 1
test_prerequisites:
- - path: Cisco-IOS-XE-native:native/vrf/definition=VRF1
+ - path: /Cisco-IOS-XE-native:native/vrf/definition[name=VRF1]
no_delete: true
attributes:
- name: name
diff --git a/gen/definitions/pim.yaml b/gen/definitions/pim.yaml
index 7f539784..683c1566 100644
--- a/gen/definitions/pim.yaml
+++ b/gen/definitions/pim.yaml
@@ -1,6 +1,6 @@
---
name: PIM
-path: Cisco-IOS-XE-native:native/ip/pim
+path: /Cisco-IOS-XE-native:native/ip/pim
doc_category: Multicast
attributes:
- yang_name: Cisco-IOS-XE-multicast:autorp-container/autorp
@@ -142,14 +142,14 @@ attributes:
- yang_name: bidir
example: false
test_prerequisites:
- - path: Cisco-IOS-XE-native:native/vrf/definition=VRF1
+ - path: /Cisco-IOS-XE-native:native/vrf/definition[name=VRF1]
no_delete: true
attributes:
- name: name
value: VRF1
- name: address-family/ipv4
value: ""
- - path: Cisco-IOS-XE-native:native/interface/Loopback=200
+ - path: /Cisco-IOS-XE-native:native/interface/Loopback[name=200]
attributes:
- name: name
value: 200
@@ -160,7 +160,7 @@ test_prerequisites:
- name: ip/address/primary/mask
value: 255.255.255.255
dependencies: [0]
- - path: Cisco-IOS-XE-native:native/interface/Loopback=100
+ - path: /Cisco-IOS-XE-native:native/interface/Loopback[name=100]
attributes:
- name: name
value: 100
diff --git a/gen/definitions/platform.yaml b/gen/definitions/platform.yaml
index 0daeb5cd..5305e694 100644
--- a/gen/definitions/platform.yaml
+++ b/gen/definitions/platform.yaml
@@ -1,6 +1,6 @@
---
name: Platform
-path: Cisco-IOS-XE-native:native/platform
+path: /Cisco-IOS-XE-native:native/platform
doc_category: System
no_delete: true
attributes:
diff --git a/gen/definitions/policy_map.yaml b/gen/definitions/policy_map.yaml
index b6a79b87..ba378051 100644
--- a/gen/definitions/policy_map.yaml
+++ b/gen/definitions/policy_map.yaml
@@ -1,6 +1,6 @@
---
name: Policy Map
-path: Cisco-IOS-XE-native:native/policy/Cisco-IOS-XE-policy:policy-map=%v
+path: /Cisco-IOS-XE-native:native/policy/Cisco-IOS-XE-policy:policy-map[name=%v]
doc_category: QoS
no_delete_attributes: true
attributes:
@@ -131,7 +131,7 @@ attributes:
exclude_test: true
test_prerequisites:
- - path: Cisco-IOS-XE-native:native/policy/Cisco-IOS-XE-policy:class-map=CLASS1
+ - path: /Cisco-IOS-XE-native:native/policy/Cisco-IOS-XE-policy:class-map[name=CLASS1]
attributes:
- name: name
value: CLASS1
diff --git a/gen/definitions/policy_map_event.yaml b/gen/definitions/policy_map_event.yaml
index 9376233c..09d58b86 100644
--- a/gen/definitions/policy_map_event.yaml
+++ b/gen/definitions/policy_map_event.yaml
@@ -1,6 +1,6 @@
---
name: Policy Map Event
-path: Cisco-IOS-XE-native:native/policy/Cisco-IOS-XE-policy:policy-map=%s/event=%v
+path: /Cisco-IOS-XE-native:native/policy/Cisco-IOS-XE-policy:policy-map[name=%s]/event[name=%v]
doc_category: QoS
no_delete_attributes: true
attributes:
@@ -107,7 +107,7 @@ attributes:
example: name1
exclude_test: true
test_prerequisites:
- - path: Cisco-IOS-XE-native:native/policy/Cisco-IOS-XE-policy:policy-map=dot1x_policy
+ - path: /Cisco-IOS-XE-native:native/policy/Cisco-IOS-XE-policy:policy-map[name=dot1x_policy]
attributes:
- name: name
value: dot1x_policy
@@ -115,7 +115,7 @@ test_prerequisites:
value: control
- name: subscriber
value: ""
- - path: Cisco-IOS-XE-native:native/policy/Cisco-IOS-XE-policy:class-map=MY_CLASS
+ - path: /Cisco-IOS-XE-native:native/policy/Cisco-IOS-XE-policy:class-map[name=MY_CLASS]
attributes:
- name: name
value: MY_CLASS
diff --git a/gen/definitions/prefix_list.yaml b/gen/definitions/prefix_list.yaml
index 19d0f6af..6d4d82ce 100644
--- a/gen/definitions/prefix_list.yaml
+++ b/gen/definitions/prefix_list.yaml
@@ -1,6 +1,6 @@
---
name: Prefix List
-path: Cisco-IOS-XE-native:native/ip/prefix-lists
+path: /Cisco-IOS-XE-native:native/ip/prefix-lists
no_delete_attributes: true
doc_category: System
attributes:
diff --git a/gen/definitions/radius.yaml b/gen/definitions/radius.yaml
index dfae9988..afbbbe97 100644
--- a/gen/definitions/radius.yaml
+++ b/gen/definitions/radius.yaml
@@ -1,6 +1,6 @@
---
name: Radius
-path: Cisco-IOS-XE-native:native/radius/Cisco-IOS-XE-aaa:server=%v
+path: /Cisco-IOS-XE-native:native/radius/Cisco-IOS-XE-aaa:server[id=%v]
no_delete_attributes: true
doc_category: AAA
attributes:
diff --git a/gen/definitions/radius_server.yaml b/gen/definitions/radius_server.yaml
index 1d284f7f..45a94aee 100644
--- a/gen/definitions/radius_server.yaml
+++ b/gen/definitions/radius_server.yaml
@@ -1,6 +1,6 @@
---
name: Radius Server
-path: Cisco-IOS-XE-native:native/radius-server
+path: /Cisco-IOS-XE-native:native/radius-server
no_delete_attributes: true
doc_category: AAA
attributes:
diff --git a/gen/definitions/route_map.yaml b/gen/definitions/route_map.yaml
index 712b378c..e73416c0 100644
--- a/gen/definitions/route_map.yaml
+++ b/gen/definitions/route_map.yaml
@@ -1,6 +1,6 @@
---
name: Route Map
-path: Cisco-IOS-XE-native:native/route-map=%v
+path: /Cisco-IOS-XE-native:native/route-map[name=%v]
no_delete_attributes: true
doc_category: System
attributes:
@@ -355,7 +355,7 @@ attributes:
example: 10000
test_prerequisites:
- - path: Cisco-IOS-XE-native:native/interface/Loopback=1
+ - path: /Cisco-IOS-XE-native:native/interface/Loopback[name=1]
attributes:
- name: name
value: 1
diff --git a/gen/definitions/service.yaml b/gen/definitions/service.yaml
index d746f1cb..8344777a 100644
--- a/gen/definitions/service.yaml
+++ b/gen/definitions/service.yaml
@@ -1,6 +1,6 @@
---
name: Service
-path: Cisco-IOS-XE-native:native/service
+path: /Cisco-IOS-XE-native:native/service
doc_category: System
no_delete: true
attributes:
diff --git a/gen/definitions/service_template.yaml b/gen/definitions/service_template.yaml
index d00aa3a0..39ec4dfc 100644
--- a/gen/definitions/service_template.yaml
+++ b/gen/definitions/service_template.yaml
@@ -1,6 +1,6 @@
---
name: Service Template
-path: Cisco-IOS-XE-native:native/Cisco-IOS-XE-switch:service-template=%v
+path: /Cisco-IOS-XE-native:native/Cisco-IOS-XE-switch:service-template[word=%v]
doc_category: System
no_delete_attributes: true
attributes:
diff --git a/gen/definitions/sla.yaml b/gen/definitions/sla.yaml
index 150c6c50..08d745b3 100644
--- a/gen/definitions/sla.yaml
+++ b/gen/definitions/sla.yaml
@@ -1,6 +1,6 @@
---
name: SLA
-path: Cisco-IOS-XE-native:native/ip/Cisco-IOS-XE-sla:sla
+path: /Cisco-IOS-XE-native:native/ip/Cisco-IOS-XE-sla:sla
doc_category: System
no_delete: true
no_augment_config: true
diff --git a/gen/definitions/snmp_server.yaml b/gen/definitions/snmp_server.yaml
index 7ed1ee87..2b547731 100644
--- a/gen/definitions/snmp_server.yaml
+++ b/gen/definitions/snmp_server.yaml
@@ -1,6 +1,6 @@
---
name: SNMP Server
-path: Cisco-IOS-XE-native:native/snmp-server
+path: /Cisco-IOS-XE-native:native/snmp-server
doc_category: Management
attributes:
- yang_name: Cisco-IOS-XE-snmp:chassis-id
@@ -997,11 +997,11 @@ attributes:
exclude_test: true
test_prerequisites:
- - path: Cisco-IOS-XE-native:native/interface/Loopback=1
+ - path: /Cisco-IOS-XE-native:native/interface/Loopback[name=1]
attributes:
- name: name
value: 1
- - path: Cisco-IOS-XE-native:native/vrf/definition=VRF1
+ - path: /Cisco-IOS-XE-native:native/vrf/definition[name=VRF1]
no_delete: true
attributes:
- name: name
diff --git a/gen/definitions/spanning_tree.yaml b/gen/definitions/spanning_tree.yaml
index b03a425b..0c22da6a 100644
--- a/gen/definitions/spanning_tree.yaml
+++ b/gen/definitions/spanning_tree.yaml
@@ -1,6 +1,6 @@
---
name: Spanning Tree
-path: Cisco-IOS-XE-native:native/spanning-tree
+path: /Cisco-IOS-XE-native:native/spanning-tree
no_delete: true
request_timeout: 1800
test_tags: [C9000V]
diff --git a/gen/definitions/static_route.yaml b/gen/definitions/static_route.yaml
index 07ec9906..c2250715 100644
--- a/gen/definitions/static_route.yaml
+++ b/gen/definitions/static_route.yaml
@@ -1,6 +1,6 @@
---
name: Static Route
-path: Cisco-IOS-XE-native:native/ip/route/ip-route-interface-forwarding-list=%s,%s
+path: /Cisco-IOS-XE-native:native/ip/route/ip-route-interface-forwarding-list[prefix=%s][mask=%s]
no_delete_attributes: true
skip_minimum_test: true
doc_category: Routing
diff --git a/gen/definitions/static_routes_vrf.yaml b/gen/definitions/static_routes_vrf.yaml
index 572dbdfc..d5158566 100644
--- a/gen/definitions/static_routes_vrf.yaml
+++ b/gen/definitions/static_routes_vrf.yaml
@@ -1,6 +1,6 @@
---
name: Static Routes VRF
-path: Cisco-IOS-XE-native:native/ip/route/vrf=%s
+path: /Cisco-IOS-XE-native:native/ip/route/vrf[name=%s]
no_delete_attributes: true
skip_minimum_test: true
doc_category: Routing
@@ -62,7 +62,7 @@ attributes:
exclude_test: true
test_prerequisites:
- - path: Cisco-IOS-XE-native:native/vrf/definition=VRF1
+ - path: /Cisco-IOS-XE-native:native/vrf/definition[name=VRF1]
no_delete: true
attributes:
- name: name
diff --git a/gen/definitions/system.yaml b/gen/definitions/system.yaml
index 9542f439..ecc275b9 100644
--- a/gen/definitions/system.yaml
+++ b/gen/definitions/system.yaml
@@ -1,6 +1,6 @@
---
name: System
-path: Cisco-IOS-XE-native:native
+path: /Cisco-IOS-XE-native:native
no_delete: true
doc_category: System
attributes:
@@ -588,7 +588,7 @@ attributes:
exclude_test: true
test_prerequisites:
- - path: Cisco-IOS-XE-native:native/vrf/definition=VRF1
+ - path: /Cisco-IOS-XE-native:native/vrf/definition[name=VRF1]
no_delete: true
attributes:
- name: name
diff --git a/gen/definitions/tacacs_server.yaml b/gen/definitions/tacacs_server.yaml
index 2473c34d..c93a0c88 100644
--- a/gen/definitions/tacacs_server.yaml
+++ b/gen/definitions/tacacs_server.yaml
@@ -1,6 +1,6 @@
---
name: TACACS Server
-path: Cisco-IOS-XE-native:native/tacacs/Cisco-IOS-XE-aaa:server=%v
+path: /Cisco-IOS-XE-native:native/tacacs/Cisco-IOS-XE-aaa:server[name=%v]
doc_category: AAA
attributes:
- yang_name: name
diff --git a/gen/definitions/template.yaml b/gen/definitions/template.yaml
index 9ce840da..5798a396 100644
--- a/gen/definitions/template.yaml
+++ b/gen/definitions/template.yaml
@@ -1,6 +1,6 @@
---
name: Template
-path: Cisco-IOS-XE-native:native/template/Cisco-IOS-XE-template:template_details=%v
+path: /Cisco-IOS-XE-native:native/template/Cisco-IOS-XE-template:template_details[template_name=%v]
test_tags: [C9000V]
doc_category: System
attributes:
@@ -207,7 +207,7 @@ attributes:
- yang_name: cts/role-based/enforcement
example: false
test_prerequisites:
- - path: Cisco-IOS-XE-native:native/policy/Cisco-IOS-XE-policy:policy-map=dot1x_policy
+ - path: /Cisco-IOS-XE-native:native/policy/Cisco-IOS-XE-policy:policy-map[name=dot1x_policy]
attributes:
- name: name
value: dot1x_policy
diff --git a/gen/definitions/udld.yaml b/gen/definitions/udld.yaml
index 9d583d8f..d6e028bf 100644
--- a/gen/definitions/udld.yaml
+++ b/gen/definitions/udld.yaml
@@ -1,6 +1,6 @@
---
name: UDLD
-path: Cisco-IOS-XE-native:native/udld
+path: /Cisco-IOS-XE-native:native/udld
doc_category: System
test_tags: [C9000V]
attributes:
diff --git a/gen/definitions/username.yaml b/gen/definitions/username.yaml
index f95287bd..7e0d0bb5 100644
--- a/gen/definitions/username.yaml
+++ b/gen/definitions/username.yaml
@@ -1,6 +1,6 @@
---
name: Username
-path: Cisco-IOS-XE-native:native/username=%s
+path: /Cisco-IOS-XE-native:native/username[name=%s]
no_delete_attributes: true
doc_category: System
attributes:
diff --git a/gen/definitions/vlan.yaml b/gen/definitions/vlan.yaml
index 7c065c7a..7ca7d75b 100644
--- a/gen/definitions/vlan.yaml
+++ b/gen/definitions/vlan.yaml
@@ -1,6 +1,6 @@
---
name: VLAN
-path: Cisco-IOS-XE-native:native/vlan/Cisco-IOS-XE-vlan:vlan-list=%v
+path: /Cisco-IOS-XE-native:native/vlan/Cisco-IOS-XE-vlan:vlan-list[id=%v]
no_delete_attributes: true
test_tags: [C9000V]
doc_category: Switching
diff --git a/gen/definitions/vlan_access_map.yaml b/gen/definitions/vlan_access_map.yaml
index 43465c45..8f27eabc 100644
--- a/gen/definitions/vlan_access_map.yaml
+++ b/gen/definitions/vlan_access_map.yaml
@@ -1,6 +1,6 @@
---
name: VLAN Access Map
-path: Cisco-IOS-XE-native:native/vlan/Cisco-IOS-XE-vlan:access-map=%v,%v
+path: /Cisco-IOS-XE-native:native/vlan/Cisco-IOS-XE-vlan:access-map[name=%v][value=%v]
no_delete_attributes: true
test_tags: [C9000V]
doc_category: Switching
diff --git a/gen/definitions/vlan_configuration.yaml b/gen/definitions/vlan_configuration.yaml
index af60d63c..74dba49a 100644
--- a/gen/definitions/vlan_configuration.yaml
+++ b/gen/definitions/vlan_configuration.yaml
@@ -1,6 +1,6 @@
---
name: VLAN Configuration
-path: Cisco-IOS-XE-native:native/vlan/Cisco-IOS-XE-vlan:configuration=%v
+path: /Cisco-IOS-XE-native:native/vlan/Cisco-IOS-XE-vlan:configuration[vlan-id=%v]
no_delete_attributes: true
test_tags: [C9000V]
doc_category: Switching
diff --git a/gen/definitions/vlan_filter.yaml b/gen/definitions/vlan_filter.yaml
index 631a84d2..becfbd30 100644
--- a/gen/definitions/vlan_filter.yaml
+++ b/gen/definitions/vlan_filter.yaml
@@ -1,6 +1,6 @@
---
name: VLAN Filter
-path: Cisco-IOS-XE-native:native/vlan/Cisco-IOS-XE-vlan:filter=%s
+path: /Cisco-IOS-XE-native:native/vlan/Cisco-IOS-XE-vlan:filter[word=%s]
no_delete_attributes: true
test_tags: [C9000V]
doc_category: Switching
@@ -12,7 +12,7 @@ attributes:
example: 1
test_prerequisites:
- - path: Cisco-IOS-XE-native:native/vlan/Cisco-IOS-XE-vlan:access-map=VAM1,10
+ - path: /Cisco-IOS-XE-native:native/vlan/Cisco-IOS-XE-vlan:access-map[name=VAM1][value=10]
attributes:
- name: name
value: VAM1
diff --git a/gen/definitions/vlan_group.yaml b/gen/definitions/vlan_group.yaml
index 5fd67562..96786477 100644
--- a/gen/definitions/vlan_group.yaml
+++ b/gen/definitions/vlan_group.yaml
@@ -1,6 +1,6 @@
---
name: VLAN Group
-path: Cisco-IOS-XE-native:native/vlan/Cisco-IOS-XE-vlan:group=%s
+path: /Cisco-IOS-XE-native:native/vlan/Cisco-IOS-XE-vlan:group[name=%s]
no_delete_attributes: true
test_tags: [C9000V]
doc_category: Switching
diff --git a/gen/definitions/vrf.yaml b/gen/definitions/vrf.yaml
index 5f9901a4..608956c3 100644
--- a/gen/definitions/vrf.yaml
+++ b/gen/definitions/vrf.yaml
@@ -1,6 +1,6 @@
---
name: VRF
-path: Cisco-IOS-XE-native:native/vrf/definition=%s
+path: /Cisco-IOS-XE-native:native/vrf/definition[name=%s]
doc_category: VRF
attributes:
- yang_name: name
diff --git a/gen/definitions/vtp.yaml b/gen/definitions/vtp.yaml
index eba28fa6..58dceded 100644
--- a/gen/definitions/vtp.yaml
+++ b/gen/definitions/vtp.yaml
@@ -1,6 +1,6 @@
---
name: VTP
-path: Cisco-IOS-XE-native:native/vtp
+path: /Cisco-IOS-XE-native:native/vtp
doc_category: Switching
test_tags: [VTP]
attributes:
diff --git a/gen/doc_category.go b/gen/doc_category.go
index 94242b8f..5362278e 100644
--- a/gen/doc_category.go
+++ b/gen/doc_category.go
@@ -84,9 +84,9 @@ func main() {
}
}
- // update iosxe_restconf resource and data source
+ // update iosxe_yang resource and data source
for _, path := range docPaths {
- filename := path + "restconf.md"
+ filename := path + "yang.md"
content, err := os.ReadFile(filename)
if err != nil {
log.Fatalf("Error opening documentation: %v", err)
diff --git a/gen/generator.go b/gen/generator.go
index 82738b0d..dc80b0ad 100644
--- a/gen/generator.go
+++ b/gen/generator.go
@@ -26,7 +26,6 @@ import (
"fmt"
"log"
"math"
- "net/url"
"os"
"path"
"path/filepath"
@@ -34,6 +33,7 @@ import (
"strings"
"text/template"
+ "github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/openconfig/goyang/pkg/yang"
"gopkg.in/yaml.v3"
)
@@ -201,14 +201,6 @@ func ToGoName(s string) string {
return s
}
-// Templating helper function to convert YANG name to GO name
-func ToJsonPath(yangPath, xPath string) string {
- if xPath != "" {
- return strings.ReplaceAll(xPath, "/", ".")
- }
- return strings.ReplaceAll(yangPath, "/", ".")
-}
-
// Templating helper function to convert string to camel case
func CamelCase(s string) string {
var g []string
@@ -243,22 +235,6 @@ func HasId(attributes []YamlConfigAttribute) bool {
return false
}
-// Templating helper function to get example dn
-func GetExamplePath(path string, attributes []YamlConfigAttribute) string {
- a := make([]interface{}, 0, len(attributes))
- for _, attr := range attributes {
- if attr.Id || attr.Reference {
- a = append(a, url.QueryEscape(attr.Example))
- }
- }
- return fmt.Sprintf(path, a...)
-}
-
-// Templating helper function to identify last element of list
-func IsLast(index int, len int) bool {
- return index+1 == len
-}
-
// Templating helper function to remove last element of path
func RemoveLastPathElement(p string) string {
return path.Dir(p)
@@ -272,14 +248,6 @@ func GetXPath(yangPath, xPath string) string {
return yangPath
}
-func contains(s []string, str string) bool {
- for _, v := range s {
- if v == str {
- return true
- }
- }
- return false
-}
// Templating helper function to support arithmetic addition
func Add(a, b int) int {
@@ -331,24 +299,28 @@ func ReverseAttributes(attributes []YamlConfigAttribute) []YamlConfigAttribute {
return reversed
}
+func ToRestconfPath(path string) string {
+ return helpers.ConvertXPathToRestconfPath(path)
+}
+
+func ToDotPath(path string) string {
+ return strings.ReplaceAll(path, "/", ".")
+}
+
// Map of templating functions
var functions = template.FuncMap{
- "toGoName": ToGoName,
- "toJsonPath": ToJsonPath,
- "camelCase": CamelCase,
- "snakeCase": SnakeCase,
- "hasId": HasId,
- "getExamplePath": GetExamplePath,
- "isLast": IsLast,
- "sprintf": fmt.Sprintf,
- "removeLastPathElement": RemoveLastPathElement,
- "getXPath": GetXPath,
- "contains": contains,
- "add": Add,
- "getImportExcludes": GetImportExcludes,
- "importAttributes": ImportAttributes,
- "getDeletePath": GetDeletePath,
- "reverseAttributes": ReverseAttributes,
+ "toGoName": ToGoName,
+ "camelCase": CamelCase,
+ "snakeCase": SnakeCase,
+ "hasId": HasId,
+ "getXPath": GetXPath,
+ "add": Add,
+ "getImportExcludes": GetImportExcludes,
+ "importAttributes": ImportAttributes,
+ "getDeletePath": GetDeletePath,
+ "reverseAttributes": ReverseAttributes,
+ "toRestconfPath": ToRestconfPath,
+ "toDotPath": ToDotPath,
}
func resolvePath(e *yang.Entry, path string) *yang.Entry {
@@ -356,11 +328,11 @@ func resolvePath(e *yang.Entry, path string) *yang.Entry {
for _, pathElement := range pathElements {
if len(pathElement) > 0 {
- // remove key
- if strings.Contains(pathElement, "=") {
- pathElement = pathElement[:strings.Index(pathElement, "=")]
+ // remove XPath predicate (e.g., [name=value] or [name=%v])
+ if strings.Contains(pathElement, "[") {
+ pathElement = pathElement[:strings.Index(pathElement, "[")]
}
- // remove reference
+ // remove namespace prefix (e.g., Cisco-IOS-XE-bgp:bgp -> bgp)
if strings.Contains(pathElement, ":") {
pathElement = pathElement[strings.Index(pathElement, ":")+1:]
}
@@ -419,11 +391,11 @@ func parseAttribute(e *yang.Entry, attr *YamlConfigAttribute) {
//fmt.Printf("%s, Kind: %+v, ListAttr: %+v, Type: %+v\n\n", leaf.Name, leaf.Kind, leaf.ListAttr, leaf.Type)
if leaf.Kind.String() == "Leaf" {
if leaf.ListAttr != nil {
- if contains([]string{"string", "union", "leafref", "enumeration"}, leaf.Type.Kind.String()) {
+ if helpers.Contains([]string{"string", "union", "leafref", "enumeration"}, leaf.Type.Kind.String()) {
if attr.Type == "" {
attr.Type = "StringList"
}
- } else if contains([]string{"uint8", "uint16", "uint32", "uint64"}, leaf.Type.Kind.String()) {
+ } else if helpers.Contains([]string{"uint8", "uint16", "uint32", "uint64"}, leaf.Type.Kind.String()) {
if attr.Type == "" {
attr.Type = "Int64List"
}
@@ -431,7 +403,7 @@ func parseAttribute(e *yang.Entry, attr *YamlConfigAttribute) {
panic(fmt.Sprintf("Unknown leaf-list type, attribute: %s, type: %s", attr.YangName, leaf.Type.Kind.String()))
}
// TODO parse union type
- } else if contains([]string{"string", "union", "leafref"}, leaf.Type.Kind.String()) {
+ } else if helpers.Contains([]string{"string", "union", "leafref"}, leaf.Type.Kind.String()) {
if attr.Type == "" {
attr.Type = "String"
}
@@ -453,7 +425,7 @@ func parseAttribute(e *yang.Entry, attr *YamlConfigAttribute) {
attr.StringPatterns = leaf.Type.Pattern
}
}
- } else if contains([]string{"uint8", "uint16", "uint32", "uint64", "int8", "int16", "int32", "int64"}, leaf.Type.Kind.String()) {
+ } else if helpers.Contains([]string{"uint8", "uint16", "uint32", "uint64", "int8", "int16", "int32", "int64"}, leaf.Type.Kind.String()) {
attr.Type = "Int64"
if leaf.Type.Range != nil {
if attr.MinInt == 0 {
@@ -471,7 +443,7 @@ func parseAttribute(e *yang.Entry, attr *YamlConfigAttribute) {
attr.MaxInt = int64(max)
}
}
- } else if contains([]string{"decimal8", "decimal16", "decimal32", "decimal64"}, leaf.Type.Kind.String()) {
+ } else if helpers.Contains([]string{"decimal8", "decimal16", "decimal32", "decimal64"}, leaf.Type.Kind.String()) {
if attr.Type == "" {
attr.Type = "Float64"
}
@@ -486,7 +458,7 @@ func parseAttribute(e *yang.Entry, attr *YamlConfigAttribute) {
attr.MaxFloat = float64(leaf.Type.Range[0].Max.Value)
}
}
- } else if contains([]string{"boolean", "empty"}, leaf.Type.Kind.String()) {
+ } else if helpers.Contains([]string{"boolean", "empty"}, leaf.Type.Kind.String()) {
if leaf.Type.Kind.String() == "boolean" {
if attr.TypeYangBool == "" {
attr.TypeYangBool = "boolean"
@@ -499,7 +471,7 @@ func parseAttribute(e *yang.Entry, attr *YamlConfigAttribute) {
if attr.Type == "" {
attr.Type = "Bool"
}
- } else if contains([]string{"enumeration"}, leaf.Type.Kind.String()) {
+ } else if helpers.Contains([]string{"enumeration"}, leaf.Type.Kind.String()) {
if attr.Type == "" {
attr.Type = "String"
}
@@ -553,6 +525,7 @@ func augmentConfig(config *YamlConfig, yangModules *yang.Modules) {
path = config.Path
}
+ path = strings.TrimPrefix(path, "/")
module := strings.Split(path, ":")[0]
e, errors := yangModules.GetModule(module)
if len(errors) > 0 {
diff --git a/gen/templates/data_source.go b/gen/templates/data_source.go
index b5b37079..a25f0e02 100644
--- a/gen/templates/data_source.go
+++ b/gen/templates/data_source.go
@@ -25,14 +25,17 @@ import (
"context"
"fmt"
- "github.com/hashicorp/terraform-plugin-framework/diag"
- "github.com/hashicorp/terraform-plugin-framework/tfsdk"
+ "github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
+ "github.com/hashicorp/terraform-plugin-framework/diag"
"github.com/hashicorp/terraform-plugin-framework/path"
+ "github.com/hashicorp/terraform-plugin-framework/tfsdk"
"github.com/hashicorp/terraform-plugin-framework/types"
"github.com/hashicorp/terraform-plugin-log/tflog"
+ "github.com/netascode/go-netconf"
"github.com/netascode/go-restconf"
+ "github.com/netascode/xmldot"
)
// End of section. //template:end imports
@@ -163,16 +166,37 @@ func (d *{{camelCase .Name}}DataSource) Read(ctx context.Context, req datasource
return
}
- res, err := device.Client.GetData(config.getPath())
- if res.StatusCode == 404 {
- config = {{camelCase .Name}}Data{Device: config.Device}
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(config.getPath())
+ if res.StatusCode == 404 {
+ config = {{camelCase .Name}}Data{Device: config.Device}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
+ return
+ }
+
+ config.fromBody(ctx, res.Res)
+ }
} else {
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
+ }
+
+ filter := helpers.GetXpathFilter(config.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
if err != nil {
resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
return
}
- config.fromBody(ctx, res.Res)
+ config.fromBodyXML(ctx, res.Res)
}
config.Id = types.StringValue(config.getPath())
diff --git a/gen/templates/data_source_test.go b/gen/templates/data_source_test.go
index 6b150618..4710a7b5 100644
--- a/gen/templates/data_source_test.go
+++ b/gen/templates/data_source_test.go
@@ -110,7 +110,7 @@ func TestAccDataSourceIosxe{{camelCase .Name}}(t *testing.T) {
{{- if .TestPrerequisites}}
const testAccDataSourceIosxe{{camelCase .Name}}PrerequisitesConfig = `
{{- range $index, $item := .TestPrerequisites}}
-resource "iosxe_restconf" "PreReq{{$index}}" {
+resource "iosxe_yang" "PreReq{{$index}}" {
path = "{{.Path}}"
{{- if .NoDelete}}
delete = false
@@ -140,7 +140,7 @@ resource "iosxe_restconf" "PreReq{{$index}}" {
]
{{- end}}
{{- if .Dependencies}}
- depends_on = [{{range .Dependencies}}iosxe_restconf.PreReq{{.}}, {{end}}]
+ depends_on = [{{range .Dependencies}}iosxe_yang.PreReq{{.}}, {{end}}]
{{- end}}
}
{{ end}}
@@ -211,7 +211,7 @@ func testAccDataSourceIosxe{{camelCase .Name}}Config() string {
{{- end}}
{{- end}}
{{- if .TestPrerequisites}}
- config += ` depends_on = [{{range $index, $item := .TestPrerequisites}}iosxe_restconf.PreReq{{$index}}, {{end}}]` + "\n"
+ config += ` depends_on = [{{range $index, $item := .TestPrerequisites}}iosxe_yang.PreReq{{$index}}, {{end}}]` + "\n"
{{- end}}
config += `}` + "\n"
diff --git a/gen/templates/model.go b/gen/templates/model.go
index d0649e5a..3ff369c3 100644
--- a/gen/templates/model.go
+++ b/gen/templates/model.go
@@ -34,6 +34,7 @@ import (
"github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/tidwall/sjson"
"github.com/tidwall/gjson"
+ "github.com/netascode/xmldot"
)
// End of section. //template:end imports
@@ -122,17 +123,17 @@ type {{$name}}{{$cname}}{{toGoName .TfName}} struct {
func (data {{camelCase .Name}}) getPath() string {
{{- if hasId .Attributes}}
- return fmt.Sprintf("{{.Path}}"{{range .Attributes}}{{if or .Id .Reference}}, url.QueryEscape(fmt.Sprintf("%v", data.{{toGoName .TfName}}.Value{{.Type}}())){{end}}{{end}})
+ return fmt.Sprintf("{{toRestconfPath .Path}}"{{range .Attributes}}{{if or .Id .Reference}}, url.QueryEscape(fmt.Sprintf("%v", data.{{toGoName .TfName}}.Value{{.Type}}())){{end}}{{end}})
{{- else}}
- return "{{.Path}}"
+ return "{{toRestconfPath .Path}}"
{{- end}}
}
func (data {{camelCase .Name}}Data) getPath() string {
{{- if hasId .Attributes}}
- return fmt.Sprintf("{{.Path}}"{{range .Attributes}}{{if or .Id .Reference}}, url.QueryEscape(fmt.Sprintf("%v", data.{{toGoName .TfName}}.Value{{.Type}}())){{end}}{{end}})
+ return fmt.Sprintf("{{toRestconfPath .Path}}"{{range .Attributes}}{{if or .Id .Reference}}, url.QueryEscape(fmt.Sprintf("%v", data.{{toGoName .TfName}}.Value{{.Type}}())){{end}}{{end}})
{{- else}}
- return "{{.Path}}"
+ return "{{toRestconfPath .Path}}"
{{- end}}
}
@@ -147,6 +148,23 @@ func (data {{camelCase .Name}}) getPathShort() string {
return matches[1]
}
+// getXPath returns the XPath for NETCONF operations
+func (data {{camelCase .Name}}) getXPath() string {
+ path := "{{.Path}}"
+{{- if hasId .Attributes}}
+ path = fmt.Sprintf(path{{range .Attributes}}{{if or .Id .Reference}}, fmt.Sprintf("%v", data.{{toGoName .TfName}}.Value{{.Type}}()){{end}}{{end}})
+{{- end}}
+ return path
+}
+
+func (data {{camelCase .Name}}Data) getXPath() string {
+ path := "{{.Path}}"
+{{- if hasId .Attributes}}
+ path = fmt.Sprintf(path{{range .Attributes}}{{if or .Id .Reference}}, fmt.Sprintf("%v", data.{{toGoName .TfName}}.Value{{.Type}}()){{end}}{{end}})
+{{- end}}
+ return path
+}
+
// End of section. //template:end getPath
// Section below is generated&owned by "gen/generator.go". //template:begin toBody
@@ -157,90 +175,90 @@ func (data {{camelCase .Name}}) toBody(ctx context.Context) string {
{{- if and (not .Reference) (ne .Type "List") (ne .Type "Set")}}
if !data.{{toGoName .TfName}}.IsNull() && !data.{{toGoName .TfName}}.IsUnknown() {
{{- if eq .Type "Int64"}}
- body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"{{toJsonPath .YangName .XPath}}", strconv.FormatInt(data.{{toGoName .TfName}}.ValueInt64(), 10))
+ body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"{{toDotPath .XPath}}", strconv.FormatInt(data.{{toGoName .TfName}}.ValueInt64(), 10))
{{- else if eq .Type "Float64"}}
- body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"{{toJsonPath .YangName .XPath}}", strconv.FormatFloat(data.{{toGoName .TfName}}.ValueFloat64(), 'f', 1, 64))
+ body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"{{toDotPath .XPath}}", strconv.FormatFloat(data.{{toGoName .TfName}}.ValueFloat64(), 'f', 1, 64))
{{- else if and (eq .Type "Bool") (ne .TypeYangBool "boolean")}}
if data.{{toGoName .TfName}}.ValueBool() {
- body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"{{toJsonPath .YangName .XPath}}", map[string]string{})
+ body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"{{toDotPath .XPath}}", map[string]string{})
}
{{- else if and (eq .Type "Bool") (eq .TypeYangBool "boolean")}}
- body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"{{toJsonPath .YangName .XPath}}", data.{{toGoName .TfName}}.ValueBool())
+ body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"{{toDotPath .XPath}}", data.{{toGoName .TfName}}.ValueBool())
{{- else if eq .Type "String"}}
- body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"{{toJsonPath .YangName .XPath}}", data.{{toGoName .TfName}}.ValueString())
+ body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"{{toDotPath .XPath}}", data.{{toGoName .TfName}}.ValueString())
{{- else if or (eq .Type "StringList") (eq .Type "StringSet")}}
var values []string
data.{{toGoName .TfName}}.ElementsAs(ctx, &values, false)
- body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"{{toJsonPath .YangName .XPath}}", values)
+ body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"{{toDotPath .XPath}}", values)
{{- else if or (eq .Type "Int64List") (eq .Type "Int64Set")}}
var values []int
data.{{toGoName .TfName}}.ElementsAs(ctx, &values, false)
- body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"{{toJsonPath .YangName .XPath}}", values)
+ body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"{{toDotPath .XPath}}", values)
{{- end}}
}
{{- end}}
{{- end}}
{{- range .Attributes}}
{{- if or (eq .Type "List") (eq .Type "Set")}}
- {{- $list := toJsonPath .YangName .XPath }}
+ {{- $list := toDotPath .XPath }}
if len(data.{{toGoName .TfName}}) > 0 {
- body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"{{toJsonPath .YangName .XPath}}", []interface{}{})
+ body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"{{toDotPath .XPath}}", []interface{}{})
for index, item := range data.{{toGoName .TfName}} {
{{- range .Attributes}}
{{- if and (ne .Type "List") (ne .Type "Set")}}
if !item.{{toGoName .TfName}}.IsNull() && !item.{{toGoName .TfName}}.IsUnknown() {
{{- if eq .Type "Int64"}}
- body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"{{$list}}"+"."+strconv.Itoa(index)+"."+"{{toJsonPath .YangName .XPath}}", strconv.FormatInt(item.{{toGoName .TfName}}.ValueInt64(), 10))
+ body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"{{$list}}"+"."+strconv.Itoa(index)+"."+"{{toDotPath .XPath}}", strconv.FormatInt(item.{{toGoName .TfName}}.ValueInt64(), 10))
{{- else if eq .Type "Float64"}}
- body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"{{$list}}"+"."+strconv.Itoa(index)+"."+"{{toJsonPath .YangName .XPath}}", strconv.FormatFloat(item.{{toGoName .TfName}}.ValueFloat64(), 'f', 1, 64))
+ body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"{{$list}}"+"."+strconv.Itoa(index)+"."+"{{toDotPath .XPath}}", strconv.FormatFloat(item.{{toGoName .TfName}}.ValueFloat64(), 'f', 1, 64))
{{- else if and (eq .Type "Bool") (ne .TypeYangBool "boolean")}}
if item.{{toGoName .TfName}}.ValueBool() {
- body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"{{$list}}"+"."+strconv.Itoa(index)+"."+"{{toJsonPath .YangName .XPath}}", map[string]string{})
+ body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"{{$list}}"+"."+strconv.Itoa(index)+"."+"{{toDotPath .XPath}}", map[string]string{})
}
{{- else if and (eq .Type "Bool") (eq .TypeYangBool "boolean")}}
- body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"{{$list}}"+"."+strconv.Itoa(index)+"."+"{{toJsonPath .YangName .XPath}}", item.{{toGoName .TfName}}.ValueBool())
+ body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"{{$list}}"+"."+strconv.Itoa(index)+"."+"{{toDotPath .XPath}}", item.{{toGoName .TfName}}.ValueBool())
{{- else if eq .Type "String"}}
- body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"{{$list}}"+"."+strconv.Itoa(index)+"."+"{{toJsonPath .YangName .XPath}}", item.{{toGoName .TfName}}.ValueString())
+ body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"{{$list}}"+"."+strconv.Itoa(index)+"."+"{{toDotPath .XPath}}", item.{{toGoName .TfName}}.ValueString())
{{- else if or (eq .Type "StringList") (eq .Type "StringSet")}}
var values []string
item.{{toGoName .TfName}}.ElementsAs(ctx, &values, false)
- body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"{{$list}}"+"."+strconv.Itoa(index)+"."+"{{toJsonPath .YangName .XPath}}", values)
+ body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"{{$list}}"+"."+strconv.Itoa(index)+"."+"{{toDotPath .XPath}}", values)
{{- else if or (eq .Type "Int64List") (eq .Type "Int64Set")}}
var values []int
item.{{toGoName .TfName}}.ElementsAs(ctx, &values, false)
- body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"{{$list}}"+"."+strconv.Itoa(index)+"."+"{{toJsonPath .YangName .XPath}}", values)
+ body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"{{$list}}"+"."+strconv.Itoa(index)+"."+"{{toDotPath .XPath}}", values)
{{- end}}
}
{{- end}}
{{- end}}
{{- range .Attributes}}
{{- if or (eq .Type "List") (eq .Type "Set")}}
- {{- $clist := toJsonPath .YangName .XPath }}
+ {{- $clist := toDotPath .XPath }}
if len(item.{{toGoName .TfName}}) > 0 {
- body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"{{$list}}"+"."+strconv.Itoa(index)+"."+"{{toJsonPath .YangName .XPath}}", []interface{}{})
+ body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"{{$list}}"+"."+strconv.Itoa(index)+"."+"{{toDotPath .XPath}}", []interface{}{})
for cindex, citem := range item.{{toGoName .TfName}} {
{{- range .Attributes}}
if !citem.{{toGoName .TfName}}.IsNull() && !citem.{{toGoName .TfName}}.IsUnknown() {
{{- if eq .Type "Int64"}}
- body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"{{$list}}"+"."+strconv.Itoa(index)+"."+"{{$clist}}"+"."+strconv.Itoa(cindex)+"."+"{{toJsonPath .YangName .XPath}}", strconv.FormatInt(citem.{{toGoName .TfName}}.ValueInt64(), 10))
+ body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"{{$list}}"+"."+strconv.Itoa(index)+"."+"{{$clist}}"+"."+strconv.Itoa(cindex)+"."+"{{toDotPath .XPath}}", strconv.FormatInt(citem.{{toGoName .TfName}}.ValueInt64(), 10))
{{- else if eq .Type "Float64"}}
- body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"{{$list}}"+"."+strconv.Itoa(index)+"."+"{{$clist}}"+"."+strconv.Itoa(cindex)+"."+"{{toJsonPath .YangName .XPath}}", strconv.FormatFloat(item.{{toGoName .TfName}}.ValueFloat64(), 'f', 1, 64))
+ body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"{{$list}}"+"."+strconv.Itoa(index)+"."+"{{$clist}}"+"."+strconv.Itoa(cindex)+"."+"{{toDotPath .XPath}}", strconv.FormatFloat(item.{{toGoName .TfName}}.ValueFloat64(), 'f', 1, 64))
{{- else if and (eq .Type "Bool") (ne .TypeYangBool "boolean")}}
if citem.{{toGoName .TfName}}.ValueBool() {
- body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"{{$list}}"+"."+strconv.Itoa(index)+"."+"{{$clist}}"+"."+strconv.Itoa(cindex)+"."+"{{toJsonPath .YangName .XPath}}", map[string]string{})
+ body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"{{$list}}"+"."+strconv.Itoa(index)+"."+"{{$clist}}"+"."+strconv.Itoa(cindex)+"."+"{{toDotPath .XPath}}", map[string]string{})
}
{{- else if and (eq .Type "Bool") (eq .TypeYangBool "boolean")}}
- body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"{{$list}}"+"."+strconv.Itoa(index)+"."+"{{$clist}}"+"."+strconv.Itoa(cindex)+"."+"{{toJsonPath .YangName .XPath}}", citem.{{toGoName .TfName}}.ValueBool())
+ body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"{{$list}}"+"."+strconv.Itoa(index)+"."+"{{$clist}}"+"."+strconv.Itoa(cindex)+"."+"{{toDotPath .XPath}}", citem.{{toGoName .TfName}}.ValueBool())
{{- else if eq .Type "String"}}
- body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"{{$list}}"+"."+strconv.Itoa(index)+"."+"{{$clist}}"+"."+strconv.Itoa(cindex)+"."+"{{toJsonPath .YangName .XPath}}", citem.{{toGoName .TfName}}.ValueString())
+ body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"{{$list}}"+"."+strconv.Itoa(index)+"."+"{{$clist}}"+"."+strconv.Itoa(cindex)+"."+"{{toDotPath .XPath}}", citem.{{toGoName .TfName}}.ValueString())
{{- else if or (eq .Type "StringList") (eq .Type "StringSet")}}
var values []string
citem.{{toGoName .TfName}}.ElementsAs(ctx, &values, false)
- body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"{{$list}}"+"."+strconv.Itoa(index)+"."+"{{$clist}}"+"."+strconv.Itoa(cindex)+"."+"{{toJsonPath .YangName .XPath}}", values)
+ body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"{{$list}}"+"."+strconv.Itoa(index)+"."+"{{$clist}}"+"."+strconv.Itoa(cindex)+"."+"{{toDotPath .XPath}}", values)
{{- else if or (eq .Type "Int64List") (eq .Type "Int64Set")}}
var values []int
citem.{{toGoName .TfName}}.ElementsAs(ctx, &values, false)
- body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"{{$list}}"+"."+strconv.Itoa(index)+"."+"{{$clist}}"+"."+strconv.Itoa(cindex)+"."+"{{toJsonPath .YangName .XPath}}", values)
+ body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"{{$list}}"+"."+strconv.Itoa(index)+"."+"{{$clist}}"+"."+strconv.Itoa(cindex)+"."+"{{toDotPath .XPath}}", values)
{{- end}}
}
{{- end}}
@@ -257,6 +275,130 @@ func (data {{camelCase .Name}}) toBody(ctx context.Context) string {
// End of section. //template:end toBody
+// Section below is generated&owned by "gen/generator.go". //template:begin toBodyXML
+
+func (data {{camelCase .Name}}) toBodyXML(ctx context.Context) string {
+ body := netconf.Body{}
+ {{- range .Attributes}}
+ {{- if and (not .Reference) (ne .Type "List") (ne .Type "Set")}}
+ if !data.{{toGoName .TfName}}.IsNull() && !data.{{toGoName .TfName}}.IsUnknown() {
+ {{- if eq .Type "Int64"}}
+ body = helpers.SetFromXPath(body, data.getXPath() + "/{{.XPath}}", strconv.FormatInt(data.{{toGoName .TfName}}.ValueInt64(), 10))
+ {{- else if eq .Type "Float64"}}
+ body = helpers.SetFromXPath(body, data.getXPath() + "/{{.XPath}}", strconv.FormatFloat(data.{{toGoName .TfName}}.ValueFloat64(), 'f', 1, 64))
+ {{- else if and (eq .Type "Bool") (ne .TypeYangBool "boolean")}}
+ if data.{{toGoName .TfName}}.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath() + "/{{.XPath}}", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath() + "/{{.XPath}}")
+ }
+ {{- else if and (eq .Type "Bool") (eq .TypeYangBool "boolean")}}
+ body = helpers.SetFromXPath(body, data.getXPath() + "/{{.XPath}}", data.{{toGoName .TfName}}.ValueBool())
+ {{- else if eq .Type "String"}}
+ body = helpers.SetFromXPath(body, data.getXPath() + "/{{.XPath}}", data.{{toGoName .TfName}}.ValueString())
+ {{- else if or (eq .Type "StringList") (eq .Type "StringSet")}}
+ var values []string
+ data.{{toGoName .TfName}}.ElementsAs(ctx, &values, false)
+ for _, v := range values {
+ body = helpers.AppendFromXPath(body, data.getXPath() + "/{{.XPath}}", v)
+ }
+ {{- else if or (eq .Type "Int64List") (eq .Type "Int64Set")}}
+ var values []int
+ data.{{toGoName .TfName}}.ElementsAs(ctx, &values, false)
+ for _, v := range values {
+ body = helpers.AppendFromXPath(body, data.getXPath() + "/{{.XPath}}", v)
+ }
+ {{- end}}
+ }
+ {{- else if or (eq .Type "List") (eq .Type "Set")}}
+ if len(data.{{toGoName .TfName}}) > 0 {
+ for _, item := range data.{{toGoName .TfName}} {
+ cBody := netconf.Body{}
+ {{- range .Attributes}}
+ {{- if and (ne .Type "List") (ne .Type "Set")}}
+ if !item.{{toGoName .TfName}}.IsNull() && !item.{{toGoName .TfName}}.IsUnknown() {
+ {{- if eq .Type "Int64"}}
+ cBody = helpers.SetFromXPath(cBody, "{{.XPath}}", strconv.FormatInt(item.{{toGoName .TfName}}.ValueInt64(), 10))
+ {{- else if eq .Type "Float64"}}
+ cBody = helpers.SetFromXPath(cBody, "{{.XPath}}", strconv.FormatFloat(item.{{toGoName .TfName}}.ValueFloat64(), 'f', 1, 64))
+ {{- else if and (eq .Type "Bool") (ne .TypeYangBool "boolean")}}
+ if item.{{toGoName .TfName}}.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "{{.XPath}}", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "{{.XPath}}")
+ }
+ {{- else if and (eq .Type "Bool") (eq .TypeYangBool "boolean")}}
+ cBody = helpers.SetFromXPath(cBody, "{{.XPath}}", item.{{toGoName .TfName}}.ValueBool())
+ {{- else if eq .Type "String"}}
+ cBody = helpers.SetFromXPath(cBody, "{{.XPath}}", item.{{toGoName .TfName}}.ValueString())
+ {{- else if or (eq .Type "StringList") (eq .Type "StringSet")}}
+ var values []string
+ item.{{toGoName .TfName}}.ElementsAs(ctx, &values, false)
+ for _, v := range values {
+ cBody = helpers.AppendFromXPath(cBody, "{{.XPath}}", v)
+ }
+ {{- else if or (eq .Type "Int64List") (eq .Type "Int64Set")}}
+ var values []int
+ item.{{toGoName .TfName}}.ElementsAs(ctx, &values, false)
+ for _, v := range values {
+ cBody = helpers.AppendFromXPath(cBody, "{{.XPath}}", v)
+ }
+ {{- end}}
+ }
+ {{- else if or (eq .Type "List") (eq .Type "Set")}}
+ if len(item.{{toGoName .TfName}}) > 0 {
+ for _, citem := range item.{{toGoName .TfName}} {
+ ccBody := netconf.Body{}
+ {{- range .Attributes}}
+ if !citem.{{toGoName .TfName}}.IsNull() && !citem.{{toGoName .TfName}}.IsUnknown() {
+ {{- if eq .Type "Int64"}}
+ ccBody = helpers.SetFromXPath(ccBody, "{{.XPath}}", strconv.FormatInt(citem.{{toGoName .TfName}}.ValueInt64(), 10))
+ {{- else if eq .Type "Float64"}}
+ ccBody = helpers.SetFromXPath(ccBody, "{{.XPath}}", strconv.FormatFloat(citem.{{toGoName .TfName}}.ValueFloat64(), 'f', 1, 64))
+ {{- else if and (eq .Type "Bool") (ne .TypeYangBool "boolean")}}
+ if citem.{{toGoName .TfName}}.ValueBool() {
+ ccBody = helpers.SetFromXPath(ccBody, "{{.XPath}}", "")
+ } else {
+ ccBody = helpers.RemoveFromXPath(ccBody, "{{.XPath}}")
+ }
+ {{- else if and (eq .Type "Bool") (eq .TypeYangBool "boolean")}}
+ ccBody = helpers.SetFromXPath(ccBody, "{{.XPath}}", citem.{{toGoName .TfName}}.ValueBool())
+ {{- else if eq .Type "String"}}
+ ccBody = helpers.SetFromXPath(ccBody, "{{.XPath}}", citem.{{toGoName .TfName}}.ValueString())
+ {{- else if or (eq .Type "StringList") (eq .Type "StringSet")}}
+ var values []string
+ citem.{{toGoName .TfName}}.ElementsAs(ctx, &values, false)
+ for _, v := range values {
+ ccBody = helpers.AppendFromXPath(ccBody, "{{.XPath}}", v)
+ }
+ {{- else if or (eq .Type "Int64List") (eq .Type "Int64Set")}}
+ var values []int
+ citem.{{toGoName .TfName}}.ElementsAs(ctx, &values, false)
+ for _, v := range values {
+ ccBody = helpers.AppendFromXPath(ccBody, "{{.XPath}}", v)
+ }
+ {{- end}}
+ }
+ {{- end}}
+ cBody = helpers.SetRawFromXPath(cBody, "{{.XPath}}", ccBody.Res())
+ }
+ }
+ {{- end}}
+ {{- end}}
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/{{.XPath}}", cBody.Res())
+ }
+ }
+ {{- end}}
+ {{- end}}
+ bodyString, err := body.String()
+ if err != nil {
+ tflog.Error(ctx, fmt.Sprintf("Error converting body to string: %s", err))
+ }
+ return bodyString
+}
+
+// End of section. //template:end toBodyXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBody
func (data *{{camelCase .Name}}) updateFromBody(ctx context.Context, res gjson.Result) {
@@ -267,19 +409,19 @@ func (data *{{camelCase .Name}}) updateFromBody(ctx context.Context, res gjson.R
{{- range .Attributes}}
{{- if and (not .Reference) (not .WriteOnly)}}
{{- if eq .Type "Int64"}}
- if value := res.Get(prefix+"{{toJsonPath .YangName .XPath}}"); value.Exists() && !data.{{toGoName .TfName}}.IsNull() {
+ if value := res.Get(prefix+"{{toDotPath .XPath}}"); value.Exists() && !data.{{toGoName .TfName}}.IsNull() {
data.{{toGoName .TfName}} = types.Int64Value(value.Int())
} else {
data.{{toGoName .TfName}} = types.Int64Null()
}
{{- else if eq .Type "Float64"}}
- if value := res.Get(prefix+"{{toJsonPath .YangName .XPath}}"); value.Exists() && !data.{{toGoName .TfName}}.IsNull() {
+ if value := res.Get(prefix+"{{toDotPath .XPath}}"); value.Exists() && !data.{{toGoName .TfName}}.IsNull() {
data.{{toGoName .TfName}} = types.Float64Value(value.Float())
} else {
data.{{toGoName .TfName}} = types.Float64Null()
}
{{- else if eq .Type "Bool"}}
- if value := res.Get(prefix+"{{toJsonPath .YangName .XPath}}"); !data.{{toGoName .TfName}}.IsNull() {
+ if value := res.Get(prefix+"{{toDotPath .XPath}}"); !data.{{toGoName .TfName}}.IsNull() {
{{- if eq .TypeYangBool "boolean"}}
if value.Exists() {
data.{{toGoName .TfName}} = types.BoolValue(value.Bool())
@@ -295,40 +437,40 @@ func (data *{{camelCase .Name}}) updateFromBody(ctx context.Context, res gjson.R
data.{{toGoName .TfName}} = types.BoolNull()
}
{{- else if eq .Type "String"}}
- if value := res.Get(prefix+"{{toJsonPath .YangName .XPath}}"); value.Exists() && !data.{{toGoName .TfName}}.IsNull() {
+ if value := res.Get(prefix+"{{toDotPath .XPath}}"); value.Exists() && !data.{{toGoName .TfName}}.IsNull() {
data.{{toGoName .TfName}} = types.StringValue(value.String())
} else {
data.{{toGoName .TfName}} = types.StringNull()
}
{{- else if eq .Type "StringList"}}
- if value := res.Get(prefix+"{{toJsonPath .YangName .XPath}}"); value.Exists() && !data.{{toGoName .TfName}}.IsNull() {
+ if value := res.Get(prefix+"{{toDotPath .XPath}}"); value.Exists() && !data.{{toGoName .TfName}}.IsNull() {
data.{{toGoName .TfName}} = helpers.GetStringList(value.Array())
} else {
data.{{toGoName .TfName}} = types.ListNull(types.StringType)
}
{{- else if eq .Type "Int64List"}}
- if value := res.Get(prefix+"{{toJsonPath .YangName .XPath}}"); value.Exists() && !data.{{toGoName .TfName}}.IsNull() {
+ if value := res.Get(prefix+"{{toDotPath .XPath}}"); value.Exists() && !data.{{toGoName .TfName}}.IsNull() {
data.{{toGoName .TfName}} = helpers.GetInt64List(value.Array())
} else {
data.{{toGoName .TfName}} = types.ListNull(types.Int64Type)
}
{{- else if eq .Type "StringSet"}}
- if value := res.Get(prefix+"{{toJsonPath .YangName .XPath}}"); value.Exists() && !data.{{toGoName .TfName}}.IsNull() {
+ if value := res.Get(prefix+"{{toDotPath .XPath}}"); value.Exists() && !data.{{toGoName .TfName}}.IsNull() {
data.{{toGoName .TfName}} = helpers.GetStringSet(value.Array())
} else {
data.{{toGoName .TfName}} = types.SetNull(types.StringType)
}
{{- else if eq .Type "Int64Set"}}
- if value := res.Get(prefix+"{{toJsonPath .YangName .XPath}}"); value.Exists() && !data.{{toGoName .TfName}}.IsNull() {
+ if value := res.Get(prefix+"{{toDotPath .XPath}}"); value.Exists() && !data.{{toGoName .TfName}}.IsNull() {
data.{{toGoName .TfName}} = helpers.GetInt64Set(value.Array())
} else {
data.{{toGoName .TfName}} = types.SetNull(types.Int64Type)
}
{{- else if or (eq .Type "List") (eq .Type "Set")}}
{{- $list := (toGoName .TfName)}}
- {{- $listPath := (toJsonPath .YangName .XPath)}}
+ {{- $listPath := toDotPath .XPath}}
for i := range data.{{$list}} {
- keys := [...]string{ {{range .Attributes}}{{if .Id}}"{{getXPath .YangName .XPath}}", {{end}}{{end}} }
+ keys := [...]string{ {{range .Attributes}}{{if .Id}}"{{.XPath}}", {{end}}{{end}} }
keyValues := [...]string{ {{range .Attributes}}{{if .Id}}{{if eq .Type "Int64"}}strconv.FormatInt(data.{{$list}}[i].{{toGoName .TfName}}.ValueInt64(), 10), {{else if eq .Type "Bool"}}strconv.FormatBool(data.{{$list}}[i].{{toGoName .TfName}}.ValueBool()), {{else}}data.{{$list}}[i].{{toGoName .TfName}}.Value{{.Type}}(), {{end}}{{end}}{{end}} }
var r gjson.Result
@@ -354,19 +496,19 @@ func (data *{{camelCase .Name}}) updateFromBody(ctx context.Context, res gjson.R
{{- range .Attributes}}
{{- if not .WriteOnly}}
{{- if eq .Type "Int64"}}
- if value := r.Get("{{toJsonPath .YangName .XPath}}"); value.Exists() && !data.{{$list}}[i].{{toGoName .TfName}}.IsNull() {
+ if value := r.Get("{{toDotPath .XPath}}"); value.Exists() && !data.{{$list}}[i].{{toGoName .TfName}}.IsNull() {
data.{{$list}}[i].{{toGoName .TfName}} = types.Int64Value(value.Int())
} else {
data.{{$list}}[i].{{toGoName .TfName}} = types.Int64Null()
}
{{- else if eq .Type "Float64"}}
- if value := r.Get("{{toJsonPath .YangName .XPath}}"); value.Exists() && !data.{{$list}}[i].{{toGoName .TfName}}.IsNull() {
+ if value := r.Get("{{toDotPath .XPath}}"); value.Exists() && !data.{{$list}}[i].{{toGoName .TfName}}.IsNull() {
data.{{$list}}[i].{{toGoName .TfName}} = types.Float64Value(value.Float())
} else {
data.{{$list}}[i].{{toGoName .TfName}} = types.Float64Null()
}
{{- else if eq .Type "Bool"}}
- if value := r.Get("{{toJsonPath .YangName .XPath}}"); !data.{{$list}}[i].{{toGoName .TfName}}.IsNull() {
+ if value := r.Get("{{toDotPath .XPath}}"); !data.{{$list}}[i].{{toGoName .TfName}}.IsNull() {
{{- if eq .TypeYangBool "boolean"}}
if value.Exists() {
data.{{$list}}[i].{{toGoName .TfName}} = types.BoolValue(value.Bool())
@@ -382,40 +524,40 @@ func (data *{{camelCase .Name}}) updateFromBody(ctx context.Context, res gjson.R
data.{{$list}}[i].{{toGoName .TfName}} = types.BoolNull()
}
{{- else if eq .Type "String"}}
- if value := r.Get("{{toJsonPath .YangName .XPath}}"); value.Exists() && !data.{{$list}}[i].{{toGoName .TfName}}.IsNull() {
+ if value := r.Get("{{toDotPath .XPath}}"); value.Exists() && !data.{{$list}}[i].{{toGoName .TfName}}.IsNull() {
data.{{$list}}[i].{{toGoName .TfName}} = types.StringValue(value.String())
} else {
data.{{$list}}[i].{{toGoName .TfName}} = types.StringNull()
}
{{- else if eq .Type "StringList"}}
- if value := r.Get("{{toJsonPath .YangName .XPath}}"); value.Exists() && !data.{{$list}}[i].{{toGoName .TfName}}.IsNull() {
+ if value := r.Get("{{toDotPath .XPath}}"); value.Exists() && !data.{{$list}}[i].{{toGoName .TfName}}.IsNull() {
data.{{$list}}[i].{{toGoName .TfName}} = helpers.GetStringList(value.Array())
} else {
data.{{$list}}[i].{{toGoName .TfName}} = types.ListNull(types.StringType)
}
{{- else if eq .Type "Int64List"}}
- if value := r.Get("{{toJsonPath .YangName .XPath}}"); value.Exists() && !data.{{$list}}[i].{{toGoName .TfName}}.IsNull() {
+ if value := r.Get("{{toDotPath .XPath}}"); value.Exists() && !data.{{$list}}[i].{{toGoName .TfName}}.IsNull() {
data.{{$list}}[i].{{toGoName .TfName}} = helpers.GetInt64List(value.Array())
} else {
data.{{$list}}[i].{{toGoName .TfName}} = types.ListNull(types.Int64Type)
}
{{- else if eq .Type "StringSet"}}
- if value := r.Get("{{toJsonPath .YangName .XPath}}"); value.Exists() && !data.{{$list}}[i].{{toGoName .TfName}}.IsNull() {
+ if value := r.Get("{{toDotPath .XPath}}"); value.Exists() && !data.{{$list}}[i].{{toGoName .TfName}}.IsNull() {
data.{{$list}}[i].{{toGoName .TfName}} = helpers.GetStringSet(value.Array())
} else {
data.{{$list}}[i].{{toGoName .TfName}} = types.SetNull(types.StringType)
}
{{- else if eq .Type "Int64Set"}}
- if value := r.Get("{{toJsonPath .YangName .XPath}}"); value.Exists() && !data.{{$list}}[i].{{toGoName .TfName}}.IsNull() {
+ if value := r.Get("{{toDotPath .XPath}}"); value.Exists() && !data.{{$list}}[i].{{toGoName .TfName}}.IsNull() {
data.{{$list}}[i].{{toGoName .TfName}} = helpers.GetInt64Set(value.Array())
} else {
data.{{$list}}[i].{{toGoName .TfName}} = types.SetNull(types.Int64Type)
}
{{- else if or (eq .Type "List") (eq .Type "Set")}}
{{- $clist := (toGoName .TfName)}}
- {{- $clistPath := (toJsonPath .YangName .XPath)}}
+ {{- $clistPath := toDotPath .XPath}}
for ci := range data.{{$list}}[i].{{$clist}} {
- keys := [...]string{ {{range .Attributes}}{{if .Id}}"{{getXPath .YangName .XPath}}", {{end}}{{end}} }
+ keys := [...]string{ {{range .Attributes}}{{if .Id}}"{{.XPath}}", {{end}}{{end}} }
keyValues := [...]string{ {{range .Attributes}}{{if .Id}}{{if eq .Type "Int64"}}strconv.FormatInt(data.{{$list}}[i].{{$clist}}[ci].{{toGoName .TfName}}.ValueInt64(), 10), {{else if eq .Type "Bool"}}strconv.FormatBool(data.{{$list}}[i].{{$clist}}[ci].{{toGoName .TfName}}.ValueBool()), {{else}}data.{{$list}}[i].{{$clist}}[ci].{{toGoName .TfName}}.Value{{.Type}}(), {{end}}{{end}}{{end}} }
var cr gjson.Result
@@ -441,19 +583,19 @@ func (data *{{camelCase .Name}}) updateFromBody(ctx context.Context, res gjson.R
{{- range .Attributes}}
{{- if not .WriteOnly}}
{{- if eq .Type "Int64"}}
- if value := cr.Get("{{toJsonPath .YangName .XPath}}"); value.Exists() && !data.{{$list}}[i].{{$clist}}[ci].{{toGoName .TfName}}.IsNull() {
+ if value := cr.Get("{{toDotPath .XPath}}"); value.Exists() && !data.{{$list}}[i].{{$clist}}[ci].{{toGoName .TfName}}.IsNull() {
data.{{$list}}[i].{{$clist}}[ci].{{toGoName .TfName}} = types.Int64Value(value.Int())
} else {
data.{{$list}}[i].{{$clist}}[ci].{{toGoName .TfName}} = types.Int64Null()
}
{{- else if eq .Type "Float64"}}
- if value := cr.Get("{{toJsonPath .YangName .XPath}}"); value.Exists() && !data.{{$list}}[i].{{$clist}}[ci].{{toGoName .TfName}}.IsNull() {
+ if value := cr.Get("{{toDotPath .XPath}}"); value.Exists() && !data.{{$list}}[i].{{$clist}}[ci].{{toGoName .TfName}}.IsNull() {
data.{{$list}}[i].{{$clist}}[ci].{{toGoName .TfName}} = types.Float64Value(value.Float())
} else {
data.{{$list}}[i].{{$clist}}[ci].{{toGoName .TfName}} = types.Float64Null()
}
{{- else if eq .Type "Bool"}}
- if value := cr.Get("{{toJsonPath .YangName .XPath}}"); !data.{{$list}}[i].{{$clist}}[ci].{{toGoName .TfName}}.IsNull() {
+ if value := cr.Get("{{toDotPath .XPath}}"); !data.{{$list}}[i].{{$clist}}[ci].{{toGoName .TfName}}.IsNull() {
{{- if eq .TypeYangBool "boolean"}}
if value.Exists() {
data.{{$list}}[i].{{$clist}}[ci].{{toGoName .TfName}} = types.BoolValue(value.Bool())
@@ -469,72 +611,521 @@ func (data *{{camelCase .Name}}) updateFromBody(ctx context.Context, res gjson.R
data.{{$list}}[i].{{$clist}}[ci].{{toGoName .TfName}} = types.BoolNull()
}
{{- else if eq .Type "String"}}
- if value := cr.Get("{{toJsonPath .YangName .XPath}}"); value.Exists() && !data.{{$list}}[i].{{$clist}}[ci].{{toGoName .TfName}}.IsNull() {
+ if value := cr.Get("{{toDotPath .XPath}}"); value.Exists() && !data.{{$list}}[i].{{$clist}}[ci].{{toGoName .TfName}}.IsNull() {
data.{{$list}}[i].{{$clist}}[ci].{{toGoName .TfName}} = types.StringValue(value.String())
} else {
data.{{$list}}[i].{{$clist}}[ci].{{toGoName .TfName}} = types.StringNull()
}
{{- else if eq .Type "StringList"}}
- if value := cr.Get("{{toJsonPath .YangName .XPath}}"); value.Exists() && !data.{{$list}}[i].{{$clist}}[ci].{{toGoName .TfName}}.IsNull() {
+ if value := cr.Get("{{toDotPath .XPath}}"); value.Exists() && !data.{{$list}}[i].{{$clist}}[ci].{{toGoName .TfName}}.IsNull() {
data.{{$list}}[i].{{$clist}}[ci].{{toGoName .TfName}} = helpers.GetStringList(value.Array())
} else {
data.{{$list}}[i].{{$clist}}[ci].{{toGoName .TfName}} = types.ListNull(types.StringType)
}
{{- else if eq .Type "Int64List"}}
- if value := cr.Get("{{toJsonPath .YangName .XPath}}"); value.Exists() && !data.{{$list}}[i].{{$clist}}[ci].{{toGoName .TfName}}.IsNull() {
+ if value := cr.Get("{{toDotPath .XPath}}"); value.Exists() && !data.{{$list}}[i].{{$clist}}[ci].{{toGoName .TfName}}.IsNull() {
data.{{$list}}[i].{{$clist}}[ci].{{toGoName .TfName}} = helpers.GetInt64List(value.Array())
} else {
data.{{$list}}[i].{{$clist}}[ci].{{toGoName .TfName}} = types.ListNull(types.Int64Type)
}
{{- else if eq .Type "StringSet"}}
- if value := cr.Get("{{toJsonPath .YangName .XPath}}"); value.Exists() && !data.{{$list}}[i].{{$clist}}[ci].{{toGoName .TfName}}.IsNull() {
+ if value := cr.Get("{{toDotPath .XPath}}"); value.Exists() && !data.{{$list}}[i].{{$clist}}[ci].{{toGoName .TfName}}.IsNull() {
data.{{$list}}[i].{{$clist}}[ci].{{toGoName .TfName}} = helpers.GetStringSet(value.Array())
} else {
data.{{$list}}[i].{{$clist}}[ci].{{toGoName .TfName}} = types.SetNull(types.StringType)
}
{{- else if eq .Type "Int64Set"}}
- if value := cr.Get("{{toJsonPath .YangName .XPath}}"); value.Exists() && !data.{{$list}}[i].{{$clist}}[ci].{{toGoName .TfName}}.IsNull() {
+ if value := cr.Get("{{toDotPath .XPath}}"); value.Exists() && !data.{{$list}}[i].{{$clist}}[ci].{{toGoName .TfName}}.IsNull() {
data.{{$list}}[i].{{$clist}}[ci].{{toGoName .TfName}} = helpers.GetInt64Set(value.Array())
} else {
data.{{$list}}[i].{{$clist}}[ci].{{toGoName .TfName}} = types.SetNull(types.Int64Type)
}
{{- end}}
{{- end}}
- {{- end}}
- }
- {{- end}}
- {{- end}}
- {{- end}}
+ {{- end}}
+ }
+ {{- end}}
+ {{- end}}
+ {{- end}}
+ }
+ {{- end}}
+ {{- end}}
+ {{- end}}
+}
+
+// End of section. //template:end updateFromBody
+
+// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBodyXML
+
+func (data *{{camelCase .Name}}) updateFromBodyXML(ctx context.Context, res xmldot.Result) {
+ {{- range .Attributes}}
+ {{- if and (not .Reference) (not .WriteOnly)}}
+ {{- if eq .Type "Int64"}}
+ if value := helpers.GetFromXPath(res, "data/" + data.getXPath() + "/{{.XPath}}"); value.Exists() && !data.{{toGoName .TfName}}.IsNull() {
+ data.{{toGoName .TfName}} = types.Int64Value(value.Int())
+ } else {
+ data.{{toGoName .TfName}} = types.Int64Null()
+ }
+ {{- else if eq .Type "Float64"}}
+ if value := helpers.GetFromXPath(res, "data/" + data.getXPath() + "/{{.XPath}}"); value.Exists() && !data.{{toGoName .TfName}}.IsNull() {
+ data.{{toGoName .TfName}} = types.Float64Value(value.Float())
+ } else {
+ data.{{toGoName .TfName}} = types.Float64Null()
+ }
+ {{- else if eq .Type "Bool"}}
+ if value := helpers.GetFromXPath(res, "data/" + data.getXPath() + "/{{.XPath}}"); !data.{{toGoName .TfName}}.IsNull() {
+ {{- if eq .TypeYangBool "boolean"}}
+ if value.Exists() {
+ data.{{toGoName .TfName}} = types.BoolValue(value.Bool())
+ }
+ {{- else}}
+ if value.Exists() {
+ data.{{toGoName .TfName}} = types.BoolValue(true)
+ } else {
+ data.{{toGoName .TfName}} = types.BoolValue(false)
+ }
+ {{- end}}
+ } else {
+ data.{{toGoName .TfName}} = types.BoolNull()
+ }
+ {{- else if eq .Type "String"}}
+ if value := helpers.GetFromXPath(res, "data/" + data.getXPath() + "/{{.XPath}}"); value.Exists() && !data.{{toGoName .TfName}}.IsNull() {
+ data.{{toGoName .TfName}} = types.StringValue(value.String())
+ } else {
+ data.{{toGoName .TfName}} = types.StringNull()
+ }
+ {{- else if eq .Type "StringList"}}
+ if value := helpers.GetFromXPath(res, "data/" + data.getXPath() + "/{{.XPath}}"); value.Exists() && !data.{{toGoName .TfName}}.IsNull() {
+ data.{{toGoName .TfName}} = helpers.GetStringListXML(value.Array())
+ } else {
+ data.{{toGoName .TfName}} = types.ListNull(types.StringType)
+ }
+ {{- else if eq .Type "Int64List"}}
+ if value := helpers.GetFromXPath(res, "data/" + data.getXPath() + "/{{.XPath}}"); value.Exists() && !data.{{toGoName .TfName}}.IsNull() {
+ data.{{toGoName .TfName}} = helpers.GetInt64ListXML(value.Array())
+ } else {
+ data.{{toGoName .TfName}} = types.ListNull(types.Int64Type)
+ }
+ {{- else if eq .Type "StringSet"}}
+ if value := helpers.GetFromXPath(res, "data/" + data.getXPath() + "/{{.XPath}}"); value.Exists() && !data.{{toGoName .TfName}}.IsNull() {
+ data.{{toGoName .TfName}} = helpers.GetStringSetXML(value.Array())
+ } else {
+ data.{{toGoName .TfName}} = types.SetNull(types.StringType)
+ }
+ {{- else if eq .Type "Int64Set"}}
+ if value := helpers.GetFromXPath(res, "data/" + data.getXPath() + "/{{.XPath}}"); value.Exists() && !data.{{toGoName .TfName}}.IsNull() {
+ data.{{toGoName .TfName}} = helpers.GetInt64SetXML(value.Array())
+ } else {
+ data.{{toGoName .TfName}} = types.SetNull(types.Int64Type)
+ }
+ {{- else if or (eq .Type "List") (eq .Type "Set")}}
+ {{- $list := (toGoName .TfName)}}
+ for i := range data.{{$list}} {
+ keys := [...]string{ {{range .Attributes}}{{if .Id}}"{{.XPath}}", {{end}}{{end}} }
+ keyValues := [...]string{ {{range .Attributes}}{{if .Id}}{{if eq .Type "Int64"}}strconv.FormatInt(data.{{$list}}[i].{{toGoName .TfName}}.ValueInt64(), 10), {{else if eq .Type "Bool"}}strconv.FormatBool(data.{{$list}}[i].{{toGoName .TfName}}.ValueBool()), {{else}}data.{{$list}}[i].{{toGoName .TfName}}.Value{{.Type}}(), {{end}}{{end}}{{end}} }
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/" + data.getXPath() + "/{{.XPath}}").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+
+ {{- range .Attributes}}
+ {{- if not .WriteOnly}}
+ {{- if eq .Type "Int64"}}
+ if value := helpers.GetFromXPath(r, "{{.XPath}}"); value.Exists() && !data.{{$list}}[i].{{toGoName .TfName}}.IsNull() {
+ data.{{$list}}[i].{{toGoName .TfName}} = types.Int64Value(value.Int())
+ } else {
+ data.{{$list}}[i].{{toGoName .TfName}} = types.Int64Null()
+ }
+ {{- else if eq .Type "Float64"}}
+ if value := helpers.GetFromXPath(r, "{{.XPath}}"); value.Exists() && !data.{{$list}}[i].{{toGoName .TfName}}.IsNull() {
+ data.{{$list}}[i].{{toGoName .TfName}} = types.Float64Value(value.Float())
+ } else {
+ data.{{$list}}[i].{{toGoName .TfName}} = types.Float64Null()
+ }
+ {{- else if eq .Type "Bool"}}
+ if value := helpers.GetFromXPath(r, "{{.XPath}}"); !data.{{$list}}[i].{{toGoName .TfName}}.IsNull() {
+ {{- if eq .TypeYangBool "boolean"}}
+ if value.Exists() {
+ data.{{$list}}[i].{{toGoName .TfName}} = types.BoolValue(value.Bool())
+ }
+ {{- else}}
+ if value.Exists() {
+ data.{{$list}}[i].{{toGoName .TfName}} = types.BoolValue(true)
+ } else {
+ data.{{$list}}[i].{{toGoName .TfName}} = types.BoolValue(false)
+ }
+ {{- end}}
+ } else {
+ data.{{$list}}[i].{{toGoName .TfName}} = types.BoolNull()
+ }
+ {{- else if eq .Type "String"}}
+ if value := helpers.GetFromXPath(r, "{{.XPath}}"); value.Exists() && !data.{{$list}}[i].{{toGoName .TfName}}.IsNull() {
+ data.{{$list}}[i].{{toGoName .TfName}} = types.StringValue(value.String())
+ } else {
+ data.{{$list}}[i].{{toGoName .TfName}} = types.StringNull()
+ }
+ {{- else if eq .Type "StringList"}}
+ if value := helpers.GetFromXPath(r, "{{.XPath}}"); value.Exists() && !data.{{$list}}[i].{{toGoName .TfName}}.IsNull() {
+ data.{{$list}}[i].{{toGoName .TfName}} = helpers.GetStringListXML(value.Array())
+ } else {
+ data.{{$list}}[i].{{toGoName .TfName}} = types.ListNull(types.StringType)
+ }
+ {{- else if eq .Type "Int64List"}}
+ if value := helpers.GetFromXPath(r, "{{.XPath}}"); value.Exists() && !data.{{$list}}[i].{{toGoName .TfName}}.IsNull() {
+ data.{{$list}}[i].{{toGoName .TfName}} = helpers.GetInt64ListXML(value.Array())
+ } else {
+ data.{{$list}}[i].{{toGoName .TfName}} = types.ListNull(types.Int64Type)
+ }
+ {{- else if eq .Type "StringSet"}}
+ if value := helpers.GetFromXPath(r, "{{.XPath}}"); value.Exists() && !data.{{$list}}[i].{{toGoName .TfName}}.IsNull() {
+ data.{{$list}}[i].{{toGoName .TfName}} = helpers.GetStringSetXML(value.Array())
+ } else {
+ data.{{$list}}[i].{{toGoName .TfName}} = types.SetNull(types.StringType)
+ }
+ {{- else if eq .Type "Int64Set"}}
+ if value := helpers.GetFromXPath(r, "{{.XPath}}"); value.Exists() && !data.{{$list}}[i].{{toGoName .TfName}}.IsNull() {
+ data.{{$list}}[i].{{toGoName .TfName}} = helpers.GetInt64SetXML(value.Array())
+ } else {
+ data.{{$list}}[i].{{toGoName .TfName}} = types.SetNull(types.Int64Type)
+ }
+ {{- else if or (eq .Type "List") (eq .Type "Set")}}
+ {{- $clist := (toGoName .TfName)}}
+ for ci := range data.{{$list}}[i].{{$clist}} {
+ keys := [...]string{ {{range .Attributes}}{{if .Id}}"{{.XPath}}", {{end}}{{end}} }
+ keyValues := [...]string{ {{range .Attributes}}{{if .Id}}{{if eq .Type "Int64"}}strconv.FormatInt(data.{{$list}}[i].{{$clist}}[ci].{{toGoName .TfName}}.ValueInt64(), 10), {{else if eq .Type "Bool"}}strconv.FormatBool(data.{{$list}}[i].{{$clist}}[ci].{{toGoName .TfName}}.ValueBool()), {{else}}data.{{$list}}[i].{{$clist}}[ci].{{toGoName .TfName}}.Value{{.Type}}(), {{end}}{{end}}{{end}} }
+
+ var cr xmldot.Result
+ helpers.GetFromXPath(r, "{{.XPath}}").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ cr = v
+ return false
+ }
+ return true
+ },
+ )
+
+ {{- range .Attributes}}
+ {{- if not .WriteOnly}}
+ {{- if eq .Type "Int64"}}
+ if value := helpers.GetFromXPath(cr, "{{.XPath}}"); value.Exists() && !data.{{$list}}[i].{{$clist}}[ci].{{toGoName .TfName}}.IsNull() {
+ data.{{$list}}[i].{{$clist}}[ci].{{toGoName .TfName}} = types.Int64Value(value.Int())
+ } else {
+ data.{{$list}}[i].{{$clist}}[ci].{{toGoName .TfName}} = types.Int64Null()
+ }
+ {{- else if eq .Type "Float64"}}
+ if value := helpers.GetFromXPath(cr, "{{.XPath}}"); value.Exists() && !data.{{$list}}[i].{{$clist}}[ci].{{toGoName .TfName}}.IsNull() {
+ data.{{$list}}[i].{{$clist}}[ci].{{toGoName .TfName}} = types.Float64Value(value.Float())
+ } else {
+ data.{{$list}}[i].{{$clist}}[ci].{{toGoName .TfName}} = types.Float64Null()
+ }
+ {{- else if eq .Type "Bool"}}
+ if value := helpers.GetFromXPath(cr, "{{.XPath}}"); !data.{{$list}}[i].{{$clist}}[ci].{{toGoName .TfName}}.IsNull() {
+ {{- if eq .TypeYangBool "boolean"}}
+ if value.Exists() {
+ data.{{$list}}[i].{{$clist}}[ci].{{toGoName .TfName}} = types.BoolValue(value.Bool())
+ }
+ {{- else}}
+ if value.Exists() {
+ data.{{$list}}[i].{{$clist}}[ci].{{toGoName .TfName}} = types.BoolValue(true)
+ } else {
+ data.{{$list}}[i].{{$clist}}[ci].{{toGoName .TfName}} = types.BoolValue(false)
+ }
+ {{- end}}
+ } else {
+ data.{{$list}}[i].{{$clist}}[ci].{{toGoName .TfName}} = types.BoolNull()
+ }
+ {{- else if eq .Type "String"}}
+ if value := helpers.GetFromXPath(cr, "{{.XPath}}"); value.Exists() && !data.{{$list}}[i].{{$clist}}[ci].{{toGoName .TfName}}.IsNull() {
+ data.{{$list}}[i].{{$clist}}[ci].{{toGoName .TfName}} = types.StringValue(value.String())
+ } else {
+ data.{{$list}}[i].{{$clist}}[ci].{{toGoName .TfName}} = types.StringNull()
+ }
+ {{- else if eq .Type "StringList"}}
+ if value := helpers.GetFromXPath(cr, "{{.XPath}}"); value.Exists() && !data.{{$list}}[i].{{$clist}}[ci].{{toGoName .TfName}}.IsNull() {
+ data.{{$list}}[i].{{$clist}}[ci].{{toGoName .TfName}} = helpers.GetStringListXML(value.Array())
+ } else {
+ data.{{$list}}[i].{{$clist}}[ci].{{toGoName .TfName}} = types.ListNull(types.StringType)
+ }
+ {{- else if eq .Type "Int64List"}}
+ if value := helpers.GetFromXPath(cr, "{{.XPath}}"); value.Exists() && !data.{{$list}}[i].{{$clist}}[ci].{{toGoName .TfName}}.IsNull() {
+ data.{{$list}}[i].{{$clist}}[ci].{{toGoName .TfName}} = helpers.GetInt64ListXML(value.Array())
+ } else {
+ data.{{$list}}[i].{{$clist}}[ci].{{toGoName .TfName}} = types.ListNull(types.Int64Type)
+ }
+ {{- else if eq .Type "StringSet"}}
+ if value := helpers.GetFromXPath(cr, "{{.XPath}}"); value.Exists() && !data.{{$list}}[i].{{$clist}}[ci].{{toGoName .TfName}}.IsNull() {
+ data.{{$list}}[i].{{$clist}}[ci].{{toGoName .TfName}} = helpers.GetStringSetXML(value.Array())
+ } else {
+ data.{{$list}}[i].{{$clist}}[ci].{{toGoName .TfName}} = types.SetNull(types.StringType)
+ }
+ {{- else if eq .Type "Int64Set"}}
+ if value := helpers.GetFromXPath(cr, "{{.XPath}}"); value.Exists() && !data.{{$list}}[i].{{$clist}}[ci].{{toGoName .TfName}}.IsNull() {
+ data.{{$list}}[i].{{$clist}}[ci].{{toGoName .TfName}} = helpers.GetInt64SetXML(value.Array())
+ } else {
+ data.{{$list}}[i].{{$clist}}[ci].{{toGoName .TfName}} = types.SetNull(types.Int64Type)
+ }
+ {{- end}}
+ {{- end}}
+ {{- end}}
+ }
+ {{- end}}
+ {{- end}}
+ {{- end}}
+ }
+ {{- end}}
+ {{- end}}
+ {{- end}}
+}
+
+// End of section. //template:end updateFromBodyXML
+
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBody
+
+func (data *{{camelCase .Name}}) fromBody(ctx context.Context, res gjson.Result) {
+{{- define "fromBodyTemplate"}}
+ {{- $name := camelCase .Name}}
+ prefix := helpers.LastElement(data.getPath()) + "."
+ if res.Get(helpers.LastElement(data.getPath())).IsArray() {
+ prefix += "0."
+ }
+ {{- range .Attributes}}
+ {{- $cname := toGoName .TfName}}
+ {{- if and (not .Reference) (not .Id)}}
+ {{- if eq .Type "Int64"}}
+ if value := res.Get(prefix+"{{toDotPath .XPath}}"); value.Exists() {
+ data.{{toGoName .TfName}} = types.Int64Value(value.Int())
+ }
+ {{- else if eq .Type "Float64"}}
+ if value := res.Get(prefix+"{{toDotPath .XPath}}"); value.Exists() {
+ data.{{toGoName .TfName}} = types.Float64Value(value.Float())
+ }
+ {{- else if eq .Type "Bool"}}
+ if value := res.Get(prefix+"{{toDotPath .XPath}}"); value.Exists() {
+ {{- if eq .TypeYangBool "boolean"}}
+ data.{{toGoName .TfName}} = types.BoolValue(value.Bool())
+ {{- else}}
+ data.{{toGoName .TfName}} = types.BoolValue(true)
+ {{- end}}
+ } else {
+ {{- if eq .TypeYangBool "boolean"}}
+ data.{{toGoName .TfName}} = types.BoolNull()
+ {{- else}}
+ data.{{toGoName .TfName}} = types.BoolValue(false)
+ {{- end}}
+ }
+ {{- else if eq .Type "String"}}
+ if value := res.Get(prefix+"{{toDotPath .XPath}}"); value.Exists() {
+ data.{{toGoName .TfName}} = types.StringValue(value.String())
+ }
+ {{- else if eq .Type "StringList"}}
+ if value := res.Get(prefix+"{{toDotPath .XPath}}"); value.Exists() {
+ data.{{toGoName .TfName}} = helpers.GetStringList(value.Array())
+ } else {
+ data.{{toGoName .TfName}} = types.ListNull(types.StringType)
+ }
+ {{- else if eq .Type "Int64List"}}
+ if value := res.Get(prefix+"{{toDotPath .XPath}}"); value.Exists() {
+ data.{{toGoName .TfName}} = helpers.GetInt64List(value.Array())
+ } else {
+ data.{{toGoName .TfName}} = types.ListNull(types.Int64Type)
+ }
+ {{- else if eq .Type "StringSet"}}
+ if value := res.Get(prefix+"{{toDotPath .XPath}}"); value.Exists() {
+ data.{{toGoName .TfName}} = helpers.GetStringSet(value.Array())
+ } else {
+ data.{{toGoName .TfName}} = types.SetNull(types.StringType)
+ }
+ {{- else if eq .Type "Int64Set"}}
+ if value := res.Get(prefix+"{{toDotPath .XPath}}"); value.Exists() {
+ data.{{toGoName .TfName}} = helpers.GetInt64Set(value.Array())
+ } else {
+ data.{{toGoName .TfName}} = types.SetNull(types.Int64Type)
+ }
+ {{- else if or (eq .Type "List") (eq .Type "Set")}}
+ if value := res.Get(prefix+"{{toDotPath .XPath}}"); value.Exists() {
+ data.{{toGoName .TfName}} = make([]{{$name}}{{toGoName .TfName}}, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := {{$name}}{{toGoName .TfName}}{}
+ {{- range .Attributes}}
+ {{- if eq .Type "Int64"}}
+ if cValue := v.Get("{{toDotPath .XPath}}"); cValue.Exists() {
+ item.{{toGoName .TfName}} = types.Int64Value(cValue.Int())
+ }
+ {{- else if eq .Type "Float64"}}
+ if cValue := v.Get("{{toDotPath .XPath}}"); cValue.Exists() {
+ item.{{toGoName .TfName}} = types.Float64Value(cValue.Float())
+ }
+ {{- else if eq .Type "Bool"}}
+ if cValue := v.Get("{{toDotPath .XPath}}"); cValue.Exists() {
+ {{- if eq .TypeYangBool "boolean"}}
+ item.{{toGoName .TfName}} = types.BoolValue(cValue.Bool())
+ {{- else}}
+ item.{{toGoName .TfName}} = types.BoolValue(true)
+ {{- end}}
+ } else {
+ {{- if eq .TypeYangBool "boolean"}}
+ item.{{toGoName .TfName}} = types.BoolNull()
+ {{- else}}
+ item.{{toGoName .TfName}} = types.BoolValue(false)
+ {{- end}}
+ }
+ {{- else if eq .Type "String"}}
+ if cValue := v.Get("{{toDotPath .XPath}}"); cValue.Exists() {
+ item.{{toGoName .TfName}} = types.StringValue(cValue.String())
+ }
+ {{- else if eq .Type "StringList"}}
+ if cValue := v.Get("{{toDotPath .XPath}}"); cValue.Exists() {
+ item.{{toGoName .TfName}} = helpers.GetStringList(cValue.Array())
+ } else {
+ item.{{toGoName .TfName}} = types.ListNull(types.StringType)
+ }
+ {{- else if eq .Type "Int64List"}}
+ if cValue := v.Get("{{toDotPath .XPath}}"); cValue.Exists() {
+ item.{{toGoName .TfName}} = helpers.GetInt64List(cValue.Array())
+ } else {
+ item.{{toGoName .TfName}} = types.ListNull(types.Int64Type)
+ }
+ {{- else if eq .Type "StringSet"}}
+ if cValue := v.Get("{{toDotPath .XPath}}"); cValue.Exists() {
+ item.{{toGoName .TfName}} = helpers.GetStringSet(cValue.Array())
+ } else {
+ item.{{toGoName .TfName}} = types.SetNull(types.StringType)
+ }
+ {{- else if eq .Type "Int64Set"}}
+ if cValue := v.Get("{{toDotPath .XPath}}"); cValue.Exists() {
+ item.{{toGoName .TfName}} = helpers.GetInt64Set(cValue.Array())
+ } else {
+ item.{{toGoName .TfName}} = types.SetNull(types.Int64Type)
+ }
+ {{- else if or (eq .Type "List") (eq .Type "Set")}}
+ if cValue := v.Get("{{toDotPath .XPath}}"); cValue.Exists() {
+ item.{{toGoName .TfName}} = make([]{{$name}}{{$cname}}{{toGoName .TfName}}, 0)
+ cValue.ForEach(func(ck, cv gjson.Result) bool {
+ cItem := {{$name}}{{$cname}}{{toGoName .TfName}}{}
+ {{- range .Attributes}}
+ {{- if eq .Type "Int64"}}
+ if ccValue := cv.Get("{{toDotPath .XPath}}"); ccValue.Exists() {
+ cItem.{{toGoName .TfName}} = types.Int64Value(ccValue.Int())
+ }
+ {{- else if eq .Type "Float64"}}
+ if ccValue := cv.Get("{{toDotPath .XPath}}"); ccValue.Exists() {
+ cItem.{{toGoName .TfName}} = types.Float64Value(ccValue.Float())
+ }
+ {{- else if eq .Type "Bool"}}
+ if ccValue := cv.Get("{{toDotPath .XPath}}"); ccValue.Exists() {
+ {{- if eq .TypeYangBool "boolean"}}
+ cItem.{{toGoName .TfName}} = types.BoolValue(ccValue.Bool())
+ {{- else}}
+ cItem.{{toGoName .TfName}} = types.BoolValue(true)
+ {{- end}}
+ } else {
+ {{- if eq .TypeYangBool "boolean"}}
+ cItem.{{toGoName .TfName}} = types.BoolNull()
+ {{- else}}
+ cItem.{{toGoName .TfName}} = types.BoolValue(false)
+ {{- end}}
+ }
+ {{- else if eq .Type "String"}}
+ if ccValue := cv.Get("{{toDotPath .XPath}}"); ccValue.Exists() {
+ cItem.{{toGoName .TfName}} = types.StringValue(ccValue.String())
+ }
+ {{- else if eq .Type "StringList"}}
+ if ccValue := cv.Get("{{toDotPath .XPath}}"); ccValue.Exists() {
+ cItem.{{toGoName .TfName}} = helpers.GetStringList(ccValue.Array())
+ } else {
+ cItem.{{toGoName .TfName}} = types.ListNull(types.StringType)
+ }
+ {{- else if eq .Type "Int64List"}}
+ if ccValue := cv.Get("{{toDotPath .XPath}}"); ccValue.Exists() {
+ cItem.{{toGoName .TfName}} = helpers.GetInt64List(ccValue.Array())
+ } else {
+ cItem.{{toGoName .TfName}} = types.ListNull(types.Int64Type)
+ }
+ {{- else if eq .Type "StringSet"}}
+ if ccValue := cv.Get("{{toDotPath .XPath}}"); ccValue.Exists() {
+ cItem.{{toGoName .TfName}} = helpers.GetStringSet(ccValue.Array())
+ } else {
+ cItem.{{toGoName .TfName}} = types.SetNull(types.StringType)
+ }
+ {{- else if eq .Type "Int64Set"}}
+ if ccValue := cv.Get("{{toDotPath .XPath}}"); ccValue.Exists() {
+ cItem.{{toGoName .TfName}} = helpers.GetInt64Set(ccValue.Array())
+ } else {
+ cItem.{{toGoName .TfName}} = types.SetNull(types.Int64Type)
+ }
+ {{- end}}
+ {{- end}}
+ item.{{toGoName .TfName}} = append(item.{{toGoName .TfName}}, cItem)
+ return true
+ })
+ }
+ {{- end}}
+ {{- end}}
+ data.{{toGoName .TfName}} = append(data.{{toGoName .TfName}}, item)
+ return true
+ })
}
{{- end}}
{{- end}}
{{- end}}
+{{- end}}
+{{- template "fromBodyTemplate" .}}
}
-// End of section. //template:end updateFromBody
+// End of section. //template:end fromBody
-// Section below is generated&owned by "gen/generator.go". //template:begin fromBody
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyData
-func (data *{{camelCase .Name}}) fromBody(ctx context.Context, res gjson.Result) {
-{{- define "fromBodyTemplate"}}
+func (data *{{camelCase .Name}}Data) fromBody(ctx context.Context, res gjson.Result) {
+{{- template "fromBodyTemplate" .}}
+}
+
+// End of section. //template:end fromBodyData
+
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyXML
+
+func (data *{{camelCase .Name}}) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ {{- define "fromBodyXMLTemplate"}}
{{- $name := camelCase .Name}}
- prefix := helpers.LastElement(data.getPath()) + "."
- if res.Get(helpers.LastElement(data.getPath())).IsArray() {
- prefix += "0."
- }
{{- range .Attributes}}
{{- $cname := toGoName .TfName}}
{{- if and (not .Reference) (not .Id)}}
{{- if eq .Type "Int64"}}
- if value := res.Get(prefix+"{{toJsonPath .YangName .XPath}}"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/" + data.getXPath() + "/{{.XPath}}"); value.Exists() {
data.{{toGoName .TfName}} = types.Int64Value(value.Int())
}
{{- else if eq .Type "Float64"}}
- if value := res.Get(prefix+"{{toJsonPath .YangName .XPath}}"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/" + data.getXPath() + "/{{.XPath}}"); value.Exists() {
data.{{toGoName .TfName}} = types.Float64Value(value.Float())
}
{{- else if eq .Type "Bool"}}
- if value := res.Get(prefix+"{{toJsonPath .YangName .XPath}}"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/" + data.getXPath() + "/{{.XPath}}"); value.Exists() {
{{- if eq .TypeYangBool "boolean"}}
data.{{toGoName .TfName}} = types.BoolValue(value.Bool())
{{- else}}
@@ -548,49 +1139,49 @@ func (data *{{camelCase .Name}}) fromBody(ctx context.Context, res gjson.Result)
{{- end}}
}
{{- else if eq .Type "String"}}
- if value := res.Get(prefix+"{{toJsonPath .YangName .XPath}}"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/" + data.getXPath() + "/{{.XPath}}"); value.Exists() {
data.{{toGoName .TfName}} = types.StringValue(value.String())
}
{{- else if eq .Type "StringList"}}
- if value := res.Get(prefix+"{{toJsonPath .YangName .XPath}}"); value.Exists() {
- data.{{toGoName .TfName}} = helpers.GetStringList(value.Array())
+ if value := helpers.GetFromXPath(res, "data/" + data.getXPath() + "/{{.XPath}}"); value.Exists() {
+ data.{{toGoName .TfName}} = helpers.GetStringListXML(value.Array())
} else {
data.{{toGoName .TfName}} = types.ListNull(types.StringType)
}
{{- else if eq .Type "Int64List"}}
- if value := res.Get(prefix+"{{toJsonPath .YangName .XPath}}"); value.Exists() {
- data.{{toGoName .TfName}} = helpers.GetInt64List(value.Array())
+ if value := helpers.GetFromXPath(res, "data/" + data.getXPath() + "/{{.XPath}}"); value.Exists() {
+ data.{{toGoName .TfName}} = helpers.GetInt64ListXML(value.Array())
} else {
data.{{toGoName .TfName}} = types.ListNull(types.Int64Type)
}
{{- else if eq .Type "StringSet"}}
- if value := res.Get(prefix+"{{toJsonPath .YangName .XPath}}"); value.Exists() {
- data.{{toGoName .TfName}} = helpers.GetStringSet(value.Array())
+ if value := helpers.GetFromXPath(res, "data/" + data.getXPath() + "/{{.XPath}}"); value.Exists() {
+ data.{{toGoName .TfName}} = helpers.GetStringSetXML(value.Array())
} else {
data.{{toGoName .TfName}} = types.SetNull(types.StringType)
}
{{- else if eq .Type "Int64Set"}}
- if value := res.Get(prefix+"{{toJsonPath .YangName .XPath}}"); value.Exists() {
- data.{{toGoName .TfName}} = helpers.GetInt64Set(value.Array())
+ if value := helpers.GetFromXPath(res, "data/" + data.getXPath() + "/{{.XPath}}"); value.Exists() {
+ data.{{toGoName .TfName}} = helpers.GetInt64SetXML(value.Array())
} else {
data.{{toGoName .TfName}} = types.SetNull(types.Int64Type)
}
{{- else if or (eq .Type "List") (eq .Type "Set")}}
- if value := res.Get(prefix+"{{toJsonPath .YangName .XPath}}"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/" + data.getXPath() + "/{{.XPath}}"); value.Exists() {
data.{{toGoName .TfName}} = make([]{{$name}}{{toGoName .TfName}}, 0)
- value.ForEach(func(k, v gjson.Result) bool {
+ value.ForEach(func(_ int, v xmldot.Result) bool {
item := {{$name}}{{toGoName .TfName}}{}
{{- range .Attributes}}
{{- if eq .Type "Int64"}}
- if cValue := v.Get("{{toJsonPath .YangName .XPath}}"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "{{.XPath}}"); cValue.Exists() {
item.{{toGoName .TfName}} = types.Int64Value(cValue.Int())
}
{{- else if eq .Type "Float64"}}
- if cValue := v.Get("{{toJsonPath .YangName .XPath}}"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "{{.XPath}}"); cValue.Exists() {
item.{{toGoName .TfName}} = types.Float64Value(cValue.Float())
}
{{- else if eq .Type "Bool"}}
- if cValue := v.Get("{{toJsonPath .YangName .XPath}}"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "{{.XPath}}"); cValue.Exists() {
{{- if eq .TypeYangBool "boolean"}}
item.{{toGoName .TfName}} = types.BoolValue(cValue.Bool())
{{- else}}
@@ -604,49 +1195,49 @@ func (data *{{camelCase .Name}}) fromBody(ctx context.Context, res gjson.Result)
{{- end}}
}
{{- else if eq .Type "String"}}
- if cValue := v.Get("{{toJsonPath .YangName .XPath}}"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "{{.XPath}}"); cValue.Exists() {
item.{{toGoName .TfName}} = types.StringValue(cValue.String())
}
{{- else if eq .Type "StringList"}}
- if cValue := v.Get("{{toJsonPath .YangName .XPath}}"); cValue.Exists() {
- item.{{toGoName .TfName}} = helpers.GetStringList(cValue.Array())
+ if cValue := helpers.GetFromXPath(v, "{{.XPath}}"); cValue.Exists() {
+ item.{{toGoName .TfName}} = helpers.GetStringListXML(cValue.Array())
} else {
item.{{toGoName .TfName}} = types.ListNull(types.StringType)
}
{{- else if eq .Type "Int64List"}}
- if cValue := v.Get("{{toJsonPath .YangName .XPath}}"); cValue.Exists() {
- item.{{toGoName .TfName}} = helpers.GetInt64List(cValue.Array())
+ if cValue := helpers.GetFromXPath(v, "{{.XPath}}"); cValue.Exists() {
+ item.{{toGoName .TfName}} = helpers.GetInt64ListXML(cValue.Array())
} else {
item.{{toGoName .TfName}} = types.ListNull(types.Int64Type)
}
{{- else if eq .Type "StringSet"}}
- if cValue := v.Get("{{toJsonPath .YangName .XPath}}"); cValue.Exists() {
- item.{{toGoName .TfName}} = helpers.GetStringSet(cValue.Array())
+ if cValue := helpers.GetFromXPath(v, "{{.XPath}}"); cValue.Exists() {
+ item.{{toGoName .TfName}} = helpers.GetStringSetXML(cValue.Array())
} else {
item.{{toGoName .TfName}} = types.SetNull(types.StringType)
}
{{- else if eq .Type "Int64Set"}}
- if cValue := v.Get("{{toJsonPath .YangName .XPath}}"); cValue.Exists() {
- item.{{toGoName .TfName}} = helpers.GetInt64Set(cValue.Array())
+ if cValue := helpers.GetFromXPath(v, "{{.XPath}}"); cValue.Exists() {
+ item.{{toGoName .TfName}} = helpers.GetInt64SetXML(cValue.Array())
} else {
item.{{toGoName .TfName}} = types.SetNull(types.Int64Type)
}
{{- else if or (eq .Type "List") (eq .Type "Set")}}
- if cValue := v.Get("{{toJsonPath .YangName .XPath}}"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "{{.XPath}}"); cValue.Exists() {
item.{{toGoName .TfName}} = make([]{{$name}}{{$cname}}{{toGoName .TfName}}, 0)
- cValue.ForEach(func(ck, cv gjson.Result) bool {
+ cValue.ForEach(func(_ int, cv xmldot.Result) bool {
cItem := {{$name}}{{$cname}}{{toGoName .TfName}}{}
{{- range .Attributes}}
{{- if eq .Type "Int64"}}
- if ccValue := cv.Get("{{toJsonPath .YangName .XPath}}"); ccValue.Exists() {
+ if ccValue := helpers.GetFromXPath(cv, "{{.XPath}}"); ccValue.Exists() {
cItem.{{toGoName .TfName}} = types.Int64Value(ccValue.Int())
}
{{- else if eq .Type "Float64"}}
- if ccValue := cv.Get("{{toJsonPath .YangName .XPath}}"); ccValue.Exists() {
+ if ccValue := helpers.GetFromXPath(cv, "{{.XPath}}"); ccValue.Exists() {
cItem.{{toGoName .TfName}} = types.Float64Value(ccValue.Float())
}
{{- else if eq .Type "Bool"}}
- if ccValue := cv.Get("{{toJsonPath .YangName .XPath}}"); ccValue.Exists() {
+ if ccValue := helpers.GetFromXPath(cv, "{{.XPath}}"); ccValue.Exists() {
{{- if eq .TypeYangBool "boolean"}}
cItem.{{toGoName .TfName}} = types.BoolValue(ccValue.Bool())
{{- else}}
@@ -660,30 +1251,30 @@ func (data *{{camelCase .Name}}) fromBody(ctx context.Context, res gjson.Result)
{{- end}}
}
{{- else if eq .Type "String"}}
- if ccValue := cv.Get("{{toJsonPath .YangName .XPath}}"); ccValue.Exists() {
+ if ccValue := helpers.GetFromXPath(cv, "{{.XPath}}"); ccValue.Exists() {
cItem.{{toGoName .TfName}} = types.StringValue(ccValue.String())
}
{{- else if eq .Type "StringList"}}
- if ccValue := cv.Get("{{toJsonPath .YangName .XPath}}"); ccValue.Exists() {
- cItem.{{toGoName .TfName}} = helpers.GetStringList(ccValue.Array())
+ if ccValue := helpers.GetFromXPath(cv, "{{.XPath}}"); ccValue.Exists() {
+ cItem.{{toGoName .TfName}} = helpers.GetStringListXML(ccValue.Array())
} else {
cItem.{{toGoName .TfName}} = types.ListNull(types.StringType)
}
{{- else if eq .Type "Int64List"}}
- if ccValue := cv.Get("{{toJsonPath .YangName .XPath}}"); ccValue.Exists() {
- cItem.{{toGoName .TfName}} = helpers.GetInt64List(ccValue.Array())
+ if ccValue := helpers.GetFromXPath(cv, "{{.XPath}}"); ccValue.Exists() {
+ cItem.{{toGoName .TfName}} = helpers.GetInt64ListXML(ccValue.Array())
} else {
cItem.{{toGoName .TfName}} = types.ListNull(types.Int64Type)
}
{{- else if eq .Type "StringSet"}}
- if ccValue := cv.Get("{{toJsonPath .YangName .XPath}}"); ccValue.Exists() {
- cItem.{{toGoName .TfName}} = helpers.GetStringSet(ccValue.Array())
+ if ccValue := helpers.GetFromXPath(cv, "{{.XPath}}"); ccValue.Exists() {
+ cItem.{{toGoName .TfName}} = helpers.GetStringSetXML(ccValue.Array())
} else {
cItem.{{toGoName .TfName}} = types.SetNull(types.StringType)
}
{{- else if eq .Type "Int64Set"}}
- if ccValue := cv.Get("{{toJsonPath .YangName .XPath}}"); ccValue.Exists() {
- cItem.{{toGoName .TfName}} = helpers.GetInt64Set(ccValue.Array())
+ if ccValue := helpers.GetFromXPath(cv, "{{.XPath}}"); ccValue.Exists() {
+ cItem.{{toGoName .TfName}} = helpers.GetInt64SetXML(ccValue.Array())
} else {
cItem.{{toGoName .TfName}} = types.SetNull(types.Int64Type)
}
@@ -703,18 +1294,18 @@ func (data *{{camelCase .Name}}) fromBody(ctx context.Context, res gjson.Result)
{{- end}}
{{- end}}
{{- end}}
-{{- template "fromBodyTemplate" .}}
+{{- template "fromBodyXMLTemplate" .}}
}
-// End of section. //template:end fromBody
+// End of section. //template:end fromBodyXML
-// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyData
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyDataXML
-func (data *{{camelCase .Name}}Data) fromBody(ctx context.Context, res gjson.Result) {
-{{- template "fromBodyTemplate" .}}
+func (data *{{camelCase .Name}}Data) fromBodyXML(ctx context.Context, res xmldot.Result) {
+{{- template "fromBodyXMLTemplate" .}}
}
-// End of section. //template:end fromBodyData
+// End of section. //template:end fromBodyDataXML
// Section below is generated&owned by "gen/generator.go". //template:begin getDeletedItems
@@ -885,6 +1476,185 @@ func (data *{{camelCase .Name}}) getDeletedItems(ctx context.Context, state {{ca
// End of section. //template:end getDeletedItems
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletedItemsXML
+
+func (data *{{camelCase .Name}}) addDeletedItemsXML(ctx context.Context, state {{camelCase .Name}}, body string) string {
+ b := netconf.NewBody(body)
+ {{- range .Attributes}}
+ {{- if or (eq .Type "StringList") (eq .Type "Int64List") (eq .Type "StringSet") (eq .Type "Int64Set")}}
+ if !state.{{toGoName .TfName}}.IsNull() {
+ if data.{{toGoName .TfName}}.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/{{.XPath}}")
+ } else {
+ var dataValues, stateValues []{{ if or (eq .Type "StringList") (eq .Type "StringSet") }}string{{else}}int{{end}}
+ data.{{toGoName .TfName}}.ElementsAs(ctx, &dataValues, false)
+ state.{{toGoName .TfName}}.ElementsAs(ctx, &stateValues, false)
+ for _, v := range stateValues {
+ found := false
+ for _, vv := range dataValues {
+ if v == vv {
+ found = true
+ break
+ }
+ }
+ if !found {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/{{.XPath}}[.=%v]", v))
+ }
+ }
+ }
+ }
+ {{- else if and (not .Reference) (not .Id) (ne .Type "List") (ne .Type "Set") (not .NoDelete)}}
+ if !state.{{toGoName .TfName}}.IsNull() && data.{{toGoName .TfName}}.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/{{.XPath}}")
+ }
+ {{- else if or (eq .Type "List") (eq .Type "Set")}}
+ {{- $xpath := .XPath}}
+ for i := range state.{{toGoName .TfName}} {
+ {{- $list := (toGoName .TfName)}}
+ stateKeys := [...]string{ {{range .Attributes}}{{if .Id}}"{{.XPath}}", {{end}}{{end}} }
+ stateKeyValues := [...]string{ {{range .Attributes}}{{if .Id}}{{if eq .Type "Int64"}}strconv.FormatInt(state.{{$list}}[i].{{toGoName .TfName}}.ValueInt64(), 10), {{else if eq .Type "Bool"}}strconv.FormatBool(state.{{$list}}[i].{{toGoName .TfName}}.ValueBool()), {{else}}state.{{$list}}[i].{{toGoName .TfName}}.Value{{.Type}}(), {{end}}{{end}}{{end}} }
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
+
+ emptyKeys := true
+ {{- range .Attributes}}
+ {{- if .Id}}
+ if !reflect.ValueOf(state.{{$list}}[i].{{toGoName .TfName}}.Value{{.Type}}()).IsZero() {
+ emptyKeys = false
+ }
+ {{- end}}
+ {{- end}}
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.{{toGoName .TfName}} {
+ found = true
+ {{- range .Attributes}}
+ {{- if .Id}}
+ if state.{{$list}}[i].{{toGoName .TfName}}.Value{{.Type}}() != data.{{$list}}[j].{{toGoName .TfName}}.Value{{.Type}}() {
+ found = false
+ }
+ {{- end}}
+ {{- end}}
+ if found {
+ {{- range .Attributes}}
+ {{- if or (eq .Type "StringList") (eq .Type "Int64List") (eq .Type "StringSet") (eq .Type "Int64Set")}}
+ if !state.{{$list}}[i].{{toGoName .TfName}}.IsNull() {
+ if data.{{$list}}[j].{{toGoName .TfName}}.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/{{$xpath}}%v/{{.XPath}}", predicates))
+ } else {
+ var dataValues, stateValues []{{ if or (eq .Type "StringList") (eq .Type "StringSet") }}string{{else}}int{{end}}
+ data.{{$list}}[i].{{toGoName .TfName}}.ElementsAs(ctx, &dataValues, false)
+ state.{{$list}}[j].{{toGoName .TfName}}.ElementsAs(ctx, &stateValues, false)
+ for _, v := range stateValues {
+ found := false
+ for _, vv := range dataValues {
+ if v == vv {
+ found = true
+ break
+ }
+ }
+ if !found {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/{{$xpath}}%v/{{.XPath}}[.=%v]", predicates, v))
+ }
+ }
+ }
+ }
+ {{- else if and (not .Reference) (not .Id) (ne .Type "List") (ne .Type "Set") (not .NoDelete)}}
+ if !state.{{$list}}[i].{{toGoName .TfName}}.IsNull() && data.{{$list}}[j].{{toGoName .TfName}}.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/{{$xpath}}%v/{{.XPath}}", predicates))
+ }
+ {{- else if or (eq .Type "List") (eq .Type "Set")}}
+ {{- $cXpath := .XPath}}
+ for ci := range state.{{$list}}[i].{{toGoName .TfName}} {
+ {{- $clist := (toGoName .TfName)}}
+ cstateKeys := [...]string{ {{range .Attributes}}{{if .Id}}"{{.XPath}}", {{end}}{{end}} }
+ cstateKeyValues := [...]string{ {{range .Attributes}}{{if .Id}}{{if eq .Type "Int64"}}strconv.FormatInt(state.{{$list}}[i].{{$clist}}[ci].{{toGoName .TfName}}.ValueInt64(), 10), {{else if eq .Type "Bool"}}strconv.FormatBool(state.{{$list}}[i].{{$clist}}[ci].{{toGoName .TfName}}.ValueBool()), {{else}}state.{{$list}}[i].{{$clist}}[ci].{{toGoName .TfName}}.Value{{.Type}}(), {{end}}{{end}}{{end}} }
+ cpredicates := ""
+ for i := range cstateKeys {
+ cpredicates += fmt.Sprintf("[%s='%s']", cstateKeys[i], cstateKeyValues[i])
+ }
+
+ cemptyKeys := true
+ {{- range .Attributes}}
+ {{- if .Id}}
+ if !reflect.ValueOf(state.{{$list}}[i].{{$clist}}[ci].{{toGoName .TfName}}.Value{{.Type}}()).IsZero() {
+ cemptyKeys = false
+ }
+ {{- end}}
+ {{- end}}
+ if cemptyKeys {
+ continue
+ }
+
+ found := false
+ for cj := range data.{{$list}}[j].{{toGoName .TfName}} {
+ found = true
+ {{- range .Attributes}}
+ {{- if .Id}}
+ if state.{{$list}}[i].{{$clist}}[ci].{{toGoName .TfName}}.Value{{.Type}}() != data.{{$list}}[j].{{$clist}}[cj].{{toGoName .TfName}}.Value{{.Type}}() {
+ found = false
+ }
+ {{- end}}
+ {{- end}}
+ if found {
+ {{- range .Attributes}}
+ {{- if or (eq .Type "StringList") (eq .Type "Int64List") (eq .Type "StringSet") (eq .Type "Int64Set")}}
+ if !state.{{$list}}[i].{{$clist}}[ci].{{toGoName .TfName}}.IsNull() {
+ if data.{{$list}}[j].{{$clist}}[cj].{{toGoName .TfName}}.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/{{$xpath}}%v/{{$cXpath}}%v/{{.XPath}}", predicates, cpredicates))
+ } else {
+ var dataValues, stateValues []{{ if or (eq .Type "StringList") (eq .Type "StringSet") }}string{{else}}int{{end}}
+ data.{{$list}}[i].{{$clist}}[ci].{{toGoName .TfName}}.ElementsAs(ctx, &dataValues, false)
+ state.{{$list}}[j].{{$clist}}[cj].{{toGoName .TfName}}.ElementsAs(ctx, &stateValues, false)
+ for _, v := range stateValues {
+ found := false
+ for _, vv := range dataValues {
+ if v == vv {
+ found = true
+ break
+ }
+ }
+ if !found {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/{{$xpath}}%v/{{$cXpath}}%v/{{.XPath}}=[.%v]", predicates, cpredicates, v))
+ }
+ }
+ }
+ }
+ {{- else if and (not .Reference) (not .Id) (ne .Type "List") (ne .Type "Set") (not .NoDelete)}}
+ if !state.{{$list}}[i].{{$clist}}[ci].{{toGoName .TfName}}.IsNull() && data.{{$list}}[j].{{$clist}}[cj].{{toGoName .TfName}}.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/{{$xpath}}%v/{{$cXpath}}%v/{{.XPath}}", predicates, cpredicates))
+ }
+ {{- end}}
+ {{- end}}
+ break
+ }
+ }
+ if !found {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/{{$xpath}}%v/{{.XPath}}%v", predicates, cpredicates))
+ }
+ }
+ {{- end}}
+ {{- end}}
+ break
+ }
+ }
+ if !found {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/{{.XPath}}%v", predicates))
+ }
+ }
+ {{- end}}
+ {{- end}}
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletedItemsXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin getEmptyLeafsDelete
func (data *{{camelCase .Name}}) getEmptyLeafsDelete(ctx context.Context) []string {
@@ -892,7 +1662,7 @@ func (data *{{camelCase .Name}}) getEmptyLeafsDelete(ctx context.Context) []stri
{{- range reverseAttributes .Attributes}}
{{- if and (eq .Type "Bool") (ne .TypeYangBool "boolean")}}
if !data.{{toGoName .TfName}}.IsNull() && !data.{{toGoName .TfName}}.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/{{getXPath .YangName .XPath}}", data.getPath()))
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/{{.XPath}}", data.getPath()))
}
{{- end}}
{{- if or (eq .Type "List") (eq .Type "Set")}}
@@ -921,7 +1691,7 @@ func (data *{{camelCase .Name}}) getEmptyLeafsDelete(ctx context.Context) []stri
{{- range reverseAttributes .Attributes}}
{{- if and (eq .Type "Bool") (ne .TypeYangBool "boolean")}}
if !data.{{$list}}[i].{{$clist}}[ci].{{toGoName .TfName}}.IsNull() && !data.{{$list}}[i].{{$clist}}[ci].{{toGoName .TfName}}.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/{{$yangName}}=%v/{{$cyangName}}=%v/{{getXPath .YangName .XPath}}", data.getPath(), strings.Join(keyValues[:], ","), strings.Join(ckeyValues[:], ",")))
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/{{$yangName}}=%v/{{$cyangName}}=%v/{{.XPath}}", data.getPath(), strings.Join(keyValues[:], ","), strings.Join(ckeyValues[:], ",")))
}
{{- end}}
{{- end}}
@@ -953,7 +1723,7 @@ func (data *{{camelCase .Name}}) getDeletePaths(ctx context.Context) []string {
{{- $list := (toGoName .TfName)}}
keyValues := [...]string{ {{range .Attributes}}{{if .Id}}{{if eq .Type "Int64"}}strconv.FormatInt(data.{{$list}}[i].{{toGoName .TfName}}.ValueInt64(), 10), {{else if eq .Type "Bool"}}strconv.FormatBool(data.{{$list}}[i].{{toGoName .TfName}}.ValueBool()), {{else}}data.{{$list}}[i].{{toGoName .TfName}}.Value{{.Type}}(), {{end}}{{end}}{{end}} }
- deletePaths = append(deletePaths, fmt.Sprintf("%v/{{getXPath .YangName .XPath}}=%v", data.getPath(), strings.Join(keyValues[:], ",")))
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/{{.XPath}}=%v", data.getPath(), strings.Join(keyValues[:], ",")))
}
{{- end}}
{{- end}}
@@ -962,3 +1732,32 @@ func (data *{{camelCase .Name}}) getDeletePaths(ctx context.Context) []string {
}
// End of section. //template:end getDeletePaths
+
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletePathsXML
+
+func (data *{{camelCase .Name}}) addDeletePathsXML(ctx context.Context, body string) string {
+ b := netconf.NewBody(body)
+ {{- range .Attributes}}
+ {{- if and (not .Reference) (not .Id) (ne .Type "List") (ne .Type "Set") (not .NoDelete)}}
+ if !data.{{toGoName .TfName}}.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/{{.XPath}}")
+ }
+ {{- else if and (or (eq .Type "List") (eq .Type "Set")) (not .NoDelete)}}
+ for i := range data.{{toGoName .TfName}} {
+ {{- $list := (toGoName .TfName)}}
+ keys := [...]string{ {{range .Attributes}}{{if .Id}}"{{.XPath}}", {{end}}{{end}} }
+ keyValues := [...]string{ {{range .Attributes}}{{if .Id}}{{if eq .Type "Int64"}}strconv.FormatInt(data.{{$list}}[i].{{toGoName .TfName}}.ValueInt64(), 10), {{else if eq .Type "Bool"}}strconv.FormatBool(data.{{$list}}[i].{{toGoName .TfName}}.ValueBool()), {{else}}data.{{$list}}[i].{{toGoName .TfName}}.Value{{.Type}}(), {{end}}{{end}}{{end}} }
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/{{.XPath}}%v", predicates))
+ }
+ {{- end}}
+ {{- end}}
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletePathsXML
diff --git a/gen/templates/provider.go b/gen/templates/provider.go
index 3b35b6f1..df40b78a 100644
--- a/gen/templates/provider.go
+++ b/gen/templates/provider.go
@@ -23,18 +23,25 @@ package provider
// Section below is generated&owned by "gen/generator.go". //template:begin provider
import (
"context"
+ "fmt"
"os"
+ "slices"
"strconv"
+ "strings"
+ "sync"
+ "time"
+ "github.com/CiscoDevNet/terraform-provider-iosxe/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/datasource"
"github.com/hashicorp/terraform-plugin-framework/provider"
"github.com/hashicorp/terraform-plugin-framework/provider/schema"
"github.com/hashicorp/terraform-plugin-framework/resource"
"github.com/hashicorp/terraform-plugin-framework/schema/validator"
"github.com/hashicorp/terraform-plugin-framework/types"
+ "github.com/netascode/go-netconf"
"github.com/netascode/go-restconf"
- "github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
)
const (
@@ -51,19 +58,23 @@ type IosxeProvider struct {
// IosxeProviderModel describes the provider data model.
type IosxeProviderModel struct {
- Username types.String `tfsdk:"username"`
- Password types.String `tfsdk:"password"`
- URL types.String `tfsdk:"url"`
- Insecure types.Bool `tfsdk:"insecure"`
- Retries types.Int64 `tfsdk:"retries"`
- LockReleaseTimeout types.Int64 `tfsdk:"lock_release_timeout"`
- SelectedDevices types.List `tfsdk:"selected_devices"`
- Devices []IosxeProviderModelDevice `tfsdk:"devices"`
+ Username types.String `tfsdk:"username"`
+ Password types.String `tfsdk:"password"`
+ URL types.String `tfsdk:"url"`
+ Host types.String `tfsdk:"host"`
+ Insecure types.Bool `tfsdk:"insecure"`
+ Protocol types.String `tfsdk:"protocol"`
+ Retries types.Int64 `tfsdk:"retries"`
+ LockReleaseTimeout types.Int64 `tfsdk:"lock_release_timeout"`
+ ReuseConnection types.Bool `tfsdk:"reuse_connection"`
+ SelectedDevices types.List `tfsdk:"selected_devices"`
+ Devices []IosxeProviderModelDevice `tfsdk:"devices"`
}
type IosxeProviderModelDevice struct {
Name types.String `tfsdk:"name"`
URL types.String `tfsdk:"url"`
+ Host types.String `tfsdk:"host"`
Managed types.Bool `tfsdk:"managed"`
}
@@ -73,8 +84,13 @@ type IosxeProviderData struct {
}
type IosxeProviderDataDevice struct {
- Client *restconf.Client
- Managed bool
+ RestconfClient *restconf.Client
+ NetconfClient *netconf.Client
+ Protocol string
+ ReuseConnection bool
+ Managed bool
+ NetconfWriteMutex sync.Mutex // Serializes NETCONF write operations
+ NetconfConnMutex sync.Mutex // Serializes NETCONF connection management (Reopen/Close)
}
func (p *IosxeProvider) Metadata(ctx context.Context, req provider.MetadataRequest, resp *provider.MetadataResponse) {
@@ -95,13 +111,25 @@ func (p *IosxeProvider) Schema(ctx context.Context, req provider.SchemaRequest,
Sensitive: true,
},
"url": schema.StringAttribute{
- MarkdownDescription: "URL of the Cisco IOS-XE device. Optionally a port can be added with `:12345`. The default port is `443`. This can also be set as the IOSXE_URL environment variable.",
+ MarkdownDescription: "URL of the Cisco IOS-XE device for RESTCONF protocol. Optionally a port can be added with `:12345`. The default port is `443`. This can also be set as the IOSXE_URL environment variable. **Deprecated: Use `host` instead for protocol-agnostic configuration.**",
+ Optional: true,
+ DeprecationMessage: "Use 'host' attribute instead for protocol-agnostic configuration",
+ },
+ "host": schema.StringAttribute{
+ MarkdownDescription: "Hostname or IP address of the Cisco IOS-XE device. Optionally a port can be added with `:port`. Default port is `443` for RESTCONF and `830` for NETCONF. This can also be set as the IOSXE_HOST environment variable.",
Optional: true,
},
"insecure": schema.BoolAttribute{
MarkdownDescription: "Allow insecure HTTPS client. This can also be set as the IOSXE_INSECURE environment variable. Defaults to `true`.",
Optional: true,
},
+ "protocol": schema.StringAttribute{
+ MarkdownDescription: "Protocol to use for device communication. Either `restconf` (HTTPS) or `netconf` (SSH). This can also be set as the IOSXE_PROTOCOL environment variable. Defaults to `restconf`.",
+ Optional: true,
+ Validators: []validator.String{
+ stringvalidator.OneOf("restconf", "netconf"),
+ },
+ },
"retries": schema.Int64Attribute{
MarkdownDescription: "Number of retries for REST API calls. This can also be set as the IOSXE_RETRIES environment variable. Defaults to `10`.",
Optional: true,
@@ -116,6 +144,10 @@ func (p *IosxeProvider) Schema(ctx context.Context, req provider.SchemaRequest,
int64validator.Between(0, 600),
},
},
+ "reuse_connection": schema.BoolAttribute{
+ MarkdownDescription: "Keep NETCONF connections open between operations for better performance. When disabled, connections are closed and reopened for each operation. Only applies to NETCONF protocol. This can also be set as the IOSXE_REUSE_CONNECTION environment variable. Defaults to `true`.",
+ Optional: true,
+ },
"selected_devices": schema.ListAttribute{
MarkdownDescription: "This can be used to select a list of devices to manage from the `devices` list. Selected devices will be managed while other devices will be skipped and their state will be frozen. This can be used to deploy changes to a subset of devices. Defaults to all devices.",
Optional: true,
@@ -131,8 +163,13 @@ func (p *IosxeProvider) Schema(ctx context.Context, req provider.SchemaRequest,
Required: true,
},
"url": schema.StringAttribute{
- MarkdownDescription: "URL of the Cisco IOS-XE device.",
- Required: true,
+ MarkdownDescription: "URL of the Cisco IOS-XE device for RESTCONF protocol. **Deprecated: Use `host` instead.**",
+ Optional: true,
+ DeprecationMessage: "Use 'host' attribute instead",
+ },
+ "host": schema.StringAttribute{
+ MarkdownDescription: "Hostname or IP address of the Cisco IOS-XE device. Optionally a port can be added with `:port`.",
+ Optional: true,
},
"managed": schema.BoolAttribute{
MarkdownDescription: "Enable or disable device management. This can be used to temporarily skip a device due to maintainance for example. Defaults to `true`.",
@@ -206,31 +243,80 @@ func (p *IosxeProvider) Configure(ctx context.Context, req provider.ConfigureReq
return
}
- // User must provide a username to the provider
- var url string
- if config.URL.IsUnknown() {
- // Cannot connect to client with an unknown value
+ // Determine protocol
+ var protocol string
+ if config.Protocol.IsUnknown() {
resp.Diagnostics.AddWarning(
"Unable to create client",
- "Cannot use unknown value as url",
+ "Cannot use unknown value as protocol",
)
return
}
- if config.URL.IsNull() {
- url = os.Getenv("IOSXE_URL")
- if url == "" && len(config.Devices) > 0 {
- url = config.Devices[0].URL.ValueString()
+ if config.Protocol.IsNull() {
+ protocol = os.Getenv("IOSXE_PROTOCOL")
+ if protocol == "" {
+ protocol = "restconf" // default
}
} else {
- url = config.URL.ValueString()
+ protocol = config.Protocol.ValueString()
}
- if url == "" {
- // Error vs warning - empty value must stop execution
+ // Validate protocol
+ if protocol != "restconf" && protocol != "netconf" {
resp.Diagnostics.AddError(
- "Unable to find url",
- "URL cannot be an empty string",
+ "Invalid protocol",
+ fmt.Sprintf("Protocol must be 'restconf' or 'netconf', got: %s", protocol),
+ )
+ return
+ }
+
+ // User must provide a host or url to the provider
+ var host string
+ if config.Host.IsUnknown() && config.URL.IsUnknown() {
+ resp.Diagnostics.AddWarning(
+ "Unable to create client",
+ "Cannot use unknown value as host or url",
+ )
+ return
+ }
+
+ // Priority: host > url > IOSXE_HOST env > IOSXE_URL env > first device
+ if !config.Host.IsNull() {
+ host = config.Host.ValueString()
+ } else if !config.URL.IsNull() {
+ host = config.URL.ValueString()
+ // Strip https:// prefix for NETCONF
+ if protocol == "netconf" {
+ host = strings.TrimPrefix(host, "https://")
+ host = strings.TrimPrefix(host, "http://")
+ }
+ } else {
+ host = os.Getenv("IOSXE_HOST")
+ if host == "" {
+ host = os.Getenv("IOSXE_URL")
+ if protocol == "netconf" {
+ host = strings.TrimPrefix(host, "https://")
+ host = strings.TrimPrefix(host, "http://")
+ }
+ }
+ if host == "" && len(config.Devices) > 0 {
+ if !config.Devices[0].Host.IsNull() {
+ host = config.Devices[0].Host.ValueString()
+ } else {
+ host = config.Devices[0].URL.ValueString()
+ if protocol == "netconf" {
+ host = strings.TrimPrefix(host, "https://")
+ host = strings.TrimPrefix(host, "http://")
+ }
+ }
+ }
+ }
+
+ if host == "" {
+ resp.Diagnostics.AddError(
+ "Unable to find host",
+ "Host or URL cannot be an empty string",
)
return
}
@@ -298,6 +384,26 @@ func (p *IosxeProvider) Configure(ctx context.Context, req provider.ConfigureReq
lockReleaseTimeout = config.LockReleaseTimeout.ValueInt64()
}
+ var reuseConnection bool
+ if config.ReuseConnection.IsUnknown() {
+ resp.Diagnostics.AddWarning(
+ "Unable to create client",
+ "Cannot use unknown value as reuseConnection",
+ )
+ return
+ }
+
+ if config.ReuseConnection.IsNull() {
+ reuseConnectionStr := os.Getenv("IOSXE_REUSE_CONNECTION")
+ if reuseConnectionStr == "" {
+ reuseConnection = true
+ } else {
+ reuseConnection, _ = strconv.ParseBool(reuseConnectionStr)
+ }
+ } else {
+ reuseConnection = config.ReuseConnection.ValueBool()
+ }
+
var selectedDevices []string
if config.SelectedDevices.IsUnknown() {
// Cannot connect to client with an unknown value
@@ -321,15 +427,52 @@ func (p *IosxeProvider) Configure(ctx context.Context, req provider.ConfigureReq
data := IosxeProviderData{}
data.Devices = make(map[string]*IosxeProviderDataDevice)
- c, err := restconf.NewClient(url, username, password, insecure, restconf.MaxRetries(int(retries)), restconf.SkipDiscovery("/restconf", true), restconf.LockReleaseTimeout(int(lockReleaseTimeout)))
- if err != nil {
- resp.Diagnostics.AddError(
- "Unable to create client",
- "Unable to create restconf client:\n\n"+err.Error(),
- )
- return
+ // Create default device client based on protocol
+ if protocol == "restconf" {
+ // For RESTCONF, add https:// prefix if not present
+ url := host
+ if !strings.HasPrefix(url, "https://") && !strings.HasPrefix(url, "http://") {
+ url = "https://" + url
+ }
+ c, err := restconf.NewClient(url, username, password, insecure, restconf.MaxRetries(int(retries)), restconf.SkipDiscovery("/restconf", true), restconf.LockReleaseTimeout(int(lockReleaseTimeout)))
+ if err != nil {
+ resp.Diagnostics.AddError(
+ "Unable to create RESTCONF client",
+ "Unable to create RESTCONF client:\n\n"+err.Error(),
+ )
+ return
+ }
+ data.Devices[""] = &IosxeProviderDataDevice{RestconfClient: c, Protocol: "restconf", ReuseConnection: reuseConnection, Managed: true}
+ } else {
+ // NETCONF
+ logger := helpers.NewTflogAdapter()
+ opts := []func(*netconf.Client){
+ netconf.Username(username),
+ netconf.Password(password),
+ netconf.MaxRetries(int(retries)),
+ netconf.LockReleaseTimeout(time.Duration(lockReleaseTimeout) * time.Second),
+ netconf.WithLogger(logger),
+ }
+ if insecure {
+ opts = append(opts, netconf.InsecureSkipHostKeyVerification())
+ }
+ c, err := netconf.NewClient(host, opts...)
+ if err != nil {
+ resp.Diagnostics.AddError(
+ "Unable to create NETCONF client",
+ "Unable to create NETCONF client:\n\n"+err.Error(),
+ )
+ return
+ }
+ if !reuseConnection {
+ defer func() {
+ if err := c.Close(); err != nil {
+ tflog.Warn(ctx, fmt.Sprintf("Failed to close NETCONF connection: %s", err))
+ }
+ }()
+ }
+ data.Devices[""] = &IosxeProviderDataDevice{NetconfClient: c, Protocol: "netconf", ReuseConnection: reuseConnection, Managed: true}
}
- data.Devices[""] = &IosxeProviderDataDevice{Client: c, Managed: true}
for _, device := range config.Devices {
var managed bool
@@ -346,15 +489,66 @@ func (p *IosxeProvider) Configure(ctx context.Context, req provider.ConfigureReq
managed = device.Managed.ValueBool()
}
}
- c, err := restconf.NewClient(device.URL.ValueString(), username, password, insecure, restconf.MaxRetries(int(retries)), restconf.SkipDiscovery("/restconf", true), restconf.LockReleaseTimeout(int(lockReleaseTimeout)))
- if err != nil {
- resp.Diagnostics.AddError(
- "Unable to create client",
- "Unable to create restconf client:\n\n"+err.Error(),
- )
- return
+
+ // Determine device host (prefer host over url)
+ var deviceHost string
+ if !device.Host.IsNull() {
+ deviceHost = device.Host.ValueString()
+ } else {
+ deviceHost = device.URL.ValueString()
+ // Strip https:// prefix for NETCONF
+ if protocol == "netconf" {
+ deviceHost = strings.TrimPrefix(deviceHost, "https://")
+ deviceHost = strings.TrimPrefix(deviceHost, "http://")
+ }
+ }
+
+ // Create device client based on protocol
+ if protocol == "restconf" {
+ // For RESTCONF, add https:// prefix if not present
+ url := deviceHost
+ if !strings.HasPrefix(url, "https://") && !strings.HasPrefix(url, "http://") {
+ url = "https://" + url
+ }
+ c, err := restconf.NewClient(url, username, password, insecure, restconf.MaxRetries(int(retries)), restconf.SkipDiscovery("/restconf", true), restconf.LockReleaseTimeout(int(lockReleaseTimeout)))
+ if err != nil {
+ resp.Diagnostics.AddError(
+ "Unable to create RESTCONF client",
+ fmt.Sprintf("Unable to create RESTCONF client for device '%s':\n\n%s", device.Name.ValueString(), err.Error()),
+ )
+ return
+ }
+ data.Devices[device.Name.ValueString()] = &IosxeProviderDataDevice{RestconfClient: c, Protocol: "restconf", ReuseConnection: reuseConnection, Managed: managed}
+ } else {
+ // NETCONF
+ logger := helpers.NewTflogAdapter()
+ opts := []func(*netconf.Client){
+ netconf.Username(username),
+ netconf.Password(password),
+ netconf.MaxRetries(int(retries)),
+ netconf.LockReleaseTimeout(time.Duration(lockReleaseTimeout) * time.Second),
+ netconf.WithLogger(logger),
+ }
+ if insecure {
+ opts = append(opts, netconf.InsecureSkipHostKeyVerification())
+ }
+ c, err := netconf.NewClient(deviceHost, opts...)
+ if err != nil {
+ resp.Diagnostics.AddError(
+ "Unable to create NETCONF client",
+ fmt.Sprintf("Unable to create NETCONF client for device '%s':\n\n%s", device.Name.ValueString(), err.Error()),
+ )
+ return
+ }
+ if !reuseConnection {
+ defer func() {
+ if err := c.Close(); err != nil {
+ tflog.Warn(ctx, fmt.Sprintf("Failed to close NETCONF connection: %s", err))
+ }
+ }()
+ }
+ data.Devices[device.Name.ValueString()] = &IosxeProviderDataDevice{NetconfClient: c, Protocol: "netconf", ReuseConnection: reuseConnection, Managed: managed}
}
- data.Devices[device.Name.ValueString()] = &IosxeProviderDataDevice{Client: c, Managed: managed}
}
resp.DataSourceData = &data
@@ -363,7 +557,7 @@ func (p *IosxeProvider) Configure(ctx context.Context, req provider.ConfigureReq
func (p *IosxeProvider) Resources(ctx context.Context) []func() resource.Resource {
return []func() resource.Resource{
- NewRestconfResource,
+ NewYangResource,
NewSaveConfigResource,
NewCliResource,
{{- range .}}
@@ -374,7 +568,7 @@ func (p *IosxeProvider) Resources(ctx context.Context) []func() resource.Resourc
func (p *IosxeProvider) DataSources(ctx context.Context) []func() datasource.DataSource {
return []func() datasource.DataSource{
- NewRestconfDataSource,
+ NewYangDataSource,
{{- range .}}
New{{camelCase .Name}}DataSource,
{{- end}}
diff --git a/gen/templates/resource.go b/gen/templates/resource.go
index 33b0309e..0e2c643f 100644
--- a/gen/templates/resource.go
+++ b/gen/templates/resource.go
@@ -322,37 +322,59 @@ func (r *{{camelCase .Name}}Resource) Create(ctx context.Context, req resource.C
}
if device.Managed {
- // Create object
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ // Create object
+ body := plan.toBody(ctx)
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits{{if .Wait}}, restconf.Wait{{end}}{{if .RequestTimeout}}, restconf.Timeout({{.RequestTimeout}}){{end}})
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
- return
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits{{if .Wait}}, restconf.Wait{{end}}{{if .RequestTimeout}}, restconf.Timeout({{.RequestTimeout}}){{end}})
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
+ return
+ }
+ } else {
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body{{if .Wait}}, restconf.Wait{{end}}{{if .RequestTimeout}}, restconf.Timeout({{.RequestTimeout}}){{end}})
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body{{if .Wait}}, restconf.Wait{{end}}{{if .RequestTimeout}}, restconf.Timeout({{.RequestTimeout}}){{end}})
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i{{if .Wait}}, restconf.Wait{{end}}{{if .RequestTimeout}}, restconf.Timeout({{.RequestTimeout}}){{end}})
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- res, err := device.Client.PatchData(plan.getPathShort(), body{{if .Wait}}, restconf.Wait{{end}}{{if .RequestTimeout}}, restconf.Timeout({{.RequestTimeout}}){{end}})
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body{{if .Wait}}, restconf.Wait{{end}}{{if .RequestTimeout}}, restconf.Timeout({{.RequestTimeout}}){{end}})
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
- return
- }
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i{{if .Wait}}, restconf.Wait{{end}}{{if .RequestTimeout}}, restconf.Timeout({{.RequestTimeout}}){{end}})
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
+ }
+
+ body := plan.toBodyXML(ctx)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
@@ -390,25 +412,51 @@ func (r *{{camelCase .Name}}Resource) Read(ctx context.Context, req resource.Rea
}
if device.Managed {
- res, err := device.Client.GetData(state.Id.ValueString())
- if res.StatusCode == 404 {
- state = {{camelCase .Name}}{Device: state.Device, Id: state.Id}
+ imp, diags := helpers.IsFlagImporting(ctx, req)
+ if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ return
+ }
+
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(state.Id.ValueString())
+ if res.StatusCode == 404 {
+ state = {{camelCase .Name}}{Device: state.Device, Id: state.Id}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
+ return
+ }
+
+ // After `terraform import` we switch to a full read.
+ if imp {
+ state.fromBody(ctx, res.Res)
+ } else {
+ state.updateFromBody(ctx, res.Res)
+ }
+ }
} else {
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
- return
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
}
- imp, diags := helpers.IsFlagImporting(ctx, req)
- if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ filter := helpers.GetXpathFilter(state.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.getPath(), err))
return
}
// After `terraform import` we switch to a full read.
if imp {
- state.fromBody(ctx, res.Res)
+ state.fromBodyXML(ctx, res.Res)
} else {
- state.updateFromBody(ctx, res.Res)
+ state.updateFromBodyXML(ctx, res.Res)
}
}
}
@@ -451,51 +499,74 @@ func (r *{{camelCase .Name}}Resource) Update(ctx context.Context, req resource.U
}
if device.Managed {
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ body := plan.toBody(ctx)
- deletedItems := plan.getDeletedItems(ctx, state)
- tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
+ deletedItems := plan.getDeletedItems(ctx, state)
+ tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- var edits []restconf.YangPatchEdit
- for _, i := range deletedItems {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits{{if .Wait}}, restconf.Wait{{end}}{{if .RequestTimeout}}, restconf.Timeout({{.RequestTimeout}}){{end}})
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
- return
+ if YangPatch {
+ var edits []restconf.YangPatchEdit
+ for _, i := range deletedItems {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits{{if .Wait}}, restconf.Wait{{end}}{{if .RequestTimeout}}, restconf.Timeout({{.RequestTimeout}}){{end}})
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletedItems {
+ res, err := device.RestconfClient.DeleteData(i{{if .Wait}}, restconf.Wait{{end}}{{if .RequestTimeout}}, restconf.Timeout({{.RequestTimeout}}){{end}})
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body{{if .Wait}}, restconf.Wait{{end}}{{if .RequestTimeout}}, restconf.Timeout({{.RequestTimeout}}){{end}})
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body{{if .Wait}}, restconf.Wait{{end}}{{if .RequestTimeout}}, restconf.Timeout({{.RequestTimeout}}){{end}})
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i{{if .Wait}}, restconf.Wait{{end}}{{if .RequestTimeout}}, restconf.Timeout({{.RequestTimeout}}){{end}})
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- for _, i := range deletedItems {
- res, err := device.Client.DeleteData(i{{if .Wait}}, restconf.Wait{{end}}{{if .RequestTimeout}}, restconf.Timeout({{.RequestTimeout}}){{end}})
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
}
- res, err := device.Client.PatchData(plan.getPathShort(), body{{if .Wait}}, restconf.Wait{{end}}{{if .RequestTimeout}}, restconf.Timeout({{.RequestTimeout}}){{end}})
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body{{if .Wait}}, restconf.Wait{{end}}{{if .RequestTimeout}}, restconf.Timeout({{.RequestTimeout}}){{end}})
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+
+ body := plan.toBodyXML(ctx)
+ body = plan.addDeletedItemsXML(ctx, state, body)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
return
}
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i{{if .Wait}}, restconf.Wait{{end}}{{if .RequestTimeout}}, restconf.Timeout({{.RequestTimeout}}){{end}})
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
- return
- }
- }
}
}
@@ -528,6 +599,19 @@ func (r *{{camelCase .Name}}Resource) Delete(ctx context.Context, req resource.D
}
if device.Managed {
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.Protocol == "netconf" && device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
+ }
+
{{- if or .DefaultDeleteAttributes .NoDelete}}
deleteMode := "attributes"
{{- else}}
@@ -542,31 +626,52 @@ func (r *{{camelCase .Name}}Resource) Delete(ctx context.Context, req resource.D
{{- end}}
if deleteMode == "all" {
- res, err := device.Client.DeleteData(state.Id.ValueString(){{if .Wait}}, restconf.Wait{{end}}{{if .RequestTimeout}}, restconf.Timeout({{.RequestTimeout}}){{end}})
- if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
- return
- }
- } else {
- deletePaths := state.getDeletePaths(ctx)
- tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
-
- if YangPatch {
- edits := []restconf.YangPatchEdit{}
- for _, i := range deletePaths {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits{{if .Wait}}, restconf.Wait{{end}}{{if .RequestTimeout}}, restconf.Timeout({{.RequestTimeout}}){{end}})
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.DeleteData(state.Id.ValueString(){{if .Wait}}, restconf.Wait{{end}}{{if .RequestTimeout}}, restconf.Timeout({{.RequestTimeout}}){{end}})
+ if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
return
}
} else {
- for _, i := range deletePaths {
- res, err := device.Client.DeleteData(i{{if .Wait}}, restconf.Wait{{end}}{{if .RequestTimeout}}, restconf.Timeout({{.RequestTimeout}}){{end}})
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // NETCONF
+ body := netconf.Body{}
+ body = helpers.RemoveFromXPath(body, state.getXPath())
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body.Res(), true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
+ }
+ }
+ } else {
+ if device.Protocol == "restconf" {
+ deletePaths := state.getDeletePaths(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
+
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{}
+ for _, i := range deletePaths {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
}
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits{{if .Wait}}, restconf.Wait{{end}}{{if .RequestTimeout}}, restconf.Timeout({{.RequestTimeout}}){{end}})
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletePaths {
+ res, err := device.RestconfClient.DeleteData(i{{if .Wait}}, restconf.Wait{{end}}{{if .RequestTimeout}}, restconf.Timeout({{.RequestTimeout}}){{end}})
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ }
+ }
+ }
+ } else {
+ // NETCONF
+ body := state.addDeletePathsXML(ctx, "")
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
diff --git a/gen/templates/resource_test.go b/gen/templates/resource_test.go
index 462790d7..37ec5375 100644
--- a/gen/templates/resource_test.go
+++ b/gen/templates/resource_test.go
@@ -142,7 +142,7 @@ func iosxe{{camelCase .Name}}ImportStateIdFunc(resourceName string) resource.Imp
{{- if .TestPrerequisites}}
const testAccIosxe{{camelCase .Name}}PrerequisitesConfig = `
{{- range $index, $item := .TestPrerequisites}}
-resource "iosxe_restconf" "PreReq{{$index}}" {
+resource "iosxe_yang" "PreReq{{$index}}" {
path = "{{.Path}}"
{{- if .NoDelete}}
delete = false
@@ -172,7 +172,7 @@ resource "iosxe_restconf" "PreReq{{$index}}" {
]
{{- end}}
{{- if .Dependencies}}
- depends_on = [{{range .Dependencies}}iosxe_restconf.PreReq{{.}}, {{end}}]
+ depends_on = [{{range .Dependencies}}iosxe_yang.PreReq{{.}}, {{end}}]
{{- end}}
}
{{ end}}
@@ -240,7 +240,7 @@ func testAccIosxe{{camelCase .Name}}Config_minimum() string {
{{- end}}
{{- end}}
{{- if .TestPrerequisites}}
- config += ` depends_on = [{{range $index, $item := .TestPrerequisites}}iosxe_restconf.PreReq{{$index}}, {{end}}]` + "\n"
+ config += ` depends_on = [{{range $index, $item := .TestPrerequisites}}iosxe_yang.PreReq{{$index}}, {{end}}]` + "\n"
{{- end}}
config += `}` + "\n"
return config
@@ -311,7 +311,7 @@ func testAccIosxe{{camelCase .Name}}Config_all() string {
{{- end}}
{{- end}}
{{- if .TestPrerequisites}}
- config += ` depends_on = [{{range $index, $item := .TestPrerequisites}}iosxe_restconf.PreReq{{$index}}, {{end}}]` + "\n"
+ config += ` depends_on = [{{range $index, $item := .TestPrerequisites}}iosxe_yang.PreReq{{$index}}, {{end}}]` + "\n"
{{- end}}
config += `}` + "\n"
return config
diff --git a/go.mod b/go.mod
index 02a606a4..a3f4f93c 100644
--- a/go.mod
+++ b/go.mod
@@ -11,7 +11,9 @@ require (
github.com/hashicorp/terraform-plugin-go v0.29.0
github.com/hashicorp/terraform-plugin-log v0.9.0
github.com/hashicorp/terraform-plugin-testing v1.13.3
+ github.com/netascode/go-netconf v0.0.0-20251101145739-5fcf41f8141c
github.com/netascode/go-restconf v0.1.18
+ github.com/netascode/xmldot v0.4.1
github.com/openconfig/goyang v1.6.3
github.com/tidwall/gjson v1.18.0
github.com/tidwall/sjson v1.2.5
@@ -32,6 +34,7 @@ require (
github.com/bgentry/speakeasy v0.1.0 // indirect
github.com/bmatcuk/doublestar/v4 v4.9.1 // indirect
github.com/cloudflare/circl v1.6.1 // indirect
+ github.com/creack/pty v1.1.24 // indirect
github.com/fatih/color v1.18.0 // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/google/go-cmp v0.7.0 // indirect
@@ -68,7 +71,9 @@ require (
github.com/mitchellh/reflectwalk v1.0.2 // indirect
github.com/oklog/run v1.2.0 // indirect
github.com/posener/complete v1.2.3 // indirect
+ github.com/scrapli/scrapligo v1.3.3 // indirect
github.com/shopspring/decimal v1.3.1 // indirect
+ github.com/sirikothe/gotextfsm v1.1.0 // indirect
github.com/spf13/cast v1.5.0 // indirect
github.com/tidwall/match v1.2.0 // indirect
github.com/tidwall/pretty v1.2.1 // indirect
diff --git a/go.sum b/go.sum
index 9c79f361..a57311f5 100644
--- a/go.sum
+++ b/go.sum
@@ -29,6 +29,8 @@ github.com/bufbuild/protocompile v0.14.1 h1:iA73zAf/fyljNjQKwYzUHD6AD4R8KMasmwa/
github.com/bufbuild/protocompile v0.14.1/go.mod h1:ppVdAIhbr2H8asPk6k4pY7t9zB1OU5DoEw9xY/FUi1c=
github.com/cloudflare/circl v1.6.1 h1:zqIqSPIndyBh1bjLVVDHMPpVKqp8Su/V+6MeDzzQBQ0=
github.com/cloudflare/circl v1.6.1/go.mod h1:uddAzsPgqdMAYatqJ0lsjX1oECcQLIlRpzZh3pJrofs=
+github.com/creack/pty v1.1.24 h1:bJrF4RRfyJnbTJqzRLHzcGaZK1NeM5kTC9jGgovnR1s=
+github.com/creack/pty v1.1.24/go.mod h1:08sCNb52WyoAwi2QDyzUCTgcvVFhUzewun7wtTfvcwE=
github.com/cyphar/filepath-securejoin v0.4.1 h1:JyxxyPEaktOD+GAnqIqTf9A8tHyAG22rowi7HkoSU1s=
github.com/cyphar/filepath-securejoin v0.4.1/go.mod h1:Sdj7gXlvMcPZsbhwhQ33GguGLDGQL7h7bg04C/+u9jI=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
@@ -168,8 +170,12 @@ github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RR
github.com/mitchellh/reflectwalk v1.0.0/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw=
github.com/mitchellh/reflectwalk v1.0.2 h1:G2LzWKi524PWgd3mLHV8Y5k7s6XUvT0Gef6zxSIeXaQ=
github.com/mitchellh/reflectwalk v1.0.2/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw=
+github.com/netascode/go-netconf v0.0.0-20251101145739-5fcf41f8141c h1:jRT0aAG1a3RNrCHNmEjMdajzqTDQrvOCgmoEqGAyU80=
+github.com/netascode/go-netconf v0.0.0-20251101145739-5fcf41f8141c/go.mod h1:Kyoh+O9JwZz5taPQyG7glHWAejLFPU250PEFxmZdw5U=
github.com/netascode/go-restconf v0.1.18 h1:N1V/+VfFGaGokhjy0G60G6w4Lyf4OXw84IbM6zkaW2I=
github.com/netascode/go-restconf v0.1.18/go.mod h1:BbFhcp/T59u2AWNN6sxUH0iq4pbkMSK/C//yemPT91c=
+github.com/netascode/xmldot v0.4.1 h1:Uw5qJRHOxUFOOzzcQt3F4+PYgHZC/YneRVU5UGknoqc=
+github.com/netascode/xmldot v0.4.1/go.mod h1:T0zddov+d7Sgam8cpJSOr155HiKyXwY58PE/iiuXbT8=
github.com/oklog/run v1.2.0 h1:O8x3yXwah4A73hJdlrwo/2X6J62gE5qTMusH0dvz60E=
github.com/oklog/run v1.2.0/go.mod h1:mgDbKRSwPhJfesJ4PntqFUbKQRZ50NgmZTSPlFA0YFk=
github.com/openconfig/gnmi v0.14.1 h1:qKMuFvhIRR2/xxCOsStPQ25aKpbMDdWr3kI+nP9bhMs=
@@ -185,11 +191,15 @@ github.com/posener/complete v1.2.3 h1:NP0eAhjcjImqslEwo/1hq7gpajME0fTLTezBKDqfXq
github.com/posener/complete v1.2.3/go.mod h1:WZIdtGGp+qx0sLrYKtIRAruyNpv6hFCicSgv7Sy7s/s=
github.com/rogpeppe/go-internal v1.14.1 h1:UQB4HGPB6osV0SQTLymcB4TgvyWu6ZyliaW0tI/otEQ=
github.com/rogpeppe/go-internal v1.14.1/go.mod h1:MaRKkUm5W0goXpeCfT7UZI6fk/L7L7so1lCWt35ZSgc=
+github.com/scrapli/scrapligo v1.3.3 h1:D9zj1QrOYNYAQ30YT7wfQBINvPGxvs5L5Lz+2LnL7V4=
+github.com/scrapli/scrapligo v1.3.3/go.mod h1:pOWxVyPsQRrWTrkoSSDg05tjOqtWfLffAZtAsCc0w3M=
github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 h1:n661drycOFuPLCN3Uc8sB6B/s6Z4t2xvBgU1htSHuq8=
github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3/go.mod h1:A0bzQcvG0E7Rwjx0REVgAGH58e96+X0MeOfepqsbeW4=
github.com/shopspring/decimal v1.2.0/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o=
github.com/shopspring/decimal v1.3.1 h1:2Usl1nmF/WZucqkFZhnfFYxxxu8LG21F6nPQBE5gKV8=
github.com/shopspring/decimal v1.3.1/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o=
+github.com/sirikothe/gotextfsm v1.1.0 h1:Hd6S3g4383e8b0awZQEPr+d1QPVxxnR/3NU1Kw4dI/Y=
+github.com/sirikothe/gotextfsm v1.1.0/go.mod h1:CJYqpTg9u5VPCoD0VEl9E68prCIiWQD8m457k098DdQ=
github.com/skeema/knownhosts v1.3.1 h1:X2osQ+RAjK76shCbvhHHHVl3ZlgDm8apHEHFqRjnBY8=
github.com/skeema/knownhosts v1.3.1/go.mod h1:r7KTdC8l4uxWRyK2TpQZ/1o5HaSzh06ePQNxPwTcfiY=
github.com/spf13/cast v1.3.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE=
@@ -286,6 +296,8 @@ golang.org/x/telemetry v0.0.0-20251008203120-078029d740a8/go.mod h1:Pi4ztBfryZoJ
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc=
+golang.org/x/term v0.36.0 h1:zMPR+aF8gfksFprF/Nc/rd1wRS1EI6nDBGyWAvDzx2Q=
+golang.org/x/term v0.36.0/go.mod h1:Qu394IJq6V6dCBRgwqshf3mPF85AqzYEzofzRdZkWss=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
diff --git a/internal/provider/data_source_iosxe_aaa.go b/internal/provider/data_source_iosxe_aaa.go
index 19d21663..1b069ef3 100644
--- a/internal/provider/data_source_iosxe_aaa.go
+++ b/internal/provider/data_source_iosxe_aaa.go
@@ -24,6 +24,7 @@ import (
"context"
"fmt"
+ "github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
"github.com/hashicorp/terraform-plugin-framework/path"
@@ -270,16 +271,37 @@ func (d *AAADataSource) Read(ctx context.Context, req datasource.ReadRequest, re
return
}
- res, err := device.Client.GetData(config.getPath())
- if res.StatusCode == 404 {
- config = AAAData{Device: config.Device}
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(config.getPath())
+ if res.StatusCode == 404 {
+ config = AAAData{Device: config.Device}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
+ return
+ }
+
+ config.fromBody(ctx, res.Res)
+ }
} else {
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
+ }
+
+ filter := helpers.GetXpathFilter(config.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
if err != nil {
resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
return
}
- config.fromBody(ctx, res.Res)
+ config.fromBodyXML(ctx, res.Res)
}
config.Id = types.StringValue(config.getPath())
diff --git a/internal/provider/data_source_iosxe_aaa_accounting.go b/internal/provider/data_source_iosxe_aaa_accounting.go
index 139653df..66e7d590 100644
--- a/internal/provider/data_source_iosxe_aaa_accounting.go
+++ b/internal/provider/data_source_iosxe_aaa_accounting.go
@@ -24,6 +24,7 @@ import (
"context"
"fmt"
+ "github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
"github.com/hashicorp/terraform-plugin-framework/path"
@@ -413,16 +414,37 @@ func (d *AAAAccountingDataSource) Read(ctx context.Context, req datasource.ReadR
return
}
- res, err := device.Client.GetData(config.getPath())
- if res.StatusCode == 404 {
- config = AAAAccountingData{Device: config.Device}
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(config.getPath())
+ if res.StatusCode == 404 {
+ config = AAAAccountingData{Device: config.Device}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
+ return
+ }
+
+ config.fromBody(ctx, res.Res)
+ }
} else {
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
+ }
+
+ filter := helpers.GetXpathFilter(config.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
if err != nil {
resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
return
}
- config.fromBody(ctx, res.Res)
+ config.fromBodyXML(ctx, res.Res)
}
config.Id = types.StringValue(config.getPath())
diff --git a/internal/provider/data_source_iosxe_aaa_authentication.go b/internal/provider/data_source_iosxe_aaa_authentication.go
index 0d195495..8b09174e 100644
--- a/internal/provider/data_source_iosxe_aaa_authentication.go
+++ b/internal/provider/data_source_iosxe_aaa_authentication.go
@@ -24,6 +24,7 @@ import (
"context"
"fmt"
+ "github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
"github.com/hashicorp/terraform-plugin-framework/path"
@@ -381,16 +382,37 @@ func (d *AAAAuthenticationDataSource) Read(ctx context.Context, req datasource.R
return
}
- res, err := device.Client.GetData(config.getPath())
- if res.StatusCode == 404 {
- config = AAAAuthenticationData{Device: config.Device}
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(config.getPath())
+ if res.StatusCode == 404 {
+ config = AAAAuthenticationData{Device: config.Device}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
+ return
+ }
+
+ config.fromBody(ctx, res.Res)
+ }
} else {
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
+ }
+
+ filter := helpers.GetXpathFilter(config.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
if err != nil {
resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
return
}
- config.fromBody(ctx, res.Res)
+ config.fromBodyXML(ctx, res.Res)
}
config.Id = types.StringValue(config.getPath())
diff --git a/internal/provider/data_source_iosxe_aaa_authorization.go b/internal/provider/data_source_iosxe_aaa_authorization.go
index 54fa6d15..5925d9e8 100644
--- a/internal/provider/data_source_iosxe_aaa_authorization.go
+++ b/internal/provider/data_source_iosxe_aaa_authorization.go
@@ -24,6 +24,7 @@ import (
"context"
"fmt"
+ "github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
"github.com/hashicorp/terraform-plugin-framework/path"
@@ -381,16 +382,37 @@ func (d *AAAAuthorizationDataSource) Read(ctx context.Context, req datasource.Re
return
}
- res, err := device.Client.GetData(config.getPath())
- if res.StatusCode == 404 {
- config = AAAAuthorizationData{Device: config.Device}
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(config.getPath())
+ if res.StatusCode == 404 {
+ config = AAAAuthorizationData{Device: config.Device}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
+ return
+ }
+
+ config.fromBody(ctx, res.Res)
+ }
} else {
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
+ }
+
+ filter := helpers.GetXpathFilter(config.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
if err != nil {
resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
return
}
- config.fromBody(ctx, res.Res)
+ config.fromBodyXML(ctx, res.Res)
}
config.Id = types.StringValue(config.getPath())
diff --git a/internal/provider/data_source_iosxe_aaa_test.go b/internal/provider/data_source_iosxe_aaa_test.go
index 28fed926..a3ae5dde 100644
--- a/internal/provider/data_source_iosxe_aaa_test.go
+++ b/internal/provider/data_source_iosxe_aaa_test.go
@@ -63,8 +63,8 @@ func TestAccDataSourceIosxeAAA(t *testing.T) {
// Section below is generated&owned by "gen/generator.go". //template:begin testPrerequisites
const testAccDataSourceIosxeAAAPrerequisitesConfig = `
-resource "iosxe_restconf" "PreReq0" {
- path = "Cisco-IOS-XE-native:native/vrf/definition=VRF1"
+resource "iosxe_yang" "PreReq0" {
+ path = "/Cisco-IOS-XE-native:native/vrf/definition[name=VRF1]"
delete = false
attributes = {
"name" = "VRF1"
@@ -104,7 +104,7 @@ func testAccDataSourceIosxeAAAConfig() string {
config += ` ip_tacacs_source_interface_loopback = 0` + "\n"
config += ` vrf = "VRF1"` + "\n"
config += ` }]` + "\n"
- config += ` depends_on = [iosxe_restconf.PreReq0, ]` + "\n"
+ config += ` depends_on = [iosxe_yang.PreReq0, ]` + "\n"
config += `}` + "\n"
config += `
diff --git a/internal/provider/data_source_iosxe_access_list_extended.go b/internal/provider/data_source_iosxe_access_list_extended.go
index 5bdccf28..6468d844 100644
--- a/internal/provider/data_source_iosxe_access_list_extended.go
+++ b/internal/provider/data_source_iosxe_access_list_extended.go
@@ -24,6 +24,7 @@ import (
"context"
"fmt"
+ "github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
"github.com/hashicorp/terraform-plugin-framework/path"
@@ -313,16 +314,37 @@ func (d *AccessListExtendedDataSource) Read(ctx context.Context, req datasource.
return
}
- res, err := device.Client.GetData(config.getPath())
- if res.StatusCode == 404 {
- config = AccessListExtendedData{Device: config.Device}
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(config.getPath())
+ if res.StatusCode == 404 {
+ config = AccessListExtendedData{Device: config.Device}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
+ return
+ }
+
+ config.fromBody(ctx, res.Res)
+ }
} else {
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
+ }
+
+ filter := helpers.GetXpathFilter(config.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
if err != nil {
resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
return
}
- config.fromBody(ctx, res.Res)
+ config.fromBodyXML(ctx, res.Res)
}
config.Id = types.StringValue(config.getPath())
diff --git a/internal/provider/data_source_iosxe_access_list_role_based.go b/internal/provider/data_source_iosxe_access_list_role_based.go
index e705ee76..aa2e2389 100644
--- a/internal/provider/data_source_iosxe_access_list_role_based.go
+++ b/internal/provider/data_source_iosxe_access_list_role_based.go
@@ -24,6 +24,7 @@ import (
"context"
"fmt"
+ "github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
"github.com/hashicorp/terraform-plugin-framework/path"
@@ -285,16 +286,37 @@ func (d *AccessListRoleBasedDataSource) Read(ctx context.Context, req datasource
return
}
- res, err := device.Client.GetData(config.getPath())
- if res.StatusCode == 404 {
- config = AccessListRoleBasedData{Device: config.Device}
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(config.getPath())
+ if res.StatusCode == 404 {
+ config = AccessListRoleBasedData{Device: config.Device}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
+ return
+ }
+
+ config.fromBody(ctx, res.Res)
+ }
} else {
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
+ }
+
+ filter := helpers.GetXpathFilter(config.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
if err != nil {
resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
return
}
- config.fromBody(ctx, res.Res)
+ config.fromBodyXML(ctx, res.Res)
}
config.Id = types.StringValue(config.getPath())
diff --git a/internal/provider/data_source_iosxe_access_list_standard.go b/internal/provider/data_source_iosxe_access_list_standard.go
index 075da855..2b8e9931 100644
--- a/internal/provider/data_source_iosxe_access_list_standard.go
+++ b/internal/provider/data_source_iosxe_access_list_standard.go
@@ -24,6 +24,7 @@ import (
"context"
"fmt"
+ "github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
"github.com/hashicorp/terraform-plugin-framework/path"
@@ -161,16 +162,37 @@ func (d *AccessListStandardDataSource) Read(ctx context.Context, req datasource.
return
}
- res, err := device.Client.GetData(config.getPath())
- if res.StatusCode == 404 {
- config = AccessListStandardData{Device: config.Device}
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(config.getPath())
+ if res.StatusCode == 404 {
+ config = AccessListStandardData{Device: config.Device}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
+ return
+ }
+
+ config.fromBody(ctx, res.Res)
+ }
} else {
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
+ }
+
+ filter := helpers.GetXpathFilter(config.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
if err != nil {
resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
return
}
- config.fromBody(ctx, res.Res)
+ config.fromBodyXML(ctx, res.Res)
}
config.Id = types.StringValue(config.getPath())
diff --git a/internal/provider/data_source_iosxe_arp.go b/internal/provider/data_source_iosxe_arp.go
index 0307213e..cf499591 100644
--- a/internal/provider/data_source_iosxe_arp.go
+++ b/internal/provider/data_source_iosxe_arp.go
@@ -24,6 +24,7 @@ import (
"context"
"fmt"
+ "github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
"github.com/hashicorp/terraform-plugin-framework/path"
@@ -173,16 +174,37 @@ func (d *ARPDataSource) Read(ctx context.Context, req datasource.ReadRequest, re
return
}
- res, err := device.Client.GetData(config.getPath())
- if res.StatusCode == 404 {
- config = ARPData{Device: config.Device}
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(config.getPath())
+ if res.StatusCode == 404 {
+ config = ARPData{Device: config.Device}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
+ return
+ }
+
+ config.fromBody(ctx, res.Res)
+ }
} else {
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
+ }
+
+ filter := helpers.GetXpathFilter(config.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
if err != nil {
resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
return
}
- config.fromBody(ctx, res.Res)
+ config.fromBodyXML(ctx, res.Res)
}
config.Id = types.StringValue(config.getPath())
diff --git a/internal/provider/data_source_iosxe_as_path_access_list.go b/internal/provider/data_source_iosxe_as_path_access_list.go
index 70ba75c2..4d8db4ec 100644
--- a/internal/provider/data_source_iosxe_as_path_access_list.go
+++ b/internal/provider/data_source_iosxe_as_path_access_list.go
@@ -24,6 +24,7 @@ import (
"context"
"fmt"
+ "github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
"github.com/hashicorp/terraform-plugin-framework/path"
@@ -121,16 +122,37 @@ func (d *ASPathAccessListDataSource) Read(ctx context.Context, req datasource.Re
return
}
- res, err := device.Client.GetData(config.getPath())
- if res.StatusCode == 404 {
- config = ASPathAccessListData{Device: config.Device}
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(config.getPath())
+ if res.StatusCode == 404 {
+ config = ASPathAccessListData{Device: config.Device}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
+ return
+ }
+
+ config.fromBody(ctx, res.Res)
+ }
} else {
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
+ }
+
+ filter := helpers.GetXpathFilter(config.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
if err != nil {
resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
return
}
- config.fromBody(ctx, res.Res)
+ config.fromBodyXML(ctx, res.Res)
}
config.Id = types.StringValue(config.getPath())
diff --git a/internal/provider/data_source_iosxe_banner.go b/internal/provider/data_source_iosxe_banner.go
index 3454d2a9..72108d8f 100644
--- a/internal/provider/data_source_iosxe_banner.go
+++ b/internal/provider/data_source_iosxe_banner.go
@@ -24,6 +24,7 @@ import (
"context"
"fmt"
+ "github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
"github.com/hashicorp/terraform-plugin-framework/path"
@@ -117,16 +118,37 @@ func (d *BannerDataSource) Read(ctx context.Context, req datasource.ReadRequest,
return
}
- res, err := device.Client.GetData(config.getPath())
- if res.StatusCode == 404 {
- config = BannerData{Device: config.Device}
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(config.getPath())
+ if res.StatusCode == 404 {
+ config = BannerData{Device: config.Device}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
+ return
+ }
+
+ config.fromBody(ctx, res.Res)
+ }
} else {
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
+ }
+
+ filter := helpers.GetXpathFilter(config.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
if err != nil {
resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
return
}
- config.fromBody(ctx, res.Res)
+ config.fromBodyXML(ctx, res.Res)
}
config.Id = types.StringValue(config.getPath())
diff --git a/internal/provider/data_source_iosxe_bfd.go b/internal/provider/data_source_iosxe_bfd.go
index 3bf03e13..a42a6c04 100644
--- a/internal/provider/data_source_iosxe_bfd.go
+++ b/internal/provider/data_source_iosxe_bfd.go
@@ -24,6 +24,7 @@ import (
"context"
"fmt"
+ "github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
"github.com/hashicorp/terraform-plugin-framework/path"
@@ -297,16 +298,37 @@ func (d *BFDDataSource) Read(ctx context.Context, req datasource.ReadRequest, re
return
}
- res, err := device.Client.GetData(config.getPath())
- if res.StatusCode == 404 {
- config = BFDData{Device: config.Device}
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(config.getPath())
+ if res.StatusCode == 404 {
+ config = BFDData{Device: config.Device}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
+ return
+ }
+
+ config.fromBody(ctx, res.Res)
+ }
} else {
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
+ }
+
+ filter := helpers.GetXpathFilter(config.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
if err != nil {
resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
return
}
- config.fromBody(ctx, res.Res)
+ config.fromBodyXML(ctx, res.Res)
}
config.Id = types.StringValue(config.getPath())
diff --git a/internal/provider/data_source_iosxe_bfd_template_multi_hop.go b/internal/provider/data_source_iosxe_bfd_template_multi_hop.go
index f2aab0a1..f1ac3726 100644
--- a/internal/provider/data_source_iosxe_bfd_template_multi_hop.go
+++ b/internal/provider/data_source_iosxe_bfd_template_multi_hop.go
@@ -24,6 +24,7 @@ import (
"context"
"fmt"
+ "github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
"github.com/hashicorp/terraform-plugin-framework/path"
@@ -185,16 +186,37 @@ func (d *BFDTemplateMultiHopDataSource) Read(ctx context.Context, req datasource
return
}
- res, err := device.Client.GetData(config.getPath())
- if res.StatusCode == 404 {
- config = BFDTemplateMultiHopData{Device: config.Device}
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(config.getPath())
+ if res.StatusCode == 404 {
+ config = BFDTemplateMultiHopData{Device: config.Device}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
+ return
+ }
+
+ config.fromBody(ctx, res.Res)
+ }
} else {
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
+ }
+
+ filter := helpers.GetXpathFilter(config.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
if err != nil {
resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
return
}
- config.fromBody(ctx, res.Res)
+ config.fromBodyXML(ctx, res.Res)
}
config.Id = types.StringValue(config.getPath())
diff --git a/internal/provider/data_source_iosxe_bfd_template_single_hop.go b/internal/provider/data_source_iosxe_bfd_template_single_hop.go
index 4a022d4d..80e0071a 100644
--- a/internal/provider/data_source_iosxe_bfd_template_single_hop.go
+++ b/internal/provider/data_source_iosxe_bfd_template_single_hop.go
@@ -24,6 +24,7 @@ import (
"context"
"fmt"
+ "github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
"github.com/hashicorp/terraform-plugin-framework/path"
@@ -165,16 +166,37 @@ func (d *BFDTemplateSingleHopDataSource) Read(ctx context.Context, req datasourc
return
}
- res, err := device.Client.GetData(config.getPath())
- if res.StatusCode == 404 {
- config = BFDTemplateSingleHopData{Device: config.Device}
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(config.getPath())
+ if res.StatusCode == 404 {
+ config = BFDTemplateSingleHopData{Device: config.Device}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
+ return
+ }
+
+ config.fromBody(ctx, res.Res)
+ }
} else {
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
+ }
+
+ filter := helpers.GetXpathFilter(config.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
if err != nil {
resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
return
}
- config.fromBody(ctx, res.Res)
+ config.fromBodyXML(ctx, res.Res)
}
config.Id = types.StringValue(config.getPath())
diff --git a/internal/provider/data_source_iosxe_bgp.go b/internal/provider/data_source_iosxe_bgp.go
index 1ffc3779..9bbf0163 100644
--- a/internal/provider/data_source_iosxe_bgp.go
+++ b/internal/provider/data_source_iosxe_bgp.go
@@ -24,6 +24,7 @@ import (
"context"
"fmt"
+ "github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
"github.com/hashicorp/terraform-plugin-framework/path"
@@ -121,16 +122,37 @@ func (d *BGPDataSource) Read(ctx context.Context, req datasource.ReadRequest, re
return
}
- res, err := device.Client.GetData(config.getPath())
- if res.StatusCode == 404 {
- config = BGPData{Device: config.Device}
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(config.getPath())
+ if res.StatusCode == 404 {
+ config = BGPData{Device: config.Device}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
+ return
+ }
+
+ config.fromBody(ctx, res.Res)
+ }
} else {
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
+ }
+
+ filter := helpers.GetXpathFilter(config.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
if err != nil {
resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
return
}
- config.fromBody(ctx, res.Res)
+ config.fromBodyXML(ctx, res.Res)
}
config.Id = types.StringValue(config.getPath())
diff --git a/internal/provider/data_source_iosxe_bgp_address_family_ipv4.go b/internal/provider/data_source_iosxe_bgp_address_family_ipv4.go
index 275fc961..ad542180 100644
--- a/internal/provider/data_source_iosxe_bgp_address_family_ipv4.go
+++ b/internal/provider/data_source_iosxe_bgp_address_family_ipv4.go
@@ -24,6 +24,7 @@ import (
"context"
"fmt"
+ "github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
"github.com/hashicorp/terraform-plugin-framework/path"
@@ -213,16 +214,37 @@ func (d *BGPAddressFamilyIPv4DataSource) Read(ctx context.Context, req datasourc
return
}
- res, err := device.Client.GetData(config.getPath())
- if res.StatusCode == 404 {
- config = BGPAddressFamilyIPv4Data{Device: config.Device}
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(config.getPath())
+ if res.StatusCode == 404 {
+ config = BGPAddressFamilyIPv4Data{Device: config.Device}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
+ return
+ }
+
+ config.fromBody(ctx, res.Res)
+ }
} else {
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
+ }
+
+ filter := helpers.GetXpathFilter(config.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
if err != nil {
resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
return
}
- config.fromBody(ctx, res.Res)
+ config.fromBodyXML(ctx, res.Res)
}
config.Id = types.StringValue(config.getPath())
diff --git a/internal/provider/data_source_iosxe_bgp_address_family_ipv4_test.go b/internal/provider/data_source_iosxe_bgp_address_family_ipv4_test.go
index 9cd23f02..037cdcbe 100644
--- a/internal/provider/data_source_iosxe_bgp_address_family_ipv4_test.go
+++ b/internal/provider/data_source_iosxe_bgp_address_family_ipv4_test.go
@@ -65,8 +65,8 @@ func TestAccDataSourceIosxeBGPAddressFamilyIPv4(t *testing.T) {
// Section below is generated&owned by "gen/generator.go". //template:begin testPrerequisites
const testAccDataSourceIosxeBGPAddressFamilyIPv4PrerequisitesConfig = `
-resource "iosxe_restconf" "PreReq0" {
- path = "Cisco-IOS-XE-native:native/router/Cisco-IOS-XE-bgp:bgp=65000"
+resource "iosxe_yang" "PreReq0" {
+ path = "/Cisco-IOS-XE-native:native/router/Cisco-IOS-XE-bgp:bgp[id=65000]"
attributes = {
"id" = "65000"
}
@@ -108,7 +108,7 @@ func testAccDataSourceIosxeBGPAddressFamilyIPv4Config() string {
config += ` ipv4_unicast_distance_bgp_external = 20` + "\n"
config += ` ipv4_unicast_distance_bgp_internal = 200` + "\n"
config += ` ipv4_unicast_distance_bgp_local = 200` + "\n"
- config += ` depends_on = [iosxe_restconf.PreReq0, ]` + "\n"
+ config += ` depends_on = [iosxe_yang.PreReq0, ]` + "\n"
config += `}` + "\n"
config += `
diff --git a/internal/provider/data_source_iosxe_bgp_address_family_ipv4_vrf.go b/internal/provider/data_source_iosxe_bgp_address_family_ipv4_vrf.go
index b2e47488..27a34192 100644
--- a/internal/provider/data_source_iosxe_bgp_address_family_ipv4_vrf.go
+++ b/internal/provider/data_source_iosxe_bgp_address_family_ipv4_vrf.go
@@ -24,6 +24,7 @@ import (
"context"
"fmt"
+ "github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
"github.com/hashicorp/terraform-plugin-framework/path"
@@ -245,16 +246,37 @@ func (d *BGPAddressFamilyIPv4VRFDataSource) Read(ctx context.Context, req dataso
return
}
- res, err := device.Client.GetData(config.getPath())
- if res.StatusCode == 404 {
- config = BGPAddressFamilyIPv4VRFData{Device: config.Device}
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(config.getPath())
+ if res.StatusCode == 404 {
+ config = BGPAddressFamilyIPv4VRFData{Device: config.Device}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
+ return
+ }
+
+ config.fromBody(ctx, res.Res)
+ }
} else {
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
+ }
+
+ filter := helpers.GetXpathFilter(config.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
if err != nil {
resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
return
}
- config.fromBody(ctx, res.Res)
+ config.fromBodyXML(ctx, res.Res)
}
config.Id = types.StringValue(config.getPath())
diff --git a/internal/provider/data_source_iosxe_bgp_address_family_ipv4_vrf_test.go b/internal/provider/data_source_iosxe_bgp_address_family_ipv4_vrf_test.go
index 2fbaf9fe..80d02067 100644
--- a/internal/provider/data_source_iosxe_bgp_address_family_ipv4_vrf_test.go
+++ b/internal/provider/data_source_iosxe_bgp_address_family_ipv4_vrf_test.go
@@ -69,8 +69,8 @@ func TestAccDataSourceIosxeBGPAddressFamilyIPv4VRF(t *testing.T) {
// Section below is generated&owned by "gen/generator.go". //template:begin testPrerequisites
const testAccDataSourceIosxeBGPAddressFamilyIPv4VRFPrerequisitesConfig = `
-resource "iosxe_restconf" "PreReq0" {
- path = "Cisco-IOS-XE-native:native/vrf/definition=VRF1"
+resource "iosxe_yang" "PreReq0" {
+ path = "/Cisco-IOS-XE-native:native/vrf/definition[name=VRF1]"
delete = false
attributes = {
"name" = "VRF1"
@@ -79,23 +79,23 @@ resource "iosxe_restconf" "PreReq0" {
}
}
-resource "iosxe_restconf" "PreReq1" {
- path = "Cisco-IOS-XE-native:native/router/Cisco-IOS-XE-bgp:bgp=65000"
+resource "iosxe_yang" "PreReq1" {
+ path = "/Cisco-IOS-XE-native:native/router/Cisco-IOS-XE-bgp:bgp[id=65000]"
attributes = {
"id" = "65000"
}
- depends_on = [iosxe_restconf.PreReq0, ]
+ depends_on = [iosxe_yang.PreReq0, ]
}
-resource "iosxe_restconf" "PreReq2" {
- path = "Cisco-IOS-XE-native:native/interface/Loopback=101"
+resource "iosxe_yang" "PreReq2" {
+ path = "/Cisco-IOS-XE-native:native/interface/Loopback[name=101]"
attributes = {
"name" = "101"
"ip/address/primary/address" = "22.22.22.22"
"ip/address/primary/mask" = "255.255.255.255"
"vrf/forwarding" = "VRF1"
}
- depends_on = [iosxe_restconf.PreReq0, ]
+ depends_on = [iosxe_yang.PreReq0, ]
}
`
@@ -140,7 +140,7 @@ func testAccDataSourceIosxeBGPAddressFamilyIPv4VRFConfig() string {
config += ` ipv4_unicast_distance_bgp_internal = 200` + "\n"
config += ` ipv4_unicast_distance_bgp_local = 200` + "\n"
config += ` }]` + "\n"
- config += ` depends_on = [iosxe_restconf.PreReq0, iosxe_restconf.PreReq1, iosxe_restconf.PreReq2, ]` + "\n"
+ config += ` depends_on = [iosxe_yang.PreReq0, iosxe_yang.PreReq1, iosxe_yang.PreReq2, ]` + "\n"
config += `}` + "\n"
config += `
diff --git a/internal/provider/data_source_iosxe_bgp_address_family_ipv6.go b/internal/provider/data_source_iosxe_bgp_address_family_ipv6.go
index d5c4720e..69e1ce7e 100644
--- a/internal/provider/data_source_iosxe_bgp_address_family_ipv6.go
+++ b/internal/provider/data_source_iosxe_bgp_address_family_ipv6.go
@@ -24,6 +24,7 @@ import (
"context"
"fmt"
+ "github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
"github.com/hashicorp/terraform-plugin-framework/path"
@@ -137,16 +138,37 @@ func (d *BGPAddressFamilyIPv6DataSource) Read(ctx context.Context, req datasourc
return
}
- res, err := device.Client.GetData(config.getPath())
- if res.StatusCode == 404 {
- config = BGPAddressFamilyIPv6Data{Device: config.Device}
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(config.getPath())
+ if res.StatusCode == 404 {
+ config = BGPAddressFamilyIPv6Data{Device: config.Device}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
+ return
+ }
+
+ config.fromBody(ctx, res.Res)
+ }
} else {
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
+ }
+
+ filter := helpers.GetXpathFilter(config.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
if err != nil {
resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
return
}
- config.fromBody(ctx, res.Res)
+ config.fromBodyXML(ctx, res.Res)
}
config.Id = types.StringValue(config.getPath())
diff --git a/internal/provider/data_source_iosxe_bgp_address_family_ipv6_test.go b/internal/provider/data_source_iosxe_bgp_address_family_ipv6_test.go
index 869d48aa..0e2b7cdb 100644
--- a/internal/provider/data_source_iosxe_bgp_address_family_ipv6_test.go
+++ b/internal/provider/data_source_iosxe_bgp_address_family_ipv6_test.go
@@ -53,15 +53,15 @@ func TestAccDataSourceIosxeBGPAddressFamilyIPv6(t *testing.T) {
// Section below is generated&owned by "gen/generator.go". //template:begin testPrerequisites
const testAccDataSourceIosxeBGPAddressFamilyIPv6PrerequisitesConfig = `
-resource "iosxe_restconf" "PreReq0" {
- path = "Cisco-IOS-XE-native:native/ipv6"
+resource "iosxe_yang" "PreReq0" {
+ path = "/Cisco-IOS-XE-native:native/ipv6"
attributes = {
"unicast-routing" = ""
}
}
-resource "iosxe_restconf" "PreReq1" {
- path = "Cisco-IOS-XE-native:native/router/Cisco-IOS-XE-bgp:bgp=65000"
+resource "iosxe_yang" "PreReq1" {
+ path = "/Cisco-IOS-XE-native:native/router/Cisco-IOS-XE-bgp:bgp[id=65000]"
attributes = {
"id" = "65000"
}
@@ -85,7 +85,7 @@ func testAccDataSourceIosxeBGPAddressFamilyIPv6Config() string {
config += ` route_map = "RM1"` + "\n"
config += ` backdoor = true` + "\n"
config += ` }]` + "\n"
- config += ` depends_on = [iosxe_restconf.PreReq0, iosxe_restconf.PreReq1, ]` + "\n"
+ config += ` depends_on = [iosxe_yang.PreReq0, iosxe_yang.PreReq1, ]` + "\n"
config += `}` + "\n"
config += `
diff --git a/internal/provider/data_source_iosxe_bgp_address_family_ipv6_vrf.go b/internal/provider/data_source_iosxe_bgp_address_family_ipv6_vrf.go
index 34a3c753..c3e3002f 100644
--- a/internal/provider/data_source_iosxe_bgp_address_family_ipv6_vrf.go
+++ b/internal/provider/data_source_iosxe_bgp_address_family_ipv6_vrf.go
@@ -24,6 +24,7 @@ import (
"context"
"fmt"
+ "github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
"github.com/hashicorp/terraform-plugin-framework/path"
@@ -157,16 +158,37 @@ func (d *BGPAddressFamilyIPv6VRFDataSource) Read(ctx context.Context, req dataso
return
}
- res, err := device.Client.GetData(config.getPath())
- if res.StatusCode == 404 {
- config = BGPAddressFamilyIPv6VRFData{Device: config.Device}
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(config.getPath())
+ if res.StatusCode == 404 {
+ config = BGPAddressFamilyIPv6VRFData{Device: config.Device}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
+ return
+ }
+
+ config.fromBody(ctx, res.Res)
+ }
} else {
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
+ }
+
+ filter := helpers.GetXpathFilter(config.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
if err != nil {
resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
return
}
- config.fromBody(ctx, res.Res)
+ config.fromBodyXML(ctx, res.Res)
}
config.Id = types.StringValue(config.getPath())
diff --git a/internal/provider/data_source_iosxe_bgp_address_family_ipv6_vrf_test.go b/internal/provider/data_source_iosxe_bgp_address_family_ipv6_vrf_test.go
index 5034e13b..7cc9206a 100644
--- a/internal/provider/data_source_iosxe_bgp_address_family_ipv6_vrf_test.go
+++ b/internal/provider/data_source_iosxe_bgp_address_family_ipv6_vrf_test.go
@@ -56,30 +56,30 @@ func TestAccDataSourceIosxeBGPAddressFamilyIPv6VRF(t *testing.T) {
// Section below is generated&owned by "gen/generator.go". //template:begin testPrerequisites
const testAccDataSourceIosxeBGPAddressFamilyIPv6VRFPrerequisitesConfig = `
-resource "iosxe_restconf" "PreReq0" {
- path = "Cisco-IOS-XE-native:native/ipv6"
+resource "iosxe_yang" "PreReq0" {
+ path = "/Cisco-IOS-XE-native:native/ipv6"
attributes = {
"unicast-routing" = ""
}
}
-resource "iosxe_restconf" "PreReq1" {
- path = "Cisco-IOS-XE-native:native/vrf/definition=VRF1"
+resource "iosxe_yang" "PreReq1" {
+ path = "/Cisco-IOS-XE-native:native/vrf/definition[name=VRF1]"
delete = false
attributes = {
"name" = "VRF1"
"rd" = "1:1"
"address-family/ipv6" = ""
}
- depends_on = [iosxe_restconf.PreReq0, ]
+ depends_on = [iosxe_yang.PreReq0, ]
}
-resource "iosxe_restconf" "PreReq2" {
- path = "Cisco-IOS-XE-native:native/router/Cisco-IOS-XE-bgp:bgp=65000"
+resource "iosxe_yang" "PreReq2" {
+ path = "/Cisco-IOS-XE-native:native/router/Cisco-IOS-XE-bgp:bgp[id=65000]"
attributes = {
"id" = "65000"
}
- depends_on = [iosxe_restconf.PreReq1, ]
+ depends_on = [iosxe_yang.PreReq1, ]
}
`
@@ -105,7 +105,7 @@ func testAccDataSourceIosxeBGPAddressFamilyIPv6VRFConfig() string {
config += ` evpn = false` + "\n"
config += ` }]` + "\n"
config += ` }]` + "\n"
- config += ` depends_on = [iosxe_restconf.PreReq0, iosxe_restconf.PreReq1, iosxe_restconf.PreReq2, ]` + "\n"
+ config += ` depends_on = [iosxe_yang.PreReq0, iosxe_yang.PreReq1, iosxe_yang.PreReq2, ]` + "\n"
config += `}` + "\n"
config += `
diff --git a/internal/provider/data_source_iosxe_bgp_address_family_l2vpn.go b/internal/provider/data_source_iosxe_bgp_address_family_l2vpn.go
index 663aae39..1c65aea6 100644
--- a/internal/provider/data_source_iosxe_bgp_address_family_l2vpn.go
+++ b/internal/provider/data_source_iosxe_bgp_address_family_l2vpn.go
@@ -24,6 +24,7 @@ import (
"context"
"fmt"
+ "github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
"github.com/hashicorp/terraform-plugin-framework/path"
@@ -109,16 +110,37 @@ func (d *BGPAddressFamilyL2VPNDataSource) Read(ctx context.Context, req datasour
return
}
- res, err := device.Client.GetData(config.getPath())
- if res.StatusCode == 404 {
- config = BGPAddressFamilyL2VPNData{Device: config.Device}
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(config.getPath())
+ if res.StatusCode == 404 {
+ config = BGPAddressFamilyL2VPNData{Device: config.Device}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
+ return
+ }
+
+ config.fromBody(ctx, res.Res)
+ }
} else {
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
+ }
+
+ filter := helpers.GetXpathFilter(config.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
if err != nil {
resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
return
}
- config.fromBody(ctx, res.Res)
+ config.fromBodyXML(ctx, res.Res)
}
config.Id = types.StringValue(config.getPath())
diff --git a/internal/provider/data_source_iosxe_bgp_address_family_l2vpn_test.go b/internal/provider/data_source_iosxe_bgp_address_family_l2vpn_test.go
index ebce263b..f19e61d4 100644
--- a/internal/provider/data_source_iosxe_bgp_address_family_l2vpn_test.go
+++ b/internal/provider/data_source_iosxe_bgp_address_family_l2vpn_test.go
@@ -52,8 +52,8 @@ func TestAccDataSourceIosxeBGPAddressFamilyL2VPN(t *testing.T) {
// Section below is generated&owned by "gen/generator.go". //template:begin testPrerequisites
const testAccDataSourceIosxeBGPAddressFamilyL2VPNPrerequisitesConfig = `
-resource "iosxe_restconf" "PreReq0" {
- path = "Cisco-IOS-XE-native:native/router/Cisco-IOS-XE-bgp:bgp=65000"
+resource "iosxe_yang" "PreReq0" {
+ path = "/Cisco-IOS-XE-native:native/router/Cisco-IOS-XE-bgp:bgp[id=65000]"
attributes = {
"id" = "65000"
}
@@ -70,7 +70,7 @@ func testAccDataSourceIosxeBGPAddressFamilyL2VPNConfig() string {
config += ` delete_mode = "attributes"` + "\n"
config += ` asn = "65000"` + "\n"
config += ` af_name = "evpn"` + "\n"
- config += ` depends_on = [iosxe_restconf.PreReq0, ]` + "\n"
+ config += ` depends_on = [iosxe_yang.PreReq0, ]` + "\n"
config += `}` + "\n"
config += `
diff --git a/internal/provider/data_source_iosxe_bgp_ipv4_unicast_neighbor.go b/internal/provider/data_source_iosxe_bgp_ipv4_unicast_neighbor.go
index b1ec5838..f983cdf6 100644
--- a/internal/provider/data_source_iosxe_bgp_ipv4_unicast_neighbor.go
+++ b/internal/provider/data_source_iosxe_bgp_ipv4_unicast_neighbor.go
@@ -24,6 +24,7 @@ import (
"context"
"fmt"
+ "github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
"github.com/hashicorp/terraform-plugin-framework/path"
@@ -149,16 +150,37 @@ func (d *BGPIPv4UnicastNeighborDataSource) Read(ctx context.Context, req datasou
return
}
- res, err := device.Client.GetData(config.getPath())
- if res.StatusCode == 404 {
- config = BGPIPv4UnicastNeighborData{Device: config.Device}
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(config.getPath())
+ if res.StatusCode == 404 {
+ config = BGPIPv4UnicastNeighborData{Device: config.Device}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
+ return
+ }
+
+ config.fromBody(ctx, res.Res)
+ }
} else {
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
+ }
+
+ filter := helpers.GetXpathFilter(config.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
if err != nil {
resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
return
}
- config.fromBody(ctx, res.Res)
+ config.fromBodyXML(ctx, res.Res)
}
config.Id = types.StringValue(config.getPath())
diff --git a/internal/provider/data_source_iosxe_bgp_ipv4_unicast_neighbor_test.go b/internal/provider/data_source_iosxe_bgp_ipv4_unicast_neighbor_test.go
index 15405ba0..83991828 100644
--- a/internal/provider/data_source_iosxe_bgp_ipv4_unicast_neighbor_test.go
+++ b/internal/provider/data_source_iosxe_bgp_ipv4_unicast_neighbor_test.go
@@ -56,32 +56,32 @@ func TestAccDataSourceIosxeBGPIPv4UnicastNeighbor(t *testing.T) {
// Section below is generated&owned by "gen/generator.go". //template:begin testPrerequisites
const testAccDataSourceIosxeBGPIPv4UnicastNeighborPrerequisitesConfig = `
-resource "iosxe_restconf" "PreReq0" {
- path = "Cisco-IOS-XE-native:native/router/Cisco-IOS-XE-bgp:bgp=65000"
+resource "iosxe_yang" "PreReq0" {
+ path = "/Cisco-IOS-XE-native:native/router/Cisco-IOS-XE-bgp:bgp[id=65000]"
attributes = {
"id" = "65000"
}
}
-resource "iosxe_restconf" "PreReq1" {
- path = "Cisco-IOS-XE-native:native/router/Cisco-IOS-XE-bgp:bgp=65000/address-family/no-vrf/ipv4=unicast"
+resource "iosxe_yang" "PreReq1" {
+ path = "/Cisco-IOS-XE-native:native/router/Cisco-IOS-XE-bgp:bgp[id=65000]/address-family/no-vrf/ipv4[af-name=unicast]"
attributes = {
"af-name" = "unicast"
}
- depends_on = [iosxe_restconf.PreReq0, ]
+ depends_on = [iosxe_yang.PreReq0, ]
}
-resource "iosxe_restconf" "PreReq2" {
- path = "Cisco-IOS-XE-native:native/router/Cisco-IOS-XE-bgp:bgp=65000/neighbor=3.3.3.3"
+resource "iosxe_yang" "PreReq2" {
+ path = "/Cisco-IOS-XE-native:native/router/Cisco-IOS-XE-bgp:bgp[id=65000]/neighbor[id=3.3.3.3]"
attributes = {
"id" = "3.3.3.3"
"remote-as" = "65000"
}
- depends_on = [iosxe_restconf.PreReq0, ]
+ depends_on = [iosxe_yang.PreReq0, ]
}
-resource "iosxe_restconf" "PreReq3" {
- path = "Cisco-IOS-XE-native:native/interface/Loopback=100"
+resource "iosxe_yang" "PreReq3" {
+ path = "/Cisco-IOS-XE-native:native/interface/Loopback[name=100]"
attributes = {
"name" = "100"
}
@@ -108,7 +108,7 @@ func testAccDataSourceIosxeBGPIPv4UnicastNeighborConfig() string {
config += ` in_out = "in"` + "\n"
config += ` route_map_name = "RM1"` + "\n"
config += ` }]` + "\n"
- config += ` depends_on = [iosxe_restconf.PreReq0, iosxe_restconf.PreReq1, iosxe_restconf.PreReq2, iosxe_restconf.PreReq3, ]` + "\n"
+ config += ` depends_on = [iosxe_yang.PreReq0, iosxe_yang.PreReq1, iosxe_yang.PreReq2, iosxe_yang.PreReq3, ]` + "\n"
config += `}` + "\n"
config += `
diff --git a/internal/provider/data_source_iosxe_bgp_ipv4_unicast_vrf_neighbor.go b/internal/provider/data_source_iosxe_bgp_ipv4_unicast_vrf_neighbor.go
index 5e5b1514..4ab99afa 100644
--- a/internal/provider/data_source_iosxe_bgp_ipv4_unicast_vrf_neighbor.go
+++ b/internal/provider/data_source_iosxe_bgp_ipv4_unicast_vrf_neighbor.go
@@ -24,6 +24,7 @@ import (
"context"
"fmt"
+ "github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
"github.com/hashicorp/terraform-plugin-framework/path"
@@ -278,16 +279,37 @@ func (d *BGPIPv4UnicastVRFNeighborDataSource) Read(ctx context.Context, req data
return
}
- res, err := device.Client.GetData(config.getPath())
- if res.StatusCode == 404 {
- config = BGPIPv4UnicastVRFNeighborData{Device: config.Device}
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(config.getPath())
+ if res.StatusCode == 404 {
+ config = BGPIPv4UnicastVRFNeighborData{Device: config.Device}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
+ return
+ }
+
+ config.fromBody(ctx, res.Res)
+ }
} else {
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
+ }
+
+ filter := helpers.GetXpathFilter(config.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
if err != nil {
resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
return
}
- config.fromBody(ctx, res.Res)
+ config.fromBodyXML(ctx, res.Res)
}
config.Id = types.StringValue(config.getPath())
diff --git a/internal/provider/data_source_iosxe_bgp_ipv4_unicast_vrf_neighbor_test.go b/internal/provider/data_source_iosxe_bgp_ipv4_unicast_vrf_neighbor_test.go
index 8cad9af5..ac8a684a 100644
--- a/internal/provider/data_source_iosxe_bgp_ipv4_unicast_vrf_neighbor_test.go
+++ b/internal/provider/data_source_iosxe_bgp_ipv4_unicast_vrf_neighbor_test.go
@@ -75,8 +75,8 @@ func TestAccDataSourceIosxeBGPIPv4UnicastVRFNeighbor(t *testing.T) {
// Section below is generated&owned by "gen/generator.go". //template:begin testPrerequisites
const testAccDataSourceIosxeBGPIPv4UnicastVRFNeighborPrerequisitesConfig = `
-resource "iosxe_restconf" "PreReq0" {
- path = "Cisco-IOS-XE-native:native/vrf/definition=VRF1"
+resource "iosxe_yang" "PreReq0" {
+ path = "/Cisco-IOS-XE-native:native/vrf/definition[name=VRF1]"
delete = false
attributes = {
"name" = "VRF1"
@@ -85,15 +85,15 @@ resource "iosxe_restconf" "PreReq0" {
}
}
-resource "iosxe_restconf" "PreReq1" {
- path = "Cisco-IOS-XE-native:native/router/Cisco-IOS-XE-bgp:bgp=65000"
+resource "iosxe_yang" "PreReq1" {
+ path = "/Cisco-IOS-XE-native:native/router/Cisco-IOS-XE-bgp:bgp[id=65000]"
attributes = {
"id" = "65000"
}
}
-resource "iosxe_restconf" "PreReq2" {
- path = "Cisco-IOS-XE-native:native/router/Cisco-IOS-XE-bgp:bgp=65000/address-family/with-vrf/ipv4=unicast"
+resource "iosxe_yang" "PreReq2" {
+ path = "/Cisco-IOS-XE-native:native/router/Cisco-IOS-XE-bgp:bgp[id=65000]/address-family/with-vrf/ipv4[af-name=unicast]"
attributes = {
"af-name" = "unicast"
}
@@ -108,11 +108,11 @@ resource "iosxe_restconf" "PreReq2" {
]
},
]
- depends_on = [iosxe_restconf.PreReq0, iosxe_restconf.PreReq1, ]
+ depends_on = [iosxe_yang.PreReq0, iosxe_yang.PreReq1, ]
}
-resource "iosxe_restconf" "PreReq3" {
- path = "Cisco-IOS-XE-native:native/interface/Loopback=100"
+resource "iosxe_yang" "PreReq3" {
+ path = "/Cisco-IOS-XE-native:native/interface/Loopback[name=100]"
attributes = {
"name" = "100"
}
@@ -161,7 +161,7 @@ func testAccDataSourceIosxeBGPIPv4UnicastVRFNeighborConfig() string {
config += ` next_hop_self = true` + "\n"
config += ` next_hop_self_all = true` + "\n"
config += ` advertisement_interval = 300` + "\n"
- config += ` depends_on = [iosxe_restconf.PreReq0, iosxe_restconf.PreReq1, iosxe_restconf.PreReq2, iosxe_restconf.PreReq3, ]` + "\n"
+ config += ` depends_on = [iosxe_yang.PreReq0, iosxe_yang.PreReq1, iosxe_yang.PreReq2, iosxe_yang.PreReq3, ]` + "\n"
config += `}` + "\n"
config += `
diff --git a/internal/provider/data_source_iosxe_bgp_ipv6_unicast_neighbor.go b/internal/provider/data_source_iosxe_bgp_ipv6_unicast_neighbor.go
index 709c07ee..7c486a40 100644
--- a/internal/provider/data_source_iosxe_bgp_ipv6_unicast_neighbor.go
+++ b/internal/provider/data_source_iosxe_bgp_ipv6_unicast_neighbor.go
@@ -24,6 +24,7 @@ import (
"context"
"fmt"
+ "github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
"github.com/hashicorp/terraform-plugin-framework/path"
@@ -149,16 +150,37 @@ func (d *BGPIPv6UnicastNeighborDataSource) Read(ctx context.Context, req datasou
return
}
- res, err := device.Client.GetData(config.getPath())
- if res.StatusCode == 404 {
- config = BGPIPv6UnicastNeighborData{Device: config.Device}
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(config.getPath())
+ if res.StatusCode == 404 {
+ config = BGPIPv6UnicastNeighborData{Device: config.Device}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
+ return
+ }
+
+ config.fromBody(ctx, res.Res)
+ }
} else {
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
+ }
+
+ filter := helpers.GetXpathFilter(config.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
if err != nil {
resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
return
}
- config.fromBody(ctx, res.Res)
+ config.fromBodyXML(ctx, res.Res)
}
config.Id = types.StringValue(config.getPath())
diff --git a/internal/provider/data_source_iosxe_bgp_ipv6_unicast_neighbor_test.go b/internal/provider/data_source_iosxe_bgp_ipv6_unicast_neighbor_test.go
index 87969da2..dca5b283 100644
--- a/internal/provider/data_source_iosxe_bgp_ipv6_unicast_neighbor_test.go
+++ b/internal/provider/data_source_iosxe_bgp_ipv6_unicast_neighbor_test.go
@@ -56,39 +56,39 @@ func TestAccDataSourceIosxeBGPIPv6UnicastNeighbor(t *testing.T) {
// Section below is generated&owned by "gen/generator.go". //template:begin testPrerequisites
const testAccDataSourceIosxeBGPIPv6UnicastNeighborPrerequisitesConfig = `
-resource "iosxe_restconf" "PreReq0" {
- path = "Cisco-IOS-XE-native:native/ipv6"
+resource "iosxe_yang" "PreReq0" {
+ path = "/Cisco-IOS-XE-native:native/ipv6"
attributes = {
"unicast-routing" = ""
}
}
-resource "iosxe_restconf" "PreReq1" {
- path = "Cisco-IOS-XE-native:native/router/Cisco-IOS-XE-bgp:bgp=65000"
+resource "iosxe_yang" "PreReq1" {
+ path = "/Cisco-IOS-XE-native:native/router/Cisco-IOS-XE-bgp:bgp[id=65000]"
attributes = {
"id" = "65000"
}
}
-resource "iosxe_restconf" "PreReq2" {
- path = "Cisco-IOS-XE-native:native/router/Cisco-IOS-XE-bgp:bgp=65000/address-family/no-vrf/ipv6=unicast"
+resource "iosxe_yang" "PreReq2" {
+ path = "/Cisco-IOS-XE-native:native/router/Cisco-IOS-XE-bgp:bgp[id=65000]/address-family/no-vrf/ipv6[af-name=unicast]"
attributes = {
"af-name" = "unicast"
}
- depends_on = [iosxe_restconf.PreReq0, iosxe_restconf.PreReq1, ]
+ depends_on = [iosxe_yang.PreReq0, iosxe_yang.PreReq1, ]
}
-resource "iosxe_restconf" "PreReq3" {
- path = "Cisco-IOS-XE-native:native/router/Cisco-IOS-XE-bgp:bgp=65000/neighbor=3.3.3.3"
+resource "iosxe_yang" "PreReq3" {
+ path = "/Cisco-IOS-XE-native:native/router/Cisco-IOS-XE-bgp:bgp[id=65000]/neighbor[id=3.3.3.3]"
attributes = {
"id" = "3.3.3.3"
"remote-as" = "65000"
}
- depends_on = [iosxe_restconf.PreReq0, iosxe_restconf.PreReq1, ]
+ depends_on = [iosxe_yang.PreReq0, iosxe_yang.PreReq1, ]
}
-resource "iosxe_restconf" "PreReq4" {
- path = "Cisco-IOS-XE-native:native/interface/Loopback=100"
+resource "iosxe_yang" "PreReq4" {
+ path = "/Cisco-IOS-XE-native:native/interface/Loopback[name=100]"
attributes = {
"name" = "100"
}
@@ -115,7 +115,7 @@ func testAccDataSourceIosxeBGPIPv6UnicastNeighborConfig() string {
config += ` in_out = "in"` + "\n"
config += ` route_map_name = "RM1"` + "\n"
config += ` }]` + "\n"
- config += ` depends_on = [iosxe_restconf.PreReq0, iosxe_restconf.PreReq1, iosxe_restconf.PreReq2, iosxe_restconf.PreReq3, iosxe_restconf.PreReq4, ]` + "\n"
+ config += ` depends_on = [iosxe_yang.PreReq0, iosxe_yang.PreReq1, iosxe_yang.PreReq2, iosxe_yang.PreReq3, iosxe_yang.PreReq4, ]` + "\n"
config += `}` + "\n"
config += `
diff --git a/internal/provider/data_source_iosxe_bgp_l2vpn_evpn_neighbor.go b/internal/provider/data_source_iosxe_bgp_l2vpn_evpn_neighbor.go
index c90149bd..19ce1a05 100644
--- a/internal/provider/data_source_iosxe_bgp_l2vpn_evpn_neighbor.go
+++ b/internal/provider/data_source_iosxe_bgp_l2vpn_evpn_neighbor.go
@@ -24,6 +24,7 @@ import (
"context"
"fmt"
+ "github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
"github.com/hashicorp/terraform-plugin-framework/path"
@@ -125,16 +126,37 @@ func (d *BGPL2VPNEVPNNeighborDataSource) Read(ctx context.Context, req datasourc
return
}
- res, err := device.Client.GetData(config.getPath())
- if res.StatusCode == 404 {
- config = BGPL2VPNEVPNNeighborData{Device: config.Device}
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(config.getPath())
+ if res.StatusCode == 404 {
+ config = BGPL2VPNEVPNNeighborData{Device: config.Device}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
+ return
+ }
+
+ config.fromBody(ctx, res.Res)
+ }
} else {
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
+ }
+
+ filter := helpers.GetXpathFilter(config.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
if err != nil {
resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
return
}
- config.fromBody(ctx, res.Res)
+ config.fromBodyXML(ctx, res.Res)
}
config.Id = types.StringValue(config.getPath())
diff --git a/internal/provider/data_source_iosxe_bgp_l2vpn_evpn_neighbor_test.go b/internal/provider/data_source_iosxe_bgp_l2vpn_evpn_neighbor_test.go
index 0c6b6944..1ce03f64 100644
--- a/internal/provider/data_source_iosxe_bgp_l2vpn_evpn_neighbor_test.go
+++ b/internal/provider/data_source_iosxe_bgp_l2vpn_evpn_neighbor_test.go
@@ -56,28 +56,28 @@ func TestAccDataSourceIosxeBGPL2VPNEVPNNeighbor(t *testing.T) {
// Section below is generated&owned by "gen/generator.go". //template:begin testPrerequisites
const testAccDataSourceIosxeBGPL2VPNEVPNNeighborPrerequisitesConfig = `
-resource "iosxe_restconf" "PreReq0" {
- path = "Cisco-IOS-XE-native:native/router/Cisco-IOS-XE-bgp:bgp=65000"
+resource "iosxe_yang" "PreReq0" {
+ path = "/Cisco-IOS-XE-native:native/router/Cisco-IOS-XE-bgp:bgp[id=65000]"
attributes = {
"id" = "65000"
}
}
-resource "iosxe_restconf" "PreReq1" {
- path = "Cisco-IOS-XE-native:native/router/Cisco-IOS-XE-bgp:bgp=65000/address-family/no-vrf/l2vpn=evpn"
+resource "iosxe_yang" "PreReq1" {
+ path = "/Cisco-IOS-XE-native:native/router/Cisco-IOS-XE-bgp:bgp[id=65000]/address-family/no-vrf/l2vpn[af-name=evpn]"
attributes = {
"af-name" = "evpn"
}
- depends_on = [iosxe_restconf.PreReq0, ]
+ depends_on = [iosxe_yang.PreReq0, ]
}
-resource "iosxe_restconf" "PreReq2" {
- path = "Cisco-IOS-XE-native:native/router/Cisco-IOS-XE-bgp:bgp=65000/neighbor=3.3.3.3"
+resource "iosxe_yang" "PreReq2" {
+ path = "/Cisco-IOS-XE-native:native/router/Cisco-IOS-XE-bgp:bgp[id=65000]/neighbor[id=3.3.3.3]"
attributes = {
"id" = "3.3.3.3"
"remote-as" = "65000"
}
- depends_on = [iosxe_restconf.PreReq0, ]
+ depends_on = [iosxe_yang.PreReq0, ]
}
`
@@ -95,7 +95,7 @@ func testAccDataSourceIosxeBGPL2VPNEVPNNeighborConfig() string {
config += ` send_community = "both"` + "\n"
config += ` route_reflector_client = false` + "\n"
config += ` soft_reconfiguration = "inbound"` + "\n"
- config += ` depends_on = [iosxe_restconf.PreReq0, iosxe_restconf.PreReq1, iosxe_restconf.PreReq2, ]` + "\n"
+ config += ` depends_on = [iosxe_yang.PreReq0, iosxe_yang.PreReq1, iosxe_yang.PreReq2, ]` + "\n"
config += `}` + "\n"
config += `
diff --git a/internal/provider/data_source_iosxe_bgp_neighbor.go b/internal/provider/data_source_iosxe_bgp_neighbor.go
index 599f970f..c8d0ebf2 100644
--- a/internal/provider/data_source_iosxe_bgp_neighbor.go
+++ b/internal/provider/data_source_iosxe_bgp_neighbor.go
@@ -24,6 +24,7 @@ import (
"context"
"fmt"
+ "github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
"github.com/hashicorp/terraform-plugin-framework/path"
@@ -226,16 +227,37 @@ func (d *BGPNeighborDataSource) Read(ctx context.Context, req datasource.ReadReq
return
}
- res, err := device.Client.GetData(config.getPath())
- if res.StatusCode == 404 {
- config = BGPNeighborData{Device: config.Device}
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(config.getPath())
+ if res.StatusCode == 404 {
+ config = BGPNeighborData{Device: config.Device}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
+ return
+ }
+
+ config.fromBody(ctx, res.Res)
+ }
} else {
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
+ }
+
+ filter := helpers.GetXpathFilter(config.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
if err != nil {
resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
return
}
- config.fromBody(ctx, res.Res)
+ config.fromBodyXML(ctx, res.Res)
}
config.Id = types.StringValue(config.getPath())
diff --git a/internal/provider/data_source_iosxe_bgp_neighbor_test.go b/internal/provider/data_source_iosxe_bgp_neighbor_test.go
index 633fa24d..e7de1b6d 100644
--- a/internal/provider/data_source_iosxe_bgp_neighbor_test.go
+++ b/internal/provider/data_source_iosxe_bgp_neighbor_test.go
@@ -66,15 +66,15 @@ func TestAccDataSourceIosxeBGPNeighbor(t *testing.T) {
// Section below is generated&owned by "gen/generator.go". //template:begin testPrerequisites
const testAccDataSourceIosxeBGPNeighborPrerequisitesConfig = `
-resource "iosxe_restconf" "PreReq0" {
- path = "Cisco-IOS-XE-native:native/router/Cisco-IOS-XE-bgp:bgp=65000"
+resource "iosxe_yang" "PreReq0" {
+ path = "/Cisco-IOS-XE-native:native/router/Cisco-IOS-XE-bgp:bgp[id=65000]"
attributes = {
"id" = "65000"
}
}
-resource "iosxe_restconf" "PreReq1" {
- path = "Cisco-IOS-XE-native:native/interface/Loopback=100"
+resource "iosxe_yang" "PreReq1" {
+ path = "/Cisco-IOS-XE-native:native/interface/Loopback[name=100]"
attributes = {
"name" = "100"
}
@@ -111,7 +111,7 @@ func testAccDataSourceIosxeBGPNeighborConfig() string {
config += ` timers_holdtime = 866` + "\n"
config += ` timers_minimum_neighbor_hold = 222` + "\n"
config += ` update_source_loopback = 100` + "\n"
- config += ` depends_on = [iosxe_restconf.PreReq0, iosxe_restconf.PreReq1, ]` + "\n"
+ config += ` depends_on = [iosxe_yang.PreReq0, iosxe_yang.PreReq1, ]` + "\n"
config += `}` + "\n"
config += `
diff --git a/internal/provider/data_source_iosxe_bgp_test.go b/internal/provider/data_source_iosxe_bgp_test.go
index 951c836f..afbfeb0c 100644
--- a/internal/provider/data_source_iosxe_bgp_test.go
+++ b/internal/provider/data_source_iosxe_bgp_test.go
@@ -52,8 +52,8 @@ func TestAccDataSourceIosxeBGP(t *testing.T) {
// Section below is generated&owned by "gen/generator.go". //template:begin testPrerequisites
const testAccDataSourceIosxeBGPPrerequisitesConfig = `
-resource "iosxe_restconf" "PreReq0" {
- path = "Cisco-IOS-XE-native:native/interface/Loopback=100"
+resource "iosxe_yang" "PreReq0" {
+ path = "/Cisco-IOS-XE-native:native/interface/Loopback[name=100]"
attributes = {
"name" = "100"
"ip/address/primary/address" = "200.200.200.200"
@@ -75,7 +75,7 @@ func testAccDataSourceIosxeBGPConfig() string {
config += ` log_neighbor_changes = true` + "\n"
config += ` router_id_loopback = 100` + "\n"
config += ` router_id_ip = "172.16.255.1"` + "\n"
- config += ` depends_on = [iosxe_restconf.PreReq0, ]` + "\n"
+ config += ` depends_on = [iosxe_yang.PreReq0, ]` + "\n"
config += `}` + "\n"
config += `
diff --git a/internal/provider/data_source_iosxe_cdp.go b/internal/provider/data_source_iosxe_cdp.go
index 562eb628..c0c84942 100644
--- a/internal/provider/data_source_iosxe_cdp.go
+++ b/internal/provider/data_source_iosxe_cdp.go
@@ -24,6 +24,7 @@ import (
"context"
"fmt"
+ "github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
"github.com/hashicorp/terraform-plugin-framework/path"
@@ -149,16 +150,37 @@ func (d *CDPDataSource) Read(ctx context.Context, req datasource.ReadRequest, re
return
}
- res, err := device.Client.GetData(config.getPath())
- if res.StatusCode == 404 {
- config = CDPData{Device: config.Device}
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(config.getPath())
+ if res.StatusCode == 404 {
+ config = CDPData{Device: config.Device}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
+ return
+ }
+
+ config.fromBody(ctx, res.Res)
+ }
} else {
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
+ }
+
+ filter := helpers.GetXpathFilter(config.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
if err != nil {
resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
return
}
- config.fromBody(ctx, res.Res)
+ config.fromBodyXML(ctx, res.Res)
}
config.Id = types.StringValue(config.getPath())
diff --git a/internal/provider/data_source_iosxe_class_map.go b/internal/provider/data_source_iosxe_class_map.go
index ad456d7d..35a33327 100644
--- a/internal/provider/data_source_iosxe_class_map.go
+++ b/internal/provider/data_source_iosxe_class_map.go
@@ -24,6 +24,7 @@ import (
"context"
"fmt"
+ "github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
"github.com/hashicorp/terraform-plugin-framework/path"
@@ -194,16 +195,37 @@ func (d *ClassMapDataSource) Read(ctx context.Context, req datasource.ReadReques
return
}
- res, err := device.Client.GetData(config.getPath())
- if res.StatusCode == 404 {
- config = ClassMapData{Device: config.Device}
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(config.getPath())
+ if res.StatusCode == 404 {
+ config = ClassMapData{Device: config.Device}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
+ return
+ }
+
+ config.fromBody(ctx, res.Res)
+ }
} else {
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
+ }
+
+ filter := helpers.GetXpathFilter(config.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
if err != nil {
resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
return
}
- config.fromBody(ctx, res.Res)
+ config.fromBodyXML(ctx, res.Res)
}
config.Id = types.StringValue(config.getPath())
diff --git a/internal/provider/data_source_iosxe_clock.go b/internal/provider/data_source_iosxe_clock.go
index 8dcce318..f433faaa 100644
--- a/internal/provider/data_source_iosxe_clock.go
+++ b/internal/provider/data_source_iosxe_clock.go
@@ -24,6 +24,7 @@ import (
"context"
"fmt"
+ "github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
"github.com/hashicorp/terraform-plugin-framework/path"
@@ -201,16 +202,37 @@ func (d *ClockDataSource) Read(ctx context.Context, req datasource.ReadRequest,
return
}
- res, err := device.Client.GetData(config.getPath())
- if res.StatusCode == 404 {
- config = ClockData{Device: config.Device}
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(config.getPath())
+ if res.StatusCode == 404 {
+ config = ClockData{Device: config.Device}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
+ return
+ }
+
+ config.fromBody(ctx, res.Res)
+ }
} else {
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
+ }
+
+ filter := helpers.GetXpathFilter(config.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
if err != nil {
resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
return
}
- config.fromBody(ctx, res.Res)
+ config.fromBodyXML(ctx, res.Res)
}
config.Id = types.StringValue(config.getPath())
diff --git a/internal/provider/data_source_iosxe_community_list_expanded.go b/internal/provider/data_source_iosxe_community_list_expanded.go
index ac4737d8..3a498ee4 100644
--- a/internal/provider/data_source_iosxe_community_list_expanded.go
+++ b/internal/provider/data_source_iosxe_community_list_expanded.go
@@ -24,6 +24,7 @@ import (
"context"
"fmt"
+ "github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
"github.com/hashicorp/terraform-plugin-framework/path"
@@ -121,16 +122,37 @@ func (d *CommunityListExpandedDataSource) Read(ctx context.Context, req datasour
return
}
- res, err := device.Client.GetData(config.getPath())
- if res.StatusCode == 404 {
- config = CommunityListExpandedData{Device: config.Device}
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(config.getPath())
+ if res.StatusCode == 404 {
+ config = CommunityListExpandedData{Device: config.Device}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
+ return
+ }
+
+ config.fromBody(ctx, res.Res)
+ }
} else {
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
+ }
+
+ filter := helpers.GetXpathFilter(config.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
if err != nil {
resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
return
}
- config.fromBody(ctx, res.Res)
+ config.fromBodyXML(ctx, res.Res)
}
config.Id = types.StringValue(config.getPath())
diff --git a/internal/provider/data_source_iosxe_community_list_standard.go b/internal/provider/data_source_iosxe_community_list_standard.go
index 24f6e9ba..3f16559a 100644
--- a/internal/provider/data_source_iosxe_community_list_standard.go
+++ b/internal/provider/data_source_iosxe_community_list_standard.go
@@ -24,6 +24,7 @@ import (
"context"
"fmt"
+ "github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
"github.com/hashicorp/terraform-plugin-framework/path"
@@ -115,16 +116,37 @@ func (d *CommunityListStandardDataSource) Read(ctx context.Context, req datasour
return
}
- res, err := device.Client.GetData(config.getPath())
- if res.StatusCode == 404 {
- config = CommunityListStandardData{Device: config.Device}
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(config.getPath())
+ if res.StatusCode == 404 {
+ config = CommunityListStandardData{Device: config.Device}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
+ return
+ }
+
+ config.fromBody(ctx, res.Res)
+ }
} else {
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
+ }
+
+ filter := helpers.GetXpathFilter(config.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
if err != nil {
resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
return
}
- config.fromBody(ctx, res.Res)
+ config.fromBodyXML(ctx, res.Res)
}
config.Id = types.StringValue(config.getPath())
diff --git a/internal/provider/data_source_iosxe_crypto_ikev2.go b/internal/provider/data_source_iosxe_crypto_ikev2.go
index 84991d52..ebccf48a 100644
--- a/internal/provider/data_source_iosxe_crypto_ikev2.go
+++ b/internal/provider/data_source_iosxe_crypto_ikev2.go
@@ -24,6 +24,7 @@ import (
"context"
"fmt"
+ "github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
"github.com/hashicorp/terraform-plugin-framework/path"
@@ -121,16 +122,37 @@ func (d *CryptoIKEv2DataSource) Read(ctx context.Context, req datasource.ReadReq
return
}
- res, err := device.Client.GetData(config.getPath())
- if res.StatusCode == 404 {
- config = CryptoIKEv2Data{Device: config.Device}
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(config.getPath())
+ if res.StatusCode == 404 {
+ config = CryptoIKEv2Data{Device: config.Device}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
+ return
+ }
+
+ config.fromBody(ctx, res.Res)
+ }
} else {
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
+ }
+
+ filter := helpers.GetXpathFilter(config.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
if err != nil {
resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
return
}
- config.fromBody(ctx, res.Res)
+ config.fromBodyXML(ctx, res.Res)
}
config.Id = types.StringValue(config.getPath())
diff --git a/internal/provider/data_source_iosxe_crypto_ikev2_keyring.go b/internal/provider/data_source_iosxe_crypto_ikev2_keyring.go
index 33eec21e..e697f99f 100644
--- a/internal/provider/data_source_iosxe_crypto_ikev2_keyring.go
+++ b/internal/provider/data_source_iosxe_crypto_ikev2_keyring.go
@@ -24,6 +24,7 @@ import (
"context"
"fmt"
+ "github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
"github.com/hashicorp/terraform-plugin-framework/path"
@@ -188,16 +189,37 @@ func (d *CryptoIKEv2KeyringDataSource) Read(ctx context.Context, req datasource.
return
}
- res, err := device.Client.GetData(config.getPath())
- if res.StatusCode == 404 {
- config = CryptoIKEv2KeyringData{Device: config.Device}
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(config.getPath())
+ if res.StatusCode == 404 {
+ config = CryptoIKEv2KeyringData{Device: config.Device}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
+ return
+ }
+
+ config.fromBody(ctx, res.Res)
+ }
} else {
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
+ }
+
+ filter := helpers.GetXpathFilter(config.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
if err != nil {
resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
return
}
- config.fromBody(ctx, res.Res)
+ config.fromBodyXML(ctx, res.Res)
}
config.Id = types.StringValue(config.getPath())
diff --git a/internal/provider/data_source_iosxe_crypto_ikev2_policy.go b/internal/provider/data_source_iosxe_crypto_ikev2_policy.go
index be3b4d31..3d00e260 100644
--- a/internal/provider/data_source_iosxe_crypto_ikev2_policy.go
+++ b/internal/provider/data_source_iosxe_crypto_ikev2_policy.go
@@ -24,6 +24,7 @@ import (
"context"
"fmt"
+ "github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
"github.com/hashicorp/terraform-plugin-framework/path"
@@ -134,16 +135,37 @@ func (d *CryptoIKEv2PolicyDataSource) Read(ctx context.Context, req datasource.R
return
}
- res, err := device.Client.GetData(config.getPath())
- if res.StatusCode == 404 {
- config = CryptoIKEv2PolicyData{Device: config.Device}
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(config.getPath())
+ if res.StatusCode == 404 {
+ config = CryptoIKEv2PolicyData{Device: config.Device}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
+ return
+ }
+
+ config.fromBody(ctx, res.Res)
+ }
} else {
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
+ }
+
+ filter := helpers.GetXpathFilter(config.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
if err != nil {
resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
return
}
- config.fromBody(ctx, res.Res)
+ config.fromBodyXML(ctx, res.Res)
}
config.Id = types.StringValue(config.getPath())
diff --git a/internal/provider/data_source_iosxe_crypto_ikev2_policy_test.go b/internal/provider/data_source_iosxe_crypto_ikev2_policy_test.go
index 5d237bb6..f79ecfb5 100644
--- a/internal/provider/data_source_iosxe_crypto_ikev2_policy_test.go
+++ b/internal/provider/data_source_iosxe_crypto_ikev2_policy_test.go
@@ -51,8 +51,8 @@ func TestAccDataSourceIosxeCryptoIKEv2Policy(t *testing.T) {
// Section below is generated&owned by "gen/generator.go". //template:begin testPrerequisites
const testAccDataSourceIosxeCryptoIKEv2PolicyPrerequisitesConfig = `
-resource "iosxe_restconf" "PreReq0" {
- path = "Cisco-IOS-XE-native:native/crypto/Cisco-IOS-XE-crypto:ikev2/proposal=proposal123"
+resource "iosxe_yang" "PreReq0" {
+ path = "/Cisco-IOS-XE-native:native/crypto/Cisco-IOS-XE-crypto:ikev2/proposal[name=proposal123]"
attributes = {
"name" = "proposal123"
"encryption/aes-cbc-256" = ""
@@ -75,7 +75,7 @@ func testAccDataSourceIosxeCryptoIKEv2PolicyConfig() string {
config += ` proposals = [{` + "\n"
config += ` proposals = "proposal123"` + "\n"
config += ` }]` + "\n"
- config += ` depends_on = [iosxe_restconf.PreReq0, ]` + "\n"
+ config += ` depends_on = [iosxe_yang.PreReq0, ]` + "\n"
config += `}` + "\n"
config += `
diff --git a/internal/provider/data_source_iosxe_crypto_ikev2_profile.go b/internal/provider/data_source_iosxe_crypto_ikev2_profile.go
index 292bea50..1fec61c9 100644
--- a/internal/provider/data_source_iosxe_crypto_ikev2_profile.go
+++ b/internal/provider/data_source_iosxe_crypto_ikev2_profile.go
@@ -24,6 +24,7 @@ import (
"context"
"fmt"
+ "github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
"github.com/hashicorp/terraform-plugin-framework/path"
@@ -191,16 +192,37 @@ func (d *CryptoIKEv2ProfileDataSource) Read(ctx context.Context, req datasource.
return
}
- res, err := device.Client.GetData(config.getPath())
- if res.StatusCode == 404 {
- config = CryptoIKEv2ProfileData{Device: config.Device}
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(config.getPath())
+ if res.StatusCode == 404 {
+ config = CryptoIKEv2ProfileData{Device: config.Device}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
+ return
+ }
+
+ config.fromBody(ctx, res.Res)
+ }
} else {
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
+ }
+
+ filter := helpers.GetXpathFilter(config.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
if err != nil {
resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
return
}
- config.fromBody(ctx, res.Res)
+ config.fromBodyXML(ctx, res.Res)
}
config.Id = types.StringValue(config.getPath())
diff --git a/internal/provider/data_source_iosxe_crypto_ikev2_profile_test.go b/internal/provider/data_source_iosxe_crypto_ikev2_profile_test.go
index c5efaf5f..27a65ca9 100644
--- a/internal/provider/data_source_iosxe_crypto_ikev2_profile_test.go
+++ b/internal/provider/data_source_iosxe_crypto_ikev2_profile_test.go
@@ -63,15 +63,15 @@ func TestAccDataSourceIosxeCryptoIKEv2Profile(t *testing.T) {
// Section below is generated&owned by "gen/generator.go". //template:begin testPrerequisites
const testAccDataSourceIosxeCryptoIKEv2ProfilePrerequisitesConfig = `
-resource "iosxe_restconf" "PreReq0" {
- path = "Cisco-IOS-XE-native:native/crypto/Cisco-IOS-XE-crypto:ikev2/keyring=test"
+resource "iosxe_yang" "PreReq0" {
+ path = "/Cisco-IOS-XE-native:native/crypto/Cisco-IOS-XE-crypto:ikev2/keyring[name=test]"
attributes = {
"name" = "test"
}
}
-resource "iosxe_restconf" "PreReq1" {
- path = "Cisco-IOS-XE-native:native/vrf/definition=VRF1"
+resource "iosxe_yang" "PreReq1" {
+ path = "/Cisco-IOS-XE-native:native/vrf/definition[name=VRF1]"
delete = false
attributes = {
"name" = "VRF1"
@@ -106,7 +106,7 @@ func testAccDataSourceIosxeCryptoIKEv2ProfileConfig() string {
config += ` dpd_retry = 2` + "\n"
config += ` dpd_query = "periodic"` + "\n"
config += ` config_exchange_request = false` + "\n"
- config += ` depends_on = [iosxe_restconf.PreReq0, iosxe_restconf.PreReq1, ]` + "\n"
+ config += ` depends_on = [iosxe_yang.PreReq0, iosxe_yang.PreReq1, ]` + "\n"
config += `}` + "\n"
config += `
diff --git a/internal/provider/data_source_iosxe_crypto_ikev2_proposal.go b/internal/provider/data_source_iosxe_crypto_ikev2_proposal.go
index 62c2f2b7..f22c1e8c 100644
--- a/internal/provider/data_source_iosxe_crypto_ikev2_proposal.go
+++ b/internal/provider/data_source_iosxe_crypto_ikev2_proposal.go
@@ -24,6 +24,7 @@ import (
"context"
"fmt"
+ "github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
"github.com/hashicorp/terraform-plugin-framework/path"
@@ -205,16 +206,37 @@ func (d *CryptoIKEv2ProposalDataSource) Read(ctx context.Context, req datasource
return
}
- res, err := device.Client.GetData(config.getPath())
- if res.StatusCode == 404 {
- config = CryptoIKEv2ProposalData{Device: config.Device}
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(config.getPath())
+ if res.StatusCode == 404 {
+ config = CryptoIKEv2ProposalData{Device: config.Device}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
+ return
+ }
+
+ config.fromBody(ctx, res.Res)
+ }
} else {
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
+ }
+
+ filter := helpers.GetXpathFilter(config.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
if err != nil {
resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
return
}
- config.fromBody(ctx, res.Res)
+ config.fromBodyXML(ctx, res.Res)
}
config.Id = types.StringValue(config.getPath())
diff --git a/internal/provider/data_source_iosxe_crypto_ipsec_profile.go b/internal/provider/data_source_iosxe_crypto_ipsec_profile.go
index fcaab872..3aba8b85 100644
--- a/internal/provider/data_source_iosxe_crypto_ipsec_profile.go
+++ b/internal/provider/data_source_iosxe_crypto_ipsec_profile.go
@@ -24,6 +24,7 @@ import (
"context"
"fmt"
+ "github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
"github.com/hashicorp/terraform-plugin-framework/path"
@@ -118,16 +119,37 @@ func (d *CryptoIPSecProfileDataSource) Read(ctx context.Context, req datasource.
return
}
- res, err := device.Client.GetData(config.getPath())
- if res.StatusCode == 404 {
- config = CryptoIPSecProfileData{Device: config.Device}
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(config.getPath())
+ if res.StatusCode == 404 {
+ config = CryptoIPSecProfileData{Device: config.Device}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
+ return
+ }
+
+ config.fromBody(ctx, res.Res)
+ }
} else {
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
+ }
+
+ filter := helpers.GetXpathFilter(config.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
if err != nil {
resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
return
}
- config.fromBody(ctx, res.Res)
+ config.fromBodyXML(ctx, res.Res)
}
config.Id = types.StringValue(config.getPath())
diff --git a/internal/provider/data_source_iosxe_crypto_ipsec_profile_test.go b/internal/provider/data_source_iosxe_crypto_ipsec_profile_test.go
index cb7df9d5..7586f874 100644
--- a/internal/provider/data_source_iosxe_crypto_ipsec_profile_test.go
+++ b/internal/provider/data_source_iosxe_crypto_ipsec_profile_test.go
@@ -50,8 +50,8 @@ func TestAccDataSourceIosxeCryptoIPSecProfile(t *testing.T) {
// Section below is generated&owned by "gen/generator.go". //template:begin testPrerequisites
const testAccDataSourceIosxeCryptoIPSecProfilePrerequisitesConfig = `
-resource "iosxe_restconf" "PreReq0" {
- path = "Cisco-IOS-XE-native:native/crypto/Cisco-IOS-XE-crypto:ipsec/transform-set=TS1"
+resource "iosxe_yang" "PreReq0" {
+ path = "/Cisco-IOS-XE-native:native/crypto/Cisco-IOS-XE-crypto:ipsec/transform-set[tag=TS1]"
attributes = {
"tag" = "TS1"
"esp" = "esp-aes"
@@ -59,8 +59,8 @@ resource "iosxe_restconf" "PreReq0" {
}
}
-resource "iosxe_restconf" "PreReq1" {
- path = "Cisco-IOS-XE-native:native/crypto/Cisco-IOS-XE-crypto:ikev2/profile=vpn300"
+resource "iosxe_yang" "PreReq1" {
+ path = "/Cisco-IOS-XE-native:native/crypto/Cisco-IOS-XE-crypto:ikev2/profile[name=vpn300]"
attributes = {
"name" = "vpn300"
"aaa/authentication/anyconnect-eap" = "attached"
@@ -78,7 +78,7 @@ func testAccDataSourceIosxeCryptoIPSecProfileConfig() string {
config += ` name = "vpn200"` + "\n"
config += ` set_transform_set = ["TS1"]` + "\n"
config += ` set_ikev2_profile = "vpn300"` + "\n"
- config += ` depends_on = [iosxe_restconf.PreReq0, iosxe_restconf.PreReq1, ]` + "\n"
+ config += ` depends_on = [iosxe_yang.PreReq0, iosxe_yang.PreReq1, ]` + "\n"
config += `}` + "\n"
config += `
diff --git a/internal/provider/data_source_iosxe_crypto_ipsec_transform_set.go b/internal/provider/data_source_iosxe_crypto_ipsec_transform_set.go
index f8446334..bc54db21 100644
--- a/internal/provider/data_source_iosxe_crypto_ipsec_transform_set.go
+++ b/internal/provider/data_source_iosxe_crypto_ipsec_transform_set.go
@@ -24,6 +24,7 @@ import (
"context"
"fmt"
+ "github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
"github.com/hashicorp/terraform-plugin-framework/path"
@@ -117,16 +118,37 @@ func (d *CryptoIPSecTransformSetDataSource) Read(ctx context.Context, req dataso
return
}
- res, err := device.Client.GetData(config.getPath())
- if res.StatusCode == 404 {
- config = CryptoIPSecTransformSetData{Device: config.Device}
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(config.getPath())
+ if res.StatusCode == 404 {
+ config = CryptoIPSecTransformSetData{Device: config.Device}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
+ return
+ }
+
+ config.fromBody(ctx, res.Res)
+ }
} else {
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
+ }
+
+ filter := helpers.GetXpathFilter(config.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
if err != nil {
resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
return
}
- config.fromBody(ctx, res.Res)
+ config.fromBodyXML(ctx, res.Res)
}
config.Id = types.StringValue(config.getPath())
diff --git a/internal/provider/data_source_iosxe_crypto_pki.go b/internal/provider/data_source_iosxe_crypto_pki.go
index cb61a40c..59a70c11 100644
--- a/internal/provider/data_source_iosxe_crypto_pki.go
+++ b/internal/provider/data_source_iosxe_crypto_pki.go
@@ -24,6 +24,7 @@ import (
"context"
"fmt"
+ "github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
"github.com/hashicorp/terraform-plugin-framework/path"
@@ -154,16 +155,37 @@ func (d *CryptoPKIDataSource) Read(ctx context.Context, req datasource.ReadReque
return
}
- res, err := device.Client.GetData(config.getPath())
- if res.StatusCode == 404 {
- config = CryptoPKIData{Device: config.Device}
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(config.getPath())
+ if res.StatusCode == 404 {
+ config = CryptoPKIData{Device: config.Device}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
+ return
+ }
+
+ config.fromBody(ctx, res.Res)
+ }
} else {
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
+ }
+
+ filter := helpers.GetXpathFilter(config.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
if err != nil {
resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
return
}
- config.fromBody(ctx, res.Res)
+ config.fromBodyXML(ctx, res.Res)
}
config.Id = types.StringValue(config.getPath())
diff --git a/internal/provider/data_source_iosxe_cts.go b/internal/provider/data_source_iosxe_cts.go
index a721742f..49d4ec82 100644
--- a/internal/provider/data_source_iosxe_cts.go
+++ b/internal/provider/data_source_iosxe_cts.go
@@ -24,6 +24,7 @@ import (
"context"
"fmt"
+ "github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
"github.com/hashicorp/terraform-plugin-framework/path"
@@ -234,16 +235,37 @@ func (d *CTSDataSource) Read(ctx context.Context, req datasource.ReadRequest, re
return
}
- res, err := device.Client.GetData(config.getPath())
- if res.StatusCode == 404 {
- config = CTSData{Device: config.Device}
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(config.getPath())
+ if res.StatusCode == 404 {
+ config = CTSData{Device: config.Device}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
+ return
+ }
+
+ config.fromBody(ctx, res.Res)
+ }
} else {
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
+ }
+
+ filter := helpers.GetXpathFilter(config.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
if err != nil {
resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
return
}
- config.fromBody(ctx, res.Res)
+ config.fromBodyXML(ctx, res.Res)
}
config.Id = types.StringValue(config.getPath())
diff --git a/internal/provider/data_source_iosxe_cts_test.go b/internal/provider/data_source_iosxe_cts_test.go
index f838f0d7..14df871b 100644
--- a/internal/provider/data_source_iosxe_cts_test.go
+++ b/internal/provider/data_source_iosxe_cts_test.go
@@ -74,8 +74,8 @@ func TestAccDataSourceIosxeCTS(t *testing.T) {
// Section below is generated&owned by "gen/generator.go". //template:begin testPrerequisites
const testAccDataSourceIosxeCTSPrerequisitesConfig = `
-resource "iosxe_restconf" "PreReq0" {
- path = "Cisco-IOS-XE-native:native/vrf/definition=VRF1"
+resource "iosxe_yang" "PreReq0" {
+ path = "/Cisco-IOS-XE-native:native/vrf/definition[name=VRF1]"
delete = false
attributes = {
"name" = "VRF1"
@@ -123,7 +123,7 @@ func testAccDataSourceIosxeCTSConfig() string {
config += ` sxp_listener_hold_max_time = 300` + "\n"
config += ` role_based_enforcement = true` + "\n"
config += ` role_based_enforcement_logging_interval = 300` + "\n"
- config += ` depends_on = [iosxe_restconf.PreReq0, ]` + "\n"
+ config += ` depends_on = [iosxe_yang.PreReq0, ]` + "\n"
config += `}` + "\n"
config += `
diff --git a/internal/provider/data_source_iosxe_device_sensor.go b/internal/provider/data_source_iosxe_device_sensor.go
index c6f6f6d0..a4933795 100644
--- a/internal/provider/data_source_iosxe_device_sensor.go
+++ b/internal/provider/data_source_iosxe_device_sensor.go
@@ -24,6 +24,7 @@ import (
"context"
"fmt"
+ "github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
"github.com/hashicorp/terraform-plugin-framework/path"
@@ -281,16 +282,37 @@ func (d *DeviceSensorDataSource) Read(ctx context.Context, req datasource.ReadRe
return
}
- res, err := device.Client.GetData(config.getPath())
- if res.StatusCode == 404 {
- config = DeviceSensorData{Device: config.Device}
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(config.getPath())
+ if res.StatusCode == 404 {
+ config = DeviceSensorData{Device: config.Device}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
+ return
+ }
+
+ config.fromBody(ctx, res.Res)
+ }
} else {
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
+ }
+
+ filter := helpers.GetXpathFilter(config.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
if err != nil {
resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
return
}
- config.fromBody(ctx, res.Res)
+ config.fromBodyXML(ctx, res.Res)
}
config.Id = types.StringValue(config.getPath())
diff --git a/internal/provider/data_source_iosxe_dhcp.go b/internal/provider/data_source_iosxe_dhcp.go
index 80df4d83..ed6f1c8e 100644
--- a/internal/provider/data_source_iosxe_dhcp.go
+++ b/internal/provider/data_source_iosxe_dhcp.go
@@ -24,6 +24,7 @@ import (
"context"
"fmt"
+ "github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
"github.com/hashicorp/terraform-plugin-framework/path"
@@ -165,16 +166,37 @@ func (d *DHCPDataSource) Read(ctx context.Context, req datasource.ReadRequest, r
return
}
- res, err := device.Client.GetData(config.getPath())
- if res.StatusCode == 404 {
- config = DHCPData{Device: config.Device}
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(config.getPath())
+ if res.StatusCode == 404 {
+ config = DHCPData{Device: config.Device}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
+ return
+ }
+
+ config.fromBody(ctx, res.Res)
+ }
} else {
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
+ }
+
+ filter := helpers.GetXpathFilter(config.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
if err != nil {
resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
return
}
- config.fromBody(ctx, res.Res)
+ config.fromBodyXML(ctx, res.Res)
}
config.Id = types.StringValue(config.getPath())
diff --git a/internal/provider/data_source_iosxe_dot1x.go b/internal/provider/data_source_iosxe_dot1x.go
index 261f061b..17952ca2 100644
--- a/internal/provider/data_source_iosxe_dot1x.go
+++ b/internal/provider/data_source_iosxe_dot1x.go
@@ -24,6 +24,7 @@ import (
"context"
"fmt"
+ "github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
"github.com/hashicorp/terraform-plugin-framework/path"
@@ -182,16 +183,37 @@ func (d *Dot1xDataSource) Read(ctx context.Context, req datasource.ReadRequest,
return
}
- res, err := device.Client.GetData(config.getPath())
- if res.StatusCode == 404 {
- config = Dot1xData{Device: config.Device}
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(config.getPath())
+ if res.StatusCode == 404 {
+ config = Dot1xData{Device: config.Device}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
+ return
+ }
+
+ config.fromBody(ctx, res.Res)
+ }
} else {
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
+ }
+
+ filter := helpers.GetXpathFilter(config.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
if err != nil {
resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
return
}
- config.fromBody(ctx, res.Res)
+ config.fromBodyXML(ctx, res.Res)
}
config.Id = types.StringValue(config.getPath())
diff --git a/internal/provider/data_source_iosxe_eem.go b/internal/provider/data_source_iosxe_eem.go
index 3e444afa..53c32a4d 100644
--- a/internal/provider/data_source_iosxe_eem.go
+++ b/internal/provider/data_source_iosxe_eem.go
@@ -24,6 +24,7 @@ import (
"context"
"fmt"
+ "github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
"github.com/hashicorp/terraform-plugin-framework/path"
@@ -505,16 +506,37 @@ func (d *EEMDataSource) Read(ctx context.Context, req datasource.ReadRequest, re
return
}
- res, err := device.Client.GetData(config.getPath())
- if res.StatusCode == 404 {
- config = EEMData{Device: config.Device}
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(config.getPath())
+ if res.StatusCode == 404 {
+ config = EEMData{Device: config.Device}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
+ return
+ }
+
+ config.fromBody(ctx, res.Res)
+ }
} else {
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
+ }
+
+ filter := helpers.GetXpathFilter(config.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
if err != nil {
resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
return
}
- config.fromBody(ctx, res.Res)
+ config.fromBodyXML(ctx, res.Res)
}
config.Id = types.StringValue(config.getPath())
diff --git a/internal/provider/data_source_iosxe_errdisable.go b/internal/provider/data_source_iosxe_errdisable.go
index bcc3bcab..f0f877e2 100644
--- a/internal/provider/data_source_iosxe_errdisable.go
+++ b/internal/provider/data_source_iosxe_errdisable.go
@@ -24,6 +24,7 @@ import (
"context"
"fmt"
+ "github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
"github.com/hashicorp/terraform-plugin-framework/path"
@@ -313,16 +314,37 @@ func (d *ErrdisableDataSource) Read(ctx context.Context, req datasource.ReadRequ
return
}
- res, err := device.Client.GetData(config.getPath())
- if res.StatusCode == 404 {
- config = ErrdisableData{Device: config.Device}
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(config.getPath())
+ if res.StatusCode == 404 {
+ config = ErrdisableData{Device: config.Device}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
+ return
+ }
+
+ config.fromBody(ctx, res.Res)
+ }
} else {
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
+ }
+
+ filter := helpers.GetXpathFilter(config.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
if err != nil {
resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
return
}
- config.fromBody(ctx, res.Res)
+ config.fromBodyXML(ctx, res.Res)
}
config.Id = types.StringValue(config.getPath())
diff --git a/internal/provider/data_source_iosxe_evpn.go b/internal/provider/data_source_iosxe_evpn.go
index 128139c9..156afd4a 100644
--- a/internal/provider/data_source_iosxe_evpn.go
+++ b/internal/provider/data_source_iosxe_evpn.go
@@ -24,6 +24,7 @@ import (
"context"
"fmt"
+ "github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
"github.com/hashicorp/terraform-plugin-framework/path"
@@ -157,16 +158,37 @@ func (d *EVPNDataSource) Read(ctx context.Context, req datasource.ReadRequest, r
return
}
- res, err := device.Client.GetData(config.getPath())
- if res.StatusCode == 404 {
- config = EVPNData{Device: config.Device}
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(config.getPath())
+ if res.StatusCode == 404 {
+ config = EVPNData{Device: config.Device}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
+ return
+ }
+
+ config.fromBody(ctx, res.Res)
+ }
} else {
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
+ }
+
+ filter := helpers.GetXpathFilter(config.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
if err != nil {
resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
return
}
- config.fromBody(ctx, res.Res)
+ config.fromBodyXML(ctx, res.Res)
}
config.Id = types.StringValue(config.getPath())
diff --git a/internal/provider/data_source_iosxe_evpn_instance.go b/internal/provider/data_source_iosxe_evpn_instance.go
index ba84d278..7a787b9d 100644
--- a/internal/provider/data_source_iosxe_evpn_instance.go
+++ b/internal/provider/data_source_iosxe_evpn_instance.go
@@ -24,6 +24,7 @@ import (
"context"
"fmt"
+ "github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
"github.com/hashicorp/terraform-plugin-framework/path"
@@ -193,16 +194,37 @@ func (d *EVPNInstanceDataSource) Read(ctx context.Context, req datasource.ReadRe
return
}
- res, err := device.Client.GetData(config.getPath())
- if res.StatusCode == 404 {
- config = EVPNInstanceData{Device: config.Device}
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(config.getPath())
+ if res.StatusCode == 404 {
+ config = EVPNInstanceData{Device: config.Device}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
+ return
+ }
+
+ config.fromBody(ctx, res.Res)
+ }
} else {
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
+ }
+
+ filter := helpers.GetXpathFilter(config.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
if err != nil {
resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
return
}
- config.fromBody(ctx, res.Res)
+ config.fromBodyXML(ctx, res.Res)
}
config.Id = types.StringValue(config.getPath())
diff --git a/internal/provider/data_source_iosxe_flow_exporter.go b/internal/provider/data_source_iosxe_flow_exporter.go
index 71a8ca32..19c22728 100644
--- a/internal/provider/data_source_iosxe_flow_exporter.go
+++ b/internal/provider/data_source_iosxe_flow_exporter.go
@@ -24,6 +24,7 @@ import (
"context"
"fmt"
+ "github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
"github.com/hashicorp/terraform-plugin-framework/path"
@@ -149,16 +150,37 @@ func (d *FlowExporterDataSource) Read(ctx context.Context, req datasource.ReadRe
return
}
- res, err := device.Client.GetData(config.getPath())
- if res.StatusCode == 404 {
- config = FlowExporterData{Device: config.Device}
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(config.getPath())
+ if res.StatusCode == 404 {
+ config = FlowExporterData{Device: config.Device}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
+ return
+ }
+
+ config.fromBody(ctx, res.Res)
+ }
} else {
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
+ }
+
+ filter := helpers.GetXpathFilter(config.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
if err != nil {
resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
return
}
- config.fromBody(ctx, res.Res)
+ config.fromBodyXML(ctx, res.Res)
}
config.Id = types.StringValue(config.getPath())
diff --git a/internal/provider/data_source_iosxe_flow_monitor.go b/internal/provider/data_source_iosxe_flow_monitor.go
index 45f704e5..7d240901 100644
--- a/internal/provider/data_source_iosxe_flow_monitor.go
+++ b/internal/provider/data_source_iosxe_flow_monitor.go
@@ -24,6 +24,7 @@ import (
"context"
"fmt"
+ "github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
"github.com/hashicorp/terraform-plugin-framework/path"
@@ -133,16 +134,37 @@ func (d *FlowMonitorDataSource) Read(ctx context.Context, req datasource.ReadReq
return
}
- res, err := device.Client.GetData(config.getPath())
- if res.StatusCode == 404 {
- config = FlowMonitorData{Device: config.Device}
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(config.getPath())
+ if res.StatusCode == 404 {
+ config = FlowMonitorData{Device: config.Device}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
+ return
+ }
+
+ config.fromBody(ctx, res.Res)
+ }
} else {
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
+ }
+
+ filter := helpers.GetXpathFilter(config.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
if err != nil {
resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
return
}
- config.fromBody(ctx, res.Res)
+ config.fromBodyXML(ctx, res.Res)
}
config.Id = types.StringValue(config.getPath())
diff --git a/internal/provider/data_source_iosxe_flow_monitor_test.go b/internal/provider/data_source_iosxe_flow_monitor_test.go
index 2f20b3d4..d089176b 100644
--- a/internal/provider/data_source_iosxe_flow_monitor_test.go
+++ b/internal/provider/data_source_iosxe_flow_monitor_test.go
@@ -53,15 +53,15 @@ func TestAccDataSourceIosxeFlowMonitor(t *testing.T) {
// Section below is generated&owned by "gen/generator.go". //template:begin testPrerequisites
const testAccDataSourceIosxeFlowMonitorPrerequisitesConfig = `
-resource "iosxe_restconf" "PreReq0" {
- path = "Cisco-IOS-XE-native:native/flow/Cisco-IOS-XE-flow:exporter=EXPORTER1"
+resource "iosxe_yang" "PreReq0" {
+ path = "/Cisco-IOS-XE-native:native/flow/Cisco-IOS-XE-flow:exporter[name=EXPORTER1]"
attributes = {
"name" = "EXPORTER1"
}
}
-resource "iosxe_restconf" "PreReq1" {
- path = "Cisco-IOS-XE-native:native/flow/Cisco-IOS-XE-flow:record=FNF1"
+resource "iosxe_yang" "PreReq1" {
+ path = "/Cisco-IOS-XE-native:native/flow/Cisco-IOS-XE-flow:record[name=FNF1]"
attributes = {
"name" = "FNF1"
}
@@ -84,7 +84,7 @@ func testAccDataSourceIosxeFlowMonitorConfig() string {
config += ` cache_timeout_active = 60` + "\n"
config += ` cache_timeout_inactive = 10` + "\n"
config += ` record = "FNF1"` + "\n"
- config += ` depends_on = [iosxe_restconf.PreReq0, iosxe_restconf.PreReq1, ]` + "\n"
+ config += ` depends_on = [iosxe_yang.PreReq0, iosxe_yang.PreReq1, ]` + "\n"
config += `}` + "\n"
config += `
diff --git a/internal/provider/data_source_iosxe_flow_record.go b/internal/provider/data_source_iosxe_flow_record.go
index bd9f7dd8..65cd587c 100644
--- a/internal/provider/data_source_iosxe_flow_record.go
+++ b/internal/provider/data_source_iosxe_flow_record.go
@@ -24,6 +24,7 @@ import (
"context"
"fmt"
+ "github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
"github.com/hashicorp/terraform-plugin-framework/path"
@@ -237,16 +238,37 @@ func (d *FlowRecordDataSource) Read(ctx context.Context, req datasource.ReadRequ
return
}
- res, err := device.Client.GetData(config.getPath())
- if res.StatusCode == 404 {
- config = FlowRecordData{Device: config.Device}
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(config.getPath())
+ if res.StatusCode == 404 {
+ config = FlowRecordData{Device: config.Device}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
+ return
+ }
+
+ config.fromBody(ctx, res.Res)
+ }
} else {
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
+ }
+
+ filter := helpers.GetXpathFilter(config.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
if err != nil {
resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
return
}
- config.fromBody(ctx, res.Res)
+ config.fromBodyXML(ctx, res.Res)
}
config.Id = types.StringValue(config.getPath())
diff --git a/internal/provider/data_source_iosxe_interface_ethernet.go b/internal/provider/data_source_iosxe_interface_ethernet.go
index 8cf3ce6b..c0771b37 100644
--- a/internal/provider/data_source_iosxe_interface_ethernet.go
+++ b/internal/provider/data_source_iosxe_interface_ethernet.go
@@ -24,6 +24,7 @@ import (
"context"
"fmt"
+ "github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
"github.com/hashicorp/terraform-plugin-framework/path"
@@ -709,16 +710,37 @@ func (d *InterfaceEthernetDataSource) Read(ctx context.Context, req datasource.R
return
}
- res, err := device.Client.GetData(config.getPath())
- if res.StatusCode == 404 {
- config = InterfaceEthernetData{Device: config.Device}
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(config.getPath())
+ if res.StatusCode == 404 {
+ config = InterfaceEthernetData{Device: config.Device}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
+ return
+ }
+
+ config.fromBody(ctx, res.Res)
+ }
} else {
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
+ }
+
+ filter := helpers.GetXpathFilter(config.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
if err != nil {
resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
return
}
- config.fromBody(ctx, res.Res)
+ config.fromBodyXML(ctx, res.Res)
}
config.Id = types.StringValue(config.getPath())
diff --git a/internal/provider/data_source_iosxe_interface_ethernet_test.go b/internal/provider/data_source_iosxe_interface_ethernet_test.go
index 3605a123..876f495d 100644
--- a/internal/provider/data_source_iosxe_interface_ethernet_test.go
+++ b/internal/provider/data_source_iosxe_interface_ethernet_test.go
@@ -112,8 +112,8 @@ func TestAccDataSourceIosxeInterfaceEthernet(t *testing.T) {
// Section below is generated&owned by "gen/generator.go". //template:begin testPrerequisites
const testAccDataSourceIosxeInterfaceEthernetPrerequisitesConfig = `
-resource "iosxe_restconf" "PreReq0" {
- path = "Cisco-IOS-XE-native:native/vrf/definition=VRF1"
+resource "iosxe_yang" "PreReq0" {
+ path = "/Cisco-IOS-XE-native:native/vrf/definition[name=VRF1]"
delete = false
attributes = {
"name" = "VRF1"
@@ -121,15 +121,15 @@ resource "iosxe_restconf" "PreReq0" {
}
}
-resource "iosxe_restconf" "PreReq1" {
- path = "Cisco-IOS-XE-native:native/policy/Cisco-IOS-XE-policy:policy-map=POLICY1"
+resource "iosxe_yang" "PreReq1" {
+ path = "/Cisco-IOS-XE-native:native/policy/Cisco-IOS-XE-policy:policy-map[name=POLICY1]"
attributes = {
"name" = "POLICY1"
}
}
-resource "iosxe_restconf" "PreReq2" {
- path = "Cisco-IOS-XE-native:native/flow/Cisco-IOS-XE-flow:record=REC1"
+resource "iosxe_yang" "PreReq2" {
+ path = "/Cisco-IOS-XE-native:native/flow/Cisco-IOS-XE-flow:record[name=REC1]"
attributes = {
"name" = "REC1"
"match/ipv4/source/address" = ""
@@ -137,17 +137,17 @@ resource "iosxe_restconf" "PreReq2" {
}
}
-resource "iosxe_restconf" "PreReq3" {
- path = "Cisco-IOS-XE-native:native/flow/Cisco-IOS-XE-flow:monitor=MON1"
+resource "iosxe_yang" "PreReq3" {
+ path = "/Cisco-IOS-XE-native:native/flow/Cisco-IOS-XE-flow:monitor[name=MON1]"
attributes = {
"name" = "MON1"
"record/type" = "REC1"
}
- depends_on = [iosxe_restconf.PreReq2, ]
+ depends_on = [iosxe_yang.PreReq2, ]
}
-resource "iosxe_restconf" "PreReq4" {
- path = "Cisco-IOS-XE-native:native/template/Cisco-IOS-XE-template:template_details=TEMP1"
+resource "iosxe_yang" "PreReq4" {
+ path = "/Cisco-IOS-XE-native:native/template/Cisco-IOS-XE-template:template_details[template_name=TEMP1]"
attributes = {
"template_name" = "TEMP1"
}
@@ -233,7 +233,7 @@ func testAccDataSourceIosxeInterfaceEthernetConfig() string {
config += ` cdp_tlv_location = false` + "\n"
config += ` cdp_tlv_server_location = false` + "\n"
config += ` ip_nat_inside = true` + "\n"
- config += ` depends_on = [iosxe_restconf.PreReq0, iosxe_restconf.PreReq1, iosxe_restconf.PreReq2, iosxe_restconf.PreReq3, iosxe_restconf.PreReq4, ]` + "\n"
+ config += ` depends_on = [iosxe_yang.PreReq0, iosxe_yang.PreReq1, iosxe_yang.PreReq2, iosxe_yang.PreReq3, iosxe_yang.PreReq4, ]` + "\n"
config += `}` + "\n"
config += `
diff --git a/internal/provider/data_source_iosxe_interface_loopback.go b/internal/provider/data_source_iosxe_interface_loopback.go
index 90b9dec4..8cb6e2b4 100644
--- a/internal/provider/data_source_iosxe_interface_loopback.go
+++ b/internal/provider/data_source_iosxe_interface_loopback.go
@@ -24,6 +24,7 @@ import (
"context"
"fmt"
+ "github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
"github.com/hashicorp/terraform-plugin-framework/path"
@@ -209,16 +210,37 @@ func (d *InterfaceLoopbackDataSource) Read(ctx context.Context, req datasource.R
return
}
- res, err := device.Client.GetData(config.getPath())
- if res.StatusCode == 404 {
- config = InterfaceLoopbackData{Device: config.Device}
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(config.getPath())
+ if res.StatusCode == 404 {
+ config = InterfaceLoopbackData{Device: config.Device}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
+ return
+ }
+
+ config.fromBody(ctx, res.Res)
+ }
} else {
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
+ }
+
+ filter := helpers.GetXpathFilter(config.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
if err != nil {
resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
return
}
- config.fromBody(ctx, res.Res)
+ config.fromBodyXML(ctx, res.Res)
}
config.Id = types.StringValue(config.getPath())
diff --git a/internal/provider/data_source_iosxe_interface_loopback_test.go b/internal/provider/data_source_iosxe_interface_loopback_test.go
index 9bfc2dc1..9537e062 100644
--- a/internal/provider/data_source_iosxe_interface_loopback_test.go
+++ b/internal/provider/data_source_iosxe_interface_loopback_test.go
@@ -68,8 +68,8 @@ func TestAccDataSourceIosxeInterfaceLoopback(t *testing.T) {
// Section below is generated&owned by "gen/generator.go". //template:begin testPrerequisites
const testAccDataSourceIosxeInterfaceLoopbackPrerequisitesConfig = `
-resource "iosxe_restconf" "PreReq0" {
- path = "Cisco-IOS-XE-native:native/vrf/definition=VRF1"
+resource "iosxe_yang" "PreReq0" {
+ path = "/Cisco-IOS-XE-native:native/vrf/definition[name=VRF1]"
delete = false
attributes = {
"name" = "VRF1"
@@ -111,7 +111,7 @@ func testAccDataSourceIosxeInterfaceLoopbackConfig() string {
config += ` eui_64 = true` + "\n"
config += ` }]` + "\n"
config += ` arp_timeout = 2147` + "\n"
- config += ` depends_on = [iosxe_restconf.PreReq0, ]` + "\n"
+ config += ` depends_on = [iosxe_yang.PreReq0, ]` + "\n"
config += `}` + "\n"
config += `
diff --git a/internal/provider/data_source_iosxe_interface_mpls.go b/internal/provider/data_source_iosxe_interface_mpls.go
index c3481a55..fa5ef33d 100644
--- a/internal/provider/data_source_iosxe_interface_mpls.go
+++ b/internal/provider/data_source_iosxe_interface_mpls.go
@@ -24,6 +24,7 @@ import (
"context"
"fmt"
+ "github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
"github.com/hashicorp/terraform-plugin-framework/path"
@@ -117,16 +118,37 @@ func (d *InterfaceMPLSDataSource) Read(ctx context.Context, req datasource.ReadR
return
}
- res, err := device.Client.GetData(config.getPath())
- if res.StatusCode == 404 {
- config = InterfaceMPLSData{Device: config.Device}
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(config.getPath())
+ if res.StatusCode == 404 {
+ config = InterfaceMPLSData{Device: config.Device}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
+ return
+ }
+
+ config.fromBody(ctx, res.Res)
+ }
} else {
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
+ }
+
+ filter := helpers.GetXpathFilter(config.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
if err != nil {
resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
return
}
- config.fromBody(ctx, res.Res)
+ config.fromBodyXML(ctx, res.Res)
}
config.Id = types.StringValue(config.getPath())
diff --git a/internal/provider/data_source_iosxe_interface_mpls_test.go b/internal/provider/data_source_iosxe_interface_mpls_test.go
index 34e41bf6..1643c9cf 100644
--- a/internal/provider/data_source_iosxe_interface_mpls_test.go
+++ b/internal/provider/data_source_iosxe_interface_mpls_test.go
@@ -50,8 +50,8 @@ func TestAccDataSourceIosxeInterfaceMPLS(t *testing.T) {
// Section below is generated&owned by "gen/generator.go". //template:begin testPrerequisites
const testAccDataSourceIosxeInterfaceMPLSPrerequisitesConfig = `
-resource "iosxe_restconf" "PreReq0" {
- path = "Cisco-IOS-XE-native:native/interface/Loopback=1"
+resource "iosxe_yang" "PreReq0" {
+ path = "/Cisco-IOS-XE-native:native/interface/Loopback[name=1]"
attributes = {
"name" = "1"
}
@@ -70,7 +70,7 @@ func testAccDataSourceIosxeInterfaceMPLSConfig() string {
config += ` name = "1"` + "\n"
config += ` ip = true` + "\n"
config += ` mtu = "1200"` + "\n"
- config += ` depends_on = [iosxe_restconf.PreReq0, ]` + "\n"
+ config += ` depends_on = [iosxe_yang.PreReq0, ]` + "\n"
config += `}` + "\n"
config += `
diff --git a/internal/provider/data_source_iosxe_interface_nve.go b/internal/provider/data_source_iosxe_interface_nve.go
index 2ed9b223..148e6190 100644
--- a/internal/provider/data_source_iosxe_interface_nve.go
+++ b/internal/provider/data_source_iosxe_interface_nve.go
@@ -24,6 +24,7 @@ import (
"context"
"fmt"
+ "github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
"github.com/hashicorp/terraform-plugin-framework/path"
@@ -157,16 +158,37 @@ func (d *InterfaceNVEDataSource) Read(ctx context.Context, req datasource.ReadRe
return
}
- res, err := device.Client.GetData(config.getPath())
- if res.StatusCode == 404 {
- config = InterfaceNVEData{Device: config.Device}
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(config.getPath())
+ if res.StatusCode == 404 {
+ config = InterfaceNVEData{Device: config.Device}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
+ return
+ }
+
+ config.fromBody(ctx, res.Res)
+ }
} else {
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
+ }
+
+ filter := helpers.GetXpathFilter(config.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
if err != nil {
resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
return
}
- config.fromBody(ctx, res.Res)
+ config.fromBodyXML(ctx, res.Res)
}
config.Id = types.StringValue(config.getPath())
diff --git a/internal/provider/data_source_iosxe_interface_ospf.go b/internal/provider/data_source_iosxe_interface_ospf.go
index 451d63ed..9e282a2b 100644
--- a/internal/provider/data_source_iosxe_interface_ospf.go
+++ b/internal/provider/data_source_iosxe_interface_ospf.go
@@ -24,6 +24,7 @@ import (
"context"
"fmt"
+ "github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
"github.com/hashicorp/terraform-plugin-framework/path"
@@ -194,16 +195,37 @@ func (d *InterfaceOSPFDataSource) Read(ctx context.Context, req datasource.ReadR
return
}
- res, err := device.Client.GetData(config.getPath())
- if res.StatusCode == 404 {
- config = InterfaceOSPFData{Device: config.Device}
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(config.getPath())
+ if res.StatusCode == 404 {
+ config = InterfaceOSPFData{Device: config.Device}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
+ return
+ }
+
+ config.fromBody(ctx, res.Res)
+ }
} else {
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
+ }
+
+ filter := helpers.GetXpathFilter(config.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
if err != nil {
resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
return
}
- config.fromBody(ctx, res.Res)
+ config.fromBodyXML(ctx, res.Res)
}
config.Id = types.StringValue(config.getPath())
diff --git a/internal/provider/data_source_iosxe_interface_ospf_test.go b/internal/provider/data_source_iosxe_interface_ospf_test.go
index 6dd20b07..047cadd4 100644
--- a/internal/provider/data_source_iosxe_interface_ospf_test.go
+++ b/internal/provider/data_source_iosxe_interface_ospf_test.go
@@ -61,15 +61,15 @@ func TestAccDataSourceIosxeInterfaceOSPF(t *testing.T) {
// Section below is generated&owned by "gen/generator.go". //template:begin testPrerequisites
const testAccDataSourceIosxeInterfaceOSPFPrerequisitesConfig = `
-resource "iosxe_restconf" "PreReq0" {
- path = "Cisco-IOS-XE-native:native/router/Cisco-IOS-XE-ospf:router-ospf/ospf/process-id=1"
+resource "iosxe_yang" "PreReq0" {
+ path = "/Cisco-IOS-XE-native:native/router/Cisco-IOS-XE-ospf:router-ospf/ospf/process-id[id=1]"
attributes = {
"id" = "1"
}
}
-resource "iosxe_restconf" "PreReq1" {
- path = "Cisco-IOS-XE-native:native/interface/Loopback=1"
+resource "iosxe_yang" "PreReq1" {
+ path = "/Cisco-IOS-XE-native:native/interface/Loopback[name=1]"
attributes = {
"name" = "1"
}
@@ -107,7 +107,7 @@ func testAccDataSourceIosxeInterfaceOSPFConfig() string {
config += ` md5_auth_key = "mykey"` + "\n"
config += ` md5_auth_type = 0` + "\n"
config += ` }]` + "\n"
- config += ` depends_on = [iosxe_restconf.PreReq0, iosxe_restconf.PreReq1, ]` + "\n"
+ config += ` depends_on = [iosxe_yang.PreReq0, iosxe_yang.PreReq1, ]` + "\n"
config += `}` + "\n"
config += `
diff --git a/internal/provider/data_source_iosxe_interface_ospfv3.go b/internal/provider/data_source_iosxe_interface_ospfv3.go
index 8ea65a05..b913391d 100644
--- a/internal/provider/data_source_iosxe_interface_ospfv3.go
+++ b/internal/provider/data_source_iosxe_interface_ospfv3.go
@@ -24,6 +24,7 @@ import (
"context"
"fmt"
+ "github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
"github.com/hashicorp/terraform-plugin-framework/path"
@@ -129,16 +130,37 @@ func (d *InterfaceOSPFv3DataSource) Read(ctx context.Context, req datasource.Rea
return
}
- res, err := device.Client.GetData(config.getPath())
- if res.StatusCode == 404 {
- config = InterfaceOSPFv3Data{Device: config.Device}
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(config.getPath())
+ if res.StatusCode == 404 {
+ config = InterfaceOSPFv3Data{Device: config.Device}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
+ return
+ }
+
+ config.fromBody(ctx, res.Res)
+ }
} else {
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
+ }
+
+ filter := helpers.GetXpathFilter(config.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
if err != nil {
resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
return
}
- config.fromBody(ctx, res.Res)
+ config.fromBodyXML(ctx, res.Res)
}
config.Id = types.StringValue(config.getPath())
diff --git a/internal/provider/data_source_iosxe_interface_ospfv3_test.go b/internal/provider/data_source_iosxe_interface_ospfv3_test.go
index 83837678..4d04d103 100644
--- a/internal/provider/data_source_iosxe_interface_ospfv3_test.go
+++ b/internal/provider/data_source_iosxe_interface_ospfv3_test.go
@@ -53,8 +53,8 @@ func TestAccDataSourceIosxeInterfaceOSPFv3(t *testing.T) {
// Section below is generated&owned by "gen/generator.go". //template:begin testPrerequisites
const testAccDataSourceIosxeInterfaceOSPFv3PrerequisitesConfig = `
-resource "iosxe_restconf" "PreReq0" {
- path = "Cisco-IOS-XE-native:native/interface/Loopback=1"
+resource "iosxe_yang" "PreReq0" {
+ path = "/Cisco-IOS-XE-native:native/interface/Loopback[name=1]"
attributes = {
"name" = "1"
}
@@ -76,7 +76,7 @@ func testAccDataSourceIosxeInterfaceOSPFv3Config() string {
config += ` network_type_point_to_multipoint = false` + "\n"
config += ` network_type_point_to_point = true` + "\n"
config += ` cost = 1000` + "\n"
- config += ` depends_on = [iosxe_restconf.PreReq0, ]` + "\n"
+ config += ` depends_on = [iosxe_yang.PreReq0, ]` + "\n"
config += `}` + "\n"
config += `
diff --git a/internal/provider/data_source_iosxe_interface_pim.go b/internal/provider/data_source_iosxe_interface_pim.go
index 5228fddf..0c06c648 100644
--- a/internal/provider/data_source_iosxe_interface_pim.go
+++ b/internal/provider/data_source_iosxe_interface_pim.go
@@ -24,6 +24,7 @@ import (
"context"
"fmt"
+ "github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
"github.com/hashicorp/terraform-plugin-framework/path"
@@ -141,16 +142,37 @@ func (d *InterfacePIMDataSource) Read(ctx context.Context, req datasource.ReadRe
return
}
- res, err := device.Client.GetData(config.getPath())
- if res.StatusCode == 404 {
- config = InterfacePIMData{Device: config.Device}
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(config.getPath())
+ if res.StatusCode == 404 {
+ config = InterfacePIMData{Device: config.Device}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
+ return
+ }
+
+ config.fromBody(ctx, res.Res)
+ }
} else {
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
+ }
+
+ filter := helpers.GetXpathFilter(config.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
if err != nil {
resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
return
}
- config.fromBody(ctx, res.Res)
+ config.fromBodyXML(ctx, res.Res)
}
config.Id = types.StringValue(config.getPath())
diff --git a/internal/provider/data_source_iosxe_interface_pim_test.go b/internal/provider/data_source_iosxe_interface_pim_test.go
index 231fe8c7..b25b5d23 100644
--- a/internal/provider/data_source_iosxe_interface_pim_test.go
+++ b/internal/provider/data_source_iosxe_interface_pim_test.go
@@ -56,8 +56,8 @@ func TestAccDataSourceIosxeInterfacePIM(t *testing.T) {
// Section below is generated&owned by "gen/generator.go". //template:begin testPrerequisites
const testAccDataSourceIosxeInterfacePIMPrerequisitesConfig = `
-resource "iosxe_restconf" "PreReq0" {
- path = "Cisco-IOS-XE-native:native/interface/Loopback=100"
+resource "iosxe_yang" "PreReq0" {
+ path = "/Cisco-IOS-XE-native:native/interface/Loopback[name=100]"
attributes = {
"name" = "100"
}
@@ -81,7 +81,7 @@ func testAccDataSourceIosxeInterfacePIMConfig() string {
config += ` border = false` + "\n"
config += ` bsr_border = false` + "\n"
config += ` dr_priority = 10` + "\n"
- config += ` depends_on = [iosxe_restconf.PreReq0, ]` + "\n"
+ config += ` depends_on = [iosxe_yang.PreReq0, ]` + "\n"
config += `}` + "\n"
config += `
diff --git a/internal/provider/data_source_iosxe_interface_port_channel.go b/internal/provider/data_source_iosxe_interface_port_channel.go
index bb4ee6e4..f56b2819 100644
--- a/internal/provider/data_source_iosxe_interface_port_channel.go
+++ b/internal/provider/data_source_iosxe_interface_port_channel.go
@@ -24,6 +24,7 @@ import (
"context"
"fmt"
+ "github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
"github.com/hashicorp/terraform-plugin-framework/path"
@@ -369,16 +370,37 @@ func (d *InterfacePortChannelDataSource) Read(ctx context.Context, req datasourc
return
}
- res, err := device.Client.GetData(config.getPath())
- if res.StatusCode == 404 {
- config = InterfacePortChannelData{Device: config.Device}
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(config.getPath())
+ if res.StatusCode == 404 {
+ config = InterfacePortChannelData{Device: config.Device}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
+ return
+ }
+
+ config.fromBody(ctx, res.Res)
+ }
} else {
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
+ }
+
+ filter := helpers.GetXpathFilter(config.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
if err != nil {
resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
return
}
- config.fromBody(ctx, res.Res)
+ config.fromBodyXML(ctx, res.Res)
}
config.Id = types.StringValue(config.getPath())
diff --git a/internal/provider/data_source_iosxe_interface_port_channel_subinterface.go b/internal/provider/data_source_iosxe_interface_port_channel_subinterface.go
index 8d56e223..73a2aaa3 100644
--- a/internal/provider/data_source_iosxe_interface_port_channel_subinterface.go
+++ b/internal/provider/data_source_iosxe_interface_port_channel_subinterface.go
@@ -24,6 +24,7 @@ import (
"context"
"fmt"
+ "github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
"github.com/hashicorp/terraform-plugin-framework/path"
@@ -321,16 +322,37 @@ func (d *InterfacePortChannelSubinterfaceDataSource) Read(ctx context.Context, r
return
}
- res, err := device.Client.GetData(config.getPath())
- if res.StatusCode == 404 {
- config = InterfacePortChannelSubinterfaceData{Device: config.Device}
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(config.getPath())
+ if res.StatusCode == 404 {
+ config = InterfacePortChannelSubinterfaceData{Device: config.Device}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
+ return
+ }
+
+ config.fromBody(ctx, res.Res)
+ }
} else {
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
+ }
+
+ filter := helpers.GetXpathFilter(config.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
if err != nil {
resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
return
}
- config.fromBody(ctx, res.Res)
+ config.fromBodyXML(ctx, res.Res)
}
config.Id = types.StringValue(config.getPath())
diff --git a/internal/provider/data_source_iosxe_interface_port_channel_subinterface_test.go b/internal/provider/data_source_iosxe_interface_port_channel_subinterface_test.go
index 35042ae4..25a15021 100644
--- a/internal/provider/data_source_iosxe_interface_port_channel_subinterface_test.go
+++ b/internal/provider/data_source_iosxe_interface_port_channel_subinterface_test.go
@@ -85,8 +85,8 @@ func TestAccDataSourceIosxeInterfacePortChannelSubinterface(t *testing.T) {
// Section below is generated&owned by "gen/generator.go". //template:begin testPrerequisites
const testAccDataSourceIosxeInterfacePortChannelSubinterfacePrerequisitesConfig = `
-resource "iosxe_restconf" "PreReq0" {
- path = "Cisco-IOS-XE-native:native/vrf/definition=VRF1"
+resource "iosxe_yang" "PreReq0" {
+ path = "/Cisco-IOS-XE-native:native/vrf/definition[name=VRF1]"
delete = false
attributes = {
"name" = "VRF1"
@@ -94,19 +94,19 @@ resource "iosxe_restconf" "PreReq0" {
}
}
-resource "iosxe_restconf" "PreReq1" {
- path = "Cisco-IOS-XE-native:native/interface/Port-channel=10"
+resource "iosxe_yang" "PreReq1" {
+ path = "/Cisco-IOS-XE-native:native/interface/Port-channel[name=10]"
attributes = {
"name" = "10"
}
}
-resource "iosxe_restconf" "PreReq2" {
- path = "Cisco-IOS-XE-native:native/interface/Port-channel-subinterface/Port-channel=10.666"
+resource "iosxe_yang" "PreReq2" {
+ path = "/Cisco-IOS-XE-native:native/interface/Port-channel-subinterface/Port-channel[name=10.666]"
attributes = {
"name" = "10.666"
}
- depends_on = [iosxe_restconf.PreReq1, ]
+ depends_on = [iosxe_yang.PreReq1, ]
}
`
@@ -158,7 +158,7 @@ func testAccDataSourceIosxeInterfacePortChannelSubinterfaceConfig() string {
if os.Getenv("C9000V") != "" {
config += ` ip_arp_inspection_limit_rate = 1000` + "\n"
}
- config += ` depends_on = [iosxe_restconf.PreReq0, iosxe_restconf.PreReq1, iosxe_restconf.PreReq2, ]` + "\n"
+ config += ` depends_on = [iosxe_yang.PreReq0, iosxe_yang.PreReq1, iosxe_yang.PreReq2, ]` + "\n"
config += `}` + "\n"
config += `
diff --git a/internal/provider/data_source_iosxe_interface_port_channel_test.go b/internal/provider/data_source_iosxe_interface_port_channel_test.go
index 6cedb380..dc01dabf 100644
--- a/internal/provider/data_source_iosxe_interface_port_channel_test.go
+++ b/internal/provider/data_source_iosxe_interface_port_channel_test.go
@@ -94,8 +94,8 @@ func TestAccDataSourceIosxeInterfacePortChannel(t *testing.T) {
// Section below is generated&owned by "gen/generator.go". //template:begin testPrerequisites
const testAccDataSourceIosxeInterfacePortChannelPrerequisitesConfig = `
-resource "iosxe_restconf" "PreReq0" {
- path = "Cisco-IOS-XE-native:native/vrf/definition=VRF1"
+resource "iosxe_yang" "PreReq0" {
+ path = "/Cisco-IOS-XE-native:native/vrf/definition[name=VRF1]"
delete = false
attributes = {
"name" = "VRF1"
@@ -164,7 +164,7 @@ func testAccDataSourceIosxeInterfacePortChannelConfig() string {
config += ` load_interval = 30` + "\n"
config += ` snmp_trap_link_status = true` + "\n"
config += ` logging_event_link_status_enable = false` + "\n"
- config += ` depends_on = [iosxe_restconf.PreReq0, ]` + "\n"
+ config += ` depends_on = [iosxe_yang.PreReq0, ]` + "\n"
config += `}` + "\n"
config += `
diff --git a/internal/provider/data_source_iosxe_interface_switchport.go b/internal/provider/data_source_iosxe_interface_switchport.go
index 28090f63..1a437262 100644
--- a/internal/provider/data_source_iosxe_interface_switchport.go
+++ b/internal/provider/data_source_iosxe_interface_switchport.go
@@ -24,6 +24,7 @@ import (
"context"
"fmt"
+ "github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
"github.com/hashicorp/terraform-plugin-framework/path"
@@ -161,16 +162,37 @@ func (d *InterfaceSwitchportDataSource) Read(ctx context.Context, req datasource
return
}
- res, err := device.Client.GetData(config.getPath())
- if res.StatusCode == 404 {
- config = InterfaceSwitchportData{Device: config.Device}
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(config.getPath())
+ if res.StatusCode == 404 {
+ config = InterfaceSwitchportData{Device: config.Device}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
+ return
+ }
+
+ config.fromBody(ctx, res.Res)
+ }
} else {
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
+ }
+
+ filter := helpers.GetXpathFilter(config.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
if err != nil {
resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
return
}
- config.fromBody(ctx, res.Res)
+ config.fromBodyXML(ctx, res.Res)
}
config.Id = types.StringValue(config.getPath())
diff --git a/internal/provider/data_source_iosxe_interface_tunnel.go b/internal/provider/data_source_iosxe_interface_tunnel.go
index fc998b7e..484b07e7 100644
--- a/internal/provider/data_source_iosxe_interface_tunnel.go
+++ b/internal/provider/data_source_iosxe_interface_tunnel.go
@@ -24,6 +24,7 @@ import (
"context"
"fmt"
+ "github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
"github.com/hashicorp/terraform-plugin-framework/path"
@@ -305,16 +306,37 @@ func (d *InterfaceTunnelDataSource) Read(ctx context.Context, req datasource.Rea
return
}
- res, err := device.Client.GetData(config.getPath())
- if res.StatusCode == 404 {
- config = InterfaceTunnelData{Device: config.Device}
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(config.getPath())
+ if res.StatusCode == 404 {
+ config = InterfaceTunnelData{Device: config.Device}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
+ return
+ }
+
+ config.fromBody(ctx, res.Res)
+ }
} else {
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
+ }
+
+ filter := helpers.GetXpathFilter(config.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
if err != nil {
resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
return
}
- config.fromBody(ctx, res.Res)
+ config.fromBodyXML(ctx, res.Res)
}
config.Id = types.StringValue(config.getPath())
diff --git a/internal/provider/data_source_iosxe_interface_tunnel_test.go b/internal/provider/data_source_iosxe_interface_tunnel_test.go
index 6da3e5c2..c9aa32b2 100644
--- a/internal/provider/data_source_iosxe_interface_tunnel_test.go
+++ b/internal/provider/data_source_iosxe_interface_tunnel_test.go
@@ -89,8 +89,8 @@ func TestAccDataSourceIosxeInterfaceTunnel(t *testing.T) {
// Section below is generated&owned by "gen/generator.go". //template:begin testPrerequisites
const testAccDataSourceIosxeInterfaceTunnelPrerequisitesConfig = `
-resource "iosxe_restconf" "PreReq0" {
- path = "Cisco-IOS-XE-native:native/vrf/definition=VRF1"
+resource "iosxe_yang" "PreReq0" {
+ path = "/Cisco-IOS-XE-native:native/vrf/definition[name=VRF1]"
delete = false
attributes = {
"name" = "VRF1"
@@ -155,7 +155,7 @@ func testAccDataSourceIosxeInterfaceTunnelConfig() string {
config += ` snmp_trap_link_status = false` + "\n"
config += ` logging_event_link_status_enable = true` + "\n"
config += ` tunnel_vrf = "VRF1"` + "\n"
- config += ` depends_on = [iosxe_restconf.PreReq0, ]` + "\n"
+ config += ` depends_on = [iosxe_yang.PreReq0, ]` + "\n"
config += `}` + "\n"
config += `
diff --git a/internal/provider/data_source_iosxe_interface_vlan.go b/internal/provider/data_source_iosxe_interface_vlan.go
index a3e2bd39..3ebd1358 100644
--- a/internal/provider/data_source_iosxe_interface_vlan.go
+++ b/internal/provider/data_source_iosxe_interface_vlan.go
@@ -24,6 +24,7 @@ import (
"context"
"fmt"
+ "github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
"github.com/hashicorp/terraform-plugin-framework/path"
@@ -273,16 +274,37 @@ func (d *InterfaceVLANDataSource) Read(ctx context.Context, req datasource.ReadR
return
}
- res, err := device.Client.GetData(config.getPath())
- if res.StatusCode == 404 {
- config = InterfaceVLANData{Device: config.Device}
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(config.getPath())
+ if res.StatusCode == 404 {
+ config = InterfaceVLANData{Device: config.Device}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
+ return
+ }
+
+ config.fromBody(ctx, res.Res)
+ }
} else {
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
+ }
+
+ filter := helpers.GetXpathFilter(config.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
if err != nil {
resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
return
}
- config.fromBody(ctx, res.Res)
+ config.fromBodyXML(ctx, res.Res)
}
config.Id = types.StringValue(config.getPath())
diff --git a/internal/provider/data_source_iosxe_interface_vlan_test.go b/internal/provider/data_source_iosxe_interface_vlan_test.go
index 13485b28..e493ee1a 100644
--- a/internal/provider/data_source_iosxe_interface_vlan_test.go
+++ b/internal/provider/data_source_iosxe_interface_vlan_test.go
@@ -82,8 +82,8 @@ func TestAccDataSourceIosxeInterfaceVLAN(t *testing.T) {
// Section below is generated&owned by "gen/generator.go". //template:begin testPrerequisites
const testAccDataSourceIosxeInterfaceVLANPrerequisitesConfig = `
-resource "iosxe_restconf" "PreReq0" {
- path = "Cisco-IOS-XE-native:native/vrf/definition=VRF1"
+resource "iosxe_yang" "PreReq0" {
+ path = "/Cisco-IOS-XE-native:native/vrf/definition[name=VRF1]"
delete = false
attributes = {
"name" = "VRF1"
@@ -138,7 +138,7 @@ func testAccDataSourceIosxeInterfaceVLANConfig() string {
config += ` }]` + "\n"
config += ` load_interval = 30` + "\n"
config += ` mac_address = "0000.dead.beef"` + "\n"
- config += ` depends_on = [iosxe_restconf.PreReq0, ]` + "\n"
+ config += ` depends_on = [iosxe_yang.PreReq0, ]` + "\n"
config += `}` + "\n"
config += `
diff --git a/internal/provider/data_source_iosxe_license.go b/internal/provider/data_source_iosxe_license.go
index 38854458..9dbd53db 100644
--- a/internal/provider/data_source_iosxe_license.go
+++ b/internal/provider/data_source_iosxe_license.go
@@ -24,6 +24,7 @@ import (
"context"
"fmt"
+ "github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
"github.com/hashicorp/terraform-plugin-framework/path"
@@ -165,16 +166,37 @@ func (d *LicenseDataSource) Read(ctx context.Context, req datasource.ReadRequest
return
}
- res, err := device.Client.GetData(config.getPath())
- if res.StatusCode == 404 {
- config = LicenseData{Device: config.Device}
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(config.getPath())
+ if res.StatusCode == 404 {
+ config = LicenseData{Device: config.Device}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
+ return
+ }
+
+ config.fromBody(ctx, res.Res)
+ }
} else {
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
+ }
+
+ filter := helpers.GetXpathFilter(config.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
if err != nil {
resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
return
}
- config.fromBody(ctx, res.Res)
+ config.fromBodyXML(ctx, res.Res)
}
config.Id = types.StringValue(config.getPath())
diff --git a/internal/provider/data_source_iosxe_line.go b/internal/provider/data_source_iosxe_line.go
index 114db0b7..55b31562 100644
--- a/internal/provider/data_source_iosxe_line.go
+++ b/internal/provider/data_source_iosxe_line.go
@@ -24,6 +24,7 @@ import (
"context"
"fmt"
+ "github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
"github.com/hashicorp/terraform-plugin-framework/path"
@@ -326,16 +327,37 @@ func (d *LineDataSource) Read(ctx context.Context, req datasource.ReadRequest, r
return
}
- res, err := device.Client.GetData(config.getPath())
- if res.StatusCode == 404 {
- config = LineData{Device: config.Device}
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(config.getPath())
+ if res.StatusCode == 404 {
+ config = LineData{Device: config.Device}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
+ return
+ }
+
+ config.fromBody(ctx, res.Res)
+ }
} else {
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
+ }
+
+ filter := helpers.GetXpathFilter(config.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
if err != nil {
resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
return
}
- config.fromBody(ctx, res.Res)
+ config.fromBodyXML(ctx, res.Res)
}
config.Id = types.StringValue(config.getPath())
diff --git a/internal/provider/data_source_iosxe_lldp.go b/internal/provider/data_source_iosxe_lldp.go
index acaf7644..5ef3b1bf 100644
--- a/internal/provider/data_source_iosxe_lldp.go
+++ b/internal/provider/data_source_iosxe_lldp.go
@@ -24,6 +24,7 @@ import (
"context"
"fmt"
+ "github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
"github.com/hashicorp/terraform-plugin-framework/path"
@@ -143,16 +144,37 @@ func (d *LLDPDataSource) Read(ctx context.Context, req datasource.ReadRequest, r
return
}
- res, err := device.Client.GetData(config.getPath())
- if res.StatusCode == 404 {
- config = LLDPData{Device: config.Device}
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(config.getPath())
+ if res.StatusCode == 404 {
+ config = LLDPData{Device: config.Device}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
+ return
+ }
+
+ config.fromBody(ctx, res.Res)
+ }
} else {
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
+ }
+
+ filter := helpers.GetXpathFilter(config.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
if err != nil {
resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
return
}
- config.fromBody(ctx, res.Res)
+ config.fromBodyXML(ctx, res.Res)
}
config.Id = types.StringValue(config.getPath())
diff --git a/internal/provider/data_source_iosxe_logging.go b/internal/provider/data_source_iosxe_logging.go
index d978e226..bcb2e613 100644
--- a/internal/provider/data_source_iosxe_logging.go
+++ b/internal/provider/data_source_iosxe_logging.go
@@ -24,6 +24,7 @@ import (
"context"
"fmt"
+ "github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
"github.com/hashicorp/terraform-plugin-framework/path"
@@ -457,16 +458,37 @@ func (d *LoggingDataSource) Read(ctx context.Context, req datasource.ReadRequest
return
}
- res, err := device.Client.GetData(config.getPath())
- if res.StatusCode == 404 {
- config = LoggingData{Device: config.Device}
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(config.getPath())
+ if res.StatusCode == 404 {
+ config = LoggingData{Device: config.Device}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
+ return
+ }
+
+ config.fromBody(ctx, res.Res)
+ }
} else {
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
+ }
+
+ filter := helpers.GetXpathFilter(config.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
if err != nil {
resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
return
}
- config.fromBody(ctx, res.Res)
+ config.fromBodyXML(ctx, res.Res)
}
config.Id = types.StringValue(config.getPath())
diff --git a/internal/provider/data_source_iosxe_logging_test.go b/internal/provider/data_source_iosxe_logging_test.go
index 5c7be155..5f705dd3 100644
--- a/internal/provider/data_source_iosxe_logging_test.go
+++ b/internal/provider/data_source_iosxe_logging_test.go
@@ -85,8 +85,8 @@ func TestAccDataSourceIosxeLogging(t *testing.T) {
// Section below is generated&owned by "gen/generator.go". //template:begin testPrerequisites
const testAccDataSourceIosxeLoggingPrerequisitesConfig = `
-resource "iosxe_restconf" "PreReq0" {
- path = "Cisco-IOS-XE-native:native/vrf/definition=VRF1"
+resource "iosxe_yang" "PreReq0" {
+ path = "/Cisco-IOS-XE-native:native/vrf/definition[name=VRF1]"
delete = false
attributes = {
"name" = "VRF1"
@@ -95,13 +95,13 @@ resource "iosxe_restconf" "PreReq0" {
}
}
-resource "iosxe_restconf" "PreReq1" {
- path = "Cisco-IOS-XE-native:native/interface/Loopback=100"
+resource "iosxe_yang" "PreReq1" {
+ path = "/Cisco-IOS-XE-native:native/interface/Loopback[name=100]"
attributes = {
"name" = "100"
"vrf/forwarding" = "VRF1"
}
- depends_on = [iosxe_restconf.PreReq0, ]
+ depends_on = [iosxe_yang.PreReq0, ]
}
`
@@ -191,7 +191,7 @@ func testAccDataSourceIosxeLoggingConfig() string {
config += ` port_number = 10002` + "\n"
config += ` }]` + "\n"
config += ` }]` + "\n"
- config += ` depends_on = [iosxe_restconf.PreReq0, iosxe_restconf.PreReq1, ]` + "\n"
+ config += ` depends_on = [iosxe_yang.PreReq0, iosxe_yang.PreReq1, ]` + "\n"
config += `}` + "\n"
config += `
diff --git a/internal/provider/data_source_iosxe_mdt_subscription.go b/internal/provider/data_source_iosxe_mdt_subscription.go
index cab42a18..9a654cd5 100644
--- a/internal/provider/data_source_iosxe_mdt_subscription.go
+++ b/internal/provider/data_source_iosxe_mdt_subscription.go
@@ -24,6 +24,7 @@ import (
"context"
"fmt"
+ "github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
"github.com/hashicorp/terraform-plugin-framework/path"
@@ -153,16 +154,37 @@ func (d *MDTSubscriptionDataSource) Read(ctx context.Context, req datasource.Rea
return
}
- res, err := device.Client.GetData(config.getPath())
- if res.StatusCode == 404 {
- config = MDTSubscriptionData{Device: config.Device}
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(config.getPath())
+ if res.StatusCode == 404 {
+ config = MDTSubscriptionData{Device: config.Device}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
+ return
+ }
+
+ config.fromBody(ctx, res.Res)
+ }
} else {
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
+ }
+
+ filter := helpers.GetXpathFilter(config.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
if err != nil {
resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
return
}
- config.fromBody(ctx, res.Res)
+ config.fromBodyXML(ctx, res.Res)
}
config.Id = types.StringValue(config.getPath())
diff --git a/internal/provider/data_source_iosxe_msdp.go b/internal/provider/data_source_iosxe_msdp.go
index 872910bc..1a216d2b 100644
--- a/internal/provider/data_source_iosxe_msdp.go
+++ b/internal/provider/data_source_iosxe_msdp.go
@@ -24,6 +24,7 @@ import (
"context"
"fmt"
+ "github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
"github.com/hashicorp/terraform-plugin-framework/path"
@@ -203,16 +204,37 @@ func (d *MSDPDataSource) Read(ctx context.Context, req datasource.ReadRequest, r
return
}
- res, err := device.Client.GetData(config.getPath())
- if res.StatusCode == 404 {
- config = MSDPData{Device: config.Device}
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(config.getPath())
+ if res.StatusCode == 404 {
+ config = MSDPData{Device: config.Device}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
+ return
+ }
+
+ config.fromBody(ctx, res.Res)
+ }
} else {
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
+ }
+
+ filter := helpers.GetXpathFilter(config.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
if err != nil {
resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
return
}
- config.fromBody(ctx, res.Res)
+ config.fromBodyXML(ctx, res.Res)
}
config.Id = types.StringValue(config.getPath())
diff --git a/internal/provider/data_source_iosxe_msdp_test.go b/internal/provider/data_source_iosxe_msdp_test.go
index 3132f440..eb2101eb 100644
--- a/internal/provider/data_source_iosxe_msdp_test.go
+++ b/internal/provider/data_source_iosxe_msdp_test.go
@@ -59,8 +59,8 @@ func TestAccDataSourceIosxeMSDP(t *testing.T) {
// Section below is generated&owned by "gen/generator.go". //template:begin testPrerequisites
const testAccDataSourceIosxeMSDPPrerequisitesConfig = `
-resource "iosxe_restconf" "PreReq0" {
- path = "Cisco-IOS-XE-native:native/vrf/definition=VRF1"
+resource "iosxe_yang" "PreReq0" {
+ path = "/Cisco-IOS-XE-native:native/vrf/definition[name=VRF1]"
delete = false
attributes = {
"name" = "VRF1"
@@ -68,17 +68,17 @@ resource "iosxe_restconf" "PreReq0" {
}
}
-resource "iosxe_restconf" "PreReq1" {
- path = "Cisco-IOS-XE-native:native/interface/Loopback=200"
+resource "iosxe_yang" "PreReq1" {
+ path = "/Cisco-IOS-XE-native:native/interface/Loopback[name=200]"
attributes = {
"name" = "200"
"vrf/forwarding" = "VRF1"
}
- depends_on = [iosxe_restconf.PreReq0, ]
+ depends_on = [iosxe_yang.PreReq0, ]
}
-resource "iosxe_restconf" "PreReq2" {
- path = "Cisco-IOS-XE-native:native/interface/Loopback=100"
+resource "iosxe_yang" "PreReq2" {
+ path = "/Cisco-IOS-XE-native:native/interface/Loopback[name=100]"
attributes = {
"name" = "100"
}
@@ -118,7 +118,7 @@ func testAccDataSourceIosxeMSDPConfig() string {
config += ` password = "Cisco123"` + "\n"
config += ` }]` + "\n"
config += ` }]` + "\n"
- config += ` depends_on = [iosxe_restconf.PreReq0, iosxe_restconf.PreReq1, iosxe_restconf.PreReq2, ]` + "\n"
+ config += ` depends_on = [iosxe_yang.PreReq0, iosxe_yang.PreReq1, iosxe_yang.PreReq2, ]` + "\n"
config += `}` + "\n"
config += `
diff --git a/internal/provider/data_source_iosxe_nat.go b/internal/provider/data_source_iosxe_nat.go
index 54f9f79c..e819fb2e 100644
--- a/internal/provider/data_source_iosxe_nat.go
+++ b/internal/provider/data_source_iosxe_nat.go
@@ -24,6 +24,7 @@ import (
"context"
"fmt"
+ "github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
"github.com/hashicorp/terraform-plugin-framework/path"
@@ -129,16 +130,37 @@ func (d *NATDataSource) Read(ctx context.Context, req datasource.ReadRequest, re
return
}
- res, err := device.Client.GetData(config.getPath())
- if res.StatusCode == 404 {
- config = NATData{Device: config.Device}
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(config.getPath())
+ if res.StatusCode == 404 {
+ config = NATData{Device: config.Device}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
+ return
+ }
+
+ config.fromBody(ctx, res.Res)
+ }
} else {
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
+ }
+
+ filter := helpers.GetXpathFilter(config.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
if err != nil {
resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
return
}
- config.fromBody(ctx, res.Res)
+ config.fromBodyXML(ctx, res.Res)
}
config.Id = types.StringValue(config.getPath())
diff --git a/internal/provider/data_source_iosxe_ntp.go b/internal/provider/data_source_iosxe_ntp.go
index a8698986..9d6bc4d7 100644
--- a/internal/provider/data_source_iosxe_ntp.go
+++ b/internal/provider/data_source_iosxe_ntp.go
@@ -24,6 +24,7 @@ import (
"context"
"fmt"
+ "github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
"github.com/hashicorp/terraform-plugin-framework/path"
@@ -387,16 +388,37 @@ func (d *NTPDataSource) Read(ctx context.Context, req datasource.ReadRequest, re
return
}
- res, err := device.Client.GetData(config.getPath())
- if res.StatusCode == 404 {
- config = NTPData{Device: config.Device}
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(config.getPath())
+ if res.StatusCode == 404 {
+ config = NTPData{Device: config.Device}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
+ return
+ }
+
+ config.fromBody(ctx, res.Res)
+ }
} else {
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
+ }
+
+ filter := helpers.GetXpathFilter(config.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
if err != nil {
resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
return
}
- config.fromBody(ctx, res.Res)
+ config.fromBodyXML(ctx, res.Res)
}
config.Id = types.StringValue(config.getPath())
diff --git a/internal/provider/data_source_iosxe_ntp_test.go b/internal/provider/data_source_iosxe_ntp_test.go
index f72b7e8c..99c68d47 100644
--- a/internal/provider/data_source_iosxe_ntp_test.go
+++ b/internal/provider/data_source_iosxe_ntp_test.go
@@ -85,8 +85,8 @@ func TestAccDataSourceIosxeNTP(t *testing.T) {
// Section below is generated&owned by "gen/generator.go". //template:begin testPrerequisites
const testAccDataSourceIosxeNTPPrerequisitesConfig = `
-resource "iosxe_restconf" "PreReq0" {
- path = "Cisco-IOS-XE-native:native/vrf/definition=VRF1"
+resource "iosxe_yang" "PreReq0" {
+ path = "/Cisco-IOS-XE-native:native/vrf/definition[name=VRF1]"
delete = false
attributes = {
"name" = "VRF1"
@@ -94,15 +94,15 @@ resource "iosxe_restconf" "PreReq0" {
}
}
-resource "iosxe_restconf" "PreReq1" {
- path = "Cisco-IOS-XE-native:native/ip/access-list/Cisco-IOS-XE-acl:standard=SACL1"
+resource "iosxe_yang" "PreReq1" {
+ path = "/Cisco-IOS-XE-native:native/ip/access-list/Cisco-IOS-XE-acl:standard[name=SACL1]"
attributes = {
"name" = "SACL1"
}
}
-resource "iosxe_restconf" "PreReq2" {
- path = "Cisco-IOS-XE-native:native/interface/Loopback=1"
+resource "iosxe_yang" "PreReq2" {
+ path = "/Cisco-IOS-XE-native:native/interface/Loopback[name=1]"
attributes = {
"name" = "1"
}
@@ -172,7 +172,7 @@ func testAccDataSourceIosxeNTPConfig() string {
config += ` trusted_keys = [{` + "\n"
config += ` number = 1` + "\n"
config += ` }]` + "\n"
- config += ` depends_on = [iosxe_restconf.PreReq0, iosxe_restconf.PreReq1, iosxe_restconf.PreReq2, ]` + "\n"
+ config += ` depends_on = [iosxe_yang.PreReq0, iosxe_yang.PreReq1, iosxe_yang.PreReq2, ]` + "\n"
config += `}` + "\n"
config += `
diff --git a/internal/provider/data_source_iosxe_ospf.go b/internal/provider/data_source_iosxe_ospf.go
index 72961553..60817921 100644
--- a/internal/provider/data_source_iosxe_ospf.go
+++ b/internal/provider/data_source_iosxe_ospf.go
@@ -24,6 +24,7 @@ import (
"context"
"fmt"
+ "github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
"github.com/hashicorp/terraform-plugin-framework/path"
@@ -426,16 +427,37 @@ func (d *OSPFDataSource) Read(ctx context.Context, req datasource.ReadRequest, r
return
}
- res, err := device.Client.GetData(config.getPath())
- if res.StatusCode == 404 {
- config = OSPFData{Device: config.Device}
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(config.getPath())
+ if res.StatusCode == 404 {
+ config = OSPFData{Device: config.Device}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
+ return
+ }
+
+ config.fromBody(ctx, res.Res)
+ }
} else {
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
+ }
+
+ filter := helpers.GetXpathFilter(config.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
if err != nil {
resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
return
}
- config.fromBody(ctx, res.Res)
+ config.fromBodyXML(ctx, res.Res)
}
config.Id = types.StringValue(config.getPath())
diff --git a/internal/provider/data_source_iosxe_ospf_vrf.go b/internal/provider/data_source_iosxe_ospf_vrf.go
index 8ffea9c4..bbaadf82 100644
--- a/internal/provider/data_source_iosxe_ospf_vrf.go
+++ b/internal/provider/data_source_iosxe_ospf_vrf.go
@@ -24,6 +24,7 @@ import (
"context"
"fmt"
+ "github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
"github.com/hashicorp/terraform-plugin-framework/path"
@@ -430,16 +431,37 @@ func (d *OSPFVRFDataSource) Read(ctx context.Context, req datasource.ReadRequest
return
}
- res, err := device.Client.GetData(config.getPath())
- if res.StatusCode == 404 {
- config = OSPFVRFData{Device: config.Device}
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(config.getPath())
+ if res.StatusCode == 404 {
+ config = OSPFVRFData{Device: config.Device}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
+ return
+ }
+
+ config.fromBody(ctx, res.Res)
+ }
} else {
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
+ }
+
+ filter := helpers.GetXpathFilter(config.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
if err != nil {
resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
return
}
- config.fromBody(ctx, res.Res)
+ config.fromBodyXML(ctx, res.Res)
}
config.Id = types.StringValue(config.getPath())
diff --git a/internal/provider/data_source_iosxe_ospf_vrf_test.go b/internal/provider/data_source_iosxe_ospf_vrf_test.go
index d135c460..60e739a7 100644
--- a/internal/provider/data_source_iosxe_ospf_vrf_test.go
+++ b/internal/provider/data_source_iosxe_ospf_vrf_test.go
@@ -75,8 +75,8 @@ func TestAccDataSourceIosxeOSPFVRF(t *testing.T) {
// Section below is generated&owned by "gen/generator.go". //template:begin testPrerequisites
const testAccDataSourceIosxeOSPFVRFPrerequisitesConfig = `
-resource "iosxe_restconf" "PreReq0" {
- path = "Cisco-IOS-XE-native:native/vrf/definition=VRF1"
+resource "iosxe_yang" "PreReq0" {
+ path = "/Cisco-IOS-XE-native:native/vrf/definition[name=VRF1]"
delete = false
attributes = {
"name" = "VRF1"
@@ -130,7 +130,7 @@ func testAccDataSourceIosxeOSPFVRFConfig() string {
config += ` }]` + "\n"
config += ` auto_cost_reference_bandwidth = 40000` + "\n"
config += ` passive_interface_default = true` + "\n"
- config += ` depends_on = [iosxe_restconf.PreReq0, ]` + "\n"
+ config += ` depends_on = [iosxe_yang.PreReq0, ]` + "\n"
config += `}` + "\n"
config += `
diff --git a/internal/provider/data_source_iosxe_pim.go b/internal/provider/data_source_iosxe_pim.go
index ccd8140f..916333a4 100644
--- a/internal/provider/data_source_iosxe_pim.go
+++ b/internal/provider/data_source_iosxe_pim.go
@@ -24,6 +24,7 @@ import (
"context"
"fmt"
+ "github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
"github.com/hashicorp/terraform-plugin-framework/path"
@@ -309,16 +310,37 @@ func (d *PIMDataSource) Read(ctx context.Context, req datasource.ReadRequest, re
return
}
- res, err := device.Client.GetData(config.getPath())
- if res.StatusCode == 404 {
- config = PIMData{Device: config.Device}
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(config.getPath())
+ if res.StatusCode == 404 {
+ config = PIMData{Device: config.Device}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
+ return
+ }
+
+ config.fromBody(ctx, res.Res)
+ }
} else {
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
+ }
+
+ filter := helpers.GetXpathFilter(config.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
if err != nil {
resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
return
}
- config.fromBody(ctx, res.Res)
+ config.fromBodyXML(ctx, res.Res)
}
config.Id = types.StringValue(config.getPath())
diff --git a/internal/provider/data_source_iosxe_pim_test.go b/internal/provider/data_source_iosxe_pim_test.go
index 952a1a6e..7d57f3e6 100644
--- a/internal/provider/data_source_iosxe_pim_test.go
+++ b/internal/provider/data_source_iosxe_pim_test.go
@@ -86,8 +86,8 @@ func TestAccDataSourceIosxePIM(t *testing.T) {
// Section below is generated&owned by "gen/generator.go". //template:begin testPrerequisites
const testAccDataSourceIosxePIMPrerequisitesConfig = `
-resource "iosxe_restconf" "PreReq0" {
- path = "Cisco-IOS-XE-native:native/vrf/definition=VRF1"
+resource "iosxe_yang" "PreReq0" {
+ path = "/Cisco-IOS-XE-native:native/vrf/definition[name=VRF1]"
delete = false
attributes = {
"name" = "VRF1"
@@ -95,19 +95,19 @@ resource "iosxe_restconf" "PreReq0" {
}
}
-resource "iosxe_restconf" "PreReq1" {
- path = "Cisco-IOS-XE-native:native/interface/Loopback=200"
+resource "iosxe_yang" "PreReq1" {
+ path = "/Cisco-IOS-XE-native:native/interface/Loopback[name=200]"
attributes = {
"name" = "200"
"vrf/forwarding" = "VRF1"
"ip/address/primary/address" = "200.200.200.200"
"ip/address/primary/mask" = "255.255.255.255"
}
- depends_on = [iosxe_restconf.PreReq0, ]
+ depends_on = [iosxe_yang.PreReq0, ]
}
-resource "iosxe_restconf" "PreReq2" {
- path = "Cisco-IOS-XE-native:native/interface/Loopback=100"
+resource "iosxe_yang" "PreReq2" {
+ path = "/Cisco-IOS-XE-native:native/interface/Loopback[name=100]"
attributes = {
"name" = "100"
"ip/address/primary/address" = "200.200.200.200"
@@ -173,7 +173,7 @@ func testAccDataSourceIosxePIMConfig() string {
config += ` bidir = false` + "\n"
config += ` }]` + "\n"
config += ` }]` + "\n"
- config += ` depends_on = [iosxe_restconf.PreReq0, iosxe_restconf.PreReq1, iosxe_restconf.PreReq2, ]` + "\n"
+ config += ` depends_on = [iosxe_yang.PreReq0, iosxe_yang.PreReq1, iosxe_yang.PreReq2, ]` + "\n"
config += `}` + "\n"
config += `
diff --git a/internal/provider/data_source_iosxe_platform.go b/internal/provider/data_source_iosxe_platform.go
index 92872f5d..2b6cc866 100644
--- a/internal/provider/data_source_iosxe_platform.go
+++ b/internal/provider/data_source_iosxe_platform.go
@@ -24,6 +24,7 @@ import (
"context"
"fmt"
+ "github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
"github.com/hashicorp/terraform-plugin-framework/path"
@@ -117,16 +118,37 @@ func (d *PlatformDataSource) Read(ctx context.Context, req datasource.ReadReques
return
}
- res, err := device.Client.GetData(config.getPath())
- if res.StatusCode == 404 {
- config = PlatformData{Device: config.Device}
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(config.getPath())
+ if res.StatusCode == 404 {
+ config = PlatformData{Device: config.Device}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
+ return
+ }
+
+ config.fromBody(ctx, res.Res)
+ }
} else {
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
+ }
+
+ filter := helpers.GetXpathFilter(config.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
if err != nil {
resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
return
}
- config.fromBody(ctx, res.Res)
+ config.fromBodyXML(ctx, res.Res)
}
config.Id = types.StringValue(config.getPath())
diff --git a/internal/provider/data_source_iosxe_policy_map.go b/internal/provider/data_source_iosxe_policy_map.go
index 9e033351..152a0524 100644
--- a/internal/provider/data_source_iosxe_policy_map.go
+++ b/internal/provider/data_source_iosxe_policy_map.go
@@ -24,6 +24,7 @@ import (
"context"
"fmt"
+ "github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
"github.com/hashicorp/terraform-plugin-framework/path"
@@ -221,16 +222,37 @@ func (d *PolicyMapDataSource) Read(ctx context.Context, req datasource.ReadReque
return
}
- res, err := device.Client.GetData(config.getPath())
- if res.StatusCode == 404 {
- config = PolicyMapData{Device: config.Device}
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(config.getPath())
+ if res.StatusCode == 404 {
+ config = PolicyMapData{Device: config.Device}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
+ return
+ }
+
+ config.fromBody(ctx, res.Res)
+ }
} else {
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
+ }
+
+ filter := helpers.GetXpathFilter(config.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
if err != nil {
resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
return
}
- config.fromBody(ctx, res.Res)
+ config.fromBodyXML(ctx, res.Res)
}
config.Id = types.StringValue(config.getPath())
diff --git a/internal/provider/data_source_iosxe_policy_map_event.go b/internal/provider/data_source_iosxe_policy_map_event.go
index 3fb17a8e..1faae252 100644
--- a/internal/provider/data_source_iosxe_policy_map_event.go
+++ b/internal/provider/data_source_iosxe_policy_map_event.go
@@ -24,6 +24,7 @@ import (
"context"
"fmt"
+ "github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
"github.com/hashicorp/terraform-plugin-framework/path"
@@ -281,16 +282,37 @@ func (d *PolicyMapEventDataSource) Read(ctx context.Context, req datasource.Read
return
}
- res, err := device.Client.GetData(config.getPath())
- if res.StatusCode == 404 {
- config = PolicyMapEventData{Device: config.Device}
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(config.getPath())
+ if res.StatusCode == 404 {
+ config = PolicyMapEventData{Device: config.Device}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
+ return
+ }
+
+ config.fromBody(ctx, res.Res)
+ }
} else {
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
+ }
+
+ filter := helpers.GetXpathFilter(config.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
if err != nil {
resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
return
}
- config.fromBody(ctx, res.Res)
+ config.fromBodyXML(ctx, res.Res)
}
config.Id = types.StringValue(config.getPath())
diff --git a/internal/provider/data_source_iosxe_policy_map_event_test.go b/internal/provider/data_source_iosxe_policy_map_event_test.go
index cfd0f4e1..5a9dc8db 100644
--- a/internal/provider/data_source_iosxe_policy_map_event_test.go
+++ b/internal/provider/data_source_iosxe_policy_map_event_test.go
@@ -78,8 +78,8 @@ func TestAccDataSourceIosxePolicyMapEvent(t *testing.T) {
// Section below is generated&owned by "gen/generator.go". //template:begin testPrerequisites
const testAccDataSourceIosxePolicyMapEventPrerequisitesConfig = `
-resource "iosxe_restconf" "PreReq0" {
- path = "Cisco-IOS-XE-native:native/policy/Cisco-IOS-XE-policy:policy-map=dot1x_policy"
+resource "iosxe_yang" "PreReq0" {
+ path = "/Cisco-IOS-XE-native:native/policy/Cisco-IOS-XE-policy:policy-map[name=dot1x_policy]"
attributes = {
"name" = "dot1x_policy"
"type" = "control"
@@ -87,8 +87,8 @@ resource "iosxe_restconf" "PreReq0" {
}
}
-resource "iosxe_restconf" "PreReq1" {
- path = "Cisco-IOS-XE-native:native/policy/Cisco-IOS-XE-policy:class-map=MY_CLASS"
+resource "iosxe_yang" "PreReq1" {
+ path = "/Cisco-IOS-XE-native:native/policy/Cisco-IOS-XE-policy:class-map[name=MY_CLASS]"
attributes = {
"name" = "MY_CLASS"
"type" = "control"
@@ -141,7 +141,7 @@ func testAccDataSourceIosxePolicyMapEventConfig() string {
config += ` set_timer_value = 3600` + "\n"
config += ` }]` + "\n"
config += ` }]` + "\n"
- config += ` depends_on = [iosxe_restconf.PreReq0, iosxe_restconf.PreReq1, ]` + "\n"
+ config += ` depends_on = [iosxe_yang.PreReq0, iosxe_yang.PreReq1, ]` + "\n"
config += `}` + "\n"
config += `
diff --git a/internal/provider/data_source_iosxe_policy_map_test.go b/internal/provider/data_source_iosxe_policy_map_test.go
index b5545afe..21bfe230 100644
--- a/internal/provider/data_source_iosxe_policy_map_test.go
+++ b/internal/provider/data_source_iosxe_policy_map_test.go
@@ -52,8 +52,8 @@ func TestAccDataSourceIosxePolicyMap(t *testing.T) {
// Section below is generated&owned by "gen/generator.go". //template:begin testPrerequisites
const testAccDataSourceIosxePolicyMapPrerequisitesConfig = `
-resource "iosxe_restconf" "PreReq0" {
- path = "Cisco-IOS-XE-native:native/policy/Cisco-IOS-XE-policy:class-map=CLASS1"
+resource "iosxe_yang" "PreReq0" {
+ path = "/Cisco-IOS-XE-native:native/policy/Cisco-IOS-XE-policy:class-map[name=CLASS1]"
attributes = {
"name" = "CLASS1"
"prematch" = "match-all"
@@ -77,7 +77,7 @@ func testAccDataSourceIosxePolicyMapConfig() string {
config += ` bandwidth_percent = 10` + "\n"
config += ` }]` + "\n"
config += ` }]` + "\n"
- config += ` depends_on = [iosxe_restconf.PreReq0, ]` + "\n"
+ config += ` depends_on = [iosxe_yang.PreReq0, ]` + "\n"
config += `}` + "\n"
config += `
diff --git a/internal/provider/data_source_iosxe_prefix_list.go b/internal/provider/data_source_iosxe_prefix_list.go
index 7ac5505f..50584055 100644
--- a/internal/provider/data_source_iosxe_prefix_list.go
+++ b/internal/provider/data_source_iosxe_prefix_list.go
@@ -24,6 +24,7 @@ import (
"context"
"fmt"
+ "github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
"github.com/hashicorp/terraform-plugin-framework/path"
@@ -149,16 +150,37 @@ func (d *PrefixListDataSource) Read(ctx context.Context, req datasource.ReadRequ
return
}
- res, err := device.Client.GetData(config.getPath())
- if res.StatusCode == 404 {
- config = PrefixListData{Device: config.Device}
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(config.getPath())
+ if res.StatusCode == 404 {
+ config = PrefixListData{Device: config.Device}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
+ return
+ }
+
+ config.fromBody(ctx, res.Res)
+ }
} else {
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
+ }
+
+ filter := helpers.GetXpathFilter(config.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
if err != nil {
resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
return
}
- config.fromBody(ctx, res.Res)
+ config.fromBodyXML(ctx, res.Res)
}
config.Id = types.StringValue(config.getPath())
diff --git a/internal/provider/data_source_iosxe_radius.go b/internal/provider/data_source_iosxe_radius.go
index b8d079c8..0cc0f46b 100644
--- a/internal/provider/data_source_iosxe_radius.go
+++ b/internal/provider/data_source_iosxe_radius.go
@@ -24,6 +24,7 @@ import (
"context"
"fmt"
+ "github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
"github.com/hashicorp/terraform-plugin-framework/path"
@@ -151,16 +152,37 @@ func (d *RadiusDataSource) Read(ctx context.Context, req datasource.ReadRequest,
return
}
- res, err := device.Client.GetData(config.getPath())
- if res.StatusCode == 404 {
- config = RadiusData{Device: config.Device}
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(config.getPath())
+ if res.StatusCode == 404 {
+ config = RadiusData{Device: config.Device}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
+ return
+ }
+
+ config.fromBody(ctx, res.Res)
+ }
} else {
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
+ }
+
+ filter := helpers.GetXpathFilter(config.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
if err != nil {
resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
return
}
- config.fromBody(ctx, res.Res)
+ config.fromBodyXML(ctx, res.Res)
}
config.Id = types.StringValue(config.getPath())
diff --git a/internal/provider/data_source_iosxe_radius_server.go b/internal/provider/data_source_iosxe_radius_server.go
index 9a5c4881..356c0348 100644
--- a/internal/provider/data_source_iosxe_radius_server.go
+++ b/internal/provider/data_source_iosxe_radius_server.go
@@ -24,6 +24,7 @@ import (
"context"
"fmt"
+ "github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
"github.com/hashicorp/terraform-plugin-framework/path"
@@ -162,16 +163,37 @@ func (d *RadiusServerDataSource) Read(ctx context.Context, req datasource.ReadRe
return
}
- res, err := device.Client.GetData(config.getPath())
- if res.StatusCode == 404 {
- config = RadiusServerData{Device: config.Device}
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(config.getPath())
+ if res.StatusCode == 404 {
+ config = RadiusServerData{Device: config.Device}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
+ return
+ }
+
+ config.fromBody(ctx, res.Res)
+ }
} else {
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
+ }
+
+ filter := helpers.GetXpathFilter(config.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
if err != nil {
resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
return
}
- config.fromBody(ctx, res.Res)
+ config.fromBodyXML(ctx, res.Res)
}
config.Id = types.StringValue(config.getPath())
diff --git a/internal/provider/data_source_iosxe_restconf.go b/internal/provider/data_source_iosxe_restconf.go
deleted file mode 100644
index c682fffb..00000000
--- a/internal/provider/data_source_iosxe_restconf.go
+++ /dev/null
@@ -1,135 +0,0 @@
-// 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
-
-import (
- "context"
- "fmt"
-
- "github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
- "github.com/hashicorp/terraform-plugin-framework/attr"
- "github.com/hashicorp/terraform-plugin-framework/datasource"
- "github.com/hashicorp/terraform-plugin-framework/datasource/schema"
- "github.com/hashicorp/terraform-plugin-framework/path"
- "github.com/hashicorp/terraform-plugin-framework/types"
- "github.com/hashicorp/terraform-plugin-log/tflog"
-)
-
-// Ensure the implementation satisfies the expected interfaces.
-var (
- _ datasource.DataSource = &RestconfDataSource{}
- _ datasource.DataSourceWithConfigure = &RestconfDataSource{}
-)
-
-func NewRestconfDataSource() datasource.DataSource {
- return &RestconfDataSource{}
-}
-
-type RestconfDataSource struct {
- data *IosxeProviderData
-}
-
-func (d *RestconfDataSource) Metadata(_ context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) {
- resp.TypeName = req.ProviderTypeName + "_restconf"
-}
-
-func (d *RestconfDataSource) 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 retrieve one or more attributes via RESTCONF.",
-
- Attributes: map[string]schema.Attribute{
- "device": schema.StringAttribute{
- MarkdownDescription: "A device name from the provider configuration.",
- Optional: true,
- },
- "id": schema.StringAttribute{
- MarkdownDescription: "The path of the retrieved object.",
- Computed: true,
- },
- "path": schema.StringAttribute{
- MarkdownDescription: "A RESTCONF path, e.g. `openconfig-interfaces:interfaces`.",
- Required: true,
- },
- "attributes": schema.MapAttribute{
- MarkdownDescription: "Map of key-value pairs which represents the attributes and its values.",
- Computed: true,
- ElementType: types.StringType,
- },
- },
- }
-}
-
-func (d *RestconfDataSource) Configure(_ context.Context, req datasource.ConfigureRequest, _ *datasource.ConfigureResponse) {
- if req.ProviderData == nil {
- return
- }
-
- d.data = req.ProviderData.(*IosxeProviderData)
-}
-
-func (d *RestconfDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) {
- var config, state RestconfDataSourceModel
-
- // 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.ValueString()))
-
- device, ok := d.data.Devices[config.Device.ValueString()]
- if !ok {
- resp.Diagnostics.AddAttributeError(path.Root("device"), "Invalid device", fmt.Sprintf("Device '%s' does not exist in provider configuration.", config.Device.ValueString()))
- return
- }
-
- res, err := device.Client.GetData(config.Path.ValueString())
- if res.StatusCode == 404 {
- state.Attributes = types.MapValueMust(types.StringType, map[string]attr.Value{})
- } else {
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object, got error: %s", err))
- return
- }
-
- state.Path = config.Path
- state.Id = config.Path
-
- attributes := make(map[string]attr.Value)
-
- for attr, value := range res.Res.Get(helpers.LastElement(config.Path.ValueString())).Map() {
- // handle empty maps
- if value.IsObject() && len(value.Map()) == 0 {
- attributes[attr] = types.StringValue("")
- } else if value.Raw == "[null]" {
- attributes[attr] = types.StringValue("")
- } else {
- attributes[attr] = types.StringValue(value.String())
- }
- }
- state.Attributes = types.MapValueMust(types.StringType, attributes)
- }
-
- tflog.Debug(ctx, fmt.Sprintf("%s: Read finished successfully", config.Id.ValueString()))
-
- diags = resp.State.Set(ctx, &state)
- resp.Diagnostics.Append(diags...)
-}
diff --git a/internal/provider/data_source_iosxe_route_map.go b/internal/provider/data_source_iosxe_route_map.go
index 3efdad4f..ed422cd1 100644
--- a/internal/provider/data_source_iosxe_route_map.go
+++ b/internal/provider/data_source_iosxe_route_map.go
@@ -24,6 +24,7 @@ import (
"context"
"fmt"
+ "github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
"github.com/hashicorp/terraform-plugin-framework/path"
@@ -556,16 +557,37 @@ func (d *RouteMapDataSource) Read(ctx context.Context, req datasource.ReadReques
return
}
- res, err := device.Client.GetData(config.getPath())
- if res.StatusCode == 404 {
- config = RouteMapData{Device: config.Device}
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(config.getPath())
+ if res.StatusCode == 404 {
+ config = RouteMapData{Device: config.Device}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
+ return
+ }
+
+ config.fromBody(ctx, res.Res)
+ }
} else {
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
+ }
+
+ filter := helpers.GetXpathFilter(config.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
if err != nil {
resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
return
}
- config.fromBody(ctx, res.Res)
+ config.fromBodyXML(ctx, res.Res)
}
config.Id = types.StringValue(config.getPath())
diff --git a/internal/provider/data_source_iosxe_route_map_test.go b/internal/provider/data_source_iosxe_route_map_test.go
index 1bdf15ed..e621b4c0 100644
--- a/internal/provider/data_source_iosxe_route_map_test.go
+++ b/internal/provider/data_source_iosxe_route_map_test.go
@@ -167,8 +167,8 @@ func TestAccDataSourceIosxeRouteMap(t *testing.T) {
// Section below is generated&owned by "gen/generator.go". //template:begin testPrerequisites
const testAccDataSourceIosxeRouteMapPrerequisitesConfig = `
-resource "iosxe_restconf" "PreReq0" {
- path = "Cisco-IOS-XE-native:native/interface/Loopback=1"
+resource "iosxe_yang" "PreReq0" {
+ path = "/Cisco-IOS-XE-native:native/interface/Loopback[name=1]"
attributes = {
"name" = "1"
}
@@ -303,7 +303,7 @@ func testAccDataSourceIosxeRouteMapConfig() string {
config += ` set_local_preference = 110` + "\n"
config += ` set_weight = 10000` + "\n"
config += ` }]` + "\n"
- config += ` depends_on = [iosxe_restconf.PreReq0, ]` + "\n"
+ config += ` depends_on = [iosxe_yang.PreReq0, ]` + "\n"
config += `}` + "\n"
config += `
diff --git a/internal/provider/data_source_iosxe_service.go b/internal/provider/data_source_iosxe_service.go
index bd0ee5d0..b0509bf1 100644
--- a/internal/provider/data_source_iosxe_service.go
+++ b/internal/provider/data_source_iosxe_service.go
@@ -24,6 +24,7 @@ import (
"context"
"fmt"
+ "github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
"github.com/hashicorp/terraform-plugin-framework/path"
@@ -201,16 +202,37 @@ func (d *ServiceDataSource) Read(ctx context.Context, req datasource.ReadRequest
return
}
- res, err := device.Client.GetData(config.getPath())
- if res.StatusCode == 404 {
- config = ServiceData{Device: config.Device}
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(config.getPath())
+ if res.StatusCode == 404 {
+ config = ServiceData{Device: config.Device}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
+ return
+ }
+
+ config.fromBody(ctx, res.Res)
+ }
} else {
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
+ }
+
+ filter := helpers.GetXpathFilter(config.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
if err != nil {
resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
return
}
- config.fromBody(ctx, res.Res)
+ config.fromBodyXML(ctx, res.Res)
}
config.Id = types.StringValue(config.getPath())
diff --git a/internal/provider/data_source_iosxe_service_template.go b/internal/provider/data_source_iosxe_service_template.go
index 96e250a1..7531133d 100644
--- a/internal/provider/data_source_iosxe_service_template.go
+++ b/internal/provider/data_source_iosxe_service_template.go
@@ -24,6 +24,7 @@ import (
"context"
"fmt"
+ "github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
"github.com/hashicorp/terraform-plugin-framework/path"
@@ -217,16 +218,37 @@ func (d *ServiceTemplateDataSource) Read(ctx context.Context, req datasource.Rea
return
}
- res, err := device.Client.GetData(config.getPath())
- if res.StatusCode == 404 {
- config = ServiceTemplateData{Device: config.Device}
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(config.getPath())
+ if res.StatusCode == 404 {
+ config = ServiceTemplateData{Device: config.Device}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
+ return
+ }
+
+ config.fromBody(ctx, res.Res)
+ }
} else {
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
+ }
+
+ filter := helpers.GetXpathFilter(config.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
if err != nil {
resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
return
}
- config.fromBody(ctx, res.Res)
+ config.fromBodyXML(ctx, res.Res)
}
config.Id = types.StringValue(config.getPath())
diff --git a/internal/provider/data_source_iosxe_sla.go b/internal/provider/data_source_iosxe_sla.go
index ec3c95c7..66a19afe 100644
--- a/internal/provider/data_source_iosxe_sla.go
+++ b/internal/provider/data_source_iosxe_sla.go
@@ -24,6 +24,7 @@ import (
"context"
"fmt"
+ "github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
"github.com/hashicorp/terraform-plugin-framework/path"
@@ -141,16 +142,37 @@ func (d *SLADataSource) Read(ctx context.Context, req datasource.ReadRequest, re
return
}
- res, err := device.Client.GetData(config.getPath())
- if res.StatusCode == 404 {
- config = SLAData{Device: config.Device}
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(config.getPath())
+ if res.StatusCode == 404 {
+ config = SLAData{Device: config.Device}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
+ return
+ }
+
+ config.fromBody(ctx, res.Res)
+ }
} else {
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
+ }
+
+ filter := helpers.GetXpathFilter(config.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
if err != nil {
resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
return
}
- config.fromBody(ctx, res.Res)
+ config.fromBodyXML(ctx, res.Res)
}
config.Id = types.StringValue(config.getPath())
diff --git a/internal/provider/data_source_iosxe_snmp_server.go b/internal/provider/data_source_iosxe_snmp_server.go
index 7276f43f..f72b4652 100644
--- a/internal/provider/data_source_iosxe_snmp_server.go
+++ b/internal/provider/data_source_iosxe_snmp_server.go
@@ -24,6 +24,7 @@ import (
"context"
"fmt"
+ "github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
"github.com/hashicorp/terraform-plugin-framework/path"
@@ -1208,16 +1209,37 @@ func (d *SNMPServerDataSource) Read(ctx context.Context, req datasource.ReadRequ
return
}
- res, err := device.Client.GetData(config.getPath())
- if res.StatusCode == 404 {
- config = SNMPServerData{Device: config.Device}
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(config.getPath())
+ if res.StatusCode == 404 {
+ config = SNMPServerData{Device: config.Device}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
+ return
+ }
+
+ config.fromBody(ctx, res.Res)
+ }
} else {
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
+ }
+
+ filter := helpers.GetXpathFilter(config.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
if err != nil {
resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
return
}
- config.fromBody(ctx, res.Res)
+ config.fromBodyXML(ctx, res.Res)
}
config.Id = types.StringValue(config.getPath())
diff --git a/internal/provider/data_source_iosxe_snmp_server_test.go b/internal/provider/data_source_iosxe_snmp_server_test.go
index 1cbeebb6..e7d395d3 100644
--- a/internal/provider/data_source_iosxe_snmp_server_test.go
+++ b/internal/provider/data_source_iosxe_snmp_server_test.go
@@ -336,15 +336,15 @@ func TestAccDataSourceIosxeSNMPServer(t *testing.T) {
// Section below is generated&owned by "gen/generator.go". //template:begin testPrerequisites
const testAccDataSourceIosxeSNMPServerPrerequisitesConfig = `
-resource "iosxe_restconf" "PreReq0" {
- path = "Cisco-IOS-XE-native:native/interface/Loopback=1"
+resource "iosxe_yang" "PreReq0" {
+ path = "/Cisco-IOS-XE-native:native/interface/Loopback[name=1]"
attributes = {
"name" = "1"
}
}
-resource "iosxe_restconf" "PreReq1" {
- path = "Cisco-IOS-XE-native:native/vrf/definition=VRF1"
+resource "iosxe_yang" "PreReq1" {
+ path = "/Cisco-IOS-XE-native:native/vrf/definition[name=VRF1]"
delete = false
attributes = {
"name" = "VRF1"
@@ -669,7 +669,7 @@ func testAccDataSourceIosxeSNMPServerConfig() string {
config += ` v3_auth_priv_aes_access_ipv6_acl = "V6ACL1"` + "\n"
config += ` v3_auth_priv_aes_access_acl_name = "ACL123"` + "\n"
config += ` }]` + "\n"
- config += ` depends_on = [iosxe_restconf.PreReq0, iosxe_restconf.PreReq1, ]` + "\n"
+ config += ` depends_on = [iosxe_yang.PreReq0, iosxe_yang.PreReq1, ]` + "\n"
config += `}` + "\n"
config += `
diff --git a/internal/provider/data_source_iosxe_spanning_tree.go b/internal/provider/data_source_iosxe_spanning_tree.go
index 8feef76d..ed688bb5 100644
--- a/internal/provider/data_source_iosxe_spanning_tree.go
+++ b/internal/provider/data_source_iosxe_spanning_tree.go
@@ -24,6 +24,7 @@ import (
"context"
"fmt"
+ "github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
"github.com/hashicorp/terraform-plugin-framework/path"
@@ -158,16 +159,37 @@ func (d *SpanningTreeDataSource) Read(ctx context.Context, req datasource.ReadRe
return
}
- res, err := device.Client.GetData(config.getPath())
- if res.StatusCode == 404 {
- config = SpanningTreeData{Device: config.Device}
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(config.getPath())
+ if res.StatusCode == 404 {
+ config = SpanningTreeData{Device: config.Device}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
+ return
+ }
+
+ config.fromBody(ctx, res.Res)
+ }
} else {
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
+ }
+
+ filter := helpers.GetXpathFilter(config.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
if err != nil {
resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
return
}
- config.fromBody(ctx, res.Res)
+ config.fromBodyXML(ctx, res.Res)
}
config.Id = types.StringValue(config.getPath())
diff --git a/internal/provider/data_source_iosxe_static_route.go b/internal/provider/data_source_iosxe_static_route.go
index 923be0d1..4aad5cc2 100644
--- a/internal/provider/data_source_iosxe_static_route.go
+++ b/internal/provider/data_source_iosxe_static_route.go
@@ -24,6 +24,7 @@ import (
"context"
"fmt"
+ "github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
"github.com/hashicorp/terraform-plugin-framework/path"
@@ -173,16 +174,37 @@ func (d *StaticRouteDataSource) Read(ctx context.Context, req datasource.ReadReq
return
}
- res, err := device.Client.GetData(config.getPath())
- if res.StatusCode == 404 {
- config = StaticRouteData{Device: config.Device}
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(config.getPath())
+ if res.StatusCode == 404 {
+ config = StaticRouteData{Device: config.Device}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
+ return
+ }
+
+ config.fromBody(ctx, res.Res)
+ }
} else {
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
+ }
+
+ filter := helpers.GetXpathFilter(config.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
if err != nil {
resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
return
}
- config.fromBody(ctx, res.Res)
+ config.fromBodyXML(ctx, res.Res)
}
config.Id = types.StringValue(config.getPath())
diff --git a/internal/provider/data_source_iosxe_static_routes_vrf.go b/internal/provider/data_source_iosxe_static_routes_vrf.go
index 2f0deb37..1a6b30ac 100644
--- a/internal/provider/data_source_iosxe_static_routes_vrf.go
+++ b/internal/provider/data_source_iosxe_static_routes_vrf.go
@@ -24,6 +24,7 @@ import (
"context"
"fmt"
+ "github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
"github.com/hashicorp/terraform-plugin-framework/path"
@@ -185,16 +186,37 @@ func (d *StaticRoutesVRFDataSource) Read(ctx context.Context, req datasource.Rea
return
}
- res, err := device.Client.GetData(config.getPath())
- if res.StatusCode == 404 {
- config = StaticRoutesVRFData{Device: config.Device}
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(config.getPath())
+ if res.StatusCode == 404 {
+ config = StaticRoutesVRFData{Device: config.Device}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
+ return
+ }
+
+ config.fromBody(ctx, res.Res)
+ }
} else {
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
+ }
+
+ filter := helpers.GetXpathFilter(config.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
if err != nil {
resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
return
}
- config.fromBody(ctx, res.Res)
+ config.fromBodyXML(ctx, res.Res)
}
config.Id = types.StringValue(config.getPath())
diff --git a/internal/provider/data_source_iosxe_static_routes_vrf_test.go b/internal/provider/data_source_iosxe_static_routes_vrf_test.go
index a86c6bc6..32da557f 100644
--- a/internal/provider/data_source_iosxe_static_routes_vrf_test.go
+++ b/internal/provider/data_source_iosxe_static_routes_vrf_test.go
@@ -56,8 +56,8 @@ func TestAccDataSourceIosxeStaticRoutesVRF(t *testing.T) {
// Section below is generated&owned by "gen/generator.go". //template:begin testPrerequisites
const testAccDataSourceIosxeStaticRoutesVRFPrerequisitesConfig = `
-resource "iosxe_restconf" "PreReq0" {
- path = "Cisco-IOS-XE-native:native/vrf/definition=VRF1"
+resource "iosxe_yang" "PreReq0" {
+ path = "/Cisco-IOS-XE-native:native/vrf/definition[name=VRF1]"
delete = false
attributes = {
"name" = "VRF1"
@@ -86,7 +86,7 @@ func testAccDataSourceIosxeStaticRoutesVRFConfig() string {
config += ` tag = 100` + "\n"
config += ` }]` + "\n"
config += ` }]` + "\n"
- config += ` depends_on = [iosxe_restconf.PreReq0, ]` + "\n"
+ config += ` depends_on = [iosxe_yang.PreReq0, ]` + "\n"
config += `}` + "\n"
config += `
diff --git a/internal/provider/data_source_iosxe_system.go b/internal/provider/data_source_iosxe_system.go
index 9e20b4db..dd84d530 100644
--- a/internal/provider/data_source_iosxe_system.go
+++ b/internal/provider/data_source_iosxe_system.go
@@ -24,6 +24,7 @@ import (
"context"
"fmt"
+ "github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
"github.com/hashicorp/terraform-plugin-framework/path"
@@ -743,16 +744,37 @@ func (d *SystemDataSource) Read(ctx context.Context, req datasource.ReadRequest,
return
}
- res, err := device.Client.GetData(config.getPath())
- if res.StatusCode == 404 {
- config = SystemData{Device: config.Device}
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(config.getPath())
+ if res.StatusCode == 404 {
+ config = SystemData{Device: config.Device}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
+ return
+ }
+
+ config.fromBody(ctx, res.Res)
+ }
} else {
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
+ }
+
+ filter := helpers.GetXpathFilter(config.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
if err != nil {
resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
return
}
- config.fromBody(ctx, res.Res)
+ config.fromBodyXML(ctx, res.Res)
}
config.Id = types.StringValue(config.getPath())
diff --git a/internal/provider/data_source_iosxe_system_test.go b/internal/provider/data_source_iosxe_system_test.go
index 2e997c15..26e295e6 100644
--- a/internal/provider/data_source_iosxe_system_test.go
+++ b/internal/provider/data_source_iosxe_system_test.go
@@ -94,8 +94,8 @@ func TestAccDataSourceIosxeSystem(t *testing.T) {
// Section below is generated&owned by "gen/generator.go". //template:begin testPrerequisites
const testAccDataSourceIosxeSystemPrerequisitesConfig = `
-resource "iosxe_restconf" "PreReq0" {
- path = "Cisco-IOS-XE-native:native/vrf/definition=VRF1"
+resource "iosxe_yang" "PreReq0" {
+ path = "/Cisco-IOS-XE-native:native/vrf/definition[name=VRF1]"
delete = false
attributes = {
"name" = "VRF1"
@@ -162,7 +162,7 @@ func testAccDataSourceIosxeSystemConfig() string {
config += ` ip_multicast_route_limit = 200000` + "\n"
config += ` ip_domain_list_vrf_domain = "example.com"` + "\n"
config += ` ip_domain_list_vrf = "VRF1"` + "\n"
- config += ` depends_on = [iosxe_restconf.PreReq0, ]` + "\n"
+ config += ` depends_on = [iosxe_yang.PreReq0, ]` + "\n"
config += `}` + "\n"
config += `
diff --git a/internal/provider/data_source_iosxe_tacacs_server.go b/internal/provider/data_source_iosxe_tacacs_server.go
index 899ae193..0252c67b 100644
--- a/internal/provider/data_source_iosxe_tacacs_server.go
+++ b/internal/provider/data_source_iosxe_tacacs_server.go
@@ -24,6 +24,7 @@ import (
"context"
"fmt"
+ "github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
"github.com/hashicorp/terraform-plugin-framework/path"
@@ -122,16 +123,37 @@ func (d *TACACSServerDataSource) Read(ctx context.Context, req datasource.ReadRe
return
}
- res, err := device.Client.GetData(config.getPath())
- if res.StatusCode == 404 {
- config = TACACSServerData{Device: config.Device}
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(config.getPath())
+ if res.StatusCode == 404 {
+ config = TACACSServerData{Device: config.Device}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
+ return
+ }
+
+ config.fromBody(ctx, res.Res)
+ }
} else {
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
+ }
+
+ filter := helpers.GetXpathFilter(config.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
if err != nil {
resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
return
}
- config.fromBody(ctx, res.Res)
+ config.fromBodyXML(ctx, res.Res)
}
config.Id = types.StringValue(config.getPath())
diff --git a/internal/provider/data_source_iosxe_template.go b/internal/provider/data_source_iosxe_template.go
index e55d8e64..a1256dac 100644
--- a/internal/provider/data_source_iosxe_template.go
+++ b/internal/provider/data_source_iosxe_template.go
@@ -24,6 +24,7 @@ import (
"context"
"fmt"
+ "github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
"github.com/hashicorp/terraform-plugin-framework/path"
@@ -429,16 +430,37 @@ func (d *TemplateDataSource) Read(ctx context.Context, req datasource.ReadReques
return
}
- res, err := device.Client.GetData(config.getPath())
- if res.StatusCode == 404 {
- config = TemplateData{Device: config.Device}
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(config.getPath())
+ if res.StatusCode == 404 {
+ config = TemplateData{Device: config.Device}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
+ return
+ }
+
+ config.fromBody(ctx, res.Res)
+ }
} else {
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
+ }
+
+ filter := helpers.GetXpathFilter(config.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
if err != nil {
resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
return
}
- config.fromBody(ctx, res.Res)
+ config.fromBodyXML(ctx, res.Res)
}
config.Id = types.StringValue(config.getPath())
diff --git a/internal/provider/data_source_iosxe_template_test.go b/internal/provider/data_source_iosxe_template_test.go
index 4c976dab..4f65e399 100644
--- a/internal/provider/data_source_iosxe_template_test.go
+++ b/internal/provider/data_source_iosxe_template_test.go
@@ -117,8 +117,8 @@ func TestAccDataSourceIosxeTemplate(t *testing.T) {
// Section below is generated&owned by "gen/generator.go". //template:begin testPrerequisites
const testAccDataSourceIosxeTemplatePrerequisitesConfig = `
-resource "iosxe_restconf" "PreReq0" {
- path = "Cisco-IOS-XE-native:native/policy/Cisco-IOS-XE-policy:policy-map=dot1x_policy"
+resource "iosxe_yang" "PreReq0" {
+ path = "/Cisco-IOS-XE-native:native/policy/Cisco-IOS-XE-policy:policy-map[name=dot1x_policy]"
attributes = {
"name" = "dot1x_policy"
"type" = "control"
@@ -205,7 +205,7 @@ func testAccDataSourceIosxeTemplateConfig() string {
config += ` cts_manual_policy_static_trusted = false` + "\n"
config += ` cts_manual_propagate_sgt = false` + "\n"
config += ` cts_role_based_enforcement = false` + "\n"
- config += ` depends_on = [iosxe_restconf.PreReq0, ]` + "\n"
+ config += ` depends_on = [iosxe_yang.PreReq0, ]` + "\n"
config += `}` + "\n"
config += `
diff --git a/internal/provider/data_source_iosxe_udld.go b/internal/provider/data_source_iosxe_udld.go
index c4c50790..c912a506 100644
--- a/internal/provider/data_source_iosxe_udld.go
+++ b/internal/provider/data_source_iosxe_udld.go
@@ -24,6 +24,7 @@ import (
"context"
"fmt"
+ "github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
"github.com/hashicorp/terraform-plugin-framework/path"
@@ -117,16 +118,37 @@ func (d *UDLDDataSource) Read(ctx context.Context, req datasource.ReadRequest, r
return
}
- res, err := device.Client.GetData(config.getPath())
- if res.StatusCode == 404 {
- config = UDLDData{Device: config.Device}
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(config.getPath())
+ if res.StatusCode == 404 {
+ config = UDLDData{Device: config.Device}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
+ return
+ }
+
+ config.fromBody(ctx, res.Res)
+ }
} else {
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
+ }
+
+ filter := helpers.GetXpathFilter(config.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
if err != nil {
resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
return
}
- config.fromBody(ctx, res.Res)
+ config.fromBodyXML(ctx, res.Res)
}
config.Id = types.StringValue(config.getPath())
diff --git a/internal/provider/data_source_iosxe_username.go b/internal/provider/data_source_iosxe_username.go
index f2437071..eb685779 100644
--- a/internal/provider/data_source_iosxe_username.go
+++ b/internal/provider/data_source_iosxe_username.go
@@ -24,6 +24,7 @@ import (
"context"
"fmt"
+ "github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
"github.com/hashicorp/terraform-plugin-framework/path"
@@ -131,16 +132,37 @@ func (d *UsernameDataSource) Read(ctx context.Context, req datasource.ReadReques
return
}
- res, err := device.Client.GetData(config.getPath())
- if res.StatusCode == 404 {
- config = UsernameData{Device: config.Device}
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(config.getPath())
+ if res.StatusCode == 404 {
+ config = UsernameData{Device: config.Device}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
+ return
+ }
+
+ config.fromBody(ctx, res.Res)
+ }
} else {
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
+ }
+
+ filter := helpers.GetXpathFilter(config.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
if err != nil {
resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
return
}
- config.fromBody(ctx, res.Res)
+ config.fromBodyXML(ctx, res.Res)
}
config.Id = types.StringValue(config.getPath())
diff --git a/internal/provider/data_source_iosxe_vlan.go b/internal/provider/data_source_iosxe_vlan.go
index 4edf768a..451bfa64 100644
--- a/internal/provider/data_source_iosxe_vlan.go
+++ b/internal/provider/data_source_iosxe_vlan.go
@@ -24,6 +24,7 @@ import (
"context"
"fmt"
+ "github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
"github.com/hashicorp/terraform-plugin-framework/path"
@@ -133,16 +134,37 @@ func (d *VLANDataSource) Read(ctx context.Context, req datasource.ReadRequest, r
return
}
- res, err := device.Client.GetData(config.getPath())
- if res.StatusCode == 404 {
- config = VLANData{Device: config.Device}
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(config.getPath())
+ if res.StatusCode == 404 {
+ config = VLANData{Device: config.Device}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
+ return
+ }
+
+ config.fromBody(ctx, res.Res)
+ }
} else {
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
+ }
+
+ filter := helpers.GetXpathFilter(config.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
if err != nil {
resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
return
}
- config.fromBody(ctx, res.Res)
+ config.fromBodyXML(ctx, res.Res)
}
config.Id = types.StringValue(config.getPath())
diff --git a/internal/provider/data_source_iosxe_vlan_access_map.go b/internal/provider/data_source_iosxe_vlan_access_map.go
index 71c2a9c0..687c6570 100644
--- a/internal/provider/data_source_iosxe_vlan_access_map.go
+++ b/internal/provider/data_source_iosxe_vlan_access_map.go
@@ -24,6 +24,7 @@ import (
"context"
"fmt"
+ "github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
"github.com/hashicorp/terraform-plugin-framework/path"
@@ -123,16 +124,37 @@ func (d *VLANAccessMapDataSource) Read(ctx context.Context, req datasource.ReadR
return
}
- res, err := device.Client.GetData(config.getPath())
- if res.StatusCode == 404 {
- config = VLANAccessMapData{Device: config.Device}
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(config.getPath())
+ if res.StatusCode == 404 {
+ config = VLANAccessMapData{Device: config.Device}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
+ return
+ }
+
+ config.fromBody(ctx, res.Res)
+ }
} else {
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
+ }
+
+ filter := helpers.GetXpathFilter(config.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
if err != nil {
resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
return
}
- config.fromBody(ctx, res.Res)
+ config.fromBodyXML(ctx, res.Res)
}
config.Id = types.StringValue(config.getPath())
diff --git a/internal/provider/data_source_iosxe_vlan_configuration.go b/internal/provider/data_source_iosxe_vlan_configuration.go
index ae1668e1..29002486 100644
--- a/internal/provider/data_source_iosxe_vlan_configuration.go
+++ b/internal/provider/data_source_iosxe_vlan_configuration.go
@@ -24,6 +24,7 @@ import (
"context"
"fmt"
+ "github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
"github.com/hashicorp/terraform-plugin-framework/path"
@@ -121,16 +122,37 @@ func (d *VLANConfigurationDataSource) Read(ctx context.Context, req datasource.R
return
}
- res, err := device.Client.GetData(config.getPath())
- if res.StatusCode == 404 {
- config = VLANConfigurationData{Device: config.Device}
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(config.getPath())
+ if res.StatusCode == 404 {
+ config = VLANConfigurationData{Device: config.Device}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
+ return
+ }
+
+ config.fromBody(ctx, res.Res)
+ }
} else {
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
+ }
+
+ filter := helpers.GetXpathFilter(config.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
if err != nil {
resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
return
}
- config.fromBody(ctx, res.Res)
+ config.fromBodyXML(ctx, res.Res)
}
config.Id = types.StringValue(config.getPath())
diff --git a/internal/provider/data_source_iosxe_vlan_filter.go b/internal/provider/data_source_iosxe_vlan_filter.go
index 013d77a3..efdff3d0 100644
--- a/internal/provider/data_source_iosxe_vlan_filter.go
+++ b/internal/provider/data_source_iosxe_vlan_filter.go
@@ -24,6 +24,7 @@ import (
"context"
"fmt"
+ "github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
"github.com/hashicorp/terraform-plugin-framework/path"
@@ -110,16 +111,37 @@ func (d *VLANFilterDataSource) Read(ctx context.Context, req datasource.ReadRequ
return
}
- res, err := device.Client.GetData(config.getPath())
- if res.StatusCode == 404 {
- config = VLANFilterData{Device: config.Device}
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(config.getPath())
+ if res.StatusCode == 404 {
+ config = VLANFilterData{Device: config.Device}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
+ return
+ }
+
+ config.fromBody(ctx, res.Res)
+ }
} else {
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
+ }
+
+ filter := helpers.GetXpathFilter(config.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
if err != nil {
resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
return
}
- config.fromBody(ctx, res.Res)
+ config.fromBodyXML(ctx, res.Res)
}
config.Id = types.StringValue(config.getPath())
diff --git a/internal/provider/data_source_iosxe_vlan_filter_test.go b/internal/provider/data_source_iosxe_vlan_filter_test.go
index f028188e..3854929e 100644
--- a/internal/provider/data_source_iosxe_vlan_filter_test.go
+++ b/internal/provider/data_source_iosxe_vlan_filter_test.go
@@ -53,8 +53,8 @@ func TestAccDataSourceIosxeVLANFilter(t *testing.T) {
// Section below is generated&owned by "gen/generator.go". //template:begin testPrerequisites
const testAccDataSourceIosxeVLANFilterPrerequisitesConfig = `
-resource "iosxe_restconf" "PreReq0" {
- path = "Cisco-IOS-XE-native:native/vlan/Cisco-IOS-XE-vlan:access-map=VAM1,10"
+resource "iosxe_yang" "PreReq0" {
+ path = "/Cisco-IOS-XE-native:native/vlan/Cisco-IOS-XE-vlan:access-map[name=VAM1][value=10]"
attributes = {
"name" = "VAM1"
"value" = "10"
@@ -71,7 +71,7 @@ func testAccDataSourceIosxeVLANFilterConfig() string {
config := `resource "iosxe_vlan_filter" "test" {` + "\n"
config += ` word = "VAM1"` + "\n"
config += ` vlan_lists = [1]` + "\n"
- config += ` depends_on = [iosxe_restconf.PreReq0, ]` + "\n"
+ config += ` depends_on = [iosxe_yang.PreReq0, ]` + "\n"
config += `}` + "\n"
config += `
diff --git a/internal/provider/data_source_iosxe_vlan_group.go b/internal/provider/data_source_iosxe_vlan_group.go
index 1f7accdc..b4e0e6c3 100644
--- a/internal/provider/data_source_iosxe_vlan_group.go
+++ b/internal/provider/data_source_iosxe_vlan_group.go
@@ -24,6 +24,7 @@ import (
"context"
"fmt"
+ "github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
"github.com/hashicorp/terraform-plugin-framework/path"
@@ -110,16 +111,37 @@ func (d *VLANGroupDataSource) Read(ctx context.Context, req datasource.ReadReque
return
}
- res, err := device.Client.GetData(config.getPath())
- if res.StatusCode == 404 {
- config = VLANGroupData{Device: config.Device}
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(config.getPath())
+ if res.StatusCode == 404 {
+ config = VLANGroupData{Device: config.Device}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
+ return
+ }
+
+ config.fromBody(ctx, res.Res)
+ }
} else {
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
+ }
+
+ filter := helpers.GetXpathFilter(config.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
if err != nil {
resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
return
}
- config.fromBody(ctx, res.Res)
+ config.fromBodyXML(ctx, res.Res)
}
config.Id = types.StringValue(config.getPath())
diff --git a/internal/provider/data_source_iosxe_vrf.go b/internal/provider/data_source_iosxe_vrf.go
index f3127305..4a46f522 100644
--- a/internal/provider/data_source_iosxe_vrf.go
+++ b/internal/provider/data_source_iosxe_vrf.go
@@ -24,6 +24,7 @@ import (
"context"
"fmt"
+ "github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
"github.com/hashicorp/terraform-plugin-framework/path"
@@ -269,16 +270,37 @@ func (d *VRFDataSource) Read(ctx context.Context, req datasource.ReadRequest, re
return
}
- res, err := device.Client.GetData(config.getPath())
- if res.StatusCode == 404 {
- config = VRFData{Device: config.Device}
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(config.getPath())
+ if res.StatusCode == 404 {
+ config = VRFData{Device: config.Device}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
+ return
+ }
+
+ config.fromBody(ctx, res.Res)
+ }
} else {
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
+ }
+
+ filter := helpers.GetXpathFilter(config.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
if err != nil {
resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
return
}
- config.fromBody(ctx, res.Res)
+ config.fromBodyXML(ctx, res.Res)
}
config.Id = types.StringValue(config.getPath())
diff --git a/internal/provider/data_source_iosxe_vtp.go b/internal/provider/data_source_iosxe_vtp.go
index ad6cebfc..d8049c46 100644
--- a/internal/provider/data_source_iosxe_vtp.go
+++ b/internal/provider/data_source_iosxe_vtp.go
@@ -24,6 +24,7 @@ import (
"context"
"fmt"
+ "github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
"github.com/hashicorp/terraform-plugin-framework/path"
@@ -203,16 +204,37 @@ func (d *VTPDataSource) Read(ctx context.Context, req datasource.ReadRequest, re
return
}
- res, err := device.Client.GetData(config.getPath())
- if res.StatusCode == 404 {
- config = VTPData{Device: config.Device}
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(config.getPath())
+ if res.StatusCode == 404 {
+ config = VTPData{Device: config.Device}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
+ return
+ }
+
+ config.fromBody(ctx, res.Res)
+ }
} else {
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
+ }
+
+ filter := helpers.GetXpathFilter(config.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
if err != nil {
resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", config.getPath(), err))
return
}
- config.fromBody(ctx, res.Res)
+ config.fromBodyXML(ctx, res.Res)
}
config.Id = types.StringValue(config.getPath())
diff --git a/internal/provider/data_source_iosxe_yang.go b/internal/provider/data_source_iosxe_yang.go
new file mode 100644
index 00000000..fd970347
--- /dev/null
+++ b/internal/provider/data_source_iosxe_yang.go
@@ -0,0 +1,185 @@
+// 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
+
+import (
+ "context"
+ "fmt"
+
+ "github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
+ "github.com/hashicorp/terraform-plugin-framework/attr"
+ "github.com/hashicorp/terraform-plugin-framework/datasource"
+ "github.com/hashicorp/terraform-plugin-framework/datasource/schema"
+ "github.com/hashicorp/terraform-plugin-framework/path"
+ "github.com/hashicorp/terraform-plugin-framework/types"
+ "github.com/hashicorp/terraform-plugin-log/tflog"
+)
+
+// Ensure the implementation satisfies the expected interfaces.
+var (
+ _ datasource.DataSource = &YangDataSource{}
+ _ datasource.DataSourceWithConfigure = &YangDataSource{}
+)
+
+func NewYangDataSource() datasource.DataSource {
+ return &YangDataSource{}
+}
+
+type YangDataSource struct {
+ data *IosxeProviderData
+}
+
+func (d *YangDataSource) Metadata(_ context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) {
+ resp.TypeName = req.ProviderTypeName + "_yang"
+}
+
+func (d *YangDataSource) 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 retrieve one or more attributes via YANG paths.",
+
+ Attributes: map[string]schema.Attribute{
+ "device": schema.StringAttribute{
+ MarkdownDescription: "A device name from the provider configuration.",
+ Optional: true,
+ },
+ "id": schema.StringAttribute{
+ MarkdownDescription: "The path of the retrieved object.",
+ Computed: true,
+ },
+ "path": schema.StringAttribute{
+ MarkdownDescription: "A YANG path, e.g. `openconfig-interfaces:interfaces`.",
+ Required: true,
+ },
+ "attributes": schema.MapAttribute{
+ MarkdownDescription: "Map of key-value pairs which represents the attributes and its values.",
+ Computed: true,
+ ElementType: types.StringType,
+ },
+ },
+ }
+}
+
+func (d *YangDataSource) Configure(_ context.Context, req datasource.ConfigureRequest, _ *datasource.ConfigureResponse) {
+ if req.ProviderData == nil {
+ return
+ }
+
+ d.data = req.ProviderData.(*IosxeProviderData)
+}
+
+func (d *YangDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) {
+ var config, state YangDataSourceModel
+
+ // 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.Path.ValueString()))
+
+ device, ok := d.data.Devices[config.Device.ValueString()]
+ if !ok {
+ resp.Diagnostics.AddAttributeError(path.Root("device"), "Invalid device", fmt.Sprintf("Device '%s' does not exist in provider configuration.", config.Device.ValueString()))
+ return
+ }
+
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(config.getPath())
+ if res.StatusCode == 404 {
+ state.Attributes = types.MapValueMust(types.StringType, map[string]attr.Value{})
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object, got error: %s", err))
+ return
+ }
+
+ state.Path = config.Path
+ state.Id = config.Path
+
+ attributes := make(map[string]attr.Value)
+
+ for attr, value := range res.Res.Get(helpers.LastElement(config.getPath())).Map() {
+ // handle empty maps
+ if value.IsObject() && len(value.Map()) == 0 {
+ attributes[attr] = types.StringValue("")
+ } else if value.Raw == "[null]" {
+ attributes[attr] = types.StringValue("")
+ } else {
+ attributes[attr] = types.StringValue(value.String())
+ }
+ }
+ state.Attributes = types.MapValueMust(types.StringType, attributes)
+ }
+ } else {
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
+ }
+
+ res, err := device.NetconfClient.GetConfig(ctx, "running", helpers.GetXpathFilter(config.Path.ValueString()))
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object, got error: %s", err))
+ return
+ }
+
+ state.Path = config.Path
+ state.Id = config.Path
+
+ // Get the result at the specified path
+ result := helpers.GetFromXPath(res.Res, config.Path.ValueString())
+
+ if !result.Exists() {
+ state.Attributes = types.MapValueMust(types.StringType, map[string]attr.Value{})
+ } else {
+ attributes := make(map[string]attr.Value)
+
+ // If the result is an array, use the first element
+ if result.IsArray() {
+ resultArray := result.Array()
+ if len(resultArray) > 0 {
+ result = resultArray[0]
+ }
+ }
+
+ // Parse the raw XML to get child elements
+ // The result.Raw contains the XML content, we need to parse it to get attributes
+ // For simplicity, we'll just return the raw content as a single attribute if needed
+ // In a real implementation, you would parse child elements here
+
+ // For now, store the entire content as a single value if it's a simple type
+ if result.String() != "" {
+ attributes["value"] = types.StringValue(result.String())
+ }
+
+ state.Attributes = types.MapValueMust(types.StringType, attributes)
+ }
+ }
+
+ tflog.Debug(ctx, fmt.Sprintf("%s: Read finished successfully", config.Path.ValueString()))
+
+ diags = resp.State.Set(ctx, &state)
+ resp.Diagnostics.Append(diags...)
+}
diff --git a/internal/provider/data_source_iosxe_restconf_test.go b/internal/provider/data_source_iosxe_yang_test.go
similarity index 65%
rename from internal/provider/data_source_iosxe_restconf_test.go
rename to internal/provider/data_source_iosxe_yang_test.go
index 65ad460a..7c492a92 100644
--- a/internal/provider/data_source_iosxe_restconf_test.go
+++ b/internal/provider/data_source_iosxe_yang_test.go
@@ -23,32 +23,32 @@ import (
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
)
-func TestAccDataSourceIosxeRestconf(t *testing.T) {
+func TestAccDataSourceIosxeYang(t *testing.T) {
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ProtoV6ProviderFactories: testAccProtoV6ProviderFactories,
Steps: []resource.TestStep{
{
- Config: testAccDataSourceIosxeRestconfConfigInterface,
+ Config: testAccDataSourceIosxeYangConfigInterface,
Check: resource.ComposeTestCheckFunc(
- resource.TestCheckResourceAttr("data.iosxe_restconf.test", "id", "Cisco-IOS-XE-native:native/banner/login"),
- resource.TestCheckResourceAttr("data.iosxe_restconf.test", "attributes.banner", "My Banner"),
+ resource.TestCheckResourceAttr("data.iosxe_yang.test", "id", "/Cisco-IOS-XE-native:native/banner/login"),
+ resource.TestCheckResourceAttr("data.iosxe_yang.test", "attributes.banner", "My Banner"),
),
},
},
})
}
-const testAccDataSourceIosxeRestconfConfigInterface = `
-resource "iosxe_restconf" "test" {
- path = "Cisco-IOS-XE-native:native/banner/login"
+const testAccDataSourceIosxeYangConfigInterface = `
+resource "iosxe_yang" "test" {
+ path = "/Cisco-IOS-XE-native:native/banner/login"
attributes = {
banner = "My Banner"
}
}
-data "iosxe_restconf" "test" {
- path = "Cisco-IOS-XE-native:native/banner/login"
- depends_on = [iosxe_restconf.test]
+data "iosxe_yang" "test" {
+ path = "/Cisco-IOS-XE-native:native/banner/login"
+ depends_on = [iosxe_yang.test]
}
`
diff --git a/internal/provider/helpers/netconf.go b/internal/provider/helpers/netconf.go
new file mode 100644
index 00000000..163cc18a
--- /dev/null
+++ b/internal/provider/helpers/netconf.go
@@ -0,0 +1,808 @@
+// Copyright © 2025 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 helpers
+
+import (
+ "context"
+ "fmt"
+ "regexp"
+ "strings"
+ "sync"
+
+ "github.com/hashicorp/terraform-plugin-log/tflog"
+ "github.com/netascode/go-netconf"
+ "github.com/netascode/xmldot"
+)
+
+// Pre-compiled regular expressions for performance
+var (
+ xpathPredicateRegex = regexp.MustCompile(`\[[^\]]*\]`)
+ namespaceRegex = regexp.MustCompile(`[a-zA-Z0-9\-]+:`)
+ predicatePattern = regexp.MustCompile(`\[([^\]]+)\]`)
+)
+
+// Namespace base URL for Cisco YANG models
+const namespaceBaseURL = "http://cisco.com/ns/yang/"
+
+// ManageNetconfConnection manages NETCONF connection lifecycle based on reuse policy.
+//
+// The connMutex parameter serializes connection state changes (Reopen/Close) to prevent
+// race conditions when multiple goroutines access the same NETCONF session concurrently.
+//
+// When reuseConnection is true (default):
+// - Reopens connection if closed (with mutex protection)
+// - Returns no-op defer function (keeps connection open for subsequent operations)
+//
+// When reuseConnection is false:
+// - Reopens connection if closed (with mutex protection)
+// - Returns defer function to close connection after operation (with mutex protection)
+//
+// Usage:
+//
+// cleanup, err := helpers.ManageNetconfConnection(ctx, client, &device.NetconfConnMutex, reuseConnection)
+// if err != nil {
+// return err
+// }
+// defer cleanup()
+func ManageNetconfConnection(
+ ctx context.Context,
+ client *netconf.Client,
+ connMutex *sync.Mutex,
+ reuseConnection bool,
+) (cleanup func(), err error) {
+ // Serialize connection state changes (Reopen/Close)
+ connMutex.Lock()
+
+ // Reopen connection if closed (required regardless of reuse policy)
+ if client.IsClosed() {
+ if err := client.Reopen(); err != nil {
+ connMutex.Unlock()
+ return nil, fmt.Errorf("failed to reopen NETCONF connection: %w", err)
+ }
+ }
+
+ connMutex.Unlock()
+
+ // Return appropriate cleanup function based on reuse policy
+ if reuseConnection {
+ // Keep connection open - return no-op cleanup
+ return func() {}, nil
+ }
+
+ // Close connection after operation (legacy behavior) with mutex protection
+ return func() {
+ connMutex.Lock()
+ defer connMutex.Unlock()
+ if err := client.Close(); err != nil {
+ tflog.Warn(ctx, fmt.Sprintf("Failed to close NETCONF connection: %s", err))
+ }
+ }, nil
+}
+
+// EditConfig edits the configuration on the device
+// If the server supports the candidate capability, it will edit the configuration in the candidate datastore
+// and commit it to the running datastore if commit is true.
+// If the server does not support the candidate capability, it will edit the configuration in the running datastore.
+//
+// IMPORTANT: When connection reuse is enabled, callers MUST serialize calls to EditConfig using an
+// application-level mutex that also covers ManageNetconfConnection(). This prevents concurrent goroutines
+// from attempting to acquire NETCONF datastore locks simultaneously on the same session.
+//
+// Parameters:
+// - ctx: context.Context
+// - client: *netconf.Client
+// - body: string
+// - commit: bool
+func EditConfig(ctx context.Context, client *netconf.Client, body string, commit bool) error {
+
+ candidate := client.ServerHasCapability("urn:ietf:params:netconf:capability:candidate:1.0")
+
+ if candidate {
+ // Lock running datastore
+ if _, err := client.Lock(ctx, "running"); err != nil {
+ return fmt.Errorf("failed to lock running datastore: %w", err)
+ }
+ defer client.Unlock(ctx, "running")
+
+ // Lock candidate datastore
+ if _, err := client.Lock(ctx, "candidate"); err != nil {
+ return fmt.Errorf("failed to lock candidate datastore: %w", err)
+ }
+ defer client.Unlock(ctx, "candidate")
+
+ if _, err := client.EditConfig(ctx, "candidate", body); err != nil {
+ return fmt.Errorf("failed to edit config: %w", err)
+ }
+
+ if commit {
+ if _, err := client.Commit(ctx); err != nil {
+ return fmt.Errorf("failed to commit config: %w", err)
+ }
+ }
+ } else {
+ // Lock running datastore
+ if _, err := client.Lock(ctx, "running"); err != nil {
+ return fmt.Errorf("failed to lock running datastore: %w", err)
+ }
+ defer client.Unlock(ctx, "running")
+
+ if _, err := client.EditConfig(ctx, "running", body); err != nil {
+ return fmt.Errorf("failed to edit config: %w", err)
+ }
+ }
+ return nil
+}
+
+// GetXpathFilter creates a NETCONF XPath filter with namespace prefixes removed.
+// It processes the XPath expression to strip namespace prefixes from both element names
+// and predicate key names, preserving the path structure.
+//
+// Supports the same XPath formats as SetFromXPath and GetFromXPath:
+// - Paths with namespace prefixes: /Cisco-IOS-XE-native:native/interface
+// - Single predicates: /native/interface[name='GigabitEthernet1']
+// - Multiple predicates: /native/interface[name='Gi1'][vrf='VRF1']
+// - Nested paths: /native/interface[name='Gi1']/ip/address
+// - Values with slashes: /native/interface[name='GigabitEthernet1/0/1']
+// - Predicates with namespace prefixes: /Cisco-IOS-XE-native:interface[Cisco-IOS-XE-native:name='Gi1']
+//
+// Example transformations:
+//
+// Input: "/Cisco-IOS-XE-native:native/aaa"
+// Output: netconf.Filter{Type: "xpath", Content: "/native/aaa"}
+//
+// Input: "/Cisco-IOS-XE-native:native/interface[Cisco-IOS-XE-native:name='Gi1']/Cisco-IOS-XE-native:ip"
+// Output: netconf.Filter{Type: "xpath", Content: "/native/interface[name='Gi1']/ip"}
+//
+// Input: "/native/interface[name='GigabitEthernet1/0/1']"
+// Output: netconf.Filter{Type: "xpath", Content: "/native/interface[name='GigabitEthernet1/0/1']"}
+func GetXpathFilter(xPath string) netconf.Filter {
+ // Remove leading slash if present
+ xPath = strings.TrimPrefix(xPath, "/")
+
+ // Split into segments while respecting bracket boundaries
+ segments := splitXPathSegments(xPath)
+
+ // Process each segment to remove namespace prefixes
+ processedSegments := make([]string, 0, len(segments))
+ for _, segment := range segments {
+ elementName, keys := parseXPathSegment(segment)
+
+ // Remove namespace prefix from element name
+ elementName = removeNamespacePrefix(elementName)
+
+ // Reconstruct segment with predicates
+ if len(keys) > 0 {
+ // Build predicates in order
+ predicates := make([]string, 0, len(keys))
+ for _, kv := range keys {
+ // Remove namespace prefix from key name
+ keyName := removeNamespacePrefix(kv.Key)
+ predicates = append(predicates, fmt.Sprintf("%s='%s'", keyName, kv.Value))
+ }
+ // Reconstruct segment with all predicates
+ reconstructed := elementName
+ for _, pred := range predicates {
+ reconstructed += "[" + pred + "]"
+ }
+ processedSegments = append(processedSegments, reconstructed)
+ } else {
+ processedSegments = append(processedSegments, elementName)
+ }
+ }
+
+ // Join segments back with slashes
+ cleanedPath := "/" + strings.Join(processedSegments, "/")
+ return netconf.XPathFilter(cleanedPath)
+}
+
+// ConvertRestconfPathToXPath converts a RESTCONF-style path to XPath-style with predicates.
+// Key names are always converted to %v placeholders for generic path handling.
+//
+// RESTCONF uses: element=value
+// XPath uses: element[%v=value]
+//
+// Examples:
+// - "interface/%s=%v" → "interface/%s[%v=%v]"
+// - "interface/GigabitEthernet=1" → "interface/GigabitEthernet[%v=1]"
+// - "vrf=VRF1,af=ipv4" → "vrf[%v=VRF1][%v=ipv4]"
+// - "native/vrf=VRF1/address-family=ipv4" → "native/vrf[%v=VRF1]/address-family[%v=ipv4]"
+func ConvertRestconfPathToXPath(path string) string {
+ // Replace =placeholder patterns with [%v=placeholder]
+ // This handles: %s=%v, %d=%v, %v=%v, etc.
+ re := regexp.MustCompile(`=(%[sdv])`)
+ path = re.ReplaceAllString(path, "[%v=$1]")
+
+ // Handle concrete paths with actual key values
+ // Split path into segments
+ segments := strings.Split(path, "/")
+ result := make([]string, 0, len(segments))
+
+ for _, segment := range segments {
+ if !strings.Contains(segment, "=") || strings.Contains(segment, "[") {
+ // No key in this segment, or already processed, keep as-is
+ result = append(result, segment)
+ continue
+ }
+
+ // Extract element name and key values
+ parts := strings.SplitN(segment, "=", 2)
+ if len(parts) != 2 {
+ result = append(result, segment)
+ continue
+ }
+
+ elementName := parts[0]
+ keyValues := strings.Split(parts[1], ",")
+
+ // Build XPath predicates with %v placeholders for key names
+ predicates := ""
+ for _, keyValue := range keyValues {
+ predicates += fmt.Sprintf("[%%v=%s]", keyValue)
+ }
+
+ result = append(result, elementName+predicates)
+ }
+
+ return strings.Join(result, "/")
+}
+
+// KeyValue represents a key-value pair with preserved order
+type KeyValue struct {
+ Key string
+ Value string
+}
+
+// dotPath converts a YANG path to a dot path by removing XPath predicates (keys) and namespace prefixes.
+// Example: "Cisco-IOS-XE-native:interface/GigabitEthernet[name]/description" -> "interface.GigabitEthernet.description"
+func dotPath(path string) string {
+ // Remove XPath predicates like [name='value'] or [name]
+ path = xpathPredicateRegex.ReplaceAllString(path, "")
+
+ path = strings.ReplaceAll(path, "/", ".")
+
+ // Remove namespace prefixes like "Cisco-IOS-XE-native:" or "Cisco-IOS-XE-bgp:"
+ return namespaceRegex.ReplaceAllString(path, "")
+}
+
+// removeNamespacePrefix removes the namespace prefix from a single element or attribute name.
+// Example: "Cisco-IOS-XE-native:interface" -> "interface"
+func removeNamespacePrefix(name string) string {
+ if idx := strings.Index(name, ":"); idx != -1 {
+ return name[idx+1:]
+ }
+ return name
+}
+
+// setWithNamespaces sets a value in the netconf body and automatically adds
+// namespace declarations for any prefixes found in the path.
+func setWithNamespaces(body netconf.Body, fullPath string, value any) netconf.Body {
+ // Set the value
+ body = body.Set(dotPath(fullPath), value)
+
+ // Extract and add namespace declarations
+ body = augmentNamespaces(body, fullPath)
+
+ return body
+}
+
+// augmentNamespaces walks through the path and adds namespace declarations
+// to elements where prefixes appear, checking the current body to avoid duplicates.
+func augmentNamespaces(body netconf.Body, path string) netconf.Body {
+ segments := strings.Split(path, ".")
+ pathWithoutPrefix := make([]string, 0, len(segments))
+
+ for _, segment := range segments {
+ // Strip prefix from segment and add to path
+ cleanSegment := removeNamespacePrefix(segment)
+ // Also strip XPath predicates like [key='value']
+ // This prevents malformed paths like "standard[name=SACL1].@xmlns"
+ if idx := strings.IndexByte(cleanSegment, '['); idx != -1 {
+ cleanSegment = cleanSegment[:idx]
+ }
+ pathWithoutPrefix = append(pathWithoutPrefix, cleanSegment)
+
+ // If this segment has a namespace prefix, add xmlns declaration
+ if idx := strings.Index(segment, ":"); idx != -1 {
+ prefix := segment[:idx]
+ currentPath := strings.Join(pathWithoutPrefix, ".")
+ namespace := namespaceBaseURL + prefix
+
+ xmlnsPath := currentPath + ".@xmlns"
+ if !xmldot.Get(body.Res(), xmlnsPath).Exists() {
+ body = body.Set(xmlnsPath, namespace)
+ }
+ }
+ }
+
+ return body
+}
+
+// splitXPathSegments splits an XPath into segments while respecting bracket boundaries.
+// This prevents splitting on forward slashes inside predicates like [name='GigabitEthernet1/0/1']
+func splitXPathSegments(xPath string) []string {
+ segments := []string{}
+ var currentSegment strings.Builder
+ bracketDepth := 0
+
+ for _, char := range xPath {
+ switch char {
+ case '[':
+ bracketDepth++
+ currentSegment.WriteRune(char)
+ case ']':
+ bracketDepth--
+ currentSegment.WriteRune(char)
+ case '/':
+ if bracketDepth == 0 {
+ // We're not inside brackets, so this is a segment separator
+ if currentSegment.Len() > 0 {
+ segments = append(segments, currentSegment.String())
+ currentSegment.Reset()
+ }
+ } else {
+ // We're inside brackets, so this is part of a predicate value
+ currentSegment.WriteRune(char)
+ }
+ default:
+ currentSegment.WriteRune(char)
+ }
+ }
+
+ // Add the last segment if there's anything left
+ if currentSegment.Len() > 0 {
+ segments = append(segments, currentSegment.String())
+ }
+
+ return segments
+}
+
+// buildXPathStructure is a helper that creates all elements in an XPath, including keys and namespaces.
+// Returns the body with the structure created and the path segments for further processing.
+// The ensureStructure parameter controls whether an empty element should be created at the final path
+// if it doesn't already exist. Set to false when a value will be immediately set afterward.
+func buildXPathStructure(body netconf.Body, xPath string, ensureStructure bool) (netconf.Body, []string) {
+ // Remove leading slash if present
+ xPath = strings.TrimPrefix(xPath, "/")
+
+ // Split into segments while respecting bracket boundaries
+ segments := splitXPathSegments(xPath)
+
+ // Build path incrementally, creating each element
+ pathSegments := make([]string, 0, len(segments))
+
+ for i, segment := range segments {
+ // Parse segment: element[key='value'][key2='value2'] -> element, []KeyValue
+ elementName, keys := parseXPathSegment(segment)
+
+ // Add element name to path (without predicates)
+ pathSegments = append(pathSegments, elementName)
+ fullPath := strings.Join(pathSegments[:i+1], ".")
+
+ // If this segment has keys, set all key values in order
+ if len(keys) > 0 {
+ for _, kv := range keys {
+ keyPath := fullPath + "." + kv.Key
+ body = setWithNamespaces(body, keyPath, kv.Value)
+ }
+ }
+ }
+
+ // Optionally ensure the complete path structure exists, including non-predicate elements.
+ // Only create the structure if requested and if it doesn't already exist.
+ if ensureStructure && len(pathSegments) > 0 {
+ fullPath := strings.Join(pathSegments, ".")
+ existingContent := xmldot.Get(body.Res(), dotPath(fullPath)).String()
+ if existingContent == "" {
+ // Path doesn't exist yet, create it with SetWithNamespaces
+ body = setWithNamespaces(body, fullPath, "")
+ }
+ }
+
+ return body, pathSegments
+}
+
+// parseXPathSegment parses an XPath segment with single or multiple keys
+// Supports formats:
+// - element[key='value']
+// - element[key1='value1'][key2='value2']
+// - element[key1='value1' and key2='value2']
+//
+// Returns: (elementName, []KeyValue) - order is preserved from the XPath
+func parseXPathSegment(segment string) (string, []KeyValue) {
+ // Check for predicate: element[...]
+ if idx := strings.Index(segment, "["); idx != -1 {
+ elementName := segment[:idx]
+ keys := make([]KeyValue, 0)
+
+ // Extract all predicates - handle both [key1='val1'][key2='val2'] and [key1='val1' and key2='val2']
+ remainingPredicates := segment[idx:]
+
+ // Use pre-compiled pattern to match predicates: [anything]
+ predicates := predicatePattern.FindAllStringSubmatch(remainingPredicates, -1)
+
+ for _, match := range predicates {
+ if len(match) > 1 {
+ predicate := match[1]
+
+ // Split by 'and' to handle combined predicates
+ conditions := strings.Split(predicate, " and ")
+ for _, condition := range conditions {
+ // Parse each condition: key='value' or key="value"
+ if eqIdx := strings.Index(condition, "="); eqIdx != -1 {
+ keyName := strings.TrimSpace(condition[:eqIdx])
+ value := condition[eqIdx+1:]
+ // Remove quotes
+ keyValue := strings.Trim(value, `'"`)
+ keys = append(keys, KeyValue{Key: keyName, Value: keyValue})
+ }
+ }
+ }
+ }
+
+ return elementName, keys
+ }
+
+ // No predicate
+ return segment, nil
+}
+
+// RemoveFromXPath creates all elements in an XPath with an operation="remove" attribute
+// on the last element for NETCONF delete operations.
+// Supports the same XPath formats as SetFromXPath.
+//
+// Example: /native/interface[name='Gi1']/ip/address
+// Creates: Gi1
+func RemoveFromXPath(body netconf.Body, xPath string) netconf.Body {
+ // We don't need empty structure since operation="remove" will create the element
+ body, pathSegments := buildXPathStructure(body, xPath, false)
+
+ // Set operation="remove" on the last element
+ if len(pathSegments) > 0 {
+ targetPath := strings.Join(pathSegments, ".")
+ operationPath := targetPath + ".@operation"
+ body = setWithNamespaces(body, operationPath, "remove")
+ }
+
+ return body
+}
+
+// SetFromXPath creates all elements in an XPath, including keys and namespaces,
+// and optionally sets a value at the final path location.
+// Supports single and composite keys:
+// - Single: /interface[name='GigabitEthernet1']
+// - Multiple predicates: /interface[name='GigabitEthernet1'][vrf='VRF1']
+// - Combined with 'and': /interface[name='GigabitEthernet1' and vrf='VRF1']
+// - Values with slashes: /interface[name='GigabitEthernet1/0/1']
+//
+// If value is nil or empty string, only the structure is created without setting a value.
+// If value is non-empty, it's set at the final path location.
+//
+// Multi-Root Support:
+// SetFromXPath properly handles multiple root-level sibling elements (e.g., both and
+// at the same level). The underlying xmldot library automatically detects when different root paths
+// are used and creates sibling elements instead of nesting them.
+//
+// Example (multi-root XML):
+//
+// body := netconf.Body{}
+// body = SetFromXPath(body, "sequence", "10")
+// body = SetFromXPath(body, "deny/std-ace/prefix", "10.0.0.0")
+// body = SetFromXPath(body, "permit/std-ace/prefix", "192.168.0.0")
+// // Result: 10......
+func SetFromXPath(body netconf.Body, xPath string, value any) netconf.Body {
+ // Determine if we need to create empty structure
+ // Only create empty structure if no value will be set
+ hasValue := value != nil && value != ""
+ ensureStructure := !hasValue
+
+ body, pathSegments := buildXPathStructure(body, xPath, ensureStructure)
+
+ // Only set the value if it's not nil and not empty string
+ // This prevents overwriting key children when no value is needed
+ if hasValue && len(pathSegments) > 0 {
+ fullPath := strings.Join(pathSegments, ".")
+ body = setWithNamespaces(body, fullPath, value)
+ }
+
+ return body
+}
+
+// AppendFromXPath creates all elements in an XPath and appends a value to a list by using
+// the ".-1" syntax. This is useful for adding multiple items to a list without keys.
+// The function automatically appends ".-1" to the final element in the path.
+//
+// Example:
+//
+// body := netconf.Body{}
+// body = AppendFromXPath(body, "native/route-map/rule/match/ip/address", "10")
+// body = AppendFromXPath(body, "native/route-map/rule/match/ip/address", "20")
+// // Result:
+// // 10
+// // 20
+// //
+//
+// Note: This function is designed for simple list items without keys. For lists with keys,
+// use SetFromXPath with predicates instead.
+func AppendFromXPath(body netconf.Body, xPath string, value any) netconf.Body {
+ // Determine if we need to create empty structure
+ hasValue := value != nil && value != ""
+ ensureStructure := !hasValue
+
+ body, pathSegments := buildXPathStructure(body, xPath, ensureStructure)
+
+ // Append to the list using .-1 syntax
+ if hasValue && len(pathSegments) > 0 {
+ fullPath := strings.Join(pathSegments, ".") + ".-1"
+ body = setWithNamespaces(body, fullPath, value)
+ }
+
+ return body
+}
+
+// SetRawFromXPath creates all elements in an XPath, including keys and namespace declarations,
+// then inserts raw XML content at the final path location. This is useful when you have
+// pre-formatted XML that needs to be inserted as child elements.
+//
+// The value parameter should contain raw XML content (child elements, attributes, etc.) that will
+// be parsed and inserted at the target path. The content is wrapped in the final element tag
+// specified by the xPath.
+//
+// Multi-root Support:
+// When called multiple times with the same path, this function appends the new XML content
+// as an additional sibling element, creating a multi-root XML fragment at the parent level.
+// The underlying xmldot library automatically handles multi-root fragments, making this safe for
+// creating multiple sibling elements (e.g., multiple elements in a list).
+//
+// Example (single call):
+//
+// xPath: /Cisco-IOS-XE-native:native/interface[name='Gi1']
+// value: "Management"
+// Result:
+//
+// Gi1
+// Management
+//
+//
+//
+//
+// Example (multiple calls - multi-root):
+//
+// First call: SetRawFromXPath(body, "/native/interface", "Gi1")
+// Second call: SetRawFromXPath(body, "/native/interface", "Gi2")
+// Result:
+// Gi1
+// Gi2
+//
+//
+// Unlike SetFromXPath, this function:
+// - Adds xmlns declarations for namespace prefixes in the path (via buildXPathStructure)
+// - Inserts the value as raw XML (parsed as child elements) rather than as text content
+// - Uses body.SetRaw() instead of body.Set() for XML insertion
+// - Supports appending multiple elements at the same path (multi-root fragments)
+func SetRawFromXPath(body netconf.Body, xPath string, value string) netconf.Body {
+ if len(value) == 0 {
+ return body
+ }
+
+ // Remove leading slash if present
+ xPath = strings.TrimPrefix(xPath, "/")
+
+ // Split into segments while respecting bracket boundaries
+ segments := splitXPathSegments(xPath)
+ if len(segments) == 0 {
+ return body
+ }
+
+ // Extract the final element name to wrap the content
+ finalSegment := segments[len(segments)-1]
+ finalElement, keys := parseXPathSegment(finalSegment)
+ finalElementClean := removeNamespacePrefix(finalElement)
+ wrappedContent := "<" + finalElementClean + ">" + value + "" + finalElementClean + ">"
+
+ // Build parent structure (everything except the final element)
+ if len(segments) > 1 {
+ parentXPath := "/" + strings.Join(segments[:len(segments)-1], "/")
+ // Build structure but don't create empty elements (may already have content)
+ body, _ = buildXPathStructure(body, parentXPath, false)
+
+ // Get parent path for setting content
+ parentPathSegments := make([]string, 0, len(segments)-1)
+ for _, segment := range segments[:len(segments)-1] {
+ elementName, _ := parseXPathSegment(segment)
+ parentPathSegments = append(parentPathSegments, elementName)
+ }
+ parentPath := dotPath(strings.Join(parentPathSegments, "."))
+
+ // Check if content already exists at parent path
+ existingXML := xmldot.Get(body.Res(), parentPath).Raw
+
+ if existingXML != "" {
+ // Append wrapped element as sibling to existing content
+ // xmldot now supports multi-root XML fragments at the parent level
+ combinedXML := existingXML + wrappedContent
+ body = body.SetRaw(parentPath, combinedXML)
+ } else {
+ // First element, set the wrapped content at parent
+ body = body.SetRaw(parentPath, wrappedContent)
+ }
+ } else {
+ // No parent path - the element is at root level
+ // Build any keys if present
+ if len(keys) > 0 {
+ tempBody := netconf.Body{}
+ for _, kv := range keys {
+ tempBody = setWithNamespaces(tempBody, kv.Key, kv.Value)
+ }
+ wrappedContent = "<" + finalElementClean + ">" + tempBody.Res() + value + "" + finalElementClean + ">"
+ }
+
+ // Check if root already has content
+ existingXML := body.Res()
+ if existingXML != "" {
+ // Append as sibling
+ body = body.SetRaw("", existingXML+wrappedContent)
+ } else {
+ // First element
+ body = body.SetRaw("", wrappedContent)
+ }
+ }
+
+ // Add namespace declarations if present in the original path
+ // Convert XPath segments back to dotPath format for augmentNamespaces
+ if len(segments) > 0 {
+ dotPathForNamespaces := strings.Join(segments, ".")
+ body = augmentNamespaces(body, dotPathForNamespaces)
+ }
+
+ return body
+}
+
+// GetFromXPath converts an XPath expression to a xmldot path with filters and retrieves the result.
+// Uses xmldot's native filter syntax #() for single predicates, manual filtering for multiple.
+// Supports the same XPath formats as SetFromXPath:
+// - Single: /interface[name='GigabitEthernet1']
+// - Multiple predicates: /interface[name='GigabitEthernet1'][vrf='VRF1']
+// - Combined with 'and': /interface[name='GigabitEthernet1' and vrf='VRF1']
+// - Values with slashes: /interface[name='GigabitEthernet1/0/1']
+// - Nested paths: /native/interface[name='Gi1']/ip/address
+//
+// Example: /native/interface[name='Gi1']/ip/address
+// Converts to: native.interface.#(name==Gi1).ip.address
+func GetFromXPath(res xmldot.Result, xPath string) xmldot.Result {
+ // Remove leading slash if present
+ xPath = strings.TrimPrefix(xPath, "/")
+
+ // Split into segments while respecting bracket boundaries
+ segments := splitXPathSegments(xPath)
+
+ // Check if we need manual filtering:
+ // 1. Any segment has multiple predicates
+ // 2. Multiple segments have predicates (nested filters not supported by xmldot)
+ needsManualFiltering := false
+ segmentsWithKeys := 0
+ for _, segment := range segments {
+ _, keys := parseXPathSegment(segment)
+ if len(keys) > 1 {
+ needsManualFiltering = true
+ break
+ }
+ if len(keys) > 0 {
+ segmentsWithKeys++
+ }
+ }
+ if segmentsWithKeys > 1 {
+ needsManualFiltering = true
+ }
+
+ // If only single predicates, use xmldot's native filter syntax (fast path)
+ if !needsManualFiltering {
+ pathParts := make([]string, 0, len(segments))
+ for _, segment := range segments {
+ elementName, keys := parseXPathSegment(segment)
+
+ // Remove namespace prefix from element name only
+ elementName = removeNamespacePrefix(elementName)
+
+ if len(keys) == 1 {
+ // Single predicate - use xmldot's native filter syntax
+ // Also remove namespace prefix from key name
+ kv := keys[0]
+ keyName := removeNamespacePrefix(kv.Key)
+ pathParts = append(pathParts, elementName+".#("+keyName+"=="+kv.Value+")")
+ } else {
+ // No predicates
+ pathParts = append(pathParts, elementName)
+ }
+ }
+
+ dotPath := strings.Join(pathParts, ".")
+ return res.Get(dotPath)
+ }
+
+ // Slow path: manual filtering for multiple predicates
+ // Since we need to work with absolute paths for counting, get the XML from res.Raw
+ xml := res.Raw
+ pathSoFar := make([]string, 0, len(segments))
+
+ for _, segment := range segments {
+ elementName, keys := parseXPathSegment(segment)
+
+ // Remove namespace prefix from element name
+ elementName = removeNamespacePrefix(elementName)
+ pathSoFar = append(pathSoFar, elementName)
+
+ // Build current path
+ currentPath := strings.Join(pathSoFar, ".")
+
+ // Check if there are multiple sibling elements using absolute path
+ countPath := currentPath + ".#"
+ count := xmldot.Get(xml, countPath).Int()
+
+ // Apply filtering if keys exist
+ if len(keys) > 0 {
+ found := false
+ if count > 1 {
+ // Multiple elements - iterate using numeric indices
+ for idx := 0; idx < int(count); idx++ {
+ indexedPath := fmt.Sprintf("%s.%d", currentPath, idx)
+ item := xmldot.Get(xml, indexedPath)
+
+ allMatch := true
+ for _, kv := range keys {
+ // Remove namespace prefix from key name
+ keyName := removeNamespacePrefix(kv.Key)
+ keyResult := item.Get(keyName)
+ if !keyResult.Exists() || keyResult.String() != kv.Value {
+ allMatch = false
+ break
+ }
+ }
+
+ if allMatch {
+ // Update currentPath to point to the matched item
+ pathSoFar[len(pathSoFar)-1] = fmt.Sprintf("%s.%d", elementName, idx)
+ found = true
+ break
+ }
+ }
+ } else {
+ // Single element - check directly
+ currentResult := xmldot.Get(xml, currentPath)
+ allMatch := true
+ for _, kv := range keys {
+ // Remove namespace prefix from key name
+ keyName := removeNamespacePrefix(kv.Key)
+ keyResult := currentResult.Get(keyName)
+ if !keyResult.Exists() || keyResult.String() != kv.Value {
+ allMatch = false
+ break
+ }
+ }
+ found = allMatch
+ }
+
+ if !found {
+ return xmldot.Result{}
+ }
+ }
+ }
+
+ // Return the final result
+ finalPath := strings.Join(pathSoFar, ".")
+ return xmldot.Get(xml, finalPath)
+}
diff --git a/internal/provider/helpers/netconf_test.go b/internal/provider/helpers/netconf_test.go
new file mode 100644
index 00000000..d2e0cb76
--- /dev/null
+++ b/internal/provider/helpers/netconf_test.go
@@ -0,0 +1,1377 @@
+package helpers
+
+import (
+ "fmt"
+
+ "reflect"
+ "strings"
+ "testing"
+
+ "github.com/netascode/go-netconf"
+ "github.com/netascode/xmldot"
+)
+
+// TestSplitXPathSegments tests the splitXPathSegments function
+func TestSplitXPathSegments(t *testing.T) {
+ tests := []struct {
+ name string
+ xPath string
+ expected []string
+ }{
+ {
+ name: "simple path",
+ xPath: "native/interface",
+ expected: []string{"native", "interface"},
+ },
+ {
+ name: "path with single predicate",
+ xPath: "native/interface[name='GigabitEthernet1']",
+ expected: []string{"native", "interface[name='GigabitEthernet1']"},
+ },
+ {
+ name: "path with slash in predicate value",
+ xPath: "interface[name='GigabitEthernet1/0/1']/description",
+ expected: []string{"interface[name='GigabitEthernet1/0/1']", "description"},
+ },
+ {
+ name: "complex path with multiple slashes in predicate",
+ xPath: "native/interface[name='GigabitEthernet1/0/1']/ip/address",
+ expected: []string{"native", "interface[name='GigabitEthernet1/0/1']", "ip", "address"},
+ },
+ {
+ name: "multiple predicates with slashes",
+ xPath: "interface[name='Gi1/0/1'][desc='port 1/0/1']",
+ expected: []string{"interface[name='Gi1/0/1'][desc='port 1/0/1']"},
+ },
+ {
+ name: "nested path with composite keys containing slashes",
+ xPath: "native/interface[name='Gi1/0/1']/vrf[name='VRF1']/address",
+ expected: []string{"native", "interface[name='Gi1/0/1']", "vrf[name='VRF1']", "address"},
+ },
+ {
+ name: "empty path",
+ xPath: "",
+ expected: []string{},
+ },
+ {
+ name: "single segment",
+ xPath: "native",
+ expected: []string{"native"},
+ },
+ }
+
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ result := splitXPathSegments(tt.xPath)
+
+ if !reflect.DeepEqual(result, tt.expected) {
+ t.Errorf("splitXPathSegments() = %v, want %v", result, tt.expected)
+ }
+ })
+ }
+}
+
+// TestParseXPathSegment tests the parseXPathSegment function with various XPath formats
+func TestParseXPathSegment(t *testing.T) {
+ tests := []struct {
+ name string
+ segment string
+ wantElement string
+ wantKeys map[string]string
+ }{
+ {
+ name: "simple element without predicate",
+ segment: "interface",
+ wantElement: "interface",
+ wantKeys: nil,
+ },
+ {
+ name: "element with single predicate single quotes",
+ segment: "interface[name='GigabitEthernet1']",
+ wantElement: "interface",
+ wantKeys: map[string]string{"name": "GigabitEthernet1"},
+ },
+ {
+ name: "element with single predicate double quotes",
+ segment: "interface[name=\"GigabitEthernet1\"]",
+ wantElement: "interface",
+ wantKeys: map[string]string{"name": "GigabitEthernet1"},
+ },
+ {
+ name: "element with multiple separate predicates",
+ segment: "interface[name='GigabitEthernet1'][vrf='VRF1']",
+ wantElement: "interface",
+ wantKeys: map[string]string{"name": "GigabitEthernet1", "vrf": "VRF1"},
+ },
+ {
+ name: "element with multiple predicates using and",
+ segment: "interface[name='GigabitEthernet1' and vrf='VRF1']",
+ wantElement: "interface",
+ wantKeys: map[string]string{"name": "GigabitEthernet1", "vrf": "VRF1"},
+ },
+ {
+ name: "element with three separate predicates",
+ segment: "neighbor[ip='192.168.1.1'][vrf='default'][asn='65000']",
+ wantElement: "neighbor",
+ wantKeys: map[string]string{
+ "ip": "192.168.1.1",
+ "vrf": "default",
+ "asn": "65000",
+ },
+ },
+ {
+ name: "element with three predicates using and",
+ segment: "neighbor[ip='192.168.1.1' and vrf='default' and asn='65000']",
+ wantElement: "neighbor",
+ wantKeys: map[string]string{
+ "ip": "192.168.1.1",
+ "vrf": "default",
+ "asn": "65000",
+ },
+ },
+ {
+ name: "element with mixed quotes in predicates",
+ segment: "interface[name='GigabitEthernet1'][vrf=\"VRF1\"]",
+ wantElement: "interface",
+ wantKeys: map[string]string{"name": "GigabitEthernet1", "vrf": "VRF1"},
+ },
+ {
+ name: "element with numeric key values",
+ segment: "vlan[id='100']",
+ wantElement: "vlan",
+ wantKeys: map[string]string{"id": "100"},
+ },
+ {
+ name: "element with special characters in value",
+ segment: "interface[name='GigabitEthernet1/0/1']",
+ wantElement: "interface",
+ wantKeys: map[string]string{"name": "GigabitEthernet1/0/1"},
+ },
+ {
+ name: "element with spaces in value",
+ segment: "description[text='test description']",
+ wantElement: "description",
+ wantKeys: map[string]string{"text": "test description"},
+ },
+ {
+ name: "element with empty predicate",
+ segment: "interface[]",
+ wantElement: "interface",
+ wantKeys: map[string]string{},
+ },
+ {
+ name: "element name with hyphen",
+ segment: "access-list[name='TEST']",
+ wantElement: "access-list",
+ wantKeys: map[string]string{"name": "TEST"},
+ },
+ {
+ name: "element name with underscore",
+ segment: "bgp_neighbor[ip='10.0.0.1']",
+ wantElement: "bgp_neighbor",
+ wantKeys: map[string]string{"ip": "10.0.0.1"},
+ },
+ {
+ name: "composite key with multiple separate predicates and mixed quotes",
+ segment: "route[vrf=\"VRF1\"][destination='10.0.0.0/8'][next-hop='192.168.1.1']",
+ wantElement: "route",
+ wantKeys: map[string]string{
+ "vrf": "VRF1",
+ "destination": "10.0.0.0/8",
+ "next-hop": "192.168.1.1",
+ },
+ },
+ }
+
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ gotElement, gotKeys := parseXPathSegment(tt.segment)
+
+ if gotElement != tt.wantElement {
+ t.Errorf("parseXPathSegment() element = %v, want %v", gotElement, tt.wantElement)
+ }
+
+ // Convert []KeyValue to map for comparison
+ gotKeysMap := make(map[string]string)
+ for _, kv := range gotKeys {
+ gotKeysMap[kv.Key] = kv.Value
+ }
+
+ // Normalize for comparison: nil and empty map should be treated as equal
+ wantKeys := tt.wantKeys
+ if wantKeys == nil {
+ wantKeys = make(map[string]string)
+ }
+
+ if !reflect.DeepEqual(gotKeysMap, wantKeys) {
+ t.Errorf("parseXPathSegment() keys = %v, want %v", gotKeysMap, wantKeys)
+ }
+ })
+ }
+}
+
+// TestSetFromXPath tests the SetFromXPath function with various XPath patterns
+func TestSetFromXPath(t *testing.T) {
+ tests := []struct {
+ name string
+ xPath string
+ wantPaths []string // Expected paths that should be set in the body
+ }{
+ {
+ name: "simple single element with key",
+ xPath: "/interface[name='GigabitEthernet1']",
+ wantPaths: []string{
+ "interface.name",
+ },
+ },
+ {
+ name: "nested path with single key",
+ xPath: "/native/interface[name='GigabitEthernet1']",
+ wantPaths: []string{
+ "native.interface.name",
+ },
+ },
+ {
+ name: "element with multiple separate predicates",
+ xPath: "/interface[name='GigabitEthernet1'][vrf='VRF1']",
+ wantPaths: []string{
+ "interface.name",
+ "interface.vrf",
+ },
+ },
+ {
+ name: "element with multiple predicates using and",
+ xPath: "/interface[name='GigabitEthernet1' and vrf='VRF1']",
+ wantPaths: []string{
+ "interface.name",
+ "interface.vrf",
+ },
+ },
+ {
+ name: "nested path with composite keys",
+ xPath: "/native/vrf[name='VRF1']/address-family[type='ipv4']",
+ wantPaths: []string{
+ "native.vrf.name",
+ "native.vrf.address-family.type",
+ },
+ },
+ {
+ name: "deep nested path",
+ xPath: "/native/router/bgp[asn='65000']/neighbor[ip='192.168.1.1']",
+ wantPaths: []string{
+ "native.router.bgp.asn",
+ "native.router.bgp.neighbor.ip",
+ },
+ },
+ {
+ name: "path without leading slash",
+ xPath: "interface[name='GigabitEthernet1']",
+ wantPaths: []string{
+ "interface.name",
+ },
+ },
+ {
+ name: "path without predicates",
+ xPath: "/native/cdp/holdtime",
+ wantPaths: []string{
+ "native.cdp.holdtime",
+ },
+ },
+ {
+ name: "mixed path with and without predicates",
+ xPath: "/native/interface[name='GigabitEthernet1']/ip/address",
+ wantPaths: []string{
+ "native.interface.name",
+ "native.interface.ip.address",
+ },
+ },
+ {
+ name: "three level composite key",
+ xPath: "/native/vrf[name='VRF1']/address-family[type='ipv4'][safi='unicast']",
+ wantPaths: []string{
+ "native.vrf.name",
+ "native.vrf.address-family.type",
+ "native.vrf.address-family.safi",
+ },
+ },
+ }
+
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ // Start with empty body
+ body := netconf.Body{}
+
+ // Apply SetFromXPath with empty value (just creating structure)
+ result := SetFromXPath(body, tt.xPath, "")
+
+ // Verify each expected path exists in the result
+ resultStr := result.Res()
+ for _, wantPath := range tt.wantPaths {
+ // Check if the path was created in the result
+ // We verify by checking if xmldot.Get can find the path
+ if !xmldotPathExists(resultStr, wantPath) {
+ t.Errorf("SetFromXPath() missing expected path %q in result:\n%s", wantPath, resultStr)
+ }
+ }
+ })
+ }
+}
+
+// TestSetFromXPath_Values tests that SetFromXPath correctly sets the key values
+func TestSetFromXPath_Values(t *testing.T) {
+ tests := []struct {
+ name string
+ xPath string
+ checkPath string
+ checkValue string
+ }{
+ {
+ name: "single key value",
+ xPath: "/interface[name='GigabitEthernet1']",
+ checkPath: "interface.name",
+ checkValue: "GigabitEthernet1",
+ },
+ {
+ name: "numeric key value",
+ xPath: "/vlan[id='100']",
+ checkPath: "vlan.id",
+ checkValue: "100",
+ },
+ {
+ name: "value with special characters",
+ xPath: "/interface[name='GigabitEthernet1/0/1']",
+ checkPath: "interface.name",
+ checkValue: "GigabitEthernet1/0/1",
+ },
+ {
+ name: "value with spaces",
+ xPath: "/description[text='test description']",
+ checkPath: "description.text",
+ checkValue: "test description",
+ },
+ {
+ name: "nested with multiple keys",
+ xPath: "/native/interface[name='GigabitEthernet1'][vrf='VRF1']",
+ checkPath: "native.interface.vrf",
+ checkValue: "VRF1",
+ },
+ }
+
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ body := netconf.Body{}
+
+ // Log what we're testing
+ t.Logf("Testing xPath: %s", tt.xPath)
+ t.Logf("Expect value at path %s to be: %s", tt.checkPath, tt.checkValue)
+
+ result := SetFromXPath(body, tt.xPath, "")
+
+ // Check for errors
+ if err := result.Err(); err != nil {
+ t.Fatalf("SetFromXPath() returned error: %v", err)
+ }
+
+ // Get the actual value at the path
+ resultXML := result.Res()
+ t.Logf("Generated XML:\n%s", resultXML)
+
+ actualValue := xmldotGetValue(resultXML, tt.checkPath)
+ if actualValue != tt.checkValue {
+ t.Errorf("SetFromXPath() value at %q = %q, want %q", tt.checkPath, actualValue, tt.checkValue)
+ }
+ })
+ }
+}
+
+// TestRemoveFromXPath tests the RemoveFromXPath function
+func TestRemoveFromXPath(t *testing.T) {
+ tests := []struct {
+ name string
+ xPath string
+ wantPaths []string // Paths that should exist in the structure
+ operationPath string // Path where operation="remove" should be set
+ }{
+ {
+ name: "simple single element with key",
+ xPath: "/interface[name='GigabitEthernet1']",
+ wantPaths: []string{
+ "interface.name",
+ },
+ operationPath: "interface",
+ },
+ {
+ name: "nested path with single key",
+ xPath: "/native/interface[name='GigabitEthernet1']",
+ wantPaths: []string{
+ "native.interface.name",
+ },
+ operationPath: "native.interface",
+ },
+ {
+ name: "path without predicates",
+ xPath: "/native/cdp/holdtime",
+ wantPaths: []string{
+ "native.cdp.holdtime",
+ },
+ operationPath: "native.cdp.holdtime",
+ },
+ {
+ name: "mixed path with and without predicates",
+ xPath: "/native/interface[name='GigabitEthernet1']/ip/address",
+ wantPaths: []string{
+ "native.interface.name",
+ "native.interface.ip.address",
+ },
+ operationPath: "native.interface.ip.address",
+ },
+ {
+ name: "deep nested path with multiple keys",
+ xPath: "/native/router/bgp[asn='65000']/neighbor[ip='192.168.1.1']/description",
+ wantPaths: []string{
+ "native.router.bgp.asn",
+ "native.router.bgp.neighbor.ip",
+ "native.router.bgp.neighbor.description",
+ },
+ operationPath: "native.router.bgp.neighbor.description",
+ },
+ {
+ name: "interface with slashes in name",
+ xPath: "/native/interface[name='GigabitEthernet1/0/1']/shutdown",
+ wantPaths: []string{
+ "native.interface.name",
+ "native.interface.shutdown",
+ },
+ operationPath: "native.interface.shutdown",
+ },
+ }
+
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ // Start with empty body
+ body := netconf.Body{}
+
+ // Apply RemoveFromXPath
+ result := RemoveFromXPath(body, tt.xPath)
+
+ // Verify each expected path exists in the result
+ resultStr := result.Res()
+ for _, wantPath := range tt.wantPaths {
+ if !xmldotPathExists(resultStr, wantPath) {
+ t.Errorf("RemoveFromXPath() missing expected path %q in result:\n%s", wantPath, resultStr)
+ }
+ }
+
+ // Verify operation="remove" is set on the correct element
+ operationAttrPath := tt.operationPath + ".@operation"
+ operationValue := xmldotGetValue(resultStr, operationAttrPath)
+ if operationValue != "remove" {
+ t.Errorf("RemoveFromXPath() operation attribute at %q = %q, want %q\nGenerated XML:\n%s",
+ operationAttrPath, operationValue, "remove", resultStr)
+ }
+ })
+ }
+}
+
+// TestRemoveFromXPath_Values tests that RemoveFromXPath correctly sets key values and operation attribute
+func TestRemoveFromXPath_Values(t *testing.T) {
+ tests := []struct {
+ name string
+ xPath string
+ checkPath string
+ checkValue string
+ operationPath string
+ }{
+ {
+ name: "single key with operation on element",
+ xPath: "/interface[name='GigabitEthernet1']",
+ checkPath: "interface.name",
+ checkValue: "GigabitEthernet1",
+ operationPath: "interface",
+ },
+ {
+ name: "nested with key and child element",
+ xPath: "/native/interface[name='GigabitEthernet1']/shutdown",
+ checkPath: "native.interface.name",
+ checkValue: "GigabitEthernet1",
+ operationPath: "native.interface.shutdown",
+ },
+ {
+ name: "interface name with slashes",
+ xPath: "/interface[name='GigabitEthernet1/0/1']",
+ checkPath: "interface.name",
+ checkValue: "GigabitEthernet1/0/1",
+ operationPath: "interface",
+ },
+ }
+
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ body := netconf.Body{}
+
+ t.Logf("Testing xPath: %s", tt.xPath)
+ t.Logf("Expect value at path %s to be: %s", tt.checkPath, tt.checkValue)
+ t.Logf("Expect operation='remove' at path: %s", tt.operationPath)
+
+ result := RemoveFromXPath(body, tt.xPath)
+
+ if err := result.Err(); err != nil {
+ t.Fatalf("RemoveFromXPath() returned error: %v", err)
+ }
+
+ resultXML := result.Res()
+ t.Logf("Generated XML:\n%s", resultXML)
+
+ // Check the key value is set correctly
+ actualValue := xmldotGetValue(resultXML, tt.checkPath)
+ if actualValue != tt.checkValue {
+ t.Errorf("RemoveFromXPath() value at %q = %q, want %q", tt.checkPath, actualValue, tt.checkValue)
+ }
+
+ // Check operation="remove" is set on the correct element
+ operationAttrPath := tt.operationPath + ".@operation"
+ operationValue := xmldotGetValue(resultXML, operationAttrPath)
+ if operationValue != "remove" {
+ t.Errorf("RemoveFromXPath() operation at %q = %q, want %q", operationAttrPath, operationValue, "remove")
+ }
+ })
+ }
+}
+
+// TestSetFromXPath_WithValue tests that SetFromXPath can set values at the final path
+func TestSetFromXPath_WithValue(t *testing.T) {
+ tests := []struct {
+ name string
+ xPath string
+ value string
+ checkPath string
+ }{
+ {
+ name: "set value on leaf element",
+ xPath: "/native/interface[name='GigabitEthernet1']/description",
+ value: "Management Interface",
+ checkPath: "native.interface.description",
+ },
+ {
+ name: "set value on deep path",
+ xPath: "/native/cdp/holdtime",
+ value: "180",
+ checkPath: "native.cdp.holdtime",
+ },
+ {
+ name: "set value with multiple keys in path",
+ xPath: "/native/router/bgp[asn='65000']/neighbor[ip='192.168.1.1']/description",
+ value: "Peer Router",
+ checkPath: "native.router.bgp.neighbor.description",
+ },
+ }
+
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ body := netconf.Body{}
+
+ result := SetFromXPath(body, tt.xPath, tt.value)
+
+ if err := result.Err(); err != nil {
+ t.Fatalf("SetFromXPath() returned error: %v", err)
+ }
+
+ resultXML := result.Res()
+ t.Logf("Generated XML:\n%s", resultXML)
+
+ actualValue := xmldotGetValue(resultXML, tt.checkPath)
+ if actualValue != tt.value {
+ t.Errorf("SetFromXPath() value at %q = %q, want %q", tt.checkPath, actualValue, tt.value)
+ }
+ })
+ }
+}
+
+// TestGetFromXPath tests the GetFromXPath function with filter conversion
+func TestGetFromXPath(t *testing.T) {
+ tests := []struct {
+ name string
+ xml string
+ xPath string
+ expectedValue string
+ shouldExist bool
+ }{
+ {
+ name: "simple path without predicates",
+ xml: "180",
+ xPath: "/native/cdp/holdtime",
+ expectedValue: "180",
+ shouldExist: true,
+ },
+ {
+ name: "filter by key - single interface",
+ xml: `
+ GigabitEthernet1Management
+ GigabitEthernet2Uplink
+ `,
+ xPath: "/native/interface[name='GigabitEthernet1']/description",
+ expectedValue: "Management",
+ shouldExist: true,
+ },
+ {
+ name: "filter correctly returns first match",
+ xml: `
+ GigabitEthernet1First
+ GigabitEthernet2Second
+ `,
+ xPath: "/native/interface[name='GigabitEthernet2']/description",
+ expectedValue: "Second",
+ shouldExist: true,
+ },
+ {
+ name: "path with value containing slashes",
+ xml: "GigabitEthernet1/0/1",
+ xPath: "/native/interface[name='GigabitEthernet1/0/1']/shutdown",
+ expectedValue: "",
+ shouldExist: true,
+ },
+ {
+ name: "path with multiple predicates",
+ xml: "Gi1VRF1192.168.1.1",
+ xPath: "/native/interface[name='Gi1'][vrf='VRF1']/ip/address",
+ expectedValue: "192.168.1.1",
+ shouldExist: true,
+ },
+ {
+ name: "filter with multiple predicates - multiple elements",
+ xml: `
+ Gi1VRF1192.168.1.1
+ Gi1VRF2192.168.2.1
+ Gi2VRF1192.168.3.1
+ `,
+ xPath: "/native/interface[name='Gi1'][vrf='VRF2']/ip/address",
+ expectedValue: "192.168.2.1",
+ shouldExist: true,
+ },
+ {
+ name: "deep nested path with filtering",
+ xml: "6500010.0.0.1Peer",
+ xPath: "/native/router/bgp[asn='65000']/neighbor[ip='10.0.0.1']/description",
+ expectedValue: "Peer",
+ shouldExist: true,
+ },
+ {
+ name: "non-existent path",
+ xml: "180",
+ xPath: "/native/cdp/run",
+ expectedValue: "",
+ shouldExist: false,
+ },
+ {
+ name: "filter with no matching key",
+ xml: `
+ GigabitEthernet1Mgmt
+ `,
+ xPath: "/native/interface[name='GigabitEthernet2']/description",
+ shouldExist: false,
+ },
+ }
+
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ // Wrap XML in a root element and get Result, simulating NETCONF response structure
+ wrappedXML := "" + tt.xml + ""
+ res := xmldot.Get(wrappedXML, "root")
+ result := GetFromXPath(res, tt.xPath)
+
+ // Check existence
+ if result.Exists() != tt.shouldExist {
+ t.Errorf("GetFromXPath() Exists() = %v, want %v", result.Exists(), tt.shouldExist)
+ }
+
+ // Check value if it should exist
+ if tt.shouldExist {
+ actualValue := result.String()
+ if actualValue != tt.expectedValue {
+ t.Errorf("GetFromXPath() value = %q, want %q", actualValue, tt.expectedValue)
+ }
+ }
+
+ t.Logf("XPath: %s -> Value: %q (Exists: %v)", tt.xPath, result.String(), result.Exists())
+ })
+ }
+}
+
+// TestSetWithNamespaces_SpecialChars tests if SetWithNamespaces handles special characters like "/"
+func TestSetWithNamespaces_SpecialChars(t *testing.T) {
+ body := netconf.Body{}
+
+ // Test with a value containing "/"
+ result := setWithNamespaces(body, "interface.name", "GigabitEthernet1/0/1")
+
+ if err := result.Err(); err != nil {
+ t.Fatalf("setWithNamespaces() error: %v", err)
+ }
+
+ xml := result.Res()
+ t.Logf("Generated XML: %s", xml)
+
+ if xml == "" {
+ t.Error("Generated XML is empty")
+ }
+
+ value := xmldotGetValue(xml, "interface.name")
+ if value != "GigabitEthernet1/0/1" {
+ t.Errorf("Expected value 'GigabitEthernet1/0/1', got %q", value)
+ }
+}
+
+// Helper function to check if a path exists in XML using xmldot
+func xmldotPathExists(xml, path string) bool {
+ result := xmldot.Get(xml, path)
+ return result.Exists()
+}
+
+// Helper function to get value at a path in XML using xmldot
+func xmldotGetValue(xml, path string) string {
+ result := xmldot.Get(xml, path)
+ return result.String()
+}
+
+// TestGetXpathFilter tests the GetXpathFilter function
+func TestGetXpathFilter(t *testing.T) {
+ tests := []struct {
+ name string
+ xPath string
+ expected string
+ }{
+ {
+ name: "simple path without namespace",
+ xPath: "/native/interface/GigabitEthernet",
+ expected: "/native/interface/GigabitEthernet",
+ },
+ {
+ name: "path with namespace prefix",
+ xPath: "/Cisco-IOS-XE-native:native/interface/GigabitEthernet",
+ expected: "/native/interface/GigabitEthernet",
+ },
+ {
+ name: "path with predicate and namespace",
+ xPath: "/Cisco-IOS-XE-native:native/interface[Cisco-IOS-XE-native:name='GigabitEthernet1']",
+ expected: "/native/interface[name='GigabitEthernet1']",
+ },
+ {
+ name: "path with multiple predicates",
+ xPath: "/native/interface[name='Gi1'][vrf='VRF1']",
+ expected: "/native/interface[name='Gi1'][vrf='VRF1']",
+ },
+ {
+ name: "nested path with namespace prefixes",
+ xPath: "/Cisco-IOS-XE-native:native/interface[Cisco-IOS-XE-native:name='Gi1']/Cisco-IOS-XE-native:ip/Cisco-IOS-XE-native:address",
+ expected: "/native/interface[name='Gi1']/ip/address",
+ },
+ {
+ name: "path without leading slash",
+ xPath: "Cisco-IOS-XE-native:native/interface/GigabitEthernet",
+ expected: "/native/interface/GigabitEthernet",
+ },
+ {
+ name: "path with slash in predicate value",
+ xPath: "/native/interface[name='GigabitEthernet1/0/1']",
+ expected: "/native/interface[name='GigabitEthernet1/0/1']",
+ },
+ {
+ name: "realistic getXPath output",
+ xPath: "/Cisco-IOS-XE-native:native/aaa",
+ expected: "/native/aaa",
+ },
+ }
+
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ result := GetXpathFilter(tt.xPath)
+
+ if result.Content != tt.expected {
+ t.Errorf("GetXpathFilter(%q).Content = %q, want %q", tt.xPath, result.Content, tt.expected)
+ }
+
+ if result.Type != "xpath" {
+ t.Errorf("GetXpathFilter(%q).Type = %q, want %q", tt.xPath, result.Type, "xpath")
+ }
+
+ t.Logf("XPath: %s -> Filter: %s", tt.xPath, result.Content)
+ })
+ }
+}
+
+// TestConvertRestconfPathToXPath tests the ConvertRestconfPathToXPath function
+func TestConvertRestconfPathToXPath(t *testing.T) {
+ tests := []struct {
+ name string
+ path string
+ expected string
+ }{
+ {
+ name: "format string with %s=%v",
+ path: "Cisco-IOS-XE-native:native/interface/%s=%v",
+ expected: "Cisco-IOS-XE-native:native/interface/%s[%v=%v]",
+ },
+ {
+ name: "format string with multiple placeholders",
+ path: "vrf/%s=%v/address-family/%s=%v",
+ expected: "vrf/%s[%v=%v]/address-family/%s[%v=%v]",
+ },
+ {
+ name: "concrete path with single key",
+ path: "interface/GigabitEthernet=1",
+ expected: "interface/GigabitEthernet[%v=1]",
+ },
+ {
+ name: "concrete path with composite key",
+ path: "vrf=VRF1,address-family=ipv4",
+ expected: "vrf[%v=VRF1][%v=address-family=ipv4]",
+ },
+ {
+ name: "concrete path with multiple segments",
+ path: "native/vrf=VRF1/address-family=ipv4",
+ expected: "native/vrf[%v=VRF1]/address-family[%v=ipv4]",
+ },
+ {
+ name: "path without keys",
+ path: "native/ip/source-route",
+ expected: "native/ip/source-route",
+ },
+ {
+ name: "namespace prefix preserved",
+ path: "Cisco-IOS-XE-native:native/interface/GigabitEthernet=1/ip",
+ expected: "Cisco-IOS-XE-native:native/interface/GigabitEthernet[%v=1]/ip",
+ },
+ {
+ name: "mixed format strings and concrete values",
+ path: "native/interface/%s=%v/vlan=100",
+ expected: "native/interface/%s[%v=%v]/vlan[%v=100]",
+ },
+ }
+
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ result := ConvertRestconfPathToXPath(tt.path)
+ if result != tt.expected {
+ t.Errorf("ConvertRestconfPathToXPath(%q) = %q, want %q",
+ tt.path, result, tt.expected)
+ }
+ })
+ }
+}
+
+// TestSetRawFromXPath_MultiRoot tests multi-root XML fragment creation
+func TestSetRawFromXPath_MultiRoot(t *testing.T) {
+ tests := []struct {
+ name string
+ xPath string
+ values []string
+ expectedCount int
+ checkPaths []string
+ checkValues []string
+ }{
+ {
+ name: "multiple interface elements at same path",
+ xPath: "/native/interface",
+ values: []string{"Gi1First", "Gi2Second"},
+ expectedCount: 2,
+ checkPaths: []string{"native.interface.0.name", "native.interface.1.name"},
+ checkValues: []string{"Gi1", "Gi2"},
+ },
+ {
+ name: "multiple list items with keys",
+ xPath: "/native/router/bgp/neighbor",
+ values: []string{"10.0.0.165001", "10.0.0.265002", "10.0.0.365003"},
+ expectedCount: 3,
+ checkPaths: []string{"native.router.bgp.neighbor.0.ip", "native.router.bgp.neighbor.1.ip", "native.router.bgp.neighbor.2.ip"},
+ checkValues: []string{"10.0.0.1", "10.0.0.2", "10.0.0.3"},
+ },
+ {
+ name: "nested list items",
+ xPath: "/native/access-list/extended/rule",
+ values: []string{"10ip", "20tcp"},
+ expectedCount: 2,
+ checkPaths: []string{"native.access-list.extended.rule.0.id", "native.access-list.extended.rule.1.id"},
+ checkValues: []string{"10", "20"},
+ },
+ {
+ name: "single element (baseline test)",
+ xPath: "/native/hostname",
+ values: []string{"router1"},
+ expectedCount: 1,
+ checkPaths: []string{"native.hostname.value"},
+ checkValues: []string{"router1"},
+ },
+ }
+
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ body := netconf.Body{}
+
+ // Add each value sequentially
+ for i, value := range tt.values {
+ t.Logf("Adding element %d with value: %s", i+1, value)
+ body = SetRawFromXPath(body, tt.xPath, value)
+ }
+
+ // Check for errors
+ if err := body.Err(); err != nil {
+ t.Fatalf("SetRawFromXPath() returned error: %v", err)
+ }
+
+ resultXML := body.Res()
+ t.Logf("Generated XML:\n%s", resultXML)
+
+ // Verify each expected value exists at the correct path
+ for i, checkPath := range tt.checkPaths {
+ actualValue := xmldotGetValue(resultXML, checkPath)
+ expectedValue := tt.checkValues[i]
+
+ if actualValue != expectedValue {
+ t.Errorf("Value at %q = %q, want %q", checkPath, actualValue, expectedValue)
+ } else {
+ t.Logf("✓ Verified: %s = %s", checkPath, actualValue)
+ }
+ }
+ })
+ }
+}
+
+// TestSetRawFromXPath_MultiRoot_NestedLists tests multi-root with nested list structures
+func TestSetRawFromXPath_MultiRoot_NestedLists(t *testing.T) {
+ body := netconf.Body{}
+
+ // Create first outer list item with nested inner items
+ // Build the inner XML manually for the first list item
+ innerXML1 := "pool1eth0trueeth1false"
+
+ body = SetRawFromXPath(body, "/native/nat/inside/source/list", innerXML1)
+
+ // Create second outer list item with nested inner items
+ innerXML2 := "pool2eth2true"
+
+ body = SetRawFromXPath(body, "/native/nat/inside/source/list", innerXML2)
+
+ // Verify structure
+ if err := body.Err(); err != nil {
+ t.Fatalf("SetRawFromXPath() returned error: %v", err)
+ }
+
+ resultXML := body.Res()
+ t.Logf("Generated XML:\n%s", resultXML)
+
+ // Verify outer list items
+ pool1ID := xmldotGetValue(resultXML, "native.nat.inside.source.list.0.id")
+ pool2ID := xmldotGetValue(resultXML, "native.nat.inside.source.list.1.id")
+
+ if pool1ID != "pool1" {
+ t.Errorf("First outer list item id = %q, want %q", pool1ID, "pool1")
+ }
+ if pool2ID != "pool2" {
+ t.Errorf("Second outer list item id = %q, want %q", pool2ID, "pool2")
+ }
+
+ // Verify inner list items for first outer item
+ inner1a := xmldotGetValue(resultXML, "native.nat.inside.source.list.0.interface.0.name")
+ inner1b := xmldotGetValue(resultXML, "native.nat.inside.source.list.0.interface.1.name")
+
+ if inner1a != "eth0" {
+ t.Errorf("First inner item name = %q, want %q", inner1a, "eth0")
+ }
+ if inner1b != "eth1" {
+ t.Errorf("Second inner item name = %q, want %q", inner1b, "eth1")
+ }
+
+ // Verify inner list items for second outer item
+ inner2a := xmldotGetValue(resultXML, "native.nat.inside.source.list.1.interface.0.name")
+ if inner2a != "eth2" {
+ t.Errorf("Third inner item name = %q, want %q", inner2a, "eth2")
+ }
+
+ t.Log("✓ All nested list structures verified successfully")
+}
+
+// TestSetRawFromXPath_MultiRoot_WithNamespaces tests multi-root with namespace prefixes
+func TestSetRawFromXPath_MultiRoot_WithNamespaces(t *testing.T) {
+ body := netconf.Body{}
+
+ // Add multiple elements with namespace prefixes in path
+ xml1 := "Gi1"
+ xml2 := "Gi2Uplink"
+
+ body = SetRawFromXPath(body, "/Cisco-IOS-XE-native:native/interface", xml1)
+ body = SetRawFromXPath(body, "/Cisco-IOS-XE-native:native/interface", xml2)
+
+ if err := body.Err(); err != nil {
+ t.Fatalf("SetRawFromXPath() returned error: %v", err)
+ }
+
+ resultXML := body.Res()
+ t.Logf("Generated XML:\n%s", resultXML)
+
+ // Verify both interfaces exist
+ name1 := xmldotGetValue(resultXML, "native.interface.0.name")
+ name2 := xmldotGetValue(resultXML, "native.interface.1.name")
+
+ if name1 != "Gi1" {
+ t.Errorf("First interface name = %q, want %q", name1, "Gi1")
+ }
+ if name2 != "Gi2" {
+ t.Errorf("Second interface name = %q, want %q", name2, "Gi2")
+ }
+
+ // Verify namespace declaration exists
+ if !xmldotPathExists(resultXML, "native.@xmlns") {
+ t.Error("Namespace declaration missing")
+ }
+
+ t.Log("✓ Multi-root with namespaces verified successfully")
+}
+
+// TestSetFromXPath_MultipleRoots tests that SetFromXPath with different root paths creates multi-root XML
+func TestSetFromXPath_MultipleRoots(t *testing.T) {
+ // This tests the ACL use case where we have both deny and permit in the same cBody
+ cBody := netconf.Body{}
+
+ cBody = SetFromXPath(cBody, "sequence", "10")
+ cBody = SetFromXPath(cBody, "deny/std-ace/ipv4-address-prefix", "10.0.0.0")
+ cBody = SetFromXPath(cBody, "deny/std-ace/mask", "0.0.0.255")
+ cBody = SetFromXPath(cBody, "permit/std-ace/ipv4-address-prefix", "192.168.0.0")
+ cBody = SetFromXPath(cBody, "permit/std-ace/mask", "0.0.255.255")
+
+ if err := cBody.Err(); err != nil {
+ t.Fatalf("SetFromXPath() returned error: %v", err)
+ }
+
+ resultXML := cBody.Res()
+ t.Logf("Generated XML:\n%s", resultXML)
+
+ // Check if we have both deny and permit as separate elements
+ denyPrefix := xmldotGetValue(resultXML, "deny.std-ace.ipv4-address-prefix")
+ permitPrefix := xmldotGetValue(resultXML, "permit.std-ace.ipv4-address-prefix")
+ sequence := xmldotGetValue(resultXML, "sequence")
+
+ if sequence != "10" {
+ t.Errorf("sequence = %q, want %q", sequence, "10")
+ }
+ if denyPrefix != "10.0.0.0" {
+ t.Errorf("deny prefix = %q, want %q", denyPrefix, "10.0.0.0")
+ }
+ if permitPrefix != "192.168.0.0" {
+ t.Errorf("permit prefix = %q, want %q", permitPrefix, "192.168.0.0")
+ }
+
+ t.Log("✓ SetFromXPath with multiple roots verified successfully")
+}
+
+// TestSetRawFromXPath_WithPredicates tests that XPath predicates don't create malformed element names
+// Regression test for issue where namespace augmentation created elements like
+func TestSetRawFromXPath_WithPredicates(t *testing.T) {
+ // Simulate creating an ACL structure with predicates in the path
+ body := netconf.Body{}
+
+ // First, create the name element (this builds the parent structure with predicates)
+ xpathWithPredicate := "Cisco-IOS-XE-native:native/ip/access-list/Cisco-IOS-XE-acl:standard[name=SACL1]"
+ body = SetFromXPath(body, xpathWithPredicate+"/name", "SACL1")
+
+ // Then add a child structure using SetRawFromXPath
+ childXML := "10Test"
+ body = SetRawFromXPath(body, xpathWithPredicate+"/access-list-seq-rule", childXML)
+
+ xml, err := body.String()
+ if err != nil {
+ t.Fatalf("Body.String() error: %v", err)
+ }
+
+ t.Logf("Generated XML:\n%s", xml)
+
+ // Verify no malformed elements with predicates in the name
+ if strings.Contains(xml, "standard[name") {
+ t.Errorf("XML contains malformed element with XPath predicate in name: standard[name=...]")
+ }
+
+ // Verify the structure is correct with clean element names
+ if !strings.Contains(xml, " element")
+ }
+ if !strings.Contains(xml, "SACL1") {
+ t.Errorf("XML missing name element")
+ }
+ if !strings.Contains(xml, "") {
+ t.Errorf("XML missing access-list-seq-rule element")
+ }
+
+ t.Log("✓ XPath predicates properly stripped in namespace augmentation")
+}
+
+// TestSetFromXPath_NoDuplicateElements verifies that SetFromXPath doesn't create
+// duplicate elements when setting a value at a leaf path. This was a bug where
+// paths like "match/authorizing-method-priority/greater-than" with value "20"
+// would create both an empty and 20.
+func TestSetFromXPath_NoDuplicateElements(t *testing.T) {
+ body := netconf.Body{}
+
+ // Test the case that was causing duplicate elements
+ body = SetFromXPath(body, "match/authorizing-method-priority/greater-than", 20)
+
+ xml := body.Res()
+
+ // Count occurrences of ""
+ openingTagCount := 0
+ search := ""
+ str := xml
+ for {
+ idx := strings.Index(str, search)
+ if idx == -1 {
+ break
+ }
+ openingTagCount++
+ str = str[idx+len(search):]
+ }
+
+ if openingTagCount != 1 {
+ t.Errorf("Expected exactly 1 element, found %d. XML:\n%s", openingTagCount, xml)
+ }
+
+ // Verify the value is set correctly
+ result := xmldot.Get(body.Res(), "match.authorizing-method-priority.greater-than")
+ if result.Int() != 20 {
+ t.Errorf("Expected value 20, got %d", result.Int())
+ }
+
+ t.Logf("✓ No duplicate elements, value correctly set to: %d", result.Int())
+}
+
+// TestSetFromXPath_BooleanEmptyValue tests that boolean true values (empty strings)
+// correctly create empty elements in XML for NETCONF presence containers.
+func TestSetFromXPath_BooleanEmptyValue(t *testing.T) {
+ body := netconf.Body{}
+
+ // Test setting an empty string (boolean true in NETCONF)
+ body = SetFromXPath(body, "match/authorization-status/authorized", "")
+
+ xml := body.Res()
+ t.Logf("Generated XML:\n%s", xml)
+
+ // Check that the authorized element exists
+ if !strings.Contains(xml, "") && !strings.Contains(xml, "") {
+ t.Errorf("Expected element to be present in XML")
+ }
+
+ // Verify the element exists using xmldot
+ result := xmldot.Get(body.Res(), "match.authorization-status.authorized")
+ if !result.Exists() {
+ t.Errorf("Expected match.authorization-status.authorized to exist")
+ }
+
+ t.Log("✓ Boolean empty value correctly creates presence container element")
+}
+
+// TestGetXPathFormat tests what format getXPath produces
+func TestGetXPathFormat(t *testing.T) {
+ // Test ConvertRestconfPathToXPath
+ path := ConvertRestconfPathToXPath("Cisco-IOS-XE-native:native/policy/Cisco-IOS-XE-policy:class-map=%v")
+ t.Logf("After ConvertRestconfPathToXPath: %s", path)
+
+ // Then sprintf with key
+ finalPath := fmt.Sprintf(path, "name", "CM1")
+ t.Logf("After fmt.Sprintf: %s", finalPath)
+}
+
+// TestSetFromXPath_ClassMapSequence tests the exact sequence used in class-map
+// to understand why authorized element is missing.
+func TestSetFromXPath_ClassMapSequence(t *testing.T) {
+ body := netconf.Body{}
+ path := "Cisco-IOS-XE-native:native/policy/Cisco-IOS-XE-policy:class-map[name=CM1]"
+
+ // authorized (boolean empty)
+ body = SetFromXPath(body, path+"/match/authorization-status/authorized", "")
+ t.Log("After authorized:")
+ t.Log(body.Res())
+
+ // aaa-timeout (boolean empty)
+ body = SetFromXPath(body, path+"/match/result-type/aaa-timeout", "")
+ t.Log("\nAfter aaa-timeout:")
+ t.Log(body.Res())
+
+ // activated-service-template list
+ cBody := netconf.Body{}
+ cBody = SetFromXPath(cBody, "service-name", "CRITICAL_AUTH_ACCESS")
+ body = SetRawFromXPath(body, path+"/match/activated-service-template", cBody.Res())
+ t.Log("\nAfter activated-service-template:")
+ t.Log(body.Res())
+
+ // Check both elements still exist
+ authResult := xmldot.Get(body.Res(), "native.policy.class-map.match.authorization-status.authorized")
+ if !authResult.Exists() {
+ t.Error("❌ authorized element missing after list addition!")
+ } else {
+ t.Log("✓ authorized element still exists")
+ }
+
+ aaaResult := xmldot.Get(body.Res(), "native.policy.class-map.match.result-type.aaa-timeout")
+ if !aaaResult.Exists() {
+ t.Error("❌ aaa-timeout element missing after list addition!")
+ } else {
+ t.Log("✓ aaa-timeout element still exists")
+ }
+}
+
+// TestSetRawFromXPath_DebugParentPath debugs the parent path resolution
+func TestSetRawFromXPath_DebugParentPath(t *testing.T) {
+ body := netconf.Body{}
+ path := "Cisco-IOS-XE-native:native/policy/Cisco-IOS-XE-policy:class-map[name=CM1]"
+
+ // Set some initial content
+ body = SetFromXPath(body, path+"/match/authorization-status/authorized", "")
+ body = SetFromXPath(body, path+"/match/result-type/aaa-timeout", "")
+
+ t.Log("Initial XML:")
+ t.Log(body.Res())
+
+ // Now add the list item
+ t.Log("\nAdding activated-service-template...")
+ cBody := netconf.Body{}
+ cBody = SetFromXPath(cBody, "service-name", "CRITICAL_AUTH_ACCESS")
+
+ // What is the parent path for activated-service-template?
+ fullPath := path + "/match/activated-service-template"
+ segments := splitXPathSegments(strings.TrimPrefix(fullPath, "/"))
+ t.Logf("Segments: %v", segments)
+ t.Logf("Number of segments: %d", len(segments))
+
+ parentPathSegments := make([]string, 0, len(segments)-1)
+ for _, segment := range segments[:len(segments)-1] {
+ elementName, _ := parseXPathSegment(segment)
+ parentPathSegments = append(parentPathSegments, elementName)
+ }
+ parentPath := dotPath(strings.Join(parentPathSegments, "."))
+ t.Logf("Parent path: %s", parentPath)
+
+ // What content exists at parent path?
+ existingXML := xmldot.Get(body.Res(), parentPath).Raw
+ t.Logf("Existing XML at parent: %s", existingXML)
+
+ body = SetRawFromXPath(body, fullPath, cBody.Res())
+
+ t.Log("\nAfter SetRawFromXPath:")
+ t.Log(body.Res())
+}
+
+// TestBodySetRaw tests how body.SetRaw behaves
+func TestBodySetRaw(t *testing.T) {
+ body := netconf.Body{}
+
+ // Create initial structure
+ body = body.Set("match.foo", "value1")
+ t.Log("Initial:")
+ t.Log(body.Res())
+
+ // Now try to SetRaw at match with combined content
+ existing := xmldot.Get(body.Res(), "match").Raw
+ t.Logf("\nExisting at 'match': %s", existing)
+
+ newContent := "value2"
+ combined := existing + newContent
+ t.Logf("Combined: %s", combined)
+
+ body = body.SetRaw("match", combined)
+ t.Log("\nAfter SetRaw:")
+ t.Log(body.Res())
+}
+
+// TestAppendFromXPath tests the AppendFromXPath function
+func TestAppendFromXPath(t *testing.T) {
+ body := netconf.Body{}
+ path := "native/route-map/rule/match/ip/address"
+
+ // Add first item
+ body = AppendFromXPath(body, path, "10")
+ t.Log("After first append:")
+ t.Log(body.Res())
+
+ // Add second item
+ body = AppendFromXPath(body, path, "20")
+ t.Log("\nAfter second append:")
+ t.Log(body.Res())
+
+ // Add third item
+ body = AppendFromXPath(body, path, "30")
+ t.Log("\nAfter third append:")
+ t.Log(body.Res())
+
+ // Verify all three items exist
+ result1 := xmldot.Get(body.Res(), "native.route-map.rule.match.ip.address.0")
+ result2 := xmldot.Get(body.Res(), "native.route-map.rule.match.ip.address.1")
+ result3 := xmldot.Get(body.Res(), "native.route-map.rule.match.ip.address.2")
+
+ if result1.String() != "10" {
+ t.Errorf("Expected first item to be '10', got '%s'", result1.String())
+ }
+ if result2.String() != "20" {
+ t.Errorf("Expected second item to be '20', got '%s'", result2.String())
+ }
+ if result3.String() != "30" {
+ t.Errorf("Expected third item to be '30', got '%s'", result3.String())
+ }
+
+ t.Log("✓ All three items appended successfully")
+}
+
+// TestAppendFromXPath_WithNamespaces tests AppendFromXPath with namespace prefixes
+func TestAppendFromXPath_WithNamespaces(t *testing.T) {
+ body := netconf.Body{}
+ path := "Cisco-IOS-XE-native:native/Cisco-IOS-XE-policy:class-map[name=CM1]/match/dscp"
+
+ // Append multiple dscp values
+ body = AppendFromXPath(body, path, 8)
+ body = AppendFromXPath(body, path, 16)
+ body = AppendFromXPath(body, path, 24)
+
+ t.Log("Generated XML with namespaces:")
+ t.Log(body.Res())
+
+ // Verify all items exist
+ result1 := xmldot.Get(body.Res(), "native.class-map.match.dscp.0")
+ result2 := xmldot.Get(body.Res(), "native.class-map.match.dscp.1")
+ result3 := xmldot.Get(body.Res(), "native.class-map.match.dscp.2")
+
+ if result1.Int() != 8 {
+ t.Errorf("Expected first dscp to be 8, got %d", result1.Int())
+ }
+ if result2.Int() != 16 {
+ t.Errorf("Expected second dscp to be 16, got %d", result2.Int())
+ }
+ if result3.Int() != 24 {
+ t.Errorf("Expected third dscp to be 24, got %d", result3.Int())
+ }
+
+ // Verify namespace declarations
+ if !strings.Contains(body.Res(), `xmlns="http://cisco.com/ns/yang/Cisco-IOS-XE-native"`) {
+ t.Error("Missing Cisco-IOS-XE-native namespace declaration")
+ }
+ if !strings.Contains(body.Res(), `xmlns="http://cisco.com/ns/yang/Cisco-IOS-XE-policy"`) {
+ t.Error("Missing Cisco-IOS-XE-policy namespace declaration")
+ }
+
+ t.Log("✓ List items appended with proper namespaces")
+}
+
+// TestAppendFromXPath_EmptyValue tests AppendFromXPath with empty values (boolean presence)
+func TestAppendFromXPath_EmptyValue(t *testing.T) {
+ body := netconf.Body{}
+ path := "native/feature/item"
+
+ // Append empty values (presence containers)
+ body = AppendFromXPath(body, path, "")
+ body = AppendFromXPath(body, path, "")
+
+ t.Log("Generated XML with empty values:")
+ t.Log(body.Res())
+
+ // Verify structure exists
+ if !strings.Contains(body.Res(), " ") && !strings.Contains(body.Res(), " ") {
+ t.Error("Expected empty - elements")
+ }
+
+ t.Log("✓ Empty values (presence containers) appended successfully")
+}
diff --git a/internal/provider/helpers/restconf.go b/internal/provider/helpers/restconf.go
new file mode 100644
index 00000000..abd4821f
--- /dev/null
+++ b/internal/provider/helpers/restconf.go
@@ -0,0 +1,183 @@
+// Copyright © 2025 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 helpers
+
+import (
+ "net/url"
+ "regexp"
+ "strings"
+)
+
+// ConvertXPathToRestconfPath converts an XPath-style path to RESTCONF-style path.
+// It retains placeholders (%v, %s, %d) and namespace prefixes.
+// Values are URL-encoded as required by RESTCONF (except placeholders).
+//
+// XPath uses: element[key=value] or element[%v=value]
+// RESTCONF uses: element=value (URL-encoded)
+//
+// Examples:
+// - "interface[name=GigabitEthernet1]" → "interface=GigabitEthernet1"
+// - "interface[%v=GigabitEthernet1]" → "interface=%v"
+// - "interface[%v=%v]" → "interface=%v"
+// - "vrf[name=VRF1][af-name=ipv4]" → "vrf=VRF1,ipv4"
+// - "Cisco-IOS-XE-native:native/vrf[%v=%v]" → "Cisco-IOS-XE-native:native/vrf=%v"
+// - "native/interface[name='GigabitEthernet1/0/1']" → "native/interface=GigabitEthernet1%2F0%2F1"
+// - "route-map[name='test map']" → "route-map=test+map"
+func ConvertXPathToRestconfPath(xPath string) string {
+ // Remove leading slash if present
+ xPath = strings.TrimPrefix(xPath, "/")
+
+ // Use splitXPathSegments to handle slashes inside predicates correctly
+ segments := splitXPathSegmentsForConversion(xPath)
+ result := make([]string, 0, len(segments))
+
+ for _, segment := range segments {
+ if !strings.Contains(segment, "[") {
+ // No predicates, keep as-is
+ result = append(result, segment)
+ continue
+ }
+
+ // Extract element name and predicates
+ elementName := segment
+ predicates := []string{}
+
+ // Find the element name (everything before first '[')
+ bracketIdx := strings.IndexByte(segment, '[')
+ if bracketIdx != -1 {
+ elementName = segment[:bracketIdx]
+
+ // Extract all predicates
+ predicateStr := segment[bracketIdx:]
+
+ // Parse predicates - handle quotes for values with special chars
+ predicateRegex := regexp.MustCompile(`\[([^\]]+)\]`)
+ matches := predicateRegex.FindAllStringSubmatch(predicateStr, -1)
+
+ for _, match := range matches {
+ if len(match) > 1 {
+ predicate := match[1]
+
+ // Parse key=value
+ eqIdx := strings.Index(predicate, "=")
+ if eqIdx != -1 {
+ key := strings.TrimSpace(predicate[:eqIdx])
+ value := strings.TrimSpace(predicate[eqIdx+1:])
+
+ // Remove quotes from value if present
+ value = strings.Trim(value, `'"`)
+
+ // If key is a placeholder (%v), use placeholder for value
+ // If value is a placeholder, keep it (don't encode placeholders)
+ if strings.HasPrefix(key, "%") {
+ predicates = append(predicates, "%v")
+ } else if strings.HasPrefix(value, "%") {
+ predicates = append(predicates, value)
+ } else {
+ // URL-encode the value for RESTCONF paths
+ encodedValue := url.QueryEscape(value)
+ predicates = append(predicates, encodedValue)
+ }
+ }
+ }
+ }
+ }
+
+ // Build RESTCONF-style segment
+ if len(predicates) > 0 {
+ result = append(result, elementName+"="+strings.Join(predicates, ","))
+ } else {
+ result = append(result, elementName)
+ }
+ }
+
+ return strings.Join(result, "/")
+}
+
+// splitXPathSegmentsForConversion splits an XPath into segments while respecting
+// bracket boundaries. This prevents splitting on slashes inside predicates.
+func splitXPathSegmentsForConversion(xPath string) []string {
+ segments := []string{}
+ var currentSegment strings.Builder
+ bracketDepth := 0
+ inQuote := false
+ var quoteChar rune
+
+ for _, char := range xPath {
+ switch char {
+ case '\'', '"':
+ if !inQuote {
+ inQuote = true
+ quoteChar = char
+ } else if char == quoteChar {
+ inQuote = false
+ }
+ currentSegment.WriteRune(char)
+ case '[':
+ if !inQuote {
+ bracketDepth++
+ }
+ currentSegment.WriteRune(char)
+ case ']':
+ if !inQuote {
+ bracketDepth--
+ }
+ currentSegment.WriteRune(char)
+ case '/':
+ if bracketDepth == 0 && !inQuote {
+ // We're not inside brackets or quotes, so this is a segment separator
+ if currentSegment.Len() > 0 {
+ segments = append(segments, currentSegment.String())
+ currentSegment.Reset()
+ }
+ } else {
+ // We're inside brackets or quotes, so this is part of a predicate value
+ currentSegment.WriteRune(char)
+ }
+ default:
+ currentSegment.WriteRune(char)
+ }
+ }
+
+ // Add the last segment if there's anything left
+ if currentSegment.Len() > 0 {
+ segments = append(segments, currentSegment.String())
+ }
+
+ return segments
+}
+
+// LastElement returns the last element of a YANG path with its namespace prefix.
+// Example: "Cisco-IOS-XE-native:native/interface/GigabitEthernet=1" -> "Cisco-IOS-XE-native:GigabitEthernet"
+func LastElement(path string) string {
+ pes := strings.Split(path, "/")
+ var prefix, element string
+ for _, pe := range pes {
+ // remove key
+ if strings.Contains(pe, "=") {
+ pe = pe[:strings.Index(pe, "=")]
+ }
+ if strings.Contains(pe, ":") {
+ prefix = strings.Split(pe, ":")[0]
+ element = strings.Split(pe, ":")[1]
+ } else {
+ element = pe
+ }
+ }
+ return prefix + ":" + element
+}
diff --git a/internal/provider/helpers/restconf_test.go b/internal/provider/helpers/restconf_test.go
new file mode 100644
index 00000000..0bbb40c9
--- /dev/null
+++ b/internal/provider/helpers/restconf_test.go
@@ -0,0 +1,210 @@
+// Copyright © 2025 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 helpers
+
+import (
+ "testing"
+)
+
+// TestConvertXPathToRestconfPath tests the XPath to RESTCONF path conversion
+func TestConvertXPathToRestconfPath(t *testing.T) {
+ tests := []struct {
+ name string
+ xPath string
+ expected string
+ }{
+ {
+ name: "simple element without predicates",
+ xPath: "native/interface",
+ expected: "native/interface",
+ },
+ {
+ name: "single predicate with concrete value",
+ xPath: "interface[name=GigabitEthernet1]",
+ expected: "interface=GigabitEthernet1",
+ },
+ {
+ name: "single predicate with placeholder key",
+ xPath: "interface[%v=GigabitEthernet1]",
+ expected: "interface=%v",
+ },
+ {
+ name: "single predicate with placeholder value",
+ xPath: "interface[name=%v]",
+ expected: "interface=%v",
+ },
+ {
+ name: "double placeholders",
+ xPath: "interface[%v=%v]",
+ expected: "interface=%v",
+ },
+ {
+ name: "multiple predicates (composite key)",
+ xPath: "vrf[name=VRF1][af-name=ipv4]",
+ expected: "vrf=VRF1,ipv4",
+ },
+ {
+ name: "multiple predicates with placeholders",
+ xPath: "vrf[%v=VRF1][%v=ipv4]",
+ expected: "vrf=%v,%v",
+ },
+ {
+ name: "namespace prefix retained",
+ xPath: "Cisco-IOS-XE-native:native/Cisco-IOS-XE-policy:class-map[%v=%v]",
+ expected: "Cisco-IOS-XE-native:native/Cisco-IOS-XE-policy:class-map=%v",
+ },
+ {
+ name: "nested path with multiple keys",
+ xPath: "native/vrf[name=VRF1]/address-family[af-name=ipv4]",
+ expected: "native/vrf=VRF1/address-family=ipv4",
+ },
+ {
+ name: "value with special characters (quoted)",
+ xPath: "interface[name='GigabitEthernet1/0/1']",
+ expected: "interface=GigabitEthernet1%2F0%2F1",
+ },
+ {
+ name: "value with special characters (double quotes)",
+ xPath: `interface[name="GigabitEthernet1/0/1"]`,
+ expected: "interface=GigabitEthernet1%2F0%2F1",
+ },
+ {
+ name: "leading slash",
+ xPath: "/native/interface[name=Gi1]",
+ expected: "native/interface=Gi1",
+ },
+ {
+ name: "complex real-world example",
+ xPath: "Cisco-IOS-XE-native:native/policy/Cisco-IOS-XE-policy:class-map[%v=%v]/match/activated-service-template",
+ expected: "Cisco-IOS-XE-native:native/policy/Cisco-IOS-XE-policy:class-map=%v/match/activated-service-template",
+ },
+ {
+ name: "placeholder with %s format",
+ xPath: "interface[name=%s]",
+ expected: "interface=%s",
+ },
+ {
+ name: "placeholder with %d format",
+ xPath: "vlan[id=%d]",
+ expected: "vlan=%d",
+ },
+ }
+
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ result := ConvertXPathToRestconfPath(tt.xPath)
+ if result != tt.expected {
+ t.Errorf("ConvertXPathToRestconfPath(%q) = %q, expected %q", tt.xPath, result, tt.expected)
+ }
+ })
+ }
+}
+
+// TestConvertXPathToRestconfPath_RoundTrip tests converting back and forth
+func TestConvertXPathToRestconfPath_RoundTrip(t *testing.T) {
+ tests := []struct {
+ name string
+ restconfPath string
+ xPath string
+ }{
+ {
+ name: "simple path",
+ restconfPath: "native/interface=%v",
+ xPath: "native/interface[%v=%v]",
+ },
+ {
+ name: "with namespace",
+ restconfPath: "Cisco-IOS-XE-native:native/Cisco-IOS-XE-policy:class-map=%v",
+ xPath: "Cisco-IOS-XE-native:native/Cisco-IOS-XE-policy:class-map[%v=%v]",
+ },
+ }
+
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ // RESTCONF → XPath
+ converted := ConvertRestconfPathToXPath(tt.restconfPath)
+ if converted != tt.xPath {
+ t.Errorf("ConvertRestconfPathToXPath(%q) = %q, expected %q", tt.restconfPath, converted, tt.xPath)
+ }
+
+ // XPath → RESTCONF
+ reverted := ConvertXPathToRestconfPath(tt.xPath)
+ if reverted != tt.restconfPath {
+ t.Errorf("ConvertXPathToRestconfPath(%q) = %q, expected %q", tt.xPath, reverted, tt.restconfPath)
+ }
+
+ t.Logf("✓ Round-trip successful: %q ↔ %q", tt.restconfPath, tt.xPath)
+ })
+ }
+}
+
+// TestConvertXPathToRestconfPath_URLEncoding tests URL encoding of special characters
+func TestConvertXPathToRestconfPath_URLEncoding(t *testing.T) {
+ tests := []struct {
+ name string
+ xPath string
+ expected string
+ }{
+ {
+ name: "slash in value",
+ xPath: "interface[name='GigabitEthernet1/0/1']",
+ expected: "interface=GigabitEthernet1%2F0%2F1",
+ },
+ {
+ name: "space in value",
+ xPath: "route-map[name='test map']",
+ expected: "route-map=test+map",
+ },
+ {
+ name: "special characters",
+ xPath: "description[text='hello@world!']",
+ expected: "description=hello%40world%21",
+ },
+ {
+ name: "equals sign in value",
+ xPath: "config[setting='key=value']",
+ expected: "config=key%3Dvalue",
+ },
+ {
+ name: "percent in value (not placeholder)",
+ xPath: "policy[name='CPU>80%']",
+ expected: "policy=CPU%3E80%25",
+ },
+ {
+ name: "placeholder not encoded",
+ xPath: "interface[name=%v]",
+ expected: "interface=%v",
+ },
+ {
+ name: "multiple special chars with namespace",
+ xPath: "Cisco-IOS-XE-native:native/route-map[name='my/route@map']",
+ expected: "Cisco-IOS-XE-native:native/route-map=my%2Froute%40map",
+ },
+ }
+
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ result := ConvertXPathToRestconfPath(tt.xPath)
+ if result != tt.expected {
+ t.Errorf("ConvertXPathToRestconfPath(%q) = %q, expected %q", tt.xPath, result, tt.expected)
+ } else {
+ t.Logf("✓ %s correctly encoded", tt.name)
+ }
+ })
+ }
+}
diff --git a/internal/provider/helpers/tflog_adapter.go b/internal/provider/helpers/tflog_adapter.go
new file mode 100644
index 00000000..18defb0a
--- /dev/null
+++ b/internal/provider/helpers/tflog_adapter.go
@@ -0,0 +1,198 @@
+// Copyright © 2025 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 helpers
+
+import (
+ "context"
+
+ "github.com/hashicorp/terraform-plugin-log/tflog"
+ "github.com/netascode/go-netconf"
+)
+
+// TflogAdapter adapts go-netconf's Logger interface to Terraform's tflog package.
+//
+// This adapter bridges the gap between go-netconf's logging interface and Terraform's
+// context-based logging. It leverages go-netconf's context-aware Logger interface,
+// which passes context as the first parameter to all logging methods.
+//
+// The adapter automatically creates the "netconf" subsystem on first use, eliminating
+// the need for manual subsystem creation in provider code.
+//
+// Thread-safety: This adapter is safe for concurrent use. Context is passed per
+// log call via the Logger interface, eliminating the need for internal state.
+//
+// Usage in provider initialization:
+//
+// logger := helpers.NewTflogAdapter()
+// client, err := netconf.NewClient(host,
+// netconf.Username(username),
+// netconf.Password(password),
+// netconf.WithLogger(logger),
+// )
+//
+// Usage in resource operations:
+//
+// // Context is automatically propagated through go-netconf's Logger interface
+// _, err := device.NetconfClient.GetConfig(ctx, "running", filter)
+// // Logs will automatically use the correct context and netconf subsystem
+type TflogAdapter struct{}
+
+var _ netconf.Logger = (*TflogAdapter)(nil)
+
+// NewTflogAdapter creates a new Terraform logging adapter.
+//
+// The adapter automatically receives context from go-netconf's Logger interface
+// on each logging call, ensuring proper context propagation without manual management.
+func NewTflogAdapter() *TflogAdapter {
+ return &TflogAdapter{}
+}
+
+// Debug logs a debug message with structured key-value pairs to tflog.SubsystemDebug.
+//
+// Debug logs are typically used for detailed operational information useful
+// for troubleshooting and development.
+//
+// Context is provided by go-netconf's Logger interface, ensuring automatic
+// propagation of trace IDs, request IDs, and deadlines.
+//
+// Logs are written to the "netconf" subsystem for proper organization and filtering.
+// The subsystem is automatically created if it doesn't exist.
+func (t *TflogAdapter) Debug(ctx context.Context, msg string, keysAndValues ...any) {
+ if ctx == nil {
+ return
+ }
+ // Ensure subsystem exists (idempotent operation)
+ ctx = tflog.NewSubsystem(ctx, "netconf")
+
+ fields := keysAndValuesToMap(keysAndValues)
+ if fields != nil {
+ tflog.SubsystemDebug(ctx, "netconf", msg, fields)
+ } else {
+ tflog.SubsystemDebug(ctx, "netconf", msg)
+ }
+}
+
+// Info logs an informational message with structured key-value pairs to tflog.SubsystemInfo.
+//
+// Info logs represent normal operational messages that highlight progress
+// or state changes.
+//
+// Context is provided by go-netconf's Logger interface, ensuring automatic
+// propagation of trace IDs, request IDs, and deadlines.
+//
+// Logs are written to the "netconf" subsystem for proper organization and filtering.
+// The subsystem is automatically created if it doesn't exist.
+func (t *TflogAdapter) Info(ctx context.Context, msg string, keysAndValues ...any) {
+ if ctx == nil {
+ return
+ }
+ // Ensure subsystem exists (idempotent operation)
+ ctx = tflog.NewSubsystem(ctx, "netconf")
+
+ fields := keysAndValuesToMap(keysAndValues)
+ if fields != nil {
+ tflog.SubsystemInfo(ctx, "netconf", msg, fields)
+ } else {
+ tflog.SubsystemInfo(ctx, "netconf", msg)
+ }
+}
+
+// Warn logs a warning message with structured key-value pairs to tflog.SubsystemWarn.
+//
+// Warnings indicate potentially harmful situations that don't prevent
+// operation but should be addressed.
+//
+// Context is provided by go-netconf's Logger interface, ensuring automatic
+// propagation of trace IDs, request IDs, and deadlines.
+//
+// Logs are written to the "netconf" subsystem for proper organization and filtering.
+// The subsystem is automatically created if it doesn't exist.
+func (t *TflogAdapter) Warn(ctx context.Context, msg string, keysAndValues ...any) {
+ if ctx == nil {
+ return
+ }
+ // Ensure subsystem exists (idempotent operation)
+ ctx = tflog.NewSubsystem(ctx, "netconf")
+
+ fields := keysAndValuesToMap(keysAndValues)
+ if fields != nil {
+ tflog.SubsystemWarn(ctx, "netconf", msg, fields)
+ } else {
+ tflog.SubsystemWarn(ctx, "netconf", msg)
+ }
+}
+
+// Error logs an error message with structured key-value pairs to tflog.SubsystemError.
+//
+// Errors indicate serious problems that prevent successful operation.
+//
+// Context is provided by go-netconf's Logger interface, ensuring automatic
+// propagation of trace IDs, request IDs, and deadlines.
+//
+// Logs are written to the "netconf" subsystem for proper organization and filtering.
+// The subsystem is automatically created if it doesn't exist.
+func (t *TflogAdapter) Error(ctx context.Context, msg string, keysAndValues ...any) {
+ if ctx == nil {
+ return
+ }
+ // Ensure subsystem exists (idempotent operation)
+ ctx = tflog.NewSubsystem(ctx, "netconf")
+
+ fields := keysAndValuesToMap(keysAndValues)
+ if fields != nil {
+ tflog.SubsystemError(ctx, "netconf", msg, fields)
+ } else {
+ tflog.SubsystemError(ctx, "netconf", msg)
+ }
+}
+
+// keysAndValuesToMap converts variadic key-value pairs to a map for tflog.
+//
+// tflog expects structured fields as map[string]any, while go-netconf uses
+// variadic key-value pairs (following Go's slog standard). This function performs
+// the conversion.
+//
+// Example:
+//
+// Input: "operation", "GetConfig", "datastore", "running", "duration", 150
+// Output: map[string]any{"operation": "GetConfig", "datastore": "running", "duration": 150}
+//
+// If the number of elements is odd, the last key will have a nil value.
+func keysAndValuesToMap(keysAndValues []any) map[string]any {
+ if len(keysAndValues) == 0 {
+ return nil
+ }
+
+ fields := make(map[string]any, len(keysAndValues)/2)
+ for i := 0; i < len(keysAndValues); i += 2 {
+ key, ok := keysAndValues[i].(string)
+ if !ok {
+ // Skip non-string keys
+ continue
+ }
+
+ var value any
+ if i+1 < len(keysAndValues) {
+ value = keysAndValues[i+1]
+ }
+
+ fields[key] = value
+ }
+
+ return fields
+}
diff --git a/internal/provider/helpers/utils.go b/internal/provider/helpers/utils.go
index 8182472c..7ad54861 100644
--- a/internal/provider/helpers/utils.go
+++ b/internal/provider/helpers/utils.go
@@ -18,13 +18,13 @@
package helpers
import (
- "strings"
-
"github.com/hashicorp/terraform-plugin-framework/attr"
"github.com/hashicorp/terraform-plugin-framework/types"
+ "github.com/netascode/xmldot"
"github.com/tidwall/gjson"
)
+// Contains checks if a string exists in a slice of strings.
func Contains(s []string, str string) bool {
for _, v := range s {
if v == str {
@@ -34,24 +34,7 @@ func Contains(s []string, str string) bool {
return false
}
-func LastElement(path string) string {
- pes := strings.Split(path, "/")
- var prefix, element string
- for _, pe := range pes {
- // remove key
- if strings.Contains(pe, "=") {
- pe = pe[:strings.Index(pe, "=")]
- }
- if strings.Contains(pe, ":") {
- prefix = strings.Split(pe, ":")[0]
- element = strings.Split(pe, ":")[1]
- } else {
- element = pe
- }
- }
- return prefix + ":" + element
-}
-
+// GetValueSlice converts a slice of gjson.Result to a slice of Terraform attr.Value.
func GetValueSlice(result []gjson.Result) []attr.Value {
v := make([]attr.Value, len(result))
for r := range result {
@@ -60,6 +43,7 @@ func GetValueSlice(result []gjson.Result) []attr.Value {
return v
}
+// GetStringList converts a slice of gjson.Result to a Terraform types.List of strings.
func GetStringList(result []gjson.Result) types.List {
v := make([]attr.Value, len(result))
for r := range result {
@@ -68,6 +52,7 @@ func GetStringList(result []gjson.Result) types.List {
return types.ListValueMust(types.StringType, v)
}
+// GetInt64List converts a slice of gjson.Result to a Terraform types.List of int64.
func GetInt64List(result []gjson.Result) types.List {
v := make([]attr.Value, len(result))
for r := range result {
@@ -76,6 +61,7 @@ func GetInt64List(result []gjson.Result) types.List {
return types.ListValueMust(types.Int64Type, v)
}
+// GetStringSet converts a slice of gjson.Result to a Terraform types.Set of strings.
func GetStringSet(result []gjson.Result) types.Set {
v := make([]attr.Value, len(result))
for r := range result {
@@ -84,6 +70,7 @@ func GetStringSet(result []gjson.Result) types.Set {
return types.SetValueMust(types.StringType, v)
}
+// GetInt64Set converts a slice of gjson.Result to a Terraform types.Set of int64.
func GetInt64Set(result []gjson.Result) types.Set {
v := make([]attr.Value, len(result))
for r := range result {
@@ -92,6 +79,44 @@ func GetInt64Set(result []gjson.Result) types.Set {
return types.SetValueMust(types.Int64Type, v)
}
+// GetStringListXML converts a slice of xmldot.Result to a Terraform types.List of strings.
+func GetStringListXML(result []xmldot.Result) types.List {
+ v := make([]attr.Value, len(result))
+ for r := range result {
+ v[r] = types.StringValue(result[r].String())
+ }
+ return types.ListValueMust(types.StringType, v)
+}
+
+// GetInt64ListXML converts a slice of xmldot.Result to a Terraform types.List of int64.
+func GetInt64ListXML(result []xmldot.Result) types.List {
+ v := make([]attr.Value, len(result))
+ for r := range result {
+ v[r] = types.Int64Value(result[r].Int())
+ }
+ return types.ListValueMust(types.Int64Type, v)
+}
+
+// GetStringSetXML converts a slice of xmldot.Result to a Terraform types.Set of strings.
+func GetStringSetXML(result []xmldot.Result) types.Set {
+ v := make([]attr.Value, len(result))
+ for r := range result {
+ v[r] = types.StringValue(result[r].String())
+ }
+ return types.SetValueMust(types.StringType, v)
+}
+
+// GetInt64SetXML converts a slice of xmldot.Result to a Terraform types.Set of int64.
+func GetInt64SetXML(result []xmldot.Result) types.Set {
+ v := make([]attr.Value, len(result))
+ for r := range result {
+ v[r] = types.Int64Value(result[r].Int())
+ }
+ return types.SetValueMust(types.Int64Type, v)
+}
+
+// Must panics if err is not nil, otherwise returns the value v.
+// Useful for must-succeed operations in initialization code.
func Must[T any](v T, err error) T {
if err != nil {
panic(err)
@@ -99,6 +124,7 @@ func Must[T any](v T, err error) T {
return v
}
+// RemoveEmptyStrings filters out empty strings from a slice.
func RemoveEmptyStrings(s []string) []string {
var r []string
for _, v := range s {
diff --git a/internal/provider/model_iosxe_aaa.go b/internal/provider/model_iosxe_aaa.go
index 346c8d10..100532c6 100644
--- a/internal/provider/model_iosxe_aaa.go
+++ b/internal/provider/model_iosxe_aaa.go
@@ -30,6 +30,9 @@ import (
"github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/types"
+ "github.com/hashicorp/terraform-plugin-log/tflog"
+ "github.com/netascode/go-netconf"
+ "github.com/netascode/xmldot"
"github.com/tidwall/gjson"
"github.com/tidwall/sjson"
)
@@ -126,6 +129,17 @@ func (data AAA) getPathShort() string {
return matches[1]
}
+// getXPath returns the XPath for NETCONF operations
+func (data AAA) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/aaa"
+ return path
+}
+
+func (data AAAData) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/aaa"
+ return path
+}
+
// End of section. //template:end getPath
// Section below is generated&owned by "gen/generator.go". //template:begin toBody
@@ -262,6 +276,153 @@ func (data AAA) toBody(ctx context.Context) string {
// End of section. //template:end toBody
+// Section below is generated&owned by "gen/generator.go". //template:begin toBodyXML
+
+func (data AAA) toBodyXML(ctx context.Context) string {
+ body := netconf.Body{}
+ if !data.NewModel.IsNull() && !data.NewModel.IsUnknown() {
+ if data.NewModel.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-aaa:new-model", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-aaa:new-model")
+ }
+ }
+ if !data.ServerRadiusDynamicAuthor.IsNull() && !data.ServerRadiusDynamicAuthor.IsUnknown() {
+ if data.ServerRadiusDynamicAuthor.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-aaa:server/radius/dynamic-author", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-aaa:server/radius/dynamic-author")
+ }
+ }
+ if !data.SessionId.IsNull() && !data.SessionId.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-aaa:session-id", data.SessionId.ValueString())
+ }
+ if len(data.ServerRadiusDynamicAuthorClients) > 0 {
+ for _, item := range data.ServerRadiusDynamicAuthorClients {
+ cBody := netconf.Body{}
+ if !item.Ip.IsNull() && !item.Ip.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "ip", item.Ip.ValueString())
+ }
+ if !item.ServerKeyType.IsNull() && !item.ServerKeyType.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "server-key/key", item.ServerKeyType.ValueString())
+ }
+ if !item.ServerKey.IsNull() && !item.ServerKey.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "server-key/string", item.ServerKey.ValueString())
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-aaa:server/radius/dynamic-author/client", cBody.Res())
+ }
+ }
+ if len(data.GroupServerRadius) > 0 {
+ for _, item := range data.GroupServerRadius {
+ cBody := netconf.Body{}
+ if !item.Name.IsNull() && !item.Name.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "name", item.Name.ValueString())
+ }
+ if len(item.ServerNames) > 0 {
+ for _, citem := range item.ServerNames {
+ ccBody := netconf.Body{}
+ if !citem.Name.IsNull() && !citem.Name.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "name", citem.Name.ValueString())
+ }
+ cBody = helpers.SetRawFromXPath(cBody, "server/name", ccBody.Res())
+ }
+ }
+ if !item.IpRadiusSourceInterfaceLoopback.IsNull() && !item.IpRadiusSourceInterfaceLoopback.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "ip/radius/source-interface/Loopback", strconv.FormatInt(item.IpRadiusSourceInterfaceLoopback.ValueInt64(), 10))
+ }
+ if !item.IpRadiusSourceInterfaceVlan.IsNull() && !item.IpRadiusSourceInterfaceVlan.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "ip/radius/source-interface/Vlan", strconv.FormatInt(item.IpRadiusSourceInterfaceVlan.ValueInt64(), 10))
+ }
+ if !item.IpRadiusSourceInterfaceGigabitEthernet.IsNull() && !item.IpRadiusSourceInterfaceGigabitEthernet.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "ip/radius/source-interface/GigabitEthernet", item.IpRadiusSourceInterfaceGigabitEthernet.ValueString())
+ }
+ if !item.IpRadiusSourceInterfaceTwoGigabitEthernet.IsNull() && !item.IpRadiusSourceInterfaceTwoGigabitEthernet.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "ip/radius/source-interface/TwoGigabitEthernet", item.IpRadiusSourceInterfaceTwoGigabitEthernet.ValueString())
+ }
+ if !item.IpRadiusSourceInterfaceFiveGigabitEthernet.IsNull() && !item.IpRadiusSourceInterfaceFiveGigabitEthernet.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "ip/radius/source-interface/FiveGigabitEthernet", item.IpRadiusSourceInterfaceFiveGigabitEthernet.ValueString())
+ }
+ if !item.IpRadiusSourceInterfaceTenGigabitEthernet.IsNull() && !item.IpRadiusSourceInterfaceTenGigabitEthernet.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "ip/radius/source-interface/TenGigabitEthernet", item.IpRadiusSourceInterfaceTenGigabitEthernet.ValueString())
+ }
+ if !item.IpRadiusSourceInterfaceTwentyFiveGigabitEthernet.IsNull() && !item.IpRadiusSourceInterfaceTwentyFiveGigabitEthernet.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "ip/radius/source-interface/TwentyFiveGigE", item.IpRadiusSourceInterfaceTwentyFiveGigabitEthernet.ValueString())
+ }
+ if !item.IpRadiusSourceInterfaceFortyGigabitEthernet.IsNull() && !item.IpRadiusSourceInterfaceFortyGigabitEthernet.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "ip/radius/source-interface/FortyGigabitEthernet", item.IpRadiusSourceInterfaceFortyGigabitEthernet.ValueString())
+ }
+ if !item.IpRadiusSourceInterfaceHundredGigabitEthernet.IsNull() && !item.IpRadiusSourceInterfaceHundredGigabitEthernet.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "ip/radius/source-interface/HundredGigE", item.IpRadiusSourceInterfaceHundredGigabitEthernet.ValueString())
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-aaa:group/server/radius", cBody.Res())
+ }
+ }
+ if len(data.GroupServerTacacsplus) > 0 {
+ for _, item := range data.GroupServerTacacsplus {
+ cBody := netconf.Body{}
+ if !item.Name.IsNull() && !item.Name.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "name", item.Name.ValueString())
+ }
+ if len(item.ServerNames) > 0 {
+ for _, citem := range item.ServerNames {
+ ccBody := netconf.Body{}
+ if !citem.Name.IsNull() && !citem.Name.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "name", citem.Name.ValueString())
+ }
+ cBody = helpers.SetRawFromXPath(cBody, "server/name", ccBody.Res())
+ }
+ }
+ if !item.IpTacacsSourceInterfaceLoopback.IsNull() && !item.IpTacacsSourceInterfaceLoopback.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "ip/tacacs/source-interface/Loopback", strconv.FormatInt(item.IpTacacsSourceInterfaceLoopback.ValueInt64(), 10))
+ }
+ if !item.IpTacacsSourceInterfaceVlan.IsNull() && !item.IpTacacsSourceInterfaceVlan.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "ip/tacacs/source-interface/Vlan", strconv.FormatInt(item.IpTacacsSourceInterfaceVlan.ValueInt64(), 10))
+ }
+ if !item.IpTacacsSourceInterfaceGigabitEthernet.IsNull() && !item.IpTacacsSourceInterfaceGigabitEthernet.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "ip/tacacs/source-interface/GigabitEthernet", item.IpTacacsSourceInterfaceGigabitEthernet.ValueString())
+ }
+ if !item.IpTacacsSourceInterfaceTwoGigabitEthernet.IsNull() && !item.IpTacacsSourceInterfaceTwoGigabitEthernet.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "ip/tacacs/source-interface/TwoGigabitEthernet", item.IpTacacsSourceInterfaceTwoGigabitEthernet.ValueString())
+ }
+ if !item.IpTacacsSourceInterfaceFiveGigabitEthernet.IsNull() && !item.IpTacacsSourceInterfaceFiveGigabitEthernet.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "ip/tacacs/source-interface/FiveGigabitEthernet", item.IpTacacsSourceInterfaceFiveGigabitEthernet.ValueString())
+ }
+ if !item.IpTacacsSourceInterfaceTenGigabitEthernet.IsNull() && !item.IpTacacsSourceInterfaceTenGigabitEthernet.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "ip/tacacs/source-interface/TenGigabitEthernet", item.IpTacacsSourceInterfaceTenGigabitEthernet.ValueString())
+ }
+ if !item.IpTacacsSourceInterfaceTwentyFiveGigabitEthernet.IsNull() && !item.IpTacacsSourceInterfaceTwentyFiveGigabitEthernet.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "ip/tacacs/source-interface/TwentyFiveGigE", item.IpTacacsSourceInterfaceTwentyFiveGigabitEthernet.ValueString())
+ }
+ if !item.IpTacacsSourceInterfaceFortyGigabitEthernet.IsNull() && !item.IpTacacsSourceInterfaceFortyGigabitEthernet.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "ip/tacacs/source-interface/FortyGigabitEthernet", item.IpTacacsSourceInterfaceFortyGigabitEthernet.ValueString())
+ }
+ if !item.IpTacacsSourceInterfaceHundredGigabitEthernet.IsNull() && !item.IpTacacsSourceInterfaceHundredGigabitEthernet.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "ip/tacacs/source-interface/HundredGigE", item.IpTacacsSourceInterfaceHundredGigabitEthernet.ValueString())
+ }
+ if !item.Vrf.IsNull() && !item.Vrf.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "ip/vrf/forwarding", item.Vrf.ValueString())
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-aaa:group/server/tacacsplus", cBody.Res())
+ }
+ }
+ if !data.LocalAuthenticationType.IsNull() && !data.LocalAuthenticationType.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-aaa:local/authentication/authorization/authen-type", data.LocalAuthenticationType.ValueString())
+ }
+ if !data.LocalAuthorization.IsNull() && !data.LocalAuthorization.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-aaa:local/authentication/authorization/authorization", data.LocalAuthorization.ValueString())
+ }
+ if !data.LocalAuthenticationMaxFailAttempts.IsNull() && !data.LocalAuthenticationMaxFailAttempts.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-aaa:local/authentication/attempts/max-fail", strconv.FormatInt(data.LocalAuthenticationMaxFailAttempts.ValueInt64(), 10))
+ }
+ bodyString, err := body.String()
+ if err != nil {
+ tflog.Error(ctx, fmt.Sprintf("Error converting body to string: %s", err))
+ }
+ return bodyString
+}
+
+// End of section. //template:end toBodyXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBody
func (data *AAA) updateFromBody(ctx context.Context, res gjson.Result) {
@@ -551,96 +712,381 @@ func (data *AAA) updateFromBody(ctx context.Context, res gjson.Result) {
// End of section. //template:end updateFromBody
-// Section below is generated&owned by "gen/generator.go". //template:begin fromBody
+// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBodyXML
-func (data *AAA) fromBody(ctx context.Context, res gjson.Result) {
- prefix := helpers.LastElement(data.getPath()) + "."
- if res.Get(helpers.LastElement(data.getPath())).IsArray() {
- prefix += "0."
- }
- if value := res.Get(prefix + "Cisco-IOS-XE-aaa:new-model"); value.Exists() {
- data.NewModel = types.BoolValue(true)
+func (data *AAA) updateFromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-aaa:new-model"); !data.NewModel.IsNull() {
+ if value.Exists() {
+ data.NewModel = types.BoolValue(true)
+ } else {
+ data.NewModel = types.BoolValue(false)
+ }
} else {
- data.NewModel = types.BoolValue(false)
+ data.NewModel = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-aaa:server.radius.dynamic-author"); value.Exists() {
- data.ServerRadiusDynamicAuthor = types.BoolValue(true)
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-aaa:server/radius/dynamic-author"); !data.ServerRadiusDynamicAuthor.IsNull() {
+ if value.Exists() {
+ data.ServerRadiusDynamicAuthor = types.BoolValue(true)
+ } else {
+ data.ServerRadiusDynamicAuthor = types.BoolValue(false)
+ }
} else {
- data.ServerRadiusDynamicAuthor = types.BoolValue(false)
+ data.ServerRadiusDynamicAuthor = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-aaa:session-id"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-aaa:session-id"); value.Exists() && !data.SessionId.IsNull() {
data.SessionId = types.StringValue(value.String())
+ } else {
+ data.SessionId = types.StringNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-aaa:server.radius.dynamic-author.client"); value.Exists() {
- data.ServerRadiusDynamicAuthorClients = make([]AAAServerRadiusDynamicAuthorClients, 0)
- value.ForEach(func(k, v gjson.Result) bool {
- item := AAAServerRadiusDynamicAuthorClients{}
- if cValue := v.Get("ip"); cValue.Exists() {
- item.Ip = types.StringValue(cValue.String())
- }
- if cValue := v.Get("server-key.key"); cValue.Exists() {
- item.ServerKeyType = types.StringValue(cValue.String())
- }
- if cValue := v.Get("server-key.string"); cValue.Exists() {
- item.ServerKey = types.StringValue(cValue.String())
- }
- data.ServerRadiusDynamicAuthorClients = append(data.ServerRadiusDynamicAuthorClients, item)
- return true
- })
+ for i := range data.ServerRadiusDynamicAuthorClients {
+ keys := [...]string{"ip"}
+ keyValues := [...]string{data.ServerRadiusDynamicAuthorClients[i].Ip.ValueString()}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-aaa:server/radius/dynamic-author/client").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, "ip"); value.Exists() && !data.ServerRadiusDynamicAuthorClients[i].Ip.IsNull() {
+ data.ServerRadiusDynamicAuthorClients[i].Ip = types.StringValue(value.String())
+ } else {
+ data.ServerRadiusDynamicAuthorClients[i].Ip = types.StringNull()
+ }
}
- if value := res.Get(prefix + "Cisco-IOS-XE-aaa:group.server.radius"); value.Exists() {
- data.GroupServerRadius = make([]AAAGroupServerRadius, 0)
- value.ForEach(func(k, v gjson.Result) bool {
- item := AAAGroupServerRadius{}
- if cValue := v.Get("name"); cValue.Exists() {
- item.Name = types.StringValue(cValue.String())
- }
- if cValue := v.Get("server.name"); cValue.Exists() {
- item.ServerNames = make([]AAAGroupServerRadiusServerNames, 0)
- cValue.ForEach(func(ck, cv gjson.Result) bool {
- cItem := AAAGroupServerRadiusServerNames{}
- if ccValue := cv.Get("name"); ccValue.Exists() {
- cItem.Name = types.StringValue(ccValue.String())
+ for i := range data.GroupServerRadius {
+ keys := [...]string{"name"}
+ keyValues := [...]string{data.GroupServerRadius[i].Name.ValueString()}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-aaa:group/server/radius").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, "name"); value.Exists() && !data.GroupServerRadius[i].Name.IsNull() {
+ data.GroupServerRadius[i].Name = types.StringValue(value.String())
+ } else {
+ data.GroupServerRadius[i].Name = types.StringNull()
+ }
+ for ci := range data.GroupServerRadius[i].ServerNames {
+ keys := [...]string{"name"}
+ keyValues := [...]string{data.GroupServerRadius[i].ServerNames[ci].Name.ValueString()}
+
+ var cr xmldot.Result
+ helpers.GetFromXPath(r, "server/name").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ cr = v
+ return false
}
- item.ServerNames = append(item.ServerNames, cItem)
return true
- })
- }
- if cValue := v.Get("ip.radius.source-interface.Loopback"); cValue.Exists() {
- item.IpRadiusSourceInterfaceLoopback = types.Int64Value(cValue.Int())
- }
- if cValue := v.Get("ip.radius.source-interface.Vlan"); cValue.Exists() {
- item.IpRadiusSourceInterfaceVlan = types.Int64Value(cValue.Int())
- }
- if cValue := v.Get("ip.radius.source-interface.GigabitEthernet"); cValue.Exists() {
- item.IpRadiusSourceInterfaceGigabitEthernet = types.StringValue(cValue.String())
- }
- if cValue := v.Get("ip.radius.source-interface.TwoGigabitEthernet"); cValue.Exists() {
- item.IpRadiusSourceInterfaceTwoGigabitEthernet = types.StringValue(cValue.String())
- }
- if cValue := v.Get("ip.radius.source-interface.FiveGigabitEthernet"); cValue.Exists() {
- item.IpRadiusSourceInterfaceFiveGigabitEthernet = types.StringValue(cValue.String())
- }
- if cValue := v.Get("ip.radius.source-interface.TenGigabitEthernet"); cValue.Exists() {
- item.IpRadiusSourceInterfaceTenGigabitEthernet = types.StringValue(cValue.String())
- }
- if cValue := v.Get("ip.radius.source-interface.TwentyFiveGigE"); cValue.Exists() {
- item.IpRadiusSourceInterfaceTwentyFiveGigabitEthernet = types.StringValue(cValue.String())
- }
- if cValue := v.Get("ip.radius.source-interface.FortyGigabitEthernet"); cValue.Exists() {
- item.IpRadiusSourceInterfaceFortyGigabitEthernet = types.StringValue(cValue.String())
- }
- if cValue := v.Get("ip.radius.source-interface.HundredGigE"); cValue.Exists() {
- item.IpRadiusSourceInterfaceHundredGigabitEthernet = types.StringValue(cValue.String())
+ },
+ )
+ if value := helpers.GetFromXPath(cr, "name"); value.Exists() && !data.GroupServerRadius[i].ServerNames[ci].Name.IsNull() {
+ data.GroupServerRadius[i].ServerNames[ci].Name = types.StringValue(value.String())
+ } else {
+ data.GroupServerRadius[i].ServerNames[ci].Name = types.StringNull()
}
- data.GroupServerRadius = append(data.GroupServerRadius, item)
- return true
- })
- }
- if value := res.Get(prefix + "Cisco-IOS-XE-aaa:group.server.tacacsplus"); value.Exists() {
- data.GroupServerTacacsplus = make([]AAAGroupServerTacacsplus, 0)
- value.ForEach(func(k, v gjson.Result) bool {
- item := AAAGroupServerTacacsplus{}
+ }
+ if value := helpers.GetFromXPath(r, "ip/radius/source-interface/Loopback"); value.Exists() && !data.GroupServerRadius[i].IpRadiusSourceInterfaceLoopback.IsNull() {
+ data.GroupServerRadius[i].IpRadiusSourceInterfaceLoopback = types.Int64Value(value.Int())
+ } else {
+ data.GroupServerRadius[i].IpRadiusSourceInterfaceLoopback = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(r, "ip/radius/source-interface/Vlan"); value.Exists() && !data.GroupServerRadius[i].IpRadiusSourceInterfaceVlan.IsNull() {
+ data.GroupServerRadius[i].IpRadiusSourceInterfaceVlan = types.Int64Value(value.Int())
+ } else {
+ data.GroupServerRadius[i].IpRadiusSourceInterfaceVlan = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(r, "ip/radius/source-interface/GigabitEthernet"); value.Exists() && !data.GroupServerRadius[i].IpRadiusSourceInterfaceGigabitEthernet.IsNull() {
+ data.GroupServerRadius[i].IpRadiusSourceInterfaceGigabitEthernet = types.StringValue(value.String())
+ } else {
+ data.GroupServerRadius[i].IpRadiusSourceInterfaceGigabitEthernet = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "ip/radius/source-interface/TwoGigabitEthernet"); value.Exists() && !data.GroupServerRadius[i].IpRadiusSourceInterfaceTwoGigabitEthernet.IsNull() {
+ data.GroupServerRadius[i].IpRadiusSourceInterfaceTwoGigabitEthernet = types.StringValue(value.String())
+ } else {
+ data.GroupServerRadius[i].IpRadiusSourceInterfaceTwoGigabitEthernet = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "ip/radius/source-interface/FiveGigabitEthernet"); value.Exists() && !data.GroupServerRadius[i].IpRadiusSourceInterfaceFiveGigabitEthernet.IsNull() {
+ data.GroupServerRadius[i].IpRadiusSourceInterfaceFiveGigabitEthernet = types.StringValue(value.String())
+ } else {
+ data.GroupServerRadius[i].IpRadiusSourceInterfaceFiveGigabitEthernet = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "ip/radius/source-interface/TenGigabitEthernet"); value.Exists() && !data.GroupServerRadius[i].IpRadiusSourceInterfaceTenGigabitEthernet.IsNull() {
+ data.GroupServerRadius[i].IpRadiusSourceInterfaceTenGigabitEthernet = types.StringValue(value.String())
+ } else {
+ data.GroupServerRadius[i].IpRadiusSourceInterfaceTenGigabitEthernet = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "ip/radius/source-interface/TwentyFiveGigE"); value.Exists() && !data.GroupServerRadius[i].IpRadiusSourceInterfaceTwentyFiveGigabitEthernet.IsNull() {
+ data.GroupServerRadius[i].IpRadiusSourceInterfaceTwentyFiveGigabitEthernet = types.StringValue(value.String())
+ } else {
+ data.GroupServerRadius[i].IpRadiusSourceInterfaceTwentyFiveGigabitEthernet = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "ip/radius/source-interface/FortyGigabitEthernet"); value.Exists() && !data.GroupServerRadius[i].IpRadiusSourceInterfaceFortyGigabitEthernet.IsNull() {
+ data.GroupServerRadius[i].IpRadiusSourceInterfaceFortyGigabitEthernet = types.StringValue(value.String())
+ } else {
+ data.GroupServerRadius[i].IpRadiusSourceInterfaceFortyGigabitEthernet = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "ip/radius/source-interface/HundredGigE"); value.Exists() && !data.GroupServerRadius[i].IpRadiusSourceInterfaceHundredGigabitEthernet.IsNull() {
+ data.GroupServerRadius[i].IpRadiusSourceInterfaceHundredGigabitEthernet = types.StringValue(value.String())
+ } else {
+ data.GroupServerRadius[i].IpRadiusSourceInterfaceHundredGigabitEthernet = types.StringNull()
+ }
+ }
+ for i := range data.GroupServerTacacsplus {
+ keys := [...]string{"name"}
+ keyValues := [...]string{data.GroupServerTacacsplus[i].Name.ValueString()}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-aaa:group/server/tacacsplus").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, "name"); value.Exists() && !data.GroupServerTacacsplus[i].Name.IsNull() {
+ data.GroupServerTacacsplus[i].Name = types.StringValue(value.String())
+ } else {
+ data.GroupServerTacacsplus[i].Name = types.StringNull()
+ }
+ for ci := range data.GroupServerTacacsplus[i].ServerNames {
+ keys := [...]string{"name"}
+ keyValues := [...]string{data.GroupServerTacacsplus[i].ServerNames[ci].Name.ValueString()}
+
+ var cr xmldot.Result
+ helpers.GetFromXPath(r, "server/name").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ cr = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(cr, "name"); value.Exists() && !data.GroupServerTacacsplus[i].ServerNames[ci].Name.IsNull() {
+ data.GroupServerTacacsplus[i].ServerNames[ci].Name = types.StringValue(value.String())
+ } else {
+ data.GroupServerTacacsplus[i].ServerNames[ci].Name = types.StringNull()
+ }
+ }
+ if value := helpers.GetFromXPath(r, "ip/tacacs/source-interface/Loopback"); value.Exists() && !data.GroupServerTacacsplus[i].IpTacacsSourceInterfaceLoopback.IsNull() {
+ data.GroupServerTacacsplus[i].IpTacacsSourceInterfaceLoopback = types.Int64Value(value.Int())
+ } else {
+ data.GroupServerTacacsplus[i].IpTacacsSourceInterfaceLoopback = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(r, "ip/tacacs/source-interface/Vlan"); value.Exists() && !data.GroupServerTacacsplus[i].IpTacacsSourceInterfaceVlan.IsNull() {
+ data.GroupServerTacacsplus[i].IpTacacsSourceInterfaceVlan = types.Int64Value(value.Int())
+ } else {
+ data.GroupServerTacacsplus[i].IpTacacsSourceInterfaceVlan = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(r, "ip/tacacs/source-interface/GigabitEthernet"); value.Exists() && !data.GroupServerTacacsplus[i].IpTacacsSourceInterfaceGigabitEthernet.IsNull() {
+ data.GroupServerTacacsplus[i].IpTacacsSourceInterfaceGigabitEthernet = types.StringValue(value.String())
+ } else {
+ data.GroupServerTacacsplus[i].IpTacacsSourceInterfaceGigabitEthernet = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "ip/tacacs/source-interface/TwoGigabitEthernet"); value.Exists() && !data.GroupServerTacacsplus[i].IpTacacsSourceInterfaceTwoGigabitEthernet.IsNull() {
+ data.GroupServerTacacsplus[i].IpTacacsSourceInterfaceTwoGigabitEthernet = types.StringValue(value.String())
+ } else {
+ data.GroupServerTacacsplus[i].IpTacacsSourceInterfaceTwoGigabitEthernet = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "ip/tacacs/source-interface/FiveGigabitEthernet"); value.Exists() && !data.GroupServerTacacsplus[i].IpTacacsSourceInterfaceFiveGigabitEthernet.IsNull() {
+ data.GroupServerTacacsplus[i].IpTacacsSourceInterfaceFiveGigabitEthernet = types.StringValue(value.String())
+ } else {
+ data.GroupServerTacacsplus[i].IpTacacsSourceInterfaceFiveGigabitEthernet = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "ip/tacacs/source-interface/TenGigabitEthernet"); value.Exists() && !data.GroupServerTacacsplus[i].IpTacacsSourceInterfaceTenGigabitEthernet.IsNull() {
+ data.GroupServerTacacsplus[i].IpTacacsSourceInterfaceTenGigabitEthernet = types.StringValue(value.String())
+ } else {
+ data.GroupServerTacacsplus[i].IpTacacsSourceInterfaceTenGigabitEthernet = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "ip/tacacs/source-interface/TwentyFiveGigE"); value.Exists() && !data.GroupServerTacacsplus[i].IpTacacsSourceInterfaceTwentyFiveGigabitEthernet.IsNull() {
+ data.GroupServerTacacsplus[i].IpTacacsSourceInterfaceTwentyFiveGigabitEthernet = types.StringValue(value.String())
+ } else {
+ data.GroupServerTacacsplus[i].IpTacacsSourceInterfaceTwentyFiveGigabitEthernet = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "ip/tacacs/source-interface/FortyGigabitEthernet"); value.Exists() && !data.GroupServerTacacsplus[i].IpTacacsSourceInterfaceFortyGigabitEthernet.IsNull() {
+ data.GroupServerTacacsplus[i].IpTacacsSourceInterfaceFortyGigabitEthernet = types.StringValue(value.String())
+ } else {
+ data.GroupServerTacacsplus[i].IpTacacsSourceInterfaceFortyGigabitEthernet = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "ip/tacacs/source-interface/HundredGigE"); value.Exists() && !data.GroupServerTacacsplus[i].IpTacacsSourceInterfaceHundredGigabitEthernet.IsNull() {
+ data.GroupServerTacacsplus[i].IpTacacsSourceInterfaceHundredGigabitEthernet = types.StringValue(value.String())
+ } else {
+ data.GroupServerTacacsplus[i].IpTacacsSourceInterfaceHundredGigabitEthernet = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "ip/vrf/forwarding"); value.Exists() && !data.GroupServerTacacsplus[i].Vrf.IsNull() {
+ data.GroupServerTacacsplus[i].Vrf = types.StringValue(value.String())
+ } else {
+ data.GroupServerTacacsplus[i].Vrf = types.StringNull()
+ }
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-aaa:local/authentication/authorization/authen-type"); value.Exists() && !data.LocalAuthenticationType.IsNull() {
+ data.LocalAuthenticationType = types.StringValue(value.String())
+ } else {
+ data.LocalAuthenticationType = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-aaa:local/authentication/authorization/authorization"); value.Exists() && !data.LocalAuthorization.IsNull() {
+ data.LocalAuthorization = types.StringValue(value.String())
+ } else {
+ data.LocalAuthorization = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-aaa:local/authentication/attempts/max-fail"); value.Exists() && !data.LocalAuthenticationMaxFailAttempts.IsNull() {
+ data.LocalAuthenticationMaxFailAttempts = types.Int64Value(value.Int())
+ } else {
+ data.LocalAuthenticationMaxFailAttempts = types.Int64Null()
+ }
+}
+
+// End of section. //template:end updateFromBodyXML
+
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBody
+
+func (data *AAA) fromBody(ctx context.Context, res gjson.Result) {
+ prefix := helpers.LastElement(data.getPath()) + "."
+ if res.Get(helpers.LastElement(data.getPath())).IsArray() {
+ prefix += "0."
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-aaa:new-model"); value.Exists() {
+ data.NewModel = types.BoolValue(true)
+ } else {
+ data.NewModel = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-aaa:server.radius.dynamic-author"); value.Exists() {
+ data.ServerRadiusDynamicAuthor = types.BoolValue(true)
+ } else {
+ data.ServerRadiusDynamicAuthor = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-aaa:session-id"); value.Exists() {
+ data.SessionId = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-aaa:server.radius.dynamic-author.client"); value.Exists() {
+ data.ServerRadiusDynamicAuthorClients = make([]AAAServerRadiusDynamicAuthorClients, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := AAAServerRadiusDynamicAuthorClients{}
+ if cValue := v.Get("ip"); cValue.Exists() {
+ item.Ip = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("server-key.key"); cValue.Exists() {
+ item.ServerKeyType = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("server-key.string"); cValue.Exists() {
+ item.ServerKey = types.StringValue(cValue.String())
+ }
+ data.ServerRadiusDynamicAuthorClients = append(data.ServerRadiusDynamicAuthorClients, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-aaa:group.server.radius"); value.Exists() {
+ data.GroupServerRadius = make([]AAAGroupServerRadius, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := AAAGroupServerRadius{}
+ if cValue := v.Get("name"); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("server.name"); cValue.Exists() {
+ item.ServerNames = make([]AAAGroupServerRadiusServerNames, 0)
+ cValue.ForEach(func(ck, cv gjson.Result) bool {
+ cItem := AAAGroupServerRadiusServerNames{}
+ if ccValue := cv.Get("name"); ccValue.Exists() {
+ cItem.Name = types.StringValue(ccValue.String())
+ }
+ item.ServerNames = append(item.ServerNames, cItem)
+ return true
+ })
+ }
+ if cValue := v.Get("ip.radius.source-interface.Loopback"); cValue.Exists() {
+ item.IpRadiusSourceInterfaceLoopback = types.Int64Value(cValue.Int())
+ }
+ if cValue := v.Get("ip.radius.source-interface.Vlan"); cValue.Exists() {
+ item.IpRadiusSourceInterfaceVlan = types.Int64Value(cValue.Int())
+ }
+ if cValue := v.Get("ip.radius.source-interface.GigabitEthernet"); cValue.Exists() {
+ item.IpRadiusSourceInterfaceGigabitEthernet = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("ip.radius.source-interface.TwoGigabitEthernet"); cValue.Exists() {
+ item.IpRadiusSourceInterfaceTwoGigabitEthernet = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("ip.radius.source-interface.FiveGigabitEthernet"); cValue.Exists() {
+ item.IpRadiusSourceInterfaceFiveGigabitEthernet = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("ip.radius.source-interface.TenGigabitEthernet"); cValue.Exists() {
+ item.IpRadiusSourceInterfaceTenGigabitEthernet = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("ip.radius.source-interface.TwentyFiveGigE"); cValue.Exists() {
+ item.IpRadiusSourceInterfaceTwentyFiveGigabitEthernet = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("ip.radius.source-interface.FortyGigabitEthernet"); cValue.Exists() {
+ item.IpRadiusSourceInterfaceFortyGigabitEthernet = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("ip.radius.source-interface.HundredGigE"); cValue.Exists() {
+ item.IpRadiusSourceInterfaceHundredGigabitEthernet = types.StringValue(cValue.String())
+ }
+ data.GroupServerRadius = append(data.GroupServerRadius, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-aaa:group.server.tacacsplus"); value.Exists() {
+ data.GroupServerTacacsplus = make([]AAAGroupServerTacacsplus, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := AAAGroupServerTacacsplus{}
if cValue := v.Get("name"); cValue.Exists() {
item.Name = types.StringValue(cValue.String())
}
@@ -729,129 +1175,423 @@ func (data *AAAData) fromBody(ctx context.Context, res gjson.Result) {
if cValue := v.Get("ip"); cValue.Exists() {
item.Ip = types.StringValue(cValue.String())
}
- if cValue := v.Get("server-key.key"); cValue.Exists() {
+ if cValue := v.Get("server-key.key"); cValue.Exists() {
+ item.ServerKeyType = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("server-key.string"); cValue.Exists() {
+ item.ServerKey = types.StringValue(cValue.String())
+ }
+ data.ServerRadiusDynamicAuthorClients = append(data.ServerRadiusDynamicAuthorClients, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-aaa:group.server.radius"); value.Exists() {
+ data.GroupServerRadius = make([]AAAGroupServerRadius, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := AAAGroupServerRadius{}
+ if cValue := v.Get("name"); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("server.name"); cValue.Exists() {
+ item.ServerNames = make([]AAAGroupServerRadiusServerNames, 0)
+ cValue.ForEach(func(ck, cv gjson.Result) bool {
+ cItem := AAAGroupServerRadiusServerNames{}
+ if ccValue := cv.Get("name"); ccValue.Exists() {
+ cItem.Name = types.StringValue(ccValue.String())
+ }
+ item.ServerNames = append(item.ServerNames, cItem)
+ return true
+ })
+ }
+ if cValue := v.Get("ip.radius.source-interface.Loopback"); cValue.Exists() {
+ item.IpRadiusSourceInterfaceLoopback = types.Int64Value(cValue.Int())
+ }
+ if cValue := v.Get("ip.radius.source-interface.Vlan"); cValue.Exists() {
+ item.IpRadiusSourceInterfaceVlan = types.Int64Value(cValue.Int())
+ }
+ if cValue := v.Get("ip.radius.source-interface.GigabitEthernet"); cValue.Exists() {
+ item.IpRadiusSourceInterfaceGigabitEthernet = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("ip.radius.source-interface.TwoGigabitEthernet"); cValue.Exists() {
+ item.IpRadiusSourceInterfaceTwoGigabitEthernet = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("ip.radius.source-interface.FiveGigabitEthernet"); cValue.Exists() {
+ item.IpRadiusSourceInterfaceFiveGigabitEthernet = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("ip.radius.source-interface.TenGigabitEthernet"); cValue.Exists() {
+ item.IpRadiusSourceInterfaceTenGigabitEthernet = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("ip.radius.source-interface.TwentyFiveGigE"); cValue.Exists() {
+ item.IpRadiusSourceInterfaceTwentyFiveGigabitEthernet = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("ip.radius.source-interface.FortyGigabitEthernet"); cValue.Exists() {
+ item.IpRadiusSourceInterfaceFortyGigabitEthernet = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("ip.radius.source-interface.HundredGigE"); cValue.Exists() {
+ item.IpRadiusSourceInterfaceHundredGigabitEthernet = types.StringValue(cValue.String())
+ }
+ data.GroupServerRadius = append(data.GroupServerRadius, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-aaa:group.server.tacacsplus"); value.Exists() {
+ data.GroupServerTacacsplus = make([]AAAGroupServerTacacsplus, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := AAAGroupServerTacacsplus{}
+ if cValue := v.Get("name"); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("server.name"); cValue.Exists() {
+ item.ServerNames = make([]AAAGroupServerTacacsplusServerNames, 0)
+ cValue.ForEach(func(ck, cv gjson.Result) bool {
+ cItem := AAAGroupServerTacacsplusServerNames{}
+ if ccValue := cv.Get("name"); ccValue.Exists() {
+ cItem.Name = types.StringValue(ccValue.String())
+ }
+ item.ServerNames = append(item.ServerNames, cItem)
+ return true
+ })
+ }
+ if cValue := v.Get("ip.tacacs.source-interface.Loopback"); cValue.Exists() {
+ item.IpTacacsSourceInterfaceLoopback = types.Int64Value(cValue.Int())
+ }
+ if cValue := v.Get("ip.tacacs.source-interface.Vlan"); cValue.Exists() {
+ item.IpTacacsSourceInterfaceVlan = types.Int64Value(cValue.Int())
+ }
+ if cValue := v.Get("ip.tacacs.source-interface.GigabitEthernet"); cValue.Exists() {
+ item.IpTacacsSourceInterfaceGigabitEthernet = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("ip.tacacs.source-interface.TwoGigabitEthernet"); cValue.Exists() {
+ item.IpTacacsSourceInterfaceTwoGigabitEthernet = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("ip.tacacs.source-interface.FiveGigabitEthernet"); cValue.Exists() {
+ item.IpTacacsSourceInterfaceFiveGigabitEthernet = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("ip.tacacs.source-interface.TenGigabitEthernet"); cValue.Exists() {
+ item.IpTacacsSourceInterfaceTenGigabitEthernet = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("ip.tacacs.source-interface.TwentyFiveGigE"); cValue.Exists() {
+ item.IpTacacsSourceInterfaceTwentyFiveGigabitEthernet = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("ip.tacacs.source-interface.FortyGigabitEthernet"); cValue.Exists() {
+ item.IpTacacsSourceInterfaceFortyGigabitEthernet = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("ip.tacacs.source-interface.HundredGigE"); cValue.Exists() {
+ item.IpTacacsSourceInterfaceHundredGigabitEthernet = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("ip.vrf.forwarding"); cValue.Exists() {
+ item.Vrf = types.StringValue(cValue.String())
+ }
+ data.GroupServerTacacsplus = append(data.GroupServerTacacsplus, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-aaa:local.authentication.authorization.authen-type"); value.Exists() {
+ data.LocalAuthenticationType = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-aaa:local.authentication.authorization.authorization"); value.Exists() {
+ data.LocalAuthorization = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-aaa:local.authentication.attempts.max-fail"); value.Exists() {
+ data.LocalAuthenticationMaxFailAttempts = types.Int64Value(value.Int())
+ }
+}
+
+// End of section. //template:end fromBodyData
+
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyXML
+
+func (data *AAA) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-aaa:new-model"); value.Exists() {
+ data.NewModel = types.BoolValue(true)
+ } else {
+ data.NewModel = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-aaa:server/radius/dynamic-author"); value.Exists() {
+ data.ServerRadiusDynamicAuthor = types.BoolValue(true)
+ } else {
+ data.ServerRadiusDynamicAuthor = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-aaa:session-id"); value.Exists() {
+ data.SessionId = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-aaa:server/radius/dynamic-author/client"); value.Exists() {
+ data.ServerRadiusDynamicAuthorClients = make([]AAAServerRadiusDynamicAuthorClients, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := AAAServerRadiusDynamicAuthorClients{}
+ if cValue := helpers.GetFromXPath(v, "ip"); cValue.Exists() {
+ item.Ip = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "server-key/key"); cValue.Exists() {
+ item.ServerKeyType = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "server-key/string"); cValue.Exists() {
+ item.ServerKey = types.StringValue(cValue.String())
+ }
+ data.ServerRadiusDynamicAuthorClients = append(data.ServerRadiusDynamicAuthorClients, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-aaa:group/server/radius"); value.Exists() {
+ data.GroupServerRadius = make([]AAAGroupServerRadius, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := AAAGroupServerRadius{}
+ if cValue := helpers.GetFromXPath(v, "name"); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "server/name"); cValue.Exists() {
+ item.ServerNames = make([]AAAGroupServerRadiusServerNames, 0)
+ cValue.ForEach(func(_ int, cv xmldot.Result) bool {
+ cItem := AAAGroupServerRadiusServerNames{}
+ if ccValue := helpers.GetFromXPath(cv, "name"); ccValue.Exists() {
+ cItem.Name = types.StringValue(ccValue.String())
+ }
+ item.ServerNames = append(item.ServerNames, cItem)
+ return true
+ })
+ }
+ if cValue := helpers.GetFromXPath(v, "ip/radius/source-interface/Loopback"); cValue.Exists() {
+ item.IpRadiusSourceInterfaceLoopback = types.Int64Value(cValue.Int())
+ }
+ if cValue := helpers.GetFromXPath(v, "ip/radius/source-interface/Vlan"); cValue.Exists() {
+ item.IpRadiusSourceInterfaceVlan = types.Int64Value(cValue.Int())
+ }
+ if cValue := helpers.GetFromXPath(v, "ip/radius/source-interface/GigabitEthernet"); cValue.Exists() {
+ item.IpRadiusSourceInterfaceGigabitEthernet = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "ip/radius/source-interface/TwoGigabitEthernet"); cValue.Exists() {
+ item.IpRadiusSourceInterfaceTwoGigabitEthernet = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "ip/radius/source-interface/FiveGigabitEthernet"); cValue.Exists() {
+ item.IpRadiusSourceInterfaceFiveGigabitEthernet = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "ip/radius/source-interface/TenGigabitEthernet"); cValue.Exists() {
+ item.IpRadiusSourceInterfaceTenGigabitEthernet = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "ip/radius/source-interface/TwentyFiveGigE"); cValue.Exists() {
+ item.IpRadiusSourceInterfaceTwentyFiveGigabitEthernet = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "ip/radius/source-interface/FortyGigabitEthernet"); cValue.Exists() {
+ item.IpRadiusSourceInterfaceFortyGigabitEthernet = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "ip/radius/source-interface/HundredGigE"); cValue.Exists() {
+ item.IpRadiusSourceInterfaceHundredGigabitEthernet = types.StringValue(cValue.String())
+ }
+ data.GroupServerRadius = append(data.GroupServerRadius, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-aaa:group/server/tacacsplus"); value.Exists() {
+ data.GroupServerTacacsplus = make([]AAAGroupServerTacacsplus, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := AAAGroupServerTacacsplus{}
+ if cValue := helpers.GetFromXPath(v, "name"); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "server/name"); cValue.Exists() {
+ item.ServerNames = make([]AAAGroupServerTacacsplusServerNames, 0)
+ cValue.ForEach(func(_ int, cv xmldot.Result) bool {
+ cItem := AAAGroupServerTacacsplusServerNames{}
+ if ccValue := helpers.GetFromXPath(cv, "name"); ccValue.Exists() {
+ cItem.Name = types.StringValue(ccValue.String())
+ }
+ item.ServerNames = append(item.ServerNames, cItem)
+ return true
+ })
+ }
+ if cValue := helpers.GetFromXPath(v, "ip/tacacs/source-interface/Loopback"); cValue.Exists() {
+ item.IpTacacsSourceInterfaceLoopback = types.Int64Value(cValue.Int())
+ }
+ if cValue := helpers.GetFromXPath(v, "ip/tacacs/source-interface/Vlan"); cValue.Exists() {
+ item.IpTacacsSourceInterfaceVlan = types.Int64Value(cValue.Int())
+ }
+ if cValue := helpers.GetFromXPath(v, "ip/tacacs/source-interface/GigabitEthernet"); cValue.Exists() {
+ item.IpTacacsSourceInterfaceGigabitEthernet = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "ip/tacacs/source-interface/TwoGigabitEthernet"); cValue.Exists() {
+ item.IpTacacsSourceInterfaceTwoGigabitEthernet = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "ip/tacacs/source-interface/FiveGigabitEthernet"); cValue.Exists() {
+ item.IpTacacsSourceInterfaceFiveGigabitEthernet = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "ip/tacacs/source-interface/TenGigabitEthernet"); cValue.Exists() {
+ item.IpTacacsSourceInterfaceTenGigabitEthernet = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "ip/tacacs/source-interface/TwentyFiveGigE"); cValue.Exists() {
+ item.IpTacacsSourceInterfaceTwentyFiveGigabitEthernet = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "ip/tacacs/source-interface/FortyGigabitEthernet"); cValue.Exists() {
+ item.IpTacacsSourceInterfaceFortyGigabitEthernet = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "ip/tacacs/source-interface/HundredGigE"); cValue.Exists() {
+ item.IpTacacsSourceInterfaceHundredGigabitEthernet = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "ip/vrf/forwarding"); cValue.Exists() {
+ item.Vrf = types.StringValue(cValue.String())
+ }
+ data.GroupServerTacacsplus = append(data.GroupServerTacacsplus, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-aaa:local/authentication/authorization/authen-type"); value.Exists() {
+ data.LocalAuthenticationType = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-aaa:local/authentication/authorization/authorization"); value.Exists() {
+ data.LocalAuthorization = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-aaa:local/authentication/attempts/max-fail"); value.Exists() {
+ data.LocalAuthenticationMaxFailAttempts = types.Int64Value(value.Int())
+ }
+}
+
+// End of section. //template:end fromBodyXML
+
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyDataXML
+
+func (data *AAAData) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-aaa:new-model"); value.Exists() {
+ data.NewModel = types.BoolValue(true)
+ } else {
+ data.NewModel = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-aaa:server/radius/dynamic-author"); value.Exists() {
+ data.ServerRadiusDynamicAuthor = types.BoolValue(true)
+ } else {
+ data.ServerRadiusDynamicAuthor = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-aaa:session-id"); value.Exists() {
+ data.SessionId = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-aaa:server/radius/dynamic-author/client"); value.Exists() {
+ data.ServerRadiusDynamicAuthorClients = make([]AAAServerRadiusDynamicAuthorClients, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := AAAServerRadiusDynamicAuthorClients{}
+ if cValue := helpers.GetFromXPath(v, "ip"); cValue.Exists() {
+ item.Ip = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "server-key/key"); cValue.Exists() {
item.ServerKeyType = types.StringValue(cValue.String())
}
- if cValue := v.Get("server-key.string"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "server-key/string"); cValue.Exists() {
item.ServerKey = types.StringValue(cValue.String())
}
data.ServerRadiusDynamicAuthorClients = append(data.ServerRadiusDynamicAuthorClients, item)
return true
})
}
- if value := res.Get(prefix + "Cisco-IOS-XE-aaa:group.server.radius"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-aaa:group/server/radius"); value.Exists() {
data.GroupServerRadius = make([]AAAGroupServerRadius, 0)
- value.ForEach(func(k, v gjson.Result) bool {
+ value.ForEach(func(_ int, v xmldot.Result) bool {
item := AAAGroupServerRadius{}
- if cValue := v.Get("name"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "name"); cValue.Exists() {
item.Name = types.StringValue(cValue.String())
}
- if cValue := v.Get("server.name"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "server/name"); cValue.Exists() {
item.ServerNames = make([]AAAGroupServerRadiusServerNames, 0)
- cValue.ForEach(func(ck, cv gjson.Result) bool {
+ cValue.ForEach(func(_ int, cv xmldot.Result) bool {
cItem := AAAGroupServerRadiusServerNames{}
- if ccValue := cv.Get("name"); ccValue.Exists() {
+ if ccValue := helpers.GetFromXPath(cv, "name"); ccValue.Exists() {
cItem.Name = types.StringValue(ccValue.String())
}
item.ServerNames = append(item.ServerNames, cItem)
return true
})
}
- if cValue := v.Get("ip.radius.source-interface.Loopback"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ip/radius/source-interface/Loopback"); cValue.Exists() {
item.IpRadiusSourceInterfaceLoopback = types.Int64Value(cValue.Int())
}
- if cValue := v.Get("ip.radius.source-interface.Vlan"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ip/radius/source-interface/Vlan"); cValue.Exists() {
item.IpRadiusSourceInterfaceVlan = types.Int64Value(cValue.Int())
}
- if cValue := v.Get("ip.radius.source-interface.GigabitEthernet"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ip/radius/source-interface/GigabitEthernet"); cValue.Exists() {
item.IpRadiusSourceInterfaceGigabitEthernet = types.StringValue(cValue.String())
}
- if cValue := v.Get("ip.radius.source-interface.TwoGigabitEthernet"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ip/radius/source-interface/TwoGigabitEthernet"); cValue.Exists() {
item.IpRadiusSourceInterfaceTwoGigabitEthernet = types.StringValue(cValue.String())
}
- if cValue := v.Get("ip.radius.source-interface.FiveGigabitEthernet"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ip/radius/source-interface/FiveGigabitEthernet"); cValue.Exists() {
item.IpRadiusSourceInterfaceFiveGigabitEthernet = types.StringValue(cValue.String())
}
- if cValue := v.Get("ip.radius.source-interface.TenGigabitEthernet"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ip/radius/source-interface/TenGigabitEthernet"); cValue.Exists() {
item.IpRadiusSourceInterfaceTenGigabitEthernet = types.StringValue(cValue.String())
}
- if cValue := v.Get("ip.radius.source-interface.TwentyFiveGigE"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ip/radius/source-interface/TwentyFiveGigE"); cValue.Exists() {
item.IpRadiusSourceInterfaceTwentyFiveGigabitEthernet = types.StringValue(cValue.String())
}
- if cValue := v.Get("ip.radius.source-interface.FortyGigabitEthernet"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ip/radius/source-interface/FortyGigabitEthernet"); cValue.Exists() {
item.IpRadiusSourceInterfaceFortyGigabitEthernet = types.StringValue(cValue.String())
}
- if cValue := v.Get("ip.radius.source-interface.HundredGigE"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ip/radius/source-interface/HundredGigE"); cValue.Exists() {
item.IpRadiusSourceInterfaceHundredGigabitEthernet = types.StringValue(cValue.String())
}
data.GroupServerRadius = append(data.GroupServerRadius, item)
return true
})
}
- if value := res.Get(prefix + "Cisco-IOS-XE-aaa:group.server.tacacsplus"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-aaa:group/server/tacacsplus"); value.Exists() {
data.GroupServerTacacsplus = make([]AAAGroupServerTacacsplus, 0)
- value.ForEach(func(k, v gjson.Result) bool {
+ value.ForEach(func(_ int, v xmldot.Result) bool {
item := AAAGroupServerTacacsplus{}
- if cValue := v.Get("name"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "name"); cValue.Exists() {
item.Name = types.StringValue(cValue.String())
}
- if cValue := v.Get("server.name"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "server/name"); cValue.Exists() {
item.ServerNames = make([]AAAGroupServerTacacsplusServerNames, 0)
- cValue.ForEach(func(ck, cv gjson.Result) bool {
+ cValue.ForEach(func(_ int, cv xmldot.Result) bool {
cItem := AAAGroupServerTacacsplusServerNames{}
- if ccValue := cv.Get("name"); ccValue.Exists() {
+ if ccValue := helpers.GetFromXPath(cv, "name"); ccValue.Exists() {
cItem.Name = types.StringValue(ccValue.String())
}
item.ServerNames = append(item.ServerNames, cItem)
return true
})
}
- if cValue := v.Get("ip.tacacs.source-interface.Loopback"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ip/tacacs/source-interface/Loopback"); cValue.Exists() {
item.IpTacacsSourceInterfaceLoopback = types.Int64Value(cValue.Int())
}
- if cValue := v.Get("ip.tacacs.source-interface.Vlan"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ip/tacacs/source-interface/Vlan"); cValue.Exists() {
item.IpTacacsSourceInterfaceVlan = types.Int64Value(cValue.Int())
}
- if cValue := v.Get("ip.tacacs.source-interface.GigabitEthernet"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ip/tacacs/source-interface/GigabitEthernet"); cValue.Exists() {
item.IpTacacsSourceInterfaceGigabitEthernet = types.StringValue(cValue.String())
}
- if cValue := v.Get("ip.tacacs.source-interface.TwoGigabitEthernet"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ip/tacacs/source-interface/TwoGigabitEthernet"); cValue.Exists() {
item.IpTacacsSourceInterfaceTwoGigabitEthernet = types.StringValue(cValue.String())
}
- if cValue := v.Get("ip.tacacs.source-interface.FiveGigabitEthernet"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ip/tacacs/source-interface/FiveGigabitEthernet"); cValue.Exists() {
item.IpTacacsSourceInterfaceFiveGigabitEthernet = types.StringValue(cValue.String())
}
- if cValue := v.Get("ip.tacacs.source-interface.TenGigabitEthernet"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ip/tacacs/source-interface/TenGigabitEthernet"); cValue.Exists() {
item.IpTacacsSourceInterfaceTenGigabitEthernet = types.StringValue(cValue.String())
}
- if cValue := v.Get("ip.tacacs.source-interface.TwentyFiveGigE"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ip/tacacs/source-interface/TwentyFiveGigE"); cValue.Exists() {
item.IpTacacsSourceInterfaceTwentyFiveGigabitEthernet = types.StringValue(cValue.String())
}
- if cValue := v.Get("ip.tacacs.source-interface.FortyGigabitEthernet"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ip/tacacs/source-interface/FortyGigabitEthernet"); cValue.Exists() {
item.IpTacacsSourceInterfaceFortyGigabitEthernet = types.StringValue(cValue.String())
}
- if cValue := v.Get("ip.tacacs.source-interface.HundredGigE"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ip/tacacs/source-interface/HundredGigE"); cValue.Exists() {
item.IpTacacsSourceInterfaceHundredGigabitEthernet = types.StringValue(cValue.String())
}
- if cValue := v.Get("ip.vrf.forwarding"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ip/vrf/forwarding"); cValue.Exists() {
item.Vrf = types.StringValue(cValue.String())
}
data.GroupServerTacacsplus = append(data.GroupServerTacacsplus, item)
return true
})
}
- if value := res.Get(prefix + "Cisco-IOS-XE-aaa:local.authentication.authorization.authen-type"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-aaa:local/authentication/authorization/authen-type"); value.Exists() {
data.LocalAuthenticationType = types.StringValue(value.String())
}
- if value := res.Get(prefix + "Cisco-IOS-XE-aaa:local.authentication.authorization.authorization"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-aaa:local/authentication/authorization/authorization"); value.Exists() {
data.LocalAuthorization = types.StringValue(value.String())
}
- if value := res.Get(prefix + "Cisco-IOS-XE-aaa:local.authentication.attempts.max-fail"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-aaa:local/authentication/attempts/max-fail"); value.Exists() {
data.LocalAuthenticationMaxFailAttempts = types.Int64Value(value.Int())
}
}
-// End of section. //template:end fromBodyData
+// End of section. //template:end fromBodyDataXML
// Section below is generated&owned by "gen/generator.go". //template:begin getDeletedItems
@@ -1069,6 +1809,247 @@ func (data *AAA) getDeletedItems(ctx context.Context, state AAA) []string {
// End of section. //template:end getDeletedItems
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletedItemsXML
+
+func (data *AAA) addDeletedItemsXML(ctx context.Context, state AAA, body string) string {
+ b := netconf.NewBody(body)
+ if !state.NewModel.IsNull() && data.NewModel.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-aaa:new-model")
+ }
+ if !state.ServerRadiusDynamicAuthor.IsNull() && data.ServerRadiusDynamicAuthor.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-aaa:server/radius/dynamic-author")
+ }
+ if !state.SessionId.IsNull() && data.SessionId.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-aaa:session-id")
+ }
+ for i := range state.ServerRadiusDynamicAuthorClients {
+ stateKeys := [...]string{"ip"}
+ stateKeyValues := [...]string{state.ServerRadiusDynamicAuthorClients[i].Ip.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.ServerRadiusDynamicAuthorClients[i].Ip.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.ServerRadiusDynamicAuthorClients {
+ found = true
+ if state.ServerRadiusDynamicAuthorClients[i].Ip.ValueString() != data.ServerRadiusDynamicAuthorClients[j].Ip.ValueString() {
+ found = false
+ }
+ if found {
+ if !state.ServerRadiusDynamicAuthorClients[i].ServerKeyType.IsNull() && data.ServerRadiusDynamicAuthorClients[j].ServerKeyType.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-aaa:server/radius/dynamic-author/client%v/server-key/key", predicates))
+ }
+ if !state.ServerRadiusDynamicAuthorClients[i].ServerKey.IsNull() && data.ServerRadiusDynamicAuthorClients[j].ServerKey.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-aaa:server/radius/dynamic-author/client%v/server-key/string", predicates))
+ }
+ break
+ }
+ }
+ if !found {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-aaa:server/radius/dynamic-author/client%v", predicates))
+ }
+ }
+ for i := range state.GroupServerRadius {
+ stateKeys := [...]string{"name"}
+ stateKeyValues := [...]string{state.GroupServerRadius[i].Name.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.GroupServerRadius[i].Name.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.GroupServerRadius {
+ found = true
+ if state.GroupServerRadius[i].Name.ValueString() != data.GroupServerRadius[j].Name.ValueString() {
+ found = false
+ }
+ if found {
+ for ci := range state.GroupServerRadius[i].ServerNames {
+ cstateKeys := [...]string{"name"}
+ cstateKeyValues := [...]string{state.GroupServerRadius[i].ServerNames[ci].Name.ValueString()}
+ cpredicates := ""
+ for i := range cstateKeys {
+ cpredicates += fmt.Sprintf("[%s='%s']", cstateKeys[i], cstateKeyValues[i])
+ }
+
+ cemptyKeys := true
+ if !reflect.ValueOf(state.GroupServerRadius[i].ServerNames[ci].Name.ValueString()).IsZero() {
+ cemptyKeys = false
+ }
+ if cemptyKeys {
+ continue
+ }
+
+ found := false
+ for cj := range data.GroupServerRadius[j].ServerNames {
+ found = true
+ if state.GroupServerRadius[i].ServerNames[ci].Name.ValueString() != data.GroupServerRadius[j].ServerNames[cj].Name.ValueString() {
+ found = false
+ }
+ if found {
+ break
+ }
+ }
+ if !found {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-aaa:group/server/radius%v/server/name%v", predicates, cpredicates))
+ }
+ }
+ if !state.GroupServerRadius[i].IpRadiusSourceInterfaceLoopback.IsNull() && data.GroupServerRadius[j].IpRadiusSourceInterfaceLoopback.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-aaa:group/server/radius%v/ip/radius/source-interface/Loopback", predicates))
+ }
+ if !state.GroupServerRadius[i].IpRadiusSourceInterfaceVlan.IsNull() && data.GroupServerRadius[j].IpRadiusSourceInterfaceVlan.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-aaa:group/server/radius%v/ip/radius/source-interface/Vlan", predicates))
+ }
+ if !state.GroupServerRadius[i].IpRadiusSourceInterfaceGigabitEthernet.IsNull() && data.GroupServerRadius[j].IpRadiusSourceInterfaceGigabitEthernet.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-aaa:group/server/radius%v/ip/radius/source-interface/GigabitEthernet", predicates))
+ }
+ if !state.GroupServerRadius[i].IpRadiusSourceInterfaceTwoGigabitEthernet.IsNull() && data.GroupServerRadius[j].IpRadiusSourceInterfaceTwoGigabitEthernet.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-aaa:group/server/radius%v/ip/radius/source-interface/TwoGigabitEthernet", predicates))
+ }
+ if !state.GroupServerRadius[i].IpRadiusSourceInterfaceFiveGigabitEthernet.IsNull() && data.GroupServerRadius[j].IpRadiusSourceInterfaceFiveGigabitEthernet.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-aaa:group/server/radius%v/ip/radius/source-interface/FiveGigabitEthernet", predicates))
+ }
+ if !state.GroupServerRadius[i].IpRadiusSourceInterfaceTenGigabitEthernet.IsNull() && data.GroupServerRadius[j].IpRadiusSourceInterfaceTenGigabitEthernet.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-aaa:group/server/radius%v/ip/radius/source-interface/TenGigabitEthernet", predicates))
+ }
+ if !state.GroupServerRadius[i].IpRadiusSourceInterfaceTwentyFiveGigabitEthernet.IsNull() && data.GroupServerRadius[j].IpRadiusSourceInterfaceTwentyFiveGigabitEthernet.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-aaa:group/server/radius%v/ip/radius/source-interface/TwentyFiveGigE", predicates))
+ }
+ if !state.GroupServerRadius[i].IpRadiusSourceInterfaceFortyGigabitEthernet.IsNull() && data.GroupServerRadius[j].IpRadiusSourceInterfaceFortyGigabitEthernet.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-aaa:group/server/radius%v/ip/radius/source-interface/FortyGigabitEthernet", predicates))
+ }
+ if !state.GroupServerRadius[i].IpRadiusSourceInterfaceHundredGigabitEthernet.IsNull() && data.GroupServerRadius[j].IpRadiusSourceInterfaceHundredGigabitEthernet.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-aaa:group/server/radius%v/ip/radius/source-interface/HundredGigE", predicates))
+ }
+ break
+ }
+ }
+ if !found {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-aaa:group/server/radius%v", predicates))
+ }
+ }
+ for i := range state.GroupServerTacacsplus {
+ stateKeys := [...]string{"name"}
+ stateKeyValues := [...]string{state.GroupServerTacacsplus[i].Name.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.GroupServerTacacsplus[i].Name.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.GroupServerTacacsplus {
+ found = true
+ if state.GroupServerTacacsplus[i].Name.ValueString() != data.GroupServerTacacsplus[j].Name.ValueString() {
+ found = false
+ }
+ if found {
+ for ci := range state.GroupServerTacacsplus[i].ServerNames {
+ cstateKeys := [...]string{"name"}
+ cstateKeyValues := [...]string{state.GroupServerTacacsplus[i].ServerNames[ci].Name.ValueString()}
+ cpredicates := ""
+ for i := range cstateKeys {
+ cpredicates += fmt.Sprintf("[%s='%s']", cstateKeys[i], cstateKeyValues[i])
+ }
+
+ cemptyKeys := true
+ if !reflect.ValueOf(state.GroupServerTacacsplus[i].ServerNames[ci].Name.ValueString()).IsZero() {
+ cemptyKeys = false
+ }
+ if cemptyKeys {
+ continue
+ }
+
+ found := false
+ for cj := range data.GroupServerTacacsplus[j].ServerNames {
+ found = true
+ if state.GroupServerTacacsplus[i].ServerNames[ci].Name.ValueString() != data.GroupServerTacacsplus[j].ServerNames[cj].Name.ValueString() {
+ found = false
+ }
+ if found {
+ break
+ }
+ }
+ if !found {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-aaa:group/server/tacacsplus%v/server/name%v", predicates, cpredicates))
+ }
+ }
+ if !state.GroupServerTacacsplus[i].IpTacacsSourceInterfaceLoopback.IsNull() && data.GroupServerTacacsplus[j].IpTacacsSourceInterfaceLoopback.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-aaa:group/server/tacacsplus%v/ip/tacacs/source-interface/Loopback", predicates))
+ }
+ if !state.GroupServerTacacsplus[i].IpTacacsSourceInterfaceVlan.IsNull() && data.GroupServerTacacsplus[j].IpTacacsSourceInterfaceVlan.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-aaa:group/server/tacacsplus%v/ip/tacacs/source-interface/Vlan", predicates))
+ }
+ if !state.GroupServerTacacsplus[i].IpTacacsSourceInterfaceGigabitEthernet.IsNull() && data.GroupServerTacacsplus[j].IpTacacsSourceInterfaceGigabitEthernet.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-aaa:group/server/tacacsplus%v/ip/tacacs/source-interface/GigabitEthernet", predicates))
+ }
+ if !state.GroupServerTacacsplus[i].IpTacacsSourceInterfaceTwoGigabitEthernet.IsNull() && data.GroupServerTacacsplus[j].IpTacacsSourceInterfaceTwoGigabitEthernet.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-aaa:group/server/tacacsplus%v/ip/tacacs/source-interface/TwoGigabitEthernet", predicates))
+ }
+ if !state.GroupServerTacacsplus[i].IpTacacsSourceInterfaceFiveGigabitEthernet.IsNull() && data.GroupServerTacacsplus[j].IpTacacsSourceInterfaceFiveGigabitEthernet.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-aaa:group/server/tacacsplus%v/ip/tacacs/source-interface/FiveGigabitEthernet", predicates))
+ }
+ if !state.GroupServerTacacsplus[i].IpTacacsSourceInterfaceTenGigabitEthernet.IsNull() && data.GroupServerTacacsplus[j].IpTacacsSourceInterfaceTenGigabitEthernet.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-aaa:group/server/tacacsplus%v/ip/tacacs/source-interface/TenGigabitEthernet", predicates))
+ }
+ if !state.GroupServerTacacsplus[i].IpTacacsSourceInterfaceTwentyFiveGigabitEthernet.IsNull() && data.GroupServerTacacsplus[j].IpTacacsSourceInterfaceTwentyFiveGigabitEthernet.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-aaa:group/server/tacacsplus%v/ip/tacacs/source-interface/TwentyFiveGigE", predicates))
+ }
+ if !state.GroupServerTacacsplus[i].IpTacacsSourceInterfaceFortyGigabitEthernet.IsNull() && data.GroupServerTacacsplus[j].IpTacacsSourceInterfaceFortyGigabitEthernet.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-aaa:group/server/tacacsplus%v/ip/tacacs/source-interface/FortyGigabitEthernet", predicates))
+ }
+ if !state.GroupServerTacacsplus[i].IpTacacsSourceInterfaceHundredGigabitEthernet.IsNull() && data.GroupServerTacacsplus[j].IpTacacsSourceInterfaceHundredGigabitEthernet.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-aaa:group/server/tacacsplus%v/ip/tacacs/source-interface/HundredGigE", predicates))
+ }
+ if !state.GroupServerTacacsplus[i].Vrf.IsNull() && data.GroupServerTacacsplus[j].Vrf.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-aaa:group/server/tacacsplus%v/ip/vrf/forwarding", predicates))
+ }
+ break
+ }
+ }
+ if !found {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-aaa:group/server/tacacsplus%v", predicates))
+ }
+ }
+ if !state.LocalAuthenticationType.IsNull() && data.LocalAuthenticationType.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-aaa:local/authentication/authorization/authen-type")
+ }
+ if !state.LocalAuthorization.IsNull() && data.LocalAuthorization.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-aaa:local/authentication/authorization/authorization")
+ }
+ if !state.LocalAuthenticationMaxFailAttempts.IsNull() && data.LocalAuthenticationMaxFailAttempts.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-aaa:local/authentication/attempts/max-fail")
+ }
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletedItemsXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin getEmptyLeafsDelete
func (data *AAA) getEmptyLeafsDelete(ctx context.Context) []string {
@@ -1128,3 +2109,61 @@ func (data *AAA) getDeletePaths(ctx context.Context) []string {
}
// End of section. //template:end getDeletePaths
+
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletePathsXML
+
+func (data *AAA) addDeletePathsXML(ctx context.Context, body string) string {
+ b := netconf.NewBody(body)
+ if !data.NewModel.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-aaa:new-model")
+ }
+ if !data.ServerRadiusDynamicAuthor.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-aaa:server/radius/dynamic-author")
+ }
+ if !data.SessionId.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-aaa:session-id")
+ }
+ for i := range data.ServerRadiusDynamicAuthorClients {
+ keys := [...]string{"ip"}
+ keyValues := [...]string{data.ServerRadiusDynamicAuthorClients[i].Ip.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/Cisco-IOS-XE-aaa:server/radius/dynamic-author/client%v", predicates))
+ }
+ for i := range data.GroupServerRadius {
+ keys := [...]string{"name"}
+ keyValues := [...]string{data.GroupServerRadius[i].Name.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/Cisco-IOS-XE-aaa:group/server/radius%v", predicates))
+ }
+ for i := range data.GroupServerTacacsplus {
+ keys := [...]string{"name"}
+ keyValues := [...]string{data.GroupServerTacacsplus[i].Name.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/Cisco-IOS-XE-aaa:group/server/tacacsplus%v", predicates))
+ }
+ if !data.LocalAuthenticationType.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-aaa:local/authentication/authorization/authen-type")
+ }
+ if !data.LocalAuthorization.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-aaa:local/authentication/authorization/authorization")
+ }
+ if !data.LocalAuthenticationMaxFailAttempts.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-aaa:local/authentication/attempts/max-fail")
+ }
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletePathsXML
diff --git a/internal/provider/model_iosxe_aaa_accounting.go b/internal/provider/model_iosxe_aaa_accounting.go
index 2db4d7f6..e93e63ee 100644
--- a/internal/provider/model_iosxe_aaa_accounting.go
+++ b/internal/provider/model_iosxe_aaa_accounting.go
@@ -30,6 +30,9 @@ import (
"github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/types"
+ "github.com/hashicorp/terraform-plugin-log/tflog"
+ "github.com/netascode/go-netconf"
+ "github.com/netascode/xmldot"
"github.com/tidwall/gjson"
"github.com/tidwall/sjson"
)
@@ -165,6 +168,17 @@ func (data AAAAccounting) getPathShort() string {
return matches[1]
}
+// getXPath returns the XPath for NETCONF operations
+func (data AAAAccounting) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/aaa/Cisco-IOS-XE-aaa:accounting"
+ return path
+}
+
+func (data AAAAccountingData) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/aaa/Cisco-IOS-XE-aaa:accounting"
+ return path
+}
+
// End of section. //template:end getPath
// Section below is generated&owned by "gen/generator.go". //template:begin toBody
@@ -447,6 +461,337 @@ func (data AAAAccounting) toBody(ctx context.Context) string {
// End of section. //template:end toBody
+// Section below is generated&owned by "gen/generator.go". //template:begin toBodyXML
+
+func (data AAAAccounting) toBodyXML(ctx context.Context) string {
+ body := netconf.Body{}
+ if !data.UpdateNewinfoPeriodic.IsNull() && !data.UpdateNewinfoPeriodic.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/update/newinfo/periodic", strconv.FormatInt(data.UpdateNewinfoPeriodic.ValueInt64(), 10))
+ }
+ if len(data.Identities) > 0 {
+ for _, item := range data.Identities {
+ cBody := netconf.Body{}
+ if !item.Name.IsNull() && !item.Name.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "name", item.Name.ValueString())
+ }
+ if !item.StartStopBroadcast.IsNull() && !item.StartStopBroadcast.IsUnknown() {
+ if item.StartStopBroadcast.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "start-stop/broadcast", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "start-stop/broadcast")
+ }
+ }
+ if !item.StartStopGroupBroadcast.IsNull() && !item.StartStopGroupBroadcast.IsUnknown() {
+ if item.StartStopGroupBroadcast.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "start-stop/group-config/broadcast", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "start-stop/group-config/broadcast")
+ }
+ }
+ if !item.StartStopGroupLogger.IsNull() && !item.StartStopGroupLogger.IsUnknown() {
+ if item.StartStopGroupLogger.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "start-stop/group-config/logger", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "start-stop/group-config/logger")
+ }
+ }
+ if !item.StartStopGroup1.IsNull() && !item.StartStopGroup1.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "start-stop/group-config/group1/group", item.StartStopGroup1.ValueString())
+ }
+ if !item.StartStopGroup2.IsNull() && !item.StartStopGroup2.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "start-stop/group-config/group2/group", item.StartStopGroup2.ValueString())
+ }
+ if !item.StartStopGroup3.IsNull() && !item.StartStopGroup3.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "start-stop/group-config/group3/group", item.StartStopGroup3.ValueString())
+ }
+ if !item.StartStopGroup4.IsNull() && !item.StartStopGroup4.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "start-stop/group-config/group4/group", item.StartStopGroup4.ValueString())
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/identity/accounting-list", cBody.Res())
+ }
+ }
+ if !data.IdentityDefaultStartStopGroup1.IsNull() && !data.IdentityDefaultStartStopGroup1.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/identity/default/start-stop/group-config/group1/group", data.IdentityDefaultStartStopGroup1.ValueString())
+ }
+ if !data.IdentityDefaultStartStopGroup2.IsNull() && !data.IdentityDefaultStartStopGroup2.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/identity/default/start-stop/group-config/group2/group", data.IdentityDefaultStartStopGroup2.ValueString())
+ }
+ if !data.IdentityDefaultStartStopGroup3.IsNull() && !data.IdentityDefaultStartStopGroup3.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/identity/default/start-stop/group-config/group3/group", data.IdentityDefaultStartStopGroup3.ValueString())
+ }
+ if !data.IdentityDefaultStartStopGroup4.IsNull() && !data.IdentityDefaultStartStopGroup4.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/identity/default/start-stop/group-config/group4/group", data.IdentityDefaultStartStopGroup4.ValueString())
+ }
+ if len(data.Networks) > 0 {
+ for _, item := range data.Networks {
+ cBody := netconf.Body{}
+ if !item.Id.IsNull() && !item.Id.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "id", item.Id.ValueString())
+ }
+ if !item.StartStopGroup1.IsNull() && !item.StartStopGroup1.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "start-stop/group-config/group1/group", item.StartStopGroup1.ValueString())
+ }
+ if !item.StartStopGroup2.IsNull() && !item.StartStopGroup2.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "start-stop/group-config/group2/group", item.StartStopGroup2.ValueString())
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/network", cBody.Res())
+ }
+ }
+ if !data.SystemGuaranteeFirst.IsNull() && !data.SystemGuaranteeFirst.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/system/guarantee-first", data.SystemGuaranteeFirst.ValueBool())
+ }
+ if len(data.Commands) > 0 {
+ for _, item := range data.Commands {
+ cBody := netconf.Body{}
+ if !item.Level.IsNull() && !item.Level.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "level", strconv.FormatInt(item.Level.ValueInt64(), 10))
+ }
+ if !item.ListName.IsNull() && !item.ListName.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "list-name", item.ListName.ValueString())
+ }
+ if !item.ActionType.IsNull() && !item.ActionType.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "commands-config/action-type", item.ActionType.ValueString())
+ }
+ if !item.Broadcast.IsNull() && !item.Broadcast.IsUnknown() {
+ if item.Broadcast.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "commands-config/broadcast", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "commands-config/broadcast")
+ }
+ }
+ if !item.GroupBroadcast.IsNull() && !item.GroupBroadcast.IsUnknown() {
+ if item.GroupBroadcast.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "commands-config/group-config/broadcast", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "commands-config/group-config/broadcast")
+ }
+ }
+ if !item.GroupLogger.IsNull() && !item.GroupLogger.IsUnknown() {
+ if item.GroupLogger.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "commands-config/group-config/logger", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "commands-config/group-config/logger")
+ }
+ }
+ if !item.Group1Group.IsNull() && !item.Group1Group.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "commands-config/group-config/group1/group", item.Group1Group.ValueString())
+ }
+ if !item.Group2Group.IsNull() && !item.Group2Group.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "commands-config/group-config/group2/group", item.Group2Group.ValueString())
+ }
+ if !item.Group3Group.IsNull() && !item.Group3Group.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "commands-config/group-config/group3/group", item.Group3Group.ValueString())
+ }
+ if !item.Group4Group.IsNull() && !item.Group4Group.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "commands-config/group-config/group4/group", item.Group4Group.ValueString())
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/commands", cBody.Res())
+ }
+ }
+ if len(data.Connections) > 0 {
+ for _, item := range data.Connections {
+ cBody := netconf.Body{}
+ if !item.Name.IsNull() && !item.Name.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "name", item.Name.ValueString())
+ }
+ if !item.Default.IsNull() && !item.Default.IsUnknown() {
+ if item.Default.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "default", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "default")
+ }
+ }
+ if !item.None.IsNull() && !item.None.IsUnknown() {
+ if item.None.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "none", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "none")
+ }
+ }
+ if !item.StartStopBroadcast.IsNull() && !item.StartStopBroadcast.IsUnknown() {
+ if item.StartStopBroadcast.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "start-stop/broadcast", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "start-stop/broadcast")
+ }
+ }
+ if !item.StartStopLogger.IsNull() && !item.StartStopLogger.IsUnknown() {
+ if item.StartStopLogger.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "start-stop/logger", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "start-stop/logger")
+ }
+ }
+ if !item.StartStopGroup1.IsNull() && !item.StartStopGroup1.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "start-stop/group1/group", item.StartStopGroup1.ValueString())
+ }
+ if !item.StartStopGroup2.IsNull() && !item.StartStopGroup2.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "start-stop/group2/group", item.StartStopGroup2.ValueString())
+ }
+ if !item.StartStopGroup3.IsNull() && !item.StartStopGroup3.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "start-stop/group3/group", item.StartStopGroup3.ValueString())
+ }
+ if !item.StartStopGroup4.IsNull() && !item.StartStopGroup4.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "start-stop/group4/group", item.StartStopGroup4.ValueString())
+ }
+ if !item.StopOnlyBroadcast.IsNull() && !item.StopOnlyBroadcast.IsUnknown() {
+ if item.StopOnlyBroadcast.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "stop-only/broadcast", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "stop-only/broadcast")
+ }
+ }
+ if !item.StopOnlyLogger.IsNull() && !item.StopOnlyLogger.IsUnknown() {
+ if item.StopOnlyLogger.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "stop-only/logger", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "stop-only/logger")
+ }
+ }
+ if !item.StopOnlyGroup1.IsNull() && !item.StopOnlyGroup1.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "stop-only/group1/group", item.StopOnlyGroup1.ValueString())
+ }
+ if !item.StopOnlyGroup2.IsNull() && !item.StopOnlyGroup2.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "stop-only/group2/group", item.StopOnlyGroup2.ValueString())
+ }
+ if !item.StopOnlyGroup3.IsNull() && !item.StopOnlyGroup3.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "stop-only/group3/group", item.StopOnlyGroup3.ValueString())
+ }
+ if !item.StopOnlyGroup4.IsNull() && !item.StopOnlyGroup4.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "stop-only/group4/group", item.StopOnlyGroup4.ValueString())
+ }
+ if !item.WaitStartBroadcast.IsNull() && !item.WaitStartBroadcast.IsUnknown() {
+ if item.WaitStartBroadcast.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "wait-start/broadcast", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "wait-start/broadcast")
+ }
+ }
+ if !item.WaitStartLogger.IsNull() && !item.WaitStartLogger.IsUnknown() {
+ if item.WaitStartLogger.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "wait-start/logger", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "wait-start/logger")
+ }
+ }
+ if !item.WaitStartGroup1.IsNull() && !item.WaitStartGroup1.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "wait-start/group1/group", item.WaitStartGroup1.ValueString())
+ }
+ if !item.WaitStartGroup2.IsNull() && !item.WaitStartGroup2.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "wait-start/group2/group", item.WaitStartGroup2.ValueString())
+ }
+ if !item.WaitStartGroup3.IsNull() && !item.WaitStartGroup3.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "wait-start/group3/group", item.WaitStartGroup3.ValueString())
+ }
+ if !item.WaitStartGroup4.IsNull() && !item.WaitStartGroup4.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "wait-start/group4/group", item.WaitStartGroup4.ValueString())
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/connection", cBody.Res())
+ }
+ }
+ if len(data.Execs) > 0 {
+ for _, item := range data.Execs {
+ cBody := netconf.Body{}
+ if !item.Name.IsNull() && !item.Name.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "name", item.Name.ValueString())
+ }
+ if !item.None.IsNull() && !item.None.IsUnknown() {
+ if item.None.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "none", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "none")
+ }
+ }
+ if !item.StartStopBroadcast.IsNull() && !item.StartStopBroadcast.IsUnknown() {
+ if item.StartStopBroadcast.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "start-stop/broadcast", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "start-stop/broadcast")
+ }
+ }
+ if !item.StartStopLogger.IsNull() && !item.StartStopLogger.IsUnknown() {
+ if item.StartStopLogger.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "start-stop/logger", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "start-stop/logger")
+ }
+ }
+ if !item.StartStopGroup1.IsNull() && !item.StartStopGroup1.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "start-stop/group1/group", item.StartStopGroup1.ValueString())
+ }
+ if !item.StartStopGroup2.IsNull() && !item.StartStopGroup2.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "start-stop/group2/group", item.StartStopGroup2.ValueString())
+ }
+ if !item.StartStopGroup3.IsNull() && !item.StartStopGroup3.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "start-stop/group3/group", item.StartStopGroup3.ValueString())
+ }
+ if !item.StartStopGroup4.IsNull() && !item.StartStopGroup4.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "start-stop/group4/group", item.StartStopGroup4.ValueString())
+ }
+ if !item.StopOnlyBroadcast.IsNull() && !item.StopOnlyBroadcast.IsUnknown() {
+ if item.StopOnlyBroadcast.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "stop-only/broadcast", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "stop-only/broadcast")
+ }
+ }
+ if !item.StopOnlyLogger.IsNull() && !item.StopOnlyLogger.IsUnknown() {
+ if item.StopOnlyLogger.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "stop-only/logger", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "stop-only/logger")
+ }
+ }
+ if !item.StopOnlyGroup1.IsNull() && !item.StopOnlyGroup1.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "stop-only/group1/group", item.StopOnlyGroup1.ValueString())
+ }
+ if !item.StopOnlyGroup2.IsNull() && !item.StopOnlyGroup2.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "stop-only/group2/group", item.StopOnlyGroup2.ValueString())
+ }
+ if !item.StopOnlyGroup3.IsNull() && !item.StopOnlyGroup3.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "stop-only/group3/group", item.StopOnlyGroup3.ValueString())
+ }
+ if !item.StopOnlyGroup4.IsNull() && !item.StopOnlyGroup4.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "stop-only/group4/group", item.StopOnlyGroup4.ValueString())
+ }
+ if !item.WaitStartBroadcast.IsNull() && !item.WaitStartBroadcast.IsUnknown() {
+ if item.WaitStartBroadcast.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "wait-start/broadcast", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "wait-start/broadcast")
+ }
+ }
+ if !item.WaitStartLogger.IsNull() && !item.WaitStartLogger.IsUnknown() {
+ if item.WaitStartLogger.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "wait-start/logger", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "wait-start/logger")
+ }
+ }
+ if !item.WaitStartGroup1.IsNull() && !item.WaitStartGroup1.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "wait-start/group1/group", item.WaitStartGroup1.ValueString())
+ }
+ if !item.WaitStartGroup2.IsNull() && !item.WaitStartGroup2.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "wait-start/group2/group", item.WaitStartGroup2.ValueString())
+ }
+ if !item.WaitStartGroup3.IsNull() && !item.WaitStartGroup3.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "wait-start/group3/group", item.WaitStartGroup3.ValueString())
+ }
+ if !item.WaitStartGroup4.IsNull() && !item.WaitStartGroup4.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "wait-start/group4/group", item.WaitStartGroup4.ValueString())
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/exec", cBody.Res())
+ }
+ }
+ bodyString, err := body.String()
+ if err != nil {
+ tflog.Error(ctx, fmt.Sprintf("Error converting body to string: %s", err))
+ }
+ return bodyString
+}
+
+// End of section. //template:end toBodyXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBody
func (data *AAAAccounting) updateFromBody(ctx context.Context, res gjson.Result) {
@@ -1004,32 +1349,884 @@ func (data *AAAAccounting) updateFromBody(ctx context.Context, res gjson.Result)
// End of section. //template:end updateFromBody
-// Section below is generated&owned by "gen/generator.go". //template:begin fromBody
+// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBodyXML
-func (data *AAAAccounting) fromBody(ctx context.Context, res gjson.Result) {
- prefix := helpers.LastElement(data.getPath()) + "."
- if res.Get(helpers.LastElement(data.getPath())).IsArray() {
- prefix += "0."
- }
- if value := res.Get(prefix + "update.newinfo.periodic"); value.Exists() {
+func (data *AAAAccounting) updateFromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/update/newinfo/periodic"); value.Exists() && !data.UpdateNewinfoPeriodic.IsNull() {
data.UpdateNewinfoPeriodic = types.Int64Value(value.Int())
+ } else {
+ data.UpdateNewinfoPeriodic = types.Int64Null()
}
- if value := res.Get(prefix + "identity.accounting-list"); value.Exists() {
- data.Identities = make([]AAAAccountingIdentities, 0)
- value.ForEach(func(k, v gjson.Result) bool {
- item := AAAAccountingIdentities{}
- if cValue := v.Get("name"); cValue.Exists() {
- item.Name = types.StringValue(cValue.String())
- }
- if cValue := v.Get("start-stop.broadcast"); cValue.Exists() {
- item.StartStopBroadcast = types.BoolValue(true)
+ for i := range data.Identities {
+ keys := [...]string{"name"}
+ keyValues := [...]string{data.Identities[i].Name.ValueString()}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/identity/accounting-list").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, "name"); value.Exists() && !data.Identities[i].Name.IsNull() {
+ data.Identities[i].Name = types.StringValue(value.String())
+ } else {
+ data.Identities[i].Name = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "start-stop/broadcast"); !data.Identities[i].StartStopBroadcast.IsNull() {
+ if value.Exists() {
+ data.Identities[i].StartStopBroadcast = types.BoolValue(true)
} else {
- item.StartStopBroadcast = types.BoolValue(false)
+ data.Identities[i].StartStopBroadcast = types.BoolValue(false)
}
- if cValue := v.Get("start-stop.group-config.broadcast"); cValue.Exists() {
- item.StartStopGroupBroadcast = types.BoolValue(true)
+ } else {
+ data.Identities[i].StartStopBroadcast = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "start-stop/group-config/broadcast"); !data.Identities[i].StartStopGroupBroadcast.IsNull() {
+ if value.Exists() {
+ data.Identities[i].StartStopGroupBroadcast = types.BoolValue(true)
} else {
- item.StartStopGroupBroadcast = types.BoolValue(false)
+ data.Identities[i].StartStopGroupBroadcast = types.BoolValue(false)
+ }
+ } else {
+ data.Identities[i].StartStopGroupBroadcast = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "start-stop/group-config/logger"); !data.Identities[i].StartStopGroupLogger.IsNull() {
+ if value.Exists() {
+ data.Identities[i].StartStopGroupLogger = types.BoolValue(true)
+ } else {
+ data.Identities[i].StartStopGroupLogger = types.BoolValue(false)
+ }
+ } else {
+ data.Identities[i].StartStopGroupLogger = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "start-stop/group-config/group1/group"); value.Exists() && !data.Identities[i].StartStopGroup1.IsNull() {
+ data.Identities[i].StartStopGroup1 = types.StringValue(value.String())
+ } else {
+ data.Identities[i].StartStopGroup1 = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "start-stop/group-config/group2/group"); value.Exists() && !data.Identities[i].StartStopGroup2.IsNull() {
+ data.Identities[i].StartStopGroup2 = types.StringValue(value.String())
+ } else {
+ data.Identities[i].StartStopGroup2 = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "start-stop/group-config/group3/group"); value.Exists() && !data.Identities[i].StartStopGroup3.IsNull() {
+ data.Identities[i].StartStopGroup3 = types.StringValue(value.String())
+ } else {
+ data.Identities[i].StartStopGroup3 = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "start-stop/group-config/group4/group"); value.Exists() && !data.Identities[i].StartStopGroup4.IsNull() {
+ data.Identities[i].StartStopGroup4 = types.StringValue(value.String())
+ } else {
+ data.Identities[i].StartStopGroup4 = types.StringNull()
+ }
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/identity/default/start-stop/group-config/group1/group"); value.Exists() && !data.IdentityDefaultStartStopGroup1.IsNull() {
+ data.IdentityDefaultStartStopGroup1 = types.StringValue(value.String())
+ } else {
+ data.IdentityDefaultStartStopGroup1 = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/identity/default/start-stop/group-config/group2/group"); value.Exists() && !data.IdentityDefaultStartStopGroup2.IsNull() {
+ data.IdentityDefaultStartStopGroup2 = types.StringValue(value.String())
+ } else {
+ data.IdentityDefaultStartStopGroup2 = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/identity/default/start-stop/group-config/group3/group"); value.Exists() && !data.IdentityDefaultStartStopGroup3.IsNull() {
+ data.IdentityDefaultStartStopGroup3 = types.StringValue(value.String())
+ } else {
+ data.IdentityDefaultStartStopGroup3 = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/identity/default/start-stop/group-config/group4/group"); value.Exists() && !data.IdentityDefaultStartStopGroup4.IsNull() {
+ data.IdentityDefaultStartStopGroup4 = types.StringValue(value.String())
+ } else {
+ data.IdentityDefaultStartStopGroup4 = types.StringNull()
+ }
+ for i := range data.Networks {
+ keys := [...]string{"id"}
+ keyValues := [...]string{data.Networks[i].Id.ValueString()}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/network").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, "id"); value.Exists() && !data.Networks[i].Id.IsNull() {
+ data.Networks[i].Id = types.StringValue(value.String())
+ } else {
+ data.Networks[i].Id = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "start-stop/group-config/group1/group"); value.Exists() && !data.Networks[i].StartStopGroup1.IsNull() {
+ data.Networks[i].StartStopGroup1 = types.StringValue(value.String())
+ } else {
+ data.Networks[i].StartStopGroup1 = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "start-stop/group-config/group2/group"); value.Exists() && !data.Networks[i].StartStopGroup2.IsNull() {
+ data.Networks[i].StartStopGroup2 = types.StringValue(value.String())
+ } else {
+ data.Networks[i].StartStopGroup2 = types.StringNull()
+ }
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/system/guarantee-first"); !data.SystemGuaranteeFirst.IsNull() {
+ if value.Exists() {
+ data.SystemGuaranteeFirst = types.BoolValue(value.Bool())
+ }
+ } else {
+ data.SystemGuaranteeFirst = types.BoolNull()
+ }
+ for i := range data.Commands {
+ keys := [...]string{"level", "list-name"}
+ keyValues := [...]string{strconv.FormatInt(data.Commands[i].Level.ValueInt64(), 10), data.Commands[i].ListName.ValueString()}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/commands").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, "level"); value.Exists() && !data.Commands[i].Level.IsNull() {
+ data.Commands[i].Level = types.Int64Value(value.Int())
+ } else {
+ data.Commands[i].Level = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(r, "list-name"); value.Exists() && !data.Commands[i].ListName.IsNull() {
+ data.Commands[i].ListName = types.StringValue(value.String())
+ } else {
+ data.Commands[i].ListName = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "commands-config/action-type"); value.Exists() && !data.Commands[i].ActionType.IsNull() {
+ data.Commands[i].ActionType = types.StringValue(value.String())
+ } else {
+ data.Commands[i].ActionType = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "commands-config/broadcast"); !data.Commands[i].Broadcast.IsNull() {
+ if value.Exists() {
+ data.Commands[i].Broadcast = types.BoolValue(true)
+ } else {
+ data.Commands[i].Broadcast = types.BoolValue(false)
+ }
+ } else {
+ data.Commands[i].Broadcast = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "commands-config/group-config/broadcast"); !data.Commands[i].GroupBroadcast.IsNull() {
+ if value.Exists() {
+ data.Commands[i].GroupBroadcast = types.BoolValue(true)
+ } else {
+ data.Commands[i].GroupBroadcast = types.BoolValue(false)
+ }
+ } else {
+ data.Commands[i].GroupBroadcast = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "commands-config/group-config/logger"); !data.Commands[i].GroupLogger.IsNull() {
+ if value.Exists() {
+ data.Commands[i].GroupLogger = types.BoolValue(true)
+ } else {
+ data.Commands[i].GroupLogger = types.BoolValue(false)
+ }
+ } else {
+ data.Commands[i].GroupLogger = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "commands-config/group-config/group1/group"); value.Exists() && !data.Commands[i].Group1Group.IsNull() {
+ data.Commands[i].Group1Group = types.StringValue(value.String())
+ } else {
+ data.Commands[i].Group1Group = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "commands-config/group-config/group2/group"); value.Exists() && !data.Commands[i].Group2Group.IsNull() {
+ data.Commands[i].Group2Group = types.StringValue(value.String())
+ } else {
+ data.Commands[i].Group2Group = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "commands-config/group-config/group3/group"); value.Exists() && !data.Commands[i].Group3Group.IsNull() {
+ data.Commands[i].Group3Group = types.StringValue(value.String())
+ } else {
+ data.Commands[i].Group3Group = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "commands-config/group-config/group4/group"); value.Exists() && !data.Commands[i].Group4Group.IsNull() {
+ data.Commands[i].Group4Group = types.StringValue(value.String())
+ } else {
+ data.Commands[i].Group4Group = types.StringNull()
+ }
+ }
+ for i := range data.Connections {
+ keys := [...]string{"name"}
+ keyValues := [...]string{data.Connections[i].Name.ValueString()}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/connection").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, "name"); value.Exists() && !data.Connections[i].Name.IsNull() {
+ data.Connections[i].Name = types.StringValue(value.String())
+ } else {
+ data.Connections[i].Name = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "default"); !data.Connections[i].Default.IsNull() {
+ if value.Exists() {
+ data.Connections[i].Default = types.BoolValue(true)
+ } else {
+ data.Connections[i].Default = types.BoolValue(false)
+ }
+ } else {
+ data.Connections[i].Default = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "none"); !data.Connections[i].None.IsNull() {
+ if value.Exists() {
+ data.Connections[i].None = types.BoolValue(true)
+ } else {
+ data.Connections[i].None = types.BoolValue(false)
+ }
+ } else {
+ data.Connections[i].None = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "start-stop/broadcast"); !data.Connections[i].StartStopBroadcast.IsNull() {
+ if value.Exists() {
+ data.Connections[i].StartStopBroadcast = types.BoolValue(true)
+ } else {
+ data.Connections[i].StartStopBroadcast = types.BoolValue(false)
+ }
+ } else {
+ data.Connections[i].StartStopBroadcast = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "start-stop/logger"); !data.Connections[i].StartStopLogger.IsNull() {
+ if value.Exists() {
+ data.Connections[i].StartStopLogger = types.BoolValue(true)
+ } else {
+ data.Connections[i].StartStopLogger = types.BoolValue(false)
+ }
+ } else {
+ data.Connections[i].StartStopLogger = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "start-stop/group1/group"); value.Exists() && !data.Connections[i].StartStopGroup1.IsNull() {
+ data.Connections[i].StartStopGroup1 = types.StringValue(value.String())
+ } else {
+ data.Connections[i].StartStopGroup1 = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "start-stop/group2/group"); value.Exists() && !data.Connections[i].StartStopGroup2.IsNull() {
+ data.Connections[i].StartStopGroup2 = types.StringValue(value.String())
+ } else {
+ data.Connections[i].StartStopGroup2 = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "start-stop/group3/group"); value.Exists() && !data.Connections[i].StartStopGroup3.IsNull() {
+ data.Connections[i].StartStopGroup3 = types.StringValue(value.String())
+ } else {
+ data.Connections[i].StartStopGroup3 = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "start-stop/group4/group"); value.Exists() && !data.Connections[i].StartStopGroup4.IsNull() {
+ data.Connections[i].StartStopGroup4 = types.StringValue(value.String())
+ } else {
+ data.Connections[i].StartStopGroup4 = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "stop-only/broadcast"); !data.Connections[i].StopOnlyBroadcast.IsNull() {
+ if value.Exists() {
+ data.Connections[i].StopOnlyBroadcast = types.BoolValue(true)
+ } else {
+ data.Connections[i].StopOnlyBroadcast = types.BoolValue(false)
+ }
+ } else {
+ data.Connections[i].StopOnlyBroadcast = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "stop-only/logger"); !data.Connections[i].StopOnlyLogger.IsNull() {
+ if value.Exists() {
+ data.Connections[i].StopOnlyLogger = types.BoolValue(true)
+ } else {
+ data.Connections[i].StopOnlyLogger = types.BoolValue(false)
+ }
+ } else {
+ data.Connections[i].StopOnlyLogger = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "stop-only/group1/group"); value.Exists() && !data.Connections[i].StopOnlyGroup1.IsNull() {
+ data.Connections[i].StopOnlyGroup1 = types.StringValue(value.String())
+ } else {
+ data.Connections[i].StopOnlyGroup1 = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "stop-only/group2/group"); value.Exists() && !data.Connections[i].StopOnlyGroup2.IsNull() {
+ data.Connections[i].StopOnlyGroup2 = types.StringValue(value.String())
+ } else {
+ data.Connections[i].StopOnlyGroup2 = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "stop-only/group3/group"); value.Exists() && !data.Connections[i].StopOnlyGroup3.IsNull() {
+ data.Connections[i].StopOnlyGroup3 = types.StringValue(value.String())
+ } else {
+ data.Connections[i].StopOnlyGroup3 = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "stop-only/group4/group"); value.Exists() && !data.Connections[i].StopOnlyGroup4.IsNull() {
+ data.Connections[i].StopOnlyGroup4 = types.StringValue(value.String())
+ } else {
+ data.Connections[i].StopOnlyGroup4 = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "wait-start/broadcast"); !data.Connections[i].WaitStartBroadcast.IsNull() {
+ if value.Exists() {
+ data.Connections[i].WaitStartBroadcast = types.BoolValue(true)
+ } else {
+ data.Connections[i].WaitStartBroadcast = types.BoolValue(false)
+ }
+ } else {
+ data.Connections[i].WaitStartBroadcast = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "wait-start/logger"); !data.Connections[i].WaitStartLogger.IsNull() {
+ if value.Exists() {
+ data.Connections[i].WaitStartLogger = types.BoolValue(true)
+ } else {
+ data.Connections[i].WaitStartLogger = types.BoolValue(false)
+ }
+ } else {
+ data.Connections[i].WaitStartLogger = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "wait-start/group1/group"); value.Exists() && !data.Connections[i].WaitStartGroup1.IsNull() {
+ data.Connections[i].WaitStartGroup1 = types.StringValue(value.String())
+ } else {
+ data.Connections[i].WaitStartGroup1 = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "wait-start/group2/group"); value.Exists() && !data.Connections[i].WaitStartGroup2.IsNull() {
+ data.Connections[i].WaitStartGroup2 = types.StringValue(value.String())
+ } else {
+ data.Connections[i].WaitStartGroup2 = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "wait-start/group3/group"); value.Exists() && !data.Connections[i].WaitStartGroup3.IsNull() {
+ data.Connections[i].WaitStartGroup3 = types.StringValue(value.String())
+ } else {
+ data.Connections[i].WaitStartGroup3 = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "wait-start/group4/group"); value.Exists() && !data.Connections[i].WaitStartGroup4.IsNull() {
+ data.Connections[i].WaitStartGroup4 = types.StringValue(value.String())
+ } else {
+ data.Connections[i].WaitStartGroup4 = types.StringNull()
+ }
+ }
+ for i := range data.Execs {
+ keys := [...]string{"name"}
+ keyValues := [...]string{data.Execs[i].Name.ValueString()}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/exec").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, "name"); value.Exists() && !data.Execs[i].Name.IsNull() {
+ data.Execs[i].Name = types.StringValue(value.String())
+ } else {
+ data.Execs[i].Name = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "none"); !data.Execs[i].None.IsNull() {
+ if value.Exists() {
+ data.Execs[i].None = types.BoolValue(true)
+ } else {
+ data.Execs[i].None = types.BoolValue(false)
+ }
+ } else {
+ data.Execs[i].None = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "start-stop/broadcast"); !data.Execs[i].StartStopBroadcast.IsNull() {
+ if value.Exists() {
+ data.Execs[i].StartStopBroadcast = types.BoolValue(true)
+ } else {
+ data.Execs[i].StartStopBroadcast = types.BoolValue(false)
+ }
+ } else {
+ data.Execs[i].StartStopBroadcast = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "start-stop/logger"); !data.Execs[i].StartStopLogger.IsNull() {
+ if value.Exists() {
+ data.Execs[i].StartStopLogger = types.BoolValue(true)
+ } else {
+ data.Execs[i].StartStopLogger = types.BoolValue(false)
+ }
+ } else {
+ data.Execs[i].StartStopLogger = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "start-stop/group1/group"); value.Exists() && !data.Execs[i].StartStopGroup1.IsNull() {
+ data.Execs[i].StartStopGroup1 = types.StringValue(value.String())
+ } else {
+ data.Execs[i].StartStopGroup1 = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "start-stop/group2/group"); value.Exists() && !data.Execs[i].StartStopGroup2.IsNull() {
+ data.Execs[i].StartStopGroup2 = types.StringValue(value.String())
+ } else {
+ data.Execs[i].StartStopGroup2 = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "start-stop/group3/group"); value.Exists() && !data.Execs[i].StartStopGroup3.IsNull() {
+ data.Execs[i].StartStopGroup3 = types.StringValue(value.String())
+ } else {
+ data.Execs[i].StartStopGroup3 = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "start-stop/group4/group"); value.Exists() && !data.Execs[i].StartStopGroup4.IsNull() {
+ data.Execs[i].StartStopGroup4 = types.StringValue(value.String())
+ } else {
+ data.Execs[i].StartStopGroup4 = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "stop-only/broadcast"); !data.Execs[i].StopOnlyBroadcast.IsNull() {
+ if value.Exists() {
+ data.Execs[i].StopOnlyBroadcast = types.BoolValue(true)
+ } else {
+ data.Execs[i].StopOnlyBroadcast = types.BoolValue(false)
+ }
+ } else {
+ data.Execs[i].StopOnlyBroadcast = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "stop-only/logger"); !data.Execs[i].StopOnlyLogger.IsNull() {
+ if value.Exists() {
+ data.Execs[i].StopOnlyLogger = types.BoolValue(true)
+ } else {
+ data.Execs[i].StopOnlyLogger = types.BoolValue(false)
+ }
+ } else {
+ data.Execs[i].StopOnlyLogger = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "stop-only/group1/group"); value.Exists() && !data.Execs[i].StopOnlyGroup1.IsNull() {
+ data.Execs[i].StopOnlyGroup1 = types.StringValue(value.String())
+ } else {
+ data.Execs[i].StopOnlyGroup1 = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "stop-only/group2/group"); value.Exists() && !data.Execs[i].StopOnlyGroup2.IsNull() {
+ data.Execs[i].StopOnlyGroup2 = types.StringValue(value.String())
+ } else {
+ data.Execs[i].StopOnlyGroup2 = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "stop-only/group3/group"); value.Exists() && !data.Execs[i].StopOnlyGroup3.IsNull() {
+ data.Execs[i].StopOnlyGroup3 = types.StringValue(value.String())
+ } else {
+ data.Execs[i].StopOnlyGroup3 = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "stop-only/group4/group"); value.Exists() && !data.Execs[i].StopOnlyGroup4.IsNull() {
+ data.Execs[i].StopOnlyGroup4 = types.StringValue(value.String())
+ } else {
+ data.Execs[i].StopOnlyGroup4 = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "wait-start/broadcast"); !data.Execs[i].WaitStartBroadcast.IsNull() {
+ if value.Exists() {
+ data.Execs[i].WaitStartBroadcast = types.BoolValue(true)
+ } else {
+ data.Execs[i].WaitStartBroadcast = types.BoolValue(false)
+ }
+ } else {
+ data.Execs[i].WaitStartBroadcast = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "wait-start/logger"); !data.Execs[i].WaitStartLogger.IsNull() {
+ if value.Exists() {
+ data.Execs[i].WaitStartLogger = types.BoolValue(true)
+ } else {
+ data.Execs[i].WaitStartLogger = types.BoolValue(false)
+ }
+ } else {
+ data.Execs[i].WaitStartLogger = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "wait-start/group1/group"); value.Exists() && !data.Execs[i].WaitStartGroup1.IsNull() {
+ data.Execs[i].WaitStartGroup1 = types.StringValue(value.String())
+ } else {
+ data.Execs[i].WaitStartGroup1 = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "wait-start/group2/group"); value.Exists() && !data.Execs[i].WaitStartGroup2.IsNull() {
+ data.Execs[i].WaitStartGroup2 = types.StringValue(value.String())
+ } else {
+ data.Execs[i].WaitStartGroup2 = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "wait-start/group3/group"); value.Exists() && !data.Execs[i].WaitStartGroup3.IsNull() {
+ data.Execs[i].WaitStartGroup3 = types.StringValue(value.String())
+ } else {
+ data.Execs[i].WaitStartGroup3 = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "wait-start/group4/group"); value.Exists() && !data.Execs[i].WaitStartGroup4.IsNull() {
+ data.Execs[i].WaitStartGroup4 = types.StringValue(value.String())
+ } else {
+ data.Execs[i].WaitStartGroup4 = types.StringNull()
+ }
+ }
+}
+
+// End of section. //template:end updateFromBodyXML
+
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBody
+
+func (data *AAAAccounting) fromBody(ctx context.Context, res gjson.Result) {
+ prefix := helpers.LastElement(data.getPath()) + "."
+ if res.Get(helpers.LastElement(data.getPath())).IsArray() {
+ prefix += "0."
+ }
+ if value := res.Get(prefix + "update.newinfo.periodic"); value.Exists() {
+ data.UpdateNewinfoPeriodic = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "identity.accounting-list"); value.Exists() {
+ data.Identities = make([]AAAAccountingIdentities, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := AAAAccountingIdentities{}
+ if cValue := v.Get("name"); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("start-stop.broadcast"); cValue.Exists() {
+ item.StartStopBroadcast = types.BoolValue(true)
+ } else {
+ item.StartStopBroadcast = types.BoolValue(false)
+ }
+ if cValue := v.Get("start-stop.group-config.broadcast"); cValue.Exists() {
+ item.StartStopGroupBroadcast = types.BoolValue(true)
+ } else {
+ item.StartStopGroupBroadcast = types.BoolValue(false)
+ }
+ if cValue := v.Get("start-stop.group-config.logger"); cValue.Exists() {
+ item.StartStopGroupLogger = types.BoolValue(true)
+ } else {
+ item.StartStopGroupLogger = types.BoolValue(false)
+ }
+ if cValue := v.Get("start-stop.group-config.group1.group"); cValue.Exists() {
+ item.StartStopGroup1 = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("start-stop.group-config.group2.group"); cValue.Exists() {
+ item.StartStopGroup2 = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("start-stop.group-config.group3.group"); cValue.Exists() {
+ item.StartStopGroup3 = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("start-stop.group-config.group4.group"); cValue.Exists() {
+ item.StartStopGroup4 = types.StringValue(cValue.String())
+ }
+ data.Identities = append(data.Identities, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + "identity.default.start-stop.group-config.group1.group"); value.Exists() {
+ data.IdentityDefaultStartStopGroup1 = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "identity.default.start-stop.group-config.group2.group"); value.Exists() {
+ data.IdentityDefaultStartStopGroup2 = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "identity.default.start-stop.group-config.group3.group"); value.Exists() {
+ data.IdentityDefaultStartStopGroup3 = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "identity.default.start-stop.group-config.group4.group"); value.Exists() {
+ data.IdentityDefaultStartStopGroup4 = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "network"); value.Exists() {
+ data.Networks = make([]AAAAccountingNetworks, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := AAAAccountingNetworks{}
+ if cValue := v.Get("id"); cValue.Exists() {
+ item.Id = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("start-stop.group-config.group1.group"); cValue.Exists() {
+ item.StartStopGroup1 = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("start-stop.group-config.group2.group"); cValue.Exists() {
+ item.StartStopGroup2 = types.StringValue(cValue.String())
+ }
+ data.Networks = append(data.Networks, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + "system.guarantee-first"); value.Exists() {
+ data.SystemGuaranteeFirst = types.BoolValue(value.Bool())
+ } else {
+ data.SystemGuaranteeFirst = types.BoolNull()
+ }
+ if value := res.Get(prefix + "commands"); value.Exists() {
+ data.Commands = make([]AAAAccountingCommands, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := AAAAccountingCommands{}
+ if cValue := v.Get("level"); cValue.Exists() {
+ item.Level = types.Int64Value(cValue.Int())
+ }
+ if cValue := v.Get("list-name"); cValue.Exists() {
+ item.ListName = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("commands-config.action-type"); cValue.Exists() {
+ item.ActionType = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("commands-config.broadcast"); cValue.Exists() {
+ item.Broadcast = types.BoolValue(true)
+ } else {
+ item.Broadcast = types.BoolValue(false)
+ }
+ if cValue := v.Get("commands-config.group-config.broadcast"); cValue.Exists() {
+ item.GroupBroadcast = types.BoolValue(true)
+ } else {
+ item.GroupBroadcast = types.BoolValue(false)
+ }
+ if cValue := v.Get("commands-config.group-config.logger"); cValue.Exists() {
+ item.GroupLogger = types.BoolValue(true)
+ } else {
+ item.GroupLogger = types.BoolValue(false)
+ }
+ if cValue := v.Get("commands-config.group-config.group1.group"); cValue.Exists() {
+ item.Group1Group = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("commands-config.group-config.group2.group"); cValue.Exists() {
+ item.Group2Group = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("commands-config.group-config.group3.group"); cValue.Exists() {
+ item.Group3Group = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("commands-config.group-config.group4.group"); cValue.Exists() {
+ item.Group4Group = types.StringValue(cValue.String())
+ }
+ data.Commands = append(data.Commands, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + "connection"); value.Exists() {
+ data.Connections = make([]AAAAccountingConnections, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := AAAAccountingConnections{}
+ if cValue := v.Get("name"); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("default"); cValue.Exists() {
+ item.Default = types.BoolValue(true)
+ } else {
+ item.Default = types.BoolValue(false)
+ }
+ if cValue := v.Get("none"); cValue.Exists() {
+ item.None = types.BoolValue(true)
+ } else {
+ item.None = types.BoolValue(false)
+ }
+ if cValue := v.Get("start-stop.broadcast"); cValue.Exists() {
+ item.StartStopBroadcast = types.BoolValue(true)
+ } else {
+ item.StartStopBroadcast = types.BoolValue(false)
+ }
+ if cValue := v.Get("start-stop.logger"); cValue.Exists() {
+ item.StartStopLogger = types.BoolValue(true)
+ } else {
+ item.StartStopLogger = types.BoolValue(false)
+ }
+ if cValue := v.Get("start-stop.group1.group"); cValue.Exists() {
+ item.StartStopGroup1 = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("start-stop.group2.group"); cValue.Exists() {
+ item.StartStopGroup2 = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("start-stop.group3.group"); cValue.Exists() {
+ item.StartStopGroup3 = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("start-stop.group4.group"); cValue.Exists() {
+ item.StartStopGroup4 = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("stop-only.broadcast"); cValue.Exists() {
+ item.StopOnlyBroadcast = types.BoolValue(true)
+ } else {
+ item.StopOnlyBroadcast = types.BoolValue(false)
+ }
+ if cValue := v.Get("stop-only.logger"); cValue.Exists() {
+ item.StopOnlyLogger = types.BoolValue(true)
+ } else {
+ item.StopOnlyLogger = types.BoolValue(false)
+ }
+ if cValue := v.Get("stop-only.group1.group"); cValue.Exists() {
+ item.StopOnlyGroup1 = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("stop-only.group2.group"); cValue.Exists() {
+ item.StopOnlyGroup2 = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("stop-only.group3.group"); cValue.Exists() {
+ item.StopOnlyGroup3 = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("stop-only.group4.group"); cValue.Exists() {
+ item.StopOnlyGroup4 = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("wait-start.broadcast"); cValue.Exists() {
+ item.WaitStartBroadcast = types.BoolValue(true)
+ } else {
+ item.WaitStartBroadcast = types.BoolValue(false)
+ }
+ if cValue := v.Get("wait-start.logger"); cValue.Exists() {
+ item.WaitStartLogger = types.BoolValue(true)
+ } else {
+ item.WaitStartLogger = types.BoolValue(false)
+ }
+ if cValue := v.Get("wait-start.group1.group"); cValue.Exists() {
+ item.WaitStartGroup1 = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("wait-start.group2.group"); cValue.Exists() {
+ item.WaitStartGroup2 = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("wait-start.group3.group"); cValue.Exists() {
+ item.WaitStartGroup3 = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("wait-start.group4.group"); cValue.Exists() {
+ item.WaitStartGroup4 = types.StringValue(cValue.String())
+ }
+ data.Connections = append(data.Connections, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + "exec"); value.Exists() {
+ data.Execs = make([]AAAAccountingExecs, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := AAAAccountingExecs{}
+ if cValue := v.Get("name"); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("none"); cValue.Exists() {
+ item.None = types.BoolValue(true)
+ } else {
+ item.None = types.BoolValue(false)
+ }
+ if cValue := v.Get("start-stop.broadcast"); cValue.Exists() {
+ item.StartStopBroadcast = types.BoolValue(true)
+ } else {
+ item.StartStopBroadcast = types.BoolValue(false)
+ }
+ if cValue := v.Get("start-stop.logger"); cValue.Exists() {
+ item.StartStopLogger = types.BoolValue(true)
+ } else {
+ item.StartStopLogger = types.BoolValue(false)
+ }
+ if cValue := v.Get("start-stop.group1.group"); cValue.Exists() {
+ item.StartStopGroup1 = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("start-stop.group2.group"); cValue.Exists() {
+ item.StartStopGroup2 = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("start-stop.group3.group"); cValue.Exists() {
+ item.StartStopGroup3 = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("start-stop.group4.group"); cValue.Exists() {
+ item.StartStopGroup4 = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("stop-only.broadcast"); cValue.Exists() {
+ item.StopOnlyBroadcast = types.BoolValue(true)
+ } else {
+ item.StopOnlyBroadcast = types.BoolValue(false)
+ }
+ if cValue := v.Get("stop-only.logger"); cValue.Exists() {
+ item.StopOnlyLogger = types.BoolValue(true)
+ } else {
+ item.StopOnlyLogger = types.BoolValue(false)
+ }
+ if cValue := v.Get("stop-only.group1.group"); cValue.Exists() {
+ item.StopOnlyGroup1 = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("stop-only.group2.group"); cValue.Exists() {
+ item.StopOnlyGroup2 = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("stop-only.group3.group"); cValue.Exists() {
+ item.StopOnlyGroup3 = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("stop-only.group4.group"); cValue.Exists() {
+ item.StopOnlyGroup4 = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("wait-start.broadcast"); cValue.Exists() {
+ item.WaitStartBroadcast = types.BoolValue(true)
+ } else {
+ item.WaitStartBroadcast = types.BoolValue(false)
+ }
+ if cValue := v.Get("wait-start.logger"); cValue.Exists() {
+ item.WaitStartLogger = types.BoolValue(true)
+ } else {
+ item.WaitStartLogger = types.BoolValue(false)
+ }
+ if cValue := v.Get("wait-start.group1.group"); cValue.Exists() {
+ item.WaitStartGroup1 = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("wait-start.group2.group"); cValue.Exists() {
+ item.WaitStartGroup2 = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("wait-start.group3.group"); cValue.Exists() {
+ item.WaitStartGroup3 = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("wait-start.group4.group"); cValue.Exists() {
+ item.WaitStartGroup4 = types.StringValue(cValue.String())
+ }
+ data.Execs = append(data.Execs, item)
+ return true
+ })
+ }
+}
+
+// End of section. //template:end fromBody
+
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyData
+
+func (data *AAAAccountingData) fromBody(ctx context.Context, res gjson.Result) {
+ prefix := helpers.LastElement(data.getPath()) + "."
+ if res.Get(helpers.LastElement(data.getPath())).IsArray() {
+ prefix += "0."
+ }
+ if value := res.Get(prefix + "update.newinfo.periodic"); value.Exists() {
+ data.UpdateNewinfoPeriodic = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "identity.accounting-list"); value.Exists() {
+ data.Identities = make([]AAAAccountingIdentities, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := AAAAccountingIdentities{}
+ if cValue := v.Get("name"); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("start-stop.broadcast"); cValue.Exists() {
+ item.StartStopBroadcast = types.BoolValue(true)
+ } else {
+ item.StartStopBroadcast = types.BoolValue(false)
+ }
+ if cValue := v.Get("start-stop.group-config.broadcast"); cValue.Exists() {
+ item.StartStopGroupBroadcast = types.BoolValue(true)
+ } else {
+ item.StartStopGroupBroadcast = types.BoolValue(false)
}
if cValue := v.Get("start-stop.group-config.logger"); cValue.Exists() {
item.StartStopGroupLogger = types.BoolValue(true)
@@ -1301,297 +2498,588 @@ func (data *AAAAccounting) fromBody(ctx context.Context, res gjson.Result) {
}
}
-// End of section. //template:end fromBody
+// End of section. //template:end fromBodyData
-// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyData
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyXML
-func (data *AAAAccountingData) fromBody(ctx context.Context, res gjson.Result) {
- prefix := helpers.LastElement(data.getPath()) + "."
- if res.Get(helpers.LastElement(data.getPath())).IsArray() {
- prefix += "0."
+func (data *AAAAccounting) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/update/newinfo/periodic"); value.Exists() {
+ data.UpdateNewinfoPeriodic = types.Int64Value(value.Int())
}
- if value := res.Get(prefix + "update.newinfo.periodic"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/identity/accounting-list"); value.Exists() {
+ data.Identities = make([]AAAAccountingIdentities, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := AAAAccountingIdentities{}
+ if cValue := helpers.GetFromXPath(v, "name"); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "start-stop/broadcast"); cValue.Exists() {
+ item.StartStopBroadcast = types.BoolValue(true)
+ } else {
+ item.StartStopBroadcast = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "start-stop/group-config/broadcast"); cValue.Exists() {
+ item.StartStopGroupBroadcast = types.BoolValue(true)
+ } else {
+ item.StartStopGroupBroadcast = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "start-stop/group-config/logger"); cValue.Exists() {
+ item.StartStopGroupLogger = types.BoolValue(true)
+ } else {
+ item.StartStopGroupLogger = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "start-stop/group-config/group1/group"); cValue.Exists() {
+ item.StartStopGroup1 = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "start-stop/group-config/group2/group"); cValue.Exists() {
+ item.StartStopGroup2 = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "start-stop/group-config/group3/group"); cValue.Exists() {
+ item.StartStopGroup3 = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "start-stop/group-config/group4/group"); cValue.Exists() {
+ item.StartStopGroup4 = types.StringValue(cValue.String())
+ }
+ data.Identities = append(data.Identities, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/identity/default/start-stop/group-config/group1/group"); value.Exists() {
+ data.IdentityDefaultStartStopGroup1 = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/identity/default/start-stop/group-config/group2/group"); value.Exists() {
+ data.IdentityDefaultStartStopGroup2 = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/identity/default/start-stop/group-config/group3/group"); value.Exists() {
+ data.IdentityDefaultStartStopGroup3 = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/identity/default/start-stop/group-config/group4/group"); value.Exists() {
+ data.IdentityDefaultStartStopGroup4 = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/network"); value.Exists() {
+ data.Networks = make([]AAAAccountingNetworks, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := AAAAccountingNetworks{}
+ if cValue := helpers.GetFromXPath(v, "id"); cValue.Exists() {
+ item.Id = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "start-stop/group-config/group1/group"); cValue.Exists() {
+ item.StartStopGroup1 = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "start-stop/group-config/group2/group"); cValue.Exists() {
+ item.StartStopGroup2 = types.StringValue(cValue.String())
+ }
+ data.Networks = append(data.Networks, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/system/guarantee-first"); value.Exists() {
+ data.SystemGuaranteeFirst = types.BoolValue(value.Bool())
+ } else {
+ data.SystemGuaranteeFirst = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/commands"); value.Exists() {
+ data.Commands = make([]AAAAccountingCommands, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := AAAAccountingCommands{}
+ if cValue := helpers.GetFromXPath(v, "level"); cValue.Exists() {
+ item.Level = types.Int64Value(cValue.Int())
+ }
+ if cValue := helpers.GetFromXPath(v, "list-name"); cValue.Exists() {
+ item.ListName = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "commands-config/action-type"); cValue.Exists() {
+ item.ActionType = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "commands-config/broadcast"); cValue.Exists() {
+ item.Broadcast = types.BoolValue(true)
+ } else {
+ item.Broadcast = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "commands-config/group-config/broadcast"); cValue.Exists() {
+ item.GroupBroadcast = types.BoolValue(true)
+ } else {
+ item.GroupBroadcast = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "commands-config/group-config/logger"); cValue.Exists() {
+ item.GroupLogger = types.BoolValue(true)
+ } else {
+ item.GroupLogger = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "commands-config/group-config/group1/group"); cValue.Exists() {
+ item.Group1Group = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "commands-config/group-config/group2/group"); cValue.Exists() {
+ item.Group2Group = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "commands-config/group-config/group3/group"); cValue.Exists() {
+ item.Group3Group = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "commands-config/group-config/group4/group"); cValue.Exists() {
+ item.Group4Group = types.StringValue(cValue.String())
+ }
+ data.Commands = append(data.Commands, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/connection"); value.Exists() {
+ data.Connections = make([]AAAAccountingConnections, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := AAAAccountingConnections{}
+ if cValue := helpers.GetFromXPath(v, "name"); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "default"); cValue.Exists() {
+ item.Default = types.BoolValue(true)
+ } else {
+ item.Default = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "none"); cValue.Exists() {
+ item.None = types.BoolValue(true)
+ } else {
+ item.None = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "start-stop/broadcast"); cValue.Exists() {
+ item.StartStopBroadcast = types.BoolValue(true)
+ } else {
+ item.StartStopBroadcast = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "start-stop/logger"); cValue.Exists() {
+ item.StartStopLogger = types.BoolValue(true)
+ } else {
+ item.StartStopLogger = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "start-stop/group1/group"); cValue.Exists() {
+ item.StartStopGroup1 = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "start-stop/group2/group"); cValue.Exists() {
+ item.StartStopGroup2 = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "start-stop/group3/group"); cValue.Exists() {
+ item.StartStopGroup3 = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "start-stop/group4/group"); cValue.Exists() {
+ item.StartStopGroup4 = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "stop-only/broadcast"); cValue.Exists() {
+ item.StopOnlyBroadcast = types.BoolValue(true)
+ } else {
+ item.StopOnlyBroadcast = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "stop-only/logger"); cValue.Exists() {
+ item.StopOnlyLogger = types.BoolValue(true)
+ } else {
+ item.StopOnlyLogger = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "stop-only/group1/group"); cValue.Exists() {
+ item.StopOnlyGroup1 = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "stop-only/group2/group"); cValue.Exists() {
+ item.StopOnlyGroup2 = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "stop-only/group3/group"); cValue.Exists() {
+ item.StopOnlyGroup3 = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "stop-only/group4/group"); cValue.Exists() {
+ item.StopOnlyGroup4 = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "wait-start/broadcast"); cValue.Exists() {
+ item.WaitStartBroadcast = types.BoolValue(true)
+ } else {
+ item.WaitStartBroadcast = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "wait-start/logger"); cValue.Exists() {
+ item.WaitStartLogger = types.BoolValue(true)
+ } else {
+ item.WaitStartLogger = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "wait-start/group1/group"); cValue.Exists() {
+ item.WaitStartGroup1 = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "wait-start/group2/group"); cValue.Exists() {
+ item.WaitStartGroup2 = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "wait-start/group3/group"); cValue.Exists() {
+ item.WaitStartGroup3 = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "wait-start/group4/group"); cValue.Exists() {
+ item.WaitStartGroup4 = types.StringValue(cValue.String())
+ }
+ data.Connections = append(data.Connections, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/exec"); value.Exists() {
+ data.Execs = make([]AAAAccountingExecs, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := AAAAccountingExecs{}
+ if cValue := helpers.GetFromXPath(v, "name"); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "none"); cValue.Exists() {
+ item.None = types.BoolValue(true)
+ } else {
+ item.None = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "start-stop/broadcast"); cValue.Exists() {
+ item.StartStopBroadcast = types.BoolValue(true)
+ } else {
+ item.StartStopBroadcast = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "start-stop/logger"); cValue.Exists() {
+ item.StartStopLogger = types.BoolValue(true)
+ } else {
+ item.StartStopLogger = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "start-stop/group1/group"); cValue.Exists() {
+ item.StartStopGroup1 = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "start-stop/group2/group"); cValue.Exists() {
+ item.StartStopGroup2 = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "start-stop/group3/group"); cValue.Exists() {
+ item.StartStopGroup3 = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "start-stop/group4/group"); cValue.Exists() {
+ item.StartStopGroup4 = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "stop-only/broadcast"); cValue.Exists() {
+ item.StopOnlyBroadcast = types.BoolValue(true)
+ } else {
+ item.StopOnlyBroadcast = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "stop-only/logger"); cValue.Exists() {
+ item.StopOnlyLogger = types.BoolValue(true)
+ } else {
+ item.StopOnlyLogger = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "stop-only/group1/group"); cValue.Exists() {
+ item.StopOnlyGroup1 = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "stop-only/group2/group"); cValue.Exists() {
+ item.StopOnlyGroup2 = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "stop-only/group3/group"); cValue.Exists() {
+ item.StopOnlyGroup3 = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "stop-only/group4/group"); cValue.Exists() {
+ item.StopOnlyGroup4 = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "wait-start/broadcast"); cValue.Exists() {
+ item.WaitStartBroadcast = types.BoolValue(true)
+ } else {
+ item.WaitStartBroadcast = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "wait-start/logger"); cValue.Exists() {
+ item.WaitStartLogger = types.BoolValue(true)
+ } else {
+ item.WaitStartLogger = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "wait-start/group1/group"); cValue.Exists() {
+ item.WaitStartGroup1 = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "wait-start/group2/group"); cValue.Exists() {
+ item.WaitStartGroup2 = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "wait-start/group3/group"); cValue.Exists() {
+ item.WaitStartGroup3 = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "wait-start/group4/group"); cValue.Exists() {
+ item.WaitStartGroup4 = types.StringValue(cValue.String())
+ }
+ data.Execs = append(data.Execs, item)
+ return true
+ })
+ }
+}
+
+// End of section. //template:end fromBodyXML
+
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyDataXML
+
+func (data *AAAAccountingData) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/update/newinfo/periodic"); value.Exists() {
data.UpdateNewinfoPeriodic = types.Int64Value(value.Int())
}
- if value := res.Get(prefix + "identity.accounting-list"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/identity/accounting-list"); value.Exists() {
data.Identities = make([]AAAAccountingIdentities, 0)
- value.ForEach(func(k, v gjson.Result) bool {
+ value.ForEach(func(_ int, v xmldot.Result) bool {
item := AAAAccountingIdentities{}
- if cValue := v.Get("name"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "name"); cValue.Exists() {
item.Name = types.StringValue(cValue.String())
}
- if cValue := v.Get("start-stop.broadcast"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "start-stop/broadcast"); cValue.Exists() {
item.StartStopBroadcast = types.BoolValue(true)
} else {
item.StartStopBroadcast = types.BoolValue(false)
}
- if cValue := v.Get("start-stop.group-config.broadcast"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "start-stop/group-config/broadcast"); cValue.Exists() {
item.StartStopGroupBroadcast = types.BoolValue(true)
} else {
item.StartStopGroupBroadcast = types.BoolValue(false)
}
- if cValue := v.Get("start-stop.group-config.logger"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "start-stop/group-config/logger"); cValue.Exists() {
item.StartStopGroupLogger = types.BoolValue(true)
} else {
item.StartStopGroupLogger = types.BoolValue(false)
}
- if cValue := v.Get("start-stop.group-config.group1.group"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "start-stop/group-config/group1/group"); cValue.Exists() {
item.StartStopGroup1 = types.StringValue(cValue.String())
}
- if cValue := v.Get("start-stop.group-config.group2.group"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "start-stop/group-config/group2/group"); cValue.Exists() {
item.StartStopGroup2 = types.StringValue(cValue.String())
}
- if cValue := v.Get("start-stop.group-config.group3.group"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "start-stop/group-config/group3/group"); cValue.Exists() {
item.StartStopGroup3 = types.StringValue(cValue.String())
}
- if cValue := v.Get("start-stop.group-config.group4.group"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "start-stop/group-config/group4/group"); cValue.Exists() {
item.StartStopGroup4 = types.StringValue(cValue.String())
}
data.Identities = append(data.Identities, item)
return true
})
}
- if value := res.Get(prefix + "identity.default.start-stop.group-config.group1.group"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/identity/default/start-stop/group-config/group1/group"); value.Exists() {
data.IdentityDefaultStartStopGroup1 = types.StringValue(value.String())
}
- if value := res.Get(prefix + "identity.default.start-stop.group-config.group2.group"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/identity/default/start-stop/group-config/group2/group"); value.Exists() {
data.IdentityDefaultStartStopGroup2 = types.StringValue(value.String())
}
- if value := res.Get(prefix + "identity.default.start-stop.group-config.group3.group"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/identity/default/start-stop/group-config/group3/group"); value.Exists() {
data.IdentityDefaultStartStopGroup3 = types.StringValue(value.String())
}
- if value := res.Get(prefix + "identity.default.start-stop.group-config.group4.group"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/identity/default/start-stop/group-config/group4/group"); value.Exists() {
data.IdentityDefaultStartStopGroup4 = types.StringValue(value.String())
}
- if value := res.Get(prefix + "network"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/network"); value.Exists() {
data.Networks = make([]AAAAccountingNetworks, 0)
- value.ForEach(func(k, v gjson.Result) bool {
+ value.ForEach(func(_ int, v xmldot.Result) bool {
item := AAAAccountingNetworks{}
- if cValue := v.Get("id"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "id"); cValue.Exists() {
item.Id = types.StringValue(cValue.String())
}
- if cValue := v.Get("start-stop.group-config.group1.group"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "start-stop/group-config/group1/group"); cValue.Exists() {
item.StartStopGroup1 = types.StringValue(cValue.String())
}
- if cValue := v.Get("start-stop.group-config.group2.group"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "start-stop/group-config/group2/group"); cValue.Exists() {
item.StartStopGroup2 = types.StringValue(cValue.String())
}
data.Networks = append(data.Networks, item)
return true
})
}
- if value := res.Get(prefix + "system.guarantee-first"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/system/guarantee-first"); value.Exists() {
data.SystemGuaranteeFirst = types.BoolValue(value.Bool())
} else {
data.SystemGuaranteeFirst = types.BoolNull()
}
- if value := res.Get(prefix + "commands"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/commands"); value.Exists() {
data.Commands = make([]AAAAccountingCommands, 0)
- value.ForEach(func(k, v gjson.Result) bool {
+ value.ForEach(func(_ int, v xmldot.Result) bool {
item := AAAAccountingCommands{}
- if cValue := v.Get("level"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "level"); cValue.Exists() {
item.Level = types.Int64Value(cValue.Int())
}
- if cValue := v.Get("list-name"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "list-name"); cValue.Exists() {
item.ListName = types.StringValue(cValue.String())
}
- if cValue := v.Get("commands-config.action-type"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "commands-config/action-type"); cValue.Exists() {
item.ActionType = types.StringValue(cValue.String())
}
- if cValue := v.Get("commands-config.broadcast"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "commands-config/broadcast"); cValue.Exists() {
item.Broadcast = types.BoolValue(true)
} else {
item.Broadcast = types.BoolValue(false)
}
- if cValue := v.Get("commands-config.group-config.broadcast"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "commands-config/group-config/broadcast"); cValue.Exists() {
item.GroupBroadcast = types.BoolValue(true)
} else {
item.GroupBroadcast = types.BoolValue(false)
}
- if cValue := v.Get("commands-config.group-config.logger"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "commands-config/group-config/logger"); cValue.Exists() {
item.GroupLogger = types.BoolValue(true)
} else {
item.GroupLogger = types.BoolValue(false)
}
- if cValue := v.Get("commands-config.group-config.group1.group"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "commands-config/group-config/group1/group"); cValue.Exists() {
item.Group1Group = types.StringValue(cValue.String())
}
- if cValue := v.Get("commands-config.group-config.group2.group"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "commands-config/group-config/group2/group"); cValue.Exists() {
item.Group2Group = types.StringValue(cValue.String())
}
- if cValue := v.Get("commands-config.group-config.group3.group"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "commands-config/group-config/group3/group"); cValue.Exists() {
item.Group3Group = types.StringValue(cValue.String())
}
- if cValue := v.Get("commands-config.group-config.group4.group"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "commands-config/group-config/group4/group"); cValue.Exists() {
item.Group4Group = types.StringValue(cValue.String())
}
data.Commands = append(data.Commands, item)
return true
})
}
- if value := res.Get(prefix + "connection"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/connection"); value.Exists() {
data.Connections = make([]AAAAccountingConnections, 0)
- value.ForEach(func(k, v gjson.Result) bool {
+ value.ForEach(func(_ int, v xmldot.Result) bool {
item := AAAAccountingConnections{}
- if cValue := v.Get("name"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "name"); cValue.Exists() {
item.Name = types.StringValue(cValue.String())
}
- if cValue := v.Get("default"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "default"); cValue.Exists() {
item.Default = types.BoolValue(true)
} else {
item.Default = types.BoolValue(false)
}
- if cValue := v.Get("none"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "none"); cValue.Exists() {
item.None = types.BoolValue(true)
} else {
item.None = types.BoolValue(false)
}
- if cValue := v.Get("start-stop.broadcast"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "start-stop/broadcast"); cValue.Exists() {
item.StartStopBroadcast = types.BoolValue(true)
} else {
item.StartStopBroadcast = types.BoolValue(false)
}
- if cValue := v.Get("start-stop.logger"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "start-stop/logger"); cValue.Exists() {
item.StartStopLogger = types.BoolValue(true)
} else {
item.StartStopLogger = types.BoolValue(false)
}
- if cValue := v.Get("start-stop.group1.group"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "start-stop/group1/group"); cValue.Exists() {
item.StartStopGroup1 = types.StringValue(cValue.String())
}
- if cValue := v.Get("start-stop.group2.group"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "start-stop/group2/group"); cValue.Exists() {
item.StartStopGroup2 = types.StringValue(cValue.String())
}
- if cValue := v.Get("start-stop.group3.group"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "start-stop/group3/group"); cValue.Exists() {
item.StartStopGroup3 = types.StringValue(cValue.String())
}
- if cValue := v.Get("start-stop.group4.group"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "start-stop/group4/group"); cValue.Exists() {
item.StartStopGroup4 = types.StringValue(cValue.String())
}
- if cValue := v.Get("stop-only.broadcast"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "stop-only/broadcast"); cValue.Exists() {
item.StopOnlyBroadcast = types.BoolValue(true)
} else {
item.StopOnlyBroadcast = types.BoolValue(false)
}
- if cValue := v.Get("stop-only.logger"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "stop-only/logger"); cValue.Exists() {
item.StopOnlyLogger = types.BoolValue(true)
} else {
item.StopOnlyLogger = types.BoolValue(false)
}
- if cValue := v.Get("stop-only.group1.group"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "stop-only/group1/group"); cValue.Exists() {
item.StopOnlyGroup1 = types.StringValue(cValue.String())
}
- if cValue := v.Get("stop-only.group2.group"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "stop-only/group2/group"); cValue.Exists() {
item.StopOnlyGroup2 = types.StringValue(cValue.String())
}
- if cValue := v.Get("stop-only.group3.group"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "stop-only/group3/group"); cValue.Exists() {
item.StopOnlyGroup3 = types.StringValue(cValue.String())
}
- if cValue := v.Get("stop-only.group4.group"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "stop-only/group4/group"); cValue.Exists() {
item.StopOnlyGroup4 = types.StringValue(cValue.String())
}
- if cValue := v.Get("wait-start.broadcast"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "wait-start/broadcast"); cValue.Exists() {
item.WaitStartBroadcast = types.BoolValue(true)
} else {
item.WaitStartBroadcast = types.BoolValue(false)
}
- if cValue := v.Get("wait-start.logger"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "wait-start/logger"); cValue.Exists() {
item.WaitStartLogger = types.BoolValue(true)
} else {
item.WaitStartLogger = types.BoolValue(false)
}
- if cValue := v.Get("wait-start.group1.group"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "wait-start/group1/group"); cValue.Exists() {
item.WaitStartGroup1 = types.StringValue(cValue.String())
}
- if cValue := v.Get("wait-start.group2.group"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "wait-start/group2/group"); cValue.Exists() {
item.WaitStartGroup2 = types.StringValue(cValue.String())
}
- if cValue := v.Get("wait-start.group3.group"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "wait-start/group3/group"); cValue.Exists() {
item.WaitStartGroup3 = types.StringValue(cValue.String())
}
- if cValue := v.Get("wait-start.group4.group"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "wait-start/group4/group"); cValue.Exists() {
item.WaitStartGroup4 = types.StringValue(cValue.String())
}
data.Connections = append(data.Connections, item)
return true
})
}
- if value := res.Get(prefix + "exec"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/exec"); value.Exists() {
data.Execs = make([]AAAAccountingExecs, 0)
- value.ForEach(func(k, v gjson.Result) bool {
+ value.ForEach(func(_ int, v xmldot.Result) bool {
item := AAAAccountingExecs{}
- if cValue := v.Get("name"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "name"); cValue.Exists() {
item.Name = types.StringValue(cValue.String())
}
- if cValue := v.Get("none"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "none"); cValue.Exists() {
item.None = types.BoolValue(true)
} else {
item.None = types.BoolValue(false)
}
- if cValue := v.Get("start-stop.broadcast"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "start-stop/broadcast"); cValue.Exists() {
item.StartStopBroadcast = types.BoolValue(true)
} else {
item.StartStopBroadcast = types.BoolValue(false)
}
- if cValue := v.Get("start-stop.logger"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "start-stop/logger"); cValue.Exists() {
item.StartStopLogger = types.BoolValue(true)
} else {
item.StartStopLogger = types.BoolValue(false)
}
- if cValue := v.Get("start-stop.group1.group"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "start-stop/group1/group"); cValue.Exists() {
item.StartStopGroup1 = types.StringValue(cValue.String())
}
- if cValue := v.Get("start-stop.group2.group"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "start-stop/group2/group"); cValue.Exists() {
item.StartStopGroup2 = types.StringValue(cValue.String())
}
- if cValue := v.Get("start-stop.group3.group"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "start-stop/group3/group"); cValue.Exists() {
item.StartStopGroup3 = types.StringValue(cValue.String())
}
- if cValue := v.Get("start-stop.group4.group"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "start-stop/group4/group"); cValue.Exists() {
item.StartStopGroup4 = types.StringValue(cValue.String())
}
- if cValue := v.Get("stop-only.broadcast"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "stop-only/broadcast"); cValue.Exists() {
item.StopOnlyBroadcast = types.BoolValue(true)
} else {
item.StopOnlyBroadcast = types.BoolValue(false)
}
- if cValue := v.Get("stop-only.logger"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "stop-only/logger"); cValue.Exists() {
item.StopOnlyLogger = types.BoolValue(true)
} else {
item.StopOnlyLogger = types.BoolValue(false)
}
- if cValue := v.Get("stop-only.group1.group"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "stop-only/group1/group"); cValue.Exists() {
item.StopOnlyGroup1 = types.StringValue(cValue.String())
}
- if cValue := v.Get("stop-only.group2.group"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "stop-only/group2/group"); cValue.Exists() {
item.StopOnlyGroup2 = types.StringValue(cValue.String())
}
- if cValue := v.Get("stop-only.group3.group"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "stop-only/group3/group"); cValue.Exists() {
item.StopOnlyGroup3 = types.StringValue(cValue.String())
}
- if cValue := v.Get("stop-only.group4.group"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "stop-only/group4/group"); cValue.Exists() {
item.StopOnlyGroup4 = types.StringValue(cValue.String())
}
- if cValue := v.Get("wait-start.broadcast"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "wait-start/broadcast"); cValue.Exists() {
item.WaitStartBroadcast = types.BoolValue(true)
} else {
item.WaitStartBroadcast = types.BoolValue(false)
}
- if cValue := v.Get("wait-start.logger"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "wait-start/logger"); cValue.Exists() {
item.WaitStartLogger = types.BoolValue(true)
} else {
item.WaitStartLogger = types.BoolValue(false)
}
- if cValue := v.Get("wait-start.group1.group"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "wait-start/group1/group"); cValue.Exists() {
item.WaitStartGroup1 = types.StringValue(cValue.String())
}
- if cValue := v.Get("wait-start.group2.group"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "wait-start/group2/group"); cValue.Exists() {
item.WaitStartGroup2 = types.StringValue(cValue.String())
}
- if cValue := v.Get("wait-start.group3.group"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "wait-start/group3/group"); cValue.Exists() {
item.WaitStartGroup3 = types.StringValue(cValue.String())
}
- if cValue := v.Get("wait-start.group4.group"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "wait-start/group4/group"); cValue.Exists() {
item.WaitStartGroup4 = types.StringValue(cValue.String())
}
data.Execs = append(data.Execs, item)
@@ -1600,7 +3088,7 @@ func (data *AAAAccountingData) fromBody(ctx context.Context, res gjson.Result) {
}
}
-// End of section. //template:end fromBodyData
+// End of section. //template:end fromBodyDataXML
// Section below is generated&owned by "gen/generator.go". //template:begin getDeletedItems
@@ -1751,30 +3239,300 @@ func (data *AAAAccounting) getDeletedItems(ctx context.Context, state AAAAccount
if !state.Connections[i].StartStopGroup2.IsNull() && data.Connections[j].StartStopGroup2.IsNull() {
deletedItems = append(deletedItems, fmt.Sprintf("%v/connection=%v/start-stop/group2/group", state.getPath(), strings.Join(stateKeyValues[:], ",")))
}
- if !state.Connections[i].StartStopGroup1.IsNull() && data.Connections[j].StartStopGroup1.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/connection=%v/start-stop/group1/group", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ if !state.Connections[i].StartStopGroup1.IsNull() && data.Connections[j].StartStopGroup1.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/connection=%v/start-stop/group1/group", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ if !state.Connections[i].StartStopLogger.IsNull() && data.Connections[j].StartStopLogger.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/connection=%v/start-stop/logger", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ if !state.Connections[i].StartStopBroadcast.IsNull() && data.Connections[j].StartStopBroadcast.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/connection=%v/start-stop/broadcast", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ if !state.Connections[i].None.IsNull() && data.Connections[j].None.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/connection=%v/none", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ if !state.Connections[i].Default.IsNull() && data.Connections[j].Default.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/connection=%v/default", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ break
+ }
+ }
+ if !found {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/connection=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ }
+ for i := range state.Commands {
+ stateKeyValues := [...]string{strconv.FormatInt(state.Commands[i].Level.ValueInt64(), 10), state.Commands[i].ListName.ValueString()}
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.Commands[i].Level.ValueInt64()).IsZero() {
+ emptyKeys = false
+ }
+ if !reflect.ValueOf(state.Commands[i].ListName.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.Commands {
+ found = true
+ if state.Commands[i].Level.ValueInt64() != data.Commands[j].Level.ValueInt64() {
+ found = false
+ }
+ if state.Commands[i].ListName.ValueString() != data.Commands[j].ListName.ValueString() {
+ found = false
+ }
+ if found {
+ if !state.Commands[i].Group4Group.IsNull() && data.Commands[j].Group4Group.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/commands=%v/commands-config/group-config/group4/group", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ if !state.Commands[i].Group3Group.IsNull() && data.Commands[j].Group3Group.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/commands=%v/commands-config/group-config/group3/group", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ if !state.Commands[i].Group2Group.IsNull() && data.Commands[j].Group2Group.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/commands=%v/commands-config/group-config/group2/group", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ if !state.Commands[i].Group1Group.IsNull() && data.Commands[j].Group1Group.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/commands=%v/commands-config/group-config/group1/group", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ if !state.Commands[i].GroupLogger.IsNull() && data.Commands[j].GroupLogger.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/commands=%v/commands-config/group-config/logger", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ if !state.Commands[i].GroupBroadcast.IsNull() && data.Commands[j].GroupBroadcast.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/commands=%v/commands-config/group-config/broadcast", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ if !state.Commands[i].Broadcast.IsNull() && data.Commands[j].Broadcast.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/commands=%v/commands-config/broadcast", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ if !state.Commands[i].ActionType.IsNull() && data.Commands[j].ActionType.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/commands=%v/commands-config/action-type", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ break
+ }
+ }
+ if !found {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/commands=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ }
+ if !state.SystemGuaranteeFirst.IsNull() && data.SystemGuaranteeFirst.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/system/guarantee-first", state.getPath()))
+ }
+ for i := range state.Networks {
+ stateKeyValues := [...]string{state.Networks[i].Id.ValueString()}
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.Networks[i].Id.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.Networks {
+ found = true
+ if state.Networks[i].Id.ValueString() != data.Networks[j].Id.ValueString() {
+ found = false
+ }
+ if found {
+ if !state.Networks[i].StartStopGroup2.IsNull() && data.Networks[j].StartStopGroup2.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/network=%v/start-stop/group-config/group2/group", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ if !state.Networks[i].StartStopGroup1.IsNull() && data.Networks[j].StartStopGroup1.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/network=%v/start-stop/group-config/group1/group", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ break
+ }
+ }
+ if !found {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/network=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ }
+ if !state.IdentityDefaultStartStopGroup4.IsNull() && data.IdentityDefaultStartStopGroup4.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/identity/default/start-stop/group-config/group4/group", state.getPath()))
+ }
+ if !state.IdentityDefaultStartStopGroup3.IsNull() && data.IdentityDefaultStartStopGroup3.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/identity/default/start-stop/group-config/group3/group", state.getPath()))
+ }
+ if !state.IdentityDefaultStartStopGroup2.IsNull() && data.IdentityDefaultStartStopGroup2.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/identity/default/start-stop/group-config/group2/group", state.getPath()))
+ }
+ if !state.IdentityDefaultStartStopGroup1.IsNull() && data.IdentityDefaultStartStopGroup1.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/identity/default/start-stop/group-config/group1/group", state.getPath()))
+ }
+ for i := range state.Identities {
+ stateKeyValues := [...]string{state.Identities[i].Name.ValueString()}
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.Identities[i].Name.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.Identities {
+ found = true
+ if state.Identities[i].Name.ValueString() != data.Identities[j].Name.ValueString() {
+ found = false
+ }
+ if found {
+ if !state.Identities[i].StartStopGroup4.IsNull() && data.Identities[j].StartStopGroup4.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/identity/accounting-list=%v/start-stop/group-config/group4/group", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ if !state.Identities[i].StartStopGroup3.IsNull() && data.Identities[j].StartStopGroup3.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/identity/accounting-list=%v/start-stop/group-config/group3/group", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ if !state.Identities[i].StartStopGroup2.IsNull() && data.Identities[j].StartStopGroup2.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/identity/accounting-list=%v/start-stop/group-config/group2/group", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ if !state.Identities[i].StartStopGroup1.IsNull() && data.Identities[j].StartStopGroup1.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/identity/accounting-list=%v/start-stop/group-config/group1/group", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ if !state.Identities[i].StartStopGroupLogger.IsNull() && data.Identities[j].StartStopGroupLogger.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/identity/accounting-list=%v/start-stop/group-config/logger", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ if !state.Identities[i].StartStopGroupBroadcast.IsNull() && data.Identities[j].StartStopGroupBroadcast.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/identity/accounting-list=%v/start-stop/group-config/broadcast", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ if !state.Identities[i].StartStopBroadcast.IsNull() && data.Identities[j].StartStopBroadcast.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/identity/accounting-list=%v/start-stop/broadcast", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ break
+ }
+ }
+ if !found {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/identity/accounting-list=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ }
+ if !state.UpdateNewinfoPeriodic.IsNull() && data.UpdateNewinfoPeriodic.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/update/newinfo/periodic", state.getPath()))
+ }
+
+ return deletedItems
+}
+
+// End of section. //template:end getDeletedItems
+
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletedItemsXML
+
+func (data *AAAAccounting) addDeletedItemsXML(ctx context.Context, state AAAAccounting, body string) string {
+ b := netconf.NewBody(body)
+ if !state.UpdateNewinfoPeriodic.IsNull() && data.UpdateNewinfoPeriodic.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/update/newinfo/periodic")
+ }
+ for i := range state.Identities {
+ stateKeys := [...]string{"name"}
+ stateKeyValues := [...]string{state.Identities[i].Name.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.Identities[i].Name.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.Identities {
+ found = true
+ if state.Identities[i].Name.ValueString() != data.Identities[j].Name.ValueString() {
+ found = false
+ }
+ if found {
+ if !state.Identities[i].StartStopBroadcast.IsNull() && data.Identities[j].StartStopBroadcast.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/identity/accounting-list%v/start-stop/broadcast", predicates))
+ }
+ if !state.Identities[i].StartStopGroupBroadcast.IsNull() && data.Identities[j].StartStopGroupBroadcast.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/identity/accounting-list%v/start-stop/group-config/broadcast", predicates))
+ }
+ if !state.Identities[i].StartStopGroupLogger.IsNull() && data.Identities[j].StartStopGroupLogger.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/identity/accounting-list%v/start-stop/group-config/logger", predicates))
+ }
+ if !state.Identities[i].StartStopGroup1.IsNull() && data.Identities[j].StartStopGroup1.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/identity/accounting-list%v/start-stop/group-config/group1/group", predicates))
+ }
+ if !state.Identities[i].StartStopGroup2.IsNull() && data.Identities[j].StartStopGroup2.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/identity/accounting-list%v/start-stop/group-config/group2/group", predicates))
}
- if !state.Connections[i].StartStopLogger.IsNull() && data.Connections[j].StartStopLogger.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/connection=%v/start-stop/logger", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ if !state.Identities[i].StartStopGroup3.IsNull() && data.Identities[j].StartStopGroup3.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/identity/accounting-list%v/start-stop/group-config/group3/group", predicates))
}
- if !state.Connections[i].StartStopBroadcast.IsNull() && data.Connections[j].StartStopBroadcast.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/connection=%v/start-stop/broadcast", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ if !state.Identities[i].StartStopGroup4.IsNull() && data.Identities[j].StartStopGroup4.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/identity/accounting-list%v/start-stop/group-config/group4/group", predicates))
}
- if !state.Connections[i].None.IsNull() && data.Connections[j].None.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/connection=%v/none", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ break
+ }
+ }
+ if !found {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/identity/accounting-list%v", predicates))
+ }
+ }
+ if !state.IdentityDefaultStartStopGroup1.IsNull() && data.IdentityDefaultStartStopGroup1.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/identity/default/start-stop/group-config/group1/group")
+ }
+ if !state.IdentityDefaultStartStopGroup2.IsNull() && data.IdentityDefaultStartStopGroup2.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/identity/default/start-stop/group-config/group2/group")
+ }
+ if !state.IdentityDefaultStartStopGroup3.IsNull() && data.IdentityDefaultStartStopGroup3.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/identity/default/start-stop/group-config/group3/group")
+ }
+ if !state.IdentityDefaultStartStopGroup4.IsNull() && data.IdentityDefaultStartStopGroup4.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/identity/default/start-stop/group-config/group4/group")
+ }
+ for i := range state.Networks {
+ stateKeys := [...]string{"id"}
+ stateKeyValues := [...]string{state.Networks[i].Id.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.Networks[i].Id.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.Networks {
+ found = true
+ if state.Networks[i].Id.ValueString() != data.Networks[j].Id.ValueString() {
+ found = false
+ }
+ if found {
+ if !state.Networks[i].StartStopGroup1.IsNull() && data.Networks[j].StartStopGroup1.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/network%v/start-stop/group-config/group1/group", predicates))
}
- if !state.Connections[i].Default.IsNull() && data.Connections[j].Default.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/connection=%v/default", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ if !state.Networks[i].StartStopGroup2.IsNull() && data.Networks[j].StartStopGroup2.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/network%v/start-stop/group-config/group2/group", predicates))
}
break
}
}
if !found {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/connection=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/network%v", predicates))
}
}
+ if !state.SystemGuaranteeFirst.IsNull() && data.SystemGuaranteeFirst.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/system/guarantee-first")
+ }
for i := range state.Commands {
+ stateKeys := [...]string{"level", "list-name"}
stateKeyValues := [...]string{strconv.FormatInt(state.Commands[i].Level.ValueInt64(), 10), state.Commands[i].ListName.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
emptyKeys := true
if !reflect.ValueOf(state.Commands[i].Level.ValueInt64()).IsZero() {
@@ -1797,45 +3555,47 @@ func (data *AAAAccounting) getDeletedItems(ctx context.Context, state AAAAccount
found = false
}
if found {
- if !state.Commands[i].Group4Group.IsNull() && data.Commands[j].Group4Group.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/commands=%v/commands-config/group-config/group4/group", state.getPath(), strings.Join(stateKeyValues[:], ",")))
- }
- if !state.Commands[i].Group3Group.IsNull() && data.Commands[j].Group3Group.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/commands=%v/commands-config/group-config/group3/group", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ if !state.Commands[i].ActionType.IsNull() && data.Commands[j].ActionType.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/commands%v/commands-config/action-type", predicates))
}
- if !state.Commands[i].Group2Group.IsNull() && data.Commands[j].Group2Group.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/commands=%v/commands-config/group-config/group2/group", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ if !state.Commands[i].Broadcast.IsNull() && data.Commands[j].Broadcast.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/commands%v/commands-config/broadcast", predicates))
}
- if !state.Commands[i].Group1Group.IsNull() && data.Commands[j].Group1Group.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/commands=%v/commands-config/group-config/group1/group", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ if !state.Commands[i].GroupBroadcast.IsNull() && data.Commands[j].GroupBroadcast.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/commands%v/commands-config/group-config/broadcast", predicates))
}
if !state.Commands[i].GroupLogger.IsNull() && data.Commands[j].GroupLogger.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/commands=%v/commands-config/group-config/logger", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/commands%v/commands-config/group-config/logger", predicates))
}
- if !state.Commands[i].GroupBroadcast.IsNull() && data.Commands[j].GroupBroadcast.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/commands=%v/commands-config/group-config/broadcast", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ if !state.Commands[i].Group1Group.IsNull() && data.Commands[j].Group1Group.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/commands%v/commands-config/group-config/group1/group", predicates))
}
- if !state.Commands[i].Broadcast.IsNull() && data.Commands[j].Broadcast.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/commands=%v/commands-config/broadcast", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ if !state.Commands[i].Group2Group.IsNull() && data.Commands[j].Group2Group.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/commands%v/commands-config/group-config/group2/group", predicates))
}
- if !state.Commands[i].ActionType.IsNull() && data.Commands[j].ActionType.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/commands=%v/commands-config/action-type", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ if !state.Commands[i].Group3Group.IsNull() && data.Commands[j].Group3Group.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/commands%v/commands-config/group-config/group3/group", predicates))
+ }
+ if !state.Commands[i].Group4Group.IsNull() && data.Commands[j].Group4Group.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/commands%v/commands-config/group-config/group4/group", predicates))
}
break
}
}
if !found {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/commands=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/commands%v", predicates))
}
}
- if !state.SystemGuaranteeFirst.IsNull() && data.SystemGuaranteeFirst.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/system/guarantee-first", state.getPath()))
- }
- for i := range state.Networks {
- stateKeyValues := [...]string{state.Networks[i].Id.ValueString()}
+ for i := range state.Connections {
+ stateKeys := [...]string{"name"}
+ stateKeyValues := [...]string{state.Connections[i].Name.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
emptyKeys := true
- if !reflect.ValueOf(state.Networks[i].Id.ValueString()).IsZero() {
+ if !reflect.ValueOf(state.Connections[i].Name.ValueString()).IsZero() {
emptyKeys = false
}
if emptyKeys {
@@ -1843,42 +3603,89 @@ func (data *AAAAccounting) getDeletedItems(ctx context.Context, state AAAAccount
}
found := false
- for j := range data.Networks {
+ for j := range data.Connections {
found = true
- if state.Networks[i].Id.ValueString() != data.Networks[j].Id.ValueString() {
+ if state.Connections[i].Name.ValueString() != data.Connections[j].Name.ValueString() {
found = false
}
if found {
- if !state.Networks[i].StartStopGroup2.IsNull() && data.Networks[j].StartStopGroup2.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/network=%v/start-stop/group-config/group2/group", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ if !state.Connections[i].Default.IsNull() && data.Connections[j].Default.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/connection%v/default", predicates))
}
- if !state.Networks[i].StartStopGroup1.IsNull() && data.Networks[j].StartStopGroup1.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/network=%v/start-stop/group-config/group1/group", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ if !state.Connections[i].None.IsNull() && data.Connections[j].None.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/connection%v/none", predicates))
+ }
+ if !state.Connections[i].StartStopBroadcast.IsNull() && data.Connections[j].StartStopBroadcast.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/connection%v/start-stop/broadcast", predicates))
+ }
+ if !state.Connections[i].StartStopLogger.IsNull() && data.Connections[j].StartStopLogger.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/connection%v/start-stop/logger", predicates))
+ }
+ if !state.Connections[i].StartStopGroup1.IsNull() && data.Connections[j].StartStopGroup1.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/connection%v/start-stop/group1/group", predicates))
+ }
+ if !state.Connections[i].StartStopGroup2.IsNull() && data.Connections[j].StartStopGroup2.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/connection%v/start-stop/group2/group", predicates))
+ }
+ if !state.Connections[i].StartStopGroup3.IsNull() && data.Connections[j].StartStopGroup3.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/connection%v/start-stop/group3/group", predicates))
+ }
+ if !state.Connections[i].StartStopGroup4.IsNull() && data.Connections[j].StartStopGroup4.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/connection%v/start-stop/group4/group", predicates))
+ }
+ if !state.Connections[i].StopOnlyBroadcast.IsNull() && data.Connections[j].StopOnlyBroadcast.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/connection%v/stop-only/broadcast", predicates))
+ }
+ if !state.Connections[i].StopOnlyLogger.IsNull() && data.Connections[j].StopOnlyLogger.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/connection%v/stop-only/logger", predicates))
+ }
+ if !state.Connections[i].StopOnlyGroup1.IsNull() && data.Connections[j].StopOnlyGroup1.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/connection%v/stop-only/group1/group", predicates))
+ }
+ if !state.Connections[i].StopOnlyGroup2.IsNull() && data.Connections[j].StopOnlyGroup2.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/connection%v/stop-only/group2/group", predicates))
+ }
+ if !state.Connections[i].StopOnlyGroup3.IsNull() && data.Connections[j].StopOnlyGroup3.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/connection%v/stop-only/group3/group", predicates))
+ }
+ if !state.Connections[i].StopOnlyGroup4.IsNull() && data.Connections[j].StopOnlyGroup4.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/connection%v/stop-only/group4/group", predicates))
+ }
+ if !state.Connections[i].WaitStartBroadcast.IsNull() && data.Connections[j].WaitStartBroadcast.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/connection%v/wait-start/broadcast", predicates))
+ }
+ if !state.Connections[i].WaitStartLogger.IsNull() && data.Connections[j].WaitStartLogger.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/connection%v/wait-start/logger", predicates))
+ }
+ if !state.Connections[i].WaitStartGroup1.IsNull() && data.Connections[j].WaitStartGroup1.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/connection%v/wait-start/group1/group", predicates))
+ }
+ if !state.Connections[i].WaitStartGroup2.IsNull() && data.Connections[j].WaitStartGroup2.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/connection%v/wait-start/group2/group", predicates))
+ }
+ if !state.Connections[i].WaitStartGroup3.IsNull() && data.Connections[j].WaitStartGroup3.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/connection%v/wait-start/group3/group", predicates))
+ }
+ if !state.Connections[i].WaitStartGroup4.IsNull() && data.Connections[j].WaitStartGroup4.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/connection%v/wait-start/group4/group", predicates))
}
break
}
}
if !found {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/network=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/connection%v", predicates))
}
}
- if !state.IdentityDefaultStartStopGroup4.IsNull() && data.IdentityDefaultStartStopGroup4.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/identity/default/start-stop/group-config/group4/group", state.getPath()))
- }
- if !state.IdentityDefaultStartStopGroup3.IsNull() && data.IdentityDefaultStartStopGroup3.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/identity/default/start-stop/group-config/group3/group", state.getPath()))
- }
- if !state.IdentityDefaultStartStopGroup2.IsNull() && data.IdentityDefaultStartStopGroup2.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/identity/default/start-stop/group-config/group2/group", state.getPath()))
- }
- if !state.IdentityDefaultStartStopGroup1.IsNull() && data.IdentityDefaultStartStopGroup1.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/identity/default/start-stop/group-config/group1/group", state.getPath()))
- }
- for i := range state.Identities {
- stateKeyValues := [...]string{state.Identities[i].Name.ValueString()}
+ for i := range state.Execs {
+ stateKeys := [...]string{"name"}
+ stateKeyValues := [...]string{state.Execs[i].Name.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
emptyKeys := true
- if !reflect.ValueOf(state.Identities[i].Name.ValueString()).IsZero() {
+ if !reflect.ValueOf(state.Execs[i].Name.ValueString()).IsZero() {
emptyKeys = false
}
if emptyKeys {
@@ -1886,48 +3693,81 @@ func (data *AAAAccounting) getDeletedItems(ctx context.Context, state AAAAccount
}
found := false
- for j := range data.Identities {
+ for j := range data.Execs {
found = true
- if state.Identities[i].Name.ValueString() != data.Identities[j].Name.ValueString() {
+ if state.Execs[i].Name.ValueString() != data.Execs[j].Name.ValueString() {
found = false
}
if found {
- if !state.Identities[i].StartStopGroup4.IsNull() && data.Identities[j].StartStopGroup4.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/identity/accounting-list=%v/start-stop/group-config/group4/group", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ if !state.Execs[i].None.IsNull() && data.Execs[j].None.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/exec%v/none", predicates))
}
- if !state.Identities[i].StartStopGroup3.IsNull() && data.Identities[j].StartStopGroup3.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/identity/accounting-list=%v/start-stop/group-config/group3/group", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ if !state.Execs[i].StartStopBroadcast.IsNull() && data.Execs[j].StartStopBroadcast.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/exec%v/start-stop/broadcast", predicates))
}
- if !state.Identities[i].StartStopGroup2.IsNull() && data.Identities[j].StartStopGroup2.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/identity/accounting-list=%v/start-stop/group-config/group2/group", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ if !state.Execs[i].StartStopLogger.IsNull() && data.Execs[j].StartStopLogger.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/exec%v/start-stop/logger", predicates))
}
- if !state.Identities[i].StartStopGroup1.IsNull() && data.Identities[j].StartStopGroup1.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/identity/accounting-list=%v/start-stop/group-config/group1/group", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ if !state.Execs[i].StartStopGroup1.IsNull() && data.Execs[j].StartStopGroup1.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/exec%v/start-stop/group1/group", predicates))
}
- if !state.Identities[i].StartStopGroupLogger.IsNull() && data.Identities[j].StartStopGroupLogger.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/identity/accounting-list=%v/start-stop/group-config/logger", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ if !state.Execs[i].StartStopGroup2.IsNull() && data.Execs[j].StartStopGroup2.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/exec%v/start-stop/group2/group", predicates))
}
- if !state.Identities[i].StartStopGroupBroadcast.IsNull() && data.Identities[j].StartStopGroupBroadcast.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/identity/accounting-list=%v/start-stop/group-config/broadcast", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ if !state.Execs[i].StartStopGroup3.IsNull() && data.Execs[j].StartStopGroup3.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/exec%v/start-stop/group3/group", predicates))
}
- if !state.Identities[i].StartStopBroadcast.IsNull() && data.Identities[j].StartStopBroadcast.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/identity/accounting-list=%v/start-stop/broadcast", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ if !state.Execs[i].StartStopGroup4.IsNull() && data.Execs[j].StartStopGroup4.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/exec%v/start-stop/group4/group", predicates))
+ }
+ if !state.Execs[i].StopOnlyBroadcast.IsNull() && data.Execs[j].StopOnlyBroadcast.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/exec%v/stop-only/broadcast", predicates))
+ }
+ if !state.Execs[i].StopOnlyLogger.IsNull() && data.Execs[j].StopOnlyLogger.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/exec%v/stop-only/logger", predicates))
+ }
+ if !state.Execs[i].StopOnlyGroup1.IsNull() && data.Execs[j].StopOnlyGroup1.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/exec%v/stop-only/group1/group", predicates))
+ }
+ if !state.Execs[i].StopOnlyGroup2.IsNull() && data.Execs[j].StopOnlyGroup2.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/exec%v/stop-only/group2/group", predicates))
+ }
+ if !state.Execs[i].StopOnlyGroup3.IsNull() && data.Execs[j].StopOnlyGroup3.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/exec%v/stop-only/group3/group", predicates))
+ }
+ if !state.Execs[i].StopOnlyGroup4.IsNull() && data.Execs[j].StopOnlyGroup4.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/exec%v/stop-only/group4/group", predicates))
+ }
+ if !state.Execs[i].WaitStartBroadcast.IsNull() && data.Execs[j].WaitStartBroadcast.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/exec%v/wait-start/broadcast", predicates))
+ }
+ if !state.Execs[i].WaitStartLogger.IsNull() && data.Execs[j].WaitStartLogger.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/exec%v/wait-start/logger", predicates))
+ }
+ if !state.Execs[i].WaitStartGroup1.IsNull() && data.Execs[j].WaitStartGroup1.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/exec%v/wait-start/group1/group", predicates))
+ }
+ if !state.Execs[i].WaitStartGroup2.IsNull() && data.Execs[j].WaitStartGroup2.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/exec%v/wait-start/group2/group", predicates))
+ }
+ if !state.Execs[i].WaitStartGroup3.IsNull() && data.Execs[j].WaitStartGroup3.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/exec%v/wait-start/group3/group", predicates))
+ }
+ if !state.Execs[i].WaitStartGroup4.IsNull() && data.Execs[j].WaitStartGroup4.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/exec%v/wait-start/group4/group", predicates))
}
break
}
}
if !found {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/identity/accounting-list=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/exec%v", predicates))
}
}
- if !state.UpdateNewinfoPeriodic.IsNull() && data.UpdateNewinfoPeriodic.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/update/newinfo/periodic", state.getPath()))
- }
- return deletedItems
+ return b.Res()
}
-// End of section. //template:end getDeletedItems
+// End of section. //template:end addDeletedItemsXML
// Section below is generated&owned by "gen/generator.go". //template:begin getEmptyLeafsDelete
@@ -2070,3 +3910,81 @@ func (data *AAAAccounting) getDeletePaths(ctx context.Context) []string {
}
// End of section. //template:end getDeletePaths
+
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletePathsXML
+
+func (data *AAAAccounting) addDeletePathsXML(ctx context.Context, body string) string {
+ b := netconf.NewBody(body)
+ if !data.UpdateNewinfoPeriodic.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/update/newinfo/periodic")
+ }
+ for i := range data.Identities {
+ keys := [...]string{"name"}
+ keyValues := [...]string{data.Identities[i].Name.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/identity/accounting-list%v", predicates))
+ }
+ if !data.IdentityDefaultStartStopGroup1.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/identity/default/start-stop/group-config/group1/group")
+ }
+ if !data.IdentityDefaultStartStopGroup2.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/identity/default/start-stop/group-config/group2/group")
+ }
+ if !data.IdentityDefaultStartStopGroup3.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/identity/default/start-stop/group-config/group3/group")
+ }
+ if !data.IdentityDefaultStartStopGroup4.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/identity/default/start-stop/group-config/group4/group")
+ }
+ for i := range data.Networks {
+ keys := [...]string{"id"}
+ keyValues := [...]string{data.Networks[i].Id.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/network%v", predicates))
+ }
+ if !data.SystemGuaranteeFirst.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/system/guarantee-first")
+ }
+ for i := range data.Commands {
+ keys := [...]string{"level", "list-name"}
+ keyValues := [...]string{strconv.FormatInt(data.Commands[i].Level.ValueInt64(), 10), data.Commands[i].ListName.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/commands%v", predicates))
+ }
+ for i := range data.Connections {
+ keys := [...]string{"name"}
+ keyValues := [...]string{data.Connections[i].Name.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/connection%v", predicates))
+ }
+ for i := range data.Execs {
+ keys := [...]string{"name"}
+ keyValues := [...]string{data.Execs[i].Name.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/exec%v", predicates))
+ }
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletePathsXML
diff --git a/internal/provider/model_iosxe_aaa_authentication.go b/internal/provider/model_iosxe_aaa_authentication.go
index 1c438756..f1f052f8 100644
--- a/internal/provider/model_iosxe_aaa_authentication.go
+++ b/internal/provider/model_iosxe_aaa_authentication.go
@@ -30,6 +30,9 @@ import (
"github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/types"
+ "github.com/hashicorp/terraform-plugin-log/tflog"
+ "github.com/netascode/go-netconf"
+ "github.com/netascode/xmldot"
"github.com/tidwall/gjson"
"github.com/tidwall/sjson"
)
@@ -173,6 +176,17 @@ func (data AAAAuthentication) getPathShort() string {
return matches[1]
}
+// getXPath returns the XPath for NETCONF operations
+func (data AAAAuthentication) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/aaa/Cisco-IOS-XE-aaa:authentication"
+ return path
+}
+
+func (data AAAAuthenticationData) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/aaa/Cisco-IOS-XE-aaa:authentication"
+ return path
+}
+
// End of section. //template:end getPath
// Section below is generated&owned by "gen/generator.go". //template:begin toBody
@@ -472,6 +486,389 @@ func (data AAAAuthentication) toBody(ctx context.Context) string {
// End of section. //template:end toBody
+// Section below is generated&owned by "gen/generator.go". //template:begin toBodyXML
+
+func (data AAAAuthentication) toBodyXML(ctx context.Context) string {
+ body := netconf.Body{}
+ if len(data.Logins) > 0 {
+ for _, item := range data.Logins {
+ cBody := netconf.Body{}
+ if !item.Name.IsNull() && !item.Name.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "name", item.Name.ValueString())
+ }
+ if !item.A1None.IsNull() && !item.A1None.IsUnknown() {
+ if item.A1None.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "a1/none", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "a1/none")
+ }
+ }
+ if !item.A1Line.IsNull() && !item.A1Line.IsUnknown() {
+ if item.A1Line.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "a1/line", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "a1/line")
+ }
+ }
+ if !item.A1Enable.IsNull() && !item.A1Enable.IsUnknown() {
+ if item.A1Enable.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "a1/enable", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "a1/enable")
+ }
+ }
+ if !item.A1Local.IsNull() && !item.A1Local.IsUnknown() {
+ if item.A1Local.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "a1/local", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "a1/local")
+ }
+ }
+ if !item.A1Group.IsNull() && !item.A1Group.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "a1/group", item.A1Group.ValueString())
+ }
+ if !item.A2None.IsNull() && !item.A2None.IsUnknown() {
+ if item.A2None.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "a2/none", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "a2/none")
+ }
+ }
+ if !item.A2Line.IsNull() && !item.A2Line.IsUnknown() {
+ if item.A2Line.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "a2/line", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "a2/line")
+ }
+ }
+ if !item.A2Enable.IsNull() && !item.A2Enable.IsUnknown() {
+ if item.A2Enable.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "a2/enable", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "a2/enable")
+ }
+ }
+ if !item.A2Local.IsNull() && !item.A2Local.IsUnknown() {
+ if item.A2Local.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "a2/local", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "a2/local")
+ }
+ }
+ if !item.A2Group.IsNull() && !item.A2Group.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "a2/group", item.A2Group.ValueString())
+ }
+ if !item.A3None.IsNull() && !item.A3None.IsUnknown() {
+ if item.A3None.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "a3/none", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "a3/none")
+ }
+ }
+ if !item.A3Line.IsNull() && !item.A3Line.IsUnknown() {
+ if item.A3Line.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "a3/line", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "a3/line")
+ }
+ }
+ if !item.A3Enable.IsNull() && !item.A3Enable.IsUnknown() {
+ if item.A3Enable.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "a3/enable", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "a3/enable")
+ }
+ }
+ if !item.A3Local.IsNull() && !item.A3Local.IsUnknown() {
+ if item.A3Local.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "a3/local", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "a3/local")
+ }
+ }
+ if !item.A3Group.IsNull() && !item.A3Group.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "a3/group", item.A3Group.ValueString())
+ }
+ if !item.A4None.IsNull() && !item.A4None.IsUnknown() {
+ if item.A4None.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "a4/none", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "a4/none")
+ }
+ }
+ if !item.A4Line.IsNull() && !item.A4Line.IsUnknown() {
+ if item.A4Line.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "a4/line", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "a4/line")
+ }
+ }
+ if !item.A4Enable.IsNull() && !item.A4Enable.IsUnknown() {
+ if item.A4Enable.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "a4/enable", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "a4/enable")
+ }
+ }
+ if !item.A4Local.IsNull() && !item.A4Local.IsUnknown() {
+ if item.A4Local.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "a4/local", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "a4/local")
+ }
+ }
+ if !item.A4Group.IsNull() && !item.A4Group.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "a4/group", item.A4Group.ValueString())
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/login", cBody.Res())
+ }
+ }
+ if len(data.Dot1x) > 0 {
+ for _, item := range data.Dot1x {
+ cBody := netconf.Body{}
+ if !item.Name.IsNull() && !item.Name.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "name", item.Name.ValueString())
+ }
+ if !item.A1Group.IsNull() && !item.A1Group.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "a1-config/group", item.A1Group.ValueString())
+ }
+ if !item.A1Local.IsNull() && !item.A1Local.IsUnknown() {
+ if item.A1Local.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "a1-config/local", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "a1-config/local")
+ }
+ }
+ if !item.A1Cache.IsNull() && !item.A1Cache.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "a1-config/cache", item.A1Cache.ValueString())
+ }
+ if !item.A1Radius.IsNull() && !item.A1Radius.IsUnknown() {
+ if item.A1Radius.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "a1-config/radius", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "a1-config/radius")
+ }
+ }
+ if !item.A2Group.IsNull() && !item.A2Group.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "a2-config/group", item.A2Group.ValueString())
+ }
+ if !item.A2Local.IsNull() && !item.A2Local.IsUnknown() {
+ if item.A2Local.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "a2-config/local", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "a2-config/local")
+ }
+ }
+ if !item.A2Cache.IsNull() && !item.A2Cache.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "a2-config/cache", item.A2Cache.ValueString())
+ }
+ if !item.A2Radius.IsNull() && !item.A2Radius.IsUnknown() {
+ if item.A2Radius.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "a2-config/radius", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "a2-config/radius")
+ }
+ }
+ if !item.A3Group.IsNull() && !item.A3Group.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "a3-config/group", item.A3Group.ValueString())
+ }
+ if !item.A3Local.IsNull() && !item.A3Local.IsUnknown() {
+ if item.A3Local.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "a3-config/local", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "a3-config/local")
+ }
+ }
+ if !item.A3Cache.IsNull() && !item.A3Cache.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "a3-config/cache", item.A3Cache.ValueString())
+ }
+ if !item.A3Radius.IsNull() && !item.A3Radius.IsUnknown() {
+ if item.A3Radius.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "a3-config/radius", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "a3-config/radius")
+ }
+ }
+ if !item.A4Group.IsNull() && !item.A4Group.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "a4-config/group", item.A4Group.ValueString())
+ }
+ if !item.A4Local.IsNull() && !item.A4Local.IsUnknown() {
+ if item.A4Local.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "a4-config/local", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "a4-config/local")
+ }
+ }
+ if !item.A4Cache.IsNull() && !item.A4Cache.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "a4-config/cache", item.A4Cache.ValueString())
+ }
+ if !item.A4Radius.IsNull() && !item.A4Radius.IsUnknown() {
+ if item.A4Radius.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "a4-config/radius", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "a4-config/radius")
+ }
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/dot1x/dot1x-list", cBody.Res())
+ }
+ }
+ if !data.Dot1xDefaultA1Group.IsNull() && !data.Dot1xDefaultA1Group.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/dot1x/default/a1-config/group", data.Dot1xDefaultA1Group.ValueString())
+ }
+ if !data.Dot1xDefaultA1Local.IsNull() && !data.Dot1xDefaultA1Local.IsUnknown() {
+ if data.Dot1xDefaultA1Local.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/dot1x/default/a1-config/local", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/dot1x/default/a1-config/local")
+ }
+ }
+ if !data.Dot1xDefaultA2Group.IsNull() && !data.Dot1xDefaultA2Group.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/dot1x/default/a2-config/group", data.Dot1xDefaultA2Group.ValueString())
+ }
+ if !data.Dot1xDefaultA2Local.IsNull() && !data.Dot1xDefaultA2Local.IsUnknown() {
+ if data.Dot1xDefaultA2Local.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/dot1x/default/a2-config/local", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/dot1x/default/a2-config/local")
+ }
+ }
+ if !data.Dot1xDefaultA3Group.IsNull() && !data.Dot1xDefaultA3Group.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/dot1x/default/a3-config/group", data.Dot1xDefaultA3Group.ValueString())
+ }
+ if !data.Dot1xDefaultA3Local.IsNull() && !data.Dot1xDefaultA3Local.IsUnknown() {
+ if data.Dot1xDefaultA3Local.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/dot1x/default/a3-config/local", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/dot1x/default/a3-config/local")
+ }
+ }
+ if !data.Dot1xDefaultA4Group.IsNull() && !data.Dot1xDefaultA4Group.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/dot1x/default/a4-config/group", data.Dot1xDefaultA4Group.ValueString())
+ }
+ if !data.Dot1xDefaultA4Local.IsNull() && !data.Dot1xDefaultA4Local.IsUnknown() {
+ if data.Dot1xDefaultA4Local.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/dot1x/default/a4-config/local", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/dot1x/default/a4-config/local")
+ }
+ }
+ if !data.EnableDefaultGroup1Cache.IsNull() && !data.EnableDefaultGroup1Cache.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/enable/default/group1/cache", data.EnableDefaultGroup1Cache.ValueString())
+ }
+ if !data.EnableDefaultGroup1Enable.IsNull() && !data.EnableDefaultGroup1Enable.IsUnknown() {
+ if data.EnableDefaultGroup1Enable.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/enable/default/group1/enable", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/enable/default/group1/enable")
+ }
+ }
+ if !data.EnableDefaultGroup1Group.IsNull() && !data.EnableDefaultGroup1Group.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/enable/default/group1/group", data.EnableDefaultGroup1Group.ValueString())
+ }
+ if !data.EnableDefaultGroup1Line.IsNull() && !data.EnableDefaultGroup1Line.IsUnknown() {
+ if data.EnableDefaultGroup1Line.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/enable/default/group1/line", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/enable/default/group1/line")
+ }
+ }
+ if !data.EnableDefaultGroup1None.IsNull() && !data.EnableDefaultGroup1None.IsUnknown() {
+ if data.EnableDefaultGroup1None.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/enable/default/group1/none", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/enable/default/group1/none")
+ }
+ }
+ if !data.EnableDefaultGroup2Cache.IsNull() && !data.EnableDefaultGroup2Cache.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/enable/default/group2/cache", data.EnableDefaultGroup2Cache.ValueString())
+ }
+ if !data.EnableDefaultGroup2Enable.IsNull() && !data.EnableDefaultGroup2Enable.IsUnknown() {
+ if data.EnableDefaultGroup2Enable.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/enable/default/group2/enable", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/enable/default/group2/enable")
+ }
+ }
+ if !data.EnableDefaultGroup2Group.IsNull() && !data.EnableDefaultGroup2Group.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/enable/default/group2/group", data.EnableDefaultGroup2Group.ValueString())
+ }
+ if !data.EnableDefaultGroup2Line.IsNull() && !data.EnableDefaultGroup2Line.IsUnknown() {
+ if data.EnableDefaultGroup2Line.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/enable/default/group2/line", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/enable/default/group2/line")
+ }
+ }
+ if !data.EnableDefaultGroup2None.IsNull() && !data.EnableDefaultGroup2None.IsUnknown() {
+ if data.EnableDefaultGroup2None.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/enable/default/group2/none", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/enable/default/group2/none")
+ }
+ }
+ if !data.EnableDefaultGroup3Cache.IsNull() && !data.EnableDefaultGroup3Cache.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/enable/default/group3/cache", data.EnableDefaultGroup3Cache.ValueString())
+ }
+ if !data.EnableDefaultGroup3Enable.IsNull() && !data.EnableDefaultGroup3Enable.IsUnknown() {
+ if data.EnableDefaultGroup3Enable.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/enable/default/group3/enable", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/enable/default/group3/enable")
+ }
+ }
+ if !data.EnableDefaultGroup3Group.IsNull() && !data.EnableDefaultGroup3Group.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/enable/default/group3/group", data.EnableDefaultGroup3Group.ValueString())
+ }
+ if !data.EnableDefaultGroup3Line.IsNull() && !data.EnableDefaultGroup3Line.IsUnknown() {
+ if data.EnableDefaultGroup3Line.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/enable/default/group3/line", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/enable/default/group3/line")
+ }
+ }
+ if !data.EnableDefaultGroup3None.IsNull() && !data.EnableDefaultGroup3None.IsUnknown() {
+ if data.EnableDefaultGroup3None.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/enable/default/group3/none", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/enable/default/group3/none")
+ }
+ }
+ if !data.EnableDefaultGroup4Cache.IsNull() && !data.EnableDefaultGroup4Cache.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/enable/default/group4/cache", data.EnableDefaultGroup4Cache.ValueString())
+ }
+ if !data.EnableDefaultGroup4Enable.IsNull() && !data.EnableDefaultGroup4Enable.IsUnknown() {
+ if data.EnableDefaultGroup4Enable.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/enable/default/group4/enable", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/enable/default/group4/enable")
+ }
+ }
+ if !data.EnableDefaultGroup4Group.IsNull() && !data.EnableDefaultGroup4Group.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/enable/default/group4/group", data.EnableDefaultGroup4Group.ValueString())
+ }
+ if !data.EnableDefaultGroup4Line.IsNull() && !data.EnableDefaultGroup4Line.IsUnknown() {
+ if data.EnableDefaultGroup4Line.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/enable/default/group4/line", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/enable/default/group4/line")
+ }
+ }
+ if !data.EnableDefaultGroup4None.IsNull() && !data.EnableDefaultGroup4None.IsUnknown() {
+ if data.EnableDefaultGroup4None.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/enable/default/group4/none", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/enable/default/group4/none")
+ }
+ }
+ bodyString, err := body.String()
+ if err != nil {
+ tflog.Error(ctx, fmt.Sprintf("Error converting body to string: %s", err))
+ }
+ return bodyString
+}
+
+// End of section. //template:end toBodyXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBody
func (data *AAAAuthentication) updateFromBody(ctx context.Context, res gjson.Result) {
@@ -1021,183 +1418,1334 @@ func (data *AAAAuthentication) updateFromBody(ctx context.Context, res gjson.Res
// End of section. //template:end updateFromBody
-// Section below is generated&owned by "gen/generator.go". //template:begin fromBody
+// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBodyXML
-func (data *AAAAuthentication) fromBody(ctx context.Context, res gjson.Result) {
- prefix := helpers.LastElement(data.getPath()) + "."
- if res.Get(helpers.LastElement(data.getPath())).IsArray() {
- prefix += "0."
- }
- if value := res.Get(prefix + "login"); value.Exists() {
- data.Logins = make([]AAAAuthenticationLogins, 0)
- value.ForEach(func(k, v gjson.Result) bool {
- item := AAAAuthenticationLogins{}
- if cValue := v.Get("name"); cValue.Exists() {
- item.Name = types.StringValue(cValue.String())
- }
+func (data *AAAAuthentication) updateFromBodyXML(ctx context.Context, res xmldot.Result) {
+ for i := range data.Logins {
+ keys := [...]string{"name"}
+ keyValues := [...]string{data.Logins[i].Name.ValueString()}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/login").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, "name"); value.Exists() && !data.Logins[i].Name.IsNull() {
+ data.Logins[i].Name = types.StringValue(value.String())
+ } else {
+ data.Logins[i].Name = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "a1/none"); !data.Logins[i].A1None.IsNull() {
+ if value.Exists() {
+ data.Logins[i].A1None = types.BoolValue(true)
+ } else {
+ data.Logins[i].A1None = types.BoolValue(false)
+ }
+ } else {
+ data.Logins[i].A1None = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "a1/line"); !data.Logins[i].A1Line.IsNull() {
+ if value.Exists() {
+ data.Logins[i].A1Line = types.BoolValue(true)
+ } else {
+ data.Logins[i].A1Line = types.BoolValue(false)
+ }
+ } else {
+ data.Logins[i].A1Line = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "a1/enable"); !data.Logins[i].A1Enable.IsNull() {
+ if value.Exists() {
+ data.Logins[i].A1Enable = types.BoolValue(true)
+ } else {
+ data.Logins[i].A1Enable = types.BoolValue(false)
+ }
+ } else {
+ data.Logins[i].A1Enable = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "a1/local"); !data.Logins[i].A1Local.IsNull() {
+ if value.Exists() {
+ data.Logins[i].A1Local = types.BoolValue(true)
+ } else {
+ data.Logins[i].A1Local = types.BoolValue(false)
+ }
+ } else {
+ data.Logins[i].A1Local = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "a1/group"); value.Exists() && !data.Logins[i].A1Group.IsNull() {
+ data.Logins[i].A1Group = types.StringValue(value.String())
+ } else {
+ data.Logins[i].A1Group = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "a2/none"); !data.Logins[i].A2None.IsNull() {
+ if value.Exists() {
+ data.Logins[i].A2None = types.BoolValue(true)
+ } else {
+ data.Logins[i].A2None = types.BoolValue(false)
+ }
+ } else {
+ data.Logins[i].A2None = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "a2/line"); !data.Logins[i].A2Line.IsNull() {
+ if value.Exists() {
+ data.Logins[i].A2Line = types.BoolValue(true)
+ } else {
+ data.Logins[i].A2Line = types.BoolValue(false)
+ }
+ } else {
+ data.Logins[i].A2Line = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "a2/enable"); !data.Logins[i].A2Enable.IsNull() {
+ if value.Exists() {
+ data.Logins[i].A2Enable = types.BoolValue(true)
+ } else {
+ data.Logins[i].A2Enable = types.BoolValue(false)
+ }
+ } else {
+ data.Logins[i].A2Enable = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "a2/local"); !data.Logins[i].A2Local.IsNull() {
+ if value.Exists() {
+ data.Logins[i].A2Local = types.BoolValue(true)
+ } else {
+ data.Logins[i].A2Local = types.BoolValue(false)
+ }
+ } else {
+ data.Logins[i].A2Local = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "a2/group"); value.Exists() && !data.Logins[i].A2Group.IsNull() {
+ data.Logins[i].A2Group = types.StringValue(value.String())
+ } else {
+ data.Logins[i].A2Group = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "a3/none"); !data.Logins[i].A3None.IsNull() {
+ if value.Exists() {
+ data.Logins[i].A3None = types.BoolValue(true)
+ } else {
+ data.Logins[i].A3None = types.BoolValue(false)
+ }
+ } else {
+ data.Logins[i].A3None = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "a3/line"); !data.Logins[i].A3Line.IsNull() {
+ if value.Exists() {
+ data.Logins[i].A3Line = types.BoolValue(true)
+ } else {
+ data.Logins[i].A3Line = types.BoolValue(false)
+ }
+ } else {
+ data.Logins[i].A3Line = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "a3/enable"); !data.Logins[i].A3Enable.IsNull() {
+ if value.Exists() {
+ data.Logins[i].A3Enable = types.BoolValue(true)
+ } else {
+ data.Logins[i].A3Enable = types.BoolValue(false)
+ }
+ } else {
+ data.Logins[i].A3Enable = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "a3/local"); !data.Logins[i].A3Local.IsNull() {
+ if value.Exists() {
+ data.Logins[i].A3Local = types.BoolValue(true)
+ } else {
+ data.Logins[i].A3Local = types.BoolValue(false)
+ }
+ } else {
+ data.Logins[i].A3Local = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "a3/group"); value.Exists() && !data.Logins[i].A3Group.IsNull() {
+ data.Logins[i].A3Group = types.StringValue(value.String())
+ } else {
+ data.Logins[i].A3Group = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "a4/none"); !data.Logins[i].A4None.IsNull() {
+ if value.Exists() {
+ data.Logins[i].A4None = types.BoolValue(true)
+ } else {
+ data.Logins[i].A4None = types.BoolValue(false)
+ }
+ } else {
+ data.Logins[i].A4None = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "a4/line"); !data.Logins[i].A4Line.IsNull() {
+ if value.Exists() {
+ data.Logins[i].A4Line = types.BoolValue(true)
+ } else {
+ data.Logins[i].A4Line = types.BoolValue(false)
+ }
+ } else {
+ data.Logins[i].A4Line = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "a4/enable"); !data.Logins[i].A4Enable.IsNull() {
+ if value.Exists() {
+ data.Logins[i].A4Enable = types.BoolValue(true)
+ } else {
+ data.Logins[i].A4Enable = types.BoolValue(false)
+ }
+ } else {
+ data.Logins[i].A4Enable = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "a4/local"); !data.Logins[i].A4Local.IsNull() {
+ if value.Exists() {
+ data.Logins[i].A4Local = types.BoolValue(true)
+ } else {
+ data.Logins[i].A4Local = types.BoolValue(false)
+ }
+ } else {
+ data.Logins[i].A4Local = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "a4/group"); value.Exists() && !data.Logins[i].A4Group.IsNull() {
+ data.Logins[i].A4Group = types.StringValue(value.String())
+ } else {
+ data.Logins[i].A4Group = types.StringNull()
+ }
+ }
+ for i := range data.Dot1x {
+ keys := [...]string{"name"}
+ keyValues := [...]string{data.Dot1x[i].Name.ValueString()}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/dot1x/dot1x-list").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, "name"); value.Exists() && !data.Dot1x[i].Name.IsNull() {
+ data.Dot1x[i].Name = types.StringValue(value.String())
+ } else {
+ data.Dot1x[i].Name = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "a1-config/group"); value.Exists() && !data.Dot1x[i].A1Group.IsNull() {
+ data.Dot1x[i].A1Group = types.StringValue(value.String())
+ } else {
+ data.Dot1x[i].A1Group = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "a1-config/local"); !data.Dot1x[i].A1Local.IsNull() {
+ if value.Exists() {
+ data.Dot1x[i].A1Local = types.BoolValue(true)
+ } else {
+ data.Dot1x[i].A1Local = types.BoolValue(false)
+ }
+ } else {
+ data.Dot1x[i].A1Local = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "a1-config/cache"); value.Exists() && !data.Dot1x[i].A1Cache.IsNull() {
+ data.Dot1x[i].A1Cache = types.StringValue(value.String())
+ } else {
+ data.Dot1x[i].A1Cache = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "a1-config/radius"); !data.Dot1x[i].A1Radius.IsNull() {
+ if value.Exists() {
+ data.Dot1x[i].A1Radius = types.BoolValue(true)
+ } else {
+ data.Dot1x[i].A1Radius = types.BoolValue(false)
+ }
+ } else {
+ data.Dot1x[i].A1Radius = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "a2-config/group"); value.Exists() && !data.Dot1x[i].A2Group.IsNull() {
+ data.Dot1x[i].A2Group = types.StringValue(value.String())
+ } else {
+ data.Dot1x[i].A2Group = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "a2-config/local"); !data.Dot1x[i].A2Local.IsNull() {
+ if value.Exists() {
+ data.Dot1x[i].A2Local = types.BoolValue(true)
+ } else {
+ data.Dot1x[i].A2Local = types.BoolValue(false)
+ }
+ } else {
+ data.Dot1x[i].A2Local = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "a2-config/cache"); value.Exists() && !data.Dot1x[i].A2Cache.IsNull() {
+ data.Dot1x[i].A2Cache = types.StringValue(value.String())
+ } else {
+ data.Dot1x[i].A2Cache = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "a2-config/radius"); !data.Dot1x[i].A2Radius.IsNull() {
+ if value.Exists() {
+ data.Dot1x[i].A2Radius = types.BoolValue(true)
+ } else {
+ data.Dot1x[i].A2Radius = types.BoolValue(false)
+ }
+ } else {
+ data.Dot1x[i].A2Radius = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "a3-config/group"); value.Exists() && !data.Dot1x[i].A3Group.IsNull() {
+ data.Dot1x[i].A3Group = types.StringValue(value.String())
+ } else {
+ data.Dot1x[i].A3Group = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "a3-config/local"); !data.Dot1x[i].A3Local.IsNull() {
+ if value.Exists() {
+ data.Dot1x[i].A3Local = types.BoolValue(true)
+ } else {
+ data.Dot1x[i].A3Local = types.BoolValue(false)
+ }
+ } else {
+ data.Dot1x[i].A3Local = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "a3-config/cache"); value.Exists() && !data.Dot1x[i].A3Cache.IsNull() {
+ data.Dot1x[i].A3Cache = types.StringValue(value.String())
+ } else {
+ data.Dot1x[i].A3Cache = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "a3-config/radius"); !data.Dot1x[i].A3Radius.IsNull() {
+ if value.Exists() {
+ data.Dot1x[i].A3Radius = types.BoolValue(true)
+ } else {
+ data.Dot1x[i].A3Radius = types.BoolValue(false)
+ }
+ } else {
+ data.Dot1x[i].A3Radius = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "a4-config/group"); value.Exists() && !data.Dot1x[i].A4Group.IsNull() {
+ data.Dot1x[i].A4Group = types.StringValue(value.String())
+ } else {
+ data.Dot1x[i].A4Group = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "a4-config/local"); !data.Dot1x[i].A4Local.IsNull() {
+ if value.Exists() {
+ data.Dot1x[i].A4Local = types.BoolValue(true)
+ } else {
+ data.Dot1x[i].A4Local = types.BoolValue(false)
+ }
+ } else {
+ data.Dot1x[i].A4Local = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "a4-config/cache"); value.Exists() && !data.Dot1x[i].A4Cache.IsNull() {
+ data.Dot1x[i].A4Cache = types.StringValue(value.String())
+ } else {
+ data.Dot1x[i].A4Cache = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "a4-config/radius"); !data.Dot1x[i].A4Radius.IsNull() {
+ if value.Exists() {
+ data.Dot1x[i].A4Radius = types.BoolValue(true)
+ } else {
+ data.Dot1x[i].A4Radius = types.BoolValue(false)
+ }
+ } else {
+ data.Dot1x[i].A4Radius = types.BoolNull()
+ }
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/dot1x/default/a1-config/group"); value.Exists() && !data.Dot1xDefaultA1Group.IsNull() {
+ data.Dot1xDefaultA1Group = types.StringValue(value.String())
+ } else {
+ data.Dot1xDefaultA1Group = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/dot1x/default/a1-config/local"); !data.Dot1xDefaultA1Local.IsNull() {
+ if value.Exists() {
+ data.Dot1xDefaultA1Local = types.BoolValue(true)
+ } else {
+ data.Dot1xDefaultA1Local = types.BoolValue(false)
+ }
+ } else {
+ data.Dot1xDefaultA1Local = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/dot1x/default/a2-config/group"); value.Exists() && !data.Dot1xDefaultA2Group.IsNull() {
+ data.Dot1xDefaultA2Group = types.StringValue(value.String())
+ } else {
+ data.Dot1xDefaultA2Group = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/dot1x/default/a2-config/local"); !data.Dot1xDefaultA2Local.IsNull() {
+ if value.Exists() {
+ data.Dot1xDefaultA2Local = types.BoolValue(true)
+ } else {
+ data.Dot1xDefaultA2Local = types.BoolValue(false)
+ }
+ } else {
+ data.Dot1xDefaultA2Local = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/dot1x/default/a3-config/group"); value.Exists() && !data.Dot1xDefaultA3Group.IsNull() {
+ data.Dot1xDefaultA3Group = types.StringValue(value.String())
+ } else {
+ data.Dot1xDefaultA3Group = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/dot1x/default/a3-config/local"); !data.Dot1xDefaultA3Local.IsNull() {
+ if value.Exists() {
+ data.Dot1xDefaultA3Local = types.BoolValue(true)
+ } else {
+ data.Dot1xDefaultA3Local = types.BoolValue(false)
+ }
+ } else {
+ data.Dot1xDefaultA3Local = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/dot1x/default/a4-config/group"); value.Exists() && !data.Dot1xDefaultA4Group.IsNull() {
+ data.Dot1xDefaultA4Group = types.StringValue(value.String())
+ } else {
+ data.Dot1xDefaultA4Group = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/dot1x/default/a4-config/local"); !data.Dot1xDefaultA4Local.IsNull() {
+ if value.Exists() {
+ data.Dot1xDefaultA4Local = types.BoolValue(true)
+ } else {
+ data.Dot1xDefaultA4Local = types.BoolValue(false)
+ }
+ } else {
+ data.Dot1xDefaultA4Local = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/enable/default/group1/cache"); value.Exists() && !data.EnableDefaultGroup1Cache.IsNull() {
+ data.EnableDefaultGroup1Cache = types.StringValue(value.String())
+ } else {
+ data.EnableDefaultGroup1Cache = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/enable/default/group1/enable"); !data.EnableDefaultGroup1Enable.IsNull() {
+ if value.Exists() {
+ data.EnableDefaultGroup1Enable = types.BoolValue(true)
+ } else {
+ data.EnableDefaultGroup1Enable = types.BoolValue(false)
+ }
+ } else {
+ data.EnableDefaultGroup1Enable = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/enable/default/group1/group"); value.Exists() && !data.EnableDefaultGroup1Group.IsNull() {
+ data.EnableDefaultGroup1Group = types.StringValue(value.String())
+ } else {
+ data.EnableDefaultGroup1Group = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/enable/default/group1/line"); !data.EnableDefaultGroup1Line.IsNull() {
+ if value.Exists() {
+ data.EnableDefaultGroup1Line = types.BoolValue(true)
+ } else {
+ data.EnableDefaultGroup1Line = types.BoolValue(false)
+ }
+ } else {
+ data.EnableDefaultGroup1Line = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/enable/default/group1/none"); !data.EnableDefaultGroup1None.IsNull() {
+ if value.Exists() {
+ data.EnableDefaultGroup1None = types.BoolValue(true)
+ } else {
+ data.EnableDefaultGroup1None = types.BoolValue(false)
+ }
+ } else {
+ data.EnableDefaultGroup1None = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/enable/default/group2/cache"); value.Exists() && !data.EnableDefaultGroup2Cache.IsNull() {
+ data.EnableDefaultGroup2Cache = types.StringValue(value.String())
+ } else {
+ data.EnableDefaultGroup2Cache = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/enable/default/group2/enable"); !data.EnableDefaultGroup2Enable.IsNull() {
+ if value.Exists() {
+ data.EnableDefaultGroup2Enable = types.BoolValue(true)
+ } else {
+ data.EnableDefaultGroup2Enable = types.BoolValue(false)
+ }
+ } else {
+ data.EnableDefaultGroup2Enable = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/enable/default/group2/group"); value.Exists() && !data.EnableDefaultGroup2Group.IsNull() {
+ data.EnableDefaultGroup2Group = types.StringValue(value.String())
+ } else {
+ data.EnableDefaultGroup2Group = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/enable/default/group2/line"); !data.EnableDefaultGroup2Line.IsNull() {
+ if value.Exists() {
+ data.EnableDefaultGroup2Line = types.BoolValue(true)
+ } else {
+ data.EnableDefaultGroup2Line = types.BoolValue(false)
+ }
+ } else {
+ data.EnableDefaultGroup2Line = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/enable/default/group2/none"); !data.EnableDefaultGroup2None.IsNull() {
+ if value.Exists() {
+ data.EnableDefaultGroup2None = types.BoolValue(true)
+ } else {
+ data.EnableDefaultGroup2None = types.BoolValue(false)
+ }
+ } else {
+ data.EnableDefaultGroup2None = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/enable/default/group3/cache"); value.Exists() && !data.EnableDefaultGroup3Cache.IsNull() {
+ data.EnableDefaultGroup3Cache = types.StringValue(value.String())
+ } else {
+ data.EnableDefaultGroup3Cache = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/enable/default/group3/enable"); !data.EnableDefaultGroup3Enable.IsNull() {
+ if value.Exists() {
+ data.EnableDefaultGroup3Enable = types.BoolValue(true)
+ } else {
+ data.EnableDefaultGroup3Enable = types.BoolValue(false)
+ }
+ } else {
+ data.EnableDefaultGroup3Enable = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/enable/default/group3/group"); value.Exists() && !data.EnableDefaultGroup3Group.IsNull() {
+ data.EnableDefaultGroup3Group = types.StringValue(value.String())
+ } else {
+ data.EnableDefaultGroup3Group = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/enable/default/group3/line"); !data.EnableDefaultGroup3Line.IsNull() {
+ if value.Exists() {
+ data.EnableDefaultGroup3Line = types.BoolValue(true)
+ } else {
+ data.EnableDefaultGroup3Line = types.BoolValue(false)
+ }
+ } else {
+ data.EnableDefaultGroup3Line = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/enable/default/group3/none"); !data.EnableDefaultGroup3None.IsNull() {
+ if value.Exists() {
+ data.EnableDefaultGroup3None = types.BoolValue(true)
+ } else {
+ data.EnableDefaultGroup3None = types.BoolValue(false)
+ }
+ } else {
+ data.EnableDefaultGroup3None = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/enable/default/group4/cache"); value.Exists() && !data.EnableDefaultGroup4Cache.IsNull() {
+ data.EnableDefaultGroup4Cache = types.StringValue(value.String())
+ } else {
+ data.EnableDefaultGroup4Cache = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/enable/default/group4/enable"); !data.EnableDefaultGroup4Enable.IsNull() {
+ if value.Exists() {
+ data.EnableDefaultGroup4Enable = types.BoolValue(true)
+ } else {
+ data.EnableDefaultGroup4Enable = types.BoolValue(false)
+ }
+ } else {
+ data.EnableDefaultGroup4Enable = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/enable/default/group4/group"); value.Exists() && !data.EnableDefaultGroup4Group.IsNull() {
+ data.EnableDefaultGroup4Group = types.StringValue(value.String())
+ } else {
+ data.EnableDefaultGroup4Group = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/enable/default/group4/line"); !data.EnableDefaultGroup4Line.IsNull() {
+ if value.Exists() {
+ data.EnableDefaultGroup4Line = types.BoolValue(true)
+ } else {
+ data.EnableDefaultGroup4Line = types.BoolValue(false)
+ }
+ } else {
+ data.EnableDefaultGroup4Line = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/enable/default/group4/none"); !data.EnableDefaultGroup4None.IsNull() {
+ if value.Exists() {
+ data.EnableDefaultGroup4None = types.BoolValue(true)
+ } else {
+ data.EnableDefaultGroup4None = types.BoolValue(false)
+ }
+ } else {
+ data.EnableDefaultGroup4None = types.BoolNull()
+ }
+}
+
+// End of section. //template:end updateFromBodyXML
+
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBody
+
+func (data *AAAAuthentication) fromBody(ctx context.Context, res gjson.Result) {
+ prefix := helpers.LastElement(data.getPath()) + "."
+ if res.Get(helpers.LastElement(data.getPath())).IsArray() {
+ prefix += "0."
+ }
+ if value := res.Get(prefix + "login"); value.Exists() {
+ data.Logins = make([]AAAAuthenticationLogins, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := AAAAuthenticationLogins{}
+ if cValue := v.Get("name"); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("a1.none"); cValue.Exists() {
+ item.A1None = types.BoolValue(true)
+ } else {
+ item.A1None = types.BoolValue(false)
+ }
+ if cValue := v.Get("a1.line"); cValue.Exists() {
+ item.A1Line = types.BoolValue(true)
+ } else {
+ item.A1Line = types.BoolValue(false)
+ }
+ if cValue := v.Get("a1.enable"); cValue.Exists() {
+ item.A1Enable = types.BoolValue(true)
+ } else {
+ item.A1Enable = types.BoolValue(false)
+ }
+ if cValue := v.Get("a1.local"); cValue.Exists() {
+ item.A1Local = types.BoolValue(true)
+ } else {
+ item.A1Local = types.BoolValue(false)
+ }
+ if cValue := v.Get("a1.group"); cValue.Exists() {
+ item.A1Group = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("a2.none"); cValue.Exists() {
+ item.A2None = types.BoolValue(true)
+ } else {
+ item.A2None = types.BoolValue(false)
+ }
+ if cValue := v.Get("a2.line"); cValue.Exists() {
+ item.A2Line = types.BoolValue(true)
+ } else {
+ item.A2Line = types.BoolValue(false)
+ }
+ if cValue := v.Get("a2.enable"); cValue.Exists() {
+ item.A2Enable = types.BoolValue(true)
+ } else {
+ item.A2Enable = types.BoolValue(false)
+ }
+ if cValue := v.Get("a2.local"); cValue.Exists() {
+ item.A2Local = types.BoolValue(true)
+ } else {
+ item.A2Local = types.BoolValue(false)
+ }
+ if cValue := v.Get("a2.group"); cValue.Exists() {
+ item.A2Group = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("a3.none"); cValue.Exists() {
+ item.A3None = types.BoolValue(true)
+ } else {
+ item.A3None = types.BoolValue(false)
+ }
+ if cValue := v.Get("a3.line"); cValue.Exists() {
+ item.A3Line = types.BoolValue(true)
+ } else {
+ item.A3Line = types.BoolValue(false)
+ }
+ if cValue := v.Get("a3.enable"); cValue.Exists() {
+ item.A3Enable = types.BoolValue(true)
+ } else {
+ item.A3Enable = types.BoolValue(false)
+ }
+ if cValue := v.Get("a3.local"); cValue.Exists() {
+ item.A3Local = types.BoolValue(true)
+ } else {
+ item.A3Local = types.BoolValue(false)
+ }
+ if cValue := v.Get("a3.group"); cValue.Exists() {
+ item.A3Group = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("a4.none"); cValue.Exists() {
+ item.A4None = types.BoolValue(true)
+ } else {
+ item.A4None = types.BoolValue(false)
+ }
+ if cValue := v.Get("a4.line"); cValue.Exists() {
+ item.A4Line = types.BoolValue(true)
+ } else {
+ item.A4Line = types.BoolValue(false)
+ }
+ if cValue := v.Get("a4.enable"); cValue.Exists() {
+ item.A4Enable = types.BoolValue(true)
+ } else {
+ item.A4Enable = types.BoolValue(false)
+ }
+ if cValue := v.Get("a4.local"); cValue.Exists() {
+ item.A4Local = types.BoolValue(true)
+ } else {
+ item.A4Local = types.BoolValue(false)
+ }
+ if cValue := v.Get("a4.group"); cValue.Exists() {
+ item.A4Group = types.StringValue(cValue.String())
+ }
+ data.Logins = append(data.Logins, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + "dot1x.dot1x-list"); value.Exists() {
+ data.Dot1x = make([]AAAAuthenticationDot1x, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := AAAAuthenticationDot1x{}
+ if cValue := v.Get("name"); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("a1-config.group"); cValue.Exists() {
+ item.A1Group = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("a1-config.local"); cValue.Exists() {
+ item.A1Local = types.BoolValue(true)
+ } else {
+ item.A1Local = types.BoolValue(false)
+ }
+ if cValue := v.Get("a1-config.cache"); cValue.Exists() {
+ item.A1Cache = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("a1-config.radius"); cValue.Exists() {
+ item.A1Radius = types.BoolValue(true)
+ } else {
+ item.A1Radius = types.BoolValue(false)
+ }
+ if cValue := v.Get("a2-config.group"); cValue.Exists() {
+ item.A2Group = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("a2-config.local"); cValue.Exists() {
+ item.A2Local = types.BoolValue(true)
+ } else {
+ item.A2Local = types.BoolValue(false)
+ }
+ if cValue := v.Get("a2-config.cache"); cValue.Exists() {
+ item.A2Cache = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("a2-config.radius"); cValue.Exists() {
+ item.A2Radius = types.BoolValue(true)
+ } else {
+ item.A2Radius = types.BoolValue(false)
+ }
+ if cValue := v.Get("a3-config.group"); cValue.Exists() {
+ item.A3Group = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("a3-config.local"); cValue.Exists() {
+ item.A3Local = types.BoolValue(true)
+ } else {
+ item.A3Local = types.BoolValue(false)
+ }
+ if cValue := v.Get("a3-config.cache"); cValue.Exists() {
+ item.A3Cache = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("a3-config.radius"); cValue.Exists() {
+ item.A3Radius = types.BoolValue(true)
+ } else {
+ item.A3Radius = types.BoolValue(false)
+ }
+ if cValue := v.Get("a4-config.group"); cValue.Exists() {
+ item.A4Group = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("a4-config.local"); cValue.Exists() {
+ item.A4Local = types.BoolValue(true)
+ } else {
+ item.A4Local = types.BoolValue(false)
+ }
+ if cValue := v.Get("a4-config.cache"); cValue.Exists() {
+ item.A4Cache = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("a4-config.radius"); cValue.Exists() {
+ item.A4Radius = types.BoolValue(true)
+ } else {
+ item.A4Radius = types.BoolValue(false)
+ }
+ data.Dot1x = append(data.Dot1x, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + "dot1x.default.a1-config.group"); value.Exists() {
+ data.Dot1xDefaultA1Group = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "dot1x.default.a1-config.local"); value.Exists() {
+ data.Dot1xDefaultA1Local = types.BoolValue(true)
+ } else {
+ data.Dot1xDefaultA1Local = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "dot1x.default.a2-config.group"); value.Exists() {
+ data.Dot1xDefaultA2Group = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "dot1x.default.a2-config.local"); value.Exists() {
+ data.Dot1xDefaultA2Local = types.BoolValue(true)
+ } else {
+ data.Dot1xDefaultA2Local = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "dot1x.default.a3-config.group"); value.Exists() {
+ data.Dot1xDefaultA3Group = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "dot1x.default.a3-config.local"); value.Exists() {
+ data.Dot1xDefaultA3Local = types.BoolValue(true)
+ } else {
+ data.Dot1xDefaultA3Local = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "dot1x.default.a4-config.group"); value.Exists() {
+ data.Dot1xDefaultA4Group = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "dot1x.default.a4-config.local"); value.Exists() {
+ data.Dot1xDefaultA4Local = types.BoolValue(true)
+ } else {
+ data.Dot1xDefaultA4Local = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "enable.default.group1.cache"); value.Exists() {
+ data.EnableDefaultGroup1Cache = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "enable.default.group1.enable"); value.Exists() {
+ data.EnableDefaultGroup1Enable = types.BoolValue(true)
+ } else {
+ data.EnableDefaultGroup1Enable = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "enable.default.group1.group"); value.Exists() {
+ data.EnableDefaultGroup1Group = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "enable.default.group1.line"); value.Exists() {
+ data.EnableDefaultGroup1Line = types.BoolValue(true)
+ } else {
+ data.EnableDefaultGroup1Line = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "enable.default.group1.none"); value.Exists() {
+ data.EnableDefaultGroup1None = types.BoolValue(true)
+ } else {
+ data.EnableDefaultGroup1None = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "enable.default.group2.cache"); value.Exists() {
+ data.EnableDefaultGroup2Cache = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "enable.default.group2.enable"); value.Exists() {
+ data.EnableDefaultGroup2Enable = types.BoolValue(true)
+ } else {
+ data.EnableDefaultGroup2Enable = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "enable.default.group2.group"); value.Exists() {
+ data.EnableDefaultGroup2Group = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "enable.default.group2.line"); value.Exists() {
+ data.EnableDefaultGroup2Line = types.BoolValue(true)
+ } else {
+ data.EnableDefaultGroup2Line = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "enable.default.group2.none"); value.Exists() {
+ data.EnableDefaultGroup2None = types.BoolValue(true)
+ } else {
+ data.EnableDefaultGroup2None = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "enable.default.group3.cache"); value.Exists() {
+ data.EnableDefaultGroup3Cache = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "enable.default.group3.enable"); value.Exists() {
+ data.EnableDefaultGroup3Enable = types.BoolValue(true)
+ } else {
+ data.EnableDefaultGroup3Enable = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "enable.default.group3.group"); value.Exists() {
+ data.EnableDefaultGroup3Group = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "enable.default.group3.line"); value.Exists() {
+ data.EnableDefaultGroup3Line = types.BoolValue(true)
+ } else {
+ data.EnableDefaultGroup3Line = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "enable.default.group3.none"); value.Exists() {
+ data.EnableDefaultGroup3None = types.BoolValue(true)
+ } else {
+ data.EnableDefaultGroup3None = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "enable.default.group4.cache"); value.Exists() {
+ data.EnableDefaultGroup4Cache = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "enable.default.group4.enable"); value.Exists() {
+ data.EnableDefaultGroup4Enable = types.BoolValue(true)
+ } else {
+ data.EnableDefaultGroup4Enable = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "enable.default.group4.group"); value.Exists() {
+ data.EnableDefaultGroup4Group = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "enable.default.group4.line"); value.Exists() {
+ data.EnableDefaultGroup4Line = types.BoolValue(true)
+ } else {
+ data.EnableDefaultGroup4Line = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "enable.default.group4.none"); value.Exists() {
+ data.EnableDefaultGroup4None = types.BoolValue(true)
+ } else {
+ data.EnableDefaultGroup4None = types.BoolValue(false)
+ }
+}
+
+// End of section. //template:end fromBody
+
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyData
+
+func (data *AAAAuthenticationData) fromBody(ctx context.Context, res gjson.Result) {
+ prefix := helpers.LastElement(data.getPath()) + "."
+ if res.Get(helpers.LastElement(data.getPath())).IsArray() {
+ prefix += "0."
+ }
+ if value := res.Get(prefix + "login"); value.Exists() {
+ data.Logins = make([]AAAAuthenticationLogins, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := AAAAuthenticationLogins{}
+ if cValue := v.Get("name"); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
if cValue := v.Get("a1.none"); cValue.Exists() {
item.A1None = types.BoolValue(true)
} else {
item.A1None = types.BoolValue(false)
}
- if cValue := v.Get("a1.line"); cValue.Exists() {
+ if cValue := v.Get("a1.line"); cValue.Exists() {
+ item.A1Line = types.BoolValue(true)
+ } else {
+ item.A1Line = types.BoolValue(false)
+ }
+ if cValue := v.Get("a1.enable"); cValue.Exists() {
+ item.A1Enable = types.BoolValue(true)
+ } else {
+ item.A1Enable = types.BoolValue(false)
+ }
+ if cValue := v.Get("a1.local"); cValue.Exists() {
+ item.A1Local = types.BoolValue(true)
+ } else {
+ item.A1Local = types.BoolValue(false)
+ }
+ if cValue := v.Get("a1.group"); cValue.Exists() {
+ item.A1Group = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("a2.none"); cValue.Exists() {
+ item.A2None = types.BoolValue(true)
+ } else {
+ item.A2None = types.BoolValue(false)
+ }
+ if cValue := v.Get("a2.line"); cValue.Exists() {
+ item.A2Line = types.BoolValue(true)
+ } else {
+ item.A2Line = types.BoolValue(false)
+ }
+ if cValue := v.Get("a2.enable"); cValue.Exists() {
+ item.A2Enable = types.BoolValue(true)
+ } else {
+ item.A2Enable = types.BoolValue(false)
+ }
+ if cValue := v.Get("a2.local"); cValue.Exists() {
+ item.A2Local = types.BoolValue(true)
+ } else {
+ item.A2Local = types.BoolValue(false)
+ }
+ if cValue := v.Get("a2.group"); cValue.Exists() {
+ item.A2Group = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("a3.none"); cValue.Exists() {
+ item.A3None = types.BoolValue(true)
+ } else {
+ item.A3None = types.BoolValue(false)
+ }
+ if cValue := v.Get("a3.line"); cValue.Exists() {
+ item.A3Line = types.BoolValue(true)
+ } else {
+ item.A3Line = types.BoolValue(false)
+ }
+ if cValue := v.Get("a3.enable"); cValue.Exists() {
+ item.A3Enable = types.BoolValue(true)
+ } else {
+ item.A3Enable = types.BoolValue(false)
+ }
+ if cValue := v.Get("a3.local"); cValue.Exists() {
+ item.A3Local = types.BoolValue(true)
+ } else {
+ item.A3Local = types.BoolValue(false)
+ }
+ if cValue := v.Get("a3.group"); cValue.Exists() {
+ item.A3Group = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("a4.none"); cValue.Exists() {
+ item.A4None = types.BoolValue(true)
+ } else {
+ item.A4None = types.BoolValue(false)
+ }
+ if cValue := v.Get("a4.line"); cValue.Exists() {
+ item.A4Line = types.BoolValue(true)
+ } else {
+ item.A4Line = types.BoolValue(false)
+ }
+ if cValue := v.Get("a4.enable"); cValue.Exists() {
+ item.A4Enable = types.BoolValue(true)
+ } else {
+ item.A4Enable = types.BoolValue(false)
+ }
+ if cValue := v.Get("a4.local"); cValue.Exists() {
+ item.A4Local = types.BoolValue(true)
+ } else {
+ item.A4Local = types.BoolValue(false)
+ }
+ if cValue := v.Get("a4.group"); cValue.Exists() {
+ item.A4Group = types.StringValue(cValue.String())
+ }
+ data.Logins = append(data.Logins, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + "dot1x.dot1x-list"); value.Exists() {
+ data.Dot1x = make([]AAAAuthenticationDot1x, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := AAAAuthenticationDot1x{}
+ if cValue := v.Get("name"); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("a1-config.group"); cValue.Exists() {
+ item.A1Group = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("a1-config.local"); cValue.Exists() {
+ item.A1Local = types.BoolValue(true)
+ } else {
+ item.A1Local = types.BoolValue(false)
+ }
+ if cValue := v.Get("a1-config.cache"); cValue.Exists() {
+ item.A1Cache = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("a1-config.radius"); cValue.Exists() {
+ item.A1Radius = types.BoolValue(true)
+ } else {
+ item.A1Radius = types.BoolValue(false)
+ }
+ if cValue := v.Get("a2-config.group"); cValue.Exists() {
+ item.A2Group = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("a2-config.local"); cValue.Exists() {
+ item.A2Local = types.BoolValue(true)
+ } else {
+ item.A2Local = types.BoolValue(false)
+ }
+ if cValue := v.Get("a2-config.cache"); cValue.Exists() {
+ item.A2Cache = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("a2-config.radius"); cValue.Exists() {
+ item.A2Radius = types.BoolValue(true)
+ } else {
+ item.A2Radius = types.BoolValue(false)
+ }
+ if cValue := v.Get("a3-config.group"); cValue.Exists() {
+ item.A3Group = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("a3-config.local"); cValue.Exists() {
+ item.A3Local = types.BoolValue(true)
+ } else {
+ item.A3Local = types.BoolValue(false)
+ }
+ if cValue := v.Get("a3-config.cache"); cValue.Exists() {
+ item.A3Cache = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("a3-config.radius"); cValue.Exists() {
+ item.A3Radius = types.BoolValue(true)
+ } else {
+ item.A3Radius = types.BoolValue(false)
+ }
+ if cValue := v.Get("a4-config.group"); cValue.Exists() {
+ item.A4Group = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("a4-config.local"); cValue.Exists() {
+ item.A4Local = types.BoolValue(true)
+ } else {
+ item.A4Local = types.BoolValue(false)
+ }
+ if cValue := v.Get("a4-config.cache"); cValue.Exists() {
+ item.A4Cache = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("a4-config.radius"); cValue.Exists() {
+ item.A4Radius = types.BoolValue(true)
+ } else {
+ item.A4Radius = types.BoolValue(false)
+ }
+ data.Dot1x = append(data.Dot1x, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + "dot1x.default.a1-config.group"); value.Exists() {
+ data.Dot1xDefaultA1Group = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "dot1x.default.a1-config.local"); value.Exists() {
+ data.Dot1xDefaultA1Local = types.BoolValue(true)
+ } else {
+ data.Dot1xDefaultA1Local = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "dot1x.default.a2-config.group"); value.Exists() {
+ data.Dot1xDefaultA2Group = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "dot1x.default.a2-config.local"); value.Exists() {
+ data.Dot1xDefaultA2Local = types.BoolValue(true)
+ } else {
+ data.Dot1xDefaultA2Local = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "dot1x.default.a3-config.group"); value.Exists() {
+ data.Dot1xDefaultA3Group = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "dot1x.default.a3-config.local"); value.Exists() {
+ data.Dot1xDefaultA3Local = types.BoolValue(true)
+ } else {
+ data.Dot1xDefaultA3Local = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "dot1x.default.a4-config.group"); value.Exists() {
+ data.Dot1xDefaultA4Group = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "dot1x.default.a4-config.local"); value.Exists() {
+ data.Dot1xDefaultA4Local = types.BoolValue(true)
+ } else {
+ data.Dot1xDefaultA4Local = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "enable.default.group1.cache"); value.Exists() {
+ data.EnableDefaultGroup1Cache = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "enable.default.group1.enable"); value.Exists() {
+ data.EnableDefaultGroup1Enable = types.BoolValue(true)
+ } else {
+ data.EnableDefaultGroup1Enable = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "enable.default.group1.group"); value.Exists() {
+ data.EnableDefaultGroup1Group = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "enable.default.group1.line"); value.Exists() {
+ data.EnableDefaultGroup1Line = types.BoolValue(true)
+ } else {
+ data.EnableDefaultGroup1Line = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "enable.default.group1.none"); value.Exists() {
+ data.EnableDefaultGroup1None = types.BoolValue(true)
+ } else {
+ data.EnableDefaultGroup1None = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "enable.default.group2.cache"); value.Exists() {
+ data.EnableDefaultGroup2Cache = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "enable.default.group2.enable"); value.Exists() {
+ data.EnableDefaultGroup2Enable = types.BoolValue(true)
+ } else {
+ data.EnableDefaultGroup2Enable = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "enable.default.group2.group"); value.Exists() {
+ data.EnableDefaultGroup2Group = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "enable.default.group2.line"); value.Exists() {
+ data.EnableDefaultGroup2Line = types.BoolValue(true)
+ } else {
+ data.EnableDefaultGroup2Line = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "enable.default.group2.none"); value.Exists() {
+ data.EnableDefaultGroup2None = types.BoolValue(true)
+ } else {
+ data.EnableDefaultGroup2None = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "enable.default.group3.cache"); value.Exists() {
+ data.EnableDefaultGroup3Cache = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "enable.default.group3.enable"); value.Exists() {
+ data.EnableDefaultGroup3Enable = types.BoolValue(true)
+ } else {
+ data.EnableDefaultGroup3Enable = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "enable.default.group3.group"); value.Exists() {
+ data.EnableDefaultGroup3Group = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "enable.default.group3.line"); value.Exists() {
+ data.EnableDefaultGroup3Line = types.BoolValue(true)
+ } else {
+ data.EnableDefaultGroup3Line = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "enable.default.group3.none"); value.Exists() {
+ data.EnableDefaultGroup3None = types.BoolValue(true)
+ } else {
+ data.EnableDefaultGroup3None = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "enable.default.group4.cache"); value.Exists() {
+ data.EnableDefaultGroup4Cache = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "enable.default.group4.enable"); value.Exists() {
+ data.EnableDefaultGroup4Enable = types.BoolValue(true)
+ } else {
+ data.EnableDefaultGroup4Enable = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "enable.default.group4.group"); value.Exists() {
+ data.EnableDefaultGroup4Group = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "enable.default.group4.line"); value.Exists() {
+ data.EnableDefaultGroup4Line = types.BoolValue(true)
+ } else {
+ data.EnableDefaultGroup4Line = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "enable.default.group4.none"); value.Exists() {
+ data.EnableDefaultGroup4None = types.BoolValue(true)
+ } else {
+ data.EnableDefaultGroup4None = types.BoolValue(false)
+ }
+}
+
+// End of section. //template:end fromBodyData
+
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyXML
+
+func (data *AAAAuthentication) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/login"); value.Exists() {
+ data.Logins = make([]AAAAuthenticationLogins, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := AAAAuthenticationLogins{}
+ if cValue := helpers.GetFromXPath(v, "name"); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "a1/none"); cValue.Exists() {
+ item.A1None = types.BoolValue(true)
+ } else {
+ item.A1None = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "a1/line"); cValue.Exists() {
item.A1Line = types.BoolValue(true)
} else {
item.A1Line = types.BoolValue(false)
}
- if cValue := v.Get("a1.enable"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "a1/enable"); cValue.Exists() {
item.A1Enable = types.BoolValue(true)
} else {
item.A1Enable = types.BoolValue(false)
}
- if cValue := v.Get("a1.local"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "a1/local"); cValue.Exists() {
item.A1Local = types.BoolValue(true)
} else {
item.A1Local = types.BoolValue(false)
}
- if cValue := v.Get("a1.group"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "a1/group"); cValue.Exists() {
item.A1Group = types.StringValue(cValue.String())
}
- if cValue := v.Get("a2.none"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "a2/none"); cValue.Exists() {
item.A2None = types.BoolValue(true)
} else {
item.A2None = types.BoolValue(false)
}
- if cValue := v.Get("a2.line"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "a2/line"); cValue.Exists() {
item.A2Line = types.BoolValue(true)
} else {
item.A2Line = types.BoolValue(false)
}
- if cValue := v.Get("a2.enable"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "a2/enable"); cValue.Exists() {
item.A2Enable = types.BoolValue(true)
} else {
item.A2Enable = types.BoolValue(false)
}
- if cValue := v.Get("a2.local"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "a2/local"); cValue.Exists() {
item.A2Local = types.BoolValue(true)
} else {
item.A2Local = types.BoolValue(false)
}
- if cValue := v.Get("a2.group"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "a2/group"); cValue.Exists() {
item.A2Group = types.StringValue(cValue.String())
}
- if cValue := v.Get("a3.none"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "a3/none"); cValue.Exists() {
item.A3None = types.BoolValue(true)
} else {
item.A3None = types.BoolValue(false)
}
- if cValue := v.Get("a3.line"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "a3/line"); cValue.Exists() {
item.A3Line = types.BoolValue(true)
} else {
item.A3Line = types.BoolValue(false)
}
- if cValue := v.Get("a3.enable"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "a3/enable"); cValue.Exists() {
item.A3Enable = types.BoolValue(true)
} else {
item.A3Enable = types.BoolValue(false)
}
- if cValue := v.Get("a3.local"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "a3/local"); cValue.Exists() {
item.A3Local = types.BoolValue(true)
} else {
item.A3Local = types.BoolValue(false)
}
- if cValue := v.Get("a3.group"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "a3/group"); cValue.Exists() {
item.A3Group = types.StringValue(cValue.String())
}
- if cValue := v.Get("a4.none"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "a4/none"); cValue.Exists() {
item.A4None = types.BoolValue(true)
} else {
item.A4None = types.BoolValue(false)
}
- if cValue := v.Get("a4.line"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "a4/line"); cValue.Exists() {
item.A4Line = types.BoolValue(true)
} else {
item.A4Line = types.BoolValue(false)
}
- if cValue := v.Get("a4.enable"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "a4/enable"); cValue.Exists() {
item.A4Enable = types.BoolValue(true)
} else {
item.A4Enable = types.BoolValue(false)
}
- if cValue := v.Get("a4.local"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "a4/local"); cValue.Exists() {
item.A4Local = types.BoolValue(true)
} else {
item.A4Local = types.BoolValue(false)
}
- if cValue := v.Get("a4.group"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "a4/group"); cValue.Exists() {
item.A4Group = types.StringValue(cValue.String())
}
data.Logins = append(data.Logins, item)
return true
})
}
- if value := res.Get(prefix + "dot1x.dot1x-list"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/dot1x/dot1x-list"); value.Exists() {
data.Dot1x = make([]AAAAuthenticationDot1x, 0)
- value.ForEach(func(k, v gjson.Result) bool {
+ value.ForEach(func(_ int, v xmldot.Result) bool {
item := AAAAuthenticationDot1x{}
- if cValue := v.Get("name"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "name"); cValue.Exists() {
item.Name = types.StringValue(cValue.String())
}
- if cValue := v.Get("a1-config.group"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "a1-config/group"); cValue.Exists() {
item.A1Group = types.StringValue(cValue.String())
}
- if cValue := v.Get("a1-config.local"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "a1-config/local"); cValue.Exists() {
item.A1Local = types.BoolValue(true)
} else {
item.A1Local = types.BoolValue(false)
}
- if cValue := v.Get("a1-config.cache"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "a1-config/cache"); cValue.Exists() {
item.A1Cache = types.StringValue(cValue.String())
}
- if cValue := v.Get("a1-config.radius"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "a1-config/radius"); cValue.Exists() {
item.A1Radius = types.BoolValue(true)
} else {
item.A1Radius = types.BoolValue(false)
}
- if cValue := v.Get("a2-config.group"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "a2-config/group"); cValue.Exists() {
item.A2Group = types.StringValue(cValue.String())
}
- if cValue := v.Get("a2-config.local"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "a2-config/local"); cValue.Exists() {
item.A2Local = types.BoolValue(true)
} else {
item.A2Local = types.BoolValue(false)
}
- if cValue := v.Get("a2-config.cache"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "a2-config/cache"); cValue.Exists() {
item.A2Cache = types.StringValue(cValue.String())
}
- if cValue := v.Get("a2-config.radius"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "a2-config/radius"); cValue.Exists() {
item.A2Radius = types.BoolValue(true)
} else {
item.A2Radius = types.BoolValue(false)
}
- if cValue := v.Get("a3-config.group"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "a3-config/group"); cValue.Exists() {
item.A3Group = types.StringValue(cValue.String())
}
- if cValue := v.Get("a3-config.local"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "a3-config/local"); cValue.Exists() {
item.A3Local = types.BoolValue(true)
} else {
item.A3Local = types.BoolValue(false)
}
- if cValue := v.Get("a3-config.cache"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "a3-config/cache"); cValue.Exists() {
item.A3Cache = types.StringValue(cValue.String())
}
- if cValue := v.Get("a3-config.radius"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "a3-config/radius"); cValue.Exists() {
item.A3Radius = types.BoolValue(true)
} else {
item.A3Radius = types.BoolValue(false)
}
- if cValue := v.Get("a4-config.group"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "a4-config/group"); cValue.Exists() {
item.A4Group = types.StringValue(cValue.String())
}
- if cValue := v.Get("a4-config.local"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "a4-config/local"); cValue.Exists() {
item.A4Local = types.BoolValue(true)
} else {
item.A4Local = types.BoolValue(false)
}
- if cValue := v.Get("a4-config.cache"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "a4-config/cache"); cValue.Exists() {
item.A4Cache = types.StringValue(cValue.String())
}
- if cValue := v.Get("a4-config.radius"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "a4-config/radius"); cValue.Exists() {
item.A4Radius = types.BoolValue(true)
} else {
item.A4Radius = types.BoolValue(false)
@@ -1206,303 +2754,299 @@ func (data *AAAAuthentication) fromBody(ctx context.Context, res gjson.Result) {
return true
})
}
- if value := res.Get(prefix + "dot1x.default.a1-config.group"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/dot1x/default/a1-config/group"); value.Exists() {
data.Dot1xDefaultA1Group = types.StringValue(value.String())
}
- if value := res.Get(prefix + "dot1x.default.a1-config.local"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/dot1x/default/a1-config/local"); value.Exists() {
data.Dot1xDefaultA1Local = types.BoolValue(true)
} else {
data.Dot1xDefaultA1Local = types.BoolValue(false)
}
- if value := res.Get(prefix + "dot1x.default.a2-config.group"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/dot1x/default/a2-config/group"); value.Exists() {
data.Dot1xDefaultA2Group = types.StringValue(value.String())
}
- if value := res.Get(prefix + "dot1x.default.a2-config.local"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/dot1x/default/a2-config/local"); value.Exists() {
data.Dot1xDefaultA2Local = types.BoolValue(true)
} else {
data.Dot1xDefaultA2Local = types.BoolValue(false)
}
- if value := res.Get(prefix + "dot1x.default.a3-config.group"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/dot1x/default/a3-config/group"); value.Exists() {
data.Dot1xDefaultA3Group = types.StringValue(value.String())
}
- if value := res.Get(prefix + "dot1x.default.a3-config.local"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/dot1x/default/a3-config/local"); value.Exists() {
data.Dot1xDefaultA3Local = types.BoolValue(true)
} else {
data.Dot1xDefaultA3Local = types.BoolValue(false)
}
- if value := res.Get(prefix + "dot1x.default.a4-config.group"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/dot1x/default/a4-config/group"); value.Exists() {
data.Dot1xDefaultA4Group = types.StringValue(value.String())
}
- if value := res.Get(prefix + "dot1x.default.a4-config.local"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/dot1x/default/a4-config/local"); value.Exists() {
data.Dot1xDefaultA4Local = types.BoolValue(true)
} else {
data.Dot1xDefaultA4Local = types.BoolValue(false)
}
- if value := res.Get(prefix + "enable.default.group1.cache"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/enable/default/group1/cache"); value.Exists() {
data.EnableDefaultGroup1Cache = types.StringValue(value.String())
}
- if value := res.Get(prefix + "enable.default.group1.enable"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/enable/default/group1/enable"); value.Exists() {
data.EnableDefaultGroup1Enable = types.BoolValue(true)
} else {
data.EnableDefaultGroup1Enable = types.BoolValue(false)
}
- if value := res.Get(prefix + "enable.default.group1.group"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/enable/default/group1/group"); value.Exists() {
data.EnableDefaultGroup1Group = types.StringValue(value.String())
}
- if value := res.Get(prefix + "enable.default.group1.line"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/enable/default/group1/line"); value.Exists() {
data.EnableDefaultGroup1Line = types.BoolValue(true)
} else {
data.EnableDefaultGroup1Line = types.BoolValue(false)
}
- if value := res.Get(prefix + "enable.default.group1.none"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/enable/default/group1/none"); value.Exists() {
data.EnableDefaultGroup1None = types.BoolValue(true)
} else {
data.EnableDefaultGroup1None = types.BoolValue(false)
}
- if value := res.Get(prefix + "enable.default.group2.cache"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/enable/default/group2/cache"); value.Exists() {
data.EnableDefaultGroup2Cache = types.StringValue(value.String())
}
- if value := res.Get(prefix + "enable.default.group2.enable"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/enable/default/group2/enable"); value.Exists() {
data.EnableDefaultGroup2Enable = types.BoolValue(true)
} else {
data.EnableDefaultGroup2Enable = types.BoolValue(false)
}
- if value := res.Get(prefix + "enable.default.group2.group"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/enable/default/group2/group"); value.Exists() {
data.EnableDefaultGroup2Group = types.StringValue(value.String())
}
- if value := res.Get(prefix + "enable.default.group2.line"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/enable/default/group2/line"); value.Exists() {
data.EnableDefaultGroup2Line = types.BoolValue(true)
} else {
data.EnableDefaultGroup2Line = types.BoolValue(false)
}
- if value := res.Get(prefix + "enable.default.group2.none"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/enable/default/group2/none"); value.Exists() {
data.EnableDefaultGroup2None = types.BoolValue(true)
} else {
data.EnableDefaultGroup2None = types.BoolValue(false)
}
- if value := res.Get(prefix + "enable.default.group3.cache"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/enable/default/group3/cache"); value.Exists() {
data.EnableDefaultGroup3Cache = types.StringValue(value.String())
}
- if value := res.Get(prefix + "enable.default.group3.enable"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/enable/default/group3/enable"); value.Exists() {
data.EnableDefaultGroup3Enable = types.BoolValue(true)
} else {
data.EnableDefaultGroup3Enable = types.BoolValue(false)
}
- if value := res.Get(prefix + "enable.default.group3.group"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/enable/default/group3/group"); value.Exists() {
data.EnableDefaultGroup3Group = types.StringValue(value.String())
}
- if value := res.Get(prefix + "enable.default.group3.line"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/enable/default/group3/line"); value.Exists() {
data.EnableDefaultGroup3Line = types.BoolValue(true)
} else {
data.EnableDefaultGroup3Line = types.BoolValue(false)
}
- if value := res.Get(prefix + "enable.default.group3.none"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/enable/default/group3/none"); value.Exists() {
data.EnableDefaultGroup3None = types.BoolValue(true)
} else {
data.EnableDefaultGroup3None = types.BoolValue(false)
}
- if value := res.Get(prefix + "enable.default.group4.cache"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/enable/default/group4/cache"); value.Exists() {
data.EnableDefaultGroup4Cache = types.StringValue(value.String())
}
- if value := res.Get(prefix + "enable.default.group4.enable"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/enable/default/group4/enable"); value.Exists() {
data.EnableDefaultGroup4Enable = types.BoolValue(true)
} else {
data.EnableDefaultGroup4Enable = types.BoolValue(false)
}
- if value := res.Get(prefix + "enable.default.group4.group"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/enable/default/group4/group"); value.Exists() {
data.EnableDefaultGroup4Group = types.StringValue(value.String())
}
- if value := res.Get(prefix + "enable.default.group4.line"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/enable/default/group4/line"); value.Exists() {
data.EnableDefaultGroup4Line = types.BoolValue(true)
} else {
data.EnableDefaultGroup4Line = types.BoolValue(false)
}
- if value := res.Get(prefix + "enable.default.group4.none"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/enable/default/group4/none"); value.Exists() {
data.EnableDefaultGroup4None = types.BoolValue(true)
} else {
data.EnableDefaultGroup4None = types.BoolValue(false)
}
}
-// End of section. //template:end fromBody
+// End of section. //template:end fromBodyXML
-// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyData
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyDataXML
-func (data *AAAAuthenticationData) fromBody(ctx context.Context, res gjson.Result) {
- prefix := helpers.LastElement(data.getPath()) + "."
- if res.Get(helpers.LastElement(data.getPath())).IsArray() {
- prefix += "0."
- }
- if value := res.Get(prefix + "login"); value.Exists() {
+func (data *AAAAuthenticationData) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/login"); value.Exists() {
data.Logins = make([]AAAAuthenticationLogins, 0)
- value.ForEach(func(k, v gjson.Result) bool {
+ value.ForEach(func(_ int, v xmldot.Result) bool {
item := AAAAuthenticationLogins{}
- if cValue := v.Get("name"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "name"); cValue.Exists() {
item.Name = types.StringValue(cValue.String())
}
- if cValue := v.Get("a1.none"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "a1/none"); cValue.Exists() {
item.A1None = types.BoolValue(true)
} else {
item.A1None = types.BoolValue(false)
}
- if cValue := v.Get("a1.line"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "a1/line"); cValue.Exists() {
item.A1Line = types.BoolValue(true)
} else {
item.A1Line = types.BoolValue(false)
}
- if cValue := v.Get("a1.enable"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "a1/enable"); cValue.Exists() {
item.A1Enable = types.BoolValue(true)
} else {
item.A1Enable = types.BoolValue(false)
}
- if cValue := v.Get("a1.local"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "a1/local"); cValue.Exists() {
item.A1Local = types.BoolValue(true)
} else {
item.A1Local = types.BoolValue(false)
}
- if cValue := v.Get("a1.group"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "a1/group"); cValue.Exists() {
item.A1Group = types.StringValue(cValue.String())
}
- if cValue := v.Get("a2.none"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "a2/none"); cValue.Exists() {
item.A2None = types.BoolValue(true)
} else {
item.A2None = types.BoolValue(false)
}
- if cValue := v.Get("a2.line"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "a2/line"); cValue.Exists() {
item.A2Line = types.BoolValue(true)
} else {
item.A2Line = types.BoolValue(false)
}
- if cValue := v.Get("a2.enable"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "a2/enable"); cValue.Exists() {
item.A2Enable = types.BoolValue(true)
} else {
item.A2Enable = types.BoolValue(false)
}
- if cValue := v.Get("a2.local"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "a2/local"); cValue.Exists() {
item.A2Local = types.BoolValue(true)
} else {
item.A2Local = types.BoolValue(false)
}
- if cValue := v.Get("a2.group"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "a2/group"); cValue.Exists() {
item.A2Group = types.StringValue(cValue.String())
}
- if cValue := v.Get("a3.none"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "a3/none"); cValue.Exists() {
item.A3None = types.BoolValue(true)
} else {
item.A3None = types.BoolValue(false)
}
- if cValue := v.Get("a3.line"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "a3/line"); cValue.Exists() {
item.A3Line = types.BoolValue(true)
} else {
item.A3Line = types.BoolValue(false)
}
- if cValue := v.Get("a3.enable"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "a3/enable"); cValue.Exists() {
item.A3Enable = types.BoolValue(true)
} else {
item.A3Enable = types.BoolValue(false)
}
- if cValue := v.Get("a3.local"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "a3/local"); cValue.Exists() {
item.A3Local = types.BoolValue(true)
} else {
item.A3Local = types.BoolValue(false)
}
- if cValue := v.Get("a3.group"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "a3/group"); cValue.Exists() {
item.A3Group = types.StringValue(cValue.String())
}
- if cValue := v.Get("a4.none"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "a4/none"); cValue.Exists() {
item.A4None = types.BoolValue(true)
} else {
item.A4None = types.BoolValue(false)
}
- if cValue := v.Get("a4.line"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "a4/line"); cValue.Exists() {
item.A4Line = types.BoolValue(true)
} else {
item.A4Line = types.BoolValue(false)
}
- if cValue := v.Get("a4.enable"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "a4/enable"); cValue.Exists() {
item.A4Enable = types.BoolValue(true)
} else {
item.A4Enable = types.BoolValue(false)
}
- if cValue := v.Get("a4.local"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "a4/local"); cValue.Exists() {
item.A4Local = types.BoolValue(true)
} else {
item.A4Local = types.BoolValue(false)
}
- if cValue := v.Get("a4.group"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "a4/group"); cValue.Exists() {
item.A4Group = types.StringValue(cValue.String())
}
data.Logins = append(data.Logins, item)
return true
})
}
- if value := res.Get(prefix + "dot1x.dot1x-list"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/dot1x/dot1x-list"); value.Exists() {
data.Dot1x = make([]AAAAuthenticationDot1x, 0)
- value.ForEach(func(k, v gjson.Result) bool {
+ value.ForEach(func(_ int, v xmldot.Result) bool {
item := AAAAuthenticationDot1x{}
- if cValue := v.Get("name"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "name"); cValue.Exists() {
item.Name = types.StringValue(cValue.String())
}
- if cValue := v.Get("a1-config.group"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "a1-config/group"); cValue.Exists() {
item.A1Group = types.StringValue(cValue.String())
}
- if cValue := v.Get("a1-config.local"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "a1-config/local"); cValue.Exists() {
item.A1Local = types.BoolValue(true)
} else {
item.A1Local = types.BoolValue(false)
}
- if cValue := v.Get("a1-config.cache"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "a1-config/cache"); cValue.Exists() {
item.A1Cache = types.StringValue(cValue.String())
}
- if cValue := v.Get("a1-config.radius"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "a1-config/radius"); cValue.Exists() {
item.A1Radius = types.BoolValue(true)
} else {
item.A1Radius = types.BoolValue(false)
}
- if cValue := v.Get("a2-config.group"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "a2-config/group"); cValue.Exists() {
item.A2Group = types.StringValue(cValue.String())
}
- if cValue := v.Get("a2-config.local"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "a2-config/local"); cValue.Exists() {
item.A2Local = types.BoolValue(true)
} else {
item.A2Local = types.BoolValue(false)
}
- if cValue := v.Get("a2-config.cache"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "a2-config/cache"); cValue.Exists() {
item.A2Cache = types.StringValue(cValue.String())
}
- if cValue := v.Get("a2-config.radius"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "a2-config/radius"); cValue.Exists() {
item.A2Radius = types.BoolValue(true)
} else {
item.A2Radius = types.BoolValue(false)
}
- if cValue := v.Get("a3-config.group"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "a3-config/group"); cValue.Exists() {
item.A3Group = types.StringValue(cValue.String())
}
- if cValue := v.Get("a3-config.local"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "a3-config/local"); cValue.Exists() {
item.A3Local = types.BoolValue(true)
} else {
item.A3Local = types.BoolValue(false)
}
- if cValue := v.Get("a3-config.cache"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "a3-config/cache"); cValue.Exists() {
item.A3Cache = types.StringValue(cValue.String())
}
- if cValue := v.Get("a3-config.radius"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "a3-config/radius"); cValue.Exists() {
item.A3Radius = types.BoolValue(true)
} else {
item.A3Radius = types.BoolValue(false)
}
- if cValue := v.Get("a4-config.group"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "a4-config/group"); cValue.Exists() {
item.A4Group = types.StringValue(cValue.String())
}
- if cValue := v.Get("a4-config.local"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "a4-config/local"); cValue.Exists() {
item.A4Local = types.BoolValue(true)
} else {
item.A4Local = types.BoolValue(false)
}
- if cValue := v.Get("a4-config.cache"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "a4-config/cache"); cValue.Exists() {
item.A4Cache = types.StringValue(cValue.String())
}
- if cValue := v.Get("a4-config.radius"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "a4-config/radius"); cValue.Exists() {
item.A4Radius = types.BoolValue(true)
} else {
item.A4Radius = types.BoolValue(false)
@@ -1511,125 +3055,125 @@ func (data *AAAAuthenticationData) fromBody(ctx context.Context, res gjson.Resul
return true
})
}
- if value := res.Get(prefix + "dot1x.default.a1-config.group"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/dot1x/default/a1-config/group"); value.Exists() {
data.Dot1xDefaultA1Group = types.StringValue(value.String())
}
- if value := res.Get(prefix + "dot1x.default.a1-config.local"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/dot1x/default/a1-config/local"); value.Exists() {
data.Dot1xDefaultA1Local = types.BoolValue(true)
} else {
data.Dot1xDefaultA1Local = types.BoolValue(false)
}
- if value := res.Get(prefix + "dot1x.default.a2-config.group"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/dot1x/default/a2-config/group"); value.Exists() {
data.Dot1xDefaultA2Group = types.StringValue(value.String())
}
- if value := res.Get(prefix + "dot1x.default.a2-config.local"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/dot1x/default/a2-config/local"); value.Exists() {
data.Dot1xDefaultA2Local = types.BoolValue(true)
} else {
data.Dot1xDefaultA2Local = types.BoolValue(false)
}
- if value := res.Get(prefix + "dot1x.default.a3-config.group"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/dot1x/default/a3-config/group"); value.Exists() {
data.Dot1xDefaultA3Group = types.StringValue(value.String())
}
- if value := res.Get(prefix + "dot1x.default.a3-config.local"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/dot1x/default/a3-config/local"); value.Exists() {
data.Dot1xDefaultA3Local = types.BoolValue(true)
} else {
data.Dot1xDefaultA3Local = types.BoolValue(false)
}
- if value := res.Get(prefix + "dot1x.default.a4-config.group"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/dot1x/default/a4-config/group"); value.Exists() {
data.Dot1xDefaultA4Group = types.StringValue(value.String())
}
- if value := res.Get(prefix + "dot1x.default.a4-config.local"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/dot1x/default/a4-config/local"); value.Exists() {
data.Dot1xDefaultA4Local = types.BoolValue(true)
} else {
data.Dot1xDefaultA4Local = types.BoolValue(false)
}
- if value := res.Get(prefix + "enable.default.group1.cache"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/enable/default/group1/cache"); value.Exists() {
data.EnableDefaultGroup1Cache = types.StringValue(value.String())
}
- if value := res.Get(prefix + "enable.default.group1.enable"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/enable/default/group1/enable"); value.Exists() {
data.EnableDefaultGroup1Enable = types.BoolValue(true)
} else {
data.EnableDefaultGroup1Enable = types.BoolValue(false)
}
- if value := res.Get(prefix + "enable.default.group1.group"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/enable/default/group1/group"); value.Exists() {
data.EnableDefaultGroup1Group = types.StringValue(value.String())
}
- if value := res.Get(prefix + "enable.default.group1.line"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/enable/default/group1/line"); value.Exists() {
data.EnableDefaultGroup1Line = types.BoolValue(true)
} else {
data.EnableDefaultGroup1Line = types.BoolValue(false)
}
- if value := res.Get(prefix + "enable.default.group1.none"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/enable/default/group1/none"); value.Exists() {
data.EnableDefaultGroup1None = types.BoolValue(true)
} else {
data.EnableDefaultGroup1None = types.BoolValue(false)
}
- if value := res.Get(prefix + "enable.default.group2.cache"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/enable/default/group2/cache"); value.Exists() {
data.EnableDefaultGroup2Cache = types.StringValue(value.String())
}
- if value := res.Get(prefix + "enable.default.group2.enable"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/enable/default/group2/enable"); value.Exists() {
data.EnableDefaultGroup2Enable = types.BoolValue(true)
} else {
data.EnableDefaultGroup2Enable = types.BoolValue(false)
}
- if value := res.Get(prefix + "enable.default.group2.group"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/enable/default/group2/group"); value.Exists() {
data.EnableDefaultGroup2Group = types.StringValue(value.String())
}
- if value := res.Get(prefix + "enable.default.group2.line"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/enable/default/group2/line"); value.Exists() {
data.EnableDefaultGroup2Line = types.BoolValue(true)
} else {
data.EnableDefaultGroup2Line = types.BoolValue(false)
}
- if value := res.Get(prefix + "enable.default.group2.none"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/enable/default/group2/none"); value.Exists() {
data.EnableDefaultGroup2None = types.BoolValue(true)
} else {
data.EnableDefaultGroup2None = types.BoolValue(false)
}
- if value := res.Get(prefix + "enable.default.group3.cache"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/enable/default/group3/cache"); value.Exists() {
data.EnableDefaultGroup3Cache = types.StringValue(value.String())
}
- if value := res.Get(prefix + "enable.default.group3.enable"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/enable/default/group3/enable"); value.Exists() {
data.EnableDefaultGroup3Enable = types.BoolValue(true)
} else {
data.EnableDefaultGroup3Enable = types.BoolValue(false)
}
- if value := res.Get(prefix + "enable.default.group3.group"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/enable/default/group3/group"); value.Exists() {
data.EnableDefaultGroup3Group = types.StringValue(value.String())
}
- if value := res.Get(prefix + "enable.default.group3.line"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/enable/default/group3/line"); value.Exists() {
data.EnableDefaultGroup3Line = types.BoolValue(true)
} else {
data.EnableDefaultGroup3Line = types.BoolValue(false)
}
- if value := res.Get(prefix + "enable.default.group3.none"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/enable/default/group3/none"); value.Exists() {
data.EnableDefaultGroup3None = types.BoolValue(true)
} else {
data.EnableDefaultGroup3None = types.BoolValue(false)
}
- if value := res.Get(prefix + "enable.default.group4.cache"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/enable/default/group4/cache"); value.Exists() {
data.EnableDefaultGroup4Cache = types.StringValue(value.String())
}
- if value := res.Get(prefix + "enable.default.group4.enable"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/enable/default/group4/enable"); value.Exists() {
data.EnableDefaultGroup4Enable = types.BoolValue(true)
} else {
data.EnableDefaultGroup4Enable = types.BoolValue(false)
}
- if value := res.Get(prefix + "enable.default.group4.group"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/enable/default/group4/group"); value.Exists() {
data.EnableDefaultGroup4Group = types.StringValue(value.String())
}
- if value := res.Get(prefix + "enable.default.group4.line"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/enable/default/group4/line"); value.Exists() {
data.EnableDefaultGroup4Line = types.BoolValue(true)
} else {
data.EnableDefaultGroup4Line = types.BoolValue(false)
}
- if value := res.Get(prefix + "enable.default.group4.none"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/enable/default/group4/none"); value.Exists() {
data.EnableDefaultGroup4None = types.BoolValue(true)
} else {
data.EnableDefaultGroup4None = types.BoolValue(false)
}
}
-// End of section. //template:end fromBodyData
+// End of section. //template:end fromBodyDataXML
// Section below is generated&owned by "gen/generator.go". //template:begin getDeletedItems
@@ -1883,6 +3427,268 @@ func (data *AAAAuthentication) getDeletedItems(ctx context.Context, state AAAAut
// End of section. //template:end getDeletedItems
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletedItemsXML
+
+func (data *AAAAuthentication) addDeletedItemsXML(ctx context.Context, state AAAAuthentication, body string) string {
+ b := netconf.NewBody(body)
+ for i := range state.Logins {
+ stateKeys := [...]string{"name"}
+ stateKeyValues := [...]string{state.Logins[i].Name.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.Logins[i].Name.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.Logins {
+ found = true
+ if state.Logins[i].Name.ValueString() != data.Logins[j].Name.ValueString() {
+ found = false
+ }
+ if found {
+ if !state.Logins[i].A1None.IsNull() && data.Logins[j].A1None.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/login%v/a1/none", predicates))
+ }
+ if !state.Logins[i].A1Line.IsNull() && data.Logins[j].A1Line.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/login%v/a1/line", predicates))
+ }
+ if !state.Logins[i].A1Enable.IsNull() && data.Logins[j].A1Enable.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/login%v/a1/enable", predicates))
+ }
+ if !state.Logins[i].A1Local.IsNull() && data.Logins[j].A1Local.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/login%v/a1/local", predicates))
+ }
+ if !state.Logins[i].A1Group.IsNull() && data.Logins[j].A1Group.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/login%v/a1/group", predicates))
+ }
+ if !state.Logins[i].A2None.IsNull() && data.Logins[j].A2None.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/login%v/a2/none", predicates))
+ }
+ if !state.Logins[i].A2Line.IsNull() && data.Logins[j].A2Line.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/login%v/a2/line", predicates))
+ }
+ if !state.Logins[i].A2Enable.IsNull() && data.Logins[j].A2Enable.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/login%v/a2/enable", predicates))
+ }
+ if !state.Logins[i].A2Local.IsNull() && data.Logins[j].A2Local.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/login%v/a2/local", predicates))
+ }
+ if !state.Logins[i].A2Group.IsNull() && data.Logins[j].A2Group.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/login%v/a2/group", predicates))
+ }
+ if !state.Logins[i].A3None.IsNull() && data.Logins[j].A3None.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/login%v/a3/none", predicates))
+ }
+ if !state.Logins[i].A3Line.IsNull() && data.Logins[j].A3Line.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/login%v/a3/line", predicates))
+ }
+ if !state.Logins[i].A3Enable.IsNull() && data.Logins[j].A3Enable.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/login%v/a3/enable", predicates))
+ }
+ if !state.Logins[i].A3Local.IsNull() && data.Logins[j].A3Local.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/login%v/a3/local", predicates))
+ }
+ if !state.Logins[i].A3Group.IsNull() && data.Logins[j].A3Group.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/login%v/a3/group", predicates))
+ }
+ if !state.Logins[i].A4None.IsNull() && data.Logins[j].A4None.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/login%v/a4/none", predicates))
+ }
+ if !state.Logins[i].A4Line.IsNull() && data.Logins[j].A4Line.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/login%v/a4/line", predicates))
+ }
+ if !state.Logins[i].A4Enable.IsNull() && data.Logins[j].A4Enable.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/login%v/a4/enable", predicates))
+ }
+ if !state.Logins[i].A4Local.IsNull() && data.Logins[j].A4Local.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/login%v/a4/local", predicates))
+ }
+ if !state.Logins[i].A4Group.IsNull() && data.Logins[j].A4Group.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/login%v/a4/group", predicates))
+ }
+ break
+ }
+ }
+ if !found {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/login%v", predicates))
+ }
+ }
+ for i := range state.Dot1x {
+ stateKeys := [...]string{"name"}
+ stateKeyValues := [...]string{state.Dot1x[i].Name.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.Dot1x[i].Name.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.Dot1x {
+ found = true
+ if state.Dot1x[i].Name.ValueString() != data.Dot1x[j].Name.ValueString() {
+ found = false
+ }
+ if found {
+ if !state.Dot1x[i].A1Group.IsNull() && data.Dot1x[j].A1Group.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/dot1x/dot1x-list%v/a1-config/group", predicates))
+ }
+ if !state.Dot1x[i].A1Local.IsNull() && data.Dot1x[j].A1Local.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/dot1x/dot1x-list%v/a1-config/local", predicates))
+ }
+ if !state.Dot1x[i].A1Cache.IsNull() && data.Dot1x[j].A1Cache.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/dot1x/dot1x-list%v/a1-config/cache", predicates))
+ }
+ if !state.Dot1x[i].A1Radius.IsNull() && data.Dot1x[j].A1Radius.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/dot1x/dot1x-list%v/a1-config/radius", predicates))
+ }
+ if !state.Dot1x[i].A2Group.IsNull() && data.Dot1x[j].A2Group.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/dot1x/dot1x-list%v/a2-config/group", predicates))
+ }
+ if !state.Dot1x[i].A2Local.IsNull() && data.Dot1x[j].A2Local.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/dot1x/dot1x-list%v/a2-config/local", predicates))
+ }
+ if !state.Dot1x[i].A2Cache.IsNull() && data.Dot1x[j].A2Cache.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/dot1x/dot1x-list%v/a2-config/cache", predicates))
+ }
+ if !state.Dot1x[i].A2Radius.IsNull() && data.Dot1x[j].A2Radius.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/dot1x/dot1x-list%v/a2-config/radius", predicates))
+ }
+ if !state.Dot1x[i].A3Group.IsNull() && data.Dot1x[j].A3Group.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/dot1x/dot1x-list%v/a3-config/group", predicates))
+ }
+ if !state.Dot1x[i].A3Local.IsNull() && data.Dot1x[j].A3Local.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/dot1x/dot1x-list%v/a3-config/local", predicates))
+ }
+ if !state.Dot1x[i].A3Cache.IsNull() && data.Dot1x[j].A3Cache.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/dot1x/dot1x-list%v/a3-config/cache", predicates))
+ }
+ if !state.Dot1x[i].A3Radius.IsNull() && data.Dot1x[j].A3Radius.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/dot1x/dot1x-list%v/a3-config/radius", predicates))
+ }
+ if !state.Dot1x[i].A4Group.IsNull() && data.Dot1x[j].A4Group.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/dot1x/dot1x-list%v/a4-config/group", predicates))
+ }
+ if !state.Dot1x[i].A4Local.IsNull() && data.Dot1x[j].A4Local.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/dot1x/dot1x-list%v/a4-config/local", predicates))
+ }
+ if !state.Dot1x[i].A4Cache.IsNull() && data.Dot1x[j].A4Cache.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/dot1x/dot1x-list%v/a4-config/cache", predicates))
+ }
+ if !state.Dot1x[i].A4Radius.IsNull() && data.Dot1x[j].A4Radius.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/dot1x/dot1x-list%v/a4-config/radius", predicates))
+ }
+ break
+ }
+ }
+ if !found {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/dot1x/dot1x-list%v", predicates))
+ }
+ }
+ if !state.Dot1xDefaultA1Group.IsNull() && data.Dot1xDefaultA1Group.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/dot1x/default/a1-config/group")
+ }
+ if !state.Dot1xDefaultA1Local.IsNull() && data.Dot1xDefaultA1Local.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/dot1x/default/a1-config/local")
+ }
+ if !state.Dot1xDefaultA2Group.IsNull() && data.Dot1xDefaultA2Group.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/dot1x/default/a2-config/group")
+ }
+ if !state.Dot1xDefaultA2Local.IsNull() && data.Dot1xDefaultA2Local.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/dot1x/default/a2-config/local")
+ }
+ if !state.Dot1xDefaultA3Group.IsNull() && data.Dot1xDefaultA3Group.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/dot1x/default/a3-config/group")
+ }
+ if !state.Dot1xDefaultA3Local.IsNull() && data.Dot1xDefaultA3Local.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/dot1x/default/a3-config/local")
+ }
+ if !state.Dot1xDefaultA4Group.IsNull() && data.Dot1xDefaultA4Group.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/dot1x/default/a4-config/group")
+ }
+ if !state.Dot1xDefaultA4Local.IsNull() && data.Dot1xDefaultA4Local.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/dot1x/default/a4-config/local")
+ }
+ if !state.EnableDefaultGroup1Cache.IsNull() && data.EnableDefaultGroup1Cache.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/enable/default/group1/cache")
+ }
+ if !state.EnableDefaultGroup1Enable.IsNull() && data.EnableDefaultGroup1Enable.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/enable/default/group1/enable")
+ }
+ if !state.EnableDefaultGroup1Group.IsNull() && data.EnableDefaultGroup1Group.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/enable/default/group1/group")
+ }
+ if !state.EnableDefaultGroup1Line.IsNull() && data.EnableDefaultGroup1Line.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/enable/default/group1/line")
+ }
+ if !state.EnableDefaultGroup1None.IsNull() && data.EnableDefaultGroup1None.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/enable/default/group1/none")
+ }
+ if !state.EnableDefaultGroup2Cache.IsNull() && data.EnableDefaultGroup2Cache.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/enable/default/group2/cache")
+ }
+ if !state.EnableDefaultGroup2Enable.IsNull() && data.EnableDefaultGroup2Enable.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/enable/default/group2/enable")
+ }
+ if !state.EnableDefaultGroup2Group.IsNull() && data.EnableDefaultGroup2Group.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/enable/default/group2/group")
+ }
+ if !state.EnableDefaultGroup2Line.IsNull() && data.EnableDefaultGroup2Line.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/enable/default/group2/line")
+ }
+ if !state.EnableDefaultGroup2None.IsNull() && data.EnableDefaultGroup2None.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/enable/default/group2/none")
+ }
+ if !state.EnableDefaultGroup3Cache.IsNull() && data.EnableDefaultGroup3Cache.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/enable/default/group3/cache")
+ }
+ if !state.EnableDefaultGroup3Enable.IsNull() && data.EnableDefaultGroup3Enable.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/enable/default/group3/enable")
+ }
+ if !state.EnableDefaultGroup3Group.IsNull() && data.EnableDefaultGroup3Group.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/enable/default/group3/group")
+ }
+ if !state.EnableDefaultGroup3Line.IsNull() && data.EnableDefaultGroup3Line.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/enable/default/group3/line")
+ }
+ if !state.EnableDefaultGroup3None.IsNull() && data.EnableDefaultGroup3None.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/enable/default/group3/none")
+ }
+ if !state.EnableDefaultGroup4Cache.IsNull() && data.EnableDefaultGroup4Cache.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/enable/default/group4/cache")
+ }
+ if !state.EnableDefaultGroup4Enable.IsNull() && data.EnableDefaultGroup4Enable.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/enable/default/group4/enable")
+ }
+ if !state.EnableDefaultGroup4Group.IsNull() && data.EnableDefaultGroup4Group.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/enable/default/group4/group")
+ }
+ if !state.EnableDefaultGroup4Line.IsNull() && data.EnableDefaultGroup4Line.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/enable/default/group4/line")
+ }
+ if !state.EnableDefaultGroup4None.IsNull() && data.EnableDefaultGroup4None.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/enable/default/group4/none")
+ }
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletedItemsXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin getEmptyLeafsDelete
func (data *AAAAuthentication) getEmptyLeafsDelete(ctx context.Context) []string {
@@ -2124,3 +3930,117 @@ func (data *AAAAuthentication) getDeletePaths(ctx context.Context) []string {
}
// End of section. //template:end getDeletePaths
+
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletePathsXML
+
+func (data *AAAAuthentication) addDeletePathsXML(ctx context.Context, body string) string {
+ b := netconf.NewBody(body)
+ for i := range data.Logins {
+ keys := [...]string{"name"}
+ keyValues := [...]string{data.Logins[i].Name.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/login%v", predicates))
+ }
+ for i := range data.Dot1x {
+ keys := [...]string{"name"}
+ keyValues := [...]string{data.Dot1x[i].Name.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/dot1x/dot1x-list%v", predicates))
+ }
+ if !data.Dot1xDefaultA1Group.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/dot1x/default/a1-config/group")
+ }
+ if !data.Dot1xDefaultA1Local.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/dot1x/default/a1-config/local")
+ }
+ if !data.Dot1xDefaultA2Group.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/dot1x/default/a2-config/group")
+ }
+ if !data.Dot1xDefaultA2Local.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/dot1x/default/a2-config/local")
+ }
+ if !data.Dot1xDefaultA3Group.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/dot1x/default/a3-config/group")
+ }
+ if !data.Dot1xDefaultA3Local.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/dot1x/default/a3-config/local")
+ }
+ if !data.Dot1xDefaultA4Group.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/dot1x/default/a4-config/group")
+ }
+ if !data.Dot1xDefaultA4Local.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/dot1x/default/a4-config/local")
+ }
+ if !data.EnableDefaultGroup1Cache.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/enable/default/group1/cache")
+ }
+ if !data.EnableDefaultGroup1Enable.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/enable/default/group1/enable")
+ }
+ if !data.EnableDefaultGroup1Group.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/enable/default/group1/group")
+ }
+ if !data.EnableDefaultGroup1Line.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/enable/default/group1/line")
+ }
+ if !data.EnableDefaultGroup1None.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/enable/default/group1/none")
+ }
+ if !data.EnableDefaultGroup2Cache.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/enable/default/group2/cache")
+ }
+ if !data.EnableDefaultGroup2Enable.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/enable/default/group2/enable")
+ }
+ if !data.EnableDefaultGroup2Group.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/enable/default/group2/group")
+ }
+ if !data.EnableDefaultGroup2Line.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/enable/default/group2/line")
+ }
+ if !data.EnableDefaultGroup2None.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/enable/default/group2/none")
+ }
+ if !data.EnableDefaultGroup3Cache.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/enable/default/group3/cache")
+ }
+ if !data.EnableDefaultGroup3Enable.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/enable/default/group3/enable")
+ }
+ if !data.EnableDefaultGroup3Group.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/enable/default/group3/group")
+ }
+ if !data.EnableDefaultGroup3Line.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/enable/default/group3/line")
+ }
+ if !data.EnableDefaultGroup3None.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/enable/default/group3/none")
+ }
+ if !data.EnableDefaultGroup4Cache.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/enable/default/group4/cache")
+ }
+ if !data.EnableDefaultGroup4Enable.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/enable/default/group4/enable")
+ }
+ if !data.EnableDefaultGroup4Group.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/enable/default/group4/group")
+ }
+ if !data.EnableDefaultGroup4Line.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/enable/default/group4/line")
+ }
+ if !data.EnableDefaultGroup4None.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/enable/default/group4/none")
+ }
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletePathsXML
diff --git a/internal/provider/model_iosxe_aaa_authorization.go b/internal/provider/model_iosxe_aaa_authorization.go
index bd6b7ea2..c7a965ff 100644
--- a/internal/provider/model_iosxe_aaa_authorization.go
+++ b/internal/provider/model_iosxe_aaa_authorization.go
@@ -30,6 +30,9 @@ import (
"github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/types"
+ "github.com/hashicorp/terraform-plugin-log/tflog"
+ "github.com/netascode/go-netconf"
+ "github.com/netascode/xmldot"
"github.com/tidwall/gjson"
"github.com/tidwall/sjson"
)
@@ -150,6 +153,17 @@ func (data AAAAuthorization) getPathShort() string {
return matches[1]
}
+// getXPath returns the XPath for NETCONF operations
+func (data AAAAuthorization) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/aaa/Cisco-IOS-XE-aaa:authorization"
+ return path
+}
+
+func (data AAAAuthorizationData) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/aaa/Cisco-IOS-XE-aaa:authorization"
+ return path
+}
+
// End of section. //template:end getPath
// Section below is generated&owned by "gen/generator.go". //template:begin toBody
@@ -453,6 +467,401 @@ func (data AAAAuthorization) toBody(ctx context.Context) string {
// End of section. //template:end toBody
+// Section below is generated&owned by "gen/generator.go". //template:begin toBodyXML
+
+func (data AAAAuthorization) toBodyXML(ctx context.Context) string {
+ body := netconf.Body{}
+ if len(data.Execs) > 0 {
+ for _, item := range data.Execs {
+ cBody := netconf.Body{}
+ if !item.Name.IsNull() && !item.Name.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "name", item.Name.ValueString())
+ }
+ if !item.A1Local.IsNull() && !item.A1Local.IsUnknown() {
+ if item.A1Local.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "a1/local", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "a1/local")
+ }
+ }
+ if !item.A1Group.IsNull() && !item.A1Group.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "a1/group", item.A1Group.ValueString())
+ }
+ if !item.A1Radius.IsNull() && !item.A1Radius.IsUnknown() {
+ if item.A1Radius.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "a1/radius", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "a1/radius")
+ }
+ }
+ if !item.A1Tacacs.IsNull() && !item.A1Tacacs.IsUnknown() {
+ if item.A1Tacacs.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "a1/tacacs", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "a1/tacacs")
+ }
+ }
+ if !item.A1IfAuthenticated.IsNull() && !item.A1IfAuthenticated.IsUnknown() {
+ if item.A1IfAuthenticated.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "a1/if-authenticated", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "a1/if-authenticated")
+ }
+ }
+ if !item.A2Local.IsNull() && !item.A2Local.IsUnknown() {
+ if item.A2Local.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "a2/local", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "a2/local")
+ }
+ }
+ if !item.A2Group.IsNull() && !item.A2Group.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "a2/group", item.A2Group.ValueString())
+ }
+ if !item.A2Radius.IsNull() && !item.A2Radius.IsUnknown() {
+ if item.A2Radius.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "a2/radius", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "a2/radius")
+ }
+ }
+ if !item.A2Tacacs.IsNull() && !item.A2Tacacs.IsUnknown() {
+ if item.A2Tacacs.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "a2/tacacs", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "a2/tacacs")
+ }
+ }
+ if !item.A2IfAuthenticated.IsNull() && !item.A2IfAuthenticated.IsUnknown() {
+ if item.A2IfAuthenticated.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "a2/if-authenticated", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "a2/if-authenticated")
+ }
+ }
+ if !item.A3Local.IsNull() && !item.A3Local.IsUnknown() {
+ if item.A3Local.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "a3/local", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "a3/local")
+ }
+ }
+ if !item.A3Group.IsNull() && !item.A3Group.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "a3/group", item.A3Group.ValueString())
+ }
+ if !item.A3Radius.IsNull() && !item.A3Radius.IsUnknown() {
+ if item.A3Radius.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "a3/radius", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "a3/radius")
+ }
+ }
+ if !item.A3Tacacs.IsNull() && !item.A3Tacacs.IsUnknown() {
+ if item.A3Tacacs.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "a3/tacacs", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "a3/tacacs")
+ }
+ }
+ if !item.A3IfAuthenticated.IsNull() && !item.A3IfAuthenticated.IsUnknown() {
+ if item.A3IfAuthenticated.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "a3/if-authenticated", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "a3/if-authenticated")
+ }
+ }
+ if !item.A4Local.IsNull() && !item.A4Local.IsUnknown() {
+ if item.A4Local.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "a4/local", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "a4/local")
+ }
+ }
+ if !item.A4Group.IsNull() && !item.A4Group.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "a4/group", item.A4Group.ValueString())
+ }
+ if !item.A4Radius.IsNull() && !item.A4Radius.IsUnknown() {
+ if item.A4Radius.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "a4/radius", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "a4/radius")
+ }
+ }
+ if !item.A4Tacacs.IsNull() && !item.A4Tacacs.IsUnknown() {
+ if item.A4Tacacs.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "a4/tacacs", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "a4/tacacs")
+ }
+ }
+ if !item.A4IfAuthenticated.IsNull() && !item.A4IfAuthenticated.IsUnknown() {
+ if item.A4IfAuthenticated.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "a4/if-authenticated", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "a4/if-authenticated")
+ }
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/exec", cBody.Res())
+ }
+ }
+ if len(data.Networks) > 0 {
+ for _, item := range data.Networks {
+ cBody := netconf.Body{}
+ if !item.Id.IsNull() && !item.Id.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "id", item.Id.ValueString())
+ }
+ if !item.A1Local.IsNull() && !item.A1Local.IsUnknown() {
+ if item.A1Local.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "a1/local", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "a1/local")
+ }
+ }
+ if !item.A1Group.IsNull() && !item.A1Group.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "a1/group", item.A1Group.ValueString())
+ }
+ if !item.A2Local.IsNull() && !item.A2Local.IsUnknown() {
+ if item.A2Local.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "a2/local", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "a2/local")
+ }
+ }
+ if !item.A2Group.IsNull() && !item.A2Group.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "a2/group", item.A2Group.ValueString())
+ }
+ if !item.A3Local.IsNull() && !item.A3Local.IsUnknown() {
+ if item.A3Local.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "a3/local", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "a3/local")
+ }
+ }
+ if !item.A3Group.IsNull() && !item.A3Group.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "a3/group", item.A3Group.ValueString())
+ }
+ if !item.A4Local.IsNull() && !item.A4Local.IsUnknown() {
+ if item.A4Local.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "a4/local", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "a4/local")
+ }
+ }
+ if !item.A4Group.IsNull() && !item.A4Group.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "a4/group", item.A4Group.ValueString())
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/network", cBody.Res())
+ }
+ }
+ if len(data.Commands) > 0 {
+ for _, item := range data.Commands {
+ cBody := netconf.Body{}
+ if !item.Level.IsNull() && !item.Level.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "level", strconv.FormatInt(item.Level.ValueInt64(), 10))
+ }
+ if !item.ListName.IsNull() && !item.ListName.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "list-name", item.ListName.ValueString())
+ }
+ if !item.A1Group.IsNull() && !item.A1Group.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "a1/group", item.A1Group.ValueString())
+ }
+ if !item.A1Local.IsNull() && !item.A1Local.IsUnknown() {
+ if item.A1Local.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "a1/local", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "a1/local")
+ }
+ }
+ if !item.A1IfAuthenticated.IsNull() && !item.A1IfAuthenticated.IsUnknown() {
+ if item.A1IfAuthenticated.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "a1/if-authenticated", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "a1/if-authenticated")
+ }
+ }
+ if !item.A1None.IsNull() && !item.A1None.IsUnknown() {
+ if item.A1None.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "a1/none", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "a1/none")
+ }
+ }
+ if !item.A1Radius.IsNull() && !item.A1Radius.IsUnknown() {
+ if item.A1Radius.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "a1/radius", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "a1/radius")
+ }
+ }
+ if !item.A1Tacacs.IsNull() && !item.A1Tacacs.IsUnknown() {
+ if item.A1Tacacs.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "a1/tacacs", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "a1/tacacs")
+ }
+ }
+ if !item.A2Group.IsNull() && !item.A2Group.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "a2/group", item.A2Group.ValueString())
+ }
+ if !item.A2Local.IsNull() && !item.A2Local.IsUnknown() {
+ if item.A2Local.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "a2/local", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "a2/local")
+ }
+ }
+ if !item.A2IfAuthenticated.IsNull() && !item.A2IfAuthenticated.IsUnknown() {
+ if item.A2IfAuthenticated.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "a2/if-authenticated", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "a2/if-authenticated")
+ }
+ }
+ if !item.A2None.IsNull() && !item.A2None.IsUnknown() {
+ if item.A2None.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "a2/none", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "a2/none")
+ }
+ }
+ if !item.A2Radius.IsNull() && !item.A2Radius.IsUnknown() {
+ if item.A2Radius.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "a2/radius", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "a2/radius")
+ }
+ }
+ if !item.A2Tacacs.IsNull() && !item.A2Tacacs.IsUnknown() {
+ if item.A2Tacacs.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "a2/tacacs", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "a2/tacacs")
+ }
+ }
+ if !item.A3Group.IsNull() && !item.A3Group.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "a3/group", item.A3Group.ValueString())
+ }
+ if !item.A3Local.IsNull() && !item.A3Local.IsUnknown() {
+ if item.A3Local.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "a3/local", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "a3/local")
+ }
+ }
+ if !item.A3IfAuthenticated.IsNull() && !item.A3IfAuthenticated.IsUnknown() {
+ if item.A3IfAuthenticated.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "a3/if-authenticated", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "a3/if-authenticated")
+ }
+ }
+ if !item.A3None.IsNull() && !item.A3None.IsUnknown() {
+ if item.A3None.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "a3/none", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "a3/none")
+ }
+ }
+ if !item.A3Radius.IsNull() && !item.A3Radius.IsUnknown() {
+ if item.A3Radius.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "a3/radius", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "a3/radius")
+ }
+ }
+ if !item.A3Tacacs.IsNull() && !item.A3Tacacs.IsUnknown() {
+ if item.A3Tacacs.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "a3/tacacs", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "a3/tacacs")
+ }
+ }
+ if !item.A4Group.IsNull() && !item.A4Group.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "a4/group", item.A4Group.ValueString())
+ }
+ if !item.A4Local.IsNull() && !item.A4Local.IsUnknown() {
+ if item.A4Local.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "a4/local", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "a4/local")
+ }
+ }
+ if !item.A4IfAuthenticated.IsNull() && !item.A4IfAuthenticated.IsUnknown() {
+ if item.A4IfAuthenticated.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "a4/if-authenticated", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "a4/if-authenticated")
+ }
+ }
+ if !item.A4None.IsNull() && !item.A4None.IsUnknown() {
+ if item.A4None.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "a4/none", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "a4/none")
+ }
+ }
+ if !item.A4Radius.IsNull() && !item.A4Radius.IsUnknown() {
+ if item.A4Radius.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "a4/radius", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "a4/radius")
+ }
+ }
+ if !item.A4Tacacs.IsNull() && !item.A4Tacacs.IsUnknown() {
+ if item.A4Tacacs.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "a4/tacacs", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "a4/tacacs")
+ }
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/commands", cBody.Res())
+ }
+ }
+ if !data.ConfigCommands.IsNull() && !data.ConfigCommands.IsUnknown() {
+ if data.ConfigCommands.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/config-commands", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/config-commands")
+ }
+ }
+ if len(data.ConfigLists) > 0 {
+ for _, item := range data.ConfigLists {
+ cBody := netconf.Body{}
+ if !item.Name.IsNull() && !item.Name.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "name", item.Name.ValueString())
+ }
+ if !item.Group1Cache.IsNull() && !item.Group1Cache.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "group1/cache", item.Group1Cache.ValueString())
+ }
+ if !item.Group1Group.IsNull() && !item.Group1Group.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "group1/group", item.Group1Group.ValueString())
+ }
+ if !item.Group1Radius.IsNull() && !item.Group1Radius.IsUnknown() {
+ if item.Group1Radius.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "group1/radius", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "group1/radius")
+ }
+ }
+ if !item.Group1Tacacs.IsNull() && !item.Group1Tacacs.IsUnknown() {
+ if item.Group1Tacacs.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "group1/tacacs", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "group1/tacacs")
+ }
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/configuration/config-list", cBody.Res())
+ }
+ }
+ bodyString, err := body.String()
+ if err != nil {
+ tflog.Error(ctx, fmt.Sprintf("Error converting body to string: %s", err))
+ }
+ return bodyString
+}
+
+// End of section. //template:end toBodyXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBody
func (data *AAAAuthorization) updateFromBody(ctx context.Context, res gjson.Result) {
@@ -1042,108 +1451,1319 @@ func (data *AAAAuthorization) updateFromBody(ctx context.Context, res gjson.Resu
// End of section. //template:end updateFromBody
-// Section below is generated&owned by "gen/generator.go". //template:begin fromBody
+// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBodyXML
-func (data *AAAAuthorization) fromBody(ctx context.Context, res gjson.Result) {
- prefix := helpers.LastElement(data.getPath()) + "."
- if res.Get(helpers.LastElement(data.getPath())).IsArray() {
- prefix += "0."
- }
- if value := res.Get(prefix + "exec"); value.Exists() {
- data.Execs = make([]AAAAuthorizationExecs, 0)
- value.ForEach(func(k, v gjson.Result) bool {
- item := AAAAuthorizationExecs{}
- if cValue := v.Get("name"); cValue.Exists() {
- item.Name = types.StringValue(cValue.String())
- }
- if cValue := v.Get("a1.local"); cValue.Exists() {
- item.A1Local = types.BoolValue(true)
- } else {
- item.A1Local = types.BoolValue(false)
- }
- if cValue := v.Get("a1.group"); cValue.Exists() {
- item.A1Group = types.StringValue(cValue.String())
- }
- if cValue := v.Get("a1.radius"); cValue.Exists() {
- item.A1Radius = types.BoolValue(true)
- } else {
+func (data *AAAAuthorization) updateFromBodyXML(ctx context.Context, res xmldot.Result) {
+ for i := range data.Execs {
+ keys := [...]string{"name"}
+ keyValues := [...]string{data.Execs[i].Name.ValueString()}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/exec").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, "name"); value.Exists() && !data.Execs[i].Name.IsNull() {
+ data.Execs[i].Name = types.StringValue(value.String())
+ } else {
+ data.Execs[i].Name = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "a1/local"); !data.Execs[i].A1Local.IsNull() {
+ if value.Exists() {
+ data.Execs[i].A1Local = types.BoolValue(true)
+ } else {
+ data.Execs[i].A1Local = types.BoolValue(false)
+ }
+ } else {
+ data.Execs[i].A1Local = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "a1/group"); value.Exists() && !data.Execs[i].A1Group.IsNull() {
+ data.Execs[i].A1Group = types.StringValue(value.String())
+ } else {
+ data.Execs[i].A1Group = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "a1/radius"); !data.Execs[i].A1Radius.IsNull() {
+ if value.Exists() {
+ data.Execs[i].A1Radius = types.BoolValue(true)
+ } else {
+ data.Execs[i].A1Radius = types.BoolValue(false)
+ }
+ } else {
+ data.Execs[i].A1Radius = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "a1/tacacs"); !data.Execs[i].A1Tacacs.IsNull() {
+ if value.Exists() {
+ data.Execs[i].A1Tacacs = types.BoolValue(true)
+ } else {
+ data.Execs[i].A1Tacacs = types.BoolValue(false)
+ }
+ } else {
+ data.Execs[i].A1Tacacs = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "a1/if-authenticated"); !data.Execs[i].A1IfAuthenticated.IsNull() {
+ if value.Exists() {
+ data.Execs[i].A1IfAuthenticated = types.BoolValue(true)
+ } else {
+ data.Execs[i].A1IfAuthenticated = types.BoolValue(false)
+ }
+ } else {
+ data.Execs[i].A1IfAuthenticated = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "a2/local"); !data.Execs[i].A2Local.IsNull() {
+ if value.Exists() {
+ data.Execs[i].A2Local = types.BoolValue(true)
+ } else {
+ data.Execs[i].A2Local = types.BoolValue(false)
+ }
+ } else {
+ data.Execs[i].A2Local = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "a2/group"); value.Exists() && !data.Execs[i].A2Group.IsNull() {
+ data.Execs[i].A2Group = types.StringValue(value.String())
+ } else {
+ data.Execs[i].A2Group = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "a2/radius"); !data.Execs[i].A2Radius.IsNull() {
+ if value.Exists() {
+ data.Execs[i].A2Radius = types.BoolValue(true)
+ } else {
+ data.Execs[i].A2Radius = types.BoolValue(false)
+ }
+ } else {
+ data.Execs[i].A2Radius = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "a2/tacacs"); !data.Execs[i].A2Tacacs.IsNull() {
+ if value.Exists() {
+ data.Execs[i].A2Tacacs = types.BoolValue(true)
+ } else {
+ data.Execs[i].A2Tacacs = types.BoolValue(false)
+ }
+ } else {
+ data.Execs[i].A2Tacacs = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "a2/if-authenticated"); !data.Execs[i].A2IfAuthenticated.IsNull() {
+ if value.Exists() {
+ data.Execs[i].A2IfAuthenticated = types.BoolValue(true)
+ } else {
+ data.Execs[i].A2IfAuthenticated = types.BoolValue(false)
+ }
+ } else {
+ data.Execs[i].A2IfAuthenticated = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "a3/local"); !data.Execs[i].A3Local.IsNull() {
+ if value.Exists() {
+ data.Execs[i].A3Local = types.BoolValue(true)
+ } else {
+ data.Execs[i].A3Local = types.BoolValue(false)
+ }
+ } else {
+ data.Execs[i].A3Local = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "a3/group"); value.Exists() && !data.Execs[i].A3Group.IsNull() {
+ data.Execs[i].A3Group = types.StringValue(value.String())
+ } else {
+ data.Execs[i].A3Group = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "a3/radius"); !data.Execs[i].A3Radius.IsNull() {
+ if value.Exists() {
+ data.Execs[i].A3Radius = types.BoolValue(true)
+ } else {
+ data.Execs[i].A3Radius = types.BoolValue(false)
+ }
+ } else {
+ data.Execs[i].A3Radius = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "a3/tacacs"); !data.Execs[i].A3Tacacs.IsNull() {
+ if value.Exists() {
+ data.Execs[i].A3Tacacs = types.BoolValue(true)
+ } else {
+ data.Execs[i].A3Tacacs = types.BoolValue(false)
+ }
+ } else {
+ data.Execs[i].A3Tacacs = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "a3/if-authenticated"); !data.Execs[i].A3IfAuthenticated.IsNull() {
+ if value.Exists() {
+ data.Execs[i].A3IfAuthenticated = types.BoolValue(true)
+ } else {
+ data.Execs[i].A3IfAuthenticated = types.BoolValue(false)
+ }
+ } else {
+ data.Execs[i].A3IfAuthenticated = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "a4/local"); !data.Execs[i].A4Local.IsNull() {
+ if value.Exists() {
+ data.Execs[i].A4Local = types.BoolValue(true)
+ } else {
+ data.Execs[i].A4Local = types.BoolValue(false)
+ }
+ } else {
+ data.Execs[i].A4Local = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "a4/group"); value.Exists() && !data.Execs[i].A4Group.IsNull() {
+ data.Execs[i].A4Group = types.StringValue(value.String())
+ } else {
+ data.Execs[i].A4Group = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "a4/radius"); !data.Execs[i].A4Radius.IsNull() {
+ if value.Exists() {
+ data.Execs[i].A4Radius = types.BoolValue(true)
+ } else {
+ data.Execs[i].A4Radius = types.BoolValue(false)
+ }
+ } else {
+ data.Execs[i].A4Radius = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "a4/tacacs"); !data.Execs[i].A4Tacacs.IsNull() {
+ if value.Exists() {
+ data.Execs[i].A4Tacacs = types.BoolValue(true)
+ } else {
+ data.Execs[i].A4Tacacs = types.BoolValue(false)
+ }
+ } else {
+ data.Execs[i].A4Tacacs = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "a4/if-authenticated"); !data.Execs[i].A4IfAuthenticated.IsNull() {
+ if value.Exists() {
+ data.Execs[i].A4IfAuthenticated = types.BoolValue(true)
+ } else {
+ data.Execs[i].A4IfAuthenticated = types.BoolValue(false)
+ }
+ } else {
+ data.Execs[i].A4IfAuthenticated = types.BoolNull()
+ }
+ }
+ for i := range data.Networks {
+ keys := [...]string{"id"}
+ keyValues := [...]string{data.Networks[i].Id.ValueString()}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/network").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, "id"); value.Exists() && !data.Networks[i].Id.IsNull() {
+ data.Networks[i].Id = types.StringValue(value.String())
+ } else {
+ data.Networks[i].Id = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "a1/local"); !data.Networks[i].A1Local.IsNull() {
+ if value.Exists() {
+ data.Networks[i].A1Local = types.BoolValue(true)
+ } else {
+ data.Networks[i].A1Local = types.BoolValue(false)
+ }
+ } else {
+ data.Networks[i].A1Local = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "a1/group"); value.Exists() && !data.Networks[i].A1Group.IsNull() {
+ data.Networks[i].A1Group = types.StringValue(value.String())
+ } else {
+ data.Networks[i].A1Group = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "a2/local"); !data.Networks[i].A2Local.IsNull() {
+ if value.Exists() {
+ data.Networks[i].A2Local = types.BoolValue(true)
+ } else {
+ data.Networks[i].A2Local = types.BoolValue(false)
+ }
+ } else {
+ data.Networks[i].A2Local = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "a2/group"); value.Exists() && !data.Networks[i].A2Group.IsNull() {
+ data.Networks[i].A2Group = types.StringValue(value.String())
+ } else {
+ data.Networks[i].A2Group = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "a3/local"); !data.Networks[i].A3Local.IsNull() {
+ if value.Exists() {
+ data.Networks[i].A3Local = types.BoolValue(true)
+ } else {
+ data.Networks[i].A3Local = types.BoolValue(false)
+ }
+ } else {
+ data.Networks[i].A3Local = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "a3/group"); value.Exists() && !data.Networks[i].A3Group.IsNull() {
+ data.Networks[i].A3Group = types.StringValue(value.String())
+ } else {
+ data.Networks[i].A3Group = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "a4/local"); !data.Networks[i].A4Local.IsNull() {
+ if value.Exists() {
+ data.Networks[i].A4Local = types.BoolValue(true)
+ } else {
+ data.Networks[i].A4Local = types.BoolValue(false)
+ }
+ } else {
+ data.Networks[i].A4Local = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "a4/group"); value.Exists() && !data.Networks[i].A4Group.IsNull() {
+ data.Networks[i].A4Group = types.StringValue(value.String())
+ } else {
+ data.Networks[i].A4Group = types.StringNull()
+ }
+ }
+ for i := range data.Commands {
+ keys := [...]string{"level", "list-name"}
+ keyValues := [...]string{strconv.FormatInt(data.Commands[i].Level.ValueInt64(), 10), data.Commands[i].ListName.ValueString()}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/commands").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, "level"); value.Exists() && !data.Commands[i].Level.IsNull() {
+ data.Commands[i].Level = types.Int64Value(value.Int())
+ } else {
+ data.Commands[i].Level = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(r, "list-name"); value.Exists() && !data.Commands[i].ListName.IsNull() {
+ data.Commands[i].ListName = types.StringValue(value.String())
+ } else {
+ data.Commands[i].ListName = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "a1/group"); value.Exists() && !data.Commands[i].A1Group.IsNull() {
+ data.Commands[i].A1Group = types.StringValue(value.String())
+ } else {
+ data.Commands[i].A1Group = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "a1/local"); !data.Commands[i].A1Local.IsNull() {
+ if value.Exists() {
+ data.Commands[i].A1Local = types.BoolValue(true)
+ } else {
+ data.Commands[i].A1Local = types.BoolValue(false)
+ }
+ } else {
+ data.Commands[i].A1Local = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "a1/if-authenticated"); !data.Commands[i].A1IfAuthenticated.IsNull() {
+ if value.Exists() {
+ data.Commands[i].A1IfAuthenticated = types.BoolValue(true)
+ } else {
+ data.Commands[i].A1IfAuthenticated = types.BoolValue(false)
+ }
+ } else {
+ data.Commands[i].A1IfAuthenticated = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "a1/none"); !data.Commands[i].A1None.IsNull() {
+ if value.Exists() {
+ data.Commands[i].A1None = types.BoolValue(true)
+ } else {
+ data.Commands[i].A1None = types.BoolValue(false)
+ }
+ } else {
+ data.Commands[i].A1None = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "a1/radius"); !data.Commands[i].A1Radius.IsNull() {
+ if value.Exists() {
+ data.Commands[i].A1Radius = types.BoolValue(true)
+ } else {
+ data.Commands[i].A1Radius = types.BoolValue(false)
+ }
+ } else {
+ data.Commands[i].A1Radius = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "a1/tacacs"); !data.Commands[i].A1Tacacs.IsNull() {
+ if value.Exists() {
+ data.Commands[i].A1Tacacs = types.BoolValue(true)
+ } else {
+ data.Commands[i].A1Tacacs = types.BoolValue(false)
+ }
+ } else {
+ data.Commands[i].A1Tacacs = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "a2/group"); value.Exists() && !data.Commands[i].A2Group.IsNull() {
+ data.Commands[i].A2Group = types.StringValue(value.String())
+ } else {
+ data.Commands[i].A2Group = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "a2/local"); !data.Commands[i].A2Local.IsNull() {
+ if value.Exists() {
+ data.Commands[i].A2Local = types.BoolValue(true)
+ } else {
+ data.Commands[i].A2Local = types.BoolValue(false)
+ }
+ } else {
+ data.Commands[i].A2Local = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "a2/if-authenticated"); !data.Commands[i].A2IfAuthenticated.IsNull() {
+ if value.Exists() {
+ data.Commands[i].A2IfAuthenticated = types.BoolValue(true)
+ } else {
+ data.Commands[i].A2IfAuthenticated = types.BoolValue(false)
+ }
+ } else {
+ data.Commands[i].A2IfAuthenticated = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "a2/none"); !data.Commands[i].A2None.IsNull() {
+ if value.Exists() {
+ data.Commands[i].A2None = types.BoolValue(true)
+ } else {
+ data.Commands[i].A2None = types.BoolValue(false)
+ }
+ } else {
+ data.Commands[i].A2None = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "a2/radius"); !data.Commands[i].A2Radius.IsNull() {
+ if value.Exists() {
+ data.Commands[i].A2Radius = types.BoolValue(true)
+ } else {
+ data.Commands[i].A2Radius = types.BoolValue(false)
+ }
+ } else {
+ data.Commands[i].A2Radius = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "a2/tacacs"); !data.Commands[i].A2Tacacs.IsNull() {
+ if value.Exists() {
+ data.Commands[i].A2Tacacs = types.BoolValue(true)
+ } else {
+ data.Commands[i].A2Tacacs = types.BoolValue(false)
+ }
+ } else {
+ data.Commands[i].A2Tacacs = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "a3/group"); value.Exists() && !data.Commands[i].A3Group.IsNull() {
+ data.Commands[i].A3Group = types.StringValue(value.String())
+ } else {
+ data.Commands[i].A3Group = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "a3/local"); !data.Commands[i].A3Local.IsNull() {
+ if value.Exists() {
+ data.Commands[i].A3Local = types.BoolValue(true)
+ } else {
+ data.Commands[i].A3Local = types.BoolValue(false)
+ }
+ } else {
+ data.Commands[i].A3Local = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "a3/if-authenticated"); !data.Commands[i].A3IfAuthenticated.IsNull() {
+ if value.Exists() {
+ data.Commands[i].A3IfAuthenticated = types.BoolValue(true)
+ } else {
+ data.Commands[i].A3IfAuthenticated = types.BoolValue(false)
+ }
+ } else {
+ data.Commands[i].A3IfAuthenticated = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "a3/none"); !data.Commands[i].A3None.IsNull() {
+ if value.Exists() {
+ data.Commands[i].A3None = types.BoolValue(true)
+ } else {
+ data.Commands[i].A3None = types.BoolValue(false)
+ }
+ } else {
+ data.Commands[i].A3None = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "a3/radius"); !data.Commands[i].A3Radius.IsNull() {
+ if value.Exists() {
+ data.Commands[i].A3Radius = types.BoolValue(true)
+ } else {
+ data.Commands[i].A3Radius = types.BoolValue(false)
+ }
+ } else {
+ data.Commands[i].A3Radius = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "a3/tacacs"); !data.Commands[i].A3Tacacs.IsNull() {
+ if value.Exists() {
+ data.Commands[i].A3Tacacs = types.BoolValue(true)
+ } else {
+ data.Commands[i].A3Tacacs = types.BoolValue(false)
+ }
+ } else {
+ data.Commands[i].A3Tacacs = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "a4/group"); value.Exists() && !data.Commands[i].A4Group.IsNull() {
+ data.Commands[i].A4Group = types.StringValue(value.String())
+ } else {
+ data.Commands[i].A4Group = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "a4/local"); !data.Commands[i].A4Local.IsNull() {
+ if value.Exists() {
+ data.Commands[i].A4Local = types.BoolValue(true)
+ } else {
+ data.Commands[i].A4Local = types.BoolValue(false)
+ }
+ } else {
+ data.Commands[i].A4Local = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "a4/if-authenticated"); !data.Commands[i].A4IfAuthenticated.IsNull() {
+ if value.Exists() {
+ data.Commands[i].A4IfAuthenticated = types.BoolValue(true)
+ } else {
+ data.Commands[i].A4IfAuthenticated = types.BoolValue(false)
+ }
+ } else {
+ data.Commands[i].A4IfAuthenticated = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "a4/none"); !data.Commands[i].A4None.IsNull() {
+ if value.Exists() {
+ data.Commands[i].A4None = types.BoolValue(true)
+ } else {
+ data.Commands[i].A4None = types.BoolValue(false)
+ }
+ } else {
+ data.Commands[i].A4None = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "a4/radius"); !data.Commands[i].A4Radius.IsNull() {
+ if value.Exists() {
+ data.Commands[i].A4Radius = types.BoolValue(true)
+ } else {
+ data.Commands[i].A4Radius = types.BoolValue(false)
+ }
+ } else {
+ data.Commands[i].A4Radius = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "a4/tacacs"); !data.Commands[i].A4Tacacs.IsNull() {
+ if value.Exists() {
+ data.Commands[i].A4Tacacs = types.BoolValue(true)
+ } else {
+ data.Commands[i].A4Tacacs = types.BoolValue(false)
+ }
+ } else {
+ data.Commands[i].A4Tacacs = types.BoolNull()
+ }
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/config-commands"); !data.ConfigCommands.IsNull() {
+ if value.Exists() {
+ data.ConfigCommands = types.BoolValue(true)
+ } else {
+ data.ConfigCommands = types.BoolValue(false)
+ }
+ } else {
+ data.ConfigCommands = types.BoolNull()
+ }
+ for i := range data.ConfigLists {
+ keys := [...]string{"name"}
+ keyValues := [...]string{data.ConfigLists[i].Name.ValueString()}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/configuration/config-list").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, "name"); value.Exists() && !data.ConfigLists[i].Name.IsNull() {
+ data.ConfigLists[i].Name = types.StringValue(value.String())
+ } else {
+ data.ConfigLists[i].Name = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "group1/cache"); value.Exists() && !data.ConfigLists[i].Group1Cache.IsNull() {
+ data.ConfigLists[i].Group1Cache = types.StringValue(value.String())
+ } else {
+ data.ConfigLists[i].Group1Cache = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "group1/group"); value.Exists() && !data.ConfigLists[i].Group1Group.IsNull() {
+ data.ConfigLists[i].Group1Group = types.StringValue(value.String())
+ } else {
+ data.ConfigLists[i].Group1Group = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "group1/radius"); !data.ConfigLists[i].Group1Radius.IsNull() {
+ if value.Exists() {
+ data.ConfigLists[i].Group1Radius = types.BoolValue(true)
+ } else {
+ data.ConfigLists[i].Group1Radius = types.BoolValue(false)
+ }
+ } else {
+ data.ConfigLists[i].Group1Radius = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "group1/tacacs"); !data.ConfigLists[i].Group1Tacacs.IsNull() {
+ if value.Exists() {
+ data.ConfigLists[i].Group1Tacacs = types.BoolValue(true)
+ } else {
+ data.ConfigLists[i].Group1Tacacs = types.BoolValue(false)
+ }
+ } else {
+ data.ConfigLists[i].Group1Tacacs = types.BoolNull()
+ }
+ }
+}
+
+// End of section. //template:end updateFromBodyXML
+
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBody
+
+func (data *AAAAuthorization) fromBody(ctx context.Context, res gjson.Result) {
+ prefix := helpers.LastElement(data.getPath()) + "."
+ if res.Get(helpers.LastElement(data.getPath())).IsArray() {
+ prefix += "0."
+ }
+ if value := res.Get(prefix + "exec"); value.Exists() {
+ data.Execs = make([]AAAAuthorizationExecs, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := AAAAuthorizationExecs{}
+ if cValue := v.Get("name"); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("a1.local"); cValue.Exists() {
+ item.A1Local = types.BoolValue(true)
+ } else {
+ item.A1Local = types.BoolValue(false)
+ }
+ if cValue := v.Get("a1.group"); cValue.Exists() {
+ item.A1Group = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("a1.radius"); cValue.Exists() {
+ item.A1Radius = types.BoolValue(true)
+ } else {
+ item.A1Radius = types.BoolValue(false)
+ }
+ if cValue := v.Get("a1.tacacs"); cValue.Exists() {
+ item.A1Tacacs = types.BoolValue(true)
+ } else {
+ item.A1Tacacs = types.BoolValue(false)
+ }
+ if cValue := v.Get("a1.if-authenticated"); cValue.Exists() {
+ item.A1IfAuthenticated = types.BoolValue(true)
+ } else {
+ item.A1IfAuthenticated = types.BoolValue(false)
+ }
+ if cValue := v.Get("a2.local"); cValue.Exists() {
+ item.A2Local = types.BoolValue(true)
+ } else {
+ item.A2Local = types.BoolValue(false)
+ }
+ if cValue := v.Get("a2.group"); cValue.Exists() {
+ item.A2Group = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("a2.radius"); cValue.Exists() {
+ item.A2Radius = types.BoolValue(true)
+ } else {
+ item.A2Radius = types.BoolValue(false)
+ }
+ if cValue := v.Get("a2.tacacs"); cValue.Exists() {
+ item.A2Tacacs = types.BoolValue(true)
+ } else {
+ item.A2Tacacs = types.BoolValue(false)
+ }
+ if cValue := v.Get("a2.if-authenticated"); cValue.Exists() {
+ item.A2IfAuthenticated = types.BoolValue(true)
+ } else {
+ item.A2IfAuthenticated = types.BoolValue(false)
+ }
+ if cValue := v.Get("a3.local"); cValue.Exists() {
+ item.A3Local = types.BoolValue(true)
+ } else {
+ item.A3Local = types.BoolValue(false)
+ }
+ if cValue := v.Get("a3.group"); cValue.Exists() {
+ item.A3Group = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("a3.radius"); cValue.Exists() {
+ item.A3Radius = types.BoolValue(true)
+ } else {
+ item.A3Radius = types.BoolValue(false)
+ }
+ if cValue := v.Get("a3.tacacs"); cValue.Exists() {
+ item.A3Tacacs = types.BoolValue(true)
+ } else {
+ item.A3Tacacs = types.BoolValue(false)
+ }
+ if cValue := v.Get("a3.if-authenticated"); cValue.Exists() {
+ item.A3IfAuthenticated = types.BoolValue(true)
+ } else {
+ item.A3IfAuthenticated = types.BoolValue(false)
+ }
+ if cValue := v.Get("a4.local"); cValue.Exists() {
+ item.A4Local = types.BoolValue(true)
+ } else {
+ item.A4Local = types.BoolValue(false)
+ }
+ if cValue := v.Get("a4.group"); cValue.Exists() {
+ item.A4Group = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("a4.radius"); cValue.Exists() {
+ item.A4Radius = types.BoolValue(true)
+ } else {
+ item.A4Radius = types.BoolValue(false)
+ }
+ if cValue := v.Get("a4.tacacs"); cValue.Exists() {
+ item.A4Tacacs = types.BoolValue(true)
+ } else {
+ item.A4Tacacs = types.BoolValue(false)
+ }
+ if cValue := v.Get("a4.if-authenticated"); cValue.Exists() {
+ item.A4IfAuthenticated = types.BoolValue(true)
+ } else {
+ item.A4IfAuthenticated = types.BoolValue(false)
+ }
+ data.Execs = append(data.Execs, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + "network"); value.Exists() {
+ data.Networks = make([]AAAAuthorizationNetworks, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := AAAAuthorizationNetworks{}
+ if cValue := v.Get("id"); cValue.Exists() {
+ item.Id = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("a1.local"); cValue.Exists() {
+ item.A1Local = types.BoolValue(true)
+ } else {
+ item.A1Local = types.BoolValue(false)
+ }
+ if cValue := v.Get("a1.group"); cValue.Exists() {
+ item.A1Group = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("a2.local"); cValue.Exists() {
+ item.A2Local = types.BoolValue(true)
+ } else {
+ item.A2Local = types.BoolValue(false)
+ }
+ if cValue := v.Get("a2.group"); cValue.Exists() {
+ item.A2Group = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("a3.local"); cValue.Exists() {
+ item.A3Local = types.BoolValue(true)
+ } else {
+ item.A3Local = types.BoolValue(false)
+ }
+ if cValue := v.Get("a3.group"); cValue.Exists() {
+ item.A3Group = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("a4.local"); cValue.Exists() {
+ item.A4Local = types.BoolValue(true)
+ } else {
+ item.A4Local = types.BoolValue(false)
+ }
+ if cValue := v.Get("a4.group"); cValue.Exists() {
+ item.A4Group = types.StringValue(cValue.String())
+ }
+ data.Networks = append(data.Networks, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + "commands"); value.Exists() {
+ data.Commands = make([]AAAAuthorizationCommands, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := AAAAuthorizationCommands{}
+ if cValue := v.Get("level"); cValue.Exists() {
+ item.Level = types.Int64Value(cValue.Int())
+ }
+ if cValue := v.Get("list-name"); cValue.Exists() {
+ item.ListName = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("a1.group"); cValue.Exists() {
+ item.A1Group = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("a1.local"); cValue.Exists() {
+ item.A1Local = types.BoolValue(true)
+ } else {
+ item.A1Local = types.BoolValue(false)
+ }
+ if cValue := v.Get("a1.if-authenticated"); cValue.Exists() {
+ item.A1IfAuthenticated = types.BoolValue(true)
+ } else {
+ item.A1IfAuthenticated = types.BoolValue(false)
+ }
+ if cValue := v.Get("a1.none"); cValue.Exists() {
+ item.A1None = types.BoolValue(true)
+ } else {
+ item.A1None = types.BoolValue(false)
+ }
+ if cValue := v.Get("a1.radius"); cValue.Exists() {
+ item.A1Radius = types.BoolValue(true)
+ } else {
+ item.A1Radius = types.BoolValue(false)
+ }
+ if cValue := v.Get("a1.tacacs"); cValue.Exists() {
+ item.A1Tacacs = types.BoolValue(true)
+ } else {
+ item.A1Tacacs = types.BoolValue(false)
+ }
+ if cValue := v.Get("a2.group"); cValue.Exists() {
+ item.A2Group = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("a2.local"); cValue.Exists() {
+ item.A2Local = types.BoolValue(true)
+ } else {
+ item.A2Local = types.BoolValue(false)
+ }
+ if cValue := v.Get("a2.if-authenticated"); cValue.Exists() {
+ item.A2IfAuthenticated = types.BoolValue(true)
+ } else {
+ item.A2IfAuthenticated = types.BoolValue(false)
+ }
+ if cValue := v.Get("a2.none"); cValue.Exists() {
+ item.A2None = types.BoolValue(true)
+ } else {
+ item.A2None = types.BoolValue(false)
+ }
+ if cValue := v.Get("a2.radius"); cValue.Exists() {
+ item.A2Radius = types.BoolValue(true)
+ } else {
+ item.A2Radius = types.BoolValue(false)
+ }
+ if cValue := v.Get("a2.tacacs"); cValue.Exists() {
+ item.A2Tacacs = types.BoolValue(true)
+ } else {
+ item.A2Tacacs = types.BoolValue(false)
+ }
+ if cValue := v.Get("a3.group"); cValue.Exists() {
+ item.A3Group = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("a3.local"); cValue.Exists() {
+ item.A3Local = types.BoolValue(true)
+ } else {
+ item.A3Local = types.BoolValue(false)
+ }
+ if cValue := v.Get("a3.if-authenticated"); cValue.Exists() {
+ item.A3IfAuthenticated = types.BoolValue(true)
+ } else {
+ item.A3IfAuthenticated = types.BoolValue(false)
+ }
+ if cValue := v.Get("a3.none"); cValue.Exists() {
+ item.A3None = types.BoolValue(true)
+ } else {
+ item.A3None = types.BoolValue(false)
+ }
+ if cValue := v.Get("a3.radius"); cValue.Exists() {
+ item.A3Radius = types.BoolValue(true)
+ } else {
+ item.A3Radius = types.BoolValue(false)
+ }
+ if cValue := v.Get("a3.tacacs"); cValue.Exists() {
+ item.A3Tacacs = types.BoolValue(true)
+ } else {
+ item.A3Tacacs = types.BoolValue(false)
+ }
+ if cValue := v.Get("a4.group"); cValue.Exists() {
+ item.A4Group = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("a4.local"); cValue.Exists() {
+ item.A4Local = types.BoolValue(true)
+ } else {
+ item.A4Local = types.BoolValue(false)
+ }
+ if cValue := v.Get("a4.if-authenticated"); cValue.Exists() {
+ item.A4IfAuthenticated = types.BoolValue(true)
+ } else {
+ item.A4IfAuthenticated = types.BoolValue(false)
+ }
+ if cValue := v.Get("a4.none"); cValue.Exists() {
+ item.A4None = types.BoolValue(true)
+ } else {
+ item.A4None = types.BoolValue(false)
+ }
+ if cValue := v.Get("a4.radius"); cValue.Exists() {
+ item.A4Radius = types.BoolValue(true)
+ } else {
+ item.A4Radius = types.BoolValue(false)
+ }
+ if cValue := v.Get("a4.tacacs"); cValue.Exists() {
+ item.A4Tacacs = types.BoolValue(true)
+ } else {
+ item.A4Tacacs = types.BoolValue(false)
+ }
+ data.Commands = append(data.Commands, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + "config-commands"); value.Exists() {
+ data.ConfigCommands = types.BoolValue(true)
+ } else {
+ data.ConfigCommands = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "configuration.config-list"); value.Exists() {
+ data.ConfigLists = make([]AAAAuthorizationConfigLists, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := AAAAuthorizationConfigLists{}
+ if cValue := v.Get("name"); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("group1.cache"); cValue.Exists() {
+ item.Group1Cache = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("group1.group"); cValue.Exists() {
+ item.Group1Group = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("group1.radius"); cValue.Exists() {
+ item.Group1Radius = types.BoolValue(true)
+ } else {
+ item.Group1Radius = types.BoolValue(false)
+ }
+ if cValue := v.Get("group1.tacacs"); cValue.Exists() {
+ item.Group1Tacacs = types.BoolValue(true)
+ } else {
+ item.Group1Tacacs = types.BoolValue(false)
+ }
+ data.ConfigLists = append(data.ConfigLists, item)
+ return true
+ })
+ }
+}
+
+// End of section. //template:end fromBody
+
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyData
+
+func (data *AAAAuthorizationData) fromBody(ctx context.Context, res gjson.Result) {
+ prefix := helpers.LastElement(data.getPath()) + "."
+ if res.Get(helpers.LastElement(data.getPath())).IsArray() {
+ prefix += "0."
+ }
+ if value := res.Get(prefix + "exec"); value.Exists() {
+ data.Execs = make([]AAAAuthorizationExecs, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := AAAAuthorizationExecs{}
+ if cValue := v.Get("name"); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("a1.local"); cValue.Exists() {
+ item.A1Local = types.BoolValue(true)
+ } else {
+ item.A1Local = types.BoolValue(false)
+ }
+ if cValue := v.Get("a1.group"); cValue.Exists() {
+ item.A1Group = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("a1.radius"); cValue.Exists() {
+ item.A1Radius = types.BoolValue(true)
+ } else {
+ item.A1Radius = types.BoolValue(false)
+ }
+ if cValue := v.Get("a1.tacacs"); cValue.Exists() {
+ item.A1Tacacs = types.BoolValue(true)
+ } else {
+ item.A1Tacacs = types.BoolValue(false)
+ }
+ if cValue := v.Get("a1.if-authenticated"); cValue.Exists() {
+ item.A1IfAuthenticated = types.BoolValue(true)
+ } else {
+ item.A1IfAuthenticated = types.BoolValue(false)
+ }
+ if cValue := v.Get("a2.local"); cValue.Exists() {
+ item.A2Local = types.BoolValue(true)
+ } else {
+ item.A2Local = types.BoolValue(false)
+ }
+ if cValue := v.Get("a2.group"); cValue.Exists() {
+ item.A2Group = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("a2.radius"); cValue.Exists() {
+ item.A2Radius = types.BoolValue(true)
+ } else {
+ item.A2Radius = types.BoolValue(false)
+ }
+ if cValue := v.Get("a2.tacacs"); cValue.Exists() {
+ item.A2Tacacs = types.BoolValue(true)
+ } else {
+ item.A2Tacacs = types.BoolValue(false)
+ }
+ if cValue := v.Get("a2.if-authenticated"); cValue.Exists() {
+ item.A2IfAuthenticated = types.BoolValue(true)
+ } else {
+ item.A2IfAuthenticated = types.BoolValue(false)
+ }
+ if cValue := v.Get("a3.local"); cValue.Exists() {
+ item.A3Local = types.BoolValue(true)
+ } else {
+ item.A3Local = types.BoolValue(false)
+ }
+ if cValue := v.Get("a3.group"); cValue.Exists() {
+ item.A3Group = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("a3.radius"); cValue.Exists() {
+ item.A3Radius = types.BoolValue(true)
+ } else {
+ item.A3Radius = types.BoolValue(false)
+ }
+ if cValue := v.Get("a3.tacacs"); cValue.Exists() {
+ item.A3Tacacs = types.BoolValue(true)
+ } else {
+ item.A3Tacacs = types.BoolValue(false)
+ }
+ if cValue := v.Get("a3.if-authenticated"); cValue.Exists() {
+ item.A3IfAuthenticated = types.BoolValue(true)
+ } else {
+ item.A3IfAuthenticated = types.BoolValue(false)
+ }
+ if cValue := v.Get("a4.local"); cValue.Exists() {
+ item.A4Local = types.BoolValue(true)
+ } else {
+ item.A4Local = types.BoolValue(false)
+ }
+ if cValue := v.Get("a4.group"); cValue.Exists() {
+ item.A4Group = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("a4.radius"); cValue.Exists() {
+ item.A4Radius = types.BoolValue(true)
+ } else {
+ item.A4Radius = types.BoolValue(false)
+ }
+ if cValue := v.Get("a4.tacacs"); cValue.Exists() {
+ item.A4Tacacs = types.BoolValue(true)
+ } else {
+ item.A4Tacacs = types.BoolValue(false)
+ }
+ if cValue := v.Get("a4.if-authenticated"); cValue.Exists() {
+ item.A4IfAuthenticated = types.BoolValue(true)
+ } else {
+ item.A4IfAuthenticated = types.BoolValue(false)
+ }
+ data.Execs = append(data.Execs, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + "network"); value.Exists() {
+ data.Networks = make([]AAAAuthorizationNetworks, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := AAAAuthorizationNetworks{}
+ if cValue := v.Get("id"); cValue.Exists() {
+ item.Id = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("a1.local"); cValue.Exists() {
+ item.A1Local = types.BoolValue(true)
+ } else {
+ item.A1Local = types.BoolValue(false)
+ }
+ if cValue := v.Get("a1.group"); cValue.Exists() {
+ item.A1Group = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("a2.local"); cValue.Exists() {
+ item.A2Local = types.BoolValue(true)
+ } else {
+ item.A2Local = types.BoolValue(false)
+ }
+ if cValue := v.Get("a2.group"); cValue.Exists() {
+ item.A2Group = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("a3.local"); cValue.Exists() {
+ item.A3Local = types.BoolValue(true)
+ } else {
+ item.A3Local = types.BoolValue(false)
+ }
+ if cValue := v.Get("a3.group"); cValue.Exists() {
+ item.A3Group = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("a4.local"); cValue.Exists() {
+ item.A4Local = types.BoolValue(true)
+ } else {
+ item.A4Local = types.BoolValue(false)
+ }
+ if cValue := v.Get("a4.group"); cValue.Exists() {
+ item.A4Group = types.StringValue(cValue.String())
+ }
+ data.Networks = append(data.Networks, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + "commands"); value.Exists() {
+ data.Commands = make([]AAAAuthorizationCommands, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := AAAAuthorizationCommands{}
+ if cValue := v.Get("level"); cValue.Exists() {
+ item.Level = types.Int64Value(cValue.Int())
+ }
+ if cValue := v.Get("list-name"); cValue.Exists() {
+ item.ListName = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("a1.group"); cValue.Exists() {
+ item.A1Group = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("a1.local"); cValue.Exists() {
+ item.A1Local = types.BoolValue(true)
+ } else {
+ item.A1Local = types.BoolValue(false)
+ }
+ if cValue := v.Get("a1.if-authenticated"); cValue.Exists() {
+ item.A1IfAuthenticated = types.BoolValue(true)
+ } else {
+ item.A1IfAuthenticated = types.BoolValue(false)
+ }
+ if cValue := v.Get("a1.none"); cValue.Exists() {
+ item.A1None = types.BoolValue(true)
+ } else {
+ item.A1None = types.BoolValue(false)
+ }
+ if cValue := v.Get("a1.radius"); cValue.Exists() {
+ item.A1Radius = types.BoolValue(true)
+ } else {
+ item.A1Radius = types.BoolValue(false)
+ }
+ if cValue := v.Get("a1.tacacs"); cValue.Exists() {
+ item.A1Tacacs = types.BoolValue(true)
+ } else {
+ item.A1Tacacs = types.BoolValue(false)
+ }
+ if cValue := v.Get("a2.group"); cValue.Exists() {
+ item.A2Group = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("a2.local"); cValue.Exists() {
+ item.A2Local = types.BoolValue(true)
+ } else {
+ item.A2Local = types.BoolValue(false)
+ }
+ if cValue := v.Get("a2.if-authenticated"); cValue.Exists() {
+ item.A2IfAuthenticated = types.BoolValue(true)
+ } else {
+ item.A2IfAuthenticated = types.BoolValue(false)
+ }
+ if cValue := v.Get("a2.none"); cValue.Exists() {
+ item.A2None = types.BoolValue(true)
+ } else {
+ item.A2None = types.BoolValue(false)
+ }
+ if cValue := v.Get("a2.radius"); cValue.Exists() {
+ item.A2Radius = types.BoolValue(true)
+ } else {
+ item.A2Radius = types.BoolValue(false)
+ }
+ if cValue := v.Get("a2.tacacs"); cValue.Exists() {
+ item.A2Tacacs = types.BoolValue(true)
+ } else {
+ item.A2Tacacs = types.BoolValue(false)
+ }
+ if cValue := v.Get("a3.group"); cValue.Exists() {
+ item.A3Group = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("a3.local"); cValue.Exists() {
+ item.A3Local = types.BoolValue(true)
+ } else {
+ item.A3Local = types.BoolValue(false)
+ }
+ if cValue := v.Get("a3.if-authenticated"); cValue.Exists() {
+ item.A3IfAuthenticated = types.BoolValue(true)
+ } else {
+ item.A3IfAuthenticated = types.BoolValue(false)
+ }
+ if cValue := v.Get("a3.none"); cValue.Exists() {
+ item.A3None = types.BoolValue(true)
+ } else {
+ item.A3None = types.BoolValue(false)
+ }
+ if cValue := v.Get("a3.radius"); cValue.Exists() {
+ item.A3Radius = types.BoolValue(true)
+ } else {
+ item.A3Radius = types.BoolValue(false)
+ }
+ if cValue := v.Get("a3.tacacs"); cValue.Exists() {
+ item.A3Tacacs = types.BoolValue(true)
+ } else {
+ item.A3Tacacs = types.BoolValue(false)
+ }
+ if cValue := v.Get("a4.group"); cValue.Exists() {
+ item.A4Group = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("a4.local"); cValue.Exists() {
+ item.A4Local = types.BoolValue(true)
+ } else {
+ item.A4Local = types.BoolValue(false)
+ }
+ if cValue := v.Get("a4.if-authenticated"); cValue.Exists() {
+ item.A4IfAuthenticated = types.BoolValue(true)
+ } else {
+ item.A4IfAuthenticated = types.BoolValue(false)
+ }
+ if cValue := v.Get("a4.none"); cValue.Exists() {
+ item.A4None = types.BoolValue(true)
+ } else {
+ item.A4None = types.BoolValue(false)
+ }
+ if cValue := v.Get("a4.radius"); cValue.Exists() {
+ item.A4Radius = types.BoolValue(true)
+ } else {
+ item.A4Radius = types.BoolValue(false)
+ }
+ if cValue := v.Get("a4.tacacs"); cValue.Exists() {
+ item.A4Tacacs = types.BoolValue(true)
+ } else {
+ item.A4Tacacs = types.BoolValue(false)
+ }
+ data.Commands = append(data.Commands, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + "config-commands"); value.Exists() {
+ data.ConfigCommands = types.BoolValue(true)
+ } else {
+ data.ConfigCommands = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "configuration.config-list"); value.Exists() {
+ data.ConfigLists = make([]AAAAuthorizationConfigLists, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := AAAAuthorizationConfigLists{}
+ if cValue := v.Get("name"); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("group1.cache"); cValue.Exists() {
+ item.Group1Cache = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("group1.group"); cValue.Exists() {
+ item.Group1Group = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("group1.radius"); cValue.Exists() {
+ item.Group1Radius = types.BoolValue(true)
+ } else {
+ item.Group1Radius = types.BoolValue(false)
+ }
+ if cValue := v.Get("group1.tacacs"); cValue.Exists() {
+ item.Group1Tacacs = types.BoolValue(true)
+ } else {
+ item.Group1Tacacs = types.BoolValue(false)
+ }
+ data.ConfigLists = append(data.ConfigLists, item)
+ return true
+ })
+ }
+}
+
+// End of section. //template:end fromBodyData
+
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyXML
+
+func (data *AAAAuthorization) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/exec"); value.Exists() {
+ data.Execs = make([]AAAAuthorizationExecs, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := AAAAuthorizationExecs{}
+ if cValue := helpers.GetFromXPath(v, "name"); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "a1/local"); cValue.Exists() {
+ item.A1Local = types.BoolValue(true)
+ } else {
+ item.A1Local = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "a1/group"); cValue.Exists() {
+ item.A1Group = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "a1/radius"); cValue.Exists() {
+ item.A1Radius = types.BoolValue(true)
+ } else {
item.A1Radius = types.BoolValue(false)
}
- if cValue := v.Get("a1.tacacs"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "a1/tacacs"); cValue.Exists() {
item.A1Tacacs = types.BoolValue(true)
} else {
item.A1Tacacs = types.BoolValue(false)
}
- if cValue := v.Get("a1.if-authenticated"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "a1/if-authenticated"); cValue.Exists() {
item.A1IfAuthenticated = types.BoolValue(true)
} else {
item.A1IfAuthenticated = types.BoolValue(false)
}
- if cValue := v.Get("a2.local"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "a2/local"); cValue.Exists() {
item.A2Local = types.BoolValue(true)
} else {
item.A2Local = types.BoolValue(false)
}
- if cValue := v.Get("a2.group"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "a2/group"); cValue.Exists() {
item.A2Group = types.StringValue(cValue.String())
}
- if cValue := v.Get("a2.radius"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "a2/radius"); cValue.Exists() {
item.A2Radius = types.BoolValue(true)
} else {
item.A2Radius = types.BoolValue(false)
}
- if cValue := v.Get("a2.tacacs"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "a2/tacacs"); cValue.Exists() {
item.A2Tacacs = types.BoolValue(true)
} else {
item.A2Tacacs = types.BoolValue(false)
}
- if cValue := v.Get("a2.if-authenticated"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "a2/if-authenticated"); cValue.Exists() {
item.A2IfAuthenticated = types.BoolValue(true)
} else {
item.A2IfAuthenticated = types.BoolValue(false)
}
- if cValue := v.Get("a3.local"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "a3/local"); cValue.Exists() {
item.A3Local = types.BoolValue(true)
} else {
item.A3Local = types.BoolValue(false)
}
- if cValue := v.Get("a3.group"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "a3/group"); cValue.Exists() {
item.A3Group = types.StringValue(cValue.String())
}
- if cValue := v.Get("a3.radius"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "a3/radius"); cValue.Exists() {
item.A3Radius = types.BoolValue(true)
} else {
item.A3Radius = types.BoolValue(false)
}
- if cValue := v.Get("a3.tacacs"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "a3/tacacs"); cValue.Exists() {
item.A3Tacacs = types.BoolValue(true)
} else {
item.A3Tacacs = types.BoolValue(false)
}
- if cValue := v.Get("a3.if-authenticated"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "a3/if-authenticated"); cValue.Exists() {
item.A3IfAuthenticated = types.BoolValue(true)
} else {
item.A3IfAuthenticated = types.BoolValue(false)
}
- if cValue := v.Get("a4.local"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "a4/local"); cValue.Exists() {
item.A4Local = types.BoolValue(true)
} else {
item.A4Local = types.BoolValue(false)
}
- if cValue := v.Get("a4.group"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "a4/group"); cValue.Exists() {
item.A4Group = types.StringValue(cValue.String())
}
- if cValue := v.Get("a4.radius"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "a4/radius"); cValue.Exists() {
item.A4Radius = types.BoolValue(true)
} else {
item.A4Radius = types.BoolValue(false)
}
- if cValue := v.Get("a4.tacacs"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "a4/tacacs"); cValue.Exists() {
item.A4Tacacs = types.BoolValue(true)
} else {
item.A4Tacacs = types.BoolValue(false)
}
- if cValue := v.Get("a4.if-authenticated"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "a4/if-authenticated"); cValue.Exists() {
item.A4IfAuthenticated = types.BoolValue(true)
} else {
item.A4IfAuthenticated = types.BoolValue(false)
@@ -1152,167 +2772,167 @@ func (data *AAAAuthorization) fromBody(ctx context.Context, res gjson.Result) {
return true
})
}
- if value := res.Get(prefix + "network"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/network"); value.Exists() {
data.Networks = make([]AAAAuthorizationNetworks, 0)
- value.ForEach(func(k, v gjson.Result) bool {
+ value.ForEach(func(_ int, v xmldot.Result) bool {
item := AAAAuthorizationNetworks{}
- if cValue := v.Get("id"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "id"); cValue.Exists() {
item.Id = types.StringValue(cValue.String())
}
- if cValue := v.Get("a1.local"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "a1/local"); cValue.Exists() {
item.A1Local = types.BoolValue(true)
} else {
item.A1Local = types.BoolValue(false)
}
- if cValue := v.Get("a1.group"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "a1/group"); cValue.Exists() {
item.A1Group = types.StringValue(cValue.String())
}
- if cValue := v.Get("a2.local"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "a2/local"); cValue.Exists() {
item.A2Local = types.BoolValue(true)
} else {
item.A2Local = types.BoolValue(false)
}
- if cValue := v.Get("a2.group"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "a2/group"); cValue.Exists() {
item.A2Group = types.StringValue(cValue.String())
}
- if cValue := v.Get("a3.local"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "a3/local"); cValue.Exists() {
item.A3Local = types.BoolValue(true)
} else {
item.A3Local = types.BoolValue(false)
}
- if cValue := v.Get("a3.group"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "a3/group"); cValue.Exists() {
item.A3Group = types.StringValue(cValue.String())
}
- if cValue := v.Get("a4.local"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "a4/local"); cValue.Exists() {
item.A4Local = types.BoolValue(true)
} else {
item.A4Local = types.BoolValue(false)
}
- if cValue := v.Get("a4.group"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "a4/group"); cValue.Exists() {
item.A4Group = types.StringValue(cValue.String())
}
data.Networks = append(data.Networks, item)
return true
})
}
- if value := res.Get(prefix + "commands"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/commands"); value.Exists() {
data.Commands = make([]AAAAuthorizationCommands, 0)
- value.ForEach(func(k, v gjson.Result) bool {
+ value.ForEach(func(_ int, v xmldot.Result) bool {
item := AAAAuthorizationCommands{}
- if cValue := v.Get("level"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "level"); cValue.Exists() {
item.Level = types.Int64Value(cValue.Int())
}
- if cValue := v.Get("list-name"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "list-name"); cValue.Exists() {
item.ListName = types.StringValue(cValue.String())
}
- if cValue := v.Get("a1.group"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "a1/group"); cValue.Exists() {
item.A1Group = types.StringValue(cValue.String())
}
- if cValue := v.Get("a1.local"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "a1/local"); cValue.Exists() {
item.A1Local = types.BoolValue(true)
} else {
item.A1Local = types.BoolValue(false)
}
- if cValue := v.Get("a1.if-authenticated"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "a1/if-authenticated"); cValue.Exists() {
item.A1IfAuthenticated = types.BoolValue(true)
} else {
item.A1IfAuthenticated = types.BoolValue(false)
}
- if cValue := v.Get("a1.none"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "a1/none"); cValue.Exists() {
item.A1None = types.BoolValue(true)
} else {
item.A1None = types.BoolValue(false)
}
- if cValue := v.Get("a1.radius"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "a1/radius"); cValue.Exists() {
item.A1Radius = types.BoolValue(true)
} else {
item.A1Radius = types.BoolValue(false)
}
- if cValue := v.Get("a1.tacacs"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "a1/tacacs"); cValue.Exists() {
item.A1Tacacs = types.BoolValue(true)
} else {
item.A1Tacacs = types.BoolValue(false)
}
- if cValue := v.Get("a2.group"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "a2/group"); cValue.Exists() {
item.A2Group = types.StringValue(cValue.String())
}
- if cValue := v.Get("a2.local"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "a2/local"); cValue.Exists() {
item.A2Local = types.BoolValue(true)
} else {
item.A2Local = types.BoolValue(false)
}
- if cValue := v.Get("a2.if-authenticated"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "a2/if-authenticated"); cValue.Exists() {
item.A2IfAuthenticated = types.BoolValue(true)
} else {
item.A2IfAuthenticated = types.BoolValue(false)
}
- if cValue := v.Get("a2.none"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "a2/none"); cValue.Exists() {
item.A2None = types.BoolValue(true)
} else {
item.A2None = types.BoolValue(false)
}
- if cValue := v.Get("a2.radius"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "a2/radius"); cValue.Exists() {
item.A2Radius = types.BoolValue(true)
} else {
item.A2Radius = types.BoolValue(false)
}
- if cValue := v.Get("a2.tacacs"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "a2/tacacs"); cValue.Exists() {
item.A2Tacacs = types.BoolValue(true)
} else {
item.A2Tacacs = types.BoolValue(false)
}
- if cValue := v.Get("a3.group"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "a3/group"); cValue.Exists() {
item.A3Group = types.StringValue(cValue.String())
}
- if cValue := v.Get("a3.local"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "a3/local"); cValue.Exists() {
item.A3Local = types.BoolValue(true)
} else {
item.A3Local = types.BoolValue(false)
}
- if cValue := v.Get("a3.if-authenticated"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "a3/if-authenticated"); cValue.Exists() {
item.A3IfAuthenticated = types.BoolValue(true)
} else {
item.A3IfAuthenticated = types.BoolValue(false)
}
- if cValue := v.Get("a3.none"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "a3/none"); cValue.Exists() {
item.A3None = types.BoolValue(true)
} else {
item.A3None = types.BoolValue(false)
}
- if cValue := v.Get("a3.radius"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "a3/radius"); cValue.Exists() {
item.A3Radius = types.BoolValue(true)
} else {
item.A3Radius = types.BoolValue(false)
}
- if cValue := v.Get("a3.tacacs"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "a3/tacacs"); cValue.Exists() {
item.A3Tacacs = types.BoolValue(true)
} else {
item.A3Tacacs = types.BoolValue(false)
}
- if cValue := v.Get("a4.group"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "a4/group"); cValue.Exists() {
item.A4Group = types.StringValue(cValue.String())
}
- if cValue := v.Get("a4.local"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "a4/local"); cValue.Exists() {
item.A4Local = types.BoolValue(true)
} else {
item.A4Local = types.BoolValue(false)
}
- if cValue := v.Get("a4.if-authenticated"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "a4/if-authenticated"); cValue.Exists() {
item.A4IfAuthenticated = types.BoolValue(true)
} else {
item.A4IfAuthenticated = types.BoolValue(false)
}
- if cValue := v.Get("a4.none"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "a4/none"); cValue.Exists() {
item.A4None = types.BoolValue(true)
} else {
item.A4None = types.BoolValue(false)
}
- if cValue := v.Get("a4.radius"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "a4/radius"); cValue.Exists() {
item.A4Radius = types.BoolValue(true)
} else {
item.A4Radius = types.BoolValue(false)
}
- if cValue := v.Get("a4.tacacs"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "a4/tacacs"); cValue.Exists() {
item.A4Tacacs = types.BoolValue(true)
} else {
item.A4Tacacs = types.BoolValue(false)
@@ -1321,30 +2941,30 @@ func (data *AAAAuthorization) fromBody(ctx context.Context, res gjson.Result) {
return true
})
}
- if value := res.Get(prefix + "config-commands"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/config-commands"); value.Exists() {
data.ConfigCommands = types.BoolValue(true)
} else {
data.ConfigCommands = types.BoolValue(false)
}
- if value := res.Get(prefix + "configuration.config-list"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/configuration/config-list"); value.Exists() {
data.ConfigLists = make([]AAAAuthorizationConfigLists, 0)
- value.ForEach(func(k, v gjson.Result) bool {
+ value.ForEach(func(_ int, v xmldot.Result) bool {
item := AAAAuthorizationConfigLists{}
- if cValue := v.Get("name"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "name"); cValue.Exists() {
item.Name = types.StringValue(cValue.String())
}
- if cValue := v.Get("group1.cache"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "group1/cache"); cValue.Exists() {
item.Group1Cache = types.StringValue(cValue.String())
}
- if cValue := v.Get("group1.group"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "group1/group"); cValue.Exists() {
item.Group1Group = types.StringValue(cValue.String())
}
- if cValue := v.Get("group1.radius"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "group1/radius"); cValue.Exists() {
item.Group1Radius = types.BoolValue(true)
} else {
item.Group1Radius = types.BoolValue(false)
}
- if cValue := v.Get("group1.tacacs"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "group1/tacacs"); cValue.Exists() {
item.Group1Tacacs = types.BoolValue(true)
} else {
item.Group1Tacacs = types.BoolValue(false)
@@ -1355,110 +2975,106 @@ func (data *AAAAuthorization) fromBody(ctx context.Context, res gjson.Result) {
}
}
-// End of section. //template:end fromBody
+// End of section. //template:end fromBodyXML
-// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyData
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyDataXML
-func (data *AAAAuthorizationData) fromBody(ctx context.Context, res gjson.Result) {
- prefix := helpers.LastElement(data.getPath()) + "."
- if res.Get(helpers.LastElement(data.getPath())).IsArray() {
- prefix += "0."
- }
- if value := res.Get(prefix + "exec"); value.Exists() {
+func (data *AAAAuthorizationData) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/exec"); value.Exists() {
data.Execs = make([]AAAAuthorizationExecs, 0)
- value.ForEach(func(k, v gjson.Result) bool {
+ value.ForEach(func(_ int, v xmldot.Result) bool {
item := AAAAuthorizationExecs{}
- if cValue := v.Get("name"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "name"); cValue.Exists() {
item.Name = types.StringValue(cValue.String())
}
- if cValue := v.Get("a1.local"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "a1/local"); cValue.Exists() {
item.A1Local = types.BoolValue(true)
} else {
item.A1Local = types.BoolValue(false)
}
- if cValue := v.Get("a1.group"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "a1/group"); cValue.Exists() {
item.A1Group = types.StringValue(cValue.String())
}
- if cValue := v.Get("a1.radius"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "a1/radius"); cValue.Exists() {
item.A1Radius = types.BoolValue(true)
} else {
item.A1Radius = types.BoolValue(false)
}
- if cValue := v.Get("a1.tacacs"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "a1/tacacs"); cValue.Exists() {
item.A1Tacacs = types.BoolValue(true)
} else {
item.A1Tacacs = types.BoolValue(false)
}
- if cValue := v.Get("a1.if-authenticated"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "a1/if-authenticated"); cValue.Exists() {
item.A1IfAuthenticated = types.BoolValue(true)
} else {
item.A1IfAuthenticated = types.BoolValue(false)
}
- if cValue := v.Get("a2.local"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "a2/local"); cValue.Exists() {
item.A2Local = types.BoolValue(true)
} else {
item.A2Local = types.BoolValue(false)
}
- if cValue := v.Get("a2.group"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "a2/group"); cValue.Exists() {
item.A2Group = types.StringValue(cValue.String())
}
- if cValue := v.Get("a2.radius"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "a2/radius"); cValue.Exists() {
item.A2Radius = types.BoolValue(true)
} else {
item.A2Radius = types.BoolValue(false)
}
- if cValue := v.Get("a2.tacacs"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "a2/tacacs"); cValue.Exists() {
item.A2Tacacs = types.BoolValue(true)
} else {
item.A2Tacacs = types.BoolValue(false)
}
- if cValue := v.Get("a2.if-authenticated"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "a2/if-authenticated"); cValue.Exists() {
item.A2IfAuthenticated = types.BoolValue(true)
} else {
item.A2IfAuthenticated = types.BoolValue(false)
}
- if cValue := v.Get("a3.local"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "a3/local"); cValue.Exists() {
item.A3Local = types.BoolValue(true)
} else {
item.A3Local = types.BoolValue(false)
}
- if cValue := v.Get("a3.group"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "a3/group"); cValue.Exists() {
item.A3Group = types.StringValue(cValue.String())
}
- if cValue := v.Get("a3.radius"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "a3/radius"); cValue.Exists() {
item.A3Radius = types.BoolValue(true)
} else {
item.A3Radius = types.BoolValue(false)
}
- if cValue := v.Get("a3.tacacs"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "a3/tacacs"); cValue.Exists() {
item.A3Tacacs = types.BoolValue(true)
} else {
item.A3Tacacs = types.BoolValue(false)
}
- if cValue := v.Get("a3.if-authenticated"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "a3/if-authenticated"); cValue.Exists() {
item.A3IfAuthenticated = types.BoolValue(true)
} else {
item.A3IfAuthenticated = types.BoolValue(false)
}
- if cValue := v.Get("a4.local"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "a4/local"); cValue.Exists() {
item.A4Local = types.BoolValue(true)
} else {
item.A4Local = types.BoolValue(false)
}
- if cValue := v.Get("a4.group"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "a4/group"); cValue.Exists() {
item.A4Group = types.StringValue(cValue.String())
}
- if cValue := v.Get("a4.radius"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "a4/radius"); cValue.Exists() {
item.A4Radius = types.BoolValue(true)
} else {
item.A4Radius = types.BoolValue(false)
}
- if cValue := v.Get("a4.tacacs"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "a4/tacacs"); cValue.Exists() {
item.A4Tacacs = types.BoolValue(true)
} else {
item.A4Tacacs = types.BoolValue(false)
}
- if cValue := v.Get("a4.if-authenticated"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "a4/if-authenticated"); cValue.Exists() {
item.A4IfAuthenticated = types.BoolValue(true)
} else {
item.A4IfAuthenticated = types.BoolValue(false)
@@ -1467,167 +3083,167 @@ func (data *AAAAuthorizationData) fromBody(ctx context.Context, res gjson.Result
return true
})
}
- if value := res.Get(prefix + "network"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/network"); value.Exists() {
data.Networks = make([]AAAAuthorizationNetworks, 0)
- value.ForEach(func(k, v gjson.Result) bool {
+ value.ForEach(func(_ int, v xmldot.Result) bool {
item := AAAAuthorizationNetworks{}
- if cValue := v.Get("id"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "id"); cValue.Exists() {
item.Id = types.StringValue(cValue.String())
}
- if cValue := v.Get("a1.local"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "a1/local"); cValue.Exists() {
item.A1Local = types.BoolValue(true)
} else {
item.A1Local = types.BoolValue(false)
}
- if cValue := v.Get("a1.group"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "a1/group"); cValue.Exists() {
item.A1Group = types.StringValue(cValue.String())
}
- if cValue := v.Get("a2.local"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "a2/local"); cValue.Exists() {
item.A2Local = types.BoolValue(true)
} else {
item.A2Local = types.BoolValue(false)
}
- if cValue := v.Get("a2.group"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "a2/group"); cValue.Exists() {
item.A2Group = types.StringValue(cValue.String())
}
- if cValue := v.Get("a3.local"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "a3/local"); cValue.Exists() {
item.A3Local = types.BoolValue(true)
} else {
item.A3Local = types.BoolValue(false)
}
- if cValue := v.Get("a3.group"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "a3/group"); cValue.Exists() {
item.A3Group = types.StringValue(cValue.String())
}
- if cValue := v.Get("a4.local"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "a4/local"); cValue.Exists() {
item.A4Local = types.BoolValue(true)
} else {
item.A4Local = types.BoolValue(false)
}
- if cValue := v.Get("a4.group"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "a4/group"); cValue.Exists() {
item.A4Group = types.StringValue(cValue.String())
}
data.Networks = append(data.Networks, item)
return true
})
}
- if value := res.Get(prefix + "commands"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/commands"); value.Exists() {
data.Commands = make([]AAAAuthorizationCommands, 0)
- value.ForEach(func(k, v gjson.Result) bool {
+ value.ForEach(func(_ int, v xmldot.Result) bool {
item := AAAAuthorizationCommands{}
- if cValue := v.Get("level"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "level"); cValue.Exists() {
item.Level = types.Int64Value(cValue.Int())
}
- if cValue := v.Get("list-name"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "list-name"); cValue.Exists() {
item.ListName = types.StringValue(cValue.String())
}
- if cValue := v.Get("a1.group"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "a1/group"); cValue.Exists() {
item.A1Group = types.StringValue(cValue.String())
}
- if cValue := v.Get("a1.local"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "a1/local"); cValue.Exists() {
item.A1Local = types.BoolValue(true)
} else {
item.A1Local = types.BoolValue(false)
}
- if cValue := v.Get("a1.if-authenticated"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "a1/if-authenticated"); cValue.Exists() {
item.A1IfAuthenticated = types.BoolValue(true)
} else {
item.A1IfAuthenticated = types.BoolValue(false)
}
- if cValue := v.Get("a1.none"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "a1/none"); cValue.Exists() {
item.A1None = types.BoolValue(true)
} else {
item.A1None = types.BoolValue(false)
}
- if cValue := v.Get("a1.radius"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "a1/radius"); cValue.Exists() {
item.A1Radius = types.BoolValue(true)
} else {
item.A1Radius = types.BoolValue(false)
}
- if cValue := v.Get("a1.tacacs"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "a1/tacacs"); cValue.Exists() {
item.A1Tacacs = types.BoolValue(true)
} else {
item.A1Tacacs = types.BoolValue(false)
}
- if cValue := v.Get("a2.group"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "a2/group"); cValue.Exists() {
item.A2Group = types.StringValue(cValue.String())
}
- if cValue := v.Get("a2.local"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "a2/local"); cValue.Exists() {
item.A2Local = types.BoolValue(true)
} else {
item.A2Local = types.BoolValue(false)
}
- if cValue := v.Get("a2.if-authenticated"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "a2/if-authenticated"); cValue.Exists() {
item.A2IfAuthenticated = types.BoolValue(true)
} else {
item.A2IfAuthenticated = types.BoolValue(false)
}
- if cValue := v.Get("a2.none"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "a2/none"); cValue.Exists() {
item.A2None = types.BoolValue(true)
} else {
item.A2None = types.BoolValue(false)
}
- if cValue := v.Get("a2.radius"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "a2/radius"); cValue.Exists() {
item.A2Radius = types.BoolValue(true)
} else {
item.A2Radius = types.BoolValue(false)
}
- if cValue := v.Get("a2.tacacs"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "a2/tacacs"); cValue.Exists() {
item.A2Tacacs = types.BoolValue(true)
} else {
item.A2Tacacs = types.BoolValue(false)
}
- if cValue := v.Get("a3.group"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "a3/group"); cValue.Exists() {
item.A3Group = types.StringValue(cValue.String())
}
- if cValue := v.Get("a3.local"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "a3/local"); cValue.Exists() {
item.A3Local = types.BoolValue(true)
} else {
item.A3Local = types.BoolValue(false)
}
- if cValue := v.Get("a3.if-authenticated"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "a3/if-authenticated"); cValue.Exists() {
item.A3IfAuthenticated = types.BoolValue(true)
} else {
item.A3IfAuthenticated = types.BoolValue(false)
}
- if cValue := v.Get("a3.none"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "a3/none"); cValue.Exists() {
item.A3None = types.BoolValue(true)
} else {
item.A3None = types.BoolValue(false)
}
- if cValue := v.Get("a3.radius"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "a3/radius"); cValue.Exists() {
item.A3Radius = types.BoolValue(true)
} else {
item.A3Radius = types.BoolValue(false)
}
- if cValue := v.Get("a3.tacacs"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "a3/tacacs"); cValue.Exists() {
item.A3Tacacs = types.BoolValue(true)
} else {
item.A3Tacacs = types.BoolValue(false)
}
- if cValue := v.Get("a4.group"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "a4/group"); cValue.Exists() {
item.A4Group = types.StringValue(cValue.String())
}
- if cValue := v.Get("a4.local"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "a4/local"); cValue.Exists() {
item.A4Local = types.BoolValue(true)
} else {
item.A4Local = types.BoolValue(false)
}
- if cValue := v.Get("a4.if-authenticated"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "a4/if-authenticated"); cValue.Exists() {
item.A4IfAuthenticated = types.BoolValue(true)
} else {
item.A4IfAuthenticated = types.BoolValue(false)
}
- if cValue := v.Get("a4.none"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "a4/none"); cValue.Exists() {
item.A4None = types.BoolValue(true)
} else {
item.A4None = types.BoolValue(false)
}
- if cValue := v.Get("a4.radius"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "a4/radius"); cValue.Exists() {
item.A4Radius = types.BoolValue(true)
} else {
item.A4Radius = types.BoolValue(false)
}
- if cValue := v.Get("a4.tacacs"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "a4/tacacs"); cValue.Exists() {
item.A4Tacacs = types.BoolValue(true)
} else {
item.A4Tacacs = types.BoolValue(false)
@@ -1636,30 +3252,30 @@ func (data *AAAAuthorizationData) fromBody(ctx context.Context, res gjson.Result
return true
})
}
- if value := res.Get(prefix + "config-commands"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/config-commands"); value.Exists() {
data.ConfigCommands = types.BoolValue(true)
} else {
data.ConfigCommands = types.BoolValue(false)
}
- if value := res.Get(prefix + "configuration.config-list"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/configuration/config-list"); value.Exists() {
data.ConfigLists = make([]AAAAuthorizationConfigLists, 0)
- value.ForEach(func(k, v gjson.Result) bool {
+ value.ForEach(func(_ int, v xmldot.Result) bool {
item := AAAAuthorizationConfigLists{}
- if cValue := v.Get("name"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "name"); cValue.Exists() {
item.Name = types.StringValue(cValue.String())
}
- if cValue := v.Get("group1.cache"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "group1/cache"); cValue.Exists() {
item.Group1Cache = types.StringValue(cValue.String())
}
- if cValue := v.Get("group1.group"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "group1/group"); cValue.Exists() {
item.Group1Group = types.StringValue(cValue.String())
}
- if cValue := v.Get("group1.radius"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "group1/radius"); cValue.Exists() {
item.Group1Radius = types.BoolValue(true)
} else {
item.Group1Radius = types.BoolValue(false)
}
- if cValue := v.Get("group1.tacacs"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "group1/tacacs"); cValue.Exists() {
item.Group1Tacacs = types.BoolValue(true)
} else {
item.Group1Tacacs = types.BoolValue(false)
@@ -1670,7 +3286,7 @@ func (data *AAAAuthorizationData) fromBody(ctx context.Context, res gjson.Result
}
}
-// End of section. //template:end fromBodyData
+// End of section. //template:end fromBodyDataXML
// Section below is generated&owned by "gen/generator.go". //template:begin getDeletedItems
@@ -1959,6 +3575,313 @@ func (data *AAAAuthorization) getDeletedItems(ctx context.Context, state AAAAuth
// End of section. //template:end getDeletedItems
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletedItemsXML
+
+func (data *AAAAuthorization) addDeletedItemsXML(ctx context.Context, state AAAAuthorization, body string) string {
+ b := netconf.NewBody(body)
+ for i := range state.Execs {
+ stateKeys := [...]string{"name"}
+ stateKeyValues := [...]string{state.Execs[i].Name.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.Execs[i].Name.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.Execs {
+ found = true
+ if state.Execs[i].Name.ValueString() != data.Execs[j].Name.ValueString() {
+ found = false
+ }
+ if found {
+ if !state.Execs[i].A1Local.IsNull() && data.Execs[j].A1Local.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/exec%v/a1/local", predicates))
+ }
+ if !state.Execs[i].A1Group.IsNull() && data.Execs[j].A1Group.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/exec%v/a1/group", predicates))
+ }
+ if !state.Execs[i].A1Radius.IsNull() && data.Execs[j].A1Radius.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/exec%v/a1/radius", predicates))
+ }
+ if !state.Execs[i].A1Tacacs.IsNull() && data.Execs[j].A1Tacacs.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/exec%v/a1/tacacs", predicates))
+ }
+ if !state.Execs[i].A1IfAuthenticated.IsNull() && data.Execs[j].A1IfAuthenticated.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/exec%v/a1/if-authenticated", predicates))
+ }
+ if !state.Execs[i].A2Local.IsNull() && data.Execs[j].A2Local.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/exec%v/a2/local", predicates))
+ }
+ if !state.Execs[i].A2Group.IsNull() && data.Execs[j].A2Group.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/exec%v/a2/group", predicates))
+ }
+ if !state.Execs[i].A2Radius.IsNull() && data.Execs[j].A2Radius.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/exec%v/a2/radius", predicates))
+ }
+ if !state.Execs[i].A2Tacacs.IsNull() && data.Execs[j].A2Tacacs.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/exec%v/a2/tacacs", predicates))
+ }
+ if !state.Execs[i].A2IfAuthenticated.IsNull() && data.Execs[j].A2IfAuthenticated.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/exec%v/a2/if-authenticated", predicates))
+ }
+ if !state.Execs[i].A3Local.IsNull() && data.Execs[j].A3Local.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/exec%v/a3/local", predicates))
+ }
+ if !state.Execs[i].A3Group.IsNull() && data.Execs[j].A3Group.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/exec%v/a3/group", predicates))
+ }
+ if !state.Execs[i].A3Radius.IsNull() && data.Execs[j].A3Radius.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/exec%v/a3/radius", predicates))
+ }
+ if !state.Execs[i].A3Tacacs.IsNull() && data.Execs[j].A3Tacacs.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/exec%v/a3/tacacs", predicates))
+ }
+ if !state.Execs[i].A3IfAuthenticated.IsNull() && data.Execs[j].A3IfAuthenticated.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/exec%v/a3/if-authenticated", predicates))
+ }
+ if !state.Execs[i].A4Local.IsNull() && data.Execs[j].A4Local.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/exec%v/a4/local", predicates))
+ }
+ if !state.Execs[i].A4Group.IsNull() && data.Execs[j].A4Group.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/exec%v/a4/group", predicates))
+ }
+ if !state.Execs[i].A4Radius.IsNull() && data.Execs[j].A4Radius.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/exec%v/a4/radius", predicates))
+ }
+ if !state.Execs[i].A4Tacacs.IsNull() && data.Execs[j].A4Tacacs.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/exec%v/a4/tacacs", predicates))
+ }
+ if !state.Execs[i].A4IfAuthenticated.IsNull() && data.Execs[j].A4IfAuthenticated.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/exec%v/a4/if-authenticated", predicates))
+ }
+ break
+ }
+ }
+ if !found {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/exec%v", predicates))
+ }
+ }
+ for i := range state.Networks {
+ stateKeys := [...]string{"id"}
+ stateKeyValues := [...]string{state.Networks[i].Id.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.Networks[i].Id.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.Networks {
+ found = true
+ if state.Networks[i].Id.ValueString() != data.Networks[j].Id.ValueString() {
+ found = false
+ }
+ if found {
+ if !state.Networks[i].A1Local.IsNull() && data.Networks[j].A1Local.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/network%v/a1/local", predicates))
+ }
+ if !state.Networks[i].A1Group.IsNull() && data.Networks[j].A1Group.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/network%v/a1/group", predicates))
+ }
+ if !state.Networks[i].A2Local.IsNull() && data.Networks[j].A2Local.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/network%v/a2/local", predicates))
+ }
+ if !state.Networks[i].A2Group.IsNull() && data.Networks[j].A2Group.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/network%v/a2/group", predicates))
+ }
+ if !state.Networks[i].A3Local.IsNull() && data.Networks[j].A3Local.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/network%v/a3/local", predicates))
+ }
+ if !state.Networks[i].A3Group.IsNull() && data.Networks[j].A3Group.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/network%v/a3/group", predicates))
+ }
+ if !state.Networks[i].A4Local.IsNull() && data.Networks[j].A4Local.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/network%v/a4/local", predicates))
+ }
+ if !state.Networks[i].A4Group.IsNull() && data.Networks[j].A4Group.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/network%v/a4/group", predicates))
+ }
+ break
+ }
+ }
+ if !found {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/network%v", predicates))
+ }
+ }
+ for i := range state.Commands {
+ stateKeys := [...]string{"level", "list-name"}
+ stateKeyValues := [...]string{strconv.FormatInt(state.Commands[i].Level.ValueInt64(), 10), state.Commands[i].ListName.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.Commands[i].Level.ValueInt64()).IsZero() {
+ emptyKeys = false
+ }
+ if !reflect.ValueOf(state.Commands[i].ListName.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.Commands {
+ found = true
+ if state.Commands[i].Level.ValueInt64() != data.Commands[j].Level.ValueInt64() {
+ found = false
+ }
+ if state.Commands[i].ListName.ValueString() != data.Commands[j].ListName.ValueString() {
+ found = false
+ }
+ if found {
+ if !state.Commands[i].A1Group.IsNull() && data.Commands[j].A1Group.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/commands%v/a1/group", predicates))
+ }
+ if !state.Commands[i].A1Local.IsNull() && data.Commands[j].A1Local.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/commands%v/a1/local", predicates))
+ }
+ if !state.Commands[i].A1IfAuthenticated.IsNull() && data.Commands[j].A1IfAuthenticated.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/commands%v/a1/if-authenticated", predicates))
+ }
+ if !state.Commands[i].A1None.IsNull() && data.Commands[j].A1None.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/commands%v/a1/none", predicates))
+ }
+ if !state.Commands[i].A1Radius.IsNull() && data.Commands[j].A1Radius.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/commands%v/a1/radius", predicates))
+ }
+ if !state.Commands[i].A1Tacacs.IsNull() && data.Commands[j].A1Tacacs.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/commands%v/a1/tacacs", predicates))
+ }
+ if !state.Commands[i].A2Group.IsNull() && data.Commands[j].A2Group.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/commands%v/a2/group", predicates))
+ }
+ if !state.Commands[i].A2Local.IsNull() && data.Commands[j].A2Local.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/commands%v/a2/local", predicates))
+ }
+ if !state.Commands[i].A2IfAuthenticated.IsNull() && data.Commands[j].A2IfAuthenticated.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/commands%v/a2/if-authenticated", predicates))
+ }
+ if !state.Commands[i].A2None.IsNull() && data.Commands[j].A2None.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/commands%v/a2/none", predicates))
+ }
+ if !state.Commands[i].A2Radius.IsNull() && data.Commands[j].A2Radius.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/commands%v/a2/radius", predicates))
+ }
+ if !state.Commands[i].A2Tacacs.IsNull() && data.Commands[j].A2Tacacs.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/commands%v/a2/tacacs", predicates))
+ }
+ if !state.Commands[i].A3Group.IsNull() && data.Commands[j].A3Group.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/commands%v/a3/group", predicates))
+ }
+ if !state.Commands[i].A3Local.IsNull() && data.Commands[j].A3Local.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/commands%v/a3/local", predicates))
+ }
+ if !state.Commands[i].A3IfAuthenticated.IsNull() && data.Commands[j].A3IfAuthenticated.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/commands%v/a3/if-authenticated", predicates))
+ }
+ if !state.Commands[i].A3None.IsNull() && data.Commands[j].A3None.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/commands%v/a3/none", predicates))
+ }
+ if !state.Commands[i].A3Radius.IsNull() && data.Commands[j].A3Radius.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/commands%v/a3/radius", predicates))
+ }
+ if !state.Commands[i].A3Tacacs.IsNull() && data.Commands[j].A3Tacacs.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/commands%v/a3/tacacs", predicates))
+ }
+ if !state.Commands[i].A4Group.IsNull() && data.Commands[j].A4Group.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/commands%v/a4/group", predicates))
+ }
+ if !state.Commands[i].A4Local.IsNull() && data.Commands[j].A4Local.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/commands%v/a4/local", predicates))
+ }
+ if !state.Commands[i].A4IfAuthenticated.IsNull() && data.Commands[j].A4IfAuthenticated.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/commands%v/a4/if-authenticated", predicates))
+ }
+ if !state.Commands[i].A4None.IsNull() && data.Commands[j].A4None.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/commands%v/a4/none", predicates))
+ }
+ if !state.Commands[i].A4Radius.IsNull() && data.Commands[j].A4Radius.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/commands%v/a4/radius", predicates))
+ }
+ if !state.Commands[i].A4Tacacs.IsNull() && data.Commands[j].A4Tacacs.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/commands%v/a4/tacacs", predicates))
+ }
+ break
+ }
+ }
+ if !found {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/commands%v", predicates))
+ }
+ }
+ if !state.ConfigCommands.IsNull() && data.ConfigCommands.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/config-commands")
+ }
+ for i := range state.ConfigLists {
+ stateKeys := [...]string{"name"}
+ stateKeyValues := [...]string{state.ConfigLists[i].Name.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.ConfigLists[i].Name.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.ConfigLists {
+ found = true
+ if state.ConfigLists[i].Name.ValueString() != data.ConfigLists[j].Name.ValueString() {
+ found = false
+ }
+ if found {
+ if !state.ConfigLists[i].Group1Cache.IsNull() && data.ConfigLists[j].Group1Cache.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/configuration/config-list%v/group1/cache", predicates))
+ }
+ if !state.ConfigLists[i].Group1Group.IsNull() && data.ConfigLists[j].Group1Group.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/configuration/config-list%v/group1/group", predicates))
+ }
+ if !state.ConfigLists[i].Group1Radius.IsNull() && data.ConfigLists[j].Group1Radius.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/configuration/config-list%v/group1/radius", predicates))
+ }
+ if !state.ConfigLists[i].Group1Tacacs.IsNull() && data.ConfigLists[j].Group1Tacacs.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/configuration/config-list%v/group1/tacacs", predicates))
+ }
+ break
+ }
+ }
+ if !found {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/configuration/config-list%v", predicates))
+ }
+ }
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletedItemsXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin getEmptyLeafsDelete
func (data *AAAAuthorization) getEmptyLeafsDelete(ctx context.Context) []string {
@@ -2146,3 +4069,56 @@ func (data *AAAAuthorization) getDeletePaths(ctx context.Context) []string {
}
// End of section. //template:end getDeletePaths
+
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletePathsXML
+
+func (data *AAAAuthorization) addDeletePathsXML(ctx context.Context, body string) string {
+ b := netconf.NewBody(body)
+ for i := range data.Execs {
+ keys := [...]string{"name"}
+ keyValues := [...]string{data.Execs[i].Name.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/exec%v", predicates))
+ }
+ for i := range data.Networks {
+ keys := [...]string{"id"}
+ keyValues := [...]string{data.Networks[i].Id.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/network%v", predicates))
+ }
+ for i := range data.Commands {
+ keys := [...]string{"level", "list-name"}
+ keyValues := [...]string{strconv.FormatInt(data.Commands[i].Level.ValueInt64(), 10), data.Commands[i].ListName.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/commands%v", predicates))
+ }
+ if !data.ConfigCommands.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/config-commands")
+ }
+ for i := range data.ConfigLists {
+ keys := [...]string{"name"}
+ keyValues := [...]string{data.ConfigLists[i].Name.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/configuration/config-list%v", predicates))
+ }
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletePathsXML
diff --git a/internal/provider/model_iosxe_access_list_extended.go b/internal/provider/model_iosxe_access_list_extended.go
index d73eb492..67704418 100644
--- a/internal/provider/model_iosxe_access_list_extended.go
+++ b/internal/provider/model_iosxe_access_list_extended.go
@@ -31,6 +31,9 @@ import (
"github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/types"
+ "github.com/hashicorp/terraform-plugin-log/tflog"
+ "github.com/netascode/go-netconf"
+ "github.com/netascode/xmldot"
"github.com/tidwall/gjson"
"github.com/tidwall/sjson"
)
@@ -127,6 +130,19 @@ func (data AccessListExtended) getPathShort() string {
return matches[1]
}
+// getXPath returns the XPath for NETCONF operations
+func (data AccessListExtended) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/ip/access-list/Cisco-IOS-XE-acl:extended[name=%v]"
+ path = fmt.Sprintf(path, fmt.Sprintf("%v", data.Name.ValueString()))
+ return path
+}
+
+func (data AccessListExtendedData) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/ip/access-list/Cisco-IOS-XE-acl:extended[name=%v]"
+ path = fmt.Sprintf(path, fmt.Sprintf("%v", data.Name.ValueString()))
+ return path
+}
+
// End of section. //template:end getPath
// Section below is generated&owned by "gen/generator.go". //template:begin toBody
@@ -320,6 +336,226 @@ func (data AccessListExtended) toBody(ctx context.Context) string {
// End of section. //template:end toBody
+// Section below is generated&owned by "gen/generator.go". //template:begin toBodyXML
+
+func (data AccessListExtended) toBodyXML(ctx context.Context) string {
+ body := netconf.Body{}
+ if !data.Name.IsNull() && !data.Name.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/name", data.Name.ValueString())
+ }
+ if len(data.Entries) > 0 {
+ for _, item := range data.Entries {
+ cBody := netconf.Body{}
+ if !item.Sequence.IsNull() && !item.Sequence.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "sequence", strconv.FormatInt(item.Sequence.ValueInt64(), 10))
+ }
+ if !item.Remark.IsNull() && !item.Remark.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "remark", item.Remark.ValueString())
+ }
+ if !item.AceRuleAction.IsNull() && !item.AceRuleAction.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "ace-rule/action", item.AceRuleAction.ValueString())
+ }
+ if !item.AceRuleProtocol.IsNull() && !item.AceRuleProtocol.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "ace-rule/protocol", item.AceRuleProtocol.ValueString())
+ }
+ if !item.ServiceObjectGroup.IsNull() && !item.ServiceObjectGroup.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "ace-rule/object-group-str", item.ServiceObjectGroup.ValueString())
+ }
+ if !item.SourcePrefix.IsNull() && !item.SourcePrefix.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "ace-rule/ipv4-address", item.SourcePrefix.ValueString())
+ }
+ if !item.SourcePrefixMask.IsNull() && !item.SourcePrefixMask.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "ace-rule/mask", item.SourcePrefixMask.ValueString())
+ }
+ if !item.SourceAny.IsNull() && !item.SourceAny.IsUnknown() {
+ if item.SourceAny.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "ace-rule/any", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "ace-rule/any")
+ }
+ }
+ if !item.SourceHost.IsNull() && !item.SourceHost.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "ace-rule/host-address", item.SourceHost.ValueString())
+ }
+ if !item.SourceObjectGroup.IsNull() && !item.SourceObjectGroup.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "ace-rule/object-group", item.SourceObjectGroup.ValueString())
+ }
+ if !item.SourcePortEqual.IsNull() && !item.SourcePortEqual.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "ace-rule/src-eq", item.SourcePortEqual.ValueString())
+ }
+ if !item.SourcePortGreaterThan.IsNull() && !item.SourcePortGreaterThan.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "ace-rule/src-gt", item.SourcePortGreaterThan.ValueString())
+ }
+ if !item.SourcePortLesserThan.IsNull() && !item.SourcePortLesserThan.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "ace-rule/src-lt", item.SourcePortLesserThan.ValueString())
+ }
+ if !item.SourcePortRangeFrom.IsNull() && !item.SourcePortRangeFrom.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "ace-rule/src-range1", item.SourcePortRangeFrom.ValueString())
+ }
+ if !item.SourcePortRangeTo.IsNull() && !item.SourcePortRangeTo.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "ace-rule/src-range2", item.SourcePortRangeTo.ValueString())
+ }
+ if !item.DestinationPrefix.IsNull() && !item.DestinationPrefix.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "ace-rule/dest-ipv4-address", item.DestinationPrefix.ValueString())
+ }
+ if !item.DestinationPrefixMask.IsNull() && !item.DestinationPrefixMask.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "ace-rule/dest-mask", item.DestinationPrefixMask.ValueString())
+ }
+ if !item.DestinationAny.IsNull() && !item.DestinationAny.IsUnknown() {
+ if item.DestinationAny.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "ace-rule/dst-any", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "ace-rule/dst-any")
+ }
+ }
+ if !item.DestinationHost.IsNull() && !item.DestinationHost.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "ace-rule/dst-host-address", item.DestinationHost.ValueString())
+ }
+ if !item.DestinationObjectGroup.IsNull() && !item.DestinationObjectGroup.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "ace-rule/dst-object-group", item.DestinationObjectGroup.ValueString())
+ }
+ if !item.DestinationPortEqual.IsNull() && !item.DestinationPortEqual.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "ace-rule/dst-eq", item.DestinationPortEqual.ValueString())
+ }
+ if !item.DestinationPortGreaterThan.IsNull() && !item.DestinationPortGreaterThan.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "ace-rule/dst-gt", item.DestinationPortGreaterThan.ValueString())
+ }
+ if !item.DestinationPortLesserThan.IsNull() && !item.DestinationPortLesserThan.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "ace-rule/dst-lt", item.DestinationPortLesserThan.ValueString())
+ }
+ if !item.DestinationPortRangeFrom.IsNull() && !item.DestinationPortRangeFrom.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "ace-rule/dst-range1", item.DestinationPortRangeFrom.ValueString())
+ }
+ if !item.DestinationPortRangeTo.IsNull() && !item.DestinationPortRangeTo.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "ace-rule/dst-range2", item.DestinationPortRangeTo.ValueString())
+ }
+ if !item.Ack.IsNull() && !item.Ack.IsUnknown() {
+ if item.Ack.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "ace-rule/ack", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "ace-rule/ack")
+ }
+ }
+ if !item.Fin.IsNull() && !item.Fin.IsUnknown() {
+ if item.Fin.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "ace-rule/fin", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "ace-rule/fin")
+ }
+ }
+ if !item.Psh.IsNull() && !item.Psh.IsUnknown() {
+ if item.Psh.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "ace-rule/psh", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "ace-rule/psh")
+ }
+ }
+ if !item.Rst.IsNull() && !item.Rst.IsUnknown() {
+ if item.Rst.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "ace-rule/rst", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "ace-rule/rst")
+ }
+ }
+ if !item.Syn.IsNull() && !item.Syn.IsUnknown() {
+ if item.Syn.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "ace-rule/syn", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "ace-rule/syn")
+ }
+ }
+ if !item.Urg.IsNull() && !item.Urg.IsUnknown() {
+ if item.Urg.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "ace-rule/urg", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "ace-rule/urg")
+ }
+ }
+ if !item.Established.IsNull() && !item.Established.IsUnknown() {
+ if item.Established.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "ace-rule/established", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "ace-rule/established")
+ }
+ }
+ if !item.Dscp.IsNull() && !item.Dscp.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "ace-rule/dscp", item.Dscp.ValueString())
+ }
+ if !item.Fragments.IsNull() && !item.Fragments.IsUnknown() {
+ if item.Fragments.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "ace-rule/fragments", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "ace-rule/fragments")
+ }
+ }
+ if !item.Precedence.IsNull() && !item.Precedence.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "ace-rule/precedence", item.Precedence.ValueString())
+ }
+ if !item.Tos.IsNull() && !item.Tos.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "ace-rule/tos", item.Tos.ValueString())
+ }
+ if !item.Log.IsNull() && !item.Log.IsUnknown() {
+ if item.Log.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "ace-rule/log", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "ace-rule/log")
+ }
+ }
+ if !item.LogInput.IsNull() && !item.LogInput.IsUnknown() {
+ if item.LogInput.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "ace-rule/log-input", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "ace-rule/log-input")
+ }
+ }
+ if !item.IcmpNamedMsgType.IsNull() && !item.IcmpNamedMsgType.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "ace-rule/named-msg-type", item.IcmpNamedMsgType.ValueString())
+ }
+ if !item.DestinationPortEqual2.IsNull() && !item.DestinationPortEqual2.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "ace-rule/dst-eq-port2", item.DestinationPortEqual2.ValueString())
+ }
+ if !item.DestinationPortEqual3.IsNull() && !item.DestinationPortEqual3.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "ace-rule/dst-eq-port3", item.DestinationPortEqual3.ValueString())
+ }
+ if !item.DestinationPortEqual4.IsNull() && !item.DestinationPortEqual4.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "ace-rule/dst-eq-port4", item.DestinationPortEqual4.ValueString())
+ }
+ if !item.DestinationPortEqual5.IsNull() && !item.DestinationPortEqual5.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "ace-rule/dst-eq-port5", item.DestinationPortEqual5.ValueString())
+ }
+ if !item.DestinationPortEqual6.IsNull() && !item.DestinationPortEqual6.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "ace-rule/dst-eq-port6", item.DestinationPortEqual6.ValueString())
+ }
+ if !item.DestinationPortEqual7.IsNull() && !item.DestinationPortEqual7.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "ace-rule/dst-eq-port7", item.DestinationPortEqual7.ValueString())
+ }
+ if !item.DestinationPortEqual8.IsNull() && !item.DestinationPortEqual8.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "ace-rule/dst-eq-port8", item.DestinationPortEqual8.ValueString())
+ }
+ if !item.DestinationPortEqual9.IsNull() && !item.DestinationPortEqual9.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "ace-rule/dst-eq-port9", item.DestinationPortEqual9.ValueString())
+ }
+ if !item.DestinationPortEqual10.IsNull() && !item.DestinationPortEqual10.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "ace-rule/dst-eq-port10", item.DestinationPortEqual10.ValueString())
+ }
+ if !item.IcmpMsgType.IsNull() && !item.IcmpMsgType.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "ace-rule/msg-type", strconv.FormatInt(item.IcmpMsgType.ValueInt64(), 10))
+ }
+ if !item.IcmpMsgCode.IsNull() && !item.IcmpMsgCode.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "ace-rule/msg-code", strconv.FormatInt(item.IcmpMsgCode.ValueInt64(), 10))
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/access-list-seq-rule", cBody.Res())
+ }
+ }
+ bodyString, err := body.String()
+ if err != nil {
+ tflog.Error(ctx, fmt.Sprintf("Error converting body to string: %s", err))
+ }
+ return bodyString
+}
+
+// End of section. //template:end toBodyXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBody
func (data *AccessListExtended) updateFromBody(ctx context.Context, res gjson.Result) {
@@ -658,189 +894,905 @@ func (data *AccessListExtended) updateFromBody(ctx context.Context, res gjson.Re
// End of section. //template:end updateFromBody
-// Section below is generated&owned by "gen/generator.go". //template:begin fromBody
+// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBodyXML
-func (data *AccessListExtended) fromBody(ctx context.Context, res gjson.Result) {
- prefix := helpers.LastElement(data.getPath()) + "."
- if res.Get(helpers.LastElement(data.getPath())).IsArray() {
- prefix += "0."
+func (data *AccessListExtended) updateFromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/name"); value.Exists() && !data.Name.IsNull() {
+ data.Name = types.StringValue(value.String())
+ } else {
+ data.Name = types.StringNull()
}
- if value := res.Get(prefix + "access-list-seq-rule"); value.Exists() {
- data.Entries = make([]AccessListExtendedEntries, 0)
- value.ForEach(func(k, v gjson.Result) bool {
- item := AccessListExtendedEntries{}
- if cValue := v.Get("sequence"); cValue.Exists() {
- item.Sequence = types.Int64Value(cValue.Int())
- }
- if cValue := v.Get("remark"); cValue.Exists() {
- item.Remark = types.StringValue(cValue.String())
- }
- if cValue := v.Get("ace-rule.action"); cValue.Exists() {
- item.AceRuleAction = types.StringValue(cValue.String())
- }
- if cValue := v.Get("ace-rule.protocol"); cValue.Exists() {
- item.AceRuleProtocol = types.StringValue(cValue.String())
- }
- if cValue := v.Get("ace-rule.object-group-str"); cValue.Exists() {
- item.ServiceObjectGroup = types.StringValue(cValue.String())
- }
- if cValue := v.Get("ace-rule.ipv4-address"); cValue.Exists() {
- item.SourcePrefix = types.StringValue(cValue.String())
- }
- if cValue := v.Get("ace-rule.mask"); cValue.Exists() {
- item.SourcePrefixMask = types.StringValue(cValue.String())
- }
- if cValue := v.Get("ace-rule.any"); cValue.Exists() {
- item.SourceAny = types.BoolValue(true)
+ for i := range data.Entries {
+ keys := [...]string{"sequence"}
+ keyValues := [...]string{strconv.FormatInt(data.Entries[i].Sequence.ValueInt64(), 10)}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/access-list-seq-rule").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, "sequence"); value.Exists() && !data.Entries[i].Sequence.IsNull() {
+ data.Entries[i].Sequence = types.Int64Value(value.Int())
+ } else {
+ data.Entries[i].Sequence = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(r, "remark"); value.Exists() && !data.Entries[i].Remark.IsNull() {
+ data.Entries[i].Remark = types.StringValue(value.String())
+ } else {
+ data.Entries[i].Remark = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "ace-rule/action"); value.Exists() && !data.Entries[i].AceRuleAction.IsNull() {
+ data.Entries[i].AceRuleAction = types.StringValue(value.String())
+ } else {
+ data.Entries[i].AceRuleAction = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "ace-rule/protocol"); value.Exists() && !data.Entries[i].AceRuleProtocol.IsNull() {
+ data.Entries[i].AceRuleProtocol = types.StringValue(value.String())
+ } else {
+ data.Entries[i].AceRuleProtocol = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "ace-rule/object-group-str"); value.Exists() && !data.Entries[i].ServiceObjectGroup.IsNull() {
+ data.Entries[i].ServiceObjectGroup = types.StringValue(value.String())
+ } else {
+ data.Entries[i].ServiceObjectGroup = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "ace-rule/ipv4-address"); value.Exists() && !data.Entries[i].SourcePrefix.IsNull() {
+ data.Entries[i].SourcePrefix = types.StringValue(value.String())
+ } else {
+ data.Entries[i].SourcePrefix = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "ace-rule/mask"); value.Exists() && !data.Entries[i].SourcePrefixMask.IsNull() {
+ data.Entries[i].SourcePrefixMask = types.StringValue(value.String())
+ } else {
+ data.Entries[i].SourcePrefixMask = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "ace-rule/any"); !data.Entries[i].SourceAny.IsNull() {
+ if value.Exists() {
+ data.Entries[i].SourceAny = types.BoolValue(true)
} else {
- item.SourceAny = types.BoolValue(false)
- }
- if cValue := v.Get("ace-rule.host-address"); cValue.Exists() {
- item.SourceHost = types.StringValue(cValue.String())
- }
- if cValue := v.Get("ace-rule.object-group"); cValue.Exists() {
- item.SourceObjectGroup = types.StringValue(cValue.String())
- }
- if cValue := v.Get("ace-rule.src-eq"); cValue.Exists() {
- item.SourcePortEqual = types.StringValue(cValue.String())
- }
- if cValue := v.Get("ace-rule.src-gt"); cValue.Exists() {
- item.SourcePortGreaterThan = types.StringValue(cValue.String())
- }
- if cValue := v.Get("ace-rule.src-lt"); cValue.Exists() {
- item.SourcePortLesserThan = types.StringValue(cValue.String())
- }
- if cValue := v.Get("ace-rule.src-range1"); cValue.Exists() {
- item.SourcePortRangeFrom = types.StringValue(cValue.String())
- }
- if cValue := v.Get("ace-rule.src-range2"); cValue.Exists() {
- item.SourcePortRangeTo = types.StringValue(cValue.String())
- }
- if cValue := v.Get("ace-rule.dest-ipv4-address"); cValue.Exists() {
- item.DestinationPrefix = types.StringValue(cValue.String())
- }
- if cValue := v.Get("ace-rule.dest-mask"); cValue.Exists() {
- item.DestinationPrefixMask = types.StringValue(cValue.String())
+ data.Entries[i].SourceAny = types.BoolValue(false)
}
- if cValue := v.Get("ace-rule.dst-any"); cValue.Exists() {
- item.DestinationAny = types.BoolValue(true)
- } else {
- item.DestinationAny = types.BoolValue(false)
+ } else {
+ data.Entries[i].SourceAny = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "ace-rule/host-address"); value.Exists() && !data.Entries[i].SourceHost.IsNull() {
+ data.Entries[i].SourceHost = types.StringValue(value.String())
+ } else {
+ data.Entries[i].SourceHost = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "ace-rule/object-group"); value.Exists() && !data.Entries[i].SourceObjectGroup.IsNull() {
+ data.Entries[i].SourceObjectGroup = types.StringValue(value.String())
+ } else {
+ data.Entries[i].SourceObjectGroup = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "ace-rule/src-eq"); value.Exists() && !data.Entries[i].SourcePortEqual.IsNull() {
+ data.Entries[i].SourcePortEqual = types.StringValue(value.String())
+ } else {
+ data.Entries[i].SourcePortEqual = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "ace-rule/src-gt"); value.Exists() && !data.Entries[i].SourcePortGreaterThan.IsNull() {
+ data.Entries[i].SourcePortGreaterThan = types.StringValue(value.String())
+ } else {
+ data.Entries[i].SourcePortGreaterThan = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "ace-rule/src-lt"); value.Exists() && !data.Entries[i].SourcePortLesserThan.IsNull() {
+ data.Entries[i].SourcePortLesserThan = types.StringValue(value.String())
+ } else {
+ data.Entries[i].SourcePortLesserThan = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "ace-rule/src-range1"); value.Exists() && !data.Entries[i].SourcePortRangeFrom.IsNull() {
+ data.Entries[i].SourcePortRangeFrom = types.StringValue(value.String())
+ } else {
+ data.Entries[i].SourcePortRangeFrom = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "ace-rule/src-range2"); value.Exists() && !data.Entries[i].SourcePortRangeTo.IsNull() {
+ data.Entries[i].SourcePortRangeTo = types.StringValue(value.String())
+ } else {
+ data.Entries[i].SourcePortRangeTo = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "ace-rule/dest-ipv4-address"); value.Exists() && !data.Entries[i].DestinationPrefix.IsNull() {
+ data.Entries[i].DestinationPrefix = types.StringValue(value.String())
+ } else {
+ data.Entries[i].DestinationPrefix = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "ace-rule/dest-mask"); value.Exists() && !data.Entries[i].DestinationPrefixMask.IsNull() {
+ data.Entries[i].DestinationPrefixMask = types.StringValue(value.String())
+ } else {
+ data.Entries[i].DestinationPrefixMask = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "ace-rule/dst-any"); !data.Entries[i].DestinationAny.IsNull() {
+ if value.Exists() {
+ data.Entries[i].DestinationAny = types.BoolValue(true)
+ } else {
+ data.Entries[i].DestinationAny = types.BoolValue(false)
+ }
+ } else {
+ data.Entries[i].DestinationAny = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "ace-rule/dst-host-address"); value.Exists() && !data.Entries[i].DestinationHost.IsNull() {
+ data.Entries[i].DestinationHost = types.StringValue(value.String())
+ } else {
+ data.Entries[i].DestinationHost = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "ace-rule/dst-object-group"); value.Exists() && !data.Entries[i].DestinationObjectGroup.IsNull() {
+ data.Entries[i].DestinationObjectGroup = types.StringValue(value.String())
+ } else {
+ data.Entries[i].DestinationObjectGroup = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "ace-rule/dst-eq"); value.Exists() && !data.Entries[i].DestinationPortEqual.IsNull() {
+ data.Entries[i].DestinationPortEqual = types.StringValue(value.String())
+ } else {
+ data.Entries[i].DestinationPortEqual = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "ace-rule/dst-gt"); value.Exists() && !data.Entries[i].DestinationPortGreaterThan.IsNull() {
+ data.Entries[i].DestinationPortGreaterThan = types.StringValue(value.String())
+ } else {
+ data.Entries[i].DestinationPortGreaterThan = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "ace-rule/dst-lt"); value.Exists() && !data.Entries[i].DestinationPortLesserThan.IsNull() {
+ data.Entries[i].DestinationPortLesserThan = types.StringValue(value.String())
+ } else {
+ data.Entries[i].DestinationPortLesserThan = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "ace-rule/dst-range1"); value.Exists() && !data.Entries[i].DestinationPortRangeFrom.IsNull() {
+ data.Entries[i].DestinationPortRangeFrom = types.StringValue(value.String())
+ } else {
+ data.Entries[i].DestinationPortRangeFrom = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "ace-rule/dst-range2"); value.Exists() && !data.Entries[i].DestinationPortRangeTo.IsNull() {
+ data.Entries[i].DestinationPortRangeTo = types.StringValue(value.String())
+ } else {
+ data.Entries[i].DestinationPortRangeTo = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "ace-rule/ack"); !data.Entries[i].Ack.IsNull() {
+ if value.Exists() {
+ data.Entries[i].Ack = types.BoolValue(true)
+ } else {
+ data.Entries[i].Ack = types.BoolValue(false)
+ }
+ } else {
+ data.Entries[i].Ack = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "ace-rule/fin"); !data.Entries[i].Fin.IsNull() {
+ if value.Exists() {
+ data.Entries[i].Fin = types.BoolValue(true)
+ } else {
+ data.Entries[i].Fin = types.BoolValue(false)
+ }
+ } else {
+ data.Entries[i].Fin = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "ace-rule/psh"); !data.Entries[i].Psh.IsNull() {
+ if value.Exists() {
+ data.Entries[i].Psh = types.BoolValue(true)
+ } else {
+ data.Entries[i].Psh = types.BoolValue(false)
+ }
+ } else {
+ data.Entries[i].Psh = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "ace-rule/rst"); !data.Entries[i].Rst.IsNull() {
+ if value.Exists() {
+ data.Entries[i].Rst = types.BoolValue(true)
+ } else {
+ data.Entries[i].Rst = types.BoolValue(false)
+ }
+ } else {
+ data.Entries[i].Rst = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "ace-rule/syn"); !data.Entries[i].Syn.IsNull() {
+ if value.Exists() {
+ data.Entries[i].Syn = types.BoolValue(true)
+ } else {
+ data.Entries[i].Syn = types.BoolValue(false)
+ }
+ } else {
+ data.Entries[i].Syn = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "ace-rule/urg"); !data.Entries[i].Urg.IsNull() {
+ if value.Exists() {
+ data.Entries[i].Urg = types.BoolValue(true)
+ } else {
+ data.Entries[i].Urg = types.BoolValue(false)
+ }
+ } else {
+ data.Entries[i].Urg = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "ace-rule/established"); !data.Entries[i].Established.IsNull() {
+ if value.Exists() {
+ data.Entries[i].Established = types.BoolValue(true)
+ } else {
+ data.Entries[i].Established = types.BoolValue(false)
+ }
+ } else {
+ data.Entries[i].Established = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "ace-rule/dscp"); value.Exists() && !data.Entries[i].Dscp.IsNull() {
+ data.Entries[i].Dscp = types.StringValue(value.String())
+ } else {
+ data.Entries[i].Dscp = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "ace-rule/fragments"); !data.Entries[i].Fragments.IsNull() {
+ if value.Exists() {
+ data.Entries[i].Fragments = types.BoolValue(true)
+ } else {
+ data.Entries[i].Fragments = types.BoolValue(false)
+ }
+ } else {
+ data.Entries[i].Fragments = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "ace-rule/precedence"); value.Exists() && !data.Entries[i].Precedence.IsNull() {
+ data.Entries[i].Precedence = types.StringValue(value.String())
+ } else {
+ data.Entries[i].Precedence = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "ace-rule/tos"); value.Exists() && !data.Entries[i].Tos.IsNull() {
+ data.Entries[i].Tos = types.StringValue(value.String())
+ } else {
+ data.Entries[i].Tos = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "ace-rule/log"); !data.Entries[i].Log.IsNull() {
+ if value.Exists() {
+ data.Entries[i].Log = types.BoolValue(true)
+ } else {
+ data.Entries[i].Log = types.BoolValue(false)
+ }
+ } else {
+ data.Entries[i].Log = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "ace-rule/log-input"); !data.Entries[i].LogInput.IsNull() {
+ if value.Exists() {
+ data.Entries[i].LogInput = types.BoolValue(true)
+ } else {
+ data.Entries[i].LogInput = types.BoolValue(false)
+ }
+ } else {
+ data.Entries[i].LogInput = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "ace-rule/named-msg-type"); value.Exists() && !data.Entries[i].IcmpNamedMsgType.IsNull() {
+ data.Entries[i].IcmpNamedMsgType = types.StringValue(value.String())
+ } else {
+ data.Entries[i].IcmpNamedMsgType = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "ace-rule/dst-eq-port2"); value.Exists() && !data.Entries[i].DestinationPortEqual2.IsNull() {
+ data.Entries[i].DestinationPortEqual2 = types.StringValue(value.String())
+ } else {
+ data.Entries[i].DestinationPortEqual2 = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "ace-rule/dst-eq-port3"); value.Exists() && !data.Entries[i].DestinationPortEqual3.IsNull() {
+ data.Entries[i].DestinationPortEqual3 = types.StringValue(value.String())
+ } else {
+ data.Entries[i].DestinationPortEqual3 = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "ace-rule/dst-eq-port4"); value.Exists() && !data.Entries[i].DestinationPortEqual4.IsNull() {
+ data.Entries[i].DestinationPortEqual4 = types.StringValue(value.String())
+ } else {
+ data.Entries[i].DestinationPortEqual4 = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "ace-rule/dst-eq-port5"); value.Exists() && !data.Entries[i].DestinationPortEqual5.IsNull() {
+ data.Entries[i].DestinationPortEqual5 = types.StringValue(value.String())
+ } else {
+ data.Entries[i].DestinationPortEqual5 = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "ace-rule/dst-eq-port6"); value.Exists() && !data.Entries[i].DestinationPortEqual6.IsNull() {
+ data.Entries[i].DestinationPortEqual6 = types.StringValue(value.String())
+ } else {
+ data.Entries[i].DestinationPortEqual6 = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "ace-rule/dst-eq-port7"); value.Exists() && !data.Entries[i].DestinationPortEqual7.IsNull() {
+ data.Entries[i].DestinationPortEqual7 = types.StringValue(value.String())
+ } else {
+ data.Entries[i].DestinationPortEqual7 = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "ace-rule/dst-eq-port8"); value.Exists() && !data.Entries[i].DestinationPortEqual8.IsNull() {
+ data.Entries[i].DestinationPortEqual8 = types.StringValue(value.String())
+ } else {
+ data.Entries[i].DestinationPortEqual8 = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "ace-rule/dst-eq-port9"); value.Exists() && !data.Entries[i].DestinationPortEqual9.IsNull() {
+ data.Entries[i].DestinationPortEqual9 = types.StringValue(value.String())
+ } else {
+ data.Entries[i].DestinationPortEqual9 = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "ace-rule/dst-eq-port10"); value.Exists() && !data.Entries[i].DestinationPortEqual10.IsNull() {
+ data.Entries[i].DestinationPortEqual10 = types.StringValue(value.String())
+ } else {
+ data.Entries[i].DestinationPortEqual10 = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "ace-rule/msg-type"); value.Exists() && !data.Entries[i].IcmpMsgType.IsNull() {
+ data.Entries[i].IcmpMsgType = types.Int64Value(value.Int())
+ } else {
+ data.Entries[i].IcmpMsgType = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(r, "ace-rule/msg-code"); value.Exists() && !data.Entries[i].IcmpMsgCode.IsNull() {
+ data.Entries[i].IcmpMsgCode = types.Int64Value(value.Int())
+ } else {
+ data.Entries[i].IcmpMsgCode = types.Int64Null()
+ }
+ }
+}
+
+// End of section. //template:end updateFromBodyXML
+
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBody
+
+func (data *AccessListExtended) fromBody(ctx context.Context, res gjson.Result) {
+ prefix := helpers.LastElement(data.getPath()) + "."
+ if res.Get(helpers.LastElement(data.getPath())).IsArray() {
+ prefix += "0."
+ }
+ if value := res.Get(prefix + "access-list-seq-rule"); value.Exists() {
+ data.Entries = make([]AccessListExtendedEntries, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := AccessListExtendedEntries{}
+ if cValue := v.Get("sequence"); cValue.Exists() {
+ item.Sequence = types.Int64Value(cValue.Int())
+ }
+ if cValue := v.Get("remark"); cValue.Exists() {
+ item.Remark = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("ace-rule.action"); cValue.Exists() {
+ item.AceRuleAction = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("ace-rule.protocol"); cValue.Exists() {
+ item.AceRuleProtocol = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("ace-rule.object-group-str"); cValue.Exists() {
+ item.ServiceObjectGroup = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("ace-rule.ipv4-address"); cValue.Exists() {
+ item.SourcePrefix = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("ace-rule.mask"); cValue.Exists() {
+ item.SourcePrefixMask = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("ace-rule.any"); cValue.Exists() {
+ item.SourceAny = types.BoolValue(true)
+ } else {
+ item.SourceAny = types.BoolValue(false)
+ }
+ if cValue := v.Get("ace-rule.host-address"); cValue.Exists() {
+ item.SourceHost = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("ace-rule.object-group"); cValue.Exists() {
+ item.SourceObjectGroup = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("ace-rule.src-eq"); cValue.Exists() {
+ item.SourcePortEqual = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("ace-rule.src-gt"); cValue.Exists() {
+ item.SourcePortGreaterThan = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("ace-rule.src-lt"); cValue.Exists() {
+ item.SourcePortLesserThan = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("ace-rule.src-range1"); cValue.Exists() {
+ item.SourcePortRangeFrom = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("ace-rule.src-range2"); cValue.Exists() {
+ item.SourcePortRangeTo = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("ace-rule.dest-ipv4-address"); cValue.Exists() {
+ item.DestinationPrefix = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("ace-rule.dest-mask"); cValue.Exists() {
+ item.DestinationPrefixMask = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("ace-rule.dst-any"); cValue.Exists() {
+ item.DestinationAny = types.BoolValue(true)
+ } else {
+ item.DestinationAny = types.BoolValue(false)
+ }
+ if cValue := v.Get("ace-rule.dst-host-address"); cValue.Exists() {
+ item.DestinationHost = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("ace-rule.dst-object-group"); cValue.Exists() {
+ item.DestinationObjectGroup = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("ace-rule.dst-eq"); cValue.Exists() {
+ item.DestinationPortEqual = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("ace-rule.dst-gt"); cValue.Exists() {
+ item.DestinationPortGreaterThan = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("ace-rule.dst-lt"); cValue.Exists() {
+ item.DestinationPortLesserThan = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("ace-rule.dst-range1"); cValue.Exists() {
+ item.DestinationPortRangeFrom = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("ace-rule.dst-range2"); cValue.Exists() {
+ item.DestinationPortRangeTo = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("ace-rule.ack"); cValue.Exists() {
+ item.Ack = types.BoolValue(true)
+ } else {
+ item.Ack = types.BoolValue(false)
+ }
+ if cValue := v.Get("ace-rule.fin"); cValue.Exists() {
+ item.Fin = types.BoolValue(true)
+ } else {
+ item.Fin = types.BoolValue(false)
+ }
+ if cValue := v.Get("ace-rule.psh"); cValue.Exists() {
+ item.Psh = types.BoolValue(true)
+ } else {
+ item.Psh = types.BoolValue(false)
+ }
+ if cValue := v.Get("ace-rule.rst"); cValue.Exists() {
+ item.Rst = types.BoolValue(true)
+ } else {
+ item.Rst = types.BoolValue(false)
+ }
+ if cValue := v.Get("ace-rule.syn"); cValue.Exists() {
+ item.Syn = types.BoolValue(true)
+ } else {
+ item.Syn = types.BoolValue(false)
+ }
+ if cValue := v.Get("ace-rule.urg"); cValue.Exists() {
+ item.Urg = types.BoolValue(true)
+ } else {
+ item.Urg = types.BoolValue(false)
+ }
+ if cValue := v.Get("ace-rule.established"); cValue.Exists() {
+ item.Established = types.BoolValue(true)
+ } else {
+ item.Established = types.BoolValue(false)
+ }
+ if cValue := v.Get("ace-rule.dscp"); cValue.Exists() {
+ item.Dscp = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("ace-rule.fragments"); cValue.Exists() {
+ item.Fragments = types.BoolValue(true)
+ } else {
+ item.Fragments = types.BoolValue(false)
+ }
+ if cValue := v.Get("ace-rule.precedence"); cValue.Exists() {
+ item.Precedence = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("ace-rule.tos"); cValue.Exists() {
+ item.Tos = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("ace-rule.log"); cValue.Exists() {
+ item.Log = types.BoolValue(true)
+ } else {
+ item.Log = types.BoolValue(false)
+ }
+ if cValue := v.Get("ace-rule.log-input"); cValue.Exists() {
+ item.LogInput = types.BoolValue(true)
+ } else {
+ item.LogInput = types.BoolValue(false)
+ }
+ if cValue := v.Get("ace-rule.named-msg-type"); cValue.Exists() {
+ item.IcmpNamedMsgType = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("ace-rule.dst-eq-port2"); cValue.Exists() {
+ item.DestinationPortEqual2 = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("ace-rule.dst-eq-port3"); cValue.Exists() {
+ item.DestinationPortEqual3 = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("ace-rule.dst-eq-port4"); cValue.Exists() {
+ item.DestinationPortEqual4 = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("ace-rule.dst-eq-port5"); cValue.Exists() {
+ item.DestinationPortEqual5 = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("ace-rule.dst-eq-port6"); cValue.Exists() {
+ item.DestinationPortEqual6 = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("ace-rule.dst-eq-port7"); cValue.Exists() {
+ item.DestinationPortEqual7 = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("ace-rule.dst-eq-port8"); cValue.Exists() {
+ item.DestinationPortEqual8 = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("ace-rule.dst-eq-port9"); cValue.Exists() {
+ item.DestinationPortEqual9 = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("ace-rule.dst-eq-port10"); cValue.Exists() {
+ item.DestinationPortEqual10 = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("ace-rule.msg-type"); cValue.Exists() {
+ item.IcmpMsgType = types.Int64Value(cValue.Int())
+ }
+ if cValue := v.Get("ace-rule.msg-code"); cValue.Exists() {
+ item.IcmpMsgCode = types.Int64Value(cValue.Int())
+ }
+ data.Entries = append(data.Entries, item)
+ return true
+ })
+ }
+}
+
+// End of section. //template:end fromBody
+
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyData
+
+func (data *AccessListExtendedData) fromBody(ctx context.Context, res gjson.Result) {
+ prefix := helpers.LastElement(data.getPath()) + "."
+ if res.Get(helpers.LastElement(data.getPath())).IsArray() {
+ prefix += "0."
+ }
+ if value := res.Get(prefix + "access-list-seq-rule"); value.Exists() {
+ data.Entries = make([]AccessListExtendedEntries, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := AccessListExtendedEntries{}
+ if cValue := v.Get("sequence"); cValue.Exists() {
+ item.Sequence = types.Int64Value(cValue.Int())
+ }
+ if cValue := v.Get("remark"); cValue.Exists() {
+ item.Remark = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("ace-rule.action"); cValue.Exists() {
+ item.AceRuleAction = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("ace-rule.protocol"); cValue.Exists() {
+ item.AceRuleProtocol = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("ace-rule.object-group-str"); cValue.Exists() {
+ item.ServiceObjectGroup = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("ace-rule.ipv4-address"); cValue.Exists() {
+ item.SourcePrefix = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("ace-rule.mask"); cValue.Exists() {
+ item.SourcePrefixMask = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("ace-rule.any"); cValue.Exists() {
+ item.SourceAny = types.BoolValue(true)
+ } else {
+ item.SourceAny = types.BoolValue(false)
+ }
+ if cValue := v.Get("ace-rule.host-address"); cValue.Exists() {
+ item.SourceHost = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("ace-rule.object-group"); cValue.Exists() {
+ item.SourceObjectGroup = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("ace-rule.src-eq"); cValue.Exists() {
+ item.SourcePortEqual = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("ace-rule.src-gt"); cValue.Exists() {
+ item.SourcePortGreaterThan = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("ace-rule.src-lt"); cValue.Exists() {
+ item.SourcePortLesserThan = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("ace-rule.src-range1"); cValue.Exists() {
+ item.SourcePortRangeFrom = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("ace-rule.src-range2"); cValue.Exists() {
+ item.SourcePortRangeTo = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("ace-rule.dest-ipv4-address"); cValue.Exists() {
+ item.DestinationPrefix = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("ace-rule.dest-mask"); cValue.Exists() {
+ item.DestinationPrefixMask = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("ace-rule.dst-any"); cValue.Exists() {
+ item.DestinationAny = types.BoolValue(true)
+ } else {
+ item.DestinationAny = types.BoolValue(false)
+ }
+ if cValue := v.Get("ace-rule.dst-host-address"); cValue.Exists() {
+ item.DestinationHost = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("ace-rule.dst-object-group"); cValue.Exists() {
+ item.DestinationObjectGroup = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("ace-rule.dst-eq"); cValue.Exists() {
+ item.DestinationPortEqual = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("ace-rule.dst-gt"); cValue.Exists() {
+ item.DestinationPortGreaterThan = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("ace-rule.dst-lt"); cValue.Exists() {
+ item.DestinationPortLesserThan = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("ace-rule.dst-range1"); cValue.Exists() {
+ item.DestinationPortRangeFrom = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("ace-rule.dst-range2"); cValue.Exists() {
+ item.DestinationPortRangeTo = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("ace-rule.ack"); cValue.Exists() {
+ item.Ack = types.BoolValue(true)
+ } else {
+ item.Ack = types.BoolValue(false)
+ }
+ if cValue := v.Get("ace-rule.fin"); cValue.Exists() {
+ item.Fin = types.BoolValue(true)
+ } else {
+ item.Fin = types.BoolValue(false)
+ }
+ if cValue := v.Get("ace-rule.psh"); cValue.Exists() {
+ item.Psh = types.BoolValue(true)
+ } else {
+ item.Psh = types.BoolValue(false)
+ }
+ if cValue := v.Get("ace-rule.rst"); cValue.Exists() {
+ item.Rst = types.BoolValue(true)
+ } else {
+ item.Rst = types.BoolValue(false)
+ }
+ if cValue := v.Get("ace-rule.syn"); cValue.Exists() {
+ item.Syn = types.BoolValue(true)
+ } else {
+ item.Syn = types.BoolValue(false)
+ }
+ if cValue := v.Get("ace-rule.urg"); cValue.Exists() {
+ item.Urg = types.BoolValue(true)
+ } else {
+ item.Urg = types.BoolValue(false)
+ }
+ if cValue := v.Get("ace-rule.established"); cValue.Exists() {
+ item.Established = types.BoolValue(true)
+ } else {
+ item.Established = types.BoolValue(false)
+ }
+ if cValue := v.Get("ace-rule.dscp"); cValue.Exists() {
+ item.Dscp = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("ace-rule.fragments"); cValue.Exists() {
+ item.Fragments = types.BoolValue(true)
+ } else {
+ item.Fragments = types.BoolValue(false)
+ }
+ if cValue := v.Get("ace-rule.precedence"); cValue.Exists() {
+ item.Precedence = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("ace-rule.tos"); cValue.Exists() {
+ item.Tos = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("ace-rule.log"); cValue.Exists() {
+ item.Log = types.BoolValue(true)
+ } else {
+ item.Log = types.BoolValue(false)
+ }
+ if cValue := v.Get("ace-rule.log-input"); cValue.Exists() {
+ item.LogInput = types.BoolValue(true)
+ } else {
+ item.LogInput = types.BoolValue(false)
+ }
+ if cValue := v.Get("ace-rule.named-msg-type"); cValue.Exists() {
+ item.IcmpNamedMsgType = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("ace-rule.dst-eq-port2"); cValue.Exists() {
+ item.DestinationPortEqual2 = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("ace-rule.dst-eq-port3"); cValue.Exists() {
+ item.DestinationPortEqual3 = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("ace-rule.dst-eq-port4"); cValue.Exists() {
+ item.DestinationPortEqual4 = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("ace-rule.dst-eq-port5"); cValue.Exists() {
+ item.DestinationPortEqual5 = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("ace-rule.dst-eq-port6"); cValue.Exists() {
+ item.DestinationPortEqual6 = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("ace-rule.dst-eq-port7"); cValue.Exists() {
+ item.DestinationPortEqual7 = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("ace-rule.dst-eq-port8"); cValue.Exists() {
+ item.DestinationPortEqual8 = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("ace-rule.dst-eq-port9"); cValue.Exists() {
+ item.DestinationPortEqual9 = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("ace-rule.dst-eq-port10"); cValue.Exists() {
+ item.DestinationPortEqual10 = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("ace-rule.msg-type"); cValue.Exists() {
+ item.IcmpMsgType = types.Int64Value(cValue.Int())
+ }
+ if cValue := v.Get("ace-rule.msg-code"); cValue.Exists() {
+ item.IcmpMsgCode = types.Int64Value(cValue.Int())
+ }
+ data.Entries = append(data.Entries, item)
+ return true
+ })
+ }
+}
+
+// End of section. //template:end fromBodyData
+
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyXML
+
+func (data *AccessListExtended) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/access-list-seq-rule"); value.Exists() {
+ data.Entries = make([]AccessListExtendedEntries, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := AccessListExtendedEntries{}
+ if cValue := helpers.GetFromXPath(v, "sequence"); cValue.Exists() {
+ item.Sequence = types.Int64Value(cValue.Int())
+ }
+ if cValue := helpers.GetFromXPath(v, "remark"); cValue.Exists() {
+ item.Remark = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "ace-rule/action"); cValue.Exists() {
+ item.AceRuleAction = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "ace-rule/protocol"); cValue.Exists() {
+ item.AceRuleProtocol = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "ace-rule/object-group-str"); cValue.Exists() {
+ item.ServiceObjectGroup = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "ace-rule/ipv4-address"); cValue.Exists() {
+ item.SourcePrefix = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "ace-rule/mask"); cValue.Exists() {
+ item.SourcePrefixMask = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "ace-rule/any"); cValue.Exists() {
+ item.SourceAny = types.BoolValue(true)
+ } else {
+ item.SourceAny = types.BoolValue(false)
}
- if cValue := v.Get("ace-rule.dst-host-address"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ace-rule/host-address"); cValue.Exists() {
+ item.SourceHost = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "ace-rule/object-group"); cValue.Exists() {
+ item.SourceObjectGroup = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "ace-rule/src-eq"); cValue.Exists() {
+ item.SourcePortEqual = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "ace-rule/src-gt"); cValue.Exists() {
+ item.SourcePortGreaterThan = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "ace-rule/src-lt"); cValue.Exists() {
+ item.SourcePortLesserThan = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "ace-rule/src-range1"); cValue.Exists() {
+ item.SourcePortRangeFrom = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "ace-rule/src-range2"); cValue.Exists() {
+ item.SourcePortRangeTo = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "ace-rule/dest-ipv4-address"); cValue.Exists() {
+ item.DestinationPrefix = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "ace-rule/dest-mask"); cValue.Exists() {
+ item.DestinationPrefixMask = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "ace-rule/dst-any"); cValue.Exists() {
+ item.DestinationAny = types.BoolValue(true)
+ } else {
+ item.DestinationAny = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "ace-rule/dst-host-address"); cValue.Exists() {
item.DestinationHost = types.StringValue(cValue.String())
}
- if cValue := v.Get("ace-rule.dst-object-group"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ace-rule/dst-object-group"); cValue.Exists() {
item.DestinationObjectGroup = types.StringValue(cValue.String())
}
- if cValue := v.Get("ace-rule.dst-eq"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ace-rule/dst-eq"); cValue.Exists() {
item.DestinationPortEqual = types.StringValue(cValue.String())
}
- if cValue := v.Get("ace-rule.dst-gt"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ace-rule/dst-gt"); cValue.Exists() {
item.DestinationPortGreaterThan = types.StringValue(cValue.String())
}
- if cValue := v.Get("ace-rule.dst-lt"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ace-rule/dst-lt"); cValue.Exists() {
item.DestinationPortLesserThan = types.StringValue(cValue.String())
}
- if cValue := v.Get("ace-rule.dst-range1"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ace-rule/dst-range1"); cValue.Exists() {
item.DestinationPortRangeFrom = types.StringValue(cValue.String())
}
- if cValue := v.Get("ace-rule.dst-range2"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ace-rule/dst-range2"); cValue.Exists() {
item.DestinationPortRangeTo = types.StringValue(cValue.String())
}
- if cValue := v.Get("ace-rule.ack"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ace-rule/ack"); cValue.Exists() {
item.Ack = types.BoolValue(true)
} else {
item.Ack = types.BoolValue(false)
}
- if cValue := v.Get("ace-rule.fin"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ace-rule/fin"); cValue.Exists() {
item.Fin = types.BoolValue(true)
} else {
item.Fin = types.BoolValue(false)
}
- if cValue := v.Get("ace-rule.psh"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ace-rule/psh"); cValue.Exists() {
item.Psh = types.BoolValue(true)
} else {
item.Psh = types.BoolValue(false)
}
- if cValue := v.Get("ace-rule.rst"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ace-rule/rst"); cValue.Exists() {
item.Rst = types.BoolValue(true)
} else {
item.Rst = types.BoolValue(false)
}
- if cValue := v.Get("ace-rule.syn"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ace-rule/syn"); cValue.Exists() {
item.Syn = types.BoolValue(true)
} else {
item.Syn = types.BoolValue(false)
}
- if cValue := v.Get("ace-rule.urg"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ace-rule/urg"); cValue.Exists() {
item.Urg = types.BoolValue(true)
} else {
item.Urg = types.BoolValue(false)
}
- if cValue := v.Get("ace-rule.established"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ace-rule/established"); cValue.Exists() {
item.Established = types.BoolValue(true)
} else {
item.Established = types.BoolValue(false)
}
- if cValue := v.Get("ace-rule.dscp"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ace-rule/dscp"); cValue.Exists() {
item.Dscp = types.StringValue(cValue.String())
}
- if cValue := v.Get("ace-rule.fragments"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ace-rule/fragments"); cValue.Exists() {
item.Fragments = types.BoolValue(true)
} else {
item.Fragments = types.BoolValue(false)
}
- if cValue := v.Get("ace-rule.precedence"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ace-rule/precedence"); cValue.Exists() {
item.Precedence = types.StringValue(cValue.String())
}
- if cValue := v.Get("ace-rule.tos"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ace-rule/tos"); cValue.Exists() {
item.Tos = types.StringValue(cValue.String())
}
- if cValue := v.Get("ace-rule.log"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ace-rule/log"); cValue.Exists() {
item.Log = types.BoolValue(true)
} else {
item.Log = types.BoolValue(false)
}
- if cValue := v.Get("ace-rule.log-input"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ace-rule/log-input"); cValue.Exists() {
item.LogInput = types.BoolValue(true)
} else {
item.LogInput = types.BoolValue(false)
}
- if cValue := v.Get("ace-rule.named-msg-type"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ace-rule/named-msg-type"); cValue.Exists() {
item.IcmpNamedMsgType = types.StringValue(cValue.String())
}
- if cValue := v.Get("ace-rule.dst-eq-port2"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ace-rule/dst-eq-port2"); cValue.Exists() {
item.DestinationPortEqual2 = types.StringValue(cValue.String())
}
- if cValue := v.Get("ace-rule.dst-eq-port3"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ace-rule/dst-eq-port3"); cValue.Exists() {
item.DestinationPortEqual3 = types.StringValue(cValue.String())
}
- if cValue := v.Get("ace-rule.dst-eq-port4"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ace-rule/dst-eq-port4"); cValue.Exists() {
item.DestinationPortEqual4 = types.StringValue(cValue.String())
}
- if cValue := v.Get("ace-rule.dst-eq-port5"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ace-rule/dst-eq-port5"); cValue.Exists() {
item.DestinationPortEqual5 = types.StringValue(cValue.String())
}
- if cValue := v.Get("ace-rule.dst-eq-port6"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ace-rule/dst-eq-port6"); cValue.Exists() {
item.DestinationPortEqual6 = types.StringValue(cValue.String())
}
- if cValue := v.Get("ace-rule.dst-eq-port7"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ace-rule/dst-eq-port7"); cValue.Exists() {
item.DestinationPortEqual7 = types.StringValue(cValue.String())
}
- if cValue := v.Get("ace-rule.dst-eq-port8"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ace-rule/dst-eq-port8"); cValue.Exists() {
item.DestinationPortEqual8 = types.StringValue(cValue.String())
}
- if cValue := v.Get("ace-rule.dst-eq-port9"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ace-rule/dst-eq-port9"); cValue.Exists() {
item.DestinationPortEqual9 = types.StringValue(cValue.String())
}
- if cValue := v.Get("ace-rule.dst-eq-port10"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ace-rule/dst-eq-port10"); cValue.Exists() {
item.DestinationPortEqual10 = types.StringValue(cValue.String())
}
- if cValue := v.Get("ace-rule.msg-type"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ace-rule/msg-type"); cValue.Exists() {
item.IcmpMsgType = types.Int64Value(cValue.Int())
}
- if cValue := v.Get("ace-rule.msg-code"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ace-rule/msg-code"); cValue.Exists() {
item.IcmpMsgCode = types.Int64Value(cValue.Int())
}
data.Entries = append(data.Entries, item)
@@ -849,191 +1801,187 @@ func (data *AccessListExtended) fromBody(ctx context.Context, res gjson.Result)
}
}
-// End of section. //template:end fromBody
+// End of section. //template:end fromBodyXML
-// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyData
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyDataXML
-func (data *AccessListExtendedData) fromBody(ctx context.Context, res gjson.Result) {
- prefix := helpers.LastElement(data.getPath()) + "."
- if res.Get(helpers.LastElement(data.getPath())).IsArray() {
- prefix += "0."
- }
- if value := res.Get(prefix + "access-list-seq-rule"); value.Exists() {
+func (data *AccessListExtendedData) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/access-list-seq-rule"); value.Exists() {
data.Entries = make([]AccessListExtendedEntries, 0)
- value.ForEach(func(k, v gjson.Result) bool {
+ value.ForEach(func(_ int, v xmldot.Result) bool {
item := AccessListExtendedEntries{}
- if cValue := v.Get("sequence"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "sequence"); cValue.Exists() {
item.Sequence = types.Int64Value(cValue.Int())
}
- if cValue := v.Get("remark"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "remark"); cValue.Exists() {
item.Remark = types.StringValue(cValue.String())
}
- if cValue := v.Get("ace-rule.action"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ace-rule/action"); cValue.Exists() {
item.AceRuleAction = types.StringValue(cValue.String())
}
- if cValue := v.Get("ace-rule.protocol"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ace-rule/protocol"); cValue.Exists() {
item.AceRuleProtocol = types.StringValue(cValue.String())
}
- if cValue := v.Get("ace-rule.object-group-str"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ace-rule/object-group-str"); cValue.Exists() {
item.ServiceObjectGroup = types.StringValue(cValue.String())
}
- if cValue := v.Get("ace-rule.ipv4-address"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ace-rule/ipv4-address"); cValue.Exists() {
item.SourcePrefix = types.StringValue(cValue.String())
}
- if cValue := v.Get("ace-rule.mask"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ace-rule/mask"); cValue.Exists() {
item.SourcePrefixMask = types.StringValue(cValue.String())
}
- if cValue := v.Get("ace-rule.any"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ace-rule/any"); cValue.Exists() {
item.SourceAny = types.BoolValue(true)
} else {
item.SourceAny = types.BoolValue(false)
}
- if cValue := v.Get("ace-rule.host-address"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ace-rule/host-address"); cValue.Exists() {
item.SourceHost = types.StringValue(cValue.String())
}
- if cValue := v.Get("ace-rule.object-group"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ace-rule/object-group"); cValue.Exists() {
item.SourceObjectGroup = types.StringValue(cValue.String())
}
- if cValue := v.Get("ace-rule.src-eq"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ace-rule/src-eq"); cValue.Exists() {
item.SourcePortEqual = types.StringValue(cValue.String())
}
- if cValue := v.Get("ace-rule.src-gt"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ace-rule/src-gt"); cValue.Exists() {
item.SourcePortGreaterThan = types.StringValue(cValue.String())
}
- if cValue := v.Get("ace-rule.src-lt"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ace-rule/src-lt"); cValue.Exists() {
item.SourcePortLesserThan = types.StringValue(cValue.String())
}
- if cValue := v.Get("ace-rule.src-range1"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ace-rule/src-range1"); cValue.Exists() {
item.SourcePortRangeFrom = types.StringValue(cValue.String())
}
- if cValue := v.Get("ace-rule.src-range2"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ace-rule/src-range2"); cValue.Exists() {
item.SourcePortRangeTo = types.StringValue(cValue.String())
}
- if cValue := v.Get("ace-rule.dest-ipv4-address"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ace-rule/dest-ipv4-address"); cValue.Exists() {
item.DestinationPrefix = types.StringValue(cValue.String())
}
- if cValue := v.Get("ace-rule.dest-mask"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ace-rule/dest-mask"); cValue.Exists() {
item.DestinationPrefixMask = types.StringValue(cValue.String())
}
- if cValue := v.Get("ace-rule.dst-any"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ace-rule/dst-any"); cValue.Exists() {
item.DestinationAny = types.BoolValue(true)
} else {
item.DestinationAny = types.BoolValue(false)
}
- if cValue := v.Get("ace-rule.dst-host-address"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ace-rule/dst-host-address"); cValue.Exists() {
item.DestinationHost = types.StringValue(cValue.String())
}
- if cValue := v.Get("ace-rule.dst-object-group"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ace-rule/dst-object-group"); cValue.Exists() {
item.DestinationObjectGroup = types.StringValue(cValue.String())
}
- if cValue := v.Get("ace-rule.dst-eq"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ace-rule/dst-eq"); cValue.Exists() {
item.DestinationPortEqual = types.StringValue(cValue.String())
}
- if cValue := v.Get("ace-rule.dst-gt"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ace-rule/dst-gt"); cValue.Exists() {
item.DestinationPortGreaterThan = types.StringValue(cValue.String())
}
- if cValue := v.Get("ace-rule.dst-lt"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ace-rule/dst-lt"); cValue.Exists() {
item.DestinationPortLesserThan = types.StringValue(cValue.String())
}
- if cValue := v.Get("ace-rule.dst-range1"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ace-rule/dst-range1"); cValue.Exists() {
item.DestinationPortRangeFrom = types.StringValue(cValue.String())
}
- if cValue := v.Get("ace-rule.dst-range2"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ace-rule/dst-range2"); cValue.Exists() {
item.DestinationPortRangeTo = types.StringValue(cValue.String())
}
- if cValue := v.Get("ace-rule.ack"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ace-rule/ack"); cValue.Exists() {
item.Ack = types.BoolValue(true)
} else {
item.Ack = types.BoolValue(false)
}
- if cValue := v.Get("ace-rule.fin"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ace-rule/fin"); cValue.Exists() {
item.Fin = types.BoolValue(true)
} else {
item.Fin = types.BoolValue(false)
}
- if cValue := v.Get("ace-rule.psh"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ace-rule/psh"); cValue.Exists() {
item.Psh = types.BoolValue(true)
} else {
item.Psh = types.BoolValue(false)
}
- if cValue := v.Get("ace-rule.rst"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ace-rule/rst"); cValue.Exists() {
item.Rst = types.BoolValue(true)
} else {
item.Rst = types.BoolValue(false)
}
- if cValue := v.Get("ace-rule.syn"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ace-rule/syn"); cValue.Exists() {
item.Syn = types.BoolValue(true)
} else {
item.Syn = types.BoolValue(false)
}
- if cValue := v.Get("ace-rule.urg"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ace-rule/urg"); cValue.Exists() {
item.Urg = types.BoolValue(true)
} else {
item.Urg = types.BoolValue(false)
}
- if cValue := v.Get("ace-rule.established"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ace-rule/established"); cValue.Exists() {
item.Established = types.BoolValue(true)
} else {
item.Established = types.BoolValue(false)
}
- if cValue := v.Get("ace-rule.dscp"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ace-rule/dscp"); cValue.Exists() {
item.Dscp = types.StringValue(cValue.String())
}
- if cValue := v.Get("ace-rule.fragments"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ace-rule/fragments"); cValue.Exists() {
item.Fragments = types.BoolValue(true)
} else {
item.Fragments = types.BoolValue(false)
}
- if cValue := v.Get("ace-rule.precedence"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ace-rule/precedence"); cValue.Exists() {
item.Precedence = types.StringValue(cValue.String())
}
- if cValue := v.Get("ace-rule.tos"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ace-rule/tos"); cValue.Exists() {
item.Tos = types.StringValue(cValue.String())
}
- if cValue := v.Get("ace-rule.log"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ace-rule/log"); cValue.Exists() {
item.Log = types.BoolValue(true)
} else {
item.Log = types.BoolValue(false)
}
- if cValue := v.Get("ace-rule.log-input"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ace-rule/log-input"); cValue.Exists() {
item.LogInput = types.BoolValue(true)
} else {
item.LogInput = types.BoolValue(false)
}
- if cValue := v.Get("ace-rule.named-msg-type"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ace-rule/named-msg-type"); cValue.Exists() {
item.IcmpNamedMsgType = types.StringValue(cValue.String())
}
- if cValue := v.Get("ace-rule.dst-eq-port2"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ace-rule/dst-eq-port2"); cValue.Exists() {
item.DestinationPortEqual2 = types.StringValue(cValue.String())
}
- if cValue := v.Get("ace-rule.dst-eq-port3"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ace-rule/dst-eq-port3"); cValue.Exists() {
item.DestinationPortEqual3 = types.StringValue(cValue.String())
}
- if cValue := v.Get("ace-rule.dst-eq-port4"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ace-rule/dst-eq-port4"); cValue.Exists() {
item.DestinationPortEqual4 = types.StringValue(cValue.String())
}
- if cValue := v.Get("ace-rule.dst-eq-port5"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ace-rule/dst-eq-port5"); cValue.Exists() {
item.DestinationPortEqual5 = types.StringValue(cValue.String())
}
- if cValue := v.Get("ace-rule.dst-eq-port6"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ace-rule/dst-eq-port6"); cValue.Exists() {
item.DestinationPortEqual6 = types.StringValue(cValue.String())
}
- if cValue := v.Get("ace-rule.dst-eq-port7"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ace-rule/dst-eq-port7"); cValue.Exists() {
item.DestinationPortEqual7 = types.StringValue(cValue.String())
}
- if cValue := v.Get("ace-rule.dst-eq-port8"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ace-rule/dst-eq-port8"); cValue.Exists() {
item.DestinationPortEqual8 = types.StringValue(cValue.String())
}
- if cValue := v.Get("ace-rule.dst-eq-port9"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ace-rule/dst-eq-port9"); cValue.Exists() {
item.DestinationPortEqual9 = types.StringValue(cValue.String())
}
- if cValue := v.Get("ace-rule.dst-eq-port10"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ace-rule/dst-eq-port10"); cValue.Exists() {
item.DestinationPortEqual10 = types.StringValue(cValue.String())
}
- if cValue := v.Get("ace-rule.msg-type"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ace-rule/msg-type"); cValue.Exists() {
item.IcmpMsgType = types.Int64Value(cValue.Int())
}
- if cValue := v.Get("ace-rule.msg-code"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ace-rule/msg-code"); cValue.Exists() {
item.IcmpMsgCode = types.Int64Value(cValue.Int())
}
data.Entries = append(data.Entries, item)
@@ -1042,7 +1990,7 @@ func (data *AccessListExtendedData) fromBody(ctx context.Context, res gjson.Resu
}
}
-// End of section. //template:end fromBodyData
+// End of section. //template:end fromBodyDataXML
// Section below is generated&owned by "gen/generator.go". //template:begin getDeletedItems
@@ -1226,6 +2174,193 @@ func (data *AccessListExtended) getDeletedItems(ctx context.Context, state Acces
// End of section. //template:end getDeletedItems
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletedItemsXML
+
+func (data *AccessListExtended) addDeletedItemsXML(ctx context.Context, state AccessListExtended, body string) string {
+ b := netconf.NewBody(body)
+ for i := range state.Entries {
+ stateKeys := [...]string{"sequence"}
+ stateKeyValues := [...]string{strconv.FormatInt(state.Entries[i].Sequence.ValueInt64(), 10)}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.Entries[i].Sequence.ValueInt64()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.Entries {
+ found = true
+ if state.Entries[i].Sequence.ValueInt64() != data.Entries[j].Sequence.ValueInt64() {
+ found = false
+ }
+ if found {
+ if !state.Entries[i].Remark.IsNull() && data.Entries[j].Remark.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/access-list-seq-rule%v/remark", predicates))
+ }
+ if !state.Entries[i].AceRuleAction.IsNull() && data.Entries[j].AceRuleAction.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/access-list-seq-rule%v/ace-rule/action", predicates))
+ }
+ if !state.Entries[i].AceRuleProtocol.IsNull() && data.Entries[j].AceRuleProtocol.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/access-list-seq-rule%v/ace-rule/protocol", predicates))
+ }
+ if !state.Entries[i].ServiceObjectGroup.IsNull() && data.Entries[j].ServiceObjectGroup.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/access-list-seq-rule%v/ace-rule/object-group-str", predicates))
+ }
+ if !state.Entries[i].SourcePrefix.IsNull() && data.Entries[j].SourcePrefix.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/access-list-seq-rule%v/ace-rule/ipv4-address", predicates))
+ }
+ if !state.Entries[i].SourcePrefixMask.IsNull() && data.Entries[j].SourcePrefixMask.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/access-list-seq-rule%v/ace-rule/mask", predicates))
+ }
+ if !state.Entries[i].SourceAny.IsNull() && data.Entries[j].SourceAny.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/access-list-seq-rule%v/ace-rule/any", predicates))
+ }
+ if !state.Entries[i].SourceHost.IsNull() && data.Entries[j].SourceHost.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/access-list-seq-rule%v/ace-rule/host-address", predicates))
+ }
+ if !state.Entries[i].SourceObjectGroup.IsNull() && data.Entries[j].SourceObjectGroup.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/access-list-seq-rule%v/ace-rule/object-group", predicates))
+ }
+ if !state.Entries[i].SourcePortEqual.IsNull() && data.Entries[j].SourcePortEqual.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/access-list-seq-rule%v/ace-rule/src-eq", predicates))
+ }
+ if !state.Entries[i].SourcePortGreaterThan.IsNull() && data.Entries[j].SourcePortGreaterThan.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/access-list-seq-rule%v/ace-rule/src-gt", predicates))
+ }
+ if !state.Entries[i].SourcePortLesserThan.IsNull() && data.Entries[j].SourcePortLesserThan.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/access-list-seq-rule%v/ace-rule/src-lt", predicates))
+ }
+ if !state.Entries[i].SourcePortRangeFrom.IsNull() && data.Entries[j].SourcePortRangeFrom.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/access-list-seq-rule%v/ace-rule/src-range1", predicates))
+ }
+ if !state.Entries[i].SourcePortRangeTo.IsNull() && data.Entries[j].SourcePortRangeTo.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/access-list-seq-rule%v/ace-rule/src-range2", predicates))
+ }
+ if !state.Entries[i].DestinationPrefix.IsNull() && data.Entries[j].DestinationPrefix.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/access-list-seq-rule%v/ace-rule/dest-ipv4-address", predicates))
+ }
+ if !state.Entries[i].DestinationPrefixMask.IsNull() && data.Entries[j].DestinationPrefixMask.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/access-list-seq-rule%v/ace-rule/dest-mask", predicates))
+ }
+ if !state.Entries[i].DestinationAny.IsNull() && data.Entries[j].DestinationAny.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/access-list-seq-rule%v/ace-rule/dst-any", predicates))
+ }
+ if !state.Entries[i].DestinationHost.IsNull() && data.Entries[j].DestinationHost.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/access-list-seq-rule%v/ace-rule/dst-host-address", predicates))
+ }
+ if !state.Entries[i].DestinationObjectGroup.IsNull() && data.Entries[j].DestinationObjectGroup.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/access-list-seq-rule%v/ace-rule/dst-object-group", predicates))
+ }
+ if !state.Entries[i].DestinationPortEqual.IsNull() && data.Entries[j].DestinationPortEqual.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/access-list-seq-rule%v/ace-rule/dst-eq", predicates))
+ }
+ if !state.Entries[i].DestinationPortGreaterThan.IsNull() && data.Entries[j].DestinationPortGreaterThan.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/access-list-seq-rule%v/ace-rule/dst-gt", predicates))
+ }
+ if !state.Entries[i].DestinationPortLesserThan.IsNull() && data.Entries[j].DestinationPortLesserThan.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/access-list-seq-rule%v/ace-rule/dst-lt", predicates))
+ }
+ if !state.Entries[i].DestinationPortRangeFrom.IsNull() && data.Entries[j].DestinationPortRangeFrom.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/access-list-seq-rule%v/ace-rule/dst-range1", predicates))
+ }
+ if !state.Entries[i].DestinationPortRangeTo.IsNull() && data.Entries[j].DestinationPortRangeTo.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/access-list-seq-rule%v/ace-rule/dst-range2", predicates))
+ }
+ if !state.Entries[i].Ack.IsNull() && data.Entries[j].Ack.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/access-list-seq-rule%v/ace-rule/ack", predicates))
+ }
+ if !state.Entries[i].Fin.IsNull() && data.Entries[j].Fin.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/access-list-seq-rule%v/ace-rule/fin", predicates))
+ }
+ if !state.Entries[i].Psh.IsNull() && data.Entries[j].Psh.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/access-list-seq-rule%v/ace-rule/psh", predicates))
+ }
+ if !state.Entries[i].Rst.IsNull() && data.Entries[j].Rst.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/access-list-seq-rule%v/ace-rule/rst", predicates))
+ }
+ if !state.Entries[i].Syn.IsNull() && data.Entries[j].Syn.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/access-list-seq-rule%v/ace-rule/syn", predicates))
+ }
+ if !state.Entries[i].Urg.IsNull() && data.Entries[j].Urg.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/access-list-seq-rule%v/ace-rule/urg", predicates))
+ }
+ if !state.Entries[i].Established.IsNull() && data.Entries[j].Established.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/access-list-seq-rule%v/ace-rule/established", predicates))
+ }
+ if !state.Entries[i].Dscp.IsNull() && data.Entries[j].Dscp.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/access-list-seq-rule%v/ace-rule/dscp", predicates))
+ }
+ if !state.Entries[i].Fragments.IsNull() && data.Entries[j].Fragments.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/access-list-seq-rule%v/ace-rule/fragments", predicates))
+ }
+ if !state.Entries[i].Precedence.IsNull() && data.Entries[j].Precedence.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/access-list-seq-rule%v/ace-rule/precedence", predicates))
+ }
+ if !state.Entries[i].Tos.IsNull() && data.Entries[j].Tos.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/access-list-seq-rule%v/ace-rule/tos", predicates))
+ }
+ if !state.Entries[i].Log.IsNull() && data.Entries[j].Log.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/access-list-seq-rule%v/ace-rule/log", predicates))
+ }
+ if !state.Entries[i].LogInput.IsNull() && data.Entries[j].LogInput.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/access-list-seq-rule%v/ace-rule/log-input", predicates))
+ }
+ if !state.Entries[i].IcmpNamedMsgType.IsNull() && data.Entries[j].IcmpNamedMsgType.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/access-list-seq-rule%v/ace-rule/named-msg-type", predicates))
+ }
+ if !state.Entries[i].DestinationPortEqual2.IsNull() && data.Entries[j].DestinationPortEqual2.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/access-list-seq-rule%v/ace-rule/dst-eq-port2", predicates))
+ }
+ if !state.Entries[i].DestinationPortEqual3.IsNull() && data.Entries[j].DestinationPortEqual3.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/access-list-seq-rule%v/ace-rule/dst-eq-port3", predicates))
+ }
+ if !state.Entries[i].DestinationPortEqual4.IsNull() && data.Entries[j].DestinationPortEqual4.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/access-list-seq-rule%v/ace-rule/dst-eq-port4", predicates))
+ }
+ if !state.Entries[i].DestinationPortEqual5.IsNull() && data.Entries[j].DestinationPortEqual5.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/access-list-seq-rule%v/ace-rule/dst-eq-port5", predicates))
+ }
+ if !state.Entries[i].DestinationPortEqual6.IsNull() && data.Entries[j].DestinationPortEqual6.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/access-list-seq-rule%v/ace-rule/dst-eq-port6", predicates))
+ }
+ if !state.Entries[i].DestinationPortEqual7.IsNull() && data.Entries[j].DestinationPortEqual7.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/access-list-seq-rule%v/ace-rule/dst-eq-port7", predicates))
+ }
+ if !state.Entries[i].DestinationPortEqual8.IsNull() && data.Entries[j].DestinationPortEqual8.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/access-list-seq-rule%v/ace-rule/dst-eq-port8", predicates))
+ }
+ if !state.Entries[i].DestinationPortEqual9.IsNull() && data.Entries[j].DestinationPortEqual9.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/access-list-seq-rule%v/ace-rule/dst-eq-port9", predicates))
+ }
+ if !state.Entries[i].DestinationPortEqual10.IsNull() && data.Entries[j].DestinationPortEqual10.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/access-list-seq-rule%v/ace-rule/dst-eq-port10", predicates))
+ }
+ if !state.Entries[i].IcmpMsgType.IsNull() && data.Entries[j].IcmpMsgType.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/access-list-seq-rule%v/ace-rule/msg-type", predicates))
+ }
+ if !state.Entries[i].IcmpMsgCode.IsNull() && data.Entries[j].IcmpMsgCode.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/access-list-seq-rule%v/ace-rule/msg-code", predicates))
+ }
+ break
+ }
+ }
+ if !found {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/access-list-seq-rule%v", predicates))
+ }
+ }
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletedItemsXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin getEmptyLeafsDelete
func (data *AccessListExtended) getEmptyLeafsDelete(ctx context.Context) []string {
@@ -1290,3 +2425,23 @@ func (data *AccessListExtended) getDeletePaths(ctx context.Context) []string {
}
// End of section. //template:end getDeletePaths
+
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletePathsXML
+
+func (data *AccessListExtended) addDeletePathsXML(ctx context.Context, body string) string {
+ b := netconf.NewBody(body)
+ for i := range data.Entries {
+ keys := [...]string{"sequence"}
+ keyValues := [...]string{strconv.FormatInt(data.Entries[i].Sequence.ValueInt64(), 10)}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/access-list-seq-rule%v", predicates))
+ }
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletePathsXML
diff --git a/internal/provider/model_iosxe_access_list_role_based.go b/internal/provider/model_iosxe_access_list_role_based.go
index a64e1d45..28aacb30 100644
--- a/internal/provider/model_iosxe_access_list_role_based.go
+++ b/internal/provider/model_iosxe_access_list_role_based.go
@@ -31,6 +31,9 @@ import (
"github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/types"
+ "github.com/hashicorp/terraform-plugin-log/tflog"
+ "github.com/netascode/go-netconf"
+ "github.com/netascode/xmldot"
"github.com/tidwall/gjson"
"github.com/tidwall/sjson"
)
@@ -120,6 +123,19 @@ func (data AccessListRoleBased) getPathShort() string {
return matches[1]
}
+// getXPath returns the XPath for NETCONF operations
+func (data AccessListRoleBased) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/ip/access-list/Cisco-IOS-XE-acl:role-based[name=%v]"
+ path = fmt.Sprintf(path, fmt.Sprintf("%v", data.Name.ValueString()))
+ return path
+}
+
+func (data AccessListRoleBasedData) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/ip/access-list/Cisco-IOS-XE-acl:role-based[name=%v]"
+ path = fmt.Sprintf(path, fmt.Sprintf("%v", data.Name.ValueString()))
+ return path
+}
+
// End of section. //template:end getPath
// Section below is generated&owned by "gen/generator.go". //template:begin toBody
@@ -336,6 +352,293 @@ func (data AccessListRoleBased) toBody(ctx context.Context) string {
// End of section. //template:end toBody
+// Section below is generated&owned by "gen/generator.go". //template:begin toBodyXML
+
+func (data AccessListRoleBased) toBodyXML(ctx context.Context) string {
+ body := netconf.Body{}
+ if !data.Name.IsNull() && !data.Name.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/name", data.Name.ValueString())
+ }
+ if len(data.Entries) > 0 {
+ for _, item := range data.Entries {
+ cBody := netconf.Body{}
+ if !item.Sequence.IsNull() && !item.Sequence.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "sequence", strconv.FormatInt(item.Sequence.ValueInt64(), 10))
+ }
+ if !item.Remark.IsNull() && !item.Remark.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "remark", item.Remark.ValueString())
+ }
+ if !item.AceRuleAction.IsNull() && !item.AceRuleAction.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "ace-rule/action", item.AceRuleAction.ValueString())
+ }
+ if !item.AceRuleProtocol.IsNull() && !item.AceRuleProtocol.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "ace-rule/protocol", item.AceRuleProtocol.ValueString())
+ }
+ if !item.Ack.IsNull() && !item.Ack.IsUnknown() {
+ if item.Ack.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "ace-rule/ack", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "ace-rule/ack")
+ }
+ }
+ if !item.Fin.IsNull() && !item.Fin.IsUnknown() {
+ if item.Fin.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "ace-rule/fin", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "ace-rule/fin")
+ }
+ }
+ if !item.Psh.IsNull() && !item.Psh.IsUnknown() {
+ if item.Psh.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "ace-rule/psh", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "ace-rule/psh")
+ }
+ }
+ if !item.Rst.IsNull() && !item.Rst.IsUnknown() {
+ if item.Rst.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "ace-rule/rst", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "ace-rule/rst")
+ }
+ }
+ if !item.Syn.IsNull() && !item.Syn.IsUnknown() {
+ if item.Syn.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "ace-rule/syn", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "ace-rule/syn")
+ }
+ }
+ if !item.Urg.IsNull() && !item.Urg.IsUnknown() {
+ if item.Urg.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "ace-rule/urg", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "ace-rule/urg")
+ }
+ }
+ if !item.Established.IsNull() && !item.Established.IsUnknown() {
+ if item.Established.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "ace-rule/established", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "ace-rule/established")
+ }
+ }
+ if !item.Dscp.IsNull() && !item.Dscp.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "ace-rule/dscp", item.Dscp.ValueString())
+ }
+ if !item.Fragments.IsNull() && !item.Fragments.IsUnknown() {
+ if item.Fragments.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "ace-rule/fragments", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "ace-rule/fragments")
+ }
+ }
+ if !item.Option.IsNull() && !item.Option.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "ace-rule/option", item.Option.ValueString())
+ }
+ if !item.Precedence.IsNull() && !item.Precedence.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "ace-rule/precedence", item.Precedence.ValueString())
+ }
+ if !item.TimeRange.IsNull() && !item.TimeRange.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "ace-rule/time-range", item.TimeRange.ValueString())
+ }
+ if !item.Tos.IsNull() && !item.Tos.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "ace-rule/tos", item.Tos.ValueString())
+ }
+ if !item.Log.IsNull() && !item.Log.IsUnknown() {
+ if item.Log.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "ace-rule/log", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "ace-rule/log")
+ }
+ }
+ if !item.LogInput.IsNull() && !item.LogInput.IsUnknown() {
+ if item.LogInput.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "ace-rule/log-input", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "ace-rule/log-input")
+ }
+ }
+ if !item.MatchAllPlusack.IsNull() && !item.MatchAllPlusack.IsUnknown() {
+ if item.MatchAllPlusack.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "ace-rule/match-all/plusack", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "ace-rule/match-all/plusack")
+ }
+ }
+ if !item.MatchAllPlusfin.IsNull() && !item.MatchAllPlusfin.IsUnknown() {
+ if item.MatchAllPlusfin.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "ace-rule/match-all/plusfin", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "ace-rule/match-all/plusfin")
+ }
+ }
+ if !item.MatchAllPluspsh.IsNull() && !item.MatchAllPluspsh.IsUnknown() {
+ if item.MatchAllPluspsh.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "ace-rule/match-all/pluspsh", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "ace-rule/match-all/pluspsh")
+ }
+ }
+ if !item.MatchAllPlusrst.IsNull() && !item.MatchAllPlusrst.IsUnknown() {
+ if item.MatchAllPlusrst.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "ace-rule/match-all/plusrst", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "ace-rule/match-all/plusrst")
+ }
+ }
+ if !item.MatchAllPlussyn.IsNull() && !item.MatchAllPlussyn.IsUnknown() {
+ if item.MatchAllPlussyn.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "ace-rule/match-all/plussyn", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "ace-rule/match-all/plussyn")
+ }
+ }
+ if !item.MatchAllPlusurg.IsNull() && !item.MatchAllPlusurg.IsUnknown() {
+ if item.MatchAllPlusurg.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "ace-rule/match-all/plusurg", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "ace-rule/match-all/plusurg")
+ }
+ }
+ if !item.MatchAllMinusack.IsNull() && !item.MatchAllMinusack.IsUnknown() {
+ if item.MatchAllMinusack.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "ace-rule/match-all/minusack", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "ace-rule/match-all/minusack")
+ }
+ }
+ if !item.MatchAllMinusfin.IsNull() && !item.MatchAllMinusfin.IsUnknown() {
+ if item.MatchAllMinusfin.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "ace-rule/match-all/minusfin", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "ace-rule/match-all/minusfin")
+ }
+ }
+ if !item.MatchAllMinuspsh.IsNull() && !item.MatchAllMinuspsh.IsUnknown() {
+ if item.MatchAllMinuspsh.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "ace-rule/match-all/minuspsh", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "ace-rule/match-all/minuspsh")
+ }
+ }
+ if !item.MatchAllMinusrst.IsNull() && !item.MatchAllMinusrst.IsUnknown() {
+ if item.MatchAllMinusrst.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "ace-rule/match-all/minusrst", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "ace-rule/match-all/minusrst")
+ }
+ }
+ if !item.MatchAllMinussyn.IsNull() && !item.MatchAllMinussyn.IsUnknown() {
+ if item.MatchAllMinussyn.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "ace-rule/match-all/minussyn", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "ace-rule/match-all/minussyn")
+ }
+ }
+ if !item.MatchAllMinusurg.IsNull() && !item.MatchAllMinusurg.IsUnknown() {
+ if item.MatchAllMinusurg.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "ace-rule/match-all/minusurg", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "ace-rule/match-all/minusurg")
+ }
+ }
+ if !item.MatchAnyPlusack.IsNull() && !item.MatchAnyPlusack.IsUnknown() {
+ if item.MatchAnyPlusack.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "ace-rule/match-any/plusack", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "ace-rule/match-any/plusack")
+ }
+ }
+ if !item.MatchAnyPlusfin.IsNull() && !item.MatchAnyPlusfin.IsUnknown() {
+ if item.MatchAnyPlusfin.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "ace-rule/match-any/plusfin", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "ace-rule/match-any/plusfin")
+ }
+ }
+ if !item.MatchAnyPluspsh.IsNull() && !item.MatchAnyPluspsh.IsUnknown() {
+ if item.MatchAnyPluspsh.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "ace-rule/match-any/pluspsh", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "ace-rule/match-any/pluspsh")
+ }
+ }
+ if !item.MatchAnyPlusrst.IsNull() && !item.MatchAnyPlusrst.IsUnknown() {
+ if item.MatchAnyPlusrst.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "ace-rule/match-any/plusrst", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "ace-rule/match-any/plusrst")
+ }
+ }
+ if !item.MatchAnyPlussyn.IsNull() && !item.MatchAnyPlussyn.IsUnknown() {
+ if item.MatchAnyPlussyn.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "ace-rule/match-any/plussyn", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "ace-rule/match-any/plussyn")
+ }
+ }
+ if !item.MatchAnyPlusurg.IsNull() && !item.MatchAnyPlusurg.IsUnknown() {
+ if item.MatchAnyPlusurg.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "ace-rule/match-any/plusurg", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "ace-rule/match-any/plusurg")
+ }
+ }
+ if !item.MatchAnyMinusack.IsNull() && !item.MatchAnyMinusack.IsUnknown() {
+ if item.MatchAnyMinusack.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "ace-rule/match-any/minusack", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "ace-rule/match-any/minusack")
+ }
+ }
+ if !item.MatchAnyMinusfin.IsNull() && !item.MatchAnyMinusfin.IsUnknown() {
+ if item.MatchAnyMinusfin.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "ace-rule/match-any/minusfin", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "ace-rule/match-any/minusfin")
+ }
+ }
+ if !item.MatchAnyMinuspsh.IsNull() && !item.MatchAnyMinuspsh.IsUnknown() {
+ if item.MatchAnyMinuspsh.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "ace-rule/match-any/minuspsh", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "ace-rule/match-any/minuspsh")
+ }
+ }
+ if !item.MatchAnyMinusrst.IsNull() && !item.MatchAnyMinusrst.IsUnknown() {
+ if item.MatchAnyMinusrst.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "ace-rule/match-any/minusrst", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "ace-rule/match-any/minusrst")
+ }
+ }
+ if !item.MatchAnyMinussyn.IsNull() && !item.MatchAnyMinussyn.IsUnknown() {
+ if item.MatchAnyMinussyn.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "ace-rule/match-any/minussyn", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "ace-rule/match-any/minussyn")
+ }
+ }
+ if !item.MatchAnyMinusurg.IsNull() && !item.MatchAnyMinusurg.IsUnknown() {
+ if item.MatchAnyMinusurg.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "ace-rule/match-any/minusurg", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "ace-rule/match-any/minusurg")
+ }
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/access-list-seq-rule", cBody.Res())
+ }
+ }
+ bodyString, err := body.String()
+ if err != nil {
+ tflog.Error(ctx, fmt.Sprintf("Error converting body to string: %s", err))
+ }
+ return bodyString
+}
+
+// End of section. //template:end toBodyXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBody
func (data *AccessListRoleBased) updateFromBody(ctx context.Context, res gjson.Result) {
@@ -708,229 +1011,1044 @@ func (data *AccessListRoleBased) updateFromBody(ctx context.Context, res gjson.R
if value.Exists() {
data.Entries[i].MatchAnyMinussyn = types.BoolValue(true)
} else {
- data.Entries[i].MatchAnyMinussyn = types.BoolValue(false)
+ data.Entries[i].MatchAnyMinussyn = types.BoolValue(false)
+ }
+ } else {
+ data.Entries[i].MatchAnyMinussyn = types.BoolNull()
+ }
+ if value := r.Get("ace-rule.match-any.minusurg"); !data.Entries[i].MatchAnyMinusurg.IsNull() {
+ if value.Exists() {
+ data.Entries[i].MatchAnyMinusurg = types.BoolValue(true)
+ } else {
+ data.Entries[i].MatchAnyMinusurg = types.BoolValue(false)
+ }
+ } else {
+ data.Entries[i].MatchAnyMinusurg = types.BoolNull()
+ }
+ }
+}
+
+// End of section. //template:end updateFromBody
+
+// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBodyXML
+
+func (data *AccessListRoleBased) updateFromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/name"); value.Exists() && !data.Name.IsNull() {
+ data.Name = types.StringValue(value.String())
+ } else {
+ data.Name = types.StringNull()
+ }
+ for i := range data.Entries {
+ keys := [...]string{"sequence"}
+ keyValues := [...]string{strconv.FormatInt(data.Entries[i].Sequence.ValueInt64(), 10)}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/access-list-seq-rule").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, "sequence"); value.Exists() && !data.Entries[i].Sequence.IsNull() {
+ data.Entries[i].Sequence = types.Int64Value(value.Int())
+ } else {
+ data.Entries[i].Sequence = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(r, "remark"); value.Exists() && !data.Entries[i].Remark.IsNull() {
+ data.Entries[i].Remark = types.StringValue(value.String())
+ } else {
+ data.Entries[i].Remark = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "ace-rule/action"); value.Exists() && !data.Entries[i].AceRuleAction.IsNull() {
+ data.Entries[i].AceRuleAction = types.StringValue(value.String())
+ } else {
+ data.Entries[i].AceRuleAction = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "ace-rule/protocol"); value.Exists() && !data.Entries[i].AceRuleProtocol.IsNull() {
+ data.Entries[i].AceRuleProtocol = types.StringValue(value.String())
+ } else {
+ data.Entries[i].AceRuleProtocol = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "ace-rule/ack"); !data.Entries[i].Ack.IsNull() {
+ if value.Exists() {
+ data.Entries[i].Ack = types.BoolValue(true)
+ } else {
+ data.Entries[i].Ack = types.BoolValue(false)
+ }
+ } else {
+ data.Entries[i].Ack = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "ace-rule/fin"); !data.Entries[i].Fin.IsNull() {
+ if value.Exists() {
+ data.Entries[i].Fin = types.BoolValue(true)
+ } else {
+ data.Entries[i].Fin = types.BoolValue(false)
+ }
+ } else {
+ data.Entries[i].Fin = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "ace-rule/psh"); !data.Entries[i].Psh.IsNull() {
+ if value.Exists() {
+ data.Entries[i].Psh = types.BoolValue(true)
+ } else {
+ data.Entries[i].Psh = types.BoolValue(false)
+ }
+ } else {
+ data.Entries[i].Psh = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "ace-rule/rst"); !data.Entries[i].Rst.IsNull() {
+ if value.Exists() {
+ data.Entries[i].Rst = types.BoolValue(true)
+ } else {
+ data.Entries[i].Rst = types.BoolValue(false)
+ }
+ } else {
+ data.Entries[i].Rst = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "ace-rule/syn"); !data.Entries[i].Syn.IsNull() {
+ if value.Exists() {
+ data.Entries[i].Syn = types.BoolValue(true)
+ } else {
+ data.Entries[i].Syn = types.BoolValue(false)
+ }
+ } else {
+ data.Entries[i].Syn = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "ace-rule/urg"); !data.Entries[i].Urg.IsNull() {
+ if value.Exists() {
+ data.Entries[i].Urg = types.BoolValue(true)
+ } else {
+ data.Entries[i].Urg = types.BoolValue(false)
+ }
+ } else {
+ data.Entries[i].Urg = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "ace-rule/established"); !data.Entries[i].Established.IsNull() {
+ if value.Exists() {
+ data.Entries[i].Established = types.BoolValue(true)
+ } else {
+ data.Entries[i].Established = types.BoolValue(false)
+ }
+ } else {
+ data.Entries[i].Established = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "ace-rule/dscp"); value.Exists() && !data.Entries[i].Dscp.IsNull() {
+ data.Entries[i].Dscp = types.StringValue(value.String())
+ } else {
+ data.Entries[i].Dscp = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "ace-rule/fragments"); !data.Entries[i].Fragments.IsNull() {
+ if value.Exists() {
+ data.Entries[i].Fragments = types.BoolValue(true)
+ } else {
+ data.Entries[i].Fragments = types.BoolValue(false)
+ }
+ } else {
+ data.Entries[i].Fragments = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "ace-rule/option"); value.Exists() && !data.Entries[i].Option.IsNull() {
+ data.Entries[i].Option = types.StringValue(value.String())
+ } else {
+ data.Entries[i].Option = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "ace-rule/precedence"); value.Exists() && !data.Entries[i].Precedence.IsNull() {
+ data.Entries[i].Precedence = types.StringValue(value.String())
+ } else {
+ data.Entries[i].Precedence = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "ace-rule/time-range"); value.Exists() && !data.Entries[i].TimeRange.IsNull() {
+ data.Entries[i].TimeRange = types.StringValue(value.String())
+ } else {
+ data.Entries[i].TimeRange = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "ace-rule/tos"); value.Exists() && !data.Entries[i].Tos.IsNull() {
+ data.Entries[i].Tos = types.StringValue(value.String())
+ } else {
+ data.Entries[i].Tos = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "ace-rule/log"); !data.Entries[i].Log.IsNull() {
+ if value.Exists() {
+ data.Entries[i].Log = types.BoolValue(true)
+ } else {
+ data.Entries[i].Log = types.BoolValue(false)
+ }
+ } else {
+ data.Entries[i].Log = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "ace-rule/log-input"); !data.Entries[i].LogInput.IsNull() {
+ if value.Exists() {
+ data.Entries[i].LogInput = types.BoolValue(true)
+ } else {
+ data.Entries[i].LogInput = types.BoolValue(false)
+ }
+ } else {
+ data.Entries[i].LogInput = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "ace-rule/match-all/plusack"); !data.Entries[i].MatchAllPlusack.IsNull() {
+ if value.Exists() {
+ data.Entries[i].MatchAllPlusack = types.BoolValue(true)
+ } else {
+ data.Entries[i].MatchAllPlusack = types.BoolValue(false)
+ }
+ } else {
+ data.Entries[i].MatchAllPlusack = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "ace-rule/match-all/plusfin"); !data.Entries[i].MatchAllPlusfin.IsNull() {
+ if value.Exists() {
+ data.Entries[i].MatchAllPlusfin = types.BoolValue(true)
+ } else {
+ data.Entries[i].MatchAllPlusfin = types.BoolValue(false)
+ }
+ } else {
+ data.Entries[i].MatchAllPlusfin = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "ace-rule/match-all/pluspsh"); !data.Entries[i].MatchAllPluspsh.IsNull() {
+ if value.Exists() {
+ data.Entries[i].MatchAllPluspsh = types.BoolValue(true)
+ } else {
+ data.Entries[i].MatchAllPluspsh = types.BoolValue(false)
+ }
+ } else {
+ data.Entries[i].MatchAllPluspsh = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "ace-rule/match-all/plusrst"); !data.Entries[i].MatchAllPlusrst.IsNull() {
+ if value.Exists() {
+ data.Entries[i].MatchAllPlusrst = types.BoolValue(true)
+ } else {
+ data.Entries[i].MatchAllPlusrst = types.BoolValue(false)
+ }
+ } else {
+ data.Entries[i].MatchAllPlusrst = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "ace-rule/match-all/plussyn"); !data.Entries[i].MatchAllPlussyn.IsNull() {
+ if value.Exists() {
+ data.Entries[i].MatchAllPlussyn = types.BoolValue(true)
+ } else {
+ data.Entries[i].MatchAllPlussyn = types.BoolValue(false)
+ }
+ } else {
+ data.Entries[i].MatchAllPlussyn = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "ace-rule/match-all/plusurg"); !data.Entries[i].MatchAllPlusurg.IsNull() {
+ if value.Exists() {
+ data.Entries[i].MatchAllPlusurg = types.BoolValue(true)
+ } else {
+ data.Entries[i].MatchAllPlusurg = types.BoolValue(false)
+ }
+ } else {
+ data.Entries[i].MatchAllPlusurg = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "ace-rule/match-all/minusack"); !data.Entries[i].MatchAllMinusack.IsNull() {
+ if value.Exists() {
+ data.Entries[i].MatchAllMinusack = types.BoolValue(true)
+ } else {
+ data.Entries[i].MatchAllMinusack = types.BoolValue(false)
+ }
+ } else {
+ data.Entries[i].MatchAllMinusack = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "ace-rule/match-all/minusfin"); !data.Entries[i].MatchAllMinusfin.IsNull() {
+ if value.Exists() {
+ data.Entries[i].MatchAllMinusfin = types.BoolValue(true)
+ } else {
+ data.Entries[i].MatchAllMinusfin = types.BoolValue(false)
+ }
+ } else {
+ data.Entries[i].MatchAllMinusfin = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "ace-rule/match-all/minuspsh"); !data.Entries[i].MatchAllMinuspsh.IsNull() {
+ if value.Exists() {
+ data.Entries[i].MatchAllMinuspsh = types.BoolValue(true)
+ } else {
+ data.Entries[i].MatchAllMinuspsh = types.BoolValue(false)
+ }
+ } else {
+ data.Entries[i].MatchAllMinuspsh = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "ace-rule/match-all/minusrst"); !data.Entries[i].MatchAllMinusrst.IsNull() {
+ if value.Exists() {
+ data.Entries[i].MatchAllMinusrst = types.BoolValue(true)
+ } else {
+ data.Entries[i].MatchAllMinusrst = types.BoolValue(false)
+ }
+ } else {
+ data.Entries[i].MatchAllMinusrst = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "ace-rule/match-all/minussyn"); !data.Entries[i].MatchAllMinussyn.IsNull() {
+ if value.Exists() {
+ data.Entries[i].MatchAllMinussyn = types.BoolValue(true)
+ } else {
+ data.Entries[i].MatchAllMinussyn = types.BoolValue(false)
+ }
+ } else {
+ data.Entries[i].MatchAllMinussyn = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "ace-rule/match-all/minusurg"); !data.Entries[i].MatchAllMinusurg.IsNull() {
+ if value.Exists() {
+ data.Entries[i].MatchAllMinusurg = types.BoolValue(true)
+ } else {
+ data.Entries[i].MatchAllMinusurg = types.BoolValue(false)
+ }
+ } else {
+ data.Entries[i].MatchAllMinusurg = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "ace-rule/match-any/plusack"); !data.Entries[i].MatchAnyPlusack.IsNull() {
+ if value.Exists() {
+ data.Entries[i].MatchAnyPlusack = types.BoolValue(true)
+ } else {
+ data.Entries[i].MatchAnyPlusack = types.BoolValue(false)
+ }
+ } else {
+ data.Entries[i].MatchAnyPlusack = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "ace-rule/match-any/plusfin"); !data.Entries[i].MatchAnyPlusfin.IsNull() {
+ if value.Exists() {
+ data.Entries[i].MatchAnyPlusfin = types.BoolValue(true)
+ } else {
+ data.Entries[i].MatchAnyPlusfin = types.BoolValue(false)
+ }
+ } else {
+ data.Entries[i].MatchAnyPlusfin = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "ace-rule/match-any/pluspsh"); !data.Entries[i].MatchAnyPluspsh.IsNull() {
+ if value.Exists() {
+ data.Entries[i].MatchAnyPluspsh = types.BoolValue(true)
+ } else {
+ data.Entries[i].MatchAnyPluspsh = types.BoolValue(false)
+ }
+ } else {
+ data.Entries[i].MatchAnyPluspsh = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "ace-rule/match-any/plusrst"); !data.Entries[i].MatchAnyPlusrst.IsNull() {
+ if value.Exists() {
+ data.Entries[i].MatchAnyPlusrst = types.BoolValue(true)
+ } else {
+ data.Entries[i].MatchAnyPlusrst = types.BoolValue(false)
+ }
+ } else {
+ data.Entries[i].MatchAnyPlusrst = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "ace-rule/match-any/plussyn"); !data.Entries[i].MatchAnyPlussyn.IsNull() {
+ if value.Exists() {
+ data.Entries[i].MatchAnyPlussyn = types.BoolValue(true)
+ } else {
+ data.Entries[i].MatchAnyPlussyn = types.BoolValue(false)
+ }
+ } else {
+ data.Entries[i].MatchAnyPlussyn = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "ace-rule/match-any/plusurg"); !data.Entries[i].MatchAnyPlusurg.IsNull() {
+ if value.Exists() {
+ data.Entries[i].MatchAnyPlusurg = types.BoolValue(true)
+ } else {
+ data.Entries[i].MatchAnyPlusurg = types.BoolValue(false)
+ }
+ } else {
+ data.Entries[i].MatchAnyPlusurg = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "ace-rule/match-any/minusack"); !data.Entries[i].MatchAnyMinusack.IsNull() {
+ if value.Exists() {
+ data.Entries[i].MatchAnyMinusack = types.BoolValue(true)
+ } else {
+ data.Entries[i].MatchAnyMinusack = types.BoolValue(false)
+ }
+ } else {
+ data.Entries[i].MatchAnyMinusack = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "ace-rule/match-any/minusfin"); !data.Entries[i].MatchAnyMinusfin.IsNull() {
+ if value.Exists() {
+ data.Entries[i].MatchAnyMinusfin = types.BoolValue(true)
+ } else {
+ data.Entries[i].MatchAnyMinusfin = types.BoolValue(false)
+ }
+ } else {
+ data.Entries[i].MatchAnyMinusfin = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "ace-rule/match-any/minuspsh"); !data.Entries[i].MatchAnyMinuspsh.IsNull() {
+ if value.Exists() {
+ data.Entries[i].MatchAnyMinuspsh = types.BoolValue(true)
+ } else {
+ data.Entries[i].MatchAnyMinuspsh = types.BoolValue(false)
+ }
+ } else {
+ data.Entries[i].MatchAnyMinuspsh = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "ace-rule/match-any/minusrst"); !data.Entries[i].MatchAnyMinusrst.IsNull() {
+ if value.Exists() {
+ data.Entries[i].MatchAnyMinusrst = types.BoolValue(true)
+ } else {
+ data.Entries[i].MatchAnyMinusrst = types.BoolValue(false)
+ }
+ } else {
+ data.Entries[i].MatchAnyMinusrst = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "ace-rule/match-any/minussyn"); !data.Entries[i].MatchAnyMinussyn.IsNull() {
+ if value.Exists() {
+ data.Entries[i].MatchAnyMinussyn = types.BoolValue(true)
+ } else {
+ data.Entries[i].MatchAnyMinussyn = types.BoolValue(false)
+ }
+ } else {
+ data.Entries[i].MatchAnyMinussyn = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "ace-rule/match-any/minusurg"); !data.Entries[i].MatchAnyMinusurg.IsNull() {
+ if value.Exists() {
+ data.Entries[i].MatchAnyMinusurg = types.BoolValue(true)
+ } else {
+ data.Entries[i].MatchAnyMinusurg = types.BoolValue(false)
+ }
+ } else {
+ data.Entries[i].MatchAnyMinusurg = types.BoolNull()
+ }
+ }
+}
+
+// End of section. //template:end updateFromBodyXML
+
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBody
+
+func (data *AccessListRoleBased) fromBody(ctx context.Context, res gjson.Result) {
+ prefix := helpers.LastElement(data.getPath()) + "."
+ if res.Get(helpers.LastElement(data.getPath())).IsArray() {
+ prefix += "0."
+ }
+ if value := res.Get(prefix + "access-list-seq-rule"); value.Exists() {
+ data.Entries = make([]AccessListRoleBasedEntries, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := AccessListRoleBasedEntries{}
+ if cValue := v.Get("sequence"); cValue.Exists() {
+ item.Sequence = types.Int64Value(cValue.Int())
+ }
+ if cValue := v.Get("remark"); cValue.Exists() {
+ item.Remark = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("ace-rule.action"); cValue.Exists() {
+ item.AceRuleAction = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("ace-rule.protocol"); cValue.Exists() {
+ item.AceRuleProtocol = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("ace-rule.ack"); cValue.Exists() {
+ item.Ack = types.BoolValue(true)
+ } else {
+ item.Ack = types.BoolValue(false)
+ }
+ if cValue := v.Get("ace-rule.fin"); cValue.Exists() {
+ item.Fin = types.BoolValue(true)
+ } else {
+ item.Fin = types.BoolValue(false)
+ }
+ if cValue := v.Get("ace-rule.psh"); cValue.Exists() {
+ item.Psh = types.BoolValue(true)
+ } else {
+ item.Psh = types.BoolValue(false)
+ }
+ if cValue := v.Get("ace-rule.rst"); cValue.Exists() {
+ item.Rst = types.BoolValue(true)
+ } else {
+ item.Rst = types.BoolValue(false)
+ }
+ if cValue := v.Get("ace-rule.syn"); cValue.Exists() {
+ item.Syn = types.BoolValue(true)
+ } else {
+ item.Syn = types.BoolValue(false)
+ }
+ if cValue := v.Get("ace-rule.urg"); cValue.Exists() {
+ item.Urg = types.BoolValue(true)
+ } else {
+ item.Urg = types.BoolValue(false)
+ }
+ if cValue := v.Get("ace-rule.established"); cValue.Exists() {
+ item.Established = types.BoolValue(true)
+ } else {
+ item.Established = types.BoolValue(false)
+ }
+ if cValue := v.Get("ace-rule.dscp"); cValue.Exists() {
+ item.Dscp = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("ace-rule.fragments"); cValue.Exists() {
+ item.Fragments = types.BoolValue(true)
+ } else {
+ item.Fragments = types.BoolValue(false)
+ }
+ if cValue := v.Get("ace-rule.option"); cValue.Exists() {
+ item.Option = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("ace-rule.precedence"); cValue.Exists() {
+ item.Precedence = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("ace-rule.time-range"); cValue.Exists() {
+ item.TimeRange = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("ace-rule.tos"); cValue.Exists() {
+ item.Tos = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("ace-rule.log"); cValue.Exists() {
+ item.Log = types.BoolValue(true)
+ } else {
+ item.Log = types.BoolValue(false)
+ }
+ if cValue := v.Get("ace-rule.log-input"); cValue.Exists() {
+ item.LogInput = types.BoolValue(true)
+ } else {
+ item.LogInput = types.BoolValue(false)
+ }
+ if cValue := v.Get("ace-rule.match-all.plusack"); cValue.Exists() {
+ item.MatchAllPlusack = types.BoolValue(true)
+ } else {
+ item.MatchAllPlusack = types.BoolValue(false)
+ }
+ if cValue := v.Get("ace-rule.match-all.plusfin"); cValue.Exists() {
+ item.MatchAllPlusfin = types.BoolValue(true)
+ } else {
+ item.MatchAllPlusfin = types.BoolValue(false)
+ }
+ if cValue := v.Get("ace-rule.match-all.pluspsh"); cValue.Exists() {
+ item.MatchAllPluspsh = types.BoolValue(true)
+ } else {
+ item.MatchAllPluspsh = types.BoolValue(false)
+ }
+ if cValue := v.Get("ace-rule.match-all.plusrst"); cValue.Exists() {
+ item.MatchAllPlusrst = types.BoolValue(true)
+ } else {
+ item.MatchAllPlusrst = types.BoolValue(false)
+ }
+ if cValue := v.Get("ace-rule.match-all.plussyn"); cValue.Exists() {
+ item.MatchAllPlussyn = types.BoolValue(true)
+ } else {
+ item.MatchAllPlussyn = types.BoolValue(false)
+ }
+ if cValue := v.Get("ace-rule.match-all.plusurg"); cValue.Exists() {
+ item.MatchAllPlusurg = types.BoolValue(true)
+ } else {
+ item.MatchAllPlusurg = types.BoolValue(false)
+ }
+ if cValue := v.Get("ace-rule.match-all.minusack"); cValue.Exists() {
+ item.MatchAllMinusack = types.BoolValue(true)
+ } else {
+ item.MatchAllMinusack = types.BoolValue(false)
+ }
+ if cValue := v.Get("ace-rule.match-all.minusfin"); cValue.Exists() {
+ item.MatchAllMinusfin = types.BoolValue(true)
+ } else {
+ item.MatchAllMinusfin = types.BoolValue(false)
+ }
+ if cValue := v.Get("ace-rule.match-all.minuspsh"); cValue.Exists() {
+ item.MatchAllMinuspsh = types.BoolValue(true)
+ } else {
+ item.MatchAllMinuspsh = types.BoolValue(false)
+ }
+ if cValue := v.Get("ace-rule.match-all.minusrst"); cValue.Exists() {
+ item.MatchAllMinusrst = types.BoolValue(true)
+ } else {
+ item.MatchAllMinusrst = types.BoolValue(false)
+ }
+ if cValue := v.Get("ace-rule.match-all.minussyn"); cValue.Exists() {
+ item.MatchAllMinussyn = types.BoolValue(true)
+ } else {
+ item.MatchAllMinussyn = types.BoolValue(false)
+ }
+ if cValue := v.Get("ace-rule.match-all.minusurg"); cValue.Exists() {
+ item.MatchAllMinusurg = types.BoolValue(true)
+ } else {
+ item.MatchAllMinusurg = types.BoolValue(false)
+ }
+ if cValue := v.Get("ace-rule.match-any.plusack"); cValue.Exists() {
+ item.MatchAnyPlusack = types.BoolValue(true)
+ } else {
+ item.MatchAnyPlusack = types.BoolValue(false)
+ }
+ if cValue := v.Get("ace-rule.match-any.plusfin"); cValue.Exists() {
+ item.MatchAnyPlusfin = types.BoolValue(true)
+ } else {
+ item.MatchAnyPlusfin = types.BoolValue(false)
+ }
+ if cValue := v.Get("ace-rule.match-any.pluspsh"); cValue.Exists() {
+ item.MatchAnyPluspsh = types.BoolValue(true)
+ } else {
+ item.MatchAnyPluspsh = types.BoolValue(false)
+ }
+ if cValue := v.Get("ace-rule.match-any.plusrst"); cValue.Exists() {
+ item.MatchAnyPlusrst = types.BoolValue(true)
+ } else {
+ item.MatchAnyPlusrst = types.BoolValue(false)
+ }
+ if cValue := v.Get("ace-rule.match-any.plussyn"); cValue.Exists() {
+ item.MatchAnyPlussyn = types.BoolValue(true)
+ } else {
+ item.MatchAnyPlussyn = types.BoolValue(false)
+ }
+ if cValue := v.Get("ace-rule.match-any.plusurg"); cValue.Exists() {
+ item.MatchAnyPlusurg = types.BoolValue(true)
+ } else {
+ item.MatchAnyPlusurg = types.BoolValue(false)
+ }
+ if cValue := v.Get("ace-rule.match-any.minusack"); cValue.Exists() {
+ item.MatchAnyMinusack = types.BoolValue(true)
+ } else {
+ item.MatchAnyMinusack = types.BoolValue(false)
+ }
+ if cValue := v.Get("ace-rule.match-any.minusfin"); cValue.Exists() {
+ item.MatchAnyMinusfin = types.BoolValue(true)
+ } else {
+ item.MatchAnyMinusfin = types.BoolValue(false)
+ }
+ if cValue := v.Get("ace-rule.match-any.minuspsh"); cValue.Exists() {
+ item.MatchAnyMinuspsh = types.BoolValue(true)
+ } else {
+ item.MatchAnyMinuspsh = types.BoolValue(false)
+ }
+ if cValue := v.Get("ace-rule.match-any.minusrst"); cValue.Exists() {
+ item.MatchAnyMinusrst = types.BoolValue(true)
+ } else {
+ item.MatchAnyMinusrst = types.BoolValue(false)
+ }
+ if cValue := v.Get("ace-rule.match-any.minussyn"); cValue.Exists() {
+ item.MatchAnyMinussyn = types.BoolValue(true)
+ } else {
+ item.MatchAnyMinussyn = types.BoolValue(false)
+ }
+ if cValue := v.Get("ace-rule.match-any.minusurg"); cValue.Exists() {
+ item.MatchAnyMinusurg = types.BoolValue(true)
+ } else {
+ item.MatchAnyMinusurg = types.BoolValue(false)
+ }
+ data.Entries = append(data.Entries, item)
+ return true
+ })
+ }
+}
+
+// End of section. //template:end fromBody
+
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyData
+
+func (data *AccessListRoleBasedData) fromBody(ctx context.Context, res gjson.Result) {
+ prefix := helpers.LastElement(data.getPath()) + "."
+ if res.Get(helpers.LastElement(data.getPath())).IsArray() {
+ prefix += "0."
+ }
+ if value := res.Get(prefix + "access-list-seq-rule"); value.Exists() {
+ data.Entries = make([]AccessListRoleBasedEntries, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := AccessListRoleBasedEntries{}
+ if cValue := v.Get("sequence"); cValue.Exists() {
+ item.Sequence = types.Int64Value(cValue.Int())
+ }
+ if cValue := v.Get("remark"); cValue.Exists() {
+ item.Remark = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("ace-rule.action"); cValue.Exists() {
+ item.AceRuleAction = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("ace-rule.protocol"); cValue.Exists() {
+ item.AceRuleProtocol = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("ace-rule.ack"); cValue.Exists() {
+ item.Ack = types.BoolValue(true)
+ } else {
+ item.Ack = types.BoolValue(false)
+ }
+ if cValue := v.Get("ace-rule.fin"); cValue.Exists() {
+ item.Fin = types.BoolValue(true)
+ } else {
+ item.Fin = types.BoolValue(false)
+ }
+ if cValue := v.Get("ace-rule.psh"); cValue.Exists() {
+ item.Psh = types.BoolValue(true)
+ } else {
+ item.Psh = types.BoolValue(false)
+ }
+ if cValue := v.Get("ace-rule.rst"); cValue.Exists() {
+ item.Rst = types.BoolValue(true)
+ } else {
+ item.Rst = types.BoolValue(false)
+ }
+ if cValue := v.Get("ace-rule.syn"); cValue.Exists() {
+ item.Syn = types.BoolValue(true)
+ } else {
+ item.Syn = types.BoolValue(false)
+ }
+ if cValue := v.Get("ace-rule.urg"); cValue.Exists() {
+ item.Urg = types.BoolValue(true)
+ } else {
+ item.Urg = types.BoolValue(false)
+ }
+ if cValue := v.Get("ace-rule.established"); cValue.Exists() {
+ item.Established = types.BoolValue(true)
+ } else {
+ item.Established = types.BoolValue(false)
+ }
+ if cValue := v.Get("ace-rule.dscp"); cValue.Exists() {
+ item.Dscp = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("ace-rule.fragments"); cValue.Exists() {
+ item.Fragments = types.BoolValue(true)
+ } else {
+ item.Fragments = types.BoolValue(false)
+ }
+ if cValue := v.Get("ace-rule.option"); cValue.Exists() {
+ item.Option = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("ace-rule.precedence"); cValue.Exists() {
+ item.Precedence = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("ace-rule.time-range"); cValue.Exists() {
+ item.TimeRange = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("ace-rule.tos"); cValue.Exists() {
+ item.Tos = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("ace-rule.log"); cValue.Exists() {
+ item.Log = types.BoolValue(true)
+ } else {
+ item.Log = types.BoolValue(false)
+ }
+ if cValue := v.Get("ace-rule.log-input"); cValue.Exists() {
+ item.LogInput = types.BoolValue(true)
+ } else {
+ item.LogInput = types.BoolValue(false)
+ }
+ if cValue := v.Get("ace-rule.match-all.plusack"); cValue.Exists() {
+ item.MatchAllPlusack = types.BoolValue(true)
+ } else {
+ item.MatchAllPlusack = types.BoolValue(false)
+ }
+ if cValue := v.Get("ace-rule.match-all.plusfin"); cValue.Exists() {
+ item.MatchAllPlusfin = types.BoolValue(true)
+ } else {
+ item.MatchAllPlusfin = types.BoolValue(false)
+ }
+ if cValue := v.Get("ace-rule.match-all.pluspsh"); cValue.Exists() {
+ item.MatchAllPluspsh = types.BoolValue(true)
+ } else {
+ item.MatchAllPluspsh = types.BoolValue(false)
+ }
+ if cValue := v.Get("ace-rule.match-all.plusrst"); cValue.Exists() {
+ item.MatchAllPlusrst = types.BoolValue(true)
+ } else {
+ item.MatchAllPlusrst = types.BoolValue(false)
+ }
+ if cValue := v.Get("ace-rule.match-all.plussyn"); cValue.Exists() {
+ item.MatchAllPlussyn = types.BoolValue(true)
+ } else {
+ item.MatchAllPlussyn = types.BoolValue(false)
+ }
+ if cValue := v.Get("ace-rule.match-all.plusurg"); cValue.Exists() {
+ item.MatchAllPlusurg = types.BoolValue(true)
+ } else {
+ item.MatchAllPlusurg = types.BoolValue(false)
+ }
+ if cValue := v.Get("ace-rule.match-all.minusack"); cValue.Exists() {
+ item.MatchAllMinusack = types.BoolValue(true)
+ } else {
+ item.MatchAllMinusack = types.BoolValue(false)
+ }
+ if cValue := v.Get("ace-rule.match-all.minusfin"); cValue.Exists() {
+ item.MatchAllMinusfin = types.BoolValue(true)
+ } else {
+ item.MatchAllMinusfin = types.BoolValue(false)
+ }
+ if cValue := v.Get("ace-rule.match-all.minuspsh"); cValue.Exists() {
+ item.MatchAllMinuspsh = types.BoolValue(true)
+ } else {
+ item.MatchAllMinuspsh = types.BoolValue(false)
+ }
+ if cValue := v.Get("ace-rule.match-all.minusrst"); cValue.Exists() {
+ item.MatchAllMinusrst = types.BoolValue(true)
+ } else {
+ item.MatchAllMinusrst = types.BoolValue(false)
+ }
+ if cValue := v.Get("ace-rule.match-all.minussyn"); cValue.Exists() {
+ item.MatchAllMinussyn = types.BoolValue(true)
+ } else {
+ item.MatchAllMinussyn = types.BoolValue(false)
+ }
+ if cValue := v.Get("ace-rule.match-all.minusurg"); cValue.Exists() {
+ item.MatchAllMinusurg = types.BoolValue(true)
+ } else {
+ item.MatchAllMinusurg = types.BoolValue(false)
+ }
+ if cValue := v.Get("ace-rule.match-any.plusack"); cValue.Exists() {
+ item.MatchAnyPlusack = types.BoolValue(true)
+ } else {
+ item.MatchAnyPlusack = types.BoolValue(false)
+ }
+ if cValue := v.Get("ace-rule.match-any.plusfin"); cValue.Exists() {
+ item.MatchAnyPlusfin = types.BoolValue(true)
+ } else {
+ item.MatchAnyPlusfin = types.BoolValue(false)
+ }
+ if cValue := v.Get("ace-rule.match-any.pluspsh"); cValue.Exists() {
+ item.MatchAnyPluspsh = types.BoolValue(true)
+ } else {
+ item.MatchAnyPluspsh = types.BoolValue(false)
+ }
+ if cValue := v.Get("ace-rule.match-any.plusrst"); cValue.Exists() {
+ item.MatchAnyPlusrst = types.BoolValue(true)
+ } else {
+ item.MatchAnyPlusrst = types.BoolValue(false)
+ }
+ if cValue := v.Get("ace-rule.match-any.plussyn"); cValue.Exists() {
+ item.MatchAnyPlussyn = types.BoolValue(true)
+ } else {
+ item.MatchAnyPlussyn = types.BoolValue(false)
+ }
+ if cValue := v.Get("ace-rule.match-any.plusurg"); cValue.Exists() {
+ item.MatchAnyPlusurg = types.BoolValue(true)
+ } else {
+ item.MatchAnyPlusurg = types.BoolValue(false)
+ }
+ if cValue := v.Get("ace-rule.match-any.minusack"); cValue.Exists() {
+ item.MatchAnyMinusack = types.BoolValue(true)
+ } else {
+ item.MatchAnyMinusack = types.BoolValue(false)
+ }
+ if cValue := v.Get("ace-rule.match-any.minusfin"); cValue.Exists() {
+ item.MatchAnyMinusfin = types.BoolValue(true)
+ } else {
+ item.MatchAnyMinusfin = types.BoolValue(false)
+ }
+ if cValue := v.Get("ace-rule.match-any.minuspsh"); cValue.Exists() {
+ item.MatchAnyMinuspsh = types.BoolValue(true)
+ } else {
+ item.MatchAnyMinuspsh = types.BoolValue(false)
+ }
+ if cValue := v.Get("ace-rule.match-any.minusrst"); cValue.Exists() {
+ item.MatchAnyMinusrst = types.BoolValue(true)
+ } else {
+ item.MatchAnyMinusrst = types.BoolValue(false)
}
- } else {
- data.Entries[i].MatchAnyMinussyn = types.BoolNull()
- }
- if value := r.Get("ace-rule.match-any.minusurg"); !data.Entries[i].MatchAnyMinusurg.IsNull() {
- if value.Exists() {
- data.Entries[i].MatchAnyMinusurg = types.BoolValue(true)
+ if cValue := v.Get("ace-rule.match-any.minussyn"); cValue.Exists() {
+ item.MatchAnyMinussyn = types.BoolValue(true)
} else {
- data.Entries[i].MatchAnyMinusurg = types.BoolValue(false)
+ item.MatchAnyMinussyn = types.BoolValue(false)
}
- } else {
- data.Entries[i].MatchAnyMinusurg = types.BoolNull()
- }
+ if cValue := v.Get("ace-rule.match-any.minusurg"); cValue.Exists() {
+ item.MatchAnyMinusurg = types.BoolValue(true)
+ } else {
+ item.MatchAnyMinusurg = types.BoolValue(false)
+ }
+ data.Entries = append(data.Entries, item)
+ return true
+ })
}
}
-// End of section. //template:end updateFromBody
+// End of section. //template:end fromBodyData
-// Section below is generated&owned by "gen/generator.go". //template:begin fromBody
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyXML
-func (data *AccessListRoleBased) fromBody(ctx context.Context, res gjson.Result) {
- prefix := helpers.LastElement(data.getPath()) + "."
- if res.Get(helpers.LastElement(data.getPath())).IsArray() {
- prefix += "0."
- }
- if value := res.Get(prefix + "access-list-seq-rule"); value.Exists() {
+func (data *AccessListRoleBased) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/access-list-seq-rule"); value.Exists() {
data.Entries = make([]AccessListRoleBasedEntries, 0)
- value.ForEach(func(k, v gjson.Result) bool {
+ value.ForEach(func(_ int, v xmldot.Result) bool {
item := AccessListRoleBasedEntries{}
- if cValue := v.Get("sequence"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "sequence"); cValue.Exists() {
item.Sequence = types.Int64Value(cValue.Int())
}
- if cValue := v.Get("remark"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "remark"); cValue.Exists() {
item.Remark = types.StringValue(cValue.String())
}
- if cValue := v.Get("ace-rule.action"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ace-rule/action"); cValue.Exists() {
item.AceRuleAction = types.StringValue(cValue.String())
}
- if cValue := v.Get("ace-rule.protocol"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ace-rule/protocol"); cValue.Exists() {
item.AceRuleProtocol = types.StringValue(cValue.String())
}
- if cValue := v.Get("ace-rule.ack"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ace-rule/ack"); cValue.Exists() {
item.Ack = types.BoolValue(true)
} else {
item.Ack = types.BoolValue(false)
}
- if cValue := v.Get("ace-rule.fin"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ace-rule/fin"); cValue.Exists() {
item.Fin = types.BoolValue(true)
} else {
item.Fin = types.BoolValue(false)
}
- if cValue := v.Get("ace-rule.psh"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ace-rule/psh"); cValue.Exists() {
item.Psh = types.BoolValue(true)
} else {
item.Psh = types.BoolValue(false)
}
- if cValue := v.Get("ace-rule.rst"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ace-rule/rst"); cValue.Exists() {
item.Rst = types.BoolValue(true)
} else {
item.Rst = types.BoolValue(false)
}
- if cValue := v.Get("ace-rule.syn"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ace-rule/syn"); cValue.Exists() {
item.Syn = types.BoolValue(true)
} else {
item.Syn = types.BoolValue(false)
}
- if cValue := v.Get("ace-rule.urg"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ace-rule/urg"); cValue.Exists() {
item.Urg = types.BoolValue(true)
} else {
item.Urg = types.BoolValue(false)
}
- if cValue := v.Get("ace-rule.established"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ace-rule/established"); cValue.Exists() {
item.Established = types.BoolValue(true)
} else {
item.Established = types.BoolValue(false)
}
- if cValue := v.Get("ace-rule.dscp"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ace-rule/dscp"); cValue.Exists() {
item.Dscp = types.StringValue(cValue.String())
}
- if cValue := v.Get("ace-rule.fragments"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ace-rule/fragments"); cValue.Exists() {
item.Fragments = types.BoolValue(true)
} else {
item.Fragments = types.BoolValue(false)
}
- if cValue := v.Get("ace-rule.option"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ace-rule/option"); cValue.Exists() {
item.Option = types.StringValue(cValue.String())
}
- if cValue := v.Get("ace-rule.precedence"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ace-rule/precedence"); cValue.Exists() {
item.Precedence = types.StringValue(cValue.String())
}
- if cValue := v.Get("ace-rule.time-range"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ace-rule/time-range"); cValue.Exists() {
item.TimeRange = types.StringValue(cValue.String())
}
- if cValue := v.Get("ace-rule.tos"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ace-rule/tos"); cValue.Exists() {
item.Tos = types.StringValue(cValue.String())
}
- if cValue := v.Get("ace-rule.log"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ace-rule/log"); cValue.Exists() {
item.Log = types.BoolValue(true)
} else {
item.Log = types.BoolValue(false)
}
- if cValue := v.Get("ace-rule.log-input"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ace-rule/log-input"); cValue.Exists() {
item.LogInput = types.BoolValue(true)
} else {
item.LogInput = types.BoolValue(false)
}
- if cValue := v.Get("ace-rule.match-all.plusack"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ace-rule/match-all/plusack"); cValue.Exists() {
item.MatchAllPlusack = types.BoolValue(true)
} else {
item.MatchAllPlusack = types.BoolValue(false)
}
- if cValue := v.Get("ace-rule.match-all.plusfin"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ace-rule/match-all/plusfin"); cValue.Exists() {
item.MatchAllPlusfin = types.BoolValue(true)
} else {
item.MatchAllPlusfin = types.BoolValue(false)
}
- if cValue := v.Get("ace-rule.match-all.pluspsh"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ace-rule/match-all/pluspsh"); cValue.Exists() {
item.MatchAllPluspsh = types.BoolValue(true)
} else {
item.MatchAllPluspsh = types.BoolValue(false)
}
- if cValue := v.Get("ace-rule.match-all.plusrst"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ace-rule/match-all/plusrst"); cValue.Exists() {
item.MatchAllPlusrst = types.BoolValue(true)
} else {
item.MatchAllPlusrst = types.BoolValue(false)
}
- if cValue := v.Get("ace-rule.match-all.plussyn"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ace-rule/match-all/plussyn"); cValue.Exists() {
item.MatchAllPlussyn = types.BoolValue(true)
} else {
item.MatchAllPlussyn = types.BoolValue(false)
}
- if cValue := v.Get("ace-rule.match-all.plusurg"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ace-rule/match-all/plusurg"); cValue.Exists() {
item.MatchAllPlusurg = types.BoolValue(true)
} else {
item.MatchAllPlusurg = types.BoolValue(false)
}
- if cValue := v.Get("ace-rule.match-all.minusack"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ace-rule/match-all/minusack"); cValue.Exists() {
item.MatchAllMinusack = types.BoolValue(true)
} else {
item.MatchAllMinusack = types.BoolValue(false)
}
- if cValue := v.Get("ace-rule.match-all.minusfin"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ace-rule/match-all/minusfin"); cValue.Exists() {
item.MatchAllMinusfin = types.BoolValue(true)
} else {
item.MatchAllMinusfin = types.BoolValue(false)
}
- if cValue := v.Get("ace-rule.match-all.minuspsh"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ace-rule/match-all/minuspsh"); cValue.Exists() {
item.MatchAllMinuspsh = types.BoolValue(true)
} else {
item.MatchAllMinuspsh = types.BoolValue(false)
}
- if cValue := v.Get("ace-rule.match-all.minusrst"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ace-rule/match-all/minusrst"); cValue.Exists() {
item.MatchAllMinusrst = types.BoolValue(true)
} else {
item.MatchAllMinusrst = types.BoolValue(false)
}
- if cValue := v.Get("ace-rule.match-all.minussyn"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ace-rule/match-all/minussyn"); cValue.Exists() {
item.MatchAllMinussyn = types.BoolValue(true)
} else {
item.MatchAllMinussyn = types.BoolValue(false)
}
- if cValue := v.Get("ace-rule.match-all.minusurg"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ace-rule/match-all/minusurg"); cValue.Exists() {
item.MatchAllMinusurg = types.BoolValue(true)
} else {
item.MatchAllMinusurg = types.BoolValue(false)
}
- if cValue := v.Get("ace-rule.match-any.plusack"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ace-rule/match-any/plusack"); cValue.Exists() {
item.MatchAnyPlusack = types.BoolValue(true)
} else {
item.MatchAnyPlusack = types.BoolValue(false)
}
- if cValue := v.Get("ace-rule.match-any.plusfin"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ace-rule/match-any/plusfin"); cValue.Exists() {
item.MatchAnyPlusfin = types.BoolValue(true)
} else {
item.MatchAnyPlusfin = types.BoolValue(false)
}
- if cValue := v.Get("ace-rule.match-any.pluspsh"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ace-rule/match-any/pluspsh"); cValue.Exists() {
item.MatchAnyPluspsh = types.BoolValue(true)
} else {
item.MatchAnyPluspsh = types.BoolValue(false)
}
- if cValue := v.Get("ace-rule.match-any.plusrst"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ace-rule/match-any/plusrst"); cValue.Exists() {
item.MatchAnyPlusrst = types.BoolValue(true)
} else {
item.MatchAnyPlusrst = types.BoolValue(false)
}
- if cValue := v.Get("ace-rule.match-any.plussyn"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ace-rule/match-any/plussyn"); cValue.Exists() {
item.MatchAnyPlussyn = types.BoolValue(true)
} else {
item.MatchAnyPlussyn = types.BoolValue(false)
}
- if cValue := v.Get("ace-rule.match-any.plusurg"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ace-rule/match-any/plusurg"); cValue.Exists() {
item.MatchAnyPlusurg = types.BoolValue(true)
} else {
item.MatchAnyPlusurg = types.BoolValue(false)
}
- if cValue := v.Get("ace-rule.match-any.minusack"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ace-rule/match-any/minusack"); cValue.Exists() {
item.MatchAnyMinusack = types.BoolValue(true)
} else {
item.MatchAnyMinusack = types.BoolValue(false)
}
- if cValue := v.Get("ace-rule.match-any.minusfin"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ace-rule/match-any/minusfin"); cValue.Exists() {
item.MatchAnyMinusfin = types.BoolValue(true)
} else {
item.MatchAnyMinusfin = types.BoolValue(false)
}
- if cValue := v.Get("ace-rule.match-any.minuspsh"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ace-rule/match-any/minuspsh"); cValue.Exists() {
item.MatchAnyMinuspsh = types.BoolValue(true)
} else {
item.MatchAnyMinuspsh = types.BoolValue(false)
}
- if cValue := v.Get("ace-rule.match-any.minusrst"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ace-rule/match-any/minusrst"); cValue.Exists() {
item.MatchAnyMinusrst = types.BoolValue(true)
} else {
item.MatchAnyMinusrst = types.BoolValue(false)
}
- if cValue := v.Get("ace-rule.match-any.minussyn"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ace-rule/match-any/minussyn"); cValue.Exists() {
item.MatchAnyMinussyn = types.BoolValue(true)
} else {
item.MatchAnyMinussyn = types.BoolValue(false)
}
- if cValue := v.Get("ace-rule.match-any.minusurg"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ace-rule/match-any/minusurg"); cValue.Exists() {
item.MatchAnyMinusurg = types.BoolValue(true)
} else {
item.MatchAnyMinusurg = types.BoolValue(false)
@@ -941,212 +2059,208 @@ func (data *AccessListRoleBased) fromBody(ctx context.Context, res gjson.Result)
}
}
-// End of section. //template:end fromBody
+// End of section. //template:end fromBodyXML
-// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyData
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyDataXML
-func (data *AccessListRoleBasedData) fromBody(ctx context.Context, res gjson.Result) {
- prefix := helpers.LastElement(data.getPath()) + "."
- if res.Get(helpers.LastElement(data.getPath())).IsArray() {
- prefix += "0."
- }
- if value := res.Get(prefix + "access-list-seq-rule"); value.Exists() {
+func (data *AccessListRoleBasedData) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/access-list-seq-rule"); value.Exists() {
data.Entries = make([]AccessListRoleBasedEntries, 0)
- value.ForEach(func(k, v gjson.Result) bool {
+ value.ForEach(func(_ int, v xmldot.Result) bool {
item := AccessListRoleBasedEntries{}
- if cValue := v.Get("sequence"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "sequence"); cValue.Exists() {
item.Sequence = types.Int64Value(cValue.Int())
}
- if cValue := v.Get("remark"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "remark"); cValue.Exists() {
item.Remark = types.StringValue(cValue.String())
}
- if cValue := v.Get("ace-rule.action"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ace-rule/action"); cValue.Exists() {
item.AceRuleAction = types.StringValue(cValue.String())
}
- if cValue := v.Get("ace-rule.protocol"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ace-rule/protocol"); cValue.Exists() {
item.AceRuleProtocol = types.StringValue(cValue.String())
}
- if cValue := v.Get("ace-rule.ack"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ace-rule/ack"); cValue.Exists() {
item.Ack = types.BoolValue(true)
} else {
item.Ack = types.BoolValue(false)
}
- if cValue := v.Get("ace-rule.fin"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ace-rule/fin"); cValue.Exists() {
item.Fin = types.BoolValue(true)
} else {
item.Fin = types.BoolValue(false)
}
- if cValue := v.Get("ace-rule.psh"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ace-rule/psh"); cValue.Exists() {
item.Psh = types.BoolValue(true)
} else {
item.Psh = types.BoolValue(false)
}
- if cValue := v.Get("ace-rule.rst"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ace-rule/rst"); cValue.Exists() {
item.Rst = types.BoolValue(true)
} else {
item.Rst = types.BoolValue(false)
}
- if cValue := v.Get("ace-rule.syn"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ace-rule/syn"); cValue.Exists() {
item.Syn = types.BoolValue(true)
} else {
item.Syn = types.BoolValue(false)
}
- if cValue := v.Get("ace-rule.urg"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ace-rule/urg"); cValue.Exists() {
item.Urg = types.BoolValue(true)
} else {
item.Urg = types.BoolValue(false)
}
- if cValue := v.Get("ace-rule.established"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ace-rule/established"); cValue.Exists() {
item.Established = types.BoolValue(true)
} else {
item.Established = types.BoolValue(false)
}
- if cValue := v.Get("ace-rule.dscp"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ace-rule/dscp"); cValue.Exists() {
item.Dscp = types.StringValue(cValue.String())
}
- if cValue := v.Get("ace-rule.fragments"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ace-rule/fragments"); cValue.Exists() {
item.Fragments = types.BoolValue(true)
} else {
item.Fragments = types.BoolValue(false)
}
- if cValue := v.Get("ace-rule.option"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ace-rule/option"); cValue.Exists() {
item.Option = types.StringValue(cValue.String())
}
- if cValue := v.Get("ace-rule.precedence"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ace-rule/precedence"); cValue.Exists() {
item.Precedence = types.StringValue(cValue.String())
}
- if cValue := v.Get("ace-rule.time-range"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ace-rule/time-range"); cValue.Exists() {
item.TimeRange = types.StringValue(cValue.String())
}
- if cValue := v.Get("ace-rule.tos"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ace-rule/tos"); cValue.Exists() {
item.Tos = types.StringValue(cValue.String())
}
- if cValue := v.Get("ace-rule.log"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ace-rule/log"); cValue.Exists() {
item.Log = types.BoolValue(true)
} else {
item.Log = types.BoolValue(false)
}
- if cValue := v.Get("ace-rule.log-input"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ace-rule/log-input"); cValue.Exists() {
item.LogInput = types.BoolValue(true)
} else {
item.LogInput = types.BoolValue(false)
}
- if cValue := v.Get("ace-rule.match-all.plusack"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ace-rule/match-all/plusack"); cValue.Exists() {
item.MatchAllPlusack = types.BoolValue(true)
} else {
item.MatchAllPlusack = types.BoolValue(false)
}
- if cValue := v.Get("ace-rule.match-all.plusfin"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ace-rule/match-all/plusfin"); cValue.Exists() {
item.MatchAllPlusfin = types.BoolValue(true)
} else {
item.MatchAllPlusfin = types.BoolValue(false)
}
- if cValue := v.Get("ace-rule.match-all.pluspsh"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ace-rule/match-all/pluspsh"); cValue.Exists() {
item.MatchAllPluspsh = types.BoolValue(true)
} else {
item.MatchAllPluspsh = types.BoolValue(false)
}
- if cValue := v.Get("ace-rule.match-all.plusrst"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ace-rule/match-all/plusrst"); cValue.Exists() {
item.MatchAllPlusrst = types.BoolValue(true)
} else {
item.MatchAllPlusrst = types.BoolValue(false)
}
- if cValue := v.Get("ace-rule.match-all.plussyn"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ace-rule/match-all/plussyn"); cValue.Exists() {
item.MatchAllPlussyn = types.BoolValue(true)
} else {
item.MatchAllPlussyn = types.BoolValue(false)
}
- if cValue := v.Get("ace-rule.match-all.plusurg"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ace-rule/match-all/plusurg"); cValue.Exists() {
item.MatchAllPlusurg = types.BoolValue(true)
} else {
item.MatchAllPlusurg = types.BoolValue(false)
}
- if cValue := v.Get("ace-rule.match-all.minusack"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ace-rule/match-all/minusack"); cValue.Exists() {
item.MatchAllMinusack = types.BoolValue(true)
} else {
item.MatchAllMinusack = types.BoolValue(false)
}
- if cValue := v.Get("ace-rule.match-all.minusfin"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ace-rule/match-all/minusfin"); cValue.Exists() {
item.MatchAllMinusfin = types.BoolValue(true)
} else {
item.MatchAllMinusfin = types.BoolValue(false)
}
- if cValue := v.Get("ace-rule.match-all.minuspsh"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ace-rule/match-all/minuspsh"); cValue.Exists() {
item.MatchAllMinuspsh = types.BoolValue(true)
} else {
item.MatchAllMinuspsh = types.BoolValue(false)
}
- if cValue := v.Get("ace-rule.match-all.minusrst"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ace-rule/match-all/minusrst"); cValue.Exists() {
item.MatchAllMinusrst = types.BoolValue(true)
} else {
item.MatchAllMinusrst = types.BoolValue(false)
}
- if cValue := v.Get("ace-rule.match-all.minussyn"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ace-rule/match-all/minussyn"); cValue.Exists() {
item.MatchAllMinussyn = types.BoolValue(true)
} else {
item.MatchAllMinussyn = types.BoolValue(false)
}
- if cValue := v.Get("ace-rule.match-all.minusurg"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ace-rule/match-all/minusurg"); cValue.Exists() {
item.MatchAllMinusurg = types.BoolValue(true)
} else {
item.MatchAllMinusurg = types.BoolValue(false)
}
- if cValue := v.Get("ace-rule.match-any.plusack"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ace-rule/match-any/plusack"); cValue.Exists() {
item.MatchAnyPlusack = types.BoolValue(true)
} else {
item.MatchAnyPlusack = types.BoolValue(false)
}
- if cValue := v.Get("ace-rule.match-any.plusfin"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ace-rule/match-any/plusfin"); cValue.Exists() {
item.MatchAnyPlusfin = types.BoolValue(true)
} else {
item.MatchAnyPlusfin = types.BoolValue(false)
}
- if cValue := v.Get("ace-rule.match-any.pluspsh"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ace-rule/match-any/pluspsh"); cValue.Exists() {
item.MatchAnyPluspsh = types.BoolValue(true)
} else {
item.MatchAnyPluspsh = types.BoolValue(false)
}
- if cValue := v.Get("ace-rule.match-any.plusrst"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ace-rule/match-any/plusrst"); cValue.Exists() {
item.MatchAnyPlusrst = types.BoolValue(true)
} else {
item.MatchAnyPlusrst = types.BoolValue(false)
}
- if cValue := v.Get("ace-rule.match-any.plussyn"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ace-rule/match-any/plussyn"); cValue.Exists() {
item.MatchAnyPlussyn = types.BoolValue(true)
} else {
item.MatchAnyPlussyn = types.BoolValue(false)
}
- if cValue := v.Get("ace-rule.match-any.plusurg"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ace-rule/match-any/plusurg"); cValue.Exists() {
item.MatchAnyPlusurg = types.BoolValue(true)
} else {
item.MatchAnyPlusurg = types.BoolValue(false)
}
- if cValue := v.Get("ace-rule.match-any.minusack"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ace-rule/match-any/minusack"); cValue.Exists() {
item.MatchAnyMinusack = types.BoolValue(true)
} else {
item.MatchAnyMinusack = types.BoolValue(false)
}
- if cValue := v.Get("ace-rule.match-any.minusfin"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ace-rule/match-any/minusfin"); cValue.Exists() {
item.MatchAnyMinusfin = types.BoolValue(true)
} else {
item.MatchAnyMinusfin = types.BoolValue(false)
}
- if cValue := v.Get("ace-rule.match-any.minuspsh"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ace-rule/match-any/minuspsh"); cValue.Exists() {
item.MatchAnyMinuspsh = types.BoolValue(true)
} else {
item.MatchAnyMinuspsh = types.BoolValue(false)
}
- if cValue := v.Get("ace-rule.match-any.minusrst"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ace-rule/match-any/minusrst"); cValue.Exists() {
item.MatchAnyMinusrst = types.BoolValue(true)
} else {
item.MatchAnyMinusrst = types.BoolValue(false)
}
- if cValue := v.Get("ace-rule.match-any.minussyn"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ace-rule/match-any/minussyn"); cValue.Exists() {
item.MatchAnyMinussyn = types.BoolValue(true)
} else {
item.MatchAnyMinussyn = types.BoolValue(false)
}
- if cValue := v.Get("ace-rule.match-any.minusurg"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ace-rule/match-any/minusurg"); cValue.Exists() {
item.MatchAnyMinusurg = types.BoolValue(true)
} else {
item.MatchAnyMinusurg = types.BoolValue(false)
@@ -1157,7 +2271,7 @@ func (data *AccessListRoleBasedData) fromBody(ctx context.Context, res gjson.Res
}
}
-// End of section. //template:end fromBodyData
+// End of section. //template:end fromBodyDataXML
// Section below is generated&owned by "gen/generator.go". //template:begin getDeletedItems
@@ -1320,6 +2434,172 @@ func (data *AccessListRoleBased) getDeletedItems(ctx context.Context, state Acce
// End of section. //template:end getDeletedItems
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletedItemsXML
+
+func (data *AccessListRoleBased) addDeletedItemsXML(ctx context.Context, state AccessListRoleBased, body string) string {
+ b := netconf.NewBody(body)
+ for i := range state.Entries {
+ stateKeys := [...]string{"sequence"}
+ stateKeyValues := [...]string{strconv.FormatInt(state.Entries[i].Sequence.ValueInt64(), 10)}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.Entries[i].Sequence.ValueInt64()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.Entries {
+ found = true
+ if state.Entries[i].Sequence.ValueInt64() != data.Entries[j].Sequence.ValueInt64() {
+ found = false
+ }
+ if found {
+ if !state.Entries[i].Remark.IsNull() && data.Entries[j].Remark.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/access-list-seq-rule%v/remark", predicates))
+ }
+ if !state.Entries[i].AceRuleAction.IsNull() && data.Entries[j].AceRuleAction.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/access-list-seq-rule%v/ace-rule/action", predicates))
+ }
+ if !state.Entries[i].AceRuleProtocol.IsNull() && data.Entries[j].AceRuleProtocol.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/access-list-seq-rule%v/ace-rule/protocol", predicates))
+ }
+ if !state.Entries[i].Ack.IsNull() && data.Entries[j].Ack.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/access-list-seq-rule%v/ace-rule/ack", predicates))
+ }
+ if !state.Entries[i].Fin.IsNull() && data.Entries[j].Fin.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/access-list-seq-rule%v/ace-rule/fin", predicates))
+ }
+ if !state.Entries[i].Psh.IsNull() && data.Entries[j].Psh.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/access-list-seq-rule%v/ace-rule/psh", predicates))
+ }
+ if !state.Entries[i].Rst.IsNull() && data.Entries[j].Rst.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/access-list-seq-rule%v/ace-rule/rst", predicates))
+ }
+ if !state.Entries[i].Syn.IsNull() && data.Entries[j].Syn.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/access-list-seq-rule%v/ace-rule/syn", predicates))
+ }
+ if !state.Entries[i].Urg.IsNull() && data.Entries[j].Urg.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/access-list-seq-rule%v/ace-rule/urg", predicates))
+ }
+ if !state.Entries[i].Established.IsNull() && data.Entries[j].Established.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/access-list-seq-rule%v/ace-rule/established", predicates))
+ }
+ if !state.Entries[i].Dscp.IsNull() && data.Entries[j].Dscp.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/access-list-seq-rule%v/ace-rule/dscp", predicates))
+ }
+ if !state.Entries[i].Fragments.IsNull() && data.Entries[j].Fragments.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/access-list-seq-rule%v/ace-rule/fragments", predicates))
+ }
+ if !state.Entries[i].Option.IsNull() && data.Entries[j].Option.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/access-list-seq-rule%v/ace-rule/option", predicates))
+ }
+ if !state.Entries[i].Precedence.IsNull() && data.Entries[j].Precedence.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/access-list-seq-rule%v/ace-rule/precedence", predicates))
+ }
+ if !state.Entries[i].TimeRange.IsNull() && data.Entries[j].TimeRange.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/access-list-seq-rule%v/ace-rule/time-range", predicates))
+ }
+ if !state.Entries[i].Tos.IsNull() && data.Entries[j].Tos.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/access-list-seq-rule%v/ace-rule/tos", predicates))
+ }
+ if !state.Entries[i].Log.IsNull() && data.Entries[j].Log.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/access-list-seq-rule%v/ace-rule/log", predicates))
+ }
+ if !state.Entries[i].LogInput.IsNull() && data.Entries[j].LogInput.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/access-list-seq-rule%v/ace-rule/log-input", predicates))
+ }
+ if !state.Entries[i].MatchAllPlusack.IsNull() && data.Entries[j].MatchAllPlusack.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/access-list-seq-rule%v/ace-rule/match-all/plusack", predicates))
+ }
+ if !state.Entries[i].MatchAllPlusfin.IsNull() && data.Entries[j].MatchAllPlusfin.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/access-list-seq-rule%v/ace-rule/match-all/plusfin", predicates))
+ }
+ if !state.Entries[i].MatchAllPluspsh.IsNull() && data.Entries[j].MatchAllPluspsh.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/access-list-seq-rule%v/ace-rule/match-all/pluspsh", predicates))
+ }
+ if !state.Entries[i].MatchAllPlusrst.IsNull() && data.Entries[j].MatchAllPlusrst.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/access-list-seq-rule%v/ace-rule/match-all/plusrst", predicates))
+ }
+ if !state.Entries[i].MatchAllPlussyn.IsNull() && data.Entries[j].MatchAllPlussyn.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/access-list-seq-rule%v/ace-rule/match-all/plussyn", predicates))
+ }
+ if !state.Entries[i].MatchAllPlusurg.IsNull() && data.Entries[j].MatchAllPlusurg.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/access-list-seq-rule%v/ace-rule/match-all/plusurg", predicates))
+ }
+ if !state.Entries[i].MatchAllMinusack.IsNull() && data.Entries[j].MatchAllMinusack.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/access-list-seq-rule%v/ace-rule/match-all/minusack", predicates))
+ }
+ if !state.Entries[i].MatchAllMinusfin.IsNull() && data.Entries[j].MatchAllMinusfin.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/access-list-seq-rule%v/ace-rule/match-all/minusfin", predicates))
+ }
+ if !state.Entries[i].MatchAllMinuspsh.IsNull() && data.Entries[j].MatchAllMinuspsh.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/access-list-seq-rule%v/ace-rule/match-all/minuspsh", predicates))
+ }
+ if !state.Entries[i].MatchAllMinusrst.IsNull() && data.Entries[j].MatchAllMinusrst.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/access-list-seq-rule%v/ace-rule/match-all/minusrst", predicates))
+ }
+ if !state.Entries[i].MatchAllMinussyn.IsNull() && data.Entries[j].MatchAllMinussyn.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/access-list-seq-rule%v/ace-rule/match-all/minussyn", predicates))
+ }
+ if !state.Entries[i].MatchAllMinusurg.IsNull() && data.Entries[j].MatchAllMinusurg.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/access-list-seq-rule%v/ace-rule/match-all/minusurg", predicates))
+ }
+ if !state.Entries[i].MatchAnyPlusack.IsNull() && data.Entries[j].MatchAnyPlusack.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/access-list-seq-rule%v/ace-rule/match-any/plusack", predicates))
+ }
+ if !state.Entries[i].MatchAnyPlusfin.IsNull() && data.Entries[j].MatchAnyPlusfin.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/access-list-seq-rule%v/ace-rule/match-any/plusfin", predicates))
+ }
+ if !state.Entries[i].MatchAnyPluspsh.IsNull() && data.Entries[j].MatchAnyPluspsh.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/access-list-seq-rule%v/ace-rule/match-any/pluspsh", predicates))
+ }
+ if !state.Entries[i].MatchAnyPlusrst.IsNull() && data.Entries[j].MatchAnyPlusrst.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/access-list-seq-rule%v/ace-rule/match-any/plusrst", predicates))
+ }
+ if !state.Entries[i].MatchAnyPlussyn.IsNull() && data.Entries[j].MatchAnyPlussyn.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/access-list-seq-rule%v/ace-rule/match-any/plussyn", predicates))
+ }
+ if !state.Entries[i].MatchAnyPlusurg.IsNull() && data.Entries[j].MatchAnyPlusurg.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/access-list-seq-rule%v/ace-rule/match-any/plusurg", predicates))
+ }
+ if !state.Entries[i].MatchAnyMinusack.IsNull() && data.Entries[j].MatchAnyMinusack.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/access-list-seq-rule%v/ace-rule/match-any/minusack", predicates))
+ }
+ if !state.Entries[i].MatchAnyMinusfin.IsNull() && data.Entries[j].MatchAnyMinusfin.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/access-list-seq-rule%v/ace-rule/match-any/minusfin", predicates))
+ }
+ if !state.Entries[i].MatchAnyMinuspsh.IsNull() && data.Entries[j].MatchAnyMinuspsh.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/access-list-seq-rule%v/ace-rule/match-any/minuspsh", predicates))
+ }
+ if !state.Entries[i].MatchAnyMinusrst.IsNull() && data.Entries[j].MatchAnyMinusrst.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/access-list-seq-rule%v/ace-rule/match-any/minusrst", predicates))
+ }
+ if !state.Entries[i].MatchAnyMinussyn.IsNull() && data.Entries[j].MatchAnyMinussyn.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/access-list-seq-rule%v/ace-rule/match-any/minussyn", predicates))
+ }
+ if !state.Entries[i].MatchAnyMinusurg.IsNull() && data.Entries[j].MatchAnyMinusurg.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/access-list-seq-rule%v/ace-rule/match-any/minusurg", predicates))
+ }
+ break
+ }
+ }
+ if !found {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/access-list-seq-rule%v", predicates))
+ }
+ }
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletedItemsXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin getEmptyLeafsDelete
func (data *AccessListRoleBased) getEmptyLeafsDelete(ctx context.Context) []string {
@@ -1450,3 +2730,23 @@ func (data *AccessListRoleBased) getDeletePaths(ctx context.Context) []string {
}
// End of section. //template:end getDeletePaths
+
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletePathsXML
+
+func (data *AccessListRoleBased) addDeletePathsXML(ctx context.Context, body string) string {
+ b := netconf.NewBody(body)
+ for i := range data.Entries {
+ keys := [...]string{"sequence"}
+ keyValues := [...]string{strconv.FormatInt(data.Entries[i].Sequence.ValueInt64(), 10)}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/access-list-seq-rule%v", predicates))
+ }
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletePathsXML
diff --git a/internal/provider/model_iosxe_access_list_standard.go b/internal/provider/model_iosxe_access_list_standard.go
index e4be5fbb..1eaf7a1d 100644
--- a/internal/provider/model_iosxe_access_list_standard.go
+++ b/internal/provider/model_iosxe_access_list_standard.go
@@ -31,6 +31,9 @@ import (
"github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/types"
+ "github.com/hashicorp/terraform-plugin-log/tflog"
+ "github.com/netascode/go-netconf"
+ "github.com/netascode/xmldot"
"github.com/tidwall/gjson"
"github.com/tidwall/sjson"
)
@@ -89,6 +92,19 @@ func (data AccessListStandard) getPathShort() string {
return matches[1]
}
+// getXPath returns the XPath for NETCONF operations
+func (data AccessListStandard) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/ip/access-list/Cisco-IOS-XE-acl:standard[name=%v]"
+ path = fmt.Sprintf(path, fmt.Sprintf("%v", data.Name.ValueString()))
+ return path
+}
+
+func (data AccessListStandardData) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/ip/access-list/Cisco-IOS-XE-acl:standard[name=%v]"
+ path = fmt.Sprintf(path, fmt.Sprintf("%v", data.Name.ValueString()))
+ return path
+}
+
// End of section. //template:end getPath
// Section below is generated&owned by "gen/generator.go". //template:begin toBody
@@ -152,6 +168,80 @@ func (data AccessListStandard) toBody(ctx context.Context) string {
// End of section. //template:end toBody
+// Section below is generated&owned by "gen/generator.go". //template:begin toBodyXML
+
+func (data AccessListStandard) toBodyXML(ctx context.Context) string {
+ body := netconf.Body{}
+ if !data.Name.IsNull() && !data.Name.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/name", data.Name.ValueString())
+ }
+ if len(data.Entries) > 0 {
+ for _, item := range data.Entries {
+ cBody := netconf.Body{}
+ if !item.Sequence.IsNull() && !item.Sequence.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "sequence", strconv.FormatInt(item.Sequence.ValueInt64(), 10))
+ }
+ if !item.Remark.IsNull() && !item.Remark.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "remark", item.Remark.ValueString())
+ }
+ if !item.DenyPrefix.IsNull() && !item.DenyPrefix.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "deny/std-ace/ipv4-address-prefix", item.DenyPrefix.ValueString())
+ }
+ if !item.DenyPrefixMask.IsNull() && !item.DenyPrefixMask.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "deny/std-ace/mask", item.DenyPrefixMask.ValueString())
+ }
+ if !item.DenyAny.IsNull() && !item.DenyAny.IsUnknown() {
+ if item.DenyAny.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "deny/std-ace/any", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "deny/std-ace/any")
+ }
+ }
+ if !item.DenyHost.IsNull() && !item.DenyHost.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "deny/std-ace/host-address", item.DenyHost.ValueString())
+ }
+ if !item.DenyLog.IsNull() && !item.DenyLog.IsUnknown() {
+ if item.DenyLog.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "deny/std-ace/log", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "deny/std-ace/log")
+ }
+ }
+ if !item.PermitPrefix.IsNull() && !item.PermitPrefix.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "permit/std-ace/ipv4-address-prefix", item.PermitPrefix.ValueString())
+ }
+ if !item.PermitPrefixMask.IsNull() && !item.PermitPrefixMask.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "permit/std-ace/mask", item.PermitPrefixMask.ValueString())
+ }
+ if !item.PermitAny.IsNull() && !item.PermitAny.IsUnknown() {
+ if item.PermitAny.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "permit/std-ace/any", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "permit/std-ace/any")
+ }
+ }
+ if !item.PermitHost.IsNull() && !item.PermitHost.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "permit/std-ace/host-address", item.PermitHost.ValueString())
+ }
+ if !item.PermitLog.IsNull() && !item.PermitLog.IsUnknown() {
+ if item.PermitLog.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "permit/std-ace/log", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "permit/std-ace/log")
+ }
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/access-list-seq-rule", cBody.Res())
+ }
+ }
+ bodyString, err := body.String()
+ if err != nil {
+ tflog.Error(ctx, fmt.Sprintf("Error converting body to string: %s", err))
+ }
+ return bodyString
+}
+
+// End of section. //template:end toBodyXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBody
func (data *AccessListStandard) updateFromBody(ctx context.Context, res gjson.Result) {
@@ -268,6 +358,118 @@ func (data *AccessListStandard) updateFromBody(ctx context.Context, res gjson.Re
// End of section. //template:end updateFromBody
+// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBodyXML
+
+func (data *AccessListStandard) updateFromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/name"); value.Exists() && !data.Name.IsNull() {
+ data.Name = types.StringValue(value.String())
+ } else {
+ data.Name = types.StringNull()
+ }
+ for i := range data.Entries {
+ keys := [...]string{"sequence"}
+ keyValues := [...]string{strconv.FormatInt(data.Entries[i].Sequence.ValueInt64(), 10)}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/access-list-seq-rule").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, "sequence"); value.Exists() && !data.Entries[i].Sequence.IsNull() {
+ data.Entries[i].Sequence = types.Int64Value(value.Int())
+ } else {
+ data.Entries[i].Sequence = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(r, "remark"); value.Exists() && !data.Entries[i].Remark.IsNull() {
+ data.Entries[i].Remark = types.StringValue(value.String())
+ } else {
+ data.Entries[i].Remark = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "deny/std-ace/ipv4-address-prefix"); value.Exists() && !data.Entries[i].DenyPrefix.IsNull() {
+ data.Entries[i].DenyPrefix = types.StringValue(value.String())
+ } else {
+ data.Entries[i].DenyPrefix = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "deny/std-ace/mask"); value.Exists() && !data.Entries[i].DenyPrefixMask.IsNull() {
+ data.Entries[i].DenyPrefixMask = types.StringValue(value.String())
+ } else {
+ data.Entries[i].DenyPrefixMask = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "deny/std-ace/any"); !data.Entries[i].DenyAny.IsNull() {
+ if value.Exists() {
+ data.Entries[i].DenyAny = types.BoolValue(true)
+ } else {
+ data.Entries[i].DenyAny = types.BoolValue(false)
+ }
+ } else {
+ data.Entries[i].DenyAny = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "deny/std-ace/host-address"); value.Exists() && !data.Entries[i].DenyHost.IsNull() {
+ data.Entries[i].DenyHost = types.StringValue(value.String())
+ } else {
+ data.Entries[i].DenyHost = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "deny/std-ace/log"); !data.Entries[i].DenyLog.IsNull() {
+ if value.Exists() {
+ data.Entries[i].DenyLog = types.BoolValue(true)
+ } else {
+ data.Entries[i].DenyLog = types.BoolValue(false)
+ }
+ } else {
+ data.Entries[i].DenyLog = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "permit/std-ace/ipv4-address-prefix"); value.Exists() && !data.Entries[i].PermitPrefix.IsNull() {
+ data.Entries[i].PermitPrefix = types.StringValue(value.String())
+ } else {
+ data.Entries[i].PermitPrefix = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "permit/std-ace/mask"); value.Exists() && !data.Entries[i].PermitPrefixMask.IsNull() {
+ data.Entries[i].PermitPrefixMask = types.StringValue(value.String())
+ } else {
+ data.Entries[i].PermitPrefixMask = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "permit/std-ace/any"); !data.Entries[i].PermitAny.IsNull() {
+ if value.Exists() {
+ data.Entries[i].PermitAny = types.BoolValue(true)
+ } else {
+ data.Entries[i].PermitAny = types.BoolValue(false)
+ }
+ } else {
+ data.Entries[i].PermitAny = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "permit/std-ace/host-address"); value.Exists() && !data.Entries[i].PermitHost.IsNull() {
+ data.Entries[i].PermitHost = types.StringValue(value.String())
+ } else {
+ data.Entries[i].PermitHost = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "permit/std-ace/log"); !data.Entries[i].PermitLog.IsNull() {
+ if value.Exists() {
+ data.Entries[i].PermitLog = types.BoolValue(true)
+ } else {
+ data.Entries[i].PermitLog = types.BoolValue(false)
+ }
+ } else {
+ data.Entries[i].PermitLog = types.BoolNull()
+ }
+ }
+}
+
+// End of section. //template:end updateFromBodyXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin fromBody
func (data *AccessListStandard) fromBody(ctx context.Context, res gjson.Result) {
@@ -394,6 +596,124 @@ func (data *AccessListStandardData) fromBody(ctx context.Context, res gjson.Resu
// End of section. //template:end fromBodyData
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyXML
+
+func (data *AccessListStandard) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/access-list-seq-rule"); value.Exists() {
+ data.Entries = make([]AccessListStandardEntries, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := AccessListStandardEntries{}
+ if cValue := helpers.GetFromXPath(v, "sequence"); cValue.Exists() {
+ item.Sequence = types.Int64Value(cValue.Int())
+ }
+ if cValue := helpers.GetFromXPath(v, "remark"); cValue.Exists() {
+ item.Remark = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "deny/std-ace/ipv4-address-prefix"); cValue.Exists() {
+ item.DenyPrefix = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "deny/std-ace/mask"); cValue.Exists() {
+ item.DenyPrefixMask = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "deny/std-ace/any"); cValue.Exists() {
+ item.DenyAny = types.BoolValue(true)
+ } else {
+ item.DenyAny = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "deny/std-ace/host-address"); cValue.Exists() {
+ item.DenyHost = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "deny/std-ace/log"); cValue.Exists() {
+ item.DenyLog = types.BoolValue(true)
+ } else {
+ item.DenyLog = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "permit/std-ace/ipv4-address-prefix"); cValue.Exists() {
+ item.PermitPrefix = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "permit/std-ace/mask"); cValue.Exists() {
+ item.PermitPrefixMask = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "permit/std-ace/any"); cValue.Exists() {
+ item.PermitAny = types.BoolValue(true)
+ } else {
+ item.PermitAny = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "permit/std-ace/host-address"); cValue.Exists() {
+ item.PermitHost = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "permit/std-ace/log"); cValue.Exists() {
+ item.PermitLog = types.BoolValue(true)
+ } else {
+ item.PermitLog = types.BoolValue(false)
+ }
+ data.Entries = append(data.Entries, item)
+ return true
+ })
+ }
+}
+
+// End of section. //template:end fromBodyXML
+
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyDataXML
+
+func (data *AccessListStandardData) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/access-list-seq-rule"); value.Exists() {
+ data.Entries = make([]AccessListStandardEntries, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := AccessListStandardEntries{}
+ if cValue := helpers.GetFromXPath(v, "sequence"); cValue.Exists() {
+ item.Sequence = types.Int64Value(cValue.Int())
+ }
+ if cValue := helpers.GetFromXPath(v, "remark"); cValue.Exists() {
+ item.Remark = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "deny/std-ace/ipv4-address-prefix"); cValue.Exists() {
+ item.DenyPrefix = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "deny/std-ace/mask"); cValue.Exists() {
+ item.DenyPrefixMask = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "deny/std-ace/any"); cValue.Exists() {
+ item.DenyAny = types.BoolValue(true)
+ } else {
+ item.DenyAny = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "deny/std-ace/host-address"); cValue.Exists() {
+ item.DenyHost = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "deny/std-ace/log"); cValue.Exists() {
+ item.DenyLog = types.BoolValue(true)
+ } else {
+ item.DenyLog = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "permit/std-ace/ipv4-address-prefix"); cValue.Exists() {
+ item.PermitPrefix = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "permit/std-ace/mask"); cValue.Exists() {
+ item.PermitPrefixMask = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "permit/std-ace/any"); cValue.Exists() {
+ item.PermitAny = types.BoolValue(true)
+ } else {
+ item.PermitAny = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "permit/std-ace/host-address"); cValue.Exists() {
+ item.PermitHost = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "permit/std-ace/log"); cValue.Exists() {
+ item.PermitLog = types.BoolValue(true)
+ } else {
+ item.PermitLog = types.BoolValue(false)
+ }
+ data.Entries = append(data.Entries, item)
+ return true
+ })
+ }
+}
+
+// End of section. //template:end fromBodyDataXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin getDeletedItems
func (data *AccessListStandard) getDeletedItems(ctx context.Context, state AccessListStandard) []string {
@@ -462,6 +782,79 @@ func (data *AccessListStandard) getDeletedItems(ctx context.Context, state Acces
// End of section. //template:end getDeletedItems
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletedItemsXML
+
+func (data *AccessListStandard) addDeletedItemsXML(ctx context.Context, state AccessListStandard, body string) string {
+ b := netconf.NewBody(body)
+ for i := range state.Entries {
+ stateKeys := [...]string{"sequence"}
+ stateKeyValues := [...]string{strconv.FormatInt(state.Entries[i].Sequence.ValueInt64(), 10)}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.Entries[i].Sequence.ValueInt64()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.Entries {
+ found = true
+ if state.Entries[i].Sequence.ValueInt64() != data.Entries[j].Sequence.ValueInt64() {
+ found = false
+ }
+ if found {
+ if !state.Entries[i].Remark.IsNull() && data.Entries[j].Remark.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/access-list-seq-rule%v/remark", predicates))
+ }
+ if !state.Entries[i].DenyPrefix.IsNull() && data.Entries[j].DenyPrefix.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/access-list-seq-rule%v/deny/std-ace/ipv4-address-prefix", predicates))
+ }
+ if !state.Entries[i].DenyPrefixMask.IsNull() && data.Entries[j].DenyPrefixMask.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/access-list-seq-rule%v/deny/std-ace/mask", predicates))
+ }
+ if !state.Entries[i].DenyAny.IsNull() && data.Entries[j].DenyAny.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/access-list-seq-rule%v/deny/std-ace/any", predicates))
+ }
+ if !state.Entries[i].DenyHost.IsNull() && data.Entries[j].DenyHost.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/access-list-seq-rule%v/deny/std-ace/host-address", predicates))
+ }
+ if !state.Entries[i].DenyLog.IsNull() && data.Entries[j].DenyLog.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/access-list-seq-rule%v/deny/std-ace/log", predicates))
+ }
+ if !state.Entries[i].PermitPrefix.IsNull() && data.Entries[j].PermitPrefix.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/access-list-seq-rule%v/permit/std-ace/ipv4-address-prefix", predicates))
+ }
+ if !state.Entries[i].PermitPrefixMask.IsNull() && data.Entries[j].PermitPrefixMask.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/access-list-seq-rule%v/permit/std-ace/mask", predicates))
+ }
+ if !state.Entries[i].PermitAny.IsNull() && data.Entries[j].PermitAny.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/access-list-seq-rule%v/permit/std-ace/any", predicates))
+ }
+ if !state.Entries[i].PermitHost.IsNull() && data.Entries[j].PermitHost.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/access-list-seq-rule%v/permit/std-ace/host-address", predicates))
+ }
+ if !state.Entries[i].PermitLog.IsNull() && data.Entries[j].PermitLog.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/access-list-seq-rule%v/permit/std-ace/log", predicates))
+ }
+ break
+ }
+ }
+ if !found {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/access-list-seq-rule%v", predicates))
+ }
+ }
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletedItemsXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin getEmptyLeafsDelete
func (data *AccessListStandard) getEmptyLeafsDelete(ctx context.Context) []string {
@@ -502,3 +895,23 @@ func (data *AccessListStandard) getDeletePaths(ctx context.Context) []string {
}
// End of section. //template:end getDeletePaths
+
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletePathsXML
+
+func (data *AccessListStandard) addDeletePathsXML(ctx context.Context, body string) string {
+ b := netconf.NewBody(body)
+ for i := range data.Entries {
+ keys := [...]string{"sequence"}
+ keyValues := [...]string{strconv.FormatInt(data.Entries[i].Sequence.ValueInt64(), 10)}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/access-list-seq-rule%v", predicates))
+ }
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletePathsXML
diff --git a/internal/provider/model_iosxe_arp.go b/internal/provider/model_iosxe_arp.go
index b98dc3b2..1dd721a6 100644
--- a/internal/provider/model_iosxe_arp.go
+++ b/internal/provider/model_iosxe_arp.go
@@ -30,6 +30,9 @@ import (
"github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/types"
+ "github.com/hashicorp/terraform-plugin-log/tflog"
+ "github.com/netascode/go-netconf"
+ "github.com/netascode/xmldot"
"github.com/tidwall/gjson"
"github.com/tidwall/sjson"
)
@@ -103,6 +106,17 @@ func (data ARP) getPathShort() string {
return matches[1]
}
+// getXPath returns the XPath for NETCONF operations
+func (data ARP) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/ip/arp"
+ return path
+}
+
+func (data ARPData) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/ip/arp"
+ return path
+}
+
// End of section. //template:end getPath
// Section below is generated&owned by "gen/generator.go". //template:begin toBody
@@ -178,6 +192,97 @@ func (data ARP) toBody(ctx context.Context) string {
// End of section. //template:end toBody
+// Section below is generated&owned by "gen/generator.go". //template:begin toBodyXML
+
+func (data ARP) toBodyXML(ctx context.Context) string {
+ body := netconf.Body{}
+ if !data.IncompleteEntries.IsNull() && !data.IncompleteEntries.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/incomplete/entries", strconv.FormatInt(data.IncompleteEntries.ValueInt64(), 10))
+ }
+ if !data.ProxyDisable.IsNull() && !data.ProxyDisable.IsUnknown() {
+ if data.ProxyDisable.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/proxy/disable", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/proxy/disable")
+ }
+ }
+ if !data.EntryLearn.IsNull() && !data.EntryLearn.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/entry/learn", strconv.FormatInt(data.EntryLearn.ValueInt64(), 10))
+ }
+ if len(data.InspectionFilters) > 0 {
+ for _, item := range data.InspectionFilters {
+ cBody := netconf.Body{}
+ if !item.Name.IsNull() && !item.Name.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "arpacl", item.Name.ValueString())
+ }
+ if len(item.Vlans) > 0 {
+ for _, citem := range item.Vlans {
+ ccBody := netconf.Body{}
+ if !citem.VlanRange.IsNull() && !citem.VlanRange.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "vlan-range", citem.VlanRange.ValueString())
+ }
+ if !citem.Static.IsNull() && !citem.Static.IsUnknown() {
+ if citem.Static.ValueBool() {
+ ccBody = helpers.SetFromXPath(ccBody, "static", "")
+ } else {
+ ccBody = helpers.RemoveFromXPath(ccBody, "static")
+ }
+ }
+ cBody = helpers.SetRawFromXPath(cBody, "vlan", ccBody.Res())
+ }
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/inspection/filter", cBody.Res())
+ }
+ }
+ if !data.InspectionValidateSrcMac.IsNull() && !data.InspectionValidateSrcMac.IsUnknown() {
+ if data.InspectionValidateSrcMac.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/inspection/validate/src-mac", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/inspection/validate/src-mac")
+ }
+ }
+ if !data.InspectionValidateDstMac.IsNull() && !data.InspectionValidateDstMac.IsUnknown() {
+ if data.InspectionValidateDstMac.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/inspection/validate/dst-mac", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/inspection/validate/dst-mac")
+ }
+ }
+ if !data.InspectionValidateIp.IsNull() && !data.InspectionValidateIp.IsUnknown() {
+ if data.InspectionValidateIp.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/inspection/validate/ip", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/inspection/validate/ip")
+ }
+ }
+ if !data.InspectionValidateAllowZeros.IsNull() && !data.InspectionValidateAllowZeros.IsUnknown() {
+ if data.InspectionValidateAllowZeros.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/inspection/validate/allow/zeros", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/inspection/validate/allow/zeros")
+ }
+ }
+ if !data.InspectionLogBufferEntries.IsNull() && !data.InspectionLogBufferEntries.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/inspection/log-buffer/entries", strconv.FormatInt(data.InspectionLogBufferEntries.ValueInt64(), 10))
+ }
+ if !data.InspectionLogBufferLogsEntries.IsNull() && !data.InspectionLogBufferLogsEntries.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/inspection/log-buffer/logs/entries", strconv.FormatInt(data.InspectionLogBufferLogsEntries.ValueInt64(), 10))
+ }
+ if !data.InspectionLogBufferLogsInterval.IsNull() && !data.InspectionLogBufferLogsInterval.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/inspection/log-buffer/logs/interval", strconv.FormatInt(data.InspectionLogBufferLogsInterval.ValueInt64(), 10))
+ }
+ if !data.InspectionVlan.IsNull() && !data.InspectionVlan.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/inspection/vlan", data.InspectionVlan.ValueString())
+ }
+ bodyString, err := body.String()
+ if err != nil {
+ tflog.Error(ctx, fmt.Sprintf("Error converting body to string: %s", err))
+ }
+ return bodyString
+}
+
+// End of section. //template:end toBodyXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBody
func (data *ARP) updateFromBody(ctx context.Context, res gjson.Result) {
@@ -331,6 +436,155 @@ func (data *ARP) updateFromBody(ctx context.Context, res gjson.Result) {
// End of section. //template:end updateFromBody
+// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBodyXML
+
+func (data *ARP) updateFromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/incomplete/entries"); value.Exists() && !data.IncompleteEntries.IsNull() {
+ data.IncompleteEntries = types.Int64Value(value.Int())
+ } else {
+ data.IncompleteEntries = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/proxy/disable"); !data.ProxyDisable.IsNull() {
+ if value.Exists() {
+ data.ProxyDisable = types.BoolValue(true)
+ } else {
+ data.ProxyDisable = types.BoolValue(false)
+ }
+ } else {
+ data.ProxyDisable = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/entry/learn"); value.Exists() && !data.EntryLearn.IsNull() {
+ data.EntryLearn = types.Int64Value(value.Int())
+ } else {
+ data.EntryLearn = types.Int64Null()
+ }
+ for i := range data.InspectionFilters {
+ keys := [...]string{"arpacl"}
+ keyValues := [...]string{data.InspectionFilters[i].Name.ValueString()}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/inspection/filter").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, "arpacl"); value.Exists() && !data.InspectionFilters[i].Name.IsNull() {
+ data.InspectionFilters[i].Name = types.StringValue(value.String())
+ } else {
+ data.InspectionFilters[i].Name = types.StringNull()
+ }
+ for ci := range data.InspectionFilters[i].Vlans {
+ keys := [...]string{"vlan-range"}
+ keyValues := [...]string{data.InspectionFilters[i].Vlans[ci].VlanRange.ValueString()}
+
+ var cr xmldot.Result
+ helpers.GetFromXPath(r, "vlan").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ cr = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(cr, "vlan-range"); value.Exists() && !data.InspectionFilters[i].Vlans[ci].VlanRange.IsNull() {
+ data.InspectionFilters[i].Vlans[ci].VlanRange = types.StringValue(value.String())
+ } else {
+ data.InspectionFilters[i].Vlans[ci].VlanRange = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(cr, "static"); !data.InspectionFilters[i].Vlans[ci].Static.IsNull() {
+ if value.Exists() {
+ data.InspectionFilters[i].Vlans[ci].Static = types.BoolValue(true)
+ } else {
+ data.InspectionFilters[i].Vlans[ci].Static = types.BoolValue(false)
+ }
+ } else {
+ data.InspectionFilters[i].Vlans[ci].Static = types.BoolNull()
+ }
+ }
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/inspection/validate/src-mac"); !data.InspectionValidateSrcMac.IsNull() {
+ if value.Exists() {
+ data.InspectionValidateSrcMac = types.BoolValue(true)
+ } else {
+ data.InspectionValidateSrcMac = types.BoolValue(false)
+ }
+ } else {
+ data.InspectionValidateSrcMac = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/inspection/validate/dst-mac"); !data.InspectionValidateDstMac.IsNull() {
+ if value.Exists() {
+ data.InspectionValidateDstMac = types.BoolValue(true)
+ } else {
+ data.InspectionValidateDstMac = types.BoolValue(false)
+ }
+ } else {
+ data.InspectionValidateDstMac = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/inspection/validate/ip"); !data.InspectionValidateIp.IsNull() {
+ if value.Exists() {
+ data.InspectionValidateIp = types.BoolValue(true)
+ } else {
+ data.InspectionValidateIp = types.BoolValue(false)
+ }
+ } else {
+ data.InspectionValidateIp = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/inspection/validate/allow/zeros"); !data.InspectionValidateAllowZeros.IsNull() {
+ if value.Exists() {
+ data.InspectionValidateAllowZeros = types.BoolValue(true)
+ } else {
+ data.InspectionValidateAllowZeros = types.BoolValue(false)
+ }
+ } else {
+ data.InspectionValidateAllowZeros = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/inspection/log-buffer/entries"); value.Exists() && !data.InspectionLogBufferEntries.IsNull() {
+ data.InspectionLogBufferEntries = types.Int64Value(value.Int())
+ } else {
+ data.InspectionLogBufferEntries = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/inspection/log-buffer/logs/entries"); value.Exists() && !data.InspectionLogBufferLogsEntries.IsNull() {
+ data.InspectionLogBufferLogsEntries = types.Int64Value(value.Int())
+ } else {
+ data.InspectionLogBufferLogsEntries = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/inspection/log-buffer/logs/interval"); value.Exists() && !data.InspectionLogBufferLogsInterval.IsNull() {
+ data.InspectionLogBufferLogsInterval = types.Int64Value(value.Int())
+ } else {
+ data.InspectionLogBufferLogsInterval = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/inspection/vlan"); value.Exists() && !data.InspectionVlan.IsNull() {
+ data.InspectionVlan = types.StringValue(value.String())
+ } else {
+ data.InspectionVlan = types.StringNull()
+ }
+}
+
+// End of section. //template:end updateFromBodyXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin fromBody
func (data *ARP) fromBody(ctx context.Context, res gjson.Result) {
@@ -493,6 +747,160 @@ func (data *ARPData) fromBody(ctx context.Context, res gjson.Result) {
// End of section. //template:end fromBodyData
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyXML
+
+func (data *ARP) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/incomplete/entries"); value.Exists() {
+ data.IncompleteEntries = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/proxy/disable"); value.Exists() {
+ data.ProxyDisable = types.BoolValue(true)
+ } else {
+ data.ProxyDisable = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/entry/learn"); value.Exists() {
+ data.EntryLearn = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/inspection/filter"); value.Exists() {
+ data.InspectionFilters = make([]ARPInspectionFilters, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := ARPInspectionFilters{}
+ if cValue := helpers.GetFromXPath(v, "arpacl"); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "vlan"); cValue.Exists() {
+ item.Vlans = make([]ARPInspectionFiltersVlans, 0)
+ cValue.ForEach(func(_ int, cv xmldot.Result) bool {
+ cItem := ARPInspectionFiltersVlans{}
+ if ccValue := helpers.GetFromXPath(cv, "vlan-range"); ccValue.Exists() {
+ cItem.VlanRange = types.StringValue(ccValue.String())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "static"); ccValue.Exists() {
+ cItem.Static = types.BoolValue(true)
+ } else {
+ cItem.Static = types.BoolValue(false)
+ }
+ item.Vlans = append(item.Vlans, cItem)
+ return true
+ })
+ }
+ data.InspectionFilters = append(data.InspectionFilters, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/inspection/validate/src-mac"); value.Exists() {
+ data.InspectionValidateSrcMac = types.BoolValue(true)
+ } else {
+ data.InspectionValidateSrcMac = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/inspection/validate/dst-mac"); value.Exists() {
+ data.InspectionValidateDstMac = types.BoolValue(true)
+ } else {
+ data.InspectionValidateDstMac = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/inspection/validate/ip"); value.Exists() {
+ data.InspectionValidateIp = types.BoolValue(true)
+ } else {
+ data.InspectionValidateIp = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/inspection/validate/allow/zeros"); value.Exists() {
+ data.InspectionValidateAllowZeros = types.BoolValue(true)
+ } else {
+ data.InspectionValidateAllowZeros = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/inspection/log-buffer/entries"); value.Exists() {
+ data.InspectionLogBufferEntries = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/inspection/log-buffer/logs/entries"); value.Exists() {
+ data.InspectionLogBufferLogsEntries = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/inspection/log-buffer/logs/interval"); value.Exists() {
+ data.InspectionLogBufferLogsInterval = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/inspection/vlan"); value.Exists() {
+ data.InspectionVlan = types.StringValue(value.String())
+ }
+}
+
+// End of section. //template:end fromBodyXML
+
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyDataXML
+
+func (data *ARPData) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/incomplete/entries"); value.Exists() {
+ data.IncompleteEntries = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/proxy/disable"); value.Exists() {
+ data.ProxyDisable = types.BoolValue(true)
+ } else {
+ data.ProxyDisable = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/entry/learn"); value.Exists() {
+ data.EntryLearn = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/inspection/filter"); value.Exists() {
+ data.InspectionFilters = make([]ARPInspectionFilters, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := ARPInspectionFilters{}
+ if cValue := helpers.GetFromXPath(v, "arpacl"); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "vlan"); cValue.Exists() {
+ item.Vlans = make([]ARPInspectionFiltersVlans, 0)
+ cValue.ForEach(func(_ int, cv xmldot.Result) bool {
+ cItem := ARPInspectionFiltersVlans{}
+ if ccValue := helpers.GetFromXPath(cv, "vlan-range"); ccValue.Exists() {
+ cItem.VlanRange = types.StringValue(ccValue.String())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "static"); ccValue.Exists() {
+ cItem.Static = types.BoolValue(true)
+ } else {
+ cItem.Static = types.BoolValue(false)
+ }
+ item.Vlans = append(item.Vlans, cItem)
+ return true
+ })
+ }
+ data.InspectionFilters = append(data.InspectionFilters, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/inspection/validate/src-mac"); value.Exists() {
+ data.InspectionValidateSrcMac = types.BoolValue(true)
+ } else {
+ data.InspectionValidateSrcMac = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/inspection/validate/dst-mac"); value.Exists() {
+ data.InspectionValidateDstMac = types.BoolValue(true)
+ } else {
+ data.InspectionValidateDstMac = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/inspection/validate/ip"); value.Exists() {
+ data.InspectionValidateIp = types.BoolValue(true)
+ } else {
+ data.InspectionValidateIp = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/inspection/validate/allow/zeros"); value.Exists() {
+ data.InspectionValidateAllowZeros = types.BoolValue(true)
+ } else {
+ data.InspectionValidateAllowZeros = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/inspection/log-buffer/entries"); value.Exists() {
+ data.InspectionLogBufferEntries = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/inspection/log-buffer/logs/entries"); value.Exists() {
+ data.InspectionLogBufferLogsEntries = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/inspection/log-buffer/logs/interval"); value.Exists() {
+ data.InspectionLogBufferLogsInterval = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/inspection/vlan"); value.Exists() {
+ data.InspectionVlan = types.StringValue(value.String())
+ }
+}
+
+// End of section. //template:end fromBodyDataXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin getDeletedItems
func (data *ARP) getDeletedItems(ctx context.Context, state ARP) []string {
@@ -589,6 +997,112 @@ func (data *ARP) getDeletedItems(ctx context.Context, state ARP) []string {
// End of section. //template:end getDeletedItems
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletedItemsXML
+
+func (data *ARP) addDeletedItemsXML(ctx context.Context, state ARP, body string) string {
+ b := netconf.NewBody(body)
+ if !state.IncompleteEntries.IsNull() && data.IncompleteEntries.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/incomplete/entries")
+ }
+ if !state.ProxyDisable.IsNull() && data.ProxyDisable.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/proxy/disable")
+ }
+ if !state.EntryLearn.IsNull() && data.EntryLearn.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/entry/learn")
+ }
+ for i := range state.InspectionFilters {
+ stateKeys := [...]string{"arpacl"}
+ stateKeyValues := [...]string{state.InspectionFilters[i].Name.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.InspectionFilters[i].Name.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.InspectionFilters {
+ found = true
+ if state.InspectionFilters[i].Name.ValueString() != data.InspectionFilters[j].Name.ValueString() {
+ found = false
+ }
+ if found {
+ for ci := range state.InspectionFilters[i].Vlans {
+ cstateKeys := [...]string{"vlan-range"}
+ cstateKeyValues := [...]string{state.InspectionFilters[i].Vlans[ci].VlanRange.ValueString()}
+ cpredicates := ""
+ for i := range cstateKeys {
+ cpredicates += fmt.Sprintf("[%s='%s']", cstateKeys[i], cstateKeyValues[i])
+ }
+
+ cemptyKeys := true
+ if !reflect.ValueOf(state.InspectionFilters[i].Vlans[ci].VlanRange.ValueString()).IsZero() {
+ cemptyKeys = false
+ }
+ if cemptyKeys {
+ continue
+ }
+
+ found := false
+ for cj := range data.InspectionFilters[j].Vlans {
+ found = true
+ if state.InspectionFilters[i].Vlans[ci].VlanRange.ValueString() != data.InspectionFilters[j].Vlans[cj].VlanRange.ValueString() {
+ found = false
+ }
+ if found {
+ if !state.InspectionFilters[i].Vlans[ci].Static.IsNull() && data.InspectionFilters[j].Vlans[cj].Static.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/inspection/filter%v/vlan%v/static", predicates, cpredicates))
+ }
+ break
+ }
+ }
+ if !found {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/inspection/filter%v/vlan%v", predicates, cpredicates))
+ }
+ }
+ break
+ }
+ }
+ if !found {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/inspection/filter%v", predicates))
+ }
+ }
+ if !state.InspectionValidateSrcMac.IsNull() && data.InspectionValidateSrcMac.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/inspection/validate/src-mac")
+ }
+ if !state.InspectionValidateDstMac.IsNull() && data.InspectionValidateDstMac.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/inspection/validate/dst-mac")
+ }
+ if !state.InspectionValidateIp.IsNull() && data.InspectionValidateIp.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/inspection/validate/ip")
+ }
+ if !state.InspectionValidateAllowZeros.IsNull() && data.InspectionValidateAllowZeros.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/inspection/validate/allow/zeros")
+ }
+ if !state.InspectionLogBufferEntries.IsNull() && data.InspectionLogBufferEntries.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/inspection/log-buffer/entries")
+ }
+ if !state.InspectionLogBufferLogsEntries.IsNull() && data.InspectionLogBufferLogsEntries.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/inspection/log-buffer/logs/entries")
+ }
+ if !state.InspectionLogBufferLogsInterval.IsNull() && data.InspectionLogBufferLogsInterval.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/inspection/log-buffer/logs/interval")
+ }
+ if !state.InspectionVlan.IsNull() && data.InspectionVlan.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/inspection/vlan")
+ }
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletedItemsXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin getEmptyLeafsDelete
func (data *ARP) getEmptyLeafsDelete(ctx context.Context) []string {
@@ -672,3 +1186,56 @@ func (data *ARP) getDeletePaths(ctx context.Context) []string {
}
// End of section. //template:end getDeletePaths
+
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletePathsXML
+
+func (data *ARP) addDeletePathsXML(ctx context.Context, body string) string {
+ b := netconf.NewBody(body)
+ if !data.IncompleteEntries.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/incomplete/entries")
+ }
+ if !data.ProxyDisable.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/proxy/disable")
+ }
+ if !data.EntryLearn.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/entry/learn")
+ }
+ for i := range data.InspectionFilters {
+ keys := [...]string{"arpacl"}
+ keyValues := [...]string{data.InspectionFilters[i].Name.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/inspection/filter%v", predicates))
+ }
+ if !data.InspectionValidateSrcMac.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/inspection/validate/src-mac")
+ }
+ if !data.InspectionValidateDstMac.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/inspection/validate/dst-mac")
+ }
+ if !data.InspectionValidateIp.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/inspection/validate/ip")
+ }
+ if !data.InspectionValidateAllowZeros.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/inspection/validate/allow/zeros")
+ }
+ if !data.InspectionLogBufferEntries.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/inspection/log-buffer/entries")
+ }
+ if !data.InspectionLogBufferLogsEntries.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/inspection/log-buffer/logs/entries")
+ }
+ if !data.InspectionLogBufferLogsInterval.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/inspection/log-buffer/logs/interval")
+ }
+ if !data.InspectionVlan.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/inspection/vlan")
+ }
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletePathsXML
diff --git a/internal/provider/model_iosxe_as_path_access_list.go b/internal/provider/model_iosxe_as_path_access_list.go
index 303b26aa..6121d182 100644
--- a/internal/provider/model_iosxe_as_path_access_list.go
+++ b/internal/provider/model_iosxe_as_path_access_list.go
@@ -31,6 +31,9 @@ import (
"github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/types"
+ "github.com/hashicorp/terraform-plugin-log/tflog"
+ "github.com/netascode/go-netconf"
+ "github.com/netascode/xmldot"
"github.com/tidwall/gjson"
"github.com/tidwall/sjson"
)
@@ -79,6 +82,19 @@ func (data ASPathAccessList) getPathShort() string {
return matches[1]
}
+// getXPath returns the XPath for NETCONF operations
+func (data ASPathAccessList) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/ip/as-path/Cisco-IOS-XE-bgp:access-list[name=%v]"
+ path = fmt.Sprintf(path, fmt.Sprintf("%v", data.Name.ValueInt64()))
+ return path
+}
+
+func (data ASPathAccessListData) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/ip/as-path/Cisco-IOS-XE-bgp:access-list[name=%v]"
+ path = fmt.Sprintf(path, fmt.Sprintf("%v", data.Name.ValueInt64()))
+ return path
+}
+
// End of section. //template:end getPath
// Section below is generated&owned by "gen/generator.go". //template:begin toBody
@@ -104,6 +120,34 @@ func (data ASPathAccessList) toBody(ctx context.Context) string {
// End of section. //template:end toBody
+// Section below is generated&owned by "gen/generator.go". //template:begin toBodyXML
+
+func (data ASPathAccessList) toBodyXML(ctx context.Context) string {
+ body := netconf.Body{}
+ if !data.Name.IsNull() && !data.Name.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/name", strconv.FormatInt(data.Name.ValueInt64(), 10))
+ }
+ if len(data.Entries) > 0 {
+ for _, item := range data.Entries {
+ cBody := netconf.Body{}
+ if !item.Action.IsNull() && !item.Action.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "action", item.Action.ValueString())
+ }
+ if !item.Regex.IsNull() && !item.Regex.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "string", item.Regex.ValueString())
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/extended-grouping/extended_grouping", cBody.Res())
+ }
+ }
+ bodyString, err := body.String()
+ if err != nil {
+ tflog.Error(ctx, fmt.Sprintf("Error converting body to string: %s", err))
+ }
+ return bodyString
+}
+
+// End of section. //template:end toBodyXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBody
func (data *ASPathAccessList) updateFromBody(ctx context.Context, res gjson.Result) {
@@ -154,6 +198,52 @@ func (data *ASPathAccessList) updateFromBody(ctx context.Context, res gjson.Resu
// End of section. //template:end updateFromBody
+// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBodyXML
+
+func (data *ASPathAccessList) updateFromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/name"); value.Exists() && !data.Name.IsNull() {
+ data.Name = types.Int64Value(value.Int())
+ } else {
+ data.Name = types.Int64Null()
+ }
+ for i := range data.Entries {
+ keys := [...]string{"action", "string"}
+ keyValues := [...]string{data.Entries[i].Action.ValueString(), data.Entries[i].Regex.ValueString()}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/extended-grouping/extended_grouping").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, "action"); value.Exists() && !data.Entries[i].Action.IsNull() {
+ data.Entries[i].Action = types.StringValue(value.String())
+ } else {
+ data.Entries[i].Action = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "string"); value.Exists() && !data.Entries[i].Regex.IsNull() {
+ data.Entries[i].Regex = types.StringValue(value.String())
+ } else {
+ data.Entries[i].Regex = types.StringNull()
+ }
+ }
+}
+
+// End of section. //template:end updateFromBodyXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin fromBody
func (data *ASPathAccessList) fromBody(ctx context.Context, res gjson.Result) {
@@ -204,6 +294,48 @@ func (data *ASPathAccessListData) fromBody(ctx context.Context, res gjson.Result
// End of section. //template:end fromBodyData
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyXML
+
+func (data *ASPathAccessList) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/extended-grouping/extended_grouping"); value.Exists() {
+ data.Entries = make([]ASPathAccessListEntries, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := ASPathAccessListEntries{}
+ if cValue := helpers.GetFromXPath(v, "action"); cValue.Exists() {
+ item.Action = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "string"); cValue.Exists() {
+ item.Regex = types.StringValue(cValue.String())
+ }
+ data.Entries = append(data.Entries, item)
+ return true
+ })
+ }
+}
+
+// End of section. //template:end fromBodyXML
+
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyDataXML
+
+func (data *ASPathAccessListData) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/extended-grouping/extended_grouping"); value.Exists() {
+ data.Entries = make([]ASPathAccessListEntries, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := ASPathAccessListEntries{}
+ if cValue := helpers.GetFromXPath(v, "action"); cValue.Exists() {
+ item.Action = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "string"); cValue.Exists() {
+ item.Regex = types.StringValue(cValue.String())
+ }
+ data.Entries = append(data.Entries, item)
+ return true
+ })
+ }
+}
+
+// End of section. //template:end fromBodyDataXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin getDeletedItems
func (data *ASPathAccessList) getDeletedItems(ctx context.Context, state ASPathAccessList) []string {
@@ -245,6 +377,52 @@ func (data *ASPathAccessList) getDeletedItems(ctx context.Context, state ASPathA
// End of section. //template:end getDeletedItems
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletedItemsXML
+
+func (data *ASPathAccessList) addDeletedItemsXML(ctx context.Context, state ASPathAccessList, body string) string {
+ b := netconf.NewBody(body)
+ for i := range state.Entries {
+ stateKeys := [...]string{"action", "string"}
+ stateKeyValues := [...]string{state.Entries[i].Action.ValueString(), state.Entries[i].Regex.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.Entries[i].Action.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if !reflect.ValueOf(state.Entries[i].Regex.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.Entries {
+ found = true
+ if state.Entries[i].Action.ValueString() != data.Entries[j].Action.ValueString() {
+ found = false
+ }
+ if state.Entries[i].Regex.ValueString() != data.Entries[j].Regex.ValueString() {
+ found = false
+ }
+ if found {
+ break
+ }
+ }
+ if !found {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/extended-grouping/extended_grouping%v", predicates))
+ }
+ }
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletedItemsXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin getEmptyLeafsDelete
func (data *ASPathAccessList) getEmptyLeafsDelete(ctx context.Context) []string {
@@ -269,3 +447,23 @@ func (data *ASPathAccessList) getDeletePaths(ctx context.Context) []string {
}
// End of section. //template:end getDeletePaths
+
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletePathsXML
+
+func (data *ASPathAccessList) addDeletePathsXML(ctx context.Context, body string) string {
+ b := netconf.NewBody(body)
+ for i := range data.Entries {
+ keys := [...]string{"action", "string"}
+ keyValues := [...]string{data.Entries[i].Action.ValueString(), data.Entries[i].Regex.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/extended-grouping/extended_grouping%v", predicates))
+ }
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletePathsXML
diff --git a/internal/provider/model_iosxe_banner.go b/internal/provider/model_iosxe_banner.go
index 5520024f..8a679ea2 100644
--- a/internal/provider/model_iosxe_banner.go
+++ b/internal/provider/model_iosxe_banner.go
@@ -27,6 +27,9 @@ import (
"github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/types"
+ "github.com/hashicorp/terraform-plugin-log/tflog"
+ "github.com/netascode/go-netconf"
+ "github.com/netascode/xmldot"
"github.com/tidwall/gjson"
"github.com/tidwall/sjson"
)
@@ -76,6 +79,17 @@ func (data Banner) getPathShort() string {
return matches[1]
}
+// getXPath returns the XPath for NETCONF operations
+func (data Banner) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/banner"
+ return path
+}
+
+func (data BannerData) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/banner"
+ return path
+}
+
// End of section. //template:end getPath
// Section below is generated&owned by "gen/generator.go". //template:begin toBody
@@ -99,6 +113,31 @@ func (data Banner) toBody(ctx context.Context) string {
// End of section. //template:end toBody
+// Section below is generated&owned by "gen/generator.go". //template:begin toBodyXML
+
+func (data Banner) toBodyXML(ctx context.Context) string {
+ body := netconf.Body{}
+ if !data.ExecBanner.IsNull() && !data.ExecBanner.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/exec/banner", data.ExecBanner.ValueString())
+ }
+ if !data.LoginBanner.IsNull() && !data.LoginBanner.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/login/banner", data.LoginBanner.ValueString())
+ }
+ if !data.PromptTimeoutBanner.IsNull() && !data.PromptTimeoutBanner.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/prompt-timeout/banner", data.PromptTimeoutBanner.ValueString())
+ }
+ if !data.MotdBanner.IsNull() && !data.MotdBanner.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/motd/banner", data.MotdBanner.ValueString())
+ }
+ bodyString, err := body.String()
+ if err != nil {
+ tflog.Error(ctx, fmt.Sprintf("Error converting body to string: %s", err))
+ }
+ return bodyString
+}
+
+// End of section. //template:end toBodyXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBody
func (data *Banner) updateFromBody(ctx context.Context, res gjson.Result) {
@@ -130,6 +169,33 @@ func (data *Banner) updateFromBody(ctx context.Context, res gjson.Result) {
// End of section. //template:end updateFromBody
+// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBodyXML
+
+func (data *Banner) updateFromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/exec/banner"); value.Exists() && !data.ExecBanner.IsNull() {
+ data.ExecBanner = types.StringValue(value.String())
+ } else {
+ data.ExecBanner = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/login/banner"); value.Exists() && !data.LoginBanner.IsNull() {
+ data.LoginBanner = types.StringValue(value.String())
+ } else {
+ data.LoginBanner = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/prompt-timeout/banner"); value.Exists() && !data.PromptTimeoutBanner.IsNull() {
+ data.PromptTimeoutBanner = types.StringValue(value.String())
+ } else {
+ data.PromptTimeoutBanner = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/motd/banner"); value.Exists() && !data.MotdBanner.IsNull() {
+ data.MotdBanner = types.StringValue(value.String())
+ } else {
+ data.MotdBanner = types.StringNull()
+ }
+}
+
+// End of section. //template:end updateFromBodyXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin fromBody
func (data *Banner) fromBody(ctx context.Context, res gjson.Result) {
@@ -176,6 +242,44 @@ func (data *BannerData) fromBody(ctx context.Context, res gjson.Result) {
// End of section. //template:end fromBodyData
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyXML
+
+func (data *Banner) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/exec/banner"); value.Exists() {
+ data.ExecBanner = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/login/banner"); value.Exists() {
+ data.LoginBanner = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/prompt-timeout/banner"); value.Exists() {
+ data.PromptTimeoutBanner = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/motd/banner"); value.Exists() {
+ data.MotdBanner = types.StringValue(value.String())
+ }
+}
+
+// End of section. //template:end fromBodyXML
+
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyDataXML
+
+func (data *BannerData) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/exec/banner"); value.Exists() {
+ data.ExecBanner = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/login/banner"); value.Exists() {
+ data.LoginBanner = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/prompt-timeout/banner"); value.Exists() {
+ data.PromptTimeoutBanner = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/motd/banner"); value.Exists() {
+ data.MotdBanner = types.StringValue(value.String())
+ }
+}
+
+// End of section. //template:end fromBodyDataXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin getDeletedItems
func (data *Banner) getDeletedItems(ctx context.Context, state Banner) []string {
@@ -198,6 +302,28 @@ func (data *Banner) getDeletedItems(ctx context.Context, state Banner) []string
// End of section. //template:end getDeletedItems
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletedItemsXML
+
+func (data *Banner) addDeletedItemsXML(ctx context.Context, state Banner, body string) string {
+ b := netconf.NewBody(body)
+ if !state.ExecBanner.IsNull() && data.ExecBanner.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/exec/banner")
+ }
+ if !state.LoginBanner.IsNull() && data.LoginBanner.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/login/banner")
+ }
+ if !state.PromptTimeoutBanner.IsNull() && data.PromptTimeoutBanner.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/prompt-timeout/banner")
+ }
+ if !state.MotdBanner.IsNull() && data.MotdBanner.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/motd/banner")
+ }
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletedItemsXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin getEmptyLeafsDelete
func (data *Banner) getEmptyLeafsDelete(ctx context.Context) []string {
@@ -229,3 +355,25 @@ func (data *Banner) getDeletePaths(ctx context.Context) []string {
}
// End of section. //template:end getDeletePaths
+
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletePathsXML
+
+func (data *Banner) addDeletePathsXML(ctx context.Context, body string) string {
+ b := netconf.NewBody(body)
+ if !data.ExecBanner.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/exec/banner")
+ }
+ if !data.LoginBanner.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/login/banner")
+ }
+ if !data.PromptTimeoutBanner.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/prompt-timeout/banner")
+ }
+ if !data.MotdBanner.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/motd/banner")
+ }
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletePathsXML
diff --git a/internal/provider/model_iosxe_bfd.go b/internal/provider/model_iosxe_bfd.go
index 88a8a895..b466ec99 100644
--- a/internal/provider/model_iosxe_bfd.go
+++ b/internal/provider/model_iosxe_bfd.go
@@ -30,6 +30,9 @@ import (
"github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/types"
+ "github.com/hashicorp/terraform-plugin-log/tflog"
+ "github.com/netascode/go-netconf"
+ "github.com/netascode/xmldot"
"github.com/tidwall/gjson"
"github.com/tidwall/sjson"
)
@@ -137,6 +140,17 @@ func (data BFD) getPathShort() string {
return matches[1]
}
+// getXPath returns the XPath for NETCONF operations
+func (data BFD) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/bfd"
+ return path
+}
+
+func (data BFDData) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/bfd"
+ return path
+}
+
// End of section. //template:end getPath
// Section below is generated&owned by "gen/generator.go". //template:begin toBody
@@ -287,6 +301,166 @@ func (data BFD) toBody(ctx context.Context) string {
// End of section. //template:end toBody
+// Section below is generated&owned by "gen/generator.go". //template:begin toBodyXML
+
+func (data BFD) toBodyXML(ctx context.Context) string {
+ body := netconf.Body{}
+ if len(data.Ipv4BothVrfs) > 0 {
+ for _, item := range data.Ipv4BothVrfs {
+ cBody := netconf.Body{}
+ if !item.DstVrf.IsNull() && !item.DstVrf.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "dst-vrf", item.DstVrf.ValueString())
+ }
+ if !item.DestIp.IsNull() && !item.DestIp.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "dest-ip", item.DestIp.ValueString())
+ }
+ if !item.SrcVrf.IsNull() && !item.SrcVrf.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "src-vrf", item.SrcVrf.ValueString())
+ }
+ if !item.SrcIp.IsNull() && !item.SrcIp.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "src-ip", item.SrcIp.ValueString())
+ }
+ if !item.TemplateName.IsNull() && !item.TemplateName.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "template-name", item.TemplateName.ValueString())
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-bfd:map/ipv4-list-with-both-vrf/ipv4", cBody.Res())
+ }
+ }
+ if len(data.Ipv4WithoutVrfs) > 0 {
+ for _, item := range data.Ipv4WithoutVrfs {
+ cBody := netconf.Body{}
+ if !item.DestIp.IsNull() && !item.DestIp.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "dest-ip", item.DestIp.ValueString())
+ }
+ if !item.SrcIp.IsNull() && !item.SrcIp.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "src-ip", item.SrcIp.ValueString())
+ }
+ if !item.TemplateName.IsNull() && !item.TemplateName.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "template-name", item.TemplateName.ValueString())
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-bfd:map/ipv4-list-without-vrf/ipv4", cBody.Res())
+ }
+ }
+ if len(data.Ipv4WithSrcVrfs) > 0 {
+ for _, item := range data.Ipv4WithSrcVrfs {
+ cBody := netconf.Body{}
+ if !item.DestIp.IsNull() && !item.DestIp.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "dest-ip", item.DestIp.ValueString())
+ }
+ if !item.SrcVrf.IsNull() && !item.SrcVrf.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "src-vrf", item.SrcVrf.ValueString())
+ }
+ if !item.SrcIp.IsNull() && !item.SrcIp.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "src-ip", item.SrcIp.ValueString())
+ }
+ if !item.TemplateName.IsNull() && !item.TemplateName.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "template-name", item.TemplateName.ValueString())
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-bfd:map/ipv4-list-with-src-vrf/ipv4", cBody.Res())
+ }
+ }
+ if len(data.Ipv4WithDstVrfs) > 0 {
+ for _, item := range data.Ipv4WithDstVrfs {
+ cBody := netconf.Body{}
+ if !item.DstVrf.IsNull() && !item.DstVrf.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "dst-vrf", item.DstVrf.ValueString())
+ }
+ if !item.DestIp.IsNull() && !item.DestIp.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "dest-ip", item.DestIp.ValueString())
+ }
+ if !item.SrcIp.IsNull() && !item.SrcIp.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "src-ip", item.SrcIp.ValueString())
+ }
+ if !item.TemplateName.IsNull() && !item.TemplateName.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "template-name", item.TemplateName.ValueString())
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-bfd:map/ipv4-list-with-dst-vrf/ipv4", cBody.Res())
+ }
+ }
+ if len(data.Ipv6WithBothVrfs) > 0 {
+ for _, item := range data.Ipv6WithBothVrfs {
+ cBody := netconf.Body{}
+ if !item.DstVrf.IsNull() && !item.DstVrf.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "dst-vrf", item.DstVrf.ValueString())
+ }
+ if !item.DestIpv6.IsNull() && !item.DestIpv6.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "dest-ipv6", item.DestIpv6.ValueString())
+ }
+ if !item.SrcVrf.IsNull() && !item.SrcVrf.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "src-vrf", item.SrcVrf.ValueString())
+ }
+ if !item.SrcIpv6.IsNull() && !item.SrcIpv6.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "src-ipv6", item.SrcIpv6.ValueString())
+ }
+ if !item.TemplateName.IsNull() && !item.TemplateName.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "template-name", item.TemplateName.ValueString())
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-bfd:map/ipv6-list-with-both-vrf/ipv6", cBody.Res())
+ }
+ }
+ if len(data.Ipv6WithoutVrfs) > 0 {
+ for _, item := range data.Ipv6WithoutVrfs {
+ cBody := netconf.Body{}
+ if !item.DestIpv6.IsNull() && !item.DestIpv6.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "dest-ipv6", item.DestIpv6.ValueString())
+ }
+ if !item.SrcIpv6.IsNull() && !item.SrcIpv6.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "src-ipv6", item.SrcIpv6.ValueString())
+ }
+ if !item.TemplateName.IsNull() && !item.TemplateName.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "template-name", item.TemplateName.ValueString())
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-bfd:map/ipv6-list-without-vrf/ipv6", cBody.Res())
+ }
+ }
+ if len(data.Ipv6WithSrcVrfs) > 0 {
+ for _, item := range data.Ipv6WithSrcVrfs {
+ cBody := netconf.Body{}
+ if !item.DestIpv6.IsNull() && !item.DestIpv6.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "dest-ipv6", item.DestIpv6.ValueString())
+ }
+ if !item.SrcVrf.IsNull() && !item.SrcVrf.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "src-vrf", item.SrcVrf.ValueString())
+ }
+ if !item.SrcIpv6.IsNull() && !item.SrcIpv6.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "src-ipv6", item.SrcIpv6.ValueString())
+ }
+ if !item.TemplateName.IsNull() && !item.TemplateName.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "template-name", item.TemplateName.ValueString())
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-bfd:map/ipv6-list-with-src-vrf/ipv6", cBody.Res())
+ }
+ }
+ if len(data.Ipv6WithDstVrfs) > 0 {
+ for _, item := range data.Ipv6WithDstVrfs {
+ cBody := netconf.Body{}
+ if !item.DstVrf.IsNull() && !item.DstVrf.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "dst-vrf", item.DstVrf.ValueString())
+ }
+ if !item.DestIpv6.IsNull() && !item.DestIpv6.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "dest-ipv6", item.DestIpv6.ValueString())
+ }
+ if !item.SrcIpv6.IsNull() && !item.SrcIpv6.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "src-ipv6", item.SrcIpv6.ValueString())
+ }
+ if !item.TemplateName.IsNull() && !item.TemplateName.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "template-name", item.TemplateName.ValueString())
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-bfd:map/ipv6-list-with-dst-vrf/ipv6", cBody.Res())
+ }
+ }
+ if !data.SlowTimers.IsNull() && !data.SlowTimers.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-bfd:slow-timers", strconv.FormatInt(data.SlowTimers.ValueInt64(), 10))
+ }
+ bodyString, err := body.String()
+ if err != nil {
+ tflog.Error(ctx, fmt.Sprintf("Error converting body to string: %s", err))
+ }
+ return bodyString
+}
+
+// End of section. //template:end toBodyXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBody
func (data *BFD) updateFromBody(ctx context.Context, res gjson.Result) {
@@ -655,59 +829,423 @@ func (data *BFD) updateFromBody(ctx context.Context, res gjson.Result) {
// End of section. //template:end updateFromBody
-// Section below is generated&owned by "gen/generator.go". //template:begin fromBody
+// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBodyXML
-func (data *BFD) fromBody(ctx context.Context, res gjson.Result) {
- prefix := helpers.LastElement(data.getPath()) + "."
- if res.Get(helpers.LastElement(data.getPath())).IsArray() {
- prefix += "0."
+func (data *BFD) updateFromBodyXML(ctx context.Context, res xmldot.Result) {
+ for i := range data.Ipv4BothVrfs {
+ keys := [...]string{"dst-vrf", "dest-ip", "src-vrf", "src-ip"}
+ keyValues := [...]string{data.Ipv4BothVrfs[i].DstVrf.ValueString(), data.Ipv4BothVrfs[i].DestIp.ValueString(), data.Ipv4BothVrfs[i].SrcVrf.ValueString(), data.Ipv4BothVrfs[i].SrcIp.ValueString()}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-bfd:map/ipv4-list-with-both-vrf/ipv4").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, "dst-vrf"); value.Exists() && !data.Ipv4BothVrfs[i].DstVrf.IsNull() {
+ data.Ipv4BothVrfs[i].DstVrf = types.StringValue(value.String())
+ } else {
+ data.Ipv4BothVrfs[i].DstVrf = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "dest-ip"); value.Exists() && !data.Ipv4BothVrfs[i].DestIp.IsNull() {
+ data.Ipv4BothVrfs[i].DestIp = types.StringValue(value.String())
+ } else {
+ data.Ipv4BothVrfs[i].DestIp = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "src-vrf"); value.Exists() && !data.Ipv4BothVrfs[i].SrcVrf.IsNull() {
+ data.Ipv4BothVrfs[i].SrcVrf = types.StringValue(value.String())
+ } else {
+ data.Ipv4BothVrfs[i].SrcVrf = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "src-ip"); value.Exists() && !data.Ipv4BothVrfs[i].SrcIp.IsNull() {
+ data.Ipv4BothVrfs[i].SrcIp = types.StringValue(value.String())
+ } else {
+ data.Ipv4BothVrfs[i].SrcIp = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "template-name"); value.Exists() && !data.Ipv4BothVrfs[i].TemplateName.IsNull() {
+ data.Ipv4BothVrfs[i].TemplateName = types.StringValue(value.String())
+ } else {
+ data.Ipv4BothVrfs[i].TemplateName = types.StringNull()
+ }
}
- if value := res.Get(prefix + "Cisco-IOS-XE-bfd:map.ipv4-list-with-both-vrf.ipv4"); value.Exists() {
- data.Ipv4BothVrfs = make([]BFDIpv4BothVrfs, 0)
- value.ForEach(func(k, v gjson.Result) bool {
- item := BFDIpv4BothVrfs{}
- if cValue := v.Get("dst-vrf"); cValue.Exists() {
- item.DstVrf = types.StringValue(cValue.String())
- }
- if cValue := v.Get("dest-ip"); cValue.Exists() {
- item.DestIp = types.StringValue(cValue.String())
- }
- if cValue := v.Get("src-vrf"); cValue.Exists() {
- item.SrcVrf = types.StringValue(cValue.String())
- }
- if cValue := v.Get("src-ip"); cValue.Exists() {
- item.SrcIp = types.StringValue(cValue.String())
- }
- if cValue := v.Get("template-name"); cValue.Exists() {
- item.TemplateName = types.StringValue(cValue.String())
- }
- data.Ipv4BothVrfs = append(data.Ipv4BothVrfs, item)
- return true
- })
+ for i := range data.Ipv4WithoutVrfs {
+ keys := [...]string{"dest-ip", "src-ip"}
+ keyValues := [...]string{data.Ipv4WithoutVrfs[i].DestIp.ValueString(), data.Ipv4WithoutVrfs[i].SrcIp.ValueString()}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-bfd:map/ipv4-list-without-vrf/ipv4").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, "dest-ip"); value.Exists() && !data.Ipv4WithoutVrfs[i].DestIp.IsNull() {
+ data.Ipv4WithoutVrfs[i].DestIp = types.StringValue(value.String())
+ } else {
+ data.Ipv4WithoutVrfs[i].DestIp = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "src-ip"); value.Exists() && !data.Ipv4WithoutVrfs[i].SrcIp.IsNull() {
+ data.Ipv4WithoutVrfs[i].SrcIp = types.StringValue(value.String())
+ } else {
+ data.Ipv4WithoutVrfs[i].SrcIp = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "template-name"); value.Exists() && !data.Ipv4WithoutVrfs[i].TemplateName.IsNull() {
+ data.Ipv4WithoutVrfs[i].TemplateName = types.StringValue(value.String())
+ } else {
+ data.Ipv4WithoutVrfs[i].TemplateName = types.StringNull()
+ }
}
- if value := res.Get(prefix + "Cisco-IOS-XE-bfd:map.ipv4-list-without-vrf.ipv4"); value.Exists() {
- data.Ipv4WithoutVrfs = make([]BFDIpv4WithoutVrfs, 0)
- value.ForEach(func(k, v gjson.Result) bool {
- item := BFDIpv4WithoutVrfs{}
- if cValue := v.Get("dest-ip"); cValue.Exists() {
- item.DestIp = types.StringValue(cValue.String())
- }
- if cValue := v.Get("src-ip"); cValue.Exists() {
- item.SrcIp = types.StringValue(cValue.String())
- }
- if cValue := v.Get("template-name"); cValue.Exists() {
- item.TemplateName = types.StringValue(cValue.String())
- }
- data.Ipv4WithoutVrfs = append(data.Ipv4WithoutVrfs, item)
- return true
- })
+ for i := range data.Ipv4WithSrcVrfs {
+ keys := [...]string{"dest-ip", "src-vrf", "src-ip"}
+ keyValues := [...]string{data.Ipv4WithSrcVrfs[i].DestIp.ValueString(), data.Ipv4WithSrcVrfs[i].SrcVrf.ValueString(), data.Ipv4WithSrcVrfs[i].SrcIp.ValueString()}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-bfd:map/ipv4-list-with-src-vrf/ipv4").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, "dest-ip"); value.Exists() && !data.Ipv4WithSrcVrfs[i].DestIp.IsNull() {
+ data.Ipv4WithSrcVrfs[i].DestIp = types.StringValue(value.String())
+ } else {
+ data.Ipv4WithSrcVrfs[i].DestIp = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "src-vrf"); value.Exists() && !data.Ipv4WithSrcVrfs[i].SrcVrf.IsNull() {
+ data.Ipv4WithSrcVrfs[i].SrcVrf = types.StringValue(value.String())
+ } else {
+ data.Ipv4WithSrcVrfs[i].SrcVrf = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "src-ip"); value.Exists() && !data.Ipv4WithSrcVrfs[i].SrcIp.IsNull() {
+ data.Ipv4WithSrcVrfs[i].SrcIp = types.StringValue(value.String())
+ } else {
+ data.Ipv4WithSrcVrfs[i].SrcIp = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "template-name"); value.Exists() && !data.Ipv4WithSrcVrfs[i].TemplateName.IsNull() {
+ data.Ipv4WithSrcVrfs[i].TemplateName = types.StringValue(value.String())
+ } else {
+ data.Ipv4WithSrcVrfs[i].TemplateName = types.StringNull()
+ }
}
- if value := res.Get(prefix + "Cisco-IOS-XE-bfd:map.ipv4-list-with-src-vrf.ipv4"); value.Exists() {
- data.Ipv4WithSrcVrfs = make([]BFDIpv4WithSrcVrfs, 0)
- value.ForEach(func(k, v gjson.Result) bool {
- item := BFDIpv4WithSrcVrfs{}
- if cValue := v.Get("dest-ip"); cValue.Exists() {
- item.DestIp = types.StringValue(cValue.String())
+ for i := range data.Ipv4WithDstVrfs {
+ keys := [...]string{"dst-vrf", "dest-ip", "src-ip"}
+ keyValues := [...]string{data.Ipv4WithDstVrfs[i].DstVrf.ValueString(), data.Ipv4WithDstVrfs[i].DestIp.ValueString(), data.Ipv4WithDstVrfs[i].SrcIp.ValueString()}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-bfd:map/ipv4-list-with-dst-vrf/ipv4").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, "dst-vrf"); value.Exists() && !data.Ipv4WithDstVrfs[i].DstVrf.IsNull() {
+ data.Ipv4WithDstVrfs[i].DstVrf = types.StringValue(value.String())
+ } else {
+ data.Ipv4WithDstVrfs[i].DstVrf = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "dest-ip"); value.Exists() && !data.Ipv4WithDstVrfs[i].DestIp.IsNull() {
+ data.Ipv4WithDstVrfs[i].DestIp = types.StringValue(value.String())
+ } else {
+ data.Ipv4WithDstVrfs[i].DestIp = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "src-ip"); value.Exists() && !data.Ipv4WithDstVrfs[i].SrcIp.IsNull() {
+ data.Ipv4WithDstVrfs[i].SrcIp = types.StringValue(value.String())
+ } else {
+ data.Ipv4WithDstVrfs[i].SrcIp = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "template-name"); value.Exists() && !data.Ipv4WithDstVrfs[i].TemplateName.IsNull() {
+ data.Ipv4WithDstVrfs[i].TemplateName = types.StringValue(value.String())
+ } else {
+ data.Ipv4WithDstVrfs[i].TemplateName = types.StringNull()
+ }
+ }
+ for i := range data.Ipv6WithBothVrfs {
+ keys := [...]string{"dst-vrf", "dest-ipv6", "src-vrf", "src-ipv6"}
+ keyValues := [...]string{data.Ipv6WithBothVrfs[i].DstVrf.ValueString(), data.Ipv6WithBothVrfs[i].DestIpv6.ValueString(), data.Ipv6WithBothVrfs[i].SrcVrf.ValueString(), data.Ipv6WithBothVrfs[i].SrcIpv6.ValueString()}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-bfd:map/ipv6-list-with-both-vrf/ipv6").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, "dst-vrf"); value.Exists() && !data.Ipv6WithBothVrfs[i].DstVrf.IsNull() {
+ data.Ipv6WithBothVrfs[i].DstVrf = types.StringValue(value.String())
+ } else {
+ data.Ipv6WithBothVrfs[i].DstVrf = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "dest-ipv6"); value.Exists() && !data.Ipv6WithBothVrfs[i].DestIpv6.IsNull() {
+ data.Ipv6WithBothVrfs[i].DestIpv6 = types.StringValue(value.String())
+ } else {
+ data.Ipv6WithBothVrfs[i].DestIpv6 = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "src-vrf"); value.Exists() && !data.Ipv6WithBothVrfs[i].SrcVrf.IsNull() {
+ data.Ipv6WithBothVrfs[i].SrcVrf = types.StringValue(value.String())
+ } else {
+ data.Ipv6WithBothVrfs[i].SrcVrf = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "src-ipv6"); value.Exists() && !data.Ipv6WithBothVrfs[i].SrcIpv6.IsNull() {
+ data.Ipv6WithBothVrfs[i].SrcIpv6 = types.StringValue(value.String())
+ } else {
+ data.Ipv6WithBothVrfs[i].SrcIpv6 = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "template-name"); value.Exists() && !data.Ipv6WithBothVrfs[i].TemplateName.IsNull() {
+ data.Ipv6WithBothVrfs[i].TemplateName = types.StringValue(value.String())
+ } else {
+ data.Ipv6WithBothVrfs[i].TemplateName = types.StringNull()
+ }
+ }
+ for i := range data.Ipv6WithoutVrfs {
+ keys := [...]string{"dest-ipv6", "src-ipv6"}
+ keyValues := [...]string{data.Ipv6WithoutVrfs[i].DestIpv6.ValueString(), data.Ipv6WithoutVrfs[i].SrcIpv6.ValueString()}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-bfd:map/ipv6-list-without-vrf/ipv6").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, "dest-ipv6"); value.Exists() && !data.Ipv6WithoutVrfs[i].DestIpv6.IsNull() {
+ data.Ipv6WithoutVrfs[i].DestIpv6 = types.StringValue(value.String())
+ } else {
+ data.Ipv6WithoutVrfs[i].DestIpv6 = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "src-ipv6"); value.Exists() && !data.Ipv6WithoutVrfs[i].SrcIpv6.IsNull() {
+ data.Ipv6WithoutVrfs[i].SrcIpv6 = types.StringValue(value.String())
+ } else {
+ data.Ipv6WithoutVrfs[i].SrcIpv6 = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "template-name"); value.Exists() && !data.Ipv6WithoutVrfs[i].TemplateName.IsNull() {
+ data.Ipv6WithoutVrfs[i].TemplateName = types.StringValue(value.String())
+ } else {
+ data.Ipv6WithoutVrfs[i].TemplateName = types.StringNull()
+ }
+ }
+ for i := range data.Ipv6WithSrcVrfs {
+ keys := [...]string{"dest-ipv6", "src-vrf", "src-ipv6"}
+ keyValues := [...]string{data.Ipv6WithSrcVrfs[i].DestIpv6.ValueString(), data.Ipv6WithSrcVrfs[i].SrcVrf.ValueString(), data.Ipv6WithSrcVrfs[i].SrcIpv6.ValueString()}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-bfd:map/ipv6-list-with-src-vrf/ipv6").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, "dest-ipv6"); value.Exists() && !data.Ipv6WithSrcVrfs[i].DestIpv6.IsNull() {
+ data.Ipv6WithSrcVrfs[i].DestIpv6 = types.StringValue(value.String())
+ } else {
+ data.Ipv6WithSrcVrfs[i].DestIpv6 = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "src-vrf"); value.Exists() && !data.Ipv6WithSrcVrfs[i].SrcVrf.IsNull() {
+ data.Ipv6WithSrcVrfs[i].SrcVrf = types.StringValue(value.String())
+ } else {
+ data.Ipv6WithSrcVrfs[i].SrcVrf = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "src-ipv6"); value.Exists() && !data.Ipv6WithSrcVrfs[i].SrcIpv6.IsNull() {
+ data.Ipv6WithSrcVrfs[i].SrcIpv6 = types.StringValue(value.String())
+ } else {
+ data.Ipv6WithSrcVrfs[i].SrcIpv6 = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "template-name"); value.Exists() && !data.Ipv6WithSrcVrfs[i].TemplateName.IsNull() {
+ data.Ipv6WithSrcVrfs[i].TemplateName = types.StringValue(value.String())
+ } else {
+ data.Ipv6WithSrcVrfs[i].TemplateName = types.StringNull()
+ }
+ }
+ for i := range data.Ipv6WithDstVrfs {
+ keys := [...]string{"dst-vrf", "dest-ipv6", "src-ipv6"}
+ keyValues := [...]string{data.Ipv6WithDstVrfs[i].DstVrf.ValueString(), data.Ipv6WithDstVrfs[i].DestIpv6.ValueString(), data.Ipv6WithDstVrfs[i].SrcIpv6.ValueString()}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-bfd:map/ipv6-list-with-dst-vrf/ipv6").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, "dst-vrf"); value.Exists() && !data.Ipv6WithDstVrfs[i].DstVrf.IsNull() {
+ data.Ipv6WithDstVrfs[i].DstVrf = types.StringValue(value.String())
+ } else {
+ data.Ipv6WithDstVrfs[i].DstVrf = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "dest-ipv6"); value.Exists() && !data.Ipv6WithDstVrfs[i].DestIpv6.IsNull() {
+ data.Ipv6WithDstVrfs[i].DestIpv6 = types.StringValue(value.String())
+ } else {
+ data.Ipv6WithDstVrfs[i].DestIpv6 = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "src-ipv6"); value.Exists() && !data.Ipv6WithDstVrfs[i].SrcIpv6.IsNull() {
+ data.Ipv6WithDstVrfs[i].SrcIpv6 = types.StringValue(value.String())
+ } else {
+ data.Ipv6WithDstVrfs[i].SrcIpv6 = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "template-name"); value.Exists() && !data.Ipv6WithDstVrfs[i].TemplateName.IsNull() {
+ data.Ipv6WithDstVrfs[i].TemplateName = types.StringValue(value.String())
+ } else {
+ data.Ipv6WithDstVrfs[i].TemplateName = types.StringNull()
+ }
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-bfd:slow-timers"); value.Exists() && !data.SlowTimers.IsNull() {
+ data.SlowTimers = types.Int64Value(value.Int())
+ } else {
+ data.SlowTimers = types.Int64Null()
+ }
+}
+
+// End of section. //template:end updateFromBodyXML
+
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBody
+
+func (data *BFD) fromBody(ctx context.Context, res gjson.Result) {
+ prefix := helpers.LastElement(data.getPath()) + "."
+ if res.Get(helpers.LastElement(data.getPath())).IsArray() {
+ prefix += "0."
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-bfd:map.ipv4-list-with-both-vrf.ipv4"); value.Exists() {
+ data.Ipv4BothVrfs = make([]BFDIpv4BothVrfs, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := BFDIpv4BothVrfs{}
+ if cValue := v.Get("dst-vrf"); cValue.Exists() {
+ item.DstVrf = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("dest-ip"); cValue.Exists() {
+ item.DestIp = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("src-vrf"); cValue.Exists() {
+ item.SrcVrf = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("src-ip"); cValue.Exists() {
+ item.SrcIp = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("template-name"); cValue.Exists() {
+ item.TemplateName = types.StringValue(cValue.String())
+ }
+ data.Ipv4BothVrfs = append(data.Ipv4BothVrfs, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-bfd:map.ipv4-list-without-vrf.ipv4"); value.Exists() {
+ data.Ipv4WithoutVrfs = make([]BFDIpv4WithoutVrfs, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := BFDIpv4WithoutVrfs{}
+ if cValue := v.Get("dest-ip"); cValue.Exists() {
+ item.DestIp = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("src-ip"); cValue.Exists() {
+ item.SrcIp = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("template-name"); cValue.Exists() {
+ item.TemplateName = types.StringValue(cValue.String())
+ }
+ data.Ipv4WithoutVrfs = append(data.Ipv4WithoutVrfs, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-bfd:map.ipv4-list-with-src-vrf.ipv4"); value.Exists() {
+ data.Ipv4WithSrcVrfs = make([]BFDIpv4WithSrcVrfs, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := BFDIpv4WithSrcVrfs{}
+ if cValue := v.Get("dest-ip"); cValue.Exists() {
+ item.DestIp = types.StringValue(cValue.String())
}
if cValue := v.Get("src-vrf"); cValue.Exists() {
item.SrcVrf = types.StringValue(cValue.String())
@@ -1003,18 +1541,358 @@ func (data *BFDData) fromBody(ctx context.Context, res gjson.Result) {
// End of section. //template:end fromBodyData
-// Section below is generated&owned by "gen/generator.go". //template:begin getDeletedItems
-
-func (data *BFD) getDeletedItems(ctx context.Context, state BFD) []string {
- deletedItems := make([]string, 0)
- if !state.SlowTimers.IsNull() && data.SlowTimers.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-bfd:slow-timers", state.getPath()))
- }
- for i := range state.Ipv6WithDstVrfs {
- stateKeyValues := [...]string{state.Ipv6WithDstVrfs[i].DstVrf.ValueString(), state.Ipv6WithDstVrfs[i].DestIpv6.ValueString(), state.Ipv6WithDstVrfs[i].SrcIpv6.ValueString()}
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyXML
- emptyKeys := true
- if !reflect.ValueOf(state.Ipv6WithDstVrfs[i].DstVrf.ValueString()).IsZero() {
+func (data *BFD) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-bfd:map/ipv4-list-with-both-vrf/ipv4"); value.Exists() {
+ data.Ipv4BothVrfs = make([]BFDIpv4BothVrfs, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := BFDIpv4BothVrfs{}
+ if cValue := helpers.GetFromXPath(v, "dst-vrf"); cValue.Exists() {
+ item.DstVrf = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "dest-ip"); cValue.Exists() {
+ item.DestIp = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "src-vrf"); cValue.Exists() {
+ item.SrcVrf = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "src-ip"); cValue.Exists() {
+ item.SrcIp = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "template-name"); cValue.Exists() {
+ item.TemplateName = types.StringValue(cValue.String())
+ }
+ data.Ipv4BothVrfs = append(data.Ipv4BothVrfs, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-bfd:map/ipv4-list-without-vrf/ipv4"); value.Exists() {
+ data.Ipv4WithoutVrfs = make([]BFDIpv4WithoutVrfs, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := BFDIpv4WithoutVrfs{}
+ if cValue := helpers.GetFromXPath(v, "dest-ip"); cValue.Exists() {
+ item.DestIp = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "src-ip"); cValue.Exists() {
+ item.SrcIp = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "template-name"); cValue.Exists() {
+ item.TemplateName = types.StringValue(cValue.String())
+ }
+ data.Ipv4WithoutVrfs = append(data.Ipv4WithoutVrfs, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-bfd:map/ipv4-list-with-src-vrf/ipv4"); value.Exists() {
+ data.Ipv4WithSrcVrfs = make([]BFDIpv4WithSrcVrfs, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := BFDIpv4WithSrcVrfs{}
+ if cValue := helpers.GetFromXPath(v, "dest-ip"); cValue.Exists() {
+ item.DestIp = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "src-vrf"); cValue.Exists() {
+ item.SrcVrf = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "src-ip"); cValue.Exists() {
+ item.SrcIp = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "template-name"); cValue.Exists() {
+ item.TemplateName = types.StringValue(cValue.String())
+ }
+ data.Ipv4WithSrcVrfs = append(data.Ipv4WithSrcVrfs, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-bfd:map/ipv4-list-with-dst-vrf/ipv4"); value.Exists() {
+ data.Ipv4WithDstVrfs = make([]BFDIpv4WithDstVrfs, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := BFDIpv4WithDstVrfs{}
+ if cValue := helpers.GetFromXPath(v, "dst-vrf"); cValue.Exists() {
+ item.DstVrf = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "dest-ip"); cValue.Exists() {
+ item.DestIp = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "src-ip"); cValue.Exists() {
+ item.SrcIp = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "template-name"); cValue.Exists() {
+ item.TemplateName = types.StringValue(cValue.String())
+ }
+ data.Ipv4WithDstVrfs = append(data.Ipv4WithDstVrfs, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-bfd:map/ipv6-list-with-both-vrf/ipv6"); value.Exists() {
+ data.Ipv6WithBothVrfs = make([]BFDIpv6WithBothVrfs, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := BFDIpv6WithBothVrfs{}
+ if cValue := helpers.GetFromXPath(v, "dst-vrf"); cValue.Exists() {
+ item.DstVrf = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "dest-ipv6"); cValue.Exists() {
+ item.DestIpv6 = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "src-vrf"); cValue.Exists() {
+ item.SrcVrf = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "src-ipv6"); cValue.Exists() {
+ item.SrcIpv6 = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "template-name"); cValue.Exists() {
+ item.TemplateName = types.StringValue(cValue.String())
+ }
+ data.Ipv6WithBothVrfs = append(data.Ipv6WithBothVrfs, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-bfd:map/ipv6-list-without-vrf/ipv6"); value.Exists() {
+ data.Ipv6WithoutVrfs = make([]BFDIpv6WithoutVrfs, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := BFDIpv6WithoutVrfs{}
+ if cValue := helpers.GetFromXPath(v, "dest-ipv6"); cValue.Exists() {
+ item.DestIpv6 = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "src-ipv6"); cValue.Exists() {
+ item.SrcIpv6 = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "template-name"); cValue.Exists() {
+ item.TemplateName = types.StringValue(cValue.String())
+ }
+ data.Ipv6WithoutVrfs = append(data.Ipv6WithoutVrfs, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-bfd:map/ipv6-list-with-src-vrf/ipv6"); value.Exists() {
+ data.Ipv6WithSrcVrfs = make([]BFDIpv6WithSrcVrfs, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := BFDIpv6WithSrcVrfs{}
+ if cValue := helpers.GetFromXPath(v, "dest-ipv6"); cValue.Exists() {
+ item.DestIpv6 = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "src-vrf"); cValue.Exists() {
+ item.SrcVrf = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "src-ipv6"); cValue.Exists() {
+ item.SrcIpv6 = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "template-name"); cValue.Exists() {
+ item.TemplateName = types.StringValue(cValue.String())
+ }
+ data.Ipv6WithSrcVrfs = append(data.Ipv6WithSrcVrfs, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-bfd:map/ipv6-list-with-dst-vrf/ipv6"); value.Exists() {
+ data.Ipv6WithDstVrfs = make([]BFDIpv6WithDstVrfs, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := BFDIpv6WithDstVrfs{}
+ if cValue := helpers.GetFromXPath(v, "dst-vrf"); cValue.Exists() {
+ item.DstVrf = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "dest-ipv6"); cValue.Exists() {
+ item.DestIpv6 = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "src-ipv6"); cValue.Exists() {
+ item.SrcIpv6 = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "template-name"); cValue.Exists() {
+ item.TemplateName = types.StringValue(cValue.String())
+ }
+ data.Ipv6WithDstVrfs = append(data.Ipv6WithDstVrfs, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-bfd:slow-timers"); value.Exists() {
+ data.SlowTimers = types.Int64Value(value.Int())
+ }
+}
+
+// End of section. //template:end fromBodyXML
+
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyDataXML
+
+func (data *BFDData) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-bfd:map/ipv4-list-with-both-vrf/ipv4"); value.Exists() {
+ data.Ipv4BothVrfs = make([]BFDIpv4BothVrfs, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := BFDIpv4BothVrfs{}
+ if cValue := helpers.GetFromXPath(v, "dst-vrf"); cValue.Exists() {
+ item.DstVrf = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "dest-ip"); cValue.Exists() {
+ item.DestIp = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "src-vrf"); cValue.Exists() {
+ item.SrcVrf = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "src-ip"); cValue.Exists() {
+ item.SrcIp = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "template-name"); cValue.Exists() {
+ item.TemplateName = types.StringValue(cValue.String())
+ }
+ data.Ipv4BothVrfs = append(data.Ipv4BothVrfs, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-bfd:map/ipv4-list-without-vrf/ipv4"); value.Exists() {
+ data.Ipv4WithoutVrfs = make([]BFDIpv4WithoutVrfs, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := BFDIpv4WithoutVrfs{}
+ if cValue := helpers.GetFromXPath(v, "dest-ip"); cValue.Exists() {
+ item.DestIp = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "src-ip"); cValue.Exists() {
+ item.SrcIp = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "template-name"); cValue.Exists() {
+ item.TemplateName = types.StringValue(cValue.String())
+ }
+ data.Ipv4WithoutVrfs = append(data.Ipv4WithoutVrfs, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-bfd:map/ipv4-list-with-src-vrf/ipv4"); value.Exists() {
+ data.Ipv4WithSrcVrfs = make([]BFDIpv4WithSrcVrfs, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := BFDIpv4WithSrcVrfs{}
+ if cValue := helpers.GetFromXPath(v, "dest-ip"); cValue.Exists() {
+ item.DestIp = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "src-vrf"); cValue.Exists() {
+ item.SrcVrf = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "src-ip"); cValue.Exists() {
+ item.SrcIp = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "template-name"); cValue.Exists() {
+ item.TemplateName = types.StringValue(cValue.String())
+ }
+ data.Ipv4WithSrcVrfs = append(data.Ipv4WithSrcVrfs, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-bfd:map/ipv4-list-with-dst-vrf/ipv4"); value.Exists() {
+ data.Ipv4WithDstVrfs = make([]BFDIpv4WithDstVrfs, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := BFDIpv4WithDstVrfs{}
+ if cValue := helpers.GetFromXPath(v, "dst-vrf"); cValue.Exists() {
+ item.DstVrf = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "dest-ip"); cValue.Exists() {
+ item.DestIp = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "src-ip"); cValue.Exists() {
+ item.SrcIp = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "template-name"); cValue.Exists() {
+ item.TemplateName = types.StringValue(cValue.String())
+ }
+ data.Ipv4WithDstVrfs = append(data.Ipv4WithDstVrfs, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-bfd:map/ipv6-list-with-both-vrf/ipv6"); value.Exists() {
+ data.Ipv6WithBothVrfs = make([]BFDIpv6WithBothVrfs, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := BFDIpv6WithBothVrfs{}
+ if cValue := helpers.GetFromXPath(v, "dst-vrf"); cValue.Exists() {
+ item.DstVrf = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "dest-ipv6"); cValue.Exists() {
+ item.DestIpv6 = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "src-vrf"); cValue.Exists() {
+ item.SrcVrf = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "src-ipv6"); cValue.Exists() {
+ item.SrcIpv6 = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "template-name"); cValue.Exists() {
+ item.TemplateName = types.StringValue(cValue.String())
+ }
+ data.Ipv6WithBothVrfs = append(data.Ipv6WithBothVrfs, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-bfd:map/ipv6-list-without-vrf/ipv6"); value.Exists() {
+ data.Ipv6WithoutVrfs = make([]BFDIpv6WithoutVrfs, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := BFDIpv6WithoutVrfs{}
+ if cValue := helpers.GetFromXPath(v, "dest-ipv6"); cValue.Exists() {
+ item.DestIpv6 = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "src-ipv6"); cValue.Exists() {
+ item.SrcIpv6 = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "template-name"); cValue.Exists() {
+ item.TemplateName = types.StringValue(cValue.String())
+ }
+ data.Ipv6WithoutVrfs = append(data.Ipv6WithoutVrfs, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-bfd:map/ipv6-list-with-src-vrf/ipv6"); value.Exists() {
+ data.Ipv6WithSrcVrfs = make([]BFDIpv6WithSrcVrfs, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := BFDIpv6WithSrcVrfs{}
+ if cValue := helpers.GetFromXPath(v, "dest-ipv6"); cValue.Exists() {
+ item.DestIpv6 = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "src-vrf"); cValue.Exists() {
+ item.SrcVrf = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "src-ipv6"); cValue.Exists() {
+ item.SrcIpv6 = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "template-name"); cValue.Exists() {
+ item.TemplateName = types.StringValue(cValue.String())
+ }
+ data.Ipv6WithSrcVrfs = append(data.Ipv6WithSrcVrfs, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-bfd:map/ipv6-list-with-dst-vrf/ipv6"); value.Exists() {
+ data.Ipv6WithDstVrfs = make([]BFDIpv6WithDstVrfs, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := BFDIpv6WithDstVrfs{}
+ if cValue := helpers.GetFromXPath(v, "dst-vrf"); cValue.Exists() {
+ item.DstVrf = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "dest-ipv6"); cValue.Exists() {
+ item.DestIpv6 = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "src-ipv6"); cValue.Exists() {
+ item.SrcIpv6 = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "template-name"); cValue.Exists() {
+ item.TemplateName = types.StringValue(cValue.String())
+ }
+ data.Ipv6WithDstVrfs = append(data.Ipv6WithDstVrfs, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-bfd:slow-timers"); value.Exists() {
+ data.SlowTimers = types.Int64Value(value.Int())
+ }
+}
+
+// End of section. //template:end fromBodyDataXML
+
+// Section below is generated&owned by "gen/generator.go". //template:begin getDeletedItems
+
+func (data *BFD) getDeletedItems(ctx context.Context, state BFD) []string {
+ deletedItems := make([]string, 0)
+ if !state.SlowTimers.IsNull() && data.SlowTimers.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-bfd:slow-timers", state.getPath()))
+ }
+ for i := range state.Ipv6WithDstVrfs {
+ stateKeyValues := [...]string{state.Ipv6WithDstVrfs[i].DstVrf.ValueString(), state.Ipv6WithDstVrfs[i].DestIpv6.ValueString(), state.Ipv6WithDstVrfs[i].SrcIpv6.ValueString()}
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.Ipv6WithDstVrfs[i].DstVrf.ValueString()).IsZero() {
emptyKeys = false
}
if !reflect.ValueOf(state.Ipv6WithDstVrfs[i].DestIpv6.ValueString()).IsZero() {
@@ -1336,13 +2214,386 @@ func (data *BFD) getDeletedItems(ctx context.Context, state BFD) []string {
// End of section. //template:end getDeletedItems
-// Section below is generated&owned by "gen/generator.go". //template:begin getEmptyLeafsDelete
-
-func (data *BFD) getEmptyLeafsDelete(ctx context.Context) []string {
- emptyLeafsDelete := make([]string, 0)
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletedItemsXML
- return emptyLeafsDelete
-}
+func (data *BFD) addDeletedItemsXML(ctx context.Context, state BFD, body string) string {
+ b := netconf.NewBody(body)
+ for i := range state.Ipv4BothVrfs {
+ stateKeys := [...]string{"dst-vrf", "dest-ip", "src-vrf", "src-ip"}
+ stateKeyValues := [...]string{state.Ipv4BothVrfs[i].DstVrf.ValueString(), state.Ipv4BothVrfs[i].DestIp.ValueString(), state.Ipv4BothVrfs[i].SrcVrf.ValueString(), state.Ipv4BothVrfs[i].SrcIp.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.Ipv4BothVrfs[i].DstVrf.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if !reflect.ValueOf(state.Ipv4BothVrfs[i].DestIp.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if !reflect.ValueOf(state.Ipv4BothVrfs[i].SrcVrf.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if !reflect.ValueOf(state.Ipv4BothVrfs[i].SrcIp.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.Ipv4BothVrfs {
+ found = true
+ if state.Ipv4BothVrfs[i].DstVrf.ValueString() != data.Ipv4BothVrfs[j].DstVrf.ValueString() {
+ found = false
+ }
+ if state.Ipv4BothVrfs[i].DestIp.ValueString() != data.Ipv4BothVrfs[j].DestIp.ValueString() {
+ found = false
+ }
+ if state.Ipv4BothVrfs[i].SrcVrf.ValueString() != data.Ipv4BothVrfs[j].SrcVrf.ValueString() {
+ found = false
+ }
+ if state.Ipv4BothVrfs[i].SrcIp.ValueString() != data.Ipv4BothVrfs[j].SrcIp.ValueString() {
+ found = false
+ }
+ if found {
+ if !state.Ipv4BothVrfs[i].TemplateName.IsNull() && data.Ipv4BothVrfs[j].TemplateName.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-bfd:map/ipv4-list-with-both-vrf/ipv4%v/template-name", predicates))
+ }
+ break
+ }
+ }
+ if !found {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-bfd:map/ipv4-list-with-both-vrf/ipv4%v", predicates))
+ }
+ }
+ for i := range state.Ipv4WithoutVrfs {
+ stateKeys := [...]string{"dest-ip", "src-ip"}
+ stateKeyValues := [...]string{state.Ipv4WithoutVrfs[i].DestIp.ValueString(), state.Ipv4WithoutVrfs[i].SrcIp.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.Ipv4WithoutVrfs[i].DestIp.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if !reflect.ValueOf(state.Ipv4WithoutVrfs[i].SrcIp.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.Ipv4WithoutVrfs {
+ found = true
+ if state.Ipv4WithoutVrfs[i].DestIp.ValueString() != data.Ipv4WithoutVrfs[j].DestIp.ValueString() {
+ found = false
+ }
+ if state.Ipv4WithoutVrfs[i].SrcIp.ValueString() != data.Ipv4WithoutVrfs[j].SrcIp.ValueString() {
+ found = false
+ }
+ if found {
+ if !state.Ipv4WithoutVrfs[i].TemplateName.IsNull() && data.Ipv4WithoutVrfs[j].TemplateName.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-bfd:map/ipv4-list-without-vrf/ipv4%v/template-name", predicates))
+ }
+ break
+ }
+ }
+ if !found {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-bfd:map/ipv4-list-without-vrf/ipv4%v", predicates))
+ }
+ }
+ for i := range state.Ipv4WithSrcVrfs {
+ stateKeys := [...]string{"dest-ip", "src-vrf", "src-ip"}
+ stateKeyValues := [...]string{state.Ipv4WithSrcVrfs[i].DestIp.ValueString(), state.Ipv4WithSrcVrfs[i].SrcVrf.ValueString(), state.Ipv4WithSrcVrfs[i].SrcIp.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.Ipv4WithSrcVrfs[i].DestIp.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if !reflect.ValueOf(state.Ipv4WithSrcVrfs[i].SrcVrf.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if !reflect.ValueOf(state.Ipv4WithSrcVrfs[i].SrcIp.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.Ipv4WithSrcVrfs {
+ found = true
+ if state.Ipv4WithSrcVrfs[i].DestIp.ValueString() != data.Ipv4WithSrcVrfs[j].DestIp.ValueString() {
+ found = false
+ }
+ if state.Ipv4WithSrcVrfs[i].SrcVrf.ValueString() != data.Ipv4WithSrcVrfs[j].SrcVrf.ValueString() {
+ found = false
+ }
+ if state.Ipv4WithSrcVrfs[i].SrcIp.ValueString() != data.Ipv4WithSrcVrfs[j].SrcIp.ValueString() {
+ found = false
+ }
+ if found {
+ if !state.Ipv4WithSrcVrfs[i].TemplateName.IsNull() && data.Ipv4WithSrcVrfs[j].TemplateName.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-bfd:map/ipv4-list-with-src-vrf/ipv4%v/template-name", predicates))
+ }
+ break
+ }
+ }
+ if !found {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-bfd:map/ipv4-list-with-src-vrf/ipv4%v", predicates))
+ }
+ }
+ for i := range state.Ipv4WithDstVrfs {
+ stateKeys := [...]string{"dst-vrf", "dest-ip", "src-ip"}
+ stateKeyValues := [...]string{state.Ipv4WithDstVrfs[i].DstVrf.ValueString(), state.Ipv4WithDstVrfs[i].DestIp.ValueString(), state.Ipv4WithDstVrfs[i].SrcIp.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.Ipv4WithDstVrfs[i].DstVrf.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if !reflect.ValueOf(state.Ipv4WithDstVrfs[i].DestIp.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if !reflect.ValueOf(state.Ipv4WithDstVrfs[i].SrcIp.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.Ipv4WithDstVrfs {
+ found = true
+ if state.Ipv4WithDstVrfs[i].DstVrf.ValueString() != data.Ipv4WithDstVrfs[j].DstVrf.ValueString() {
+ found = false
+ }
+ if state.Ipv4WithDstVrfs[i].DestIp.ValueString() != data.Ipv4WithDstVrfs[j].DestIp.ValueString() {
+ found = false
+ }
+ if state.Ipv4WithDstVrfs[i].SrcIp.ValueString() != data.Ipv4WithDstVrfs[j].SrcIp.ValueString() {
+ found = false
+ }
+ if found {
+ if !state.Ipv4WithDstVrfs[i].TemplateName.IsNull() && data.Ipv4WithDstVrfs[j].TemplateName.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-bfd:map/ipv4-list-with-dst-vrf/ipv4%v/template-name", predicates))
+ }
+ break
+ }
+ }
+ if !found {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-bfd:map/ipv4-list-with-dst-vrf/ipv4%v", predicates))
+ }
+ }
+ for i := range state.Ipv6WithBothVrfs {
+ stateKeys := [...]string{"dst-vrf", "dest-ipv6", "src-vrf", "src-ipv6"}
+ stateKeyValues := [...]string{state.Ipv6WithBothVrfs[i].DstVrf.ValueString(), state.Ipv6WithBothVrfs[i].DestIpv6.ValueString(), state.Ipv6WithBothVrfs[i].SrcVrf.ValueString(), state.Ipv6WithBothVrfs[i].SrcIpv6.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.Ipv6WithBothVrfs[i].DstVrf.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if !reflect.ValueOf(state.Ipv6WithBothVrfs[i].DestIpv6.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if !reflect.ValueOf(state.Ipv6WithBothVrfs[i].SrcVrf.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if !reflect.ValueOf(state.Ipv6WithBothVrfs[i].SrcIpv6.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.Ipv6WithBothVrfs {
+ found = true
+ if state.Ipv6WithBothVrfs[i].DstVrf.ValueString() != data.Ipv6WithBothVrfs[j].DstVrf.ValueString() {
+ found = false
+ }
+ if state.Ipv6WithBothVrfs[i].DestIpv6.ValueString() != data.Ipv6WithBothVrfs[j].DestIpv6.ValueString() {
+ found = false
+ }
+ if state.Ipv6WithBothVrfs[i].SrcVrf.ValueString() != data.Ipv6WithBothVrfs[j].SrcVrf.ValueString() {
+ found = false
+ }
+ if state.Ipv6WithBothVrfs[i].SrcIpv6.ValueString() != data.Ipv6WithBothVrfs[j].SrcIpv6.ValueString() {
+ found = false
+ }
+ if found {
+ if !state.Ipv6WithBothVrfs[i].TemplateName.IsNull() && data.Ipv6WithBothVrfs[j].TemplateName.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-bfd:map/ipv6-list-with-both-vrf/ipv6%v/template-name", predicates))
+ }
+ break
+ }
+ }
+ if !found {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-bfd:map/ipv6-list-with-both-vrf/ipv6%v", predicates))
+ }
+ }
+ for i := range state.Ipv6WithoutVrfs {
+ stateKeys := [...]string{"dest-ipv6", "src-ipv6"}
+ stateKeyValues := [...]string{state.Ipv6WithoutVrfs[i].DestIpv6.ValueString(), state.Ipv6WithoutVrfs[i].SrcIpv6.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.Ipv6WithoutVrfs[i].DestIpv6.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if !reflect.ValueOf(state.Ipv6WithoutVrfs[i].SrcIpv6.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.Ipv6WithoutVrfs {
+ found = true
+ if state.Ipv6WithoutVrfs[i].DestIpv6.ValueString() != data.Ipv6WithoutVrfs[j].DestIpv6.ValueString() {
+ found = false
+ }
+ if state.Ipv6WithoutVrfs[i].SrcIpv6.ValueString() != data.Ipv6WithoutVrfs[j].SrcIpv6.ValueString() {
+ found = false
+ }
+ if found {
+ if !state.Ipv6WithoutVrfs[i].TemplateName.IsNull() && data.Ipv6WithoutVrfs[j].TemplateName.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-bfd:map/ipv6-list-without-vrf/ipv6%v/template-name", predicates))
+ }
+ break
+ }
+ }
+ if !found {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-bfd:map/ipv6-list-without-vrf/ipv6%v", predicates))
+ }
+ }
+ for i := range state.Ipv6WithSrcVrfs {
+ stateKeys := [...]string{"dest-ipv6", "src-vrf", "src-ipv6"}
+ stateKeyValues := [...]string{state.Ipv6WithSrcVrfs[i].DestIpv6.ValueString(), state.Ipv6WithSrcVrfs[i].SrcVrf.ValueString(), state.Ipv6WithSrcVrfs[i].SrcIpv6.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.Ipv6WithSrcVrfs[i].DestIpv6.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if !reflect.ValueOf(state.Ipv6WithSrcVrfs[i].SrcVrf.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if !reflect.ValueOf(state.Ipv6WithSrcVrfs[i].SrcIpv6.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.Ipv6WithSrcVrfs {
+ found = true
+ if state.Ipv6WithSrcVrfs[i].DestIpv6.ValueString() != data.Ipv6WithSrcVrfs[j].DestIpv6.ValueString() {
+ found = false
+ }
+ if state.Ipv6WithSrcVrfs[i].SrcVrf.ValueString() != data.Ipv6WithSrcVrfs[j].SrcVrf.ValueString() {
+ found = false
+ }
+ if state.Ipv6WithSrcVrfs[i].SrcIpv6.ValueString() != data.Ipv6WithSrcVrfs[j].SrcIpv6.ValueString() {
+ found = false
+ }
+ if found {
+ if !state.Ipv6WithSrcVrfs[i].TemplateName.IsNull() && data.Ipv6WithSrcVrfs[j].TemplateName.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-bfd:map/ipv6-list-with-src-vrf/ipv6%v/template-name", predicates))
+ }
+ break
+ }
+ }
+ if !found {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-bfd:map/ipv6-list-with-src-vrf/ipv6%v", predicates))
+ }
+ }
+ for i := range state.Ipv6WithDstVrfs {
+ stateKeys := [...]string{"dst-vrf", "dest-ipv6", "src-ipv6"}
+ stateKeyValues := [...]string{state.Ipv6WithDstVrfs[i].DstVrf.ValueString(), state.Ipv6WithDstVrfs[i].DestIpv6.ValueString(), state.Ipv6WithDstVrfs[i].SrcIpv6.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.Ipv6WithDstVrfs[i].DstVrf.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if !reflect.ValueOf(state.Ipv6WithDstVrfs[i].DestIpv6.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if !reflect.ValueOf(state.Ipv6WithDstVrfs[i].SrcIpv6.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.Ipv6WithDstVrfs {
+ found = true
+ if state.Ipv6WithDstVrfs[i].DstVrf.ValueString() != data.Ipv6WithDstVrfs[j].DstVrf.ValueString() {
+ found = false
+ }
+ if state.Ipv6WithDstVrfs[i].DestIpv6.ValueString() != data.Ipv6WithDstVrfs[j].DestIpv6.ValueString() {
+ found = false
+ }
+ if state.Ipv6WithDstVrfs[i].SrcIpv6.ValueString() != data.Ipv6WithDstVrfs[j].SrcIpv6.ValueString() {
+ found = false
+ }
+ if found {
+ if !state.Ipv6WithDstVrfs[i].TemplateName.IsNull() && data.Ipv6WithDstVrfs[j].TemplateName.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-bfd:map/ipv6-list-with-dst-vrf/ipv6%v/template-name", predicates))
+ }
+ break
+ }
+ }
+ if !found {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-bfd:map/ipv6-list-with-dst-vrf/ipv6%v", predicates))
+ }
+ }
+ if !state.SlowTimers.IsNull() && data.SlowTimers.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-bfd:slow-timers")
+ }
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletedItemsXML
+
+// Section below is generated&owned by "gen/generator.go". //template:begin getEmptyLeafsDelete
+
+func (data *BFD) getEmptyLeafsDelete(ctx context.Context) []string {
+ emptyLeafsDelete := make([]string, 0)
+
+ return emptyLeafsDelete
+}
// End of section. //template:end getEmptyLeafsDelete
@@ -1398,3 +2649,96 @@ func (data *BFD) getDeletePaths(ctx context.Context) []string {
}
// End of section. //template:end getDeletePaths
+
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletePathsXML
+
+func (data *BFD) addDeletePathsXML(ctx context.Context, body string) string {
+ b := netconf.NewBody(body)
+ for i := range data.Ipv4BothVrfs {
+ keys := [...]string{"dst-vrf", "dest-ip", "src-vrf", "src-ip"}
+ keyValues := [...]string{data.Ipv4BothVrfs[i].DstVrf.ValueString(), data.Ipv4BothVrfs[i].DestIp.ValueString(), data.Ipv4BothVrfs[i].SrcVrf.ValueString(), data.Ipv4BothVrfs[i].SrcIp.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/Cisco-IOS-XE-bfd:map/ipv4-list-with-both-vrf/ipv4%v", predicates))
+ }
+ for i := range data.Ipv4WithoutVrfs {
+ keys := [...]string{"dest-ip", "src-ip"}
+ keyValues := [...]string{data.Ipv4WithoutVrfs[i].DestIp.ValueString(), data.Ipv4WithoutVrfs[i].SrcIp.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/Cisco-IOS-XE-bfd:map/ipv4-list-without-vrf/ipv4%v", predicates))
+ }
+ for i := range data.Ipv4WithSrcVrfs {
+ keys := [...]string{"dest-ip", "src-vrf", "src-ip"}
+ keyValues := [...]string{data.Ipv4WithSrcVrfs[i].DestIp.ValueString(), data.Ipv4WithSrcVrfs[i].SrcVrf.ValueString(), data.Ipv4WithSrcVrfs[i].SrcIp.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/Cisco-IOS-XE-bfd:map/ipv4-list-with-src-vrf/ipv4%v", predicates))
+ }
+ for i := range data.Ipv4WithDstVrfs {
+ keys := [...]string{"dst-vrf", "dest-ip", "src-ip"}
+ keyValues := [...]string{data.Ipv4WithDstVrfs[i].DstVrf.ValueString(), data.Ipv4WithDstVrfs[i].DestIp.ValueString(), data.Ipv4WithDstVrfs[i].SrcIp.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/Cisco-IOS-XE-bfd:map/ipv4-list-with-dst-vrf/ipv4%v", predicates))
+ }
+ for i := range data.Ipv6WithBothVrfs {
+ keys := [...]string{"dst-vrf", "dest-ipv6", "src-vrf", "src-ipv6"}
+ keyValues := [...]string{data.Ipv6WithBothVrfs[i].DstVrf.ValueString(), data.Ipv6WithBothVrfs[i].DestIpv6.ValueString(), data.Ipv6WithBothVrfs[i].SrcVrf.ValueString(), data.Ipv6WithBothVrfs[i].SrcIpv6.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/Cisco-IOS-XE-bfd:map/ipv6-list-with-both-vrf/ipv6%v", predicates))
+ }
+ for i := range data.Ipv6WithoutVrfs {
+ keys := [...]string{"dest-ipv6", "src-ipv6"}
+ keyValues := [...]string{data.Ipv6WithoutVrfs[i].DestIpv6.ValueString(), data.Ipv6WithoutVrfs[i].SrcIpv6.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/Cisco-IOS-XE-bfd:map/ipv6-list-without-vrf/ipv6%v", predicates))
+ }
+ for i := range data.Ipv6WithSrcVrfs {
+ keys := [...]string{"dest-ipv6", "src-vrf", "src-ipv6"}
+ keyValues := [...]string{data.Ipv6WithSrcVrfs[i].DestIpv6.ValueString(), data.Ipv6WithSrcVrfs[i].SrcVrf.ValueString(), data.Ipv6WithSrcVrfs[i].SrcIpv6.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/Cisco-IOS-XE-bfd:map/ipv6-list-with-src-vrf/ipv6%v", predicates))
+ }
+ for i := range data.Ipv6WithDstVrfs {
+ keys := [...]string{"dst-vrf", "dest-ipv6", "src-ipv6"}
+ keyValues := [...]string{data.Ipv6WithDstVrfs[i].DstVrf.ValueString(), data.Ipv6WithDstVrfs[i].DestIpv6.ValueString(), data.Ipv6WithDstVrfs[i].SrcIpv6.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/Cisco-IOS-XE-bfd:map/ipv6-list-with-dst-vrf/ipv6%v", predicates))
+ }
+ if !data.SlowTimers.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-bfd:slow-timers")
+ }
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletePathsXML
diff --git a/internal/provider/model_iosxe_bfd_template_multi_hop.go b/internal/provider/model_iosxe_bfd_template_multi_hop.go
index 737cf1e3..61b96f9a 100644
--- a/internal/provider/model_iosxe_bfd_template_multi_hop.go
+++ b/internal/provider/model_iosxe_bfd_template_multi_hop.go
@@ -29,6 +29,9 @@ import (
"github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/types"
+ "github.com/hashicorp/terraform-plugin-log/tflog"
+ "github.com/netascode/go-netconf"
+ "github.com/netascode/xmldot"
"github.com/tidwall/gjson"
"github.com/tidwall/sjson"
)
@@ -111,6 +114,19 @@ func (data BFDTemplateMultiHop) getPathShort() string {
return matches[1]
}
+// getXPath returns the XPath for NETCONF operations
+func (data BFDTemplateMultiHop) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/bfd-template/Cisco-IOS-XE-bfd:multi-hop[name=%s]"
+ path = fmt.Sprintf(path, fmt.Sprintf("%v", data.Name.ValueString()))
+ return path
+}
+
+func (data BFDTemplateMultiHopData) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/bfd-template/Cisco-IOS-XE-bfd:multi-hop[name=%s]"
+ path = fmt.Sprintf(path, fmt.Sprintf("%v", data.Name.ValueString()))
+ return path
+}
+
// End of section. //template:end getPath
// Section below is generated&owned by "gen/generator.go". //template:begin toBody
@@ -191,6 +207,94 @@ func (data BFDTemplateMultiHop) toBody(ctx context.Context) string {
// End of section. //template:end toBody
+// Section below is generated&owned by "gen/generator.go". //template:begin toBodyXML
+
+func (data BFDTemplateMultiHop) toBodyXML(ctx context.Context) string {
+ body := netconf.Body{}
+ if !data.Name.IsNull() && !data.Name.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/name", data.Name.ValueString())
+ }
+ if !data.Echo.IsNull() && !data.Echo.IsUnknown() {
+ if data.Echo.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/echo", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/echo")
+ }
+ }
+ if !data.IntervalMillisecondsBoth.IsNull() && !data.IntervalMillisecondsBoth.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/interval-multihop-v2/mill-unit/both", strconv.FormatInt(data.IntervalMillisecondsBoth.ValueInt64(), 10))
+ }
+ if !data.IntervalMillisecondsMinTx.IsNull() && !data.IntervalMillisecondsMinTx.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/interval-multihop-v2/mill-unit/min-tx", strconv.FormatInt(data.IntervalMillisecondsMinTx.ValueInt64(), 10))
+ }
+ if !data.IntervalMillisecondsMinRx.IsNull() && !data.IntervalMillisecondsMinRx.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/interval-multihop-v2/mill-unit/min-rx", strconv.FormatInt(data.IntervalMillisecondsMinRx.ValueInt64(), 10))
+ }
+ if !data.IntervalMillisecondsMultiplier.IsNull() && !data.IntervalMillisecondsMultiplier.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/interval-multihop-v2/mill-unit/multiplier", strconv.FormatInt(data.IntervalMillisecondsMultiplier.ValueInt64(), 10))
+ }
+ if !data.IntervalMicroseconds.IsNull() && !data.IntervalMicroseconds.IsUnknown() {
+ if data.IntervalMicroseconds.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/interval-multihop-v2/microseconds", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/interval-multihop-v2/microseconds")
+ }
+ }
+ if !data.IntervalMicrosecondsBoth.IsNull() && !data.IntervalMicrosecondsBoth.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/interval-multihop-v2/both", strconv.FormatInt(data.IntervalMicrosecondsBoth.ValueInt64(), 10))
+ }
+ if !data.IntervalMicrosecondsMinTx.IsNull() && !data.IntervalMicrosecondsMinTx.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/interval-multihop-v2/min-tx", strconv.FormatInt(data.IntervalMicrosecondsMinTx.ValueInt64(), 10))
+ }
+ if !data.IntervalMicrosecondsMinRx.IsNull() && !data.IntervalMicrosecondsMinRx.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/interval-multihop-v2/min-rx", strconv.FormatInt(data.IntervalMicrosecondsMinRx.ValueInt64(), 10))
+ }
+ if !data.IntervalMicrosecondsMultiplier.IsNull() && !data.IntervalMicrosecondsMultiplier.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/interval-multihop-v2/multiplier", strconv.FormatInt(data.IntervalMicrosecondsMultiplier.ValueInt64(), 10))
+ }
+ if !data.AuthenticationMd5Keychain.IsNull() && !data.AuthenticationMd5Keychain.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/authentication/md5/keychain", data.AuthenticationMd5Keychain.ValueString())
+ }
+ if !data.AuthenticationMeticulousMd5Keychain.IsNull() && !data.AuthenticationMeticulousMd5Keychain.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/authentication/meticulous-md5/keychain", data.AuthenticationMeticulousMd5Keychain.ValueString())
+ }
+ if !data.AuthenticationMeticulousSha1keychain.IsNull() && !data.AuthenticationMeticulousSha1keychain.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/authentication/meticulous-sha-1_keychain", data.AuthenticationMeticulousSha1keychain.ValueString())
+ }
+ if !data.AuthenticationSha1Keychain.IsNull() && !data.AuthenticationSha1Keychain.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/authentication/sha-1/keychain", data.AuthenticationSha1Keychain.ValueString())
+ }
+ if !data.DampeningHalfTime.IsNull() && !data.DampeningHalfTime.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/dampening/half-time", strconv.FormatInt(data.DampeningHalfTime.ValueInt64(), 10))
+ }
+ if !data.DampeningUnsuppressTime.IsNull() && !data.DampeningUnsuppressTime.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/dampening/unsuppress-time", strconv.FormatInt(data.DampeningUnsuppressTime.ValueInt64(), 10))
+ }
+ if !data.DampeningSuppressTime.IsNull() && !data.DampeningSuppressTime.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/dampening/suppress-time", strconv.FormatInt(data.DampeningSuppressTime.ValueInt64(), 10))
+ }
+ if !data.DampeningMaxSuppressingTime.IsNull() && !data.DampeningMaxSuppressingTime.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/dampening/max-suppressing-time", strconv.FormatInt(data.DampeningMaxSuppressingTime.ValueInt64(), 10))
+ }
+ if !data.DampeningThreshold.IsNull() && !data.DampeningThreshold.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/dampening/threshold", strconv.FormatInt(data.DampeningThreshold.ValueInt64(), 10))
+ }
+ if !data.DampeningDownMonitoring.IsNull() && !data.DampeningDownMonitoring.IsUnknown() {
+ if data.DampeningDownMonitoring.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/dampening/down-monitoring", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/dampening/down-monitoring")
+ }
+ }
+ bodyString, err := body.String()
+ if err != nil {
+ tflog.Error(ctx, fmt.Sprintf("Error converting body to string: %s", err))
+ }
+ return bodyString
+}
+
+// End of section. //template:end toBodyXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBody
func (data *BFDTemplateMultiHop) updateFromBody(ctx context.Context, res gjson.Result) {
@@ -319,6 +423,130 @@ func (data *BFDTemplateMultiHop) updateFromBody(ctx context.Context, res gjson.R
// End of section. //template:end updateFromBody
+// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBodyXML
+
+func (data *BFDTemplateMultiHop) updateFromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/name"); value.Exists() && !data.Name.IsNull() {
+ data.Name = types.StringValue(value.String())
+ } else {
+ data.Name = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/echo"); !data.Echo.IsNull() {
+ if value.Exists() {
+ data.Echo = types.BoolValue(true)
+ } else {
+ data.Echo = types.BoolValue(false)
+ }
+ } else {
+ data.Echo = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/interval-multihop-v2/mill-unit/both"); value.Exists() && !data.IntervalMillisecondsBoth.IsNull() {
+ data.IntervalMillisecondsBoth = types.Int64Value(value.Int())
+ } else {
+ data.IntervalMillisecondsBoth = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/interval-multihop-v2/mill-unit/min-tx"); value.Exists() && !data.IntervalMillisecondsMinTx.IsNull() {
+ data.IntervalMillisecondsMinTx = types.Int64Value(value.Int())
+ } else {
+ data.IntervalMillisecondsMinTx = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/interval-multihop-v2/mill-unit/min-rx"); value.Exists() && !data.IntervalMillisecondsMinRx.IsNull() {
+ data.IntervalMillisecondsMinRx = types.Int64Value(value.Int())
+ } else {
+ data.IntervalMillisecondsMinRx = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/interval-multihop-v2/mill-unit/multiplier"); value.Exists() && !data.IntervalMillisecondsMultiplier.IsNull() {
+ data.IntervalMillisecondsMultiplier = types.Int64Value(value.Int())
+ } else {
+ data.IntervalMillisecondsMultiplier = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/interval-multihop-v2/microseconds"); !data.IntervalMicroseconds.IsNull() {
+ if value.Exists() {
+ data.IntervalMicroseconds = types.BoolValue(true)
+ } else {
+ data.IntervalMicroseconds = types.BoolValue(false)
+ }
+ } else {
+ data.IntervalMicroseconds = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/interval-multihop-v2/both"); value.Exists() && !data.IntervalMicrosecondsBoth.IsNull() {
+ data.IntervalMicrosecondsBoth = types.Int64Value(value.Int())
+ } else {
+ data.IntervalMicrosecondsBoth = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/interval-multihop-v2/min-tx"); value.Exists() && !data.IntervalMicrosecondsMinTx.IsNull() {
+ data.IntervalMicrosecondsMinTx = types.Int64Value(value.Int())
+ } else {
+ data.IntervalMicrosecondsMinTx = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/interval-multihop-v2/min-rx"); value.Exists() && !data.IntervalMicrosecondsMinRx.IsNull() {
+ data.IntervalMicrosecondsMinRx = types.Int64Value(value.Int())
+ } else {
+ data.IntervalMicrosecondsMinRx = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/interval-multihop-v2/multiplier"); value.Exists() && !data.IntervalMicrosecondsMultiplier.IsNull() {
+ data.IntervalMicrosecondsMultiplier = types.Int64Value(value.Int())
+ } else {
+ data.IntervalMicrosecondsMultiplier = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/authentication/md5/keychain"); value.Exists() && !data.AuthenticationMd5Keychain.IsNull() {
+ data.AuthenticationMd5Keychain = types.StringValue(value.String())
+ } else {
+ data.AuthenticationMd5Keychain = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/authentication/meticulous-md5/keychain"); value.Exists() && !data.AuthenticationMeticulousMd5Keychain.IsNull() {
+ data.AuthenticationMeticulousMd5Keychain = types.StringValue(value.String())
+ } else {
+ data.AuthenticationMeticulousMd5Keychain = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/authentication/meticulous-sha-1_keychain"); value.Exists() && !data.AuthenticationMeticulousSha1keychain.IsNull() {
+ data.AuthenticationMeticulousSha1keychain = types.StringValue(value.String())
+ } else {
+ data.AuthenticationMeticulousSha1keychain = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/authentication/sha-1/keychain"); value.Exists() && !data.AuthenticationSha1Keychain.IsNull() {
+ data.AuthenticationSha1Keychain = types.StringValue(value.String())
+ } else {
+ data.AuthenticationSha1Keychain = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/dampening/half-time"); value.Exists() && !data.DampeningHalfTime.IsNull() {
+ data.DampeningHalfTime = types.Int64Value(value.Int())
+ } else {
+ data.DampeningHalfTime = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/dampening/unsuppress-time"); value.Exists() && !data.DampeningUnsuppressTime.IsNull() {
+ data.DampeningUnsuppressTime = types.Int64Value(value.Int())
+ } else {
+ data.DampeningUnsuppressTime = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/dampening/suppress-time"); value.Exists() && !data.DampeningSuppressTime.IsNull() {
+ data.DampeningSuppressTime = types.Int64Value(value.Int())
+ } else {
+ data.DampeningSuppressTime = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/dampening/max-suppressing-time"); value.Exists() && !data.DampeningMaxSuppressingTime.IsNull() {
+ data.DampeningMaxSuppressingTime = types.Int64Value(value.Int())
+ } else {
+ data.DampeningMaxSuppressingTime = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/dampening/threshold"); value.Exists() && !data.DampeningThreshold.IsNull() {
+ data.DampeningThreshold = types.Int64Value(value.Int())
+ } else {
+ data.DampeningThreshold = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/dampening/down-monitoring"); !data.DampeningDownMonitoring.IsNull() {
+ if value.Exists() {
+ data.DampeningDownMonitoring = types.BoolValue(true)
+ } else {
+ data.DampeningDownMonitoring = types.BoolValue(false)
+ }
+ } else {
+ data.DampeningDownMonitoring = types.BoolNull()
+ }
+}
+
+// End of section. //template:end updateFromBodyXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin fromBody
func (data *BFDTemplateMultiHop) fromBody(ctx context.Context, res gjson.Result) {
@@ -473,6 +701,152 @@ func (data *BFDTemplateMultiHopData) fromBody(ctx context.Context, res gjson.Res
// End of section. //template:end fromBodyData
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyXML
+
+func (data *BFDTemplateMultiHop) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/echo"); value.Exists() {
+ data.Echo = types.BoolValue(true)
+ } else {
+ data.Echo = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/interval-multihop-v2/mill-unit/both"); value.Exists() {
+ data.IntervalMillisecondsBoth = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/interval-multihop-v2/mill-unit/min-tx"); value.Exists() {
+ data.IntervalMillisecondsMinTx = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/interval-multihop-v2/mill-unit/min-rx"); value.Exists() {
+ data.IntervalMillisecondsMinRx = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/interval-multihop-v2/mill-unit/multiplier"); value.Exists() {
+ data.IntervalMillisecondsMultiplier = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/interval-multihop-v2/microseconds"); value.Exists() {
+ data.IntervalMicroseconds = types.BoolValue(true)
+ } else {
+ data.IntervalMicroseconds = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/interval-multihop-v2/both"); value.Exists() {
+ data.IntervalMicrosecondsBoth = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/interval-multihop-v2/min-tx"); value.Exists() {
+ data.IntervalMicrosecondsMinTx = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/interval-multihop-v2/min-rx"); value.Exists() {
+ data.IntervalMicrosecondsMinRx = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/interval-multihop-v2/multiplier"); value.Exists() {
+ data.IntervalMicrosecondsMultiplier = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/authentication/md5/keychain"); value.Exists() {
+ data.AuthenticationMd5Keychain = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/authentication/meticulous-md5/keychain"); value.Exists() {
+ data.AuthenticationMeticulousMd5Keychain = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/authentication/meticulous-sha-1_keychain"); value.Exists() {
+ data.AuthenticationMeticulousSha1keychain = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/authentication/sha-1/keychain"); value.Exists() {
+ data.AuthenticationSha1Keychain = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/dampening/half-time"); value.Exists() {
+ data.DampeningHalfTime = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/dampening/unsuppress-time"); value.Exists() {
+ data.DampeningUnsuppressTime = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/dampening/suppress-time"); value.Exists() {
+ data.DampeningSuppressTime = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/dampening/max-suppressing-time"); value.Exists() {
+ data.DampeningMaxSuppressingTime = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/dampening/threshold"); value.Exists() {
+ data.DampeningThreshold = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/dampening/down-monitoring"); value.Exists() {
+ data.DampeningDownMonitoring = types.BoolValue(true)
+ } else {
+ data.DampeningDownMonitoring = types.BoolValue(false)
+ }
+}
+
+// End of section. //template:end fromBodyXML
+
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyDataXML
+
+func (data *BFDTemplateMultiHopData) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/echo"); value.Exists() {
+ data.Echo = types.BoolValue(true)
+ } else {
+ data.Echo = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/interval-multihop-v2/mill-unit/both"); value.Exists() {
+ data.IntervalMillisecondsBoth = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/interval-multihop-v2/mill-unit/min-tx"); value.Exists() {
+ data.IntervalMillisecondsMinTx = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/interval-multihop-v2/mill-unit/min-rx"); value.Exists() {
+ data.IntervalMillisecondsMinRx = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/interval-multihop-v2/mill-unit/multiplier"); value.Exists() {
+ data.IntervalMillisecondsMultiplier = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/interval-multihop-v2/microseconds"); value.Exists() {
+ data.IntervalMicroseconds = types.BoolValue(true)
+ } else {
+ data.IntervalMicroseconds = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/interval-multihop-v2/both"); value.Exists() {
+ data.IntervalMicrosecondsBoth = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/interval-multihop-v2/min-tx"); value.Exists() {
+ data.IntervalMicrosecondsMinTx = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/interval-multihop-v2/min-rx"); value.Exists() {
+ data.IntervalMicrosecondsMinRx = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/interval-multihop-v2/multiplier"); value.Exists() {
+ data.IntervalMicrosecondsMultiplier = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/authentication/md5/keychain"); value.Exists() {
+ data.AuthenticationMd5Keychain = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/authentication/meticulous-md5/keychain"); value.Exists() {
+ data.AuthenticationMeticulousMd5Keychain = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/authentication/meticulous-sha-1_keychain"); value.Exists() {
+ data.AuthenticationMeticulousSha1keychain = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/authentication/sha-1/keychain"); value.Exists() {
+ data.AuthenticationSha1Keychain = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/dampening/half-time"); value.Exists() {
+ data.DampeningHalfTime = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/dampening/unsuppress-time"); value.Exists() {
+ data.DampeningUnsuppressTime = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/dampening/suppress-time"); value.Exists() {
+ data.DampeningSuppressTime = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/dampening/max-suppressing-time"); value.Exists() {
+ data.DampeningMaxSuppressingTime = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/dampening/threshold"); value.Exists() {
+ data.DampeningThreshold = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/dampening/down-monitoring"); value.Exists() {
+ data.DampeningDownMonitoring = types.BoolValue(true)
+ } else {
+ data.DampeningDownMonitoring = types.BoolValue(false)
+ }
+}
+
+// End of section. //template:end fromBodyDataXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin getDeletedItems
func (data *BFDTemplateMultiHop) getDeletedItems(ctx context.Context, state BFDTemplateMultiHop) []string {
@@ -543,6 +917,76 @@ func (data *BFDTemplateMultiHop) getDeletedItems(ctx context.Context, state BFDT
// End of section. //template:end getDeletedItems
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletedItemsXML
+
+func (data *BFDTemplateMultiHop) addDeletedItemsXML(ctx context.Context, state BFDTemplateMultiHop, body string) string {
+ b := netconf.NewBody(body)
+ if !state.Echo.IsNull() && data.Echo.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/echo")
+ }
+ if !state.IntervalMillisecondsBoth.IsNull() && data.IntervalMillisecondsBoth.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/interval-multihop-v2/mill-unit/both")
+ }
+ if !state.IntervalMillisecondsMinTx.IsNull() && data.IntervalMillisecondsMinTx.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/interval-multihop-v2/mill-unit/min-tx")
+ }
+ if !state.IntervalMillisecondsMinRx.IsNull() && data.IntervalMillisecondsMinRx.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/interval-multihop-v2/mill-unit/min-rx")
+ }
+ if !state.IntervalMillisecondsMultiplier.IsNull() && data.IntervalMillisecondsMultiplier.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/interval-multihop-v2/mill-unit/multiplier")
+ }
+ if !state.IntervalMicroseconds.IsNull() && data.IntervalMicroseconds.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/interval-multihop-v2/microseconds")
+ }
+ if !state.IntervalMicrosecondsBoth.IsNull() && data.IntervalMicrosecondsBoth.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/interval-multihop-v2/both")
+ }
+ if !state.IntervalMicrosecondsMinTx.IsNull() && data.IntervalMicrosecondsMinTx.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/interval-multihop-v2/min-tx")
+ }
+ if !state.IntervalMicrosecondsMinRx.IsNull() && data.IntervalMicrosecondsMinRx.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/interval-multihop-v2/min-rx")
+ }
+ if !state.IntervalMicrosecondsMultiplier.IsNull() && data.IntervalMicrosecondsMultiplier.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/interval-multihop-v2/multiplier")
+ }
+ if !state.AuthenticationMd5Keychain.IsNull() && data.AuthenticationMd5Keychain.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/authentication/md5/keychain")
+ }
+ if !state.AuthenticationMeticulousMd5Keychain.IsNull() && data.AuthenticationMeticulousMd5Keychain.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/authentication/meticulous-md5/keychain")
+ }
+ if !state.AuthenticationMeticulousSha1keychain.IsNull() && data.AuthenticationMeticulousSha1keychain.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/authentication/meticulous-sha-1_keychain")
+ }
+ if !state.AuthenticationSha1Keychain.IsNull() && data.AuthenticationSha1Keychain.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/authentication/sha-1/keychain")
+ }
+ if !state.DampeningHalfTime.IsNull() && data.DampeningHalfTime.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/dampening/half-time")
+ }
+ if !state.DampeningUnsuppressTime.IsNull() && data.DampeningUnsuppressTime.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/dampening/unsuppress-time")
+ }
+ if !state.DampeningSuppressTime.IsNull() && data.DampeningSuppressTime.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/dampening/suppress-time")
+ }
+ if !state.DampeningMaxSuppressingTime.IsNull() && data.DampeningMaxSuppressingTime.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/dampening/max-suppressing-time")
+ }
+ if !state.DampeningThreshold.IsNull() && data.DampeningThreshold.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/dampening/threshold")
+ }
+ if !state.DampeningDownMonitoring.IsNull() && data.DampeningDownMonitoring.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/dampening/down-monitoring")
+ }
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletedItemsXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin getEmptyLeafsDelete
func (data *BFDTemplateMultiHop) getEmptyLeafsDelete(ctx context.Context) []string {
@@ -631,3 +1075,73 @@ func (data *BFDTemplateMultiHop) getDeletePaths(ctx context.Context) []string {
}
// End of section. //template:end getDeletePaths
+
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletePathsXML
+
+func (data *BFDTemplateMultiHop) addDeletePathsXML(ctx context.Context, body string) string {
+ b := netconf.NewBody(body)
+ if !data.Echo.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/echo")
+ }
+ if !data.IntervalMillisecondsBoth.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/interval-multihop-v2/mill-unit/both")
+ }
+ if !data.IntervalMillisecondsMinTx.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/interval-multihop-v2/mill-unit/min-tx")
+ }
+ if !data.IntervalMillisecondsMinRx.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/interval-multihop-v2/mill-unit/min-rx")
+ }
+ if !data.IntervalMillisecondsMultiplier.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/interval-multihop-v2/mill-unit/multiplier")
+ }
+ if !data.IntervalMicroseconds.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/interval-multihop-v2/microseconds")
+ }
+ if !data.IntervalMicrosecondsBoth.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/interval-multihop-v2/both")
+ }
+ if !data.IntervalMicrosecondsMinTx.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/interval-multihop-v2/min-tx")
+ }
+ if !data.IntervalMicrosecondsMinRx.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/interval-multihop-v2/min-rx")
+ }
+ if !data.IntervalMicrosecondsMultiplier.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/interval-multihop-v2/multiplier")
+ }
+ if !data.AuthenticationMd5Keychain.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/authentication/md5/keychain")
+ }
+ if !data.AuthenticationMeticulousMd5Keychain.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/authentication/meticulous-md5/keychain")
+ }
+ if !data.AuthenticationMeticulousSha1keychain.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/authentication/meticulous-sha-1_keychain")
+ }
+ if !data.AuthenticationSha1Keychain.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/authentication/sha-1/keychain")
+ }
+ if !data.DampeningHalfTime.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/dampening/half-time")
+ }
+ if !data.DampeningUnsuppressTime.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/dampening/unsuppress-time")
+ }
+ if !data.DampeningSuppressTime.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/dampening/suppress-time")
+ }
+ if !data.DampeningMaxSuppressingTime.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/dampening/max-suppressing-time")
+ }
+ if !data.DampeningThreshold.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/dampening/threshold")
+ }
+ if !data.DampeningDownMonitoring.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/dampening/down-monitoring")
+ }
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletePathsXML
diff --git a/internal/provider/model_iosxe_bfd_template_single_hop.go b/internal/provider/model_iosxe_bfd_template_single_hop.go
index e58ded12..57847bae 100644
--- a/internal/provider/model_iosxe_bfd_template_single_hop.go
+++ b/internal/provider/model_iosxe_bfd_template_single_hop.go
@@ -29,6 +29,9 @@ import (
"github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/types"
+ "github.com/hashicorp/terraform-plugin-log/tflog"
+ "github.com/netascode/go-netconf"
+ "github.com/netascode/xmldot"
"github.com/tidwall/gjson"
"github.com/tidwall/sjson"
)
@@ -101,6 +104,19 @@ func (data BFDTemplateSingleHop) getPathShort() string {
return matches[1]
}
+// getXPath returns the XPath for NETCONF operations
+func (data BFDTemplateSingleHop) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/bfd-template/Cisco-IOS-XE-bfd:single-hop[name=%v]"
+ path = fmt.Sprintf(path, fmt.Sprintf("%v", data.Name.ValueString()))
+ return path
+}
+
+func (data BFDTemplateSingleHopData) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/bfd-template/Cisco-IOS-XE-bfd:single-hop[name=%v]"
+ path = fmt.Sprintf(path, fmt.Sprintf("%v", data.Name.ValueString()))
+ return path
+}
+
// End of section. //template:end getPath
// Section below is generated&owned by "gen/generator.go". //template:begin toBody
@@ -162,6 +178,71 @@ func (data BFDTemplateSingleHop) toBody(ctx context.Context) string {
// End of section. //template:end toBody
+// Section below is generated&owned by "gen/generator.go". //template:begin toBodyXML
+
+func (data BFDTemplateSingleHop) toBodyXML(ctx context.Context) string {
+ body := netconf.Body{}
+ if !data.Name.IsNull() && !data.Name.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/name", data.Name.ValueString())
+ }
+ if !data.AuthenticationMd5Keychain.IsNull() && !data.AuthenticationMd5Keychain.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/authentication/md5/keychain", data.AuthenticationMd5Keychain.ValueString())
+ }
+ if !data.AuthenticationMeticulousMd5Keychain.IsNull() && !data.AuthenticationMeticulousMd5Keychain.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/authentication/meticulous-md5/keychain", data.AuthenticationMeticulousMd5Keychain.ValueString())
+ }
+ if !data.AuthenticationMeticulousSha1Keychain.IsNull() && !data.AuthenticationMeticulousSha1Keychain.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/authentication/meticulous-sha-1/keychain", data.AuthenticationMeticulousSha1Keychain.ValueString())
+ }
+ if !data.AuthenticationSha1Keychain.IsNull() && !data.AuthenticationSha1Keychain.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/authentication/sha-1/keychain", data.AuthenticationSha1Keychain.ValueString())
+ }
+ if !data.IntervalMillisecondsMinTx.IsNull() && !data.IntervalMillisecondsMinTx.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/interval-singlehop-v2/mill-unit/min-tx", strconv.FormatInt(data.IntervalMillisecondsMinTx.ValueInt64(), 10))
+ }
+ if !data.IntervalMillisecondsMinRx.IsNull() && !data.IntervalMillisecondsMinRx.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/interval-singlehop-v2/mill-unit/min-rx", strconv.FormatInt(data.IntervalMillisecondsMinRx.ValueInt64(), 10))
+ }
+ if !data.IntervalMillisecondsBoth.IsNull() && !data.IntervalMillisecondsBoth.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/interval-singlehop-v2/mill-unit/both", strconv.FormatInt(data.IntervalMillisecondsBoth.ValueInt64(), 10))
+ }
+ if !data.IntervalMillisecondsMultiplier.IsNull() && !data.IntervalMillisecondsMultiplier.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/interval-singlehop-v2/mill-unit/multiplier", strconv.FormatInt(data.IntervalMillisecondsMultiplier.ValueInt64(), 10))
+ }
+ if !data.IntervalMicrosecondsMinRx.IsNull() && !data.IntervalMicrosecondsMinRx.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/interval-singlehop-v2/ms-unit/min-rx", strconv.FormatInt(data.IntervalMicrosecondsMinRx.ValueInt64(), 10))
+ }
+ if !data.IntervalMicrosecondsMinTx.IsNull() && !data.IntervalMicrosecondsMinTx.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/interval-singlehop-v2/ms-unit/min-tx", strconv.FormatInt(data.IntervalMicrosecondsMinTx.ValueInt64(), 10))
+ }
+ if !data.Echo.IsNull() && !data.Echo.IsUnknown() {
+ if data.Echo.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/echo", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/echo")
+ }
+ }
+ if !data.DampeningHalfTime.IsNull() && !data.DampeningHalfTime.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/dampening/half-time", strconv.FormatInt(data.DampeningHalfTime.ValueInt64(), 10))
+ }
+ if !data.DampeningUnsuppressTime.IsNull() && !data.DampeningUnsuppressTime.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/dampening/unsuppress-time", strconv.FormatInt(data.DampeningUnsuppressTime.ValueInt64(), 10))
+ }
+ if !data.DampeningSuppressTime.IsNull() && !data.DampeningSuppressTime.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/dampening/suppress-time", strconv.FormatInt(data.DampeningSuppressTime.ValueInt64(), 10))
+ }
+ if !data.DampeningMaxSuppressingTime.IsNull() && !data.DampeningMaxSuppressingTime.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/dampening/max-suppressing-time", strconv.FormatInt(data.DampeningMaxSuppressingTime.ValueInt64(), 10))
+ }
+ bodyString, err := body.String()
+ if err != nil {
+ tflog.Error(ctx, fmt.Sprintf("Error converting body to string: %s", err))
+ }
+ return bodyString
+}
+
+// End of section. //template:end toBodyXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBody
func (data *BFDTemplateSingleHop) updateFromBody(ctx context.Context, res gjson.Result) {
@@ -257,6 +338,97 @@ func (data *BFDTemplateSingleHop) updateFromBody(ctx context.Context, res gjson.
// End of section. //template:end updateFromBody
+// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBodyXML
+
+func (data *BFDTemplateSingleHop) updateFromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/name"); value.Exists() && !data.Name.IsNull() {
+ data.Name = types.StringValue(value.String())
+ } else {
+ data.Name = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/authentication/md5/keychain"); value.Exists() && !data.AuthenticationMd5Keychain.IsNull() {
+ data.AuthenticationMd5Keychain = types.StringValue(value.String())
+ } else {
+ data.AuthenticationMd5Keychain = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/authentication/meticulous-md5/keychain"); value.Exists() && !data.AuthenticationMeticulousMd5Keychain.IsNull() {
+ data.AuthenticationMeticulousMd5Keychain = types.StringValue(value.String())
+ } else {
+ data.AuthenticationMeticulousMd5Keychain = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/authentication/meticulous-sha-1/keychain"); value.Exists() && !data.AuthenticationMeticulousSha1Keychain.IsNull() {
+ data.AuthenticationMeticulousSha1Keychain = types.StringValue(value.String())
+ } else {
+ data.AuthenticationMeticulousSha1Keychain = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/authentication/sha-1/keychain"); value.Exists() && !data.AuthenticationSha1Keychain.IsNull() {
+ data.AuthenticationSha1Keychain = types.StringValue(value.String())
+ } else {
+ data.AuthenticationSha1Keychain = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/interval-singlehop-v2/mill-unit/min-tx"); value.Exists() && !data.IntervalMillisecondsMinTx.IsNull() {
+ data.IntervalMillisecondsMinTx = types.Int64Value(value.Int())
+ } else {
+ data.IntervalMillisecondsMinTx = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/interval-singlehop-v2/mill-unit/min-rx"); value.Exists() && !data.IntervalMillisecondsMinRx.IsNull() {
+ data.IntervalMillisecondsMinRx = types.Int64Value(value.Int())
+ } else {
+ data.IntervalMillisecondsMinRx = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/interval-singlehop-v2/mill-unit/both"); value.Exists() && !data.IntervalMillisecondsBoth.IsNull() {
+ data.IntervalMillisecondsBoth = types.Int64Value(value.Int())
+ } else {
+ data.IntervalMillisecondsBoth = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/interval-singlehop-v2/mill-unit/multiplier"); value.Exists() && !data.IntervalMillisecondsMultiplier.IsNull() {
+ data.IntervalMillisecondsMultiplier = types.Int64Value(value.Int())
+ } else {
+ data.IntervalMillisecondsMultiplier = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/interval-singlehop-v2/ms-unit/min-rx"); value.Exists() && !data.IntervalMicrosecondsMinRx.IsNull() {
+ data.IntervalMicrosecondsMinRx = types.Int64Value(value.Int())
+ } else {
+ data.IntervalMicrosecondsMinRx = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/interval-singlehop-v2/ms-unit/min-tx"); value.Exists() && !data.IntervalMicrosecondsMinTx.IsNull() {
+ data.IntervalMicrosecondsMinTx = types.Int64Value(value.Int())
+ } else {
+ data.IntervalMicrosecondsMinTx = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/echo"); !data.Echo.IsNull() {
+ if value.Exists() {
+ data.Echo = types.BoolValue(true)
+ } else {
+ data.Echo = types.BoolValue(false)
+ }
+ } else {
+ data.Echo = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/dampening/half-time"); value.Exists() && !data.DampeningHalfTime.IsNull() {
+ data.DampeningHalfTime = types.Int64Value(value.Int())
+ } else {
+ data.DampeningHalfTime = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/dampening/unsuppress-time"); value.Exists() && !data.DampeningUnsuppressTime.IsNull() {
+ data.DampeningUnsuppressTime = types.Int64Value(value.Int())
+ } else {
+ data.DampeningUnsuppressTime = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/dampening/suppress-time"); value.Exists() && !data.DampeningSuppressTime.IsNull() {
+ data.DampeningSuppressTime = types.Int64Value(value.Int())
+ } else {
+ data.DampeningSuppressTime = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/dampening/max-suppressing-time"); value.Exists() && !data.DampeningMaxSuppressingTime.IsNull() {
+ data.DampeningMaxSuppressingTime = types.Int64Value(value.Int())
+ } else {
+ data.DampeningMaxSuppressingTime = types.Int64Null()
+ }
+}
+
+// End of section. //template:end updateFromBodyXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin fromBody
func (data *BFDTemplateSingleHop) fromBody(ctx context.Context, res gjson.Result) {
@@ -373,6 +545,114 @@ func (data *BFDTemplateSingleHopData) fromBody(ctx context.Context, res gjson.Re
// End of section. //template:end fromBodyData
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyXML
+
+func (data *BFDTemplateSingleHop) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/authentication/md5/keychain"); value.Exists() {
+ data.AuthenticationMd5Keychain = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/authentication/meticulous-md5/keychain"); value.Exists() {
+ data.AuthenticationMeticulousMd5Keychain = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/authentication/meticulous-sha-1/keychain"); value.Exists() {
+ data.AuthenticationMeticulousSha1Keychain = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/authentication/sha-1/keychain"); value.Exists() {
+ data.AuthenticationSha1Keychain = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/interval-singlehop-v2/mill-unit/min-tx"); value.Exists() {
+ data.IntervalMillisecondsMinTx = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/interval-singlehop-v2/mill-unit/min-rx"); value.Exists() {
+ data.IntervalMillisecondsMinRx = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/interval-singlehop-v2/mill-unit/both"); value.Exists() {
+ data.IntervalMillisecondsBoth = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/interval-singlehop-v2/mill-unit/multiplier"); value.Exists() {
+ data.IntervalMillisecondsMultiplier = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/interval-singlehop-v2/ms-unit/min-rx"); value.Exists() {
+ data.IntervalMicrosecondsMinRx = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/interval-singlehop-v2/ms-unit/min-tx"); value.Exists() {
+ data.IntervalMicrosecondsMinTx = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/echo"); value.Exists() {
+ data.Echo = types.BoolValue(true)
+ } else {
+ data.Echo = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/dampening/half-time"); value.Exists() {
+ data.DampeningHalfTime = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/dampening/unsuppress-time"); value.Exists() {
+ data.DampeningUnsuppressTime = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/dampening/suppress-time"); value.Exists() {
+ data.DampeningSuppressTime = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/dampening/max-suppressing-time"); value.Exists() {
+ data.DampeningMaxSuppressingTime = types.Int64Value(value.Int())
+ }
+}
+
+// End of section. //template:end fromBodyXML
+
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyDataXML
+
+func (data *BFDTemplateSingleHopData) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/authentication/md5/keychain"); value.Exists() {
+ data.AuthenticationMd5Keychain = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/authentication/meticulous-md5/keychain"); value.Exists() {
+ data.AuthenticationMeticulousMd5Keychain = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/authentication/meticulous-sha-1/keychain"); value.Exists() {
+ data.AuthenticationMeticulousSha1Keychain = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/authentication/sha-1/keychain"); value.Exists() {
+ data.AuthenticationSha1Keychain = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/interval-singlehop-v2/mill-unit/min-tx"); value.Exists() {
+ data.IntervalMillisecondsMinTx = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/interval-singlehop-v2/mill-unit/min-rx"); value.Exists() {
+ data.IntervalMillisecondsMinRx = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/interval-singlehop-v2/mill-unit/both"); value.Exists() {
+ data.IntervalMillisecondsBoth = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/interval-singlehop-v2/mill-unit/multiplier"); value.Exists() {
+ data.IntervalMillisecondsMultiplier = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/interval-singlehop-v2/ms-unit/min-rx"); value.Exists() {
+ data.IntervalMicrosecondsMinRx = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/interval-singlehop-v2/ms-unit/min-tx"); value.Exists() {
+ data.IntervalMicrosecondsMinTx = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/echo"); value.Exists() {
+ data.Echo = types.BoolValue(true)
+ } else {
+ data.Echo = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/dampening/half-time"); value.Exists() {
+ data.DampeningHalfTime = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/dampening/unsuppress-time"); value.Exists() {
+ data.DampeningUnsuppressTime = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/dampening/suppress-time"); value.Exists() {
+ data.DampeningSuppressTime = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/dampening/max-suppressing-time"); value.Exists() {
+ data.DampeningMaxSuppressingTime = types.Int64Value(value.Int())
+ }
+}
+
+// End of section. //template:end fromBodyDataXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin getDeletedItems
func (data *BFDTemplateSingleHop) getDeletedItems(ctx context.Context, state BFDTemplateSingleHop) []string {
@@ -428,6 +708,61 @@ func (data *BFDTemplateSingleHop) getDeletedItems(ctx context.Context, state BFD
// End of section. //template:end getDeletedItems
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletedItemsXML
+
+func (data *BFDTemplateSingleHop) addDeletedItemsXML(ctx context.Context, state BFDTemplateSingleHop, body string) string {
+ b := netconf.NewBody(body)
+ if !state.AuthenticationMd5Keychain.IsNull() && data.AuthenticationMd5Keychain.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/authentication/md5/keychain")
+ }
+ if !state.AuthenticationMeticulousMd5Keychain.IsNull() && data.AuthenticationMeticulousMd5Keychain.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/authentication/meticulous-md5/keychain")
+ }
+ if !state.AuthenticationMeticulousSha1Keychain.IsNull() && data.AuthenticationMeticulousSha1Keychain.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/authentication/meticulous-sha-1/keychain")
+ }
+ if !state.AuthenticationSha1Keychain.IsNull() && data.AuthenticationSha1Keychain.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/authentication/sha-1/keychain")
+ }
+ if !state.IntervalMillisecondsMinTx.IsNull() && data.IntervalMillisecondsMinTx.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/interval-singlehop-v2/mill-unit/min-tx")
+ }
+ if !state.IntervalMillisecondsMinRx.IsNull() && data.IntervalMillisecondsMinRx.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/interval-singlehop-v2/mill-unit/min-rx")
+ }
+ if !state.IntervalMillisecondsBoth.IsNull() && data.IntervalMillisecondsBoth.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/interval-singlehop-v2/mill-unit/both")
+ }
+ if !state.IntervalMillisecondsMultiplier.IsNull() && data.IntervalMillisecondsMultiplier.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/interval-singlehop-v2/mill-unit/multiplier")
+ }
+ if !state.IntervalMicrosecondsMinRx.IsNull() && data.IntervalMicrosecondsMinRx.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/interval-singlehop-v2/ms-unit/min-rx")
+ }
+ if !state.IntervalMicrosecondsMinTx.IsNull() && data.IntervalMicrosecondsMinTx.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/interval-singlehop-v2/ms-unit/min-tx")
+ }
+ if !state.Echo.IsNull() && data.Echo.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/echo")
+ }
+ if !state.DampeningHalfTime.IsNull() && data.DampeningHalfTime.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/dampening/half-time")
+ }
+ if !state.DampeningUnsuppressTime.IsNull() && data.DampeningUnsuppressTime.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/dampening/unsuppress-time")
+ }
+ if !state.DampeningSuppressTime.IsNull() && data.DampeningSuppressTime.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/dampening/suppress-time")
+ }
+ if !state.DampeningMaxSuppressingTime.IsNull() && data.DampeningMaxSuppressingTime.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/dampening/max-suppressing-time")
+ }
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletedItemsXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin getEmptyLeafsDelete
func (data *BFDTemplateSingleHop) getEmptyLeafsDelete(ctx context.Context) []string {
@@ -495,3 +830,58 @@ func (data *BFDTemplateSingleHop) getDeletePaths(ctx context.Context) []string {
}
// End of section. //template:end getDeletePaths
+
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletePathsXML
+
+func (data *BFDTemplateSingleHop) addDeletePathsXML(ctx context.Context, body string) string {
+ b := netconf.NewBody(body)
+ if !data.AuthenticationMd5Keychain.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/authentication/md5/keychain")
+ }
+ if !data.AuthenticationMeticulousMd5Keychain.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/authentication/meticulous-md5/keychain")
+ }
+ if !data.AuthenticationMeticulousSha1Keychain.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/authentication/meticulous-sha-1/keychain")
+ }
+ if !data.AuthenticationSha1Keychain.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/authentication/sha-1/keychain")
+ }
+ if !data.IntervalMillisecondsMinTx.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/interval-singlehop-v2/mill-unit/min-tx")
+ }
+ if !data.IntervalMillisecondsMinRx.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/interval-singlehop-v2/mill-unit/min-rx")
+ }
+ if !data.IntervalMillisecondsBoth.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/interval-singlehop-v2/mill-unit/both")
+ }
+ if !data.IntervalMillisecondsMultiplier.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/interval-singlehop-v2/mill-unit/multiplier")
+ }
+ if !data.IntervalMicrosecondsMinRx.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/interval-singlehop-v2/ms-unit/min-rx")
+ }
+ if !data.IntervalMicrosecondsMinTx.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/interval-singlehop-v2/ms-unit/min-tx")
+ }
+ if !data.Echo.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/echo")
+ }
+ if !data.DampeningHalfTime.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/dampening/half-time")
+ }
+ if !data.DampeningUnsuppressTime.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/dampening/unsuppress-time")
+ }
+ if !data.DampeningSuppressTime.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/dampening/suppress-time")
+ }
+ if !data.DampeningMaxSuppressingTime.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/dampening/max-suppressing-time")
+ }
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletePathsXML
diff --git a/internal/provider/model_iosxe_bgp.go b/internal/provider/model_iosxe_bgp.go
index d81a0cee..1f088971 100644
--- a/internal/provider/model_iosxe_bgp.go
+++ b/internal/provider/model_iosxe_bgp.go
@@ -29,6 +29,9 @@ import (
"github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/types"
+ "github.com/hashicorp/terraform-plugin-log/tflog"
+ "github.com/netascode/go-netconf"
+ "github.com/netascode/xmldot"
"github.com/tidwall/gjson"
"github.com/tidwall/sjson"
)
@@ -80,6 +83,19 @@ func (data BGP) getPathShort() string {
return matches[1]
}
+// getXPath returns the XPath for NETCONF operations
+func (data BGP) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/router/Cisco-IOS-XE-bgp:bgp[id=%v]"
+ path = fmt.Sprintf(path, fmt.Sprintf("%v", data.Asn.ValueString()))
+ return path
+}
+
+func (data BGPData) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/router/Cisco-IOS-XE-bgp:bgp[id=%v]"
+ path = fmt.Sprintf(path, fmt.Sprintf("%v", data.Asn.ValueString()))
+ return path
+}
+
// End of section. //template:end getPath
// Section below is generated&owned by "gen/generator.go". //template:begin toBody
@@ -106,6 +122,34 @@ func (data BGP) toBody(ctx context.Context) string {
// End of section. //template:end toBody
+// Section below is generated&owned by "gen/generator.go". //template:begin toBodyXML
+
+func (data BGP) toBodyXML(ctx context.Context) string {
+ body := netconf.Body{}
+ if !data.Asn.IsNull() && !data.Asn.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/id", data.Asn.ValueString())
+ }
+ if !data.DefaultIpv4Unicast.IsNull() && !data.DefaultIpv4Unicast.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/bgp/default/ipv4-unicast", data.DefaultIpv4Unicast.ValueBool())
+ }
+ if !data.LogNeighborChanges.IsNull() && !data.LogNeighborChanges.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/bgp/log-neighbor-changes", data.LogNeighborChanges.ValueBool())
+ }
+ if !data.RouterIdLoopback.IsNull() && !data.RouterIdLoopback.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/bgp/router-id/interface/Loopback", strconv.FormatInt(data.RouterIdLoopback.ValueInt64(), 10))
+ }
+ if !data.RouterIdIp.IsNull() && !data.RouterIdIp.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/bgp/router-id/ip-id", data.RouterIdIp.ValueString())
+ }
+ bodyString, err := body.String()
+ if err != nil {
+ tflog.Error(ctx, fmt.Sprintf("Error converting body to string: %s", err))
+ }
+ return bodyString
+}
+
+// End of section. //template:end toBodyXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBody
func (data *BGP) updateFromBody(ctx context.Context, res gjson.Result) {
@@ -146,6 +190,42 @@ func (data *BGP) updateFromBody(ctx context.Context, res gjson.Result) {
// End of section. //template:end updateFromBody
+// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBodyXML
+
+func (data *BGP) updateFromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/id"); value.Exists() && !data.Asn.IsNull() {
+ data.Asn = types.StringValue(value.String())
+ } else {
+ data.Asn = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/bgp/default/ipv4-unicast"); !data.DefaultIpv4Unicast.IsNull() {
+ if value.Exists() {
+ data.DefaultIpv4Unicast = types.BoolValue(value.Bool())
+ }
+ } else {
+ data.DefaultIpv4Unicast = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/bgp/log-neighbor-changes"); !data.LogNeighborChanges.IsNull() {
+ if value.Exists() {
+ data.LogNeighborChanges = types.BoolValue(value.Bool())
+ }
+ } else {
+ data.LogNeighborChanges = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/bgp/router-id/interface/Loopback"); value.Exists() && !data.RouterIdLoopback.IsNull() {
+ data.RouterIdLoopback = types.Int64Value(value.Int())
+ } else {
+ data.RouterIdLoopback = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/bgp/router-id/ip-id"); value.Exists() && !data.RouterIdIp.IsNull() {
+ data.RouterIdIp = types.StringValue(value.String())
+ } else {
+ data.RouterIdIp = types.StringNull()
+ }
+}
+
+// End of section. //template:end updateFromBodyXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin fromBody
func (data *BGP) fromBody(ctx context.Context, res gjson.Result) {
@@ -200,6 +280,52 @@ func (data *BGPData) fromBody(ctx context.Context, res gjson.Result) {
// End of section. //template:end fromBodyData
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyXML
+
+func (data *BGP) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/bgp/default/ipv4-unicast"); value.Exists() {
+ data.DefaultIpv4Unicast = types.BoolValue(value.Bool())
+ } else {
+ data.DefaultIpv4Unicast = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/bgp/log-neighbor-changes"); value.Exists() {
+ data.LogNeighborChanges = types.BoolValue(value.Bool())
+ } else {
+ data.LogNeighborChanges = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/bgp/router-id/interface/Loopback"); value.Exists() {
+ data.RouterIdLoopback = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/bgp/router-id/ip-id"); value.Exists() {
+ data.RouterIdIp = types.StringValue(value.String())
+ }
+}
+
+// End of section. //template:end fromBodyXML
+
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyDataXML
+
+func (data *BGPData) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/bgp/default/ipv4-unicast"); value.Exists() {
+ data.DefaultIpv4Unicast = types.BoolValue(value.Bool())
+ } else {
+ data.DefaultIpv4Unicast = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/bgp/log-neighbor-changes"); value.Exists() {
+ data.LogNeighborChanges = types.BoolValue(value.Bool())
+ } else {
+ data.LogNeighborChanges = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/bgp/router-id/interface/Loopback"); value.Exists() {
+ data.RouterIdLoopback = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/bgp/router-id/ip-id"); value.Exists() {
+ data.RouterIdIp = types.StringValue(value.String())
+ }
+}
+
+// End of section. //template:end fromBodyDataXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin getDeletedItems
func (data *BGP) getDeletedItems(ctx context.Context, state BGP) []string {
@@ -222,6 +348,28 @@ func (data *BGP) getDeletedItems(ctx context.Context, state BGP) []string {
// End of section. //template:end getDeletedItems
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletedItemsXML
+
+func (data *BGP) addDeletedItemsXML(ctx context.Context, state BGP, body string) string {
+ b := netconf.NewBody(body)
+ if !state.DefaultIpv4Unicast.IsNull() && data.DefaultIpv4Unicast.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/bgp/default/ipv4-unicast")
+ }
+ if !state.LogNeighborChanges.IsNull() && data.LogNeighborChanges.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/bgp/log-neighbor-changes")
+ }
+ if !state.RouterIdLoopback.IsNull() && data.RouterIdLoopback.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/bgp/router-id/interface/Loopback")
+ }
+ if !state.RouterIdIp.IsNull() && data.RouterIdIp.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/bgp/router-id/ip-id")
+ }
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletedItemsXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin getEmptyLeafsDelete
func (data *BGP) getEmptyLeafsDelete(ctx context.Context) []string {
@@ -253,3 +401,25 @@ func (data *BGP) getDeletePaths(ctx context.Context) []string {
}
// End of section. //template:end getDeletePaths
+
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletePathsXML
+
+func (data *BGP) addDeletePathsXML(ctx context.Context, body string) string {
+ b := netconf.NewBody(body)
+ if !data.DefaultIpv4Unicast.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/bgp/default/ipv4-unicast")
+ }
+ if !data.LogNeighborChanges.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/bgp/log-neighbor-changes")
+ }
+ if !data.RouterIdLoopback.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/bgp/router-id/interface/Loopback")
+ }
+ if !data.RouterIdIp.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/bgp/router-id/ip-id")
+ }
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletePathsXML
diff --git a/internal/provider/model_iosxe_bgp_address_family_ipv4.go b/internal/provider/model_iosxe_bgp_address_family_ipv4.go
index 2696107f..c7178778 100644
--- a/internal/provider/model_iosxe_bgp_address_family_ipv4.go
+++ b/internal/provider/model_iosxe_bgp_address_family_ipv4.go
@@ -31,6 +31,9 @@ import (
"github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/types"
+ "github.com/hashicorp/terraform-plugin-log/tflog"
+ "github.com/netascode/go-netconf"
+ "github.com/netascode/xmldot"
"github.com/tidwall/gjson"
"github.com/tidwall/sjson"
)
@@ -115,6 +118,19 @@ func (data BGPAddressFamilyIPv4) getPathShort() string {
return matches[1]
}
+// getXPath returns the XPath for NETCONF operations
+func (data BGPAddressFamilyIPv4) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/router/Cisco-IOS-XE-bgp:bgp[id=%v]/address-family/no-vrf/ipv4[af-name=%s]"
+ path = fmt.Sprintf(path, fmt.Sprintf("%v", data.Asn.ValueString()), fmt.Sprintf("%v", data.AfName.ValueString()))
+ return path
+}
+
+func (data BGPAddressFamilyIPv4Data) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/router/Cisco-IOS-XE-bgp:bgp[id=%v]/address-family/no-vrf/ipv4[af-name=%s]"
+ path = fmt.Sprintf(path, fmt.Sprintf("%v", data.Asn.ValueString()), fmt.Sprintf("%v", data.AfName.ValueString()))
+ return path
+}
+
// End of section. //template:end getPath
// Section below is generated&owned by "gen/generator.go". //template:begin toBody
@@ -211,6 +227,116 @@ func (data BGPAddressFamilyIPv4) toBody(ctx context.Context) string {
// End of section. //template:end toBody
+// Section below is generated&owned by "gen/generator.go". //template:begin toBodyXML
+
+func (data BGPAddressFamilyIPv4) toBodyXML(ctx context.Context) string {
+ body := netconf.Body{}
+ if !data.AfName.IsNull() && !data.AfName.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/af-name", data.AfName.ValueString())
+ }
+ if !data.Ipv4UnicastRedistributeConnected.IsNull() && !data.Ipv4UnicastRedistributeConnected.IsUnknown() {
+ if data.Ipv4UnicastRedistributeConnected.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ipv4-unicast/redistribute/connected", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/ipv4-unicast/redistribute/connected")
+ }
+ }
+ if !data.Ipv4UnicastRedistributeStatic.IsNull() && !data.Ipv4UnicastRedistributeStatic.IsUnknown() {
+ if data.Ipv4UnicastRedistributeStatic.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ipv4-unicast/redistribute/static", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/ipv4-unicast/redistribute/static")
+ }
+ }
+ if len(data.Ipv4UnicastAggregateAddresses) > 0 {
+ for _, item := range data.Ipv4UnicastAggregateAddresses {
+ cBody := netconf.Body{}
+ if !item.Ipv4Address.IsNull() && !item.Ipv4Address.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "ipv4-address", item.Ipv4Address.ValueString())
+ }
+ if !item.Ipv4Mask.IsNull() && !item.Ipv4Mask.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "ipv4-mask", item.Ipv4Mask.ValueString())
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/ipv4-unicast/aggregate-address", cBody.Res())
+ }
+ }
+ if len(data.Ipv4UnicastNetworksMask) > 0 {
+ for _, item := range data.Ipv4UnicastNetworksMask {
+ cBody := netconf.Body{}
+ if !item.Network.IsNull() && !item.Network.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "number", item.Network.ValueString())
+ }
+ if !item.Mask.IsNull() && !item.Mask.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "mask", item.Mask.ValueString())
+ }
+ if !item.RouteMap.IsNull() && !item.RouteMap.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "route-map", item.RouteMap.ValueString())
+ }
+ if !item.Backdoor.IsNull() && !item.Backdoor.IsUnknown() {
+ if item.Backdoor.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "backdoor", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "backdoor")
+ }
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/ipv4-unicast/network/with-mask", cBody.Res())
+ }
+ }
+ if len(data.Ipv4UnicastNetworks) > 0 {
+ for _, item := range data.Ipv4UnicastNetworks {
+ cBody := netconf.Body{}
+ if !item.Network.IsNull() && !item.Network.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "number", item.Network.ValueString())
+ }
+ if !item.RouteMap.IsNull() && !item.RouteMap.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "route-map", item.RouteMap.ValueString())
+ }
+ if !item.Backdoor.IsNull() && !item.Backdoor.IsUnknown() {
+ if item.Backdoor.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "backdoor", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "backdoor")
+ }
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/ipv4-unicast/network/no-mask", cBody.Res())
+ }
+ }
+ if len(data.Ipv4UnicastAdminDistances) > 0 {
+ for _, item := range data.Ipv4UnicastAdminDistances {
+ cBody := netconf.Body{}
+ if !item.Distance.IsNull() && !item.Distance.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "distance", strconv.FormatInt(item.Distance.ValueInt64(), 10))
+ }
+ if !item.SourceIp.IsNull() && !item.SourceIp.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "srcip", item.SourceIp.ValueString())
+ }
+ if !item.Wildcard.IsNull() && !item.Wildcard.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "wildbits", item.Wildcard.ValueString())
+ }
+ if !item.Acl.IsNull() && !item.Acl.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "acl", item.Acl.ValueString())
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/ipv4-unicast/distance/adm-distance", cBody.Res())
+ }
+ }
+ if !data.Ipv4UnicastDistanceBgpExternal.IsNull() && !data.Ipv4UnicastDistanceBgpExternal.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ipv4-unicast/distance/bgp/extern-as", strconv.FormatInt(data.Ipv4UnicastDistanceBgpExternal.ValueInt64(), 10))
+ }
+ if !data.Ipv4UnicastDistanceBgpInternal.IsNull() && !data.Ipv4UnicastDistanceBgpInternal.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ipv4-unicast/distance/bgp/internal-as", strconv.FormatInt(data.Ipv4UnicastDistanceBgpInternal.ValueInt64(), 10))
+ }
+ if !data.Ipv4UnicastDistanceBgpLocal.IsNull() && !data.Ipv4UnicastDistanceBgpLocal.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ipv4-unicast/distance/bgp/local", strconv.FormatInt(data.Ipv4UnicastDistanceBgpLocal.ValueInt64(), 10))
+ }
+ bodyString, err := body.String()
+ if err != nil {
+ tflog.Error(ctx, fmt.Sprintf("Error converting body to string: %s", err))
+ }
+ return bodyString
+}
+
+// End of section. //template:end toBodyXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBody
func (data *BGPAddressFamilyIPv4) updateFromBody(ctx context.Context, res gjson.Result) {
@@ -429,6 +555,220 @@ func (data *BGPAddressFamilyIPv4) updateFromBody(ctx context.Context, res gjson.
// End of section. //template:end updateFromBody
+// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBodyXML
+
+func (data *BGPAddressFamilyIPv4) updateFromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/af-name"); value.Exists() && !data.AfName.IsNull() {
+ data.AfName = types.StringValue(value.String())
+ } else {
+ data.AfName = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ipv4-unicast/redistribute/connected"); !data.Ipv4UnicastRedistributeConnected.IsNull() {
+ if value.Exists() {
+ data.Ipv4UnicastRedistributeConnected = types.BoolValue(true)
+ } else {
+ data.Ipv4UnicastRedistributeConnected = types.BoolValue(false)
+ }
+ } else {
+ data.Ipv4UnicastRedistributeConnected = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ipv4-unicast/redistribute/static"); !data.Ipv4UnicastRedistributeStatic.IsNull() {
+ if value.Exists() {
+ data.Ipv4UnicastRedistributeStatic = types.BoolValue(true)
+ } else {
+ data.Ipv4UnicastRedistributeStatic = types.BoolValue(false)
+ }
+ } else {
+ data.Ipv4UnicastRedistributeStatic = types.BoolNull()
+ }
+ for i := range data.Ipv4UnicastAggregateAddresses {
+ keys := [...]string{"ipv4-address", "ipv4-mask"}
+ keyValues := [...]string{data.Ipv4UnicastAggregateAddresses[i].Ipv4Address.ValueString(), data.Ipv4UnicastAggregateAddresses[i].Ipv4Mask.ValueString()}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ipv4-unicast/aggregate-address").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, "ipv4-address"); value.Exists() && !data.Ipv4UnicastAggregateAddresses[i].Ipv4Address.IsNull() {
+ data.Ipv4UnicastAggregateAddresses[i].Ipv4Address = types.StringValue(value.String())
+ } else {
+ data.Ipv4UnicastAggregateAddresses[i].Ipv4Address = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "ipv4-mask"); value.Exists() && !data.Ipv4UnicastAggregateAddresses[i].Ipv4Mask.IsNull() {
+ data.Ipv4UnicastAggregateAddresses[i].Ipv4Mask = types.StringValue(value.String())
+ } else {
+ data.Ipv4UnicastAggregateAddresses[i].Ipv4Mask = types.StringNull()
+ }
+ }
+ for i := range data.Ipv4UnicastNetworksMask {
+ keys := [...]string{"number", "mask"}
+ keyValues := [...]string{data.Ipv4UnicastNetworksMask[i].Network.ValueString(), data.Ipv4UnicastNetworksMask[i].Mask.ValueString()}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ipv4-unicast/network/with-mask").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, "number"); value.Exists() && !data.Ipv4UnicastNetworksMask[i].Network.IsNull() {
+ data.Ipv4UnicastNetworksMask[i].Network = types.StringValue(value.String())
+ } else {
+ data.Ipv4UnicastNetworksMask[i].Network = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "mask"); value.Exists() && !data.Ipv4UnicastNetworksMask[i].Mask.IsNull() {
+ data.Ipv4UnicastNetworksMask[i].Mask = types.StringValue(value.String())
+ } else {
+ data.Ipv4UnicastNetworksMask[i].Mask = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "route-map"); value.Exists() && !data.Ipv4UnicastNetworksMask[i].RouteMap.IsNull() {
+ data.Ipv4UnicastNetworksMask[i].RouteMap = types.StringValue(value.String())
+ } else {
+ data.Ipv4UnicastNetworksMask[i].RouteMap = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "backdoor"); !data.Ipv4UnicastNetworksMask[i].Backdoor.IsNull() {
+ if value.Exists() {
+ data.Ipv4UnicastNetworksMask[i].Backdoor = types.BoolValue(true)
+ } else {
+ data.Ipv4UnicastNetworksMask[i].Backdoor = types.BoolValue(false)
+ }
+ } else {
+ data.Ipv4UnicastNetworksMask[i].Backdoor = types.BoolNull()
+ }
+ }
+ for i := range data.Ipv4UnicastNetworks {
+ keys := [...]string{"number"}
+ keyValues := [...]string{data.Ipv4UnicastNetworks[i].Network.ValueString()}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ipv4-unicast/network/no-mask").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, "number"); value.Exists() && !data.Ipv4UnicastNetworks[i].Network.IsNull() {
+ data.Ipv4UnicastNetworks[i].Network = types.StringValue(value.String())
+ } else {
+ data.Ipv4UnicastNetworks[i].Network = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "route-map"); value.Exists() && !data.Ipv4UnicastNetworks[i].RouteMap.IsNull() {
+ data.Ipv4UnicastNetworks[i].RouteMap = types.StringValue(value.String())
+ } else {
+ data.Ipv4UnicastNetworks[i].RouteMap = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "backdoor"); !data.Ipv4UnicastNetworks[i].Backdoor.IsNull() {
+ if value.Exists() {
+ data.Ipv4UnicastNetworks[i].Backdoor = types.BoolValue(true)
+ } else {
+ data.Ipv4UnicastNetworks[i].Backdoor = types.BoolValue(false)
+ }
+ } else {
+ data.Ipv4UnicastNetworks[i].Backdoor = types.BoolNull()
+ }
+ }
+ for i := range data.Ipv4UnicastAdminDistances {
+ keys := [...]string{"distance", "srcip", "wildbits"}
+ keyValues := [...]string{strconv.FormatInt(data.Ipv4UnicastAdminDistances[i].Distance.ValueInt64(), 10), data.Ipv4UnicastAdminDistances[i].SourceIp.ValueString(), data.Ipv4UnicastAdminDistances[i].Wildcard.ValueString()}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ipv4-unicast/distance/adm-distance").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, "distance"); value.Exists() && !data.Ipv4UnicastAdminDistances[i].Distance.IsNull() {
+ data.Ipv4UnicastAdminDistances[i].Distance = types.Int64Value(value.Int())
+ } else {
+ data.Ipv4UnicastAdminDistances[i].Distance = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(r, "srcip"); value.Exists() && !data.Ipv4UnicastAdminDistances[i].SourceIp.IsNull() {
+ data.Ipv4UnicastAdminDistances[i].SourceIp = types.StringValue(value.String())
+ } else {
+ data.Ipv4UnicastAdminDistances[i].SourceIp = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "wildbits"); value.Exists() && !data.Ipv4UnicastAdminDistances[i].Wildcard.IsNull() {
+ data.Ipv4UnicastAdminDistances[i].Wildcard = types.StringValue(value.String())
+ } else {
+ data.Ipv4UnicastAdminDistances[i].Wildcard = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "acl"); value.Exists() && !data.Ipv4UnicastAdminDistances[i].Acl.IsNull() {
+ data.Ipv4UnicastAdminDistances[i].Acl = types.StringValue(value.String())
+ } else {
+ data.Ipv4UnicastAdminDistances[i].Acl = types.StringNull()
+ }
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ipv4-unicast/distance/bgp/extern-as"); value.Exists() && !data.Ipv4UnicastDistanceBgpExternal.IsNull() {
+ data.Ipv4UnicastDistanceBgpExternal = types.Int64Value(value.Int())
+ } else {
+ data.Ipv4UnicastDistanceBgpExternal = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ipv4-unicast/distance/bgp/internal-as"); value.Exists() && !data.Ipv4UnicastDistanceBgpInternal.IsNull() {
+ data.Ipv4UnicastDistanceBgpInternal = types.Int64Value(value.Int())
+ } else {
+ data.Ipv4UnicastDistanceBgpInternal = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ipv4-unicast/distance/bgp/local"); value.Exists() && !data.Ipv4UnicastDistanceBgpLocal.IsNull() {
+ data.Ipv4UnicastDistanceBgpLocal = types.Int64Value(value.Int())
+ } else {
+ data.Ipv4UnicastDistanceBgpLocal = types.Int64Null()
+ }
+}
+
+// End of section. //template:end updateFromBodyXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin fromBody
func (data *BGPAddressFamilyIPv4) fromBody(ctx context.Context, res gjson.Result) {
@@ -639,14 +979,216 @@ func (data *BGPAddressFamilyIPv4Data) fromBody(ctx context.Context, res gjson.Re
// End of section. //template:end fromBodyData
-// Section below is generated&owned by "gen/generator.go". //template:begin getDeletedItems
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyXML
-func (data *BGPAddressFamilyIPv4) getDeletedItems(ctx context.Context, state BGPAddressFamilyIPv4) []string {
- deletedItems := make([]string, 0)
- if !state.Ipv4UnicastDistanceBgpLocal.IsNull() && data.Ipv4UnicastDistanceBgpLocal.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ipv4-unicast/distance/bgp/local", state.getPath()))
- }
- if !state.Ipv4UnicastDistanceBgpInternal.IsNull() && data.Ipv4UnicastDistanceBgpInternal.IsNull() {
+func (data *BGPAddressFamilyIPv4) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ipv4-unicast/redistribute/connected"); value.Exists() {
+ data.Ipv4UnicastRedistributeConnected = types.BoolValue(true)
+ } else {
+ data.Ipv4UnicastRedistributeConnected = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ipv4-unicast/redistribute/static"); value.Exists() {
+ data.Ipv4UnicastRedistributeStatic = types.BoolValue(true)
+ } else {
+ data.Ipv4UnicastRedistributeStatic = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ipv4-unicast/aggregate-address"); value.Exists() {
+ data.Ipv4UnicastAggregateAddresses = make([]BGPAddressFamilyIPv4Ipv4UnicastAggregateAddresses, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := BGPAddressFamilyIPv4Ipv4UnicastAggregateAddresses{}
+ if cValue := helpers.GetFromXPath(v, "ipv4-address"); cValue.Exists() {
+ item.Ipv4Address = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "ipv4-mask"); cValue.Exists() {
+ item.Ipv4Mask = types.StringValue(cValue.String())
+ }
+ data.Ipv4UnicastAggregateAddresses = append(data.Ipv4UnicastAggregateAddresses, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ipv4-unicast/network/with-mask"); value.Exists() {
+ data.Ipv4UnicastNetworksMask = make([]BGPAddressFamilyIPv4Ipv4UnicastNetworksMask, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := BGPAddressFamilyIPv4Ipv4UnicastNetworksMask{}
+ if cValue := helpers.GetFromXPath(v, "number"); cValue.Exists() {
+ item.Network = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "mask"); cValue.Exists() {
+ item.Mask = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "route-map"); cValue.Exists() {
+ item.RouteMap = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "backdoor"); cValue.Exists() {
+ item.Backdoor = types.BoolValue(true)
+ } else {
+ item.Backdoor = types.BoolValue(false)
+ }
+ data.Ipv4UnicastNetworksMask = append(data.Ipv4UnicastNetworksMask, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ipv4-unicast/network/no-mask"); value.Exists() {
+ data.Ipv4UnicastNetworks = make([]BGPAddressFamilyIPv4Ipv4UnicastNetworks, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := BGPAddressFamilyIPv4Ipv4UnicastNetworks{}
+ if cValue := helpers.GetFromXPath(v, "number"); cValue.Exists() {
+ item.Network = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "route-map"); cValue.Exists() {
+ item.RouteMap = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "backdoor"); cValue.Exists() {
+ item.Backdoor = types.BoolValue(true)
+ } else {
+ item.Backdoor = types.BoolValue(false)
+ }
+ data.Ipv4UnicastNetworks = append(data.Ipv4UnicastNetworks, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ipv4-unicast/distance/adm-distance"); value.Exists() {
+ data.Ipv4UnicastAdminDistances = make([]BGPAddressFamilyIPv4Ipv4UnicastAdminDistances, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := BGPAddressFamilyIPv4Ipv4UnicastAdminDistances{}
+ if cValue := helpers.GetFromXPath(v, "distance"); cValue.Exists() {
+ item.Distance = types.Int64Value(cValue.Int())
+ }
+ if cValue := helpers.GetFromXPath(v, "srcip"); cValue.Exists() {
+ item.SourceIp = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "wildbits"); cValue.Exists() {
+ item.Wildcard = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "acl"); cValue.Exists() {
+ item.Acl = types.StringValue(cValue.String())
+ }
+ data.Ipv4UnicastAdminDistances = append(data.Ipv4UnicastAdminDistances, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ipv4-unicast/distance/bgp/extern-as"); value.Exists() {
+ data.Ipv4UnicastDistanceBgpExternal = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ipv4-unicast/distance/bgp/internal-as"); value.Exists() {
+ data.Ipv4UnicastDistanceBgpInternal = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ipv4-unicast/distance/bgp/local"); value.Exists() {
+ data.Ipv4UnicastDistanceBgpLocal = types.Int64Value(value.Int())
+ }
+}
+
+// End of section. //template:end fromBodyXML
+
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyDataXML
+
+func (data *BGPAddressFamilyIPv4Data) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ipv4-unicast/redistribute/connected"); value.Exists() {
+ data.Ipv4UnicastRedistributeConnected = types.BoolValue(true)
+ } else {
+ data.Ipv4UnicastRedistributeConnected = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ipv4-unicast/redistribute/static"); value.Exists() {
+ data.Ipv4UnicastRedistributeStatic = types.BoolValue(true)
+ } else {
+ data.Ipv4UnicastRedistributeStatic = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ipv4-unicast/aggregate-address"); value.Exists() {
+ data.Ipv4UnicastAggregateAddresses = make([]BGPAddressFamilyIPv4Ipv4UnicastAggregateAddresses, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := BGPAddressFamilyIPv4Ipv4UnicastAggregateAddresses{}
+ if cValue := helpers.GetFromXPath(v, "ipv4-address"); cValue.Exists() {
+ item.Ipv4Address = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "ipv4-mask"); cValue.Exists() {
+ item.Ipv4Mask = types.StringValue(cValue.String())
+ }
+ data.Ipv4UnicastAggregateAddresses = append(data.Ipv4UnicastAggregateAddresses, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ipv4-unicast/network/with-mask"); value.Exists() {
+ data.Ipv4UnicastNetworksMask = make([]BGPAddressFamilyIPv4Ipv4UnicastNetworksMask, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := BGPAddressFamilyIPv4Ipv4UnicastNetworksMask{}
+ if cValue := helpers.GetFromXPath(v, "number"); cValue.Exists() {
+ item.Network = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "mask"); cValue.Exists() {
+ item.Mask = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "route-map"); cValue.Exists() {
+ item.RouteMap = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "backdoor"); cValue.Exists() {
+ item.Backdoor = types.BoolValue(true)
+ } else {
+ item.Backdoor = types.BoolValue(false)
+ }
+ data.Ipv4UnicastNetworksMask = append(data.Ipv4UnicastNetworksMask, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ipv4-unicast/network/no-mask"); value.Exists() {
+ data.Ipv4UnicastNetworks = make([]BGPAddressFamilyIPv4Ipv4UnicastNetworks, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := BGPAddressFamilyIPv4Ipv4UnicastNetworks{}
+ if cValue := helpers.GetFromXPath(v, "number"); cValue.Exists() {
+ item.Network = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "route-map"); cValue.Exists() {
+ item.RouteMap = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "backdoor"); cValue.Exists() {
+ item.Backdoor = types.BoolValue(true)
+ } else {
+ item.Backdoor = types.BoolValue(false)
+ }
+ data.Ipv4UnicastNetworks = append(data.Ipv4UnicastNetworks, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ipv4-unicast/distance/adm-distance"); value.Exists() {
+ data.Ipv4UnicastAdminDistances = make([]BGPAddressFamilyIPv4Ipv4UnicastAdminDistances, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := BGPAddressFamilyIPv4Ipv4UnicastAdminDistances{}
+ if cValue := helpers.GetFromXPath(v, "distance"); cValue.Exists() {
+ item.Distance = types.Int64Value(cValue.Int())
+ }
+ if cValue := helpers.GetFromXPath(v, "srcip"); cValue.Exists() {
+ item.SourceIp = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "wildbits"); cValue.Exists() {
+ item.Wildcard = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "acl"); cValue.Exists() {
+ item.Acl = types.StringValue(cValue.String())
+ }
+ data.Ipv4UnicastAdminDistances = append(data.Ipv4UnicastAdminDistances, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ipv4-unicast/distance/bgp/extern-as"); value.Exists() {
+ data.Ipv4UnicastDistanceBgpExternal = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ipv4-unicast/distance/bgp/internal-as"); value.Exists() {
+ data.Ipv4UnicastDistanceBgpInternal = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ipv4-unicast/distance/bgp/local"); value.Exists() {
+ data.Ipv4UnicastDistanceBgpLocal = types.Int64Value(value.Int())
+ }
+}
+
+// End of section. //template:end fromBodyDataXML
+
+// Section below is generated&owned by "gen/generator.go". //template:begin getDeletedItems
+
+func (data *BGPAddressFamilyIPv4) getDeletedItems(ctx context.Context, state BGPAddressFamilyIPv4) []string {
+ deletedItems := make([]string, 0)
+ if !state.Ipv4UnicastDistanceBgpLocal.IsNull() && data.Ipv4UnicastDistanceBgpLocal.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ipv4-unicast/distance/bgp/local", state.getPath()))
+ }
+ if !state.Ipv4UnicastDistanceBgpInternal.IsNull() && data.Ipv4UnicastDistanceBgpInternal.IsNull() {
deletedItems = append(deletedItems, fmt.Sprintf("%v/ipv4-unicast/distance/bgp/internal-as", state.getPath()))
}
if !state.Ipv4UnicastDistanceBgpExternal.IsNull() && data.Ipv4UnicastDistanceBgpExternal.IsNull() {
@@ -803,6 +1345,190 @@ func (data *BGPAddressFamilyIPv4) getDeletedItems(ctx context.Context, state BGP
// End of section. //template:end getDeletedItems
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletedItemsXML
+
+func (data *BGPAddressFamilyIPv4) addDeletedItemsXML(ctx context.Context, state BGPAddressFamilyIPv4, body string) string {
+ b := netconf.NewBody(body)
+ if !state.Ipv4UnicastRedistributeConnected.IsNull() && data.Ipv4UnicastRedistributeConnected.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ipv4-unicast/redistribute/connected")
+ }
+ if !state.Ipv4UnicastRedistributeStatic.IsNull() && data.Ipv4UnicastRedistributeStatic.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ipv4-unicast/redistribute/static")
+ }
+ for i := range state.Ipv4UnicastAggregateAddresses {
+ stateKeys := [...]string{"ipv4-address", "ipv4-mask"}
+ stateKeyValues := [...]string{state.Ipv4UnicastAggregateAddresses[i].Ipv4Address.ValueString(), state.Ipv4UnicastAggregateAddresses[i].Ipv4Mask.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.Ipv4UnicastAggregateAddresses[i].Ipv4Address.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if !reflect.ValueOf(state.Ipv4UnicastAggregateAddresses[i].Ipv4Mask.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.Ipv4UnicastAggregateAddresses {
+ found = true
+ if state.Ipv4UnicastAggregateAddresses[i].Ipv4Address.ValueString() != data.Ipv4UnicastAggregateAddresses[j].Ipv4Address.ValueString() {
+ found = false
+ }
+ if state.Ipv4UnicastAggregateAddresses[i].Ipv4Mask.ValueString() != data.Ipv4UnicastAggregateAddresses[j].Ipv4Mask.ValueString() {
+ found = false
+ }
+ if found {
+ break
+ }
+ }
+ if !found {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/ipv4-unicast/aggregate-address%v", predicates))
+ }
+ }
+ for i := range state.Ipv4UnicastNetworksMask {
+ stateKeys := [...]string{"number", "mask"}
+ stateKeyValues := [...]string{state.Ipv4UnicastNetworksMask[i].Network.ValueString(), state.Ipv4UnicastNetworksMask[i].Mask.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.Ipv4UnicastNetworksMask[i].Network.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if !reflect.ValueOf(state.Ipv4UnicastNetworksMask[i].Mask.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.Ipv4UnicastNetworksMask {
+ found = true
+ if state.Ipv4UnicastNetworksMask[i].Network.ValueString() != data.Ipv4UnicastNetworksMask[j].Network.ValueString() {
+ found = false
+ }
+ if state.Ipv4UnicastNetworksMask[i].Mask.ValueString() != data.Ipv4UnicastNetworksMask[j].Mask.ValueString() {
+ found = false
+ }
+ if found {
+ if !state.Ipv4UnicastNetworksMask[i].RouteMap.IsNull() && data.Ipv4UnicastNetworksMask[j].RouteMap.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/ipv4-unicast/network/with-mask%v/route-map", predicates))
+ }
+ if !state.Ipv4UnicastNetworksMask[i].Backdoor.IsNull() && data.Ipv4UnicastNetworksMask[j].Backdoor.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/ipv4-unicast/network/with-mask%v/backdoor", predicates))
+ }
+ break
+ }
+ }
+ if !found {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/ipv4-unicast/network/with-mask%v", predicates))
+ }
+ }
+ for i := range state.Ipv4UnicastNetworks {
+ stateKeys := [...]string{"number"}
+ stateKeyValues := [...]string{state.Ipv4UnicastNetworks[i].Network.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.Ipv4UnicastNetworks[i].Network.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.Ipv4UnicastNetworks {
+ found = true
+ if state.Ipv4UnicastNetworks[i].Network.ValueString() != data.Ipv4UnicastNetworks[j].Network.ValueString() {
+ found = false
+ }
+ if found {
+ if !state.Ipv4UnicastNetworks[i].RouteMap.IsNull() && data.Ipv4UnicastNetworks[j].RouteMap.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/ipv4-unicast/network/no-mask%v/route-map", predicates))
+ }
+ if !state.Ipv4UnicastNetworks[i].Backdoor.IsNull() && data.Ipv4UnicastNetworks[j].Backdoor.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/ipv4-unicast/network/no-mask%v/backdoor", predicates))
+ }
+ break
+ }
+ }
+ if !found {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/ipv4-unicast/network/no-mask%v", predicates))
+ }
+ }
+ for i := range state.Ipv4UnicastAdminDistances {
+ stateKeys := [...]string{"distance", "srcip", "wildbits"}
+ stateKeyValues := [...]string{strconv.FormatInt(state.Ipv4UnicastAdminDistances[i].Distance.ValueInt64(), 10), state.Ipv4UnicastAdminDistances[i].SourceIp.ValueString(), state.Ipv4UnicastAdminDistances[i].Wildcard.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.Ipv4UnicastAdminDistances[i].Distance.ValueInt64()).IsZero() {
+ emptyKeys = false
+ }
+ if !reflect.ValueOf(state.Ipv4UnicastAdminDistances[i].SourceIp.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if !reflect.ValueOf(state.Ipv4UnicastAdminDistances[i].Wildcard.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.Ipv4UnicastAdminDistances {
+ found = true
+ if state.Ipv4UnicastAdminDistances[i].Distance.ValueInt64() != data.Ipv4UnicastAdminDistances[j].Distance.ValueInt64() {
+ found = false
+ }
+ if state.Ipv4UnicastAdminDistances[i].SourceIp.ValueString() != data.Ipv4UnicastAdminDistances[j].SourceIp.ValueString() {
+ found = false
+ }
+ if state.Ipv4UnicastAdminDistances[i].Wildcard.ValueString() != data.Ipv4UnicastAdminDistances[j].Wildcard.ValueString() {
+ found = false
+ }
+ if found {
+ if !state.Ipv4UnicastAdminDistances[i].Acl.IsNull() && data.Ipv4UnicastAdminDistances[j].Acl.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/ipv4-unicast/distance/adm-distance%v/acl", predicates))
+ }
+ break
+ }
+ }
+ if !found {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/ipv4-unicast/distance/adm-distance%v", predicates))
+ }
+ }
+ if !state.Ipv4UnicastDistanceBgpExternal.IsNull() && data.Ipv4UnicastDistanceBgpExternal.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ipv4-unicast/distance/bgp/extern-as")
+ }
+ if !state.Ipv4UnicastDistanceBgpInternal.IsNull() && data.Ipv4UnicastDistanceBgpInternal.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ipv4-unicast/distance/bgp/internal-as")
+ }
+ if !state.Ipv4UnicastDistanceBgpLocal.IsNull() && data.Ipv4UnicastDistanceBgpLocal.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ipv4-unicast/distance/bgp/local")
+ }
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletedItemsXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin getEmptyLeafsDelete
func (data *BGPAddressFamilyIPv4) getEmptyLeafsDelete(ctx context.Context) []string {
@@ -878,3 +1604,68 @@ func (data *BGPAddressFamilyIPv4) getDeletePaths(ctx context.Context) []string {
}
// End of section. //template:end getDeletePaths
+
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletePathsXML
+
+func (data *BGPAddressFamilyIPv4) addDeletePathsXML(ctx context.Context, body string) string {
+ b := netconf.NewBody(body)
+ if !data.Ipv4UnicastRedistributeConnected.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ipv4-unicast/redistribute/connected")
+ }
+ if !data.Ipv4UnicastRedistributeStatic.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ipv4-unicast/redistribute/static")
+ }
+ for i := range data.Ipv4UnicastAggregateAddresses {
+ keys := [...]string{"ipv4-address", "ipv4-mask"}
+ keyValues := [...]string{data.Ipv4UnicastAggregateAddresses[i].Ipv4Address.ValueString(), data.Ipv4UnicastAggregateAddresses[i].Ipv4Mask.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/ipv4-unicast/aggregate-address%v", predicates))
+ }
+ for i := range data.Ipv4UnicastNetworksMask {
+ keys := [...]string{"number", "mask"}
+ keyValues := [...]string{data.Ipv4UnicastNetworksMask[i].Network.ValueString(), data.Ipv4UnicastNetworksMask[i].Mask.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/ipv4-unicast/network/with-mask%v", predicates))
+ }
+ for i := range data.Ipv4UnicastNetworks {
+ keys := [...]string{"number"}
+ keyValues := [...]string{data.Ipv4UnicastNetworks[i].Network.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/ipv4-unicast/network/no-mask%v", predicates))
+ }
+ for i := range data.Ipv4UnicastAdminDistances {
+ keys := [...]string{"distance", "srcip", "wildbits"}
+ keyValues := [...]string{strconv.FormatInt(data.Ipv4UnicastAdminDistances[i].Distance.ValueInt64(), 10), data.Ipv4UnicastAdminDistances[i].SourceIp.ValueString(), data.Ipv4UnicastAdminDistances[i].Wildcard.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/ipv4-unicast/distance/adm-distance%v", predicates))
+ }
+ if !data.Ipv4UnicastDistanceBgpExternal.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ipv4-unicast/distance/bgp/extern-as")
+ }
+ if !data.Ipv4UnicastDistanceBgpInternal.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ipv4-unicast/distance/bgp/internal-as")
+ }
+ if !data.Ipv4UnicastDistanceBgpLocal.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ipv4-unicast/distance/bgp/local")
+ }
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletePathsXML
diff --git a/internal/provider/model_iosxe_bgp_address_family_ipv4_vrf.go b/internal/provider/model_iosxe_bgp_address_family_ipv4_vrf.go
index c90b5515..9ca87226 100644
--- a/internal/provider/model_iosxe_bgp_address_family_ipv4_vrf.go
+++ b/internal/provider/model_iosxe_bgp_address_family_ipv4_vrf.go
@@ -31,6 +31,9 @@ import (
"github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/types"
+ "github.com/hashicorp/terraform-plugin-log/tflog"
+ "github.com/netascode/go-netconf"
+ "github.com/netascode/xmldot"
"github.com/tidwall/gjson"
"github.com/tidwall/sjson"
)
@@ -116,6 +119,19 @@ func (data BGPAddressFamilyIPv4VRF) getPathShort() string {
return matches[1]
}
+// getXPath returns the XPath for NETCONF operations
+func (data BGPAddressFamilyIPv4VRF) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/router/Cisco-IOS-XE-bgp:bgp[id=%v]/address-family/with-vrf/ipv4[af-name=%s]"
+ path = fmt.Sprintf(path, fmt.Sprintf("%v", data.Asn.ValueString()), fmt.Sprintf("%v", data.AfName.ValueString()))
+ return path
+}
+
+func (data BGPAddressFamilyIPv4VRFData) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/router/Cisco-IOS-XE-bgp:bgp[id=%v]/address-family/with-vrf/ipv4[af-name=%s]"
+ path = fmt.Sprintf(path, fmt.Sprintf("%v", data.Asn.ValueString()), fmt.Sprintf("%v", data.AfName.ValueString()))
+ return path
+}
+
// End of section. //template:end getPath
// Section below is generated&owned by "gen/generator.go". //template:begin toBody
@@ -241,6 +257,152 @@ func (data BGPAddressFamilyIPv4VRF) toBody(ctx context.Context) string {
// End of section. //template:end toBody
+// Section below is generated&owned by "gen/generator.go". //template:begin toBodyXML
+
+func (data BGPAddressFamilyIPv4VRF) toBodyXML(ctx context.Context) string {
+ body := netconf.Body{}
+ if !data.AfName.IsNull() && !data.AfName.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/af-name", data.AfName.ValueString())
+ }
+ if len(data.Vrfs) > 0 {
+ for _, item := range data.Vrfs {
+ cBody := netconf.Body{}
+ if !item.Name.IsNull() && !item.Name.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "name", item.Name.ValueString())
+ }
+ if !item.Ipv4UnicastAdvertiseL2vpnEvpn.IsNull() && !item.Ipv4UnicastAdvertiseL2vpnEvpn.IsUnknown() {
+ if item.Ipv4UnicastAdvertiseL2vpnEvpn.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "ipv4-unicast/advertise/l2vpn/evpn", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "ipv4-unicast/advertise/l2vpn/evpn")
+ }
+ }
+ if !item.Ipv4UnicastRedistributeConnected.IsNull() && !item.Ipv4UnicastRedistributeConnected.IsUnknown() {
+ if item.Ipv4UnicastRedistributeConnected.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "ipv4-unicast/redistribute-vrf/connected", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "ipv4-unicast/redistribute-vrf/connected")
+ }
+ }
+ if !item.Ipv4UnicastRouterIdLoopback.IsNull() && !item.Ipv4UnicastRouterIdLoopback.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "ipv4-unicast/bgp/router-id/interface/Loopback", strconv.FormatInt(item.Ipv4UnicastRouterIdLoopback.ValueInt64(), 10))
+ }
+ if !item.Ipv4UnicastRouterIdIp.IsNull() && !item.Ipv4UnicastRouterIdIp.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "ipv4-unicast/bgp/router-id/ip-id", item.Ipv4UnicastRouterIdIp.ValueString())
+ }
+ if len(item.Ipv4UnicastAggregateAddresses) > 0 {
+ for _, citem := range item.Ipv4UnicastAggregateAddresses {
+ ccBody := netconf.Body{}
+ if !citem.Ipv4Address.IsNull() && !citem.Ipv4Address.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "ipv4-address", citem.Ipv4Address.ValueString())
+ }
+ if !citem.Ipv4Mask.IsNull() && !citem.Ipv4Mask.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "ipv4-mask", citem.Ipv4Mask.ValueString())
+ }
+ cBody = helpers.SetRawFromXPath(cBody, "ipv4-unicast/aggregate-address", ccBody.Res())
+ }
+ }
+ if !item.Ipv4UnicastRedistributeStatic.IsNull() && !item.Ipv4UnicastRedistributeStatic.IsUnknown() {
+ if item.Ipv4UnicastRedistributeStatic.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "ipv4-unicast/redistribute-vrf/static", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "ipv4-unicast/redistribute-vrf/static")
+ }
+ }
+ if len(item.Ipv4UnicastNetworksMask) > 0 {
+ for _, citem := range item.Ipv4UnicastNetworksMask {
+ ccBody := netconf.Body{}
+ if !citem.Network.IsNull() && !citem.Network.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "number", citem.Network.ValueString())
+ }
+ if !citem.Mask.IsNull() && !citem.Mask.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "mask", citem.Mask.ValueString())
+ }
+ if !citem.RouteMap.IsNull() && !citem.RouteMap.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "route-map", citem.RouteMap.ValueString())
+ }
+ if !citem.Backdoor.IsNull() && !citem.Backdoor.IsUnknown() {
+ if citem.Backdoor.ValueBool() {
+ ccBody = helpers.SetFromXPath(ccBody, "backdoor", "")
+ } else {
+ ccBody = helpers.RemoveFromXPath(ccBody, "backdoor")
+ }
+ }
+ if !citem.Evpn.IsNull() && !citem.Evpn.IsUnknown() {
+ if citem.Evpn.ValueBool() {
+ ccBody = helpers.SetFromXPath(ccBody, "evpn", "")
+ } else {
+ ccBody = helpers.RemoveFromXPath(ccBody, "evpn")
+ }
+ }
+ cBody = helpers.SetRawFromXPath(cBody, "ipv4-unicast/network/with-mask", ccBody.Res())
+ }
+ }
+ if len(item.Ipv4UnicastNetworks) > 0 {
+ for _, citem := range item.Ipv4UnicastNetworks {
+ ccBody := netconf.Body{}
+ if !citem.Network.IsNull() && !citem.Network.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "number", citem.Network.ValueString())
+ }
+ if !citem.RouteMap.IsNull() && !citem.RouteMap.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "route-map", citem.RouteMap.ValueString())
+ }
+ if !citem.Backdoor.IsNull() && !citem.Backdoor.IsUnknown() {
+ if citem.Backdoor.ValueBool() {
+ ccBody = helpers.SetFromXPath(ccBody, "backdoor", "")
+ } else {
+ ccBody = helpers.RemoveFromXPath(ccBody, "backdoor")
+ }
+ }
+ if !citem.Evpn.IsNull() && !citem.Evpn.IsUnknown() {
+ if citem.Evpn.ValueBool() {
+ ccBody = helpers.SetFromXPath(ccBody, "evpn", "")
+ } else {
+ ccBody = helpers.RemoveFromXPath(ccBody, "evpn")
+ }
+ }
+ cBody = helpers.SetRawFromXPath(cBody, "ipv4-unicast/network/no-mask", ccBody.Res())
+ }
+ }
+ if len(item.Ipv4UnicastAdminDistances) > 0 {
+ for _, citem := range item.Ipv4UnicastAdminDistances {
+ ccBody := netconf.Body{}
+ if !citem.Distance.IsNull() && !citem.Distance.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "distance", strconv.FormatInt(citem.Distance.ValueInt64(), 10))
+ }
+ if !citem.SourceIp.IsNull() && !citem.SourceIp.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "srcip", citem.SourceIp.ValueString())
+ }
+ if !citem.Wildcard.IsNull() && !citem.Wildcard.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "wildbits", citem.Wildcard.ValueString())
+ }
+ if !citem.Acl.IsNull() && !citem.Acl.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "acl", citem.Acl.ValueString())
+ }
+ cBody = helpers.SetRawFromXPath(cBody, "ipv4-unicast/distance/adm-distance", ccBody.Res())
+ }
+ }
+ if !item.Ipv4UnicastDistanceBgpExternal.IsNull() && !item.Ipv4UnicastDistanceBgpExternal.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "ipv4-unicast/distance/bgp/extern-as", strconv.FormatInt(item.Ipv4UnicastDistanceBgpExternal.ValueInt64(), 10))
+ }
+ if !item.Ipv4UnicastDistanceBgpInternal.IsNull() && !item.Ipv4UnicastDistanceBgpInternal.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "ipv4-unicast/distance/bgp/internal-as", strconv.FormatInt(item.Ipv4UnicastDistanceBgpInternal.ValueInt64(), 10))
+ }
+ if !item.Ipv4UnicastDistanceBgpLocal.IsNull() && !item.Ipv4UnicastDistanceBgpLocal.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "ipv4-unicast/distance/bgp/local", strconv.FormatInt(item.Ipv4UnicastDistanceBgpLocal.ValueInt64(), 10))
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/vrf", cBody.Res())
+ }
+ }
+ bodyString, err := body.String()
+ if err != nil {
+ tflog.Error(ctx, fmt.Sprintf("Error converting body to string: %s", err))
+ }
+ return bodyString
+}
+
+// End of section. //template:end toBodyXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBody
func (data *BGPAddressFamilyIPv4VRF) updateFromBody(ctx context.Context, res gjson.Result) {
@@ -525,98 +687,648 @@ func (data *BGPAddressFamilyIPv4VRF) updateFromBody(ctx context.Context, res gjs
// End of section. //template:end updateFromBody
-// Section below is generated&owned by "gen/generator.go". //template:begin fromBody
+// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBodyXML
-func (data *BGPAddressFamilyIPv4VRF) fromBody(ctx context.Context, res gjson.Result) {
- prefix := helpers.LastElement(data.getPath()) + "."
- if res.Get(helpers.LastElement(data.getPath())).IsArray() {
- prefix += "0."
+func (data *BGPAddressFamilyIPv4VRF) updateFromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/af-name"); value.Exists() && !data.AfName.IsNull() {
+ data.AfName = types.StringValue(value.String())
+ } else {
+ data.AfName = types.StringNull()
}
- if value := res.Get(prefix + "vrf"); value.Exists() {
- data.Vrfs = make([]BGPAddressFamilyIPv4VRFVrfs, 0)
- value.ForEach(func(k, v gjson.Result) bool {
- item := BGPAddressFamilyIPv4VRFVrfs{}
- if cValue := v.Get("name"); cValue.Exists() {
- item.Name = types.StringValue(cValue.String())
- }
- if cValue := v.Get("ipv4-unicast.advertise.l2vpn.evpn"); cValue.Exists() {
- item.Ipv4UnicastAdvertiseL2vpnEvpn = types.BoolValue(true)
+ for i := range data.Vrfs {
+ keys := [...]string{"name"}
+ keyValues := [...]string{data.Vrfs[i].Name.ValueString()}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/vrf").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, "name"); value.Exists() && !data.Vrfs[i].Name.IsNull() {
+ data.Vrfs[i].Name = types.StringValue(value.String())
+ } else {
+ data.Vrfs[i].Name = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "ipv4-unicast/advertise/l2vpn/evpn"); !data.Vrfs[i].Ipv4UnicastAdvertiseL2vpnEvpn.IsNull() {
+ if value.Exists() {
+ data.Vrfs[i].Ipv4UnicastAdvertiseL2vpnEvpn = types.BoolValue(true)
} else {
- item.Ipv4UnicastAdvertiseL2vpnEvpn = types.BoolValue(false)
+ data.Vrfs[i].Ipv4UnicastAdvertiseL2vpnEvpn = types.BoolValue(false)
}
- if cValue := v.Get("ipv4-unicast.redistribute-vrf.connected"); cValue.Exists() {
- item.Ipv4UnicastRedistributeConnected = types.BoolValue(true)
+ } else {
+ data.Vrfs[i].Ipv4UnicastAdvertiseL2vpnEvpn = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "ipv4-unicast/redistribute-vrf/connected"); !data.Vrfs[i].Ipv4UnicastRedistributeConnected.IsNull() {
+ if value.Exists() {
+ data.Vrfs[i].Ipv4UnicastRedistributeConnected = types.BoolValue(true)
} else {
- item.Ipv4UnicastRedistributeConnected = types.BoolValue(false)
- }
- if cValue := v.Get("ipv4-unicast.bgp.router-id.interface.Loopback"); cValue.Exists() {
- item.Ipv4UnicastRouterIdLoopback = types.Int64Value(cValue.Int())
- }
- if cValue := v.Get("ipv4-unicast.bgp.router-id.ip-id"); cValue.Exists() {
- item.Ipv4UnicastRouterIdIp = types.StringValue(cValue.String())
+ data.Vrfs[i].Ipv4UnicastRedistributeConnected = types.BoolValue(false)
}
- if cValue := v.Get("ipv4-unicast.aggregate-address"); cValue.Exists() {
- item.Ipv4UnicastAggregateAddresses = make([]BGPAddressFamilyIPv4VRFVrfsIpv4UnicastAggregateAddresses, 0)
- cValue.ForEach(func(ck, cv gjson.Result) bool {
- cItem := BGPAddressFamilyIPv4VRFVrfsIpv4UnicastAggregateAddresses{}
- if ccValue := cv.Get("ipv4-address"); ccValue.Exists() {
- cItem.Ipv4Address = types.StringValue(ccValue.String())
+ } else {
+ data.Vrfs[i].Ipv4UnicastRedistributeConnected = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "ipv4-unicast/bgp/router-id/interface/Loopback"); value.Exists() && !data.Vrfs[i].Ipv4UnicastRouterIdLoopback.IsNull() {
+ data.Vrfs[i].Ipv4UnicastRouterIdLoopback = types.Int64Value(value.Int())
+ } else {
+ data.Vrfs[i].Ipv4UnicastRouterIdLoopback = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(r, "ipv4-unicast/bgp/router-id/ip-id"); value.Exists() && !data.Vrfs[i].Ipv4UnicastRouterIdIp.IsNull() {
+ data.Vrfs[i].Ipv4UnicastRouterIdIp = types.StringValue(value.String())
+ } else {
+ data.Vrfs[i].Ipv4UnicastRouterIdIp = types.StringNull()
+ }
+ for ci := range data.Vrfs[i].Ipv4UnicastAggregateAddresses {
+ keys := [...]string{"ipv4-address", "ipv4-mask"}
+ keyValues := [...]string{data.Vrfs[i].Ipv4UnicastAggregateAddresses[ci].Ipv4Address.ValueString(), data.Vrfs[i].Ipv4UnicastAggregateAddresses[ci].Ipv4Mask.ValueString()}
+
+ var cr xmldot.Result
+ helpers.GetFromXPath(r, "ipv4-unicast/aggregate-address").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
}
- if ccValue := cv.Get("ipv4-mask"); ccValue.Exists() {
- cItem.Ipv4Mask = types.StringValue(ccValue.String())
+ if found {
+ cr = v
+ return false
}
- item.Ipv4UnicastAggregateAddresses = append(item.Ipv4UnicastAggregateAddresses, cItem)
return true
- })
+ },
+ )
+ if value := helpers.GetFromXPath(cr, "ipv4-address"); value.Exists() && !data.Vrfs[i].Ipv4UnicastAggregateAddresses[ci].Ipv4Address.IsNull() {
+ data.Vrfs[i].Ipv4UnicastAggregateAddresses[ci].Ipv4Address = types.StringValue(value.String())
+ } else {
+ data.Vrfs[i].Ipv4UnicastAggregateAddresses[ci].Ipv4Address = types.StringNull()
}
- if cValue := v.Get("ipv4-unicast.redistribute-vrf.static"); cValue.Exists() {
- item.Ipv4UnicastRedistributeStatic = types.BoolValue(true)
+ if value := helpers.GetFromXPath(cr, "ipv4-mask"); value.Exists() && !data.Vrfs[i].Ipv4UnicastAggregateAddresses[ci].Ipv4Mask.IsNull() {
+ data.Vrfs[i].Ipv4UnicastAggregateAddresses[ci].Ipv4Mask = types.StringValue(value.String())
} else {
- item.Ipv4UnicastRedistributeStatic = types.BoolValue(false)
+ data.Vrfs[i].Ipv4UnicastAggregateAddresses[ci].Ipv4Mask = types.StringNull()
}
- if cValue := v.Get("ipv4-unicast.network.with-mask"); cValue.Exists() {
- item.Ipv4UnicastNetworksMask = make([]BGPAddressFamilyIPv4VRFVrfsIpv4UnicastNetworksMask, 0)
- cValue.ForEach(func(ck, cv gjson.Result) bool {
- cItem := BGPAddressFamilyIPv4VRFVrfsIpv4UnicastNetworksMask{}
- if ccValue := cv.Get("number"); ccValue.Exists() {
- cItem.Network = types.StringValue(ccValue.String())
- }
- if ccValue := cv.Get("mask"); ccValue.Exists() {
- cItem.Mask = types.StringValue(ccValue.String())
- }
- if ccValue := cv.Get("route-map"); ccValue.Exists() {
- cItem.RouteMap = types.StringValue(ccValue.String())
- }
- if ccValue := cv.Get("backdoor"); ccValue.Exists() {
- cItem.Backdoor = types.BoolValue(true)
- } else {
- cItem.Backdoor = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(r, "ipv4-unicast/redistribute-vrf/static"); !data.Vrfs[i].Ipv4UnicastRedistributeStatic.IsNull() {
+ if value.Exists() {
+ data.Vrfs[i].Ipv4UnicastRedistributeStatic = types.BoolValue(true)
+ } else {
+ data.Vrfs[i].Ipv4UnicastRedistributeStatic = types.BoolValue(false)
+ }
+ } else {
+ data.Vrfs[i].Ipv4UnicastRedistributeStatic = types.BoolNull()
+ }
+ for ci := range data.Vrfs[i].Ipv4UnicastNetworksMask {
+ keys := [...]string{"number", "mask"}
+ keyValues := [...]string{data.Vrfs[i].Ipv4UnicastNetworksMask[ci].Network.ValueString(), data.Vrfs[i].Ipv4UnicastNetworksMask[ci].Mask.ValueString()}
+
+ var cr xmldot.Result
+ helpers.GetFromXPath(r, "ipv4-unicast/network/with-mask").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
}
- if ccValue := cv.Get("evpn"); ccValue.Exists() {
- cItem.Evpn = types.BoolValue(true)
- } else {
- cItem.Evpn = types.BoolValue(false)
+ if found {
+ cr = v
+ return false
}
- item.Ipv4UnicastNetworksMask = append(item.Ipv4UnicastNetworksMask, cItem)
return true
- })
+ },
+ )
+ if value := helpers.GetFromXPath(cr, "number"); value.Exists() && !data.Vrfs[i].Ipv4UnicastNetworksMask[ci].Network.IsNull() {
+ data.Vrfs[i].Ipv4UnicastNetworksMask[ci].Network = types.StringValue(value.String())
+ } else {
+ data.Vrfs[i].Ipv4UnicastNetworksMask[ci].Network = types.StringNull()
}
- if cValue := v.Get("ipv4-unicast.network.no-mask"); cValue.Exists() {
- item.Ipv4UnicastNetworks = make([]BGPAddressFamilyIPv4VRFVrfsIpv4UnicastNetworks, 0)
- cValue.ForEach(func(ck, cv gjson.Result) bool {
- cItem := BGPAddressFamilyIPv4VRFVrfsIpv4UnicastNetworks{}
- if ccValue := cv.Get("number"); ccValue.Exists() {
- cItem.Network = types.StringValue(ccValue.String())
- }
+ if value := helpers.GetFromXPath(cr, "mask"); value.Exists() && !data.Vrfs[i].Ipv4UnicastNetworksMask[ci].Mask.IsNull() {
+ data.Vrfs[i].Ipv4UnicastNetworksMask[ci].Mask = types.StringValue(value.String())
+ } else {
+ data.Vrfs[i].Ipv4UnicastNetworksMask[ci].Mask = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(cr, "route-map"); value.Exists() && !data.Vrfs[i].Ipv4UnicastNetworksMask[ci].RouteMap.IsNull() {
+ data.Vrfs[i].Ipv4UnicastNetworksMask[ci].RouteMap = types.StringValue(value.String())
+ } else {
+ data.Vrfs[i].Ipv4UnicastNetworksMask[ci].RouteMap = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(cr, "backdoor"); !data.Vrfs[i].Ipv4UnicastNetworksMask[ci].Backdoor.IsNull() {
+ if value.Exists() {
+ data.Vrfs[i].Ipv4UnicastNetworksMask[ci].Backdoor = types.BoolValue(true)
+ } else {
+ data.Vrfs[i].Ipv4UnicastNetworksMask[ci].Backdoor = types.BoolValue(false)
+ }
+ } else {
+ data.Vrfs[i].Ipv4UnicastNetworksMask[ci].Backdoor = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(cr, "evpn"); !data.Vrfs[i].Ipv4UnicastNetworksMask[ci].Evpn.IsNull() {
+ if value.Exists() {
+ data.Vrfs[i].Ipv4UnicastNetworksMask[ci].Evpn = types.BoolValue(true)
+ } else {
+ data.Vrfs[i].Ipv4UnicastNetworksMask[ci].Evpn = types.BoolValue(false)
+ }
+ } else {
+ data.Vrfs[i].Ipv4UnicastNetworksMask[ci].Evpn = types.BoolNull()
+ }
+ }
+ for ci := range data.Vrfs[i].Ipv4UnicastNetworks {
+ keys := [...]string{"number"}
+ keyValues := [...]string{data.Vrfs[i].Ipv4UnicastNetworks[ci].Network.ValueString()}
+
+ var cr xmldot.Result
+ helpers.GetFromXPath(r, "ipv4-unicast/network/no-mask").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ cr = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(cr, "number"); value.Exists() && !data.Vrfs[i].Ipv4UnicastNetworks[ci].Network.IsNull() {
+ data.Vrfs[i].Ipv4UnicastNetworks[ci].Network = types.StringValue(value.String())
+ } else {
+ data.Vrfs[i].Ipv4UnicastNetworks[ci].Network = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(cr, "route-map"); value.Exists() && !data.Vrfs[i].Ipv4UnicastNetworks[ci].RouteMap.IsNull() {
+ data.Vrfs[i].Ipv4UnicastNetworks[ci].RouteMap = types.StringValue(value.String())
+ } else {
+ data.Vrfs[i].Ipv4UnicastNetworks[ci].RouteMap = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(cr, "backdoor"); !data.Vrfs[i].Ipv4UnicastNetworks[ci].Backdoor.IsNull() {
+ if value.Exists() {
+ data.Vrfs[i].Ipv4UnicastNetworks[ci].Backdoor = types.BoolValue(true)
+ } else {
+ data.Vrfs[i].Ipv4UnicastNetworks[ci].Backdoor = types.BoolValue(false)
+ }
+ } else {
+ data.Vrfs[i].Ipv4UnicastNetworks[ci].Backdoor = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(cr, "evpn"); !data.Vrfs[i].Ipv4UnicastNetworks[ci].Evpn.IsNull() {
+ if value.Exists() {
+ data.Vrfs[i].Ipv4UnicastNetworks[ci].Evpn = types.BoolValue(true)
+ } else {
+ data.Vrfs[i].Ipv4UnicastNetworks[ci].Evpn = types.BoolValue(false)
+ }
+ } else {
+ data.Vrfs[i].Ipv4UnicastNetworks[ci].Evpn = types.BoolNull()
+ }
+ }
+ for ci := range data.Vrfs[i].Ipv4UnicastAdminDistances {
+ keys := [...]string{"distance", "srcip", "wildbits"}
+ keyValues := [...]string{strconv.FormatInt(data.Vrfs[i].Ipv4UnicastAdminDistances[ci].Distance.ValueInt64(), 10), data.Vrfs[i].Ipv4UnicastAdminDistances[ci].SourceIp.ValueString(), data.Vrfs[i].Ipv4UnicastAdminDistances[ci].Wildcard.ValueString()}
+
+ var cr xmldot.Result
+ helpers.GetFromXPath(r, "ipv4-unicast/distance/adm-distance").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ cr = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(cr, "distance"); value.Exists() && !data.Vrfs[i].Ipv4UnicastAdminDistances[ci].Distance.IsNull() {
+ data.Vrfs[i].Ipv4UnicastAdminDistances[ci].Distance = types.Int64Value(value.Int())
+ } else {
+ data.Vrfs[i].Ipv4UnicastAdminDistances[ci].Distance = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(cr, "srcip"); value.Exists() && !data.Vrfs[i].Ipv4UnicastAdminDistances[ci].SourceIp.IsNull() {
+ data.Vrfs[i].Ipv4UnicastAdminDistances[ci].SourceIp = types.StringValue(value.String())
+ } else {
+ data.Vrfs[i].Ipv4UnicastAdminDistances[ci].SourceIp = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(cr, "wildbits"); value.Exists() && !data.Vrfs[i].Ipv4UnicastAdminDistances[ci].Wildcard.IsNull() {
+ data.Vrfs[i].Ipv4UnicastAdminDistances[ci].Wildcard = types.StringValue(value.String())
+ } else {
+ data.Vrfs[i].Ipv4UnicastAdminDistances[ci].Wildcard = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(cr, "acl"); value.Exists() && !data.Vrfs[i].Ipv4UnicastAdminDistances[ci].Acl.IsNull() {
+ data.Vrfs[i].Ipv4UnicastAdminDistances[ci].Acl = types.StringValue(value.String())
+ } else {
+ data.Vrfs[i].Ipv4UnicastAdminDistances[ci].Acl = types.StringNull()
+ }
+ }
+ if value := helpers.GetFromXPath(r, "ipv4-unicast/distance/bgp/extern-as"); value.Exists() && !data.Vrfs[i].Ipv4UnicastDistanceBgpExternal.IsNull() {
+ data.Vrfs[i].Ipv4UnicastDistanceBgpExternal = types.Int64Value(value.Int())
+ } else {
+ data.Vrfs[i].Ipv4UnicastDistanceBgpExternal = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(r, "ipv4-unicast/distance/bgp/internal-as"); value.Exists() && !data.Vrfs[i].Ipv4UnicastDistanceBgpInternal.IsNull() {
+ data.Vrfs[i].Ipv4UnicastDistanceBgpInternal = types.Int64Value(value.Int())
+ } else {
+ data.Vrfs[i].Ipv4UnicastDistanceBgpInternal = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(r, "ipv4-unicast/distance/bgp/local"); value.Exists() && !data.Vrfs[i].Ipv4UnicastDistanceBgpLocal.IsNull() {
+ data.Vrfs[i].Ipv4UnicastDistanceBgpLocal = types.Int64Value(value.Int())
+ } else {
+ data.Vrfs[i].Ipv4UnicastDistanceBgpLocal = types.Int64Null()
+ }
+ }
+}
+
+// End of section. //template:end updateFromBodyXML
+
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBody
+
+func (data *BGPAddressFamilyIPv4VRF) fromBody(ctx context.Context, res gjson.Result) {
+ prefix := helpers.LastElement(data.getPath()) + "."
+ if res.Get(helpers.LastElement(data.getPath())).IsArray() {
+ prefix += "0."
+ }
+ if value := res.Get(prefix + "vrf"); value.Exists() {
+ data.Vrfs = make([]BGPAddressFamilyIPv4VRFVrfs, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := BGPAddressFamilyIPv4VRFVrfs{}
+ if cValue := v.Get("name"); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("ipv4-unicast.advertise.l2vpn.evpn"); cValue.Exists() {
+ item.Ipv4UnicastAdvertiseL2vpnEvpn = types.BoolValue(true)
+ } else {
+ item.Ipv4UnicastAdvertiseL2vpnEvpn = types.BoolValue(false)
+ }
+ if cValue := v.Get("ipv4-unicast.redistribute-vrf.connected"); cValue.Exists() {
+ item.Ipv4UnicastRedistributeConnected = types.BoolValue(true)
+ } else {
+ item.Ipv4UnicastRedistributeConnected = types.BoolValue(false)
+ }
+ if cValue := v.Get("ipv4-unicast.bgp.router-id.interface.Loopback"); cValue.Exists() {
+ item.Ipv4UnicastRouterIdLoopback = types.Int64Value(cValue.Int())
+ }
+ if cValue := v.Get("ipv4-unicast.bgp.router-id.ip-id"); cValue.Exists() {
+ item.Ipv4UnicastRouterIdIp = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("ipv4-unicast.aggregate-address"); cValue.Exists() {
+ item.Ipv4UnicastAggregateAddresses = make([]BGPAddressFamilyIPv4VRFVrfsIpv4UnicastAggregateAddresses, 0)
+ cValue.ForEach(func(ck, cv gjson.Result) bool {
+ cItem := BGPAddressFamilyIPv4VRFVrfsIpv4UnicastAggregateAddresses{}
+ if ccValue := cv.Get("ipv4-address"); ccValue.Exists() {
+ cItem.Ipv4Address = types.StringValue(ccValue.String())
+ }
+ if ccValue := cv.Get("ipv4-mask"); ccValue.Exists() {
+ cItem.Ipv4Mask = types.StringValue(ccValue.String())
+ }
+ item.Ipv4UnicastAggregateAddresses = append(item.Ipv4UnicastAggregateAddresses, cItem)
+ return true
+ })
+ }
+ if cValue := v.Get("ipv4-unicast.redistribute-vrf.static"); cValue.Exists() {
+ item.Ipv4UnicastRedistributeStatic = types.BoolValue(true)
+ } else {
+ item.Ipv4UnicastRedistributeStatic = types.BoolValue(false)
+ }
+ if cValue := v.Get("ipv4-unicast.network.with-mask"); cValue.Exists() {
+ item.Ipv4UnicastNetworksMask = make([]BGPAddressFamilyIPv4VRFVrfsIpv4UnicastNetworksMask, 0)
+ cValue.ForEach(func(ck, cv gjson.Result) bool {
+ cItem := BGPAddressFamilyIPv4VRFVrfsIpv4UnicastNetworksMask{}
+ if ccValue := cv.Get("number"); ccValue.Exists() {
+ cItem.Network = types.StringValue(ccValue.String())
+ }
+ if ccValue := cv.Get("mask"); ccValue.Exists() {
+ cItem.Mask = types.StringValue(ccValue.String())
+ }
if ccValue := cv.Get("route-map"); ccValue.Exists() {
cItem.RouteMap = types.StringValue(ccValue.String())
}
- if ccValue := cv.Get("backdoor"); ccValue.Exists() {
+ if ccValue := cv.Get("backdoor"); ccValue.Exists() {
+ cItem.Backdoor = types.BoolValue(true)
+ } else {
+ cItem.Backdoor = types.BoolValue(false)
+ }
+ if ccValue := cv.Get("evpn"); ccValue.Exists() {
+ cItem.Evpn = types.BoolValue(true)
+ } else {
+ cItem.Evpn = types.BoolValue(false)
+ }
+ item.Ipv4UnicastNetworksMask = append(item.Ipv4UnicastNetworksMask, cItem)
+ return true
+ })
+ }
+ if cValue := v.Get("ipv4-unicast.network.no-mask"); cValue.Exists() {
+ item.Ipv4UnicastNetworks = make([]BGPAddressFamilyIPv4VRFVrfsIpv4UnicastNetworks, 0)
+ cValue.ForEach(func(ck, cv gjson.Result) bool {
+ cItem := BGPAddressFamilyIPv4VRFVrfsIpv4UnicastNetworks{}
+ if ccValue := cv.Get("number"); ccValue.Exists() {
+ cItem.Network = types.StringValue(ccValue.String())
+ }
+ if ccValue := cv.Get("route-map"); ccValue.Exists() {
+ cItem.RouteMap = types.StringValue(ccValue.String())
+ }
+ if ccValue := cv.Get("backdoor"); ccValue.Exists() {
+ cItem.Backdoor = types.BoolValue(true)
+ } else {
+ cItem.Backdoor = types.BoolValue(false)
+ }
+ if ccValue := cv.Get("evpn"); ccValue.Exists() {
+ cItem.Evpn = types.BoolValue(true)
+ } else {
+ cItem.Evpn = types.BoolValue(false)
+ }
+ item.Ipv4UnicastNetworks = append(item.Ipv4UnicastNetworks, cItem)
+ return true
+ })
+ }
+ if cValue := v.Get("ipv4-unicast.distance.adm-distance"); cValue.Exists() {
+ item.Ipv4UnicastAdminDistances = make([]BGPAddressFamilyIPv4VRFVrfsIpv4UnicastAdminDistances, 0)
+ cValue.ForEach(func(ck, cv gjson.Result) bool {
+ cItem := BGPAddressFamilyIPv4VRFVrfsIpv4UnicastAdminDistances{}
+ if ccValue := cv.Get("distance"); ccValue.Exists() {
+ cItem.Distance = types.Int64Value(ccValue.Int())
+ }
+ if ccValue := cv.Get("srcip"); ccValue.Exists() {
+ cItem.SourceIp = types.StringValue(ccValue.String())
+ }
+ if ccValue := cv.Get("wildbits"); ccValue.Exists() {
+ cItem.Wildcard = types.StringValue(ccValue.String())
+ }
+ if ccValue := cv.Get("acl"); ccValue.Exists() {
+ cItem.Acl = types.StringValue(ccValue.String())
+ }
+ item.Ipv4UnicastAdminDistances = append(item.Ipv4UnicastAdminDistances, cItem)
+ return true
+ })
+ }
+ if cValue := v.Get("ipv4-unicast.distance.bgp.extern-as"); cValue.Exists() {
+ item.Ipv4UnicastDistanceBgpExternal = types.Int64Value(cValue.Int())
+ }
+ if cValue := v.Get("ipv4-unicast.distance.bgp.internal-as"); cValue.Exists() {
+ item.Ipv4UnicastDistanceBgpInternal = types.Int64Value(cValue.Int())
+ }
+ if cValue := v.Get("ipv4-unicast.distance.bgp.local"); cValue.Exists() {
+ item.Ipv4UnicastDistanceBgpLocal = types.Int64Value(cValue.Int())
+ }
+ data.Vrfs = append(data.Vrfs, item)
+ return true
+ })
+ }
+}
+
+// End of section. //template:end fromBody
+
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyData
+
+func (data *BGPAddressFamilyIPv4VRFData) fromBody(ctx context.Context, res gjson.Result) {
+ prefix := helpers.LastElement(data.getPath()) + "."
+ if res.Get(helpers.LastElement(data.getPath())).IsArray() {
+ prefix += "0."
+ }
+ if value := res.Get(prefix + "vrf"); value.Exists() {
+ data.Vrfs = make([]BGPAddressFamilyIPv4VRFVrfs, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := BGPAddressFamilyIPv4VRFVrfs{}
+ if cValue := v.Get("name"); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("ipv4-unicast.advertise.l2vpn.evpn"); cValue.Exists() {
+ item.Ipv4UnicastAdvertiseL2vpnEvpn = types.BoolValue(true)
+ } else {
+ item.Ipv4UnicastAdvertiseL2vpnEvpn = types.BoolValue(false)
+ }
+ if cValue := v.Get("ipv4-unicast.redistribute-vrf.connected"); cValue.Exists() {
+ item.Ipv4UnicastRedistributeConnected = types.BoolValue(true)
+ } else {
+ item.Ipv4UnicastRedistributeConnected = types.BoolValue(false)
+ }
+ if cValue := v.Get("ipv4-unicast.bgp.router-id.interface.Loopback"); cValue.Exists() {
+ item.Ipv4UnicastRouterIdLoopback = types.Int64Value(cValue.Int())
+ }
+ if cValue := v.Get("ipv4-unicast.bgp.router-id.ip-id"); cValue.Exists() {
+ item.Ipv4UnicastRouterIdIp = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("ipv4-unicast.aggregate-address"); cValue.Exists() {
+ item.Ipv4UnicastAggregateAddresses = make([]BGPAddressFamilyIPv4VRFVrfsIpv4UnicastAggregateAddresses, 0)
+ cValue.ForEach(func(ck, cv gjson.Result) bool {
+ cItem := BGPAddressFamilyIPv4VRFVrfsIpv4UnicastAggregateAddresses{}
+ if ccValue := cv.Get("ipv4-address"); ccValue.Exists() {
+ cItem.Ipv4Address = types.StringValue(ccValue.String())
+ }
+ if ccValue := cv.Get("ipv4-mask"); ccValue.Exists() {
+ cItem.Ipv4Mask = types.StringValue(ccValue.String())
+ }
+ item.Ipv4UnicastAggregateAddresses = append(item.Ipv4UnicastAggregateAddresses, cItem)
+ return true
+ })
+ }
+ if cValue := v.Get("ipv4-unicast.redistribute-vrf.static"); cValue.Exists() {
+ item.Ipv4UnicastRedistributeStatic = types.BoolValue(true)
+ } else {
+ item.Ipv4UnicastRedistributeStatic = types.BoolValue(false)
+ }
+ if cValue := v.Get("ipv4-unicast.network.with-mask"); cValue.Exists() {
+ item.Ipv4UnicastNetworksMask = make([]BGPAddressFamilyIPv4VRFVrfsIpv4UnicastNetworksMask, 0)
+ cValue.ForEach(func(ck, cv gjson.Result) bool {
+ cItem := BGPAddressFamilyIPv4VRFVrfsIpv4UnicastNetworksMask{}
+ if ccValue := cv.Get("number"); ccValue.Exists() {
+ cItem.Network = types.StringValue(ccValue.String())
+ }
+ if ccValue := cv.Get("mask"); ccValue.Exists() {
+ cItem.Mask = types.StringValue(ccValue.String())
+ }
+ if ccValue := cv.Get("route-map"); ccValue.Exists() {
+ cItem.RouteMap = types.StringValue(ccValue.String())
+ }
+ if ccValue := cv.Get("backdoor"); ccValue.Exists() {
+ cItem.Backdoor = types.BoolValue(true)
+ } else {
+ cItem.Backdoor = types.BoolValue(false)
+ }
+ if ccValue := cv.Get("evpn"); ccValue.Exists() {
+ cItem.Evpn = types.BoolValue(true)
+ } else {
+ cItem.Evpn = types.BoolValue(false)
+ }
+ item.Ipv4UnicastNetworksMask = append(item.Ipv4UnicastNetworksMask, cItem)
+ return true
+ })
+ }
+ if cValue := v.Get("ipv4-unicast.network.no-mask"); cValue.Exists() {
+ item.Ipv4UnicastNetworks = make([]BGPAddressFamilyIPv4VRFVrfsIpv4UnicastNetworks, 0)
+ cValue.ForEach(func(ck, cv gjson.Result) bool {
+ cItem := BGPAddressFamilyIPv4VRFVrfsIpv4UnicastNetworks{}
+ if ccValue := cv.Get("number"); ccValue.Exists() {
+ cItem.Network = types.StringValue(ccValue.String())
+ }
+ if ccValue := cv.Get("route-map"); ccValue.Exists() {
+ cItem.RouteMap = types.StringValue(ccValue.String())
+ }
+ if ccValue := cv.Get("backdoor"); ccValue.Exists() {
+ cItem.Backdoor = types.BoolValue(true)
+ } else {
+ cItem.Backdoor = types.BoolValue(false)
+ }
+ if ccValue := cv.Get("evpn"); ccValue.Exists() {
+ cItem.Evpn = types.BoolValue(true)
+ } else {
+ cItem.Evpn = types.BoolValue(false)
+ }
+ item.Ipv4UnicastNetworks = append(item.Ipv4UnicastNetworks, cItem)
+ return true
+ })
+ }
+ if cValue := v.Get("ipv4-unicast.distance.adm-distance"); cValue.Exists() {
+ item.Ipv4UnicastAdminDistances = make([]BGPAddressFamilyIPv4VRFVrfsIpv4UnicastAdminDistances, 0)
+ cValue.ForEach(func(ck, cv gjson.Result) bool {
+ cItem := BGPAddressFamilyIPv4VRFVrfsIpv4UnicastAdminDistances{}
+ if ccValue := cv.Get("distance"); ccValue.Exists() {
+ cItem.Distance = types.Int64Value(ccValue.Int())
+ }
+ if ccValue := cv.Get("srcip"); ccValue.Exists() {
+ cItem.SourceIp = types.StringValue(ccValue.String())
+ }
+ if ccValue := cv.Get("wildbits"); ccValue.Exists() {
+ cItem.Wildcard = types.StringValue(ccValue.String())
+ }
+ if ccValue := cv.Get("acl"); ccValue.Exists() {
+ cItem.Acl = types.StringValue(ccValue.String())
+ }
+ item.Ipv4UnicastAdminDistances = append(item.Ipv4UnicastAdminDistances, cItem)
+ return true
+ })
+ }
+ if cValue := v.Get("ipv4-unicast.distance.bgp.extern-as"); cValue.Exists() {
+ item.Ipv4UnicastDistanceBgpExternal = types.Int64Value(cValue.Int())
+ }
+ if cValue := v.Get("ipv4-unicast.distance.bgp.internal-as"); cValue.Exists() {
+ item.Ipv4UnicastDistanceBgpInternal = types.Int64Value(cValue.Int())
+ }
+ if cValue := v.Get("ipv4-unicast.distance.bgp.local"); cValue.Exists() {
+ item.Ipv4UnicastDistanceBgpLocal = types.Int64Value(cValue.Int())
+ }
+ data.Vrfs = append(data.Vrfs, item)
+ return true
+ })
+ }
+}
+
+// End of section. //template:end fromBodyData
+
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyXML
+
+func (data *BGPAddressFamilyIPv4VRF) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/vrf"); value.Exists() {
+ data.Vrfs = make([]BGPAddressFamilyIPv4VRFVrfs, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := BGPAddressFamilyIPv4VRFVrfs{}
+ if cValue := helpers.GetFromXPath(v, "name"); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "ipv4-unicast/advertise/l2vpn/evpn"); cValue.Exists() {
+ item.Ipv4UnicastAdvertiseL2vpnEvpn = types.BoolValue(true)
+ } else {
+ item.Ipv4UnicastAdvertiseL2vpnEvpn = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "ipv4-unicast/redistribute-vrf/connected"); cValue.Exists() {
+ item.Ipv4UnicastRedistributeConnected = types.BoolValue(true)
+ } else {
+ item.Ipv4UnicastRedistributeConnected = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "ipv4-unicast/bgp/router-id/interface/Loopback"); cValue.Exists() {
+ item.Ipv4UnicastRouterIdLoopback = types.Int64Value(cValue.Int())
+ }
+ if cValue := helpers.GetFromXPath(v, "ipv4-unicast/bgp/router-id/ip-id"); cValue.Exists() {
+ item.Ipv4UnicastRouterIdIp = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "ipv4-unicast/aggregate-address"); cValue.Exists() {
+ item.Ipv4UnicastAggregateAddresses = make([]BGPAddressFamilyIPv4VRFVrfsIpv4UnicastAggregateAddresses, 0)
+ cValue.ForEach(func(_ int, cv xmldot.Result) bool {
+ cItem := BGPAddressFamilyIPv4VRFVrfsIpv4UnicastAggregateAddresses{}
+ if ccValue := helpers.GetFromXPath(cv, "ipv4-address"); ccValue.Exists() {
+ cItem.Ipv4Address = types.StringValue(ccValue.String())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "ipv4-mask"); ccValue.Exists() {
+ cItem.Ipv4Mask = types.StringValue(ccValue.String())
+ }
+ item.Ipv4UnicastAggregateAddresses = append(item.Ipv4UnicastAggregateAddresses, cItem)
+ return true
+ })
+ }
+ if cValue := helpers.GetFromXPath(v, "ipv4-unicast/redistribute-vrf/static"); cValue.Exists() {
+ item.Ipv4UnicastRedistributeStatic = types.BoolValue(true)
+ } else {
+ item.Ipv4UnicastRedistributeStatic = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "ipv4-unicast/network/with-mask"); cValue.Exists() {
+ item.Ipv4UnicastNetworksMask = make([]BGPAddressFamilyIPv4VRFVrfsIpv4UnicastNetworksMask, 0)
+ cValue.ForEach(func(_ int, cv xmldot.Result) bool {
+ cItem := BGPAddressFamilyIPv4VRFVrfsIpv4UnicastNetworksMask{}
+ if ccValue := helpers.GetFromXPath(cv, "number"); ccValue.Exists() {
+ cItem.Network = types.StringValue(ccValue.String())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "mask"); ccValue.Exists() {
+ cItem.Mask = types.StringValue(ccValue.String())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "route-map"); ccValue.Exists() {
+ cItem.RouteMap = types.StringValue(ccValue.String())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "backdoor"); ccValue.Exists() {
+ cItem.Backdoor = types.BoolValue(true)
+ } else {
+ cItem.Backdoor = types.BoolValue(false)
+ }
+ if ccValue := helpers.GetFromXPath(cv, "evpn"); ccValue.Exists() {
+ cItem.Evpn = types.BoolValue(true)
+ } else {
+ cItem.Evpn = types.BoolValue(false)
+ }
+ item.Ipv4UnicastNetworksMask = append(item.Ipv4UnicastNetworksMask, cItem)
+ return true
+ })
+ }
+ if cValue := helpers.GetFromXPath(v, "ipv4-unicast/network/no-mask"); cValue.Exists() {
+ item.Ipv4UnicastNetworks = make([]BGPAddressFamilyIPv4VRFVrfsIpv4UnicastNetworks, 0)
+ cValue.ForEach(func(_ int, cv xmldot.Result) bool {
+ cItem := BGPAddressFamilyIPv4VRFVrfsIpv4UnicastNetworks{}
+ if ccValue := helpers.GetFromXPath(cv, "number"); ccValue.Exists() {
+ cItem.Network = types.StringValue(ccValue.String())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "route-map"); ccValue.Exists() {
+ cItem.RouteMap = types.StringValue(ccValue.String())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "backdoor"); ccValue.Exists() {
cItem.Backdoor = types.BoolValue(true)
} else {
cItem.Backdoor = types.BoolValue(false)
}
- if ccValue := cv.Get("evpn"); ccValue.Exists() {
+ if ccValue := helpers.GetFromXPath(cv, "evpn"); ccValue.Exists() {
cItem.Evpn = types.BoolValue(true)
} else {
cItem.Evpn = types.BoolValue(false)
@@ -625,33 +1337,33 @@ func (data *BGPAddressFamilyIPv4VRF) fromBody(ctx context.Context, res gjson.Res
return true
})
}
- if cValue := v.Get("ipv4-unicast.distance.adm-distance"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ipv4-unicast/distance/adm-distance"); cValue.Exists() {
item.Ipv4UnicastAdminDistances = make([]BGPAddressFamilyIPv4VRFVrfsIpv4UnicastAdminDistances, 0)
- cValue.ForEach(func(ck, cv gjson.Result) bool {
+ cValue.ForEach(func(_ int, cv xmldot.Result) bool {
cItem := BGPAddressFamilyIPv4VRFVrfsIpv4UnicastAdminDistances{}
- if ccValue := cv.Get("distance"); ccValue.Exists() {
+ if ccValue := helpers.GetFromXPath(cv, "distance"); ccValue.Exists() {
cItem.Distance = types.Int64Value(ccValue.Int())
}
- if ccValue := cv.Get("srcip"); ccValue.Exists() {
+ if ccValue := helpers.GetFromXPath(cv, "srcip"); ccValue.Exists() {
cItem.SourceIp = types.StringValue(ccValue.String())
}
- if ccValue := cv.Get("wildbits"); ccValue.Exists() {
+ if ccValue := helpers.GetFromXPath(cv, "wildbits"); ccValue.Exists() {
cItem.Wildcard = types.StringValue(ccValue.String())
}
- if ccValue := cv.Get("acl"); ccValue.Exists() {
+ if ccValue := helpers.GetFromXPath(cv, "acl"); ccValue.Exists() {
cItem.Acl = types.StringValue(ccValue.String())
}
item.Ipv4UnicastAdminDistances = append(item.Ipv4UnicastAdminDistances, cItem)
return true
})
}
- if cValue := v.Get("ipv4-unicast.distance.bgp.extern-as"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ipv4-unicast/distance/bgp/extern-as"); cValue.Exists() {
item.Ipv4UnicastDistanceBgpExternal = types.Int64Value(cValue.Int())
}
- if cValue := v.Get("ipv4-unicast.distance.bgp.internal-as"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ipv4-unicast/distance/bgp/internal-as"); cValue.Exists() {
item.Ipv4UnicastDistanceBgpInternal = types.Int64Value(cValue.Int())
}
- if cValue := v.Get("ipv4-unicast.distance.bgp.local"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ipv4-unicast/distance/bgp/local"); cValue.Exists() {
item.Ipv4UnicastDistanceBgpLocal = types.Int64Value(cValue.Int())
}
data.Vrfs = append(data.Vrfs, item)
@@ -660,76 +1372,72 @@ func (data *BGPAddressFamilyIPv4VRF) fromBody(ctx context.Context, res gjson.Res
}
}
-// End of section. //template:end fromBody
+// End of section. //template:end fromBodyXML
-// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyData
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyDataXML
-func (data *BGPAddressFamilyIPv4VRFData) fromBody(ctx context.Context, res gjson.Result) {
- prefix := helpers.LastElement(data.getPath()) + "."
- if res.Get(helpers.LastElement(data.getPath())).IsArray() {
- prefix += "0."
- }
- if value := res.Get(prefix + "vrf"); value.Exists() {
+func (data *BGPAddressFamilyIPv4VRFData) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/vrf"); value.Exists() {
data.Vrfs = make([]BGPAddressFamilyIPv4VRFVrfs, 0)
- value.ForEach(func(k, v gjson.Result) bool {
+ value.ForEach(func(_ int, v xmldot.Result) bool {
item := BGPAddressFamilyIPv4VRFVrfs{}
- if cValue := v.Get("name"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "name"); cValue.Exists() {
item.Name = types.StringValue(cValue.String())
}
- if cValue := v.Get("ipv4-unicast.advertise.l2vpn.evpn"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ipv4-unicast/advertise/l2vpn/evpn"); cValue.Exists() {
item.Ipv4UnicastAdvertiseL2vpnEvpn = types.BoolValue(true)
} else {
item.Ipv4UnicastAdvertiseL2vpnEvpn = types.BoolValue(false)
}
- if cValue := v.Get("ipv4-unicast.redistribute-vrf.connected"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ipv4-unicast/redistribute-vrf/connected"); cValue.Exists() {
item.Ipv4UnicastRedistributeConnected = types.BoolValue(true)
} else {
item.Ipv4UnicastRedistributeConnected = types.BoolValue(false)
}
- if cValue := v.Get("ipv4-unicast.bgp.router-id.interface.Loopback"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ipv4-unicast/bgp/router-id/interface/Loopback"); cValue.Exists() {
item.Ipv4UnicastRouterIdLoopback = types.Int64Value(cValue.Int())
}
- if cValue := v.Get("ipv4-unicast.bgp.router-id.ip-id"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ipv4-unicast/bgp/router-id/ip-id"); cValue.Exists() {
item.Ipv4UnicastRouterIdIp = types.StringValue(cValue.String())
}
- if cValue := v.Get("ipv4-unicast.aggregate-address"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ipv4-unicast/aggregate-address"); cValue.Exists() {
item.Ipv4UnicastAggregateAddresses = make([]BGPAddressFamilyIPv4VRFVrfsIpv4UnicastAggregateAddresses, 0)
- cValue.ForEach(func(ck, cv gjson.Result) bool {
+ cValue.ForEach(func(_ int, cv xmldot.Result) bool {
cItem := BGPAddressFamilyIPv4VRFVrfsIpv4UnicastAggregateAddresses{}
- if ccValue := cv.Get("ipv4-address"); ccValue.Exists() {
+ if ccValue := helpers.GetFromXPath(cv, "ipv4-address"); ccValue.Exists() {
cItem.Ipv4Address = types.StringValue(ccValue.String())
}
- if ccValue := cv.Get("ipv4-mask"); ccValue.Exists() {
+ if ccValue := helpers.GetFromXPath(cv, "ipv4-mask"); ccValue.Exists() {
cItem.Ipv4Mask = types.StringValue(ccValue.String())
}
item.Ipv4UnicastAggregateAddresses = append(item.Ipv4UnicastAggregateAddresses, cItem)
return true
})
}
- if cValue := v.Get("ipv4-unicast.redistribute-vrf.static"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ipv4-unicast/redistribute-vrf/static"); cValue.Exists() {
item.Ipv4UnicastRedistributeStatic = types.BoolValue(true)
} else {
item.Ipv4UnicastRedistributeStatic = types.BoolValue(false)
}
- if cValue := v.Get("ipv4-unicast.network.with-mask"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ipv4-unicast/network/with-mask"); cValue.Exists() {
item.Ipv4UnicastNetworksMask = make([]BGPAddressFamilyIPv4VRFVrfsIpv4UnicastNetworksMask, 0)
- cValue.ForEach(func(ck, cv gjson.Result) bool {
+ cValue.ForEach(func(_ int, cv xmldot.Result) bool {
cItem := BGPAddressFamilyIPv4VRFVrfsIpv4UnicastNetworksMask{}
- if ccValue := cv.Get("number"); ccValue.Exists() {
+ if ccValue := helpers.GetFromXPath(cv, "number"); ccValue.Exists() {
cItem.Network = types.StringValue(ccValue.String())
}
- if ccValue := cv.Get("mask"); ccValue.Exists() {
+ if ccValue := helpers.GetFromXPath(cv, "mask"); ccValue.Exists() {
cItem.Mask = types.StringValue(ccValue.String())
}
- if ccValue := cv.Get("route-map"); ccValue.Exists() {
+ if ccValue := helpers.GetFromXPath(cv, "route-map"); ccValue.Exists() {
cItem.RouteMap = types.StringValue(ccValue.String())
}
- if ccValue := cv.Get("backdoor"); ccValue.Exists() {
+ if ccValue := helpers.GetFromXPath(cv, "backdoor"); ccValue.Exists() {
cItem.Backdoor = types.BoolValue(true)
} else {
cItem.Backdoor = types.BoolValue(false)
}
- if ccValue := cv.Get("evpn"); ccValue.Exists() {
+ if ccValue := helpers.GetFromXPath(cv, "evpn"); ccValue.Exists() {
cItem.Evpn = types.BoolValue(true)
} else {
cItem.Evpn = types.BoolValue(false)
@@ -738,22 +1446,22 @@ func (data *BGPAddressFamilyIPv4VRFData) fromBody(ctx context.Context, res gjson
return true
})
}
- if cValue := v.Get("ipv4-unicast.network.no-mask"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ipv4-unicast/network/no-mask"); cValue.Exists() {
item.Ipv4UnicastNetworks = make([]BGPAddressFamilyIPv4VRFVrfsIpv4UnicastNetworks, 0)
- cValue.ForEach(func(ck, cv gjson.Result) bool {
+ cValue.ForEach(func(_ int, cv xmldot.Result) bool {
cItem := BGPAddressFamilyIPv4VRFVrfsIpv4UnicastNetworks{}
- if ccValue := cv.Get("number"); ccValue.Exists() {
+ if ccValue := helpers.GetFromXPath(cv, "number"); ccValue.Exists() {
cItem.Network = types.StringValue(ccValue.String())
}
- if ccValue := cv.Get("route-map"); ccValue.Exists() {
+ if ccValue := helpers.GetFromXPath(cv, "route-map"); ccValue.Exists() {
cItem.RouteMap = types.StringValue(ccValue.String())
}
- if ccValue := cv.Get("backdoor"); ccValue.Exists() {
+ if ccValue := helpers.GetFromXPath(cv, "backdoor"); ccValue.Exists() {
cItem.Backdoor = types.BoolValue(true)
} else {
cItem.Backdoor = types.BoolValue(false)
}
- if ccValue := cv.Get("evpn"); ccValue.Exists() {
+ if ccValue := helpers.GetFromXPath(cv, "evpn"); ccValue.Exists() {
cItem.Evpn = types.BoolValue(true)
} else {
cItem.Evpn = types.BoolValue(false)
@@ -762,33 +1470,33 @@ func (data *BGPAddressFamilyIPv4VRFData) fromBody(ctx context.Context, res gjson
return true
})
}
- if cValue := v.Get("ipv4-unicast.distance.adm-distance"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ipv4-unicast/distance/adm-distance"); cValue.Exists() {
item.Ipv4UnicastAdminDistances = make([]BGPAddressFamilyIPv4VRFVrfsIpv4UnicastAdminDistances, 0)
- cValue.ForEach(func(ck, cv gjson.Result) bool {
+ cValue.ForEach(func(_ int, cv xmldot.Result) bool {
cItem := BGPAddressFamilyIPv4VRFVrfsIpv4UnicastAdminDistances{}
- if ccValue := cv.Get("distance"); ccValue.Exists() {
+ if ccValue := helpers.GetFromXPath(cv, "distance"); ccValue.Exists() {
cItem.Distance = types.Int64Value(ccValue.Int())
}
- if ccValue := cv.Get("srcip"); ccValue.Exists() {
+ if ccValue := helpers.GetFromXPath(cv, "srcip"); ccValue.Exists() {
cItem.SourceIp = types.StringValue(ccValue.String())
}
- if ccValue := cv.Get("wildbits"); ccValue.Exists() {
+ if ccValue := helpers.GetFromXPath(cv, "wildbits"); ccValue.Exists() {
cItem.Wildcard = types.StringValue(ccValue.String())
}
- if ccValue := cv.Get("acl"); ccValue.Exists() {
+ if ccValue := helpers.GetFromXPath(cv, "acl"); ccValue.Exists() {
cItem.Acl = types.StringValue(ccValue.String())
}
item.Ipv4UnicastAdminDistances = append(item.Ipv4UnicastAdminDistances, cItem)
return true
})
}
- if cValue := v.Get("ipv4-unicast.distance.bgp.extern-as"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ipv4-unicast/distance/bgp/extern-as"); cValue.Exists() {
item.Ipv4UnicastDistanceBgpExternal = types.Int64Value(cValue.Int())
}
- if cValue := v.Get("ipv4-unicast.distance.bgp.internal-as"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ipv4-unicast/distance/bgp/internal-as"); cValue.Exists() {
item.Ipv4UnicastDistanceBgpInternal = types.Int64Value(cValue.Int())
}
- if cValue := v.Get("ipv4-unicast.distance.bgp.local"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ipv4-unicast/distance/bgp/local"); cValue.Exists() {
item.Ipv4UnicastDistanceBgpLocal = types.Int64Value(cValue.Int())
}
data.Vrfs = append(data.Vrfs, item)
@@ -797,7 +1505,7 @@ func (data *BGPAddressFamilyIPv4VRFData) fromBody(ctx context.Context, res gjson
}
}
-// End of section. //template:end fromBodyData
+// End of section. //template:end fromBodyDataXML
// Section below is generated&owned by "gen/generator.go". //template:begin getDeletedItems
@@ -1003,6 +1711,235 @@ func (data *BGPAddressFamilyIPv4VRF) getDeletedItems(ctx context.Context, state
// End of section. //template:end getDeletedItems
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletedItemsXML
+
+func (data *BGPAddressFamilyIPv4VRF) addDeletedItemsXML(ctx context.Context, state BGPAddressFamilyIPv4VRF, body string) string {
+ b := netconf.NewBody(body)
+ for i := range state.Vrfs {
+ stateKeys := [...]string{"name"}
+ stateKeyValues := [...]string{state.Vrfs[i].Name.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.Vrfs[i].Name.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.Vrfs {
+ found = true
+ if state.Vrfs[i].Name.ValueString() != data.Vrfs[j].Name.ValueString() {
+ found = false
+ }
+ if found {
+ if !state.Vrfs[i].Ipv4UnicastAdvertiseL2vpnEvpn.IsNull() && data.Vrfs[j].Ipv4UnicastAdvertiseL2vpnEvpn.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/vrf%v/ipv4-unicast/advertise/l2vpn/evpn", predicates))
+ }
+ if !state.Vrfs[i].Ipv4UnicastRedistributeConnected.IsNull() && data.Vrfs[j].Ipv4UnicastRedistributeConnected.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/vrf%v/ipv4-unicast/redistribute-vrf/connected", predicates))
+ }
+ if !state.Vrfs[i].Ipv4UnicastRouterIdLoopback.IsNull() && data.Vrfs[j].Ipv4UnicastRouterIdLoopback.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/vrf%v/ipv4-unicast/bgp/router-id/interface/Loopback", predicates))
+ }
+ if !state.Vrfs[i].Ipv4UnicastRouterIdIp.IsNull() && data.Vrfs[j].Ipv4UnicastRouterIdIp.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/vrf%v/ipv4-unicast/bgp/router-id/ip-id", predicates))
+ }
+ for ci := range state.Vrfs[i].Ipv4UnicastAggregateAddresses {
+ cstateKeys := [...]string{"ipv4-address", "ipv4-mask"}
+ cstateKeyValues := [...]string{state.Vrfs[i].Ipv4UnicastAggregateAddresses[ci].Ipv4Address.ValueString(), state.Vrfs[i].Ipv4UnicastAggregateAddresses[ci].Ipv4Mask.ValueString()}
+ cpredicates := ""
+ for i := range cstateKeys {
+ cpredicates += fmt.Sprintf("[%s='%s']", cstateKeys[i], cstateKeyValues[i])
+ }
+
+ cemptyKeys := true
+ if !reflect.ValueOf(state.Vrfs[i].Ipv4UnicastAggregateAddresses[ci].Ipv4Address.ValueString()).IsZero() {
+ cemptyKeys = false
+ }
+ if !reflect.ValueOf(state.Vrfs[i].Ipv4UnicastAggregateAddresses[ci].Ipv4Mask.ValueString()).IsZero() {
+ cemptyKeys = false
+ }
+ if cemptyKeys {
+ continue
+ }
+
+ found := false
+ for cj := range data.Vrfs[j].Ipv4UnicastAggregateAddresses {
+ found = true
+ if state.Vrfs[i].Ipv4UnicastAggregateAddresses[ci].Ipv4Address.ValueString() != data.Vrfs[j].Ipv4UnicastAggregateAddresses[cj].Ipv4Address.ValueString() {
+ found = false
+ }
+ if state.Vrfs[i].Ipv4UnicastAggregateAddresses[ci].Ipv4Mask.ValueString() != data.Vrfs[j].Ipv4UnicastAggregateAddresses[cj].Ipv4Mask.ValueString() {
+ found = false
+ }
+ if found {
+ break
+ }
+ }
+ if !found {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/vrf%v/ipv4-unicast/aggregate-address%v", predicates, cpredicates))
+ }
+ }
+ if !state.Vrfs[i].Ipv4UnicastRedistributeStatic.IsNull() && data.Vrfs[j].Ipv4UnicastRedistributeStatic.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/vrf%v/ipv4-unicast/redistribute-vrf/static", predicates))
+ }
+ for ci := range state.Vrfs[i].Ipv4UnicastNetworksMask {
+ cstateKeys := [...]string{"number", "mask"}
+ cstateKeyValues := [...]string{state.Vrfs[i].Ipv4UnicastNetworksMask[ci].Network.ValueString(), state.Vrfs[i].Ipv4UnicastNetworksMask[ci].Mask.ValueString()}
+ cpredicates := ""
+ for i := range cstateKeys {
+ cpredicates += fmt.Sprintf("[%s='%s']", cstateKeys[i], cstateKeyValues[i])
+ }
+
+ cemptyKeys := true
+ if !reflect.ValueOf(state.Vrfs[i].Ipv4UnicastNetworksMask[ci].Network.ValueString()).IsZero() {
+ cemptyKeys = false
+ }
+ if !reflect.ValueOf(state.Vrfs[i].Ipv4UnicastNetworksMask[ci].Mask.ValueString()).IsZero() {
+ cemptyKeys = false
+ }
+ if cemptyKeys {
+ continue
+ }
+
+ found := false
+ for cj := range data.Vrfs[j].Ipv4UnicastNetworksMask {
+ found = true
+ if state.Vrfs[i].Ipv4UnicastNetworksMask[ci].Network.ValueString() != data.Vrfs[j].Ipv4UnicastNetworksMask[cj].Network.ValueString() {
+ found = false
+ }
+ if state.Vrfs[i].Ipv4UnicastNetworksMask[ci].Mask.ValueString() != data.Vrfs[j].Ipv4UnicastNetworksMask[cj].Mask.ValueString() {
+ found = false
+ }
+ if found {
+ if !state.Vrfs[i].Ipv4UnicastNetworksMask[ci].RouteMap.IsNull() && data.Vrfs[j].Ipv4UnicastNetworksMask[cj].RouteMap.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/vrf%v/ipv4-unicast/network/with-mask%v/route-map", predicates, cpredicates))
+ }
+ if !state.Vrfs[i].Ipv4UnicastNetworksMask[ci].Backdoor.IsNull() && data.Vrfs[j].Ipv4UnicastNetworksMask[cj].Backdoor.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/vrf%v/ipv4-unicast/network/with-mask%v/backdoor", predicates, cpredicates))
+ }
+ if !state.Vrfs[i].Ipv4UnicastNetworksMask[ci].Evpn.IsNull() && data.Vrfs[j].Ipv4UnicastNetworksMask[cj].Evpn.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/vrf%v/ipv4-unicast/network/with-mask%v/evpn", predicates, cpredicates))
+ }
+ break
+ }
+ }
+ if !found {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/vrf%v/ipv4-unicast/network/with-mask%v", predicates, cpredicates))
+ }
+ }
+ for ci := range state.Vrfs[i].Ipv4UnicastNetworks {
+ cstateKeys := [...]string{"number"}
+ cstateKeyValues := [...]string{state.Vrfs[i].Ipv4UnicastNetworks[ci].Network.ValueString()}
+ cpredicates := ""
+ for i := range cstateKeys {
+ cpredicates += fmt.Sprintf("[%s='%s']", cstateKeys[i], cstateKeyValues[i])
+ }
+
+ cemptyKeys := true
+ if !reflect.ValueOf(state.Vrfs[i].Ipv4UnicastNetworks[ci].Network.ValueString()).IsZero() {
+ cemptyKeys = false
+ }
+ if cemptyKeys {
+ continue
+ }
+
+ found := false
+ for cj := range data.Vrfs[j].Ipv4UnicastNetworks {
+ found = true
+ if state.Vrfs[i].Ipv4UnicastNetworks[ci].Network.ValueString() != data.Vrfs[j].Ipv4UnicastNetworks[cj].Network.ValueString() {
+ found = false
+ }
+ if found {
+ if !state.Vrfs[i].Ipv4UnicastNetworks[ci].RouteMap.IsNull() && data.Vrfs[j].Ipv4UnicastNetworks[cj].RouteMap.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/vrf%v/ipv4-unicast/network/no-mask%v/route-map", predicates, cpredicates))
+ }
+ if !state.Vrfs[i].Ipv4UnicastNetworks[ci].Backdoor.IsNull() && data.Vrfs[j].Ipv4UnicastNetworks[cj].Backdoor.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/vrf%v/ipv4-unicast/network/no-mask%v/backdoor", predicates, cpredicates))
+ }
+ if !state.Vrfs[i].Ipv4UnicastNetworks[ci].Evpn.IsNull() && data.Vrfs[j].Ipv4UnicastNetworks[cj].Evpn.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/vrf%v/ipv4-unicast/network/no-mask%v/evpn", predicates, cpredicates))
+ }
+ break
+ }
+ }
+ if !found {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/vrf%v/ipv4-unicast/network/no-mask%v", predicates, cpredicates))
+ }
+ }
+ for ci := range state.Vrfs[i].Ipv4UnicastAdminDistances {
+ cstateKeys := [...]string{"distance", "srcip", "wildbits"}
+ cstateKeyValues := [...]string{strconv.FormatInt(state.Vrfs[i].Ipv4UnicastAdminDistances[ci].Distance.ValueInt64(), 10), state.Vrfs[i].Ipv4UnicastAdminDistances[ci].SourceIp.ValueString(), state.Vrfs[i].Ipv4UnicastAdminDistances[ci].Wildcard.ValueString()}
+ cpredicates := ""
+ for i := range cstateKeys {
+ cpredicates += fmt.Sprintf("[%s='%s']", cstateKeys[i], cstateKeyValues[i])
+ }
+
+ cemptyKeys := true
+ if !reflect.ValueOf(state.Vrfs[i].Ipv4UnicastAdminDistances[ci].Distance.ValueInt64()).IsZero() {
+ cemptyKeys = false
+ }
+ if !reflect.ValueOf(state.Vrfs[i].Ipv4UnicastAdminDistances[ci].SourceIp.ValueString()).IsZero() {
+ cemptyKeys = false
+ }
+ if !reflect.ValueOf(state.Vrfs[i].Ipv4UnicastAdminDistances[ci].Wildcard.ValueString()).IsZero() {
+ cemptyKeys = false
+ }
+ if cemptyKeys {
+ continue
+ }
+
+ found := false
+ for cj := range data.Vrfs[j].Ipv4UnicastAdminDistances {
+ found = true
+ if state.Vrfs[i].Ipv4UnicastAdminDistances[ci].Distance.ValueInt64() != data.Vrfs[j].Ipv4UnicastAdminDistances[cj].Distance.ValueInt64() {
+ found = false
+ }
+ if state.Vrfs[i].Ipv4UnicastAdminDistances[ci].SourceIp.ValueString() != data.Vrfs[j].Ipv4UnicastAdminDistances[cj].SourceIp.ValueString() {
+ found = false
+ }
+ if state.Vrfs[i].Ipv4UnicastAdminDistances[ci].Wildcard.ValueString() != data.Vrfs[j].Ipv4UnicastAdminDistances[cj].Wildcard.ValueString() {
+ found = false
+ }
+ if found {
+ if !state.Vrfs[i].Ipv4UnicastAdminDistances[ci].Acl.IsNull() && data.Vrfs[j].Ipv4UnicastAdminDistances[cj].Acl.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/vrf%v/ipv4-unicast/distance/adm-distance%v/acl", predicates, cpredicates))
+ }
+ break
+ }
+ }
+ if !found {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/vrf%v/ipv4-unicast/distance/adm-distance%v", predicates, cpredicates))
+ }
+ }
+ if !state.Vrfs[i].Ipv4UnicastDistanceBgpExternal.IsNull() && data.Vrfs[j].Ipv4UnicastDistanceBgpExternal.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/vrf%v/ipv4-unicast/distance/bgp/extern-as", predicates))
+ }
+ if !state.Vrfs[i].Ipv4UnicastDistanceBgpInternal.IsNull() && data.Vrfs[j].Ipv4UnicastDistanceBgpInternal.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/vrf%v/ipv4-unicast/distance/bgp/internal-as", predicates))
+ }
+ if !state.Vrfs[i].Ipv4UnicastDistanceBgpLocal.IsNull() && data.Vrfs[j].Ipv4UnicastDistanceBgpLocal.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/vrf%v/ipv4-unicast/distance/bgp/local", predicates))
+ }
+ break
+ }
+ }
+ if !found {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/vrf%v", predicates))
+ }
+ }
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletedItemsXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin getEmptyLeafsDelete
func (data *BGPAddressFamilyIPv4VRF) getEmptyLeafsDelete(ctx context.Context) []string {
@@ -1061,3 +1998,23 @@ func (data *BGPAddressFamilyIPv4VRF) getDeletePaths(ctx context.Context) []strin
}
// End of section. //template:end getDeletePaths
+
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletePathsXML
+
+func (data *BGPAddressFamilyIPv4VRF) addDeletePathsXML(ctx context.Context, body string) string {
+ b := netconf.NewBody(body)
+ for i := range data.Vrfs {
+ keys := [...]string{"name"}
+ keyValues := [...]string{data.Vrfs[i].Name.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/vrf%v", predicates))
+ }
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletePathsXML
diff --git a/internal/provider/model_iosxe_bgp_address_family_ipv6.go b/internal/provider/model_iosxe_bgp_address_family_ipv6.go
index 7e5a2db9..3c25c10e 100644
--- a/internal/provider/model_iosxe_bgp_address_family_ipv6.go
+++ b/internal/provider/model_iosxe_bgp_address_family_ipv6.go
@@ -31,6 +31,9 @@ import (
"github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/types"
+ "github.com/hashicorp/terraform-plugin-log/tflog"
+ "github.com/netascode/go-netconf"
+ "github.com/netascode/xmldot"
"github.com/tidwall/gjson"
"github.com/tidwall/sjson"
)
@@ -87,6 +90,19 @@ func (data BGPAddressFamilyIPv6) getPathShort() string {
return matches[1]
}
+// getXPath returns the XPath for NETCONF operations
+func (data BGPAddressFamilyIPv6) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/router/Cisco-IOS-XE-bgp:bgp[id=%v]/address-family/no-vrf/ipv6[af-name=%s]"
+ path = fmt.Sprintf(path, fmt.Sprintf("%v", data.Asn.ValueString()), fmt.Sprintf("%v", data.AfName.ValueString()))
+ return path
+}
+
+func (data BGPAddressFamilyIPv6Data) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/router/Cisco-IOS-XE-bgp:bgp[id=%v]/address-family/no-vrf/ipv6[af-name=%s]"
+ path = fmt.Sprintf(path, fmt.Sprintf("%v", data.Asn.ValueString()), fmt.Sprintf("%v", data.AfName.ValueString()))
+ return path
+}
+
// End of section. //template:end getPath
// Section below is generated&owned by "gen/generator.go". //template:begin toBody
@@ -127,6 +143,55 @@ func (data BGPAddressFamilyIPv6) toBody(ctx context.Context) string {
// End of section. //template:end toBody
+// Section below is generated&owned by "gen/generator.go". //template:begin toBodyXML
+
+func (data BGPAddressFamilyIPv6) toBodyXML(ctx context.Context) string {
+ body := netconf.Body{}
+ if !data.AfName.IsNull() && !data.AfName.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/af-name", data.AfName.ValueString())
+ }
+ if !data.Ipv6UnicastRedistributeConnected.IsNull() && !data.Ipv6UnicastRedistributeConnected.IsUnknown() {
+ if data.Ipv6UnicastRedistributeConnected.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ipv6-unicast/redistribute-v6/connected", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/ipv6-unicast/redistribute-v6/connected")
+ }
+ }
+ if !data.Ipv6UnicastRedistributeStatic.IsNull() && !data.Ipv6UnicastRedistributeStatic.IsUnknown() {
+ if data.Ipv6UnicastRedistributeStatic.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ipv6-unicast/redistribute-v6/static", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/ipv6-unicast/redistribute-v6/static")
+ }
+ }
+ if len(data.Ipv6UnicastNetworks) > 0 {
+ for _, item := range data.Ipv6UnicastNetworks {
+ cBody := netconf.Body{}
+ if !item.Network.IsNull() && !item.Network.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "number", item.Network.ValueString())
+ }
+ if !item.RouteMap.IsNull() && !item.RouteMap.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "route-map", item.RouteMap.ValueString())
+ }
+ if !item.Backdoor.IsNull() && !item.Backdoor.IsUnknown() {
+ if item.Backdoor.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "backdoor", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "backdoor")
+ }
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/ipv6-unicast/network", cBody.Res())
+ }
+ }
+ bodyString, err := body.String()
+ if err != nil {
+ tflog.Error(ctx, fmt.Sprintf("Error converting body to string: %s", err))
+ }
+ return bodyString
+}
+
+// End of section. //template:end toBodyXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBody
func (data *BGPAddressFamilyIPv6) updateFromBody(ctx context.Context, res gjson.Result) {
@@ -204,6 +269,79 @@ func (data *BGPAddressFamilyIPv6) updateFromBody(ctx context.Context, res gjson.
// End of section. //template:end updateFromBody
+// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBodyXML
+
+func (data *BGPAddressFamilyIPv6) updateFromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/af-name"); value.Exists() && !data.AfName.IsNull() {
+ data.AfName = types.StringValue(value.String())
+ } else {
+ data.AfName = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ipv6-unicast/redistribute-v6/connected"); !data.Ipv6UnicastRedistributeConnected.IsNull() {
+ if value.Exists() {
+ data.Ipv6UnicastRedistributeConnected = types.BoolValue(true)
+ } else {
+ data.Ipv6UnicastRedistributeConnected = types.BoolValue(false)
+ }
+ } else {
+ data.Ipv6UnicastRedistributeConnected = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ipv6-unicast/redistribute-v6/static"); !data.Ipv6UnicastRedistributeStatic.IsNull() {
+ if value.Exists() {
+ data.Ipv6UnicastRedistributeStatic = types.BoolValue(true)
+ } else {
+ data.Ipv6UnicastRedistributeStatic = types.BoolValue(false)
+ }
+ } else {
+ data.Ipv6UnicastRedistributeStatic = types.BoolNull()
+ }
+ for i := range data.Ipv6UnicastNetworks {
+ keys := [...]string{"number"}
+ keyValues := [...]string{data.Ipv6UnicastNetworks[i].Network.ValueString()}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ipv6-unicast/network").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, "number"); value.Exists() && !data.Ipv6UnicastNetworks[i].Network.IsNull() {
+ data.Ipv6UnicastNetworks[i].Network = types.StringValue(value.String())
+ } else {
+ data.Ipv6UnicastNetworks[i].Network = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "route-map"); value.Exists() && !data.Ipv6UnicastNetworks[i].RouteMap.IsNull() {
+ data.Ipv6UnicastNetworks[i].RouteMap = types.StringValue(value.String())
+ } else {
+ data.Ipv6UnicastNetworks[i].RouteMap = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "backdoor"); !data.Ipv6UnicastNetworks[i].Backdoor.IsNull() {
+ if value.Exists() {
+ data.Ipv6UnicastNetworks[i].Backdoor = types.BoolValue(true)
+ } else {
+ data.Ipv6UnicastNetworks[i].Backdoor = types.BoolValue(false)
+ }
+ } else {
+ data.Ipv6UnicastNetworks[i].Backdoor = types.BoolNull()
+ }
+ }
+}
+
+// End of section. //template:end updateFromBodyXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin fromBody
func (data *BGPAddressFamilyIPv6) fromBody(ctx context.Context, res gjson.Result) {
@@ -284,6 +422,78 @@ func (data *BGPAddressFamilyIPv6Data) fromBody(ctx context.Context, res gjson.Re
// End of section. //template:end fromBodyData
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyXML
+
+func (data *BGPAddressFamilyIPv6) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ipv6-unicast/redistribute-v6/connected"); value.Exists() {
+ data.Ipv6UnicastRedistributeConnected = types.BoolValue(true)
+ } else {
+ data.Ipv6UnicastRedistributeConnected = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ipv6-unicast/redistribute-v6/static"); value.Exists() {
+ data.Ipv6UnicastRedistributeStatic = types.BoolValue(true)
+ } else {
+ data.Ipv6UnicastRedistributeStatic = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ipv6-unicast/network"); value.Exists() {
+ data.Ipv6UnicastNetworks = make([]BGPAddressFamilyIPv6Ipv6UnicastNetworks, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := BGPAddressFamilyIPv6Ipv6UnicastNetworks{}
+ if cValue := helpers.GetFromXPath(v, "number"); cValue.Exists() {
+ item.Network = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "route-map"); cValue.Exists() {
+ item.RouteMap = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "backdoor"); cValue.Exists() {
+ item.Backdoor = types.BoolValue(true)
+ } else {
+ item.Backdoor = types.BoolValue(false)
+ }
+ data.Ipv6UnicastNetworks = append(data.Ipv6UnicastNetworks, item)
+ return true
+ })
+ }
+}
+
+// End of section. //template:end fromBodyXML
+
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyDataXML
+
+func (data *BGPAddressFamilyIPv6Data) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ipv6-unicast/redistribute-v6/connected"); value.Exists() {
+ data.Ipv6UnicastRedistributeConnected = types.BoolValue(true)
+ } else {
+ data.Ipv6UnicastRedistributeConnected = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ipv6-unicast/redistribute-v6/static"); value.Exists() {
+ data.Ipv6UnicastRedistributeStatic = types.BoolValue(true)
+ } else {
+ data.Ipv6UnicastRedistributeStatic = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ipv6-unicast/network"); value.Exists() {
+ data.Ipv6UnicastNetworks = make([]BGPAddressFamilyIPv6Ipv6UnicastNetworks, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := BGPAddressFamilyIPv6Ipv6UnicastNetworks{}
+ if cValue := helpers.GetFromXPath(v, "number"); cValue.Exists() {
+ item.Network = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "route-map"); cValue.Exists() {
+ item.RouteMap = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "backdoor"); cValue.Exists() {
+ item.Backdoor = types.BoolValue(true)
+ } else {
+ item.Backdoor = types.BoolValue(false)
+ }
+ data.Ipv6UnicastNetworks = append(data.Ipv6UnicastNetworks, item)
+ return true
+ })
+ }
+}
+
+// End of section. //template:end fromBodyDataXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin getDeletedItems
func (data *BGPAddressFamilyIPv6) getDeletedItems(ctx context.Context, state BGPAddressFamilyIPv6) []string {
@@ -331,6 +541,58 @@ func (data *BGPAddressFamilyIPv6) getDeletedItems(ctx context.Context, state BGP
// End of section. //template:end getDeletedItems
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletedItemsXML
+
+func (data *BGPAddressFamilyIPv6) addDeletedItemsXML(ctx context.Context, state BGPAddressFamilyIPv6, body string) string {
+ b := netconf.NewBody(body)
+ if !state.Ipv6UnicastRedistributeConnected.IsNull() && data.Ipv6UnicastRedistributeConnected.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ipv6-unicast/redistribute-v6/connected")
+ }
+ if !state.Ipv6UnicastRedistributeStatic.IsNull() && data.Ipv6UnicastRedistributeStatic.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ipv6-unicast/redistribute-v6/static")
+ }
+ for i := range state.Ipv6UnicastNetworks {
+ stateKeys := [...]string{"number"}
+ stateKeyValues := [...]string{state.Ipv6UnicastNetworks[i].Network.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.Ipv6UnicastNetworks[i].Network.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.Ipv6UnicastNetworks {
+ found = true
+ if state.Ipv6UnicastNetworks[i].Network.ValueString() != data.Ipv6UnicastNetworks[j].Network.ValueString() {
+ found = false
+ }
+ if found {
+ if !state.Ipv6UnicastNetworks[i].RouteMap.IsNull() && data.Ipv6UnicastNetworks[j].RouteMap.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/ipv6-unicast/network%v/route-map", predicates))
+ }
+ if !state.Ipv6UnicastNetworks[i].Backdoor.IsNull() && data.Ipv6UnicastNetworks[j].Backdoor.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/ipv6-unicast/network%v/backdoor", predicates))
+ }
+ break
+ }
+ }
+ if !found {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/ipv6-unicast/network%v", predicates))
+ }
+ }
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletedItemsXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin getEmptyLeafsDelete
func (data *BGPAddressFamilyIPv6) getEmptyLeafsDelete(ctx context.Context) []string {
@@ -374,3 +636,29 @@ func (data *BGPAddressFamilyIPv6) getDeletePaths(ctx context.Context) []string {
}
// End of section. //template:end getDeletePaths
+
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletePathsXML
+
+func (data *BGPAddressFamilyIPv6) addDeletePathsXML(ctx context.Context, body string) string {
+ b := netconf.NewBody(body)
+ if !data.Ipv6UnicastRedistributeConnected.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ipv6-unicast/redistribute-v6/connected")
+ }
+ if !data.Ipv6UnicastRedistributeStatic.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ipv6-unicast/redistribute-v6/static")
+ }
+ for i := range data.Ipv6UnicastNetworks {
+ keys := [...]string{"number"}
+ keyValues := [...]string{data.Ipv6UnicastNetworks[i].Network.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/ipv6-unicast/network%v", predicates))
+ }
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletePathsXML
diff --git a/internal/provider/model_iosxe_bgp_address_family_ipv6_vrf.go b/internal/provider/model_iosxe_bgp_address_family_ipv6_vrf.go
index 3b583888..52cecaff 100644
--- a/internal/provider/model_iosxe_bgp_address_family_ipv6_vrf.go
+++ b/internal/provider/model_iosxe_bgp_address_family_ipv6_vrf.go
@@ -31,6 +31,9 @@ import (
"github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/types"
+ "github.com/hashicorp/terraform-plugin-log/tflog"
+ "github.com/netascode/go-netconf"
+ "github.com/netascode/xmldot"
"github.com/tidwall/gjson"
"github.com/tidwall/sjson"
)
@@ -91,6 +94,19 @@ func (data BGPAddressFamilyIPv6VRF) getPathShort() string {
return matches[1]
}
+// getXPath returns the XPath for NETCONF operations
+func (data BGPAddressFamilyIPv6VRF) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/router/Cisco-IOS-XE-bgp:bgp[id=%v]/address-family/with-vrf/ipv6[af-name=%s]"
+ path = fmt.Sprintf(path, fmt.Sprintf("%v", data.Asn.ValueString()), fmt.Sprintf("%v", data.AfName.ValueString()))
+ return path
+}
+
+func (data BGPAddressFamilyIPv6VRFData) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/router/Cisco-IOS-XE-bgp:bgp[id=%v]/address-family/with-vrf/ipv6[af-name=%s]"
+ path = fmt.Sprintf(path, fmt.Sprintf("%v", data.Asn.ValueString()), fmt.Sprintf("%v", data.AfName.ValueString()))
+ return path
+}
+
// End of section. //template:end getPath
// Section below is generated&owned by "gen/generator.go". //template:begin toBody
@@ -149,6 +165,78 @@ func (data BGPAddressFamilyIPv6VRF) toBody(ctx context.Context) string {
// End of section. //template:end toBody
+// Section below is generated&owned by "gen/generator.go". //template:begin toBodyXML
+
+func (data BGPAddressFamilyIPv6VRF) toBodyXML(ctx context.Context) string {
+ body := netconf.Body{}
+ if !data.AfName.IsNull() && !data.AfName.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/af-name", data.AfName.ValueString())
+ }
+ if len(data.Vrfs) > 0 {
+ for _, item := range data.Vrfs {
+ cBody := netconf.Body{}
+ if !item.Name.IsNull() && !item.Name.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "name", item.Name.ValueString())
+ }
+ if !item.Ipv6UnicastAdvertiseL2vpnEvpn.IsNull() && !item.Ipv6UnicastAdvertiseL2vpnEvpn.IsUnknown() {
+ if item.Ipv6UnicastAdvertiseL2vpnEvpn.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "ipv6-unicast/advertise/l2vpn/evpn", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "ipv6-unicast/advertise/l2vpn/evpn")
+ }
+ }
+ if !item.Ipv6UnicastRedistributeConnected.IsNull() && !item.Ipv6UnicastRedistributeConnected.IsUnknown() {
+ if item.Ipv6UnicastRedistributeConnected.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "ipv6-unicast/redistribute-v6/connected", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "ipv6-unicast/redistribute-v6/connected")
+ }
+ }
+ if !item.Ipv6UnicastRedistributeStatic.IsNull() && !item.Ipv6UnicastRedistributeStatic.IsUnknown() {
+ if item.Ipv6UnicastRedistributeStatic.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "ipv6-unicast/redistribute-v6/static", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "ipv6-unicast/redistribute-v6/static")
+ }
+ }
+ if len(item.Ipv6UnicastNetworks) > 0 {
+ for _, citem := range item.Ipv6UnicastNetworks {
+ ccBody := netconf.Body{}
+ if !citem.Network.IsNull() && !citem.Network.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "number", citem.Network.ValueString())
+ }
+ if !citem.RouteMap.IsNull() && !citem.RouteMap.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "route-map", citem.RouteMap.ValueString())
+ }
+ if !citem.Backdoor.IsNull() && !citem.Backdoor.IsUnknown() {
+ if citem.Backdoor.ValueBool() {
+ ccBody = helpers.SetFromXPath(ccBody, "backdoor", "")
+ } else {
+ ccBody = helpers.RemoveFromXPath(ccBody, "backdoor")
+ }
+ }
+ if !citem.Evpn.IsNull() && !citem.Evpn.IsUnknown() {
+ if citem.Evpn.ValueBool() {
+ ccBody = helpers.SetFromXPath(ccBody, "evpn", "")
+ } else {
+ ccBody = helpers.RemoveFromXPath(ccBody, "evpn")
+ }
+ }
+ cBody = helpers.SetRawFromXPath(cBody, "ipv6-unicast/network", ccBody.Res())
+ }
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/vrf", cBody.Res())
+ }
+ }
+ bodyString, err := body.String()
+ if err != nil {
+ tflog.Error(ctx, fmt.Sprintf("Error converting body to string: %s", err))
+ }
+ return bodyString
+}
+
+// End of section. //template:end toBodyXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBody
func (data *BGPAddressFamilyIPv6VRF) updateFromBody(ctx context.Context, res gjson.Result) {
@@ -273,6 +361,126 @@ func (data *BGPAddressFamilyIPv6VRF) updateFromBody(ctx context.Context, res gjs
// End of section. //template:end updateFromBody
+// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBodyXML
+
+func (data *BGPAddressFamilyIPv6VRF) updateFromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/af-name"); value.Exists() && !data.AfName.IsNull() {
+ data.AfName = types.StringValue(value.String())
+ } else {
+ data.AfName = types.StringNull()
+ }
+ for i := range data.Vrfs {
+ keys := [...]string{"name"}
+ keyValues := [...]string{data.Vrfs[i].Name.ValueString()}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/vrf").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, "name"); value.Exists() && !data.Vrfs[i].Name.IsNull() {
+ data.Vrfs[i].Name = types.StringValue(value.String())
+ } else {
+ data.Vrfs[i].Name = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "ipv6-unicast/advertise/l2vpn/evpn"); !data.Vrfs[i].Ipv6UnicastAdvertiseL2vpnEvpn.IsNull() {
+ if value.Exists() {
+ data.Vrfs[i].Ipv6UnicastAdvertiseL2vpnEvpn = types.BoolValue(true)
+ } else {
+ data.Vrfs[i].Ipv6UnicastAdvertiseL2vpnEvpn = types.BoolValue(false)
+ }
+ } else {
+ data.Vrfs[i].Ipv6UnicastAdvertiseL2vpnEvpn = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "ipv6-unicast/redistribute-v6/connected"); !data.Vrfs[i].Ipv6UnicastRedistributeConnected.IsNull() {
+ if value.Exists() {
+ data.Vrfs[i].Ipv6UnicastRedistributeConnected = types.BoolValue(true)
+ } else {
+ data.Vrfs[i].Ipv6UnicastRedistributeConnected = types.BoolValue(false)
+ }
+ } else {
+ data.Vrfs[i].Ipv6UnicastRedistributeConnected = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "ipv6-unicast/redistribute-v6/static"); !data.Vrfs[i].Ipv6UnicastRedistributeStatic.IsNull() {
+ if value.Exists() {
+ data.Vrfs[i].Ipv6UnicastRedistributeStatic = types.BoolValue(true)
+ } else {
+ data.Vrfs[i].Ipv6UnicastRedistributeStatic = types.BoolValue(false)
+ }
+ } else {
+ data.Vrfs[i].Ipv6UnicastRedistributeStatic = types.BoolNull()
+ }
+ for ci := range data.Vrfs[i].Ipv6UnicastNetworks {
+ keys := [...]string{"number"}
+ keyValues := [...]string{data.Vrfs[i].Ipv6UnicastNetworks[ci].Network.ValueString()}
+
+ var cr xmldot.Result
+ helpers.GetFromXPath(r, "ipv6-unicast/network").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ cr = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(cr, "number"); value.Exists() && !data.Vrfs[i].Ipv6UnicastNetworks[ci].Network.IsNull() {
+ data.Vrfs[i].Ipv6UnicastNetworks[ci].Network = types.StringValue(value.String())
+ } else {
+ data.Vrfs[i].Ipv6UnicastNetworks[ci].Network = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(cr, "route-map"); value.Exists() && !data.Vrfs[i].Ipv6UnicastNetworks[ci].RouteMap.IsNull() {
+ data.Vrfs[i].Ipv6UnicastNetworks[ci].RouteMap = types.StringValue(value.String())
+ } else {
+ data.Vrfs[i].Ipv6UnicastNetworks[ci].RouteMap = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(cr, "backdoor"); !data.Vrfs[i].Ipv6UnicastNetworks[ci].Backdoor.IsNull() {
+ if value.Exists() {
+ data.Vrfs[i].Ipv6UnicastNetworks[ci].Backdoor = types.BoolValue(true)
+ } else {
+ data.Vrfs[i].Ipv6UnicastNetworks[ci].Backdoor = types.BoolValue(false)
+ }
+ } else {
+ data.Vrfs[i].Ipv6UnicastNetworks[ci].Backdoor = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(cr, "evpn"); !data.Vrfs[i].Ipv6UnicastNetworks[ci].Evpn.IsNull() {
+ if value.Exists() {
+ data.Vrfs[i].Ipv6UnicastNetworks[ci].Evpn = types.BoolValue(true)
+ } else {
+ data.Vrfs[i].Ipv6UnicastNetworks[ci].Evpn = types.BoolValue(false)
+ }
+ } else {
+ data.Vrfs[i].Ipv6UnicastNetworks[ci].Evpn = types.BoolNull()
+ }
+ }
+ }
+}
+
+// End of section. //template:end updateFromBodyXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin fromBody
func (data *BGPAddressFamilyIPv6VRF) fromBody(ctx context.Context, res gjson.Result) {
@@ -395,6 +603,120 @@ func (data *BGPAddressFamilyIPv6VRFData) fromBody(ctx context.Context, res gjson
// End of section. //template:end fromBodyData
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyXML
+
+func (data *BGPAddressFamilyIPv6VRF) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/vrf"); value.Exists() {
+ data.Vrfs = make([]BGPAddressFamilyIPv6VRFVrfs, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := BGPAddressFamilyIPv6VRFVrfs{}
+ if cValue := helpers.GetFromXPath(v, "name"); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "ipv6-unicast/advertise/l2vpn/evpn"); cValue.Exists() {
+ item.Ipv6UnicastAdvertiseL2vpnEvpn = types.BoolValue(true)
+ } else {
+ item.Ipv6UnicastAdvertiseL2vpnEvpn = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "ipv6-unicast/redistribute-v6/connected"); cValue.Exists() {
+ item.Ipv6UnicastRedistributeConnected = types.BoolValue(true)
+ } else {
+ item.Ipv6UnicastRedistributeConnected = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "ipv6-unicast/redistribute-v6/static"); cValue.Exists() {
+ item.Ipv6UnicastRedistributeStatic = types.BoolValue(true)
+ } else {
+ item.Ipv6UnicastRedistributeStatic = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "ipv6-unicast/network"); cValue.Exists() {
+ item.Ipv6UnicastNetworks = make([]BGPAddressFamilyIPv6VRFVrfsIpv6UnicastNetworks, 0)
+ cValue.ForEach(func(_ int, cv xmldot.Result) bool {
+ cItem := BGPAddressFamilyIPv6VRFVrfsIpv6UnicastNetworks{}
+ if ccValue := helpers.GetFromXPath(cv, "number"); ccValue.Exists() {
+ cItem.Network = types.StringValue(ccValue.String())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "route-map"); ccValue.Exists() {
+ cItem.RouteMap = types.StringValue(ccValue.String())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "backdoor"); ccValue.Exists() {
+ cItem.Backdoor = types.BoolValue(true)
+ } else {
+ cItem.Backdoor = types.BoolValue(false)
+ }
+ if ccValue := helpers.GetFromXPath(cv, "evpn"); ccValue.Exists() {
+ cItem.Evpn = types.BoolValue(true)
+ } else {
+ cItem.Evpn = types.BoolValue(false)
+ }
+ item.Ipv6UnicastNetworks = append(item.Ipv6UnicastNetworks, cItem)
+ return true
+ })
+ }
+ data.Vrfs = append(data.Vrfs, item)
+ return true
+ })
+ }
+}
+
+// End of section. //template:end fromBodyXML
+
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyDataXML
+
+func (data *BGPAddressFamilyIPv6VRFData) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/vrf"); value.Exists() {
+ data.Vrfs = make([]BGPAddressFamilyIPv6VRFVrfs, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := BGPAddressFamilyIPv6VRFVrfs{}
+ if cValue := helpers.GetFromXPath(v, "name"); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "ipv6-unicast/advertise/l2vpn/evpn"); cValue.Exists() {
+ item.Ipv6UnicastAdvertiseL2vpnEvpn = types.BoolValue(true)
+ } else {
+ item.Ipv6UnicastAdvertiseL2vpnEvpn = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "ipv6-unicast/redistribute-v6/connected"); cValue.Exists() {
+ item.Ipv6UnicastRedistributeConnected = types.BoolValue(true)
+ } else {
+ item.Ipv6UnicastRedistributeConnected = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "ipv6-unicast/redistribute-v6/static"); cValue.Exists() {
+ item.Ipv6UnicastRedistributeStatic = types.BoolValue(true)
+ } else {
+ item.Ipv6UnicastRedistributeStatic = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "ipv6-unicast/network"); cValue.Exists() {
+ item.Ipv6UnicastNetworks = make([]BGPAddressFamilyIPv6VRFVrfsIpv6UnicastNetworks, 0)
+ cValue.ForEach(func(_ int, cv xmldot.Result) bool {
+ cItem := BGPAddressFamilyIPv6VRFVrfsIpv6UnicastNetworks{}
+ if ccValue := helpers.GetFromXPath(cv, "number"); ccValue.Exists() {
+ cItem.Network = types.StringValue(ccValue.String())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "route-map"); ccValue.Exists() {
+ cItem.RouteMap = types.StringValue(ccValue.String())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "backdoor"); ccValue.Exists() {
+ cItem.Backdoor = types.BoolValue(true)
+ } else {
+ cItem.Backdoor = types.BoolValue(false)
+ }
+ if ccValue := helpers.GetFromXPath(cv, "evpn"); ccValue.Exists() {
+ cItem.Evpn = types.BoolValue(true)
+ } else {
+ cItem.Evpn = types.BoolValue(false)
+ }
+ item.Ipv6UnicastNetworks = append(item.Ipv6UnicastNetworks, cItem)
+ return true
+ })
+ }
+ data.Vrfs = append(data.Vrfs, item)
+ return true
+ })
+ }
+}
+
+// End of section. //template:end fromBodyDataXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin getDeletedItems
func (data *BGPAddressFamilyIPv6VRF) getDeletedItems(ctx context.Context, state BGPAddressFamilyIPv6VRF) []string {
@@ -473,6 +795,94 @@ func (data *BGPAddressFamilyIPv6VRF) getDeletedItems(ctx context.Context, state
// End of section. //template:end getDeletedItems
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletedItemsXML
+
+func (data *BGPAddressFamilyIPv6VRF) addDeletedItemsXML(ctx context.Context, state BGPAddressFamilyIPv6VRF, body string) string {
+ b := netconf.NewBody(body)
+ for i := range state.Vrfs {
+ stateKeys := [...]string{"name"}
+ stateKeyValues := [...]string{state.Vrfs[i].Name.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.Vrfs[i].Name.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.Vrfs {
+ found = true
+ if state.Vrfs[i].Name.ValueString() != data.Vrfs[j].Name.ValueString() {
+ found = false
+ }
+ if found {
+ if !state.Vrfs[i].Ipv6UnicastAdvertiseL2vpnEvpn.IsNull() && data.Vrfs[j].Ipv6UnicastAdvertiseL2vpnEvpn.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/vrf%v/ipv6-unicast/advertise/l2vpn/evpn", predicates))
+ }
+ if !state.Vrfs[i].Ipv6UnicastRedistributeConnected.IsNull() && data.Vrfs[j].Ipv6UnicastRedistributeConnected.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/vrf%v/ipv6-unicast/redistribute-v6/connected", predicates))
+ }
+ if !state.Vrfs[i].Ipv6UnicastRedistributeStatic.IsNull() && data.Vrfs[j].Ipv6UnicastRedistributeStatic.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/vrf%v/ipv6-unicast/redistribute-v6/static", predicates))
+ }
+ for ci := range state.Vrfs[i].Ipv6UnicastNetworks {
+ cstateKeys := [...]string{"number"}
+ cstateKeyValues := [...]string{state.Vrfs[i].Ipv6UnicastNetworks[ci].Network.ValueString()}
+ cpredicates := ""
+ for i := range cstateKeys {
+ cpredicates += fmt.Sprintf("[%s='%s']", cstateKeys[i], cstateKeyValues[i])
+ }
+
+ cemptyKeys := true
+ if !reflect.ValueOf(state.Vrfs[i].Ipv6UnicastNetworks[ci].Network.ValueString()).IsZero() {
+ cemptyKeys = false
+ }
+ if cemptyKeys {
+ continue
+ }
+
+ found := false
+ for cj := range data.Vrfs[j].Ipv6UnicastNetworks {
+ found = true
+ if state.Vrfs[i].Ipv6UnicastNetworks[ci].Network.ValueString() != data.Vrfs[j].Ipv6UnicastNetworks[cj].Network.ValueString() {
+ found = false
+ }
+ if found {
+ if !state.Vrfs[i].Ipv6UnicastNetworks[ci].RouteMap.IsNull() && data.Vrfs[j].Ipv6UnicastNetworks[cj].RouteMap.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/vrf%v/ipv6-unicast/network%v/route-map", predicates, cpredicates))
+ }
+ if !state.Vrfs[i].Ipv6UnicastNetworks[ci].Backdoor.IsNull() && data.Vrfs[j].Ipv6UnicastNetworks[cj].Backdoor.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/vrf%v/ipv6-unicast/network%v/backdoor", predicates, cpredicates))
+ }
+ if !state.Vrfs[i].Ipv6UnicastNetworks[ci].Evpn.IsNull() && data.Vrfs[j].Ipv6UnicastNetworks[cj].Evpn.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/vrf%v/ipv6-unicast/network%v/evpn", predicates, cpredicates))
+ }
+ break
+ }
+ }
+ if !found {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/vrf%v/ipv6-unicast/network%v", predicates, cpredicates))
+ }
+ }
+ break
+ }
+ }
+ if !found {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/vrf%v", predicates))
+ }
+ }
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletedItemsXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin getEmptyLeafsDelete
func (data *BGPAddressFamilyIPv6VRF) getEmptyLeafsDelete(ctx context.Context) []string {
@@ -520,3 +930,23 @@ func (data *BGPAddressFamilyIPv6VRF) getDeletePaths(ctx context.Context) []strin
}
// End of section. //template:end getDeletePaths
+
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletePathsXML
+
+func (data *BGPAddressFamilyIPv6VRF) addDeletePathsXML(ctx context.Context, body string) string {
+ b := netconf.NewBody(body)
+ for i := range data.Vrfs {
+ keys := [...]string{"name"}
+ keyValues := [...]string{data.Vrfs[i].Name.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/vrf%v", predicates))
+ }
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletePathsXML
diff --git a/internal/provider/model_iosxe_bgp_address_family_l2vpn.go b/internal/provider/model_iosxe_bgp_address_family_l2vpn.go
index db89dc70..5cb31ef9 100644
--- a/internal/provider/model_iosxe_bgp_address_family_l2vpn.go
+++ b/internal/provider/model_iosxe_bgp_address_family_l2vpn.go
@@ -28,6 +28,9 @@ import (
"github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/types"
+ "github.com/hashicorp/terraform-plugin-log/tflog"
+ "github.com/netascode/go-netconf"
+ "github.com/netascode/xmldot"
"github.com/tidwall/gjson"
"github.com/tidwall/sjson"
)
@@ -73,6 +76,19 @@ func (data BGPAddressFamilyL2VPN) getPathShort() string {
return matches[1]
}
+// getXPath returns the XPath for NETCONF operations
+func (data BGPAddressFamilyL2VPN) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/router/Cisco-IOS-XE-bgp:bgp[id=%v]/address-family/no-vrf/l2vpn[af-name=%s]"
+ path = fmt.Sprintf(path, fmt.Sprintf("%v", data.Asn.ValueString()), fmt.Sprintf("%v", data.AfName.ValueString()))
+ return path
+}
+
+func (data BGPAddressFamilyL2VPNData) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/router/Cisco-IOS-XE-bgp:bgp[id=%v]/address-family/no-vrf/l2vpn[af-name=%s]"
+ path = fmt.Sprintf(path, fmt.Sprintf("%v", data.Asn.ValueString()), fmt.Sprintf("%v", data.AfName.ValueString()))
+ return path
+}
+
// End of section. //template:end getPath
// Section below is generated&owned by "gen/generator.go". //template:begin toBody
@@ -87,6 +103,22 @@ func (data BGPAddressFamilyL2VPN) toBody(ctx context.Context) string {
// End of section. //template:end toBody
+// Section below is generated&owned by "gen/generator.go". //template:begin toBodyXML
+
+func (data BGPAddressFamilyL2VPN) toBodyXML(ctx context.Context) string {
+ body := netconf.Body{}
+ if !data.AfName.IsNull() && !data.AfName.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/af-name", data.AfName.ValueString())
+ }
+ bodyString, err := body.String()
+ if err != nil {
+ tflog.Error(ctx, fmt.Sprintf("Error converting body to string: %s", err))
+ }
+ return bodyString
+}
+
+// End of section. //template:end toBodyXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBody
func (data *BGPAddressFamilyL2VPN) updateFromBody(ctx context.Context, res gjson.Result) {
@@ -103,6 +135,18 @@ func (data *BGPAddressFamilyL2VPN) updateFromBody(ctx context.Context, res gjson
// End of section. //template:end updateFromBody
+// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBodyXML
+
+func (data *BGPAddressFamilyL2VPN) updateFromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/af-name"); value.Exists() && !data.AfName.IsNull() {
+ data.AfName = types.StringValue(value.String())
+ } else {
+ data.AfName = types.StringNull()
+ }
+}
+
+// End of section. //template:end updateFromBodyXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin fromBody
func (data *BGPAddressFamilyL2VPN) fromBody(ctx context.Context, res gjson.Result) {
@@ -125,6 +169,20 @@ func (data *BGPAddressFamilyL2VPNData) fromBody(ctx context.Context, res gjson.R
// End of section. //template:end fromBodyData
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyXML
+
+func (data *BGPAddressFamilyL2VPN) fromBodyXML(ctx context.Context, res xmldot.Result) {
+}
+
+// End of section. //template:end fromBodyXML
+
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyDataXML
+
+func (data *BGPAddressFamilyL2VPNData) fromBodyXML(ctx context.Context, res xmldot.Result) {
+}
+
+// End of section. //template:end fromBodyDataXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin getDeletedItems
func (data *BGPAddressFamilyL2VPN) getDeletedItems(ctx context.Context, state BGPAddressFamilyL2VPN) []string {
@@ -135,6 +193,16 @@ func (data *BGPAddressFamilyL2VPN) getDeletedItems(ctx context.Context, state BG
// End of section. //template:end getDeletedItems
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletedItemsXML
+
+func (data *BGPAddressFamilyL2VPN) addDeletedItemsXML(ctx context.Context, state BGPAddressFamilyL2VPN, body string) string {
+ b := netconf.NewBody(body)
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletedItemsXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin getEmptyLeafsDelete
func (data *BGPAddressFamilyL2VPN) getEmptyLeafsDelete(ctx context.Context) []string {
@@ -154,3 +222,13 @@ func (data *BGPAddressFamilyL2VPN) getDeletePaths(ctx context.Context) []string
}
// End of section. //template:end getDeletePaths
+
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletePathsXML
+
+func (data *BGPAddressFamilyL2VPN) addDeletePathsXML(ctx context.Context, body string) string {
+ b := netconf.NewBody(body)
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletePathsXML
diff --git a/internal/provider/model_iosxe_bgp_ipv4_unicast_neighbor.go b/internal/provider/model_iosxe_bgp_ipv4_unicast_neighbor.go
index 09cfd9d1..611dc2c4 100644
--- a/internal/provider/model_iosxe_bgp_ipv4_unicast_neighbor.go
+++ b/internal/provider/model_iosxe_bgp_ipv4_unicast_neighbor.go
@@ -31,6 +31,9 @@ import (
"github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/types"
+ "github.com/hashicorp/terraform-plugin-log/tflog"
+ "github.com/netascode/go-netconf"
+ "github.com/netascode/xmldot"
"github.com/tidwall/gjson"
"github.com/tidwall/sjson"
)
@@ -94,6 +97,19 @@ func (data BGPIPv4UnicastNeighbor) getPathShort() string {
return matches[1]
}
+// getXPath returns the XPath for NETCONF operations
+func (data BGPIPv4UnicastNeighbor) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/router/Cisco-IOS-XE-bgp:bgp[id=%v]/address-family/no-vrf/ipv4[af-name=unicast]/ipv4-unicast/neighbor[id=%s]"
+ path = fmt.Sprintf(path, fmt.Sprintf("%v", data.Asn.ValueString()), fmt.Sprintf("%v", data.Ip.ValueString()))
+ return path
+}
+
+func (data BGPIPv4UnicastNeighborData) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/router/Cisco-IOS-XE-bgp:bgp[id=%v]/address-family/no-vrf/ipv4[af-name=unicast]/ipv4-unicast/neighbor[id=%s]"
+ path = fmt.Sprintf(path, fmt.Sprintf("%v", data.Asn.ValueString()), fmt.Sprintf("%v", data.Ip.ValueString()))
+ return path
+}
+
// End of section. //template:end getPath
// Section below is generated&owned by "gen/generator.go". //template:begin toBody
@@ -143,6 +159,64 @@ func (data BGPIPv4UnicastNeighbor) toBody(ctx context.Context) string {
// End of section. //template:end toBody
+// Section below is generated&owned by "gen/generator.go". //template:begin toBodyXML
+
+func (data BGPIPv4UnicastNeighbor) toBodyXML(ctx context.Context) string {
+ body := netconf.Body{}
+ if !data.Ip.IsNull() && !data.Ip.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/id", data.Ip.ValueString())
+ }
+ if !data.Activate.IsNull() && !data.Activate.IsUnknown() {
+ if data.Activate.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/activate", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/activate")
+ }
+ }
+ if !data.SendCommunity.IsNull() && !data.SendCommunity.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/send-community/send-community-where", data.SendCommunity.ValueString())
+ }
+ if !data.RouteReflectorClient.IsNull() && !data.RouteReflectorClient.IsUnknown() {
+ if data.RouteReflectorClient.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/route-reflector-client", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/route-reflector-client")
+ }
+ }
+ if !data.SoftReconfiguration.IsNull() && !data.SoftReconfiguration.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/soft-reconfiguration", data.SoftReconfiguration.ValueString())
+ }
+ if !data.DefaultOriginate.IsNull() && !data.DefaultOriginate.IsUnknown() {
+ if data.DefaultOriginate.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/default-originate", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/default-originate")
+ }
+ }
+ if !data.DefaultOriginateRouteMap.IsNull() && !data.DefaultOriginateRouteMap.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/default-originate/route-map", data.DefaultOriginateRouteMap.ValueString())
+ }
+ if len(data.RouteMaps) > 0 {
+ for _, item := range data.RouteMaps {
+ cBody := netconf.Body{}
+ if !item.InOut.IsNull() && !item.InOut.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "inout", item.InOut.ValueString())
+ }
+ if !item.RouteMapName.IsNull() && !item.RouteMapName.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "route-map-name", item.RouteMapName.ValueString())
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/route-map", cBody.Res())
+ }
+ }
+ bodyString, err := body.String()
+ if err != nil {
+ tflog.Error(ctx, fmt.Sprintf("Error converting body to string: %s", err))
+ }
+ return bodyString
+}
+
+// End of section. //template:end toBodyXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBody
func (data *BGPIPv4UnicastNeighbor) updateFromBody(ctx context.Context, res gjson.Result) {
@@ -235,6 +309,94 @@ func (data *BGPIPv4UnicastNeighbor) updateFromBody(ctx context.Context, res gjso
// End of section. //template:end updateFromBody
+// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBodyXML
+
+func (data *BGPIPv4UnicastNeighbor) updateFromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/id"); value.Exists() && !data.Ip.IsNull() {
+ data.Ip = types.StringValue(value.String())
+ } else {
+ data.Ip = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/activate"); !data.Activate.IsNull() {
+ if value.Exists() {
+ data.Activate = types.BoolValue(true)
+ } else {
+ data.Activate = types.BoolValue(false)
+ }
+ } else {
+ data.Activate = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/send-community/send-community-where"); value.Exists() && !data.SendCommunity.IsNull() {
+ data.SendCommunity = types.StringValue(value.String())
+ } else {
+ data.SendCommunity = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/route-reflector-client"); !data.RouteReflectorClient.IsNull() {
+ if value.Exists() {
+ data.RouteReflectorClient = types.BoolValue(true)
+ } else {
+ data.RouteReflectorClient = types.BoolValue(false)
+ }
+ } else {
+ data.RouteReflectorClient = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/soft-reconfiguration"); value.Exists() && !data.SoftReconfiguration.IsNull() {
+ data.SoftReconfiguration = types.StringValue(value.String())
+ } else {
+ data.SoftReconfiguration = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/default-originate"); !data.DefaultOriginate.IsNull() {
+ if value.Exists() {
+ data.DefaultOriginate = types.BoolValue(true)
+ } else {
+ data.DefaultOriginate = types.BoolValue(false)
+ }
+ } else {
+ data.DefaultOriginate = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/default-originate/route-map"); value.Exists() && !data.DefaultOriginateRouteMap.IsNull() {
+ data.DefaultOriginateRouteMap = types.StringValue(value.String())
+ } else {
+ data.DefaultOriginateRouteMap = types.StringNull()
+ }
+ for i := range data.RouteMaps {
+ keys := [...]string{"inout"}
+ keyValues := [...]string{data.RouteMaps[i].InOut.ValueString()}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/route-map").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, "inout"); value.Exists() && !data.RouteMaps[i].InOut.IsNull() {
+ data.RouteMaps[i].InOut = types.StringValue(value.String())
+ } else {
+ data.RouteMaps[i].InOut = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "route-map-name"); value.Exists() && !data.RouteMaps[i].RouteMapName.IsNull() {
+ data.RouteMaps[i].RouteMapName = types.StringValue(value.String())
+ } else {
+ data.RouteMaps[i].RouteMapName = types.StringNull()
+ }
+ }
+}
+
+// End of section. //template:end updateFromBodyXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin fromBody
func (data *BGPIPv4UnicastNeighbor) fromBody(ctx context.Context, res gjson.Result) {
@@ -333,6 +495,96 @@ func (data *BGPIPv4UnicastNeighborData) fromBody(ctx context.Context, res gjson.
// End of section. //template:end fromBodyData
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyXML
+
+func (data *BGPIPv4UnicastNeighbor) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/activate"); value.Exists() {
+ data.Activate = types.BoolValue(true)
+ } else {
+ data.Activate = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/send-community/send-community-where"); value.Exists() {
+ data.SendCommunity = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/route-reflector-client"); value.Exists() {
+ data.RouteReflectorClient = types.BoolValue(true)
+ } else {
+ data.RouteReflectorClient = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/soft-reconfiguration"); value.Exists() {
+ data.SoftReconfiguration = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/default-originate"); value.Exists() {
+ data.DefaultOriginate = types.BoolValue(true)
+ } else {
+ data.DefaultOriginate = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/default-originate/route-map"); value.Exists() {
+ data.DefaultOriginateRouteMap = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/route-map"); value.Exists() {
+ data.RouteMaps = make([]BGPIPv4UnicastNeighborRouteMaps, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := BGPIPv4UnicastNeighborRouteMaps{}
+ if cValue := helpers.GetFromXPath(v, "inout"); cValue.Exists() {
+ item.InOut = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "route-map-name"); cValue.Exists() {
+ item.RouteMapName = types.StringValue(cValue.String())
+ }
+ data.RouteMaps = append(data.RouteMaps, item)
+ return true
+ })
+ }
+}
+
+// End of section. //template:end fromBodyXML
+
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyDataXML
+
+func (data *BGPIPv4UnicastNeighborData) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/activate"); value.Exists() {
+ data.Activate = types.BoolValue(true)
+ } else {
+ data.Activate = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/send-community/send-community-where"); value.Exists() {
+ data.SendCommunity = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/route-reflector-client"); value.Exists() {
+ data.RouteReflectorClient = types.BoolValue(true)
+ } else {
+ data.RouteReflectorClient = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/soft-reconfiguration"); value.Exists() {
+ data.SoftReconfiguration = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/default-originate"); value.Exists() {
+ data.DefaultOriginate = types.BoolValue(true)
+ } else {
+ data.DefaultOriginate = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/default-originate/route-map"); value.Exists() {
+ data.DefaultOriginateRouteMap = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/route-map"); value.Exists() {
+ data.RouteMaps = make([]BGPIPv4UnicastNeighborRouteMaps, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := BGPIPv4UnicastNeighborRouteMaps{}
+ if cValue := helpers.GetFromXPath(v, "inout"); cValue.Exists() {
+ item.InOut = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "route-map-name"); cValue.Exists() {
+ item.RouteMapName = types.StringValue(cValue.String())
+ }
+ data.RouteMaps = append(data.RouteMaps, item)
+ return true
+ })
+ }
+}
+
+// End of section. //template:end fromBodyDataXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin getDeletedItems
func (data *BGPIPv4UnicastNeighbor) getDeletedItems(ctx context.Context, state BGPIPv4UnicastNeighbor) []string {
@@ -386,6 +638,64 @@ func (data *BGPIPv4UnicastNeighbor) getDeletedItems(ctx context.Context, state B
// End of section. //template:end getDeletedItems
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletedItemsXML
+
+func (data *BGPIPv4UnicastNeighbor) addDeletedItemsXML(ctx context.Context, state BGPIPv4UnicastNeighbor, body string) string {
+ b := netconf.NewBody(body)
+ if !state.SendCommunity.IsNull() && data.SendCommunity.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/send-community/send-community-where")
+ }
+ if !state.RouteReflectorClient.IsNull() && data.RouteReflectorClient.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/route-reflector-client")
+ }
+ if !state.SoftReconfiguration.IsNull() && data.SoftReconfiguration.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/soft-reconfiguration")
+ }
+ if !state.DefaultOriginate.IsNull() && data.DefaultOriginate.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/default-originate")
+ }
+ if !state.DefaultOriginateRouteMap.IsNull() && data.DefaultOriginateRouteMap.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/default-originate/route-map")
+ }
+ for i := range state.RouteMaps {
+ stateKeys := [...]string{"inout"}
+ stateKeyValues := [...]string{state.RouteMaps[i].InOut.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.RouteMaps[i].InOut.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.RouteMaps {
+ found = true
+ if state.RouteMaps[i].InOut.ValueString() != data.RouteMaps[j].InOut.ValueString() {
+ found = false
+ }
+ if found {
+ if !state.RouteMaps[i].RouteMapName.IsNull() && data.RouteMaps[j].RouteMapName.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/route-map%v/route-map-name", predicates))
+ }
+ break
+ }
+ }
+ if !found {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/route-map%v", predicates))
+ }
+ }
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletedItemsXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin getEmptyLeafsDelete
func (data *BGPIPv4UnicastNeighbor) getEmptyLeafsDelete(ctx context.Context) []string {
@@ -435,3 +745,38 @@ func (data *BGPIPv4UnicastNeighbor) getDeletePaths(ctx context.Context) []string
}
// End of section. //template:end getDeletePaths
+
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletePathsXML
+
+func (data *BGPIPv4UnicastNeighbor) addDeletePathsXML(ctx context.Context, body string) string {
+ b := netconf.NewBody(body)
+ if !data.SendCommunity.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/send-community/send-community-where")
+ }
+ if !data.RouteReflectorClient.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/route-reflector-client")
+ }
+ if !data.SoftReconfiguration.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/soft-reconfiguration")
+ }
+ if !data.DefaultOriginate.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/default-originate")
+ }
+ if !data.DefaultOriginateRouteMap.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/default-originate/route-map")
+ }
+ for i := range data.RouteMaps {
+ keys := [...]string{"inout"}
+ keyValues := [...]string{data.RouteMaps[i].InOut.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/route-map%v", predicates))
+ }
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletePathsXML
diff --git a/internal/provider/model_iosxe_bgp_ipv4_unicast_vrf_neighbor.go b/internal/provider/model_iosxe_bgp_ipv4_unicast_vrf_neighbor.go
index 2314506e..278a54d2 100644
--- a/internal/provider/model_iosxe_bgp_ipv4_unicast_vrf_neighbor.go
+++ b/internal/provider/model_iosxe_bgp_ipv4_unicast_vrf_neighbor.go
@@ -31,6 +31,9 @@ import (
"github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/types"
+ "github.com/hashicorp/terraform-plugin-log/tflog"
+ "github.com/netascode/go-netconf"
+ "github.com/netascode/xmldot"
"github.com/tidwall/gjson"
"github.com/tidwall/sjson"
)
@@ -158,6 +161,19 @@ func (data BGPIPv4UnicastVRFNeighbor) getPathShort() string {
return matches[1]
}
+// getXPath returns the XPath for NETCONF operations
+func (data BGPIPv4UnicastVRFNeighbor) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/router/Cisco-IOS-XE-bgp:bgp[id=%v]/address-family/with-vrf/ipv4[af-name=unicast]/vrf[name=%s]/ipv4-unicast/neighbor[id=%s]"
+ path = fmt.Sprintf(path, fmt.Sprintf("%v", data.Asn.ValueString()), fmt.Sprintf("%v", data.Vrf.ValueString()), fmt.Sprintf("%v", data.Ip.ValueString()))
+ return path
+}
+
+func (data BGPIPv4UnicastVRFNeighborData) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/router/Cisco-IOS-XE-bgp:bgp[id=%v]/address-family/with-vrf/ipv4[af-name=unicast]/vrf[name=%s]/ipv4-unicast/neighbor[id=%s]"
+ path = fmt.Sprintf(path, fmt.Sprintf("%v", data.Asn.ValueString()), fmt.Sprintf("%v", data.Vrf.ValueString()), fmt.Sprintf("%v", data.Ip.ValueString()))
+ return path
+}
+
// End of section. //template:end getPath
// Section below is generated&owned by "gen/generator.go". //template:begin toBody
@@ -330,6 +346,217 @@ func (data BGPIPv4UnicastVRFNeighbor) toBody(ctx context.Context) string {
// End of section. //template:end toBody
+// Section below is generated&owned by "gen/generator.go". //template:begin toBodyXML
+
+func (data BGPIPv4UnicastVRFNeighbor) toBodyXML(ctx context.Context) string {
+ body := netconf.Body{}
+ if !data.Ip.IsNull() && !data.Ip.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/id", data.Ip.ValueString())
+ }
+ if !data.RemoteAs.IsNull() && !data.RemoteAs.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/remote-as", data.RemoteAs.ValueString())
+ }
+ if !data.Description.IsNull() && !data.Description.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/description", data.Description.ValueString())
+ }
+ if !data.Shutdown.IsNull() && !data.Shutdown.IsUnknown() {
+ if data.Shutdown.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/shutdown", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/shutdown")
+ }
+ }
+ if !data.ClusterId.IsNull() && !data.ClusterId.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/cluster-id", data.ClusterId.ValueString())
+ }
+ if !data.LogNeighborChangesDisable.IsNull() && !data.LogNeighborChangesDisable.IsUnknown() {
+ if data.LogNeighborChangesDisable.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/log-neighbor-changes/disable", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/log-neighbor-changes/disable")
+ }
+ }
+ if !data.PasswordType.IsNull() && !data.PasswordType.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/password/enctype", strconv.FormatInt(data.PasswordType.ValueInt64(), 10))
+ }
+ if !data.Password.IsNull() && !data.Password.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/password/text", data.Password.ValueString())
+ }
+ if !data.TimersKeepaliveInterval.IsNull() && !data.TimersKeepaliveInterval.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/timers/keepalive-interval", strconv.FormatInt(data.TimersKeepaliveInterval.ValueInt64(), 10))
+ }
+ if !data.TimersHoldtime.IsNull() && !data.TimersHoldtime.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/timers/holdtime", strconv.FormatInt(data.TimersHoldtime.ValueInt64(), 10))
+ }
+ if !data.TimersMinimumNeighborHold.IsNull() && !data.TimersMinimumNeighborHold.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/timers/minimum-neighbor-hold", strconv.FormatInt(data.TimersMinimumNeighborHold.ValueInt64(), 10))
+ }
+ if !data.Version.IsNull() && !data.Version.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/version", strconv.FormatInt(data.Version.ValueInt64(), 10))
+ }
+ if !data.FallOverDefaultRouteMap.IsNull() && !data.FallOverDefaultRouteMap.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/fall-over/default/route-map", data.FallOverDefaultRouteMap.ValueString())
+ }
+ if !data.FallOverBfd.IsNull() && !data.FallOverBfd.IsUnknown() {
+ if data.FallOverBfd.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/fall-over/bfd", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/fall-over/bfd")
+ }
+ }
+ if !data.FallOverBfdMultiHop.IsNull() && !data.FallOverBfdMultiHop.IsUnknown() {
+ if data.FallOverBfdMultiHop.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/fall-over/bfd/multi-hop", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/fall-over/bfd/multi-hop")
+ }
+ }
+ if !data.FallOverBfdSingleHop.IsNull() && !data.FallOverBfdSingleHop.IsUnknown() {
+ if data.FallOverBfdSingleHop.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/fall-over/bfd/single-hop", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/fall-over/bfd/single-hop")
+ }
+ }
+ if !data.FallOverBfdCheckControlPlaneFailure.IsNull() && !data.FallOverBfdCheckControlPlaneFailure.IsUnknown() {
+ if data.FallOverBfdCheckControlPlaneFailure.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/fall-over/bfd/check-control-plane-failure", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/fall-over/bfd/check-control-plane-failure")
+ }
+ }
+ if !data.FallOverBfdStrictMode.IsNull() && !data.FallOverBfdStrictMode.IsUnknown() {
+ if data.FallOverBfdStrictMode.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/fall-over/bfd/strict-mode", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/fall-over/bfd/strict-mode")
+ }
+ }
+ if !data.FallOverMaximumMetricRouteMap.IsNull() && !data.FallOverMaximumMetricRouteMap.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/fall-over/maximum-metric/route-map", data.FallOverMaximumMetricRouteMap.ValueString())
+ }
+ if !data.DisableConnectedCheck.IsNull() && !data.DisableConnectedCheck.IsUnknown() {
+ if data.DisableConnectedCheck.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/disable-connected-check", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/disable-connected-check")
+ }
+ }
+ if !data.TtlSecurityHops.IsNull() && !data.TtlSecurityHops.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ttl-security/hops", strconv.FormatInt(data.TtlSecurityHops.ValueInt64(), 10))
+ }
+ if !data.LocalAs.IsNull() && !data.LocalAs.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/local-as/as-no", data.LocalAs.ValueString())
+ }
+ if !data.LocalAsNoPrepend.IsNull() && !data.LocalAsNoPrepend.IsUnknown() {
+ if data.LocalAsNoPrepend.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/local-as/no-prepend", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/local-as/no-prepend")
+ }
+ }
+ if !data.LocalAsReplaceAs.IsNull() && !data.LocalAsReplaceAs.IsUnknown() {
+ if data.LocalAsReplaceAs.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/local-as/replace-as", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/local-as/replace-as")
+ }
+ }
+ if !data.LocalAsDualAs.IsNull() && !data.LocalAsDualAs.IsUnknown() {
+ if data.LocalAsDualAs.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/local-as/dual-as", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/local-as/dual-as")
+ }
+ }
+ if !data.UpdateSourceLoopback.IsNull() && !data.UpdateSourceLoopback.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/update-source/interface/Loopback", strconv.FormatInt(data.UpdateSourceLoopback.ValueInt64(), 10))
+ }
+ if !data.Activate.IsNull() && !data.Activate.IsUnknown() {
+ if data.Activate.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/activate", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/activate")
+ }
+ }
+ if !data.SendCommunity.IsNull() && !data.SendCommunity.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/send-community/send-community-where", data.SendCommunity.ValueString())
+ }
+ if !data.RouteReflectorClient.IsNull() && !data.RouteReflectorClient.IsUnknown() {
+ if data.RouteReflectorClient.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/route-reflector-client", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/route-reflector-client")
+ }
+ }
+ if !data.SoftReconfiguration.IsNull() && !data.SoftReconfiguration.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/soft-reconfiguration", data.SoftReconfiguration.ValueString())
+ }
+ if !data.DefaultOriginate.IsNull() && !data.DefaultOriginate.IsUnknown() {
+ if data.DefaultOriginate.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/default-originate", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/default-originate")
+ }
+ }
+ if !data.DefaultOriginateRouteMap.IsNull() && !data.DefaultOriginateRouteMap.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/default-originate/route-map", data.DefaultOriginateRouteMap.ValueString())
+ }
+ if len(data.RouteMaps) > 0 {
+ for _, item := range data.RouteMaps {
+ cBody := netconf.Body{}
+ if !item.InOut.IsNull() && !item.InOut.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "inout", item.InOut.ValueString())
+ }
+ if !item.RouteMapName.IsNull() && !item.RouteMapName.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "route-map-name", item.RouteMapName.ValueString())
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/route-map", cBody.Res())
+ }
+ }
+ if !data.EbgpMultihop.IsNull() && !data.EbgpMultihop.IsUnknown() {
+ if data.EbgpMultihop.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ebgp-multihop", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/ebgp-multihop")
+ }
+ }
+ if !data.EbgpMultihopMaxHop.IsNull() && !data.EbgpMultihopMaxHop.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ebgp-multihop/max-hop", strconv.FormatInt(data.EbgpMultihopMaxHop.ValueInt64(), 10))
+ }
+ if !data.HaModeGracefulRestart.IsNull() && !data.HaModeGracefulRestart.IsUnknown() {
+ if data.HaModeGracefulRestart.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ha-mode/graceful-restart", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/ha-mode/graceful-restart")
+ }
+ }
+ if !data.NextHopSelf.IsNull() && !data.NextHopSelf.IsUnknown() {
+ if data.NextHopSelf.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/next-hop-self", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/next-hop-self")
+ }
+ }
+ if !data.NextHopSelfAll.IsNull() && !data.NextHopSelfAll.IsUnknown() {
+ if data.NextHopSelfAll.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/next-hop-self/all", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/next-hop-self/all")
+ }
+ }
+ if !data.AdvertisementInterval.IsNull() && !data.AdvertisementInterval.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/advertisement-interval", strconv.FormatInt(data.AdvertisementInterval.ValueInt64(), 10))
+ }
+ bodyString, err := body.String()
+ if err != nil {
+ tflog.Error(ctx, fmt.Sprintf("Error converting body to string: %s", err))
+ }
+ return bodyString
+}
+
+// End of section. //template:end toBodyXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBody
func (data *BGPIPv4UnicastVRFNeighbor) updateFromBody(ctx context.Context, res gjson.Result) {
@@ -627,349 +854,978 @@ func (data *BGPIPv4UnicastVRFNeighbor) updateFromBody(ctx context.Context, res g
// End of section. //template:end updateFromBody
-// Section below is generated&owned by "gen/generator.go". //template:begin fromBody
+// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBodyXML
-func (data *BGPIPv4UnicastVRFNeighbor) fromBody(ctx context.Context, res gjson.Result) {
- prefix := helpers.LastElement(data.getPath()) + "."
- if res.Get(helpers.LastElement(data.getPath())).IsArray() {
- prefix += "0."
+func (data *BGPIPv4UnicastVRFNeighbor) updateFromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/id"); value.Exists() && !data.Ip.IsNull() {
+ data.Ip = types.StringValue(value.String())
+ } else {
+ data.Ip = types.StringNull()
}
- if value := res.Get(prefix + "remote-as"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/remote-as"); value.Exists() && !data.RemoteAs.IsNull() {
data.RemoteAs = types.StringValue(value.String())
+ } else {
+ data.RemoteAs = types.StringNull()
}
- if value := res.Get(prefix + "description"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/description"); value.Exists() && !data.Description.IsNull() {
data.Description = types.StringValue(value.String())
+ } else {
+ data.Description = types.StringNull()
}
- if value := res.Get(prefix + "shutdown"); value.Exists() {
- data.Shutdown = types.BoolValue(true)
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/shutdown"); !data.Shutdown.IsNull() {
+ if value.Exists() {
+ data.Shutdown = types.BoolValue(true)
+ } else {
+ data.Shutdown = types.BoolValue(false)
+ }
} else {
- data.Shutdown = types.BoolValue(false)
+ data.Shutdown = types.BoolNull()
}
- if value := res.Get(prefix + "cluster-id"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/cluster-id"); value.Exists() && !data.ClusterId.IsNull() {
data.ClusterId = types.StringValue(value.String())
- }
- if value := res.Get(prefix + "log-neighbor-changes.disable"); value.Exists() {
- data.LogNeighborChangesDisable = types.BoolValue(true)
} else {
- data.LogNeighborChangesDisable = types.BoolValue(false)
- }
- if value := res.Get(prefix + "password.enctype"); value.Exists() {
- data.PasswordType = types.Int64Value(value.Int())
+ data.ClusterId = types.StringNull()
}
- if value := res.Get(prefix + "password.text"); value.Exists() {
- data.Password = types.StringValue(value.String())
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/log-neighbor-changes/disable"); !data.LogNeighborChangesDisable.IsNull() {
+ if value.Exists() {
+ data.LogNeighborChangesDisable = types.BoolValue(true)
+ } else {
+ data.LogNeighborChangesDisable = types.BoolValue(false)
+ }
+ } else {
+ data.LogNeighborChangesDisable = types.BoolNull()
}
- if value := res.Get(prefix + "timers.keepalive-interval"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/timers/keepalive-interval"); value.Exists() && !data.TimersKeepaliveInterval.IsNull() {
data.TimersKeepaliveInterval = types.Int64Value(value.Int())
+ } else {
+ data.TimersKeepaliveInterval = types.Int64Null()
}
- if value := res.Get(prefix + "timers.holdtime"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/timers/holdtime"); value.Exists() && !data.TimersHoldtime.IsNull() {
data.TimersHoldtime = types.Int64Value(value.Int())
+ } else {
+ data.TimersHoldtime = types.Int64Null()
}
- if value := res.Get(prefix + "timers.minimum-neighbor-hold"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/timers/minimum-neighbor-hold"); value.Exists() && !data.TimersMinimumNeighborHold.IsNull() {
data.TimersMinimumNeighborHold = types.Int64Value(value.Int())
+ } else {
+ data.TimersMinimumNeighborHold = types.Int64Null()
}
- if value := res.Get(prefix + "version"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/version"); value.Exists() && !data.Version.IsNull() {
data.Version = types.Int64Value(value.Int())
+ } else {
+ data.Version = types.Int64Null()
}
- if value := res.Get(prefix + "fall-over.default.route-map"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/fall-over/default/route-map"); value.Exists() && !data.FallOverDefaultRouteMap.IsNull() {
data.FallOverDefaultRouteMap = types.StringValue(value.String())
+ } else {
+ data.FallOverDefaultRouteMap = types.StringNull()
}
- if value := res.Get(prefix + "fall-over.bfd"); value.Exists() {
- data.FallOverBfd = types.BoolValue(true)
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/fall-over/bfd"); !data.FallOverBfd.IsNull() {
+ if value.Exists() {
+ data.FallOverBfd = types.BoolValue(true)
+ } else {
+ data.FallOverBfd = types.BoolValue(false)
+ }
} else {
- data.FallOverBfd = types.BoolValue(false)
+ data.FallOverBfd = types.BoolNull()
}
- if value := res.Get(prefix + "fall-over.bfd.multi-hop"); value.Exists() {
- data.FallOverBfdMultiHop = types.BoolValue(true)
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/fall-over/bfd/multi-hop"); !data.FallOverBfdMultiHop.IsNull() {
+ if value.Exists() {
+ data.FallOverBfdMultiHop = types.BoolValue(true)
+ } else {
+ data.FallOverBfdMultiHop = types.BoolValue(false)
+ }
} else {
- data.FallOverBfdMultiHop = types.BoolValue(false)
+ data.FallOverBfdMultiHop = types.BoolNull()
}
- if value := res.Get(prefix + "fall-over.bfd.single-hop"); value.Exists() {
- data.FallOverBfdSingleHop = types.BoolValue(true)
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/fall-over/bfd/single-hop"); !data.FallOverBfdSingleHop.IsNull() {
+ if value.Exists() {
+ data.FallOverBfdSingleHop = types.BoolValue(true)
+ } else {
+ data.FallOverBfdSingleHop = types.BoolValue(false)
+ }
} else {
- data.FallOverBfdSingleHop = types.BoolValue(false)
+ data.FallOverBfdSingleHop = types.BoolNull()
}
- if value := res.Get(prefix + "fall-over.bfd.check-control-plane-failure"); value.Exists() {
- data.FallOverBfdCheckControlPlaneFailure = types.BoolValue(true)
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/fall-over/bfd/check-control-plane-failure"); !data.FallOverBfdCheckControlPlaneFailure.IsNull() {
+ if value.Exists() {
+ data.FallOverBfdCheckControlPlaneFailure = types.BoolValue(true)
+ } else {
+ data.FallOverBfdCheckControlPlaneFailure = types.BoolValue(false)
+ }
} else {
- data.FallOverBfdCheckControlPlaneFailure = types.BoolValue(false)
+ data.FallOverBfdCheckControlPlaneFailure = types.BoolNull()
}
- if value := res.Get(prefix + "fall-over.bfd.strict-mode"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/fall-over/bfd/strict-mode"); !data.FallOverBfdStrictMode.IsNull() {
+ if value.Exists() {
+ data.FallOverBfdStrictMode = types.BoolValue(true)
+ } else {
+ data.FallOverBfdStrictMode = types.BoolValue(false)
+ }
+ } else {
+ data.FallOverBfdStrictMode = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/fall-over/maximum-metric/route-map"); value.Exists() && !data.FallOverMaximumMetricRouteMap.IsNull() {
+ data.FallOverMaximumMetricRouteMap = types.StringValue(value.String())
+ } else {
+ data.FallOverMaximumMetricRouteMap = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/disable-connected-check"); !data.DisableConnectedCheck.IsNull() {
+ if value.Exists() {
+ data.DisableConnectedCheck = types.BoolValue(true)
+ } else {
+ data.DisableConnectedCheck = types.BoolValue(false)
+ }
+ } else {
+ data.DisableConnectedCheck = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ttl-security/hops"); value.Exists() && !data.TtlSecurityHops.IsNull() {
+ data.TtlSecurityHops = types.Int64Value(value.Int())
+ } else {
+ data.TtlSecurityHops = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/local-as/as-no"); value.Exists() && !data.LocalAs.IsNull() {
+ data.LocalAs = types.StringValue(value.String())
+ } else {
+ data.LocalAs = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/local-as/no-prepend"); !data.LocalAsNoPrepend.IsNull() {
+ if value.Exists() {
+ data.LocalAsNoPrepend = types.BoolValue(true)
+ } else {
+ data.LocalAsNoPrepend = types.BoolValue(false)
+ }
+ } else {
+ data.LocalAsNoPrepend = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/local-as/replace-as"); !data.LocalAsReplaceAs.IsNull() {
+ if value.Exists() {
+ data.LocalAsReplaceAs = types.BoolValue(true)
+ } else {
+ data.LocalAsReplaceAs = types.BoolValue(false)
+ }
+ } else {
+ data.LocalAsReplaceAs = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/local-as/dual-as"); !data.LocalAsDualAs.IsNull() {
+ if value.Exists() {
+ data.LocalAsDualAs = types.BoolValue(true)
+ } else {
+ data.LocalAsDualAs = types.BoolValue(false)
+ }
+ } else {
+ data.LocalAsDualAs = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/update-source/interface/Loopback"); value.Exists() && !data.UpdateSourceLoopback.IsNull() {
+ data.UpdateSourceLoopback = types.Int64Value(value.Int())
+ } else {
+ data.UpdateSourceLoopback = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/activate"); !data.Activate.IsNull() {
+ if value.Exists() {
+ data.Activate = types.BoolValue(true)
+ } else {
+ data.Activate = types.BoolValue(false)
+ }
+ } else {
+ data.Activate = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/send-community/send-community-where"); value.Exists() && !data.SendCommunity.IsNull() {
+ data.SendCommunity = types.StringValue(value.String())
+ } else {
+ data.SendCommunity = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/route-reflector-client"); !data.RouteReflectorClient.IsNull() {
+ if value.Exists() {
+ data.RouteReflectorClient = types.BoolValue(true)
+ } else {
+ data.RouteReflectorClient = types.BoolValue(false)
+ }
+ } else {
+ data.RouteReflectorClient = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/soft-reconfiguration"); value.Exists() && !data.SoftReconfiguration.IsNull() {
+ data.SoftReconfiguration = types.StringValue(value.String())
+ } else {
+ data.SoftReconfiguration = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/default-originate"); !data.DefaultOriginate.IsNull() {
+ if value.Exists() {
+ data.DefaultOriginate = types.BoolValue(true)
+ } else {
+ data.DefaultOriginate = types.BoolValue(false)
+ }
+ } else {
+ data.DefaultOriginate = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/default-originate/route-map"); value.Exists() && !data.DefaultOriginateRouteMap.IsNull() {
+ data.DefaultOriginateRouteMap = types.StringValue(value.String())
+ } else {
+ data.DefaultOriginateRouteMap = types.StringNull()
+ }
+ for i := range data.RouteMaps {
+ keys := [...]string{"inout"}
+ keyValues := [...]string{data.RouteMaps[i].InOut.ValueString()}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/route-map").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, "inout"); value.Exists() && !data.RouteMaps[i].InOut.IsNull() {
+ data.RouteMaps[i].InOut = types.StringValue(value.String())
+ } else {
+ data.RouteMaps[i].InOut = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "route-map-name"); value.Exists() && !data.RouteMaps[i].RouteMapName.IsNull() {
+ data.RouteMaps[i].RouteMapName = types.StringValue(value.String())
+ } else {
+ data.RouteMaps[i].RouteMapName = types.StringNull()
+ }
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ebgp-multihop"); !data.EbgpMultihop.IsNull() {
+ if value.Exists() {
+ data.EbgpMultihop = types.BoolValue(true)
+ } else {
+ data.EbgpMultihop = types.BoolValue(false)
+ }
+ } else {
+ data.EbgpMultihop = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ebgp-multihop/max-hop"); value.Exists() && !data.EbgpMultihopMaxHop.IsNull() {
+ data.EbgpMultihopMaxHop = types.Int64Value(value.Int())
+ } else {
+ data.EbgpMultihopMaxHop = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ha-mode/graceful-restart"); !data.HaModeGracefulRestart.IsNull() {
+ if value.Exists() {
+ data.HaModeGracefulRestart = types.BoolValue(true)
+ } else {
+ data.HaModeGracefulRestart = types.BoolValue(false)
+ }
+ } else {
+ data.HaModeGracefulRestart = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/next-hop-self"); !data.NextHopSelf.IsNull() {
+ if value.Exists() {
+ data.NextHopSelf = types.BoolValue(true)
+ } else {
+ data.NextHopSelf = types.BoolValue(false)
+ }
+ } else {
+ data.NextHopSelf = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/next-hop-self/all"); !data.NextHopSelfAll.IsNull() {
+ if value.Exists() {
+ data.NextHopSelfAll = types.BoolValue(true)
+ } else {
+ data.NextHopSelfAll = types.BoolValue(false)
+ }
+ } else {
+ data.NextHopSelfAll = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/advertisement-interval"); value.Exists() && !data.AdvertisementInterval.IsNull() {
+ data.AdvertisementInterval = types.Int64Value(value.Int())
+ } else {
+ data.AdvertisementInterval = types.Int64Null()
+ }
+}
+
+// End of section. //template:end updateFromBodyXML
+
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBody
+
+func (data *BGPIPv4UnicastVRFNeighbor) fromBody(ctx context.Context, res gjson.Result) {
+ prefix := helpers.LastElement(data.getPath()) + "."
+ if res.Get(helpers.LastElement(data.getPath())).IsArray() {
+ prefix += "0."
+ }
+ if value := res.Get(prefix + "remote-as"); value.Exists() {
+ data.RemoteAs = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "description"); value.Exists() {
+ data.Description = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "shutdown"); value.Exists() {
+ data.Shutdown = types.BoolValue(true)
+ } else {
+ data.Shutdown = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "cluster-id"); value.Exists() {
+ data.ClusterId = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "log-neighbor-changes.disable"); value.Exists() {
+ data.LogNeighborChangesDisable = types.BoolValue(true)
+ } else {
+ data.LogNeighborChangesDisable = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "password.enctype"); value.Exists() {
+ data.PasswordType = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "password.text"); value.Exists() {
+ data.Password = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "timers.keepalive-interval"); value.Exists() {
+ data.TimersKeepaliveInterval = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "timers.holdtime"); value.Exists() {
+ data.TimersHoldtime = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "timers.minimum-neighbor-hold"); value.Exists() {
+ data.TimersMinimumNeighborHold = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "version"); value.Exists() {
+ data.Version = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "fall-over.default.route-map"); value.Exists() {
+ data.FallOverDefaultRouteMap = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "fall-over.bfd"); value.Exists() {
+ data.FallOverBfd = types.BoolValue(true)
+ } else {
+ data.FallOverBfd = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "fall-over.bfd.multi-hop"); value.Exists() {
+ data.FallOverBfdMultiHop = types.BoolValue(true)
+ } else {
+ data.FallOverBfdMultiHop = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "fall-over.bfd.single-hop"); value.Exists() {
+ data.FallOverBfdSingleHop = types.BoolValue(true)
+ } else {
+ data.FallOverBfdSingleHop = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "fall-over.bfd.check-control-plane-failure"); value.Exists() {
+ data.FallOverBfdCheckControlPlaneFailure = types.BoolValue(true)
+ } else {
+ data.FallOverBfdCheckControlPlaneFailure = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "fall-over.bfd.strict-mode"); value.Exists() {
+ data.FallOverBfdStrictMode = types.BoolValue(true)
+ } else {
+ data.FallOverBfdStrictMode = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "fall-over.maximum-metric.route-map"); value.Exists() {
+ data.FallOverMaximumMetricRouteMap = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "disable-connected-check"); value.Exists() {
+ data.DisableConnectedCheck = types.BoolValue(true)
+ } else {
+ data.DisableConnectedCheck = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "ttl-security.hops"); value.Exists() {
+ data.TtlSecurityHops = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "local-as.as-no"); value.Exists() {
+ data.LocalAs = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "local-as.no-prepend"); value.Exists() {
+ data.LocalAsNoPrepend = types.BoolValue(true)
+ } else {
+ data.LocalAsNoPrepend = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "local-as.replace-as"); value.Exists() {
+ data.LocalAsReplaceAs = types.BoolValue(true)
+ } else {
+ data.LocalAsReplaceAs = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "local-as.dual-as"); value.Exists() {
+ data.LocalAsDualAs = types.BoolValue(true)
+ } else {
+ data.LocalAsDualAs = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "update-source.interface.Loopback"); value.Exists() {
+ data.UpdateSourceLoopback = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "activate"); value.Exists() {
+ data.Activate = types.BoolValue(true)
+ } else {
+ data.Activate = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "send-community.send-community-where"); value.Exists() {
+ data.SendCommunity = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "route-reflector-client"); value.Exists() {
+ data.RouteReflectorClient = types.BoolValue(true)
+ } else {
+ data.RouteReflectorClient = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "soft-reconfiguration"); value.Exists() {
+ data.SoftReconfiguration = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "default-originate"); value.Exists() {
+ data.DefaultOriginate = types.BoolValue(true)
+ } else {
+ data.DefaultOriginate = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "default-originate.route-map"); value.Exists() {
+ data.DefaultOriginateRouteMap = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "route-map"); value.Exists() {
+ data.RouteMaps = make([]BGPIPv4UnicastVRFNeighborRouteMaps, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := BGPIPv4UnicastVRFNeighborRouteMaps{}
+ if cValue := v.Get("inout"); cValue.Exists() {
+ item.InOut = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("route-map-name"); cValue.Exists() {
+ item.RouteMapName = types.StringValue(cValue.String())
+ }
+ data.RouteMaps = append(data.RouteMaps, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + "ebgp-multihop"); value.Exists() {
+ data.EbgpMultihop = types.BoolValue(true)
+ } else {
+ data.EbgpMultihop = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "ebgp-multihop.max-hop"); value.Exists() {
+ data.EbgpMultihopMaxHop = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "ha-mode.graceful-restart"); value.Exists() {
+ data.HaModeGracefulRestart = types.BoolValue(true)
+ } else {
+ data.HaModeGracefulRestart = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "next-hop-self"); value.Exists() {
+ data.NextHopSelf = types.BoolValue(true)
+ } else {
+ data.NextHopSelf = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "next-hop-self.all"); value.Exists() {
+ data.NextHopSelfAll = types.BoolValue(true)
+ } else {
+ data.NextHopSelfAll = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "advertisement-interval"); value.Exists() {
+ data.AdvertisementInterval = types.Int64Value(value.Int())
+ }
+}
+
+// End of section. //template:end fromBody
+
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyData
+
+func (data *BGPIPv4UnicastVRFNeighborData) fromBody(ctx context.Context, res gjson.Result) {
+ prefix := helpers.LastElement(data.getPath()) + "."
+ if res.Get(helpers.LastElement(data.getPath())).IsArray() {
+ prefix += "0."
+ }
+ if value := res.Get(prefix + "remote-as"); value.Exists() {
+ data.RemoteAs = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "description"); value.Exists() {
+ data.Description = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "shutdown"); value.Exists() {
+ data.Shutdown = types.BoolValue(true)
+ } else {
+ data.Shutdown = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "cluster-id"); value.Exists() {
+ data.ClusterId = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "log-neighbor-changes.disable"); value.Exists() {
+ data.LogNeighborChangesDisable = types.BoolValue(true)
+ } else {
+ data.LogNeighborChangesDisable = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "password.enctype"); value.Exists() {
+ data.PasswordType = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "password.text"); value.Exists() {
+ data.Password = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "timers.keepalive-interval"); value.Exists() {
+ data.TimersKeepaliveInterval = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "timers.holdtime"); value.Exists() {
+ data.TimersHoldtime = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "timers.minimum-neighbor-hold"); value.Exists() {
+ data.TimersMinimumNeighborHold = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "version"); value.Exists() {
+ data.Version = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "fall-over.default.route-map"); value.Exists() {
+ data.FallOverDefaultRouteMap = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "fall-over.bfd"); value.Exists() {
+ data.FallOverBfd = types.BoolValue(true)
+ } else {
+ data.FallOverBfd = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "fall-over.bfd.multi-hop"); value.Exists() {
+ data.FallOverBfdMultiHop = types.BoolValue(true)
+ } else {
+ data.FallOverBfdMultiHop = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "fall-over.bfd.single-hop"); value.Exists() {
+ data.FallOverBfdSingleHop = types.BoolValue(true)
+ } else {
+ data.FallOverBfdSingleHop = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "fall-over.bfd.check-control-plane-failure"); value.Exists() {
+ data.FallOverBfdCheckControlPlaneFailure = types.BoolValue(true)
+ } else {
+ data.FallOverBfdCheckControlPlaneFailure = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "fall-over.bfd.strict-mode"); value.Exists() {
+ data.FallOverBfdStrictMode = types.BoolValue(true)
+ } else {
+ data.FallOverBfdStrictMode = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "fall-over.maximum-metric.route-map"); value.Exists() {
+ data.FallOverMaximumMetricRouteMap = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "disable-connected-check"); value.Exists() {
+ data.DisableConnectedCheck = types.BoolValue(true)
+ } else {
+ data.DisableConnectedCheck = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "ttl-security.hops"); value.Exists() {
+ data.TtlSecurityHops = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "local-as.as-no"); value.Exists() {
+ data.LocalAs = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "local-as.no-prepend"); value.Exists() {
+ data.LocalAsNoPrepend = types.BoolValue(true)
+ } else {
+ data.LocalAsNoPrepend = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "local-as.replace-as"); value.Exists() {
+ data.LocalAsReplaceAs = types.BoolValue(true)
+ } else {
+ data.LocalAsReplaceAs = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "local-as.dual-as"); value.Exists() {
+ data.LocalAsDualAs = types.BoolValue(true)
+ } else {
+ data.LocalAsDualAs = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "update-source.interface.Loopback"); value.Exists() {
+ data.UpdateSourceLoopback = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "activate"); value.Exists() {
+ data.Activate = types.BoolValue(true)
+ } else {
+ data.Activate = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "send-community.send-community-where"); value.Exists() {
+ data.SendCommunity = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "route-reflector-client"); value.Exists() {
+ data.RouteReflectorClient = types.BoolValue(true)
+ } else {
+ data.RouteReflectorClient = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "soft-reconfiguration"); value.Exists() {
+ data.SoftReconfiguration = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "default-originate"); value.Exists() {
+ data.DefaultOriginate = types.BoolValue(true)
+ } else {
+ data.DefaultOriginate = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "default-originate.route-map"); value.Exists() {
+ data.DefaultOriginateRouteMap = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "route-map"); value.Exists() {
+ data.RouteMaps = make([]BGPIPv4UnicastVRFNeighborRouteMaps, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := BGPIPv4UnicastVRFNeighborRouteMaps{}
+ if cValue := v.Get("inout"); cValue.Exists() {
+ item.InOut = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("route-map-name"); cValue.Exists() {
+ item.RouteMapName = types.StringValue(cValue.String())
+ }
+ data.RouteMaps = append(data.RouteMaps, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + "ebgp-multihop"); value.Exists() {
+ data.EbgpMultihop = types.BoolValue(true)
+ } else {
+ data.EbgpMultihop = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "ebgp-multihop.max-hop"); value.Exists() {
+ data.EbgpMultihopMaxHop = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "ha-mode.graceful-restart"); value.Exists() {
+ data.HaModeGracefulRestart = types.BoolValue(true)
+ } else {
+ data.HaModeGracefulRestart = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "next-hop-self"); value.Exists() {
+ data.NextHopSelf = types.BoolValue(true)
+ } else {
+ data.NextHopSelf = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "next-hop-self.all"); value.Exists() {
+ data.NextHopSelfAll = types.BoolValue(true)
+ } else {
+ data.NextHopSelfAll = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "advertisement-interval"); value.Exists() {
+ data.AdvertisementInterval = types.Int64Value(value.Int())
+ }
+}
+
+// End of section. //template:end fromBodyData
+
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyXML
+
+func (data *BGPIPv4UnicastVRFNeighbor) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/remote-as"); value.Exists() {
+ data.RemoteAs = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/description"); value.Exists() {
+ data.Description = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/shutdown"); value.Exists() {
+ data.Shutdown = types.BoolValue(true)
+ } else {
+ data.Shutdown = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/cluster-id"); value.Exists() {
+ data.ClusterId = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/log-neighbor-changes/disable"); value.Exists() {
+ data.LogNeighborChangesDisable = types.BoolValue(true)
+ } else {
+ data.LogNeighborChangesDisable = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/password/enctype"); value.Exists() {
+ data.PasswordType = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/password/text"); value.Exists() {
+ data.Password = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/timers/keepalive-interval"); value.Exists() {
+ data.TimersKeepaliveInterval = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/timers/holdtime"); value.Exists() {
+ data.TimersHoldtime = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/timers/minimum-neighbor-hold"); value.Exists() {
+ data.TimersMinimumNeighborHold = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/version"); value.Exists() {
+ data.Version = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/fall-over/default/route-map"); value.Exists() {
+ data.FallOverDefaultRouteMap = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/fall-over/bfd"); value.Exists() {
+ data.FallOverBfd = types.BoolValue(true)
+ } else {
+ data.FallOverBfd = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/fall-over/bfd/multi-hop"); value.Exists() {
+ data.FallOverBfdMultiHop = types.BoolValue(true)
+ } else {
+ data.FallOverBfdMultiHop = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/fall-over/bfd/single-hop"); value.Exists() {
+ data.FallOverBfdSingleHop = types.BoolValue(true)
+ } else {
+ data.FallOverBfdSingleHop = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/fall-over/bfd/check-control-plane-failure"); value.Exists() {
+ data.FallOverBfdCheckControlPlaneFailure = types.BoolValue(true)
+ } else {
+ data.FallOverBfdCheckControlPlaneFailure = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/fall-over/bfd/strict-mode"); value.Exists() {
data.FallOverBfdStrictMode = types.BoolValue(true)
} else {
data.FallOverBfdStrictMode = types.BoolValue(false)
}
- if value := res.Get(prefix + "fall-over.maximum-metric.route-map"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/fall-over/maximum-metric/route-map"); value.Exists() {
data.FallOverMaximumMetricRouteMap = types.StringValue(value.String())
}
- if value := res.Get(prefix + "disable-connected-check"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/disable-connected-check"); value.Exists() {
data.DisableConnectedCheck = types.BoolValue(true)
} else {
data.DisableConnectedCheck = types.BoolValue(false)
}
- if value := res.Get(prefix + "ttl-security.hops"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ttl-security/hops"); value.Exists() {
data.TtlSecurityHops = types.Int64Value(value.Int())
}
- if value := res.Get(prefix + "local-as.as-no"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/local-as/as-no"); value.Exists() {
data.LocalAs = types.StringValue(value.String())
}
- if value := res.Get(prefix + "local-as.no-prepend"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/local-as/no-prepend"); value.Exists() {
data.LocalAsNoPrepend = types.BoolValue(true)
} else {
data.LocalAsNoPrepend = types.BoolValue(false)
}
- if value := res.Get(prefix + "local-as.replace-as"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/local-as/replace-as"); value.Exists() {
data.LocalAsReplaceAs = types.BoolValue(true)
} else {
data.LocalAsReplaceAs = types.BoolValue(false)
}
- if value := res.Get(prefix + "local-as.dual-as"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/local-as/dual-as"); value.Exists() {
data.LocalAsDualAs = types.BoolValue(true)
} else {
data.LocalAsDualAs = types.BoolValue(false)
}
- if value := res.Get(prefix + "update-source.interface.Loopback"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/update-source/interface/Loopback"); value.Exists() {
data.UpdateSourceLoopback = types.Int64Value(value.Int())
}
- if value := res.Get(prefix + "activate"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/activate"); value.Exists() {
data.Activate = types.BoolValue(true)
} else {
data.Activate = types.BoolValue(false)
}
- if value := res.Get(prefix + "send-community.send-community-where"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/send-community/send-community-where"); value.Exists() {
data.SendCommunity = types.StringValue(value.String())
}
- if value := res.Get(prefix + "route-reflector-client"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/route-reflector-client"); value.Exists() {
data.RouteReflectorClient = types.BoolValue(true)
} else {
data.RouteReflectorClient = types.BoolValue(false)
}
- if value := res.Get(prefix + "soft-reconfiguration"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/soft-reconfiguration"); value.Exists() {
data.SoftReconfiguration = types.StringValue(value.String())
}
- if value := res.Get(prefix + "default-originate"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/default-originate"); value.Exists() {
data.DefaultOriginate = types.BoolValue(true)
} else {
data.DefaultOriginate = types.BoolValue(false)
}
- if value := res.Get(prefix + "default-originate.route-map"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/default-originate/route-map"); value.Exists() {
data.DefaultOriginateRouteMap = types.StringValue(value.String())
}
- if value := res.Get(prefix + "route-map"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/route-map"); value.Exists() {
data.RouteMaps = make([]BGPIPv4UnicastVRFNeighborRouteMaps, 0)
- value.ForEach(func(k, v gjson.Result) bool {
+ value.ForEach(func(_ int, v xmldot.Result) bool {
item := BGPIPv4UnicastVRFNeighborRouteMaps{}
- if cValue := v.Get("inout"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "inout"); cValue.Exists() {
item.InOut = types.StringValue(cValue.String())
}
- if cValue := v.Get("route-map-name"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "route-map-name"); cValue.Exists() {
item.RouteMapName = types.StringValue(cValue.String())
}
data.RouteMaps = append(data.RouteMaps, item)
return true
})
}
- if value := res.Get(prefix + "ebgp-multihop"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ebgp-multihop"); value.Exists() {
data.EbgpMultihop = types.BoolValue(true)
} else {
data.EbgpMultihop = types.BoolValue(false)
}
- if value := res.Get(prefix + "ebgp-multihop.max-hop"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ebgp-multihop/max-hop"); value.Exists() {
data.EbgpMultihopMaxHop = types.Int64Value(value.Int())
}
- if value := res.Get(prefix + "ha-mode.graceful-restart"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ha-mode/graceful-restart"); value.Exists() {
data.HaModeGracefulRestart = types.BoolValue(true)
} else {
data.HaModeGracefulRestart = types.BoolValue(false)
}
- if value := res.Get(prefix + "next-hop-self"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/next-hop-self"); value.Exists() {
data.NextHopSelf = types.BoolValue(true)
} else {
data.NextHopSelf = types.BoolValue(false)
}
- if value := res.Get(prefix + "next-hop-self.all"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/next-hop-self/all"); value.Exists() {
data.NextHopSelfAll = types.BoolValue(true)
} else {
data.NextHopSelfAll = types.BoolValue(false)
}
- if value := res.Get(prefix + "advertisement-interval"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/advertisement-interval"); value.Exists() {
data.AdvertisementInterval = types.Int64Value(value.Int())
}
}
-// End of section. //template:end fromBody
+// End of section. //template:end fromBodyXML
-// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyData
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyDataXML
-func (data *BGPIPv4UnicastVRFNeighborData) fromBody(ctx context.Context, res gjson.Result) {
- prefix := helpers.LastElement(data.getPath()) + "."
- if res.Get(helpers.LastElement(data.getPath())).IsArray() {
- prefix += "0."
- }
- if value := res.Get(prefix + "remote-as"); value.Exists() {
+func (data *BGPIPv4UnicastVRFNeighborData) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/remote-as"); value.Exists() {
data.RemoteAs = types.StringValue(value.String())
}
- if value := res.Get(prefix + "description"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/description"); value.Exists() {
data.Description = types.StringValue(value.String())
}
- if value := res.Get(prefix + "shutdown"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/shutdown"); value.Exists() {
data.Shutdown = types.BoolValue(true)
} else {
data.Shutdown = types.BoolValue(false)
}
- if value := res.Get(prefix + "cluster-id"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/cluster-id"); value.Exists() {
data.ClusterId = types.StringValue(value.String())
}
- if value := res.Get(prefix + "log-neighbor-changes.disable"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/log-neighbor-changes/disable"); value.Exists() {
data.LogNeighborChangesDisable = types.BoolValue(true)
} else {
data.LogNeighborChangesDisable = types.BoolValue(false)
}
- if value := res.Get(prefix + "password.enctype"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/password/enctype"); value.Exists() {
data.PasswordType = types.Int64Value(value.Int())
}
- if value := res.Get(prefix + "password.text"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/password/text"); value.Exists() {
data.Password = types.StringValue(value.String())
}
- if value := res.Get(prefix + "timers.keepalive-interval"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/timers/keepalive-interval"); value.Exists() {
data.TimersKeepaliveInterval = types.Int64Value(value.Int())
}
- if value := res.Get(prefix + "timers.holdtime"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/timers/holdtime"); value.Exists() {
data.TimersHoldtime = types.Int64Value(value.Int())
}
- if value := res.Get(prefix + "timers.minimum-neighbor-hold"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/timers/minimum-neighbor-hold"); value.Exists() {
data.TimersMinimumNeighborHold = types.Int64Value(value.Int())
}
- if value := res.Get(prefix + "version"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/version"); value.Exists() {
data.Version = types.Int64Value(value.Int())
}
- if value := res.Get(prefix + "fall-over.default.route-map"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/fall-over/default/route-map"); value.Exists() {
data.FallOverDefaultRouteMap = types.StringValue(value.String())
}
- if value := res.Get(prefix + "fall-over.bfd"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/fall-over/bfd"); value.Exists() {
data.FallOverBfd = types.BoolValue(true)
} else {
data.FallOverBfd = types.BoolValue(false)
}
- if value := res.Get(prefix + "fall-over.bfd.multi-hop"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/fall-over/bfd/multi-hop"); value.Exists() {
data.FallOverBfdMultiHop = types.BoolValue(true)
} else {
data.FallOverBfdMultiHop = types.BoolValue(false)
}
- if value := res.Get(prefix + "fall-over.bfd.single-hop"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/fall-over/bfd/single-hop"); value.Exists() {
data.FallOverBfdSingleHop = types.BoolValue(true)
} else {
data.FallOverBfdSingleHop = types.BoolValue(false)
}
- if value := res.Get(prefix + "fall-over.bfd.check-control-plane-failure"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/fall-over/bfd/check-control-plane-failure"); value.Exists() {
data.FallOverBfdCheckControlPlaneFailure = types.BoolValue(true)
} else {
data.FallOverBfdCheckControlPlaneFailure = types.BoolValue(false)
}
- if value := res.Get(prefix + "fall-over.bfd.strict-mode"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/fall-over/bfd/strict-mode"); value.Exists() {
data.FallOverBfdStrictMode = types.BoolValue(true)
} else {
data.FallOverBfdStrictMode = types.BoolValue(false)
}
- if value := res.Get(prefix + "fall-over.maximum-metric.route-map"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/fall-over/maximum-metric/route-map"); value.Exists() {
data.FallOverMaximumMetricRouteMap = types.StringValue(value.String())
}
- if value := res.Get(prefix + "disable-connected-check"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/disable-connected-check"); value.Exists() {
data.DisableConnectedCheck = types.BoolValue(true)
} else {
data.DisableConnectedCheck = types.BoolValue(false)
}
- if value := res.Get(prefix + "ttl-security.hops"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ttl-security/hops"); value.Exists() {
data.TtlSecurityHops = types.Int64Value(value.Int())
}
- if value := res.Get(prefix + "local-as.as-no"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/local-as/as-no"); value.Exists() {
data.LocalAs = types.StringValue(value.String())
}
- if value := res.Get(prefix + "local-as.no-prepend"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/local-as/no-prepend"); value.Exists() {
data.LocalAsNoPrepend = types.BoolValue(true)
} else {
data.LocalAsNoPrepend = types.BoolValue(false)
}
- if value := res.Get(prefix + "local-as.replace-as"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/local-as/replace-as"); value.Exists() {
data.LocalAsReplaceAs = types.BoolValue(true)
} else {
data.LocalAsReplaceAs = types.BoolValue(false)
}
- if value := res.Get(prefix + "local-as.dual-as"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/local-as/dual-as"); value.Exists() {
data.LocalAsDualAs = types.BoolValue(true)
} else {
data.LocalAsDualAs = types.BoolValue(false)
}
- if value := res.Get(prefix + "update-source.interface.Loopback"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/update-source/interface/Loopback"); value.Exists() {
data.UpdateSourceLoopback = types.Int64Value(value.Int())
}
- if value := res.Get(prefix + "activate"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/activate"); value.Exists() {
data.Activate = types.BoolValue(true)
} else {
data.Activate = types.BoolValue(false)
}
- if value := res.Get(prefix + "send-community.send-community-where"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/send-community/send-community-where"); value.Exists() {
data.SendCommunity = types.StringValue(value.String())
}
- if value := res.Get(prefix + "route-reflector-client"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/route-reflector-client"); value.Exists() {
data.RouteReflectorClient = types.BoolValue(true)
} else {
data.RouteReflectorClient = types.BoolValue(false)
}
- if value := res.Get(prefix + "soft-reconfiguration"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/soft-reconfiguration"); value.Exists() {
data.SoftReconfiguration = types.StringValue(value.String())
}
- if value := res.Get(prefix + "default-originate"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/default-originate"); value.Exists() {
data.DefaultOriginate = types.BoolValue(true)
} else {
data.DefaultOriginate = types.BoolValue(false)
}
- if value := res.Get(prefix + "default-originate.route-map"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/default-originate/route-map"); value.Exists() {
data.DefaultOriginateRouteMap = types.StringValue(value.String())
}
- if value := res.Get(prefix + "route-map"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/route-map"); value.Exists() {
data.RouteMaps = make([]BGPIPv4UnicastVRFNeighborRouteMaps, 0)
- value.ForEach(func(k, v gjson.Result) bool {
+ value.ForEach(func(_ int, v xmldot.Result) bool {
item := BGPIPv4UnicastVRFNeighborRouteMaps{}
- if cValue := v.Get("inout"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "inout"); cValue.Exists() {
item.InOut = types.StringValue(cValue.String())
}
- if cValue := v.Get("route-map-name"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "route-map-name"); cValue.Exists() {
item.RouteMapName = types.StringValue(cValue.String())
}
data.RouteMaps = append(data.RouteMaps, item)
return true
})
}
- if value := res.Get(prefix + "ebgp-multihop"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ebgp-multihop"); value.Exists() {
data.EbgpMultihop = types.BoolValue(true)
} else {
data.EbgpMultihop = types.BoolValue(false)
}
- if value := res.Get(prefix + "ebgp-multihop.max-hop"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ebgp-multihop/max-hop"); value.Exists() {
data.EbgpMultihopMaxHop = types.Int64Value(value.Int())
}
- if value := res.Get(prefix + "ha-mode.graceful-restart"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ha-mode/graceful-restart"); value.Exists() {
data.HaModeGracefulRestart = types.BoolValue(true)
} else {
data.HaModeGracefulRestart = types.BoolValue(false)
}
- if value := res.Get(prefix + "next-hop-self"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/next-hop-self"); value.Exists() {
data.NextHopSelf = types.BoolValue(true)
} else {
data.NextHopSelf = types.BoolValue(false)
}
- if value := res.Get(prefix + "next-hop-self.all"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/next-hop-self/all"); value.Exists() {
data.NextHopSelfAll = types.BoolValue(true)
} else {
data.NextHopSelfAll = types.BoolValue(false)
}
- if value := res.Get(prefix + "advertisement-interval"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/advertisement-interval"); value.Exists() {
data.AdvertisementInterval = types.Int64Value(value.Int())
}
}
-// End of section. //template:end fromBodyData
+// End of section. //template:end fromBodyDataXML
// Section below is generated&owned by "gen/generator.go". //template:begin getDeletedItems
@@ -1114,6 +1970,154 @@ func (data *BGPIPv4UnicastVRFNeighbor) getDeletedItems(ctx context.Context, stat
// End of section. //template:end getDeletedItems
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletedItemsXML
+
+func (data *BGPIPv4UnicastVRFNeighbor) addDeletedItemsXML(ctx context.Context, state BGPIPv4UnicastVRFNeighbor, body string) string {
+ b := netconf.NewBody(body)
+ if !state.Description.IsNull() && data.Description.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/description")
+ }
+ if !state.Shutdown.IsNull() && data.Shutdown.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/shutdown")
+ }
+ if !state.ClusterId.IsNull() && data.ClusterId.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/cluster-id")
+ }
+ if !state.LogNeighborChangesDisable.IsNull() && data.LogNeighborChangesDisable.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/log-neighbor-changes/disable")
+ }
+ if !state.PasswordType.IsNull() && data.PasswordType.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/password/enctype")
+ }
+ if !state.Password.IsNull() && data.Password.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/password/text")
+ }
+ if !state.TimersKeepaliveInterval.IsNull() && data.TimersKeepaliveInterval.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/timers/keepalive-interval")
+ }
+ if !state.TimersHoldtime.IsNull() && data.TimersHoldtime.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/timers/holdtime")
+ }
+ if !state.TimersMinimumNeighborHold.IsNull() && data.TimersMinimumNeighborHold.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/timers/minimum-neighbor-hold")
+ }
+ if !state.Version.IsNull() && data.Version.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/version")
+ }
+ if !state.FallOverDefaultRouteMap.IsNull() && data.FallOverDefaultRouteMap.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/fall-over/default/route-map")
+ }
+ if !state.FallOverBfd.IsNull() && data.FallOverBfd.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/fall-over/bfd")
+ }
+ if !state.FallOverBfdMultiHop.IsNull() && data.FallOverBfdMultiHop.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/fall-over/bfd/multi-hop")
+ }
+ if !state.FallOverBfdSingleHop.IsNull() && data.FallOverBfdSingleHop.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/fall-over/bfd/single-hop")
+ }
+ if !state.FallOverBfdCheckControlPlaneFailure.IsNull() && data.FallOverBfdCheckControlPlaneFailure.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/fall-over/bfd/check-control-plane-failure")
+ }
+ if !state.FallOverBfdStrictMode.IsNull() && data.FallOverBfdStrictMode.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/fall-over/bfd/strict-mode")
+ }
+ if !state.FallOverMaximumMetricRouteMap.IsNull() && data.FallOverMaximumMetricRouteMap.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/fall-over/maximum-metric/route-map")
+ }
+ if !state.DisableConnectedCheck.IsNull() && data.DisableConnectedCheck.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/disable-connected-check")
+ }
+ if !state.TtlSecurityHops.IsNull() && data.TtlSecurityHops.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ttl-security/hops")
+ }
+ if !state.LocalAs.IsNull() && data.LocalAs.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/local-as/as-no")
+ }
+ if !state.LocalAsNoPrepend.IsNull() && data.LocalAsNoPrepend.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/local-as/no-prepend")
+ }
+ if !state.LocalAsReplaceAs.IsNull() && data.LocalAsReplaceAs.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/local-as/replace-as")
+ }
+ if !state.LocalAsDualAs.IsNull() && data.LocalAsDualAs.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/local-as/dual-as")
+ }
+ if !state.UpdateSourceLoopback.IsNull() && data.UpdateSourceLoopback.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/update-source/interface/Loopback")
+ }
+ if !state.SendCommunity.IsNull() && data.SendCommunity.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/send-community/send-community-where")
+ }
+ if !state.RouteReflectorClient.IsNull() && data.RouteReflectorClient.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/route-reflector-client")
+ }
+ if !state.SoftReconfiguration.IsNull() && data.SoftReconfiguration.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/soft-reconfiguration")
+ }
+ if !state.DefaultOriginate.IsNull() && data.DefaultOriginate.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/default-originate")
+ }
+ if !state.DefaultOriginateRouteMap.IsNull() && data.DefaultOriginateRouteMap.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/default-originate/route-map")
+ }
+ for i := range state.RouteMaps {
+ stateKeys := [...]string{"inout"}
+ stateKeyValues := [...]string{state.RouteMaps[i].InOut.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.RouteMaps[i].InOut.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.RouteMaps {
+ found = true
+ if state.RouteMaps[i].InOut.ValueString() != data.RouteMaps[j].InOut.ValueString() {
+ found = false
+ }
+ if found {
+ if !state.RouteMaps[i].RouteMapName.IsNull() && data.RouteMaps[j].RouteMapName.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/route-map%v/route-map-name", predicates))
+ }
+ break
+ }
+ }
+ if !found {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/route-map%v", predicates))
+ }
+ }
+ if !state.EbgpMultihop.IsNull() && data.EbgpMultihop.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ebgp-multihop")
+ }
+ if !state.EbgpMultihopMaxHop.IsNull() && data.EbgpMultihopMaxHop.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ebgp-multihop/max-hop")
+ }
+ if !state.HaModeGracefulRestart.IsNull() && data.HaModeGracefulRestart.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ha-mode/graceful-restart")
+ }
+ if !state.NextHopSelf.IsNull() && data.NextHopSelf.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/next-hop-self")
+ }
+ if !state.NextHopSelfAll.IsNull() && data.NextHopSelfAll.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/next-hop-self/all")
+ }
+ if !state.AdvertisementInterval.IsNull() && data.AdvertisementInterval.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/advertisement-interval")
+ }
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletedItemsXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin getEmptyLeafsDelete
func (data *BGPIPv4UnicastVRFNeighbor) getEmptyLeafsDelete(ctx context.Context) []string {
@@ -1298,3 +2302,128 @@ func (data *BGPIPv4UnicastVRFNeighbor) getDeletePaths(ctx context.Context) []str
}
// End of section. //template:end getDeletePaths
+
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletePathsXML
+
+func (data *BGPIPv4UnicastVRFNeighbor) addDeletePathsXML(ctx context.Context, body string) string {
+ b := netconf.NewBody(body)
+ if !data.Description.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/description")
+ }
+ if !data.Shutdown.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/shutdown")
+ }
+ if !data.ClusterId.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/cluster-id")
+ }
+ if !data.LogNeighborChangesDisable.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/log-neighbor-changes/disable")
+ }
+ if !data.PasswordType.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/password/enctype")
+ }
+ if !data.Password.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/password/text")
+ }
+ if !data.TimersKeepaliveInterval.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/timers/keepalive-interval")
+ }
+ if !data.TimersHoldtime.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/timers/holdtime")
+ }
+ if !data.TimersMinimumNeighborHold.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/timers/minimum-neighbor-hold")
+ }
+ if !data.Version.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/version")
+ }
+ if !data.FallOverDefaultRouteMap.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/fall-over/default/route-map")
+ }
+ if !data.FallOverBfd.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/fall-over/bfd")
+ }
+ if !data.FallOverBfdMultiHop.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/fall-over/bfd/multi-hop")
+ }
+ if !data.FallOverBfdSingleHop.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/fall-over/bfd/single-hop")
+ }
+ if !data.FallOverBfdCheckControlPlaneFailure.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/fall-over/bfd/check-control-plane-failure")
+ }
+ if !data.FallOverBfdStrictMode.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/fall-over/bfd/strict-mode")
+ }
+ if !data.FallOverMaximumMetricRouteMap.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/fall-over/maximum-metric/route-map")
+ }
+ if !data.DisableConnectedCheck.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/disable-connected-check")
+ }
+ if !data.TtlSecurityHops.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ttl-security/hops")
+ }
+ if !data.LocalAs.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/local-as/as-no")
+ }
+ if !data.LocalAsNoPrepend.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/local-as/no-prepend")
+ }
+ if !data.LocalAsReplaceAs.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/local-as/replace-as")
+ }
+ if !data.LocalAsDualAs.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/local-as/dual-as")
+ }
+ if !data.UpdateSourceLoopback.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/update-source/interface/Loopback")
+ }
+ if !data.SendCommunity.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/send-community/send-community-where")
+ }
+ if !data.RouteReflectorClient.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/route-reflector-client")
+ }
+ if !data.SoftReconfiguration.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/soft-reconfiguration")
+ }
+ if !data.DefaultOriginate.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/default-originate")
+ }
+ if !data.DefaultOriginateRouteMap.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/default-originate/route-map")
+ }
+ for i := range data.RouteMaps {
+ keys := [...]string{"inout"}
+ keyValues := [...]string{data.RouteMaps[i].InOut.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/route-map%v", predicates))
+ }
+ if !data.EbgpMultihop.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ebgp-multihop")
+ }
+ if !data.EbgpMultihopMaxHop.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ebgp-multihop/max-hop")
+ }
+ if !data.HaModeGracefulRestart.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ha-mode/graceful-restart")
+ }
+ if !data.NextHopSelf.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/next-hop-self")
+ }
+ if !data.NextHopSelfAll.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/next-hop-self/all")
+ }
+ if !data.AdvertisementInterval.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/advertisement-interval")
+ }
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletePathsXML
diff --git a/internal/provider/model_iosxe_bgp_ipv6_unicast_neighbor.go b/internal/provider/model_iosxe_bgp_ipv6_unicast_neighbor.go
index 27f5f749..8907f35b 100644
--- a/internal/provider/model_iosxe_bgp_ipv6_unicast_neighbor.go
+++ b/internal/provider/model_iosxe_bgp_ipv6_unicast_neighbor.go
@@ -31,6 +31,9 @@ import (
"github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/types"
+ "github.com/hashicorp/terraform-plugin-log/tflog"
+ "github.com/netascode/go-netconf"
+ "github.com/netascode/xmldot"
"github.com/tidwall/gjson"
"github.com/tidwall/sjson"
)
@@ -94,6 +97,19 @@ func (data BGPIPv6UnicastNeighbor) getPathShort() string {
return matches[1]
}
+// getXPath returns the XPath for NETCONF operations
+func (data BGPIPv6UnicastNeighbor) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/router/Cisco-IOS-XE-bgp:bgp[id=%v]/address-family/no-vrf/ipv6[af-name=unicast]/ipv6-unicast/neighbor[id=%s]"
+ path = fmt.Sprintf(path, fmt.Sprintf("%v", data.Asn.ValueString()), fmt.Sprintf("%v", data.Ip.ValueString()))
+ return path
+}
+
+func (data BGPIPv6UnicastNeighborData) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/router/Cisco-IOS-XE-bgp:bgp[id=%v]/address-family/no-vrf/ipv6[af-name=unicast]/ipv6-unicast/neighbor[id=%s]"
+ path = fmt.Sprintf(path, fmt.Sprintf("%v", data.Asn.ValueString()), fmt.Sprintf("%v", data.Ip.ValueString()))
+ return path
+}
+
// End of section. //template:end getPath
// Section below is generated&owned by "gen/generator.go". //template:begin toBody
@@ -143,6 +159,64 @@ func (data BGPIPv6UnicastNeighbor) toBody(ctx context.Context) string {
// End of section. //template:end toBody
+// Section below is generated&owned by "gen/generator.go". //template:begin toBodyXML
+
+func (data BGPIPv6UnicastNeighbor) toBodyXML(ctx context.Context) string {
+ body := netconf.Body{}
+ if !data.Ip.IsNull() && !data.Ip.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/id", data.Ip.ValueString())
+ }
+ if !data.Activate.IsNull() && !data.Activate.IsUnknown() {
+ if data.Activate.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/activate", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/activate")
+ }
+ }
+ if !data.SendCommunity.IsNull() && !data.SendCommunity.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/send-community/send-community-where", data.SendCommunity.ValueString())
+ }
+ if !data.RouteReflectorClient.IsNull() && !data.RouteReflectorClient.IsUnknown() {
+ if data.RouteReflectorClient.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/route-reflector-client", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/route-reflector-client")
+ }
+ }
+ if !data.SoftReconfiguration.IsNull() && !data.SoftReconfiguration.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/soft-reconfiguration", data.SoftReconfiguration.ValueString())
+ }
+ if !data.DefaultOriginate.IsNull() && !data.DefaultOriginate.IsUnknown() {
+ if data.DefaultOriginate.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/default-originate", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/default-originate")
+ }
+ }
+ if !data.DefaultOriginateRouteMap.IsNull() && !data.DefaultOriginateRouteMap.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/default-originate/route-map", data.DefaultOriginateRouteMap.ValueString())
+ }
+ if len(data.RouteMaps) > 0 {
+ for _, item := range data.RouteMaps {
+ cBody := netconf.Body{}
+ if !item.InOut.IsNull() && !item.InOut.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "inout", item.InOut.ValueString())
+ }
+ if !item.RouteMapName.IsNull() && !item.RouteMapName.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "route-map-name", item.RouteMapName.ValueString())
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/route-map", cBody.Res())
+ }
+ }
+ bodyString, err := body.String()
+ if err != nil {
+ tflog.Error(ctx, fmt.Sprintf("Error converting body to string: %s", err))
+ }
+ return bodyString
+}
+
+// End of section. //template:end toBodyXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBody
func (data *BGPIPv6UnicastNeighbor) updateFromBody(ctx context.Context, res gjson.Result) {
@@ -235,6 +309,94 @@ func (data *BGPIPv6UnicastNeighbor) updateFromBody(ctx context.Context, res gjso
// End of section. //template:end updateFromBody
+// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBodyXML
+
+func (data *BGPIPv6UnicastNeighbor) updateFromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/id"); value.Exists() && !data.Ip.IsNull() {
+ data.Ip = types.StringValue(value.String())
+ } else {
+ data.Ip = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/activate"); !data.Activate.IsNull() {
+ if value.Exists() {
+ data.Activate = types.BoolValue(true)
+ } else {
+ data.Activate = types.BoolValue(false)
+ }
+ } else {
+ data.Activate = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/send-community/send-community-where"); value.Exists() && !data.SendCommunity.IsNull() {
+ data.SendCommunity = types.StringValue(value.String())
+ } else {
+ data.SendCommunity = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/route-reflector-client"); !data.RouteReflectorClient.IsNull() {
+ if value.Exists() {
+ data.RouteReflectorClient = types.BoolValue(true)
+ } else {
+ data.RouteReflectorClient = types.BoolValue(false)
+ }
+ } else {
+ data.RouteReflectorClient = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/soft-reconfiguration"); value.Exists() && !data.SoftReconfiguration.IsNull() {
+ data.SoftReconfiguration = types.StringValue(value.String())
+ } else {
+ data.SoftReconfiguration = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/default-originate"); !data.DefaultOriginate.IsNull() {
+ if value.Exists() {
+ data.DefaultOriginate = types.BoolValue(true)
+ } else {
+ data.DefaultOriginate = types.BoolValue(false)
+ }
+ } else {
+ data.DefaultOriginate = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/default-originate/route-map"); value.Exists() && !data.DefaultOriginateRouteMap.IsNull() {
+ data.DefaultOriginateRouteMap = types.StringValue(value.String())
+ } else {
+ data.DefaultOriginateRouteMap = types.StringNull()
+ }
+ for i := range data.RouteMaps {
+ keys := [...]string{"inout"}
+ keyValues := [...]string{data.RouteMaps[i].InOut.ValueString()}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/route-map").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, "inout"); value.Exists() && !data.RouteMaps[i].InOut.IsNull() {
+ data.RouteMaps[i].InOut = types.StringValue(value.String())
+ } else {
+ data.RouteMaps[i].InOut = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "route-map-name"); value.Exists() && !data.RouteMaps[i].RouteMapName.IsNull() {
+ data.RouteMaps[i].RouteMapName = types.StringValue(value.String())
+ } else {
+ data.RouteMaps[i].RouteMapName = types.StringNull()
+ }
+ }
+}
+
+// End of section. //template:end updateFromBodyXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin fromBody
func (data *BGPIPv6UnicastNeighbor) fromBody(ctx context.Context, res gjson.Result) {
@@ -333,6 +495,96 @@ func (data *BGPIPv6UnicastNeighborData) fromBody(ctx context.Context, res gjson.
// End of section. //template:end fromBodyData
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyXML
+
+func (data *BGPIPv6UnicastNeighbor) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/activate"); value.Exists() {
+ data.Activate = types.BoolValue(true)
+ } else {
+ data.Activate = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/send-community/send-community-where"); value.Exists() {
+ data.SendCommunity = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/route-reflector-client"); value.Exists() {
+ data.RouteReflectorClient = types.BoolValue(true)
+ } else {
+ data.RouteReflectorClient = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/soft-reconfiguration"); value.Exists() {
+ data.SoftReconfiguration = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/default-originate"); value.Exists() {
+ data.DefaultOriginate = types.BoolValue(true)
+ } else {
+ data.DefaultOriginate = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/default-originate/route-map"); value.Exists() {
+ data.DefaultOriginateRouteMap = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/route-map"); value.Exists() {
+ data.RouteMaps = make([]BGPIPv6UnicastNeighborRouteMaps, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := BGPIPv6UnicastNeighborRouteMaps{}
+ if cValue := helpers.GetFromXPath(v, "inout"); cValue.Exists() {
+ item.InOut = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "route-map-name"); cValue.Exists() {
+ item.RouteMapName = types.StringValue(cValue.String())
+ }
+ data.RouteMaps = append(data.RouteMaps, item)
+ return true
+ })
+ }
+}
+
+// End of section. //template:end fromBodyXML
+
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyDataXML
+
+func (data *BGPIPv6UnicastNeighborData) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/activate"); value.Exists() {
+ data.Activate = types.BoolValue(true)
+ } else {
+ data.Activate = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/send-community/send-community-where"); value.Exists() {
+ data.SendCommunity = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/route-reflector-client"); value.Exists() {
+ data.RouteReflectorClient = types.BoolValue(true)
+ } else {
+ data.RouteReflectorClient = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/soft-reconfiguration"); value.Exists() {
+ data.SoftReconfiguration = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/default-originate"); value.Exists() {
+ data.DefaultOriginate = types.BoolValue(true)
+ } else {
+ data.DefaultOriginate = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/default-originate/route-map"); value.Exists() {
+ data.DefaultOriginateRouteMap = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/route-map"); value.Exists() {
+ data.RouteMaps = make([]BGPIPv6UnicastNeighborRouteMaps, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := BGPIPv6UnicastNeighborRouteMaps{}
+ if cValue := helpers.GetFromXPath(v, "inout"); cValue.Exists() {
+ item.InOut = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "route-map-name"); cValue.Exists() {
+ item.RouteMapName = types.StringValue(cValue.String())
+ }
+ data.RouteMaps = append(data.RouteMaps, item)
+ return true
+ })
+ }
+}
+
+// End of section. //template:end fromBodyDataXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin getDeletedItems
func (data *BGPIPv6UnicastNeighbor) getDeletedItems(ctx context.Context, state BGPIPv6UnicastNeighbor) []string {
@@ -386,6 +638,64 @@ func (data *BGPIPv6UnicastNeighbor) getDeletedItems(ctx context.Context, state B
// End of section. //template:end getDeletedItems
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletedItemsXML
+
+func (data *BGPIPv6UnicastNeighbor) addDeletedItemsXML(ctx context.Context, state BGPIPv6UnicastNeighbor, body string) string {
+ b := netconf.NewBody(body)
+ if !state.SendCommunity.IsNull() && data.SendCommunity.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/send-community/send-community-where")
+ }
+ if !state.RouteReflectorClient.IsNull() && data.RouteReflectorClient.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/route-reflector-client")
+ }
+ if !state.SoftReconfiguration.IsNull() && data.SoftReconfiguration.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/soft-reconfiguration")
+ }
+ if !state.DefaultOriginate.IsNull() && data.DefaultOriginate.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/default-originate")
+ }
+ if !state.DefaultOriginateRouteMap.IsNull() && data.DefaultOriginateRouteMap.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/default-originate/route-map")
+ }
+ for i := range state.RouteMaps {
+ stateKeys := [...]string{"inout"}
+ stateKeyValues := [...]string{state.RouteMaps[i].InOut.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.RouteMaps[i].InOut.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.RouteMaps {
+ found = true
+ if state.RouteMaps[i].InOut.ValueString() != data.RouteMaps[j].InOut.ValueString() {
+ found = false
+ }
+ if found {
+ if !state.RouteMaps[i].RouteMapName.IsNull() && data.RouteMaps[j].RouteMapName.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/route-map%v/route-map-name", predicates))
+ }
+ break
+ }
+ }
+ if !found {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/route-map%v", predicates))
+ }
+ }
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletedItemsXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin getEmptyLeafsDelete
func (data *BGPIPv6UnicastNeighbor) getEmptyLeafsDelete(ctx context.Context) []string {
@@ -435,3 +745,38 @@ func (data *BGPIPv6UnicastNeighbor) getDeletePaths(ctx context.Context) []string
}
// End of section. //template:end getDeletePaths
+
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletePathsXML
+
+func (data *BGPIPv6UnicastNeighbor) addDeletePathsXML(ctx context.Context, body string) string {
+ b := netconf.NewBody(body)
+ if !data.SendCommunity.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/send-community/send-community-where")
+ }
+ if !data.RouteReflectorClient.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/route-reflector-client")
+ }
+ if !data.SoftReconfiguration.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/soft-reconfiguration")
+ }
+ if !data.DefaultOriginate.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/default-originate")
+ }
+ if !data.DefaultOriginateRouteMap.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/default-originate/route-map")
+ }
+ for i := range data.RouteMaps {
+ keys := [...]string{"inout"}
+ keyValues := [...]string{data.RouteMaps[i].InOut.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/route-map%v", predicates))
+ }
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletePathsXML
diff --git a/internal/provider/model_iosxe_bgp_l2vpn_evpn_neighbor.go b/internal/provider/model_iosxe_bgp_l2vpn_evpn_neighbor.go
index bd7be469..0b5e5adb 100644
--- a/internal/provider/model_iosxe_bgp_l2vpn_evpn_neighbor.go
+++ b/internal/provider/model_iosxe_bgp_l2vpn_evpn_neighbor.go
@@ -28,6 +28,9 @@ import (
"github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/types"
+ "github.com/hashicorp/terraform-plugin-log/tflog"
+ "github.com/netascode/go-netconf"
+ "github.com/netascode/xmldot"
"github.com/tidwall/gjson"
"github.com/tidwall/sjson"
)
@@ -81,6 +84,19 @@ func (data BGPL2VPNEVPNNeighbor) getPathShort() string {
return matches[1]
}
+// getXPath returns the XPath for NETCONF operations
+func (data BGPL2VPNEVPNNeighbor) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/router/Cisco-IOS-XE-bgp:bgp[id=%v]/address-family/no-vrf/l2vpn[af-name=evpn]/l2vpn-evpn/neighbor[id=%s]"
+ path = fmt.Sprintf(path, fmt.Sprintf("%v", data.Asn.ValueString()), fmt.Sprintf("%v", data.Ip.ValueString()))
+ return path
+}
+
+func (data BGPL2VPNEVPNNeighborData) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/router/Cisco-IOS-XE-bgp:bgp[id=%v]/address-family/no-vrf/l2vpn[af-name=evpn]/l2vpn-evpn/neighbor[id=%s]"
+ path = fmt.Sprintf(path, fmt.Sprintf("%v", data.Asn.ValueString()), fmt.Sprintf("%v", data.Ip.ValueString()))
+ return path
+}
+
// End of section. //template:end getPath
// Section below is generated&owned by "gen/generator.go". //template:begin toBody
@@ -111,6 +127,42 @@ func (data BGPL2VPNEVPNNeighbor) toBody(ctx context.Context) string {
// End of section. //template:end toBody
+// Section below is generated&owned by "gen/generator.go". //template:begin toBodyXML
+
+func (data BGPL2VPNEVPNNeighbor) toBodyXML(ctx context.Context) string {
+ body := netconf.Body{}
+ if !data.Ip.IsNull() && !data.Ip.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/id", data.Ip.ValueString())
+ }
+ if !data.Activate.IsNull() && !data.Activate.IsUnknown() {
+ if data.Activate.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/activate", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/activate")
+ }
+ }
+ if !data.SendCommunity.IsNull() && !data.SendCommunity.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/send-community/send-community-where", data.SendCommunity.ValueString())
+ }
+ if !data.RouteReflectorClient.IsNull() && !data.RouteReflectorClient.IsUnknown() {
+ if data.RouteReflectorClient.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/route-reflector-client", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/route-reflector-client")
+ }
+ }
+ if !data.SoftReconfiguration.IsNull() && !data.SoftReconfiguration.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/soft-reconfiguration", data.SoftReconfiguration.ValueString())
+ }
+ bodyString, err := body.String()
+ if err != nil {
+ tflog.Error(ctx, fmt.Sprintf("Error converting body to string: %s", err))
+ }
+ return bodyString
+}
+
+// End of section. //template:end toBodyXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBody
func (data *BGPL2VPNEVPNNeighbor) updateFromBody(ctx context.Context, res gjson.Result) {
@@ -155,6 +207,46 @@ func (data *BGPL2VPNEVPNNeighbor) updateFromBody(ctx context.Context, res gjson.
// End of section. //template:end updateFromBody
+// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBodyXML
+
+func (data *BGPL2VPNEVPNNeighbor) updateFromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/id"); value.Exists() && !data.Ip.IsNull() {
+ data.Ip = types.StringValue(value.String())
+ } else {
+ data.Ip = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/activate"); !data.Activate.IsNull() {
+ if value.Exists() {
+ data.Activate = types.BoolValue(true)
+ } else {
+ data.Activate = types.BoolValue(false)
+ }
+ } else {
+ data.Activate = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/send-community/send-community-where"); value.Exists() && !data.SendCommunity.IsNull() {
+ data.SendCommunity = types.StringValue(value.String())
+ } else {
+ data.SendCommunity = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/route-reflector-client"); !data.RouteReflectorClient.IsNull() {
+ if value.Exists() {
+ data.RouteReflectorClient = types.BoolValue(true)
+ } else {
+ data.RouteReflectorClient = types.BoolValue(false)
+ }
+ } else {
+ data.RouteReflectorClient = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/soft-reconfiguration"); value.Exists() && !data.SoftReconfiguration.IsNull() {
+ data.SoftReconfiguration = types.StringValue(value.String())
+ } else {
+ data.SoftReconfiguration = types.StringNull()
+ }
+}
+
+// End of section. //template:end updateFromBodyXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin fromBody
func (data *BGPL2VPNEVPNNeighbor) fromBody(ctx context.Context, res gjson.Result) {
@@ -209,6 +301,52 @@ func (data *BGPL2VPNEVPNNeighborData) fromBody(ctx context.Context, res gjson.Re
// End of section. //template:end fromBodyData
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyXML
+
+func (data *BGPL2VPNEVPNNeighbor) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/activate"); value.Exists() {
+ data.Activate = types.BoolValue(true)
+ } else {
+ data.Activate = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/send-community/send-community-where"); value.Exists() {
+ data.SendCommunity = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/route-reflector-client"); value.Exists() {
+ data.RouteReflectorClient = types.BoolValue(true)
+ } else {
+ data.RouteReflectorClient = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/soft-reconfiguration"); value.Exists() {
+ data.SoftReconfiguration = types.StringValue(value.String())
+ }
+}
+
+// End of section. //template:end fromBodyXML
+
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyDataXML
+
+func (data *BGPL2VPNEVPNNeighborData) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/activate"); value.Exists() {
+ data.Activate = types.BoolValue(true)
+ } else {
+ data.Activate = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/send-community/send-community-where"); value.Exists() {
+ data.SendCommunity = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/route-reflector-client"); value.Exists() {
+ data.RouteReflectorClient = types.BoolValue(true)
+ } else {
+ data.RouteReflectorClient = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/soft-reconfiguration"); value.Exists() {
+ data.SoftReconfiguration = types.StringValue(value.String())
+ }
+}
+
+// End of section. //template:end fromBodyDataXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin getDeletedItems
func (data *BGPL2VPNEVPNNeighbor) getDeletedItems(ctx context.Context, state BGPL2VPNEVPNNeighbor) []string {
@@ -228,6 +366,25 @@ func (data *BGPL2VPNEVPNNeighbor) getDeletedItems(ctx context.Context, state BGP
// End of section. //template:end getDeletedItems
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletedItemsXML
+
+func (data *BGPL2VPNEVPNNeighbor) addDeletedItemsXML(ctx context.Context, state BGPL2VPNEVPNNeighbor, body string) string {
+ b := netconf.NewBody(body)
+ if !state.SendCommunity.IsNull() && data.SendCommunity.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/send-community/send-community-where")
+ }
+ if !state.RouteReflectorClient.IsNull() && data.RouteReflectorClient.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/route-reflector-client")
+ }
+ if !state.SoftReconfiguration.IsNull() && data.SoftReconfiguration.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/soft-reconfiguration")
+ }
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletedItemsXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin getEmptyLeafsDelete
func (data *BGPL2VPNEVPNNeighbor) getEmptyLeafsDelete(ctx context.Context) []string {
@@ -262,3 +419,22 @@ func (data *BGPL2VPNEVPNNeighbor) getDeletePaths(ctx context.Context) []string {
}
// End of section. //template:end getDeletePaths
+
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletePathsXML
+
+func (data *BGPL2VPNEVPNNeighbor) addDeletePathsXML(ctx context.Context, body string) string {
+ b := netconf.NewBody(body)
+ if !data.SendCommunity.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/send-community/send-community-where")
+ }
+ if !data.RouteReflectorClient.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/route-reflector-client")
+ }
+ if !data.SoftReconfiguration.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/soft-reconfiguration")
+ }
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletePathsXML
diff --git a/internal/provider/model_iosxe_bgp_neighbor.go b/internal/provider/model_iosxe_bgp_neighbor.go
index 640f5417..8ab58d66 100644
--- a/internal/provider/model_iosxe_bgp_neighbor.go
+++ b/internal/provider/model_iosxe_bgp_neighbor.go
@@ -29,6 +29,9 @@ import (
"github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/types"
+ "github.com/hashicorp/terraform-plugin-log/tflog"
+ "github.com/netascode/go-netconf"
+ "github.com/netascode/xmldot"
"github.com/tidwall/gjson"
"github.com/tidwall/sjson"
)
@@ -132,6 +135,19 @@ func (data BGPNeighbor) getPathShort() string {
return matches[1]
}
+// getXPath returns the XPath for NETCONF operations
+func (data BGPNeighbor) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/router/Cisco-IOS-XE-bgp:bgp[id=%v]/neighbor[id=%s]"
+ path = fmt.Sprintf(path, fmt.Sprintf("%v", data.Asn.ValueString()), fmt.Sprintf("%v", data.Ip.ValueString()))
+ return path
+}
+
+func (data BGPNeighborData) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/router/Cisco-IOS-XE-bgp:bgp[id=%v]/neighbor[id=%s]"
+ path = fmt.Sprintf(path, fmt.Sprintf("%v", data.Asn.ValueString()), fmt.Sprintf("%v", data.Ip.ValueString()))
+ return path
+}
+
// End of section. //template:end getPath
// Section below is generated&owned by "gen/generator.go". //template:begin toBody
@@ -259,6 +275,161 @@ func (data BGPNeighbor) toBody(ctx context.Context) string {
// End of section. //template:end toBody
+// Section below is generated&owned by "gen/generator.go". //template:begin toBodyXML
+
+func (data BGPNeighbor) toBodyXML(ctx context.Context) string {
+ body := netconf.Body{}
+ if !data.Ip.IsNull() && !data.Ip.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/id", data.Ip.ValueString())
+ }
+ if !data.RemoteAs.IsNull() && !data.RemoteAs.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/remote-as", data.RemoteAs.ValueString())
+ }
+ if !data.Description.IsNull() && !data.Description.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/description", data.Description.ValueString())
+ }
+ if !data.Shutdown.IsNull() && !data.Shutdown.IsUnknown() {
+ if data.Shutdown.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/shutdown", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/shutdown")
+ }
+ }
+ if !data.ClusterId.IsNull() && !data.ClusterId.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/cluster-id", data.ClusterId.ValueString())
+ }
+ if !data.Version.IsNull() && !data.Version.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/version", strconv.FormatInt(data.Version.ValueInt64(), 10))
+ }
+ if !data.DisableConnectedCheck.IsNull() && !data.DisableConnectedCheck.IsUnknown() {
+ if data.DisableConnectedCheck.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/disable-connected-check", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/disable-connected-check")
+ }
+ }
+ if !data.FallOverDefaultEnable.IsNull() && !data.FallOverDefaultEnable.IsUnknown() {
+ if data.FallOverDefaultEnable.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/fall-over/default/enable", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/fall-over/default/enable")
+ }
+ }
+ if !data.FallOverDefaultRouteMap.IsNull() && !data.FallOverDefaultRouteMap.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/fall-over/default/route-map", data.FallOverDefaultRouteMap.ValueString())
+ }
+ if !data.FallOverBfd.IsNull() && !data.FallOverBfd.IsUnknown() {
+ if data.FallOverBfd.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/fall-over/bfd", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/fall-over/bfd")
+ }
+ }
+ if !data.FallOverBfdMultiHop.IsNull() && !data.FallOverBfdMultiHop.IsUnknown() {
+ if data.FallOverBfdMultiHop.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/fall-over/bfd/multi-hop", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/fall-over/bfd/multi-hop")
+ }
+ }
+ if !data.FallOverBfdSingleHop.IsNull() && !data.FallOverBfdSingleHop.IsUnknown() {
+ if data.FallOverBfdSingleHop.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/fall-over/bfd/single-hop", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/fall-over/bfd/single-hop")
+ }
+ }
+ if !data.FallOverBfdCheckControlPlaneFailure.IsNull() && !data.FallOverBfdCheckControlPlaneFailure.IsUnknown() {
+ if data.FallOverBfdCheckControlPlaneFailure.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/fall-over/bfd/check-control-plane-failure", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/fall-over/bfd/check-control-plane-failure")
+ }
+ }
+ if !data.FallOverBfdStrictMode.IsNull() && !data.FallOverBfdStrictMode.IsUnknown() {
+ if data.FallOverBfdStrictMode.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/fall-over/bfd/strict-mode", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/fall-over/bfd/strict-mode")
+ }
+ }
+ if !data.FallOverMaximumMetricRouteMap.IsNull() && !data.FallOverMaximumMetricRouteMap.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/fall-over/maximum-metric/route-map", data.FallOverMaximumMetricRouteMap.ValueString())
+ }
+ if !data.LocalAs.IsNull() && !data.LocalAs.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/local-as/as-no", data.LocalAs.ValueString())
+ }
+ if !data.LocalAsNoPrepend.IsNull() && !data.LocalAsNoPrepend.IsUnknown() {
+ if data.LocalAsNoPrepend.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/local-as/no-prepend", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/local-as/no-prepend")
+ }
+ }
+ if !data.LocalAsReplaceAs.IsNull() && !data.LocalAsReplaceAs.IsUnknown() {
+ if data.LocalAsReplaceAs.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/local-as/replace-as", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/local-as/replace-as")
+ }
+ }
+ if !data.LocalAsDualAs.IsNull() && !data.LocalAsDualAs.IsUnknown() {
+ if data.LocalAsDualAs.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/local-as/dual-as", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/local-as/dual-as")
+ }
+ }
+ if !data.LogNeighborChanges.IsNull() && !data.LogNeighborChanges.IsUnknown() {
+ if data.LogNeighborChanges.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/log-neighbor-changes", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/log-neighbor-changes")
+ }
+ }
+ if !data.PasswordType.IsNull() && !data.PasswordType.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/password/enctype", strconv.FormatInt(data.PasswordType.ValueInt64(), 10))
+ }
+ if !data.Password.IsNull() && !data.Password.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/password/text", data.Password.ValueString())
+ }
+ if !data.PeerGroup.IsNull() && !data.PeerGroup.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/peer-group/peer-group-name", data.PeerGroup.ValueString())
+ }
+ if !data.TimersKeepaliveInterval.IsNull() && !data.TimersKeepaliveInterval.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/timers/keepalive-interval", strconv.FormatInt(data.TimersKeepaliveInterval.ValueInt64(), 10))
+ }
+ if !data.TimersHoldtime.IsNull() && !data.TimersHoldtime.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/timers/holdtime", strconv.FormatInt(data.TimersHoldtime.ValueInt64(), 10))
+ }
+ if !data.TimersMinimumNeighborHold.IsNull() && !data.TimersMinimumNeighborHold.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/timers/minimum-neighbor-hold", strconv.FormatInt(data.TimersMinimumNeighborHold.ValueInt64(), 10))
+ }
+ if !data.TtlSecurityHops.IsNull() && !data.TtlSecurityHops.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ttl-security/hops", strconv.FormatInt(data.TtlSecurityHops.ValueInt64(), 10))
+ }
+ if !data.UpdateSourceLoopback.IsNull() && !data.UpdateSourceLoopback.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/update-source/interface/Loopback", strconv.FormatInt(data.UpdateSourceLoopback.ValueInt64(), 10))
+ }
+ if !data.EbgpMultihop.IsNull() && !data.EbgpMultihop.IsUnknown() {
+ if data.EbgpMultihop.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ebgp-multihop", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/ebgp-multihop")
+ }
+ }
+ if !data.EbgpMultihopMaxHop.IsNull() && !data.EbgpMultihopMaxHop.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ebgp-multihop/max-hop", strconv.FormatInt(data.EbgpMultihopMaxHop.ValueInt64(), 10))
+ }
+ bodyString, err := body.String()
+ if err != nil {
+ tflog.Error(ctx, fmt.Sprintf("Error converting body to string: %s", err))
+ }
+ return bodyString
+}
+
+// End of section. //template:end toBodyXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBody
func (data *BGPNeighbor) updateFromBody(ctx context.Context, res gjson.Result) {
@@ -453,18 +624,341 @@ func (data *BGPNeighbor) updateFromBody(ctx context.Context, res gjson.Result) {
} else {
data.EbgpMultihop = types.BoolNull()
}
- if value := res.Get(prefix + "ebgp-multihop.max-hop"); value.Exists() && !data.EbgpMultihopMaxHop.IsNull() {
+ if value := res.Get(prefix + "ebgp-multihop.max-hop"); value.Exists() && !data.EbgpMultihopMaxHop.IsNull() {
+ data.EbgpMultihopMaxHop = types.Int64Value(value.Int())
+ } else {
+ data.EbgpMultihopMaxHop = types.Int64Null()
+ }
+}
+
+// End of section. //template:end updateFromBody
+
+// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBodyXML
+
+func (data *BGPNeighbor) updateFromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/id"); value.Exists() && !data.Ip.IsNull() {
+ data.Ip = types.StringValue(value.String())
+ } else {
+ data.Ip = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/remote-as"); value.Exists() && !data.RemoteAs.IsNull() {
+ data.RemoteAs = types.StringValue(value.String())
+ } else {
+ data.RemoteAs = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/description"); value.Exists() && !data.Description.IsNull() {
+ data.Description = types.StringValue(value.String())
+ } else {
+ data.Description = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/shutdown"); !data.Shutdown.IsNull() {
+ if value.Exists() {
+ data.Shutdown = types.BoolValue(true)
+ } else {
+ data.Shutdown = types.BoolValue(false)
+ }
+ } else {
+ data.Shutdown = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/cluster-id"); value.Exists() && !data.ClusterId.IsNull() {
+ data.ClusterId = types.StringValue(value.String())
+ } else {
+ data.ClusterId = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/version"); value.Exists() && !data.Version.IsNull() {
+ data.Version = types.Int64Value(value.Int())
+ } else {
+ data.Version = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/disable-connected-check"); !data.DisableConnectedCheck.IsNull() {
+ if value.Exists() {
+ data.DisableConnectedCheck = types.BoolValue(true)
+ } else {
+ data.DisableConnectedCheck = types.BoolValue(false)
+ }
+ } else {
+ data.DisableConnectedCheck = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/fall-over/default/enable"); !data.FallOverDefaultEnable.IsNull() {
+ if value.Exists() {
+ data.FallOverDefaultEnable = types.BoolValue(true)
+ } else {
+ data.FallOverDefaultEnable = types.BoolValue(false)
+ }
+ } else {
+ data.FallOverDefaultEnable = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/fall-over/default/route-map"); value.Exists() && !data.FallOverDefaultRouteMap.IsNull() {
+ data.FallOverDefaultRouteMap = types.StringValue(value.String())
+ } else {
+ data.FallOverDefaultRouteMap = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/fall-over/bfd"); !data.FallOverBfd.IsNull() {
+ if value.Exists() {
+ data.FallOverBfd = types.BoolValue(true)
+ } else {
+ data.FallOverBfd = types.BoolValue(false)
+ }
+ } else {
+ data.FallOverBfd = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/fall-over/bfd/multi-hop"); !data.FallOverBfdMultiHop.IsNull() {
+ if value.Exists() {
+ data.FallOverBfdMultiHop = types.BoolValue(true)
+ } else {
+ data.FallOverBfdMultiHop = types.BoolValue(false)
+ }
+ } else {
+ data.FallOverBfdMultiHop = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/fall-over/bfd/single-hop"); !data.FallOverBfdSingleHop.IsNull() {
+ if value.Exists() {
+ data.FallOverBfdSingleHop = types.BoolValue(true)
+ } else {
+ data.FallOverBfdSingleHop = types.BoolValue(false)
+ }
+ } else {
+ data.FallOverBfdSingleHop = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/fall-over/bfd/check-control-plane-failure"); !data.FallOverBfdCheckControlPlaneFailure.IsNull() {
+ if value.Exists() {
+ data.FallOverBfdCheckControlPlaneFailure = types.BoolValue(true)
+ } else {
+ data.FallOverBfdCheckControlPlaneFailure = types.BoolValue(false)
+ }
+ } else {
+ data.FallOverBfdCheckControlPlaneFailure = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/fall-over/bfd/strict-mode"); !data.FallOverBfdStrictMode.IsNull() {
+ if value.Exists() {
+ data.FallOverBfdStrictMode = types.BoolValue(true)
+ } else {
+ data.FallOverBfdStrictMode = types.BoolValue(false)
+ }
+ } else {
+ data.FallOverBfdStrictMode = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/fall-over/maximum-metric/route-map"); value.Exists() && !data.FallOverMaximumMetricRouteMap.IsNull() {
+ data.FallOverMaximumMetricRouteMap = types.StringValue(value.String())
+ } else {
+ data.FallOverMaximumMetricRouteMap = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/local-as/as-no"); value.Exists() && !data.LocalAs.IsNull() {
+ data.LocalAs = types.StringValue(value.String())
+ } else {
+ data.LocalAs = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/local-as/no-prepend"); !data.LocalAsNoPrepend.IsNull() {
+ if value.Exists() {
+ data.LocalAsNoPrepend = types.BoolValue(true)
+ } else {
+ data.LocalAsNoPrepend = types.BoolValue(false)
+ }
+ } else {
+ data.LocalAsNoPrepend = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/local-as/replace-as"); !data.LocalAsReplaceAs.IsNull() {
+ if value.Exists() {
+ data.LocalAsReplaceAs = types.BoolValue(true)
+ } else {
+ data.LocalAsReplaceAs = types.BoolValue(false)
+ }
+ } else {
+ data.LocalAsReplaceAs = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/local-as/dual-as"); !data.LocalAsDualAs.IsNull() {
+ if value.Exists() {
+ data.LocalAsDualAs = types.BoolValue(true)
+ } else {
+ data.LocalAsDualAs = types.BoolValue(false)
+ }
+ } else {
+ data.LocalAsDualAs = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/log-neighbor-changes"); !data.LogNeighborChanges.IsNull() {
+ if value.Exists() {
+ data.LogNeighborChanges = types.BoolValue(true)
+ } else {
+ data.LogNeighborChanges = types.BoolValue(false)
+ }
+ } else {
+ data.LogNeighborChanges = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/peer-group/peer-group-name"); value.Exists() && !data.PeerGroup.IsNull() {
+ data.PeerGroup = types.StringValue(value.String())
+ } else {
+ data.PeerGroup = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/timers/keepalive-interval"); value.Exists() && !data.TimersKeepaliveInterval.IsNull() {
+ data.TimersKeepaliveInterval = types.Int64Value(value.Int())
+ } else {
+ data.TimersKeepaliveInterval = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/timers/holdtime"); value.Exists() && !data.TimersHoldtime.IsNull() {
+ data.TimersHoldtime = types.Int64Value(value.Int())
+ } else {
+ data.TimersHoldtime = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/timers/minimum-neighbor-hold"); value.Exists() && !data.TimersMinimumNeighborHold.IsNull() {
+ data.TimersMinimumNeighborHold = types.Int64Value(value.Int())
+ } else {
+ data.TimersMinimumNeighborHold = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ttl-security/hops"); value.Exists() && !data.TtlSecurityHops.IsNull() {
+ data.TtlSecurityHops = types.Int64Value(value.Int())
+ } else {
+ data.TtlSecurityHops = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/update-source/interface/Loopback"); value.Exists() && !data.UpdateSourceLoopback.IsNull() {
+ data.UpdateSourceLoopback = types.Int64Value(value.Int())
+ } else {
+ data.UpdateSourceLoopback = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ebgp-multihop"); !data.EbgpMultihop.IsNull() {
+ if value.Exists() {
+ data.EbgpMultihop = types.BoolValue(true)
+ } else {
+ data.EbgpMultihop = types.BoolValue(false)
+ }
+ } else {
+ data.EbgpMultihop = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ebgp-multihop/max-hop"); value.Exists() && !data.EbgpMultihopMaxHop.IsNull() {
+ data.EbgpMultihopMaxHop = types.Int64Value(value.Int())
+ } else {
+ data.EbgpMultihopMaxHop = types.Int64Null()
+ }
+}
+
+// End of section. //template:end updateFromBodyXML
+
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBody
+
+func (data *BGPNeighbor) fromBody(ctx context.Context, res gjson.Result) {
+ prefix := helpers.LastElement(data.getPath()) + "."
+ if res.Get(helpers.LastElement(data.getPath())).IsArray() {
+ prefix += "0."
+ }
+ if value := res.Get(prefix + "remote-as"); value.Exists() {
+ data.RemoteAs = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "description"); value.Exists() {
+ data.Description = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "shutdown"); value.Exists() {
+ data.Shutdown = types.BoolValue(true)
+ } else {
+ data.Shutdown = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "cluster-id"); value.Exists() {
+ data.ClusterId = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "version"); value.Exists() {
+ data.Version = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "disable-connected-check"); value.Exists() {
+ data.DisableConnectedCheck = types.BoolValue(true)
+ } else {
+ data.DisableConnectedCheck = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "fall-over.default.enable"); value.Exists() {
+ data.FallOverDefaultEnable = types.BoolValue(true)
+ } else {
+ data.FallOverDefaultEnable = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "fall-over.default.route-map"); value.Exists() {
+ data.FallOverDefaultRouteMap = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "fall-over.bfd"); value.Exists() {
+ data.FallOverBfd = types.BoolValue(true)
+ } else {
+ data.FallOverBfd = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "fall-over.bfd.multi-hop"); value.Exists() {
+ data.FallOverBfdMultiHop = types.BoolValue(true)
+ } else {
+ data.FallOverBfdMultiHop = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "fall-over.bfd.single-hop"); value.Exists() {
+ data.FallOverBfdSingleHop = types.BoolValue(true)
+ } else {
+ data.FallOverBfdSingleHop = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "fall-over.bfd.check-control-plane-failure"); value.Exists() {
+ data.FallOverBfdCheckControlPlaneFailure = types.BoolValue(true)
+ } else {
+ data.FallOverBfdCheckControlPlaneFailure = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "fall-over.bfd.strict-mode"); value.Exists() {
+ data.FallOverBfdStrictMode = types.BoolValue(true)
+ } else {
+ data.FallOverBfdStrictMode = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "fall-over.maximum-metric.route-map"); value.Exists() {
+ data.FallOverMaximumMetricRouteMap = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "local-as.as-no"); value.Exists() {
+ data.LocalAs = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "local-as.no-prepend"); value.Exists() {
+ data.LocalAsNoPrepend = types.BoolValue(true)
+ } else {
+ data.LocalAsNoPrepend = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "local-as.replace-as"); value.Exists() {
+ data.LocalAsReplaceAs = types.BoolValue(true)
+ } else {
+ data.LocalAsReplaceAs = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "local-as.dual-as"); value.Exists() {
+ data.LocalAsDualAs = types.BoolValue(true)
+ } else {
+ data.LocalAsDualAs = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "log-neighbor-changes"); value.Exists() {
+ data.LogNeighborChanges = types.BoolValue(true)
+ } else {
+ data.LogNeighborChanges = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "password.enctype"); value.Exists() {
+ data.PasswordType = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "password.text"); value.Exists() {
+ data.Password = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "peer-group.peer-group-name"); value.Exists() {
+ data.PeerGroup = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "timers.keepalive-interval"); value.Exists() {
+ data.TimersKeepaliveInterval = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "timers.holdtime"); value.Exists() {
+ data.TimersHoldtime = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "timers.minimum-neighbor-hold"); value.Exists() {
+ data.TimersMinimumNeighborHold = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "ttl-security.hops"); value.Exists() {
+ data.TtlSecurityHops = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "update-source.interface.Loopback"); value.Exists() {
+ data.UpdateSourceLoopback = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "ebgp-multihop"); value.Exists() {
+ data.EbgpMultihop = types.BoolValue(true)
+ } else {
+ data.EbgpMultihop = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "ebgp-multihop.max-hop"); value.Exists() {
data.EbgpMultihopMaxHop = types.Int64Value(value.Int())
- } else {
- data.EbgpMultihopMaxHop = types.Int64Null()
}
}
-// End of section. //template:end updateFromBody
+// End of section. //template:end fromBody
-// Section below is generated&owned by "gen/generator.go". //template:begin fromBody
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyData
-func (data *BGPNeighbor) fromBody(ctx context.Context, res gjson.Result) {
+func (data *BGPNeighborData) fromBody(ctx context.Context, res gjson.Result) {
prefix := helpers.LastElement(data.getPath()) + "."
if res.Get(helpers.LastElement(data.getPath())).IsArray() {
prefix += "0."
@@ -584,131 +1078,247 @@ func (data *BGPNeighbor) fromBody(ctx context.Context, res gjson.Result) {
}
}
-// End of section. //template:end fromBody
+// End of section. //template:end fromBodyData
-// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyData
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyXML
-func (data *BGPNeighborData) fromBody(ctx context.Context, res gjson.Result) {
- prefix := helpers.LastElement(data.getPath()) + "."
- if res.Get(helpers.LastElement(data.getPath())).IsArray() {
- prefix += "0."
+func (data *BGPNeighbor) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/remote-as"); value.Exists() {
+ data.RemoteAs = types.StringValue(value.String())
}
- if value := res.Get(prefix + "remote-as"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/description"); value.Exists() {
+ data.Description = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/shutdown"); value.Exists() {
+ data.Shutdown = types.BoolValue(true)
+ } else {
+ data.Shutdown = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/cluster-id"); value.Exists() {
+ data.ClusterId = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/version"); value.Exists() {
+ data.Version = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/disable-connected-check"); value.Exists() {
+ data.DisableConnectedCheck = types.BoolValue(true)
+ } else {
+ data.DisableConnectedCheck = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/fall-over/default/enable"); value.Exists() {
+ data.FallOverDefaultEnable = types.BoolValue(true)
+ } else {
+ data.FallOverDefaultEnable = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/fall-over/default/route-map"); value.Exists() {
+ data.FallOverDefaultRouteMap = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/fall-over/bfd"); value.Exists() {
+ data.FallOverBfd = types.BoolValue(true)
+ } else {
+ data.FallOverBfd = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/fall-over/bfd/multi-hop"); value.Exists() {
+ data.FallOverBfdMultiHop = types.BoolValue(true)
+ } else {
+ data.FallOverBfdMultiHop = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/fall-over/bfd/single-hop"); value.Exists() {
+ data.FallOverBfdSingleHop = types.BoolValue(true)
+ } else {
+ data.FallOverBfdSingleHop = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/fall-over/bfd/check-control-plane-failure"); value.Exists() {
+ data.FallOverBfdCheckControlPlaneFailure = types.BoolValue(true)
+ } else {
+ data.FallOverBfdCheckControlPlaneFailure = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/fall-over/bfd/strict-mode"); value.Exists() {
+ data.FallOverBfdStrictMode = types.BoolValue(true)
+ } else {
+ data.FallOverBfdStrictMode = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/fall-over/maximum-metric/route-map"); value.Exists() {
+ data.FallOverMaximumMetricRouteMap = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/local-as/as-no"); value.Exists() {
+ data.LocalAs = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/local-as/no-prepend"); value.Exists() {
+ data.LocalAsNoPrepend = types.BoolValue(true)
+ } else {
+ data.LocalAsNoPrepend = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/local-as/replace-as"); value.Exists() {
+ data.LocalAsReplaceAs = types.BoolValue(true)
+ } else {
+ data.LocalAsReplaceAs = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/local-as/dual-as"); value.Exists() {
+ data.LocalAsDualAs = types.BoolValue(true)
+ } else {
+ data.LocalAsDualAs = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/log-neighbor-changes"); value.Exists() {
+ data.LogNeighborChanges = types.BoolValue(true)
+ } else {
+ data.LogNeighborChanges = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/password/enctype"); value.Exists() {
+ data.PasswordType = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/password/text"); value.Exists() {
+ data.Password = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/peer-group/peer-group-name"); value.Exists() {
+ data.PeerGroup = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/timers/keepalive-interval"); value.Exists() {
+ data.TimersKeepaliveInterval = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/timers/holdtime"); value.Exists() {
+ data.TimersHoldtime = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/timers/minimum-neighbor-hold"); value.Exists() {
+ data.TimersMinimumNeighborHold = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ttl-security/hops"); value.Exists() {
+ data.TtlSecurityHops = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/update-source/interface/Loopback"); value.Exists() {
+ data.UpdateSourceLoopback = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ebgp-multihop"); value.Exists() {
+ data.EbgpMultihop = types.BoolValue(true)
+ } else {
+ data.EbgpMultihop = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ebgp-multihop/max-hop"); value.Exists() {
+ data.EbgpMultihopMaxHop = types.Int64Value(value.Int())
+ }
+}
+
+// End of section. //template:end fromBodyXML
+
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyDataXML
+
+func (data *BGPNeighborData) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/remote-as"); value.Exists() {
data.RemoteAs = types.StringValue(value.String())
}
- if value := res.Get(prefix + "description"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/description"); value.Exists() {
data.Description = types.StringValue(value.String())
}
- if value := res.Get(prefix + "shutdown"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/shutdown"); value.Exists() {
data.Shutdown = types.BoolValue(true)
} else {
data.Shutdown = types.BoolValue(false)
}
- if value := res.Get(prefix + "cluster-id"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/cluster-id"); value.Exists() {
data.ClusterId = types.StringValue(value.String())
}
- if value := res.Get(prefix + "version"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/version"); value.Exists() {
data.Version = types.Int64Value(value.Int())
}
- if value := res.Get(prefix + "disable-connected-check"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/disable-connected-check"); value.Exists() {
data.DisableConnectedCheck = types.BoolValue(true)
} else {
data.DisableConnectedCheck = types.BoolValue(false)
}
- if value := res.Get(prefix + "fall-over.default.enable"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/fall-over/default/enable"); value.Exists() {
data.FallOverDefaultEnable = types.BoolValue(true)
} else {
data.FallOverDefaultEnable = types.BoolValue(false)
}
- if value := res.Get(prefix + "fall-over.default.route-map"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/fall-over/default/route-map"); value.Exists() {
data.FallOverDefaultRouteMap = types.StringValue(value.String())
}
- if value := res.Get(prefix + "fall-over.bfd"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/fall-over/bfd"); value.Exists() {
data.FallOverBfd = types.BoolValue(true)
} else {
data.FallOverBfd = types.BoolValue(false)
}
- if value := res.Get(prefix + "fall-over.bfd.multi-hop"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/fall-over/bfd/multi-hop"); value.Exists() {
data.FallOverBfdMultiHop = types.BoolValue(true)
} else {
data.FallOverBfdMultiHop = types.BoolValue(false)
}
- if value := res.Get(prefix + "fall-over.bfd.single-hop"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/fall-over/bfd/single-hop"); value.Exists() {
data.FallOverBfdSingleHop = types.BoolValue(true)
} else {
data.FallOverBfdSingleHop = types.BoolValue(false)
}
- if value := res.Get(prefix + "fall-over.bfd.check-control-plane-failure"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/fall-over/bfd/check-control-plane-failure"); value.Exists() {
data.FallOverBfdCheckControlPlaneFailure = types.BoolValue(true)
} else {
data.FallOverBfdCheckControlPlaneFailure = types.BoolValue(false)
}
- if value := res.Get(prefix + "fall-over.bfd.strict-mode"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/fall-over/bfd/strict-mode"); value.Exists() {
data.FallOverBfdStrictMode = types.BoolValue(true)
} else {
data.FallOverBfdStrictMode = types.BoolValue(false)
}
- if value := res.Get(prefix + "fall-over.maximum-metric.route-map"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/fall-over/maximum-metric/route-map"); value.Exists() {
data.FallOverMaximumMetricRouteMap = types.StringValue(value.String())
}
- if value := res.Get(prefix + "local-as.as-no"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/local-as/as-no"); value.Exists() {
data.LocalAs = types.StringValue(value.String())
}
- if value := res.Get(prefix + "local-as.no-prepend"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/local-as/no-prepend"); value.Exists() {
data.LocalAsNoPrepend = types.BoolValue(true)
} else {
data.LocalAsNoPrepend = types.BoolValue(false)
}
- if value := res.Get(prefix + "local-as.replace-as"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/local-as/replace-as"); value.Exists() {
data.LocalAsReplaceAs = types.BoolValue(true)
} else {
data.LocalAsReplaceAs = types.BoolValue(false)
}
- if value := res.Get(prefix + "local-as.dual-as"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/local-as/dual-as"); value.Exists() {
data.LocalAsDualAs = types.BoolValue(true)
} else {
data.LocalAsDualAs = types.BoolValue(false)
}
- if value := res.Get(prefix + "log-neighbor-changes"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/log-neighbor-changes"); value.Exists() {
data.LogNeighborChanges = types.BoolValue(true)
} else {
data.LogNeighborChanges = types.BoolValue(false)
}
- if value := res.Get(prefix + "password.enctype"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/password/enctype"); value.Exists() {
data.PasswordType = types.Int64Value(value.Int())
}
- if value := res.Get(prefix + "password.text"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/password/text"); value.Exists() {
data.Password = types.StringValue(value.String())
}
- if value := res.Get(prefix + "peer-group.peer-group-name"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/peer-group/peer-group-name"); value.Exists() {
data.PeerGroup = types.StringValue(value.String())
}
- if value := res.Get(prefix + "timers.keepalive-interval"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/timers/keepalive-interval"); value.Exists() {
data.TimersKeepaliveInterval = types.Int64Value(value.Int())
}
- if value := res.Get(prefix + "timers.holdtime"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/timers/holdtime"); value.Exists() {
data.TimersHoldtime = types.Int64Value(value.Int())
}
- if value := res.Get(prefix + "timers.minimum-neighbor-hold"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/timers/minimum-neighbor-hold"); value.Exists() {
data.TimersMinimumNeighborHold = types.Int64Value(value.Int())
}
- if value := res.Get(prefix + "ttl-security.hops"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ttl-security/hops"); value.Exists() {
data.TtlSecurityHops = types.Int64Value(value.Int())
}
- if value := res.Get(prefix + "update-source.interface.Loopback"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/update-source/interface/Loopback"); value.Exists() {
data.UpdateSourceLoopback = types.Int64Value(value.Int())
}
- if value := res.Get(prefix + "ebgp-multihop"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ebgp-multihop"); value.Exists() {
data.EbgpMultihop = types.BoolValue(true)
} else {
data.EbgpMultihop = types.BoolValue(false)
}
- if value := res.Get(prefix + "ebgp-multihop.max-hop"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ebgp-multihop/max-hop"); value.Exists() {
data.EbgpMultihopMaxHop = types.Int64Value(value.Int())
}
}
-// End of section. //template:end fromBodyData
+// End of section. //template:end fromBodyDataXML
// Section below is generated&owned by "gen/generator.go". //template:begin getDeletedItems
@@ -804,6 +1414,100 @@ func (data *BGPNeighbor) getDeletedItems(ctx context.Context, state BGPNeighbor)
// End of section. //template:end getDeletedItems
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletedItemsXML
+
+func (data *BGPNeighbor) addDeletedItemsXML(ctx context.Context, state BGPNeighbor, body string) string {
+ b := netconf.NewBody(body)
+ if !state.Description.IsNull() && data.Description.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/description")
+ }
+ if !state.Shutdown.IsNull() && data.Shutdown.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/shutdown")
+ }
+ if !state.ClusterId.IsNull() && data.ClusterId.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/cluster-id")
+ }
+ if !state.Version.IsNull() && data.Version.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/version")
+ }
+ if !state.DisableConnectedCheck.IsNull() && data.DisableConnectedCheck.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/disable-connected-check")
+ }
+ if !state.FallOverDefaultEnable.IsNull() && data.FallOverDefaultEnable.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/fall-over/default/enable")
+ }
+ if !state.FallOverDefaultRouteMap.IsNull() && data.FallOverDefaultRouteMap.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/fall-over/default/route-map")
+ }
+ if !state.FallOverBfd.IsNull() && data.FallOverBfd.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/fall-over/bfd")
+ }
+ if !state.FallOverBfdMultiHop.IsNull() && data.FallOverBfdMultiHop.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/fall-over/bfd/multi-hop")
+ }
+ if !state.FallOverBfdSingleHop.IsNull() && data.FallOverBfdSingleHop.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/fall-over/bfd/single-hop")
+ }
+ if !state.FallOverBfdCheckControlPlaneFailure.IsNull() && data.FallOverBfdCheckControlPlaneFailure.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/fall-over/bfd/check-control-plane-failure")
+ }
+ if !state.FallOverBfdStrictMode.IsNull() && data.FallOverBfdStrictMode.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/fall-over/bfd/strict-mode")
+ }
+ if !state.FallOverMaximumMetricRouteMap.IsNull() && data.FallOverMaximumMetricRouteMap.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/fall-over/maximum-metric/route-map")
+ }
+ if !state.LocalAs.IsNull() && data.LocalAs.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/local-as/as-no")
+ }
+ if !state.LocalAsNoPrepend.IsNull() && data.LocalAsNoPrepend.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/local-as/no-prepend")
+ }
+ if !state.LocalAsReplaceAs.IsNull() && data.LocalAsReplaceAs.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/local-as/replace-as")
+ }
+ if !state.LocalAsDualAs.IsNull() && data.LocalAsDualAs.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/local-as/dual-as")
+ }
+ if !state.LogNeighborChanges.IsNull() && data.LogNeighborChanges.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/log-neighbor-changes")
+ }
+ if !state.PasswordType.IsNull() && data.PasswordType.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/password/enctype")
+ }
+ if !state.Password.IsNull() && data.Password.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/password/text")
+ }
+ if !state.PeerGroup.IsNull() && data.PeerGroup.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/peer-group/peer-group-name")
+ }
+ if !state.TimersKeepaliveInterval.IsNull() && data.TimersKeepaliveInterval.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/timers/keepalive-interval")
+ }
+ if !state.TimersHoldtime.IsNull() && data.TimersHoldtime.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/timers/holdtime")
+ }
+ if !state.TimersMinimumNeighborHold.IsNull() && data.TimersMinimumNeighborHold.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/timers/minimum-neighbor-hold")
+ }
+ if !state.TtlSecurityHops.IsNull() && data.TtlSecurityHops.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ttl-security/hops")
+ }
+ if !state.UpdateSourceLoopback.IsNull() && data.UpdateSourceLoopback.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/update-source/interface/Loopback")
+ }
+ if !state.EbgpMultihop.IsNull() && data.EbgpMultihop.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ebgp-multihop")
+ }
+ if !state.EbgpMultihopMaxHop.IsNull() && data.EbgpMultihopMaxHop.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ebgp-multihop/max-hop")
+ }
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletedItemsXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin getEmptyLeafsDelete
func (data *BGPNeighbor) getEmptyLeafsDelete(ctx context.Context) []string {
@@ -946,3 +1650,97 @@ func (data *BGPNeighbor) getDeletePaths(ctx context.Context) []string {
}
// End of section. //template:end getDeletePaths
+
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletePathsXML
+
+func (data *BGPNeighbor) addDeletePathsXML(ctx context.Context, body string) string {
+ b := netconf.NewBody(body)
+ if !data.Description.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/description")
+ }
+ if !data.Shutdown.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/shutdown")
+ }
+ if !data.ClusterId.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/cluster-id")
+ }
+ if !data.Version.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/version")
+ }
+ if !data.DisableConnectedCheck.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/disable-connected-check")
+ }
+ if !data.FallOverDefaultEnable.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/fall-over/default/enable")
+ }
+ if !data.FallOverDefaultRouteMap.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/fall-over/default/route-map")
+ }
+ if !data.FallOverBfd.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/fall-over/bfd")
+ }
+ if !data.FallOverBfdMultiHop.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/fall-over/bfd/multi-hop")
+ }
+ if !data.FallOverBfdSingleHop.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/fall-over/bfd/single-hop")
+ }
+ if !data.FallOverBfdCheckControlPlaneFailure.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/fall-over/bfd/check-control-plane-failure")
+ }
+ if !data.FallOverBfdStrictMode.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/fall-over/bfd/strict-mode")
+ }
+ if !data.FallOverMaximumMetricRouteMap.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/fall-over/maximum-metric/route-map")
+ }
+ if !data.LocalAs.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/local-as/as-no")
+ }
+ if !data.LocalAsNoPrepend.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/local-as/no-prepend")
+ }
+ if !data.LocalAsReplaceAs.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/local-as/replace-as")
+ }
+ if !data.LocalAsDualAs.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/local-as/dual-as")
+ }
+ if !data.LogNeighborChanges.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/log-neighbor-changes")
+ }
+ if !data.PasswordType.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/password/enctype")
+ }
+ if !data.Password.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/password/text")
+ }
+ if !data.PeerGroup.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/peer-group/peer-group-name")
+ }
+ if !data.TimersKeepaliveInterval.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/timers/keepalive-interval")
+ }
+ if !data.TimersHoldtime.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/timers/holdtime")
+ }
+ if !data.TimersMinimumNeighborHold.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/timers/minimum-neighbor-hold")
+ }
+ if !data.TtlSecurityHops.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ttl-security/hops")
+ }
+ if !data.UpdateSourceLoopback.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/update-source/interface/Loopback")
+ }
+ if !data.EbgpMultihop.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ebgp-multihop")
+ }
+ if !data.EbgpMultihopMaxHop.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ebgp-multihop/max-hop")
+ }
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletePathsXML
diff --git a/internal/provider/model_iosxe_cdp.go b/internal/provider/model_iosxe_cdp.go
index 0f1aa8c9..a7b961a2 100644
--- a/internal/provider/model_iosxe_cdp.go
+++ b/internal/provider/model_iosxe_cdp.go
@@ -30,6 +30,9 @@ import (
"github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/types"
+ "github.com/hashicorp/terraform-plugin-log/tflog"
+ "github.com/netascode/go-netconf"
+ "github.com/netascode/xmldot"
"github.com/tidwall/gjson"
"github.com/tidwall/sjson"
)
@@ -88,6 +91,17 @@ func (data CDP) getPathShort() string {
return matches[1]
}
+// getXPath returns the XPath for NETCONF operations
+func (data CDP) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/cdp"
+ return path
+}
+
+func (data CDPData) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/cdp"
+ return path
+}
+
// End of section. //template:end getPath
// Section below is generated&owned by "gen/generator.go". //template:begin toBody
@@ -144,6 +158,75 @@ func (data CDP) toBody(ctx context.Context) string {
// End of section. //template:end toBody
+// Section below is generated&owned by "gen/generator.go". //template:begin toBodyXML
+
+func (data CDP) toBodyXML(ctx context.Context) string {
+ body := netconf.Body{}
+ if !data.Holdtime.IsNull() && !data.Holdtime.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-cdp:holdtime", strconv.FormatInt(data.Holdtime.ValueInt64(), 10))
+ }
+ if !data.Timer.IsNull() && !data.Timer.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-cdp:timer", strconv.FormatInt(data.Timer.ValueInt64(), 10))
+ }
+ if !data.Run.IsNull() && !data.Run.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-cdp:run-enable", data.Run.ValueBool())
+ }
+ if !data.FilterTlvList.IsNull() && !data.FilterTlvList.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-cdp:filter-tlv-list", data.FilterTlvList.ValueString())
+ }
+ if len(data.TlvLists) > 0 {
+ for _, item := range data.TlvLists {
+ cBody := netconf.Body{}
+ if !item.Name.IsNull() && !item.Name.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "name", item.Name.ValueString())
+ }
+ if !item.VtpMgmtDomain.IsNull() && !item.VtpMgmtDomain.IsUnknown() {
+ if item.VtpMgmtDomain.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "vtp-mgmt-domain", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "vtp-mgmt-domain")
+ }
+ }
+ if !item.Cos.IsNull() && !item.Cos.IsUnknown() {
+ if item.Cos.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "cos", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "cos")
+ }
+ }
+ if !item.Duplex.IsNull() && !item.Duplex.IsUnknown() {
+ if item.Duplex.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "duplex", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "duplex")
+ }
+ }
+ if !item.Trust.IsNull() && !item.Trust.IsUnknown() {
+ if item.Trust.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "trust", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "trust")
+ }
+ }
+ if !item.Version.IsNull() && !item.Version.IsUnknown() {
+ if item.Version.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "version", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "version")
+ }
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-cdp:tlv-list", cBody.Res())
+ }
+ }
+ bodyString, err := body.String()
+ if err != nil {
+ tflog.Error(ctx, fmt.Sprintf("Error converting body to string: %s", err))
+ }
+ return bodyString
+}
+
+// End of section. //template:end toBodyXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBody
func (data *CDP) updateFromBody(ctx context.Context, res gjson.Result) {
@@ -251,6 +334,109 @@ func (data *CDP) updateFromBody(ctx context.Context, res gjson.Result) {
// End of section. //template:end updateFromBody
+// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBodyXML
+
+func (data *CDP) updateFromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-cdp:holdtime"); value.Exists() && !data.Holdtime.IsNull() {
+ data.Holdtime = types.Int64Value(value.Int())
+ } else {
+ data.Holdtime = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-cdp:timer"); value.Exists() && !data.Timer.IsNull() {
+ data.Timer = types.Int64Value(value.Int())
+ } else {
+ data.Timer = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-cdp:run-enable"); !data.Run.IsNull() {
+ if value.Exists() {
+ data.Run = types.BoolValue(value.Bool())
+ }
+ } else {
+ data.Run = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-cdp:filter-tlv-list"); value.Exists() && !data.FilterTlvList.IsNull() {
+ data.FilterTlvList = types.StringValue(value.String())
+ } else {
+ data.FilterTlvList = types.StringNull()
+ }
+ for i := range data.TlvLists {
+ keys := [...]string{"name"}
+ keyValues := [...]string{data.TlvLists[i].Name.ValueString()}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-cdp:tlv-list").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, "name"); value.Exists() && !data.TlvLists[i].Name.IsNull() {
+ data.TlvLists[i].Name = types.StringValue(value.String())
+ } else {
+ data.TlvLists[i].Name = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "vtp-mgmt-domain"); !data.TlvLists[i].VtpMgmtDomain.IsNull() {
+ if value.Exists() {
+ data.TlvLists[i].VtpMgmtDomain = types.BoolValue(true)
+ } else {
+ data.TlvLists[i].VtpMgmtDomain = types.BoolValue(false)
+ }
+ } else {
+ data.TlvLists[i].VtpMgmtDomain = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "cos"); !data.TlvLists[i].Cos.IsNull() {
+ if value.Exists() {
+ data.TlvLists[i].Cos = types.BoolValue(true)
+ } else {
+ data.TlvLists[i].Cos = types.BoolValue(false)
+ }
+ } else {
+ data.TlvLists[i].Cos = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "duplex"); !data.TlvLists[i].Duplex.IsNull() {
+ if value.Exists() {
+ data.TlvLists[i].Duplex = types.BoolValue(true)
+ } else {
+ data.TlvLists[i].Duplex = types.BoolValue(false)
+ }
+ } else {
+ data.TlvLists[i].Duplex = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "trust"); !data.TlvLists[i].Trust.IsNull() {
+ if value.Exists() {
+ data.TlvLists[i].Trust = types.BoolValue(true)
+ } else {
+ data.TlvLists[i].Trust = types.BoolValue(false)
+ }
+ } else {
+ data.TlvLists[i].Trust = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "version"); !data.TlvLists[i].Version.IsNull() {
+ if value.Exists() {
+ data.TlvLists[i].Version = types.BoolValue(true)
+ } else {
+ data.TlvLists[i].Version = types.BoolValue(false)
+ }
+ } else {
+ data.TlvLists[i].Version = types.BoolNull()
+ }
+ }
+}
+
+// End of section. //template:end updateFromBodyXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin fromBody
func (data *CDP) fromBody(ctx context.Context, res gjson.Result) {
@@ -373,6 +559,120 @@ func (data *CDPData) fromBody(ctx context.Context, res gjson.Result) {
// End of section. //template:end fromBodyData
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyXML
+
+func (data *CDP) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-cdp:holdtime"); value.Exists() {
+ data.Holdtime = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-cdp:timer"); value.Exists() {
+ data.Timer = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-cdp:run-enable"); value.Exists() {
+ data.Run = types.BoolValue(value.Bool())
+ } else {
+ data.Run = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-cdp:filter-tlv-list"); value.Exists() {
+ data.FilterTlvList = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-cdp:tlv-list"); value.Exists() {
+ data.TlvLists = make([]CDPTlvLists, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := CDPTlvLists{}
+ if cValue := helpers.GetFromXPath(v, "name"); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "vtp-mgmt-domain"); cValue.Exists() {
+ item.VtpMgmtDomain = types.BoolValue(true)
+ } else {
+ item.VtpMgmtDomain = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "cos"); cValue.Exists() {
+ item.Cos = types.BoolValue(true)
+ } else {
+ item.Cos = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "duplex"); cValue.Exists() {
+ item.Duplex = types.BoolValue(true)
+ } else {
+ item.Duplex = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "trust"); cValue.Exists() {
+ item.Trust = types.BoolValue(true)
+ } else {
+ item.Trust = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "version"); cValue.Exists() {
+ item.Version = types.BoolValue(true)
+ } else {
+ item.Version = types.BoolValue(false)
+ }
+ data.TlvLists = append(data.TlvLists, item)
+ return true
+ })
+ }
+}
+
+// End of section. //template:end fromBodyXML
+
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyDataXML
+
+func (data *CDPData) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-cdp:holdtime"); value.Exists() {
+ data.Holdtime = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-cdp:timer"); value.Exists() {
+ data.Timer = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-cdp:run-enable"); value.Exists() {
+ data.Run = types.BoolValue(value.Bool())
+ } else {
+ data.Run = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-cdp:filter-tlv-list"); value.Exists() {
+ data.FilterTlvList = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-cdp:tlv-list"); value.Exists() {
+ data.TlvLists = make([]CDPTlvLists, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := CDPTlvLists{}
+ if cValue := helpers.GetFromXPath(v, "name"); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "vtp-mgmt-domain"); cValue.Exists() {
+ item.VtpMgmtDomain = types.BoolValue(true)
+ } else {
+ item.VtpMgmtDomain = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "cos"); cValue.Exists() {
+ item.Cos = types.BoolValue(true)
+ } else {
+ item.Cos = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "duplex"); cValue.Exists() {
+ item.Duplex = types.BoolValue(true)
+ } else {
+ item.Duplex = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "trust"); cValue.Exists() {
+ item.Trust = types.BoolValue(true)
+ } else {
+ item.Trust = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "version"); cValue.Exists() {
+ item.Version = types.BoolValue(true)
+ } else {
+ item.Version = types.BoolValue(false)
+ }
+ data.TlvLists = append(data.TlvLists, item)
+ return true
+ })
+ }
+}
+
+// End of section. //template:end fromBodyDataXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin getDeletedItems
func (data *CDP) getDeletedItems(ctx context.Context, state CDP) []string {
@@ -435,6 +735,73 @@ func (data *CDP) getDeletedItems(ctx context.Context, state CDP) []string {
// End of section. //template:end getDeletedItems
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletedItemsXML
+
+func (data *CDP) addDeletedItemsXML(ctx context.Context, state CDP, body string) string {
+ b := netconf.NewBody(body)
+ if !state.Holdtime.IsNull() && data.Holdtime.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-cdp:holdtime")
+ }
+ if !state.Timer.IsNull() && data.Timer.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-cdp:timer")
+ }
+ if !state.Run.IsNull() && data.Run.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-cdp:run-enable")
+ }
+ if !state.FilterTlvList.IsNull() && data.FilterTlvList.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-cdp:filter-tlv-list")
+ }
+ for i := range state.TlvLists {
+ stateKeys := [...]string{"name"}
+ stateKeyValues := [...]string{state.TlvLists[i].Name.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.TlvLists[i].Name.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.TlvLists {
+ found = true
+ if state.TlvLists[i].Name.ValueString() != data.TlvLists[j].Name.ValueString() {
+ found = false
+ }
+ if found {
+ if !state.TlvLists[i].VtpMgmtDomain.IsNull() && data.TlvLists[j].VtpMgmtDomain.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-cdp:tlv-list%v/vtp-mgmt-domain", predicates))
+ }
+ if !state.TlvLists[i].Cos.IsNull() && data.TlvLists[j].Cos.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-cdp:tlv-list%v/cos", predicates))
+ }
+ if !state.TlvLists[i].Duplex.IsNull() && data.TlvLists[j].Duplex.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-cdp:tlv-list%v/duplex", predicates))
+ }
+ if !state.TlvLists[i].Trust.IsNull() && data.TlvLists[j].Trust.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-cdp:tlv-list%v/trust", predicates))
+ }
+ if !state.TlvLists[i].Version.IsNull() && data.TlvLists[j].Version.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-cdp:tlv-list%v/version", predicates))
+ }
+ break
+ }
+ }
+ if !found {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-cdp:tlv-list%v", predicates))
+ }
+ }
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletedItemsXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin getEmptyLeafsDelete
func (data *CDP) getEmptyLeafsDelete(ctx context.Context) []string {
@@ -490,3 +857,35 @@ func (data *CDP) getDeletePaths(ctx context.Context) []string {
}
// End of section. //template:end getDeletePaths
+
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletePathsXML
+
+func (data *CDP) addDeletePathsXML(ctx context.Context, body string) string {
+ b := netconf.NewBody(body)
+ if !data.Holdtime.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-cdp:holdtime")
+ }
+ if !data.Timer.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-cdp:timer")
+ }
+ if !data.Run.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-cdp:run-enable")
+ }
+ if !data.FilterTlvList.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-cdp:filter-tlv-list")
+ }
+ for i := range data.TlvLists {
+ keys := [...]string{"name"}
+ keyValues := [...]string{data.TlvLists[i].Name.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/Cisco-IOS-XE-cdp:tlv-list%v", predicates))
+ }
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletePathsXML
diff --git a/internal/provider/model_iosxe_class_map.go b/internal/provider/model_iosxe_class_map.go
index e60ef7c5..e490f751 100644
--- a/internal/provider/model_iosxe_class_map.go
+++ b/internal/provider/model_iosxe_class_map.go
@@ -31,6 +31,9 @@ import (
"github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/types"
+ "github.com/hashicorp/terraform-plugin-log/tflog"
+ "github.com/netascode/go-netconf"
+ "github.com/netascode/xmldot"
"github.com/tidwall/gjson"
"github.com/tidwall/sjson"
)
@@ -114,6 +117,19 @@ func (data ClassMap) getPathShort() string {
return matches[1]
}
+// getXPath returns the XPath for NETCONF operations
+func (data ClassMap) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/policy/Cisco-IOS-XE-policy:class-map[name=%v]"
+ path = fmt.Sprintf(path, fmt.Sprintf("%v", data.Name.ValueString()))
+ return path
+}
+
+func (data ClassMapData) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/policy/Cisco-IOS-XE-policy:class-map[name=%v]"
+ path = fmt.Sprintf(path, fmt.Sprintf("%v", data.Name.ValueString()))
+ return path
+}
+
// End of section. //template:end getPath
// Section below is generated&owned by "gen/generator.go". //template:begin toBody
@@ -220,6 +236,145 @@ func (data ClassMap) toBody(ctx context.Context) string {
// End of section. //template:end toBody
+// Section below is generated&owned by "gen/generator.go". //template:begin toBodyXML
+
+func (data ClassMap) toBodyXML(ctx context.Context) string {
+ body := netconf.Body{}
+ if !data.Name.IsNull() && !data.Name.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/name", data.Name.ValueString())
+ }
+ if !data.Type.IsNull() && !data.Type.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/type", data.Type.ValueString())
+ }
+ if !data.Subscriber.IsNull() && !data.Subscriber.IsUnknown() {
+ if data.Subscriber.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/subscriber", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/subscriber")
+ }
+ }
+ if !data.Prematch.IsNull() && !data.Prematch.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/prematch", data.Prematch.ValueString())
+ }
+ if !data.MatchAuthorizationStatusAuthorized.IsNull() && !data.MatchAuthorizationStatusAuthorized.IsUnknown() {
+ if data.MatchAuthorizationStatusAuthorized.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/match/authorization-status/authorized", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/match/authorization-status/authorized")
+ }
+ }
+ if !data.MatchResultTypeAaaTimeout.IsNull() && !data.MatchResultTypeAaaTimeout.IsUnknown() {
+ if data.MatchResultTypeAaaTimeout.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/match/result-type/aaa-timeout", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/match/result-type/aaa-timeout")
+ }
+ }
+ if !data.MatchAuthorizationStatusUnauthorized.IsNull() && !data.MatchAuthorizationStatusUnauthorized.IsUnknown() {
+ if data.MatchAuthorizationStatusUnauthorized.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/match/authorization-status/unauthorized", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/match/authorization-status/unauthorized")
+ }
+ }
+ if len(data.MatchActivatedServiceTemplates) > 0 {
+ for _, item := range data.MatchActivatedServiceTemplates {
+ cBody := netconf.Body{}
+ if !item.ServiceName.IsNull() && !item.ServiceName.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "service-name", item.ServiceName.ValueString())
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/match/activated-service-template", cBody.Res())
+ }
+ }
+ if !data.MatchAuthorizingMethodPriorityGreaterThan.IsNull() && !data.MatchAuthorizingMethodPriorityGreaterThan.IsUnknown() {
+ var values []int
+ data.MatchAuthorizingMethodPriorityGreaterThan.ElementsAs(ctx, &values, false)
+ for _, v := range values {
+ body = helpers.AppendFromXPath(body, data.getXPath()+"/match/authorizing-method-priority/greater-than", v)
+ }
+ }
+ if !data.MatchMethodDot1x.IsNull() && !data.MatchMethodDot1x.IsUnknown() {
+ if data.MatchMethodDot1x.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/match/method/dot1x", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/match/method/dot1x")
+ }
+ }
+ if !data.MatchResultTypeMethodDot1xAuthoritative.IsNull() && !data.MatchResultTypeMethodDot1xAuthoritative.IsUnknown() {
+ if data.MatchResultTypeMethodDot1xAuthoritative.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/match/result-type/method/dot1x/authoritative", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/match/result-type/method/dot1x/authoritative")
+ }
+ }
+ if !data.MatchResultTypeMethodDot1xAgentNotFound.IsNull() && !data.MatchResultTypeMethodDot1xAgentNotFound.IsUnknown() {
+ if data.MatchResultTypeMethodDot1xAgentNotFound.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/match/result-type/method/dot1x/agent-not-found", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/match/result-type/method/dot1x/agent-not-found")
+ }
+ }
+ if !data.MatchResultTypeMethodDot1xMethodTimeout.IsNull() && !data.MatchResultTypeMethodDot1xMethodTimeout.IsUnknown() {
+ if data.MatchResultTypeMethodDot1xMethodTimeout.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/match/result-type/method/dot1x/method-timeout", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/match/result-type/method/dot1x/method-timeout")
+ }
+ }
+ if !data.MatchMethodMab.IsNull() && !data.MatchMethodMab.IsUnknown() {
+ if data.MatchMethodMab.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/match/method/mab", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/match/method/mab")
+ }
+ }
+ if !data.MatchResultTypeMethodMabAuthoritative.IsNull() && !data.MatchResultTypeMethodMabAuthoritative.IsUnknown() {
+ if data.MatchResultTypeMethodMabAuthoritative.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/match/result-type/method/mab/authoritative", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/match/result-type/method/mab/authoritative")
+ }
+ }
+ if !data.MatchDscp.IsNull() && !data.MatchDscp.IsUnknown() {
+ var values []string
+ data.MatchDscp.ElementsAs(ctx, &values, false)
+ for _, v := range values {
+ body = helpers.AppendFromXPath(body, data.getXPath()+"/match/dscp", v)
+ }
+ }
+ if !data.Description.IsNull() && !data.Description.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/description", data.Description.ValueString())
+ }
+ if !data.MatchAccessGroupName.IsNull() && !data.MatchAccessGroupName.IsUnknown() {
+ var values []string
+ data.MatchAccessGroupName.ElementsAs(ctx, &values, false)
+ for _, v := range values {
+ body = helpers.AppendFromXPath(body, data.getXPath()+"/match/access-group/name", v)
+ }
+ }
+ if !data.MatchIpDscp.IsNull() && !data.MatchIpDscp.IsUnknown() {
+ var values []string
+ data.MatchIpDscp.ElementsAs(ctx, &values, false)
+ for _, v := range values {
+ body = helpers.AppendFromXPath(body, data.getXPath()+"/match/ip/dscp", v)
+ }
+ }
+ if !data.MatchIpPrecedence.IsNull() && !data.MatchIpPrecedence.IsUnknown() {
+ var values []string
+ data.MatchIpPrecedence.ElementsAs(ctx, &values, false)
+ for _, v := range values {
+ body = helpers.AppendFromXPath(body, data.getXPath()+"/match/ip/precedence", v)
+ }
+ }
+ bodyString, err := body.String()
+ if err != nil {
+ tflog.Error(ctx, fmt.Sprintf("Error converting body to string: %s", err))
+ }
+ return bodyString
+}
+
+// End of section. //template:end toBodyXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBody
func (data *ClassMap) updateFromBody(ctx context.Context, res gjson.Result) {
@@ -395,6 +550,177 @@ func (data *ClassMap) updateFromBody(ctx context.Context, res gjson.Result) {
// End of section. //template:end updateFromBody
+// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBodyXML
+
+func (data *ClassMap) updateFromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/name"); value.Exists() && !data.Name.IsNull() {
+ data.Name = types.StringValue(value.String())
+ } else {
+ data.Name = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/type"); value.Exists() && !data.Type.IsNull() {
+ data.Type = types.StringValue(value.String())
+ } else {
+ data.Type = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/subscriber"); !data.Subscriber.IsNull() {
+ if value.Exists() {
+ data.Subscriber = types.BoolValue(true)
+ } else {
+ data.Subscriber = types.BoolValue(false)
+ }
+ } else {
+ data.Subscriber = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/prematch"); value.Exists() && !data.Prematch.IsNull() {
+ data.Prematch = types.StringValue(value.String())
+ } else {
+ data.Prematch = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/match/authorization-status/authorized"); !data.MatchAuthorizationStatusAuthorized.IsNull() {
+ if value.Exists() {
+ data.MatchAuthorizationStatusAuthorized = types.BoolValue(true)
+ } else {
+ data.MatchAuthorizationStatusAuthorized = types.BoolValue(false)
+ }
+ } else {
+ data.MatchAuthorizationStatusAuthorized = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/match/result-type/aaa-timeout"); !data.MatchResultTypeAaaTimeout.IsNull() {
+ if value.Exists() {
+ data.MatchResultTypeAaaTimeout = types.BoolValue(true)
+ } else {
+ data.MatchResultTypeAaaTimeout = types.BoolValue(false)
+ }
+ } else {
+ data.MatchResultTypeAaaTimeout = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/match/authorization-status/unauthorized"); !data.MatchAuthorizationStatusUnauthorized.IsNull() {
+ if value.Exists() {
+ data.MatchAuthorizationStatusUnauthorized = types.BoolValue(true)
+ } else {
+ data.MatchAuthorizationStatusUnauthorized = types.BoolValue(false)
+ }
+ } else {
+ data.MatchAuthorizationStatusUnauthorized = types.BoolNull()
+ }
+ for i := range data.MatchActivatedServiceTemplates {
+ keys := [...]string{"service-name"}
+ keyValues := [...]string{data.MatchActivatedServiceTemplates[i].ServiceName.ValueString()}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/match/activated-service-template").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, "service-name"); value.Exists() && !data.MatchActivatedServiceTemplates[i].ServiceName.IsNull() {
+ data.MatchActivatedServiceTemplates[i].ServiceName = types.StringValue(value.String())
+ } else {
+ data.MatchActivatedServiceTemplates[i].ServiceName = types.StringNull()
+ }
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/match/authorizing-method-priority/greater-than"); value.Exists() && !data.MatchAuthorizingMethodPriorityGreaterThan.IsNull() {
+ data.MatchAuthorizingMethodPriorityGreaterThan = helpers.GetInt64ListXML(value.Array())
+ } else {
+ data.MatchAuthorizingMethodPriorityGreaterThan = types.ListNull(types.Int64Type)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/match/method/dot1x"); !data.MatchMethodDot1x.IsNull() {
+ if value.Exists() {
+ data.MatchMethodDot1x = types.BoolValue(true)
+ } else {
+ data.MatchMethodDot1x = types.BoolValue(false)
+ }
+ } else {
+ data.MatchMethodDot1x = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/match/result-type/method/dot1x/authoritative"); !data.MatchResultTypeMethodDot1xAuthoritative.IsNull() {
+ if value.Exists() {
+ data.MatchResultTypeMethodDot1xAuthoritative = types.BoolValue(true)
+ } else {
+ data.MatchResultTypeMethodDot1xAuthoritative = types.BoolValue(false)
+ }
+ } else {
+ data.MatchResultTypeMethodDot1xAuthoritative = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/match/result-type/method/dot1x/agent-not-found"); !data.MatchResultTypeMethodDot1xAgentNotFound.IsNull() {
+ if value.Exists() {
+ data.MatchResultTypeMethodDot1xAgentNotFound = types.BoolValue(true)
+ } else {
+ data.MatchResultTypeMethodDot1xAgentNotFound = types.BoolValue(false)
+ }
+ } else {
+ data.MatchResultTypeMethodDot1xAgentNotFound = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/match/result-type/method/dot1x/method-timeout"); !data.MatchResultTypeMethodDot1xMethodTimeout.IsNull() {
+ if value.Exists() {
+ data.MatchResultTypeMethodDot1xMethodTimeout = types.BoolValue(true)
+ } else {
+ data.MatchResultTypeMethodDot1xMethodTimeout = types.BoolValue(false)
+ }
+ } else {
+ data.MatchResultTypeMethodDot1xMethodTimeout = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/match/method/mab"); !data.MatchMethodMab.IsNull() {
+ if value.Exists() {
+ data.MatchMethodMab = types.BoolValue(true)
+ } else {
+ data.MatchMethodMab = types.BoolValue(false)
+ }
+ } else {
+ data.MatchMethodMab = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/match/result-type/method/mab/authoritative"); !data.MatchResultTypeMethodMabAuthoritative.IsNull() {
+ if value.Exists() {
+ data.MatchResultTypeMethodMabAuthoritative = types.BoolValue(true)
+ } else {
+ data.MatchResultTypeMethodMabAuthoritative = types.BoolValue(false)
+ }
+ } else {
+ data.MatchResultTypeMethodMabAuthoritative = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/match/dscp"); value.Exists() && !data.MatchDscp.IsNull() {
+ data.MatchDscp = helpers.GetStringListXML(value.Array())
+ } else {
+ data.MatchDscp = types.ListNull(types.StringType)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/description"); value.Exists() && !data.Description.IsNull() {
+ data.Description = types.StringValue(value.String())
+ } else {
+ data.Description = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/match/access-group/name"); value.Exists() && !data.MatchAccessGroupName.IsNull() {
+ data.MatchAccessGroupName = helpers.GetStringListXML(value.Array())
+ } else {
+ data.MatchAccessGroupName = types.ListNull(types.StringType)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/match/ip/dscp"); value.Exists() && !data.MatchIpDscp.IsNull() {
+ data.MatchIpDscp = helpers.GetStringListXML(value.Array())
+ } else {
+ data.MatchIpDscp = types.ListNull(types.StringType)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/match/ip/precedence"); value.Exists() && !data.MatchIpPrecedence.IsNull() {
+ data.MatchIpPrecedence = helpers.GetStringListXML(value.Array())
+ } else {
+ data.MatchIpPrecedence = types.ListNull(types.StringType)
+ }
+}
+
+// End of section. //template:end updateFromBodyXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin fromBody
func (data *ClassMap) fromBody(ctx context.Context, res gjson.Result) {
@@ -607,26 +933,230 @@ func (data *ClassMapData) fromBody(ctx context.Context, res gjson.Result) {
// End of section. //template:end fromBodyData
-// Section below is generated&owned by "gen/generator.go". //template:begin getDeletedItems
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyXML
-func (data *ClassMap) getDeletedItems(ctx context.Context, state ClassMap) []string {
- deletedItems := make([]string, 0)
- if !state.MatchIpPrecedence.IsNull() {
- if data.MatchIpPrecedence.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/match/ip/precedence", state.getPath()))
- } else {
- var dataValues, stateValues []string
- data.MatchIpPrecedence.ElementsAs(ctx, &dataValues, false)
- state.MatchIpPrecedence.ElementsAs(ctx, &stateValues, false)
- for _, v := range stateValues {
- found := false
- for _, vv := range dataValues {
- if v == vv {
- found = true
- break
- }
- }
- if !found {
+func (data *ClassMap) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/type"); value.Exists() {
+ data.Type = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/subscriber"); value.Exists() {
+ data.Subscriber = types.BoolValue(true)
+ } else {
+ data.Subscriber = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/prematch"); value.Exists() {
+ data.Prematch = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/match/authorization-status/authorized"); value.Exists() {
+ data.MatchAuthorizationStatusAuthorized = types.BoolValue(true)
+ } else {
+ data.MatchAuthorizationStatusAuthorized = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/match/result-type/aaa-timeout"); value.Exists() {
+ data.MatchResultTypeAaaTimeout = types.BoolValue(true)
+ } else {
+ data.MatchResultTypeAaaTimeout = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/match/authorization-status/unauthorized"); value.Exists() {
+ data.MatchAuthorizationStatusUnauthorized = types.BoolValue(true)
+ } else {
+ data.MatchAuthorizationStatusUnauthorized = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/match/activated-service-template"); value.Exists() {
+ data.MatchActivatedServiceTemplates = make([]ClassMapMatchActivatedServiceTemplates, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := ClassMapMatchActivatedServiceTemplates{}
+ if cValue := helpers.GetFromXPath(v, "service-name"); cValue.Exists() {
+ item.ServiceName = types.StringValue(cValue.String())
+ }
+ data.MatchActivatedServiceTemplates = append(data.MatchActivatedServiceTemplates, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/match/authorizing-method-priority/greater-than"); value.Exists() {
+ data.MatchAuthorizingMethodPriorityGreaterThan = helpers.GetInt64ListXML(value.Array())
+ } else {
+ data.MatchAuthorizingMethodPriorityGreaterThan = types.ListNull(types.Int64Type)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/match/method/dot1x"); value.Exists() {
+ data.MatchMethodDot1x = types.BoolValue(true)
+ } else {
+ data.MatchMethodDot1x = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/match/result-type/method/dot1x/authoritative"); value.Exists() {
+ data.MatchResultTypeMethodDot1xAuthoritative = types.BoolValue(true)
+ } else {
+ data.MatchResultTypeMethodDot1xAuthoritative = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/match/result-type/method/dot1x/agent-not-found"); value.Exists() {
+ data.MatchResultTypeMethodDot1xAgentNotFound = types.BoolValue(true)
+ } else {
+ data.MatchResultTypeMethodDot1xAgentNotFound = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/match/result-type/method/dot1x/method-timeout"); value.Exists() {
+ data.MatchResultTypeMethodDot1xMethodTimeout = types.BoolValue(true)
+ } else {
+ data.MatchResultTypeMethodDot1xMethodTimeout = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/match/method/mab"); value.Exists() {
+ data.MatchMethodMab = types.BoolValue(true)
+ } else {
+ data.MatchMethodMab = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/match/result-type/method/mab/authoritative"); value.Exists() {
+ data.MatchResultTypeMethodMabAuthoritative = types.BoolValue(true)
+ } else {
+ data.MatchResultTypeMethodMabAuthoritative = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/match/dscp"); value.Exists() {
+ data.MatchDscp = helpers.GetStringListXML(value.Array())
+ } else {
+ data.MatchDscp = types.ListNull(types.StringType)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/description"); value.Exists() {
+ data.Description = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/match/access-group/name"); value.Exists() {
+ data.MatchAccessGroupName = helpers.GetStringListXML(value.Array())
+ } else {
+ data.MatchAccessGroupName = types.ListNull(types.StringType)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/match/ip/dscp"); value.Exists() {
+ data.MatchIpDscp = helpers.GetStringListXML(value.Array())
+ } else {
+ data.MatchIpDscp = types.ListNull(types.StringType)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/match/ip/precedence"); value.Exists() {
+ data.MatchIpPrecedence = helpers.GetStringListXML(value.Array())
+ } else {
+ data.MatchIpPrecedence = types.ListNull(types.StringType)
+ }
+}
+
+// End of section. //template:end fromBodyXML
+
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyDataXML
+
+func (data *ClassMapData) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/type"); value.Exists() {
+ data.Type = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/subscriber"); value.Exists() {
+ data.Subscriber = types.BoolValue(true)
+ } else {
+ data.Subscriber = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/prematch"); value.Exists() {
+ data.Prematch = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/match/authorization-status/authorized"); value.Exists() {
+ data.MatchAuthorizationStatusAuthorized = types.BoolValue(true)
+ } else {
+ data.MatchAuthorizationStatusAuthorized = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/match/result-type/aaa-timeout"); value.Exists() {
+ data.MatchResultTypeAaaTimeout = types.BoolValue(true)
+ } else {
+ data.MatchResultTypeAaaTimeout = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/match/authorization-status/unauthorized"); value.Exists() {
+ data.MatchAuthorizationStatusUnauthorized = types.BoolValue(true)
+ } else {
+ data.MatchAuthorizationStatusUnauthorized = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/match/activated-service-template"); value.Exists() {
+ data.MatchActivatedServiceTemplates = make([]ClassMapMatchActivatedServiceTemplates, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := ClassMapMatchActivatedServiceTemplates{}
+ if cValue := helpers.GetFromXPath(v, "service-name"); cValue.Exists() {
+ item.ServiceName = types.StringValue(cValue.String())
+ }
+ data.MatchActivatedServiceTemplates = append(data.MatchActivatedServiceTemplates, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/match/authorizing-method-priority/greater-than"); value.Exists() {
+ data.MatchAuthorizingMethodPriorityGreaterThan = helpers.GetInt64ListXML(value.Array())
+ } else {
+ data.MatchAuthorizingMethodPriorityGreaterThan = types.ListNull(types.Int64Type)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/match/method/dot1x"); value.Exists() {
+ data.MatchMethodDot1x = types.BoolValue(true)
+ } else {
+ data.MatchMethodDot1x = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/match/result-type/method/dot1x/authoritative"); value.Exists() {
+ data.MatchResultTypeMethodDot1xAuthoritative = types.BoolValue(true)
+ } else {
+ data.MatchResultTypeMethodDot1xAuthoritative = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/match/result-type/method/dot1x/agent-not-found"); value.Exists() {
+ data.MatchResultTypeMethodDot1xAgentNotFound = types.BoolValue(true)
+ } else {
+ data.MatchResultTypeMethodDot1xAgentNotFound = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/match/result-type/method/dot1x/method-timeout"); value.Exists() {
+ data.MatchResultTypeMethodDot1xMethodTimeout = types.BoolValue(true)
+ } else {
+ data.MatchResultTypeMethodDot1xMethodTimeout = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/match/method/mab"); value.Exists() {
+ data.MatchMethodMab = types.BoolValue(true)
+ } else {
+ data.MatchMethodMab = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/match/result-type/method/mab/authoritative"); value.Exists() {
+ data.MatchResultTypeMethodMabAuthoritative = types.BoolValue(true)
+ } else {
+ data.MatchResultTypeMethodMabAuthoritative = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/match/dscp"); value.Exists() {
+ data.MatchDscp = helpers.GetStringListXML(value.Array())
+ } else {
+ data.MatchDscp = types.ListNull(types.StringType)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/description"); value.Exists() {
+ data.Description = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/match/access-group/name"); value.Exists() {
+ data.MatchAccessGroupName = helpers.GetStringListXML(value.Array())
+ } else {
+ data.MatchAccessGroupName = types.ListNull(types.StringType)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/match/ip/dscp"); value.Exists() {
+ data.MatchIpDscp = helpers.GetStringListXML(value.Array())
+ } else {
+ data.MatchIpDscp = types.ListNull(types.StringType)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/match/ip/precedence"); value.Exists() {
+ data.MatchIpPrecedence = helpers.GetStringListXML(value.Array())
+ } else {
+ data.MatchIpPrecedence = types.ListNull(types.StringType)
+ }
+}
+
+// End of section. //template:end fromBodyDataXML
+
+// Section below is generated&owned by "gen/generator.go". //template:begin getDeletedItems
+
+func (data *ClassMap) getDeletedItems(ctx context.Context, state ClassMap) []string {
+ deletedItems := make([]string, 0)
+ if !state.MatchIpPrecedence.IsNull() {
+ if data.MatchIpPrecedence.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/match/ip/precedence", state.getPath()))
+ } else {
+ var dataValues, stateValues []string
+ data.MatchIpPrecedence.ElementsAs(ctx, &dataValues, false)
+ state.MatchIpPrecedence.ElementsAs(ctx, &stateValues, false)
+ for _, v := range stateValues {
+ found := false
+ for _, vv := range dataValues {
+ if v == vv {
+ found = true
+ break
+ }
+ }
+ if !found {
deletedItems = append(deletedItems, fmt.Sprintf("%v/match/ip/precedence=%v", state.getPath(), v))
}
}
@@ -786,6 +1316,190 @@ func (data *ClassMap) getDeletedItems(ctx context.Context, state ClassMap) []str
// End of section. //template:end getDeletedItems
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletedItemsXML
+
+func (data *ClassMap) addDeletedItemsXML(ctx context.Context, state ClassMap, body string) string {
+ b := netconf.NewBody(body)
+ if !state.Type.IsNull() && data.Type.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/type")
+ }
+ if !state.Subscriber.IsNull() && data.Subscriber.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/subscriber")
+ }
+ if !state.Prematch.IsNull() && data.Prematch.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/prematch")
+ }
+ if !state.MatchAuthorizationStatusAuthorized.IsNull() && data.MatchAuthorizationStatusAuthorized.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/match/authorization-status/authorized")
+ }
+ if !state.MatchResultTypeAaaTimeout.IsNull() && data.MatchResultTypeAaaTimeout.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/match/result-type/aaa-timeout")
+ }
+ if !state.MatchAuthorizationStatusUnauthorized.IsNull() && data.MatchAuthorizationStatusUnauthorized.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/match/authorization-status/unauthorized")
+ }
+ for i := range state.MatchActivatedServiceTemplates {
+ stateKeys := [...]string{"service-name"}
+ stateKeyValues := [...]string{state.MatchActivatedServiceTemplates[i].ServiceName.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.MatchActivatedServiceTemplates[i].ServiceName.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.MatchActivatedServiceTemplates {
+ found = true
+ if state.MatchActivatedServiceTemplates[i].ServiceName.ValueString() != data.MatchActivatedServiceTemplates[j].ServiceName.ValueString() {
+ found = false
+ }
+ if found {
+ break
+ }
+ }
+ if !found {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/match/activated-service-template%v", predicates))
+ }
+ }
+ if !state.MatchAuthorizingMethodPriorityGreaterThan.IsNull() {
+ if data.MatchAuthorizingMethodPriorityGreaterThan.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/match/authorizing-method-priority/greater-than")
+ } else {
+ var dataValues, stateValues []int
+ data.MatchAuthorizingMethodPriorityGreaterThan.ElementsAs(ctx, &dataValues, false)
+ state.MatchAuthorizingMethodPriorityGreaterThan.ElementsAs(ctx, &stateValues, false)
+ for _, v := range stateValues {
+ found := false
+ for _, vv := range dataValues {
+ if v == vv {
+ found = true
+ break
+ }
+ }
+ if !found {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/match/authorizing-method-priority/greater-than[.=%v]", v))
+ }
+ }
+ }
+ }
+ if !state.MatchMethodDot1x.IsNull() && data.MatchMethodDot1x.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/match/method/dot1x")
+ }
+ if !state.MatchResultTypeMethodDot1xAuthoritative.IsNull() && data.MatchResultTypeMethodDot1xAuthoritative.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/match/result-type/method/dot1x/authoritative")
+ }
+ if !state.MatchResultTypeMethodDot1xAgentNotFound.IsNull() && data.MatchResultTypeMethodDot1xAgentNotFound.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/match/result-type/method/dot1x/agent-not-found")
+ }
+ if !state.MatchResultTypeMethodDot1xMethodTimeout.IsNull() && data.MatchResultTypeMethodDot1xMethodTimeout.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/match/result-type/method/dot1x/method-timeout")
+ }
+ if !state.MatchMethodMab.IsNull() && data.MatchMethodMab.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/match/method/mab")
+ }
+ if !state.MatchResultTypeMethodMabAuthoritative.IsNull() && data.MatchResultTypeMethodMabAuthoritative.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/match/result-type/method/mab/authoritative")
+ }
+ if !state.MatchDscp.IsNull() {
+ if data.MatchDscp.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/match/dscp")
+ } else {
+ var dataValues, stateValues []string
+ data.MatchDscp.ElementsAs(ctx, &dataValues, false)
+ state.MatchDscp.ElementsAs(ctx, &stateValues, false)
+ for _, v := range stateValues {
+ found := false
+ for _, vv := range dataValues {
+ if v == vv {
+ found = true
+ break
+ }
+ }
+ if !found {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/match/dscp[.=%v]", v))
+ }
+ }
+ }
+ }
+ if !state.Description.IsNull() && data.Description.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/description")
+ }
+ if !state.MatchAccessGroupName.IsNull() {
+ if data.MatchAccessGroupName.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/match/access-group/name")
+ } else {
+ var dataValues, stateValues []string
+ data.MatchAccessGroupName.ElementsAs(ctx, &dataValues, false)
+ state.MatchAccessGroupName.ElementsAs(ctx, &stateValues, false)
+ for _, v := range stateValues {
+ found := false
+ for _, vv := range dataValues {
+ if v == vv {
+ found = true
+ break
+ }
+ }
+ if !found {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/match/access-group/name[.=%v]", v))
+ }
+ }
+ }
+ }
+ if !state.MatchIpDscp.IsNull() {
+ if data.MatchIpDscp.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/match/ip/dscp")
+ } else {
+ var dataValues, stateValues []string
+ data.MatchIpDscp.ElementsAs(ctx, &dataValues, false)
+ state.MatchIpDscp.ElementsAs(ctx, &stateValues, false)
+ for _, v := range stateValues {
+ found := false
+ for _, vv := range dataValues {
+ if v == vv {
+ found = true
+ break
+ }
+ }
+ if !found {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/match/ip/dscp[.=%v]", v))
+ }
+ }
+ }
+ }
+ if !state.MatchIpPrecedence.IsNull() {
+ if data.MatchIpPrecedence.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/match/ip/precedence")
+ } else {
+ var dataValues, stateValues []string
+ data.MatchIpPrecedence.ElementsAs(ctx, &dataValues, false)
+ state.MatchIpPrecedence.ElementsAs(ctx, &stateValues, false)
+ for _, v := range stateValues {
+ found := false
+ for _, vv := range dataValues {
+ if v == vv {
+ found = true
+ break
+ }
+ }
+ if !found {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/match/ip/precedence[.=%v]", v))
+ }
+ }
+ }
+ }
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletedItemsXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin getEmptyLeafsDelete
func (data *ClassMap) getEmptyLeafsDelete(ctx context.Context) []string {
@@ -895,3 +1609,77 @@ func (data *ClassMap) getDeletePaths(ctx context.Context) []string {
}
// End of section. //template:end getDeletePaths
+
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletePathsXML
+
+func (data *ClassMap) addDeletePathsXML(ctx context.Context, body string) string {
+ b := netconf.NewBody(body)
+ if !data.Type.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/type")
+ }
+ if !data.Subscriber.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/subscriber")
+ }
+ if !data.Prematch.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/prematch")
+ }
+ if !data.MatchAuthorizationStatusAuthorized.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/match/authorization-status/authorized")
+ }
+ if !data.MatchResultTypeAaaTimeout.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/match/result-type/aaa-timeout")
+ }
+ if !data.MatchAuthorizationStatusUnauthorized.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/match/authorization-status/unauthorized")
+ }
+ for i := range data.MatchActivatedServiceTemplates {
+ keys := [...]string{"service-name"}
+ keyValues := [...]string{data.MatchActivatedServiceTemplates[i].ServiceName.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/match/activated-service-template%v", predicates))
+ }
+ if !data.MatchAuthorizingMethodPriorityGreaterThan.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/match/authorizing-method-priority/greater-than")
+ }
+ if !data.MatchMethodDot1x.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/match/method/dot1x")
+ }
+ if !data.MatchResultTypeMethodDot1xAuthoritative.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/match/result-type/method/dot1x/authoritative")
+ }
+ if !data.MatchResultTypeMethodDot1xAgentNotFound.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/match/result-type/method/dot1x/agent-not-found")
+ }
+ if !data.MatchResultTypeMethodDot1xMethodTimeout.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/match/result-type/method/dot1x/method-timeout")
+ }
+ if !data.MatchMethodMab.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/match/method/mab")
+ }
+ if !data.MatchResultTypeMethodMabAuthoritative.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/match/result-type/method/mab/authoritative")
+ }
+ if !data.MatchDscp.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/match/dscp")
+ }
+ if !data.Description.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/description")
+ }
+ if !data.MatchAccessGroupName.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/match/access-group/name")
+ }
+ if !data.MatchIpDscp.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/match/ip/dscp")
+ }
+ if !data.MatchIpPrecedence.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/match/ip/precedence")
+ }
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletePathsXML
diff --git a/internal/provider/model_iosxe_clock.go b/internal/provider/model_iosxe_clock.go
index e2ba9a66..85fc6c6c 100644
--- a/internal/provider/model_iosxe_clock.go
+++ b/internal/provider/model_iosxe_clock.go
@@ -28,6 +28,9 @@ import (
"github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/types"
+ "github.com/hashicorp/terraform-plugin-log/tflog"
+ "github.com/netascode/go-netconf"
+ "github.com/netascode/xmldot"
"github.com/tidwall/gjson"
"github.com/tidwall/sjson"
)
@@ -119,6 +122,17 @@ func (data Clock) getPathShort() string {
return matches[1]
}
+// getXPath returns the XPath for NETCONF operations
+func (data Clock) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/clock"
+ return path
+}
+
+func (data ClockData) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/clock"
+ return path
+}
+
// End of section. //template:end getPath
// Section below is generated&owned by "gen/generator.go". //template:begin toBody
@@ -211,6 +225,106 @@ func (data Clock) toBody(ctx context.Context) string {
// End of section. //template:end toBody
+// Section below is generated&owned by "gen/generator.go". //template:begin toBodyXML
+
+func (data Clock) toBodyXML(ctx context.Context) string {
+ body := netconf.Body{}
+ if !data.CalendarValid.IsNull() && !data.CalendarValid.IsUnknown() {
+ if data.CalendarValid.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/calendar-valid", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/calendar-valid")
+ }
+ }
+ if !data.SummerTimeZone.IsNull() && !data.SummerTimeZone.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/summer-time/zone", data.SummerTimeZone.ValueString())
+ }
+ if !data.SummerTimeDate.IsNull() && !data.SummerTimeDate.IsUnknown() {
+ if data.SummerTimeDate.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/summer-time/date", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/summer-time/date")
+ }
+ }
+ if !data.SummerTimeDateStartDay.IsNull() && !data.SummerTimeDateStartDay.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/summer-time/start-day", strconv.FormatInt(data.SummerTimeDateStartDay.ValueInt64(), 10))
+ }
+ if !data.SummerTimeDateStartMonth.IsNull() && !data.SummerTimeDateStartMonth.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/summer-time/start-month", data.SummerTimeDateStartMonth.ValueString())
+ }
+ if !data.SummerTimeDateStartYear.IsNull() && !data.SummerTimeDateStartYear.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/summer-time/start-year", strconv.FormatInt(data.SummerTimeDateStartYear.ValueInt64(), 10))
+ }
+ if !data.SummerTimeDateStartTime.IsNull() && !data.SummerTimeDateStartTime.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/summer-time/start-time", data.SummerTimeDateStartTime.ValueString())
+ }
+ if !data.SummerTimeDateEndDay.IsNull() && !data.SummerTimeDateEndDay.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/summer-time/date-end-day", strconv.FormatInt(data.SummerTimeDateEndDay.ValueInt64(), 10))
+ }
+ if !data.SummerTimeDateEndMonth.IsNull() && !data.SummerTimeDateEndMonth.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/summer-time/date-end-month", data.SummerTimeDateEndMonth.ValueString())
+ }
+ if !data.SummerTimeDateEndYear.IsNull() && !data.SummerTimeDateEndYear.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/summer-time/date-end-year", strconv.FormatInt(data.SummerTimeDateEndYear.ValueInt64(), 10))
+ }
+ if !data.SummerTimeDateEndTime.IsNull() && !data.SummerTimeDateEndTime.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/summer-time/date-end-time", data.SummerTimeDateEndTime.ValueString())
+ }
+ if !data.SummerTimeDateOffset.IsNull() && !data.SummerTimeDateOffset.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/summer-time/offset", strconv.FormatInt(data.SummerTimeDateOffset.ValueInt64(), 10))
+ }
+ if !data.SummerTimeRecurring.IsNull() && !data.SummerTimeRecurring.IsUnknown() {
+ if data.SummerTimeRecurring.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/summer-time/recurring", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/summer-time/recurring")
+ }
+ }
+ if !data.SummerTimeRecurringStartWeek.IsNull() && !data.SummerTimeRecurringStartWeek.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/summer-time/recurring-start", data.SummerTimeRecurringStartWeek.ValueString())
+ }
+ if !data.SummerTimeRecurringStartWeekday.IsNull() && !data.SummerTimeRecurringStartWeekday.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/summer-time/recurring-start-day", data.SummerTimeRecurringStartWeekday.ValueString())
+ }
+ if !data.SummerTimeRecurringStartMonth.IsNull() && !data.SummerTimeRecurringStartMonth.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/summer-time/recurring-start-month", data.SummerTimeRecurringStartMonth.ValueString())
+ }
+ if !data.SummerTimeRecurringStartTime.IsNull() && !data.SummerTimeRecurringStartTime.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/summer-time/recurring-start-time", data.SummerTimeRecurringStartTime.ValueString())
+ }
+ if !data.SummerTimeRecurringEndWeek.IsNull() && !data.SummerTimeRecurringEndWeek.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/summer-time/recurring-end", data.SummerTimeRecurringEndWeek.ValueString())
+ }
+ if !data.SummerTimeRecurringEndWeekday.IsNull() && !data.SummerTimeRecurringEndWeekday.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/summer-time/recurring-end-day", data.SummerTimeRecurringEndWeekday.ValueString())
+ }
+ if !data.SummerTimeRecurringEndMonth.IsNull() && !data.SummerTimeRecurringEndMonth.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/summer-time/recurring-end-month", data.SummerTimeRecurringEndMonth.ValueString())
+ }
+ if !data.SummerTimeRecurringEndTime.IsNull() && !data.SummerTimeRecurringEndTime.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/summer-time/recurring-end-time", data.SummerTimeRecurringEndTime.ValueString())
+ }
+ if !data.SummerTimeRecurringOffset.IsNull() && !data.SummerTimeRecurringOffset.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/summer-time/recurring-offset", strconv.FormatInt(data.SummerTimeRecurringOffset.ValueInt64(), 10))
+ }
+ if !data.Timezone.IsNull() && !data.Timezone.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/timezone/zone", data.Timezone.ValueString())
+ }
+ if !data.TimezoneOffsetHours.IsNull() && !data.TimezoneOffsetHours.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/timezone/hours", strconv.FormatInt(data.TimezoneOffsetHours.ValueInt64(), 10))
+ }
+ if !data.TimezoneOffsetMinutes.IsNull() && !data.TimezoneOffsetMinutes.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/timezone/minutes", strconv.FormatInt(data.TimezoneOffsetMinutes.ValueInt64(), 10))
+ }
+ bodyString, err := body.String()
+ if err != nil {
+ tflog.Error(ctx, fmt.Sprintf("Error converting body to string: %s", err))
+ }
+ return bodyString
+}
+
+// End of section. //template:end toBodyXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBody
func (data *Clock) updateFromBody(ctx context.Context, res gjson.Result) {
@@ -359,6 +473,150 @@ func (data *Clock) updateFromBody(ctx context.Context, res gjson.Result) {
// End of section. //template:end updateFromBody
+// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBodyXML
+
+func (data *Clock) updateFromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/calendar-valid"); !data.CalendarValid.IsNull() {
+ if value.Exists() {
+ data.CalendarValid = types.BoolValue(true)
+ } else {
+ data.CalendarValid = types.BoolValue(false)
+ }
+ } else {
+ data.CalendarValid = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/summer-time/zone"); value.Exists() && !data.SummerTimeZone.IsNull() {
+ data.SummerTimeZone = types.StringValue(value.String())
+ } else {
+ data.SummerTimeZone = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/summer-time/date"); !data.SummerTimeDate.IsNull() {
+ if value.Exists() {
+ data.SummerTimeDate = types.BoolValue(true)
+ } else {
+ data.SummerTimeDate = types.BoolValue(false)
+ }
+ } else {
+ data.SummerTimeDate = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/summer-time/start-day"); value.Exists() && !data.SummerTimeDateStartDay.IsNull() {
+ data.SummerTimeDateStartDay = types.Int64Value(value.Int())
+ } else {
+ data.SummerTimeDateStartDay = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/summer-time/start-month"); value.Exists() && !data.SummerTimeDateStartMonth.IsNull() {
+ data.SummerTimeDateStartMonth = types.StringValue(value.String())
+ } else {
+ data.SummerTimeDateStartMonth = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/summer-time/start-year"); value.Exists() && !data.SummerTimeDateStartYear.IsNull() {
+ data.SummerTimeDateStartYear = types.Int64Value(value.Int())
+ } else {
+ data.SummerTimeDateStartYear = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/summer-time/start-time"); value.Exists() && !data.SummerTimeDateStartTime.IsNull() {
+ data.SummerTimeDateStartTime = types.StringValue(value.String())
+ } else {
+ data.SummerTimeDateStartTime = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/summer-time/date-end-day"); value.Exists() && !data.SummerTimeDateEndDay.IsNull() {
+ data.SummerTimeDateEndDay = types.Int64Value(value.Int())
+ } else {
+ data.SummerTimeDateEndDay = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/summer-time/date-end-month"); value.Exists() && !data.SummerTimeDateEndMonth.IsNull() {
+ data.SummerTimeDateEndMonth = types.StringValue(value.String())
+ } else {
+ data.SummerTimeDateEndMonth = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/summer-time/date-end-year"); value.Exists() && !data.SummerTimeDateEndYear.IsNull() {
+ data.SummerTimeDateEndYear = types.Int64Value(value.Int())
+ } else {
+ data.SummerTimeDateEndYear = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/summer-time/date-end-time"); value.Exists() && !data.SummerTimeDateEndTime.IsNull() {
+ data.SummerTimeDateEndTime = types.StringValue(value.String())
+ } else {
+ data.SummerTimeDateEndTime = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/summer-time/offset"); value.Exists() && !data.SummerTimeDateOffset.IsNull() {
+ data.SummerTimeDateOffset = types.Int64Value(value.Int())
+ } else {
+ data.SummerTimeDateOffset = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/summer-time/recurring"); !data.SummerTimeRecurring.IsNull() {
+ if value.Exists() {
+ data.SummerTimeRecurring = types.BoolValue(true)
+ } else {
+ data.SummerTimeRecurring = types.BoolValue(false)
+ }
+ } else {
+ data.SummerTimeRecurring = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/summer-time/recurring-start"); value.Exists() && !data.SummerTimeRecurringStartWeek.IsNull() {
+ data.SummerTimeRecurringStartWeek = types.StringValue(value.String())
+ } else {
+ data.SummerTimeRecurringStartWeek = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/summer-time/recurring-start-day"); value.Exists() && !data.SummerTimeRecurringStartWeekday.IsNull() {
+ data.SummerTimeRecurringStartWeekday = types.StringValue(value.String())
+ } else {
+ data.SummerTimeRecurringStartWeekday = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/summer-time/recurring-start-month"); value.Exists() && !data.SummerTimeRecurringStartMonth.IsNull() {
+ data.SummerTimeRecurringStartMonth = types.StringValue(value.String())
+ } else {
+ data.SummerTimeRecurringStartMonth = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/summer-time/recurring-start-time"); value.Exists() && !data.SummerTimeRecurringStartTime.IsNull() {
+ data.SummerTimeRecurringStartTime = types.StringValue(value.String())
+ } else {
+ data.SummerTimeRecurringStartTime = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/summer-time/recurring-end"); value.Exists() && !data.SummerTimeRecurringEndWeek.IsNull() {
+ data.SummerTimeRecurringEndWeek = types.StringValue(value.String())
+ } else {
+ data.SummerTimeRecurringEndWeek = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/summer-time/recurring-end-day"); value.Exists() && !data.SummerTimeRecurringEndWeekday.IsNull() {
+ data.SummerTimeRecurringEndWeekday = types.StringValue(value.String())
+ } else {
+ data.SummerTimeRecurringEndWeekday = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/summer-time/recurring-end-month"); value.Exists() && !data.SummerTimeRecurringEndMonth.IsNull() {
+ data.SummerTimeRecurringEndMonth = types.StringValue(value.String())
+ } else {
+ data.SummerTimeRecurringEndMonth = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/summer-time/recurring-end-time"); value.Exists() && !data.SummerTimeRecurringEndTime.IsNull() {
+ data.SummerTimeRecurringEndTime = types.StringValue(value.String())
+ } else {
+ data.SummerTimeRecurringEndTime = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/summer-time/recurring-offset"); value.Exists() && !data.SummerTimeRecurringOffset.IsNull() {
+ data.SummerTimeRecurringOffset = types.Int64Value(value.Int())
+ } else {
+ data.SummerTimeRecurringOffset = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/timezone/zone"); value.Exists() && !data.Timezone.IsNull() {
+ data.Timezone = types.StringValue(value.String())
+ } else {
+ data.Timezone = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/timezone/hours"); value.Exists() && !data.TimezoneOffsetHours.IsNull() {
+ data.TimezoneOffsetHours = types.Int64Value(value.Int())
+ } else {
+ data.TimezoneOffsetHours = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/timezone/minutes"); value.Exists() && !data.TimezoneOffsetMinutes.IsNull() {
+ data.TimezoneOffsetMinutes = types.Int64Value(value.Int())
+ } else {
+ data.TimezoneOffsetMinutes = types.Int64Null()
+ }
+}
+
+// End of section. //template:end updateFromBodyXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin fromBody
func (data *Clock) fromBody(ctx context.Context, res gjson.Result) {
@@ -543,6 +801,182 @@ func (data *ClockData) fromBody(ctx context.Context, res gjson.Result) {
// End of section. //template:end fromBodyData
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyXML
+
+func (data *Clock) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/calendar-valid"); value.Exists() {
+ data.CalendarValid = types.BoolValue(true)
+ } else {
+ data.CalendarValid = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/summer-time/zone"); value.Exists() {
+ data.SummerTimeZone = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/summer-time/date"); value.Exists() {
+ data.SummerTimeDate = types.BoolValue(true)
+ } else {
+ data.SummerTimeDate = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/summer-time/start-day"); value.Exists() {
+ data.SummerTimeDateStartDay = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/summer-time/start-month"); value.Exists() {
+ data.SummerTimeDateStartMonth = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/summer-time/start-year"); value.Exists() {
+ data.SummerTimeDateStartYear = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/summer-time/start-time"); value.Exists() {
+ data.SummerTimeDateStartTime = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/summer-time/date-end-day"); value.Exists() {
+ data.SummerTimeDateEndDay = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/summer-time/date-end-month"); value.Exists() {
+ data.SummerTimeDateEndMonth = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/summer-time/date-end-year"); value.Exists() {
+ data.SummerTimeDateEndYear = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/summer-time/date-end-time"); value.Exists() {
+ data.SummerTimeDateEndTime = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/summer-time/offset"); value.Exists() {
+ data.SummerTimeDateOffset = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/summer-time/recurring"); value.Exists() {
+ data.SummerTimeRecurring = types.BoolValue(true)
+ } else {
+ data.SummerTimeRecurring = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/summer-time/recurring-start"); value.Exists() {
+ data.SummerTimeRecurringStartWeek = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/summer-time/recurring-start-day"); value.Exists() {
+ data.SummerTimeRecurringStartWeekday = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/summer-time/recurring-start-month"); value.Exists() {
+ data.SummerTimeRecurringStartMonth = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/summer-time/recurring-start-time"); value.Exists() {
+ data.SummerTimeRecurringStartTime = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/summer-time/recurring-end"); value.Exists() {
+ data.SummerTimeRecurringEndWeek = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/summer-time/recurring-end-day"); value.Exists() {
+ data.SummerTimeRecurringEndWeekday = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/summer-time/recurring-end-month"); value.Exists() {
+ data.SummerTimeRecurringEndMonth = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/summer-time/recurring-end-time"); value.Exists() {
+ data.SummerTimeRecurringEndTime = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/summer-time/recurring-offset"); value.Exists() {
+ data.SummerTimeRecurringOffset = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/timezone/zone"); value.Exists() {
+ data.Timezone = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/timezone/hours"); value.Exists() {
+ data.TimezoneOffsetHours = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/timezone/minutes"); value.Exists() {
+ data.TimezoneOffsetMinutes = types.Int64Value(value.Int())
+ }
+}
+
+// End of section. //template:end fromBodyXML
+
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyDataXML
+
+func (data *ClockData) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/calendar-valid"); value.Exists() {
+ data.CalendarValid = types.BoolValue(true)
+ } else {
+ data.CalendarValid = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/summer-time/zone"); value.Exists() {
+ data.SummerTimeZone = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/summer-time/date"); value.Exists() {
+ data.SummerTimeDate = types.BoolValue(true)
+ } else {
+ data.SummerTimeDate = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/summer-time/start-day"); value.Exists() {
+ data.SummerTimeDateStartDay = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/summer-time/start-month"); value.Exists() {
+ data.SummerTimeDateStartMonth = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/summer-time/start-year"); value.Exists() {
+ data.SummerTimeDateStartYear = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/summer-time/start-time"); value.Exists() {
+ data.SummerTimeDateStartTime = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/summer-time/date-end-day"); value.Exists() {
+ data.SummerTimeDateEndDay = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/summer-time/date-end-month"); value.Exists() {
+ data.SummerTimeDateEndMonth = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/summer-time/date-end-year"); value.Exists() {
+ data.SummerTimeDateEndYear = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/summer-time/date-end-time"); value.Exists() {
+ data.SummerTimeDateEndTime = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/summer-time/offset"); value.Exists() {
+ data.SummerTimeDateOffset = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/summer-time/recurring"); value.Exists() {
+ data.SummerTimeRecurring = types.BoolValue(true)
+ } else {
+ data.SummerTimeRecurring = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/summer-time/recurring-start"); value.Exists() {
+ data.SummerTimeRecurringStartWeek = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/summer-time/recurring-start-day"); value.Exists() {
+ data.SummerTimeRecurringStartWeekday = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/summer-time/recurring-start-month"); value.Exists() {
+ data.SummerTimeRecurringStartMonth = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/summer-time/recurring-start-time"); value.Exists() {
+ data.SummerTimeRecurringStartTime = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/summer-time/recurring-end"); value.Exists() {
+ data.SummerTimeRecurringEndWeek = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/summer-time/recurring-end-day"); value.Exists() {
+ data.SummerTimeRecurringEndWeekday = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/summer-time/recurring-end-month"); value.Exists() {
+ data.SummerTimeRecurringEndMonth = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/summer-time/recurring-end-time"); value.Exists() {
+ data.SummerTimeRecurringEndTime = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/summer-time/recurring-offset"); value.Exists() {
+ data.SummerTimeRecurringOffset = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/timezone/zone"); value.Exists() {
+ data.Timezone = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/timezone/hours"); value.Exists() {
+ data.TimezoneOffsetHours = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/timezone/minutes"); value.Exists() {
+ data.TimezoneOffsetMinutes = types.Int64Value(value.Int())
+ }
+}
+
+// End of section. //template:end fromBodyDataXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin getDeletedItems
func (data *Clock) getDeletedItems(ctx context.Context, state Clock) []string {
@@ -628,6 +1062,91 @@ func (data *Clock) getDeletedItems(ctx context.Context, state Clock) []string {
// End of section. //template:end getDeletedItems
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletedItemsXML
+
+func (data *Clock) addDeletedItemsXML(ctx context.Context, state Clock, body string) string {
+ b := netconf.NewBody(body)
+ if !state.CalendarValid.IsNull() && data.CalendarValid.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/calendar-valid")
+ }
+ if !state.SummerTimeZone.IsNull() && data.SummerTimeZone.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/summer-time/zone")
+ }
+ if !state.SummerTimeDate.IsNull() && data.SummerTimeDate.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/summer-time/date")
+ }
+ if !state.SummerTimeDateStartDay.IsNull() && data.SummerTimeDateStartDay.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/summer-time/start-day")
+ }
+ if !state.SummerTimeDateStartMonth.IsNull() && data.SummerTimeDateStartMonth.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/summer-time/start-month")
+ }
+ if !state.SummerTimeDateStartYear.IsNull() && data.SummerTimeDateStartYear.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/summer-time/start-year")
+ }
+ if !state.SummerTimeDateStartTime.IsNull() && data.SummerTimeDateStartTime.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/summer-time/start-time")
+ }
+ if !state.SummerTimeDateEndDay.IsNull() && data.SummerTimeDateEndDay.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/summer-time/date-end-day")
+ }
+ if !state.SummerTimeDateEndMonth.IsNull() && data.SummerTimeDateEndMonth.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/summer-time/date-end-month")
+ }
+ if !state.SummerTimeDateEndYear.IsNull() && data.SummerTimeDateEndYear.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/summer-time/date-end-year")
+ }
+ if !state.SummerTimeDateEndTime.IsNull() && data.SummerTimeDateEndTime.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/summer-time/date-end-time")
+ }
+ if !state.SummerTimeDateOffset.IsNull() && data.SummerTimeDateOffset.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/summer-time/offset")
+ }
+ if !state.SummerTimeRecurring.IsNull() && data.SummerTimeRecurring.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/summer-time/recurring")
+ }
+ if !state.SummerTimeRecurringStartWeek.IsNull() && data.SummerTimeRecurringStartWeek.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/summer-time/recurring-start")
+ }
+ if !state.SummerTimeRecurringStartWeekday.IsNull() && data.SummerTimeRecurringStartWeekday.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/summer-time/recurring-start-day")
+ }
+ if !state.SummerTimeRecurringStartMonth.IsNull() && data.SummerTimeRecurringStartMonth.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/summer-time/recurring-start-month")
+ }
+ if !state.SummerTimeRecurringStartTime.IsNull() && data.SummerTimeRecurringStartTime.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/summer-time/recurring-start-time")
+ }
+ if !state.SummerTimeRecurringEndWeek.IsNull() && data.SummerTimeRecurringEndWeek.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/summer-time/recurring-end")
+ }
+ if !state.SummerTimeRecurringEndWeekday.IsNull() && data.SummerTimeRecurringEndWeekday.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/summer-time/recurring-end-day")
+ }
+ if !state.SummerTimeRecurringEndMonth.IsNull() && data.SummerTimeRecurringEndMonth.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/summer-time/recurring-end-month")
+ }
+ if !state.SummerTimeRecurringEndTime.IsNull() && data.SummerTimeRecurringEndTime.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/summer-time/recurring-end-time")
+ }
+ if !state.SummerTimeRecurringOffset.IsNull() && data.SummerTimeRecurringOffset.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/summer-time/recurring-offset")
+ }
+ if !state.Timezone.IsNull() && data.Timezone.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/timezone/zone")
+ }
+ if !state.TimezoneOffsetHours.IsNull() && data.TimezoneOffsetHours.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/timezone/hours")
+ }
+ if !state.TimezoneOffsetMinutes.IsNull() && data.TimezoneOffsetMinutes.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/timezone/minutes")
+ }
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletedItemsXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin getEmptyLeafsDelete
func (data *Clock) getEmptyLeafsDelete(ctx context.Context) []string {
@@ -731,3 +1250,88 @@ func (data *Clock) getDeletePaths(ctx context.Context) []string {
}
// End of section. //template:end getDeletePaths
+
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletePathsXML
+
+func (data *Clock) addDeletePathsXML(ctx context.Context, body string) string {
+ b := netconf.NewBody(body)
+ if !data.CalendarValid.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/calendar-valid")
+ }
+ if !data.SummerTimeZone.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/summer-time/zone")
+ }
+ if !data.SummerTimeDate.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/summer-time/date")
+ }
+ if !data.SummerTimeDateStartDay.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/summer-time/start-day")
+ }
+ if !data.SummerTimeDateStartMonth.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/summer-time/start-month")
+ }
+ if !data.SummerTimeDateStartYear.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/summer-time/start-year")
+ }
+ if !data.SummerTimeDateStartTime.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/summer-time/start-time")
+ }
+ if !data.SummerTimeDateEndDay.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/summer-time/date-end-day")
+ }
+ if !data.SummerTimeDateEndMonth.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/summer-time/date-end-month")
+ }
+ if !data.SummerTimeDateEndYear.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/summer-time/date-end-year")
+ }
+ if !data.SummerTimeDateEndTime.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/summer-time/date-end-time")
+ }
+ if !data.SummerTimeDateOffset.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/summer-time/offset")
+ }
+ if !data.SummerTimeRecurring.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/summer-time/recurring")
+ }
+ if !data.SummerTimeRecurringStartWeek.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/summer-time/recurring-start")
+ }
+ if !data.SummerTimeRecurringStartWeekday.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/summer-time/recurring-start-day")
+ }
+ if !data.SummerTimeRecurringStartMonth.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/summer-time/recurring-start-month")
+ }
+ if !data.SummerTimeRecurringStartTime.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/summer-time/recurring-start-time")
+ }
+ if !data.SummerTimeRecurringEndWeek.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/summer-time/recurring-end")
+ }
+ if !data.SummerTimeRecurringEndWeekday.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/summer-time/recurring-end-day")
+ }
+ if !data.SummerTimeRecurringEndMonth.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/summer-time/recurring-end-month")
+ }
+ if !data.SummerTimeRecurringEndTime.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/summer-time/recurring-end-time")
+ }
+ if !data.SummerTimeRecurringOffset.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/summer-time/recurring-offset")
+ }
+ if !data.Timezone.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/timezone/zone")
+ }
+ if !data.TimezoneOffsetHours.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/timezone/hours")
+ }
+ if !data.TimezoneOffsetMinutes.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/timezone/minutes")
+ }
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletePathsXML
diff --git a/internal/provider/model_iosxe_community_list_expanded.go b/internal/provider/model_iosxe_community_list_expanded.go
index da5f8489..86e35d37 100644
--- a/internal/provider/model_iosxe_community_list_expanded.go
+++ b/internal/provider/model_iosxe_community_list_expanded.go
@@ -31,6 +31,9 @@ import (
"github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/types"
+ "github.com/hashicorp/terraform-plugin-log/tflog"
+ "github.com/netascode/go-netconf"
+ "github.com/netascode/xmldot"
"github.com/tidwall/gjson"
"github.com/tidwall/sjson"
)
@@ -79,6 +82,19 @@ func (data CommunityListExpanded) getPathShort() string {
return matches[1]
}
+// getXPath returns the XPath for NETCONF operations
+func (data CommunityListExpanded) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/ip/Cisco-IOS-XE-bgp:community-list/expanded[name=%v]"
+ path = fmt.Sprintf(path, fmt.Sprintf("%v", data.Name.ValueString()))
+ return path
+}
+
+func (data CommunityListExpandedData) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/ip/Cisco-IOS-XE-bgp:community-list/expanded[name=%v]"
+ path = fmt.Sprintf(path, fmt.Sprintf("%v", data.Name.ValueString()))
+ return path
+}
+
// End of section. //template:end getPath
// Section below is generated&owned by "gen/generator.go". //template:begin toBody
@@ -104,6 +120,34 @@ func (data CommunityListExpanded) toBody(ctx context.Context) string {
// End of section. //template:end toBody
+// Section below is generated&owned by "gen/generator.go". //template:begin toBodyXML
+
+func (data CommunityListExpanded) toBodyXML(ctx context.Context) string {
+ body := netconf.Body{}
+ if !data.Name.IsNull() && !data.Name.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/name", data.Name.ValueString())
+ }
+ if len(data.Entries) > 0 {
+ for _, item := range data.Entries {
+ cBody := netconf.Body{}
+ if !item.Action.IsNull() && !item.Action.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "action", item.Action.ValueString())
+ }
+ if !item.Regex.IsNull() && !item.Regex.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "string", item.Regex.ValueString())
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/extended-grouping/extended_grouping", cBody.Res())
+ }
+ }
+ bodyString, err := body.String()
+ if err != nil {
+ tflog.Error(ctx, fmt.Sprintf("Error converting body to string: %s", err))
+ }
+ return bodyString
+}
+
+// End of section. //template:end toBodyXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBody
func (data *CommunityListExpanded) updateFromBody(ctx context.Context, res gjson.Result) {
@@ -154,6 +198,52 @@ func (data *CommunityListExpanded) updateFromBody(ctx context.Context, res gjson
// End of section. //template:end updateFromBody
+// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBodyXML
+
+func (data *CommunityListExpanded) updateFromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/name"); value.Exists() && !data.Name.IsNull() {
+ data.Name = types.StringValue(value.String())
+ } else {
+ data.Name = types.StringNull()
+ }
+ for i := range data.Entries {
+ keys := [...]string{"action", "string"}
+ keyValues := [...]string{data.Entries[i].Action.ValueString(), data.Entries[i].Regex.ValueString()}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/extended-grouping/extended_grouping").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, "action"); value.Exists() && !data.Entries[i].Action.IsNull() {
+ data.Entries[i].Action = types.StringValue(value.String())
+ } else {
+ data.Entries[i].Action = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "string"); value.Exists() && !data.Entries[i].Regex.IsNull() {
+ data.Entries[i].Regex = types.StringValue(value.String())
+ } else {
+ data.Entries[i].Regex = types.StringNull()
+ }
+ }
+}
+
+// End of section. //template:end updateFromBodyXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin fromBody
func (data *CommunityListExpanded) fromBody(ctx context.Context, res gjson.Result) {
@@ -204,6 +294,48 @@ func (data *CommunityListExpandedData) fromBody(ctx context.Context, res gjson.R
// End of section. //template:end fromBodyData
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyXML
+
+func (data *CommunityListExpanded) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/extended-grouping/extended_grouping"); value.Exists() {
+ data.Entries = make([]CommunityListExpandedEntries, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := CommunityListExpandedEntries{}
+ if cValue := helpers.GetFromXPath(v, "action"); cValue.Exists() {
+ item.Action = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "string"); cValue.Exists() {
+ item.Regex = types.StringValue(cValue.String())
+ }
+ data.Entries = append(data.Entries, item)
+ return true
+ })
+ }
+}
+
+// End of section. //template:end fromBodyXML
+
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyDataXML
+
+func (data *CommunityListExpandedData) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/extended-grouping/extended_grouping"); value.Exists() {
+ data.Entries = make([]CommunityListExpandedEntries, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := CommunityListExpandedEntries{}
+ if cValue := helpers.GetFromXPath(v, "action"); cValue.Exists() {
+ item.Action = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "string"); cValue.Exists() {
+ item.Regex = types.StringValue(cValue.String())
+ }
+ data.Entries = append(data.Entries, item)
+ return true
+ })
+ }
+}
+
+// End of section. //template:end fromBodyDataXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin getDeletedItems
func (data *CommunityListExpanded) getDeletedItems(ctx context.Context, state CommunityListExpanded) []string {
@@ -245,6 +377,52 @@ func (data *CommunityListExpanded) getDeletedItems(ctx context.Context, state Co
// End of section. //template:end getDeletedItems
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletedItemsXML
+
+func (data *CommunityListExpanded) addDeletedItemsXML(ctx context.Context, state CommunityListExpanded, body string) string {
+ b := netconf.NewBody(body)
+ for i := range state.Entries {
+ stateKeys := [...]string{"action", "string"}
+ stateKeyValues := [...]string{state.Entries[i].Action.ValueString(), state.Entries[i].Regex.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.Entries[i].Action.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if !reflect.ValueOf(state.Entries[i].Regex.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.Entries {
+ found = true
+ if state.Entries[i].Action.ValueString() != data.Entries[j].Action.ValueString() {
+ found = false
+ }
+ if state.Entries[i].Regex.ValueString() != data.Entries[j].Regex.ValueString() {
+ found = false
+ }
+ if found {
+ break
+ }
+ }
+ if !found {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/extended-grouping/extended_grouping%v", predicates))
+ }
+ }
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletedItemsXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin getEmptyLeafsDelete
func (data *CommunityListExpanded) getEmptyLeafsDelete(ctx context.Context) []string {
@@ -269,3 +447,23 @@ func (data *CommunityListExpanded) getDeletePaths(ctx context.Context) []string
}
// End of section. //template:end getDeletePaths
+
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletePathsXML
+
+func (data *CommunityListExpanded) addDeletePathsXML(ctx context.Context, body string) string {
+ b := netconf.NewBody(body)
+ for i := range data.Entries {
+ keys := [...]string{"action", "string"}
+ keyValues := [...]string{data.Entries[i].Action.ValueString(), data.Entries[i].Regex.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/extended-grouping/extended_grouping%v", predicates))
+ }
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletePathsXML
diff --git a/internal/provider/model_iosxe_community_list_standard.go b/internal/provider/model_iosxe_community_list_standard.go
index 705723c0..d6ec2fbb 100644
--- a/internal/provider/model_iosxe_community_list_standard.go
+++ b/internal/provider/model_iosxe_community_list_standard.go
@@ -28,6 +28,9 @@ import (
"github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/types"
+ "github.com/hashicorp/terraform-plugin-log/tflog"
+ "github.com/netascode/go-netconf"
+ "github.com/netascode/xmldot"
"github.com/tidwall/gjson"
"github.com/tidwall/sjson"
)
@@ -74,6 +77,19 @@ func (data CommunityListStandard) getPathShort() string {
return matches[1]
}
+// getXPath returns the XPath for NETCONF operations
+func (data CommunityListStandard) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/ip/Cisco-IOS-XE-bgp:community-list/standard[name=%v]"
+ path = fmt.Sprintf(path, fmt.Sprintf("%v", data.Name.ValueString()))
+ return path
+}
+
+func (data CommunityListStandardData) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/ip/Cisco-IOS-XE-bgp:community-list/standard[name=%v]"
+ path = fmt.Sprintf(path, fmt.Sprintf("%v", data.Name.ValueString()))
+ return path
+}
+
// End of section. //template:end getPath
// Section below is generated&owned by "gen/generator.go". //template:begin toBody
@@ -98,6 +114,36 @@ func (data CommunityListStandard) toBody(ctx context.Context) string {
// End of section. //template:end toBody
+// Section below is generated&owned by "gen/generator.go". //template:begin toBodyXML
+
+func (data CommunityListStandard) toBodyXML(ctx context.Context) string {
+ body := netconf.Body{}
+ if !data.Name.IsNull() && !data.Name.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/name", data.Name.ValueString())
+ }
+ if !data.DenyEntries.IsNull() && !data.DenyEntries.IsUnknown() {
+ var values []string
+ data.DenyEntries.ElementsAs(ctx, &values, false)
+ for _, v := range values {
+ body = helpers.AppendFromXPath(body, data.getXPath()+"/deny/deny-list", v)
+ }
+ }
+ if !data.PermitEntries.IsNull() && !data.PermitEntries.IsUnknown() {
+ var values []string
+ data.PermitEntries.ElementsAs(ctx, &values, false)
+ for _, v := range values {
+ body = helpers.AppendFromXPath(body, data.getXPath()+"/permit/permit-list", v)
+ }
+ }
+ bodyString, err := body.String()
+ if err != nil {
+ tflog.Error(ctx, fmt.Sprintf("Error converting body to string: %s", err))
+ }
+ return bodyString
+}
+
+// End of section. //template:end toBodyXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBody
func (data *CommunityListStandard) updateFromBody(ctx context.Context, res gjson.Result) {
@@ -124,6 +170,28 @@ func (data *CommunityListStandard) updateFromBody(ctx context.Context, res gjson
// End of section. //template:end updateFromBody
+// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBodyXML
+
+func (data *CommunityListStandard) updateFromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/name"); value.Exists() && !data.Name.IsNull() {
+ data.Name = types.StringValue(value.String())
+ } else {
+ data.Name = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/deny/deny-list"); value.Exists() && !data.DenyEntries.IsNull() {
+ data.DenyEntries = helpers.GetStringSetXML(value.Array())
+ } else {
+ data.DenyEntries = types.SetNull(types.StringType)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/permit/permit-list"); value.Exists() && !data.PermitEntries.IsNull() {
+ data.PermitEntries = helpers.GetStringSetXML(value.Array())
+ } else {
+ data.PermitEntries = types.SetNull(types.StringType)
+ }
+}
+
+// End of section. //template:end updateFromBodyXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin fromBody
func (data *CommunityListStandard) fromBody(ctx context.Context, res gjson.Result) {
@@ -166,6 +234,40 @@ func (data *CommunityListStandardData) fromBody(ctx context.Context, res gjson.R
// End of section. //template:end fromBodyData
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyXML
+
+func (data *CommunityListStandard) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/deny/deny-list"); value.Exists() {
+ data.DenyEntries = helpers.GetStringSetXML(value.Array())
+ } else {
+ data.DenyEntries = types.SetNull(types.StringType)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/permit/permit-list"); value.Exists() {
+ data.PermitEntries = helpers.GetStringSetXML(value.Array())
+ } else {
+ data.PermitEntries = types.SetNull(types.StringType)
+ }
+}
+
+// End of section. //template:end fromBodyXML
+
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyDataXML
+
+func (data *CommunityListStandardData) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/deny/deny-list"); value.Exists() {
+ data.DenyEntries = helpers.GetStringSetXML(value.Array())
+ } else {
+ data.DenyEntries = types.SetNull(types.StringType)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/permit/permit-list"); value.Exists() {
+ data.PermitEntries = helpers.GetStringSetXML(value.Array())
+ } else {
+ data.PermitEntries = types.SetNull(types.StringType)
+ }
+}
+
+// End of section. //template:end fromBodyDataXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin getDeletedItems
func (data *CommunityListStandard) getDeletedItems(ctx context.Context, state CommunityListStandard) []string {
@@ -218,6 +320,58 @@ func (data *CommunityListStandard) getDeletedItems(ctx context.Context, state Co
// End of section. //template:end getDeletedItems
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletedItemsXML
+
+func (data *CommunityListStandard) addDeletedItemsXML(ctx context.Context, state CommunityListStandard, body string) string {
+ b := netconf.NewBody(body)
+ if !state.DenyEntries.IsNull() {
+ if data.DenyEntries.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/deny/deny-list")
+ } else {
+ var dataValues, stateValues []string
+ data.DenyEntries.ElementsAs(ctx, &dataValues, false)
+ state.DenyEntries.ElementsAs(ctx, &stateValues, false)
+ for _, v := range stateValues {
+ found := false
+ for _, vv := range dataValues {
+ if v == vv {
+ found = true
+ break
+ }
+ }
+ if !found {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/deny/deny-list[.=%v]", v))
+ }
+ }
+ }
+ }
+ if !state.PermitEntries.IsNull() {
+ if data.PermitEntries.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/permit/permit-list")
+ } else {
+ var dataValues, stateValues []string
+ data.PermitEntries.ElementsAs(ctx, &dataValues, false)
+ state.PermitEntries.ElementsAs(ctx, &stateValues, false)
+ for _, v := range stateValues {
+ found := false
+ for _, vv := range dataValues {
+ if v == vv {
+ found = true
+ break
+ }
+ }
+ if !found {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/permit/permit-list[.=%v]", v))
+ }
+ }
+ }
+ }
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletedItemsXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin getEmptyLeafsDelete
func (data *CommunityListStandard) getEmptyLeafsDelete(ctx context.Context) []string {
@@ -243,3 +397,19 @@ func (data *CommunityListStandard) getDeletePaths(ctx context.Context) []string
}
// End of section. //template:end getDeletePaths
+
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletePathsXML
+
+func (data *CommunityListStandard) addDeletePathsXML(ctx context.Context, body string) string {
+ b := netconf.NewBody(body)
+ if !data.DenyEntries.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/deny/deny-list")
+ }
+ if !data.PermitEntries.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/permit/permit-list")
+ }
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletePathsXML
diff --git a/internal/provider/model_iosxe_crypto_ikev2.go b/internal/provider/model_iosxe_crypto_ikev2.go
index 0656eaff..af71b3fb 100644
--- a/internal/provider/model_iosxe_crypto_ikev2.go
+++ b/internal/provider/model_iosxe_crypto_ikev2.go
@@ -28,6 +28,9 @@ import (
"github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/types"
+ "github.com/hashicorp/terraform-plugin-log/tflog"
+ "github.com/netascode/go-netconf"
+ "github.com/netascode/xmldot"
"github.com/tidwall/gjson"
"github.com/tidwall/sjson"
)
@@ -79,6 +82,17 @@ func (data CryptoIKEv2) getPathShort() string {
return matches[1]
}
+// getXPath returns the XPath for NETCONF operations
+func (data CryptoIKEv2) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/crypto/Cisco-IOS-XE-crypto:ikev2"
+ return path
+}
+
+func (data CryptoIKEv2Data) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/crypto/Cisco-IOS-XE-crypto:ikev2"
+ return path
+}
+
// End of section. //template:end getPath
// Section below is generated&owned by "gen/generator.go". //template:begin toBody
@@ -105,6 +119,34 @@ func (data CryptoIKEv2) toBody(ctx context.Context) string {
// End of section. //template:end toBody
+// Section below is generated&owned by "gen/generator.go". //template:begin toBodyXML
+
+func (data CryptoIKEv2) toBodyXML(ctx context.Context) string {
+ body := netconf.Body{}
+ if !data.NatKeepalive.IsNull() && !data.NatKeepalive.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/nat/keepalive", strconv.FormatInt(data.NatKeepalive.ValueInt64(), 10))
+ }
+ if !data.Dpd.IsNull() && !data.Dpd.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/dpd-container/dpd", strconv.FormatInt(data.Dpd.ValueInt64(), 10))
+ }
+ if !data.DpdRetryInterval.IsNull() && !data.DpdRetryInterval.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/dpd-container/retry-interval", strconv.FormatInt(data.DpdRetryInterval.ValueInt64(), 10))
+ }
+ if !data.DpdQuery.IsNull() && !data.DpdQuery.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/dpd-container/dpd-query", data.DpdQuery.ValueString())
+ }
+ if !data.HttpUrlCert.IsNull() && !data.HttpUrlCert.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/http-url/cert-leaf", data.HttpUrlCert.ValueBool())
+ }
+ bodyString, err := body.String()
+ if err != nil {
+ tflog.Error(ctx, fmt.Sprintf("Error converting body to string: %s", err))
+ }
+ return bodyString
+}
+
+// End of section. //template:end toBodyXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBody
func (data *CryptoIKEv2) updateFromBody(ctx context.Context, res gjson.Result) {
@@ -143,6 +185,40 @@ func (data *CryptoIKEv2) updateFromBody(ctx context.Context, res gjson.Result) {
// End of section. //template:end updateFromBody
+// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBodyXML
+
+func (data *CryptoIKEv2) updateFromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/nat/keepalive"); value.Exists() && !data.NatKeepalive.IsNull() {
+ data.NatKeepalive = types.Int64Value(value.Int())
+ } else {
+ data.NatKeepalive = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/dpd-container/dpd"); value.Exists() && !data.Dpd.IsNull() {
+ data.Dpd = types.Int64Value(value.Int())
+ } else {
+ data.Dpd = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/dpd-container/retry-interval"); value.Exists() && !data.DpdRetryInterval.IsNull() {
+ data.DpdRetryInterval = types.Int64Value(value.Int())
+ } else {
+ data.DpdRetryInterval = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/dpd-container/dpd-query"); value.Exists() && !data.DpdQuery.IsNull() {
+ data.DpdQuery = types.StringValue(value.String())
+ } else {
+ data.DpdQuery = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/http-url/cert-leaf"); !data.HttpUrlCert.IsNull() {
+ if value.Exists() {
+ data.HttpUrlCert = types.BoolValue(value.Bool())
+ }
+ } else {
+ data.HttpUrlCert = types.BoolNull()
+ }
+}
+
+// End of section. //template:end updateFromBodyXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin fromBody
func (data *CryptoIKEv2) fromBody(ctx context.Context, res gjson.Result) {
@@ -199,6 +275,54 @@ func (data *CryptoIKEv2Data) fromBody(ctx context.Context, res gjson.Result) {
// End of section. //template:end fromBodyData
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyXML
+
+func (data *CryptoIKEv2) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/nat/keepalive"); value.Exists() {
+ data.NatKeepalive = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/dpd-container/dpd"); value.Exists() {
+ data.Dpd = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/dpd-container/retry-interval"); value.Exists() {
+ data.DpdRetryInterval = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/dpd-container/dpd-query"); value.Exists() {
+ data.DpdQuery = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/http-url/cert-leaf"); value.Exists() {
+ data.HttpUrlCert = types.BoolValue(value.Bool())
+ } else {
+ data.HttpUrlCert = types.BoolNull()
+ }
+}
+
+// End of section. //template:end fromBodyXML
+
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyDataXML
+
+func (data *CryptoIKEv2Data) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/nat/keepalive"); value.Exists() {
+ data.NatKeepalive = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/dpd-container/dpd"); value.Exists() {
+ data.Dpd = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/dpd-container/retry-interval"); value.Exists() {
+ data.DpdRetryInterval = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/dpd-container/dpd-query"); value.Exists() {
+ data.DpdQuery = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/http-url/cert-leaf"); value.Exists() {
+ data.HttpUrlCert = types.BoolValue(value.Bool())
+ } else {
+ data.HttpUrlCert = types.BoolNull()
+ }
+}
+
+// End of section. //template:end fromBodyDataXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin getDeletedItems
func (data *CryptoIKEv2) getDeletedItems(ctx context.Context, state CryptoIKEv2) []string {
@@ -224,6 +348,31 @@ func (data *CryptoIKEv2) getDeletedItems(ctx context.Context, state CryptoIKEv2)
// End of section. //template:end getDeletedItems
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletedItemsXML
+
+func (data *CryptoIKEv2) addDeletedItemsXML(ctx context.Context, state CryptoIKEv2, body string) string {
+ b := netconf.NewBody(body)
+ if !state.NatKeepalive.IsNull() && data.NatKeepalive.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/nat/keepalive")
+ }
+ if !state.Dpd.IsNull() && data.Dpd.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/dpd-container/dpd")
+ }
+ if !state.DpdRetryInterval.IsNull() && data.DpdRetryInterval.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/dpd-container/retry-interval")
+ }
+ if !state.DpdQuery.IsNull() && data.DpdQuery.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/dpd-container/dpd-query")
+ }
+ if !state.HttpUrlCert.IsNull() && data.HttpUrlCert.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/http-url/cert-leaf")
+ }
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletedItemsXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin getEmptyLeafsDelete
func (data *CryptoIKEv2) getEmptyLeafsDelete(ctx context.Context) []string {
@@ -258,3 +407,28 @@ func (data *CryptoIKEv2) getDeletePaths(ctx context.Context) []string {
}
// End of section. //template:end getDeletePaths
+
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletePathsXML
+
+func (data *CryptoIKEv2) addDeletePathsXML(ctx context.Context, body string) string {
+ b := netconf.NewBody(body)
+ if !data.NatKeepalive.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/nat/keepalive")
+ }
+ if !data.Dpd.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/dpd-container/dpd")
+ }
+ if !data.DpdRetryInterval.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/dpd-container/retry-interval")
+ }
+ if !data.DpdQuery.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/dpd-container/dpd-query")
+ }
+ if !data.HttpUrlCert.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/http-url/cert-leaf")
+ }
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletePathsXML
diff --git a/internal/provider/model_iosxe_crypto_ikev2_keyring.go b/internal/provider/model_iosxe_crypto_ikev2_keyring.go
index 220b52f6..0abeaf65 100644
--- a/internal/provider/model_iosxe_crypto_ikev2_keyring.go
+++ b/internal/provider/model_iosxe_crypto_ikev2_keyring.go
@@ -31,6 +31,9 @@ import (
"github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/types"
+ "github.com/hashicorp/terraform-plugin-log/tflog"
+ "github.com/netascode/go-netconf"
+ "github.com/netascode/xmldot"
"github.com/tidwall/gjson"
"github.com/tidwall/sjson"
)
@@ -95,6 +98,19 @@ func (data CryptoIKEv2Keyring) getPathShort() string {
return matches[1]
}
+// getXPath returns the XPath for NETCONF operations
+func (data CryptoIKEv2Keyring) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/crypto/Cisco-IOS-XE-crypto:ikev2/keyring[name=%v]"
+ path = fmt.Sprintf(path, fmt.Sprintf("%v", data.Name.ValueString()))
+ return path
+}
+
+func (data CryptoIKEv2KeyringData) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/crypto/Cisco-IOS-XE-crypto:ikev2/keyring[name=%v]"
+ path = fmt.Sprintf(path, fmt.Sprintf("%v", data.Name.ValueString()))
+ return path
+}
+
// End of section. //template:end getPath
// Section below is generated&owned by "gen/generator.go". //template:begin toBody
@@ -168,6 +184,82 @@ func (data CryptoIKEv2Keyring) toBody(ctx context.Context) string {
// End of section. //template:end toBody
+// Section below is generated&owned by "gen/generator.go". //template:begin toBodyXML
+
+func (data CryptoIKEv2Keyring) toBodyXML(ctx context.Context) string {
+ body := netconf.Body{}
+ if !data.Name.IsNull() && !data.Name.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/name", data.Name.ValueString())
+ }
+ if len(data.Peers) > 0 {
+ for _, item := range data.Peers {
+ cBody := netconf.Body{}
+ if !item.Name.IsNull() && !item.Name.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "name", item.Name.ValueString())
+ }
+ if !item.Description.IsNull() && !item.Description.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "description", item.Description.ValueString())
+ }
+ if !item.Hostname.IsNull() && !item.Hostname.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "hostname", item.Hostname.ValueString())
+ }
+ if !item.Ipv4Address.IsNull() && !item.Ipv4Address.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "address/ipv4/ipv4-address", item.Ipv4Address.ValueString())
+ }
+ if !item.Ipv4Mask.IsNull() && !item.Ipv4Mask.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "address/ipv4/ipv4-mask", item.Ipv4Mask.ValueString())
+ }
+ if !item.Ipv6Prefix.IsNull() && !item.Ipv6Prefix.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "address/ipv6-prefix", item.Ipv6Prefix.ValueString())
+ }
+ if !item.IdentityKeyId.IsNull() && !item.IdentityKeyId.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "identity/key-id-number", item.IdentityKeyId.ValueString())
+ }
+ if !item.IdentityAddress.IsNull() && !item.IdentityAddress.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "identity/address-type", item.IdentityAddress.ValueString())
+ }
+ if !item.IdentityEmailName.IsNull() && !item.IdentityEmailName.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "identity/email-option/name", item.IdentityEmailName.ValueString())
+ }
+ if !item.IdentityEmailDomain.IsNull() && !item.IdentityEmailDomain.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "identity/email-option/domain", item.IdentityEmailDomain.ValueString())
+ }
+ if !item.IdentityFqdnName.IsNull() && !item.IdentityFqdnName.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "identity/fqdn-option/name", item.IdentityFqdnName.ValueString())
+ }
+ if !item.IdentityFqdnDomain.IsNull() && !item.IdentityFqdnDomain.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "identity/fqdn-option/domain", item.IdentityFqdnDomain.ValueString())
+ }
+ if !item.PreSharedKeyLocalEncryption.IsNull() && !item.PreSharedKeyLocalEncryption.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "pre-shared-key/local-option/encryption", item.PreSharedKeyLocalEncryption.ValueString())
+ }
+ if !item.PreSharedKeyLocal.IsNull() && !item.PreSharedKeyLocal.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "pre-shared-key/local-option/key", item.PreSharedKeyLocal.ValueString())
+ }
+ if !item.PreSharedKeyRemoteEncryption.IsNull() && !item.PreSharedKeyRemoteEncryption.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "pre-shared-key/remote-option/encryption", item.PreSharedKeyRemoteEncryption.ValueString())
+ }
+ if !item.PreSharedKeyRemote.IsNull() && !item.PreSharedKeyRemote.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "pre-shared-key/remote-option/key", item.PreSharedKeyRemote.ValueString())
+ }
+ if !item.PreSharedKeyEncryption.IsNull() && !item.PreSharedKeyEncryption.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "pre-shared-key/encryption", item.PreSharedKeyEncryption.ValueString())
+ }
+ if !item.PreSharedKey.IsNull() && !item.PreSharedKey.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "pre-shared-key/key", item.PreSharedKey.ValueString())
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/peer", cBody.Res())
+ }
+ }
+ bodyString, err := body.String()
+ if err != nil {
+ tflog.Error(ctx, fmt.Sprintf("Error converting body to string: %s", err))
+ }
+ return bodyString
+}
+
+// End of section. //template:end toBodyXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBody
func (data *CryptoIKEv2Keyring) updateFromBody(ctx context.Context, res gjson.Result) {
@@ -268,6 +360,102 @@ func (data *CryptoIKEv2Keyring) updateFromBody(ctx context.Context, res gjson.Re
// End of section. //template:end updateFromBody
+// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBodyXML
+
+func (data *CryptoIKEv2Keyring) updateFromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/name"); value.Exists() && !data.Name.IsNull() {
+ data.Name = types.StringValue(value.String())
+ } else {
+ data.Name = types.StringNull()
+ }
+ for i := range data.Peers {
+ keys := [...]string{"name"}
+ keyValues := [...]string{data.Peers[i].Name.ValueString()}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/peer").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, "name"); value.Exists() && !data.Peers[i].Name.IsNull() {
+ data.Peers[i].Name = types.StringValue(value.String())
+ } else {
+ data.Peers[i].Name = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "description"); value.Exists() && !data.Peers[i].Description.IsNull() {
+ data.Peers[i].Description = types.StringValue(value.String())
+ } else {
+ data.Peers[i].Description = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "hostname"); value.Exists() && !data.Peers[i].Hostname.IsNull() {
+ data.Peers[i].Hostname = types.StringValue(value.String())
+ } else {
+ data.Peers[i].Hostname = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "address/ipv4/ipv4-address"); value.Exists() && !data.Peers[i].Ipv4Address.IsNull() {
+ data.Peers[i].Ipv4Address = types.StringValue(value.String())
+ } else {
+ data.Peers[i].Ipv4Address = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "address/ipv4/ipv4-mask"); value.Exists() && !data.Peers[i].Ipv4Mask.IsNull() {
+ data.Peers[i].Ipv4Mask = types.StringValue(value.String())
+ } else {
+ data.Peers[i].Ipv4Mask = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "address/ipv6-prefix"); value.Exists() && !data.Peers[i].Ipv6Prefix.IsNull() {
+ data.Peers[i].Ipv6Prefix = types.StringValue(value.String())
+ } else {
+ data.Peers[i].Ipv6Prefix = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "identity/key-id-number"); value.Exists() && !data.Peers[i].IdentityKeyId.IsNull() {
+ data.Peers[i].IdentityKeyId = types.StringValue(value.String())
+ } else {
+ data.Peers[i].IdentityKeyId = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "identity/address-type"); value.Exists() && !data.Peers[i].IdentityAddress.IsNull() {
+ data.Peers[i].IdentityAddress = types.StringValue(value.String())
+ } else {
+ data.Peers[i].IdentityAddress = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "identity/email-option/name"); value.Exists() && !data.Peers[i].IdentityEmailName.IsNull() {
+ data.Peers[i].IdentityEmailName = types.StringValue(value.String())
+ } else {
+ data.Peers[i].IdentityEmailName = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "identity/email-option/domain"); value.Exists() && !data.Peers[i].IdentityEmailDomain.IsNull() {
+ data.Peers[i].IdentityEmailDomain = types.StringValue(value.String())
+ } else {
+ data.Peers[i].IdentityEmailDomain = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "identity/fqdn-option/name"); value.Exists() && !data.Peers[i].IdentityFqdnName.IsNull() {
+ data.Peers[i].IdentityFqdnName = types.StringValue(value.String())
+ } else {
+ data.Peers[i].IdentityFqdnName = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "identity/fqdn-option/domain"); value.Exists() && !data.Peers[i].IdentityFqdnDomain.IsNull() {
+ data.Peers[i].IdentityFqdnDomain = types.StringValue(value.String())
+ } else {
+ data.Peers[i].IdentityFqdnDomain = types.StringNull()
+ }
+ }
+}
+
+// End of section. //template:end updateFromBodyXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin fromBody
func (data *CryptoIKEv2Keyring) fromBody(ctx context.Context, res gjson.Result) {
@@ -414,6 +602,144 @@ func (data *CryptoIKEv2KeyringData) fromBody(ctx context.Context, res gjson.Resu
// End of section. //template:end fromBodyData
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyXML
+
+func (data *CryptoIKEv2Keyring) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/peer"); value.Exists() {
+ data.Peers = make([]CryptoIKEv2KeyringPeers, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := CryptoIKEv2KeyringPeers{}
+ if cValue := helpers.GetFromXPath(v, "name"); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "description"); cValue.Exists() {
+ item.Description = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "hostname"); cValue.Exists() {
+ item.Hostname = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "address/ipv4/ipv4-address"); cValue.Exists() {
+ item.Ipv4Address = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "address/ipv4/ipv4-mask"); cValue.Exists() {
+ item.Ipv4Mask = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "address/ipv6-prefix"); cValue.Exists() {
+ item.Ipv6Prefix = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "identity/key-id-number"); cValue.Exists() {
+ item.IdentityKeyId = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "identity/address-type"); cValue.Exists() {
+ item.IdentityAddress = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "identity/email-option/name"); cValue.Exists() {
+ item.IdentityEmailName = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "identity/email-option/domain"); cValue.Exists() {
+ item.IdentityEmailDomain = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "identity/fqdn-option/name"); cValue.Exists() {
+ item.IdentityFqdnName = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "identity/fqdn-option/domain"); cValue.Exists() {
+ item.IdentityFqdnDomain = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "pre-shared-key/local-option/encryption"); cValue.Exists() {
+ item.PreSharedKeyLocalEncryption = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "pre-shared-key/local-option/key"); cValue.Exists() {
+ item.PreSharedKeyLocal = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "pre-shared-key/remote-option/encryption"); cValue.Exists() {
+ item.PreSharedKeyRemoteEncryption = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "pre-shared-key/remote-option/key"); cValue.Exists() {
+ item.PreSharedKeyRemote = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "pre-shared-key/encryption"); cValue.Exists() {
+ item.PreSharedKeyEncryption = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "pre-shared-key/key"); cValue.Exists() {
+ item.PreSharedKey = types.StringValue(cValue.String())
+ }
+ data.Peers = append(data.Peers, item)
+ return true
+ })
+ }
+}
+
+// End of section. //template:end fromBodyXML
+
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyDataXML
+
+func (data *CryptoIKEv2KeyringData) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/peer"); value.Exists() {
+ data.Peers = make([]CryptoIKEv2KeyringPeers, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := CryptoIKEv2KeyringPeers{}
+ if cValue := helpers.GetFromXPath(v, "name"); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "description"); cValue.Exists() {
+ item.Description = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "hostname"); cValue.Exists() {
+ item.Hostname = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "address/ipv4/ipv4-address"); cValue.Exists() {
+ item.Ipv4Address = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "address/ipv4/ipv4-mask"); cValue.Exists() {
+ item.Ipv4Mask = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "address/ipv6-prefix"); cValue.Exists() {
+ item.Ipv6Prefix = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "identity/key-id-number"); cValue.Exists() {
+ item.IdentityKeyId = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "identity/address-type"); cValue.Exists() {
+ item.IdentityAddress = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "identity/email-option/name"); cValue.Exists() {
+ item.IdentityEmailName = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "identity/email-option/domain"); cValue.Exists() {
+ item.IdentityEmailDomain = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "identity/fqdn-option/name"); cValue.Exists() {
+ item.IdentityFqdnName = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "identity/fqdn-option/domain"); cValue.Exists() {
+ item.IdentityFqdnDomain = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "pre-shared-key/local-option/encryption"); cValue.Exists() {
+ item.PreSharedKeyLocalEncryption = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "pre-shared-key/local-option/key"); cValue.Exists() {
+ item.PreSharedKeyLocal = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "pre-shared-key/remote-option/encryption"); cValue.Exists() {
+ item.PreSharedKeyRemoteEncryption = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "pre-shared-key/remote-option/key"); cValue.Exists() {
+ item.PreSharedKeyRemote = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "pre-shared-key/encryption"); cValue.Exists() {
+ item.PreSharedKeyEncryption = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "pre-shared-key/key"); cValue.Exists() {
+ item.PreSharedKey = types.StringValue(cValue.String())
+ }
+ data.Peers = append(data.Peers, item)
+ return true
+ })
+ }
+}
+
+// End of section. //template:end fromBodyDataXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin getDeletedItems
func (data *CryptoIKEv2Keyring) getDeletedItems(ctx context.Context, state CryptoIKEv2Keyring) []string {
@@ -500,6 +826,97 @@ func (data *CryptoIKEv2Keyring) getDeletedItems(ctx context.Context, state Crypt
// End of section. //template:end getDeletedItems
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletedItemsXML
+
+func (data *CryptoIKEv2Keyring) addDeletedItemsXML(ctx context.Context, state CryptoIKEv2Keyring, body string) string {
+ b := netconf.NewBody(body)
+ for i := range state.Peers {
+ stateKeys := [...]string{"name"}
+ stateKeyValues := [...]string{state.Peers[i].Name.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.Peers[i].Name.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.Peers {
+ found = true
+ if state.Peers[i].Name.ValueString() != data.Peers[j].Name.ValueString() {
+ found = false
+ }
+ if found {
+ if !state.Peers[i].Description.IsNull() && data.Peers[j].Description.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/peer%v/description", predicates))
+ }
+ if !state.Peers[i].Hostname.IsNull() && data.Peers[j].Hostname.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/peer%v/hostname", predicates))
+ }
+ if !state.Peers[i].Ipv4Address.IsNull() && data.Peers[j].Ipv4Address.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/peer%v/address/ipv4/ipv4-address", predicates))
+ }
+ if !state.Peers[i].Ipv4Mask.IsNull() && data.Peers[j].Ipv4Mask.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/peer%v/address/ipv4/ipv4-mask", predicates))
+ }
+ if !state.Peers[i].Ipv6Prefix.IsNull() && data.Peers[j].Ipv6Prefix.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/peer%v/address/ipv6-prefix", predicates))
+ }
+ if !state.Peers[i].IdentityKeyId.IsNull() && data.Peers[j].IdentityKeyId.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/peer%v/identity/key-id-number", predicates))
+ }
+ if !state.Peers[i].IdentityAddress.IsNull() && data.Peers[j].IdentityAddress.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/peer%v/identity/address-type", predicates))
+ }
+ if !state.Peers[i].IdentityEmailName.IsNull() && data.Peers[j].IdentityEmailName.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/peer%v/identity/email-option/name", predicates))
+ }
+ if !state.Peers[i].IdentityEmailDomain.IsNull() && data.Peers[j].IdentityEmailDomain.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/peer%v/identity/email-option/domain", predicates))
+ }
+ if !state.Peers[i].IdentityFqdnName.IsNull() && data.Peers[j].IdentityFqdnName.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/peer%v/identity/fqdn-option/name", predicates))
+ }
+ if !state.Peers[i].IdentityFqdnDomain.IsNull() && data.Peers[j].IdentityFqdnDomain.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/peer%v/identity/fqdn-option/domain", predicates))
+ }
+ if !state.Peers[i].PreSharedKeyLocalEncryption.IsNull() && data.Peers[j].PreSharedKeyLocalEncryption.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/peer%v/pre-shared-key/local-option/encryption", predicates))
+ }
+ if !state.Peers[i].PreSharedKeyLocal.IsNull() && data.Peers[j].PreSharedKeyLocal.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/peer%v/pre-shared-key/local-option/key", predicates))
+ }
+ if !state.Peers[i].PreSharedKeyRemoteEncryption.IsNull() && data.Peers[j].PreSharedKeyRemoteEncryption.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/peer%v/pre-shared-key/remote-option/encryption", predicates))
+ }
+ if !state.Peers[i].PreSharedKeyRemote.IsNull() && data.Peers[j].PreSharedKeyRemote.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/peer%v/pre-shared-key/remote-option/key", predicates))
+ }
+ if !state.Peers[i].PreSharedKeyEncryption.IsNull() && data.Peers[j].PreSharedKeyEncryption.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/peer%v/pre-shared-key/encryption", predicates))
+ }
+ if !state.Peers[i].PreSharedKey.IsNull() && data.Peers[j].PreSharedKey.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/peer%v/pre-shared-key/key", predicates))
+ }
+ break
+ }
+ }
+ if !found {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/peer%v", predicates))
+ }
+ }
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletedItemsXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin getEmptyLeafsDelete
func (data *CryptoIKEv2Keyring) getEmptyLeafsDelete(ctx context.Context) []string {
@@ -524,3 +941,23 @@ func (data *CryptoIKEv2Keyring) getDeletePaths(ctx context.Context) []string {
}
// End of section. //template:end getDeletePaths
+
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletePathsXML
+
+func (data *CryptoIKEv2Keyring) addDeletePathsXML(ctx context.Context, body string) string {
+ b := netconf.NewBody(body)
+ for i := range data.Peers {
+ keys := [...]string{"name"}
+ keyValues := [...]string{data.Peers[i].Name.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/peer%v", predicates))
+ }
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletePathsXML
diff --git a/internal/provider/model_iosxe_crypto_ikev2_policy.go b/internal/provider/model_iosxe_crypto_ikev2_policy.go
index e0243037..c8ad1985 100644
--- a/internal/provider/model_iosxe_crypto_ikev2_policy.go
+++ b/internal/provider/model_iosxe_crypto_ikev2_policy.go
@@ -31,6 +31,9 @@ import (
"github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/types"
+ "github.com/hashicorp/terraform-plugin-log/tflog"
+ "github.com/netascode/go-netconf"
+ "github.com/netascode/xmldot"
"github.com/tidwall/gjson"
"github.com/tidwall/sjson"
)
@@ -86,6 +89,19 @@ func (data CryptoIKEv2Policy) getPathShort() string {
return matches[1]
}
+// getXPath returns the XPath for NETCONF operations
+func (data CryptoIKEv2Policy) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/crypto/Cisco-IOS-XE-crypto:ikev2/policy[name=%v]"
+ path = fmt.Sprintf(path, fmt.Sprintf("%v", data.Name.ValueString()))
+ return path
+}
+
+func (data CryptoIKEv2PolicyData) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/crypto/Cisco-IOS-XE-crypto:ikev2/policy[name=%v]"
+ path = fmt.Sprintf(path, fmt.Sprintf("%v", data.Name.ValueString()))
+ return path
+}
+
// End of section. //template:end getPath
// Section below is generated&owned by "gen/generator.go". //template:begin toBody
@@ -126,6 +142,55 @@ func (data CryptoIKEv2Policy) toBody(ctx context.Context) string {
// End of section. //template:end toBody
+// Section below is generated&owned by "gen/generator.go". //template:begin toBodyXML
+
+func (data CryptoIKEv2Policy) toBodyXML(ctx context.Context) string {
+ body := netconf.Body{}
+ if !data.Name.IsNull() && !data.Name.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/name", data.Name.ValueString())
+ }
+ if !data.MatchInboundOnly.IsNull() && !data.MatchInboundOnly.IsUnknown() {
+ if data.MatchInboundOnly.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/match/inbound-only", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/match/inbound-only")
+ }
+ }
+ if !data.MatchAddressLocalIp.IsNull() && !data.MatchAddressLocalIp.IsUnknown() {
+ var values []string
+ data.MatchAddressLocalIp.ElementsAs(ctx, &values, false)
+ for _, v := range values {
+ body = helpers.AppendFromXPath(body, data.getXPath()+"/match/address/local-ip", v)
+ }
+ }
+ if !data.MatchFvrf.IsNull() && !data.MatchFvrf.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/match/fvrf/name", data.MatchFvrf.ValueString())
+ }
+ if !data.MatchFvrfAny.IsNull() && !data.MatchFvrfAny.IsUnknown() {
+ if data.MatchFvrfAny.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/match/fvrf/any", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/match/fvrf/any")
+ }
+ }
+ if len(data.Proposals) > 0 {
+ for _, item := range data.Proposals {
+ cBody := netconf.Body{}
+ if !item.Proposals.IsNull() && !item.Proposals.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "proposals", item.Proposals.ValueString())
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/proposal", cBody.Res())
+ }
+ }
+ bodyString, err := body.String()
+ if err != nil {
+ tflog.Error(ctx, fmt.Sprintf("Error converting body to string: %s", err))
+ }
+ return bodyString
+}
+
+// End of section. //template:end toBodyXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBody
func (data *CryptoIKEv2Policy) updateFromBody(ctx context.Context, res gjson.Result) {
@@ -199,6 +264,75 @@ func (data *CryptoIKEv2Policy) updateFromBody(ctx context.Context, res gjson.Res
// End of section. //template:end updateFromBody
+// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBodyXML
+
+func (data *CryptoIKEv2Policy) updateFromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/name"); value.Exists() && !data.Name.IsNull() {
+ data.Name = types.StringValue(value.String())
+ } else {
+ data.Name = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/match/inbound-only"); !data.MatchInboundOnly.IsNull() {
+ if value.Exists() {
+ data.MatchInboundOnly = types.BoolValue(true)
+ } else {
+ data.MatchInboundOnly = types.BoolValue(false)
+ }
+ } else {
+ data.MatchInboundOnly = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/match/address/local-ip"); value.Exists() && !data.MatchAddressLocalIp.IsNull() {
+ data.MatchAddressLocalIp = helpers.GetStringListXML(value.Array())
+ } else {
+ data.MatchAddressLocalIp = types.ListNull(types.StringType)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/match/fvrf/name"); value.Exists() && !data.MatchFvrf.IsNull() {
+ data.MatchFvrf = types.StringValue(value.String())
+ } else {
+ data.MatchFvrf = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/match/fvrf/any"); !data.MatchFvrfAny.IsNull() {
+ if value.Exists() {
+ data.MatchFvrfAny = types.BoolValue(true)
+ } else {
+ data.MatchFvrfAny = types.BoolValue(false)
+ }
+ } else {
+ data.MatchFvrfAny = types.BoolNull()
+ }
+ for i := range data.Proposals {
+ keys := [...]string{"proposals"}
+ keyValues := [...]string{data.Proposals[i].Proposals.ValueString()}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/proposal").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, "proposals"); value.Exists() && !data.Proposals[i].Proposals.IsNull() {
+ data.Proposals[i].Proposals = types.StringValue(value.String())
+ } else {
+ data.Proposals[i].Proposals = types.StringNull()
+ }
+ }
+}
+
+// End of section. //template:end updateFromBodyXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin fromBody
func (data *CryptoIKEv2Policy) fromBody(ctx context.Context, res gjson.Result) {
@@ -279,6 +413,78 @@ func (data *CryptoIKEv2PolicyData) fromBody(ctx context.Context, res gjson.Resul
// End of section. //template:end fromBodyData
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyXML
+
+func (data *CryptoIKEv2Policy) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/match/inbound-only"); value.Exists() {
+ data.MatchInboundOnly = types.BoolValue(true)
+ } else {
+ data.MatchInboundOnly = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/match/address/local-ip"); value.Exists() {
+ data.MatchAddressLocalIp = helpers.GetStringListXML(value.Array())
+ } else {
+ data.MatchAddressLocalIp = types.ListNull(types.StringType)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/match/fvrf/name"); value.Exists() {
+ data.MatchFvrf = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/match/fvrf/any"); value.Exists() {
+ data.MatchFvrfAny = types.BoolValue(true)
+ } else {
+ data.MatchFvrfAny = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/proposal"); value.Exists() {
+ data.Proposals = make([]CryptoIKEv2PolicyProposals, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := CryptoIKEv2PolicyProposals{}
+ if cValue := helpers.GetFromXPath(v, "proposals"); cValue.Exists() {
+ item.Proposals = types.StringValue(cValue.String())
+ }
+ data.Proposals = append(data.Proposals, item)
+ return true
+ })
+ }
+}
+
+// End of section. //template:end fromBodyXML
+
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyDataXML
+
+func (data *CryptoIKEv2PolicyData) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/match/inbound-only"); value.Exists() {
+ data.MatchInboundOnly = types.BoolValue(true)
+ } else {
+ data.MatchInboundOnly = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/match/address/local-ip"); value.Exists() {
+ data.MatchAddressLocalIp = helpers.GetStringListXML(value.Array())
+ } else {
+ data.MatchAddressLocalIp = types.ListNull(types.StringType)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/match/fvrf/name"); value.Exists() {
+ data.MatchFvrf = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/match/fvrf/any"); value.Exists() {
+ data.MatchFvrfAny = types.BoolValue(true)
+ } else {
+ data.MatchFvrfAny = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/proposal"); value.Exists() {
+ data.Proposals = make([]CryptoIKEv2PolicyProposals, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := CryptoIKEv2PolicyProposals{}
+ if cValue := helpers.GetFromXPath(v, "proposals"); cValue.Exists() {
+ item.Proposals = types.StringValue(cValue.String())
+ }
+ data.Proposals = append(data.Proposals, item)
+ return true
+ })
+ }
+}
+
+// End of section. //template:end fromBodyDataXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin getDeletedItems
func (data *CryptoIKEv2Policy) getDeletedItems(ctx context.Context, state CryptoIKEv2Policy) []string {
@@ -344,6 +550,76 @@ func (data *CryptoIKEv2Policy) getDeletedItems(ctx context.Context, state Crypto
// End of section. //template:end getDeletedItems
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletedItemsXML
+
+func (data *CryptoIKEv2Policy) addDeletedItemsXML(ctx context.Context, state CryptoIKEv2Policy, body string) string {
+ b := netconf.NewBody(body)
+ if !state.MatchInboundOnly.IsNull() && data.MatchInboundOnly.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/match/inbound-only")
+ }
+ if !state.MatchAddressLocalIp.IsNull() {
+ if data.MatchAddressLocalIp.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/match/address/local-ip")
+ } else {
+ var dataValues, stateValues []string
+ data.MatchAddressLocalIp.ElementsAs(ctx, &dataValues, false)
+ state.MatchAddressLocalIp.ElementsAs(ctx, &stateValues, false)
+ for _, v := range stateValues {
+ found := false
+ for _, vv := range dataValues {
+ if v == vv {
+ found = true
+ break
+ }
+ }
+ if !found {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/match/address/local-ip[.=%v]", v))
+ }
+ }
+ }
+ }
+ if !state.MatchFvrf.IsNull() && data.MatchFvrf.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/match/fvrf/name")
+ }
+ if !state.MatchFvrfAny.IsNull() && data.MatchFvrfAny.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/match/fvrf/any")
+ }
+ for i := range state.Proposals {
+ stateKeys := [...]string{"proposals"}
+ stateKeyValues := [...]string{state.Proposals[i].Proposals.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.Proposals[i].Proposals.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.Proposals {
+ found = true
+ if state.Proposals[i].Proposals.ValueString() != data.Proposals[j].Proposals.ValueString() {
+ found = false
+ }
+ if found {
+ break
+ }
+ }
+ if !found {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/proposal%v", predicates))
+ }
+ }
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletedItemsXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin getEmptyLeafsDelete
func (data *CryptoIKEv2Policy) getEmptyLeafsDelete(ctx context.Context) []string {
@@ -387,3 +663,35 @@ func (data *CryptoIKEv2Policy) getDeletePaths(ctx context.Context) []string {
}
// End of section. //template:end getDeletePaths
+
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletePathsXML
+
+func (data *CryptoIKEv2Policy) addDeletePathsXML(ctx context.Context, body string) string {
+ b := netconf.NewBody(body)
+ if !data.MatchInboundOnly.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/match/inbound-only")
+ }
+ if !data.MatchAddressLocalIp.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/match/address/local-ip")
+ }
+ if !data.MatchFvrf.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/match/fvrf/name")
+ }
+ if !data.MatchFvrfAny.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/match/fvrf/any")
+ }
+ for i := range data.Proposals {
+ keys := [...]string{"proposals"}
+ keyValues := [...]string{data.Proposals[i].Proposals.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/proposal%v", predicates))
+ }
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletePathsXML
diff --git a/internal/provider/model_iosxe_crypto_ikev2_profile.go b/internal/provider/model_iosxe_crypto_ikev2_profile.go
index fe4919a5..94322ff0 100644
--- a/internal/provider/model_iosxe_crypto_ikev2_profile.go
+++ b/internal/provider/model_iosxe_crypto_ikev2_profile.go
@@ -31,6 +31,9 @@ import (
"github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/types"
+ "github.com/hashicorp/terraform-plugin-log/tflog"
+ "github.com/netascode/go-netconf"
+ "github.com/netascode/xmldot"
"github.com/tidwall/gjson"
"github.com/tidwall/sjson"
)
@@ -114,6 +117,19 @@ func (data CryptoIKEv2Profile) getPathShort() string {
return matches[1]
}
+// getXPath returns the XPath for NETCONF operations
+func (data CryptoIKEv2Profile) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/crypto/Cisco-IOS-XE-crypto:ikev2/profile[name=%v]"
+ path = fmt.Sprintf(path, fmt.Sprintf("%v", data.Name.ValueString()))
+ return path
+}
+
+func (data CryptoIKEv2ProfileData) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/crypto/Cisco-IOS-XE-crypto:ikev2/profile[name=%v]"
+ path = fmt.Sprintf(path, fmt.Sprintf("%v", data.Name.ValueString()))
+ return path
+}
+
// End of section. //template:end getPath
// Section below is generated&owned by "gen/generator.go". //template:begin toBody
@@ -202,6 +218,109 @@ func (data CryptoIKEv2Profile) toBody(ctx context.Context) string {
// End of section. //template:end toBody
+// Section below is generated&owned by "gen/generator.go". //template:begin toBodyXML
+
+func (data CryptoIKEv2Profile) toBodyXML(ctx context.Context) string {
+ body := netconf.Body{}
+ if !data.Name.IsNull() && !data.Name.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/name", data.Name.ValueString())
+ }
+ if !data.Description.IsNull() && !data.Description.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/description", data.Description.ValueString())
+ }
+ if !data.AuthenticationRemotePreShare.IsNull() && !data.AuthenticationRemotePreShare.IsUnknown() {
+ if data.AuthenticationRemotePreShare.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/authentication/remote/pre-share", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/authentication/remote/pre-share")
+ }
+ }
+ if !data.AuthenticationLocalPreShare.IsNull() && !data.AuthenticationLocalPreShare.IsUnknown() {
+ if data.AuthenticationLocalPreShare.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/authentication/local/pre-share", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/authentication/local/pre-share")
+ }
+ }
+ if !data.IdentityLocalAddress.IsNull() && !data.IdentityLocalAddress.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/identity/local/address", data.IdentityLocalAddress.ValueString())
+ }
+ if !data.IdentityLocalKeyId.IsNull() && !data.IdentityLocalKeyId.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/identity/local/key-id", data.IdentityLocalKeyId.ValueString())
+ }
+ if !data.MatchInboundOnly.IsNull() && !data.MatchInboundOnly.IsUnknown() {
+ if data.MatchInboundOnly.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/match/inbound-only", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/match/inbound-only")
+ }
+ }
+ if !data.MatchAddressLocalIp.IsNull() && !data.MatchAddressLocalIp.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/match/address/local/ip", data.MatchAddressLocalIp.ValueString())
+ }
+ if !data.MatchFvrf.IsNull() && !data.MatchFvrf.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/match/fvrf/name", data.MatchFvrf.ValueString())
+ }
+ if !data.MatchFvrfAny.IsNull() && !data.MatchFvrfAny.IsUnknown() {
+ if data.MatchFvrfAny.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/match/fvrf/any", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/match/fvrf/any")
+ }
+ }
+ if len(data.MatchIdentityRemoteIpv4Addresses) > 0 {
+ for _, item := range data.MatchIdentityRemoteIpv4Addresses {
+ cBody := netconf.Body{}
+ if !item.Address.IsNull() && !item.Address.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "ipv4-address", item.Address.ValueString())
+ }
+ if !item.Mask.IsNull() && !item.Mask.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "ipv4-mask", item.Mask.ValueString())
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/match/identity/remote/address/ipv4", cBody.Res())
+ }
+ }
+ if !data.MatchIdentityRemoteIpv6Prefixes.IsNull() && !data.MatchIdentityRemoteIpv6Prefixes.IsUnknown() {
+ var values []string
+ data.MatchIdentityRemoteIpv6Prefixes.ElementsAs(ctx, &values, false)
+ for _, v := range values {
+ body = helpers.AppendFromXPath(body, data.getXPath()+"/match/identity/remote/address/ipv6-prefix", v)
+ }
+ }
+ if !data.MatchIdentityRemoteKeys.IsNull() && !data.MatchIdentityRemoteKeys.IsUnknown() {
+ var values []string
+ data.MatchIdentityRemoteKeys.ElementsAs(ctx, &values, false)
+ for _, v := range values {
+ body = helpers.AppendFromXPath(body, data.getXPath()+"/match/identity/remote/key-ids", v)
+ }
+ }
+ if !data.KeyringLocal.IsNull() && !data.KeyringLocal.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/keyring/local/name", data.KeyringLocal.ValueString())
+ }
+ if !data.Ivrf.IsNull() && !data.Ivrf.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ivrf", data.Ivrf.ValueString())
+ }
+ if !data.DpdInterval.IsNull() && !data.DpdInterval.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/dpd/interval", strconv.FormatInt(data.DpdInterval.ValueInt64(), 10))
+ }
+ if !data.DpdRetry.IsNull() && !data.DpdRetry.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/dpd/retry", strconv.FormatInt(data.DpdRetry.ValueInt64(), 10))
+ }
+ if !data.DpdQuery.IsNull() && !data.DpdQuery.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/dpd/query", data.DpdQuery.ValueString())
+ }
+ if !data.ConfigExchangeRequest.IsNull() && !data.ConfigExchangeRequest.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/config-exchange/request-1", data.ConfigExchangeRequest.ValueBool())
+ }
+ bodyString, err := body.String()
+ if err != nil {
+ tflog.Error(ctx, fmt.Sprintf("Error converting body to string: %s", err))
+ }
+ return bodyString
+}
+
+// End of section. //template:end toBodyXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBody
func (data *CryptoIKEv2Profile) updateFromBody(ctx context.Context, res gjson.Result) {
@@ -355,6 +474,155 @@ func (data *CryptoIKEv2Profile) updateFromBody(ctx context.Context, res gjson.Re
// End of section. //template:end updateFromBody
+// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBodyXML
+
+func (data *CryptoIKEv2Profile) updateFromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/name"); value.Exists() && !data.Name.IsNull() {
+ data.Name = types.StringValue(value.String())
+ } else {
+ data.Name = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/description"); value.Exists() && !data.Description.IsNull() {
+ data.Description = types.StringValue(value.String())
+ } else {
+ data.Description = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/authentication/remote/pre-share"); !data.AuthenticationRemotePreShare.IsNull() {
+ if value.Exists() {
+ data.AuthenticationRemotePreShare = types.BoolValue(true)
+ } else {
+ data.AuthenticationRemotePreShare = types.BoolValue(false)
+ }
+ } else {
+ data.AuthenticationRemotePreShare = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/authentication/local/pre-share"); !data.AuthenticationLocalPreShare.IsNull() {
+ if value.Exists() {
+ data.AuthenticationLocalPreShare = types.BoolValue(true)
+ } else {
+ data.AuthenticationLocalPreShare = types.BoolValue(false)
+ }
+ } else {
+ data.AuthenticationLocalPreShare = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/identity/local/address"); value.Exists() && !data.IdentityLocalAddress.IsNull() {
+ data.IdentityLocalAddress = types.StringValue(value.String())
+ } else {
+ data.IdentityLocalAddress = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/identity/local/key-id"); value.Exists() && !data.IdentityLocalKeyId.IsNull() {
+ data.IdentityLocalKeyId = types.StringValue(value.String())
+ } else {
+ data.IdentityLocalKeyId = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/match/inbound-only"); !data.MatchInboundOnly.IsNull() {
+ if value.Exists() {
+ data.MatchInboundOnly = types.BoolValue(true)
+ } else {
+ data.MatchInboundOnly = types.BoolValue(false)
+ }
+ } else {
+ data.MatchInboundOnly = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/match/address/local/ip"); value.Exists() && !data.MatchAddressLocalIp.IsNull() {
+ data.MatchAddressLocalIp = types.StringValue(value.String())
+ } else {
+ data.MatchAddressLocalIp = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/match/fvrf/name"); value.Exists() && !data.MatchFvrf.IsNull() {
+ data.MatchFvrf = types.StringValue(value.String())
+ } else {
+ data.MatchFvrf = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/match/fvrf/any"); !data.MatchFvrfAny.IsNull() {
+ if value.Exists() {
+ data.MatchFvrfAny = types.BoolValue(true)
+ } else {
+ data.MatchFvrfAny = types.BoolValue(false)
+ }
+ } else {
+ data.MatchFvrfAny = types.BoolNull()
+ }
+ for i := range data.MatchIdentityRemoteIpv4Addresses {
+ keys := [...]string{"ipv4-address"}
+ keyValues := [...]string{data.MatchIdentityRemoteIpv4Addresses[i].Address.ValueString()}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/match/identity/remote/address/ipv4").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, "ipv4-address"); value.Exists() && !data.MatchIdentityRemoteIpv4Addresses[i].Address.IsNull() {
+ data.MatchIdentityRemoteIpv4Addresses[i].Address = types.StringValue(value.String())
+ } else {
+ data.MatchIdentityRemoteIpv4Addresses[i].Address = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "ipv4-mask"); value.Exists() && !data.MatchIdentityRemoteIpv4Addresses[i].Mask.IsNull() {
+ data.MatchIdentityRemoteIpv4Addresses[i].Mask = types.StringValue(value.String())
+ } else {
+ data.MatchIdentityRemoteIpv4Addresses[i].Mask = types.StringNull()
+ }
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/match/identity/remote/address/ipv6-prefix"); value.Exists() && !data.MatchIdentityRemoteIpv6Prefixes.IsNull() {
+ data.MatchIdentityRemoteIpv6Prefixes = helpers.GetStringListXML(value.Array())
+ } else {
+ data.MatchIdentityRemoteIpv6Prefixes = types.ListNull(types.StringType)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/match/identity/remote/key-ids"); value.Exists() && !data.MatchIdentityRemoteKeys.IsNull() {
+ data.MatchIdentityRemoteKeys = helpers.GetStringListXML(value.Array())
+ } else {
+ data.MatchIdentityRemoteKeys = types.ListNull(types.StringType)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/keyring/local/name"); value.Exists() && !data.KeyringLocal.IsNull() {
+ data.KeyringLocal = types.StringValue(value.String())
+ } else {
+ data.KeyringLocal = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ivrf"); value.Exists() && !data.Ivrf.IsNull() {
+ data.Ivrf = types.StringValue(value.String())
+ } else {
+ data.Ivrf = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/dpd/interval"); value.Exists() && !data.DpdInterval.IsNull() {
+ data.DpdInterval = types.Int64Value(value.Int())
+ } else {
+ data.DpdInterval = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/dpd/retry"); value.Exists() && !data.DpdRetry.IsNull() {
+ data.DpdRetry = types.Int64Value(value.Int())
+ } else {
+ data.DpdRetry = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/dpd/query"); value.Exists() && !data.DpdQuery.IsNull() {
+ data.DpdQuery = types.StringValue(value.String())
+ } else {
+ data.DpdQuery = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/config-exchange/request-1"); !data.ConfigExchangeRequest.IsNull() {
+ if value.Exists() {
+ data.ConfigExchangeRequest = types.BoolValue(value.Bool())
+ }
+ } else {
+ data.ConfigExchangeRequest = types.BoolNull()
+ }
+}
+
+// End of section. //template:end updateFromBodyXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin fromBody
func (data *CryptoIKEv2Profile) fromBody(ctx context.Context, res gjson.Result) {
@@ -535,6 +803,178 @@ func (data *CryptoIKEv2ProfileData) fromBody(ctx context.Context, res gjson.Resu
// End of section. //template:end fromBodyData
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyXML
+
+func (data *CryptoIKEv2Profile) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/description"); value.Exists() {
+ data.Description = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/authentication/remote/pre-share"); value.Exists() {
+ data.AuthenticationRemotePreShare = types.BoolValue(true)
+ } else {
+ data.AuthenticationRemotePreShare = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/authentication/local/pre-share"); value.Exists() {
+ data.AuthenticationLocalPreShare = types.BoolValue(true)
+ } else {
+ data.AuthenticationLocalPreShare = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/identity/local/address"); value.Exists() {
+ data.IdentityLocalAddress = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/identity/local/key-id"); value.Exists() {
+ data.IdentityLocalKeyId = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/match/inbound-only"); value.Exists() {
+ data.MatchInboundOnly = types.BoolValue(true)
+ } else {
+ data.MatchInboundOnly = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/match/address/local/ip"); value.Exists() {
+ data.MatchAddressLocalIp = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/match/fvrf/name"); value.Exists() {
+ data.MatchFvrf = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/match/fvrf/any"); value.Exists() {
+ data.MatchFvrfAny = types.BoolValue(true)
+ } else {
+ data.MatchFvrfAny = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/match/identity/remote/address/ipv4"); value.Exists() {
+ data.MatchIdentityRemoteIpv4Addresses = make([]CryptoIKEv2ProfileMatchIdentityRemoteIpv4Addresses, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := CryptoIKEv2ProfileMatchIdentityRemoteIpv4Addresses{}
+ if cValue := helpers.GetFromXPath(v, "ipv4-address"); cValue.Exists() {
+ item.Address = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "ipv4-mask"); cValue.Exists() {
+ item.Mask = types.StringValue(cValue.String())
+ }
+ data.MatchIdentityRemoteIpv4Addresses = append(data.MatchIdentityRemoteIpv4Addresses, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/match/identity/remote/address/ipv6-prefix"); value.Exists() {
+ data.MatchIdentityRemoteIpv6Prefixes = helpers.GetStringListXML(value.Array())
+ } else {
+ data.MatchIdentityRemoteIpv6Prefixes = types.ListNull(types.StringType)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/match/identity/remote/key-ids"); value.Exists() {
+ data.MatchIdentityRemoteKeys = helpers.GetStringListXML(value.Array())
+ } else {
+ data.MatchIdentityRemoteKeys = types.ListNull(types.StringType)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/keyring/local/name"); value.Exists() {
+ data.KeyringLocal = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ivrf"); value.Exists() {
+ data.Ivrf = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/dpd/interval"); value.Exists() {
+ data.DpdInterval = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/dpd/retry"); value.Exists() {
+ data.DpdRetry = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/dpd/query"); value.Exists() {
+ data.DpdQuery = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/config-exchange/request-1"); value.Exists() {
+ data.ConfigExchangeRequest = types.BoolValue(value.Bool())
+ } else {
+ data.ConfigExchangeRequest = types.BoolNull()
+ }
+}
+
+// End of section. //template:end fromBodyXML
+
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyDataXML
+
+func (data *CryptoIKEv2ProfileData) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/description"); value.Exists() {
+ data.Description = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/authentication/remote/pre-share"); value.Exists() {
+ data.AuthenticationRemotePreShare = types.BoolValue(true)
+ } else {
+ data.AuthenticationRemotePreShare = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/authentication/local/pre-share"); value.Exists() {
+ data.AuthenticationLocalPreShare = types.BoolValue(true)
+ } else {
+ data.AuthenticationLocalPreShare = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/identity/local/address"); value.Exists() {
+ data.IdentityLocalAddress = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/identity/local/key-id"); value.Exists() {
+ data.IdentityLocalKeyId = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/match/inbound-only"); value.Exists() {
+ data.MatchInboundOnly = types.BoolValue(true)
+ } else {
+ data.MatchInboundOnly = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/match/address/local/ip"); value.Exists() {
+ data.MatchAddressLocalIp = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/match/fvrf/name"); value.Exists() {
+ data.MatchFvrf = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/match/fvrf/any"); value.Exists() {
+ data.MatchFvrfAny = types.BoolValue(true)
+ } else {
+ data.MatchFvrfAny = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/match/identity/remote/address/ipv4"); value.Exists() {
+ data.MatchIdentityRemoteIpv4Addresses = make([]CryptoIKEv2ProfileMatchIdentityRemoteIpv4Addresses, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := CryptoIKEv2ProfileMatchIdentityRemoteIpv4Addresses{}
+ if cValue := helpers.GetFromXPath(v, "ipv4-address"); cValue.Exists() {
+ item.Address = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "ipv4-mask"); cValue.Exists() {
+ item.Mask = types.StringValue(cValue.String())
+ }
+ data.MatchIdentityRemoteIpv4Addresses = append(data.MatchIdentityRemoteIpv4Addresses, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/match/identity/remote/address/ipv6-prefix"); value.Exists() {
+ data.MatchIdentityRemoteIpv6Prefixes = helpers.GetStringListXML(value.Array())
+ } else {
+ data.MatchIdentityRemoteIpv6Prefixes = types.ListNull(types.StringType)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/match/identity/remote/key-ids"); value.Exists() {
+ data.MatchIdentityRemoteKeys = helpers.GetStringListXML(value.Array())
+ } else {
+ data.MatchIdentityRemoteKeys = types.ListNull(types.StringType)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/keyring/local/name"); value.Exists() {
+ data.KeyringLocal = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ivrf"); value.Exists() {
+ data.Ivrf = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/dpd/interval"); value.Exists() {
+ data.DpdInterval = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/dpd/retry"); value.Exists() {
+ data.DpdRetry = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/dpd/query"); value.Exists() {
+ data.DpdQuery = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/config-exchange/request-1"); value.Exists() {
+ data.ConfigExchangeRequest = types.BoolValue(value.Bool())
+ } else {
+ data.ConfigExchangeRequest = types.BoolNull()
+ }
+}
+
+// End of section. //template:end fromBodyDataXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin getDeletedItems
func (data *CryptoIKEv2Profile) getDeletedItems(ctx context.Context, state CryptoIKEv2Profile) []string {
@@ -660,6 +1100,136 @@ func (data *CryptoIKEv2Profile) getDeletedItems(ctx context.Context, state Crypt
// End of section. //template:end getDeletedItems
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletedItemsXML
+
+func (data *CryptoIKEv2Profile) addDeletedItemsXML(ctx context.Context, state CryptoIKEv2Profile, body string) string {
+ b := netconf.NewBody(body)
+ if !state.Description.IsNull() && data.Description.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/description")
+ }
+ if !state.AuthenticationRemotePreShare.IsNull() && data.AuthenticationRemotePreShare.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/authentication/remote/pre-share")
+ }
+ if !state.AuthenticationLocalPreShare.IsNull() && data.AuthenticationLocalPreShare.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/authentication/local/pre-share")
+ }
+ if !state.IdentityLocalAddress.IsNull() && data.IdentityLocalAddress.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/identity/local/address")
+ }
+ if !state.IdentityLocalKeyId.IsNull() && data.IdentityLocalKeyId.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/identity/local/key-id")
+ }
+ if !state.MatchInboundOnly.IsNull() && data.MatchInboundOnly.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/match/inbound-only")
+ }
+ if !state.MatchAddressLocalIp.IsNull() && data.MatchAddressLocalIp.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/match/address/local/ip")
+ }
+ if !state.MatchFvrf.IsNull() && data.MatchFvrf.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/match/fvrf/name")
+ }
+ if !state.MatchFvrfAny.IsNull() && data.MatchFvrfAny.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/match/fvrf/any")
+ }
+ for i := range state.MatchIdentityRemoteIpv4Addresses {
+ stateKeys := [...]string{"ipv4-address"}
+ stateKeyValues := [...]string{state.MatchIdentityRemoteIpv4Addresses[i].Address.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.MatchIdentityRemoteIpv4Addresses[i].Address.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.MatchIdentityRemoteIpv4Addresses {
+ found = true
+ if state.MatchIdentityRemoteIpv4Addresses[i].Address.ValueString() != data.MatchIdentityRemoteIpv4Addresses[j].Address.ValueString() {
+ found = false
+ }
+ if found {
+ if !state.MatchIdentityRemoteIpv4Addresses[i].Mask.IsNull() && data.MatchIdentityRemoteIpv4Addresses[j].Mask.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/match/identity/remote/address/ipv4%v/ipv4-mask", predicates))
+ }
+ break
+ }
+ }
+ if !found {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/match/identity/remote/address/ipv4%v", predicates))
+ }
+ }
+ if !state.MatchIdentityRemoteIpv6Prefixes.IsNull() {
+ if data.MatchIdentityRemoteIpv6Prefixes.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/match/identity/remote/address/ipv6-prefix")
+ } else {
+ var dataValues, stateValues []string
+ data.MatchIdentityRemoteIpv6Prefixes.ElementsAs(ctx, &dataValues, false)
+ state.MatchIdentityRemoteIpv6Prefixes.ElementsAs(ctx, &stateValues, false)
+ for _, v := range stateValues {
+ found := false
+ for _, vv := range dataValues {
+ if v == vv {
+ found = true
+ break
+ }
+ }
+ if !found {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/match/identity/remote/address/ipv6-prefix[.=%v]", v))
+ }
+ }
+ }
+ }
+ if !state.MatchIdentityRemoteKeys.IsNull() {
+ if data.MatchIdentityRemoteKeys.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/match/identity/remote/key-ids")
+ } else {
+ var dataValues, stateValues []string
+ data.MatchIdentityRemoteKeys.ElementsAs(ctx, &dataValues, false)
+ state.MatchIdentityRemoteKeys.ElementsAs(ctx, &stateValues, false)
+ for _, v := range stateValues {
+ found := false
+ for _, vv := range dataValues {
+ if v == vv {
+ found = true
+ break
+ }
+ }
+ if !found {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/match/identity/remote/key-ids[.=%v]", v))
+ }
+ }
+ }
+ }
+ if !state.KeyringLocal.IsNull() && data.KeyringLocal.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/keyring/local/name")
+ }
+ if !state.Ivrf.IsNull() && data.Ivrf.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ivrf")
+ }
+ if !state.DpdInterval.IsNull() && data.DpdInterval.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/dpd/interval")
+ }
+ if !state.DpdRetry.IsNull() && data.DpdRetry.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/dpd/retry")
+ }
+ if !state.DpdQuery.IsNull() && data.DpdQuery.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/dpd/query")
+ }
+ if !state.ConfigExchangeRequest.IsNull() && data.ConfigExchangeRequest.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/config-exchange/request-1")
+ }
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletedItemsXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin getEmptyLeafsDelete
func (data *CryptoIKEv2Profile) getEmptyLeafsDelete(ctx context.Context) []string {
@@ -748,3 +1318,74 @@ func (data *CryptoIKEv2Profile) getDeletePaths(ctx context.Context) []string {
}
// End of section. //template:end getDeletePaths
+
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletePathsXML
+
+func (data *CryptoIKEv2Profile) addDeletePathsXML(ctx context.Context, body string) string {
+ b := netconf.NewBody(body)
+ if !data.Description.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/description")
+ }
+ if !data.AuthenticationRemotePreShare.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/authentication/remote/pre-share")
+ }
+ if !data.AuthenticationLocalPreShare.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/authentication/local/pre-share")
+ }
+ if !data.IdentityLocalAddress.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/identity/local/address")
+ }
+ if !data.IdentityLocalKeyId.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/identity/local/key-id")
+ }
+ if !data.MatchInboundOnly.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/match/inbound-only")
+ }
+ if !data.MatchAddressLocalIp.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/match/address/local/ip")
+ }
+ if !data.MatchFvrf.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/match/fvrf/name")
+ }
+ if !data.MatchFvrfAny.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/match/fvrf/any")
+ }
+ for i := range data.MatchIdentityRemoteIpv4Addresses {
+ keys := [...]string{"ipv4-address"}
+ keyValues := [...]string{data.MatchIdentityRemoteIpv4Addresses[i].Address.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/match/identity/remote/address/ipv4%v", predicates))
+ }
+ if !data.MatchIdentityRemoteIpv6Prefixes.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/match/identity/remote/address/ipv6-prefix")
+ }
+ if !data.MatchIdentityRemoteKeys.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/match/identity/remote/key-ids")
+ }
+ if !data.KeyringLocal.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/keyring/local/name")
+ }
+ if !data.Ivrf.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ivrf")
+ }
+ if !data.DpdInterval.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/dpd/interval")
+ }
+ if !data.DpdRetry.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/dpd/retry")
+ }
+ if !data.DpdQuery.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/dpd/query")
+ }
+ if !data.ConfigExchangeRequest.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/config-exchange/request-1")
+ }
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletePathsXML
diff --git a/internal/provider/model_iosxe_crypto_ikev2_proposal.go b/internal/provider/model_iosxe_crypto_ikev2_proposal.go
index 330044f9..0e914104 100644
--- a/internal/provider/model_iosxe_crypto_ikev2_proposal.go
+++ b/internal/provider/model_iosxe_crypto_ikev2_proposal.go
@@ -28,6 +28,9 @@ import (
"github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/types"
+ "github.com/hashicorp/terraform-plugin-log/tflog"
+ "github.com/netascode/go-netconf"
+ "github.com/netascode/xmldot"
"github.com/tidwall/gjson"
"github.com/tidwall/sjson"
)
@@ -120,6 +123,19 @@ func (data CryptoIKEv2Proposal) getPathShort() string {
return matches[1]
}
+// getXPath returns the XPath for NETCONF operations
+func (data CryptoIKEv2Proposal) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/crypto/Cisco-IOS-XE-crypto:ikev2/proposal[name=%v]"
+ path = fmt.Sprintf(path, fmt.Sprintf("%v", data.Name.ValueString()))
+ return path
+}
+
+func (data CryptoIKEv2ProposalData) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/crypto/Cisco-IOS-XE-crypto:ikev2/proposal[name=%v]"
+ path = fmt.Sprintf(path, fmt.Sprintf("%v", data.Name.ValueString()))
+ return path
+}
+
// End of section. //template:end getPath
// Section below is generated&owned by "gen/generator.go". //template:begin toBody
@@ -259,6 +275,197 @@ func (data CryptoIKEv2Proposal) toBody(ctx context.Context) string {
// End of section. //template:end toBody
+// Section below is generated&owned by "gen/generator.go". //template:begin toBodyXML
+
+func (data CryptoIKEv2Proposal) toBodyXML(ctx context.Context) string {
+ body := netconf.Body{}
+ if !data.Name.IsNull() && !data.Name.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/name", data.Name.ValueString())
+ }
+ if !data.EncryptionEn3des.IsNull() && !data.EncryptionEn3des.IsUnknown() {
+ if data.EncryptionEn3des.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/encryption/en-3des", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/encryption/en-3des")
+ }
+ }
+ if !data.EncryptionAesCbc128.IsNull() && !data.EncryptionAesCbc128.IsUnknown() {
+ if data.EncryptionAesCbc128.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/encryption/aes-cbc-128", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/encryption/aes-cbc-128")
+ }
+ }
+ if !data.EncryptionAesCbc192.IsNull() && !data.EncryptionAesCbc192.IsUnknown() {
+ if data.EncryptionAesCbc192.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/encryption/aes-cbc-192", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/encryption/aes-cbc-192")
+ }
+ }
+ if !data.EncryptionAesCbc256.IsNull() && !data.EncryptionAesCbc256.IsUnknown() {
+ if data.EncryptionAesCbc256.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/encryption/aes-cbc-256", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/encryption/aes-cbc-256")
+ }
+ }
+ if !data.EncryptionAesGcm128.IsNull() && !data.EncryptionAesGcm128.IsUnknown() {
+ if data.EncryptionAesGcm128.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/encryption/aes-gcm-128", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/encryption/aes-gcm-128")
+ }
+ }
+ if !data.EncryptionAesGcm256.IsNull() && !data.EncryptionAesGcm256.IsUnknown() {
+ if data.EncryptionAesGcm256.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/encryption/aes-gcm-256", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/encryption/aes-gcm-256")
+ }
+ }
+ if !data.GroupOne.IsNull() && !data.GroupOne.IsUnknown() {
+ if data.GroupOne.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/group/one", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/group/one")
+ }
+ }
+ if !data.GroupTwo.IsNull() && !data.GroupTwo.IsUnknown() {
+ if data.GroupTwo.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/group/two", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/group/two")
+ }
+ }
+ if !data.GroupFourteen.IsNull() && !data.GroupFourteen.IsUnknown() {
+ if data.GroupFourteen.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/group/fourteen", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/group/fourteen")
+ }
+ }
+ if !data.GroupFifteen.IsNull() && !data.GroupFifteen.IsUnknown() {
+ if data.GroupFifteen.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/group/fifteen", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/group/fifteen")
+ }
+ }
+ if !data.GroupSixteen.IsNull() && !data.GroupSixteen.IsUnknown() {
+ if data.GroupSixteen.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/group/sixteen", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/group/sixteen")
+ }
+ }
+ if !data.GroupNineteen.IsNull() && !data.GroupNineteen.IsUnknown() {
+ if data.GroupNineteen.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/group/nineteen", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/group/nineteen")
+ }
+ }
+ if !data.GroupTwenty.IsNull() && !data.GroupTwenty.IsUnknown() {
+ if data.GroupTwenty.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/group/twenty", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/group/twenty")
+ }
+ }
+ if !data.GroupTwentyOne.IsNull() && !data.GroupTwentyOne.IsUnknown() {
+ if data.GroupTwentyOne.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/group/twenty-one", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/group/twenty-one")
+ }
+ }
+ if !data.GroupTwentyFour.IsNull() && !data.GroupTwentyFour.IsUnknown() {
+ if data.GroupTwentyFour.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/group/twenty-four", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/group/twenty-four")
+ }
+ }
+ if !data.IntegrityMd5.IsNull() && !data.IntegrityMd5.IsUnknown() {
+ if data.IntegrityMd5.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/integrity/md5", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/integrity/md5")
+ }
+ }
+ if !data.IntegritySha1.IsNull() && !data.IntegritySha1.IsUnknown() {
+ if data.IntegritySha1.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/integrity/sha1", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/integrity/sha1")
+ }
+ }
+ if !data.IntegritySha256.IsNull() && !data.IntegritySha256.IsUnknown() {
+ if data.IntegritySha256.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/integrity/sha256", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/integrity/sha256")
+ }
+ }
+ if !data.IntegritySha384.IsNull() && !data.IntegritySha384.IsUnknown() {
+ if data.IntegritySha384.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/integrity/sha384", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/integrity/sha384")
+ }
+ }
+ if !data.IntegritySha512.IsNull() && !data.IntegritySha512.IsUnknown() {
+ if data.IntegritySha512.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/integrity/sha512", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/integrity/sha512")
+ }
+ }
+ if !data.PrfMd5.IsNull() && !data.PrfMd5.IsUnknown() {
+ if data.PrfMd5.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/prf/md5", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/prf/md5")
+ }
+ }
+ if !data.PrfSha1.IsNull() && !data.PrfSha1.IsUnknown() {
+ if data.PrfSha1.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/prf/sha1", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/prf/sha1")
+ }
+ }
+ if !data.PrfSha256.IsNull() && !data.PrfSha256.IsUnknown() {
+ if data.PrfSha256.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/prf/sha256", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/prf/sha256")
+ }
+ }
+ if !data.PrfSha384.IsNull() && !data.PrfSha384.IsUnknown() {
+ if data.PrfSha384.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/prf/sha384", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/prf/sha384")
+ }
+ }
+ if !data.PrfSha512.IsNull() && !data.PrfSha512.IsUnknown() {
+ if data.PrfSha512.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/prf/sha512", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/prf/sha512")
+ }
+ }
+ bodyString, err := body.String()
+ if err != nil {
+ tflog.Error(ctx, fmt.Sprintf("Error converting body to string: %s", err))
+ }
+ return bodyString
+}
+
+// End of section. //template:end toBodyXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBody
func (data *CryptoIKEv2Proposal) updateFromBody(ctx context.Context, res gjson.Result) {
@@ -494,15 +701,388 @@ func (data *CryptoIKEv2Proposal) updateFromBody(ctx context.Context, res gjson.R
data.PrfSha512 = types.BoolValue(false)
}
} else {
- data.PrfSha512 = types.BoolNull()
+ data.PrfSha512 = types.BoolNull()
+ }
+}
+
+// End of section. //template:end updateFromBody
+
+// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBodyXML
+
+func (data *CryptoIKEv2Proposal) updateFromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/name"); value.Exists() && !data.Name.IsNull() {
+ data.Name = types.StringValue(value.String())
+ } else {
+ data.Name = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/encryption/en-3des"); !data.EncryptionEn3des.IsNull() {
+ if value.Exists() {
+ data.EncryptionEn3des = types.BoolValue(true)
+ } else {
+ data.EncryptionEn3des = types.BoolValue(false)
+ }
+ } else {
+ data.EncryptionEn3des = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/encryption/aes-cbc-128"); !data.EncryptionAesCbc128.IsNull() {
+ if value.Exists() {
+ data.EncryptionAesCbc128 = types.BoolValue(true)
+ } else {
+ data.EncryptionAesCbc128 = types.BoolValue(false)
+ }
+ } else {
+ data.EncryptionAesCbc128 = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/encryption/aes-cbc-192"); !data.EncryptionAesCbc192.IsNull() {
+ if value.Exists() {
+ data.EncryptionAesCbc192 = types.BoolValue(true)
+ } else {
+ data.EncryptionAesCbc192 = types.BoolValue(false)
+ }
+ } else {
+ data.EncryptionAesCbc192 = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/encryption/aes-cbc-256"); !data.EncryptionAesCbc256.IsNull() {
+ if value.Exists() {
+ data.EncryptionAesCbc256 = types.BoolValue(true)
+ } else {
+ data.EncryptionAesCbc256 = types.BoolValue(false)
+ }
+ } else {
+ data.EncryptionAesCbc256 = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/encryption/aes-gcm-128"); !data.EncryptionAesGcm128.IsNull() {
+ if value.Exists() {
+ data.EncryptionAesGcm128 = types.BoolValue(true)
+ } else {
+ data.EncryptionAesGcm128 = types.BoolValue(false)
+ }
+ } else {
+ data.EncryptionAesGcm128 = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/encryption/aes-gcm-256"); !data.EncryptionAesGcm256.IsNull() {
+ if value.Exists() {
+ data.EncryptionAesGcm256 = types.BoolValue(true)
+ } else {
+ data.EncryptionAesGcm256 = types.BoolValue(false)
+ }
+ } else {
+ data.EncryptionAesGcm256 = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/group/one"); !data.GroupOne.IsNull() {
+ if value.Exists() {
+ data.GroupOne = types.BoolValue(true)
+ } else {
+ data.GroupOne = types.BoolValue(false)
+ }
+ } else {
+ data.GroupOne = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/group/two"); !data.GroupTwo.IsNull() {
+ if value.Exists() {
+ data.GroupTwo = types.BoolValue(true)
+ } else {
+ data.GroupTwo = types.BoolValue(false)
+ }
+ } else {
+ data.GroupTwo = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/group/fourteen"); !data.GroupFourteen.IsNull() {
+ if value.Exists() {
+ data.GroupFourteen = types.BoolValue(true)
+ } else {
+ data.GroupFourteen = types.BoolValue(false)
+ }
+ } else {
+ data.GroupFourteen = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/group/fifteen"); !data.GroupFifteen.IsNull() {
+ if value.Exists() {
+ data.GroupFifteen = types.BoolValue(true)
+ } else {
+ data.GroupFifteen = types.BoolValue(false)
+ }
+ } else {
+ data.GroupFifteen = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/group/sixteen"); !data.GroupSixteen.IsNull() {
+ if value.Exists() {
+ data.GroupSixteen = types.BoolValue(true)
+ } else {
+ data.GroupSixteen = types.BoolValue(false)
+ }
+ } else {
+ data.GroupSixteen = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/group/nineteen"); !data.GroupNineteen.IsNull() {
+ if value.Exists() {
+ data.GroupNineteen = types.BoolValue(true)
+ } else {
+ data.GroupNineteen = types.BoolValue(false)
+ }
+ } else {
+ data.GroupNineteen = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/group/twenty"); !data.GroupTwenty.IsNull() {
+ if value.Exists() {
+ data.GroupTwenty = types.BoolValue(true)
+ } else {
+ data.GroupTwenty = types.BoolValue(false)
+ }
+ } else {
+ data.GroupTwenty = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/group/twenty-one"); !data.GroupTwentyOne.IsNull() {
+ if value.Exists() {
+ data.GroupTwentyOne = types.BoolValue(true)
+ } else {
+ data.GroupTwentyOne = types.BoolValue(false)
+ }
+ } else {
+ data.GroupTwentyOne = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/group/twenty-four"); !data.GroupTwentyFour.IsNull() {
+ if value.Exists() {
+ data.GroupTwentyFour = types.BoolValue(true)
+ } else {
+ data.GroupTwentyFour = types.BoolValue(false)
+ }
+ } else {
+ data.GroupTwentyFour = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/integrity/md5"); !data.IntegrityMd5.IsNull() {
+ if value.Exists() {
+ data.IntegrityMd5 = types.BoolValue(true)
+ } else {
+ data.IntegrityMd5 = types.BoolValue(false)
+ }
+ } else {
+ data.IntegrityMd5 = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/integrity/sha1"); !data.IntegritySha1.IsNull() {
+ if value.Exists() {
+ data.IntegritySha1 = types.BoolValue(true)
+ } else {
+ data.IntegritySha1 = types.BoolValue(false)
+ }
+ } else {
+ data.IntegritySha1 = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/integrity/sha256"); !data.IntegritySha256.IsNull() {
+ if value.Exists() {
+ data.IntegritySha256 = types.BoolValue(true)
+ } else {
+ data.IntegritySha256 = types.BoolValue(false)
+ }
+ } else {
+ data.IntegritySha256 = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/integrity/sha384"); !data.IntegritySha384.IsNull() {
+ if value.Exists() {
+ data.IntegritySha384 = types.BoolValue(true)
+ } else {
+ data.IntegritySha384 = types.BoolValue(false)
+ }
+ } else {
+ data.IntegritySha384 = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/integrity/sha512"); !data.IntegritySha512.IsNull() {
+ if value.Exists() {
+ data.IntegritySha512 = types.BoolValue(true)
+ } else {
+ data.IntegritySha512 = types.BoolValue(false)
+ }
+ } else {
+ data.IntegritySha512 = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/prf/md5"); !data.PrfMd5.IsNull() {
+ if value.Exists() {
+ data.PrfMd5 = types.BoolValue(true)
+ } else {
+ data.PrfMd5 = types.BoolValue(false)
+ }
+ } else {
+ data.PrfMd5 = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/prf/sha1"); !data.PrfSha1.IsNull() {
+ if value.Exists() {
+ data.PrfSha1 = types.BoolValue(true)
+ } else {
+ data.PrfSha1 = types.BoolValue(false)
+ }
+ } else {
+ data.PrfSha1 = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/prf/sha256"); !data.PrfSha256.IsNull() {
+ if value.Exists() {
+ data.PrfSha256 = types.BoolValue(true)
+ } else {
+ data.PrfSha256 = types.BoolValue(false)
+ }
+ } else {
+ data.PrfSha256 = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/prf/sha384"); !data.PrfSha384.IsNull() {
+ if value.Exists() {
+ data.PrfSha384 = types.BoolValue(true)
+ } else {
+ data.PrfSha384 = types.BoolValue(false)
+ }
+ } else {
+ data.PrfSha384 = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/prf/sha512"); !data.PrfSha512.IsNull() {
+ if value.Exists() {
+ data.PrfSha512 = types.BoolValue(true)
+ } else {
+ data.PrfSha512 = types.BoolValue(false)
+ }
+ } else {
+ data.PrfSha512 = types.BoolNull()
+ }
+}
+
+// End of section. //template:end updateFromBodyXML
+
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBody
+
+func (data *CryptoIKEv2Proposal) fromBody(ctx context.Context, res gjson.Result) {
+ prefix := helpers.LastElement(data.getPath()) + "."
+ if res.Get(helpers.LastElement(data.getPath())).IsArray() {
+ prefix += "0."
+ }
+ if value := res.Get(prefix + "encryption.en-3des"); value.Exists() {
+ data.EncryptionEn3des = types.BoolValue(true)
+ } else {
+ data.EncryptionEn3des = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "encryption.aes-cbc-128"); value.Exists() {
+ data.EncryptionAesCbc128 = types.BoolValue(true)
+ } else {
+ data.EncryptionAesCbc128 = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "encryption.aes-cbc-192"); value.Exists() {
+ data.EncryptionAesCbc192 = types.BoolValue(true)
+ } else {
+ data.EncryptionAesCbc192 = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "encryption.aes-cbc-256"); value.Exists() {
+ data.EncryptionAesCbc256 = types.BoolValue(true)
+ } else {
+ data.EncryptionAesCbc256 = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "encryption.aes-gcm-128"); value.Exists() {
+ data.EncryptionAesGcm128 = types.BoolValue(true)
+ } else {
+ data.EncryptionAesGcm128 = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "encryption.aes-gcm-256"); value.Exists() {
+ data.EncryptionAesGcm256 = types.BoolValue(true)
+ } else {
+ data.EncryptionAesGcm256 = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "group.one"); value.Exists() {
+ data.GroupOne = types.BoolValue(true)
+ } else {
+ data.GroupOne = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "group.two"); value.Exists() {
+ data.GroupTwo = types.BoolValue(true)
+ } else {
+ data.GroupTwo = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "group.fourteen"); value.Exists() {
+ data.GroupFourteen = types.BoolValue(true)
+ } else {
+ data.GroupFourteen = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "group.fifteen"); value.Exists() {
+ data.GroupFifteen = types.BoolValue(true)
+ } else {
+ data.GroupFifteen = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "group.sixteen"); value.Exists() {
+ data.GroupSixteen = types.BoolValue(true)
+ } else {
+ data.GroupSixteen = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "group.nineteen"); value.Exists() {
+ data.GroupNineteen = types.BoolValue(true)
+ } else {
+ data.GroupNineteen = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "group.twenty"); value.Exists() {
+ data.GroupTwenty = types.BoolValue(true)
+ } else {
+ data.GroupTwenty = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "group.twenty-one"); value.Exists() {
+ data.GroupTwentyOne = types.BoolValue(true)
+ } else {
+ data.GroupTwentyOne = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "group.twenty-four"); value.Exists() {
+ data.GroupTwentyFour = types.BoolValue(true)
+ } else {
+ data.GroupTwentyFour = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "integrity.md5"); value.Exists() {
+ data.IntegrityMd5 = types.BoolValue(true)
+ } else {
+ data.IntegrityMd5 = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "integrity.sha1"); value.Exists() {
+ data.IntegritySha1 = types.BoolValue(true)
+ } else {
+ data.IntegritySha1 = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "integrity.sha256"); value.Exists() {
+ data.IntegritySha256 = types.BoolValue(true)
+ } else {
+ data.IntegritySha256 = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "integrity.sha384"); value.Exists() {
+ data.IntegritySha384 = types.BoolValue(true)
+ } else {
+ data.IntegritySha384 = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "integrity.sha512"); value.Exists() {
+ data.IntegritySha512 = types.BoolValue(true)
+ } else {
+ data.IntegritySha512 = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "prf.md5"); value.Exists() {
+ data.PrfMd5 = types.BoolValue(true)
+ } else {
+ data.PrfMd5 = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "prf.sha1"); value.Exists() {
+ data.PrfSha1 = types.BoolValue(true)
+ } else {
+ data.PrfSha1 = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "prf.sha256"); value.Exists() {
+ data.PrfSha256 = types.BoolValue(true)
+ } else {
+ data.PrfSha256 = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "prf.sha384"); value.Exists() {
+ data.PrfSha384 = types.BoolValue(true)
+ } else {
+ data.PrfSha384 = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "prf.sha512"); value.Exists() {
+ data.PrfSha512 = types.BoolValue(true)
+ } else {
+ data.PrfSha512 = types.BoolValue(false)
}
}
-// End of section. //template:end updateFromBody
+// End of section. //template:end fromBody
-// Section below is generated&owned by "gen/generator.go". //template:begin fromBody
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyData
-func (data *CryptoIKEv2Proposal) fromBody(ctx context.Context, res gjson.Result) {
+func (data *CryptoIKEv2ProposalData) fromBody(ctx context.Context, res gjson.Result) {
prefix := helpers.LastElement(data.getPath()) + "."
if res.Get(helpers.LastElement(data.getPath())).IsArray() {
prefix += "0."
@@ -634,143 +1214,271 @@ func (data *CryptoIKEv2Proposal) fromBody(ctx context.Context, res gjson.Result)
}
}
-// End of section. //template:end fromBody
+// End of section. //template:end fromBodyData
-// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyData
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyXML
-func (data *CryptoIKEv2ProposalData) fromBody(ctx context.Context, res gjson.Result) {
- prefix := helpers.LastElement(data.getPath()) + "."
- if res.Get(helpers.LastElement(data.getPath())).IsArray() {
- prefix += "0."
+func (data *CryptoIKEv2Proposal) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/encryption/en-3des"); value.Exists() {
+ data.EncryptionEn3des = types.BoolValue(true)
+ } else {
+ data.EncryptionEn3des = types.BoolValue(false)
}
- if value := res.Get(prefix + "encryption.en-3des"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/encryption/aes-cbc-128"); value.Exists() {
+ data.EncryptionAesCbc128 = types.BoolValue(true)
+ } else {
+ data.EncryptionAesCbc128 = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/encryption/aes-cbc-192"); value.Exists() {
+ data.EncryptionAesCbc192 = types.BoolValue(true)
+ } else {
+ data.EncryptionAesCbc192 = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/encryption/aes-cbc-256"); value.Exists() {
+ data.EncryptionAesCbc256 = types.BoolValue(true)
+ } else {
+ data.EncryptionAesCbc256 = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/encryption/aes-gcm-128"); value.Exists() {
+ data.EncryptionAesGcm128 = types.BoolValue(true)
+ } else {
+ data.EncryptionAesGcm128 = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/encryption/aes-gcm-256"); value.Exists() {
+ data.EncryptionAesGcm256 = types.BoolValue(true)
+ } else {
+ data.EncryptionAesGcm256 = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/group/one"); value.Exists() {
+ data.GroupOne = types.BoolValue(true)
+ } else {
+ data.GroupOne = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/group/two"); value.Exists() {
+ data.GroupTwo = types.BoolValue(true)
+ } else {
+ data.GroupTwo = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/group/fourteen"); value.Exists() {
+ data.GroupFourteen = types.BoolValue(true)
+ } else {
+ data.GroupFourteen = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/group/fifteen"); value.Exists() {
+ data.GroupFifteen = types.BoolValue(true)
+ } else {
+ data.GroupFifteen = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/group/sixteen"); value.Exists() {
+ data.GroupSixteen = types.BoolValue(true)
+ } else {
+ data.GroupSixteen = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/group/nineteen"); value.Exists() {
+ data.GroupNineteen = types.BoolValue(true)
+ } else {
+ data.GroupNineteen = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/group/twenty"); value.Exists() {
+ data.GroupTwenty = types.BoolValue(true)
+ } else {
+ data.GroupTwenty = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/group/twenty-one"); value.Exists() {
+ data.GroupTwentyOne = types.BoolValue(true)
+ } else {
+ data.GroupTwentyOne = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/group/twenty-four"); value.Exists() {
+ data.GroupTwentyFour = types.BoolValue(true)
+ } else {
+ data.GroupTwentyFour = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/integrity/md5"); value.Exists() {
+ data.IntegrityMd5 = types.BoolValue(true)
+ } else {
+ data.IntegrityMd5 = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/integrity/sha1"); value.Exists() {
+ data.IntegritySha1 = types.BoolValue(true)
+ } else {
+ data.IntegritySha1 = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/integrity/sha256"); value.Exists() {
+ data.IntegritySha256 = types.BoolValue(true)
+ } else {
+ data.IntegritySha256 = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/integrity/sha384"); value.Exists() {
+ data.IntegritySha384 = types.BoolValue(true)
+ } else {
+ data.IntegritySha384 = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/integrity/sha512"); value.Exists() {
+ data.IntegritySha512 = types.BoolValue(true)
+ } else {
+ data.IntegritySha512 = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/prf/md5"); value.Exists() {
+ data.PrfMd5 = types.BoolValue(true)
+ } else {
+ data.PrfMd5 = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/prf/sha1"); value.Exists() {
+ data.PrfSha1 = types.BoolValue(true)
+ } else {
+ data.PrfSha1 = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/prf/sha256"); value.Exists() {
+ data.PrfSha256 = types.BoolValue(true)
+ } else {
+ data.PrfSha256 = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/prf/sha384"); value.Exists() {
+ data.PrfSha384 = types.BoolValue(true)
+ } else {
+ data.PrfSha384 = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/prf/sha512"); value.Exists() {
+ data.PrfSha512 = types.BoolValue(true)
+ } else {
+ data.PrfSha512 = types.BoolValue(false)
+ }
+}
+
+// End of section. //template:end fromBodyXML
+
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyDataXML
+
+func (data *CryptoIKEv2ProposalData) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/encryption/en-3des"); value.Exists() {
data.EncryptionEn3des = types.BoolValue(true)
} else {
data.EncryptionEn3des = types.BoolValue(false)
}
- if value := res.Get(prefix + "encryption.aes-cbc-128"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/encryption/aes-cbc-128"); value.Exists() {
data.EncryptionAesCbc128 = types.BoolValue(true)
} else {
data.EncryptionAesCbc128 = types.BoolValue(false)
}
- if value := res.Get(prefix + "encryption.aes-cbc-192"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/encryption/aes-cbc-192"); value.Exists() {
data.EncryptionAesCbc192 = types.BoolValue(true)
} else {
data.EncryptionAesCbc192 = types.BoolValue(false)
}
- if value := res.Get(prefix + "encryption.aes-cbc-256"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/encryption/aes-cbc-256"); value.Exists() {
data.EncryptionAesCbc256 = types.BoolValue(true)
} else {
data.EncryptionAesCbc256 = types.BoolValue(false)
}
- if value := res.Get(prefix + "encryption.aes-gcm-128"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/encryption/aes-gcm-128"); value.Exists() {
data.EncryptionAesGcm128 = types.BoolValue(true)
} else {
data.EncryptionAesGcm128 = types.BoolValue(false)
}
- if value := res.Get(prefix + "encryption.aes-gcm-256"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/encryption/aes-gcm-256"); value.Exists() {
data.EncryptionAesGcm256 = types.BoolValue(true)
} else {
data.EncryptionAesGcm256 = types.BoolValue(false)
}
- if value := res.Get(prefix + "group.one"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/group/one"); value.Exists() {
data.GroupOne = types.BoolValue(true)
} else {
data.GroupOne = types.BoolValue(false)
}
- if value := res.Get(prefix + "group.two"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/group/two"); value.Exists() {
data.GroupTwo = types.BoolValue(true)
} else {
data.GroupTwo = types.BoolValue(false)
}
- if value := res.Get(prefix + "group.fourteen"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/group/fourteen"); value.Exists() {
data.GroupFourteen = types.BoolValue(true)
} else {
data.GroupFourteen = types.BoolValue(false)
}
- if value := res.Get(prefix + "group.fifteen"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/group/fifteen"); value.Exists() {
data.GroupFifteen = types.BoolValue(true)
} else {
data.GroupFifteen = types.BoolValue(false)
}
- if value := res.Get(prefix + "group.sixteen"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/group/sixteen"); value.Exists() {
data.GroupSixteen = types.BoolValue(true)
} else {
data.GroupSixteen = types.BoolValue(false)
}
- if value := res.Get(prefix + "group.nineteen"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/group/nineteen"); value.Exists() {
data.GroupNineteen = types.BoolValue(true)
} else {
data.GroupNineteen = types.BoolValue(false)
}
- if value := res.Get(prefix + "group.twenty"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/group/twenty"); value.Exists() {
data.GroupTwenty = types.BoolValue(true)
} else {
data.GroupTwenty = types.BoolValue(false)
}
- if value := res.Get(prefix + "group.twenty-one"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/group/twenty-one"); value.Exists() {
data.GroupTwentyOne = types.BoolValue(true)
} else {
data.GroupTwentyOne = types.BoolValue(false)
}
- if value := res.Get(prefix + "group.twenty-four"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/group/twenty-four"); value.Exists() {
data.GroupTwentyFour = types.BoolValue(true)
} else {
data.GroupTwentyFour = types.BoolValue(false)
}
- if value := res.Get(prefix + "integrity.md5"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/integrity/md5"); value.Exists() {
data.IntegrityMd5 = types.BoolValue(true)
} else {
data.IntegrityMd5 = types.BoolValue(false)
}
- if value := res.Get(prefix + "integrity.sha1"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/integrity/sha1"); value.Exists() {
data.IntegritySha1 = types.BoolValue(true)
} else {
data.IntegritySha1 = types.BoolValue(false)
}
- if value := res.Get(prefix + "integrity.sha256"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/integrity/sha256"); value.Exists() {
data.IntegritySha256 = types.BoolValue(true)
} else {
data.IntegritySha256 = types.BoolValue(false)
}
- if value := res.Get(prefix + "integrity.sha384"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/integrity/sha384"); value.Exists() {
data.IntegritySha384 = types.BoolValue(true)
} else {
data.IntegritySha384 = types.BoolValue(false)
}
- if value := res.Get(prefix + "integrity.sha512"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/integrity/sha512"); value.Exists() {
data.IntegritySha512 = types.BoolValue(true)
} else {
data.IntegritySha512 = types.BoolValue(false)
}
- if value := res.Get(prefix + "prf.md5"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/prf/md5"); value.Exists() {
data.PrfMd5 = types.BoolValue(true)
} else {
data.PrfMd5 = types.BoolValue(false)
}
- if value := res.Get(prefix + "prf.sha1"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/prf/sha1"); value.Exists() {
data.PrfSha1 = types.BoolValue(true)
} else {
data.PrfSha1 = types.BoolValue(false)
}
- if value := res.Get(prefix + "prf.sha256"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/prf/sha256"); value.Exists() {
data.PrfSha256 = types.BoolValue(true)
} else {
data.PrfSha256 = types.BoolValue(false)
}
- if value := res.Get(prefix + "prf.sha384"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/prf/sha384"); value.Exists() {
data.PrfSha384 = types.BoolValue(true)
} else {
data.PrfSha384 = types.BoolValue(false)
}
- if value := res.Get(prefix + "prf.sha512"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/prf/sha512"); value.Exists() {
data.PrfSha512 = types.BoolValue(true)
} else {
data.PrfSha512 = types.BoolValue(false)
}
}
-// End of section. //template:end fromBodyData
+// End of section. //template:end fromBodyDataXML
// Section below is generated&owned by "gen/generator.go". //template:begin getDeletedItems
@@ -857,6 +1565,91 @@ func (data *CryptoIKEv2Proposal) getDeletedItems(ctx context.Context, state Cryp
// End of section. //template:end getDeletedItems
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletedItemsXML
+
+func (data *CryptoIKEv2Proposal) addDeletedItemsXML(ctx context.Context, state CryptoIKEv2Proposal, body string) string {
+ b := netconf.NewBody(body)
+ if !state.EncryptionEn3des.IsNull() && data.EncryptionEn3des.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/encryption/en-3des")
+ }
+ if !state.EncryptionAesCbc128.IsNull() && data.EncryptionAesCbc128.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/encryption/aes-cbc-128")
+ }
+ if !state.EncryptionAesCbc192.IsNull() && data.EncryptionAesCbc192.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/encryption/aes-cbc-192")
+ }
+ if !state.EncryptionAesCbc256.IsNull() && data.EncryptionAesCbc256.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/encryption/aes-cbc-256")
+ }
+ if !state.EncryptionAesGcm128.IsNull() && data.EncryptionAesGcm128.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/encryption/aes-gcm-128")
+ }
+ if !state.EncryptionAesGcm256.IsNull() && data.EncryptionAesGcm256.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/encryption/aes-gcm-256")
+ }
+ if !state.GroupOne.IsNull() && data.GroupOne.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/group/one")
+ }
+ if !state.GroupTwo.IsNull() && data.GroupTwo.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/group/two")
+ }
+ if !state.GroupFourteen.IsNull() && data.GroupFourteen.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/group/fourteen")
+ }
+ if !state.GroupFifteen.IsNull() && data.GroupFifteen.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/group/fifteen")
+ }
+ if !state.GroupSixteen.IsNull() && data.GroupSixteen.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/group/sixteen")
+ }
+ if !state.GroupNineteen.IsNull() && data.GroupNineteen.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/group/nineteen")
+ }
+ if !state.GroupTwenty.IsNull() && data.GroupTwenty.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/group/twenty")
+ }
+ if !state.GroupTwentyOne.IsNull() && data.GroupTwentyOne.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/group/twenty-one")
+ }
+ if !state.GroupTwentyFour.IsNull() && data.GroupTwentyFour.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/group/twenty-four")
+ }
+ if !state.IntegrityMd5.IsNull() && data.IntegrityMd5.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/integrity/md5")
+ }
+ if !state.IntegritySha1.IsNull() && data.IntegritySha1.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/integrity/sha1")
+ }
+ if !state.IntegritySha256.IsNull() && data.IntegritySha256.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/integrity/sha256")
+ }
+ if !state.IntegritySha384.IsNull() && data.IntegritySha384.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/integrity/sha384")
+ }
+ if !state.IntegritySha512.IsNull() && data.IntegritySha512.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/integrity/sha512")
+ }
+ if !state.PrfMd5.IsNull() && data.PrfMd5.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/prf/md5")
+ }
+ if !state.PrfSha1.IsNull() && data.PrfSha1.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/prf/sha1")
+ }
+ if !state.PrfSha256.IsNull() && data.PrfSha256.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/prf/sha256")
+ }
+ if !state.PrfSha384.IsNull() && data.PrfSha384.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/prf/sha384")
+ }
+ if !state.PrfSha512.IsNull() && data.PrfSha512.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/prf/sha512")
+ }
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletedItemsXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin getEmptyLeafsDelete
func (data *CryptoIKEv2Proposal) getEmptyLeafsDelete(ctx context.Context) []string {
@@ -1026,3 +1819,88 @@ func (data *CryptoIKEv2Proposal) getDeletePaths(ctx context.Context) []string {
}
// End of section. //template:end getDeletePaths
+
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletePathsXML
+
+func (data *CryptoIKEv2Proposal) addDeletePathsXML(ctx context.Context, body string) string {
+ b := netconf.NewBody(body)
+ if !data.EncryptionEn3des.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/encryption/en-3des")
+ }
+ if !data.EncryptionAesCbc128.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/encryption/aes-cbc-128")
+ }
+ if !data.EncryptionAesCbc192.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/encryption/aes-cbc-192")
+ }
+ if !data.EncryptionAesCbc256.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/encryption/aes-cbc-256")
+ }
+ if !data.EncryptionAesGcm128.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/encryption/aes-gcm-128")
+ }
+ if !data.EncryptionAesGcm256.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/encryption/aes-gcm-256")
+ }
+ if !data.GroupOne.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/group/one")
+ }
+ if !data.GroupTwo.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/group/two")
+ }
+ if !data.GroupFourteen.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/group/fourteen")
+ }
+ if !data.GroupFifteen.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/group/fifteen")
+ }
+ if !data.GroupSixteen.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/group/sixteen")
+ }
+ if !data.GroupNineteen.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/group/nineteen")
+ }
+ if !data.GroupTwenty.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/group/twenty")
+ }
+ if !data.GroupTwentyOne.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/group/twenty-one")
+ }
+ if !data.GroupTwentyFour.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/group/twenty-four")
+ }
+ if !data.IntegrityMd5.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/integrity/md5")
+ }
+ if !data.IntegritySha1.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/integrity/sha1")
+ }
+ if !data.IntegritySha256.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/integrity/sha256")
+ }
+ if !data.IntegritySha384.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/integrity/sha384")
+ }
+ if !data.IntegritySha512.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/integrity/sha512")
+ }
+ if !data.PrfMd5.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/prf/md5")
+ }
+ if !data.PrfSha1.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/prf/sha1")
+ }
+ if !data.PrfSha256.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/prf/sha256")
+ }
+ if !data.PrfSha384.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/prf/sha384")
+ }
+ if !data.PrfSha512.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/prf/sha512")
+ }
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletePathsXML
diff --git a/internal/provider/model_iosxe_crypto_ipsec_profile.go b/internal/provider/model_iosxe_crypto_ipsec_profile.go
index 3b025c8a..2eaf5947 100644
--- a/internal/provider/model_iosxe_crypto_ipsec_profile.go
+++ b/internal/provider/model_iosxe_crypto_ipsec_profile.go
@@ -28,6 +28,9 @@ import (
"github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/types"
+ "github.com/hashicorp/terraform-plugin-log/tflog"
+ "github.com/netascode/go-netconf"
+ "github.com/netascode/xmldot"
"github.com/tidwall/gjson"
"github.com/tidwall/sjson"
)
@@ -76,6 +79,19 @@ func (data CryptoIPSecProfile) getPathShort() string {
return matches[1]
}
+// getXPath returns the XPath for NETCONF operations
+func (data CryptoIPSecProfile) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/crypto/Cisco-IOS-XE-crypto:ipsec/profile[name=%v]"
+ path = fmt.Sprintf(path, fmt.Sprintf("%v", data.Name.ValueString()))
+ return path
+}
+
+func (data CryptoIPSecProfileData) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/crypto/Cisco-IOS-XE-crypto:ipsec/profile[name=%v]"
+ path = fmt.Sprintf(path, fmt.Sprintf("%v", data.Name.ValueString()))
+ return path
+}
+
// End of section. //template:end getPath
// Section below is generated&owned by "gen/generator.go". //template:begin toBody
@@ -101,6 +117,35 @@ func (data CryptoIPSecProfile) toBody(ctx context.Context) string {
// End of section. //template:end toBody
+// Section below is generated&owned by "gen/generator.go". //template:begin toBodyXML
+
+func (data CryptoIPSecProfile) toBodyXML(ctx context.Context) string {
+ body := netconf.Body{}
+ if !data.Name.IsNull() && !data.Name.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/name", data.Name.ValueString())
+ }
+ if !data.SetTransformSet.IsNull() && !data.SetTransformSet.IsUnknown() {
+ var values []string
+ data.SetTransformSet.ElementsAs(ctx, &values, false)
+ for _, v := range values {
+ body = helpers.AppendFromXPath(body, data.getXPath()+"/set/transform-set", v)
+ }
+ }
+ if !data.SetIkev2Profile.IsNull() && !data.SetIkev2Profile.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/set/ikev2-profile", data.SetIkev2Profile.ValueString())
+ }
+ if !data.SetIsakmpProfile.IsNull() && !data.SetIsakmpProfile.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/set/isakmp-profile", data.SetIsakmpProfile.ValueString())
+ }
+ bodyString, err := body.String()
+ if err != nil {
+ tflog.Error(ctx, fmt.Sprintf("Error converting body to string: %s", err))
+ }
+ return bodyString
+}
+
+// End of section. //template:end toBodyXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBody
func (data *CryptoIPSecProfile) updateFromBody(ctx context.Context, res gjson.Result) {
@@ -132,6 +177,33 @@ func (data *CryptoIPSecProfile) updateFromBody(ctx context.Context, res gjson.Re
// End of section. //template:end updateFromBody
+// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBodyXML
+
+func (data *CryptoIPSecProfile) updateFromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/name"); value.Exists() && !data.Name.IsNull() {
+ data.Name = types.StringValue(value.String())
+ } else {
+ data.Name = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/set/transform-set"); value.Exists() && !data.SetTransformSet.IsNull() {
+ data.SetTransformSet = helpers.GetStringListXML(value.Array())
+ } else {
+ data.SetTransformSet = types.ListNull(types.StringType)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/set/ikev2-profile"); value.Exists() && !data.SetIkev2Profile.IsNull() {
+ data.SetIkev2Profile = types.StringValue(value.String())
+ } else {
+ data.SetIkev2Profile = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/set/isakmp-profile"); value.Exists() && !data.SetIsakmpProfile.IsNull() {
+ data.SetIsakmpProfile = types.StringValue(value.String())
+ } else {
+ data.SetIsakmpProfile = types.StringNull()
+ }
+}
+
+// End of section. //template:end updateFromBodyXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin fromBody
func (data *CryptoIPSecProfile) fromBody(ctx context.Context, res gjson.Result) {
@@ -176,6 +248,42 @@ func (data *CryptoIPSecProfileData) fromBody(ctx context.Context, res gjson.Resu
// End of section. //template:end fromBodyData
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyXML
+
+func (data *CryptoIPSecProfile) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/set/transform-set"); value.Exists() {
+ data.SetTransformSet = helpers.GetStringListXML(value.Array())
+ } else {
+ data.SetTransformSet = types.ListNull(types.StringType)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/set/ikev2-profile"); value.Exists() {
+ data.SetIkev2Profile = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/set/isakmp-profile"); value.Exists() {
+ data.SetIsakmpProfile = types.StringValue(value.String())
+ }
+}
+
+// End of section. //template:end fromBodyXML
+
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyDataXML
+
+func (data *CryptoIPSecProfileData) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/set/transform-set"); value.Exists() {
+ data.SetTransformSet = helpers.GetStringListXML(value.Array())
+ } else {
+ data.SetTransformSet = types.ListNull(types.StringType)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/set/ikev2-profile"); value.Exists() {
+ data.SetIkev2Profile = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/set/isakmp-profile"); value.Exists() {
+ data.SetIsakmpProfile = types.StringValue(value.String())
+ }
+}
+
+// End of section. //template:end fromBodyDataXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin getDeletedItems
func (data *CryptoIPSecProfile) getDeletedItems(ctx context.Context, state CryptoIPSecProfile) []string {
@@ -213,6 +321,43 @@ func (data *CryptoIPSecProfile) getDeletedItems(ctx context.Context, state Crypt
// End of section. //template:end getDeletedItems
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletedItemsXML
+
+func (data *CryptoIPSecProfile) addDeletedItemsXML(ctx context.Context, state CryptoIPSecProfile, body string) string {
+ b := netconf.NewBody(body)
+ if !state.SetTransformSet.IsNull() {
+ if data.SetTransformSet.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/set/transform-set")
+ } else {
+ var dataValues, stateValues []string
+ data.SetTransformSet.ElementsAs(ctx, &dataValues, false)
+ state.SetTransformSet.ElementsAs(ctx, &stateValues, false)
+ for _, v := range stateValues {
+ found := false
+ for _, vv := range dataValues {
+ if v == vv {
+ found = true
+ break
+ }
+ }
+ if !found {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/set/transform-set[.=%v]", v))
+ }
+ }
+ }
+ }
+ if !state.SetIkev2Profile.IsNull() && data.SetIkev2Profile.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/set/ikev2-profile")
+ }
+ if !state.SetIsakmpProfile.IsNull() && data.SetIsakmpProfile.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/set/isakmp-profile")
+ }
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletedItemsXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin getEmptyLeafsDelete
func (data *CryptoIPSecProfile) getEmptyLeafsDelete(ctx context.Context) []string {
@@ -241,3 +386,22 @@ func (data *CryptoIPSecProfile) getDeletePaths(ctx context.Context) []string {
}
// End of section. //template:end getDeletePaths
+
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletePathsXML
+
+func (data *CryptoIPSecProfile) addDeletePathsXML(ctx context.Context, body string) string {
+ b := netconf.NewBody(body)
+ if !data.SetTransformSet.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/set/transform-set")
+ }
+ if !data.SetIkev2Profile.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/set/ikev2-profile")
+ }
+ if !data.SetIsakmpProfile.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/set/isakmp-profile")
+ }
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletePathsXML
diff --git a/internal/provider/model_iosxe_crypto_ipsec_transform_set.go b/internal/provider/model_iosxe_crypto_ipsec_transform_set.go
index e0af3df4..f68536ec 100644
--- a/internal/provider/model_iosxe_crypto_ipsec_transform_set.go
+++ b/internal/provider/model_iosxe_crypto_ipsec_transform_set.go
@@ -28,6 +28,9 @@ import (
"github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/types"
+ "github.com/hashicorp/terraform-plugin-log/tflog"
+ "github.com/netascode/go-netconf"
+ "github.com/netascode/xmldot"
"github.com/tidwall/gjson"
"github.com/tidwall/sjson"
)
@@ -76,6 +79,19 @@ func (data CryptoIPSecTransformSet) getPathShort() string {
return matches[1]
}
+// getXPath returns the XPath for NETCONF operations
+func (data CryptoIPSecTransformSet) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/crypto/Cisco-IOS-XE-crypto:ipsec/transform-set[tag=%s]"
+ path = fmt.Sprintf(path, fmt.Sprintf("%v", data.Name.ValueString()))
+ return path
+}
+
+func (data CryptoIPSecTransformSetData) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/crypto/Cisco-IOS-XE-crypto:ipsec/transform-set[tag=%s]"
+ path = fmt.Sprintf(path, fmt.Sprintf("%v", data.Name.ValueString()))
+ return path
+}
+
// End of section. //template:end getPath
// Section below is generated&owned by "gen/generator.go". //template:begin toBody
@@ -101,6 +117,35 @@ func (data CryptoIPSecTransformSet) toBody(ctx context.Context) string {
// End of section. //template:end toBody
+// Section below is generated&owned by "gen/generator.go". //template:begin toBodyXML
+
+func (data CryptoIPSecTransformSet) toBodyXML(ctx context.Context) string {
+ body := netconf.Body{}
+ if !data.Name.IsNull() && !data.Name.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/tag", data.Name.ValueString())
+ }
+ if !data.Esp.IsNull() && !data.Esp.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/esp", data.Esp.ValueString())
+ }
+ if !data.EspHmac.IsNull() && !data.EspHmac.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/esp-hmac", data.EspHmac.ValueString())
+ }
+ if !data.ModeTunnel.IsNull() && !data.ModeTunnel.IsUnknown() {
+ if data.ModeTunnel.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/mode/tunnel-choice", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/mode/tunnel-choice")
+ }
+ }
+ bodyString, err := body.String()
+ if err != nil {
+ tflog.Error(ctx, fmt.Sprintf("Error converting body to string: %s", err))
+ }
+ return bodyString
+}
+
+// End of section. //template:end toBodyXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBody
func (data *CryptoIPSecTransformSet) updateFromBody(ctx context.Context, res gjson.Result) {
@@ -136,6 +181,37 @@ func (data *CryptoIPSecTransformSet) updateFromBody(ctx context.Context, res gjs
// End of section. //template:end updateFromBody
+// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBodyXML
+
+func (data *CryptoIPSecTransformSet) updateFromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/tag"); value.Exists() && !data.Name.IsNull() {
+ data.Name = types.StringValue(value.String())
+ } else {
+ data.Name = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/esp"); value.Exists() && !data.Esp.IsNull() {
+ data.Esp = types.StringValue(value.String())
+ } else {
+ data.Esp = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/esp-hmac"); value.Exists() && !data.EspHmac.IsNull() {
+ data.EspHmac = types.StringValue(value.String())
+ } else {
+ data.EspHmac = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/mode/tunnel-choice"); !data.ModeTunnel.IsNull() {
+ if value.Exists() {
+ data.ModeTunnel = types.BoolValue(true)
+ } else {
+ data.ModeTunnel = types.BoolValue(false)
+ }
+ } else {
+ data.ModeTunnel = types.BoolNull()
+ }
+}
+
+// End of section. //template:end updateFromBodyXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin fromBody
func (data *CryptoIPSecTransformSet) fromBody(ctx context.Context, res gjson.Result) {
@@ -180,6 +256,42 @@ func (data *CryptoIPSecTransformSetData) fromBody(ctx context.Context, res gjson
// End of section. //template:end fromBodyData
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyXML
+
+func (data *CryptoIPSecTransformSet) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/esp"); value.Exists() {
+ data.Esp = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/esp-hmac"); value.Exists() {
+ data.EspHmac = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/mode/tunnel-choice"); value.Exists() {
+ data.ModeTunnel = types.BoolValue(true)
+ } else {
+ data.ModeTunnel = types.BoolValue(false)
+ }
+}
+
+// End of section. //template:end fromBodyXML
+
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyDataXML
+
+func (data *CryptoIPSecTransformSetData) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/esp"); value.Exists() {
+ data.Esp = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/esp-hmac"); value.Exists() {
+ data.EspHmac = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/mode/tunnel-choice"); value.Exists() {
+ data.ModeTunnel = types.BoolValue(true)
+ } else {
+ data.ModeTunnel = types.BoolValue(false)
+ }
+}
+
+// End of section. //template:end fromBodyDataXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin getDeletedItems
func (data *CryptoIPSecTransformSet) getDeletedItems(ctx context.Context, state CryptoIPSecTransformSet) []string {
@@ -199,6 +311,25 @@ func (data *CryptoIPSecTransformSet) getDeletedItems(ctx context.Context, state
// End of section. //template:end getDeletedItems
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletedItemsXML
+
+func (data *CryptoIPSecTransformSet) addDeletedItemsXML(ctx context.Context, state CryptoIPSecTransformSet, body string) string {
+ b := netconf.NewBody(body)
+ if !state.Esp.IsNull() && data.Esp.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/esp")
+ }
+ if !state.EspHmac.IsNull() && data.EspHmac.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/esp-hmac")
+ }
+ if !state.ModeTunnel.IsNull() && data.ModeTunnel.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/mode/tunnel-choice")
+ }
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletedItemsXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin getEmptyLeafsDelete
func (data *CryptoIPSecTransformSet) getEmptyLeafsDelete(ctx context.Context) []string {
@@ -230,3 +361,22 @@ func (data *CryptoIPSecTransformSet) getDeletePaths(ctx context.Context) []strin
}
// End of section. //template:end getDeletePaths
+
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletePathsXML
+
+func (data *CryptoIPSecTransformSet) addDeletePathsXML(ctx context.Context, body string) string {
+ b := netconf.NewBody(body)
+ if !data.Esp.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/esp")
+ }
+ if !data.EspHmac.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/esp-hmac")
+ }
+ if !data.ModeTunnel.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/mode/tunnel-choice")
+ }
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletePathsXML
diff --git a/internal/provider/model_iosxe_crypto_pki.go b/internal/provider/model_iosxe_crypto_pki.go
index 59b0b3a4..f032c655 100644
--- a/internal/provider/model_iosxe_crypto_pki.go
+++ b/internal/provider/model_iosxe_crypto_pki.go
@@ -30,6 +30,9 @@ import (
"github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/types"
+ "github.com/hashicorp/terraform-plugin-log/tflog"
+ "github.com/netascode/go-netconf"
+ "github.com/netascode/xmldot"
"github.com/tidwall/gjson"
"github.com/tidwall/sjson"
)
@@ -86,6 +89,17 @@ func (data CryptoPKI) getPathShort() string {
return matches[1]
}
+// getXPath returns the XPath for NETCONF operations
+func (data CryptoPKI) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/crypto/Cisco-IOS-XE-crypto:pki"
+ return path
+}
+
+func (data CryptoPKIData) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/crypto/Cisco-IOS-XE-crypto:pki"
+ return path
+}
+
// End of section. //template:end getPath
// Section below is generated&owned by "gen/generator.go". //template:begin toBody
@@ -145,6 +159,78 @@ func (data CryptoPKI) toBody(ctx context.Context) string {
// End of section. //template:end toBody
+// Section below is generated&owned by "gen/generator.go". //template:begin toBodyXML
+
+func (data CryptoPKI) toBodyXML(ctx context.Context) string {
+ body := netconf.Body{}
+ if len(data.Trustpoints) > 0 {
+ for _, item := range data.Trustpoints {
+ cBody := netconf.Body{}
+ if !item.Id.IsNull() && !item.Id.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "id", item.Id.ValueString())
+ }
+ if !item.EnrollmentPkcs12.IsNull() && !item.EnrollmentPkcs12.IsUnknown() {
+ if item.EnrollmentPkcs12.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "enrollment/enrollment-method/pkcs12", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "enrollment/enrollment-method/pkcs12")
+ }
+ }
+ if !item.EnrollmentSelfsigned.IsNull() && !item.EnrollmentSelfsigned.IsUnknown() {
+ if item.EnrollmentSelfsigned.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "enrollment/enrollment-method/selfsigned", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "enrollment/enrollment-method/selfsigned")
+ }
+ }
+ if !item.EnrollmentModeRa.IsNull() && !item.EnrollmentModeRa.IsUnknown() {
+ if item.EnrollmentModeRa.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "enrollment/mode/ra", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "enrollment/mode/ra")
+ }
+ }
+ if !item.EnrollmentTerminal.IsNull() && !item.EnrollmentTerminal.IsUnknown() {
+ if item.EnrollmentTerminal.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "enrollment/terminal", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "enrollment/terminal")
+ }
+ }
+ if !item.RevocationCheck.IsNull() && !item.RevocationCheck.IsUnknown() {
+ var values []string
+ item.RevocationCheck.ElementsAs(ctx, &values, false)
+ for _, v := range values {
+ cBody = helpers.AppendFromXPath(cBody, "revocation-check", v)
+ }
+ }
+ if !item.SubjectName.IsNull() && !item.SubjectName.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "subject-name", item.SubjectName.ValueString())
+ }
+ if !item.Rsakeypair.IsNull() && !item.Rsakeypair.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "rsakeypair/key-label", item.Rsakeypair.ValueString())
+ }
+ if !item.Usage.IsNull() && !item.Usage.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "usage", item.Usage.ValueString())
+ }
+ if !item.SourceInterface.IsNull() && !item.SourceInterface.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "source/interface", item.SourceInterface.ValueString())
+ }
+ if !item.Hash.IsNull() && !item.Hash.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "hash", item.Hash.ValueString())
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/trustpoint", cBody.Res())
+ }
+ }
+ bodyString, err := body.String()
+ if err != nil {
+ tflog.Error(ctx, fmt.Sprintf("Error converting body to string: %s", err))
+ }
+ return bodyString
+}
+
+// End of section. //template:end toBodyXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBody
func (data *CryptoPKI) updateFromBody(ctx context.Context, res gjson.Result) {
@@ -251,6 +337,108 @@ func (data *CryptoPKI) updateFromBody(ctx context.Context, res gjson.Result) {
// End of section. //template:end updateFromBody
+// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBodyXML
+
+func (data *CryptoPKI) updateFromBodyXML(ctx context.Context, res xmldot.Result) {
+ for i := range data.Trustpoints {
+ keys := [...]string{"id"}
+ keyValues := [...]string{data.Trustpoints[i].Id.ValueString()}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/trustpoint").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, "id"); value.Exists() && !data.Trustpoints[i].Id.IsNull() {
+ data.Trustpoints[i].Id = types.StringValue(value.String())
+ } else {
+ data.Trustpoints[i].Id = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "enrollment/enrollment-method/pkcs12"); !data.Trustpoints[i].EnrollmentPkcs12.IsNull() {
+ if value.Exists() {
+ data.Trustpoints[i].EnrollmentPkcs12 = types.BoolValue(true)
+ } else {
+ data.Trustpoints[i].EnrollmentPkcs12 = types.BoolValue(false)
+ }
+ } else {
+ data.Trustpoints[i].EnrollmentPkcs12 = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "enrollment/enrollment-method/selfsigned"); !data.Trustpoints[i].EnrollmentSelfsigned.IsNull() {
+ if value.Exists() {
+ data.Trustpoints[i].EnrollmentSelfsigned = types.BoolValue(true)
+ } else {
+ data.Trustpoints[i].EnrollmentSelfsigned = types.BoolValue(false)
+ }
+ } else {
+ data.Trustpoints[i].EnrollmentSelfsigned = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "enrollment/mode/ra"); !data.Trustpoints[i].EnrollmentModeRa.IsNull() {
+ if value.Exists() {
+ data.Trustpoints[i].EnrollmentModeRa = types.BoolValue(true)
+ } else {
+ data.Trustpoints[i].EnrollmentModeRa = types.BoolValue(false)
+ }
+ } else {
+ data.Trustpoints[i].EnrollmentModeRa = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "enrollment/terminal"); !data.Trustpoints[i].EnrollmentTerminal.IsNull() {
+ if value.Exists() {
+ data.Trustpoints[i].EnrollmentTerminal = types.BoolValue(true)
+ } else {
+ data.Trustpoints[i].EnrollmentTerminal = types.BoolValue(false)
+ }
+ } else {
+ data.Trustpoints[i].EnrollmentTerminal = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "revocation-check"); value.Exists() && !data.Trustpoints[i].RevocationCheck.IsNull() {
+ data.Trustpoints[i].RevocationCheck = helpers.GetStringListXML(value.Array())
+ } else {
+ data.Trustpoints[i].RevocationCheck = types.ListNull(types.StringType)
+ }
+ if value := helpers.GetFromXPath(r, "subject-name"); value.Exists() && !data.Trustpoints[i].SubjectName.IsNull() {
+ data.Trustpoints[i].SubjectName = types.StringValue(value.String())
+ } else {
+ data.Trustpoints[i].SubjectName = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "rsakeypair/key-label"); value.Exists() && !data.Trustpoints[i].Rsakeypair.IsNull() {
+ data.Trustpoints[i].Rsakeypair = types.StringValue(value.String())
+ } else {
+ data.Trustpoints[i].Rsakeypair = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "usage"); value.Exists() && !data.Trustpoints[i].Usage.IsNull() {
+ data.Trustpoints[i].Usage = types.StringValue(value.String())
+ } else {
+ data.Trustpoints[i].Usage = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "source/interface"); value.Exists() && !data.Trustpoints[i].SourceInterface.IsNull() {
+ data.Trustpoints[i].SourceInterface = types.StringValue(value.String())
+ } else {
+ data.Trustpoints[i].SourceInterface = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "hash"); value.Exists() && !data.Trustpoints[i].Hash.IsNull() {
+ data.Trustpoints[i].Hash = types.StringValue(value.String())
+ } else {
+ data.Trustpoints[i].Hash = types.StringNull()
+ }
+ }
+}
+
+// End of section. //template:end updateFromBodyXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin fromBody
func (data *CryptoPKI) fromBody(ctx context.Context, res gjson.Result) {
@@ -375,6 +563,122 @@ func (data *CryptoPKIData) fromBody(ctx context.Context, res gjson.Result) {
// End of section. //template:end fromBodyData
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyXML
+
+func (data *CryptoPKI) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/trustpoint"); value.Exists() {
+ data.Trustpoints = make([]CryptoPKITrustpoints, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := CryptoPKITrustpoints{}
+ if cValue := helpers.GetFromXPath(v, "id"); cValue.Exists() {
+ item.Id = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "enrollment/enrollment-method/pkcs12"); cValue.Exists() {
+ item.EnrollmentPkcs12 = types.BoolValue(true)
+ } else {
+ item.EnrollmentPkcs12 = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "enrollment/enrollment-method/selfsigned"); cValue.Exists() {
+ item.EnrollmentSelfsigned = types.BoolValue(true)
+ } else {
+ item.EnrollmentSelfsigned = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "enrollment/mode/ra"); cValue.Exists() {
+ item.EnrollmentModeRa = types.BoolValue(true)
+ } else {
+ item.EnrollmentModeRa = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "enrollment/terminal"); cValue.Exists() {
+ item.EnrollmentTerminal = types.BoolValue(true)
+ } else {
+ item.EnrollmentTerminal = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "revocation-check"); cValue.Exists() {
+ item.RevocationCheck = helpers.GetStringListXML(cValue.Array())
+ } else {
+ item.RevocationCheck = types.ListNull(types.StringType)
+ }
+ if cValue := helpers.GetFromXPath(v, "subject-name"); cValue.Exists() {
+ item.SubjectName = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "rsakeypair/key-label"); cValue.Exists() {
+ item.Rsakeypair = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "usage"); cValue.Exists() {
+ item.Usage = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "source/interface"); cValue.Exists() {
+ item.SourceInterface = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "hash"); cValue.Exists() {
+ item.Hash = types.StringValue(cValue.String())
+ }
+ data.Trustpoints = append(data.Trustpoints, item)
+ return true
+ })
+ }
+}
+
+// End of section. //template:end fromBodyXML
+
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyDataXML
+
+func (data *CryptoPKIData) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/trustpoint"); value.Exists() {
+ data.Trustpoints = make([]CryptoPKITrustpoints, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := CryptoPKITrustpoints{}
+ if cValue := helpers.GetFromXPath(v, "id"); cValue.Exists() {
+ item.Id = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "enrollment/enrollment-method/pkcs12"); cValue.Exists() {
+ item.EnrollmentPkcs12 = types.BoolValue(true)
+ } else {
+ item.EnrollmentPkcs12 = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "enrollment/enrollment-method/selfsigned"); cValue.Exists() {
+ item.EnrollmentSelfsigned = types.BoolValue(true)
+ } else {
+ item.EnrollmentSelfsigned = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "enrollment/mode/ra"); cValue.Exists() {
+ item.EnrollmentModeRa = types.BoolValue(true)
+ } else {
+ item.EnrollmentModeRa = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "enrollment/terminal"); cValue.Exists() {
+ item.EnrollmentTerminal = types.BoolValue(true)
+ } else {
+ item.EnrollmentTerminal = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "revocation-check"); cValue.Exists() {
+ item.RevocationCheck = helpers.GetStringListXML(cValue.Array())
+ } else {
+ item.RevocationCheck = types.ListNull(types.StringType)
+ }
+ if cValue := helpers.GetFromXPath(v, "subject-name"); cValue.Exists() {
+ item.SubjectName = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "rsakeypair/key-label"); cValue.Exists() {
+ item.Rsakeypair = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "usage"); cValue.Exists() {
+ item.Usage = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "source/interface"); cValue.Exists() {
+ item.SourceInterface = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "hash"); cValue.Exists() {
+ item.Hash = types.StringValue(cValue.String())
+ }
+ data.Trustpoints = append(data.Trustpoints, item)
+ return true
+ })
+ }
+}
+
+// End of section. //template:end fromBodyDataXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin getDeletedItems
func (data *CryptoPKI) getDeletedItems(ctx context.Context, state CryptoPKI) []string {
@@ -458,6 +762,94 @@ func (data *CryptoPKI) getDeletedItems(ctx context.Context, state CryptoPKI) []s
// End of section. //template:end getDeletedItems
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletedItemsXML
+
+func (data *CryptoPKI) addDeletedItemsXML(ctx context.Context, state CryptoPKI, body string) string {
+ b := netconf.NewBody(body)
+ for i := range state.Trustpoints {
+ stateKeys := [...]string{"id"}
+ stateKeyValues := [...]string{state.Trustpoints[i].Id.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.Trustpoints[i].Id.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.Trustpoints {
+ found = true
+ if state.Trustpoints[i].Id.ValueString() != data.Trustpoints[j].Id.ValueString() {
+ found = false
+ }
+ if found {
+ if !state.Trustpoints[i].EnrollmentPkcs12.IsNull() && data.Trustpoints[j].EnrollmentPkcs12.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/trustpoint%v/enrollment/enrollment-method/pkcs12", predicates))
+ }
+ if !state.Trustpoints[i].EnrollmentSelfsigned.IsNull() && data.Trustpoints[j].EnrollmentSelfsigned.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/trustpoint%v/enrollment/enrollment-method/selfsigned", predicates))
+ }
+ if !state.Trustpoints[i].EnrollmentModeRa.IsNull() && data.Trustpoints[j].EnrollmentModeRa.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/trustpoint%v/enrollment/mode/ra", predicates))
+ }
+ if !state.Trustpoints[i].EnrollmentTerminal.IsNull() && data.Trustpoints[j].EnrollmentTerminal.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/trustpoint%v/enrollment/terminal", predicates))
+ }
+ if !state.Trustpoints[i].RevocationCheck.IsNull() {
+ if data.Trustpoints[j].RevocationCheck.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/trustpoint%v/revocation-check", predicates))
+ } else {
+ var dataValues, stateValues []string
+ data.Trustpoints[i].RevocationCheck.ElementsAs(ctx, &dataValues, false)
+ state.Trustpoints[j].RevocationCheck.ElementsAs(ctx, &stateValues, false)
+ for _, v := range stateValues {
+ found := false
+ for _, vv := range dataValues {
+ if v == vv {
+ found = true
+ break
+ }
+ }
+ if !found {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/trustpoint%v/revocation-check[.=%v]", predicates, v))
+ }
+ }
+ }
+ }
+ if !state.Trustpoints[i].SubjectName.IsNull() && data.Trustpoints[j].SubjectName.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/trustpoint%v/subject-name", predicates))
+ }
+ if !state.Trustpoints[i].Rsakeypair.IsNull() && data.Trustpoints[j].Rsakeypair.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/trustpoint%v/rsakeypair/key-label", predicates))
+ }
+ if !state.Trustpoints[i].Usage.IsNull() && data.Trustpoints[j].Usage.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/trustpoint%v/usage", predicates))
+ }
+ if !state.Trustpoints[i].SourceInterface.IsNull() && data.Trustpoints[j].SourceInterface.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/trustpoint%v/source/interface", predicates))
+ }
+ if !state.Trustpoints[i].Hash.IsNull() && data.Trustpoints[j].Hash.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/trustpoint%v/hash", predicates))
+ }
+ break
+ }
+ }
+ if !found {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/trustpoint%v", predicates))
+ }
+ }
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletedItemsXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin getEmptyLeafsDelete
func (data *CryptoPKI) getEmptyLeafsDelete(ctx context.Context) []string {
@@ -498,3 +890,23 @@ func (data *CryptoPKI) getDeletePaths(ctx context.Context) []string {
}
// End of section. //template:end getDeletePaths
+
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletePathsXML
+
+func (data *CryptoPKI) addDeletePathsXML(ctx context.Context, body string) string {
+ b := netconf.NewBody(body)
+ for i := range data.Trustpoints {
+ keys := [...]string{"id"}
+ keyValues := [...]string{data.Trustpoints[i].Id.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/trustpoint%v", predicates))
+ }
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletePathsXML
diff --git a/internal/provider/model_iosxe_cts.go b/internal/provider/model_iosxe_cts.go
index a8f2424f..6bad498c 100644
--- a/internal/provider/model_iosxe_cts.go
+++ b/internal/provider/model_iosxe_cts.go
@@ -30,6 +30,9 @@ import (
"github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/types"
+ "github.com/hashicorp/terraform-plugin-log/tflog"
+ "github.com/netascode/go-netconf"
+ "github.com/netascode/xmldot"
"github.com/tidwall/gjson"
"github.com/tidwall/sjson"
)
@@ -120,6 +123,17 @@ func (data CTS) getPathShort() string {
return matches[1]
}
+// getXPath returns the XPath for NETCONF operations
+func (data CTS) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/cts"
+ return path
+}
+
+func (data CTSData) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/cts"
+ return path
+}
+
// End of section. //template:end getPath
// Section below is generated&owned by "gen/generator.go". //template:begin toBody
@@ -231,6 +245,127 @@ func (data CTS) toBody(ctx context.Context) string {
// End of section. //template:end toBody
+// Section below is generated&owned by "gen/generator.go". //template:begin toBodyXML
+
+func (data CTS) toBodyXML(ctx context.Context) string {
+ body := netconf.Body{}
+ if !data.AuthorizationList.IsNull() && !data.AuthorizationList.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-cts:authorization/list", data.AuthorizationList.ValueString())
+ }
+ if !data.Sgt.IsNull() && !data.Sgt.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-cts:sgt", strconv.FormatInt(data.Sgt.ValueInt64(), 10))
+ }
+ if !data.SxpEnable.IsNull() && !data.SxpEnable.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-cts:sxp/sxp-def-enable", data.SxpEnable.ValueBool())
+ }
+ if !data.SxpDefaultPasswordType.IsNull() && !data.SxpDefaultPasswordType.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-cts:sxp/default/password/type", data.SxpDefaultPasswordType.ValueString())
+ }
+ if !data.SxpDefaultPassword.IsNull() && !data.SxpDefaultPassword.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-cts:sxp/default/password/secret", data.SxpDefaultPassword.ValueString())
+ }
+ if !data.SxpRetryPeriod.IsNull() && !data.SxpRetryPeriod.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-cts:sxp/retry/period", strconv.FormatInt(data.SxpRetryPeriod.ValueInt64(), 10))
+ }
+ if len(data.SxpConnectionPeersIpv4) > 0 {
+ for _, item := range data.SxpConnectionPeersIpv4 {
+ cBody := netconf.Body{}
+ if !item.Ip.IsNull() && !item.Ip.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "ipv4", item.Ip.ValueString())
+ }
+ if !item.SourceIp.IsNull() && !item.SourceIp.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "source", item.SourceIp.ValueString())
+ }
+ if !item.Password.IsNull() && !item.Password.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "password", item.Password.ValueString())
+ }
+ if !item.ConnectionMode.IsNull() && !item.ConnectionMode.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "mode", item.ConnectionMode.ValueString())
+ }
+ if !item.Option.IsNull() && !item.Option.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "option", item.Option.ValueString())
+ }
+ if !item.HoldTime.IsNull() && !item.HoldTime.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "hold-time", strconv.FormatInt(item.HoldTime.ValueInt64(), 10))
+ }
+ if !item.MaxTime.IsNull() && !item.MaxTime.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "max-time", strconv.FormatInt(item.MaxTime.ValueInt64(), 10))
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-cts:sxp/connection/peer/ipv4-no-vrf", cBody.Res())
+ }
+ }
+ if len(data.SxpConnectionPeersIpv4Vrf) > 0 {
+ for _, item := range data.SxpConnectionPeersIpv4Vrf {
+ cBody := netconf.Body{}
+ if !item.Ip.IsNull() && !item.Ip.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "ipv4", item.Ip.ValueString())
+ }
+ if !item.Vrf.IsNull() && !item.Vrf.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "vrf", item.Vrf.ValueString())
+ }
+ if !item.SourceIp.IsNull() && !item.SourceIp.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "source", item.SourceIp.ValueString())
+ }
+ if !item.Password.IsNull() && !item.Password.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "password", item.Password.ValueString())
+ }
+ if !item.ConnectionMode.IsNull() && !item.ConnectionMode.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "mode", item.ConnectionMode.ValueString())
+ }
+ if !item.Option.IsNull() && !item.Option.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "option", item.Option.ValueString())
+ }
+ if !item.HoldTime.IsNull() && !item.HoldTime.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "hold-time", strconv.FormatInt(item.HoldTime.ValueInt64(), 10))
+ }
+ if !item.MaxTime.IsNull() && !item.MaxTime.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "max-time", strconv.FormatInt(item.MaxTime.ValueInt64(), 10))
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-cts:sxp/connection/peer/ipv4-with-vrf", cBody.Res())
+ }
+ }
+ if !data.SxpSpeakerHoldTime.IsNull() && !data.SxpSpeakerHoldTime.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-cts:sxp/speaker/hold-time", strconv.FormatInt(data.SxpSpeakerHoldTime.ValueInt64(), 10))
+ }
+ if !data.SxpListenerHoldMinTime.IsNull() && !data.SxpListenerHoldMinTime.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-cts:sxp/listener/hold-time/min-time", strconv.FormatInt(data.SxpListenerHoldMinTime.ValueInt64(), 10))
+ }
+ if !data.SxpListenerHoldMaxTime.IsNull() && !data.SxpListenerHoldMaxTime.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-cts:sxp/listener/hold-time/max-time", strconv.FormatInt(data.SxpListenerHoldMaxTime.ValueInt64(), 10))
+ }
+ if !data.RoleBasedEnforcement.IsNull() && !data.RoleBasedEnforcement.IsUnknown() {
+ if data.RoleBasedEnforcement.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-cts:role-based/enforcement-only/enforcement", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-cts:role-based/enforcement-only/enforcement")
+ }
+ }
+ if !data.RoleBasedEnforcementLoggingInterval.IsNull() && !data.RoleBasedEnforcementLoggingInterval.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-cts:role-based/enforcement/logging-interval", strconv.FormatInt(data.RoleBasedEnforcementLoggingInterval.ValueInt64(), 10))
+ }
+ if !data.RoleBasedEnforcementVlanLists.IsNull() && !data.RoleBasedEnforcementVlanLists.IsUnknown() {
+ var values []int
+ data.RoleBasedEnforcementVlanLists.ElementsAs(ctx, &values, false)
+ for _, v := range values {
+ body = helpers.AppendFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-cts:role-based/enforcement/vlan-lists", v)
+ }
+ }
+ if !data.RoleBasedPermissionsDefaultAclName.IsNull() && !data.RoleBasedPermissionsDefaultAclName.IsUnknown() {
+ var values []string
+ data.RoleBasedPermissionsDefaultAclName.ElementsAs(ctx, &values, false)
+ for _, v := range values {
+ body = helpers.AppendFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-cts:role-based/permissions/default/ACL-name-new", v)
+ }
+ }
+ bodyString, err := body.String()
+ if err != nil {
+ tflog.Error(ctx, fmt.Sprintf("Error converting body to string: %s", err))
+ }
+ return bodyString
+}
+
+// End of section. //template:end toBodyXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBody
func (data *CTS) updateFromBody(ctx context.Context, res gjson.Result) {
@@ -416,6 +551,187 @@ func (data *CTS) updateFromBody(ctx context.Context, res gjson.Result) {
// End of section. //template:end updateFromBody
+// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBodyXML
+
+func (data *CTS) updateFromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-cts:authorization/list"); value.Exists() && !data.AuthorizationList.IsNull() {
+ data.AuthorizationList = types.StringValue(value.String())
+ } else {
+ data.AuthorizationList = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-cts:sgt"); value.Exists() && !data.Sgt.IsNull() {
+ data.Sgt = types.Int64Value(value.Int())
+ } else {
+ data.Sgt = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-cts:sxp/sxp-def-enable"); !data.SxpEnable.IsNull() {
+ if value.Exists() {
+ data.SxpEnable = types.BoolValue(value.Bool())
+ }
+ } else {
+ data.SxpEnable = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-cts:sxp/retry/period"); value.Exists() && !data.SxpRetryPeriod.IsNull() {
+ data.SxpRetryPeriod = types.Int64Value(value.Int())
+ } else {
+ data.SxpRetryPeriod = types.Int64Null()
+ }
+ for i := range data.SxpConnectionPeersIpv4 {
+ keys := [...]string{"ipv4"}
+ keyValues := [...]string{data.SxpConnectionPeersIpv4[i].Ip.ValueString()}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-cts:sxp/connection/peer/ipv4-no-vrf").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, "ipv4"); value.Exists() && !data.SxpConnectionPeersIpv4[i].Ip.IsNull() {
+ data.SxpConnectionPeersIpv4[i].Ip = types.StringValue(value.String())
+ } else {
+ data.SxpConnectionPeersIpv4[i].Ip = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "source"); value.Exists() && !data.SxpConnectionPeersIpv4[i].SourceIp.IsNull() {
+ data.SxpConnectionPeersIpv4[i].SourceIp = types.StringValue(value.String())
+ } else {
+ data.SxpConnectionPeersIpv4[i].SourceIp = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "mode"); value.Exists() && !data.SxpConnectionPeersIpv4[i].ConnectionMode.IsNull() {
+ data.SxpConnectionPeersIpv4[i].ConnectionMode = types.StringValue(value.String())
+ } else {
+ data.SxpConnectionPeersIpv4[i].ConnectionMode = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "option"); value.Exists() && !data.SxpConnectionPeersIpv4[i].Option.IsNull() {
+ data.SxpConnectionPeersIpv4[i].Option = types.StringValue(value.String())
+ } else {
+ data.SxpConnectionPeersIpv4[i].Option = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "hold-time"); value.Exists() && !data.SxpConnectionPeersIpv4[i].HoldTime.IsNull() {
+ data.SxpConnectionPeersIpv4[i].HoldTime = types.Int64Value(value.Int())
+ } else {
+ data.SxpConnectionPeersIpv4[i].HoldTime = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(r, "max-time"); value.Exists() && !data.SxpConnectionPeersIpv4[i].MaxTime.IsNull() {
+ data.SxpConnectionPeersIpv4[i].MaxTime = types.Int64Value(value.Int())
+ } else {
+ data.SxpConnectionPeersIpv4[i].MaxTime = types.Int64Null()
+ }
+ }
+ for i := range data.SxpConnectionPeersIpv4Vrf {
+ keys := [...]string{"ipv4", "vrf"}
+ keyValues := [...]string{data.SxpConnectionPeersIpv4Vrf[i].Ip.ValueString(), data.SxpConnectionPeersIpv4Vrf[i].Vrf.ValueString()}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-cts:sxp/connection/peer/ipv4-with-vrf").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, "ipv4"); value.Exists() && !data.SxpConnectionPeersIpv4Vrf[i].Ip.IsNull() {
+ data.SxpConnectionPeersIpv4Vrf[i].Ip = types.StringValue(value.String())
+ } else {
+ data.SxpConnectionPeersIpv4Vrf[i].Ip = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "vrf"); value.Exists() && !data.SxpConnectionPeersIpv4Vrf[i].Vrf.IsNull() {
+ data.SxpConnectionPeersIpv4Vrf[i].Vrf = types.StringValue(value.String())
+ } else {
+ data.SxpConnectionPeersIpv4Vrf[i].Vrf = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "source"); value.Exists() && !data.SxpConnectionPeersIpv4Vrf[i].SourceIp.IsNull() {
+ data.SxpConnectionPeersIpv4Vrf[i].SourceIp = types.StringValue(value.String())
+ } else {
+ data.SxpConnectionPeersIpv4Vrf[i].SourceIp = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "mode"); value.Exists() && !data.SxpConnectionPeersIpv4Vrf[i].ConnectionMode.IsNull() {
+ data.SxpConnectionPeersIpv4Vrf[i].ConnectionMode = types.StringValue(value.String())
+ } else {
+ data.SxpConnectionPeersIpv4Vrf[i].ConnectionMode = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "option"); value.Exists() && !data.SxpConnectionPeersIpv4Vrf[i].Option.IsNull() {
+ data.SxpConnectionPeersIpv4Vrf[i].Option = types.StringValue(value.String())
+ } else {
+ data.SxpConnectionPeersIpv4Vrf[i].Option = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "hold-time"); value.Exists() && !data.SxpConnectionPeersIpv4Vrf[i].HoldTime.IsNull() {
+ data.SxpConnectionPeersIpv4Vrf[i].HoldTime = types.Int64Value(value.Int())
+ } else {
+ data.SxpConnectionPeersIpv4Vrf[i].HoldTime = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(r, "max-time"); value.Exists() && !data.SxpConnectionPeersIpv4Vrf[i].MaxTime.IsNull() {
+ data.SxpConnectionPeersIpv4Vrf[i].MaxTime = types.Int64Value(value.Int())
+ } else {
+ data.SxpConnectionPeersIpv4Vrf[i].MaxTime = types.Int64Null()
+ }
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-cts:sxp/speaker/hold-time"); value.Exists() && !data.SxpSpeakerHoldTime.IsNull() {
+ data.SxpSpeakerHoldTime = types.Int64Value(value.Int())
+ } else {
+ data.SxpSpeakerHoldTime = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-cts:sxp/listener/hold-time/min-time"); value.Exists() && !data.SxpListenerHoldMinTime.IsNull() {
+ data.SxpListenerHoldMinTime = types.Int64Value(value.Int())
+ } else {
+ data.SxpListenerHoldMinTime = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-cts:sxp/listener/hold-time/max-time"); value.Exists() && !data.SxpListenerHoldMaxTime.IsNull() {
+ data.SxpListenerHoldMaxTime = types.Int64Value(value.Int())
+ } else {
+ data.SxpListenerHoldMaxTime = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-cts:role-based/enforcement-only/enforcement"); !data.RoleBasedEnforcement.IsNull() {
+ if value.Exists() {
+ data.RoleBasedEnforcement = types.BoolValue(true)
+ } else {
+ data.RoleBasedEnforcement = types.BoolValue(false)
+ }
+ } else {
+ data.RoleBasedEnforcement = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-cts:role-based/enforcement/logging-interval"); value.Exists() && !data.RoleBasedEnforcementLoggingInterval.IsNull() {
+ data.RoleBasedEnforcementLoggingInterval = types.Int64Value(value.Int())
+ } else {
+ data.RoleBasedEnforcementLoggingInterval = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-cts:role-based/enforcement/vlan-lists"); value.Exists() && !data.RoleBasedEnforcementVlanLists.IsNull() {
+ data.RoleBasedEnforcementVlanLists = helpers.GetInt64ListXML(value.Array())
+ } else {
+ data.RoleBasedEnforcementVlanLists = types.ListNull(types.Int64Type)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-cts:role-based/permissions/default/ACL-name-new"); value.Exists() && !data.RoleBasedPermissionsDefaultAclName.IsNull() {
+ data.RoleBasedPermissionsDefaultAclName = helpers.GetStringListXML(value.Array())
+ } else {
+ data.RoleBasedPermissionsDefaultAclName = types.ListNull(types.StringType)
+ }
+}
+
+// End of section. //template:end updateFromBodyXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin fromBody
func (data *CTS) fromBody(ctx context.Context, res gjson.Result) {
@@ -654,37 +970,267 @@ func (data *CTSData) fromBody(ctx context.Context, res gjson.Result) {
// End of section. //template:end fromBodyData
-// Section below is generated&owned by "gen/generator.go". //template:begin getDeletedItems
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyXML
-func (data *CTS) getDeletedItems(ctx context.Context, state CTS) []string {
- deletedItems := make([]string, 0)
- if !state.RoleBasedPermissionsDefaultAclName.IsNull() {
- if data.RoleBasedPermissionsDefaultAclName.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-cts:role-based/permissions/default/ACL-name-new", state.getPath()))
- } else {
- var dataValues, stateValues []string
- data.RoleBasedPermissionsDefaultAclName.ElementsAs(ctx, &dataValues, false)
- state.RoleBasedPermissionsDefaultAclName.ElementsAs(ctx, &stateValues, false)
- for _, v := range stateValues {
- found := false
- for _, vv := range dataValues {
- if v == vv {
- found = true
- break
- }
- }
- if !found {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-cts:role-based/permissions/default/ACL-name-new=%v", state.getPath(), v))
- }
- }
- }
+func (data *CTS) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-cts:authorization/list"); value.Exists() {
+ data.AuthorizationList = types.StringValue(value.String())
}
- if !state.RoleBasedEnforcementVlanLists.IsNull() {
- if data.RoleBasedEnforcementVlanLists.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-cts:role-based/enforcement/vlan-lists", state.getPath()))
- } else {
- var dataValues, stateValues []int
- data.RoleBasedEnforcementVlanLists.ElementsAs(ctx, &dataValues, false)
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-cts:sgt"); value.Exists() {
+ data.Sgt = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-cts:sxp/sxp-def-enable"); value.Exists() {
+ data.SxpEnable = types.BoolValue(value.Bool())
+ } else {
+ data.SxpEnable = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-cts:sxp/default/password/type"); value.Exists() {
+ data.SxpDefaultPasswordType = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-cts:sxp/default/password/secret"); value.Exists() {
+ data.SxpDefaultPassword = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-cts:sxp/retry/period"); value.Exists() {
+ data.SxpRetryPeriod = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-cts:sxp/connection/peer/ipv4-no-vrf"); value.Exists() {
+ data.SxpConnectionPeersIpv4 = make([]CTSSxpConnectionPeersIpv4, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := CTSSxpConnectionPeersIpv4{}
+ if cValue := helpers.GetFromXPath(v, "ipv4"); cValue.Exists() {
+ item.Ip = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "source"); cValue.Exists() {
+ item.SourceIp = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "password"); cValue.Exists() {
+ item.Password = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "mode"); cValue.Exists() {
+ item.ConnectionMode = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "option"); cValue.Exists() {
+ item.Option = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "hold-time"); cValue.Exists() {
+ item.HoldTime = types.Int64Value(cValue.Int())
+ }
+ if cValue := helpers.GetFromXPath(v, "max-time"); cValue.Exists() {
+ item.MaxTime = types.Int64Value(cValue.Int())
+ }
+ data.SxpConnectionPeersIpv4 = append(data.SxpConnectionPeersIpv4, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-cts:sxp/connection/peer/ipv4-with-vrf"); value.Exists() {
+ data.SxpConnectionPeersIpv4Vrf = make([]CTSSxpConnectionPeersIpv4Vrf, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := CTSSxpConnectionPeersIpv4Vrf{}
+ if cValue := helpers.GetFromXPath(v, "ipv4"); cValue.Exists() {
+ item.Ip = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "vrf"); cValue.Exists() {
+ item.Vrf = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "source"); cValue.Exists() {
+ item.SourceIp = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "password"); cValue.Exists() {
+ item.Password = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "mode"); cValue.Exists() {
+ item.ConnectionMode = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "option"); cValue.Exists() {
+ item.Option = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "hold-time"); cValue.Exists() {
+ item.HoldTime = types.Int64Value(cValue.Int())
+ }
+ if cValue := helpers.GetFromXPath(v, "max-time"); cValue.Exists() {
+ item.MaxTime = types.Int64Value(cValue.Int())
+ }
+ data.SxpConnectionPeersIpv4Vrf = append(data.SxpConnectionPeersIpv4Vrf, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-cts:sxp/speaker/hold-time"); value.Exists() {
+ data.SxpSpeakerHoldTime = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-cts:sxp/listener/hold-time/min-time"); value.Exists() {
+ data.SxpListenerHoldMinTime = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-cts:sxp/listener/hold-time/max-time"); value.Exists() {
+ data.SxpListenerHoldMaxTime = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-cts:role-based/enforcement-only/enforcement"); value.Exists() {
+ data.RoleBasedEnforcement = types.BoolValue(true)
+ } else {
+ data.RoleBasedEnforcement = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-cts:role-based/enforcement/logging-interval"); value.Exists() {
+ data.RoleBasedEnforcementLoggingInterval = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-cts:role-based/enforcement/vlan-lists"); value.Exists() {
+ data.RoleBasedEnforcementVlanLists = helpers.GetInt64ListXML(value.Array())
+ } else {
+ data.RoleBasedEnforcementVlanLists = types.ListNull(types.Int64Type)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-cts:role-based/permissions/default/ACL-name-new"); value.Exists() {
+ data.RoleBasedPermissionsDefaultAclName = helpers.GetStringListXML(value.Array())
+ } else {
+ data.RoleBasedPermissionsDefaultAclName = types.ListNull(types.StringType)
+ }
+}
+
+// End of section. //template:end fromBodyXML
+
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyDataXML
+
+func (data *CTSData) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-cts:authorization/list"); value.Exists() {
+ data.AuthorizationList = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-cts:sgt"); value.Exists() {
+ data.Sgt = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-cts:sxp/sxp-def-enable"); value.Exists() {
+ data.SxpEnable = types.BoolValue(value.Bool())
+ } else {
+ data.SxpEnable = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-cts:sxp/default/password/type"); value.Exists() {
+ data.SxpDefaultPasswordType = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-cts:sxp/default/password/secret"); value.Exists() {
+ data.SxpDefaultPassword = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-cts:sxp/retry/period"); value.Exists() {
+ data.SxpRetryPeriod = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-cts:sxp/connection/peer/ipv4-no-vrf"); value.Exists() {
+ data.SxpConnectionPeersIpv4 = make([]CTSSxpConnectionPeersIpv4, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := CTSSxpConnectionPeersIpv4{}
+ if cValue := helpers.GetFromXPath(v, "ipv4"); cValue.Exists() {
+ item.Ip = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "source"); cValue.Exists() {
+ item.SourceIp = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "password"); cValue.Exists() {
+ item.Password = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "mode"); cValue.Exists() {
+ item.ConnectionMode = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "option"); cValue.Exists() {
+ item.Option = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "hold-time"); cValue.Exists() {
+ item.HoldTime = types.Int64Value(cValue.Int())
+ }
+ if cValue := helpers.GetFromXPath(v, "max-time"); cValue.Exists() {
+ item.MaxTime = types.Int64Value(cValue.Int())
+ }
+ data.SxpConnectionPeersIpv4 = append(data.SxpConnectionPeersIpv4, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-cts:sxp/connection/peer/ipv4-with-vrf"); value.Exists() {
+ data.SxpConnectionPeersIpv4Vrf = make([]CTSSxpConnectionPeersIpv4Vrf, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := CTSSxpConnectionPeersIpv4Vrf{}
+ if cValue := helpers.GetFromXPath(v, "ipv4"); cValue.Exists() {
+ item.Ip = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "vrf"); cValue.Exists() {
+ item.Vrf = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "source"); cValue.Exists() {
+ item.SourceIp = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "password"); cValue.Exists() {
+ item.Password = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "mode"); cValue.Exists() {
+ item.ConnectionMode = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "option"); cValue.Exists() {
+ item.Option = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "hold-time"); cValue.Exists() {
+ item.HoldTime = types.Int64Value(cValue.Int())
+ }
+ if cValue := helpers.GetFromXPath(v, "max-time"); cValue.Exists() {
+ item.MaxTime = types.Int64Value(cValue.Int())
+ }
+ data.SxpConnectionPeersIpv4Vrf = append(data.SxpConnectionPeersIpv4Vrf, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-cts:sxp/speaker/hold-time"); value.Exists() {
+ data.SxpSpeakerHoldTime = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-cts:sxp/listener/hold-time/min-time"); value.Exists() {
+ data.SxpListenerHoldMinTime = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-cts:sxp/listener/hold-time/max-time"); value.Exists() {
+ data.SxpListenerHoldMaxTime = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-cts:role-based/enforcement-only/enforcement"); value.Exists() {
+ data.RoleBasedEnforcement = types.BoolValue(true)
+ } else {
+ data.RoleBasedEnforcement = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-cts:role-based/enforcement/logging-interval"); value.Exists() {
+ data.RoleBasedEnforcementLoggingInterval = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-cts:role-based/enforcement/vlan-lists"); value.Exists() {
+ data.RoleBasedEnforcementVlanLists = helpers.GetInt64ListXML(value.Array())
+ } else {
+ data.RoleBasedEnforcementVlanLists = types.ListNull(types.Int64Type)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-cts:role-based/permissions/default/ACL-name-new"); value.Exists() {
+ data.RoleBasedPermissionsDefaultAclName = helpers.GetStringListXML(value.Array())
+ } else {
+ data.RoleBasedPermissionsDefaultAclName = types.ListNull(types.StringType)
+ }
+}
+
+// End of section. //template:end fromBodyDataXML
+
+// Section below is generated&owned by "gen/generator.go". //template:begin getDeletedItems
+
+func (data *CTS) getDeletedItems(ctx context.Context, state CTS) []string {
+ deletedItems := make([]string, 0)
+ if !state.RoleBasedPermissionsDefaultAclName.IsNull() {
+ if data.RoleBasedPermissionsDefaultAclName.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-cts:role-based/permissions/default/ACL-name-new", state.getPath()))
+ } else {
+ var dataValues, stateValues []string
+ data.RoleBasedPermissionsDefaultAclName.ElementsAs(ctx, &dataValues, false)
+ state.RoleBasedPermissionsDefaultAclName.ElementsAs(ctx, &stateValues, false)
+ for _, v := range stateValues {
+ found := false
+ for _, vv := range dataValues {
+ if v == vv {
+ found = true
+ break
+ }
+ }
+ if !found {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-cts:role-based/permissions/default/ACL-name-new=%v", state.getPath(), v))
+ }
+ }
+ }
+ }
+ if !state.RoleBasedEnforcementVlanLists.IsNull() {
+ if data.RoleBasedEnforcementVlanLists.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-cts:role-based/enforcement/vlan-lists", state.getPath()))
+ } else {
+ var dataValues, stateValues []int
+ data.RoleBasedEnforcementVlanLists.ElementsAs(ctx, &dataValues, false)
state.RoleBasedEnforcementVlanLists.ElementsAs(ctx, &stateValues, false)
for _, v := range stateValues {
found := false
@@ -831,6 +1377,193 @@ func (data *CTS) getDeletedItems(ctx context.Context, state CTS) []string {
// End of section. //template:end getDeletedItems
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletedItemsXML
+
+func (data *CTS) addDeletedItemsXML(ctx context.Context, state CTS, body string) string {
+ b := netconf.NewBody(body)
+ if !state.AuthorizationList.IsNull() && data.AuthorizationList.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-cts:authorization/list")
+ }
+ if !state.Sgt.IsNull() && data.Sgt.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-cts:sgt")
+ }
+ if !state.SxpEnable.IsNull() && data.SxpEnable.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-cts:sxp/sxp-def-enable")
+ }
+ if !state.SxpDefaultPasswordType.IsNull() && data.SxpDefaultPasswordType.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-cts:sxp/default/password/type")
+ }
+ if !state.SxpDefaultPassword.IsNull() && data.SxpDefaultPassword.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-cts:sxp/default/password/secret")
+ }
+ if !state.SxpRetryPeriod.IsNull() && data.SxpRetryPeriod.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-cts:sxp/retry/period")
+ }
+ for i := range state.SxpConnectionPeersIpv4 {
+ stateKeys := [...]string{"ipv4"}
+ stateKeyValues := [...]string{state.SxpConnectionPeersIpv4[i].Ip.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.SxpConnectionPeersIpv4[i].Ip.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.SxpConnectionPeersIpv4 {
+ found = true
+ if state.SxpConnectionPeersIpv4[i].Ip.ValueString() != data.SxpConnectionPeersIpv4[j].Ip.ValueString() {
+ found = false
+ }
+ if found {
+ if !state.SxpConnectionPeersIpv4[i].SourceIp.IsNull() && data.SxpConnectionPeersIpv4[j].SourceIp.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-cts:sxp/connection/peer/ipv4-no-vrf%v/source", predicates))
+ }
+ if !state.SxpConnectionPeersIpv4[i].Password.IsNull() && data.SxpConnectionPeersIpv4[j].Password.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-cts:sxp/connection/peer/ipv4-no-vrf%v/password", predicates))
+ }
+ if !state.SxpConnectionPeersIpv4[i].ConnectionMode.IsNull() && data.SxpConnectionPeersIpv4[j].ConnectionMode.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-cts:sxp/connection/peer/ipv4-no-vrf%v/mode", predicates))
+ }
+ if !state.SxpConnectionPeersIpv4[i].Option.IsNull() && data.SxpConnectionPeersIpv4[j].Option.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-cts:sxp/connection/peer/ipv4-no-vrf%v/option", predicates))
+ }
+ if !state.SxpConnectionPeersIpv4[i].HoldTime.IsNull() && data.SxpConnectionPeersIpv4[j].HoldTime.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-cts:sxp/connection/peer/ipv4-no-vrf%v/hold-time", predicates))
+ }
+ if !state.SxpConnectionPeersIpv4[i].MaxTime.IsNull() && data.SxpConnectionPeersIpv4[j].MaxTime.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-cts:sxp/connection/peer/ipv4-no-vrf%v/max-time", predicates))
+ }
+ break
+ }
+ }
+ if !found {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-cts:sxp/connection/peer/ipv4-no-vrf%v", predicates))
+ }
+ }
+ for i := range state.SxpConnectionPeersIpv4Vrf {
+ stateKeys := [...]string{"ipv4", "vrf"}
+ stateKeyValues := [...]string{state.SxpConnectionPeersIpv4Vrf[i].Ip.ValueString(), state.SxpConnectionPeersIpv4Vrf[i].Vrf.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.SxpConnectionPeersIpv4Vrf[i].Ip.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if !reflect.ValueOf(state.SxpConnectionPeersIpv4Vrf[i].Vrf.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.SxpConnectionPeersIpv4Vrf {
+ found = true
+ if state.SxpConnectionPeersIpv4Vrf[i].Ip.ValueString() != data.SxpConnectionPeersIpv4Vrf[j].Ip.ValueString() {
+ found = false
+ }
+ if state.SxpConnectionPeersIpv4Vrf[i].Vrf.ValueString() != data.SxpConnectionPeersIpv4Vrf[j].Vrf.ValueString() {
+ found = false
+ }
+ if found {
+ if !state.SxpConnectionPeersIpv4Vrf[i].SourceIp.IsNull() && data.SxpConnectionPeersIpv4Vrf[j].SourceIp.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-cts:sxp/connection/peer/ipv4-with-vrf%v/source", predicates))
+ }
+ if !state.SxpConnectionPeersIpv4Vrf[i].Password.IsNull() && data.SxpConnectionPeersIpv4Vrf[j].Password.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-cts:sxp/connection/peer/ipv4-with-vrf%v/password", predicates))
+ }
+ if !state.SxpConnectionPeersIpv4Vrf[i].ConnectionMode.IsNull() && data.SxpConnectionPeersIpv4Vrf[j].ConnectionMode.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-cts:sxp/connection/peer/ipv4-with-vrf%v/mode", predicates))
+ }
+ if !state.SxpConnectionPeersIpv4Vrf[i].Option.IsNull() && data.SxpConnectionPeersIpv4Vrf[j].Option.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-cts:sxp/connection/peer/ipv4-with-vrf%v/option", predicates))
+ }
+ if !state.SxpConnectionPeersIpv4Vrf[i].HoldTime.IsNull() && data.SxpConnectionPeersIpv4Vrf[j].HoldTime.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-cts:sxp/connection/peer/ipv4-with-vrf%v/hold-time", predicates))
+ }
+ if !state.SxpConnectionPeersIpv4Vrf[i].MaxTime.IsNull() && data.SxpConnectionPeersIpv4Vrf[j].MaxTime.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-cts:sxp/connection/peer/ipv4-with-vrf%v/max-time", predicates))
+ }
+ break
+ }
+ }
+ if !found {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-cts:sxp/connection/peer/ipv4-with-vrf%v", predicates))
+ }
+ }
+ if !state.SxpSpeakerHoldTime.IsNull() && data.SxpSpeakerHoldTime.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-cts:sxp/speaker/hold-time")
+ }
+ if !state.SxpListenerHoldMinTime.IsNull() && data.SxpListenerHoldMinTime.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-cts:sxp/listener/hold-time/min-time")
+ }
+ if !state.SxpListenerHoldMaxTime.IsNull() && data.SxpListenerHoldMaxTime.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-cts:sxp/listener/hold-time/max-time")
+ }
+ if !state.RoleBasedEnforcement.IsNull() && data.RoleBasedEnforcement.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-cts:role-based/enforcement-only/enforcement")
+ }
+ if !state.RoleBasedEnforcementLoggingInterval.IsNull() && data.RoleBasedEnforcementLoggingInterval.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-cts:role-based/enforcement/logging-interval")
+ }
+ if !state.RoleBasedEnforcementVlanLists.IsNull() {
+ if data.RoleBasedEnforcementVlanLists.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-cts:role-based/enforcement/vlan-lists")
+ } else {
+ var dataValues, stateValues []int
+ data.RoleBasedEnforcementVlanLists.ElementsAs(ctx, &dataValues, false)
+ state.RoleBasedEnforcementVlanLists.ElementsAs(ctx, &stateValues, false)
+ for _, v := range stateValues {
+ found := false
+ for _, vv := range dataValues {
+ if v == vv {
+ found = true
+ break
+ }
+ }
+ if !found {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-cts:role-based/enforcement/vlan-lists[.=%v]", v))
+ }
+ }
+ }
+ }
+ if !state.RoleBasedPermissionsDefaultAclName.IsNull() {
+ if data.RoleBasedPermissionsDefaultAclName.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-cts:role-based/permissions/default/ACL-name-new")
+ } else {
+ var dataValues, stateValues []string
+ data.RoleBasedPermissionsDefaultAclName.ElementsAs(ctx, &dataValues, false)
+ state.RoleBasedPermissionsDefaultAclName.ElementsAs(ctx, &stateValues, false)
+ for _, v := range stateValues {
+ found := false
+ for _, vv := range dataValues {
+ if v == vv {
+ found = true
+ break
+ }
+ }
+ if !found {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-cts:role-based/permissions/default/ACL-name-new[.=%v]", v))
+ }
+ }
+ }
+ }
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletedItemsXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin getEmptyLeafsDelete
func (data *CTS) getEmptyLeafsDelete(ctx context.Context) []string {
@@ -902,3 +1635,72 @@ func (data *CTS) getDeletePaths(ctx context.Context) []string {
}
// End of section. //template:end getDeletePaths
+
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletePathsXML
+
+func (data *CTS) addDeletePathsXML(ctx context.Context, body string) string {
+ b := netconf.NewBody(body)
+ if !data.AuthorizationList.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-cts:authorization/list")
+ }
+ if !data.Sgt.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-cts:sgt")
+ }
+ if !data.SxpEnable.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-cts:sxp/sxp-def-enable")
+ }
+ if !data.SxpDefaultPasswordType.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-cts:sxp/default/password/type")
+ }
+ if !data.SxpDefaultPassword.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-cts:sxp/default/password/secret")
+ }
+ if !data.SxpRetryPeriod.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-cts:sxp/retry/period")
+ }
+ for i := range data.SxpConnectionPeersIpv4 {
+ keys := [...]string{"ipv4"}
+ keyValues := [...]string{data.SxpConnectionPeersIpv4[i].Ip.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/Cisco-IOS-XE-cts:sxp/connection/peer/ipv4-no-vrf%v", predicates))
+ }
+ for i := range data.SxpConnectionPeersIpv4Vrf {
+ keys := [...]string{"ipv4", "vrf"}
+ keyValues := [...]string{data.SxpConnectionPeersIpv4Vrf[i].Ip.ValueString(), data.SxpConnectionPeersIpv4Vrf[i].Vrf.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/Cisco-IOS-XE-cts:sxp/connection/peer/ipv4-with-vrf%v", predicates))
+ }
+ if !data.SxpSpeakerHoldTime.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-cts:sxp/speaker/hold-time")
+ }
+ if !data.SxpListenerHoldMinTime.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-cts:sxp/listener/hold-time/min-time")
+ }
+ if !data.SxpListenerHoldMaxTime.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-cts:sxp/listener/hold-time/max-time")
+ }
+ if !data.RoleBasedEnforcement.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-cts:role-based/enforcement-only/enforcement")
+ }
+ if !data.RoleBasedEnforcementLoggingInterval.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-cts:role-based/enforcement/logging-interval")
+ }
+ if !data.RoleBasedEnforcementVlanLists.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-cts:role-based/enforcement/vlan-lists")
+ }
+ if !data.RoleBasedPermissionsDefaultAclName.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-cts:role-based/permissions/default/ACL-name-new")
+ }
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletePathsXML
diff --git a/internal/provider/model_iosxe_device_sensor.go b/internal/provider/model_iosxe_device_sensor.go
index d9c28e15..a9cbd051 100644
--- a/internal/provider/model_iosxe_device_sensor.go
+++ b/internal/provider/model_iosxe_device_sensor.go
@@ -30,6 +30,9 @@ import (
"github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/types"
+ "github.com/hashicorp/terraform-plugin-log/tflog"
+ "github.com/netascode/go-netconf"
+ "github.com/netascode/xmldot"
"github.com/tidwall/gjson"
"github.com/tidwall/sjson"
)
@@ -135,6 +138,17 @@ func (data DeviceSensor) getPathShort() string {
return matches[1]
}
+// getXPath returns the XPath for NETCONF operations
+func (data DeviceSensor) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/Cisco-IOS-XE-device-sensor:device-sensor"
+ return path
+}
+
+func (data DeviceSensorData) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/Cisco-IOS-XE-device-sensor:device-sensor"
+ return path
+}
+
// End of section. //template:end getPath
// Section below is generated&owned by "gen/generator.go". //template:begin toBody
@@ -308,6 +322,226 @@ func (data DeviceSensor) toBody(ctx context.Context) string {
// End of section. //template:end toBody
+// Section below is generated&owned by "gen/generator.go". //template:begin toBodyXML
+
+func (data DeviceSensor) toBodyXML(ctx context.Context) string {
+ body := netconf.Body{}
+ if len(data.FilterListsLldp) > 0 {
+ for _, item := range data.FilterListsLldp {
+ cBody := netconf.Body{}
+ if !item.Name.IsNull() && !item.Name.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "name", item.Name.ValueString())
+ }
+ if !item.TlvNamePortId.IsNull() && !item.TlvNamePortId.IsUnknown() {
+ if item.TlvNamePortId.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "tlv/name/port-id", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "tlv/name/port-id")
+ }
+ }
+ if !item.TlvNamePortDescription.IsNull() && !item.TlvNamePortDescription.IsUnknown() {
+ if item.TlvNamePortDescription.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "tlv/name/port-description", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "tlv/name/port-description")
+ }
+ }
+ if !item.TlvNameSystemName.IsNull() && !item.TlvNameSystemName.IsUnknown() {
+ if item.TlvNameSystemName.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "tlv/name/system-name", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "tlv/name/system-name")
+ }
+ }
+ if !item.TlvNameSystemDescription.IsNull() && !item.TlvNameSystemDescription.IsUnknown() {
+ if item.TlvNameSystemDescription.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "tlv/name/system-description", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "tlv/name/system-description")
+ }
+ }
+ if !item.TlvNameSystemCapabilities.IsNull() && !item.TlvNameSystemCapabilities.IsUnknown() {
+ if item.TlvNameSystemCapabilities.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "tlv/name/system-capabilities", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "tlv/name/system-capabilities")
+ }
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/filter-list/lldp/list", cBody.Res())
+ }
+ }
+ if len(data.FilterListsDhcp) > 0 {
+ for _, item := range data.FilterListsDhcp {
+ cBody := netconf.Body{}
+ if !item.Name.IsNull() && !item.Name.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "name", item.Name.ValueString())
+ }
+ if !item.OptionNameHostName.IsNull() && !item.OptionNameHostName.IsUnknown() {
+ if item.OptionNameHostName.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "option/name/host-name", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "option/name/host-name")
+ }
+ }
+ if !item.OptionNameDefaultIpTtl.IsNull() && !item.OptionNameDefaultIpTtl.IsUnknown() {
+ if item.OptionNameDefaultIpTtl.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "option/name/default-ip-ttl", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "option/name/default-ip-ttl")
+ }
+ }
+ if !item.OptionNameRequestedAddress.IsNull() && !item.OptionNameRequestedAddress.IsUnknown() {
+ if item.OptionNameRequestedAddress.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "option/name/requested-address", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "option/name/requested-address")
+ }
+ }
+ if !item.OptionNameParameterRequestList.IsNull() && !item.OptionNameParameterRequestList.IsUnknown() {
+ if item.OptionNameParameterRequestList.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "option/name/parameter-request-list", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "option/name/parameter-request-list")
+ }
+ }
+ if !item.OptionNameClassIdentifier.IsNull() && !item.OptionNameClassIdentifier.IsUnknown() {
+ if item.OptionNameClassIdentifier.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "option/name/class-identifier", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "option/name/class-identifier")
+ }
+ }
+ if !item.OptionNameClientIdentifier.IsNull() && !item.OptionNameClientIdentifier.IsUnknown() {
+ if item.OptionNameClientIdentifier.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "option/name/client-identifier", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "option/name/client-identifier")
+ }
+ }
+ if !item.OptionNameClientFqdn.IsNull() && !item.OptionNameClientFqdn.IsUnknown() {
+ if item.OptionNameClientFqdn.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "option/name/client-fqdn", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "option/name/client-fqdn")
+ }
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/filter-list/dhcp/list", cBody.Res())
+ }
+ }
+ if len(data.FilterListsCdp) > 0 {
+ for _, item := range data.FilterListsCdp {
+ cBody := netconf.Body{}
+ if !item.Name.IsNull() && !item.Name.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "name", item.Name.ValueString())
+ }
+ if !item.TlvNameDeviceName.IsNull() && !item.TlvNameDeviceName.IsUnknown() {
+ if item.TlvNameDeviceName.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "tlv/name/device-name", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "tlv/name/device-name")
+ }
+ }
+ if !item.TlvNameAddressType.IsNull() && !item.TlvNameAddressType.IsUnknown() {
+ if item.TlvNameAddressType.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "tlv/name/address-type", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "tlv/name/address-type")
+ }
+ }
+ if !item.TlvNamePortIdType.IsNull() && !item.TlvNamePortIdType.IsUnknown() {
+ if item.TlvNamePortIdType.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "tlv/name/port-id-type", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "tlv/name/port-id-type")
+ }
+ }
+ if !item.TlvNameCapabilitiesType.IsNull() && !item.TlvNameCapabilitiesType.IsUnknown() {
+ if item.TlvNameCapabilitiesType.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "tlv/name/capabilities-type", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "tlv/name/capabilities-type")
+ }
+ }
+ if !item.TlvNamePlatformType.IsNull() && !item.TlvNamePlatformType.IsUnknown() {
+ if item.TlvNamePlatformType.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "tlv/name/platform-type", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "tlv/name/platform-type")
+ }
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/filter-list/cdp/list", cBody.Res())
+ }
+ }
+ if len(data.FilterSpecDhcpIncludes) > 0 {
+ for _, item := range data.FilterSpecDhcpIncludes {
+ cBody := netconf.Body{}
+ if !item.Name.IsNull() && !item.Name.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "name", item.Name.ValueString())
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/filter-spec/dhcp/include/list", cBody.Res())
+ }
+ }
+ if len(data.FilterSpecDhcpExcludes) > 0 {
+ for _, item := range data.FilterSpecDhcpExcludes {
+ cBody := netconf.Body{}
+ if !item.Name.IsNull() && !item.Name.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "name", item.Name.ValueString())
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/filter-spec/dhcp/exclude/list", cBody.Res())
+ }
+ }
+ if len(data.FilterSpecLldpIncludes) > 0 {
+ for _, item := range data.FilterSpecLldpIncludes {
+ cBody := netconf.Body{}
+ if !item.Name.IsNull() && !item.Name.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "name", item.Name.ValueString())
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/filter-spec/lldp/include/list", cBody.Res())
+ }
+ }
+ if len(data.FilterSpecLldpExcludes) > 0 {
+ for _, item := range data.FilterSpecLldpExcludes {
+ cBody := netconf.Body{}
+ if !item.Name.IsNull() && !item.Name.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "name", item.Name.ValueString())
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/filter-spec/lldp/exclude/list", cBody.Res())
+ }
+ }
+ if len(data.FilterSpecCdpIncludes) > 0 {
+ for _, item := range data.FilterSpecCdpIncludes {
+ cBody := netconf.Body{}
+ if !item.Name.IsNull() && !item.Name.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "name", item.Name.ValueString())
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/filter-spec/cdp/include/list", cBody.Res())
+ }
+ }
+ if len(data.FilterSpecCdpExcludes) > 0 {
+ for _, item := range data.FilterSpecCdpExcludes {
+ cBody := netconf.Body{}
+ if !item.Name.IsNull() && !item.Name.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "name", item.Name.ValueString())
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/filter-spec/cdp/exclude/list", cBody.Res())
+ }
+ }
+ if !data.NotifyAllChanges.IsNull() && !data.NotifyAllChanges.IsUnknown() {
+ if data.NotifyAllChanges.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/notify/all-changes", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/notify/all-changes")
+ }
+ }
+ bodyString, err := body.String()
+ if err != nil {
+ tflog.Error(ctx, fmt.Sprintf("Error converting body to string: %s", err))
+ }
+ return bodyString
+}
+
+// End of section. //template:end toBodyXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBody
func (data *DeviceSensor) updateFromBody(ctx context.Context, res gjson.Result) {
@@ -742,209 +976,439 @@ func (data *DeviceSensor) updateFromBody(ctx context.Context, res gjson.Result)
// End of section. //template:end updateFromBody
-// Section below is generated&owned by "gen/generator.go". //template:begin fromBody
+// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBodyXML
-func (data *DeviceSensor) fromBody(ctx context.Context, res gjson.Result) {
- prefix := helpers.LastElement(data.getPath()) + "."
- if res.Get(helpers.LastElement(data.getPath())).IsArray() {
- prefix += "0."
- }
- if value := res.Get(prefix + "filter-list.lldp.list"); value.Exists() {
- data.FilterListsLldp = make([]DeviceSensorFilterListsLldp, 0)
- value.ForEach(func(k, v gjson.Result) bool {
- item := DeviceSensorFilterListsLldp{}
- if cValue := v.Get("name"); cValue.Exists() {
- item.Name = types.StringValue(cValue.String())
- }
- if cValue := v.Get("tlv.name.port-id"); cValue.Exists() {
- item.TlvNamePortId = types.BoolValue(true)
+func (data *DeviceSensor) updateFromBodyXML(ctx context.Context, res xmldot.Result) {
+ for i := range data.FilterListsLldp {
+ keys := [...]string{"name"}
+ keyValues := [...]string{data.FilterListsLldp[i].Name.ValueString()}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/filter-list/lldp/list").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, "name"); value.Exists() && !data.FilterListsLldp[i].Name.IsNull() {
+ data.FilterListsLldp[i].Name = types.StringValue(value.String())
+ } else {
+ data.FilterListsLldp[i].Name = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "tlv/name/port-id"); !data.FilterListsLldp[i].TlvNamePortId.IsNull() {
+ if value.Exists() {
+ data.FilterListsLldp[i].TlvNamePortId = types.BoolValue(true)
} else {
- item.TlvNamePortId = types.BoolValue(false)
+ data.FilterListsLldp[i].TlvNamePortId = types.BoolValue(false)
}
- if cValue := v.Get("tlv.name.port-description"); cValue.Exists() {
- item.TlvNamePortDescription = types.BoolValue(true)
+ } else {
+ data.FilterListsLldp[i].TlvNamePortId = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "tlv/name/port-description"); !data.FilterListsLldp[i].TlvNamePortDescription.IsNull() {
+ if value.Exists() {
+ data.FilterListsLldp[i].TlvNamePortDescription = types.BoolValue(true)
} else {
- item.TlvNamePortDescription = types.BoolValue(false)
+ data.FilterListsLldp[i].TlvNamePortDescription = types.BoolValue(false)
}
- if cValue := v.Get("tlv.name.system-name"); cValue.Exists() {
- item.TlvNameSystemName = types.BoolValue(true)
+ } else {
+ data.FilterListsLldp[i].TlvNamePortDescription = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "tlv/name/system-name"); !data.FilterListsLldp[i].TlvNameSystemName.IsNull() {
+ if value.Exists() {
+ data.FilterListsLldp[i].TlvNameSystemName = types.BoolValue(true)
} else {
- item.TlvNameSystemName = types.BoolValue(false)
+ data.FilterListsLldp[i].TlvNameSystemName = types.BoolValue(false)
}
- if cValue := v.Get("tlv.name.system-description"); cValue.Exists() {
- item.TlvNameSystemDescription = types.BoolValue(true)
+ } else {
+ data.FilterListsLldp[i].TlvNameSystemName = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "tlv/name/system-description"); !data.FilterListsLldp[i].TlvNameSystemDescription.IsNull() {
+ if value.Exists() {
+ data.FilterListsLldp[i].TlvNameSystemDescription = types.BoolValue(true)
} else {
- item.TlvNameSystemDescription = types.BoolValue(false)
+ data.FilterListsLldp[i].TlvNameSystemDescription = types.BoolValue(false)
}
- if cValue := v.Get("tlv.name.system-capabilities"); cValue.Exists() {
- item.TlvNameSystemCapabilities = types.BoolValue(true)
+ } else {
+ data.FilterListsLldp[i].TlvNameSystemDescription = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "tlv/name/system-capabilities"); !data.FilterListsLldp[i].TlvNameSystemCapabilities.IsNull() {
+ if value.Exists() {
+ data.FilterListsLldp[i].TlvNameSystemCapabilities = types.BoolValue(true)
} else {
- item.TlvNameSystemCapabilities = types.BoolValue(false)
+ data.FilterListsLldp[i].TlvNameSystemCapabilities = types.BoolValue(false)
}
- data.FilterListsLldp = append(data.FilterListsLldp, item)
- return true
- })
+ } else {
+ data.FilterListsLldp[i].TlvNameSystemCapabilities = types.BoolNull()
+ }
}
- if value := res.Get(prefix + "filter-list.dhcp.list"); value.Exists() {
- data.FilterListsDhcp = make([]DeviceSensorFilterListsDhcp, 0)
- value.ForEach(func(k, v gjson.Result) bool {
- item := DeviceSensorFilterListsDhcp{}
- if cValue := v.Get("name"); cValue.Exists() {
- item.Name = types.StringValue(cValue.String())
- }
- if cValue := v.Get("option.name.host-name"); cValue.Exists() {
- item.OptionNameHostName = types.BoolValue(true)
+ for i := range data.FilterListsDhcp {
+ keys := [...]string{"name"}
+ keyValues := [...]string{data.FilterListsDhcp[i].Name.ValueString()}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/filter-list/dhcp/list").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, "name"); value.Exists() && !data.FilterListsDhcp[i].Name.IsNull() {
+ data.FilterListsDhcp[i].Name = types.StringValue(value.String())
+ } else {
+ data.FilterListsDhcp[i].Name = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "option/name/host-name"); !data.FilterListsDhcp[i].OptionNameHostName.IsNull() {
+ if value.Exists() {
+ data.FilterListsDhcp[i].OptionNameHostName = types.BoolValue(true)
} else {
- item.OptionNameHostName = types.BoolValue(false)
+ data.FilterListsDhcp[i].OptionNameHostName = types.BoolValue(false)
}
- if cValue := v.Get("option.name.default-ip-ttl"); cValue.Exists() {
- item.OptionNameDefaultIpTtl = types.BoolValue(true)
+ } else {
+ data.FilterListsDhcp[i].OptionNameHostName = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "option/name/default-ip-ttl"); !data.FilterListsDhcp[i].OptionNameDefaultIpTtl.IsNull() {
+ if value.Exists() {
+ data.FilterListsDhcp[i].OptionNameDefaultIpTtl = types.BoolValue(true)
} else {
- item.OptionNameDefaultIpTtl = types.BoolValue(false)
+ data.FilterListsDhcp[i].OptionNameDefaultIpTtl = types.BoolValue(false)
}
- if cValue := v.Get("option.name.requested-address"); cValue.Exists() {
- item.OptionNameRequestedAddress = types.BoolValue(true)
+ } else {
+ data.FilterListsDhcp[i].OptionNameDefaultIpTtl = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "option/name/requested-address"); !data.FilterListsDhcp[i].OptionNameRequestedAddress.IsNull() {
+ if value.Exists() {
+ data.FilterListsDhcp[i].OptionNameRequestedAddress = types.BoolValue(true)
} else {
- item.OptionNameRequestedAddress = types.BoolValue(false)
+ data.FilterListsDhcp[i].OptionNameRequestedAddress = types.BoolValue(false)
}
- if cValue := v.Get("option.name.parameter-request-list"); cValue.Exists() {
- item.OptionNameParameterRequestList = types.BoolValue(true)
+ } else {
+ data.FilterListsDhcp[i].OptionNameRequestedAddress = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "option/name/parameter-request-list"); !data.FilterListsDhcp[i].OptionNameParameterRequestList.IsNull() {
+ if value.Exists() {
+ data.FilterListsDhcp[i].OptionNameParameterRequestList = types.BoolValue(true)
} else {
- item.OptionNameParameterRequestList = types.BoolValue(false)
+ data.FilterListsDhcp[i].OptionNameParameterRequestList = types.BoolValue(false)
}
- if cValue := v.Get("option.name.class-identifier"); cValue.Exists() {
- item.OptionNameClassIdentifier = types.BoolValue(true)
+ } else {
+ data.FilterListsDhcp[i].OptionNameParameterRequestList = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "option/name/class-identifier"); !data.FilterListsDhcp[i].OptionNameClassIdentifier.IsNull() {
+ if value.Exists() {
+ data.FilterListsDhcp[i].OptionNameClassIdentifier = types.BoolValue(true)
} else {
- item.OptionNameClassIdentifier = types.BoolValue(false)
+ data.FilterListsDhcp[i].OptionNameClassIdentifier = types.BoolValue(false)
}
- if cValue := v.Get("option.name.client-identifier"); cValue.Exists() {
- item.OptionNameClientIdentifier = types.BoolValue(true)
+ } else {
+ data.FilterListsDhcp[i].OptionNameClassIdentifier = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "option/name/client-identifier"); !data.FilterListsDhcp[i].OptionNameClientIdentifier.IsNull() {
+ if value.Exists() {
+ data.FilterListsDhcp[i].OptionNameClientIdentifier = types.BoolValue(true)
} else {
- item.OptionNameClientIdentifier = types.BoolValue(false)
+ data.FilterListsDhcp[i].OptionNameClientIdentifier = types.BoolValue(false)
}
- if cValue := v.Get("option.name.client-fqdn"); cValue.Exists() {
- item.OptionNameClientFqdn = types.BoolValue(true)
+ } else {
+ data.FilterListsDhcp[i].OptionNameClientIdentifier = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "option/name/client-fqdn"); !data.FilterListsDhcp[i].OptionNameClientFqdn.IsNull() {
+ if value.Exists() {
+ data.FilterListsDhcp[i].OptionNameClientFqdn = types.BoolValue(true)
} else {
- item.OptionNameClientFqdn = types.BoolValue(false)
+ data.FilterListsDhcp[i].OptionNameClientFqdn = types.BoolValue(false)
}
- data.FilterListsDhcp = append(data.FilterListsDhcp, item)
- return true
- })
+ } else {
+ data.FilterListsDhcp[i].OptionNameClientFqdn = types.BoolNull()
+ }
}
- if value := res.Get(prefix + "filter-list.cdp.list"); value.Exists() {
- data.FilterListsCdp = make([]DeviceSensorFilterListsCdp, 0)
- value.ForEach(func(k, v gjson.Result) bool {
- item := DeviceSensorFilterListsCdp{}
- if cValue := v.Get("name"); cValue.Exists() {
- item.Name = types.StringValue(cValue.String())
- }
- if cValue := v.Get("tlv.name.device-name"); cValue.Exists() {
- item.TlvNameDeviceName = types.BoolValue(true)
+ for i := range data.FilterListsCdp {
+ keys := [...]string{"name"}
+ keyValues := [...]string{data.FilterListsCdp[i].Name.ValueString()}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/filter-list/cdp/list").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, "name"); value.Exists() && !data.FilterListsCdp[i].Name.IsNull() {
+ data.FilterListsCdp[i].Name = types.StringValue(value.String())
+ } else {
+ data.FilterListsCdp[i].Name = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "tlv/name/device-name"); !data.FilterListsCdp[i].TlvNameDeviceName.IsNull() {
+ if value.Exists() {
+ data.FilterListsCdp[i].TlvNameDeviceName = types.BoolValue(true)
} else {
- item.TlvNameDeviceName = types.BoolValue(false)
+ data.FilterListsCdp[i].TlvNameDeviceName = types.BoolValue(false)
}
- if cValue := v.Get("tlv.name.address-type"); cValue.Exists() {
- item.TlvNameAddressType = types.BoolValue(true)
+ } else {
+ data.FilterListsCdp[i].TlvNameDeviceName = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "tlv/name/address-type"); !data.FilterListsCdp[i].TlvNameAddressType.IsNull() {
+ if value.Exists() {
+ data.FilterListsCdp[i].TlvNameAddressType = types.BoolValue(true)
} else {
- item.TlvNameAddressType = types.BoolValue(false)
+ data.FilterListsCdp[i].TlvNameAddressType = types.BoolValue(false)
}
- if cValue := v.Get("tlv.name.port-id-type"); cValue.Exists() {
- item.TlvNamePortIdType = types.BoolValue(true)
+ } else {
+ data.FilterListsCdp[i].TlvNameAddressType = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "tlv/name/port-id-type"); !data.FilterListsCdp[i].TlvNamePortIdType.IsNull() {
+ if value.Exists() {
+ data.FilterListsCdp[i].TlvNamePortIdType = types.BoolValue(true)
} else {
- item.TlvNamePortIdType = types.BoolValue(false)
+ data.FilterListsCdp[i].TlvNamePortIdType = types.BoolValue(false)
}
- if cValue := v.Get("tlv.name.capabilities-type"); cValue.Exists() {
- item.TlvNameCapabilitiesType = types.BoolValue(true)
+ } else {
+ data.FilterListsCdp[i].TlvNamePortIdType = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "tlv/name/capabilities-type"); !data.FilterListsCdp[i].TlvNameCapabilitiesType.IsNull() {
+ if value.Exists() {
+ data.FilterListsCdp[i].TlvNameCapabilitiesType = types.BoolValue(true)
} else {
- item.TlvNameCapabilitiesType = types.BoolValue(false)
+ data.FilterListsCdp[i].TlvNameCapabilitiesType = types.BoolValue(false)
}
- if cValue := v.Get("tlv.name.platform-type"); cValue.Exists() {
- item.TlvNamePlatformType = types.BoolValue(true)
+ } else {
+ data.FilterListsCdp[i].TlvNameCapabilitiesType = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "tlv/name/platform-type"); !data.FilterListsCdp[i].TlvNamePlatformType.IsNull() {
+ if value.Exists() {
+ data.FilterListsCdp[i].TlvNamePlatformType = types.BoolValue(true)
} else {
- item.TlvNamePlatformType = types.BoolValue(false)
- }
- data.FilterListsCdp = append(data.FilterListsCdp, item)
- return true
- })
- }
- if value := res.Get(prefix + "filter-spec.dhcp.include.list"); value.Exists() {
- data.FilterSpecDhcpIncludes = make([]DeviceSensorFilterSpecDhcpIncludes, 0)
- value.ForEach(func(k, v gjson.Result) bool {
- item := DeviceSensorFilterSpecDhcpIncludes{}
- if cValue := v.Get("name"); cValue.Exists() {
- item.Name = types.StringValue(cValue.String())
- }
- data.FilterSpecDhcpIncludes = append(data.FilterSpecDhcpIncludes, item)
- return true
- })
- }
- if value := res.Get(prefix + "filter-spec.dhcp.exclude.list"); value.Exists() {
- data.FilterSpecDhcpExcludes = make([]DeviceSensorFilterSpecDhcpExcludes, 0)
- value.ForEach(func(k, v gjson.Result) bool {
- item := DeviceSensorFilterSpecDhcpExcludes{}
- if cValue := v.Get("name"); cValue.Exists() {
- item.Name = types.StringValue(cValue.String())
- }
- data.FilterSpecDhcpExcludes = append(data.FilterSpecDhcpExcludes, item)
- return true
- })
- }
- if value := res.Get(prefix + "filter-spec.lldp.include.list"); value.Exists() {
- data.FilterSpecLldpIncludes = make([]DeviceSensorFilterSpecLldpIncludes, 0)
- value.ForEach(func(k, v gjson.Result) bool {
- item := DeviceSensorFilterSpecLldpIncludes{}
- if cValue := v.Get("name"); cValue.Exists() {
- item.Name = types.StringValue(cValue.String())
- }
- data.FilterSpecLldpIncludes = append(data.FilterSpecLldpIncludes, item)
- return true
- })
- }
- if value := res.Get(prefix + "filter-spec.lldp.exclude.list"); value.Exists() {
- data.FilterSpecLldpExcludes = make([]DeviceSensorFilterSpecLldpExcludes, 0)
- value.ForEach(func(k, v gjson.Result) bool {
- item := DeviceSensorFilterSpecLldpExcludes{}
- if cValue := v.Get("name"); cValue.Exists() {
- item.Name = types.StringValue(cValue.String())
- }
- data.FilterSpecLldpExcludes = append(data.FilterSpecLldpExcludes, item)
- return true
- })
- }
- if value := res.Get(prefix + "filter-spec.cdp.include.list"); value.Exists() {
- data.FilterSpecCdpIncludes = make([]DeviceSensorFilterSpecCdpIncludes, 0)
- value.ForEach(func(k, v gjson.Result) bool {
- item := DeviceSensorFilterSpecCdpIncludes{}
- if cValue := v.Get("name"); cValue.Exists() {
- item.Name = types.StringValue(cValue.String())
- }
- data.FilterSpecCdpIncludes = append(data.FilterSpecCdpIncludes, item)
- return true
- })
- }
- if value := res.Get(prefix + "filter-spec.cdp.exclude.list"); value.Exists() {
- data.FilterSpecCdpExcludes = make([]DeviceSensorFilterSpecCdpExcludes, 0)
- value.ForEach(func(k, v gjson.Result) bool {
- item := DeviceSensorFilterSpecCdpExcludes{}
- if cValue := v.Get("name"); cValue.Exists() {
- item.Name = types.StringValue(cValue.String())
+ data.FilterListsCdp[i].TlvNamePlatformType = types.BoolValue(false)
}
- data.FilterSpecCdpExcludes = append(data.FilterSpecCdpExcludes, item)
- return true
- })
+ } else {
+ data.FilterListsCdp[i].TlvNamePlatformType = types.BoolNull()
+ }
}
- if value := res.Get(prefix + "notify.all-changes"); value.Exists() {
- data.NotifyAllChanges = types.BoolValue(true)
- } else {
- data.NotifyAllChanges = types.BoolValue(false)
+ for i := range data.FilterSpecDhcpIncludes {
+ keys := [...]string{"name"}
+ keyValues := [...]string{data.FilterSpecDhcpIncludes[i].Name.ValueString()}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/filter-spec/dhcp/include/list").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, "name"); value.Exists() && !data.FilterSpecDhcpIncludes[i].Name.IsNull() {
+ data.FilterSpecDhcpIncludes[i].Name = types.StringValue(value.String())
+ } else {
+ data.FilterSpecDhcpIncludes[i].Name = types.StringNull()
+ }
}
-}
+ for i := range data.FilterSpecDhcpExcludes {
+ keys := [...]string{"name"}
+ keyValues := [...]string{data.FilterSpecDhcpExcludes[i].Name.ValueString()}
-// End of section. //template:end fromBody
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/filter-spec/dhcp/exclude/list").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, "name"); value.Exists() && !data.FilterSpecDhcpExcludes[i].Name.IsNull() {
+ data.FilterSpecDhcpExcludes[i].Name = types.StringValue(value.String())
+ } else {
+ data.FilterSpecDhcpExcludes[i].Name = types.StringNull()
+ }
+ }
+ for i := range data.FilterSpecLldpIncludes {
+ keys := [...]string{"name"}
+ keyValues := [...]string{data.FilterSpecLldpIncludes[i].Name.ValueString()}
-// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyData
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/filter-spec/lldp/include/list").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, "name"); value.Exists() && !data.FilterSpecLldpIncludes[i].Name.IsNull() {
+ data.FilterSpecLldpIncludes[i].Name = types.StringValue(value.String())
+ } else {
+ data.FilterSpecLldpIncludes[i].Name = types.StringNull()
+ }
+ }
+ for i := range data.FilterSpecLldpExcludes {
+ keys := [...]string{"name"}
+ keyValues := [...]string{data.FilterSpecLldpExcludes[i].Name.ValueString()}
-func (data *DeviceSensorData) fromBody(ctx context.Context, res gjson.Result) {
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/filter-spec/lldp/exclude/list").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, "name"); value.Exists() && !data.FilterSpecLldpExcludes[i].Name.IsNull() {
+ data.FilterSpecLldpExcludes[i].Name = types.StringValue(value.String())
+ } else {
+ data.FilterSpecLldpExcludes[i].Name = types.StringNull()
+ }
+ }
+ for i := range data.FilterSpecCdpIncludes {
+ keys := [...]string{"name"}
+ keyValues := [...]string{data.FilterSpecCdpIncludes[i].Name.ValueString()}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/filter-spec/cdp/include/list").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, "name"); value.Exists() && !data.FilterSpecCdpIncludes[i].Name.IsNull() {
+ data.FilterSpecCdpIncludes[i].Name = types.StringValue(value.String())
+ } else {
+ data.FilterSpecCdpIncludes[i].Name = types.StringNull()
+ }
+ }
+ for i := range data.FilterSpecCdpExcludes {
+ keys := [...]string{"name"}
+ keyValues := [...]string{data.FilterSpecCdpExcludes[i].Name.ValueString()}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/filter-spec/cdp/exclude/list").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, "name"); value.Exists() && !data.FilterSpecCdpExcludes[i].Name.IsNull() {
+ data.FilterSpecCdpExcludes[i].Name = types.StringValue(value.String())
+ } else {
+ data.FilterSpecCdpExcludes[i].Name = types.StringNull()
+ }
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/notify/all-changes"); !data.NotifyAllChanges.IsNull() {
+ if value.Exists() {
+ data.NotifyAllChanges = types.BoolValue(true)
+ } else {
+ data.NotifyAllChanges = types.BoolValue(false)
+ }
+ } else {
+ data.NotifyAllChanges = types.BoolNull()
+ }
+}
+
+// End of section. //template:end updateFromBodyXML
+
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBody
+
+func (data *DeviceSensor) fromBody(ctx context.Context, res gjson.Result) {
prefix := helpers.LastElement(data.getPath()) + "."
if res.Get(helpers.LastElement(data.getPath())).IsArray() {
prefix += "0."
@@ -1140,20 +1604,903 @@ func (data *DeviceSensorData) fromBody(ctx context.Context, res gjson.Result) {
}
}
-// End of section. //template:end fromBodyData
+// End of section. //template:end fromBody
+
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyData
+
+func (data *DeviceSensorData) fromBody(ctx context.Context, res gjson.Result) {
+ prefix := helpers.LastElement(data.getPath()) + "."
+ if res.Get(helpers.LastElement(data.getPath())).IsArray() {
+ prefix += "0."
+ }
+ if value := res.Get(prefix + "filter-list.lldp.list"); value.Exists() {
+ data.FilterListsLldp = make([]DeviceSensorFilterListsLldp, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := DeviceSensorFilterListsLldp{}
+ if cValue := v.Get("name"); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("tlv.name.port-id"); cValue.Exists() {
+ item.TlvNamePortId = types.BoolValue(true)
+ } else {
+ item.TlvNamePortId = types.BoolValue(false)
+ }
+ if cValue := v.Get("tlv.name.port-description"); cValue.Exists() {
+ item.TlvNamePortDescription = types.BoolValue(true)
+ } else {
+ item.TlvNamePortDescription = types.BoolValue(false)
+ }
+ if cValue := v.Get("tlv.name.system-name"); cValue.Exists() {
+ item.TlvNameSystemName = types.BoolValue(true)
+ } else {
+ item.TlvNameSystemName = types.BoolValue(false)
+ }
+ if cValue := v.Get("tlv.name.system-description"); cValue.Exists() {
+ item.TlvNameSystemDescription = types.BoolValue(true)
+ } else {
+ item.TlvNameSystemDescription = types.BoolValue(false)
+ }
+ if cValue := v.Get("tlv.name.system-capabilities"); cValue.Exists() {
+ item.TlvNameSystemCapabilities = types.BoolValue(true)
+ } else {
+ item.TlvNameSystemCapabilities = types.BoolValue(false)
+ }
+ data.FilterListsLldp = append(data.FilterListsLldp, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + "filter-list.dhcp.list"); value.Exists() {
+ data.FilterListsDhcp = make([]DeviceSensorFilterListsDhcp, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := DeviceSensorFilterListsDhcp{}
+ if cValue := v.Get("name"); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("option.name.host-name"); cValue.Exists() {
+ item.OptionNameHostName = types.BoolValue(true)
+ } else {
+ item.OptionNameHostName = types.BoolValue(false)
+ }
+ if cValue := v.Get("option.name.default-ip-ttl"); cValue.Exists() {
+ item.OptionNameDefaultIpTtl = types.BoolValue(true)
+ } else {
+ item.OptionNameDefaultIpTtl = types.BoolValue(false)
+ }
+ if cValue := v.Get("option.name.requested-address"); cValue.Exists() {
+ item.OptionNameRequestedAddress = types.BoolValue(true)
+ } else {
+ item.OptionNameRequestedAddress = types.BoolValue(false)
+ }
+ if cValue := v.Get("option.name.parameter-request-list"); cValue.Exists() {
+ item.OptionNameParameterRequestList = types.BoolValue(true)
+ } else {
+ item.OptionNameParameterRequestList = types.BoolValue(false)
+ }
+ if cValue := v.Get("option.name.class-identifier"); cValue.Exists() {
+ item.OptionNameClassIdentifier = types.BoolValue(true)
+ } else {
+ item.OptionNameClassIdentifier = types.BoolValue(false)
+ }
+ if cValue := v.Get("option.name.client-identifier"); cValue.Exists() {
+ item.OptionNameClientIdentifier = types.BoolValue(true)
+ } else {
+ item.OptionNameClientIdentifier = types.BoolValue(false)
+ }
+ if cValue := v.Get("option.name.client-fqdn"); cValue.Exists() {
+ item.OptionNameClientFqdn = types.BoolValue(true)
+ } else {
+ item.OptionNameClientFqdn = types.BoolValue(false)
+ }
+ data.FilterListsDhcp = append(data.FilterListsDhcp, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + "filter-list.cdp.list"); value.Exists() {
+ data.FilterListsCdp = make([]DeviceSensorFilterListsCdp, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := DeviceSensorFilterListsCdp{}
+ if cValue := v.Get("name"); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("tlv.name.device-name"); cValue.Exists() {
+ item.TlvNameDeviceName = types.BoolValue(true)
+ } else {
+ item.TlvNameDeviceName = types.BoolValue(false)
+ }
+ if cValue := v.Get("tlv.name.address-type"); cValue.Exists() {
+ item.TlvNameAddressType = types.BoolValue(true)
+ } else {
+ item.TlvNameAddressType = types.BoolValue(false)
+ }
+ if cValue := v.Get("tlv.name.port-id-type"); cValue.Exists() {
+ item.TlvNamePortIdType = types.BoolValue(true)
+ } else {
+ item.TlvNamePortIdType = types.BoolValue(false)
+ }
+ if cValue := v.Get("tlv.name.capabilities-type"); cValue.Exists() {
+ item.TlvNameCapabilitiesType = types.BoolValue(true)
+ } else {
+ item.TlvNameCapabilitiesType = types.BoolValue(false)
+ }
+ if cValue := v.Get("tlv.name.platform-type"); cValue.Exists() {
+ item.TlvNamePlatformType = types.BoolValue(true)
+ } else {
+ item.TlvNamePlatformType = types.BoolValue(false)
+ }
+ data.FilterListsCdp = append(data.FilterListsCdp, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + "filter-spec.dhcp.include.list"); value.Exists() {
+ data.FilterSpecDhcpIncludes = make([]DeviceSensorFilterSpecDhcpIncludes, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := DeviceSensorFilterSpecDhcpIncludes{}
+ if cValue := v.Get("name"); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ data.FilterSpecDhcpIncludes = append(data.FilterSpecDhcpIncludes, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + "filter-spec.dhcp.exclude.list"); value.Exists() {
+ data.FilterSpecDhcpExcludes = make([]DeviceSensorFilterSpecDhcpExcludes, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := DeviceSensorFilterSpecDhcpExcludes{}
+ if cValue := v.Get("name"); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ data.FilterSpecDhcpExcludes = append(data.FilterSpecDhcpExcludes, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + "filter-spec.lldp.include.list"); value.Exists() {
+ data.FilterSpecLldpIncludes = make([]DeviceSensorFilterSpecLldpIncludes, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := DeviceSensorFilterSpecLldpIncludes{}
+ if cValue := v.Get("name"); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ data.FilterSpecLldpIncludes = append(data.FilterSpecLldpIncludes, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + "filter-spec.lldp.exclude.list"); value.Exists() {
+ data.FilterSpecLldpExcludes = make([]DeviceSensorFilterSpecLldpExcludes, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := DeviceSensorFilterSpecLldpExcludes{}
+ if cValue := v.Get("name"); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ data.FilterSpecLldpExcludes = append(data.FilterSpecLldpExcludes, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + "filter-spec.cdp.include.list"); value.Exists() {
+ data.FilterSpecCdpIncludes = make([]DeviceSensorFilterSpecCdpIncludes, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := DeviceSensorFilterSpecCdpIncludes{}
+ if cValue := v.Get("name"); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ data.FilterSpecCdpIncludes = append(data.FilterSpecCdpIncludes, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + "filter-spec.cdp.exclude.list"); value.Exists() {
+ data.FilterSpecCdpExcludes = make([]DeviceSensorFilterSpecCdpExcludes, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := DeviceSensorFilterSpecCdpExcludes{}
+ if cValue := v.Get("name"); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ data.FilterSpecCdpExcludes = append(data.FilterSpecCdpExcludes, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + "notify.all-changes"); value.Exists() {
+ data.NotifyAllChanges = types.BoolValue(true)
+ } else {
+ data.NotifyAllChanges = types.BoolValue(false)
+ }
+}
+
+// End of section. //template:end fromBodyData
+
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyXML
+
+func (data *DeviceSensor) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/filter-list/lldp/list"); value.Exists() {
+ data.FilterListsLldp = make([]DeviceSensorFilterListsLldp, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := DeviceSensorFilterListsLldp{}
+ if cValue := helpers.GetFromXPath(v, "name"); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "tlv/name/port-id"); cValue.Exists() {
+ item.TlvNamePortId = types.BoolValue(true)
+ } else {
+ item.TlvNamePortId = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "tlv/name/port-description"); cValue.Exists() {
+ item.TlvNamePortDescription = types.BoolValue(true)
+ } else {
+ item.TlvNamePortDescription = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "tlv/name/system-name"); cValue.Exists() {
+ item.TlvNameSystemName = types.BoolValue(true)
+ } else {
+ item.TlvNameSystemName = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "tlv/name/system-description"); cValue.Exists() {
+ item.TlvNameSystemDescription = types.BoolValue(true)
+ } else {
+ item.TlvNameSystemDescription = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "tlv/name/system-capabilities"); cValue.Exists() {
+ item.TlvNameSystemCapabilities = types.BoolValue(true)
+ } else {
+ item.TlvNameSystemCapabilities = types.BoolValue(false)
+ }
+ data.FilterListsLldp = append(data.FilterListsLldp, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/filter-list/dhcp/list"); value.Exists() {
+ data.FilterListsDhcp = make([]DeviceSensorFilterListsDhcp, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := DeviceSensorFilterListsDhcp{}
+ if cValue := helpers.GetFromXPath(v, "name"); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "option/name/host-name"); cValue.Exists() {
+ item.OptionNameHostName = types.BoolValue(true)
+ } else {
+ item.OptionNameHostName = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "option/name/default-ip-ttl"); cValue.Exists() {
+ item.OptionNameDefaultIpTtl = types.BoolValue(true)
+ } else {
+ item.OptionNameDefaultIpTtl = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "option/name/requested-address"); cValue.Exists() {
+ item.OptionNameRequestedAddress = types.BoolValue(true)
+ } else {
+ item.OptionNameRequestedAddress = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "option/name/parameter-request-list"); cValue.Exists() {
+ item.OptionNameParameterRequestList = types.BoolValue(true)
+ } else {
+ item.OptionNameParameterRequestList = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "option/name/class-identifier"); cValue.Exists() {
+ item.OptionNameClassIdentifier = types.BoolValue(true)
+ } else {
+ item.OptionNameClassIdentifier = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "option/name/client-identifier"); cValue.Exists() {
+ item.OptionNameClientIdentifier = types.BoolValue(true)
+ } else {
+ item.OptionNameClientIdentifier = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "option/name/client-fqdn"); cValue.Exists() {
+ item.OptionNameClientFqdn = types.BoolValue(true)
+ } else {
+ item.OptionNameClientFqdn = types.BoolValue(false)
+ }
+ data.FilterListsDhcp = append(data.FilterListsDhcp, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/filter-list/cdp/list"); value.Exists() {
+ data.FilterListsCdp = make([]DeviceSensorFilterListsCdp, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := DeviceSensorFilterListsCdp{}
+ if cValue := helpers.GetFromXPath(v, "name"); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "tlv/name/device-name"); cValue.Exists() {
+ item.TlvNameDeviceName = types.BoolValue(true)
+ } else {
+ item.TlvNameDeviceName = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "tlv/name/address-type"); cValue.Exists() {
+ item.TlvNameAddressType = types.BoolValue(true)
+ } else {
+ item.TlvNameAddressType = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "tlv/name/port-id-type"); cValue.Exists() {
+ item.TlvNamePortIdType = types.BoolValue(true)
+ } else {
+ item.TlvNamePortIdType = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "tlv/name/capabilities-type"); cValue.Exists() {
+ item.TlvNameCapabilitiesType = types.BoolValue(true)
+ } else {
+ item.TlvNameCapabilitiesType = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "tlv/name/platform-type"); cValue.Exists() {
+ item.TlvNamePlatformType = types.BoolValue(true)
+ } else {
+ item.TlvNamePlatformType = types.BoolValue(false)
+ }
+ data.FilterListsCdp = append(data.FilterListsCdp, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/filter-spec/dhcp/include/list"); value.Exists() {
+ data.FilterSpecDhcpIncludes = make([]DeviceSensorFilterSpecDhcpIncludes, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := DeviceSensorFilterSpecDhcpIncludes{}
+ if cValue := helpers.GetFromXPath(v, "name"); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ data.FilterSpecDhcpIncludes = append(data.FilterSpecDhcpIncludes, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/filter-spec/dhcp/exclude/list"); value.Exists() {
+ data.FilterSpecDhcpExcludes = make([]DeviceSensorFilterSpecDhcpExcludes, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := DeviceSensorFilterSpecDhcpExcludes{}
+ if cValue := helpers.GetFromXPath(v, "name"); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ data.FilterSpecDhcpExcludes = append(data.FilterSpecDhcpExcludes, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/filter-spec/lldp/include/list"); value.Exists() {
+ data.FilterSpecLldpIncludes = make([]DeviceSensorFilterSpecLldpIncludes, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := DeviceSensorFilterSpecLldpIncludes{}
+ if cValue := helpers.GetFromXPath(v, "name"); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ data.FilterSpecLldpIncludes = append(data.FilterSpecLldpIncludes, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/filter-spec/lldp/exclude/list"); value.Exists() {
+ data.FilterSpecLldpExcludes = make([]DeviceSensorFilterSpecLldpExcludes, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := DeviceSensorFilterSpecLldpExcludes{}
+ if cValue := helpers.GetFromXPath(v, "name"); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ data.FilterSpecLldpExcludes = append(data.FilterSpecLldpExcludes, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/filter-spec/cdp/include/list"); value.Exists() {
+ data.FilterSpecCdpIncludes = make([]DeviceSensorFilterSpecCdpIncludes, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := DeviceSensorFilterSpecCdpIncludes{}
+ if cValue := helpers.GetFromXPath(v, "name"); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ data.FilterSpecCdpIncludes = append(data.FilterSpecCdpIncludes, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/filter-spec/cdp/exclude/list"); value.Exists() {
+ data.FilterSpecCdpExcludes = make([]DeviceSensorFilterSpecCdpExcludes, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := DeviceSensorFilterSpecCdpExcludes{}
+ if cValue := helpers.GetFromXPath(v, "name"); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ data.FilterSpecCdpExcludes = append(data.FilterSpecCdpExcludes, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/notify/all-changes"); value.Exists() {
+ data.NotifyAllChanges = types.BoolValue(true)
+ } else {
+ data.NotifyAllChanges = types.BoolValue(false)
+ }
+}
+
+// End of section. //template:end fromBodyXML
+
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyDataXML
+
+func (data *DeviceSensorData) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/filter-list/lldp/list"); value.Exists() {
+ data.FilterListsLldp = make([]DeviceSensorFilterListsLldp, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := DeviceSensorFilterListsLldp{}
+ if cValue := helpers.GetFromXPath(v, "name"); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "tlv/name/port-id"); cValue.Exists() {
+ item.TlvNamePortId = types.BoolValue(true)
+ } else {
+ item.TlvNamePortId = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "tlv/name/port-description"); cValue.Exists() {
+ item.TlvNamePortDescription = types.BoolValue(true)
+ } else {
+ item.TlvNamePortDescription = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "tlv/name/system-name"); cValue.Exists() {
+ item.TlvNameSystemName = types.BoolValue(true)
+ } else {
+ item.TlvNameSystemName = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "tlv/name/system-description"); cValue.Exists() {
+ item.TlvNameSystemDescription = types.BoolValue(true)
+ } else {
+ item.TlvNameSystemDescription = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "tlv/name/system-capabilities"); cValue.Exists() {
+ item.TlvNameSystemCapabilities = types.BoolValue(true)
+ } else {
+ item.TlvNameSystemCapabilities = types.BoolValue(false)
+ }
+ data.FilterListsLldp = append(data.FilterListsLldp, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/filter-list/dhcp/list"); value.Exists() {
+ data.FilterListsDhcp = make([]DeviceSensorFilterListsDhcp, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := DeviceSensorFilterListsDhcp{}
+ if cValue := helpers.GetFromXPath(v, "name"); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "option/name/host-name"); cValue.Exists() {
+ item.OptionNameHostName = types.BoolValue(true)
+ } else {
+ item.OptionNameHostName = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "option/name/default-ip-ttl"); cValue.Exists() {
+ item.OptionNameDefaultIpTtl = types.BoolValue(true)
+ } else {
+ item.OptionNameDefaultIpTtl = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "option/name/requested-address"); cValue.Exists() {
+ item.OptionNameRequestedAddress = types.BoolValue(true)
+ } else {
+ item.OptionNameRequestedAddress = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "option/name/parameter-request-list"); cValue.Exists() {
+ item.OptionNameParameterRequestList = types.BoolValue(true)
+ } else {
+ item.OptionNameParameterRequestList = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "option/name/class-identifier"); cValue.Exists() {
+ item.OptionNameClassIdentifier = types.BoolValue(true)
+ } else {
+ item.OptionNameClassIdentifier = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "option/name/client-identifier"); cValue.Exists() {
+ item.OptionNameClientIdentifier = types.BoolValue(true)
+ } else {
+ item.OptionNameClientIdentifier = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "option/name/client-fqdn"); cValue.Exists() {
+ item.OptionNameClientFqdn = types.BoolValue(true)
+ } else {
+ item.OptionNameClientFqdn = types.BoolValue(false)
+ }
+ data.FilterListsDhcp = append(data.FilterListsDhcp, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/filter-list/cdp/list"); value.Exists() {
+ data.FilterListsCdp = make([]DeviceSensorFilterListsCdp, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := DeviceSensorFilterListsCdp{}
+ if cValue := helpers.GetFromXPath(v, "name"); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "tlv/name/device-name"); cValue.Exists() {
+ item.TlvNameDeviceName = types.BoolValue(true)
+ } else {
+ item.TlvNameDeviceName = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "tlv/name/address-type"); cValue.Exists() {
+ item.TlvNameAddressType = types.BoolValue(true)
+ } else {
+ item.TlvNameAddressType = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "tlv/name/port-id-type"); cValue.Exists() {
+ item.TlvNamePortIdType = types.BoolValue(true)
+ } else {
+ item.TlvNamePortIdType = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "tlv/name/capabilities-type"); cValue.Exists() {
+ item.TlvNameCapabilitiesType = types.BoolValue(true)
+ } else {
+ item.TlvNameCapabilitiesType = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "tlv/name/platform-type"); cValue.Exists() {
+ item.TlvNamePlatformType = types.BoolValue(true)
+ } else {
+ item.TlvNamePlatformType = types.BoolValue(false)
+ }
+ data.FilterListsCdp = append(data.FilterListsCdp, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/filter-spec/dhcp/include/list"); value.Exists() {
+ data.FilterSpecDhcpIncludes = make([]DeviceSensorFilterSpecDhcpIncludes, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := DeviceSensorFilterSpecDhcpIncludes{}
+ if cValue := helpers.GetFromXPath(v, "name"); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ data.FilterSpecDhcpIncludes = append(data.FilterSpecDhcpIncludes, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/filter-spec/dhcp/exclude/list"); value.Exists() {
+ data.FilterSpecDhcpExcludes = make([]DeviceSensorFilterSpecDhcpExcludes, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := DeviceSensorFilterSpecDhcpExcludes{}
+ if cValue := helpers.GetFromXPath(v, "name"); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ data.FilterSpecDhcpExcludes = append(data.FilterSpecDhcpExcludes, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/filter-spec/lldp/include/list"); value.Exists() {
+ data.FilterSpecLldpIncludes = make([]DeviceSensorFilterSpecLldpIncludes, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := DeviceSensorFilterSpecLldpIncludes{}
+ if cValue := helpers.GetFromXPath(v, "name"); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ data.FilterSpecLldpIncludes = append(data.FilterSpecLldpIncludes, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/filter-spec/lldp/exclude/list"); value.Exists() {
+ data.FilterSpecLldpExcludes = make([]DeviceSensorFilterSpecLldpExcludes, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := DeviceSensorFilterSpecLldpExcludes{}
+ if cValue := helpers.GetFromXPath(v, "name"); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ data.FilterSpecLldpExcludes = append(data.FilterSpecLldpExcludes, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/filter-spec/cdp/include/list"); value.Exists() {
+ data.FilterSpecCdpIncludes = make([]DeviceSensorFilterSpecCdpIncludes, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := DeviceSensorFilterSpecCdpIncludes{}
+ if cValue := helpers.GetFromXPath(v, "name"); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ data.FilterSpecCdpIncludes = append(data.FilterSpecCdpIncludes, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/filter-spec/cdp/exclude/list"); value.Exists() {
+ data.FilterSpecCdpExcludes = make([]DeviceSensorFilterSpecCdpExcludes, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := DeviceSensorFilterSpecCdpExcludes{}
+ if cValue := helpers.GetFromXPath(v, "name"); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ data.FilterSpecCdpExcludes = append(data.FilterSpecCdpExcludes, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/notify/all-changes"); value.Exists() {
+ data.NotifyAllChanges = types.BoolValue(true)
+ } else {
+ data.NotifyAllChanges = types.BoolValue(false)
+ }
+}
+
+// End of section. //template:end fromBodyDataXML
+
+// Section below is generated&owned by "gen/generator.go". //template:begin getDeletedItems
+
+func (data *DeviceSensor) getDeletedItems(ctx context.Context, state DeviceSensor) []string {
+ deletedItems := make([]string, 0)
+ if !state.NotifyAllChanges.IsNull() && data.NotifyAllChanges.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/notify/all-changes", state.getPath()))
+ }
+ for i := range state.FilterSpecCdpExcludes {
+ stateKeyValues := [...]string{state.FilterSpecCdpExcludes[i].Name.ValueString()}
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.FilterSpecCdpExcludes[i].Name.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.FilterSpecCdpExcludes {
+ found = true
+ if state.FilterSpecCdpExcludes[i].Name.ValueString() != data.FilterSpecCdpExcludes[j].Name.ValueString() {
+ found = false
+ }
+ if found {
+ break
+ }
+ }
+ if !found {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/filter-spec/cdp/exclude/list=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ }
+ for i := range state.FilterSpecCdpIncludes {
+ stateKeyValues := [...]string{state.FilterSpecCdpIncludes[i].Name.ValueString()}
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.FilterSpecCdpIncludes[i].Name.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.FilterSpecCdpIncludes {
+ found = true
+ if state.FilterSpecCdpIncludes[i].Name.ValueString() != data.FilterSpecCdpIncludes[j].Name.ValueString() {
+ found = false
+ }
+ if found {
+ break
+ }
+ }
+ if !found {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/filter-spec/cdp/include/list=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ }
+ for i := range state.FilterSpecLldpExcludes {
+ stateKeyValues := [...]string{state.FilterSpecLldpExcludes[i].Name.ValueString()}
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.FilterSpecLldpExcludes[i].Name.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.FilterSpecLldpExcludes {
+ found = true
+ if state.FilterSpecLldpExcludes[i].Name.ValueString() != data.FilterSpecLldpExcludes[j].Name.ValueString() {
+ found = false
+ }
+ if found {
+ break
+ }
+ }
+ if !found {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/filter-spec/lldp/exclude/list=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ }
+ for i := range state.FilterSpecLldpIncludes {
+ stateKeyValues := [...]string{state.FilterSpecLldpIncludes[i].Name.ValueString()}
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.FilterSpecLldpIncludes[i].Name.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.FilterSpecLldpIncludes {
+ found = true
+ if state.FilterSpecLldpIncludes[i].Name.ValueString() != data.FilterSpecLldpIncludes[j].Name.ValueString() {
+ found = false
+ }
+ if found {
+ break
+ }
+ }
+ if !found {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/filter-spec/lldp/include/list=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ }
+ for i := range state.FilterSpecDhcpExcludes {
+ stateKeyValues := [...]string{state.FilterSpecDhcpExcludes[i].Name.ValueString()}
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.FilterSpecDhcpExcludes[i].Name.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.FilterSpecDhcpExcludes {
+ found = true
+ if state.FilterSpecDhcpExcludes[i].Name.ValueString() != data.FilterSpecDhcpExcludes[j].Name.ValueString() {
+ found = false
+ }
+ if found {
+ break
+ }
+ }
+ if !found {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/filter-spec/dhcp/exclude/list=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ }
+ for i := range state.FilterSpecDhcpIncludes {
+ stateKeyValues := [...]string{state.FilterSpecDhcpIncludes[i].Name.ValueString()}
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.FilterSpecDhcpIncludes[i].Name.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.FilterSpecDhcpIncludes {
+ found = true
+ if state.FilterSpecDhcpIncludes[i].Name.ValueString() != data.FilterSpecDhcpIncludes[j].Name.ValueString() {
+ found = false
+ }
+ if found {
+ break
+ }
+ }
+ if !found {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/filter-spec/dhcp/include/list=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ }
+ for i := range state.FilterListsCdp {
+ stateKeyValues := [...]string{state.FilterListsCdp[i].Name.ValueString()}
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.FilterListsCdp[i].Name.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.FilterListsCdp {
+ found = true
+ if state.FilterListsCdp[i].Name.ValueString() != data.FilterListsCdp[j].Name.ValueString() {
+ found = false
+ }
+ if found {
+ if !state.FilterListsCdp[i].TlvNamePlatformType.IsNull() && data.FilterListsCdp[j].TlvNamePlatformType.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/filter-list/cdp/list=%v/tlv/name/platform-type", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ if !state.FilterListsCdp[i].TlvNameCapabilitiesType.IsNull() && data.FilterListsCdp[j].TlvNameCapabilitiesType.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/filter-list/cdp/list=%v/tlv/name/capabilities-type", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ if !state.FilterListsCdp[i].TlvNamePortIdType.IsNull() && data.FilterListsCdp[j].TlvNamePortIdType.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/filter-list/cdp/list=%v/tlv/name/port-id-type", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ if !state.FilterListsCdp[i].TlvNameAddressType.IsNull() && data.FilterListsCdp[j].TlvNameAddressType.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/filter-list/cdp/list=%v/tlv/name/address-type", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ if !state.FilterListsCdp[i].TlvNameDeviceName.IsNull() && data.FilterListsCdp[j].TlvNameDeviceName.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/filter-list/cdp/list=%v/tlv/name/device-name", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ break
+ }
+ }
+ if !found {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/filter-list/cdp/list=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ }
+ for i := range state.FilterListsDhcp {
+ stateKeyValues := [...]string{state.FilterListsDhcp[i].Name.ValueString()}
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.FilterListsDhcp[i].Name.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.FilterListsDhcp {
+ found = true
+ if state.FilterListsDhcp[i].Name.ValueString() != data.FilterListsDhcp[j].Name.ValueString() {
+ found = false
+ }
+ if found {
+ if !state.FilterListsDhcp[i].OptionNameClientFqdn.IsNull() && data.FilterListsDhcp[j].OptionNameClientFqdn.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/filter-list/dhcp/list=%v/option/name/client-fqdn", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ if !state.FilterListsDhcp[i].OptionNameClientIdentifier.IsNull() && data.FilterListsDhcp[j].OptionNameClientIdentifier.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/filter-list/dhcp/list=%v/option/name/client-identifier", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ if !state.FilterListsDhcp[i].OptionNameClassIdentifier.IsNull() && data.FilterListsDhcp[j].OptionNameClassIdentifier.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/filter-list/dhcp/list=%v/option/name/class-identifier", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ if !state.FilterListsDhcp[i].OptionNameParameterRequestList.IsNull() && data.FilterListsDhcp[j].OptionNameParameterRequestList.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/filter-list/dhcp/list=%v/option/name/parameter-request-list", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ if !state.FilterListsDhcp[i].OptionNameRequestedAddress.IsNull() && data.FilterListsDhcp[j].OptionNameRequestedAddress.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/filter-list/dhcp/list=%v/option/name/requested-address", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ if !state.FilterListsDhcp[i].OptionNameDefaultIpTtl.IsNull() && data.FilterListsDhcp[j].OptionNameDefaultIpTtl.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/filter-list/dhcp/list=%v/option/name/default-ip-ttl", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ if !state.FilterListsDhcp[i].OptionNameHostName.IsNull() && data.FilterListsDhcp[j].OptionNameHostName.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/filter-list/dhcp/list=%v/option/name/host-name", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ break
+ }
+ }
+ if !found {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/filter-list/dhcp/list=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ }
+ for i := range state.FilterListsLldp {
+ stateKeyValues := [...]string{state.FilterListsLldp[i].Name.ValueString()}
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.FilterListsLldp[i].Name.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.FilterListsLldp {
+ found = true
+ if state.FilterListsLldp[i].Name.ValueString() != data.FilterListsLldp[j].Name.ValueString() {
+ found = false
+ }
+ if found {
+ if !state.FilterListsLldp[i].TlvNameSystemCapabilities.IsNull() && data.FilterListsLldp[j].TlvNameSystemCapabilities.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/filter-list/lldp/list=%v/tlv/name/system-capabilities", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ if !state.FilterListsLldp[i].TlvNameSystemDescription.IsNull() && data.FilterListsLldp[j].TlvNameSystemDescription.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/filter-list/lldp/list=%v/tlv/name/system-description", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ if !state.FilterListsLldp[i].TlvNameSystemName.IsNull() && data.FilterListsLldp[j].TlvNameSystemName.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/filter-list/lldp/list=%v/tlv/name/system-name", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ if !state.FilterListsLldp[i].TlvNamePortDescription.IsNull() && data.FilterListsLldp[j].TlvNamePortDescription.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/filter-list/lldp/list=%v/tlv/name/port-description", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ if !state.FilterListsLldp[i].TlvNamePortId.IsNull() && data.FilterListsLldp[j].TlvNamePortId.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/filter-list/lldp/list=%v/tlv/name/port-id", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ break
+ }
+ }
+ if !found {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/filter-list/lldp/list=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ }
+
+ return deletedItems
+}
+
+// End of section. //template:end getDeletedItems
-// Section below is generated&owned by "gen/generator.go". //template:begin getDeletedItems
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletedItemsXML
-func (data *DeviceSensor) getDeletedItems(ctx context.Context, state DeviceSensor) []string {
- deletedItems := make([]string, 0)
- if !state.NotifyAllChanges.IsNull() && data.NotifyAllChanges.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/notify/all-changes", state.getPath()))
- }
- for i := range state.FilterSpecCdpExcludes {
- stateKeyValues := [...]string{state.FilterSpecCdpExcludes[i].Name.ValueString()}
+func (data *DeviceSensor) addDeletedItemsXML(ctx context.Context, state DeviceSensor, body string) string {
+ b := netconf.NewBody(body)
+ for i := range state.FilterListsLldp {
+ stateKeys := [...]string{"name"}
+ stateKeyValues := [...]string{state.FilterListsLldp[i].Name.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
emptyKeys := true
- if !reflect.ValueOf(state.FilterSpecCdpExcludes[i].Name.ValueString()).IsZero() {
+ if !reflect.ValueOf(state.FilterListsLldp[i].Name.ValueString()).IsZero() {
emptyKeys = false
}
if emptyKeys {
@@ -1161,24 +2508,44 @@ func (data *DeviceSensor) getDeletedItems(ctx context.Context, state DeviceSenso
}
found := false
- for j := range data.FilterSpecCdpExcludes {
+ for j := range data.FilterListsLldp {
found = true
- if state.FilterSpecCdpExcludes[i].Name.ValueString() != data.FilterSpecCdpExcludes[j].Name.ValueString() {
+ if state.FilterListsLldp[i].Name.ValueString() != data.FilterListsLldp[j].Name.ValueString() {
found = false
}
if found {
+ if !state.FilterListsLldp[i].TlvNamePortId.IsNull() && data.FilterListsLldp[j].TlvNamePortId.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/filter-list/lldp/list%v/tlv/name/port-id", predicates))
+ }
+ if !state.FilterListsLldp[i].TlvNamePortDescription.IsNull() && data.FilterListsLldp[j].TlvNamePortDescription.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/filter-list/lldp/list%v/tlv/name/port-description", predicates))
+ }
+ if !state.FilterListsLldp[i].TlvNameSystemName.IsNull() && data.FilterListsLldp[j].TlvNameSystemName.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/filter-list/lldp/list%v/tlv/name/system-name", predicates))
+ }
+ if !state.FilterListsLldp[i].TlvNameSystemDescription.IsNull() && data.FilterListsLldp[j].TlvNameSystemDescription.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/filter-list/lldp/list%v/tlv/name/system-description", predicates))
+ }
+ if !state.FilterListsLldp[i].TlvNameSystemCapabilities.IsNull() && data.FilterListsLldp[j].TlvNameSystemCapabilities.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/filter-list/lldp/list%v/tlv/name/system-capabilities", predicates))
+ }
break
}
}
if !found {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/filter-spec/cdp/exclude/list=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/filter-list/lldp/list%v", predicates))
}
}
- for i := range state.FilterSpecCdpIncludes {
- stateKeyValues := [...]string{state.FilterSpecCdpIncludes[i].Name.ValueString()}
+ for i := range state.FilterListsDhcp {
+ stateKeys := [...]string{"name"}
+ stateKeyValues := [...]string{state.FilterListsDhcp[i].Name.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
emptyKeys := true
- if !reflect.ValueOf(state.FilterSpecCdpIncludes[i].Name.ValueString()).IsZero() {
+ if !reflect.ValueOf(state.FilterListsDhcp[i].Name.ValueString()).IsZero() {
emptyKeys = false
}
if emptyKeys {
@@ -1186,24 +2553,50 @@ func (data *DeviceSensor) getDeletedItems(ctx context.Context, state DeviceSenso
}
found := false
- for j := range data.FilterSpecCdpIncludes {
+ for j := range data.FilterListsDhcp {
found = true
- if state.FilterSpecCdpIncludes[i].Name.ValueString() != data.FilterSpecCdpIncludes[j].Name.ValueString() {
+ if state.FilterListsDhcp[i].Name.ValueString() != data.FilterListsDhcp[j].Name.ValueString() {
found = false
}
if found {
+ if !state.FilterListsDhcp[i].OptionNameHostName.IsNull() && data.FilterListsDhcp[j].OptionNameHostName.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/filter-list/dhcp/list%v/option/name/host-name", predicates))
+ }
+ if !state.FilterListsDhcp[i].OptionNameDefaultIpTtl.IsNull() && data.FilterListsDhcp[j].OptionNameDefaultIpTtl.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/filter-list/dhcp/list%v/option/name/default-ip-ttl", predicates))
+ }
+ if !state.FilterListsDhcp[i].OptionNameRequestedAddress.IsNull() && data.FilterListsDhcp[j].OptionNameRequestedAddress.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/filter-list/dhcp/list%v/option/name/requested-address", predicates))
+ }
+ if !state.FilterListsDhcp[i].OptionNameParameterRequestList.IsNull() && data.FilterListsDhcp[j].OptionNameParameterRequestList.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/filter-list/dhcp/list%v/option/name/parameter-request-list", predicates))
+ }
+ if !state.FilterListsDhcp[i].OptionNameClassIdentifier.IsNull() && data.FilterListsDhcp[j].OptionNameClassIdentifier.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/filter-list/dhcp/list%v/option/name/class-identifier", predicates))
+ }
+ if !state.FilterListsDhcp[i].OptionNameClientIdentifier.IsNull() && data.FilterListsDhcp[j].OptionNameClientIdentifier.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/filter-list/dhcp/list%v/option/name/client-identifier", predicates))
+ }
+ if !state.FilterListsDhcp[i].OptionNameClientFqdn.IsNull() && data.FilterListsDhcp[j].OptionNameClientFqdn.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/filter-list/dhcp/list%v/option/name/client-fqdn", predicates))
+ }
break
}
}
if !found {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/filter-spec/cdp/include/list=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/filter-list/dhcp/list%v", predicates))
}
}
- for i := range state.FilterSpecLldpExcludes {
- stateKeyValues := [...]string{state.FilterSpecLldpExcludes[i].Name.ValueString()}
+ for i := range state.FilterListsCdp {
+ stateKeys := [...]string{"name"}
+ stateKeyValues := [...]string{state.FilterListsCdp[i].Name.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
emptyKeys := true
- if !reflect.ValueOf(state.FilterSpecLldpExcludes[i].Name.ValueString()).IsZero() {
+ if !reflect.ValueOf(state.FilterListsCdp[i].Name.ValueString()).IsZero() {
emptyKeys = false
}
if emptyKeys {
@@ -1211,24 +2604,44 @@ func (data *DeviceSensor) getDeletedItems(ctx context.Context, state DeviceSenso
}
found := false
- for j := range data.FilterSpecLldpExcludes {
+ for j := range data.FilterListsCdp {
found = true
- if state.FilterSpecLldpExcludes[i].Name.ValueString() != data.FilterSpecLldpExcludes[j].Name.ValueString() {
+ if state.FilterListsCdp[i].Name.ValueString() != data.FilterListsCdp[j].Name.ValueString() {
found = false
}
if found {
+ if !state.FilterListsCdp[i].TlvNameDeviceName.IsNull() && data.FilterListsCdp[j].TlvNameDeviceName.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/filter-list/cdp/list%v/tlv/name/device-name", predicates))
+ }
+ if !state.FilterListsCdp[i].TlvNameAddressType.IsNull() && data.FilterListsCdp[j].TlvNameAddressType.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/filter-list/cdp/list%v/tlv/name/address-type", predicates))
+ }
+ if !state.FilterListsCdp[i].TlvNamePortIdType.IsNull() && data.FilterListsCdp[j].TlvNamePortIdType.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/filter-list/cdp/list%v/tlv/name/port-id-type", predicates))
+ }
+ if !state.FilterListsCdp[i].TlvNameCapabilitiesType.IsNull() && data.FilterListsCdp[j].TlvNameCapabilitiesType.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/filter-list/cdp/list%v/tlv/name/capabilities-type", predicates))
+ }
+ if !state.FilterListsCdp[i].TlvNamePlatformType.IsNull() && data.FilterListsCdp[j].TlvNamePlatformType.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/filter-list/cdp/list%v/tlv/name/platform-type", predicates))
+ }
break
}
}
if !found {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/filter-spec/lldp/exclude/list=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/filter-list/cdp/list%v", predicates))
}
}
- for i := range state.FilterSpecLldpIncludes {
- stateKeyValues := [...]string{state.FilterSpecLldpIncludes[i].Name.ValueString()}
+ for i := range state.FilterSpecDhcpIncludes {
+ stateKeys := [...]string{"name"}
+ stateKeyValues := [...]string{state.FilterSpecDhcpIncludes[i].Name.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
emptyKeys := true
- if !reflect.ValueOf(state.FilterSpecLldpIncludes[i].Name.ValueString()).IsZero() {
+ if !reflect.ValueOf(state.FilterSpecDhcpIncludes[i].Name.ValueString()).IsZero() {
emptyKeys = false
}
if emptyKeys {
@@ -1236,9 +2649,9 @@ func (data *DeviceSensor) getDeletedItems(ctx context.Context, state DeviceSenso
}
found := false
- for j := range data.FilterSpecLldpIncludes {
+ for j := range data.FilterSpecDhcpIncludes {
found = true
- if state.FilterSpecLldpIncludes[i].Name.ValueString() != data.FilterSpecLldpIncludes[j].Name.ValueString() {
+ if state.FilterSpecDhcpIncludes[i].Name.ValueString() != data.FilterSpecDhcpIncludes[j].Name.ValueString() {
found = false
}
if found {
@@ -1246,11 +2659,16 @@ func (data *DeviceSensor) getDeletedItems(ctx context.Context, state DeviceSenso
}
}
if !found {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/filter-spec/lldp/include/list=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/filter-spec/dhcp/include/list%v", predicates))
}
}
for i := range state.FilterSpecDhcpExcludes {
+ stateKeys := [...]string{"name"}
stateKeyValues := [...]string{state.FilterSpecDhcpExcludes[i].Name.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
emptyKeys := true
if !reflect.ValueOf(state.FilterSpecDhcpExcludes[i].Name.ValueString()).IsZero() {
@@ -1271,14 +2689,19 @@ func (data *DeviceSensor) getDeletedItems(ctx context.Context, state DeviceSenso
}
}
if !found {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/filter-spec/dhcp/exclude/list=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/filter-spec/dhcp/exclude/list%v", predicates))
}
}
- for i := range state.FilterSpecDhcpIncludes {
- stateKeyValues := [...]string{state.FilterSpecDhcpIncludes[i].Name.ValueString()}
+ for i := range state.FilterSpecLldpIncludes {
+ stateKeys := [...]string{"name"}
+ stateKeyValues := [...]string{state.FilterSpecLldpIncludes[i].Name.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
emptyKeys := true
- if !reflect.ValueOf(state.FilterSpecDhcpIncludes[i].Name.ValueString()).IsZero() {
+ if !reflect.ValueOf(state.FilterSpecLldpIncludes[i].Name.ValueString()).IsZero() {
emptyKeys = false
}
if emptyKeys {
@@ -1286,9 +2709,9 @@ func (data *DeviceSensor) getDeletedItems(ctx context.Context, state DeviceSenso
}
found := false
- for j := range data.FilterSpecDhcpIncludes {
+ for j := range data.FilterSpecLldpIncludes {
found = true
- if state.FilterSpecDhcpIncludes[i].Name.ValueString() != data.FilterSpecDhcpIncludes[j].Name.ValueString() {
+ if state.FilterSpecLldpIncludes[i].Name.ValueString() != data.FilterSpecLldpIncludes[j].Name.ValueString() {
found = false
}
if found {
@@ -1296,14 +2719,19 @@ func (data *DeviceSensor) getDeletedItems(ctx context.Context, state DeviceSenso
}
}
if !found {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/filter-spec/dhcp/include/list=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/filter-spec/lldp/include/list%v", predicates))
}
}
- for i := range state.FilterListsCdp {
- stateKeyValues := [...]string{state.FilterListsCdp[i].Name.ValueString()}
+ for i := range state.FilterSpecLldpExcludes {
+ stateKeys := [...]string{"name"}
+ stateKeyValues := [...]string{state.FilterSpecLldpExcludes[i].Name.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
emptyKeys := true
- if !reflect.ValueOf(state.FilterListsCdp[i].Name.ValueString()).IsZero() {
+ if !reflect.ValueOf(state.FilterSpecLldpExcludes[i].Name.ValueString()).IsZero() {
emptyKeys = false
}
if emptyKeys {
@@ -1311,39 +2739,29 @@ func (data *DeviceSensor) getDeletedItems(ctx context.Context, state DeviceSenso
}
found := false
- for j := range data.FilterListsCdp {
+ for j := range data.FilterSpecLldpExcludes {
found = true
- if state.FilterListsCdp[i].Name.ValueString() != data.FilterListsCdp[j].Name.ValueString() {
+ if state.FilterSpecLldpExcludes[i].Name.ValueString() != data.FilterSpecLldpExcludes[j].Name.ValueString() {
found = false
}
if found {
- if !state.FilterListsCdp[i].TlvNamePlatformType.IsNull() && data.FilterListsCdp[j].TlvNamePlatformType.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/filter-list/cdp/list=%v/tlv/name/platform-type", state.getPath(), strings.Join(stateKeyValues[:], ",")))
- }
- if !state.FilterListsCdp[i].TlvNameCapabilitiesType.IsNull() && data.FilterListsCdp[j].TlvNameCapabilitiesType.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/filter-list/cdp/list=%v/tlv/name/capabilities-type", state.getPath(), strings.Join(stateKeyValues[:], ",")))
- }
- if !state.FilterListsCdp[i].TlvNamePortIdType.IsNull() && data.FilterListsCdp[j].TlvNamePortIdType.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/filter-list/cdp/list=%v/tlv/name/port-id-type", state.getPath(), strings.Join(stateKeyValues[:], ",")))
- }
- if !state.FilterListsCdp[i].TlvNameAddressType.IsNull() && data.FilterListsCdp[j].TlvNameAddressType.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/filter-list/cdp/list=%v/tlv/name/address-type", state.getPath(), strings.Join(stateKeyValues[:], ",")))
- }
- if !state.FilterListsCdp[i].TlvNameDeviceName.IsNull() && data.FilterListsCdp[j].TlvNameDeviceName.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/filter-list/cdp/list=%v/tlv/name/device-name", state.getPath(), strings.Join(stateKeyValues[:], ",")))
- }
break
}
}
if !found {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/filter-list/cdp/list=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/filter-spec/lldp/exclude/list%v", predicates))
}
}
- for i := range state.FilterListsDhcp {
- stateKeyValues := [...]string{state.FilterListsDhcp[i].Name.ValueString()}
+ for i := range state.FilterSpecCdpIncludes {
+ stateKeys := [...]string{"name"}
+ stateKeyValues := [...]string{state.FilterSpecCdpIncludes[i].Name.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
emptyKeys := true
- if !reflect.ValueOf(state.FilterListsDhcp[i].Name.ValueString()).IsZero() {
+ if !reflect.ValueOf(state.FilterSpecCdpIncludes[i].Name.ValueString()).IsZero() {
emptyKeys = false
}
if emptyKeys {
@@ -1351,45 +2769,29 @@ func (data *DeviceSensor) getDeletedItems(ctx context.Context, state DeviceSenso
}
found := false
- for j := range data.FilterListsDhcp {
+ for j := range data.FilterSpecCdpIncludes {
found = true
- if state.FilterListsDhcp[i].Name.ValueString() != data.FilterListsDhcp[j].Name.ValueString() {
+ if state.FilterSpecCdpIncludes[i].Name.ValueString() != data.FilterSpecCdpIncludes[j].Name.ValueString() {
found = false
}
if found {
- if !state.FilterListsDhcp[i].OptionNameClientFqdn.IsNull() && data.FilterListsDhcp[j].OptionNameClientFqdn.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/filter-list/dhcp/list=%v/option/name/client-fqdn", state.getPath(), strings.Join(stateKeyValues[:], ",")))
- }
- if !state.FilterListsDhcp[i].OptionNameClientIdentifier.IsNull() && data.FilterListsDhcp[j].OptionNameClientIdentifier.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/filter-list/dhcp/list=%v/option/name/client-identifier", state.getPath(), strings.Join(stateKeyValues[:], ",")))
- }
- if !state.FilterListsDhcp[i].OptionNameClassIdentifier.IsNull() && data.FilterListsDhcp[j].OptionNameClassIdentifier.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/filter-list/dhcp/list=%v/option/name/class-identifier", state.getPath(), strings.Join(stateKeyValues[:], ",")))
- }
- if !state.FilterListsDhcp[i].OptionNameParameterRequestList.IsNull() && data.FilterListsDhcp[j].OptionNameParameterRequestList.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/filter-list/dhcp/list=%v/option/name/parameter-request-list", state.getPath(), strings.Join(stateKeyValues[:], ",")))
- }
- if !state.FilterListsDhcp[i].OptionNameRequestedAddress.IsNull() && data.FilterListsDhcp[j].OptionNameRequestedAddress.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/filter-list/dhcp/list=%v/option/name/requested-address", state.getPath(), strings.Join(stateKeyValues[:], ",")))
- }
- if !state.FilterListsDhcp[i].OptionNameDefaultIpTtl.IsNull() && data.FilterListsDhcp[j].OptionNameDefaultIpTtl.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/filter-list/dhcp/list=%v/option/name/default-ip-ttl", state.getPath(), strings.Join(stateKeyValues[:], ",")))
- }
- if !state.FilterListsDhcp[i].OptionNameHostName.IsNull() && data.FilterListsDhcp[j].OptionNameHostName.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/filter-list/dhcp/list=%v/option/name/host-name", state.getPath(), strings.Join(stateKeyValues[:], ",")))
- }
break
}
}
if !found {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/filter-list/dhcp/list=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/filter-spec/cdp/include/list%v", predicates))
}
}
- for i := range state.FilterListsLldp {
- stateKeyValues := [...]string{state.FilterListsLldp[i].Name.ValueString()}
+ for i := range state.FilterSpecCdpExcludes {
+ stateKeys := [...]string{"name"}
+ stateKeyValues := [...]string{state.FilterSpecCdpExcludes[i].Name.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
emptyKeys := true
- if !reflect.ValueOf(state.FilterListsLldp[i].Name.ValueString()).IsZero() {
+ if !reflect.ValueOf(state.FilterSpecCdpExcludes[i].Name.ValueString()).IsZero() {
emptyKeys = false
}
if emptyKeys {
@@ -1397,39 +2799,27 @@ func (data *DeviceSensor) getDeletedItems(ctx context.Context, state DeviceSenso
}
found := false
- for j := range data.FilterListsLldp {
+ for j := range data.FilterSpecCdpExcludes {
found = true
- if state.FilterListsLldp[i].Name.ValueString() != data.FilterListsLldp[j].Name.ValueString() {
+ if state.FilterSpecCdpExcludes[i].Name.ValueString() != data.FilterSpecCdpExcludes[j].Name.ValueString() {
found = false
}
if found {
- if !state.FilterListsLldp[i].TlvNameSystemCapabilities.IsNull() && data.FilterListsLldp[j].TlvNameSystemCapabilities.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/filter-list/lldp/list=%v/tlv/name/system-capabilities", state.getPath(), strings.Join(stateKeyValues[:], ",")))
- }
- if !state.FilterListsLldp[i].TlvNameSystemDescription.IsNull() && data.FilterListsLldp[j].TlvNameSystemDescription.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/filter-list/lldp/list=%v/tlv/name/system-description", state.getPath(), strings.Join(stateKeyValues[:], ",")))
- }
- if !state.FilterListsLldp[i].TlvNameSystemName.IsNull() && data.FilterListsLldp[j].TlvNameSystemName.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/filter-list/lldp/list=%v/tlv/name/system-name", state.getPath(), strings.Join(stateKeyValues[:], ",")))
- }
- if !state.FilterListsLldp[i].TlvNamePortDescription.IsNull() && data.FilterListsLldp[j].TlvNamePortDescription.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/filter-list/lldp/list=%v/tlv/name/port-description", state.getPath(), strings.Join(stateKeyValues[:], ",")))
- }
- if !state.FilterListsLldp[i].TlvNamePortId.IsNull() && data.FilterListsLldp[j].TlvNamePortId.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/filter-list/lldp/list=%v/tlv/name/port-id", state.getPath(), strings.Join(stateKeyValues[:], ",")))
- }
break
}
}
if !found {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/filter-list/lldp/list=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/filter-spec/cdp/exclude/list%v", predicates))
}
}
+ if !state.NotifyAllChanges.IsNull() && data.NotifyAllChanges.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/notify/all-changes")
+ }
- return deletedItems
+ return b.Res()
}
-// End of section. //template:end getDeletedItems
+// End of section. //template:end addDeletedItemsXML
// Section below is generated&owned by "gen/generator.go". //template:begin getEmptyLeafsDelete
@@ -1564,3 +2954,106 @@ func (data *DeviceSensor) getDeletePaths(ctx context.Context) []string {
}
// End of section. //template:end getDeletePaths
+
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletePathsXML
+
+func (data *DeviceSensor) addDeletePathsXML(ctx context.Context, body string) string {
+ b := netconf.NewBody(body)
+ for i := range data.FilterListsLldp {
+ keys := [...]string{"name"}
+ keyValues := [...]string{data.FilterListsLldp[i].Name.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/filter-list/lldp/list%v", predicates))
+ }
+ for i := range data.FilterListsDhcp {
+ keys := [...]string{"name"}
+ keyValues := [...]string{data.FilterListsDhcp[i].Name.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/filter-list/dhcp/list%v", predicates))
+ }
+ for i := range data.FilterListsCdp {
+ keys := [...]string{"name"}
+ keyValues := [...]string{data.FilterListsCdp[i].Name.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/filter-list/cdp/list%v", predicates))
+ }
+ for i := range data.FilterSpecDhcpIncludes {
+ keys := [...]string{"name"}
+ keyValues := [...]string{data.FilterSpecDhcpIncludes[i].Name.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/filter-spec/dhcp/include/list%v", predicates))
+ }
+ for i := range data.FilterSpecDhcpExcludes {
+ keys := [...]string{"name"}
+ keyValues := [...]string{data.FilterSpecDhcpExcludes[i].Name.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/filter-spec/dhcp/exclude/list%v", predicates))
+ }
+ for i := range data.FilterSpecLldpIncludes {
+ keys := [...]string{"name"}
+ keyValues := [...]string{data.FilterSpecLldpIncludes[i].Name.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/filter-spec/lldp/include/list%v", predicates))
+ }
+ for i := range data.FilterSpecLldpExcludes {
+ keys := [...]string{"name"}
+ keyValues := [...]string{data.FilterSpecLldpExcludes[i].Name.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/filter-spec/lldp/exclude/list%v", predicates))
+ }
+ for i := range data.FilterSpecCdpIncludes {
+ keys := [...]string{"name"}
+ keyValues := [...]string{data.FilterSpecCdpIncludes[i].Name.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/filter-spec/cdp/include/list%v", predicates))
+ }
+ for i := range data.FilterSpecCdpExcludes {
+ keys := [...]string{"name"}
+ keyValues := [...]string{data.FilterSpecCdpExcludes[i].Name.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/filter-spec/cdp/exclude/list%v", predicates))
+ }
+ if !data.NotifyAllChanges.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/notify/all-changes")
+ }
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletePathsXML
diff --git a/internal/provider/model_iosxe_dhcp.go b/internal/provider/model_iosxe_dhcp.go
index f5db7940..94d9fdfc 100644
--- a/internal/provider/model_iosxe_dhcp.go
+++ b/internal/provider/model_iosxe_dhcp.go
@@ -30,6 +30,9 @@ import (
"github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/types"
+ "github.com/hashicorp/terraform-plugin-log/tflog"
+ "github.com/netascode/go-netconf"
+ "github.com/netascode/xmldot"
"github.com/tidwall/gjson"
"github.com/tidwall/sjson"
)
@@ -101,6 +104,17 @@ func (data DHCP) getPathShort() string {
return matches[1]
}
+// getXPath returns the XPath for NETCONF operations
+func (data DHCP) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/ip/dhcp"
+ return path
+}
+
+func (data DHCPData) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/ip/dhcp"
+ return path
+}
+
// End of section. //template:end getPath
// Section below is generated&owned by "gen/generator.go". //template:begin toBody
@@ -170,6 +184,91 @@ func (data DHCP) toBody(ctx context.Context) string {
// End of section. //template:end toBody
+// Section below is generated&owned by "gen/generator.go". //template:begin toBodyXML
+
+func (data DHCP) toBodyXML(ctx context.Context) string {
+ body := netconf.Body{}
+ if !data.CompatibilitySuboptionLinkSelection.IsNull() && !data.CompatibilitySuboptionLinkSelection.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-dhcp:compatibility/suboption/link-selection", data.CompatibilitySuboptionLinkSelection.ValueString())
+ }
+ if !data.CompatibilitySuboptionServerOverride.IsNull() && !data.CompatibilitySuboptionServerOverride.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-dhcp:compatibility/suboption/server-override", data.CompatibilitySuboptionServerOverride.ValueString())
+ }
+ if !data.RelayInformationTrustAll.IsNull() && !data.RelayInformationTrustAll.IsUnknown() {
+ if data.RelayInformationTrustAll.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-dhcp:relay/information/trust-all", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-dhcp:relay/information/trust-all")
+ }
+ }
+ if !data.RelayInformationOptionDefault.IsNull() && !data.RelayInformationOptionDefault.IsUnknown() {
+ if data.RelayInformationOptionDefault.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-dhcp:relay/information/option/option-default", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-dhcp:relay/information/option/option-default")
+ }
+ }
+ if !data.RelayInformationOptionVpn.IsNull() && !data.RelayInformationOptionVpn.IsUnknown() {
+ if data.RelayInformationOptionVpn.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-dhcp:relay/information/option/vpn", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-dhcp:relay/information/option/vpn")
+ }
+ }
+ if !data.Snooping.IsNull() && !data.Snooping.IsUnknown() {
+ if data.Snooping.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-dhcp:snooping", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-dhcp:snooping")
+ }
+ }
+ if !data.SnoopingInformationOption.IsNull() && !data.SnoopingInformationOption.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-dhcp:snooping-conf/snooping/information/option", data.SnoopingInformationOption.ValueBool())
+ }
+ if !data.SnoopingInformationOptionAllowUntrusted.IsNull() && !data.SnoopingInformationOptionAllowUntrusted.IsUnknown() {
+ if data.SnoopingInformationOptionAllowUntrusted.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-dhcp:snooping-conf/snooping/information/options/option/allow-untrusted", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-dhcp:snooping-conf/snooping/information/options/option/allow-untrusted")
+ }
+ }
+ if !data.SnoopingInformationOptionFormatRemoteIdString.IsNull() && !data.SnoopingInformationOptionFormatRemoteIdString.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-dhcp:snooping-conf/snooping/information/options/option/format/remote-id/string", data.SnoopingInformationOptionFormatRemoteIdString.ValueString())
+ }
+ if !data.SnoopingInformationOptionFormatRemoteIdHostname.IsNull() && !data.SnoopingInformationOptionFormatRemoteIdHostname.IsUnknown() {
+ if data.SnoopingInformationOptionFormatRemoteIdHostname.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-dhcp:snooping-conf/snooping/information/options/option/format/remote-id/hostname", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-dhcp:snooping-conf/snooping/information/options/option/format/remote-id/hostname")
+ }
+ }
+ if len(data.SnoopingVlansLegacy) > 0 {
+ for _, item := range data.SnoopingVlansLegacy {
+ cBody := netconf.Body{}
+ if !item.VlanId.IsNull() && !item.VlanId.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "id", item.VlanId.ValueString())
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-dhcp:snooping-conf/snooping/vlan-list", cBody.Res())
+ }
+ }
+ if len(data.SnoopingVlans) > 0 {
+ for _, item := range data.SnoopingVlans {
+ cBody := netconf.Body{}
+ if !item.VlanId.IsNull() && !item.VlanId.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "id", strconv.FormatInt(item.VlanId.ValueInt64(), 10))
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-dhcp:snooping-conf/snooping/vlan-v2", cBody.Res())
+ }
+ }
+ bodyString, err := body.String()
+ if err != nil {
+ tflog.Error(ctx, fmt.Sprintf("Error converting body to string: %s", err))
+ }
+ return bodyString
+}
+
+// End of section. //template:end toBodyXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBody
func (data *DHCP) updateFromBody(ctx context.Context, res gjson.Result) {
@@ -315,6 +414,147 @@ func (data *DHCP) updateFromBody(ctx context.Context, res gjson.Result) {
// End of section. //template:end updateFromBody
+// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBodyXML
+
+func (data *DHCP) updateFromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-dhcp:compatibility/suboption/link-selection"); value.Exists() && !data.CompatibilitySuboptionLinkSelection.IsNull() {
+ data.CompatibilitySuboptionLinkSelection = types.StringValue(value.String())
+ } else {
+ data.CompatibilitySuboptionLinkSelection = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-dhcp:compatibility/suboption/server-override"); value.Exists() && !data.CompatibilitySuboptionServerOverride.IsNull() {
+ data.CompatibilitySuboptionServerOverride = types.StringValue(value.String())
+ } else {
+ data.CompatibilitySuboptionServerOverride = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-dhcp:relay/information/trust-all"); !data.RelayInformationTrustAll.IsNull() {
+ if value.Exists() {
+ data.RelayInformationTrustAll = types.BoolValue(true)
+ } else {
+ data.RelayInformationTrustAll = types.BoolValue(false)
+ }
+ } else {
+ data.RelayInformationTrustAll = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-dhcp:relay/information/option/option-default"); !data.RelayInformationOptionDefault.IsNull() {
+ if value.Exists() {
+ data.RelayInformationOptionDefault = types.BoolValue(true)
+ } else {
+ data.RelayInformationOptionDefault = types.BoolValue(false)
+ }
+ } else {
+ data.RelayInformationOptionDefault = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-dhcp:relay/information/option/vpn"); !data.RelayInformationOptionVpn.IsNull() {
+ if value.Exists() {
+ data.RelayInformationOptionVpn = types.BoolValue(true)
+ } else {
+ data.RelayInformationOptionVpn = types.BoolValue(false)
+ }
+ } else {
+ data.RelayInformationOptionVpn = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-dhcp:snooping"); !data.Snooping.IsNull() {
+ if value.Exists() {
+ data.Snooping = types.BoolValue(true)
+ } else {
+ data.Snooping = types.BoolValue(false)
+ }
+ } else {
+ data.Snooping = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-dhcp:snooping-conf/snooping/information/option"); !data.SnoopingInformationOption.IsNull() {
+ if value.Exists() {
+ data.SnoopingInformationOption = types.BoolValue(value.Bool())
+ }
+ } else {
+ data.SnoopingInformationOption = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-dhcp:snooping-conf/snooping/information/options/option/allow-untrusted"); !data.SnoopingInformationOptionAllowUntrusted.IsNull() {
+ if value.Exists() {
+ data.SnoopingInformationOptionAllowUntrusted = types.BoolValue(true)
+ } else {
+ data.SnoopingInformationOptionAllowUntrusted = types.BoolValue(false)
+ }
+ } else {
+ data.SnoopingInformationOptionAllowUntrusted = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-dhcp:snooping-conf/snooping/information/options/option/format/remote-id/string"); value.Exists() && !data.SnoopingInformationOptionFormatRemoteIdString.IsNull() {
+ data.SnoopingInformationOptionFormatRemoteIdString = types.StringValue(value.String())
+ } else {
+ data.SnoopingInformationOptionFormatRemoteIdString = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-dhcp:snooping-conf/snooping/information/options/option/format/remote-id/hostname"); !data.SnoopingInformationOptionFormatRemoteIdHostname.IsNull() {
+ if value.Exists() {
+ data.SnoopingInformationOptionFormatRemoteIdHostname = types.BoolValue(true)
+ } else {
+ data.SnoopingInformationOptionFormatRemoteIdHostname = types.BoolValue(false)
+ }
+ } else {
+ data.SnoopingInformationOptionFormatRemoteIdHostname = types.BoolNull()
+ }
+ for i := range data.SnoopingVlansLegacy {
+ keys := [...]string{"id"}
+ keyValues := [...]string{data.SnoopingVlansLegacy[i].VlanId.ValueString()}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-dhcp:snooping-conf/snooping/vlan-list").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, "id"); value.Exists() && !data.SnoopingVlansLegacy[i].VlanId.IsNull() {
+ data.SnoopingVlansLegacy[i].VlanId = types.StringValue(value.String())
+ } else {
+ data.SnoopingVlansLegacy[i].VlanId = types.StringNull()
+ }
+ }
+ for i := range data.SnoopingVlans {
+ keys := [...]string{"id"}
+ keyValues := [...]string{strconv.FormatInt(data.SnoopingVlans[i].VlanId.ValueInt64(), 10)}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-dhcp:snooping-conf/snooping/vlan-v2").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, "id"); value.Exists() && !data.SnoopingVlans[i].VlanId.IsNull() {
+ data.SnoopingVlans[i].VlanId = types.Int64Value(value.Int())
+ } else {
+ data.SnoopingVlans[i].VlanId = types.Int64Null()
+ }
+ }
+}
+
+// End of section. //template:end updateFromBodyXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin fromBody
func (data *DHCP) fromBody(ctx context.Context, res gjson.Result) {
@@ -469,6 +709,152 @@ func (data *DHCPData) fromBody(ctx context.Context, res gjson.Result) {
// End of section. //template:end fromBodyData
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyXML
+
+func (data *DHCP) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-dhcp:compatibility/suboption/link-selection"); value.Exists() {
+ data.CompatibilitySuboptionLinkSelection = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-dhcp:compatibility/suboption/server-override"); value.Exists() {
+ data.CompatibilitySuboptionServerOverride = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-dhcp:relay/information/trust-all"); value.Exists() {
+ data.RelayInformationTrustAll = types.BoolValue(true)
+ } else {
+ data.RelayInformationTrustAll = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-dhcp:relay/information/option/option-default"); value.Exists() {
+ data.RelayInformationOptionDefault = types.BoolValue(true)
+ } else {
+ data.RelayInformationOptionDefault = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-dhcp:relay/information/option/vpn"); value.Exists() {
+ data.RelayInformationOptionVpn = types.BoolValue(true)
+ } else {
+ data.RelayInformationOptionVpn = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-dhcp:snooping"); value.Exists() {
+ data.Snooping = types.BoolValue(true)
+ } else {
+ data.Snooping = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-dhcp:snooping-conf/snooping/information/option"); value.Exists() {
+ data.SnoopingInformationOption = types.BoolValue(value.Bool())
+ } else {
+ data.SnoopingInformationOption = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-dhcp:snooping-conf/snooping/information/options/option/allow-untrusted"); value.Exists() {
+ data.SnoopingInformationOptionAllowUntrusted = types.BoolValue(true)
+ } else {
+ data.SnoopingInformationOptionAllowUntrusted = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-dhcp:snooping-conf/snooping/information/options/option/format/remote-id/string"); value.Exists() {
+ data.SnoopingInformationOptionFormatRemoteIdString = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-dhcp:snooping-conf/snooping/information/options/option/format/remote-id/hostname"); value.Exists() {
+ data.SnoopingInformationOptionFormatRemoteIdHostname = types.BoolValue(true)
+ } else {
+ data.SnoopingInformationOptionFormatRemoteIdHostname = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-dhcp:snooping-conf/snooping/vlan-list"); value.Exists() {
+ data.SnoopingVlansLegacy = make([]DHCPSnoopingVlansLegacy, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := DHCPSnoopingVlansLegacy{}
+ if cValue := helpers.GetFromXPath(v, "id"); cValue.Exists() {
+ item.VlanId = types.StringValue(cValue.String())
+ }
+ data.SnoopingVlansLegacy = append(data.SnoopingVlansLegacy, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-dhcp:snooping-conf/snooping/vlan-v2"); value.Exists() {
+ data.SnoopingVlans = make([]DHCPSnoopingVlans, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := DHCPSnoopingVlans{}
+ if cValue := helpers.GetFromXPath(v, "id"); cValue.Exists() {
+ item.VlanId = types.Int64Value(cValue.Int())
+ }
+ data.SnoopingVlans = append(data.SnoopingVlans, item)
+ return true
+ })
+ }
+}
+
+// End of section. //template:end fromBodyXML
+
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyDataXML
+
+func (data *DHCPData) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-dhcp:compatibility/suboption/link-selection"); value.Exists() {
+ data.CompatibilitySuboptionLinkSelection = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-dhcp:compatibility/suboption/server-override"); value.Exists() {
+ data.CompatibilitySuboptionServerOverride = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-dhcp:relay/information/trust-all"); value.Exists() {
+ data.RelayInformationTrustAll = types.BoolValue(true)
+ } else {
+ data.RelayInformationTrustAll = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-dhcp:relay/information/option/option-default"); value.Exists() {
+ data.RelayInformationOptionDefault = types.BoolValue(true)
+ } else {
+ data.RelayInformationOptionDefault = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-dhcp:relay/information/option/vpn"); value.Exists() {
+ data.RelayInformationOptionVpn = types.BoolValue(true)
+ } else {
+ data.RelayInformationOptionVpn = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-dhcp:snooping"); value.Exists() {
+ data.Snooping = types.BoolValue(true)
+ } else {
+ data.Snooping = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-dhcp:snooping-conf/snooping/information/option"); value.Exists() {
+ data.SnoopingInformationOption = types.BoolValue(value.Bool())
+ } else {
+ data.SnoopingInformationOption = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-dhcp:snooping-conf/snooping/information/options/option/allow-untrusted"); value.Exists() {
+ data.SnoopingInformationOptionAllowUntrusted = types.BoolValue(true)
+ } else {
+ data.SnoopingInformationOptionAllowUntrusted = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-dhcp:snooping-conf/snooping/information/options/option/format/remote-id/string"); value.Exists() {
+ data.SnoopingInformationOptionFormatRemoteIdString = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-dhcp:snooping-conf/snooping/information/options/option/format/remote-id/hostname"); value.Exists() {
+ data.SnoopingInformationOptionFormatRemoteIdHostname = types.BoolValue(true)
+ } else {
+ data.SnoopingInformationOptionFormatRemoteIdHostname = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-dhcp:snooping-conf/snooping/vlan-list"); value.Exists() {
+ data.SnoopingVlansLegacy = make([]DHCPSnoopingVlansLegacy, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := DHCPSnoopingVlansLegacy{}
+ if cValue := helpers.GetFromXPath(v, "id"); cValue.Exists() {
+ item.VlanId = types.StringValue(cValue.String())
+ }
+ data.SnoopingVlansLegacy = append(data.SnoopingVlansLegacy, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-dhcp:snooping-conf/snooping/vlan-v2"); value.Exists() {
+ data.SnoopingVlans = make([]DHCPSnoopingVlans, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := DHCPSnoopingVlans{}
+ if cValue := helpers.GetFromXPath(v, "id"); cValue.Exists() {
+ item.VlanId = types.Int64Value(cValue.Int())
+ }
+ data.SnoopingVlans = append(data.SnoopingVlans, item)
+ return true
+ })
+ }
+}
+
+// End of section. //template:end fromBodyDataXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin getDeletedItems
func (data *DHCP) getDeletedItems(ctx context.Context, state DHCP) []string {
@@ -559,6 +945,106 @@ func (data *DHCP) getDeletedItems(ctx context.Context, state DHCP) []string {
// End of section. //template:end getDeletedItems
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletedItemsXML
+
+func (data *DHCP) addDeletedItemsXML(ctx context.Context, state DHCP, body string) string {
+ b := netconf.NewBody(body)
+ if !state.CompatibilitySuboptionLinkSelection.IsNull() && data.CompatibilitySuboptionLinkSelection.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-dhcp:compatibility/suboption/link-selection")
+ }
+ if !state.CompatibilitySuboptionServerOverride.IsNull() && data.CompatibilitySuboptionServerOverride.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-dhcp:compatibility/suboption/server-override")
+ }
+ if !state.RelayInformationTrustAll.IsNull() && data.RelayInformationTrustAll.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-dhcp:relay/information/trust-all")
+ }
+ if !state.RelayInformationOptionDefault.IsNull() && data.RelayInformationOptionDefault.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-dhcp:relay/information/option/option-default")
+ }
+ if !state.RelayInformationOptionVpn.IsNull() && data.RelayInformationOptionVpn.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-dhcp:relay/information/option/vpn")
+ }
+ if !state.Snooping.IsNull() && data.Snooping.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-dhcp:snooping")
+ }
+ if !state.SnoopingInformationOption.IsNull() && data.SnoopingInformationOption.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-dhcp:snooping-conf/snooping/information/option")
+ }
+ if !state.SnoopingInformationOptionAllowUntrusted.IsNull() && data.SnoopingInformationOptionAllowUntrusted.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-dhcp:snooping-conf/snooping/information/options/option/allow-untrusted")
+ }
+ if !state.SnoopingInformationOptionFormatRemoteIdString.IsNull() && data.SnoopingInformationOptionFormatRemoteIdString.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-dhcp:snooping-conf/snooping/information/options/option/format/remote-id/string")
+ }
+ if !state.SnoopingInformationOptionFormatRemoteIdHostname.IsNull() && data.SnoopingInformationOptionFormatRemoteIdHostname.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-dhcp:snooping-conf/snooping/information/options/option/format/remote-id/hostname")
+ }
+ for i := range state.SnoopingVlansLegacy {
+ stateKeys := [...]string{"id"}
+ stateKeyValues := [...]string{state.SnoopingVlansLegacy[i].VlanId.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.SnoopingVlansLegacy[i].VlanId.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.SnoopingVlansLegacy {
+ found = true
+ if state.SnoopingVlansLegacy[i].VlanId.ValueString() != data.SnoopingVlansLegacy[j].VlanId.ValueString() {
+ found = false
+ }
+ if found {
+ break
+ }
+ }
+ if !found {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-dhcp:snooping-conf/snooping/vlan-list%v", predicates))
+ }
+ }
+ for i := range state.SnoopingVlans {
+ stateKeys := [...]string{"id"}
+ stateKeyValues := [...]string{strconv.FormatInt(state.SnoopingVlans[i].VlanId.ValueInt64(), 10)}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.SnoopingVlans[i].VlanId.ValueInt64()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.SnoopingVlans {
+ found = true
+ if state.SnoopingVlans[i].VlanId.ValueInt64() != data.SnoopingVlans[j].VlanId.ValueInt64() {
+ found = false
+ }
+ if found {
+ break
+ }
+ }
+ if !found {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-dhcp:snooping-conf/snooping/vlan-v2%v", predicates))
+ }
+ }
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletedItemsXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin getEmptyLeafsDelete
func (data *DHCP) getEmptyLeafsDelete(ctx context.Context) []string {
@@ -637,3 +1123,63 @@ func (data *DHCP) getDeletePaths(ctx context.Context) []string {
}
// End of section. //template:end getDeletePaths
+
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletePathsXML
+
+func (data *DHCP) addDeletePathsXML(ctx context.Context, body string) string {
+ b := netconf.NewBody(body)
+ if !data.CompatibilitySuboptionLinkSelection.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-dhcp:compatibility/suboption/link-selection")
+ }
+ if !data.CompatibilitySuboptionServerOverride.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-dhcp:compatibility/suboption/server-override")
+ }
+ if !data.RelayInformationTrustAll.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-dhcp:relay/information/trust-all")
+ }
+ if !data.RelayInformationOptionDefault.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-dhcp:relay/information/option/option-default")
+ }
+ if !data.RelayInformationOptionVpn.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-dhcp:relay/information/option/vpn")
+ }
+ if !data.Snooping.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-dhcp:snooping")
+ }
+ if !data.SnoopingInformationOption.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-dhcp:snooping-conf/snooping/information/option")
+ }
+ if !data.SnoopingInformationOptionAllowUntrusted.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-dhcp:snooping-conf/snooping/information/options/option/allow-untrusted")
+ }
+ if !data.SnoopingInformationOptionFormatRemoteIdString.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-dhcp:snooping-conf/snooping/information/options/option/format/remote-id/string")
+ }
+ if !data.SnoopingInformationOptionFormatRemoteIdHostname.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-dhcp:snooping-conf/snooping/information/options/option/format/remote-id/hostname")
+ }
+ for i := range data.SnoopingVlansLegacy {
+ keys := [...]string{"id"}
+ keyValues := [...]string{data.SnoopingVlansLegacy[i].VlanId.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/Cisco-IOS-XE-dhcp:snooping-conf/snooping/vlan-list%v", predicates))
+ }
+ for i := range data.SnoopingVlans {
+ keys := [...]string{"id"}
+ keyValues := [...]string{strconv.FormatInt(data.SnoopingVlans[i].VlanId.ValueInt64(), 10)}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/Cisco-IOS-XE-dhcp:snooping-conf/snooping/vlan-v2%v", predicates))
+ }
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletePathsXML
diff --git a/internal/provider/model_iosxe_dot1x.go b/internal/provider/model_iosxe_dot1x.go
index ef202a6f..02d2a16d 100644
--- a/internal/provider/model_iosxe_dot1x.go
+++ b/internal/provider/model_iosxe_dot1x.go
@@ -30,6 +30,9 @@ import (
"github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/types"
+ "github.com/hashicorp/terraform-plugin-log/tflog"
+ "github.com/netascode/go-netconf"
+ "github.com/netascode/xmldot"
"github.com/tidwall/gjson"
"github.com/tidwall/sjson"
)
@@ -104,6 +107,17 @@ func (data Dot1x) getPathShort() string {
return matches[1]
}
+// getXPath returns the XPath for NETCONF operations
+func (data Dot1x) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/dot1x"
+ return path
+}
+
+func (data Dot1xData) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/dot1x"
+ return path
+}
+
// End of section. //template:end getPath
// Section below is generated&owned by "gen/generator.go". //template:begin toBody
@@ -192,6 +206,115 @@ func (data Dot1x) toBody(ctx context.Context) string {
// End of section. //template:end toBody
+// Section below is generated&owned by "gen/generator.go". //template:begin toBodyXML
+
+func (data Dot1x) toBodyXML(ctx context.Context) string {
+ body := netconf.Body{}
+ if !data.AuthFailEapol.IsNull() && !data.AuthFailEapol.IsUnknown() {
+ if data.AuthFailEapol.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-dot1x:auth-fail/eapol", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-dot1x:auth-fail/eapol")
+ }
+ }
+ if len(data.Credentials) > 0 {
+ for _, item := range data.Credentials {
+ cBody := netconf.Body{}
+ if !item.ProfileName.IsNull() && !item.ProfileName.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "profile-name", item.ProfileName.ValueString())
+ }
+ if !item.Description.IsNull() && !item.Description.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "description", item.Description.ValueString())
+ }
+ if !item.Username.IsNull() && !item.Username.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "username", item.Username.ValueString())
+ }
+ if !item.PasswordType.IsNull() && !item.PasswordType.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "password/type", item.PasswordType.ValueString())
+ }
+ if !item.Password.IsNull() && !item.Password.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "password/secret", item.Password.ValueString())
+ }
+ if !item.PkiTrustpoint.IsNull() && !item.PkiTrustpoint.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "pki-trustpoint", item.PkiTrustpoint.ValueString())
+ }
+ if !item.AnonymousId.IsNull() && !item.AnonymousId.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "anonymous-id", item.AnonymousId.ValueString())
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-dot1x:credentials", cBody.Res())
+ }
+ }
+ if !data.CriticalEapolConfigBlock.IsNull() && !data.CriticalEapolConfigBlock.IsUnknown() {
+ if data.CriticalEapolConfigBlock.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-dot1x:critical/eapol-config/block", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-dot1x:critical/eapol-config/block")
+ }
+ }
+ if !data.CriticalRecoveryDelay.IsNull() && !data.CriticalRecoveryDelay.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-dot1x:critical/recovery/delay", strconv.FormatInt(data.CriticalRecoveryDelay.ValueInt64(), 10))
+ }
+ if !data.TestTimeout.IsNull() && !data.TestTimeout.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-dot1x:test/timeout", strconv.FormatInt(data.TestTimeout.ValueInt64(), 10))
+ }
+ if !data.LoggingVerbose.IsNull() && !data.LoggingVerbose.IsUnknown() {
+ if data.LoggingVerbose.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-dot1x:logging/verbose", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-dot1x:logging/verbose")
+ }
+ }
+ if !data.SupplicantControlledTransient.IsNull() && !data.SupplicantControlledTransient.IsUnknown() {
+ if data.SupplicantControlledTransient.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-dot1x:supplicant/controlled/transient", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-dot1x:supplicant/controlled/transient")
+ }
+ }
+ if !data.SupplicantForceMulticast.IsNull() && !data.SupplicantForceMulticast.IsUnknown() {
+ if data.SupplicantForceMulticast.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-dot1x:supplicant/force-multicast", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-dot1x:supplicant/force-multicast")
+ }
+ }
+ if !data.SystemAuthControl.IsNull() && !data.SystemAuthControl.IsUnknown() {
+ if data.SystemAuthControl.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-dot1x:system-auth-control", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-dot1x:system-auth-control")
+ }
+ }
+ if !data.GuestVlanSupplicant.IsNull() && !data.GuestVlanSupplicant.IsUnknown() {
+ if data.GuestVlanSupplicant.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-dot1x:guest-vlan/supplicant", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-dot1x:guest-vlan/supplicant")
+ }
+ }
+ if !data.CriticalEapol.IsNull() && !data.CriticalEapol.IsUnknown() {
+ if data.CriticalEapol.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-dot1x:critical/eapol-config", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-dot1x:critical/eapol-config")
+ }
+ }
+ if !data.CriticalEapolBlock.IsNull() && !data.CriticalEapolBlock.IsUnknown() {
+ if data.CriticalEapolBlock.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-dot1x:critical/eapol-config/block", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-dot1x:critical/eapol-config/block")
+ }
+ }
+ bodyString, err := body.String()
+ if err != nil {
+ tflog.Error(ctx, fmt.Sprintf("Error converting body to string: %s", err))
+ }
+ return bodyString
+}
+
+// End of section. //template:end toBodyXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBody
func (data *Dot1x) updateFromBody(ctx context.Context, res gjson.Result) {
@@ -343,6 +466,153 @@ func (data *Dot1x) updateFromBody(ctx context.Context, res gjson.Result) {
// End of section. //template:end updateFromBody
+// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBodyXML
+
+func (data *Dot1x) updateFromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-dot1x:auth-fail/eapol"); !data.AuthFailEapol.IsNull() {
+ if value.Exists() {
+ data.AuthFailEapol = types.BoolValue(true)
+ } else {
+ data.AuthFailEapol = types.BoolValue(false)
+ }
+ } else {
+ data.AuthFailEapol = types.BoolNull()
+ }
+ for i := range data.Credentials {
+ keys := [...]string{"profile-name"}
+ keyValues := [...]string{data.Credentials[i].ProfileName.ValueString()}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-dot1x:credentials").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, "profile-name"); value.Exists() && !data.Credentials[i].ProfileName.IsNull() {
+ data.Credentials[i].ProfileName = types.StringValue(value.String())
+ } else {
+ data.Credentials[i].ProfileName = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "description"); value.Exists() && !data.Credentials[i].Description.IsNull() {
+ data.Credentials[i].Description = types.StringValue(value.String())
+ } else {
+ data.Credentials[i].Description = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "username"); value.Exists() && !data.Credentials[i].Username.IsNull() {
+ data.Credentials[i].Username = types.StringValue(value.String())
+ } else {
+ data.Credentials[i].Username = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "pki-trustpoint"); value.Exists() && !data.Credentials[i].PkiTrustpoint.IsNull() {
+ data.Credentials[i].PkiTrustpoint = types.StringValue(value.String())
+ } else {
+ data.Credentials[i].PkiTrustpoint = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "anonymous-id"); value.Exists() && !data.Credentials[i].AnonymousId.IsNull() {
+ data.Credentials[i].AnonymousId = types.StringValue(value.String())
+ } else {
+ data.Credentials[i].AnonymousId = types.StringNull()
+ }
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-dot1x:critical/eapol-config/block"); !data.CriticalEapolConfigBlock.IsNull() {
+ if value.Exists() {
+ data.CriticalEapolConfigBlock = types.BoolValue(true)
+ } else {
+ data.CriticalEapolConfigBlock = types.BoolValue(false)
+ }
+ } else {
+ data.CriticalEapolConfigBlock = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-dot1x:critical/recovery/delay"); value.Exists() && !data.CriticalRecoveryDelay.IsNull() {
+ data.CriticalRecoveryDelay = types.Int64Value(value.Int())
+ } else {
+ data.CriticalRecoveryDelay = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-dot1x:test/timeout"); value.Exists() && !data.TestTimeout.IsNull() {
+ data.TestTimeout = types.Int64Value(value.Int())
+ } else {
+ data.TestTimeout = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-dot1x:logging/verbose"); !data.LoggingVerbose.IsNull() {
+ if value.Exists() {
+ data.LoggingVerbose = types.BoolValue(true)
+ } else {
+ data.LoggingVerbose = types.BoolValue(false)
+ }
+ } else {
+ data.LoggingVerbose = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-dot1x:supplicant/controlled/transient"); !data.SupplicantControlledTransient.IsNull() {
+ if value.Exists() {
+ data.SupplicantControlledTransient = types.BoolValue(true)
+ } else {
+ data.SupplicantControlledTransient = types.BoolValue(false)
+ }
+ } else {
+ data.SupplicantControlledTransient = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-dot1x:supplicant/force-multicast"); !data.SupplicantForceMulticast.IsNull() {
+ if value.Exists() {
+ data.SupplicantForceMulticast = types.BoolValue(true)
+ } else {
+ data.SupplicantForceMulticast = types.BoolValue(false)
+ }
+ } else {
+ data.SupplicantForceMulticast = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-dot1x:system-auth-control"); !data.SystemAuthControl.IsNull() {
+ if value.Exists() {
+ data.SystemAuthControl = types.BoolValue(true)
+ } else {
+ data.SystemAuthControl = types.BoolValue(false)
+ }
+ } else {
+ data.SystemAuthControl = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-dot1x:guest-vlan/supplicant"); !data.GuestVlanSupplicant.IsNull() {
+ if value.Exists() {
+ data.GuestVlanSupplicant = types.BoolValue(true)
+ } else {
+ data.GuestVlanSupplicant = types.BoolValue(false)
+ }
+ } else {
+ data.GuestVlanSupplicant = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-dot1x:critical/eapol-config"); !data.CriticalEapol.IsNull() {
+ if value.Exists() {
+ data.CriticalEapol = types.BoolValue(true)
+ } else {
+ data.CriticalEapol = types.BoolValue(false)
+ }
+ } else {
+ data.CriticalEapol = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-dot1x:critical/eapol-config/block"); !data.CriticalEapolBlock.IsNull() {
+ if value.Exists() {
+ data.CriticalEapolBlock = types.BoolValue(true)
+ } else {
+ data.CriticalEapolBlock = types.BoolValue(false)
+ }
+ } else {
+ data.CriticalEapolBlock = types.BoolNull()
+ }
+}
+
+// End of section. //template:end updateFromBodyXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin fromBody
func (data *Dot1x) fromBody(ctx context.Context, res gjson.Result) {
@@ -525,6 +795,180 @@ func (data *Dot1xData) fromBody(ctx context.Context, res gjson.Result) {
// End of section. //template:end fromBodyData
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyXML
+
+func (data *Dot1x) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-dot1x:auth-fail/eapol"); value.Exists() {
+ data.AuthFailEapol = types.BoolValue(true)
+ } else {
+ data.AuthFailEapol = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-dot1x:credentials"); value.Exists() {
+ data.Credentials = make([]Dot1xCredentials, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := Dot1xCredentials{}
+ if cValue := helpers.GetFromXPath(v, "profile-name"); cValue.Exists() {
+ item.ProfileName = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "description"); cValue.Exists() {
+ item.Description = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "username"); cValue.Exists() {
+ item.Username = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "password/type"); cValue.Exists() {
+ item.PasswordType = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "password/secret"); cValue.Exists() {
+ item.Password = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "pki-trustpoint"); cValue.Exists() {
+ item.PkiTrustpoint = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "anonymous-id"); cValue.Exists() {
+ item.AnonymousId = types.StringValue(cValue.String())
+ }
+ data.Credentials = append(data.Credentials, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-dot1x:critical/eapol-config/block"); value.Exists() {
+ data.CriticalEapolConfigBlock = types.BoolValue(true)
+ } else {
+ data.CriticalEapolConfigBlock = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-dot1x:critical/recovery/delay"); value.Exists() {
+ data.CriticalRecoveryDelay = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-dot1x:test/timeout"); value.Exists() {
+ data.TestTimeout = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-dot1x:logging/verbose"); value.Exists() {
+ data.LoggingVerbose = types.BoolValue(true)
+ } else {
+ data.LoggingVerbose = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-dot1x:supplicant/controlled/transient"); value.Exists() {
+ data.SupplicantControlledTransient = types.BoolValue(true)
+ } else {
+ data.SupplicantControlledTransient = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-dot1x:supplicant/force-multicast"); value.Exists() {
+ data.SupplicantForceMulticast = types.BoolValue(true)
+ } else {
+ data.SupplicantForceMulticast = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-dot1x:system-auth-control"); value.Exists() {
+ data.SystemAuthControl = types.BoolValue(true)
+ } else {
+ data.SystemAuthControl = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-dot1x:guest-vlan/supplicant"); value.Exists() {
+ data.GuestVlanSupplicant = types.BoolValue(true)
+ } else {
+ data.GuestVlanSupplicant = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-dot1x:critical/eapol-config"); value.Exists() {
+ data.CriticalEapol = types.BoolValue(true)
+ } else {
+ data.CriticalEapol = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-dot1x:critical/eapol-config/block"); value.Exists() {
+ data.CriticalEapolBlock = types.BoolValue(true)
+ } else {
+ data.CriticalEapolBlock = types.BoolValue(false)
+ }
+}
+
+// End of section. //template:end fromBodyXML
+
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyDataXML
+
+func (data *Dot1xData) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-dot1x:auth-fail/eapol"); value.Exists() {
+ data.AuthFailEapol = types.BoolValue(true)
+ } else {
+ data.AuthFailEapol = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-dot1x:credentials"); value.Exists() {
+ data.Credentials = make([]Dot1xCredentials, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := Dot1xCredentials{}
+ if cValue := helpers.GetFromXPath(v, "profile-name"); cValue.Exists() {
+ item.ProfileName = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "description"); cValue.Exists() {
+ item.Description = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "username"); cValue.Exists() {
+ item.Username = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "password/type"); cValue.Exists() {
+ item.PasswordType = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "password/secret"); cValue.Exists() {
+ item.Password = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "pki-trustpoint"); cValue.Exists() {
+ item.PkiTrustpoint = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "anonymous-id"); cValue.Exists() {
+ item.AnonymousId = types.StringValue(cValue.String())
+ }
+ data.Credentials = append(data.Credentials, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-dot1x:critical/eapol-config/block"); value.Exists() {
+ data.CriticalEapolConfigBlock = types.BoolValue(true)
+ } else {
+ data.CriticalEapolConfigBlock = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-dot1x:critical/recovery/delay"); value.Exists() {
+ data.CriticalRecoveryDelay = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-dot1x:test/timeout"); value.Exists() {
+ data.TestTimeout = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-dot1x:logging/verbose"); value.Exists() {
+ data.LoggingVerbose = types.BoolValue(true)
+ } else {
+ data.LoggingVerbose = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-dot1x:supplicant/controlled/transient"); value.Exists() {
+ data.SupplicantControlledTransient = types.BoolValue(true)
+ } else {
+ data.SupplicantControlledTransient = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-dot1x:supplicant/force-multicast"); value.Exists() {
+ data.SupplicantForceMulticast = types.BoolValue(true)
+ } else {
+ data.SupplicantForceMulticast = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-dot1x:system-auth-control"); value.Exists() {
+ data.SystemAuthControl = types.BoolValue(true)
+ } else {
+ data.SystemAuthControl = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-dot1x:guest-vlan/supplicant"); value.Exists() {
+ data.GuestVlanSupplicant = types.BoolValue(true)
+ } else {
+ data.GuestVlanSupplicant = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-dot1x:critical/eapol-config"); value.Exists() {
+ data.CriticalEapol = types.BoolValue(true)
+ } else {
+ data.CriticalEapol = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-dot1x:critical/eapol-config/block"); value.Exists() {
+ data.CriticalEapolBlock = types.BoolValue(true)
+ } else {
+ data.CriticalEapolBlock = types.BoolValue(false)
+ }
+}
+
+// End of section. //template:end fromBodyDataXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin getDeletedItems
func (data *Dot1x) getDeletedItems(ctx context.Context, state Dot1x) []string {
@@ -611,6 +1055,97 @@ func (data *Dot1x) getDeletedItems(ctx context.Context, state Dot1x) []string {
// End of section. //template:end getDeletedItems
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletedItemsXML
+
+func (data *Dot1x) addDeletedItemsXML(ctx context.Context, state Dot1x, body string) string {
+ b := netconf.NewBody(body)
+ if !state.AuthFailEapol.IsNull() && data.AuthFailEapol.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-dot1x:auth-fail/eapol")
+ }
+ for i := range state.Credentials {
+ stateKeys := [...]string{"profile-name"}
+ stateKeyValues := [...]string{state.Credentials[i].ProfileName.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.Credentials[i].ProfileName.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.Credentials {
+ found = true
+ if state.Credentials[i].ProfileName.ValueString() != data.Credentials[j].ProfileName.ValueString() {
+ found = false
+ }
+ if found {
+ if !state.Credentials[i].Description.IsNull() && data.Credentials[j].Description.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-dot1x:credentials%v/description", predicates))
+ }
+ if !state.Credentials[i].Username.IsNull() && data.Credentials[j].Username.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-dot1x:credentials%v/username", predicates))
+ }
+ if !state.Credentials[i].PasswordType.IsNull() && data.Credentials[j].PasswordType.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-dot1x:credentials%v/password/type", predicates))
+ }
+ if !state.Credentials[i].Password.IsNull() && data.Credentials[j].Password.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-dot1x:credentials%v/password/secret", predicates))
+ }
+ if !state.Credentials[i].PkiTrustpoint.IsNull() && data.Credentials[j].PkiTrustpoint.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-dot1x:credentials%v/pki-trustpoint", predicates))
+ }
+ if !state.Credentials[i].AnonymousId.IsNull() && data.Credentials[j].AnonymousId.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-dot1x:credentials%v/anonymous-id", predicates))
+ }
+ break
+ }
+ }
+ if !found {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-dot1x:credentials%v", predicates))
+ }
+ }
+ if !state.CriticalEapolConfigBlock.IsNull() && data.CriticalEapolConfigBlock.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-dot1x:critical/eapol-config/block")
+ }
+ if !state.CriticalRecoveryDelay.IsNull() && data.CriticalRecoveryDelay.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-dot1x:critical/recovery/delay")
+ }
+ if !state.TestTimeout.IsNull() && data.TestTimeout.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-dot1x:test/timeout")
+ }
+ if !state.LoggingVerbose.IsNull() && data.LoggingVerbose.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-dot1x:logging/verbose")
+ }
+ if !state.SupplicantControlledTransient.IsNull() && data.SupplicantControlledTransient.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-dot1x:supplicant/controlled/transient")
+ }
+ if !state.SupplicantForceMulticast.IsNull() && data.SupplicantForceMulticast.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-dot1x:supplicant/force-multicast")
+ }
+ if !state.SystemAuthControl.IsNull() && data.SystemAuthControl.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-dot1x:system-auth-control")
+ }
+ if !state.GuestVlanSupplicant.IsNull() && data.GuestVlanSupplicant.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-dot1x:guest-vlan/supplicant")
+ }
+ if !state.CriticalEapol.IsNull() && data.CriticalEapol.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-dot1x:critical/eapol-config")
+ }
+ if !state.CriticalEapolBlock.IsNull() && data.CriticalEapolBlock.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-dot1x:critical/eapol-config/block")
+ }
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletedItemsXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin getEmptyLeafsDelete
func (data *Dot1x) getEmptyLeafsDelete(ctx context.Context) []string {
@@ -696,3 +1231,56 @@ func (data *Dot1x) getDeletePaths(ctx context.Context) []string {
}
// End of section. //template:end getDeletePaths
+
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletePathsXML
+
+func (data *Dot1x) addDeletePathsXML(ctx context.Context, body string) string {
+ b := netconf.NewBody(body)
+ if !data.AuthFailEapol.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-dot1x:auth-fail/eapol")
+ }
+ for i := range data.Credentials {
+ keys := [...]string{"profile-name"}
+ keyValues := [...]string{data.Credentials[i].ProfileName.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/Cisco-IOS-XE-dot1x:credentials%v", predicates))
+ }
+ if !data.CriticalEapolConfigBlock.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-dot1x:critical/eapol-config/block")
+ }
+ if !data.CriticalRecoveryDelay.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-dot1x:critical/recovery/delay")
+ }
+ if !data.TestTimeout.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-dot1x:test/timeout")
+ }
+ if !data.LoggingVerbose.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-dot1x:logging/verbose")
+ }
+ if !data.SupplicantControlledTransient.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-dot1x:supplicant/controlled/transient")
+ }
+ if !data.SupplicantForceMulticast.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-dot1x:supplicant/force-multicast")
+ }
+ if !data.SystemAuthControl.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-dot1x:system-auth-control")
+ }
+ if !data.GuestVlanSupplicant.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-dot1x:guest-vlan/supplicant")
+ }
+ if !data.CriticalEapol.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-dot1x:critical/eapol-config")
+ }
+ if !data.CriticalEapolBlock.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-dot1x:critical/eapol-config/block")
+ }
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletePathsXML
diff --git a/internal/provider/model_iosxe_eem.go b/internal/provider/model_iosxe_eem.go
index 4a8e31a5..0e80f688 100644
--- a/internal/provider/model_iosxe_eem.go
+++ b/internal/provider/model_iosxe_eem.go
@@ -30,6 +30,9 @@ import (
"github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/types"
+ "github.com/hashicorp/terraform-plugin-log/tflog"
+ "github.com/netascode/go-netconf"
+ "github.com/netascode/xmldot"
"github.com/tidwall/gjson"
"github.com/tidwall/sjson"
)
@@ -185,6 +188,17 @@ func (data EEM) getPathShort() string {
return matches[1]
}
+// getXPath returns the XPath for NETCONF operations
+func (data EEM) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/event/Cisco-IOS-XE-eem:manager"
+ return path
+}
+
+func (data EEMData) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/event/Cisco-IOS-XE-eem:manager"
+ return path
+}
+
// End of section. //template:end getPath
// Section below is generated&owned by "gen/generator.go". //template:begin toBody
@@ -518,6 +532,366 @@ func (data EEM) toBody(ctx context.Context) string {
// End of section. //template:end toBody
+// Section below is generated&owned by "gen/generator.go". //template:begin toBodyXML
+
+func (data EEM) toBodyXML(ctx context.Context) string {
+ body := netconf.Body{}
+ if len(data.EnvironmentVariables) > 0 {
+ for _, item := range data.EnvironmentVariables {
+ cBody := netconf.Body{}
+ if !item.Name.IsNull() && !item.Name.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "name", item.Name.ValueString())
+ }
+ if !item.Value.IsNull() && !item.Value.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "value", item.Value.ValueString())
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/environment", cBody.Res())
+ }
+ }
+ if !data.SessionCliUsername.IsNull() && !data.SessionCliUsername.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/session/cli/username/username_in_word_set", data.SessionCliUsername.ValueString())
+ }
+ if !data.SessionCliUsernamePrivilege.IsNull() && !data.SessionCliUsernamePrivilege.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/session/cli/username/privilege_set", strconv.FormatInt(data.SessionCliUsernamePrivilege.ValueInt64(), 10))
+ }
+ if !data.HistorySizeEvents.IsNull() && !data.HistorySizeEvents.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/history/size/events", strconv.FormatInt(data.HistorySizeEvents.ValueInt64(), 10))
+ }
+ if !data.HistorySizeTraps.IsNull() && !data.HistorySizeTraps.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/history/size/traps", strconv.FormatInt(data.HistorySizeTraps.ValueInt64(), 10))
+ }
+ if !data.DirectoryUserPolicy.IsNull() && !data.DirectoryUserPolicy.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/directory/user/policy", data.DirectoryUserPolicy.ValueString())
+ }
+ if !data.SchedulerAppletThreadClassDefault.IsNull() && !data.SchedulerAppletThreadClassDefault.IsUnknown() {
+ if data.SchedulerAppletThreadClassDefault.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/scheduler/applet/thread/class/default", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/scheduler/applet/thread/class/default")
+ }
+ }
+ if !data.SchedulerAppletThreadClassNumber.IsNull() && !data.SchedulerAppletThreadClassNumber.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/scheduler/applet/thread/class/number", strconv.FormatInt(data.SchedulerAppletThreadClassNumber.ValueInt64(), 10))
+ }
+ if !data.DetectorRpcMaxSessions.IsNull() && !data.DetectorRpcMaxSessions.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/detector/rpc/max-sessions", strconv.FormatInt(data.DetectorRpcMaxSessions.ValueInt64(), 10))
+ }
+ if !data.DetectorRoutingBootupDelay.IsNull() && !data.DetectorRoutingBootupDelay.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/detector/routing/bootup-delay", strconv.FormatFloat(data.DetectorRoutingBootupDelay.ValueFloat64(), 'f', 1, 64))
+ }
+ if len(data.Applets) > 0 {
+ for _, item := range data.Applets {
+ cBody := netconf.Body{}
+ if !item.Name.IsNull() && !item.Name.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "name", item.Name.ValueString())
+ }
+ if !item.Authorization.IsNull() && !item.Authorization.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "authorization", item.Authorization.ValueString())
+ }
+ if !item.Class.IsNull() && !item.Class.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "class", item.Class.ValueString())
+ }
+ if !item.Description.IsNull() && !item.Description.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "description", item.Description.ValueString())
+ }
+ if !item.EventCliPattern.IsNull() && !item.EventCliPattern.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "event/cli/pattern", item.EventCliPattern.ValueString())
+ }
+ if !item.EventCliSync.IsNull() && !item.EventCliSync.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "event/cli/sync", item.EventCliSync.ValueString())
+ }
+ if !item.EventCliSkip.IsNull() && !item.EventCliSkip.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "event/cli/skip", item.EventCliSkip.ValueString())
+ }
+ if len(item.Actions) > 0 {
+ for _, citem := range item.Actions {
+ ccBody := netconf.Body{}
+ if !citem.Name.IsNull() && !citem.Name.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "name", citem.Name.ValueString())
+ }
+ if !citem.CliCommand.IsNull() && !citem.CliCommand.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "cli-choice/command", citem.CliCommand.ValueString())
+ }
+ if !citem.RegexpStringPattern.IsNull() && !citem.RegexpStringPattern.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "regexp-option/string-pattern", citem.RegexpStringPattern.ValueString())
+ }
+ if !citem.RegexpStringInput.IsNull() && !citem.RegexpStringInput.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "regexp-option/string-input", citem.RegexpStringInput.ValueString())
+ }
+ if !citem.RegexpStringMatch.IsNull() && !citem.RegexpStringMatch.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "regexp-option/string-match", citem.RegexpStringMatch.ValueString())
+ }
+ if !citem.RegexpStringMatch1.IsNull() && !citem.RegexpStringMatch1.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "regexp-option/string-submatch1", citem.RegexpStringMatch1.ValueString())
+ }
+ if !citem.RegexpStringMatch2.IsNull() && !citem.RegexpStringMatch2.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "regexp-option/string-submatch2", citem.RegexpStringMatch2.ValueString())
+ }
+ if !citem.RegexpStringMatch3.IsNull() && !citem.RegexpStringMatch3.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "regexp-option/string-submatch3", citem.RegexpStringMatch3.ValueString())
+ }
+ if !citem.SyslogFacility.IsNull() && !citem.SyslogFacility.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "syslog-option/facility", citem.SyslogFacility.ValueString())
+ }
+ if !citem.SyslogMsg.IsNull() && !citem.SyslogMsg.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "syslog-option/msg", citem.SyslogMsg.ValueString())
+ }
+ if !citem.SyslogPriority.IsNull() && !citem.SyslogPriority.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "syslog-option/priority", citem.SyslogPriority.ValueString())
+ }
+ if !citem.SetVarname.IsNull() && !citem.SetVarname.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "set/varname", citem.SetVarname.ValueString())
+ }
+ if !citem.SetValue.IsNull() && !citem.SetValue.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "set/value", citem.SetValue.ValueString())
+ }
+ if !citem.IfStringOp1.IsNull() && !citem.IfStringOp1.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "if/string-op-1", citem.IfStringOp1.ValueString())
+ }
+ if !citem.IfKeyword.IsNull() && !citem.IfKeyword.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "if/keyword", citem.IfKeyword.ValueString())
+ }
+ if !citem.IfStringOp2.IsNull() && !citem.IfStringOp2.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "if/string-op-2", citem.IfStringOp2.ValueString())
+ }
+ if !citem.IfGoto.IsNull() && !citem.IfGoto.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "if/goto", citem.IfGoto.ValueString())
+ }
+ if !citem.ElseifOperand1.IsNull() && !citem.ElseifOperand1.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "elseif/operand1", citem.ElseifOperand1.ValueString())
+ }
+ if !citem.ElseifOperation.IsNull() && !citem.ElseifOperation.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "elseif/operation", citem.ElseifOperation.ValueString())
+ }
+ if !citem.ElseifOperand2.IsNull() && !citem.ElseifOperand2.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "elseif/operand2", citem.ElseifOperand2.ValueString())
+ }
+ if !citem.Else.IsNull() && !citem.Else.IsUnknown() {
+ if citem.Else.ValueBool() {
+ ccBody = helpers.SetFromXPath(ccBody, "else", "")
+ } else {
+ ccBody = helpers.RemoveFromXPath(ccBody, "else")
+ }
+ }
+ if !citem.WhileOperand1.IsNull() && !citem.WhileOperand1.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "while/operand1", citem.WhileOperand1.ValueString())
+ }
+ if !citem.WhileOperation.IsNull() && !citem.WhileOperation.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "while/operation", citem.WhileOperation.ValueString())
+ }
+ if !citem.WhileOperand2.IsNull() && !citem.WhileOperand2.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "while/operand2", citem.WhileOperand2.ValueString())
+ }
+ if !citem.Break.IsNull() && !citem.Break.IsUnknown() {
+ if citem.Break.ValueBool() {
+ ccBody = helpers.SetFromXPath(ccBody, "break", "")
+ } else {
+ ccBody = helpers.RemoveFromXPath(ccBody, "break")
+ }
+ }
+ if !citem.Continue.IsNull() && !citem.Continue.IsUnknown() {
+ if citem.Continue.ValueBool() {
+ ccBody = helpers.SetFromXPath(ccBody, "continue", "")
+ } else {
+ ccBody = helpers.RemoveFromXPath(ccBody, "continue")
+ }
+ }
+ if !citem.IncrementVarname.IsNull() && !citem.IncrementVarname.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "increment/varname", citem.IncrementVarname.ValueString())
+ }
+ if !citem.IncrementValue.IsNull() && !citem.IncrementValue.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "increment/value", citem.IncrementValue.ValueString())
+ }
+ if !citem.DecrementVarname.IsNull() && !citem.DecrementVarname.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "decrement/varname", citem.DecrementVarname.ValueString())
+ }
+ if !citem.DecrementValue.IsNull() && !citem.DecrementValue.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "decrement/value", citem.DecrementValue.ValueString())
+ }
+ if !citem.AppendVarname.IsNull() && !citem.AppendVarname.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "append/varname", citem.AppendVarname.ValueString())
+ }
+ if !citem.AppendValue.IsNull() && !citem.AppendValue.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "append/value", citem.AppendValue.ValueString())
+ }
+ if !citem.DivideOperand1.IsNull() && !citem.DivideOperand1.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "divide/operand1", citem.DivideOperand1.ValueString())
+ }
+ if !citem.DivideOperand2.IsNull() && !citem.DivideOperand2.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "divide/operand2", citem.DivideOperand2.ValueString())
+ }
+ if !citem.ForeachLoopvar.IsNull() && !citem.ForeachLoopvar.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "foreach/loopvar", citem.ForeachLoopvar.ValueString())
+ }
+ if !citem.ForeachIterator.IsNull() && !citem.ForeachIterator.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "foreach/iterator", citem.ForeachIterator.ValueString())
+ }
+ if !citem.ForeachDelimiter.IsNull() && !citem.ForeachDelimiter.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "foreach/delimiter", citem.ForeachDelimiter.ValueString())
+ }
+ if !citem.Gets.IsNull() && !citem.Gets.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "gets", citem.Gets.ValueString())
+ }
+ if !citem.Puts.IsNull() && !citem.Puts.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "puts", citem.Puts.ValueString())
+ }
+ if !citem.Wait.IsNull() && !citem.Wait.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "wait", strconv.FormatInt(citem.Wait.ValueInt64(), 10))
+ }
+ if !citem.End.IsNull() && !citem.End.IsUnknown() {
+ if citem.End.ValueBool() {
+ ccBody = helpers.SetFromXPath(ccBody, "end", "")
+ } else {
+ ccBody = helpers.RemoveFromXPath(ccBody, "end")
+ }
+ }
+ if !citem.Exit.IsNull() && !citem.Exit.IsUnknown() {
+ if citem.Exit.ValueBool() {
+ ccBody = helpers.SetFromXPath(ccBody, "exit", "")
+ } else {
+ ccBody = helpers.RemoveFromXPath(ccBody, "exit")
+ }
+ }
+ if !citem.Reload.IsNull() && !citem.Reload.IsUnknown() {
+ if citem.Reload.ValueBool() {
+ ccBody = helpers.SetFromXPath(ccBody, "reload", "")
+ } else {
+ ccBody = helpers.RemoveFromXPath(ccBody, "reload")
+ }
+ }
+ if !citem.ContextRetrieveKey.IsNull() && !citem.ContextRetrieveKey.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "context/retrieve/key", citem.ContextRetrieveKey.ValueString())
+ }
+ if !citem.ContextRetrieveVariable.IsNull() && !citem.ContextRetrieveVariable.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "context/retrieve/variable", citem.ContextRetrieveVariable.ValueString())
+ }
+ if !citem.ContextSaveKey.IsNull() && !citem.ContextSaveKey.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "context/save/key", citem.ContextSaveKey.ValueString())
+ }
+ if !citem.ContextSaveVariable.IsNull() && !citem.ContextSaveVariable.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "context/save/variable", citem.ContextSaveVariable.ValueString())
+ }
+ if !citem.StringTrim.IsNull() && !citem.StringTrim.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "string/trim", citem.StringTrim.ValueString())
+ }
+ if !citem.InfoTypeSnmpTrapEnterpriseOid.IsNull() && !citem.InfoTypeSnmpTrapEnterpriseOid.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "info/type/snmp/trap/enterprise-oid", citem.InfoTypeSnmpTrapEnterpriseOid.ValueString())
+ }
+ if !citem.InfoTypeSnmpTrapGenericTrapnum.IsNull() && !citem.InfoTypeSnmpTrapGenericTrapnum.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "info/type/snmp/trap/generic-trapnum", strconv.FormatInt(citem.InfoTypeSnmpTrapGenericTrapnum.ValueInt64(), 10))
+ }
+ if !citem.InfoTypeSnmpTrapSpecificTrapnum.IsNull() && !citem.InfoTypeSnmpTrapSpecificTrapnum.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "info/type/snmp/trap/specific-trapnum", strconv.FormatInt(citem.InfoTypeSnmpTrapSpecificTrapnum.ValueInt64(), 10))
+ }
+ if !citem.InfoTypeSnmpTrapTrapOid.IsNull() && !citem.InfoTypeSnmpTrapTrapOid.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "info/type/snmp/trap/trap-oid", citem.InfoTypeSnmpTrapTrapOid.ValueString())
+ }
+ if !citem.InfoTypeSnmpTrapTrapVar.IsNull() && !citem.InfoTypeSnmpTrapTrapVar.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "info/type/snmp/trap/trap-var", citem.InfoTypeSnmpTrapTrapVar.ValueString())
+ }
+ if !citem.HandleErrorType.IsNull() && !citem.HandleErrorType.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "handle-error/type", citem.HandleErrorType.ValueString())
+ }
+ if !citem.CounterName.IsNull() && !citem.CounterName.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "counter/name", citem.CounterName.ValueString())
+ }
+ if !citem.CounterValue.IsNull() && !citem.CounterValue.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "counter/value", strconv.FormatInt(citem.CounterValue.ValueInt64(), 10))
+ }
+ if !citem.CounterOpDec.IsNull() && !citem.CounterOpDec.IsUnknown() {
+ if citem.CounterOpDec.ValueBool() {
+ ccBody = helpers.SetFromXPath(ccBody, "counter/op/dec", "")
+ } else {
+ ccBody = helpers.RemoveFromXPath(ccBody, "counter/op/dec")
+ }
+ }
+ if !citem.CounterOpInc.IsNull() && !citem.CounterOpInc.IsUnknown() {
+ if citem.CounterOpInc.ValueBool() {
+ ccBody = helpers.SetFromXPath(ccBody, "counter/op/inc", "")
+ } else {
+ ccBody = helpers.RemoveFromXPath(ccBody, "counter/op/inc")
+ }
+ }
+ if !citem.CounterOpSet.IsNull() && !citem.CounterOpSet.IsUnknown() {
+ if citem.CounterOpSet.ValueBool() {
+ ccBody = helpers.SetFromXPath(ccBody, "counter/op/set", "")
+ } else {
+ ccBody = helpers.RemoveFromXPath(ccBody, "counter/op/set")
+ }
+ }
+ if !citem.CounterOpNop.IsNull() && !citem.CounterOpNop.IsUnknown() {
+ if citem.CounterOpNop.ValueBool() {
+ ccBody = helpers.SetFromXPath(ccBody, "counter/op/nop", "")
+ } else {
+ ccBody = helpers.RemoveFromXPath(ccBody, "counter/op/nop")
+ }
+ }
+ if !citem.SnmpTrapIntdata1.IsNull() && !citem.SnmpTrapIntdata1.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "snmp-trap/intdata1", strconv.FormatInt(citem.SnmpTrapIntdata1.ValueInt64(), 10))
+ }
+ if !citem.SnmpTrapIntdata2.IsNull() && !citem.SnmpTrapIntdata2.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "snmp-trap/intdata2", strconv.FormatInt(citem.SnmpTrapIntdata2.ValueInt64(), 10))
+ }
+ if !citem.SnmpTrapStrdata.IsNull() && !citem.SnmpTrapStrdata.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "snmp-trap/strdata", citem.SnmpTrapStrdata.ValueString())
+ }
+ if !citem.InfoTypeSnmpVar.IsNull() && !citem.InfoTypeSnmpVar.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "info/type/snmp/var/variable-name", citem.InfoTypeSnmpVar.ValueString())
+ }
+ if !citem.InfoTypeSnmpVarOid.IsNull() && !citem.InfoTypeSnmpVarOid.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "info/type/snmp/var/oid", citem.InfoTypeSnmpVarOid.ValueString())
+ }
+ if !citem.InfoTypeSnmpVarOidType.IsNull() && !citem.InfoTypeSnmpVarOidType.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "info/type/snmp/var/oid-type", citem.InfoTypeSnmpVarOidType.ValueString())
+ }
+ if !citem.InfoTypeSnmpVarOidTypeValue.IsNull() && !citem.InfoTypeSnmpVarOidTypeValue.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "info/type/snmp/var/oid-type-value", citem.InfoTypeSnmpVarOidTypeValue.ValueString())
+ }
+ if !citem.StringTrimFirstStringOp1.IsNull() && !citem.StringTrimFirstStringOp1.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "string/trim/first/string-op-1", citem.StringTrimFirstStringOp1.ValueString())
+ }
+ if !citem.StringTrimFirstStringOp2.IsNull() && !citem.StringTrimFirstStringOp2.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "string/trim/first/string-op-2", citem.StringTrimFirstStringOp2.ValueString())
+ }
+ cBody = helpers.SetRawFromXPath(cBody, "action-config/action", ccBody.Res())
+ }
+ }
+ if !item.EventTimerWatchdogTime.IsNull() && !item.EventTimerWatchdogTime.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "event/timer-choice/watchdog/time-set", strconv.FormatFloat(item.EventTimerWatchdogTime.ValueFloat64(), 'f', 1, 64))
+ }
+ if !item.EventTimerWatchdogName.IsNull() && !item.EventTimerWatchdogName.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "event/timer-choice/watchdog/name", item.EventTimerWatchdogName.ValueString())
+ }
+ if !item.EventTimerWatchdogMaxrun.IsNull() && !item.EventTimerWatchdogMaxrun.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "event/timer-choice/watchdog/maxrun-set", strconv.FormatFloat(item.EventTimerWatchdogMaxrun.ValueFloat64(), 'f', 1, 64))
+ }
+ if !item.EventTimerWatchdogRatelimit.IsNull() && !item.EventTimerWatchdogRatelimit.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "event/timer-choice/watchdog/ratelimit-set", strconv.FormatFloat(item.EventTimerWatchdogRatelimit.ValueFloat64(), 'f', 1, 64))
+ }
+ if !item.EventTimerCronEntry.IsNull() && !item.EventTimerCronEntry.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "event/timer-choice/cron/cron-entry", item.EventTimerCronEntry.ValueString())
+ }
+ if !item.EventTimerCronName.IsNull() && !item.EventTimerCronName.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "event/timer-choice/cron/name", item.EventTimerCronName.ValueString())
+ }
+ if !item.EventTimerCronMaxrun.IsNull() && !item.EventTimerCronMaxrun.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "event/timer-choice/cron/maxrun-set", strconv.FormatFloat(item.EventTimerCronMaxrun.ValueFloat64(), 'f', 1, 64))
+ }
+ if !item.EventTimerCronRatelimit.IsNull() && !item.EventTimerCronRatelimit.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "event/timer-choice/cron/ratelimit-set", strconv.FormatFloat(item.EventTimerCronRatelimit.ValueFloat64(), 'f', 1, 64))
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/applet", cBody.Res())
+ }
+ }
+ bodyString, err := body.String()
+ if err != nil {
+ tflog.Error(ctx, fmt.Sprintf("Error converting body to string: %s", err))
+ }
+ return bodyString
+}
+
+// End of section. //template:end toBodyXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBody
func (data *EEM) updateFromBody(ctx context.Context, res gjson.Result) {
@@ -1120,696 +1494,2396 @@ func (data *EEM) updateFromBody(ctx context.Context, res gjson.Result) {
// End of section. //template:end updateFromBody
-// Section below is generated&owned by "gen/generator.go". //template:begin fromBody
+// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBodyXML
-func (data *EEM) fromBody(ctx context.Context, res gjson.Result) {
- prefix := helpers.LastElement(data.getPath()) + "."
- if res.Get(helpers.LastElement(data.getPath())).IsArray() {
- prefix += "0."
- }
- if value := res.Get(prefix + "environment"); value.Exists() {
- data.EnvironmentVariables = make([]EEMEnvironmentVariables, 0)
- value.ForEach(func(k, v gjson.Result) bool {
- item := EEMEnvironmentVariables{}
- if cValue := v.Get("name"); cValue.Exists() {
- item.Name = types.StringValue(cValue.String())
- }
- if cValue := v.Get("value"); cValue.Exists() {
- item.Value = types.StringValue(cValue.String())
- }
- data.EnvironmentVariables = append(data.EnvironmentVariables, item)
- return true
- })
- }
- if value := res.Get(prefix + "session.cli.username.username_in_word_set"); value.Exists() {
- data.SessionCliUsername = types.StringValue(value.String())
- }
- if value := res.Get(prefix + "session.cli.username.privilege_set"); value.Exists() {
- data.SessionCliUsernamePrivilege = types.Int64Value(value.Int())
+func (data *EEM) updateFromBodyXML(ctx context.Context, res xmldot.Result) {
+ for i := range data.EnvironmentVariables {
+ keys := [...]string{"name"}
+ keyValues := [...]string{data.EnvironmentVariables[i].Name.ValueString()}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/environment").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, "name"); value.Exists() && !data.EnvironmentVariables[i].Name.IsNull() {
+ data.EnvironmentVariables[i].Name = types.StringValue(value.String())
+ } else {
+ data.EnvironmentVariables[i].Name = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "value"); value.Exists() && !data.EnvironmentVariables[i].Value.IsNull() {
+ data.EnvironmentVariables[i].Value = types.StringValue(value.String())
+ } else {
+ data.EnvironmentVariables[i].Value = types.StringNull()
+ }
}
- if value := res.Get(prefix + "history.size.events"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/session/cli/username/username_in_word_set"); value.Exists() && !data.SessionCliUsername.IsNull() {
+ data.SessionCliUsername = types.StringValue(value.String())
+ } else {
+ data.SessionCliUsername = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/session/cli/username/privilege_set"); value.Exists() && !data.SessionCliUsernamePrivilege.IsNull() {
+ data.SessionCliUsernamePrivilege = types.Int64Value(value.Int())
+ } else {
+ data.SessionCliUsernamePrivilege = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/history/size/events"); value.Exists() && !data.HistorySizeEvents.IsNull() {
data.HistorySizeEvents = types.Int64Value(value.Int())
+ } else {
+ data.HistorySizeEvents = types.Int64Null()
}
- if value := res.Get(prefix + "history.size.traps"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/history/size/traps"); value.Exists() && !data.HistorySizeTraps.IsNull() {
data.HistorySizeTraps = types.Int64Value(value.Int())
+ } else {
+ data.HistorySizeTraps = types.Int64Null()
}
- if value := res.Get(prefix + "directory.user.policy"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/directory/user/policy"); value.Exists() && !data.DirectoryUserPolicy.IsNull() {
data.DirectoryUserPolicy = types.StringValue(value.String())
+ } else {
+ data.DirectoryUserPolicy = types.StringNull()
}
- if value := res.Get(prefix + "scheduler.applet.thread.class.default"); value.Exists() {
- data.SchedulerAppletThreadClassDefault = types.BoolValue(true)
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/scheduler/applet/thread/class/default"); !data.SchedulerAppletThreadClassDefault.IsNull() {
+ if value.Exists() {
+ data.SchedulerAppletThreadClassDefault = types.BoolValue(true)
+ } else {
+ data.SchedulerAppletThreadClassDefault = types.BoolValue(false)
+ }
} else {
- data.SchedulerAppletThreadClassDefault = types.BoolValue(false)
+ data.SchedulerAppletThreadClassDefault = types.BoolNull()
}
- if value := res.Get(prefix + "scheduler.applet.thread.class.number"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/scheduler/applet/thread/class/number"); value.Exists() && !data.SchedulerAppletThreadClassNumber.IsNull() {
data.SchedulerAppletThreadClassNumber = types.Int64Value(value.Int())
+ } else {
+ data.SchedulerAppletThreadClassNumber = types.Int64Null()
}
- if value := res.Get(prefix + "detector.rpc.max-sessions"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/detector/rpc/max-sessions"); value.Exists() && !data.DetectorRpcMaxSessions.IsNull() {
data.DetectorRpcMaxSessions = types.Int64Value(value.Int())
+ } else {
+ data.DetectorRpcMaxSessions = types.Int64Null()
}
- if value := res.Get(prefix + "detector.routing.bootup-delay"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/detector/routing/bootup-delay"); value.Exists() && !data.DetectorRoutingBootupDelay.IsNull() {
data.DetectorRoutingBootupDelay = types.Float64Value(value.Float())
+ } else {
+ data.DetectorRoutingBootupDelay = types.Float64Null()
}
- if value := res.Get(prefix + "applet"); value.Exists() {
- data.Applets = make([]EEMApplets, 0)
- value.ForEach(func(k, v gjson.Result) bool {
- item := EEMApplets{}
- if cValue := v.Get("name"); cValue.Exists() {
- item.Name = types.StringValue(cValue.String())
+ for i := range data.Applets {
+ keys := [...]string{"name"}
+ keyValues := [...]string{data.Applets[i].Name.ValueString()}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/applet").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, "name"); value.Exists() && !data.Applets[i].Name.IsNull() {
+ data.Applets[i].Name = types.StringValue(value.String())
+ } else {
+ data.Applets[i].Name = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "authorization"); value.Exists() && !data.Applets[i].Authorization.IsNull() {
+ data.Applets[i].Authorization = types.StringValue(value.String())
+ } else {
+ data.Applets[i].Authorization = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "class"); value.Exists() && !data.Applets[i].Class.IsNull() {
+ data.Applets[i].Class = types.StringValue(value.String())
+ } else {
+ data.Applets[i].Class = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "description"); value.Exists() && !data.Applets[i].Description.IsNull() {
+ data.Applets[i].Description = types.StringValue(value.String())
+ } else {
+ data.Applets[i].Description = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "event/cli/pattern"); value.Exists() && !data.Applets[i].EventCliPattern.IsNull() {
+ data.Applets[i].EventCliPattern = types.StringValue(value.String())
+ } else {
+ data.Applets[i].EventCliPattern = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "event/cli/sync"); value.Exists() && !data.Applets[i].EventCliSync.IsNull() {
+ data.Applets[i].EventCliSync = types.StringValue(value.String())
+ } else {
+ data.Applets[i].EventCliSync = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "event/cli/skip"); value.Exists() && !data.Applets[i].EventCliSkip.IsNull() {
+ data.Applets[i].EventCliSkip = types.StringValue(value.String())
+ } else {
+ data.Applets[i].EventCliSkip = types.StringNull()
+ }
+ for ci := range data.Applets[i].Actions {
+ keys := [...]string{"name"}
+ keyValues := [...]string{data.Applets[i].Actions[ci].Name.ValueString()}
+
+ var cr xmldot.Result
+ helpers.GetFromXPath(r, "action-config/action").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ cr = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(cr, "name"); value.Exists() && !data.Applets[i].Actions[ci].Name.IsNull() {
+ data.Applets[i].Actions[ci].Name = types.StringValue(value.String())
+ } else {
+ data.Applets[i].Actions[ci].Name = types.StringNull()
}
- if cValue := v.Get("authorization"); cValue.Exists() {
- item.Authorization = types.StringValue(cValue.String())
+ if value := helpers.GetFromXPath(cr, "cli-choice/command"); value.Exists() && !data.Applets[i].Actions[ci].CliCommand.IsNull() {
+ data.Applets[i].Actions[ci].CliCommand = types.StringValue(value.String())
+ } else {
+ data.Applets[i].Actions[ci].CliCommand = types.StringNull()
}
- if cValue := v.Get("class"); cValue.Exists() {
- item.Class = types.StringValue(cValue.String())
+ if value := helpers.GetFromXPath(cr, "regexp-option/string-pattern"); value.Exists() && !data.Applets[i].Actions[ci].RegexpStringPattern.IsNull() {
+ data.Applets[i].Actions[ci].RegexpStringPattern = types.StringValue(value.String())
+ } else {
+ data.Applets[i].Actions[ci].RegexpStringPattern = types.StringNull()
}
- if cValue := v.Get("description"); cValue.Exists() {
- item.Description = types.StringValue(cValue.String())
+ if value := helpers.GetFromXPath(cr, "regexp-option/string-input"); value.Exists() && !data.Applets[i].Actions[ci].RegexpStringInput.IsNull() {
+ data.Applets[i].Actions[ci].RegexpStringInput = types.StringValue(value.String())
+ } else {
+ data.Applets[i].Actions[ci].RegexpStringInput = types.StringNull()
}
- if cValue := v.Get("event.cli.pattern"); cValue.Exists() {
- item.EventCliPattern = types.StringValue(cValue.String())
+ if value := helpers.GetFromXPath(cr, "regexp-option/string-match"); value.Exists() && !data.Applets[i].Actions[ci].RegexpStringMatch.IsNull() {
+ data.Applets[i].Actions[ci].RegexpStringMatch = types.StringValue(value.String())
+ } else {
+ data.Applets[i].Actions[ci].RegexpStringMatch = types.StringNull()
}
- if cValue := v.Get("event.cli.sync"); cValue.Exists() {
- item.EventCliSync = types.StringValue(cValue.String())
+ if value := helpers.GetFromXPath(cr, "regexp-option/string-submatch1"); value.Exists() && !data.Applets[i].Actions[ci].RegexpStringMatch1.IsNull() {
+ data.Applets[i].Actions[ci].RegexpStringMatch1 = types.StringValue(value.String())
+ } else {
+ data.Applets[i].Actions[ci].RegexpStringMatch1 = types.StringNull()
}
- if cValue := v.Get("event.cli.skip"); cValue.Exists() {
- item.EventCliSkip = types.StringValue(cValue.String())
+ if value := helpers.GetFromXPath(cr, "regexp-option/string-submatch2"); value.Exists() && !data.Applets[i].Actions[ci].RegexpStringMatch2.IsNull() {
+ data.Applets[i].Actions[ci].RegexpStringMatch2 = types.StringValue(value.String())
+ } else {
+ data.Applets[i].Actions[ci].RegexpStringMatch2 = types.StringNull()
}
- if cValue := v.Get("action-config.action"); cValue.Exists() {
- item.Actions = make([]EEMAppletsActions, 0)
- cValue.ForEach(func(ck, cv gjson.Result) bool {
- cItem := EEMAppletsActions{}
- if ccValue := cv.Get("name"); ccValue.Exists() {
- cItem.Name = types.StringValue(ccValue.String())
- }
- if ccValue := cv.Get("cli-choice.command"); ccValue.Exists() {
- cItem.CliCommand = types.StringValue(ccValue.String())
- }
- if ccValue := cv.Get("regexp-option.string-pattern"); ccValue.Exists() {
- cItem.RegexpStringPattern = types.StringValue(ccValue.String())
- }
- if ccValue := cv.Get("regexp-option.string-input"); ccValue.Exists() {
- cItem.RegexpStringInput = types.StringValue(ccValue.String())
- }
- if ccValue := cv.Get("regexp-option.string-match"); ccValue.Exists() {
- cItem.RegexpStringMatch = types.StringValue(ccValue.String())
- }
- if ccValue := cv.Get("regexp-option.string-submatch1"); ccValue.Exists() {
- cItem.RegexpStringMatch1 = types.StringValue(ccValue.String())
- }
- if ccValue := cv.Get("regexp-option.string-submatch2"); ccValue.Exists() {
- cItem.RegexpStringMatch2 = types.StringValue(ccValue.String())
- }
- if ccValue := cv.Get("regexp-option.string-submatch3"); ccValue.Exists() {
- cItem.RegexpStringMatch3 = types.StringValue(ccValue.String())
- }
- if ccValue := cv.Get("syslog-option.facility"); ccValue.Exists() {
- cItem.SyslogFacility = types.StringValue(ccValue.String())
- }
- if ccValue := cv.Get("syslog-option.msg"); ccValue.Exists() {
- cItem.SyslogMsg = types.StringValue(ccValue.String())
- }
- if ccValue := cv.Get("syslog-option.priority"); ccValue.Exists() {
- cItem.SyslogPriority = types.StringValue(ccValue.String())
- }
- if ccValue := cv.Get("set.varname"); ccValue.Exists() {
- cItem.SetVarname = types.StringValue(ccValue.String())
- }
- if ccValue := cv.Get("set.value"); ccValue.Exists() {
- cItem.SetValue = types.StringValue(ccValue.String())
- }
- if ccValue := cv.Get("if.string-op-1"); ccValue.Exists() {
- cItem.IfStringOp1 = types.StringValue(ccValue.String())
- }
- if ccValue := cv.Get("if.keyword"); ccValue.Exists() {
- cItem.IfKeyword = types.StringValue(ccValue.String())
- }
- if ccValue := cv.Get("if.string-op-2"); ccValue.Exists() {
- cItem.IfStringOp2 = types.StringValue(ccValue.String())
- }
- if ccValue := cv.Get("if.goto"); ccValue.Exists() {
- cItem.IfGoto = types.StringValue(ccValue.String())
- }
- if ccValue := cv.Get("elseif.operand1"); ccValue.Exists() {
- cItem.ElseifOperand1 = types.StringValue(ccValue.String())
- }
- if ccValue := cv.Get("elseif.operation"); ccValue.Exists() {
- cItem.ElseifOperation = types.StringValue(ccValue.String())
- }
- if ccValue := cv.Get("elseif.operand2"); ccValue.Exists() {
- cItem.ElseifOperand2 = types.StringValue(ccValue.String())
- }
- if ccValue := cv.Get("else"); ccValue.Exists() {
- cItem.Else = types.BoolValue(true)
- } else {
- cItem.Else = types.BoolValue(false)
- }
- if ccValue := cv.Get("while.operand1"); ccValue.Exists() {
- cItem.WhileOperand1 = types.StringValue(ccValue.String())
- }
- if ccValue := cv.Get("while.operation"); ccValue.Exists() {
- cItem.WhileOperation = types.StringValue(ccValue.String())
- }
- if ccValue := cv.Get("while.operand2"); ccValue.Exists() {
- cItem.WhileOperand2 = types.StringValue(ccValue.String())
- }
- if ccValue := cv.Get("break"); ccValue.Exists() {
- cItem.Break = types.BoolValue(true)
- } else {
- cItem.Break = types.BoolValue(false)
- }
- if ccValue := cv.Get("continue"); ccValue.Exists() {
- cItem.Continue = types.BoolValue(true)
- } else {
- cItem.Continue = types.BoolValue(false)
- }
- if ccValue := cv.Get("increment.varname"); ccValue.Exists() {
- cItem.IncrementVarname = types.StringValue(ccValue.String())
- }
- if ccValue := cv.Get("increment.value"); ccValue.Exists() {
- cItem.IncrementValue = types.StringValue(ccValue.String())
- }
- if ccValue := cv.Get("decrement.varname"); ccValue.Exists() {
- cItem.DecrementVarname = types.StringValue(ccValue.String())
- }
- if ccValue := cv.Get("decrement.value"); ccValue.Exists() {
- cItem.DecrementValue = types.StringValue(ccValue.String())
- }
- if ccValue := cv.Get("append.varname"); ccValue.Exists() {
- cItem.AppendVarname = types.StringValue(ccValue.String())
- }
- if ccValue := cv.Get("append.value"); ccValue.Exists() {
- cItem.AppendValue = types.StringValue(ccValue.String())
- }
- if ccValue := cv.Get("divide.operand1"); ccValue.Exists() {
- cItem.DivideOperand1 = types.StringValue(ccValue.String())
- }
- if ccValue := cv.Get("divide.operand2"); ccValue.Exists() {
- cItem.DivideOperand2 = types.StringValue(ccValue.String())
- }
- if ccValue := cv.Get("foreach.loopvar"); ccValue.Exists() {
- cItem.ForeachLoopvar = types.StringValue(ccValue.String())
- }
- if ccValue := cv.Get("foreach.iterator"); ccValue.Exists() {
- cItem.ForeachIterator = types.StringValue(ccValue.String())
- }
- if ccValue := cv.Get("foreach.delimiter"); ccValue.Exists() {
- cItem.ForeachDelimiter = types.StringValue(ccValue.String())
- }
- if ccValue := cv.Get("gets"); ccValue.Exists() {
- cItem.Gets = types.StringValue(ccValue.String())
- }
- if ccValue := cv.Get("puts"); ccValue.Exists() {
- cItem.Puts = types.StringValue(ccValue.String())
- }
- if ccValue := cv.Get("wait"); ccValue.Exists() {
- cItem.Wait = types.Int64Value(ccValue.Int())
- }
- if ccValue := cv.Get("end"); ccValue.Exists() {
- cItem.End = types.BoolValue(true)
- } else {
- cItem.End = types.BoolValue(false)
- }
- if ccValue := cv.Get("exit"); ccValue.Exists() {
- cItem.Exit = types.BoolValue(true)
- } else {
- cItem.Exit = types.BoolValue(false)
- }
- if ccValue := cv.Get("reload"); ccValue.Exists() {
- cItem.Reload = types.BoolValue(true)
- } else {
- cItem.Reload = types.BoolValue(false)
- }
- if ccValue := cv.Get("context.retrieve.key"); ccValue.Exists() {
- cItem.ContextRetrieveKey = types.StringValue(ccValue.String())
- }
- if ccValue := cv.Get("context.retrieve.variable"); ccValue.Exists() {
- cItem.ContextRetrieveVariable = types.StringValue(ccValue.String())
- }
- if ccValue := cv.Get("context.save.key"); ccValue.Exists() {
- cItem.ContextSaveKey = types.StringValue(ccValue.String())
- }
- if ccValue := cv.Get("context.save.variable"); ccValue.Exists() {
- cItem.ContextSaveVariable = types.StringValue(ccValue.String())
- }
- if ccValue := cv.Get("string.trim"); ccValue.Exists() {
- cItem.StringTrim = types.StringValue(ccValue.String())
- }
- if ccValue := cv.Get("info.type.snmp.trap.enterprise-oid"); ccValue.Exists() {
- cItem.InfoTypeSnmpTrapEnterpriseOid = types.StringValue(ccValue.String())
- }
- if ccValue := cv.Get("info.type.snmp.trap.generic-trapnum"); ccValue.Exists() {
- cItem.InfoTypeSnmpTrapGenericTrapnum = types.Int64Value(ccValue.Int())
- }
- if ccValue := cv.Get("info.type.snmp.trap.specific-trapnum"); ccValue.Exists() {
- cItem.InfoTypeSnmpTrapSpecificTrapnum = types.Int64Value(ccValue.Int())
- }
- if ccValue := cv.Get("info.type.snmp.trap.trap-oid"); ccValue.Exists() {
- cItem.InfoTypeSnmpTrapTrapOid = types.StringValue(ccValue.String())
- }
- if ccValue := cv.Get("info.type.snmp.trap.trap-var"); ccValue.Exists() {
- cItem.InfoTypeSnmpTrapTrapVar = types.StringValue(ccValue.String())
- }
- if ccValue := cv.Get("handle-error.type"); ccValue.Exists() {
- cItem.HandleErrorType = types.StringValue(ccValue.String())
- }
- if ccValue := cv.Get("counter.name"); ccValue.Exists() {
- cItem.CounterName = types.StringValue(ccValue.String())
- }
- if ccValue := cv.Get("counter.value"); ccValue.Exists() {
- cItem.CounterValue = types.Int64Value(ccValue.Int())
- }
- if ccValue := cv.Get("counter.op.dec"); ccValue.Exists() {
- cItem.CounterOpDec = types.BoolValue(true)
- } else {
- cItem.CounterOpDec = types.BoolValue(false)
- }
- if ccValue := cv.Get("counter.op.inc"); ccValue.Exists() {
- cItem.CounterOpInc = types.BoolValue(true)
- } else {
- cItem.CounterOpInc = types.BoolValue(false)
- }
- if ccValue := cv.Get("counter.op.set"); ccValue.Exists() {
- cItem.CounterOpSet = types.BoolValue(true)
- } else {
- cItem.CounterOpSet = types.BoolValue(false)
- }
- if ccValue := cv.Get("counter.op.nop"); ccValue.Exists() {
- cItem.CounterOpNop = types.BoolValue(true)
- } else {
- cItem.CounterOpNop = types.BoolValue(false)
- }
- if ccValue := cv.Get("snmp-trap.intdata1"); ccValue.Exists() {
- cItem.SnmpTrapIntdata1 = types.Int64Value(ccValue.Int())
- }
- if ccValue := cv.Get("snmp-trap.intdata2"); ccValue.Exists() {
- cItem.SnmpTrapIntdata2 = types.Int64Value(ccValue.Int())
- }
- if ccValue := cv.Get("snmp-trap.strdata"); ccValue.Exists() {
- cItem.SnmpTrapStrdata = types.StringValue(ccValue.String())
- }
- if ccValue := cv.Get("info.type.snmp.var.variable-name"); ccValue.Exists() {
- cItem.InfoTypeSnmpVar = types.StringValue(ccValue.String())
- }
- if ccValue := cv.Get("info.type.snmp.var.oid"); ccValue.Exists() {
- cItem.InfoTypeSnmpVarOid = types.StringValue(ccValue.String())
- }
- if ccValue := cv.Get("info.type.snmp.var.oid-type"); ccValue.Exists() {
- cItem.InfoTypeSnmpVarOidType = types.StringValue(ccValue.String())
- }
- if ccValue := cv.Get("info.type.snmp.var.oid-type-value"); ccValue.Exists() {
- cItem.InfoTypeSnmpVarOidTypeValue = types.StringValue(ccValue.String())
- }
- if ccValue := cv.Get("string.trim.first.string-op-1"); ccValue.Exists() {
- cItem.StringTrimFirstStringOp1 = types.StringValue(ccValue.String())
- }
- if ccValue := cv.Get("string.trim.first.string-op-2"); ccValue.Exists() {
- cItem.StringTrimFirstStringOp2 = types.StringValue(ccValue.String())
- }
- item.Actions = append(item.Actions, cItem)
- return true
- })
+ if value := helpers.GetFromXPath(cr, "regexp-option/string-submatch3"); value.Exists() && !data.Applets[i].Actions[ci].RegexpStringMatch3.IsNull() {
+ data.Applets[i].Actions[ci].RegexpStringMatch3 = types.StringValue(value.String())
+ } else {
+ data.Applets[i].Actions[ci].RegexpStringMatch3 = types.StringNull()
}
- if cValue := v.Get("event.timer-choice.watchdog.time-set"); cValue.Exists() {
- item.EventTimerWatchdogTime = types.Float64Value(cValue.Float())
+ if value := helpers.GetFromXPath(cr, "syslog-option/facility"); value.Exists() && !data.Applets[i].Actions[ci].SyslogFacility.IsNull() {
+ data.Applets[i].Actions[ci].SyslogFacility = types.StringValue(value.String())
+ } else {
+ data.Applets[i].Actions[ci].SyslogFacility = types.StringNull()
}
- if cValue := v.Get("event.timer-choice.watchdog.name"); cValue.Exists() {
- item.EventTimerWatchdogName = types.StringValue(cValue.String())
+ if value := helpers.GetFromXPath(cr, "syslog-option/msg"); value.Exists() && !data.Applets[i].Actions[ci].SyslogMsg.IsNull() {
+ data.Applets[i].Actions[ci].SyslogMsg = types.StringValue(value.String())
+ } else {
+ data.Applets[i].Actions[ci].SyslogMsg = types.StringNull()
}
- if cValue := v.Get("event.timer-choice.watchdog.maxrun-set"); cValue.Exists() {
- item.EventTimerWatchdogMaxrun = types.Float64Value(cValue.Float())
+ if value := helpers.GetFromXPath(cr, "syslog-option/priority"); value.Exists() && !data.Applets[i].Actions[ci].SyslogPriority.IsNull() {
+ data.Applets[i].Actions[ci].SyslogPriority = types.StringValue(value.String())
+ } else {
+ data.Applets[i].Actions[ci].SyslogPriority = types.StringNull()
}
- if cValue := v.Get("event.timer-choice.watchdog.ratelimit-set"); cValue.Exists() {
- item.EventTimerWatchdogRatelimit = types.Float64Value(cValue.Float())
+ if value := helpers.GetFromXPath(cr, "set/varname"); value.Exists() && !data.Applets[i].Actions[ci].SetVarname.IsNull() {
+ data.Applets[i].Actions[ci].SetVarname = types.StringValue(value.String())
+ } else {
+ data.Applets[i].Actions[ci].SetVarname = types.StringNull()
}
- if cValue := v.Get("event.timer-choice.cron.cron-entry"); cValue.Exists() {
- item.EventTimerCronEntry = types.StringValue(cValue.String())
+ if value := helpers.GetFromXPath(cr, "set/value"); value.Exists() && !data.Applets[i].Actions[ci].SetValue.IsNull() {
+ data.Applets[i].Actions[ci].SetValue = types.StringValue(value.String())
+ } else {
+ data.Applets[i].Actions[ci].SetValue = types.StringNull()
}
- if cValue := v.Get("event.timer-choice.cron.name"); cValue.Exists() {
- item.EventTimerCronName = types.StringValue(cValue.String())
+ if value := helpers.GetFromXPath(cr, "if/string-op-1"); value.Exists() && !data.Applets[i].Actions[ci].IfStringOp1.IsNull() {
+ data.Applets[i].Actions[ci].IfStringOp1 = types.StringValue(value.String())
+ } else {
+ data.Applets[i].Actions[ci].IfStringOp1 = types.StringNull()
}
- if cValue := v.Get("event.timer-choice.cron.maxrun-set"); cValue.Exists() {
- item.EventTimerCronMaxrun = types.Float64Value(cValue.Float())
+ if value := helpers.GetFromXPath(cr, "if/keyword"); value.Exists() && !data.Applets[i].Actions[ci].IfKeyword.IsNull() {
+ data.Applets[i].Actions[ci].IfKeyword = types.StringValue(value.String())
+ } else {
+ data.Applets[i].Actions[ci].IfKeyword = types.StringNull()
}
- if cValue := v.Get("event.timer-choice.cron.ratelimit-set"); cValue.Exists() {
- item.EventTimerCronRatelimit = types.Float64Value(cValue.Float())
+ if value := helpers.GetFromXPath(cr, "if/string-op-2"); value.Exists() && !data.Applets[i].Actions[ci].IfStringOp2.IsNull() {
+ data.Applets[i].Actions[ci].IfStringOp2 = types.StringValue(value.String())
+ } else {
+ data.Applets[i].Actions[ci].IfStringOp2 = types.StringNull()
}
- data.Applets = append(data.Applets, item)
- return true
- })
- }
-}
-
-// End of section. //template:end fromBody
-
-// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyData
-
-func (data *EEMData) fromBody(ctx context.Context, res gjson.Result) {
- prefix := helpers.LastElement(data.getPath()) + "."
- if res.Get(helpers.LastElement(data.getPath())).IsArray() {
- prefix += "0."
- }
- if value := res.Get(prefix + "environment"); value.Exists() {
- data.EnvironmentVariables = make([]EEMEnvironmentVariables, 0)
- value.ForEach(func(k, v gjson.Result) bool {
- item := EEMEnvironmentVariables{}
- if cValue := v.Get("name"); cValue.Exists() {
- item.Name = types.StringValue(cValue.String())
+ if value := helpers.GetFromXPath(cr, "if/goto"); value.Exists() && !data.Applets[i].Actions[ci].IfGoto.IsNull() {
+ data.Applets[i].Actions[ci].IfGoto = types.StringValue(value.String())
+ } else {
+ data.Applets[i].Actions[ci].IfGoto = types.StringNull()
}
- if cValue := v.Get("value"); cValue.Exists() {
- item.Value = types.StringValue(cValue.String())
+ if value := helpers.GetFromXPath(cr, "elseif/operand1"); value.Exists() && !data.Applets[i].Actions[ci].ElseifOperand1.IsNull() {
+ data.Applets[i].Actions[ci].ElseifOperand1 = types.StringValue(value.String())
+ } else {
+ data.Applets[i].Actions[ci].ElseifOperand1 = types.StringNull()
}
- data.EnvironmentVariables = append(data.EnvironmentVariables, item)
- return true
- })
- }
- if value := res.Get(prefix + "session.cli.username.username_in_word_set"); value.Exists() {
- data.SessionCliUsername = types.StringValue(value.String())
- }
- if value := res.Get(prefix + "session.cli.username.privilege_set"); value.Exists() {
- data.SessionCliUsernamePrivilege = types.Int64Value(value.Int())
- }
- if value := res.Get(prefix + "history.size.events"); value.Exists() {
- data.HistorySizeEvents = types.Int64Value(value.Int())
- }
- if value := res.Get(prefix + "history.size.traps"); value.Exists() {
- data.HistorySizeTraps = types.Int64Value(value.Int())
- }
- if value := res.Get(prefix + "directory.user.policy"); value.Exists() {
- data.DirectoryUserPolicy = types.StringValue(value.String())
- }
- if value := res.Get(prefix + "scheduler.applet.thread.class.default"); value.Exists() {
- data.SchedulerAppletThreadClassDefault = types.BoolValue(true)
- } else {
- data.SchedulerAppletThreadClassDefault = types.BoolValue(false)
- }
- if value := res.Get(prefix + "scheduler.applet.thread.class.number"); value.Exists() {
- data.SchedulerAppletThreadClassNumber = types.Int64Value(value.Int())
- }
- if value := res.Get(prefix + "detector.rpc.max-sessions"); value.Exists() {
- data.DetectorRpcMaxSessions = types.Int64Value(value.Int())
- }
- if value := res.Get(prefix + "detector.routing.bootup-delay"); value.Exists() {
- data.DetectorRoutingBootupDelay = types.Float64Value(value.Float())
- }
- if value := res.Get(prefix + "applet"); value.Exists() {
- data.Applets = make([]EEMApplets, 0)
- value.ForEach(func(k, v gjson.Result) bool {
- item := EEMApplets{}
- if cValue := v.Get("name"); cValue.Exists() {
- item.Name = types.StringValue(cValue.String())
+ if value := helpers.GetFromXPath(cr, "elseif/operation"); value.Exists() && !data.Applets[i].Actions[ci].ElseifOperation.IsNull() {
+ data.Applets[i].Actions[ci].ElseifOperation = types.StringValue(value.String())
+ } else {
+ data.Applets[i].Actions[ci].ElseifOperation = types.StringNull()
}
- if cValue := v.Get("authorization"); cValue.Exists() {
- item.Authorization = types.StringValue(cValue.String())
+ if value := helpers.GetFromXPath(cr, "elseif/operand2"); value.Exists() && !data.Applets[i].Actions[ci].ElseifOperand2.IsNull() {
+ data.Applets[i].Actions[ci].ElseifOperand2 = types.StringValue(value.String())
+ } else {
+ data.Applets[i].Actions[ci].ElseifOperand2 = types.StringNull()
}
- if cValue := v.Get("class"); cValue.Exists() {
- item.Class = types.StringValue(cValue.String())
+ if value := helpers.GetFromXPath(cr, "else"); !data.Applets[i].Actions[ci].Else.IsNull() {
+ if value.Exists() {
+ data.Applets[i].Actions[ci].Else = types.BoolValue(true)
+ } else {
+ data.Applets[i].Actions[ci].Else = types.BoolValue(false)
+ }
+ } else {
+ data.Applets[i].Actions[ci].Else = types.BoolNull()
}
- if cValue := v.Get("description"); cValue.Exists() {
- item.Description = types.StringValue(cValue.String())
+ if value := helpers.GetFromXPath(cr, "while/operand1"); value.Exists() && !data.Applets[i].Actions[ci].WhileOperand1.IsNull() {
+ data.Applets[i].Actions[ci].WhileOperand1 = types.StringValue(value.String())
+ } else {
+ data.Applets[i].Actions[ci].WhileOperand1 = types.StringNull()
}
- if cValue := v.Get("event.cli.pattern"); cValue.Exists() {
- item.EventCliPattern = types.StringValue(cValue.String())
+ if value := helpers.GetFromXPath(cr, "while/operation"); value.Exists() && !data.Applets[i].Actions[ci].WhileOperation.IsNull() {
+ data.Applets[i].Actions[ci].WhileOperation = types.StringValue(value.String())
+ } else {
+ data.Applets[i].Actions[ci].WhileOperation = types.StringNull()
}
- if cValue := v.Get("event.cli.sync"); cValue.Exists() {
- item.EventCliSync = types.StringValue(cValue.String())
+ if value := helpers.GetFromXPath(cr, "while/operand2"); value.Exists() && !data.Applets[i].Actions[ci].WhileOperand2.IsNull() {
+ data.Applets[i].Actions[ci].WhileOperand2 = types.StringValue(value.String())
+ } else {
+ data.Applets[i].Actions[ci].WhileOperand2 = types.StringNull()
}
- if cValue := v.Get("event.cli.skip"); cValue.Exists() {
- item.EventCliSkip = types.StringValue(cValue.String())
+ if value := helpers.GetFromXPath(cr, "break"); !data.Applets[i].Actions[ci].Break.IsNull() {
+ if value.Exists() {
+ data.Applets[i].Actions[ci].Break = types.BoolValue(true)
+ } else {
+ data.Applets[i].Actions[ci].Break = types.BoolValue(false)
+ }
+ } else {
+ data.Applets[i].Actions[ci].Break = types.BoolNull()
}
- if cValue := v.Get("action-config.action"); cValue.Exists() {
- item.Actions = make([]EEMAppletsActions, 0)
- cValue.ForEach(func(ck, cv gjson.Result) bool {
- cItem := EEMAppletsActions{}
- if ccValue := cv.Get("name"); ccValue.Exists() {
- cItem.Name = types.StringValue(ccValue.String())
- }
- if ccValue := cv.Get("cli-choice.command"); ccValue.Exists() {
- cItem.CliCommand = types.StringValue(ccValue.String())
- }
- if ccValue := cv.Get("regexp-option.string-pattern"); ccValue.Exists() {
- cItem.RegexpStringPattern = types.StringValue(ccValue.String())
- }
- if ccValue := cv.Get("regexp-option.string-input"); ccValue.Exists() {
- cItem.RegexpStringInput = types.StringValue(ccValue.String())
- }
- if ccValue := cv.Get("regexp-option.string-match"); ccValue.Exists() {
- cItem.RegexpStringMatch = types.StringValue(ccValue.String())
- }
- if ccValue := cv.Get("regexp-option.string-submatch1"); ccValue.Exists() {
- cItem.RegexpStringMatch1 = types.StringValue(ccValue.String())
- }
- if ccValue := cv.Get("regexp-option.string-submatch2"); ccValue.Exists() {
- cItem.RegexpStringMatch2 = types.StringValue(ccValue.String())
- }
- if ccValue := cv.Get("regexp-option.string-submatch3"); ccValue.Exists() {
- cItem.RegexpStringMatch3 = types.StringValue(ccValue.String())
- }
- if ccValue := cv.Get("syslog-option.facility"); ccValue.Exists() {
- cItem.SyslogFacility = types.StringValue(ccValue.String())
- }
- if ccValue := cv.Get("syslog-option.msg"); ccValue.Exists() {
- cItem.SyslogMsg = types.StringValue(ccValue.String())
- }
- if ccValue := cv.Get("syslog-option.priority"); ccValue.Exists() {
- cItem.SyslogPriority = types.StringValue(ccValue.String())
- }
- if ccValue := cv.Get("set.varname"); ccValue.Exists() {
- cItem.SetVarname = types.StringValue(ccValue.String())
- }
- if ccValue := cv.Get("set.value"); ccValue.Exists() {
- cItem.SetValue = types.StringValue(ccValue.String())
- }
- if ccValue := cv.Get("if.string-op-1"); ccValue.Exists() {
- cItem.IfStringOp1 = types.StringValue(ccValue.String())
- }
- if ccValue := cv.Get("if.keyword"); ccValue.Exists() {
- cItem.IfKeyword = types.StringValue(ccValue.String())
- }
- if ccValue := cv.Get("if.string-op-2"); ccValue.Exists() {
- cItem.IfStringOp2 = types.StringValue(ccValue.String())
- }
- if ccValue := cv.Get("if.goto"); ccValue.Exists() {
- cItem.IfGoto = types.StringValue(ccValue.String())
- }
- if ccValue := cv.Get("elseif.operand1"); ccValue.Exists() {
- cItem.ElseifOperand1 = types.StringValue(ccValue.String())
- }
- if ccValue := cv.Get("elseif.operation"); ccValue.Exists() {
- cItem.ElseifOperation = types.StringValue(ccValue.String())
- }
- if ccValue := cv.Get("elseif.operand2"); ccValue.Exists() {
- cItem.ElseifOperand2 = types.StringValue(ccValue.String())
- }
- if ccValue := cv.Get("else"); ccValue.Exists() {
- cItem.Else = types.BoolValue(true)
- } else {
- cItem.Else = types.BoolValue(false)
- }
- if ccValue := cv.Get("while.operand1"); ccValue.Exists() {
- cItem.WhileOperand1 = types.StringValue(ccValue.String())
- }
- if ccValue := cv.Get("while.operation"); ccValue.Exists() {
- cItem.WhileOperation = types.StringValue(ccValue.String())
- }
- if ccValue := cv.Get("while.operand2"); ccValue.Exists() {
- cItem.WhileOperand2 = types.StringValue(ccValue.String())
- }
- if ccValue := cv.Get("break"); ccValue.Exists() {
- cItem.Break = types.BoolValue(true)
- } else {
- cItem.Break = types.BoolValue(false)
- }
- if ccValue := cv.Get("continue"); ccValue.Exists() {
- cItem.Continue = types.BoolValue(true)
- } else {
- cItem.Continue = types.BoolValue(false)
- }
- if ccValue := cv.Get("increment.varname"); ccValue.Exists() {
- cItem.IncrementVarname = types.StringValue(ccValue.String())
- }
- if ccValue := cv.Get("increment.value"); ccValue.Exists() {
- cItem.IncrementValue = types.StringValue(ccValue.String())
- }
- if ccValue := cv.Get("decrement.varname"); ccValue.Exists() {
- cItem.DecrementVarname = types.StringValue(ccValue.String())
- }
- if ccValue := cv.Get("decrement.value"); ccValue.Exists() {
- cItem.DecrementValue = types.StringValue(ccValue.String())
- }
- if ccValue := cv.Get("append.varname"); ccValue.Exists() {
- cItem.AppendVarname = types.StringValue(ccValue.String())
- }
- if ccValue := cv.Get("append.value"); ccValue.Exists() {
- cItem.AppendValue = types.StringValue(ccValue.String())
- }
- if ccValue := cv.Get("divide.operand1"); ccValue.Exists() {
- cItem.DivideOperand1 = types.StringValue(ccValue.String())
- }
- if ccValue := cv.Get("divide.operand2"); ccValue.Exists() {
- cItem.DivideOperand2 = types.StringValue(ccValue.String())
- }
- if ccValue := cv.Get("foreach.loopvar"); ccValue.Exists() {
- cItem.ForeachLoopvar = types.StringValue(ccValue.String())
- }
- if ccValue := cv.Get("foreach.iterator"); ccValue.Exists() {
- cItem.ForeachIterator = types.StringValue(ccValue.String())
- }
- if ccValue := cv.Get("foreach.delimiter"); ccValue.Exists() {
- cItem.ForeachDelimiter = types.StringValue(ccValue.String())
- }
- if ccValue := cv.Get("gets"); ccValue.Exists() {
- cItem.Gets = types.StringValue(ccValue.String())
- }
- if ccValue := cv.Get("puts"); ccValue.Exists() {
- cItem.Puts = types.StringValue(ccValue.String())
- }
- if ccValue := cv.Get("wait"); ccValue.Exists() {
- cItem.Wait = types.Int64Value(ccValue.Int())
- }
- if ccValue := cv.Get("end"); ccValue.Exists() {
- cItem.End = types.BoolValue(true)
- } else {
- cItem.End = types.BoolValue(false)
- }
- if ccValue := cv.Get("exit"); ccValue.Exists() {
- cItem.Exit = types.BoolValue(true)
- } else {
- cItem.Exit = types.BoolValue(false)
- }
- if ccValue := cv.Get("reload"); ccValue.Exists() {
- cItem.Reload = types.BoolValue(true)
- } else {
- cItem.Reload = types.BoolValue(false)
- }
- if ccValue := cv.Get("context.retrieve.key"); ccValue.Exists() {
- cItem.ContextRetrieveKey = types.StringValue(ccValue.String())
- }
- if ccValue := cv.Get("context.retrieve.variable"); ccValue.Exists() {
- cItem.ContextRetrieveVariable = types.StringValue(ccValue.String())
- }
- if ccValue := cv.Get("context.save.key"); ccValue.Exists() {
- cItem.ContextSaveKey = types.StringValue(ccValue.String())
- }
- if ccValue := cv.Get("context.save.variable"); ccValue.Exists() {
- cItem.ContextSaveVariable = types.StringValue(ccValue.String())
- }
- if ccValue := cv.Get("string.trim"); ccValue.Exists() {
- cItem.StringTrim = types.StringValue(ccValue.String())
- }
- if ccValue := cv.Get("info.type.snmp.trap.enterprise-oid"); ccValue.Exists() {
- cItem.InfoTypeSnmpTrapEnterpriseOid = types.StringValue(ccValue.String())
- }
- if ccValue := cv.Get("info.type.snmp.trap.generic-trapnum"); ccValue.Exists() {
- cItem.InfoTypeSnmpTrapGenericTrapnum = types.Int64Value(ccValue.Int())
- }
- if ccValue := cv.Get("info.type.snmp.trap.specific-trapnum"); ccValue.Exists() {
- cItem.InfoTypeSnmpTrapSpecificTrapnum = types.Int64Value(ccValue.Int())
- }
- if ccValue := cv.Get("info.type.snmp.trap.trap-oid"); ccValue.Exists() {
- cItem.InfoTypeSnmpTrapTrapOid = types.StringValue(ccValue.String())
- }
- if ccValue := cv.Get("info.type.snmp.trap.trap-var"); ccValue.Exists() {
- cItem.InfoTypeSnmpTrapTrapVar = types.StringValue(ccValue.String())
- }
- if ccValue := cv.Get("handle-error.type"); ccValue.Exists() {
- cItem.HandleErrorType = types.StringValue(ccValue.String())
- }
- if ccValue := cv.Get("counter.name"); ccValue.Exists() {
- cItem.CounterName = types.StringValue(ccValue.String())
- }
- if ccValue := cv.Get("counter.value"); ccValue.Exists() {
- cItem.CounterValue = types.Int64Value(ccValue.Int())
- }
- if ccValue := cv.Get("counter.op.dec"); ccValue.Exists() {
- cItem.CounterOpDec = types.BoolValue(true)
- } else {
- cItem.CounterOpDec = types.BoolValue(false)
- }
- if ccValue := cv.Get("counter.op.inc"); ccValue.Exists() {
- cItem.CounterOpInc = types.BoolValue(true)
- } else {
- cItem.CounterOpInc = types.BoolValue(false)
- }
- if ccValue := cv.Get("counter.op.set"); ccValue.Exists() {
- cItem.CounterOpSet = types.BoolValue(true)
- } else {
- cItem.CounterOpSet = types.BoolValue(false)
- }
- if ccValue := cv.Get("counter.op.nop"); ccValue.Exists() {
- cItem.CounterOpNop = types.BoolValue(true)
- } else {
- cItem.CounterOpNop = types.BoolValue(false)
- }
- if ccValue := cv.Get("snmp-trap.intdata1"); ccValue.Exists() {
- cItem.SnmpTrapIntdata1 = types.Int64Value(ccValue.Int())
- }
- if ccValue := cv.Get("snmp-trap.intdata2"); ccValue.Exists() {
- cItem.SnmpTrapIntdata2 = types.Int64Value(ccValue.Int())
- }
- if ccValue := cv.Get("snmp-trap.strdata"); ccValue.Exists() {
- cItem.SnmpTrapStrdata = types.StringValue(ccValue.String())
+ if value := helpers.GetFromXPath(cr, "continue"); !data.Applets[i].Actions[ci].Continue.IsNull() {
+ if value.Exists() {
+ data.Applets[i].Actions[ci].Continue = types.BoolValue(true)
+ } else {
+ data.Applets[i].Actions[ci].Continue = types.BoolValue(false)
+ }
+ } else {
+ data.Applets[i].Actions[ci].Continue = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(cr, "increment/varname"); value.Exists() && !data.Applets[i].Actions[ci].IncrementVarname.IsNull() {
+ data.Applets[i].Actions[ci].IncrementVarname = types.StringValue(value.String())
+ } else {
+ data.Applets[i].Actions[ci].IncrementVarname = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(cr, "increment/value"); value.Exists() && !data.Applets[i].Actions[ci].IncrementValue.IsNull() {
+ data.Applets[i].Actions[ci].IncrementValue = types.StringValue(value.String())
+ } else {
+ data.Applets[i].Actions[ci].IncrementValue = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(cr, "decrement/varname"); value.Exists() && !data.Applets[i].Actions[ci].DecrementVarname.IsNull() {
+ data.Applets[i].Actions[ci].DecrementVarname = types.StringValue(value.String())
+ } else {
+ data.Applets[i].Actions[ci].DecrementVarname = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(cr, "decrement/value"); value.Exists() && !data.Applets[i].Actions[ci].DecrementValue.IsNull() {
+ data.Applets[i].Actions[ci].DecrementValue = types.StringValue(value.String())
+ } else {
+ data.Applets[i].Actions[ci].DecrementValue = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(cr, "append/varname"); value.Exists() && !data.Applets[i].Actions[ci].AppendVarname.IsNull() {
+ data.Applets[i].Actions[ci].AppendVarname = types.StringValue(value.String())
+ } else {
+ data.Applets[i].Actions[ci].AppendVarname = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(cr, "append/value"); value.Exists() && !data.Applets[i].Actions[ci].AppendValue.IsNull() {
+ data.Applets[i].Actions[ci].AppendValue = types.StringValue(value.String())
+ } else {
+ data.Applets[i].Actions[ci].AppendValue = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(cr, "divide/operand1"); value.Exists() && !data.Applets[i].Actions[ci].DivideOperand1.IsNull() {
+ data.Applets[i].Actions[ci].DivideOperand1 = types.StringValue(value.String())
+ } else {
+ data.Applets[i].Actions[ci].DivideOperand1 = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(cr, "divide/operand2"); value.Exists() && !data.Applets[i].Actions[ci].DivideOperand2.IsNull() {
+ data.Applets[i].Actions[ci].DivideOperand2 = types.StringValue(value.String())
+ } else {
+ data.Applets[i].Actions[ci].DivideOperand2 = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(cr, "foreach/loopvar"); value.Exists() && !data.Applets[i].Actions[ci].ForeachLoopvar.IsNull() {
+ data.Applets[i].Actions[ci].ForeachLoopvar = types.StringValue(value.String())
+ } else {
+ data.Applets[i].Actions[ci].ForeachLoopvar = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(cr, "foreach/iterator"); value.Exists() && !data.Applets[i].Actions[ci].ForeachIterator.IsNull() {
+ data.Applets[i].Actions[ci].ForeachIterator = types.StringValue(value.String())
+ } else {
+ data.Applets[i].Actions[ci].ForeachIterator = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(cr, "foreach/delimiter"); value.Exists() && !data.Applets[i].Actions[ci].ForeachDelimiter.IsNull() {
+ data.Applets[i].Actions[ci].ForeachDelimiter = types.StringValue(value.String())
+ } else {
+ data.Applets[i].Actions[ci].ForeachDelimiter = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(cr, "gets"); value.Exists() && !data.Applets[i].Actions[ci].Gets.IsNull() {
+ data.Applets[i].Actions[ci].Gets = types.StringValue(value.String())
+ } else {
+ data.Applets[i].Actions[ci].Gets = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(cr, "puts"); value.Exists() && !data.Applets[i].Actions[ci].Puts.IsNull() {
+ data.Applets[i].Actions[ci].Puts = types.StringValue(value.String())
+ } else {
+ data.Applets[i].Actions[ci].Puts = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(cr, "wait"); value.Exists() && !data.Applets[i].Actions[ci].Wait.IsNull() {
+ data.Applets[i].Actions[ci].Wait = types.Int64Value(value.Int())
+ } else {
+ data.Applets[i].Actions[ci].Wait = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(cr, "end"); !data.Applets[i].Actions[ci].End.IsNull() {
+ if value.Exists() {
+ data.Applets[i].Actions[ci].End = types.BoolValue(true)
+ } else {
+ data.Applets[i].Actions[ci].End = types.BoolValue(false)
+ }
+ } else {
+ data.Applets[i].Actions[ci].End = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(cr, "exit"); !data.Applets[i].Actions[ci].Exit.IsNull() {
+ if value.Exists() {
+ data.Applets[i].Actions[ci].Exit = types.BoolValue(true)
+ } else {
+ data.Applets[i].Actions[ci].Exit = types.BoolValue(false)
+ }
+ } else {
+ data.Applets[i].Actions[ci].Exit = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(cr, "reload"); !data.Applets[i].Actions[ci].Reload.IsNull() {
+ if value.Exists() {
+ data.Applets[i].Actions[ci].Reload = types.BoolValue(true)
+ } else {
+ data.Applets[i].Actions[ci].Reload = types.BoolValue(false)
+ }
+ } else {
+ data.Applets[i].Actions[ci].Reload = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(cr, "context/retrieve/key"); value.Exists() && !data.Applets[i].Actions[ci].ContextRetrieveKey.IsNull() {
+ data.Applets[i].Actions[ci].ContextRetrieveKey = types.StringValue(value.String())
+ } else {
+ data.Applets[i].Actions[ci].ContextRetrieveKey = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(cr, "context/retrieve/variable"); value.Exists() && !data.Applets[i].Actions[ci].ContextRetrieveVariable.IsNull() {
+ data.Applets[i].Actions[ci].ContextRetrieveVariable = types.StringValue(value.String())
+ } else {
+ data.Applets[i].Actions[ci].ContextRetrieveVariable = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(cr, "context/save/key"); value.Exists() && !data.Applets[i].Actions[ci].ContextSaveKey.IsNull() {
+ data.Applets[i].Actions[ci].ContextSaveKey = types.StringValue(value.String())
+ } else {
+ data.Applets[i].Actions[ci].ContextSaveKey = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(cr, "context/save/variable"); value.Exists() && !data.Applets[i].Actions[ci].ContextSaveVariable.IsNull() {
+ data.Applets[i].Actions[ci].ContextSaveVariable = types.StringValue(value.String())
+ } else {
+ data.Applets[i].Actions[ci].ContextSaveVariable = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(cr, "string/trim"); value.Exists() && !data.Applets[i].Actions[ci].StringTrim.IsNull() {
+ data.Applets[i].Actions[ci].StringTrim = types.StringValue(value.String())
+ } else {
+ data.Applets[i].Actions[ci].StringTrim = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(cr, "info/type/snmp/trap/enterprise-oid"); value.Exists() && !data.Applets[i].Actions[ci].InfoTypeSnmpTrapEnterpriseOid.IsNull() {
+ data.Applets[i].Actions[ci].InfoTypeSnmpTrapEnterpriseOid = types.StringValue(value.String())
+ } else {
+ data.Applets[i].Actions[ci].InfoTypeSnmpTrapEnterpriseOid = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(cr, "info/type/snmp/trap/generic-trapnum"); value.Exists() && !data.Applets[i].Actions[ci].InfoTypeSnmpTrapGenericTrapnum.IsNull() {
+ data.Applets[i].Actions[ci].InfoTypeSnmpTrapGenericTrapnum = types.Int64Value(value.Int())
+ } else {
+ data.Applets[i].Actions[ci].InfoTypeSnmpTrapGenericTrapnum = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(cr, "info/type/snmp/trap/specific-trapnum"); value.Exists() && !data.Applets[i].Actions[ci].InfoTypeSnmpTrapSpecificTrapnum.IsNull() {
+ data.Applets[i].Actions[ci].InfoTypeSnmpTrapSpecificTrapnum = types.Int64Value(value.Int())
+ } else {
+ data.Applets[i].Actions[ci].InfoTypeSnmpTrapSpecificTrapnum = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(cr, "info/type/snmp/trap/trap-oid"); value.Exists() && !data.Applets[i].Actions[ci].InfoTypeSnmpTrapTrapOid.IsNull() {
+ data.Applets[i].Actions[ci].InfoTypeSnmpTrapTrapOid = types.StringValue(value.String())
+ } else {
+ data.Applets[i].Actions[ci].InfoTypeSnmpTrapTrapOid = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(cr, "info/type/snmp/trap/trap-var"); value.Exists() && !data.Applets[i].Actions[ci].InfoTypeSnmpTrapTrapVar.IsNull() {
+ data.Applets[i].Actions[ci].InfoTypeSnmpTrapTrapVar = types.StringValue(value.String())
+ } else {
+ data.Applets[i].Actions[ci].InfoTypeSnmpTrapTrapVar = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(cr, "handle-error/type"); value.Exists() && !data.Applets[i].Actions[ci].HandleErrorType.IsNull() {
+ data.Applets[i].Actions[ci].HandleErrorType = types.StringValue(value.String())
+ } else {
+ data.Applets[i].Actions[ci].HandleErrorType = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(cr, "counter/name"); value.Exists() && !data.Applets[i].Actions[ci].CounterName.IsNull() {
+ data.Applets[i].Actions[ci].CounterName = types.StringValue(value.String())
+ } else {
+ data.Applets[i].Actions[ci].CounterName = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(cr, "counter/value"); value.Exists() && !data.Applets[i].Actions[ci].CounterValue.IsNull() {
+ data.Applets[i].Actions[ci].CounterValue = types.Int64Value(value.Int())
+ } else {
+ data.Applets[i].Actions[ci].CounterValue = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(cr, "counter/op/dec"); !data.Applets[i].Actions[ci].CounterOpDec.IsNull() {
+ if value.Exists() {
+ data.Applets[i].Actions[ci].CounterOpDec = types.BoolValue(true)
+ } else {
+ data.Applets[i].Actions[ci].CounterOpDec = types.BoolValue(false)
+ }
+ } else {
+ data.Applets[i].Actions[ci].CounterOpDec = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(cr, "counter/op/inc"); !data.Applets[i].Actions[ci].CounterOpInc.IsNull() {
+ if value.Exists() {
+ data.Applets[i].Actions[ci].CounterOpInc = types.BoolValue(true)
+ } else {
+ data.Applets[i].Actions[ci].CounterOpInc = types.BoolValue(false)
+ }
+ } else {
+ data.Applets[i].Actions[ci].CounterOpInc = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(cr, "counter/op/set"); !data.Applets[i].Actions[ci].CounterOpSet.IsNull() {
+ if value.Exists() {
+ data.Applets[i].Actions[ci].CounterOpSet = types.BoolValue(true)
+ } else {
+ data.Applets[i].Actions[ci].CounterOpSet = types.BoolValue(false)
+ }
+ } else {
+ data.Applets[i].Actions[ci].CounterOpSet = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(cr, "counter/op/nop"); !data.Applets[i].Actions[ci].CounterOpNop.IsNull() {
+ if value.Exists() {
+ data.Applets[i].Actions[ci].CounterOpNop = types.BoolValue(true)
+ } else {
+ data.Applets[i].Actions[ci].CounterOpNop = types.BoolValue(false)
+ }
+ } else {
+ data.Applets[i].Actions[ci].CounterOpNop = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(cr, "snmp-trap/intdata1"); value.Exists() && !data.Applets[i].Actions[ci].SnmpTrapIntdata1.IsNull() {
+ data.Applets[i].Actions[ci].SnmpTrapIntdata1 = types.Int64Value(value.Int())
+ } else {
+ data.Applets[i].Actions[ci].SnmpTrapIntdata1 = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(cr, "snmp-trap/intdata2"); value.Exists() && !data.Applets[i].Actions[ci].SnmpTrapIntdata2.IsNull() {
+ data.Applets[i].Actions[ci].SnmpTrapIntdata2 = types.Int64Value(value.Int())
+ } else {
+ data.Applets[i].Actions[ci].SnmpTrapIntdata2 = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(cr, "snmp-trap/strdata"); value.Exists() && !data.Applets[i].Actions[ci].SnmpTrapStrdata.IsNull() {
+ data.Applets[i].Actions[ci].SnmpTrapStrdata = types.StringValue(value.String())
+ } else {
+ data.Applets[i].Actions[ci].SnmpTrapStrdata = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(cr, "info/type/snmp/var/variable-name"); value.Exists() && !data.Applets[i].Actions[ci].InfoTypeSnmpVar.IsNull() {
+ data.Applets[i].Actions[ci].InfoTypeSnmpVar = types.StringValue(value.String())
+ } else {
+ data.Applets[i].Actions[ci].InfoTypeSnmpVar = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(cr, "info/type/snmp/var/oid"); value.Exists() && !data.Applets[i].Actions[ci].InfoTypeSnmpVarOid.IsNull() {
+ data.Applets[i].Actions[ci].InfoTypeSnmpVarOid = types.StringValue(value.String())
+ } else {
+ data.Applets[i].Actions[ci].InfoTypeSnmpVarOid = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(cr, "info/type/snmp/var/oid-type"); value.Exists() && !data.Applets[i].Actions[ci].InfoTypeSnmpVarOidType.IsNull() {
+ data.Applets[i].Actions[ci].InfoTypeSnmpVarOidType = types.StringValue(value.String())
+ } else {
+ data.Applets[i].Actions[ci].InfoTypeSnmpVarOidType = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(cr, "info/type/snmp/var/oid-type-value"); value.Exists() && !data.Applets[i].Actions[ci].InfoTypeSnmpVarOidTypeValue.IsNull() {
+ data.Applets[i].Actions[ci].InfoTypeSnmpVarOidTypeValue = types.StringValue(value.String())
+ } else {
+ data.Applets[i].Actions[ci].InfoTypeSnmpVarOidTypeValue = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(cr, "string/trim/first/string-op-1"); value.Exists() && !data.Applets[i].Actions[ci].StringTrimFirstStringOp1.IsNull() {
+ data.Applets[i].Actions[ci].StringTrimFirstStringOp1 = types.StringValue(value.String())
+ } else {
+ data.Applets[i].Actions[ci].StringTrimFirstStringOp1 = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(cr, "string/trim/first/string-op-2"); value.Exists() && !data.Applets[i].Actions[ci].StringTrimFirstStringOp2.IsNull() {
+ data.Applets[i].Actions[ci].StringTrimFirstStringOp2 = types.StringValue(value.String())
+ } else {
+ data.Applets[i].Actions[ci].StringTrimFirstStringOp2 = types.StringNull()
+ }
+ }
+ if value := helpers.GetFromXPath(r, "event/timer-choice/watchdog/time-set"); value.Exists() && !data.Applets[i].EventTimerWatchdogTime.IsNull() {
+ data.Applets[i].EventTimerWatchdogTime = types.Float64Value(value.Float())
+ } else {
+ data.Applets[i].EventTimerWatchdogTime = types.Float64Null()
+ }
+ if value := helpers.GetFromXPath(r, "event/timer-choice/watchdog/name"); value.Exists() && !data.Applets[i].EventTimerWatchdogName.IsNull() {
+ data.Applets[i].EventTimerWatchdogName = types.StringValue(value.String())
+ } else {
+ data.Applets[i].EventTimerWatchdogName = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "event/timer-choice/watchdog/maxrun-set"); value.Exists() && !data.Applets[i].EventTimerWatchdogMaxrun.IsNull() {
+ data.Applets[i].EventTimerWatchdogMaxrun = types.Float64Value(value.Float())
+ } else {
+ data.Applets[i].EventTimerWatchdogMaxrun = types.Float64Null()
+ }
+ if value := helpers.GetFromXPath(r, "event/timer-choice/watchdog/ratelimit-set"); value.Exists() && !data.Applets[i].EventTimerWatchdogRatelimit.IsNull() {
+ data.Applets[i].EventTimerWatchdogRatelimit = types.Float64Value(value.Float())
+ } else {
+ data.Applets[i].EventTimerWatchdogRatelimit = types.Float64Null()
+ }
+ if value := helpers.GetFromXPath(r, "event/timer-choice/cron/cron-entry"); value.Exists() && !data.Applets[i].EventTimerCronEntry.IsNull() {
+ data.Applets[i].EventTimerCronEntry = types.StringValue(value.String())
+ } else {
+ data.Applets[i].EventTimerCronEntry = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "event/timer-choice/cron/name"); value.Exists() && !data.Applets[i].EventTimerCronName.IsNull() {
+ data.Applets[i].EventTimerCronName = types.StringValue(value.String())
+ } else {
+ data.Applets[i].EventTimerCronName = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "event/timer-choice/cron/maxrun-set"); value.Exists() && !data.Applets[i].EventTimerCronMaxrun.IsNull() {
+ data.Applets[i].EventTimerCronMaxrun = types.Float64Value(value.Float())
+ } else {
+ data.Applets[i].EventTimerCronMaxrun = types.Float64Null()
+ }
+ if value := helpers.GetFromXPath(r, "event/timer-choice/cron/ratelimit-set"); value.Exists() && !data.Applets[i].EventTimerCronRatelimit.IsNull() {
+ data.Applets[i].EventTimerCronRatelimit = types.Float64Value(value.Float())
+ } else {
+ data.Applets[i].EventTimerCronRatelimit = types.Float64Null()
+ }
+ }
+}
+
+// End of section. //template:end updateFromBodyXML
+
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBody
+
+func (data *EEM) fromBody(ctx context.Context, res gjson.Result) {
+ prefix := helpers.LastElement(data.getPath()) + "."
+ if res.Get(helpers.LastElement(data.getPath())).IsArray() {
+ prefix += "0."
+ }
+ if value := res.Get(prefix + "environment"); value.Exists() {
+ data.EnvironmentVariables = make([]EEMEnvironmentVariables, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := EEMEnvironmentVariables{}
+ if cValue := v.Get("name"); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("value"); cValue.Exists() {
+ item.Value = types.StringValue(cValue.String())
+ }
+ data.EnvironmentVariables = append(data.EnvironmentVariables, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + "session.cli.username.username_in_word_set"); value.Exists() {
+ data.SessionCliUsername = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "session.cli.username.privilege_set"); value.Exists() {
+ data.SessionCliUsernamePrivilege = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "history.size.events"); value.Exists() {
+ data.HistorySizeEvents = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "history.size.traps"); value.Exists() {
+ data.HistorySizeTraps = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "directory.user.policy"); value.Exists() {
+ data.DirectoryUserPolicy = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "scheduler.applet.thread.class.default"); value.Exists() {
+ data.SchedulerAppletThreadClassDefault = types.BoolValue(true)
+ } else {
+ data.SchedulerAppletThreadClassDefault = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "scheduler.applet.thread.class.number"); value.Exists() {
+ data.SchedulerAppletThreadClassNumber = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "detector.rpc.max-sessions"); value.Exists() {
+ data.DetectorRpcMaxSessions = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "detector.routing.bootup-delay"); value.Exists() {
+ data.DetectorRoutingBootupDelay = types.Float64Value(value.Float())
+ }
+ if value := res.Get(prefix + "applet"); value.Exists() {
+ data.Applets = make([]EEMApplets, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := EEMApplets{}
+ if cValue := v.Get("name"); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("authorization"); cValue.Exists() {
+ item.Authorization = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("class"); cValue.Exists() {
+ item.Class = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("description"); cValue.Exists() {
+ item.Description = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("event.cli.pattern"); cValue.Exists() {
+ item.EventCliPattern = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("event.cli.sync"); cValue.Exists() {
+ item.EventCliSync = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("event.cli.skip"); cValue.Exists() {
+ item.EventCliSkip = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("action-config.action"); cValue.Exists() {
+ item.Actions = make([]EEMAppletsActions, 0)
+ cValue.ForEach(func(ck, cv gjson.Result) bool {
+ cItem := EEMAppletsActions{}
+ if ccValue := cv.Get("name"); ccValue.Exists() {
+ cItem.Name = types.StringValue(ccValue.String())
+ }
+ if ccValue := cv.Get("cli-choice.command"); ccValue.Exists() {
+ cItem.CliCommand = types.StringValue(ccValue.String())
+ }
+ if ccValue := cv.Get("regexp-option.string-pattern"); ccValue.Exists() {
+ cItem.RegexpStringPattern = types.StringValue(ccValue.String())
+ }
+ if ccValue := cv.Get("regexp-option.string-input"); ccValue.Exists() {
+ cItem.RegexpStringInput = types.StringValue(ccValue.String())
+ }
+ if ccValue := cv.Get("regexp-option.string-match"); ccValue.Exists() {
+ cItem.RegexpStringMatch = types.StringValue(ccValue.String())
+ }
+ if ccValue := cv.Get("regexp-option.string-submatch1"); ccValue.Exists() {
+ cItem.RegexpStringMatch1 = types.StringValue(ccValue.String())
+ }
+ if ccValue := cv.Get("regexp-option.string-submatch2"); ccValue.Exists() {
+ cItem.RegexpStringMatch2 = types.StringValue(ccValue.String())
+ }
+ if ccValue := cv.Get("regexp-option.string-submatch3"); ccValue.Exists() {
+ cItem.RegexpStringMatch3 = types.StringValue(ccValue.String())
+ }
+ if ccValue := cv.Get("syslog-option.facility"); ccValue.Exists() {
+ cItem.SyslogFacility = types.StringValue(ccValue.String())
+ }
+ if ccValue := cv.Get("syslog-option.msg"); ccValue.Exists() {
+ cItem.SyslogMsg = types.StringValue(ccValue.String())
+ }
+ if ccValue := cv.Get("syslog-option.priority"); ccValue.Exists() {
+ cItem.SyslogPriority = types.StringValue(ccValue.String())
+ }
+ if ccValue := cv.Get("set.varname"); ccValue.Exists() {
+ cItem.SetVarname = types.StringValue(ccValue.String())
+ }
+ if ccValue := cv.Get("set.value"); ccValue.Exists() {
+ cItem.SetValue = types.StringValue(ccValue.String())
+ }
+ if ccValue := cv.Get("if.string-op-1"); ccValue.Exists() {
+ cItem.IfStringOp1 = types.StringValue(ccValue.String())
+ }
+ if ccValue := cv.Get("if.keyword"); ccValue.Exists() {
+ cItem.IfKeyword = types.StringValue(ccValue.String())
+ }
+ if ccValue := cv.Get("if.string-op-2"); ccValue.Exists() {
+ cItem.IfStringOp2 = types.StringValue(ccValue.String())
+ }
+ if ccValue := cv.Get("if.goto"); ccValue.Exists() {
+ cItem.IfGoto = types.StringValue(ccValue.String())
+ }
+ if ccValue := cv.Get("elseif.operand1"); ccValue.Exists() {
+ cItem.ElseifOperand1 = types.StringValue(ccValue.String())
+ }
+ if ccValue := cv.Get("elseif.operation"); ccValue.Exists() {
+ cItem.ElseifOperation = types.StringValue(ccValue.String())
+ }
+ if ccValue := cv.Get("elseif.operand2"); ccValue.Exists() {
+ cItem.ElseifOperand2 = types.StringValue(ccValue.String())
+ }
+ if ccValue := cv.Get("else"); ccValue.Exists() {
+ cItem.Else = types.BoolValue(true)
+ } else {
+ cItem.Else = types.BoolValue(false)
+ }
+ if ccValue := cv.Get("while.operand1"); ccValue.Exists() {
+ cItem.WhileOperand1 = types.StringValue(ccValue.String())
+ }
+ if ccValue := cv.Get("while.operation"); ccValue.Exists() {
+ cItem.WhileOperation = types.StringValue(ccValue.String())
+ }
+ if ccValue := cv.Get("while.operand2"); ccValue.Exists() {
+ cItem.WhileOperand2 = types.StringValue(ccValue.String())
+ }
+ if ccValue := cv.Get("break"); ccValue.Exists() {
+ cItem.Break = types.BoolValue(true)
+ } else {
+ cItem.Break = types.BoolValue(false)
+ }
+ if ccValue := cv.Get("continue"); ccValue.Exists() {
+ cItem.Continue = types.BoolValue(true)
+ } else {
+ cItem.Continue = types.BoolValue(false)
+ }
+ if ccValue := cv.Get("increment.varname"); ccValue.Exists() {
+ cItem.IncrementVarname = types.StringValue(ccValue.String())
+ }
+ if ccValue := cv.Get("increment.value"); ccValue.Exists() {
+ cItem.IncrementValue = types.StringValue(ccValue.String())
+ }
+ if ccValue := cv.Get("decrement.varname"); ccValue.Exists() {
+ cItem.DecrementVarname = types.StringValue(ccValue.String())
+ }
+ if ccValue := cv.Get("decrement.value"); ccValue.Exists() {
+ cItem.DecrementValue = types.StringValue(ccValue.String())
+ }
+ if ccValue := cv.Get("append.varname"); ccValue.Exists() {
+ cItem.AppendVarname = types.StringValue(ccValue.String())
+ }
+ if ccValue := cv.Get("append.value"); ccValue.Exists() {
+ cItem.AppendValue = types.StringValue(ccValue.String())
+ }
+ if ccValue := cv.Get("divide.operand1"); ccValue.Exists() {
+ cItem.DivideOperand1 = types.StringValue(ccValue.String())
+ }
+ if ccValue := cv.Get("divide.operand2"); ccValue.Exists() {
+ cItem.DivideOperand2 = types.StringValue(ccValue.String())
+ }
+ if ccValue := cv.Get("foreach.loopvar"); ccValue.Exists() {
+ cItem.ForeachLoopvar = types.StringValue(ccValue.String())
+ }
+ if ccValue := cv.Get("foreach.iterator"); ccValue.Exists() {
+ cItem.ForeachIterator = types.StringValue(ccValue.String())
+ }
+ if ccValue := cv.Get("foreach.delimiter"); ccValue.Exists() {
+ cItem.ForeachDelimiter = types.StringValue(ccValue.String())
+ }
+ if ccValue := cv.Get("gets"); ccValue.Exists() {
+ cItem.Gets = types.StringValue(ccValue.String())
+ }
+ if ccValue := cv.Get("puts"); ccValue.Exists() {
+ cItem.Puts = types.StringValue(ccValue.String())
+ }
+ if ccValue := cv.Get("wait"); ccValue.Exists() {
+ cItem.Wait = types.Int64Value(ccValue.Int())
+ }
+ if ccValue := cv.Get("end"); ccValue.Exists() {
+ cItem.End = types.BoolValue(true)
+ } else {
+ cItem.End = types.BoolValue(false)
+ }
+ if ccValue := cv.Get("exit"); ccValue.Exists() {
+ cItem.Exit = types.BoolValue(true)
+ } else {
+ cItem.Exit = types.BoolValue(false)
+ }
+ if ccValue := cv.Get("reload"); ccValue.Exists() {
+ cItem.Reload = types.BoolValue(true)
+ } else {
+ cItem.Reload = types.BoolValue(false)
+ }
+ if ccValue := cv.Get("context.retrieve.key"); ccValue.Exists() {
+ cItem.ContextRetrieveKey = types.StringValue(ccValue.String())
+ }
+ if ccValue := cv.Get("context.retrieve.variable"); ccValue.Exists() {
+ cItem.ContextRetrieveVariable = types.StringValue(ccValue.String())
+ }
+ if ccValue := cv.Get("context.save.key"); ccValue.Exists() {
+ cItem.ContextSaveKey = types.StringValue(ccValue.String())
+ }
+ if ccValue := cv.Get("context.save.variable"); ccValue.Exists() {
+ cItem.ContextSaveVariable = types.StringValue(ccValue.String())
+ }
+ if ccValue := cv.Get("string.trim"); ccValue.Exists() {
+ cItem.StringTrim = types.StringValue(ccValue.String())
+ }
+ if ccValue := cv.Get("info.type.snmp.trap.enterprise-oid"); ccValue.Exists() {
+ cItem.InfoTypeSnmpTrapEnterpriseOid = types.StringValue(ccValue.String())
+ }
+ if ccValue := cv.Get("info.type.snmp.trap.generic-trapnum"); ccValue.Exists() {
+ cItem.InfoTypeSnmpTrapGenericTrapnum = types.Int64Value(ccValue.Int())
+ }
+ if ccValue := cv.Get("info.type.snmp.trap.specific-trapnum"); ccValue.Exists() {
+ cItem.InfoTypeSnmpTrapSpecificTrapnum = types.Int64Value(ccValue.Int())
+ }
+ if ccValue := cv.Get("info.type.snmp.trap.trap-oid"); ccValue.Exists() {
+ cItem.InfoTypeSnmpTrapTrapOid = types.StringValue(ccValue.String())
+ }
+ if ccValue := cv.Get("info.type.snmp.trap.trap-var"); ccValue.Exists() {
+ cItem.InfoTypeSnmpTrapTrapVar = types.StringValue(ccValue.String())
+ }
+ if ccValue := cv.Get("handle-error.type"); ccValue.Exists() {
+ cItem.HandleErrorType = types.StringValue(ccValue.String())
+ }
+ if ccValue := cv.Get("counter.name"); ccValue.Exists() {
+ cItem.CounterName = types.StringValue(ccValue.String())
+ }
+ if ccValue := cv.Get("counter.value"); ccValue.Exists() {
+ cItem.CounterValue = types.Int64Value(ccValue.Int())
+ }
+ if ccValue := cv.Get("counter.op.dec"); ccValue.Exists() {
+ cItem.CounterOpDec = types.BoolValue(true)
+ } else {
+ cItem.CounterOpDec = types.BoolValue(false)
+ }
+ if ccValue := cv.Get("counter.op.inc"); ccValue.Exists() {
+ cItem.CounterOpInc = types.BoolValue(true)
+ } else {
+ cItem.CounterOpInc = types.BoolValue(false)
+ }
+ if ccValue := cv.Get("counter.op.set"); ccValue.Exists() {
+ cItem.CounterOpSet = types.BoolValue(true)
+ } else {
+ cItem.CounterOpSet = types.BoolValue(false)
+ }
+ if ccValue := cv.Get("counter.op.nop"); ccValue.Exists() {
+ cItem.CounterOpNop = types.BoolValue(true)
+ } else {
+ cItem.CounterOpNop = types.BoolValue(false)
+ }
+ if ccValue := cv.Get("snmp-trap.intdata1"); ccValue.Exists() {
+ cItem.SnmpTrapIntdata1 = types.Int64Value(ccValue.Int())
+ }
+ if ccValue := cv.Get("snmp-trap.intdata2"); ccValue.Exists() {
+ cItem.SnmpTrapIntdata2 = types.Int64Value(ccValue.Int())
+ }
+ if ccValue := cv.Get("snmp-trap.strdata"); ccValue.Exists() {
+ cItem.SnmpTrapStrdata = types.StringValue(ccValue.String())
+ }
+ if ccValue := cv.Get("info.type.snmp.var.variable-name"); ccValue.Exists() {
+ cItem.InfoTypeSnmpVar = types.StringValue(ccValue.String())
+ }
+ if ccValue := cv.Get("info.type.snmp.var.oid"); ccValue.Exists() {
+ cItem.InfoTypeSnmpVarOid = types.StringValue(ccValue.String())
+ }
+ if ccValue := cv.Get("info.type.snmp.var.oid-type"); ccValue.Exists() {
+ cItem.InfoTypeSnmpVarOidType = types.StringValue(ccValue.String())
+ }
+ if ccValue := cv.Get("info.type.snmp.var.oid-type-value"); ccValue.Exists() {
+ cItem.InfoTypeSnmpVarOidTypeValue = types.StringValue(ccValue.String())
+ }
+ if ccValue := cv.Get("string.trim.first.string-op-1"); ccValue.Exists() {
+ cItem.StringTrimFirstStringOp1 = types.StringValue(ccValue.String())
+ }
+ if ccValue := cv.Get("string.trim.first.string-op-2"); ccValue.Exists() {
+ cItem.StringTrimFirstStringOp2 = types.StringValue(ccValue.String())
+ }
+ item.Actions = append(item.Actions, cItem)
+ return true
+ })
+ }
+ if cValue := v.Get("event.timer-choice.watchdog.time-set"); cValue.Exists() {
+ item.EventTimerWatchdogTime = types.Float64Value(cValue.Float())
+ }
+ if cValue := v.Get("event.timer-choice.watchdog.name"); cValue.Exists() {
+ item.EventTimerWatchdogName = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("event.timer-choice.watchdog.maxrun-set"); cValue.Exists() {
+ item.EventTimerWatchdogMaxrun = types.Float64Value(cValue.Float())
+ }
+ if cValue := v.Get("event.timer-choice.watchdog.ratelimit-set"); cValue.Exists() {
+ item.EventTimerWatchdogRatelimit = types.Float64Value(cValue.Float())
+ }
+ if cValue := v.Get("event.timer-choice.cron.cron-entry"); cValue.Exists() {
+ item.EventTimerCronEntry = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("event.timer-choice.cron.name"); cValue.Exists() {
+ item.EventTimerCronName = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("event.timer-choice.cron.maxrun-set"); cValue.Exists() {
+ item.EventTimerCronMaxrun = types.Float64Value(cValue.Float())
+ }
+ if cValue := v.Get("event.timer-choice.cron.ratelimit-set"); cValue.Exists() {
+ item.EventTimerCronRatelimit = types.Float64Value(cValue.Float())
+ }
+ data.Applets = append(data.Applets, item)
+ return true
+ })
+ }
+}
+
+// End of section. //template:end fromBody
+
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyData
+
+func (data *EEMData) fromBody(ctx context.Context, res gjson.Result) {
+ prefix := helpers.LastElement(data.getPath()) + "."
+ if res.Get(helpers.LastElement(data.getPath())).IsArray() {
+ prefix += "0."
+ }
+ if value := res.Get(prefix + "environment"); value.Exists() {
+ data.EnvironmentVariables = make([]EEMEnvironmentVariables, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := EEMEnvironmentVariables{}
+ if cValue := v.Get("name"); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("value"); cValue.Exists() {
+ item.Value = types.StringValue(cValue.String())
+ }
+ data.EnvironmentVariables = append(data.EnvironmentVariables, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + "session.cli.username.username_in_word_set"); value.Exists() {
+ data.SessionCliUsername = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "session.cli.username.privilege_set"); value.Exists() {
+ data.SessionCliUsernamePrivilege = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "history.size.events"); value.Exists() {
+ data.HistorySizeEvents = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "history.size.traps"); value.Exists() {
+ data.HistorySizeTraps = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "directory.user.policy"); value.Exists() {
+ data.DirectoryUserPolicy = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "scheduler.applet.thread.class.default"); value.Exists() {
+ data.SchedulerAppletThreadClassDefault = types.BoolValue(true)
+ } else {
+ data.SchedulerAppletThreadClassDefault = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "scheduler.applet.thread.class.number"); value.Exists() {
+ data.SchedulerAppletThreadClassNumber = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "detector.rpc.max-sessions"); value.Exists() {
+ data.DetectorRpcMaxSessions = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "detector.routing.bootup-delay"); value.Exists() {
+ data.DetectorRoutingBootupDelay = types.Float64Value(value.Float())
+ }
+ if value := res.Get(prefix + "applet"); value.Exists() {
+ data.Applets = make([]EEMApplets, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := EEMApplets{}
+ if cValue := v.Get("name"); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("authorization"); cValue.Exists() {
+ item.Authorization = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("class"); cValue.Exists() {
+ item.Class = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("description"); cValue.Exists() {
+ item.Description = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("event.cli.pattern"); cValue.Exists() {
+ item.EventCliPattern = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("event.cli.sync"); cValue.Exists() {
+ item.EventCliSync = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("event.cli.skip"); cValue.Exists() {
+ item.EventCliSkip = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("action-config.action"); cValue.Exists() {
+ item.Actions = make([]EEMAppletsActions, 0)
+ cValue.ForEach(func(ck, cv gjson.Result) bool {
+ cItem := EEMAppletsActions{}
+ if ccValue := cv.Get("name"); ccValue.Exists() {
+ cItem.Name = types.StringValue(ccValue.String())
+ }
+ if ccValue := cv.Get("cli-choice.command"); ccValue.Exists() {
+ cItem.CliCommand = types.StringValue(ccValue.String())
+ }
+ if ccValue := cv.Get("regexp-option.string-pattern"); ccValue.Exists() {
+ cItem.RegexpStringPattern = types.StringValue(ccValue.String())
+ }
+ if ccValue := cv.Get("regexp-option.string-input"); ccValue.Exists() {
+ cItem.RegexpStringInput = types.StringValue(ccValue.String())
+ }
+ if ccValue := cv.Get("regexp-option.string-match"); ccValue.Exists() {
+ cItem.RegexpStringMatch = types.StringValue(ccValue.String())
+ }
+ if ccValue := cv.Get("regexp-option.string-submatch1"); ccValue.Exists() {
+ cItem.RegexpStringMatch1 = types.StringValue(ccValue.String())
+ }
+ if ccValue := cv.Get("regexp-option.string-submatch2"); ccValue.Exists() {
+ cItem.RegexpStringMatch2 = types.StringValue(ccValue.String())
+ }
+ if ccValue := cv.Get("regexp-option.string-submatch3"); ccValue.Exists() {
+ cItem.RegexpStringMatch3 = types.StringValue(ccValue.String())
+ }
+ if ccValue := cv.Get("syslog-option.facility"); ccValue.Exists() {
+ cItem.SyslogFacility = types.StringValue(ccValue.String())
+ }
+ if ccValue := cv.Get("syslog-option.msg"); ccValue.Exists() {
+ cItem.SyslogMsg = types.StringValue(ccValue.String())
+ }
+ if ccValue := cv.Get("syslog-option.priority"); ccValue.Exists() {
+ cItem.SyslogPriority = types.StringValue(ccValue.String())
+ }
+ if ccValue := cv.Get("set.varname"); ccValue.Exists() {
+ cItem.SetVarname = types.StringValue(ccValue.String())
+ }
+ if ccValue := cv.Get("set.value"); ccValue.Exists() {
+ cItem.SetValue = types.StringValue(ccValue.String())
+ }
+ if ccValue := cv.Get("if.string-op-1"); ccValue.Exists() {
+ cItem.IfStringOp1 = types.StringValue(ccValue.String())
+ }
+ if ccValue := cv.Get("if.keyword"); ccValue.Exists() {
+ cItem.IfKeyword = types.StringValue(ccValue.String())
+ }
+ if ccValue := cv.Get("if.string-op-2"); ccValue.Exists() {
+ cItem.IfStringOp2 = types.StringValue(ccValue.String())
+ }
+ if ccValue := cv.Get("if.goto"); ccValue.Exists() {
+ cItem.IfGoto = types.StringValue(ccValue.String())
+ }
+ if ccValue := cv.Get("elseif.operand1"); ccValue.Exists() {
+ cItem.ElseifOperand1 = types.StringValue(ccValue.String())
+ }
+ if ccValue := cv.Get("elseif.operation"); ccValue.Exists() {
+ cItem.ElseifOperation = types.StringValue(ccValue.String())
+ }
+ if ccValue := cv.Get("elseif.operand2"); ccValue.Exists() {
+ cItem.ElseifOperand2 = types.StringValue(ccValue.String())
+ }
+ if ccValue := cv.Get("else"); ccValue.Exists() {
+ cItem.Else = types.BoolValue(true)
+ } else {
+ cItem.Else = types.BoolValue(false)
+ }
+ if ccValue := cv.Get("while.operand1"); ccValue.Exists() {
+ cItem.WhileOperand1 = types.StringValue(ccValue.String())
+ }
+ if ccValue := cv.Get("while.operation"); ccValue.Exists() {
+ cItem.WhileOperation = types.StringValue(ccValue.String())
+ }
+ if ccValue := cv.Get("while.operand2"); ccValue.Exists() {
+ cItem.WhileOperand2 = types.StringValue(ccValue.String())
+ }
+ if ccValue := cv.Get("break"); ccValue.Exists() {
+ cItem.Break = types.BoolValue(true)
+ } else {
+ cItem.Break = types.BoolValue(false)
+ }
+ if ccValue := cv.Get("continue"); ccValue.Exists() {
+ cItem.Continue = types.BoolValue(true)
+ } else {
+ cItem.Continue = types.BoolValue(false)
+ }
+ if ccValue := cv.Get("increment.varname"); ccValue.Exists() {
+ cItem.IncrementVarname = types.StringValue(ccValue.String())
+ }
+ if ccValue := cv.Get("increment.value"); ccValue.Exists() {
+ cItem.IncrementValue = types.StringValue(ccValue.String())
+ }
+ if ccValue := cv.Get("decrement.varname"); ccValue.Exists() {
+ cItem.DecrementVarname = types.StringValue(ccValue.String())
+ }
+ if ccValue := cv.Get("decrement.value"); ccValue.Exists() {
+ cItem.DecrementValue = types.StringValue(ccValue.String())
+ }
+ if ccValue := cv.Get("append.varname"); ccValue.Exists() {
+ cItem.AppendVarname = types.StringValue(ccValue.String())
+ }
+ if ccValue := cv.Get("append.value"); ccValue.Exists() {
+ cItem.AppendValue = types.StringValue(ccValue.String())
+ }
+ if ccValue := cv.Get("divide.operand1"); ccValue.Exists() {
+ cItem.DivideOperand1 = types.StringValue(ccValue.String())
+ }
+ if ccValue := cv.Get("divide.operand2"); ccValue.Exists() {
+ cItem.DivideOperand2 = types.StringValue(ccValue.String())
+ }
+ if ccValue := cv.Get("foreach.loopvar"); ccValue.Exists() {
+ cItem.ForeachLoopvar = types.StringValue(ccValue.String())
+ }
+ if ccValue := cv.Get("foreach.iterator"); ccValue.Exists() {
+ cItem.ForeachIterator = types.StringValue(ccValue.String())
+ }
+ if ccValue := cv.Get("foreach.delimiter"); ccValue.Exists() {
+ cItem.ForeachDelimiter = types.StringValue(ccValue.String())
+ }
+ if ccValue := cv.Get("gets"); ccValue.Exists() {
+ cItem.Gets = types.StringValue(ccValue.String())
+ }
+ if ccValue := cv.Get("puts"); ccValue.Exists() {
+ cItem.Puts = types.StringValue(ccValue.String())
+ }
+ if ccValue := cv.Get("wait"); ccValue.Exists() {
+ cItem.Wait = types.Int64Value(ccValue.Int())
+ }
+ if ccValue := cv.Get("end"); ccValue.Exists() {
+ cItem.End = types.BoolValue(true)
+ } else {
+ cItem.End = types.BoolValue(false)
+ }
+ if ccValue := cv.Get("exit"); ccValue.Exists() {
+ cItem.Exit = types.BoolValue(true)
+ } else {
+ cItem.Exit = types.BoolValue(false)
+ }
+ if ccValue := cv.Get("reload"); ccValue.Exists() {
+ cItem.Reload = types.BoolValue(true)
+ } else {
+ cItem.Reload = types.BoolValue(false)
+ }
+ if ccValue := cv.Get("context.retrieve.key"); ccValue.Exists() {
+ cItem.ContextRetrieveKey = types.StringValue(ccValue.String())
+ }
+ if ccValue := cv.Get("context.retrieve.variable"); ccValue.Exists() {
+ cItem.ContextRetrieveVariable = types.StringValue(ccValue.String())
+ }
+ if ccValue := cv.Get("context.save.key"); ccValue.Exists() {
+ cItem.ContextSaveKey = types.StringValue(ccValue.String())
+ }
+ if ccValue := cv.Get("context.save.variable"); ccValue.Exists() {
+ cItem.ContextSaveVariable = types.StringValue(ccValue.String())
+ }
+ if ccValue := cv.Get("string.trim"); ccValue.Exists() {
+ cItem.StringTrim = types.StringValue(ccValue.String())
+ }
+ if ccValue := cv.Get("info.type.snmp.trap.enterprise-oid"); ccValue.Exists() {
+ cItem.InfoTypeSnmpTrapEnterpriseOid = types.StringValue(ccValue.String())
+ }
+ if ccValue := cv.Get("info.type.snmp.trap.generic-trapnum"); ccValue.Exists() {
+ cItem.InfoTypeSnmpTrapGenericTrapnum = types.Int64Value(ccValue.Int())
+ }
+ if ccValue := cv.Get("info.type.snmp.trap.specific-trapnum"); ccValue.Exists() {
+ cItem.InfoTypeSnmpTrapSpecificTrapnum = types.Int64Value(ccValue.Int())
+ }
+ if ccValue := cv.Get("info.type.snmp.trap.trap-oid"); ccValue.Exists() {
+ cItem.InfoTypeSnmpTrapTrapOid = types.StringValue(ccValue.String())
+ }
+ if ccValue := cv.Get("info.type.snmp.trap.trap-var"); ccValue.Exists() {
+ cItem.InfoTypeSnmpTrapTrapVar = types.StringValue(ccValue.String())
+ }
+ if ccValue := cv.Get("handle-error.type"); ccValue.Exists() {
+ cItem.HandleErrorType = types.StringValue(ccValue.String())
+ }
+ if ccValue := cv.Get("counter.name"); ccValue.Exists() {
+ cItem.CounterName = types.StringValue(ccValue.String())
+ }
+ if ccValue := cv.Get("counter.value"); ccValue.Exists() {
+ cItem.CounterValue = types.Int64Value(ccValue.Int())
+ }
+ if ccValue := cv.Get("counter.op.dec"); ccValue.Exists() {
+ cItem.CounterOpDec = types.BoolValue(true)
+ } else {
+ cItem.CounterOpDec = types.BoolValue(false)
+ }
+ if ccValue := cv.Get("counter.op.inc"); ccValue.Exists() {
+ cItem.CounterOpInc = types.BoolValue(true)
+ } else {
+ cItem.CounterOpInc = types.BoolValue(false)
+ }
+ if ccValue := cv.Get("counter.op.set"); ccValue.Exists() {
+ cItem.CounterOpSet = types.BoolValue(true)
+ } else {
+ cItem.CounterOpSet = types.BoolValue(false)
+ }
+ if ccValue := cv.Get("counter.op.nop"); ccValue.Exists() {
+ cItem.CounterOpNop = types.BoolValue(true)
+ } else {
+ cItem.CounterOpNop = types.BoolValue(false)
+ }
+ if ccValue := cv.Get("snmp-trap.intdata1"); ccValue.Exists() {
+ cItem.SnmpTrapIntdata1 = types.Int64Value(ccValue.Int())
+ }
+ if ccValue := cv.Get("snmp-trap.intdata2"); ccValue.Exists() {
+ cItem.SnmpTrapIntdata2 = types.Int64Value(ccValue.Int())
+ }
+ if ccValue := cv.Get("snmp-trap.strdata"); ccValue.Exists() {
+ cItem.SnmpTrapStrdata = types.StringValue(ccValue.String())
+ }
+ if ccValue := cv.Get("info.type.snmp.var.variable-name"); ccValue.Exists() {
+ cItem.InfoTypeSnmpVar = types.StringValue(ccValue.String())
+ }
+ if ccValue := cv.Get("info.type.snmp.var.oid"); ccValue.Exists() {
+ cItem.InfoTypeSnmpVarOid = types.StringValue(ccValue.String())
+ }
+ if ccValue := cv.Get("info.type.snmp.var.oid-type"); ccValue.Exists() {
+ cItem.InfoTypeSnmpVarOidType = types.StringValue(ccValue.String())
+ }
+ if ccValue := cv.Get("info.type.snmp.var.oid-type-value"); ccValue.Exists() {
+ cItem.InfoTypeSnmpVarOidTypeValue = types.StringValue(ccValue.String())
+ }
+ if ccValue := cv.Get("string.trim.first.string-op-1"); ccValue.Exists() {
+ cItem.StringTrimFirstStringOp1 = types.StringValue(ccValue.String())
+ }
+ if ccValue := cv.Get("string.trim.first.string-op-2"); ccValue.Exists() {
+ cItem.StringTrimFirstStringOp2 = types.StringValue(ccValue.String())
+ }
+ item.Actions = append(item.Actions, cItem)
+ return true
+ })
+ }
+ if cValue := v.Get("event.timer-choice.watchdog.time-set"); cValue.Exists() {
+ item.EventTimerWatchdogTime = types.Float64Value(cValue.Float())
+ }
+ if cValue := v.Get("event.timer-choice.watchdog.name"); cValue.Exists() {
+ item.EventTimerWatchdogName = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("event.timer-choice.watchdog.maxrun-set"); cValue.Exists() {
+ item.EventTimerWatchdogMaxrun = types.Float64Value(cValue.Float())
+ }
+ if cValue := v.Get("event.timer-choice.watchdog.ratelimit-set"); cValue.Exists() {
+ item.EventTimerWatchdogRatelimit = types.Float64Value(cValue.Float())
+ }
+ if cValue := v.Get("event.timer-choice.cron.cron-entry"); cValue.Exists() {
+ item.EventTimerCronEntry = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("event.timer-choice.cron.name"); cValue.Exists() {
+ item.EventTimerCronName = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("event.timer-choice.cron.maxrun-set"); cValue.Exists() {
+ item.EventTimerCronMaxrun = types.Float64Value(cValue.Float())
+ }
+ if cValue := v.Get("event.timer-choice.cron.ratelimit-set"); cValue.Exists() {
+ item.EventTimerCronRatelimit = types.Float64Value(cValue.Float())
+ }
+ data.Applets = append(data.Applets, item)
+ return true
+ })
+ }
+}
+
+// End of section. //template:end fromBodyData
+
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyXML
+
+func (data *EEM) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/environment"); value.Exists() {
+ data.EnvironmentVariables = make([]EEMEnvironmentVariables, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := EEMEnvironmentVariables{}
+ if cValue := helpers.GetFromXPath(v, "name"); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "value"); cValue.Exists() {
+ item.Value = types.StringValue(cValue.String())
+ }
+ data.EnvironmentVariables = append(data.EnvironmentVariables, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/session/cli/username/username_in_word_set"); value.Exists() {
+ data.SessionCliUsername = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/session/cli/username/privilege_set"); value.Exists() {
+ data.SessionCliUsernamePrivilege = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/history/size/events"); value.Exists() {
+ data.HistorySizeEvents = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/history/size/traps"); value.Exists() {
+ data.HistorySizeTraps = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/directory/user/policy"); value.Exists() {
+ data.DirectoryUserPolicy = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/scheduler/applet/thread/class/default"); value.Exists() {
+ data.SchedulerAppletThreadClassDefault = types.BoolValue(true)
+ } else {
+ data.SchedulerAppletThreadClassDefault = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/scheduler/applet/thread/class/number"); value.Exists() {
+ data.SchedulerAppletThreadClassNumber = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/detector/rpc/max-sessions"); value.Exists() {
+ data.DetectorRpcMaxSessions = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/detector/routing/bootup-delay"); value.Exists() {
+ data.DetectorRoutingBootupDelay = types.Float64Value(value.Float())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/applet"); value.Exists() {
+ data.Applets = make([]EEMApplets, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := EEMApplets{}
+ if cValue := helpers.GetFromXPath(v, "name"); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "authorization"); cValue.Exists() {
+ item.Authorization = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "class"); cValue.Exists() {
+ item.Class = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "description"); cValue.Exists() {
+ item.Description = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "event/cli/pattern"); cValue.Exists() {
+ item.EventCliPattern = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "event/cli/sync"); cValue.Exists() {
+ item.EventCliSync = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "event/cli/skip"); cValue.Exists() {
+ item.EventCliSkip = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "action-config/action"); cValue.Exists() {
+ item.Actions = make([]EEMAppletsActions, 0)
+ cValue.ForEach(func(_ int, cv xmldot.Result) bool {
+ cItem := EEMAppletsActions{}
+ if ccValue := helpers.GetFromXPath(cv, "name"); ccValue.Exists() {
+ cItem.Name = types.StringValue(ccValue.String())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "cli-choice/command"); ccValue.Exists() {
+ cItem.CliCommand = types.StringValue(ccValue.String())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "regexp-option/string-pattern"); ccValue.Exists() {
+ cItem.RegexpStringPattern = types.StringValue(ccValue.String())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "regexp-option/string-input"); ccValue.Exists() {
+ cItem.RegexpStringInput = types.StringValue(ccValue.String())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "regexp-option/string-match"); ccValue.Exists() {
+ cItem.RegexpStringMatch = types.StringValue(ccValue.String())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "regexp-option/string-submatch1"); ccValue.Exists() {
+ cItem.RegexpStringMatch1 = types.StringValue(ccValue.String())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "regexp-option/string-submatch2"); ccValue.Exists() {
+ cItem.RegexpStringMatch2 = types.StringValue(ccValue.String())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "regexp-option/string-submatch3"); ccValue.Exists() {
+ cItem.RegexpStringMatch3 = types.StringValue(ccValue.String())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "syslog-option/facility"); ccValue.Exists() {
+ cItem.SyslogFacility = types.StringValue(ccValue.String())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "syslog-option/msg"); ccValue.Exists() {
+ cItem.SyslogMsg = types.StringValue(ccValue.String())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "syslog-option/priority"); ccValue.Exists() {
+ cItem.SyslogPriority = types.StringValue(ccValue.String())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "set/varname"); ccValue.Exists() {
+ cItem.SetVarname = types.StringValue(ccValue.String())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "set/value"); ccValue.Exists() {
+ cItem.SetValue = types.StringValue(ccValue.String())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "if/string-op-1"); ccValue.Exists() {
+ cItem.IfStringOp1 = types.StringValue(ccValue.String())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "if/keyword"); ccValue.Exists() {
+ cItem.IfKeyword = types.StringValue(ccValue.String())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "if/string-op-2"); ccValue.Exists() {
+ cItem.IfStringOp2 = types.StringValue(ccValue.String())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "if/goto"); ccValue.Exists() {
+ cItem.IfGoto = types.StringValue(ccValue.String())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "elseif/operand1"); ccValue.Exists() {
+ cItem.ElseifOperand1 = types.StringValue(ccValue.String())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "elseif/operation"); ccValue.Exists() {
+ cItem.ElseifOperation = types.StringValue(ccValue.String())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "elseif/operand2"); ccValue.Exists() {
+ cItem.ElseifOperand2 = types.StringValue(ccValue.String())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "else"); ccValue.Exists() {
+ cItem.Else = types.BoolValue(true)
+ } else {
+ cItem.Else = types.BoolValue(false)
+ }
+ if ccValue := helpers.GetFromXPath(cv, "while/operand1"); ccValue.Exists() {
+ cItem.WhileOperand1 = types.StringValue(ccValue.String())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "while/operation"); ccValue.Exists() {
+ cItem.WhileOperation = types.StringValue(ccValue.String())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "while/operand2"); ccValue.Exists() {
+ cItem.WhileOperand2 = types.StringValue(ccValue.String())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "break"); ccValue.Exists() {
+ cItem.Break = types.BoolValue(true)
+ } else {
+ cItem.Break = types.BoolValue(false)
+ }
+ if ccValue := helpers.GetFromXPath(cv, "continue"); ccValue.Exists() {
+ cItem.Continue = types.BoolValue(true)
+ } else {
+ cItem.Continue = types.BoolValue(false)
+ }
+ if ccValue := helpers.GetFromXPath(cv, "increment/varname"); ccValue.Exists() {
+ cItem.IncrementVarname = types.StringValue(ccValue.String())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "increment/value"); ccValue.Exists() {
+ cItem.IncrementValue = types.StringValue(ccValue.String())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "decrement/varname"); ccValue.Exists() {
+ cItem.DecrementVarname = types.StringValue(ccValue.String())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "decrement/value"); ccValue.Exists() {
+ cItem.DecrementValue = types.StringValue(ccValue.String())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "append/varname"); ccValue.Exists() {
+ cItem.AppendVarname = types.StringValue(ccValue.String())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "append/value"); ccValue.Exists() {
+ cItem.AppendValue = types.StringValue(ccValue.String())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "divide/operand1"); ccValue.Exists() {
+ cItem.DivideOperand1 = types.StringValue(ccValue.String())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "divide/operand2"); ccValue.Exists() {
+ cItem.DivideOperand2 = types.StringValue(ccValue.String())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "foreach/loopvar"); ccValue.Exists() {
+ cItem.ForeachLoopvar = types.StringValue(ccValue.String())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "foreach/iterator"); ccValue.Exists() {
+ cItem.ForeachIterator = types.StringValue(ccValue.String())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "foreach/delimiter"); ccValue.Exists() {
+ cItem.ForeachDelimiter = types.StringValue(ccValue.String())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "gets"); ccValue.Exists() {
+ cItem.Gets = types.StringValue(ccValue.String())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "puts"); ccValue.Exists() {
+ cItem.Puts = types.StringValue(ccValue.String())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "wait"); ccValue.Exists() {
+ cItem.Wait = types.Int64Value(ccValue.Int())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "end"); ccValue.Exists() {
+ cItem.End = types.BoolValue(true)
+ } else {
+ cItem.End = types.BoolValue(false)
+ }
+ if ccValue := helpers.GetFromXPath(cv, "exit"); ccValue.Exists() {
+ cItem.Exit = types.BoolValue(true)
+ } else {
+ cItem.Exit = types.BoolValue(false)
+ }
+ if ccValue := helpers.GetFromXPath(cv, "reload"); ccValue.Exists() {
+ cItem.Reload = types.BoolValue(true)
+ } else {
+ cItem.Reload = types.BoolValue(false)
+ }
+ if ccValue := helpers.GetFromXPath(cv, "context/retrieve/key"); ccValue.Exists() {
+ cItem.ContextRetrieveKey = types.StringValue(ccValue.String())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "context/retrieve/variable"); ccValue.Exists() {
+ cItem.ContextRetrieveVariable = types.StringValue(ccValue.String())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "context/save/key"); ccValue.Exists() {
+ cItem.ContextSaveKey = types.StringValue(ccValue.String())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "context/save/variable"); ccValue.Exists() {
+ cItem.ContextSaveVariable = types.StringValue(ccValue.String())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "string/trim"); ccValue.Exists() {
+ cItem.StringTrim = types.StringValue(ccValue.String())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "info/type/snmp/trap/enterprise-oid"); ccValue.Exists() {
+ cItem.InfoTypeSnmpTrapEnterpriseOid = types.StringValue(ccValue.String())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "info/type/snmp/trap/generic-trapnum"); ccValue.Exists() {
+ cItem.InfoTypeSnmpTrapGenericTrapnum = types.Int64Value(ccValue.Int())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "info/type/snmp/trap/specific-trapnum"); ccValue.Exists() {
+ cItem.InfoTypeSnmpTrapSpecificTrapnum = types.Int64Value(ccValue.Int())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "info/type/snmp/trap/trap-oid"); ccValue.Exists() {
+ cItem.InfoTypeSnmpTrapTrapOid = types.StringValue(ccValue.String())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "info/type/snmp/trap/trap-var"); ccValue.Exists() {
+ cItem.InfoTypeSnmpTrapTrapVar = types.StringValue(ccValue.String())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "handle-error/type"); ccValue.Exists() {
+ cItem.HandleErrorType = types.StringValue(ccValue.String())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "counter/name"); ccValue.Exists() {
+ cItem.CounterName = types.StringValue(ccValue.String())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "counter/value"); ccValue.Exists() {
+ cItem.CounterValue = types.Int64Value(ccValue.Int())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "counter/op/dec"); ccValue.Exists() {
+ cItem.CounterOpDec = types.BoolValue(true)
+ } else {
+ cItem.CounterOpDec = types.BoolValue(false)
+ }
+ if ccValue := helpers.GetFromXPath(cv, "counter/op/inc"); ccValue.Exists() {
+ cItem.CounterOpInc = types.BoolValue(true)
+ } else {
+ cItem.CounterOpInc = types.BoolValue(false)
+ }
+ if ccValue := helpers.GetFromXPath(cv, "counter/op/set"); ccValue.Exists() {
+ cItem.CounterOpSet = types.BoolValue(true)
+ } else {
+ cItem.CounterOpSet = types.BoolValue(false)
+ }
+ if ccValue := helpers.GetFromXPath(cv, "counter/op/nop"); ccValue.Exists() {
+ cItem.CounterOpNop = types.BoolValue(true)
+ } else {
+ cItem.CounterOpNop = types.BoolValue(false)
+ }
+ if ccValue := helpers.GetFromXPath(cv, "snmp-trap/intdata1"); ccValue.Exists() {
+ cItem.SnmpTrapIntdata1 = types.Int64Value(ccValue.Int())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "snmp-trap/intdata2"); ccValue.Exists() {
+ cItem.SnmpTrapIntdata2 = types.Int64Value(ccValue.Int())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "snmp-trap/strdata"); ccValue.Exists() {
+ cItem.SnmpTrapStrdata = types.StringValue(ccValue.String())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "info/type/snmp/var/variable-name"); ccValue.Exists() {
+ cItem.InfoTypeSnmpVar = types.StringValue(ccValue.String())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "info/type/snmp/var/oid"); ccValue.Exists() {
+ cItem.InfoTypeSnmpVarOid = types.StringValue(ccValue.String())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "info/type/snmp/var/oid-type"); ccValue.Exists() {
+ cItem.InfoTypeSnmpVarOidType = types.StringValue(ccValue.String())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "info/type/snmp/var/oid-type-value"); ccValue.Exists() {
+ cItem.InfoTypeSnmpVarOidTypeValue = types.StringValue(ccValue.String())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "string/trim/first/string-op-1"); ccValue.Exists() {
+ cItem.StringTrimFirstStringOp1 = types.StringValue(ccValue.String())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "string/trim/first/string-op-2"); ccValue.Exists() {
+ cItem.StringTrimFirstStringOp2 = types.StringValue(ccValue.String())
+ }
+ item.Actions = append(item.Actions, cItem)
+ return true
+ })
+ }
+ if cValue := helpers.GetFromXPath(v, "event/timer-choice/watchdog/time-set"); cValue.Exists() {
+ item.EventTimerWatchdogTime = types.Float64Value(cValue.Float())
+ }
+ if cValue := helpers.GetFromXPath(v, "event/timer-choice/watchdog/name"); cValue.Exists() {
+ item.EventTimerWatchdogName = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "event/timer-choice/watchdog/maxrun-set"); cValue.Exists() {
+ item.EventTimerWatchdogMaxrun = types.Float64Value(cValue.Float())
+ }
+ if cValue := helpers.GetFromXPath(v, "event/timer-choice/watchdog/ratelimit-set"); cValue.Exists() {
+ item.EventTimerWatchdogRatelimit = types.Float64Value(cValue.Float())
+ }
+ if cValue := helpers.GetFromXPath(v, "event/timer-choice/cron/cron-entry"); cValue.Exists() {
+ item.EventTimerCronEntry = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "event/timer-choice/cron/name"); cValue.Exists() {
+ item.EventTimerCronName = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "event/timer-choice/cron/maxrun-set"); cValue.Exists() {
+ item.EventTimerCronMaxrun = types.Float64Value(cValue.Float())
+ }
+ if cValue := helpers.GetFromXPath(v, "event/timer-choice/cron/ratelimit-set"); cValue.Exists() {
+ item.EventTimerCronRatelimit = types.Float64Value(cValue.Float())
+ }
+ data.Applets = append(data.Applets, item)
+ return true
+ })
+ }
+}
+
+// End of section. //template:end fromBodyXML
+
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyDataXML
+
+func (data *EEMData) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/environment"); value.Exists() {
+ data.EnvironmentVariables = make([]EEMEnvironmentVariables, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := EEMEnvironmentVariables{}
+ if cValue := helpers.GetFromXPath(v, "name"); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "value"); cValue.Exists() {
+ item.Value = types.StringValue(cValue.String())
+ }
+ data.EnvironmentVariables = append(data.EnvironmentVariables, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/session/cli/username/username_in_word_set"); value.Exists() {
+ data.SessionCliUsername = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/session/cli/username/privilege_set"); value.Exists() {
+ data.SessionCliUsernamePrivilege = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/history/size/events"); value.Exists() {
+ data.HistorySizeEvents = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/history/size/traps"); value.Exists() {
+ data.HistorySizeTraps = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/directory/user/policy"); value.Exists() {
+ data.DirectoryUserPolicy = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/scheduler/applet/thread/class/default"); value.Exists() {
+ data.SchedulerAppletThreadClassDefault = types.BoolValue(true)
+ } else {
+ data.SchedulerAppletThreadClassDefault = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/scheduler/applet/thread/class/number"); value.Exists() {
+ data.SchedulerAppletThreadClassNumber = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/detector/rpc/max-sessions"); value.Exists() {
+ data.DetectorRpcMaxSessions = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/detector/routing/bootup-delay"); value.Exists() {
+ data.DetectorRoutingBootupDelay = types.Float64Value(value.Float())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/applet"); value.Exists() {
+ data.Applets = make([]EEMApplets, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := EEMApplets{}
+ if cValue := helpers.GetFromXPath(v, "name"); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "authorization"); cValue.Exists() {
+ item.Authorization = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "class"); cValue.Exists() {
+ item.Class = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "description"); cValue.Exists() {
+ item.Description = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "event/cli/pattern"); cValue.Exists() {
+ item.EventCliPattern = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "event/cli/sync"); cValue.Exists() {
+ item.EventCliSync = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "event/cli/skip"); cValue.Exists() {
+ item.EventCliSkip = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "action-config/action"); cValue.Exists() {
+ item.Actions = make([]EEMAppletsActions, 0)
+ cValue.ForEach(func(_ int, cv xmldot.Result) bool {
+ cItem := EEMAppletsActions{}
+ if ccValue := helpers.GetFromXPath(cv, "name"); ccValue.Exists() {
+ cItem.Name = types.StringValue(ccValue.String())
}
- if ccValue := cv.Get("info.type.snmp.var.variable-name"); ccValue.Exists() {
+ if ccValue := helpers.GetFromXPath(cv, "cli-choice/command"); ccValue.Exists() {
+ cItem.CliCommand = types.StringValue(ccValue.String())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "regexp-option/string-pattern"); ccValue.Exists() {
+ cItem.RegexpStringPattern = types.StringValue(ccValue.String())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "regexp-option/string-input"); ccValue.Exists() {
+ cItem.RegexpStringInput = types.StringValue(ccValue.String())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "regexp-option/string-match"); ccValue.Exists() {
+ cItem.RegexpStringMatch = types.StringValue(ccValue.String())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "regexp-option/string-submatch1"); ccValue.Exists() {
+ cItem.RegexpStringMatch1 = types.StringValue(ccValue.String())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "regexp-option/string-submatch2"); ccValue.Exists() {
+ cItem.RegexpStringMatch2 = types.StringValue(ccValue.String())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "regexp-option/string-submatch3"); ccValue.Exists() {
+ cItem.RegexpStringMatch3 = types.StringValue(ccValue.String())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "syslog-option/facility"); ccValue.Exists() {
+ cItem.SyslogFacility = types.StringValue(ccValue.String())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "syslog-option/msg"); ccValue.Exists() {
+ cItem.SyslogMsg = types.StringValue(ccValue.String())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "syslog-option/priority"); ccValue.Exists() {
+ cItem.SyslogPriority = types.StringValue(ccValue.String())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "set/varname"); ccValue.Exists() {
+ cItem.SetVarname = types.StringValue(ccValue.String())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "set/value"); ccValue.Exists() {
+ cItem.SetValue = types.StringValue(ccValue.String())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "if/string-op-1"); ccValue.Exists() {
+ cItem.IfStringOp1 = types.StringValue(ccValue.String())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "if/keyword"); ccValue.Exists() {
+ cItem.IfKeyword = types.StringValue(ccValue.String())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "if/string-op-2"); ccValue.Exists() {
+ cItem.IfStringOp2 = types.StringValue(ccValue.String())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "if/goto"); ccValue.Exists() {
+ cItem.IfGoto = types.StringValue(ccValue.String())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "elseif/operand1"); ccValue.Exists() {
+ cItem.ElseifOperand1 = types.StringValue(ccValue.String())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "elseif/operation"); ccValue.Exists() {
+ cItem.ElseifOperation = types.StringValue(ccValue.String())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "elseif/operand2"); ccValue.Exists() {
+ cItem.ElseifOperand2 = types.StringValue(ccValue.String())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "else"); ccValue.Exists() {
+ cItem.Else = types.BoolValue(true)
+ } else {
+ cItem.Else = types.BoolValue(false)
+ }
+ if ccValue := helpers.GetFromXPath(cv, "while/operand1"); ccValue.Exists() {
+ cItem.WhileOperand1 = types.StringValue(ccValue.String())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "while/operation"); ccValue.Exists() {
+ cItem.WhileOperation = types.StringValue(ccValue.String())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "while/operand2"); ccValue.Exists() {
+ cItem.WhileOperand2 = types.StringValue(ccValue.String())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "break"); ccValue.Exists() {
+ cItem.Break = types.BoolValue(true)
+ } else {
+ cItem.Break = types.BoolValue(false)
+ }
+ if ccValue := helpers.GetFromXPath(cv, "continue"); ccValue.Exists() {
+ cItem.Continue = types.BoolValue(true)
+ } else {
+ cItem.Continue = types.BoolValue(false)
+ }
+ if ccValue := helpers.GetFromXPath(cv, "increment/varname"); ccValue.Exists() {
+ cItem.IncrementVarname = types.StringValue(ccValue.String())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "increment/value"); ccValue.Exists() {
+ cItem.IncrementValue = types.StringValue(ccValue.String())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "decrement/varname"); ccValue.Exists() {
+ cItem.DecrementVarname = types.StringValue(ccValue.String())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "decrement/value"); ccValue.Exists() {
+ cItem.DecrementValue = types.StringValue(ccValue.String())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "append/varname"); ccValue.Exists() {
+ cItem.AppendVarname = types.StringValue(ccValue.String())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "append/value"); ccValue.Exists() {
+ cItem.AppendValue = types.StringValue(ccValue.String())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "divide/operand1"); ccValue.Exists() {
+ cItem.DivideOperand1 = types.StringValue(ccValue.String())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "divide/operand2"); ccValue.Exists() {
+ cItem.DivideOperand2 = types.StringValue(ccValue.String())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "foreach/loopvar"); ccValue.Exists() {
+ cItem.ForeachLoopvar = types.StringValue(ccValue.String())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "foreach/iterator"); ccValue.Exists() {
+ cItem.ForeachIterator = types.StringValue(ccValue.String())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "foreach/delimiter"); ccValue.Exists() {
+ cItem.ForeachDelimiter = types.StringValue(ccValue.String())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "gets"); ccValue.Exists() {
+ cItem.Gets = types.StringValue(ccValue.String())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "puts"); ccValue.Exists() {
+ cItem.Puts = types.StringValue(ccValue.String())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "wait"); ccValue.Exists() {
+ cItem.Wait = types.Int64Value(ccValue.Int())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "end"); ccValue.Exists() {
+ cItem.End = types.BoolValue(true)
+ } else {
+ cItem.End = types.BoolValue(false)
+ }
+ if ccValue := helpers.GetFromXPath(cv, "exit"); ccValue.Exists() {
+ cItem.Exit = types.BoolValue(true)
+ } else {
+ cItem.Exit = types.BoolValue(false)
+ }
+ if ccValue := helpers.GetFromXPath(cv, "reload"); ccValue.Exists() {
+ cItem.Reload = types.BoolValue(true)
+ } else {
+ cItem.Reload = types.BoolValue(false)
+ }
+ if ccValue := helpers.GetFromXPath(cv, "context/retrieve/key"); ccValue.Exists() {
+ cItem.ContextRetrieveKey = types.StringValue(ccValue.String())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "context/retrieve/variable"); ccValue.Exists() {
+ cItem.ContextRetrieveVariable = types.StringValue(ccValue.String())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "context/save/key"); ccValue.Exists() {
+ cItem.ContextSaveKey = types.StringValue(ccValue.String())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "context/save/variable"); ccValue.Exists() {
+ cItem.ContextSaveVariable = types.StringValue(ccValue.String())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "string/trim"); ccValue.Exists() {
+ cItem.StringTrim = types.StringValue(ccValue.String())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "info/type/snmp/trap/enterprise-oid"); ccValue.Exists() {
+ cItem.InfoTypeSnmpTrapEnterpriseOid = types.StringValue(ccValue.String())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "info/type/snmp/trap/generic-trapnum"); ccValue.Exists() {
+ cItem.InfoTypeSnmpTrapGenericTrapnum = types.Int64Value(ccValue.Int())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "info/type/snmp/trap/specific-trapnum"); ccValue.Exists() {
+ cItem.InfoTypeSnmpTrapSpecificTrapnum = types.Int64Value(ccValue.Int())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "info/type/snmp/trap/trap-oid"); ccValue.Exists() {
+ cItem.InfoTypeSnmpTrapTrapOid = types.StringValue(ccValue.String())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "info/type/snmp/trap/trap-var"); ccValue.Exists() {
+ cItem.InfoTypeSnmpTrapTrapVar = types.StringValue(ccValue.String())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "handle-error/type"); ccValue.Exists() {
+ cItem.HandleErrorType = types.StringValue(ccValue.String())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "counter/name"); ccValue.Exists() {
+ cItem.CounterName = types.StringValue(ccValue.String())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "counter/value"); ccValue.Exists() {
+ cItem.CounterValue = types.Int64Value(ccValue.Int())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "counter/op/dec"); ccValue.Exists() {
+ cItem.CounterOpDec = types.BoolValue(true)
+ } else {
+ cItem.CounterOpDec = types.BoolValue(false)
+ }
+ if ccValue := helpers.GetFromXPath(cv, "counter/op/inc"); ccValue.Exists() {
+ cItem.CounterOpInc = types.BoolValue(true)
+ } else {
+ cItem.CounterOpInc = types.BoolValue(false)
+ }
+ if ccValue := helpers.GetFromXPath(cv, "counter/op/set"); ccValue.Exists() {
+ cItem.CounterOpSet = types.BoolValue(true)
+ } else {
+ cItem.CounterOpSet = types.BoolValue(false)
+ }
+ if ccValue := helpers.GetFromXPath(cv, "counter/op/nop"); ccValue.Exists() {
+ cItem.CounterOpNop = types.BoolValue(true)
+ } else {
+ cItem.CounterOpNop = types.BoolValue(false)
+ }
+ if ccValue := helpers.GetFromXPath(cv, "snmp-trap/intdata1"); ccValue.Exists() {
+ cItem.SnmpTrapIntdata1 = types.Int64Value(ccValue.Int())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "snmp-trap/intdata2"); ccValue.Exists() {
+ cItem.SnmpTrapIntdata2 = types.Int64Value(ccValue.Int())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "snmp-trap/strdata"); ccValue.Exists() {
+ cItem.SnmpTrapStrdata = types.StringValue(ccValue.String())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "info/type/snmp/var/variable-name"); ccValue.Exists() {
cItem.InfoTypeSnmpVar = types.StringValue(ccValue.String())
}
- if ccValue := cv.Get("info.type.snmp.var.oid"); ccValue.Exists() {
+ if ccValue := helpers.GetFromXPath(cv, "info/type/snmp/var/oid"); ccValue.Exists() {
cItem.InfoTypeSnmpVarOid = types.StringValue(ccValue.String())
}
- if ccValue := cv.Get("info.type.snmp.var.oid-type"); ccValue.Exists() {
+ if ccValue := helpers.GetFromXPath(cv, "info/type/snmp/var/oid-type"); ccValue.Exists() {
cItem.InfoTypeSnmpVarOidType = types.StringValue(ccValue.String())
}
- if ccValue := cv.Get("info.type.snmp.var.oid-type-value"); ccValue.Exists() {
- cItem.InfoTypeSnmpVarOidTypeValue = types.StringValue(ccValue.String())
+ if ccValue := helpers.GetFromXPath(cv, "info/type/snmp/var/oid-type-value"); ccValue.Exists() {
+ cItem.InfoTypeSnmpVarOidTypeValue = types.StringValue(ccValue.String())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "string/trim/first/string-op-1"); ccValue.Exists() {
+ cItem.StringTrimFirstStringOp1 = types.StringValue(ccValue.String())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "string/trim/first/string-op-2"); ccValue.Exists() {
+ cItem.StringTrimFirstStringOp2 = types.StringValue(ccValue.String())
+ }
+ item.Actions = append(item.Actions, cItem)
+ return true
+ })
+ }
+ if cValue := helpers.GetFromXPath(v, "event/timer-choice/watchdog/time-set"); cValue.Exists() {
+ item.EventTimerWatchdogTime = types.Float64Value(cValue.Float())
+ }
+ if cValue := helpers.GetFromXPath(v, "event/timer-choice/watchdog/name"); cValue.Exists() {
+ item.EventTimerWatchdogName = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "event/timer-choice/watchdog/maxrun-set"); cValue.Exists() {
+ item.EventTimerWatchdogMaxrun = types.Float64Value(cValue.Float())
+ }
+ if cValue := helpers.GetFromXPath(v, "event/timer-choice/watchdog/ratelimit-set"); cValue.Exists() {
+ item.EventTimerWatchdogRatelimit = types.Float64Value(cValue.Float())
+ }
+ if cValue := helpers.GetFromXPath(v, "event/timer-choice/cron/cron-entry"); cValue.Exists() {
+ item.EventTimerCronEntry = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "event/timer-choice/cron/name"); cValue.Exists() {
+ item.EventTimerCronName = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "event/timer-choice/cron/maxrun-set"); cValue.Exists() {
+ item.EventTimerCronMaxrun = types.Float64Value(cValue.Float())
+ }
+ if cValue := helpers.GetFromXPath(v, "event/timer-choice/cron/ratelimit-set"); cValue.Exists() {
+ item.EventTimerCronRatelimit = types.Float64Value(cValue.Float())
+ }
+ data.Applets = append(data.Applets, item)
+ return true
+ })
+ }
+}
+
+// End of section. //template:end fromBodyDataXML
+
+// Section below is generated&owned by "gen/generator.go". //template:begin getDeletedItems
+
+func (data *EEM) getDeletedItems(ctx context.Context, state EEM) []string {
+ deletedItems := make([]string, 0)
+ for i := range state.Applets {
+ stateKeyValues := [...]string{state.Applets[i].Name.ValueString()}
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.Applets[i].Name.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.Applets {
+ found = true
+ if state.Applets[i].Name.ValueString() != data.Applets[j].Name.ValueString() {
+ found = false
+ }
+ if found {
+ if !state.Applets[i].EventTimerCronRatelimit.IsNull() && data.Applets[j].EventTimerCronRatelimit.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/applet=%v/event/timer-choice/cron/ratelimit-set", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ if !state.Applets[i].EventTimerCronMaxrun.IsNull() && data.Applets[j].EventTimerCronMaxrun.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/applet=%v/event/timer-choice/cron/maxrun-set", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ if !state.Applets[i].EventTimerCronName.IsNull() && data.Applets[j].EventTimerCronName.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/applet=%v/event/timer-choice/cron/name", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ if !state.Applets[i].EventTimerCronEntry.IsNull() && data.Applets[j].EventTimerCronEntry.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/applet=%v/event/timer-choice/cron/cron-entry", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ if !state.Applets[i].EventTimerWatchdogRatelimit.IsNull() && data.Applets[j].EventTimerWatchdogRatelimit.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/applet=%v/event/timer-choice/watchdog/ratelimit-set", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ if !state.Applets[i].EventTimerWatchdogMaxrun.IsNull() && data.Applets[j].EventTimerWatchdogMaxrun.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/applet=%v/event/timer-choice/watchdog/maxrun-set", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ if !state.Applets[i].EventTimerWatchdogName.IsNull() && data.Applets[j].EventTimerWatchdogName.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/applet=%v/event/timer-choice/watchdog/name", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ if !state.Applets[i].EventTimerWatchdogTime.IsNull() && data.Applets[j].EventTimerWatchdogTime.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/applet=%v/event/timer-choice/watchdog/time-set", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ for ci := range state.Applets[i].Actions {
+ cstateKeyValues := [...]string{state.Applets[i].Actions[ci].Name.ValueString()}
+
+ cemptyKeys := true
+ if !reflect.ValueOf(state.Applets[i].Actions[ci].Name.ValueString()).IsZero() {
+ cemptyKeys = false
+ }
+ if cemptyKeys {
+ continue
}
- if ccValue := cv.Get("string.trim.first.string-op-1"); ccValue.Exists() {
- cItem.StringTrimFirstStringOp1 = types.StringValue(ccValue.String())
+
+ found := false
+ for cj := range data.Applets[j].Actions {
+ found = true
+ if state.Applets[i].Actions[ci].Name.ValueString() != data.Applets[j].Actions[cj].Name.ValueString() {
+ found = false
+ }
+ if found {
+ if !state.Applets[i].Actions[ci].StringTrimFirstStringOp2.IsNull() && data.Applets[j].Actions[cj].StringTrimFirstStringOp2.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/applet=%v/action-config/action=%v/string/trim/first/string-op-2", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ }
+ if !state.Applets[i].Actions[ci].StringTrimFirstStringOp1.IsNull() && data.Applets[j].Actions[cj].StringTrimFirstStringOp1.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/applet=%v/action-config/action=%v/string/trim/first/string-op-1", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ }
+ if !state.Applets[i].Actions[ci].InfoTypeSnmpVarOidTypeValue.IsNull() && data.Applets[j].Actions[cj].InfoTypeSnmpVarOidTypeValue.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/applet=%v/action-config/action=%v/info/type/snmp/var/oid-type-value", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ }
+ if !state.Applets[i].Actions[ci].InfoTypeSnmpVarOidType.IsNull() && data.Applets[j].Actions[cj].InfoTypeSnmpVarOidType.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/applet=%v/action-config/action=%v/info/type/snmp/var/oid-type", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ }
+ if !state.Applets[i].Actions[ci].InfoTypeSnmpVarOid.IsNull() && data.Applets[j].Actions[cj].InfoTypeSnmpVarOid.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/applet=%v/action-config/action=%v/info/type/snmp/var/oid", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ }
+ if !state.Applets[i].Actions[ci].InfoTypeSnmpVar.IsNull() && data.Applets[j].Actions[cj].InfoTypeSnmpVar.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/applet=%v/action-config/action=%v/info/type/snmp/var/variable-name", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ }
+ if !state.Applets[i].Actions[ci].SnmpTrapStrdata.IsNull() && data.Applets[j].Actions[cj].SnmpTrapStrdata.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/applet=%v/action-config/action=%v/snmp-trap/strdata", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ }
+ if !state.Applets[i].Actions[ci].SnmpTrapIntdata2.IsNull() && data.Applets[j].Actions[cj].SnmpTrapIntdata2.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/applet=%v/action-config/action=%v/snmp-trap/intdata2", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ }
+ if !state.Applets[i].Actions[ci].SnmpTrapIntdata1.IsNull() && data.Applets[j].Actions[cj].SnmpTrapIntdata1.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/applet=%v/action-config/action=%v/snmp-trap/intdata1", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ }
+ if !state.Applets[i].Actions[ci].CounterOpNop.IsNull() && data.Applets[j].Actions[cj].CounterOpNop.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/applet=%v/action-config/action=%v/counter/op/nop", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ }
+ if !state.Applets[i].Actions[ci].CounterOpSet.IsNull() && data.Applets[j].Actions[cj].CounterOpSet.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/applet=%v/action-config/action=%v/counter/op/set", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ }
+ if !state.Applets[i].Actions[ci].CounterOpInc.IsNull() && data.Applets[j].Actions[cj].CounterOpInc.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/applet=%v/action-config/action=%v/counter/op/inc", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ }
+ if !state.Applets[i].Actions[ci].CounterOpDec.IsNull() && data.Applets[j].Actions[cj].CounterOpDec.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/applet=%v/action-config/action=%v/counter/op/dec", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ }
+ if !state.Applets[i].Actions[ci].CounterValue.IsNull() && data.Applets[j].Actions[cj].CounterValue.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/applet=%v/action-config/action=%v/counter/value", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ }
+ if !state.Applets[i].Actions[ci].CounterName.IsNull() && data.Applets[j].Actions[cj].CounterName.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/applet=%v/action-config/action=%v/counter/name", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ }
+ if !state.Applets[i].Actions[ci].HandleErrorType.IsNull() && data.Applets[j].Actions[cj].HandleErrorType.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/applet=%v/action-config/action=%v/handle-error/type", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ }
+ if !state.Applets[i].Actions[ci].InfoTypeSnmpTrapTrapVar.IsNull() && data.Applets[j].Actions[cj].InfoTypeSnmpTrapTrapVar.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/applet=%v/action-config/action=%v/info/type/snmp/trap/trap-var", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ }
+ if !state.Applets[i].Actions[ci].InfoTypeSnmpTrapTrapOid.IsNull() && data.Applets[j].Actions[cj].InfoTypeSnmpTrapTrapOid.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/applet=%v/action-config/action=%v/info/type/snmp/trap/trap-oid", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ }
+ if !state.Applets[i].Actions[ci].InfoTypeSnmpTrapSpecificTrapnum.IsNull() && data.Applets[j].Actions[cj].InfoTypeSnmpTrapSpecificTrapnum.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/applet=%v/action-config/action=%v/info/type/snmp/trap/specific-trapnum", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ }
+ if !state.Applets[i].Actions[ci].InfoTypeSnmpTrapGenericTrapnum.IsNull() && data.Applets[j].Actions[cj].InfoTypeSnmpTrapGenericTrapnum.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/applet=%v/action-config/action=%v/info/type/snmp/trap/generic-trapnum", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ }
+ if !state.Applets[i].Actions[ci].InfoTypeSnmpTrapEnterpriseOid.IsNull() && data.Applets[j].Actions[cj].InfoTypeSnmpTrapEnterpriseOid.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/applet=%v/action-config/action=%v/info/type/snmp/trap/enterprise-oid", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ }
+ if !state.Applets[i].Actions[ci].StringTrim.IsNull() && data.Applets[j].Actions[cj].StringTrim.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/applet=%v/action-config/action=%v/string/trim", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ }
+ if !state.Applets[i].Actions[ci].ContextSaveVariable.IsNull() && data.Applets[j].Actions[cj].ContextSaveVariable.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/applet=%v/action-config/action=%v/context/save/variable", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ }
+ if !state.Applets[i].Actions[ci].ContextSaveKey.IsNull() && data.Applets[j].Actions[cj].ContextSaveKey.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/applet=%v/action-config/action=%v/context/save/key", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ }
+ if !state.Applets[i].Actions[ci].ContextRetrieveVariable.IsNull() && data.Applets[j].Actions[cj].ContextRetrieveVariable.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/applet=%v/action-config/action=%v/context/retrieve/variable", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ }
+ if !state.Applets[i].Actions[ci].ContextRetrieveKey.IsNull() && data.Applets[j].Actions[cj].ContextRetrieveKey.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/applet=%v/action-config/action=%v/context/retrieve/key", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ }
+ if !state.Applets[i].Actions[ci].Reload.IsNull() && data.Applets[j].Actions[cj].Reload.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/applet=%v/action-config/action=%v/reload", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ }
+ if !state.Applets[i].Actions[ci].Exit.IsNull() && data.Applets[j].Actions[cj].Exit.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/applet=%v/action-config/action=%v/exit", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ }
+ if !state.Applets[i].Actions[ci].End.IsNull() && data.Applets[j].Actions[cj].End.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/applet=%v/action-config/action=%v/end", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ }
+ if !state.Applets[i].Actions[ci].Wait.IsNull() && data.Applets[j].Actions[cj].Wait.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/applet=%v/action-config/action=%v/wait", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ }
+ if !state.Applets[i].Actions[ci].Puts.IsNull() && data.Applets[j].Actions[cj].Puts.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/applet=%v/action-config/action=%v/puts", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ }
+ if !state.Applets[i].Actions[ci].Gets.IsNull() && data.Applets[j].Actions[cj].Gets.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/applet=%v/action-config/action=%v/gets", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ }
+ if !state.Applets[i].Actions[ci].ForeachDelimiter.IsNull() && data.Applets[j].Actions[cj].ForeachDelimiter.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/applet=%v/action-config/action=%v/foreach/delimiter", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ }
+ if !state.Applets[i].Actions[ci].ForeachIterator.IsNull() && data.Applets[j].Actions[cj].ForeachIterator.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/applet=%v/action-config/action=%v/foreach/iterator", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ }
+ if !state.Applets[i].Actions[ci].ForeachLoopvar.IsNull() && data.Applets[j].Actions[cj].ForeachLoopvar.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/applet=%v/action-config/action=%v/foreach/loopvar", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ }
+ if !state.Applets[i].Actions[ci].DivideOperand2.IsNull() && data.Applets[j].Actions[cj].DivideOperand2.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/applet=%v/action-config/action=%v/divide/operand2", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ }
+ if !state.Applets[i].Actions[ci].DivideOperand1.IsNull() && data.Applets[j].Actions[cj].DivideOperand1.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/applet=%v/action-config/action=%v/divide/operand1", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ }
+ if !state.Applets[i].Actions[ci].AppendValue.IsNull() && data.Applets[j].Actions[cj].AppendValue.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/applet=%v/action-config/action=%v/append/value", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ }
+ if !state.Applets[i].Actions[ci].AppendVarname.IsNull() && data.Applets[j].Actions[cj].AppendVarname.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/applet=%v/action-config/action=%v/append/varname", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ }
+ if !state.Applets[i].Actions[ci].DecrementValue.IsNull() && data.Applets[j].Actions[cj].DecrementValue.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/applet=%v/action-config/action=%v/decrement/value", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ }
+ if !state.Applets[i].Actions[ci].DecrementVarname.IsNull() && data.Applets[j].Actions[cj].DecrementVarname.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/applet=%v/action-config/action=%v/decrement/varname", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ }
+ if !state.Applets[i].Actions[ci].IncrementValue.IsNull() && data.Applets[j].Actions[cj].IncrementValue.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/applet=%v/action-config/action=%v/increment/value", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ }
+ if !state.Applets[i].Actions[ci].IncrementVarname.IsNull() && data.Applets[j].Actions[cj].IncrementVarname.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/applet=%v/action-config/action=%v/increment/varname", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ }
+ if !state.Applets[i].Actions[ci].Continue.IsNull() && data.Applets[j].Actions[cj].Continue.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/applet=%v/action-config/action=%v/continue", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ }
+ if !state.Applets[i].Actions[ci].Break.IsNull() && data.Applets[j].Actions[cj].Break.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/applet=%v/action-config/action=%v/break", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ }
+ if !state.Applets[i].Actions[ci].WhileOperand2.IsNull() && data.Applets[j].Actions[cj].WhileOperand2.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/applet=%v/action-config/action=%v/while/operand2", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ }
+ if !state.Applets[i].Actions[ci].WhileOperation.IsNull() && data.Applets[j].Actions[cj].WhileOperation.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/applet=%v/action-config/action=%v/while/operation", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ }
+ if !state.Applets[i].Actions[ci].WhileOperand1.IsNull() && data.Applets[j].Actions[cj].WhileOperand1.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/applet=%v/action-config/action=%v/while/operand1", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ }
+ if !state.Applets[i].Actions[ci].Else.IsNull() && data.Applets[j].Actions[cj].Else.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/applet=%v/action-config/action=%v/else", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ }
+ if !state.Applets[i].Actions[ci].ElseifOperand2.IsNull() && data.Applets[j].Actions[cj].ElseifOperand2.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/applet=%v/action-config/action=%v/elseif/operand2", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ }
+ if !state.Applets[i].Actions[ci].ElseifOperation.IsNull() && data.Applets[j].Actions[cj].ElseifOperation.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/applet=%v/action-config/action=%v/elseif/operation", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ }
+ if !state.Applets[i].Actions[ci].ElseifOperand1.IsNull() && data.Applets[j].Actions[cj].ElseifOperand1.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/applet=%v/action-config/action=%v/elseif/operand1", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ }
+ if !state.Applets[i].Actions[ci].IfGoto.IsNull() && data.Applets[j].Actions[cj].IfGoto.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/applet=%v/action-config/action=%v/if/goto", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ }
+ if !state.Applets[i].Actions[ci].IfStringOp2.IsNull() && data.Applets[j].Actions[cj].IfStringOp2.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/applet=%v/action-config/action=%v/if/string-op-2", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ }
+ if !state.Applets[i].Actions[ci].IfKeyword.IsNull() && data.Applets[j].Actions[cj].IfKeyword.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/applet=%v/action-config/action=%v/if/keyword", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ }
+ if !state.Applets[i].Actions[ci].IfStringOp1.IsNull() && data.Applets[j].Actions[cj].IfStringOp1.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/applet=%v/action-config/action=%v/if/string-op-1", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ }
+ if !state.Applets[i].Actions[ci].SetValue.IsNull() && data.Applets[j].Actions[cj].SetValue.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/applet=%v/action-config/action=%v/set/value", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ }
+ if !state.Applets[i].Actions[ci].SetVarname.IsNull() && data.Applets[j].Actions[cj].SetVarname.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/applet=%v/action-config/action=%v/set/varname", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ }
+ if !state.Applets[i].Actions[ci].SyslogPriority.IsNull() && data.Applets[j].Actions[cj].SyslogPriority.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/applet=%v/action-config/action=%v/syslog-option/priority", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ }
+ if !state.Applets[i].Actions[ci].SyslogMsg.IsNull() && data.Applets[j].Actions[cj].SyslogMsg.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/applet=%v/action-config/action=%v/syslog-option/msg", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ }
+ if !state.Applets[i].Actions[ci].SyslogFacility.IsNull() && data.Applets[j].Actions[cj].SyslogFacility.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/applet=%v/action-config/action=%v/syslog-option/facility", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ }
+ if !state.Applets[i].Actions[ci].RegexpStringMatch3.IsNull() && data.Applets[j].Actions[cj].RegexpStringMatch3.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/applet=%v/action-config/action=%v/regexp-option/string-submatch3", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ }
+ if !state.Applets[i].Actions[ci].RegexpStringMatch2.IsNull() && data.Applets[j].Actions[cj].RegexpStringMatch2.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/applet=%v/action-config/action=%v/regexp-option/string-submatch2", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ }
+ if !state.Applets[i].Actions[ci].RegexpStringMatch1.IsNull() && data.Applets[j].Actions[cj].RegexpStringMatch1.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/applet=%v/action-config/action=%v/regexp-option/string-submatch1", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ }
+ if !state.Applets[i].Actions[ci].RegexpStringMatch.IsNull() && data.Applets[j].Actions[cj].RegexpStringMatch.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/applet=%v/action-config/action=%v/regexp-option/string-match", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ }
+ if !state.Applets[i].Actions[ci].RegexpStringInput.IsNull() && data.Applets[j].Actions[cj].RegexpStringInput.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/applet=%v/action-config/action=%v/regexp-option/string-input", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ }
+ if !state.Applets[i].Actions[ci].RegexpStringPattern.IsNull() && data.Applets[j].Actions[cj].RegexpStringPattern.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/applet=%v/action-config/action=%v/regexp-option/string-pattern", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ }
+ if !state.Applets[i].Actions[ci].CliCommand.IsNull() && data.Applets[j].Actions[cj].CliCommand.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/applet=%v/action-config/action=%v/cli-choice/command", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ }
+ break
+ }
}
- if ccValue := cv.Get("string.trim.first.string-op-2"); ccValue.Exists() {
- cItem.StringTrimFirstStringOp2 = types.StringValue(ccValue.String())
+ if !found {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/applet=%v/action-config/action=%v", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
}
- item.Actions = append(item.Actions, cItem)
- return true
- })
- }
- if cValue := v.Get("event.timer-choice.watchdog.time-set"); cValue.Exists() {
- item.EventTimerWatchdogTime = types.Float64Value(cValue.Float())
- }
- if cValue := v.Get("event.timer-choice.watchdog.name"); cValue.Exists() {
- item.EventTimerWatchdogName = types.StringValue(cValue.String())
- }
- if cValue := v.Get("event.timer-choice.watchdog.maxrun-set"); cValue.Exists() {
- item.EventTimerWatchdogMaxrun = types.Float64Value(cValue.Float())
- }
- if cValue := v.Get("event.timer-choice.watchdog.ratelimit-set"); cValue.Exists() {
- item.EventTimerWatchdogRatelimit = types.Float64Value(cValue.Float())
- }
- if cValue := v.Get("event.timer-choice.cron.cron-entry"); cValue.Exists() {
- item.EventTimerCronEntry = types.StringValue(cValue.String())
- }
- if cValue := v.Get("event.timer-choice.cron.name"); cValue.Exists() {
- item.EventTimerCronName = types.StringValue(cValue.String())
+ }
+ if !state.Applets[i].EventCliSkip.IsNull() && data.Applets[j].EventCliSkip.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/applet=%v/event/cli/skip", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ if !state.Applets[i].EventCliSync.IsNull() && data.Applets[j].EventCliSync.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/applet=%v/event/cli/sync", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ if !state.Applets[i].EventCliPattern.IsNull() && data.Applets[j].EventCliPattern.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/applet=%v/event/cli/pattern", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ if !state.Applets[i].Description.IsNull() && data.Applets[j].Description.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/applet=%v/description", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ if !state.Applets[i].Class.IsNull() && data.Applets[j].Class.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/applet=%v/class", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ if !state.Applets[i].Authorization.IsNull() && data.Applets[j].Authorization.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/applet=%v/authorization", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ break
}
- if cValue := v.Get("event.timer-choice.cron.maxrun-set"); cValue.Exists() {
- item.EventTimerCronMaxrun = types.Float64Value(cValue.Float())
+ }
+ if !found {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/applet=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ }
+ if !state.DetectorRoutingBootupDelay.IsNull() && data.DetectorRoutingBootupDelay.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/detector/routing/bootup-delay", state.getPath()))
+ }
+ if !state.DetectorRpcMaxSessions.IsNull() && data.DetectorRpcMaxSessions.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/detector/rpc/max-sessions", state.getPath()))
+ }
+ if !state.SchedulerAppletThreadClassNumber.IsNull() && data.SchedulerAppletThreadClassNumber.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/scheduler/applet/thread/class/number", state.getPath()))
+ }
+ if !state.SchedulerAppletThreadClassDefault.IsNull() && data.SchedulerAppletThreadClassDefault.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/scheduler/applet/thread/class/default", state.getPath()))
+ }
+ if !state.DirectoryUserPolicy.IsNull() && data.DirectoryUserPolicy.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/directory/user/policy", state.getPath()))
+ }
+ if !state.HistorySizeTraps.IsNull() && data.HistorySizeTraps.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/history/size/traps", state.getPath()))
+ }
+ if !state.HistorySizeEvents.IsNull() && data.HistorySizeEvents.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/history/size/events", state.getPath()))
+ }
+ if !state.SessionCliUsernamePrivilege.IsNull() && data.SessionCliUsernamePrivilege.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/session/cli/username/privilege_set", state.getPath()))
+ }
+ if !state.SessionCliUsername.IsNull() && data.SessionCliUsername.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/session/cli/username/username_in_word_set", state.getPath()))
+ }
+ for i := range state.EnvironmentVariables {
+ stateKeyValues := [...]string{state.EnvironmentVariables[i].Name.ValueString()}
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.EnvironmentVariables[i].Name.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.EnvironmentVariables {
+ found = true
+ if state.EnvironmentVariables[i].Name.ValueString() != data.EnvironmentVariables[j].Name.ValueString() {
+ found = false
}
- if cValue := v.Get("event.timer-choice.cron.ratelimit-set"); cValue.Exists() {
- item.EventTimerCronRatelimit = types.Float64Value(cValue.Float())
+ if found {
+ if !state.EnvironmentVariables[i].Value.IsNull() && data.EnvironmentVariables[j].Value.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/environment=%v/value", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ break
}
- data.Applets = append(data.Applets, item)
- return true
- })
+ }
+ if !found {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/environment=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
}
+
+ return deletedItems
}
-// End of section. //template:end fromBodyData
+// End of section. //template:end getDeletedItems
-// Section below is generated&owned by "gen/generator.go". //template:begin getDeletedItems
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletedItemsXML
-func (data *EEM) getDeletedItems(ctx context.Context, state EEM) []string {
- deletedItems := make([]string, 0)
+func (data *EEM) addDeletedItemsXML(ctx context.Context, state EEM, body string) string {
+ b := netconf.NewBody(body)
+ for i := range state.EnvironmentVariables {
+ stateKeys := [...]string{"name"}
+ stateKeyValues := [...]string{state.EnvironmentVariables[i].Name.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.EnvironmentVariables[i].Name.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.EnvironmentVariables {
+ found = true
+ if state.EnvironmentVariables[i].Name.ValueString() != data.EnvironmentVariables[j].Name.ValueString() {
+ found = false
+ }
+ if found {
+ if !state.EnvironmentVariables[i].Value.IsNull() && data.EnvironmentVariables[j].Value.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/environment%v/value", predicates))
+ }
+ break
+ }
+ }
+ if !found {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/environment%v", predicates))
+ }
+ }
+ if !state.SessionCliUsername.IsNull() && data.SessionCliUsername.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/session/cli/username/username_in_word_set")
+ }
+ if !state.SessionCliUsernamePrivilege.IsNull() && data.SessionCliUsernamePrivilege.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/session/cli/username/privilege_set")
+ }
+ if !state.HistorySizeEvents.IsNull() && data.HistorySizeEvents.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/history/size/events")
+ }
+ if !state.HistorySizeTraps.IsNull() && data.HistorySizeTraps.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/history/size/traps")
+ }
+ if !state.DirectoryUserPolicy.IsNull() && data.DirectoryUserPolicy.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/directory/user/policy")
+ }
+ if !state.SchedulerAppletThreadClassDefault.IsNull() && data.SchedulerAppletThreadClassDefault.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/scheduler/applet/thread/class/default")
+ }
+ if !state.SchedulerAppletThreadClassNumber.IsNull() && data.SchedulerAppletThreadClassNumber.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/scheduler/applet/thread/class/number")
+ }
+ if !state.DetectorRpcMaxSessions.IsNull() && data.DetectorRpcMaxSessions.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/detector/rpc/max-sessions")
+ }
+ if !state.DetectorRoutingBootupDelay.IsNull() && data.DetectorRoutingBootupDelay.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/detector/routing/bootup-delay")
+ }
for i := range state.Applets {
+ stateKeys := [...]string{"name"}
stateKeyValues := [...]string{state.Applets[i].Name.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
emptyKeys := true
if !reflect.ValueOf(state.Applets[i].Name.ValueString()).IsZero() {
@@ -1826,32 +3900,31 @@ func (data *EEM) getDeletedItems(ctx context.Context, state EEM) []string {
found = false
}
if found {
- if !state.Applets[i].EventTimerCronRatelimit.IsNull() && data.Applets[j].EventTimerCronRatelimit.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/applet=%v/event/timer-choice/cron/ratelimit-set", state.getPath(), strings.Join(stateKeyValues[:], ",")))
- }
- if !state.Applets[i].EventTimerCronMaxrun.IsNull() && data.Applets[j].EventTimerCronMaxrun.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/applet=%v/event/timer-choice/cron/maxrun-set", state.getPath(), strings.Join(stateKeyValues[:], ",")))
- }
- if !state.Applets[i].EventTimerCronName.IsNull() && data.Applets[j].EventTimerCronName.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/applet=%v/event/timer-choice/cron/name", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ if !state.Applets[i].Authorization.IsNull() && data.Applets[j].Authorization.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/applet%v/authorization", predicates))
}
- if !state.Applets[i].EventTimerCronEntry.IsNull() && data.Applets[j].EventTimerCronEntry.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/applet=%v/event/timer-choice/cron/cron-entry", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ if !state.Applets[i].Class.IsNull() && data.Applets[j].Class.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/applet%v/class", predicates))
}
- if !state.Applets[i].EventTimerWatchdogRatelimit.IsNull() && data.Applets[j].EventTimerWatchdogRatelimit.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/applet=%v/event/timer-choice/watchdog/ratelimit-set", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ if !state.Applets[i].Description.IsNull() && data.Applets[j].Description.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/applet%v/description", predicates))
}
- if !state.Applets[i].EventTimerWatchdogMaxrun.IsNull() && data.Applets[j].EventTimerWatchdogMaxrun.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/applet=%v/event/timer-choice/watchdog/maxrun-set", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ if !state.Applets[i].EventCliPattern.IsNull() && data.Applets[j].EventCliPattern.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/applet%v/event/cli/pattern", predicates))
}
- if !state.Applets[i].EventTimerWatchdogName.IsNull() && data.Applets[j].EventTimerWatchdogName.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/applet=%v/event/timer-choice/watchdog/name", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ if !state.Applets[i].EventCliSync.IsNull() && data.Applets[j].EventCliSync.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/applet%v/event/cli/sync", predicates))
}
- if !state.Applets[i].EventTimerWatchdogTime.IsNull() && data.Applets[j].EventTimerWatchdogTime.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/applet=%v/event/timer-choice/watchdog/time-set", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ if !state.Applets[i].EventCliSkip.IsNull() && data.Applets[j].EventCliSkip.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/applet%v/event/cli/skip", predicates))
}
for ci := range state.Applets[i].Actions {
+ cstateKeys := [...]string{"name"}
cstateKeyValues := [...]string{state.Applets[i].Actions[ci].Name.ValueString()}
+ cpredicates := ""
+ for i := range cstateKeys {
+ cpredicates += fmt.Sprintf("[%s='%s']", cstateKeys[i], cstateKeyValues[i])
+ }
cemptyKeys := true
if !reflect.ValueOf(state.Applets[i].Actions[ci].Name.ValueString()).IsZero() {
@@ -1868,302 +3941,253 @@ func (data *EEM) getDeletedItems(ctx context.Context, state EEM) []string {
found = false
}
if found {
- if !state.Applets[i].Actions[ci].StringTrimFirstStringOp2.IsNull() && data.Applets[j].Actions[cj].StringTrimFirstStringOp2.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/applet=%v/action-config/action=%v/string/trim/first/string-op-2", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
- }
- if !state.Applets[i].Actions[ci].StringTrimFirstStringOp1.IsNull() && data.Applets[j].Actions[cj].StringTrimFirstStringOp1.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/applet=%v/action-config/action=%v/string/trim/first/string-op-1", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ if !state.Applets[i].Actions[ci].CliCommand.IsNull() && data.Applets[j].Actions[cj].CliCommand.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/applet%v/action-config/action%v/cli-choice/command", predicates, cpredicates))
}
- if !state.Applets[i].Actions[ci].InfoTypeSnmpVarOidTypeValue.IsNull() && data.Applets[j].Actions[cj].InfoTypeSnmpVarOidTypeValue.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/applet=%v/action-config/action=%v/info/type/snmp/var/oid-type-value", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ if !state.Applets[i].Actions[ci].RegexpStringPattern.IsNull() && data.Applets[j].Actions[cj].RegexpStringPattern.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/applet%v/action-config/action%v/regexp-option/string-pattern", predicates, cpredicates))
}
- if !state.Applets[i].Actions[ci].InfoTypeSnmpVarOidType.IsNull() && data.Applets[j].Actions[cj].InfoTypeSnmpVarOidType.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/applet=%v/action-config/action=%v/info/type/snmp/var/oid-type", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ if !state.Applets[i].Actions[ci].RegexpStringInput.IsNull() && data.Applets[j].Actions[cj].RegexpStringInput.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/applet%v/action-config/action%v/regexp-option/string-input", predicates, cpredicates))
}
- if !state.Applets[i].Actions[ci].InfoTypeSnmpVarOid.IsNull() && data.Applets[j].Actions[cj].InfoTypeSnmpVarOid.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/applet=%v/action-config/action=%v/info/type/snmp/var/oid", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ if !state.Applets[i].Actions[ci].RegexpStringMatch.IsNull() && data.Applets[j].Actions[cj].RegexpStringMatch.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/applet%v/action-config/action%v/regexp-option/string-match", predicates, cpredicates))
}
- if !state.Applets[i].Actions[ci].InfoTypeSnmpVar.IsNull() && data.Applets[j].Actions[cj].InfoTypeSnmpVar.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/applet=%v/action-config/action=%v/info/type/snmp/var/variable-name", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ if !state.Applets[i].Actions[ci].RegexpStringMatch1.IsNull() && data.Applets[j].Actions[cj].RegexpStringMatch1.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/applet%v/action-config/action%v/regexp-option/string-submatch1", predicates, cpredicates))
}
- if !state.Applets[i].Actions[ci].SnmpTrapStrdata.IsNull() && data.Applets[j].Actions[cj].SnmpTrapStrdata.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/applet=%v/action-config/action=%v/snmp-trap/strdata", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ if !state.Applets[i].Actions[ci].RegexpStringMatch2.IsNull() && data.Applets[j].Actions[cj].RegexpStringMatch2.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/applet%v/action-config/action%v/regexp-option/string-submatch2", predicates, cpredicates))
}
- if !state.Applets[i].Actions[ci].SnmpTrapIntdata2.IsNull() && data.Applets[j].Actions[cj].SnmpTrapIntdata2.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/applet=%v/action-config/action=%v/snmp-trap/intdata2", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ if !state.Applets[i].Actions[ci].RegexpStringMatch3.IsNull() && data.Applets[j].Actions[cj].RegexpStringMatch3.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/applet%v/action-config/action%v/regexp-option/string-submatch3", predicates, cpredicates))
}
- if !state.Applets[i].Actions[ci].SnmpTrapIntdata1.IsNull() && data.Applets[j].Actions[cj].SnmpTrapIntdata1.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/applet=%v/action-config/action=%v/snmp-trap/intdata1", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ if !state.Applets[i].Actions[ci].SyslogFacility.IsNull() && data.Applets[j].Actions[cj].SyslogFacility.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/applet%v/action-config/action%v/syslog-option/facility", predicates, cpredicates))
}
- if !state.Applets[i].Actions[ci].CounterOpNop.IsNull() && data.Applets[j].Actions[cj].CounterOpNop.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/applet=%v/action-config/action=%v/counter/op/nop", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ if !state.Applets[i].Actions[ci].SyslogMsg.IsNull() && data.Applets[j].Actions[cj].SyslogMsg.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/applet%v/action-config/action%v/syslog-option/msg", predicates, cpredicates))
}
- if !state.Applets[i].Actions[ci].CounterOpSet.IsNull() && data.Applets[j].Actions[cj].CounterOpSet.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/applet=%v/action-config/action=%v/counter/op/set", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ if !state.Applets[i].Actions[ci].SyslogPriority.IsNull() && data.Applets[j].Actions[cj].SyslogPriority.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/applet%v/action-config/action%v/syslog-option/priority", predicates, cpredicates))
}
- if !state.Applets[i].Actions[ci].CounterOpInc.IsNull() && data.Applets[j].Actions[cj].CounterOpInc.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/applet=%v/action-config/action=%v/counter/op/inc", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ if !state.Applets[i].Actions[ci].SetVarname.IsNull() && data.Applets[j].Actions[cj].SetVarname.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/applet%v/action-config/action%v/set/varname", predicates, cpredicates))
}
- if !state.Applets[i].Actions[ci].CounterOpDec.IsNull() && data.Applets[j].Actions[cj].CounterOpDec.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/applet=%v/action-config/action=%v/counter/op/dec", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ if !state.Applets[i].Actions[ci].SetValue.IsNull() && data.Applets[j].Actions[cj].SetValue.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/applet%v/action-config/action%v/set/value", predicates, cpredicates))
}
- if !state.Applets[i].Actions[ci].CounterValue.IsNull() && data.Applets[j].Actions[cj].CounterValue.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/applet=%v/action-config/action=%v/counter/value", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ if !state.Applets[i].Actions[ci].IfStringOp1.IsNull() && data.Applets[j].Actions[cj].IfStringOp1.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/applet%v/action-config/action%v/if/string-op-1", predicates, cpredicates))
}
- if !state.Applets[i].Actions[ci].CounterName.IsNull() && data.Applets[j].Actions[cj].CounterName.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/applet=%v/action-config/action=%v/counter/name", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ if !state.Applets[i].Actions[ci].IfKeyword.IsNull() && data.Applets[j].Actions[cj].IfKeyword.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/applet%v/action-config/action%v/if/keyword", predicates, cpredicates))
}
- if !state.Applets[i].Actions[ci].HandleErrorType.IsNull() && data.Applets[j].Actions[cj].HandleErrorType.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/applet=%v/action-config/action=%v/handle-error/type", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ if !state.Applets[i].Actions[ci].IfStringOp2.IsNull() && data.Applets[j].Actions[cj].IfStringOp2.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/applet%v/action-config/action%v/if/string-op-2", predicates, cpredicates))
}
- if !state.Applets[i].Actions[ci].InfoTypeSnmpTrapTrapVar.IsNull() && data.Applets[j].Actions[cj].InfoTypeSnmpTrapTrapVar.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/applet=%v/action-config/action=%v/info/type/snmp/trap/trap-var", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ if !state.Applets[i].Actions[ci].IfGoto.IsNull() && data.Applets[j].Actions[cj].IfGoto.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/applet%v/action-config/action%v/if/goto", predicates, cpredicates))
}
- if !state.Applets[i].Actions[ci].InfoTypeSnmpTrapTrapOid.IsNull() && data.Applets[j].Actions[cj].InfoTypeSnmpTrapTrapOid.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/applet=%v/action-config/action=%v/info/type/snmp/trap/trap-oid", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ if !state.Applets[i].Actions[ci].ElseifOperand1.IsNull() && data.Applets[j].Actions[cj].ElseifOperand1.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/applet%v/action-config/action%v/elseif/operand1", predicates, cpredicates))
}
- if !state.Applets[i].Actions[ci].InfoTypeSnmpTrapSpecificTrapnum.IsNull() && data.Applets[j].Actions[cj].InfoTypeSnmpTrapSpecificTrapnum.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/applet=%v/action-config/action=%v/info/type/snmp/trap/specific-trapnum", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ if !state.Applets[i].Actions[ci].ElseifOperation.IsNull() && data.Applets[j].Actions[cj].ElseifOperation.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/applet%v/action-config/action%v/elseif/operation", predicates, cpredicates))
}
- if !state.Applets[i].Actions[ci].InfoTypeSnmpTrapGenericTrapnum.IsNull() && data.Applets[j].Actions[cj].InfoTypeSnmpTrapGenericTrapnum.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/applet=%v/action-config/action=%v/info/type/snmp/trap/generic-trapnum", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ if !state.Applets[i].Actions[ci].ElseifOperand2.IsNull() && data.Applets[j].Actions[cj].ElseifOperand2.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/applet%v/action-config/action%v/elseif/operand2", predicates, cpredicates))
}
- if !state.Applets[i].Actions[ci].InfoTypeSnmpTrapEnterpriseOid.IsNull() && data.Applets[j].Actions[cj].InfoTypeSnmpTrapEnterpriseOid.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/applet=%v/action-config/action=%v/info/type/snmp/trap/enterprise-oid", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ if !state.Applets[i].Actions[ci].Else.IsNull() && data.Applets[j].Actions[cj].Else.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/applet%v/action-config/action%v/else", predicates, cpredicates))
}
- if !state.Applets[i].Actions[ci].StringTrim.IsNull() && data.Applets[j].Actions[cj].StringTrim.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/applet=%v/action-config/action=%v/string/trim", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ if !state.Applets[i].Actions[ci].WhileOperand1.IsNull() && data.Applets[j].Actions[cj].WhileOperand1.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/applet%v/action-config/action%v/while/operand1", predicates, cpredicates))
}
- if !state.Applets[i].Actions[ci].ContextSaveVariable.IsNull() && data.Applets[j].Actions[cj].ContextSaveVariable.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/applet=%v/action-config/action=%v/context/save/variable", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ if !state.Applets[i].Actions[ci].WhileOperation.IsNull() && data.Applets[j].Actions[cj].WhileOperation.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/applet%v/action-config/action%v/while/operation", predicates, cpredicates))
}
- if !state.Applets[i].Actions[ci].ContextSaveKey.IsNull() && data.Applets[j].Actions[cj].ContextSaveKey.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/applet=%v/action-config/action=%v/context/save/key", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ if !state.Applets[i].Actions[ci].WhileOperand2.IsNull() && data.Applets[j].Actions[cj].WhileOperand2.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/applet%v/action-config/action%v/while/operand2", predicates, cpredicates))
}
- if !state.Applets[i].Actions[ci].ContextRetrieveVariable.IsNull() && data.Applets[j].Actions[cj].ContextRetrieveVariable.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/applet=%v/action-config/action=%v/context/retrieve/variable", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ if !state.Applets[i].Actions[ci].Break.IsNull() && data.Applets[j].Actions[cj].Break.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/applet%v/action-config/action%v/break", predicates, cpredicates))
}
- if !state.Applets[i].Actions[ci].ContextRetrieveKey.IsNull() && data.Applets[j].Actions[cj].ContextRetrieveKey.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/applet=%v/action-config/action=%v/context/retrieve/key", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ if !state.Applets[i].Actions[ci].Continue.IsNull() && data.Applets[j].Actions[cj].Continue.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/applet%v/action-config/action%v/continue", predicates, cpredicates))
}
- if !state.Applets[i].Actions[ci].Reload.IsNull() && data.Applets[j].Actions[cj].Reload.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/applet=%v/action-config/action=%v/reload", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ if !state.Applets[i].Actions[ci].IncrementVarname.IsNull() && data.Applets[j].Actions[cj].IncrementVarname.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/applet%v/action-config/action%v/increment/varname", predicates, cpredicates))
}
- if !state.Applets[i].Actions[ci].Exit.IsNull() && data.Applets[j].Actions[cj].Exit.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/applet=%v/action-config/action=%v/exit", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ if !state.Applets[i].Actions[ci].IncrementValue.IsNull() && data.Applets[j].Actions[cj].IncrementValue.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/applet%v/action-config/action%v/increment/value", predicates, cpredicates))
}
- if !state.Applets[i].Actions[ci].End.IsNull() && data.Applets[j].Actions[cj].End.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/applet=%v/action-config/action=%v/end", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ if !state.Applets[i].Actions[ci].DecrementVarname.IsNull() && data.Applets[j].Actions[cj].DecrementVarname.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/applet%v/action-config/action%v/decrement/varname", predicates, cpredicates))
}
- if !state.Applets[i].Actions[ci].Wait.IsNull() && data.Applets[j].Actions[cj].Wait.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/applet=%v/action-config/action=%v/wait", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ if !state.Applets[i].Actions[ci].DecrementValue.IsNull() && data.Applets[j].Actions[cj].DecrementValue.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/applet%v/action-config/action%v/decrement/value", predicates, cpredicates))
}
- if !state.Applets[i].Actions[ci].Puts.IsNull() && data.Applets[j].Actions[cj].Puts.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/applet=%v/action-config/action=%v/puts", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ if !state.Applets[i].Actions[ci].AppendVarname.IsNull() && data.Applets[j].Actions[cj].AppendVarname.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/applet%v/action-config/action%v/append/varname", predicates, cpredicates))
}
- if !state.Applets[i].Actions[ci].Gets.IsNull() && data.Applets[j].Actions[cj].Gets.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/applet=%v/action-config/action=%v/gets", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ if !state.Applets[i].Actions[ci].AppendValue.IsNull() && data.Applets[j].Actions[cj].AppendValue.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/applet%v/action-config/action%v/append/value", predicates, cpredicates))
}
- if !state.Applets[i].Actions[ci].ForeachDelimiter.IsNull() && data.Applets[j].Actions[cj].ForeachDelimiter.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/applet=%v/action-config/action=%v/foreach/delimiter", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ if !state.Applets[i].Actions[ci].DivideOperand1.IsNull() && data.Applets[j].Actions[cj].DivideOperand1.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/applet%v/action-config/action%v/divide/operand1", predicates, cpredicates))
}
- if !state.Applets[i].Actions[ci].ForeachIterator.IsNull() && data.Applets[j].Actions[cj].ForeachIterator.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/applet=%v/action-config/action=%v/foreach/iterator", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ if !state.Applets[i].Actions[ci].DivideOperand2.IsNull() && data.Applets[j].Actions[cj].DivideOperand2.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/applet%v/action-config/action%v/divide/operand2", predicates, cpredicates))
}
if !state.Applets[i].Actions[ci].ForeachLoopvar.IsNull() && data.Applets[j].Actions[cj].ForeachLoopvar.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/applet=%v/action-config/action=%v/foreach/loopvar", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/applet%v/action-config/action%v/foreach/loopvar", predicates, cpredicates))
}
- if !state.Applets[i].Actions[ci].DivideOperand2.IsNull() && data.Applets[j].Actions[cj].DivideOperand2.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/applet=%v/action-config/action=%v/divide/operand2", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ if !state.Applets[i].Actions[ci].ForeachIterator.IsNull() && data.Applets[j].Actions[cj].ForeachIterator.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/applet%v/action-config/action%v/foreach/iterator", predicates, cpredicates))
}
- if !state.Applets[i].Actions[ci].DivideOperand1.IsNull() && data.Applets[j].Actions[cj].DivideOperand1.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/applet=%v/action-config/action=%v/divide/operand1", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ if !state.Applets[i].Actions[ci].ForeachDelimiter.IsNull() && data.Applets[j].Actions[cj].ForeachDelimiter.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/applet%v/action-config/action%v/foreach/delimiter", predicates, cpredicates))
}
- if !state.Applets[i].Actions[ci].AppendValue.IsNull() && data.Applets[j].Actions[cj].AppendValue.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/applet=%v/action-config/action=%v/append/value", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ if !state.Applets[i].Actions[ci].Gets.IsNull() && data.Applets[j].Actions[cj].Gets.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/applet%v/action-config/action%v/gets", predicates, cpredicates))
}
- if !state.Applets[i].Actions[ci].AppendVarname.IsNull() && data.Applets[j].Actions[cj].AppendVarname.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/applet=%v/action-config/action=%v/append/varname", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ if !state.Applets[i].Actions[ci].Puts.IsNull() && data.Applets[j].Actions[cj].Puts.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/applet%v/action-config/action%v/puts", predicates, cpredicates))
}
- if !state.Applets[i].Actions[ci].DecrementValue.IsNull() && data.Applets[j].Actions[cj].DecrementValue.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/applet=%v/action-config/action=%v/decrement/value", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ if !state.Applets[i].Actions[ci].Wait.IsNull() && data.Applets[j].Actions[cj].Wait.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/applet%v/action-config/action%v/wait", predicates, cpredicates))
}
- if !state.Applets[i].Actions[ci].DecrementVarname.IsNull() && data.Applets[j].Actions[cj].DecrementVarname.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/applet=%v/action-config/action=%v/decrement/varname", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ if !state.Applets[i].Actions[ci].End.IsNull() && data.Applets[j].Actions[cj].End.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/applet%v/action-config/action%v/end", predicates, cpredicates))
}
- if !state.Applets[i].Actions[ci].IncrementValue.IsNull() && data.Applets[j].Actions[cj].IncrementValue.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/applet=%v/action-config/action=%v/increment/value", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ if !state.Applets[i].Actions[ci].Exit.IsNull() && data.Applets[j].Actions[cj].Exit.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/applet%v/action-config/action%v/exit", predicates, cpredicates))
}
- if !state.Applets[i].Actions[ci].IncrementVarname.IsNull() && data.Applets[j].Actions[cj].IncrementVarname.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/applet=%v/action-config/action=%v/increment/varname", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ if !state.Applets[i].Actions[ci].Reload.IsNull() && data.Applets[j].Actions[cj].Reload.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/applet%v/action-config/action%v/reload", predicates, cpredicates))
}
- if !state.Applets[i].Actions[ci].Continue.IsNull() && data.Applets[j].Actions[cj].Continue.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/applet=%v/action-config/action=%v/continue", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ if !state.Applets[i].Actions[ci].ContextRetrieveKey.IsNull() && data.Applets[j].Actions[cj].ContextRetrieveKey.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/applet%v/action-config/action%v/context/retrieve/key", predicates, cpredicates))
}
- if !state.Applets[i].Actions[ci].Break.IsNull() && data.Applets[j].Actions[cj].Break.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/applet=%v/action-config/action=%v/break", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ if !state.Applets[i].Actions[ci].ContextRetrieveVariable.IsNull() && data.Applets[j].Actions[cj].ContextRetrieveVariable.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/applet%v/action-config/action%v/context/retrieve/variable", predicates, cpredicates))
}
- if !state.Applets[i].Actions[ci].WhileOperand2.IsNull() && data.Applets[j].Actions[cj].WhileOperand2.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/applet=%v/action-config/action=%v/while/operand2", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ if !state.Applets[i].Actions[ci].ContextSaveKey.IsNull() && data.Applets[j].Actions[cj].ContextSaveKey.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/applet%v/action-config/action%v/context/save/key", predicates, cpredicates))
}
- if !state.Applets[i].Actions[ci].WhileOperation.IsNull() && data.Applets[j].Actions[cj].WhileOperation.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/applet=%v/action-config/action=%v/while/operation", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ if !state.Applets[i].Actions[ci].ContextSaveVariable.IsNull() && data.Applets[j].Actions[cj].ContextSaveVariable.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/applet%v/action-config/action%v/context/save/variable", predicates, cpredicates))
}
- if !state.Applets[i].Actions[ci].WhileOperand1.IsNull() && data.Applets[j].Actions[cj].WhileOperand1.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/applet=%v/action-config/action=%v/while/operand1", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ if !state.Applets[i].Actions[ci].StringTrim.IsNull() && data.Applets[j].Actions[cj].StringTrim.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/applet%v/action-config/action%v/string/trim", predicates, cpredicates))
}
- if !state.Applets[i].Actions[ci].Else.IsNull() && data.Applets[j].Actions[cj].Else.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/applet=%v/action-config/action=%v/else", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ if !state.Applets[i].Actions[ci].InfoTypeSnmpTrapEnterpriseOid.IsNull() && data.Applets[j].Actions[cj].InfoTypeSnmpTrapEnterpriseOid.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/applet%v/action-config/action%v/info/type/snmp/trap/enterprise-oid", predicates, cpredicates))
}
- if !state.Applets[i].Actions[ci].ElseifOperand2.IsNull() && data.Applets[j].Actions[cj].ElseifOperand2.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/applet=%v/action-config/action=%v/elseif/operand2", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ if !state.Applets[i].Actions[ci].InfoTypeSnmpTrapGenericTrapnum.IsNull() && data.Applets[j].Actions[cj].InfoTypeSnmpTrapGenericTrapnum.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/applet%v/action-config/action%v/info/type/snmp/trap/generic-trapnum", predicates, cpredicates))
}
- if !state.Applets[i].Actions[ci].ElseifOperation.IsNull() && data.Applets[j].Actions[cj].ElseifOperation.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/applet=%v/action-config/action=%v/elseif/operation", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ if !state.Applets[i].Actions[ci].InfoTypeSnmpTrapSpecificTrapnum.IsNull() && data.Applets[j].Actions[cj].InfoTypeSnmpTrapSpecificTrapnum.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/applet%v/action-config/action%v/info/type/snmp/trap/specific-trapnum", predicates, cpredicates))
}
- if !state.Applets[i].Actions[ci].ElseifOperand1.IsNull() && data.Applets[j].Actions[cj].ElseifOperand1.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/applet=%v/action-config/action=%v/elseif/operand1", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ if !state.Applets[i].Actions[ci].InfoTypeSnmpTrapTrapOid.IsNull() && data.Applets[j].Actions[cj].InfoTypeSnmpTrapTrapOid.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/applet%v/action-config/action%v/info/type/snmp/trap/trap-oid", predicates, cpredicates))
}
- if !state.Applets[i].Actions[ci].IfGoto.IsNull() && data.Applets[j].Actions[cj].IfGoto.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/applet=%v/action-config/action=%v/if/goto", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ if !state.Applets[i].Actions[ci].InfoTypeSnmpTrapTrapVar.IsNull() && data.Applets[j].Actions[cj].InfoTypeSnmpTrapTrapVar.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/applet%v/action-config/action%v/info/type/snmp/trap/trap-var", predicates, cpredicates))
}
- if !state.Applets[i].Actions[ci].IfStringOp2.IsNull() && data.Applets[j].Actions[cj].IfStringOp2.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/applet=%v/action-config/action=%v/if/string-op-2", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ if !state.Applets[i].Actions[ci].HandleErrorType.IsNull() && data.Applets[j].Actions[cj].HandleErrorType.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/applet%v/action-config/action%v/handle-error/type", predicates, cpredicates))
}
- if !state.Applets[i].Actions[ci].IfKeyword.IsNull() && data.Applets[j].Actions[cj].IfKeyword.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/applet=%v/action-config/action=%v/if/keyword", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ if !state.Applets[i].Actions[ci].CounterName.IsNull() && data.Applets[j].Actions[cj].CounterName.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/applet%v/action-config/action%v/counter/name", predicates, cpredicates))
}
- if !state.Applets[i].Actions[ci].IfStringOp1.IsNull() && data.Applets[j].Actions[cj].IfStringOp1.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/applet=%v/action-config/action=%v/if/string-op-1", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ if !state.Applets[i].Actions[ci].CounterValue.IsNull() && data.Applets[j].Actions[cj].CounterValue.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/applet%v/action-config/action%v/counter/value", predicates, cpredicates))
}
- if !state.Applets[i].Actions[ci].SetValue.IsNull() && data.Applets[j].Actions[cj].SetValue.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/applet=%v/action-config/action=%v/set/value", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ if !state.Applets[i].Actions[ci].CounterOpDec.IsNull() && data.Applets[j].Actions[cj].CounterOpDec.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/applet%v/action-config/action%v/counter/op/dec", predicates, cpredicates))
}
- if !state.Applets[i].Actions[ci].SetVarname.IsNull() && data.Applets[j].Actions[cj].SetVarname.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/applet=%v/action-config/action=%v/set/varname", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ if !state.Applets[i].Actions[ci].CounterOpInc.IsNull() && data.Applets[j].Actions[cj].CounterOpInc.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/applet%v/action-config/action%v/counter/op/inc", predicates, cpredicates))
}
- if !state.Applets[i].Actions[ci].SyslogPriority.IsNull() && data.Applets[j].Actions[cj].SyslogPriority.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/applet=%v/action-config/action=%v/syslog-option/priority", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ if !state.Applets[i].Actions[ci].CounterOpSet.IsNull() && data.Applets[j].Actions[cj].CounterOpSet.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/applet%v/action-config/action%v/counter/op/set", predicates, cpredicates))
}
- if !state.Applets[i].Actions[ci].SyslogMsg.IsNull() && data.Applets[j].Actions[cj].SyslogMsg.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/applet=%v/action-config/action=%v/syslog-option/msg", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ if !state.Applets[i].Actions[ci].CounterOpNop.IsNull() && data.Applets[j].Actions[cj].CounterOpNop.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/applet%v/action-config/action%v/counter/op/nop", predicates, cpredicates))
}
- if !state.Applets[i].Actions[ci].SyslogFacility.IsNull() && data.Applets[j].Actions[cj].SyslogFacility.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/applet=%v/action-config/action=%v/syslog-option/facility", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ if !state.Applets[i].Actions[ci].SnmpTrapIntdata1.IsNull() && data.Applets[j].Actions[cj].SnmpTrapIntdata1.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/applet%v/action-config/action%v/snmp-trap/intdata1", predicates, cpredicates))
}
- if !state.Applets[i].Actions[ci].RegexpStringMatch3.IsNull() && data.Applets[j].Actions[cj].RegexpStringMatch3.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/applet=%v/action-config/action=%v/regexp-option/string-submatch3", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ if !state.Applets[i].Actions[ci].SnmpTrapIntdata2.IsNull() && data.Applets[j].Actions[cj].SnmpTrapIntdata2.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/applet%v/action-config/action%v/snmp-trap/intdata2", predicates, cpredicates))
}
- if !state.Applets[i].Actions[ci].RegexpStringMatch2.IsNull() && data.Applets[j].Actions[cj].RegexpStringMatch2.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/applet=%v/action-config/action=%v/regexp-option/string-submatch2", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ if !state.Applets[i].Actions[ci].SnmpTrapStrdata.IsNull() && data.Applets[j].Actions[cj].SnmpTrapStrdata.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/applet%v/action-config/action%v/snmp-trap/strdata", predicates, cpredicates))
}
- if !state.Applets[i].Actions[ci].RegexpStringMatch1.IsNull() && data.Applets[j].Actions[cj].RegexpStringMatch1.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/applet=%v/action-config/action=%v/regexp-option/string-submatch1", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ if !state.Applets[i].Actions[ci].InfoTypeSnmpVar.IsNull() && data.Applets[j].Actions[cj].InfoTypeSnmpVar.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/applet%v/action-config/action%v/info/type/snmp/var/variable-name", predicates, cpredicates))
}
- if !state.Applets[i].Actions[ci].RegexpStringMatch.IsNull() && data.Applets[j].Actions[cj].RegexpStringMatch.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/applet=%v/action-config/action=%v/regexp-option/string-match", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ if !state.Applets[i].Actions[ci].InfoTypeSnmpVarOid.IsNull() && data.Applets[j].Actions[cj].InfoTypeSnmpVarOid.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/applet%v/action-config/action%v/info/type/snmp/var/oid", predicates, cpredicates))
}
- if !state.Applets[i].Actions[ci].RegexpStringInput.IsNull() && data.Applets[j].Actions[cj].RegexpStringInput.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/applet=%v/action-config/action=%v/regexp-option/string-input", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ if !state.Applets[i].Actions[ci].InfoTypeSnmpVarOidType.IsNull() && data.Applets[j].Actions[cj].InfoTypeSnmpVarOidType.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/applet%v/action-config/action%v/info/type/snmp/var/oid-type", predicates, cpredicates))
}
- if !state.Applets[i].Actions[ci].RegexpStringPattern.IsNull() && data.Applets[j].Actions[cj].RegexpStringPattern.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/applet=%v/action-config/action=%v/regexp-option/string-pattern", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ if !state.Applets[i].Actions[ci].InfoTypeSnmpVarOidTypeValue.IsNull() && data.Applets[j].Actions[cj].InfoTypeSnmpVarOidTypeValue.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/applet%v/action-config/action%v/info/type/snmp/var/oid-type-value", predicates, cpredicates))
}
- if !state.Applets[i].Actions[ci].CliCommand.IsNull() && data.Applets[j].Actions[cj].CliCommand.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/applet=%v/action-config/action=%v/cli-choice/command", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ if !state.Applets[i].Actions[ci].StringTrimFirstStringOp1.IsNull() && data.Applets[j].Actions[cj].StringTrimFirstStringOp1.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/applet%v/action-config/action%v/string/trim/first/string-op-1", predicates, cpredicates))
+ }
+ if !state.Applets[i].Actions[ci].StringTrimFirstStringOp2.IsNull() && data.Applets[j].Actions[cj].StringTrimFirstStringOp2.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/applet%v/action-config/action%v/string/trim/first/string-op-2", predicates, cpredicates))
}
break
}
}
if !found {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/applet=%v/action-config/action=%v", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/applet%v/action-config/action%v", predicates, cpredicates))
}
}
- if !state.Applets[i].EventCliSkip.IsNull() && data.Applets[j].EventCliSkip.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/applet=%v/event/cli/skip", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ if !state.Applets[i].EventTimerWatchdogTime.IsNull() && data.Applets[j].EventTimerWatchdogTime.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/applet%v/event/timer-choice/watchdog/time-set", predicates))
}
- if !state.Applets[i].EventCliSync.IsNull() && data.Applets[j].EventCliSync.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/applet=%v/event/cli/sync", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ if !state.Applets[i].EventTimerWatchdogName.IsNull() && data.Applets[j].EventTimerWatchdogName.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/applet%v/event/timer-choice/watchdog/name", predicates))
}
- if !state.Applets[i].EventCliPattern.IsNull() && data.Applets[j].EventCliPattern.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/applet=%v/event/cli/pattern", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ if !state.Applets[i].EventTimerWatchdogMaxrun.IsNull() && data.Applets[j].EventTimerWatchdogMaxrun.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/applet%v/event/timer-choice/watchdog/maxrun-set", predicates))
}
- if !state.Applets[i].Description.IsNull() && data.Applets[j].Description.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/applet=%v/description", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ if !state.Applets[i].EventTimerWatchdogRatelimit.IsNull() && data.Applets[j].EventTimerWatchdogRatelimit.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/applet%v/event/timer-choice/watchdog/ratelimit-set", predicates))
}
- if !state.Applets[i].Class.IsNull() && data.Applets[j].Class.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/applet=%v/class", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ if !state.Applets[i].EventTimerCronEntry.IsNull() && data.Applets[j].EventTimerCronEntry.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/applet%v/event/timer-choice/cron/cron-entry", predicates))
}
- if !state.Applets[i].Authorization.IsNull() && data.Applets[j].Authorization.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/applet=%v/authorization", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ if !state.Applets[i].EventTimerCronName.IsNull() && data.Applets[j].EventTimerCronName.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/applet%v/event/timer-choice/cron/name", predicates))
}
- break
- }
- }
- if !found {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/applet=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
- }
- }
- if !state.DetectorRoutingBootupDelay.IsNull() && data.DetectorRoutingBootupDelay.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/detector/routing/bootup-delay", state.getPath()))
- }
- if !state.DetectorRpcMaxSessions.IsNull() && data.DetectorRpcMaxSessions.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/detector/rpc/max-sessions", state.getPath()))
- }
- if !state.SchedulerAppletThreadClassNumber.IsNull() && data.SchedulerAppletThreadClassNumber.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/scheduler/applet/thread/class/number", state.getPath()))
- }
- if !state.SchedulerAppletThreadClassDefault.IsNull() && data.SchedulerAppletThreadClassDefault.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/scheduler/applet/thread/class/default", state.getPath()))
- }
- if !state.DirectoryUserPolicy.IsNull() && data.DirectoryUserPolicy.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/directory/user/policy", state.getPath()))
- }
- if !state.HistorySizeTraps.IsNull() && data.HistorySizeTraps.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/history/size/traps", state.getPath()))
- }
- if !state.HistorySizeEvents.IsNull() && data.HistorySizeEvents.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/history/size/events", state.getPath()))
- }
- if !state.SessionCliUsernamePrivilege.IsNull() && data.SessionCliUsernamePrivilege.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/session/cli/username/privilege_set", state.getPath()))
- }
- if !state.SessionCliUsername.IsNull() && data.SessionCliUsername.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/session/cli/username/username_in_word_set", state.getPath()))
- }
- for i := range state.EnvironmentVariables {
- stateKeyValues := [...]string{state.EnvironmentVariables[i].Name.ValueString()}
-
- emptyKeys := true
- if !reflect.ValueOf(state.EnvironmentVariables[i].Name.ValueString()).IsZero() {
- emptyKeys = false
- }
- if emptyKeys {
- continue
- }
-
- found := false
- for j := range data.EnvironmentVariables {
- found = true
- if state.EnvironmentVariables[i].Name.ValueString() != data.EnvironmentVariables[j].Name.ValueString() {
- found = false
- }
- if found {
- if !state.EnvironmentVariables[i].Value.IsNull() && data.EnvironmentVariables[j].Value.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/environment=%v/value", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ if !state.Applets[i].EventTimerCronMaxrun.IsNull() && data.Applets[j].EventTimerCronMaxrun.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/applet%v/event/timer-choice/cron/maxrun-set", predicates))
+ }
+ if !state.Applets[i].EventTimerCronRatelimit.IsNull() && data.Applets[j].EventTimerCronRatelimit.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/applet%v/event/timer-choice/cron/ratelimit-set", predicates))
}
break
}
}
if !found {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/environment=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/applet%v", predicates))
}
}
- return deletedItems
+ return b.Res()
}
-// End of section. //template:end getDeletedItems
+// End of section. //template:end addDeletedItemsXML
// Section below is generated&owned by "gen/generator.go". //template:begin getEmptyLeafsDelete
@@ -2262,3 +4286,60 @@ func (data *EEM) getDeletePaths(ctx context.Context) []string {
}
// End of section. //template:end getDeletePaths
+
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletePathsXML
+
+func (data *EEM) addDeletePathsXML(ctx context.Context, body string) string {
+ b := netconf.NewBody(body)
+ for i := range data.EnvironmentVariables {
+ keys := [...]string{"name"}
+ keyValues := [...]string{data.EnvironmentVariables[i].Name.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/environment%v", predicates))
+ }
+ if !data.SessionCliUsername.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/session/cli/username/username_in_word_set")
+ }
+ if !data.SessionCliUsernamePrivilege.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/session/cli/username/privilege_set")
+ }
+ if !data.HistorySizeEvents.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/history/size/events")
+ }
+ if !data.HistorySizeTraps.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/history/size/traps")
+ }
+ if !data.DirectoryUserPolicy.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/directory/user/policy")
+ }
+ if !data.SchedulerAppletThreadClassDefault.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/scheduler/applet/thread/class/default")
+ }
+ if !data.SchedulerAppletThreadClassNumber.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/scheduler/applet/thread/class/number")
+ }
+ if !data.DetectorRpcMaxSessions.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/detector/rpc/max-sessions")
+ }
+ if !data.DetectorRoutingBootupDelay.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/detector/routing/bootup-delay")
+ }
+ for i := range data.Applets {
+ keys := [...]string{"name"}
+ keyValues := [...]string{data.Applets[i].Name.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/applet%v", predicates))
+ }
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletePathsXML
diff --git a/internal/provider/model_iosxe_errdisable.go b/internal/provider/model_iosxe_errdisable.go
index d3594107..1396fac7 100644
--- a/internal/provider/model_iosxe_errdisable.go
+++ b/internal/provider/model_iosxe_errdisable.go
@@ -28,6 +28,9 @@ import (
"github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/types"
+ "github.com/hashicorp/terraform-plugin-log/tflog"
+ "github.com/netascode/go-netconf"
+ "github.com/netascode/xmldot"
"github.com/tidwall/gjson"
"github.com/tidwall/sjson"
)
@@ -175,6 +178,17 @@ func (data Errdisable) getPathShort() string {
return matches[1]
}
+// getXPath returns the XPath for NETCONF operations
+func (data Errdisable) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/errdisable"
+ return path
+}
+
+func (data ErrdisableData) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/errdisable"
+ return path
+}
+
// End of section. //template:end getPath
// Section below is generated&owned by "gen/generator.go". //template:begin toBody
@@ -435,6 +449,358 @@ func (data Errdisable) toBody(ctx context.Context) string {
// End of section. //template:end toBody
+// Section below is generated&owned by "gen/generator.go". //template:begin toBodyXML
+
+func (data Errdisable) toBodyXML(ctx context.Context) string {
+ body := netconf.Body{}
+ if !data.DetectCauseAll.IsNull() && !data.DetectCauseAll.IsUnknown() {
+ if data.DetectCauseAll.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/detect/cause/all", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/detect/cause/all")
+ }
+ }
+ if !data.DetectCauseArpInspection.IsNull() && !data.DetectCauseArpInspection.IsUnknown() {
+ if data.DetectCauseArpInspection.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/detect/cause/arp-inspection", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/detect/cause/arp-inspection")
+ }
+ }
+ if !data.DetectCauseBpduguard.IsNull() && !data.DetectCauseBpduguard.IsUnknown() {
+ if data.DetectCauseBpduguard.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/detect/cause/bpduguard", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/detect/cause/bpduguard")
+ }
+ }
+ if !data.DetectCauseDhcpRateLimit.IsNull() && !data.DetectCauseDhcpRateLimit.IsUnknown() {
+ if data.DetectCauseDhcpRateLimit.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/detect/cause/dhcp-rate-limit", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/detect/cause/dhcp-rate-limit")
+ }
+ }
+ if !data.DetectCauseDtpFlap.IsNull() && !data.DetectCauseDtpFlap.IsUnknown() {
+ if data.DetectCauseDtpFlap.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/detect/cause/dtp-flap", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/detect/cause/dtp-flap")
+ }
+ }
+ if !data.DetectCauseGbicInvalid.IsNull() && !data.DetectCauseGbicInvalid.IsUnknown() {
+ if data.DetectCauseGbicInvalid.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/detect/cause/gbic-invalid", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/detect/cause/gbic-invalid")
+ }
+ }
+ if !data.DetectCauseInlinePower.IsNull() && !data.DetectCauseInlinePower.IsUnknown() {
+ if data.DetectCauseInlinePower.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/detect/cause/inline-power", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/detect/cause/inline-power")
+ }
+ }
+ if !data.DetectCauseL2ptguard.IsNull() && !data.DetectCauseL2ptguard.IsUnknown() {
+ if data.DetectCauseL2ptguard.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/detect/cause/l2ptguard", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/detect/cause/l2ptguard")
+ }
+ }
+ if !data.DetectCauseLinkFlap.IsNull() && !data.DetectCauseLinkFlap.IsUnknown() {
+ if data.DetectCauseLinkFlap.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/detect/cause/link-flap", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/detect/cause/link-flap")
+ }
+ }
+ if !data.DetectCauseLoopback.IsNull() && !data.DetectCauseLoopback.IsUnknown() {
+ if data.DetectCauseLoopback.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/detect/cause/loopback", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/detect/cause/loopback")
+ }
+ }
+ if !data.DetectCauseMlacpMinlink.IsNull() && !data.DetectCauseMlacpMinlink.IsUnknown() {
+ if data.DetectCauseMlacpMinlink.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/detect/cause/mlacp-minlink", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/detect/cause/mlacp-minlink")
+ }
+ }
+ if !data.DetectCausePagpFlap.IsNull() && !data.DetectCausePagpFlap.IsUnknown() {
+ if data.DetectCausePagpFlap.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/detect/cause/pagp-flap", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/detect/cause/pagp-flap")
+ }
+ }
+ if !data.DetectCausePppoeIaRateLimit.IsNull() && !data.DetectCausePppoeIaRateLimit.IsUnknown() {
+ if data.DetectCausePppoeIaRateLimit.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/detect/cause/pppoe-ia-rate-limit", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/detect/cause/pppoe-ia-rate-limit")
+ }
+ }
+ if !data.DetectCauseSecurityViolationShutdownVlan.IsNull() && !data.DetectCauseSecurityViolationShutdownVlan.IsUnknown() {
+ if data.DetectCauseSecurityViolationShutdownVlan.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/detect/cause/security-violation/shutdown/vlan", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/detect/cause/security-violation/shutdown/vlan")
+ }
+ }
+ if !data.DetectCauseSfpConfigMismatch.IsNull() && !data.DetectCauseSfpConfigMismatch.IsUnknown() {
+ if data.DetectCauseSfpConfigMismatch.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/detect/cause/sfp-config-mismatch", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/detect/cause/sfp-config-mismatch")
+ }
+ }
+ if !data.DetectCauseSmallFrame.IsNull() && !data.DetectCauseSmallFrame.IsUnknown() {
+ if data.DetectCauseSmallFrame.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/detect/cause/small-frame", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/detect/cause/small-frame")
+ }
+ }
+ if !data.DetectCauseLoopdetect.IsNull() && !data.DetectCauseLoopdetect.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/detect/cause/loopdetect", data.DetectCauseLoopdetect.ValueBool())
+ }
+ if !data.FlapSettingCauseDtpFlapMaxFlaps.IsNull() && !data.FlapSettingCauseDtpFlapMaxFlaps.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/flap-setting/cause/dtp-flap/max-flaps", strconv.FormatInt(data.FlapSettingCauseDtpFlapMaxFlaps.ValueInt64(), 10))
+ }
+ if !data.FlapSettingCauseDtpFlapTime.IsNull() && !data.FlapSettingCauseDtpFlapTime.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/flap-setting/cause/dtp-flap/time", strconv.FormatInt(data.FlapSettingCauseDtpFlapTime.ValueInt64(), 10))
+ }
+ if !data.FlapSettingCauseLinkFlapMaxFlaps.IsNull() && !data.FlapSettingCauseLinkFlapMaxFlaps.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/flap-setting/cause/link-flap/max-flaps", strconv.FormatInt(data.FlapSettingCauseLinkFlapMaxFlaps.ValueInt64(), 10))
+ }
+ if !data.FlapSettingCauseLinkFlapTime.IsNull() && !data.FlapSettingCauseLinkFlapTime.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/flap-setting/cause/link-flap/time", strconv.FormatInt(data.FlapSettingCauseLinkFlapTime.ValueInt64(), 10))
+ }
+ if !data.FlapSettingCausePagpFlapMaxFlaps.IsNull() && !data.FlapSettingCausePagpFlapMaxFlaps.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/flap-setting/cause/pagp-flap/max-flaps", strconv.FormatInt(data.FlapSettingCausePagpFlapMaxFlaps.ValueInt64(), 10))
+ }
+ if !data.FlapSettingCausePagpFlapTime.IsNull() && !data.FlapSettingCausePagpFlapTime.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/flap-setting/cause/pagp-flap/time", strconv.FormatInt(data.FlapSettingCausePagpFlapTime.ValueInt64(), 10))
+ }
+ if !data.RecoveryInterval.IsNull() && !data.RecoveryInterval.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/recovery/interval", strconv.FormatInt(data.RecoveryInterval.ValueInt64(), 10))
+ }
+ if !data.RecoveryCauseAll.IsNull() && !data.RecoveryCauseAll.IsUnknown() {
+ if data.RecoveryCauseAll.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/recovery/cause/all", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/recovery/cause/all")
+ }
+ }
+ if !data.RecoveryCauseArpInspection.IsNull() && !data.RecoveryCauseArpInspection.IsUnknown() {
+ if data.RecoveryCauseArpInspection.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/recovery/cause/arp-inspection", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/recovery/cause/arp-inspection")
+ }
+ }
+ if !data.RecoveryCauseBpduguard.IsNull() && !data.RecoveryCauseBpduguard.IsUnknown() {
+ if data.RecoveryCauseBpduguard.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/recovery/cause/bpduguard", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/recovery/cause/bpduguard")
+ }
+ }
+ if !data.RecoveryCauseChannelMisconfig.IsNull() && !data.RecoveryCauseChannelMisconfig.IsUnknown() {
+ if data.RecoveryCauseChannelMisconfig.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/recovery/cause/channel-misconfig", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/recovery/cause/channel-misconfig")
+ }
+ }
+ if !data.RecoveryCauseDhcpRateLimit.IsNull() && !data.RecoveryCauseDhcpRateLimit.IsUnknown() {
+ if data.RecoveryCauseDhcpRateLimit.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/recovery/cause/dhcp-rate-limit", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/recovery/cause/dhcp-rate-limit")
+ }
+ }
+ if !data.RecoveryCauseDtpFlap.IsNull() && !data.RecoveryCauseDtpFlap.IsUnknown() {
+ if data.RecoveryCauseDtpFlap.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/recovery/cause/dtp-flap", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/recovery/cause/dtp-flap")
+ }
+ }
+ if !data.RecoveryCauseGbicInvalid.IsNull() && !data.RecoveryCauseGbicInvalid.IsUnknown() {
+ if data.RecoveryCauseGbicInvalid.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/recovery/cause/gbic-invalid", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/recovery/cause/gbic-invalid")
+ }
+ }
+ if !data.RecoveryCauseInlinePower.IsNull() && !data.RecoveryCauseInlinePower.IsUnknown() {
+ if data.RecoveryCauseInlinePower.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/recovery/cause/inline-power", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/recovery/cause/inline-power")
+ }
+ }
+ if !data.RecoveryCauseL2ptguard.IsNull() && !data.RecoveryCauseL2ptguard.IsUnknown() {
+ if data.RecoveryCauseL2ptguard.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/recovery/cause/l2ptguard", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/recovery/cause/l2ptguard")
+ }
+ }
+ if !data.RecoveryCauseLinkFlap.IsNull() && !data.RecoveryCauseLinkFlap.IsUnknown() {
+ if data.RecoveryCauseLinkFlap.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/recovery/cause/link-flap", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/recovery/cause/link-flap")
+ }
+ }
+ if !data.RecoveryCauseLinkMonitorFailure.IsNull() && !data.RecoveryCauseLinkMonitorFailure.IsUnknown() {
+ if data.RecoveryCauseLinkMonitorFailure.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/recovery/cause/link-monitor-failure", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/recovery/cause/link-monitor-failure")
+ }
+ }
+ if !data.RecoveryCauseLoopback.IsNull() && !data.RecoveryCauseLoopback.IsUnknown() {
+ if data.RecoveryCauseLoopback.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/recovery/cause/loopback", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/recovery/cause/loopback")
+ }
+ }
+ if !data.RecoveryCauseMacLimit.IsNull() && !data.RecoveryCauseMacLimit.IsUnknown() {
+ if data.RecoveryCauseMacLimit.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/recovery/cause/mac-limit", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/recovery/cause/mac-limit")
+ }
+ }
+ if !data.RecoveryCauseMlacpMinlink.IsNull() && !data.RecoveryCauseMlacpMinlink.IsUnknown() {
+ if data.RecoveryCauseMlacpMinlink.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/recovery/cause/mlacp-minlink", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/recovery/cause/mlacp-minlink")
+ }
+ }
+ if !data.RecoveryCausePagpFlap.IsNull() && !data.RecoveryCausePagpFlap.IsUnknown() {
+ if data.RecoveryCausePagpFlap.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/recovery/cause/pagp-flap", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/recovery/cause/pagp-flap")
+ }
+ }
+ if !data.RecoveryCausePortModeFailure.IsNull() && !data.RecoveryCausePortModeFailure.IsUnknown() {
+ if data.RecoveryCausePortModeFailure.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/recovery/cause/port-mode-failure", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/recovery/cause/port-mode-failure")
+ }
+ }
+ if !data.RecoveryCausePppoeIaRateLimit.IsNull() && !data.RecoveryCausePppoeIaRateLimit.IsUnknown() {
+ if data.RecoveryCausePppoeIaRateLimit.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/recovery/cause/pppoe-ia-rate-limit", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/recovery/cause/pppoe-ia-rate-limit")
+ }
+ }
+ if !data.RecoveryCausePsp.IsNull() && !data.RecoveryCausePsp.IsUnknown() {
+ if data.RecoveryCausePsp.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/recovery/cause/psp", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/recovery/cause/psp")
+ }
+ }
+ if !data.RecoveryCausePsecureViolation.IsNull() && !data.RecoveryCausePsecureViolation.IsUnknown() {
+ if data.RecoveryCausePsecureViolation.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/recovery/cause/psecure-violation", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/recovery/cause/psecure-violation")
+ }
+ }
+ if !data.RecoveryCauseSecurityViolation.IsNull() && !data.RecoveryCauseSecurityViolation.IsUnknown() {
+ if data.RecoveryCauseSecurityViolation.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/recovery/cause/security-violation", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/recovery/cause/security-violation")
+ }
+ }
+ if !data.RecoveryCauseSfpConfigMismatch.IsNull() && !data.RecoveryCauseSfpConfigMismatch.IsUnknown() {
+ if data.RecoveryCauseSfpConfigMismatch.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/recovery/cause/sfp-config-mismatch", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/recovery/cause/sfp-config-mismatch")
+ }
+ }
+ if !data.RecoveryCauseSmallFrame.IsNull() && !data.RecoveryCauseSmallFrame.IsUnknown() {
+ if data.RecoveryCauseSmallFrame.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/recovery/cause/small-frame", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/recovery/cause/small-frame")
+ }
+ }
+ if !data.RecoveryCauseStormControl.IsNull() && !data.RecoveryCauseStormControl.IsUnknown() {
+ if data.RecoveryCauseStormControl.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/recovery/cause/storm-control", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/recovery/cause/storm-control")
+ }
+ }
+ if !data.RecoveryCauseUdld.IsNull() && !data.RecoveryCauseUdld.IsUnknown() {
+ if data.RecoveryCauseUdld.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/recovery/cause/udld", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/recovery/cause/udld")
+ }
+ }
+ if !data.RecoveryCauseUnicastFlood.IsNull() && !data.RecoveryCauseUnicastFlood.IsUnknown() {
+ if data.RecoveryCauseUnicastFlood.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/recovery/cause/unicast-flood", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/recovery/cause/unicast-flood")
+ }
+ }
+ if !data.RecoveryCauseVmps.IsNull() && !data.RecoveryCauseVmps.IsUnknown() {
+ if data.RecoveryCauseVmps.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/recovery/cause/vmps", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/recovery/cause/vmps")
+ }
+ }
+ if !data.RecoveryCauseLoopdetect.IsNull() && !data.RecoveryCauseLoopdetect.IsUnknown() {
+ if data.RecoveryCauseLoopdetect.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/recovery/cause/loopdetect", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/recovery/cause/loopdetect")
+ }
+ }
+ if !data.RecoveryCauseOamRemoteFailure.IsNull() && !data.RecoveryCauseOamRemoteFailure.IsUnknown() {
+ if data.RecoveryCauseOamRemoteFailure.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/recovery/cause/oam-remote-failure", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/recovery/cause/oam-remote-failure")
+ }
+ }
+ if !data.RecoveryCauseMrpMiscabling.IsNull() && !data.RecoveryCauseMrpMiscabling.IsUnknown() {
+ if data.RecoveryCauseMrpMiscabling.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/recovery/cause/mrp-miscabling", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/recovery/cause/mrp-miscabling")
+ }
+ }
+ bodyString, err := body.String()
+ if err != nil {
+ tflog.Error(ctx, fmt.Sprintf("Error converting body to string: %s", err))
+ }
+ return bodyString
+}
+
+// End of section. //template:end toBodyXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBody
func (data *Errdisable) updateFromBody(ctx context.Context, res gjson.Result) {
@@ -893,13 +1259,729 @@ func (data *Errdisable) updateFromBody(ctx context.Context, res gjson.Result) {
// End of section. //template:end updateFromBody
-// Section below is generated&owned by "gen/generator.go". //template:begin fromBody
+// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBodyXML
-func (data *Errdisable) fromBody(ctx context.Context, res gjson.Result) {
- prefix := helpers.LastElement(data.getPath()) + "."
- if res.Get(helpers.LastElement(data.getPath())).IsArray() {
- prefix += "0."
- }
+func (data *Errdisable) updateFromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/detect/cause/all"); !data.DetectCauseAll.IsNull() {
+ if value.Exists() {
+ data.DetectCauseAll = types.BoolValue(true)
+ } else {
+ data.DetectCauseAll = types.BoolValue(false)
+ }
+ } else {
+ data.DetectCauseAll = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/detect/cause/arp-inspection"); !data.DetectCauseArpInspection.IsNull() {
+ if value.Exists() {
+ data.DetectCauseArpInspection = types.BoolValue(true)
+ } else {
+ data.DetectCauseArpInspection = types.BoolValue(false)
+ }
+ } else {
+ data.DetectCauseArpInspection = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/detect/cause/bpduguard"); !data.DetectCauseBpduguard.IsNull() {
+ if value.Exists() {
+ data.DetectCauseBpduguard = types.BoolValue(true)
+ } else {
+ data.DetectCauseBpduguard = types.BoolValue(false)
+ }
+ } else {
+ data.DetectCauseBpduguard = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/detect/cause/dhcp-rate-limit"); !data.DetectCauseDhcpRateLimit.IsNull() {
+ if value.Exists() {
+ data.DetectCauseDhcpRateLimit = types.BoolValue(true)
+ } else {
+ data.DetectCauseDhcpRateLimit = types.BoolValue(false)
+ }
+ } else {
+ data.DetectCauseDhcpRateLimit = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/detect/cause/dtp-flap"); !data.DetectCauseDtpFlap.IsNull() {
+ if value.Exists() {
+ data.DetectCauseDtpFlap = types.BoolValue(true)
+ } else {
+ data.DetectCauseDtpFlap = types.BoolValue(false)
+ }
+ } else {
+ data.DetectCauseDtpFlap = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/detect/cause/gbic-invalid"); !data.DetectCauseGbicInvalid.IsNull() {
+ if value.Exists() {
+ data.DetectCauseGbicInvalid = types.BoolValue(true)
+ } else {
+ data.DetectCauseGbicInvalid = types.BoolValue(false)
+ }
+ } else {
+ data.DetectCauseGbicInvalid = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/detect/cause/inline-power"); !data.DetectCauseInlinePower.IsNull() {
+ if value.Exists() {
+ data.DetectCauseInlinePower = types.BoolValue(true)
+ } else {
+ data.DetectCauseInlinePower = types.BoolValue(false)
+ }
+ } else {
+ data.DetectCauseInlinePower = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/detect/cause/l2ptguard"); !data.DetectCauseL2ptguard.IsNull() {
+ if value.Exists() {
+ data.DetectCauseL2ptguard = types.BoolValue(true)
+ } else {
+ data.DetectCauseL2ptguard = types.BoolValue(false)
+ }
+ } else {
+ data.DetectCauseL2ptguard = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/detect/cause/link-flap"); !data.DetectCauseLinkFlap.IsNull() {
+ if value.Exists() {
+ data.DetectCauseLinkFlap = types.BoolValue(true)
+ } else {
+ data.DetectCauseLinkFlap = types.BoolValue(false)
+ }
+ } else {
+ data.DetectCauseLinkFlap = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/detect/cause/loopback"); !data.DetectCauseLoopback.IsNull() {
+ if value.Exists() {
+ data.DetectCauseLoopback = types.BoolValue(true)
+ } else {
+ data.DetectCauseLoopback = types.BoolValue(false)
+ }
+ } else {
+ data.DetectCauseLoopback = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/detect/cause/mlacp-minlink"); !data.DetectCauseMlacpMinlink.IsNull() {
+ if value.Exists() {
+ data.DetectCauseMlacpMinlink = types.BoolValue(true)
+ } else {
+ data.DetectCauseMlacpMinlink = types.BoolValue(false)
+ }
+ } else {
+ data.DetectCauseMlacpMinlink = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/detect/cause/pagp-flap"); !data.DetectCausePagpFlap.IsNull() {
+ if value.Exists() {
+ data.DetectCausePagpFlap = types.BoolValue(true)
+ } else {
+ data.DetectCausePagpFlap = types.BoolValue(false)
+ }
+ } else {
+ data.DetectCausePagpFlap = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/detect/cause/pppoe-ia-rate-limit"); !data.DetectCausePppoeIaRateLimit.IsNull() {
+ if value.Exists() {
+ data.DetectCausePppoeIaRateLimit = types.BoolValue(true)
+ } else {
+ data.DetectCausePppoeIaRateLimit = types.BoolValue(false)
+ }
+ } else {
+ data.DetectCausePppoeIaRateLimit = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/detect/cause/security-violation/shutdown/vlan"); !data.DetectCauseSecurityViolationShutdownVlan.IsNull() {
+ if value.Exists() {
+ data.DetectCauseSecurityViolationShutdownVlan = types.BoolValue(true)
+ } else {
+ data.DetectCauseSecurityViolationShutdownVlan = types.BoolValue(false)
+ }
+ } else {
+ data.DetectCauseSecurityViolationShutdownVlan = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/detect/cause/sfp-config-mismatch"); !data.DetectCauseSfpConfigMismatch.IsNull() {
+ if value.Exists() {
+ data.DetectCauseSfpConfigMismatch = types.BoolValue(true)
+ } else {
+ data.DetectCauseSfpConfigMismatch = types.BoolValue(false)
+ }
+ } else {
+ data.DetectCauseSfpConfigMismatch = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/detect/cause/small-frame"); !data.DetectCauseSmallFrame.IsNull() {
+ if value.Exists() {
+ data.DetectCauseSmallFrame = types.BoolValue(true)
+ } else {
+ data.DetectCauseSmallFrame = types.BoolValue(false)
+ }
+ } else {
+ data.DetectCauseSmallFrame = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/detect/cause/loopdetect"); !data.DetectCauseLoopdetect.IsNull() {
+ if value.Exists() {
+ data.DetectCauseLoopdetect = types.BoolValue(value.Bool())
+ }
+ } else {
+ data.DetectCauseLoopdetect = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/flap-setting/cause/dtp-flap/max-flaps"); value.Exists() && !data.FlapSettingCauseDtpFlapMaxFlaps.IsNull() {
+ data.FlapSettingCauseDtpFlapMaxFlaps = types.Int64Value(value.Int())
+ } else {
+ data.FlapSettingCauseDtpFlapMaxFlaps = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/flap-setting/cause/dtp-flap/time"); value.Exists() && !data.FlapSettingCauseDtpFlapTime.IsNull() {
+ data.FlapSettingCauseDtpFlapTime = types.Int64Value(value.Int())
+ } else {
+ data.FlapSettingCauseDtpFlapTime = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/flap-setting/cause/link-flap/max-flaps"); value.Exists() && !data.FlapSettingCauseLinkFlapMaxFlaps.IsNull() {
+ data.FlapSettingCauseLinkFlapMaxFlaps = types.Int64Value(value.Int())
+ } else {
+ data.FlapSettingCauseLinkFlapMaxFlaps = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/flap-setting/cause/link-flap/time"); value.Exists() && !data.FlapSettingCauseLinkFlapTime.IsNull() {
+ data.FlapSettingCauseLinkFlapTime = types.Int64Value(value.Int())
+ } else {
+ data.FlapSettingCauseLinkFlapTime = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/flap-setting/cause/pagp-flap/max-flaps"); value.Exists() && !data.FlapSettingCausePagpFlapMaxFlaps.IsNull() {
+ data.FlapSettingCausePagpFlapMaxFlaps = types.Int64Value(value.Int())
+ } else {
+ data.FlapSettingCausePagpFlapMaxFlaps = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/flap-setting/cause/pagp-flap/time"); value.Exists() && !data.FlapSettingCausePagpFlapTime.IsNull() {
+ data.FlapSettingCausePagpFlapTime = types.Int64Value(value.Int())
+ } else {
+ data.FlapSettingCausePagpFlapTime = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/recovery/interval"); value.Exists() && !data.RecoveryInterval.IsNull() {
+ data.RecoveryInterval = types.Int64Value(value.Int())
+ } else {
+ data.RecoveryInterval = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/recovery/cause/all"); !data.RecoveryCauseAll.IsNull() {
+ if value.Exists() {
+ data.RecoveryCauseAll = types.BoolValue(true)
+ } else {
+ data.RecoveryCauseAll = types.BoolValue(false)
+ }
+ } else {
+ data.RecoveryCauseAll = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/recovery/cause/arp-inspection"); !data.RecoveryCauseArpInspection.IsNull() {
+ if value.Exists() {
+ data.RecoveryCauseArpInspection = types.BoolValue(true)
+ } else {
+ data.RecoveryCauseArpInspection = types.BoolValue(false)
+ }
+ } else {
+ data.RecoveryCauseArpInspection = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/recovery/cause/bpduguard"); !data.RecoveryCauseBpduguard.IsNull() {
+ if value.Exists() {
+ data.RecoveryCauseBpduguard = types.BoolValue(true)
+ } else {
+ data.RecoveryCauseBpduguard = types.BoolValue(false)
+ }
+ } else {
+ data.RecoveryCauseBpduguard = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/recovery/cause/channel-misconfig"); !data.RecoveryCauseChannelMisconfig.IsNull() {
+ if value.Exists() {
+ data.RecoveryCauseChannelMisconfig = types.BoolValue(true)
+ } else {
+ data.RecoveryCauseChannelMisconfig = types.BoolValue(false)
+ }
+ } else {
+ data.RecoveryCauseChannelMisconfig = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/recovery/cause/dhcp-rate-limit"); !data.RecoveryCauseDhcpRateLimit.IsNull() {
+ if value.Exists() {
+ data.RecoveryCauseDhcpRateLimit = types.BoolValue(true)
+ } else {
+ data.RecoveryCauseDhcpRateLimit = types.BoolValue(false)
+ }
+ } else {
+ data.RecoveryCauseDhcpRateLimit = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/recovery/cause/dtp-flap"); !data.RecoveryCauseDtpFlap.IsNull() {
+ if value.Exists() {
+ data.RecoveryCauseDtpFlap = types.BoolValue(true)
+ } else {
+ data.RecoveryCauseDtpFlap = types.BoolValue(false)
+ }
+ } else {
+ data.RecoveryCauseDtpFlap = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/recovery/cause/gbic-invalid"); !data.RecoveryCauseGbicInvalid.IsNull() {
+ if value.Exists() {
+ data.RecoveryCauseGbicInvalid = types.BoolValue(true)
+ } else {
+ data.RecoveryCauseGbicInvalid = types.BoolValue(false)
+ }
+ } else {
+ data.RecoveryCauseGbicInvalid = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/recovery/cause/inline-power"); !data.RecoveryCauseInlinePower.IsNull() {
+ if value.Exists() {
+ data.RecoveryCauseInlinePower = types.BoolValue(true)
+ } else {
+ data.RecoveryCauseInlinePower = types.BoolValue(false)
+ }
+ } else {
+ data.RecoveryCauseInlinePower = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/recovery/cause/l2ptguard"); !data.RecoveryCauseL2ptguard.IsNull() {
+ if value.Exists() {
+ data.RecoveryCauseL2ptguard = types.BoolValue(true)
+ } else {
+ data.RecoveryCauseL2ptguard = types.BoolValue(false)
+ }
+ } else {
+ data.RecoveryCauseL2ptguard = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/recovery/cause/link-flap"); !data.RecoveryCauseLinkFlap.IsNull() {
+ if value.Exists() {
+ data.RecoveryCauseLinkFlap = types.BoolValue(true)
+ } else {
+ data.RecoveryCauseLinkFlap = types.BoolValue(false)
+ }
+ } else {
+ data.RecoveryCauseLinkFlap = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/recovery/cause/link-monitor-failure"); !data.RecoveryCauseLinkMonitorFailure.IsNull() {
+ if value.Exists() {
+ data.RecoveryCauseLinkMonitorFailure = types.BoolValue(true)
+ } else {
+ data.RecoveryCauseLinkMonitorFailure = types.BoolValue(false)
+ }
+ } else {
+ data.RecoveryCauseLinkMonitorFailure = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/recovery/cause/loopback"); !data.RecoveryCauseLoopback.IsNull() {
+ if value.Exists() {
+ data.RecoveryCauseLoopback = types.BoolValue(true)
+ } else {
+ data.RecoveryCauseLoopback = types.BoolValue(false)
+ }
+ } else {
+ data.RecoveryCauseLoopback = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/recovery/cause/mac-limit"); !data.RecoveryCauseMacLimit.IsNull() {
+ if value.Exists() {
+ data.RecoveryCauseMacLimit = types.BoolValue(true)
+ } else {
+ data.RecoveryCauseMacLimit = types.BoolValue(false)
+ }
+ } else {
+ data.RecoveryCauseMacLimit = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/recovery/cause/mlacp-minlink"); !data.RecoveryCauseMlacpMinlink.IsNull() {
+ if value.Exists() {
+ data.RecoveryCauseMlacpMinlink = types.BoolValue(true)
+ } else {
+ data.RecoveryCauseMlacpMinlink = types.BoolValue(false)
+ }
+ } else {
+ data.RecoveryCauseMlacpMinlink = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/recovery/cause/pagp-flap"); !data.RecoveryCausePagpFlap.IsNull() {
+ if value.Exists() {
+ data.RecoveryCausePagpFlap = types.BoolValue(true)
+ } else {
+ data.RecoveryCausePagpFlap = types.BoolValue(false)
+ }
+ } else {
+ data.RecoveryCausePagpFlap = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/recovery/cause/port-mode-failure"); !data.RecoveryCausePortModeFailure.IsNull() {
+ if value.Exists() {
+ data.RecoveryCausePortModeFailure = types.BoolValue(true)
+ } else {
+ data.RecoveryCausePortModeFailure = types.BoolValue(false)
+ }
+ } else {
+ data.RecoveryCausePortModeFailure = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/recovery/cause/pppoe-ia-rate-limit"); !data.RecoveryCausePppoeIaRateLimit.IsNull() {
+ if value.Exists() {
+ data.RecoveryCausePppoeIaRateLimit = types.BoolValue(true)
+ } else {
+ data.RecoveryCausePppoeIaRateLimit = types.BoolValue(false)
+ }
+ } else {
+ data.RecoveryCausePppoeIaRateLimit = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/recovery/cause/psp"); !data.RecoveryCausePsp.IsNull() {
+ if value.Exists() {
+ data.RecoveryCausePsp = types.BoolValue(true)
+ } else {
+ data.RecoveryCausePsp = types.BoolValue(false)
+ }
+ } else {
+ data.RecoveryCausePsp = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/recovery/cause/psecure-violation"); !data.RecoveryCausePsecureViolation.IsNull() {
+ if value.Exists() {
+ data.RecoveryCausePsecureViolation = types.BoolValue(true)
+ } else {
+ data.RecoveryCausePsecureViolation = types.BoolValue(false)
+ }
+ } else {
+ data.RecoveryCausePsecureViolation = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/recovery/cause/security-violation"); !data.RecoveryCauseSecurityViolation.IsNull() {
+ if value.Exists() {
+ data.RecoveryCauseSecurityViolation = types.BoolValue(true)
+ } else {
+ data.RecoveryCauseSecurityViolation = types.BoolValue(false)
+ }
+ } else {
+ data.RecoveryCauseSecurityViolation = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/recovery/cause/sfp-config-mismatch"); !data.RecoveryCauseSfpConfigMismatch.IsNull() {
+ if value.Exists() {
+ data.RecoveryCauseSfpConfigMismatch = types.BoolValue(true)
+ } else {
+ data.RecoveryCauseSfpConfigMismatch = types.BoolValue(false)
+ }
+ } else {
+ data.RecoveryCauseSfpConfigMismatch = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/recovery/cause/small-frame"); !data.RecoveryCauseSmallFrame.IsNull() {
+ if value.Exists() {
+ data.RecoveryCauseSmallFrame = types.BoolValue(true)
+ } else {
+ data.RecoveryCauseSmallFrame = types.BoolValue(false)
+ }
+ } else {
+ data.RecoveryCauseSmallFrame = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/recovery/cause/storm-control"); !data.RecoveryCauseStormControl.IsNull() {
+ if value.Exists() {
+ data.RecoveryCauseStormControl = types.BoolValue(true)
+ } else {
+ data.RecoveryCauseStormControl = types.BoolValue(false)
+ }
+ } else {
+ data.RecoveryCauseStormControl = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/recovery/cause/udld"); !data.RecoveryCauseUdld.IsNull() {
+ if value.Exists() {
+ data.RecoveryCauseUdld = types.BoolValue(true)
+ } else {
+ data.RecoveryCauseUdld = types.BoolValue(false)
+ }
+ } else {
+ data.RecoveryCauseUdld = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/recovery/cause/unicast-flood"); !data.RecoveryCauseUnicastFlood.IsNull() {
+ if value.Exists() {
+ data.RecoveryCauseUnicastFlood = types.BoolValue(true)
+ } else {
+ data.RecoveryCauseUnicastFlood = types.BoolValue(false)
+ }
+ } else {
+ data.RecoveryCauseUnicastFlood = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/recovery/cause/vmps"); !data.RecoveryCauseVmps.IsNull() {
+ if value.Exists() {
+ data.RecoveryCauseVmps = types.BoolValue(true)
+ } else {
+ data.RecoveryCauseVmps = types.BoolValue(false)
+ }
+ } else {
+ data.RecoveryCauseVmps = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/recovery/cause/loopdetect"); !data.RecoveryCauseLoopdetect.IsNull() {
+ if value.Exists() {
+ data.RecoveryCauseLoopdetect = types.BoolValue(true)
+ } else {
+ data.RecoveryCauseLoopdetect = types.BoolValue(false)
+ }
+ } else {
+ data.RecoveryCauseLoopdetect = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/recovery/cause/oam-remote-failure"); !data.RecoveryCauseOamRemoteFailure.IsNull() {
+ if value.Exists() {
+ data.RecoveryCauseOamRemoteFailure = types.BoolValue(true)
+ } else {
+ data.RecoveryCauseOamRemoteFailure = types.BoolValue(false)
+ }
+ } else {
+ data.RecoveryCauseOamRemoteFailure = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/recovery/cause/mrp-miscabling"); !data.RecoveryCauseMrpMiscabling.IsNull() {
+ if value.Exists() {
+ data.RecoveryCauseMrpMiscabling = types.BoolValue(true)
+ } else {
+ data.RecoveryCauseMrpMiscabling = types.BoolValue(false)
+ }
+ } else {
+ data.RecoveryCauseMrpMiscabling = types.BoolNull()
+ }
+}
+
+// End of section. //template:end updateFromBodyXML
+
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBody
+
+func (data *Errdisable) fromBody(ctx context.Context, res gjson.Result) {
+ prefix := helpers.LastElement(data.getPath()) + "."
+ if res.Get(helpers.LastElement(data.getPath())).IsArray() {
+ prefix += "0."
+ }
+ if value := res.Get(prefix + "detect.cause.all"); value.Exists() {
+ data.DetectCauseAll = types.BoolValue(true)
+ } else {
+ data.DetectCauseAll = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "detect.cause.arp-inspection"); value.Exists() {
+ data.DetectCauseArpInspection = types.BoolValue(true)
+ } else {
+ data.DetectCauseArpInspection = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "detect.cause.bpduguard"); value.Exists() {
+ data.DetectCauseBpduguard = types.BoolValue(true)
+ } else {
+ data.DetectCauseBpduguard = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "detect.cause.dhcp-rate-limit"); value.Exists() {
+ data.DetectCauseDhcpRateLimit = types.BoolValue(true)
+ } else {
+ data.DetectCauseDhcpRateLimit = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "detect.cause.dtp-flap"); value.Exists() {
+ data.DetectCauseDtpFlap = types.BoolValue(true)
+ } else {
+ data.DetectCauseDtpFlap = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "detect.cause.gbic-invalid"); value.Exists() {
+ data.DetectCauseGbicInvalid = types.BoolValue(true)
+ } else {
+ data.DetectCauseGbicInvalid = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "detect.cause.inline-power"); value.Exists() {
+ data.DetectCauseInlinePower = types.BoolValue(true)
+ } else {
+ data.DetectCauseInlinePower = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "detect.cause.l2ptguard"); value.Exists() {
+ data.DetectCauseL2ptguard = types.BoolValue(true)
+ } else {
+ data.DetectCauseL2ptguard = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "detect.cause.link-flap"); value.Exists() {
+ data.DetectCauseLinkFlap = types.BoolValue(true)
+ } else {
+ data.DetectCauseLinkFlap = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "detect.cause.loopback"); value.Exists() {
+ data.DetectCauseLoopback = types.BoolValue(true)
+ } else {
+ data.DetectCauseLoopback = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "detect.cause.mlacp-minlink"); value.Exists() {
+ data.DetectCauseMlacpMinlink = types.BoolValue(true)
+ } else {
+ data.DetectCauseMlacpMinlink = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "detect.cause.pagp-flap"); value.Exists() {
+ data.DetectCausePagpFlap = types.BoolValue(true)
+ } else {
+ data.DetectCausePagpFlap = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "detect.cause.pppoe-ia-rate-limit"); value.Exists() {
+ data.DetectCausePppoeIaRateLimit = types.BoolValue(true)
+ } else {
+ data.DetectCausePppoeIaRateLimit = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "detect.cause.security-violation.shutdown.vlan"); value.Exists() {
+ data.DetectCauseSecurityViolationShutdownVlan = types.BoolValue(true)
+ } else {
+ data.DetectCauseSecurityViolationShutdownVlan = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "detect.cause.sfp-config-mismatch"); value.Exists() {
+ data.DetectCauseSfpConfigMismatch = types.BoolValue(true)
+ } else {
+ data.DetectCauseSfpConfigMismatch = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "detect.cause.small-frame"); value.Exists() {
+ data.DetectCauseSmallFrame = types.BoolValue(true)
+ } else {
+ data.DetectCauseSmallFrame = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "detect.cause.loopdetect"); value.Exists() {
+ data.DetectCauseLoopdetect = types.BoolValue(value.Bool())
+ } else {
+ data.DetectCauseLoopdetect = types.BoolNull()
+ }
+ if value := res.Get(prefix + "flap-setting.cause.dtp-flap.max-flaps"); value.Exists() {
+ data.FlapSettingCauseDtpFlapMaxFlaps = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "flap-setting.cause.dtp-flap.time"); value.Exists() {
+ data.FlapSettingCauseDtpFlapTime = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "flap-setting.cause.link-flap.max-flaps"); value.Exists() {
+ data.FlapSettingCauseLinkFlapMaxFlaps = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "flap-setting.cause.link-flap.time"); value.Exists() {
+ data.FlapSettingCauseLinkFlapTime = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "flap-setting.cause.pagp-flap.max-flaps"); value.Exists() {
+ data.FlapSettingCausePagpFlapMaxFlaps = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "flap-setting.cause.pagp-flap.time"); value.Exists() {
+ data.FlapSettingCausePagpFlapTime = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "recovery.interval"); value.Exists() {
+ data.RecoveryInterval = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "recovery.cause.all"); value.Exists() {
+ data.RecoveryCauseAll = types.BoolValue(true)
+ } else {
+ data.RecoveryCauseAll = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "recovery.cause.arp-inspection"); value.Exists() {
+ data.RecoveryCauseArpInspection = types.BoolValue(true)
+ } else {
+ data.RecoveryCauseArpInspection = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "recovery.cause.bpduguard"); value.Exists() {
+ data.RecoveryCauseBpduguard = types.BoolValue(true)
+ } else {
+ data.RecoveryCauseBpduguard = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "recovery.cause.channel-misconfig"); value.Exists() {
+ data.RecoveryCauseChannelMisconfig = types.BoolValue(true)
+ } else {
+ data.RecoveryCauseChannelMisconfig = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "recovery.cause.dhcp-rate-limit"); value.Exists() {
+ data.RecoveryCauseDhcpRateLimit = types.BoolValue(true)
+ } else {
+ data.RecoveryCauseDhcpRateLimit = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "recovery.cause.dtp-flap"); value.Exists() {
+ data.RecoveryCauseDtpFlap = types.BoolValue(true)
+ } else {
+ data.RecoveryCauseDtpFlap = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "recovery.cause.gbic-invalid"); value.Exists() {
+ data.RecoveryCauseGbicInvalid = types.BoolValue(true)
+ } else {
+ data.RecoveryCauseGbicInvalid = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "recovery.cause.inline-power"); value.Exists() {
+ data.RecoveryCauseInlinePower = types.BoolValue(true)
+ } else {
+ data.RecoveryCauseInlinePower = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "recovery.cause.l2ptguard"); value.Exists() {
+ data.RecoveryCauseL2ptguard = types.BoolValue(true)
+ } else {
+ data.RecoveryCauseL2ptguard = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "recovery.cause.link-flap"); value.Exists() {
+ data.RecoveryCauseLinkFlap = types.BoolValue(true)
+ } else {
+ data.RecoveryCauseLinkFlap = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "recovery.cause.link-monitor-failure"); value.Exists() {
+ data.RecoveryCauseLinkMonitorFailure = types.BoolValue(true)
+ } else {
+ data.RecoveryCauseLinkMonitorFailure = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "recovery.cause.loopback"); value.Exists() {
+ data.RecoveryCauseLoopback = types.BoolValue(true)
+ } else {
+ data.RecoveryCauseLoopback = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "recovery.cause.mac-limit"); value.Exists() {
+ data.RecoveryCauseMacLimit = types.BoolValue(true)
+ } else {
+ data.RecoveryCauseMacLimit = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "recovery.cause.mlacp-minlink"); value.Exists() {
+ data.RecoveryCauseMlacpMinlink = types.BoolValue(true)
+ } else {
+ data.RecoveryCauseMlacpMinlink = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "recovery.cause.pagp-flap"); value.Exists() {
+ data.RecoveryCausePagpFlap = types.BoolValue(true)
+ } else {
+ data.RecoveryCausePagpFlap = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "recovery.cause.port-mode-failure"); value.Exists() {
+ data.RecoveryCausePortModeFailure = types.BoolValue(true)
+ } else {
+ data.RecoveryCausePortModeFailure = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "recovery.cause.pppoe-ia-rate-limit"); value.Exists() {
+ data.RecoveryCausePppoeIaRateLimit = types.BoolValue(true)
+ } else {
+ data.RecoveryCausePppoeIaRateLimit = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "recovery.cause.psp"); value.Exists() {
+ data.RecoveryCausePsp = types.BoolValue(true)
+ } else {
+ data.RecoveryCausePsp = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "recovery.cause.psecure-violation"); value.Exists() {
+ data.RecoveryCausePsecureViolation = types.BoolValue(true)
+ } else {
+ data.RecoveryCausePsecureViolation = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "recovery.cause.security-violation"); value.Exists() {
+ data.RecoveryCauseSecurityViolation = types.BoolValue(true)
+ } else {
+ data.RecoveryCauseSecurityViolation = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "recovery.cause.sfp-config-mismatch"); value.Exists() {
+ data.RecoveryCauseSfpConfigMismatch = types.BoolValue(true)
+ } else {
+ data.RecoveryCauseSfpConfigMismatch = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "recovery.cause.small-frame"); value.Exists() {
+ data.RecoveryCauseSmallFrame = types.BoolValue(true)
+ } else {
+ data.RecoveryCauseSmallFrame = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "recovery.cause.storm-control"); value.Exists() {
+ data.RecoveryCauseStormControl = types.BoolValue(true)
+ } else {
+ data.RecoveryCauseStormControl = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "recovery.cause.udld"); value.Exists() {
+ data.RecoveryCauseUdld = types.BoolValue(true)
+ } else {
+ data.RecoveryCauseUdld = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "recovery.cause.unicast-flood"); value.Exists() {
+ data.RecoveryCauseUnicastFlood = types.BoolValue(true)
+ } else {
+ data.RecoveryCauseUnicastFlood = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "recovery.cause.vmps"); value.Exists() {
+ data.RecoveryCauseVmps = types.BoolValue(true)
+ } else {
+ data.RecoveryCauseVmps = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "recovery.cause.loopdetect"); value.Exists() {
+ data.RecoveryCauseLoopdetect = types.BoolValue(true)
+ } else {
+ data.RecoveryCauseLoopdetect = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "recovery.cause.oam-remote-failure"); value.Exists() {
+ data.RecoveryCauseOamRemoteFailure = types.BoolValue(true)
+ } else {
+ data.RecoveryCauseOamRemoteFailure = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "recovery.cause.mrp-miscabling"); value.Exists() {
+ data.RecoveryCauseMrpMiscabling = types.BoolValue(true)
+ } else {
+ data.RecoveryCauseMrpMiscabling = types.BoolValue(false)
+ }
+}
+
+// End of section. //template:end fromBody
+
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyData
+
+func (data *ErrdisableData) fromBody(ctx context.Context, res gjson.Result) {
+ prefix := helpers.LastElement(data.getPath()) + "."
+ if res.Get(helpers.LastElement(data.getPath())).IsArray() {
+ prefix += "0."
+ }
if value := res.Get(prefix + "detect.cause.all"); value.Exists() {
data.DetectCauseAll = types.BoolValue(true)
} else {
@@ -1153,269 +2235,523 @@ func (data *Errdisable) fromBody(ctx context.Context, res gjson.Result) {
}
}
-// End of section. //template:end fromBody
+// End of section. //template:end fromBodyData
-// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyData
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyXML
-func (data *ErrdisableData) fromBody(ctx context.Context, res gjson.Result) {
- prefix := helpers.LastElement(data.getPath()) + "."
- if res.Get(helpers.LastElement(data.getPath())).IsArray() {
- prefix += "0."
+func (data *Errdisable) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/detect/cause/all"); value.Exists() {
+ data.DetectCauseAll = types.BoolValue(true)
+ } else {
+ data.DetectCauseAll = types.BoolValue(false)
}
- if value := res.Get(prefix + "detect.cause.all"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/detect/cause/arp-inspection"); value.Exists() {
+ data.DetectCauseArpInspection = types.BoolValue(true)
+ } else {
+ data.DetectCauseArpInspection = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/detect/cause/bpduguard"); value.Exists() {
+ data.DetectCauseBpduguard = types.BoolValue(true)
+ } else {
+ data.DetectCauseBpduguard = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/detect/cause/dhcp-rate-limit"); value.Exists() {
+ data.DetectCauseDhcpRateLimit = types.BoolValue(true)
+ } else {
+ data.DetectCauseDhcpRateLimit = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/detect/cause/dtp-flap"); value.Exists() {
+ data.DetectCauseDtpFlap = types.BoolValue(true)
+ } else {
+ data.DetectCauseDtpFlap = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/detect/cause/gbic-invalid"); value.Exists() {
+ data.DetectCauseGbicInvalid = types.BoolValue(true)
+ } else {
+ data.DetectCauseGbicInvalid = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/detect/cause/inline-power"); value.Exists() {
+ data.DetectCauseInlinePower = types.BoolValue(true)
+ } else {
+ data.DetectCauseInlinePower = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/detect/cause/l2ptguard"); value.Exists() {
+ data.DetectCauseL2ptguard = types.BoolValue(true)
+ } else {
+ data.DetectCauseL2ptguard = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/detect/cause/link-flap"); value.Exists() {
+ data.DetectCauseLinkFlap = types.BoolValue(true)
+ } else {
+ data.DetectCauseLinkFlap = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/detect/cause/loopback"); value.Exists() {
+ data.DetectCauseLoopback = types.BoolValue(true)
+ } else {
+ data.DetectCauseLoopback = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/detect/cause/mlacp-minlink"); value.Exists() {
+ data.DetectCauseMlacpMinlink = types.BoolValue(true)
+ } else {
+ data.DetectCauseMlacpMinlink = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/detect/cause/pagp-flap"); value.Exists() {
+ data.DetectCausePagpFlap = types.BoolValue(true)
+ } else {
+ data.DetectCausePagpFlap = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/detect/cause/pppoe-ia-rate-limit"); value.Exists() {
+ data.DetectCausePppoeIaRateLimit = types.BoolValue(true)
+ } else {
+ data.DetectCausePppoeIaRateLimit = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/detect/cause/security-violation/shutdown/vlan"); value.Exists() {
+ data.DetectCauseSecurityViolationShutdownVlan = types.BoolValue(true)
+ } else {
+ data.DetectCauseSecurityViolationShutdownVlan = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/detect/cause/sfp-config-mismatch"); value.Exists() {
+ data.DetectCauseSfpConfigMismatch = types.BoolValue(true)
+ } else {
+ data.DetectCauseSfpConfigMismatch = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/detect/cause/small-frame"); value.Exists() {
+ data.DetectCauseSmallFrame = types.BoolValue(true)
+ } else {
+ data.DetectCauseSmallFrame = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/detect/cause/loopdetect"); value.Exists() {
+ data.DetectCauseLoopdetect = types.BoolValue(value.Bool())
+ } else {
+ data.DetectCauseLoopdetect = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/flap-setting/cause/dtp-flap/max-flaps"); value.Exists() {
+ data.FlapSettingCauseDtpFlapMaxFlaps = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/flap-setting/cause/dtp-flap/time"); value.Exists() {
+ data.FlapSettingCauseDtpFlapTime = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/flap-setting/cause/link-flap/max-flaps"); value.Exists() {
+ data.FlapSettingCauseLinkFlapMaxFlaps = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/flap-setting/cause/link-flap/time"); value.Exists() {
+ data.FlapSettingCauseLinkFlapTime = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/flap-setting/cause/pagp-flap/max-flaps"); value.Exists() {
+ data.FlapSettingCausePagpFlapMaxFlaps = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/flap-setting/cause/pagp-flap/time"); value.Exists() {
+ data.FlapSettingCausePagpFlapTime = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/recovery/interval"); value.Exists() {
+ data.RecoveryInterval = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/recovery/cause/all"); value.Exists() {
+ data.RecoveryCauseAll = types.BoolValue(true)
+ } else {
+ data.RecoveryCauseAll = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/recovery/cause/arp-inspection"); value.Exists() {
+ data.RecoveryCauseArpInspection = types.BoolValue(true)
+ } else {
+ data.RecoveryCauseArpInspection = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/recovery/cause/bpduguard"); value.Exists() {
+ data.RecoveryCauseBpduguard = types.BoolValue(true)
+ } else {
+ data.RecoveryCauseBpduguard = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/recovery/cause/channel-misconfig"); value.Exists() {
+ data.RecoveryCauseChannelMisconfig = types.BoolValue(true)
+ } else {
+ data.RecoveryCauseChannelMisconfig = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/recovery/cause/dhcp-rate-limit"); value.Exists() {
+ data.RecoveryCauseDhcpRateLimit = types.BoolValue(true)
+ } else {
+ data.RecoveryCauseDhcpRateLimit = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/recovery/cause/dtp-flap"); value.Exists() {
+ data.RecoveryCauseDtpFlap = types.BoolValue(true)
+ } else {
+ data.RecoveryCauseDtpFlap = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/recovery/cause/gbic-invalid"); value.Exists() {
+ data.RecoveryCauseGbicInvalid = types.BoolValue(true)
+ } else {
+ data.RecoveryCauseGbicInvalid = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/recovery/cause/inline-power"); value.Exists() {
+ data.RecoveryCauseInlinePower = types.BoolValue(true)
+ } else {
+ data.RecoveryCauseInlinePower = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/recovery/cause/l2ptguard"); value.Exists() {
+ data.RecoveryCauseL2ptguard = types.BoolValue(true)
+ } else {
+ data.RecoveryCauseL2ptguard = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/recovery/cause/link-flap"); value.Exists() {
+ data.RecoveryCauseLinkFlap = types.BoolValue(true)
+ } else {
+ data.RecoveryCauseLinkFlap = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/recovery/cause/link-monitor-failure"); value.Exists() {
+ data.RecoveryCauseLinkMonitorFailure = types.BoolValue(true)
+ } else {
+ data.RecoveryCauseLinkMonitorFailure = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/recovery/cause/loopback"); value.Exists() {
+ data.RecoveryCauseLoopback = types.BoolValue(true)
+ } else {
+ data.RecoveryCauseLoopback = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/recovery/cause/mac-limit"); value.Exists() {
+ data.RecoveryCauseMacLimit = types.BoolValue(true)
+ } else {
+ data.RecoveryCauseMacLimit = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/recovery/cause/mlacp-minlink"); value.Exists() {
+ data.RecoveryCauseMlacpMinlink = types.BoolValue(true)
+ } else {
+ data.RecoveryCauseMlacpMinlink = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/recovery/cause/pagp-flap"); value.Exists() {
+ data.RecoveryCausePagpFlap = types.BoolValue(true)
+ } else {
+ data.RecoveryCausePagpFlap = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/recovery/cause/port-mode-failure"); value.Exists() {
+ data.RecoveryCausePortModeFailure = types.BoolValue(true)
+ } else {
+ data.RecoveryCausePortModeFailure = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/recovery/cause/pppoe-ia-rate-limit"); value.Exists() {
+ data.RecoveryCausePppoeIaRateLimit = types.BoolValue(true)
+ } else {
+ data.RecoveryCausePppoeIaRateLimit = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/recovery/cause/psp"); value.Exists() {
+ data.RecoveryCausePsp = types.BoolValue(true)
+ } else {
+ data.RecoveryCausePsp = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/recovery/cause/psecure-violation"); value.Exists() {
+ data.RecoveryCausePsecureViolation = types.BoolValue(true)
+ } else {
+ data.RecoveryCausePsecureViolation = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/recovery/cause/security-violation"); value.Exists() {
+ data.RecoveryCauseSecurityViolation = types.BoolValue(true)
+ } else {
+ data.RecoveryCauseSecurityViolation = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/recovery/cause/sfp-config-mismatch"); value.Exists() {
+ data.RecoveryCauseSfpConfigMismatch = types.BoolValue(true)
+ } else {
+ data.RecoveryCauseSfpConfigMismatch = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/recovery/cause/small-frame"); value.Exists() {
+ data.RecoveryCauseSmallFrame = types.BoolValue(true)
+ } else {
+ data.RecoveryCauseSmallFrame = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/recovery/cause/storm-control"); value.Exists() {
+ data.RecoveryCauseStormControl = types.BoolValue(true)
+ } else {
+ data.RecoveryCauseStormControl = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/recovery/cause/udld"); value.Exists() {
+ data.RecoveryCauseUdld = types.BoolValue(true)
+ } else {
+ data.RecoveryCauseUdld = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/recovery/cause/unicast-flood"); value.Exists() {
+ data.RecoveryCauseUnicastFlood = types.BoolValue(true)
+ } else {
+ data.RecoveryCauseUnicastFlood = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/recovery/cause/vmps"); value.Exists() {
+ data.RecoveryCauseVmps = types.BoolValue(true)
+ } else {
+ data.RecoveryCauseVmps = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/recovery/cause/loopdetect"); value.Exists() {
+ data.RecoveryCauseLoopdetect = types.BoolValue(true)
+ } else {
+ data.RecoveryCauseLoopdetect = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/recovery/cause/oam-remote-failure"); value.Exists() {
+ data.RecoveryCauseOamRemoteFailure = types.BoolValue(true)
+ } else {
+ data.RecoveryCauseOamRemoteFailure = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/recovery/cause/mrp-miscabling"); value.Exists() {
+ data.RecoveryCauseMrpMiscabling = types.BoolValue(true)
+ } else {
+ data.RecoveryCauseMrpMiscabling = types.BoolValue(false)
+ }
+}
+
+// End of section. //template:end fromBodyXML
+
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyDataXML
+
+func (data *ErrdisableData) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/detect/cause/all"); value.Exists() {
data.DetectCauseAll = types.BoolValue(true)
} else {
data.DetectCauseAll = types.BoolValue(false)
}
- if value := res.Get(prefix + "detect.cause.arp-inspection"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/detect/cause/arp-inspection"); value.Exists() {
data.DetectCauseArpInspection = types.BoolValue(true)
} else {
data.DetectCauseArpInspection = types.BoolValue(false)
}
- if value := res.Get(prefix + "detect.cause.bpduguard"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/detect/cause/bpduguard"); value.Exists() {
data.DetectCauseBpduguard = types.BoolValue(true)
} else {
data.DetectCauseBpduguard = types.BoolValue(false)
}
- if value := res.Get(prefix + "detect.cause.dhcp-rate-limit"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/detect/cause/dhcp-rate-limit"); value.Exists() {
data.DetectCauseDhcpRateLimit = types.BoolValue(true)
} else {
data.DetectCauseDhcpRateLimit = types.BoolValue(false)
}
- if value := res.Get(prefix + "detect.cause.dtp-flap"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/detect/cause/dtp-flap"); value.Exists() {
data.DetectCauseDtpFlap = types.BoolValue(true)
} else {
data.DetectCauseDtpFlap = types.BoolValue(false)
}
- if value := res.Get(prefix + "detect.cause.gbic-invalid"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/detect/cause/gbic-invalid"); value.Exists() {
data.DetectCauseGbicInvalid = types.BoolValue(true)
} else {
data.DetectCauseGbicInvalid = types.BoolValue(false)
}
- if value := res.Get(prefix + "detect.cause.inline-power"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/detect/cause/inline-power"); value.Exists() {
data.DetectCauseInlinePower = types.BoolValue(true)
} else {
data.DetectCauseInlinePower = types.BoolValue(false)
}
- if value := res.Get(prefix + "detect.cause.l2ptguard"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/detect/cause/l2ptguard"); value.Exists() {
data.DetectCauseL2ptguard = types.BoolValue(true)
} else {
data.DetectCauseL2ptguard = types.BoolValue(false)
}
- if value := res.Get(prefix + "detect.cause.link-flap"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/detect/cause/link-flap"); value.Exists() {
data.DetectCauseLinkFlap = types.BoolValue(true)
} else {
data.DetectCauseLinkFlap = types.BoolValue(false)
}
- if value := res.Get(prefix + "detect.cause.loopback"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/detect/cause/loopback"); value.Exists() {
data.DetectCauseLoopback = types.BoolValue(true)
} else {
data.DetectCauseLoopback = types.BoolValue(false)
}
- if value := res.Get(prefix + "detect.cause.mlacp-minlink"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/detect/cause/mlacp-minlink"); value.Exists() {
data.DetectCauseMlacpMinlink = types.BoolValue(true)
} else {
data.DetectCauseMlacpMinlink = types.BoolValue(false)
}
- if value := res.Get(prefix + "detect.cause.pagp-flap"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/detect/cause/pagp-flap"); value.Exists() {
data.DetectCausePagpFlap = types.BoolValue(true)
} else {
data.DetectCausePagpFlap = types.BoolValue(false)
}
- if value := res.Get(prefix + "detect.cause.pppoe-ia-rate-limit"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/detect/cause/pppoe-ia-rate-limit"); value.Exists() {
data.DetectCausePppoeIaRateLimit = types.BoolValue(true)
} else {
data.DetectCausePppoeIaRateLimit = types.BoolValue(false)
}
- if value := res.Get(prefix + "detect.cause.security-violation.shutdown.vlan"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/detect/cause/security-violation/shutdown/vlan"); value.Exists() {
data.DetectCauseSecurityViolationShutdownVlan = types.BoolValue(true)
} else {
data.DetectCauseSecurityViolationShutdownVlan = types.BoolValue(false)
}
- if value := res.Get(prefix + "detect.cause.sfp-config-mismatch"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/detect/cause/sfp-config-mismatch"); value.Exists() {
data.DetectCauseSfpConfigMismatch = types.BoolValue(true)
} else {
data.DetectCauseSfpConfigMismatch = types.BoolValue(false)
}
- if value := res.Get(prefix + "detect.cause.small-frame"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/detect/cause/small-frame"); value.Exists() {
data.DetectCauseSmallFrame = types.BoolValue(true)
} else {
data.DetectCauseSmallFrame = types.BoolValue(false)
}
- if value := res.Get(prefix + "detect.cause.loopdetect"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/detect/cause/loopdetect"); value.Exists() {
data.DetectCauseLoopdetect = types.BoolValue(value.Bool())
} else {
data.DetectCauseLoopdetect = types.BoolNull()
}
- if value := res.Get(prefix + "flap-setting.cause.dtp-flap.max-flaps"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/flap-setting/cause/dtp-flap/max-flaps"); value.Exists() {
data.FlapSettingCauseDtpFlapMaxFlaps = types.Int64Value(value.Int())
}
- if value := res.Get(prefix + "flap-setting.cause.dtp-flap.time"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/flap-setting/cause/dtp-flap/time"); value.Exists() {
data.FlapSettingCauseDtpFlapTime = types.Int64Value(value.Int())
}
- if value := res.Get(prefix + "flap-setting.cause.link-flap.max-flaps"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/flap-setting/cause/link-flap/max-flaps"); value.Exists() {
data.FlapSettingCauseLinkFlapMaxFlaps = types.Int64Value(value.Int())
}
- if value := res.Get(prefix + "flap-setting.cause.link-flap.time"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/flap-setting/cause/link-flap/time"); value.Exists() {
data.FlapSettingCauseLinkFlapTime = types.Int64Value(value.Int())
}
- if value := res.Get(prefix + "flap-setting.cause.pagp-flap.max-flaps"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/flap-setting/cause/pagp-flap/max-flaps"); value.Exists() {
data.FlapSettingCausePagpFlapMaxFlaps = types.Int64Value(value.Int())
}
- if value := res.Get(prefix + "flap-setting.cause.pagp-flap.time"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/flap-setting/cause/pagp-flap/time"); value.Exists() {
data.FlapSettingCausePagpFlapTime = types.Int64Value(value.Int())
}
- if value := res.Get(prefix + "recovery.interval"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/recovery/interval"); value.Exists() {
data.RecoveryInterval = types.Int64Value(value.Int())
}
- if value := res.Get(prefix + "recovery.cause.all"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/recovery/cause/all"); value.Exists() {
data.RecoveryCauseAll = types.BoolValue(true)
} else {
data.RecoveryCauseAll = types.BoolValue(false)
}
- if value := res.Get(prefix + "recovery.cause.arp-inspection"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/recovery/cause/arp-inspection"); value.Exists() {
data.RecoveryCauseArpInspection = types.BoolValue(true)
} else {
data.RecoveryCauseArpInspection = types.BoolValue(false)
}
- if value := res.Get(prefix + "recovery.cause.bpduguard"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/recovery/cause/bpduguard"); value.Exists() {
data.RecoveryCauseBpduguard = types.BoolValue(true)
} else {
data.RecoveryCauseBpduguard = types.BoolValue(false)
}
- if value := res.Get(prefix + "recovery.cause.channel-misconfig"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/recovery/cause/channel-misconfig"); value.Exists() {
data.RecoveryCauseChannelMisconfig = types.BoolValue(true)
} else {
data.RecoveryCauseChannelMisconfig = types.BoolValue(false)
}
- if value := res.Get(prefix + "recovery.cause.dhcp-rate-limit"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/recovery/cause/dhcp-rate-limit"); value.Exists() {
data.RecoveryCauseDhcpRateLimit = types.BoolValue(true)
} else {
data.RecoveryCauseDhcpRateLimit = types.BoolValue(false)
}
- if value := res.Get(prefix + "recovery.cause.dtp-flap"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/recovery/cause/dtp-flap"); value.Exists() {
data.RecoveryCauseDtpFlap = types.BoolValue(true)
} else {
data.RecoveryCauseDtpFlap = types.BoolValue(false)
}
- if value := res.Get(prefix + "recovery.cause.gbic-invalid"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/recovery/cause/gbic-invalid"); value.Exists() {
data.RecoveryCauseGbicInvalid = types.BoolValue(true)
} else {
data.RecoveryCauseGbicInvalid = types.BoolValue(false)
}
- if value := res.Get(prefix + "recovery.cause.inline-power"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/recovery/cause/inline-power"); value.Exists() {
data.RecoveryCauseInlinePower = types.BoolValue(true)
} else {
data.RecoveryCauseInlinePower = types.BoolValue(false)
}
- if value := res.Get(prefix + "recovery.cause.l2ptguard"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/recovery/cause/l2ptguard"); value.Exists() {
data.RecoveryCauseL2ptguard = types.BoolValue(true)
} else {
data.RecoveryCauseL2ptguard = types.BoolValue(false)
}
- if value := res.Get(prefix + "recovery.cause.link-flap"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/recovery/cause/link-flap"); value.Exists() {
data.RecoveryCauseLinkFlap = types.BoolValue(true)
} else {
data.RecoveryCauseLinkFlap = types.BoolValue(false)
}
- if value := res.Get(prefix + "recovery.cause.link-monitor-failure"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/recovery/cause/link-monitor-failure"); value.Exists() {
data.RecoveryCauseLinkMonitorFailure = types.BoolValue(true)
} else {
data.RecoveryCauseLinkMonitorFailure = types.BoolValue(false)
}
- if value := res.Get(prefix + "recovery.cause.loopback"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/recovery/cause/loopback"); value.Exists() {
data.RecoveryCauseLoopback = types.BoolValue(true)
} else {
data.RecoveryCauseLoopback = types.BoolValue(false)
}
- if value := res.Get(prefix + "recovery.cause.mac-limit"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/recovery/cause/mac-limit"); value.Exists() {
data.RecoveryCauseMacLimit = types.BoolValue(true)
} else {
data.RecoveryCauseMacLimit = types.BoolValue(false)
}
- if value := res.Get(prefix + "recovery.cause.mlacp-minlink"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/recovery/cause/mlacp-minlink"); value.Exists() {
data.RecoveryCauseMlacpMinlink = types.BoolValue(true)
} else {
data.RecoveryCauseMlacpMinlink = types.BoolValue(false)
}
- if value := res.Get(prefix + "recovery.cause.pagp-flap"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/recovery/cause/pagp-flap"); value.Exists() {
data.RecoveryCausePagpFlap = types.BoolValue(true)
} else {
data.RecoveryCausePagpFlap = types.BoolValue(false)
}
- if value := res.Get(prefix + "recovery.cause.port-mode-failure"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/recovery/cause/port-mode-failure"); value.Exists() {
data.RecoveryCausePortModeFailure = types.BoolValue(true)
} else {
data.RecoveryCausePortModeFailure = types.BoolValue(false)
}
- if value := res.Get(prefix + "recovery.cause.pppoe-ia-rate-limit"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/recovery/cause/pppoe-ia-rate-limit"); value.Exists() {
data.RecoveryCausePppoeIaRateLimit = types.BoolValue(true)
} else {
data.RecoveryCausePppoeIaRateLimit = types.BoolValue(false)
}
- if value := res.Get(prefix + "recovery.cause.psp"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/recovery/cause/psp"); value.Exists() {
data.RecoveryCausePsp = types.BoolValue(true)
} else {
data.RecoveryCausePsp = types.BoolValue(false)
}
- if value := res.Get(prefix + "recovery.cause.psecure-violation"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/recovery/cause/psecure-violation"); value.Exists() {
data.RecoveryCausePsecureViolation = types.BoolValue(true)
} else {
data.RecoveryCausePsecureViolation = types.BoolValue(false)
}
- if value := res.Get(prefix + "recovery.cause.security-violation"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/recovery/cause/security-violation"); value.Exists() {
data.RecoveryCauseSecurityViolation = types.BoolValue(true)
} else {
data.RecoveryCauseSecurityViolation = types.BoolValue(false)
}
- if value := res.Get(prefix + "recovery.cause.sfp-config-mismatch"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/recovery/cause/sfp-config-mismatch"); value.Exists() {
data.RecoveryCauseSfpConfigMismatch = types.BoolValue(true)
} else {
data.RecoveryCauseSfpConfigMismatch = types.BoolValue(false)
}
- if value := res.Get(prefix + "recovery.cause.small-frame"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/recovery/cause/small-frame"); value.Exists() {
data.RecoveryCauseSmallFrame = types.BoolValue(true)
} else {
data.RecoveryCauseSmallFrame = types.BoolValue(false)
}
- if value := res.Get(prefix + "recovery.cause.storm-control"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/recovery/cause/storm-control"); value.Exists() {
data.RecoveryCauseStormControl = types.BoolValue(true)
} else {
data.RecoveryCauseStormControl = types.BoolValue(false)
}
- if value := res.Get(prefix + "recovery.cause.udld"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/recovery/cause/udld"); value.Exists() {
data.RecoveryCauseUdld = types.BoolValue(true)
} else {
data.RecoveryCauseUdld = types.BoolValue(false)
}
- if value := res.Get(prefix + "recovery.cause.unicast-flood"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/recovery/cause/unicast-flood"); value.Exists() {
data.RecoveryCauseUnicastFlood = types.BoolValue(true)
} else {
data.RecoveryCauseUnicastFlood = types.BoolValue(false)
}
- if value := res.Get(prefix + "recovery.cause.vmps"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/recovery/cause/vmps"); value.Exists() {
data.RecoveryCauseVmps = types.BoolValue(true)
} else {
data.RecoveryCauseVmps = types.BoolValue(false)
}
- if value := res.Get(prefix + "recovery.cause.loopdetect"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/recovery/cause/loopdetect"); value.Exists() {
data.RecoveryCauseLoopdetect = types.BoolValue(true)
} else {
data.RecoveryCauseLoopdetect = types.BoolValue(false)
}
- if value := res.Get(prefix + "recovery.cause.oam-remote-failure"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/recovery/cause/oam-remote-failure"); value.Exists() {
data.RecoveryCauseOamRemoteFailure = types.BoolValue(true)
} else {
data.RecoveryCauseOamRemoteFailure = types.BoolValue(false)
}
- if value := res.Get(prefix + "recovery.cause.mrp-miscabling"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/recovery/cause/mrp-miscabling"); value.Exists() {
data.RecoveryCauseMrpMiscabling = types.BoolValue(true)
} else {
data.RecoveryCauseMrpMiscabling = types.BoolValue(false)
}
}
-// End of section. //template:end fromBodyData
+// End of section. //template:end fromBodyDataXML
// Section below is generated&owned by "gen/generator.go". //template:begin getDeletedItems
@@ -1586,6 +2922,175 @@ func (data *Errdisable) getDeletedItems(ctx context.Context, state Errdisable) [
// End of section. //template:end getDeletedItems
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletedItemsXML
+
+func (data *Errdisable) addDeletedItemsXML(ctx context.Context, state Errdisable, body string) string {
+ b := netconf.NewBody(body)
+ if !state.DetectCauseAll.IsNull() && data.DetectCauseAll.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/detect/cause/all")
+ }
+ if !state.DetectCauseArpInspection.IsNull() && data.DetectCauseArpInspection.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/detect/cause/arp-inspection")
+ }
+ if !state.DetectCauseBpduguard.IsNull() && data.DetectCauseBpduguard.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/detect/cause/bpduguard")
+ }
+ if !state.DetectCauseDhcpRateLimit.IsNull() && data.DetectCauseDhcpRateLimit.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/detect/cause/dhcp-rate-limit")
+ }
+ if !state.DetectCauseDtpFlap.IsNull() && data.DetectCauseDtpFlap.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/detect/cause/dtp-flap")
+ }
+ if !state.DetectCauseGbicInvalid.IsNull() && data.DetectCauseGbicInvalid.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/detect/cause/gbic-invalid")
+ }
+ if !state.DetectCauseInlinePower.IsNull() && data.DetectCauseInlinePower.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/detect/cause/inline-power")
+ }
+ if !state.DetectCauseL2ptguard.IsNull() && data.DetectCauseL2ptguard.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/detect/cause/l2ptguard")
+ }
+ if !state.DetectCauseLinkFlap.IsNull() && data.DetectCauseLinkFlap.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/detect/cause/link-flap")
+ }
+ if !state.DetectCauseLoopback.IsNull() && data.DetectCauseLoopback.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/detect/cause/loopback")
+ }
+ if !state.DetectCauseMlacpMinlink.IsNull() && data.DetectCauseMlacpMinlink.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/detect/cause/mlacp-minlink")
+ }
+ if !state.DetectCausePagpFlap.IsNull() && data.DetectCausePagpFlap.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/detect/cause/pagp-flap")
+ }
+ if !state.DetectCausePppoeIaRateLimit.IsNull() && data.DetectCausePppoeIaRateLimit.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/detect/cause/pppoe-ia-rate-limit")
+ }
+ if !state.DetectCauseSecurityViolationShutdownVlan.IsNull() && data.DetectCauseSecurityViolationShutdownVlan.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/detect/cause/security-violation/shutdown/vlan")
+ }
+ if !state.DetectCauseSfpConfigMismatch.IsNull() && data.DetectCauseSfpConfigMismatch.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/detect/cause/sfp-config-mismatch")
+ }
+ if !state.DetectCauseSmallFrame.IsNull() && data.DetectCauseSmallFrame.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/detect/cause/small-frame")
+ }
+ if !state.DetectCauseLoopdetect.IsNull() && data.DetectCauseLoopdetect.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/detect/cause/loopdetect")
+ }
+ if !state.FlapSettingCauseDtpFlapMaxFlaps.IsNull() && data.FlapSettingCauseDtpFlapMaxFlaps.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/flap-setting/cause/dtp-flap/max-flaps")
+ }
+ if !state.FlapSettingCauseDtpFlapTime.IsNull() && data.FlapSettingCauseDtpFlapTime.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/flap-setting/cause/dtp-flap/time")
+ }
+ if !state.FlapSettingCauseLinkFlapMaxFlaps.IsNull() && data.FlapSettingCauseLinkFlapMaxFlaps.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/flap-setting/cause/link-flap/max-flaps")
+ }
+ if !state.FlapSettingCauseLinkFlapTime.IsNull() && data.FlapSettingCauseLinkFlapTime.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/flap-setting/cause/link-flap/time")
+ }
+ if !state.FlapSettingCausePagpFlapMaxFlaps.IsNull() && data.FlapSettingCausePagpFlapMaxFlaps.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/flap-setting/cause/pagp-flap/max-flaps")
+ }
+ if !state.FlapSettingCausePagpFlapTime.IsNull() && data.FlapSettingCausePagpFlapTime.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/flap-setting/cause/pagp-flap/time")
+ }
+ if !state.RecoveryInterval.IsNull() && data.RecoveryInterval.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/recovery/interval")
+ }
+ if !state.RecoveryCauseAll.IsNull() && data.RecoveryCauseAll.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/recovery/cause/all")
+ }
+ if !state.RecoveryCauseArpInspection.IsNull() && data.RecoveryCauseArpInspection.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/recovery/cause/arp-inspection")
+ }
+ if !state.RecoveryCauseBpduguard.IsNull() && data.RecoveryCauseBpduguard.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/recovery/cause/bpduguard")
+ }
+ if !state.RecoveryCauseChannelMisconfig.IsNull() && data.RecoveryCauseChannelMisconfig.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/recovery/cause/channel-misconfig")
+ }
+ if !state.RecoveryCauseDhcpRateLimit.IsNull() && data.RecoveryCauseDhcpRateLimit.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/recovery/cause/dhcp-rate-limit")
+ }
+ if !state.RecoveryCauseDtpFlap.IsNull() && data.RecoveryCauseDtpFlap.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/recovery/cause/dtp-flap")
+ }
+ if !state.RecoveryCauseGbicInvalid.IsNull() && data.RecoveryCauseGbicInvalid.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/recovery/cause/gbic-invalid")
+ }
+ if !state.RecoveryCauseInlinePower.IsNull() && data.RecoveryCauseInlinePower.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/recovery/cause/inline-power")
+ }
+ if !state.RecoveryCauseL2ptguard.IsNull() && data.RecoveryCauseL2ptguard.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/recovery/cause/l2ptguard")
+ }
+ if !state.RecoveryCauseLinkFlap.IsNull() && data.RecoveryCauseLinkFlap.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/recovery/cause/link-flap")
+ }
+ if !state.RecoveryCauseLinkMonitorFailure.IsNull() && data.RecoveryCauseLinkMonitorFailure.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/recovery/cause/link-monitor-failure")
+ }
+ if !state.RecoveryCauseLoopback.IsNull() && data.RecoveryCauseLoopback.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/recovery/cause/loopback")
+ }
+ if !state.RecoveryCauseMacLimit.IsNull() && data.RecoveryCauseMacLimit.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/recovery/cause/mac-limit")
+ }
+ if !state.RecoveryCauseMlacpMinlink.IsNull() && data.RecoveryCauseMlacpMinlink.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/recovery/cause/mlacp-minlink")
+ }
+ if !state.RecoveryCausePagpFlap.IsNull() && data.RecoveryCausePagpFlap.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/recovery/cause/pagp-flap")
+ }
+ if !state.RecoveryCausePortModeFailure.IsNull() && data.RecoveryCausePortModeFailure.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/recovery/cause/port-mode-failure")
+ }
+ if !state.RecoveryCausePppoeIaRateLimit.IsNull() && data.RecoveryCausePppoeIaRateLimit.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/recovery/cause/pppoe-ia-rate-limit")
+ }
+ if !state.RecoveryCausePsp.IsNull() && data.RecoveryCausePsp.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/recovery/cause/psp")
+ }
+ if !state.RecoveryCausePsecureViolation.IsNull() && data.RecoveryCausePsecureViolation.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/recovery/cause/psecure-violation")
+ }
+ if !state.RecoveryCauseSecurityViolation.IsNull() && data.RecoveryCauseSecurityViolation.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/recovery/cause/security-violation")
+ }
+ if !state.RecoveryCauseSfpConfigMismatch.IsNull() && data.RecoveryCauseSfpConfigMismatch.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/recovery/cause/sfp-config-mismatch")
+ }
+ if !state.RecoveryCauseSmallFrame.IsNull() && data.RecoveryCauseSmallFrame.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/recovery/cause/small-frame")
+ }
+ if !state.RecoveryCauseStormControl.IsNull() && data.RecoveryCauseStormControl.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/recovery/cause/storm-control")
+ }
+ if !state.RecoveryCauseUdld.IsNull() && data.RecoveryCauseUdld.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/recovery/cause/udld")
+ }
+ if !state.RecoveryCauseUnicastFlood.IsNull() && data.RecoveryCauseUnicastFlood.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/recovery/cause/unicast-flood")
+ }
+ if !state.RecoveryCauseVmps.IsNull() && data.RecoveryCauseVmps.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/recovery/cause/vmps")
+ }
+ if !state.RecoveryCauseLoopdetect.IsNull() && data.RecoveryCauseLoopdetect.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/recovery/cause/loopdetect")
+ }
+ if !state.RecoveryCauseOamRemoteFailure.IsNull() && data.RecoveryCauseOamRemoteFailure.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/recovery/cause/oam-remote-failure")
+ }
+ if !state.RecoveryCauseMrpMiscabling.IsNull() && data.RecoveryCauseMrpMiscabling.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/recovery/cause/mrp-miscabling")
+ }
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletedItemsXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin getEmptyLeafsDelete
func (data *Errdisable) getEmptyLeafsDelete(ctx context.Context) []string {
@@ -1899,3 +3404,172 @@ func (data *Errdisable) getDeletePaths(ctx context.Context) []string {
}
// End of section. //template:end getDeletePaths
+
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletePathsXML
+
+func (data *Errdisable) addDeletePathsXML(ctx context.Context, body string) string {
+ b := netconf.NewBody(body)
+ if !data.DetectCauseAll.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/detect/cause/all")
+ }
+ if !data.DetectCauseArpInspection.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/detect/cause/arp-inspection")
+ }
+ if !data.DetectCauseBpduguard.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/detect/cause/bpduguard")
+ }
+ if !data.DetectCauseDhcpRateLimit.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/detect/cause/dhcp-rate-limit")
+ }
+ if !data.DetectCauseDtpFlap.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/detect/cause/dtp-flap")
+ }
+ if !data.DetectCauseGbicInvalid.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/detect/cause/gbic-invalid")
+ }
+ if !data.DetectCauseInlinePower.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/detect/cause/inline-power")
+ }
+ if !data.DetectCauseL2ptguard.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/detect/cause/l2ptguard")
+ }
+ if !data.DetectCauseLinkFlap.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/detect/cause/link-flap")
+ }
+ if !data.DetectCauseLoopback.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/detect/cause/loopback")
+ }
+ if !data.DetectCauseMlacpMinlink.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/detect/cause/mlacp-minlink")
+ }
+ if !data.DetectCausePagpFlap.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/detect/cause/pagp-flap")
+ }
+ if !data.DetectCausePppoeIaRateLimit.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/detect/cause/pppoe-ia-rate-limit")
+ }
+ if !data.DetectCauseSecurityViolationShutdownVlan.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/detect/cause/security-violation/shutdown/vlan")
+ }
+ if !data.DetectCauseSfpConfigMismatch.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/detect/cause/sfp-config-mismatch")
+ }
+ if !data.DetectCauseSmallFrame.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/detect/cause/small-frame")
+ }
+ if !data.DetectCauseLoopdetect.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/detect/cause/loopdetect")
+ }
+ if !data.FlapSettingCauseDtpFlapMaxFlaps.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/flap-setting/cause/dtp-flap/max-flaps")
+ }
+ if !data.FlapSettingCauseDtpFlapTime.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/flap-setting/cause/dtp-flap/time")
+ }
+ if !data.FlapSettingCauseLinkFlapMaxFlaps.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/flap-setting/cause/link-flap/max-flaps")
+ }
+ if !data.FlapSettingCauseLinkFlapTime.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/flap-setting/cause/link-flap/time")
+ }
+ if !data.FlapSettingCausePagpFlapMaxFlaps.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/flap-setting/cause/pagp-flap/max-flaps")
+ }
+ if !data.FlapSettingCausePagpFlapTime.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/flap-setting/cause/pagp-flap/time")
+ }
+ if !data.RecoveryInterval.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/recovery/interval")
+ }
+ if !data.RecoveryCauseAll.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/recovery/cause/all")
+ }
+ if !data.RecoveryCauseArpInspection.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/recovery/cause/arp-inspection")
+ }
+ if !data.RecoveryCauseBpduguard.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/recovery/cause/bpduguard")
+ }
+ if !data.RecoveryCauseChannelMisconfig.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/recovery/cause/channel-misconfig")
+ }
+ if !data.RecoveryCauseDhcpRateLimit.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/recovery/cause/dhcp-rate-limit")
+ }
+ if !data.RecoveryCauseDtpFlap.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/recovery/cause/dtp-flap")
+ }
+ if !data.RecoveryCauseGbicInvalid.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/recovery/cause/gbic-invalid")
+ }
+ if !data.RecoveryCauseInlinePower.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/recovery/cause/inline-power")
+ }
+ if !data.RecoveryCauseL2ptguard.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/recovery/cause/l2ptguard")
+ }
+ if !data.RecoveryCauseLinkFlap.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/recovery/cause/link-flap")
+ }
+ if !data.RecoveryCauseLinkMonitorFailure.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/recovery/cause/link-monitor-failure")
+ }
+ if !data.RecoveryCauseLoopback.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/recovery/cause/loopback")
+ }
+ if !data.RecoveryCauseMacLimit.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/recovery/cause/mac-limit")
+ }
+ if !data.RecoveryCauseMlacpMinlink.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/recovery/cause/mlacp-minlink")
+ }
+ if !data.RecoveryCausePagpFlap.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/recovery/cause/pagp-flap")
+ }
+ if !data.RecoveryCausePortModeFailure.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/recovery/cause/port-mode-failure")
+ }
+ if !data.RecoveryCausePppoeIaRateLimit.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/recovery/cause/pppoe-ia-rate-limit")
+ }
+ if !data.RecoveryCausePsp.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/recovery/cause/psp")
+ }
+ if !data.RecoveryCausePsecureViolation.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/recovery/cause/psecure-violation")
+ }
+ if !data.RecoveryCauseSecurityViolation.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/recovery/cause/security-violation")
+ }
+ if !data.RecoveryCauseSfpConfigMismatch.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/recovery/cause/sfp-config-mismatch")
+ }
+ if !data.RecoveryCauseSmallFrame.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/recovery/cause/small-frame")
+ }
+ if !data.RecoveryCauseStormControl.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/recovery/cause/storm-control")
+ }
+ if !data.RecoveryCauseUdld.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/recovery/cause/udld")
+ }
+ if !data.RecoveryCauseUnicastFlood.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/recovery/cause/unicast-flood")
+ }
+ if !data.RecoveryCauseVmps.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/recovery/cause/vmps")
+ }
+ if !data.RecoveryCauseLoopdetect.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/recovery/cause/loopdetect")
+ }
+ if !data.RecoveryCauseOamRemoteFailure.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/recovery/cause/oam-remote-failure")
+ }
+ if !data.RecoveryCauseMrpMiscabling.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/recovery/cause/mrp-miscabling")
+ }
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletePathsXML
diff --git a/internal/provider/model_iosxe_evpn.go b/internal/provider/model_iosxe_evpn.go
index f1d846f3..6caea9bb 100644
--- a/internal/provider/model_iosxe_evpn.go
+++ b/internal/provider/model_iosxe_evpn.go
@@ -28,6 +28,9 @@ import (
"github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/types"
+ "github.com/hashicorp/terraform-plugin-log/tflog"
+ "github.com/netascode/go-netconf"
+ "github.com/netascode/xmldot"
"github.com/tidwall/gjson"
"github.com/tidwall/sjson"
)
@@ -97,6 +100,17 @@ func (data EVPN) getPathShort() string {
return matches[1]
}
+// getXPath returns the XPath for NETCONF operations
+func (data EVPN) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/l2vpn/Cisco-IOS-XE-l2vpn:evpn_cont/evpn"
+ return path
+}
+
+func (data EVPNData) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/l2vpn/Cisco-IOS-XE-l2vpn:evpn_cont/evpn"
+ return path
+}
+
// End of section. //template:end getPath
// Section below is generated&owned by "gen/generator.go". //template:begin toBody
@@ -168,6 +182,97 @@ func (data EVPN) toBody(ctx context.Context) string {
// End of section. //template:end toBody
+// Section below is generated&owned by "gen/generator.go". //template:begin toBodyXML
+
+func (data EVPN) toBodyXML(ctx context.Context) string {
+ body := netconf.Body{}
+ if !data.ReplicationTypeIngress.IsNull() && !data.ReplicationTypeIngress.IsUnknown() {
+ if data.ReplicationTypeIngress.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/replication-type/ingress", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/replication-type/ingress")
+ }
+ }
+ if !data.ReplicationTypeStatic.IsNull() && !data.ReplicationTypeStatic.IsUnknown() {
+ if data.ReplicationTypeStatic.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/replication-type/static", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/replication-type/static")
+ }
+ }
+ if !data.ReplicationTypeP2mp.IsNull() && !data.ReplicationTypeP2mp.IsUnknown() {
+ if data.ReplicationTypeP2mp.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/replication-type/p2mp", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/replication-type/p2mp")
+ }
+ }
+ if !data.ReplicationTypeMp2mp.IsNull() && !data.ReplicationTypeMp2mp.IsUnknown() {
+ if data.ReplicationTypeMp2mp.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/replication-type/mp2mp", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/replication-type/mp2mp")
+ }
+ }
+ if !data.MacDuplicationLimit.IsNull() && !data.MacDuplicationLimit.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/mac/duplication/limit", strconv.FormatInt(data.MacDuplicationLimit.ValueInt64(), 10))
+ }
+ if !data.MacDuplicationTime.IsNull() && !data.MacDuplicationTime.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/mac/duplication/time", strconv.FormatInt(data.MacDuplicationTime.ValueInt64(), 10))
+ }
+ if !data.IpDuplicationLimit.IsNull() && !data.IpDuplicationLimit.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ip/duplication/limit", strconv.FormatInt(data.IpDuplicationLimit.ValueInt64(), 10))
+ }
+ if !data.IpDuplicationTime.IsNull() && !data.IpDuplicationTime.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ip/duplication/time", strconv.FormatInt(data.IpDuplicationTime.ValueInt64(), 10))
+ }
+ if !data.RouterIdLoopback.IsNull() && !data.RouterIdLoopback.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/router-id/interface/Loopback", strconv.FormatInt(data.RouterIdLoopback.ValueInt64(), 10))
+ }
+ if !data.DefaultGatewayAdvertise.IsNull() && !data.DefaultGatewayAdvertise.IsUnknown() {
+ if data.DefaultGatewayAdvertise.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/default-gateway/advertise", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/default-gateway/advertise")
+ }
+ }
+ if !data.LoggingPeerState.IsNull() && !data.LoggingPeerState.IsUnknown() {
+ if data.LoggingPeerState.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/logging/peer/state", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/logging/peer/state")
+ }
+ }
+ if !data.RouteTargetAutoVni.IsNull() && !data.RouteTargetAutoVni.IsUnknown() {
+ if data.RouteTargetAutoVni.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/route-target/auto/vni", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/route-target/auto/vni")
+ }
+ }
+ if !data.AnycastGatewayMacAuto.IsNull() && !data.AnycastGatewayMacAuto.IsUnknown() {
+ if data.AnycastGatewayMacAuto.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/anycast-gateway/mac/auto", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/anycast-gateway/mac/auto")
+ }
+ }
+ if !data.FloodingSuppressionAddressResolutionDisable.IsNull() && !data.FloodingSuppressionAddressResolutionDisable.IsUnknown() {
+ if data.FloodingSuppressionAddressResolutionDisable.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/flooding-suppression/address-resolution/disable", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/flooding-suppression/address-resolution/disable")
+ }
+ }
+ bodyString, err := body.String()
+ if err != nil {
+ tflog.Error(ctx, fmt.Sprintf("Error converting body to string: %s", err))
+ }
+ return bodyString
+}
+
+// End of section. //template:end toBodyXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBody
func (data *EVPN) updateFromBody(ctx context.Context, res gjson.Result) {
@@ -285,6 +390,119 @@ func (data *EVPN) updateFromBody(ctx context.Context, res gjson.Result) {
// End of section. //template:end updateFromBody
+// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBodyXML
+
+func (data *EVPN) updateFromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/replication-type/ingress"); !data.ReplicationTypeIngress.IsNull() {
+ if value.Exists() {
+ data.ReplicationTypeIngress = types.BoolValue(true)
+ } else {
+ data.ReplicationTypeIngress = types.BoolValue(false)
+ }
+ } else {
+ data.ReplicationTypeIngress = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/replication-type/static"); !data.ReplicationTypeStatic.IsNull() {
+ if value.Exists() {
+ data.ReplicationTypeStatic = types.BoolValue(true)
+ } else {
+ data.ReplicationTypeStatic = types.BoolValue(false)
+ }
+ } else {
+ data.ReplicationTypeStatic = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/replication-type/p2mp"); !data.ReplicationTypeP2mp.IsNull() {
+ if value.Exists() {
+ data.ReplicationTypeP2mp = types.BoolValue(true)
+ } else {
+ data.ReplicationTypeP2mp = types.BoolValue(false)
+ }
+ } else {
+ data.ReplicationTypeP2mp = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/replication-type/mp2mp"); !data.ReplicationTypeMp2mp.IsNull() {
+ if value.Exists() {
+ data.ReplicationTypeMp2mp = types.BoolValue(true)
+ } else {
+ data.ReplicationTypeMp2mp = types.BoolValue(false)
+ }
+ } else {
+ data.ReplicationTypeMp2mp = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/mac/duplication/limit"); value.Exists() && !data.MacDuplicationLimit.IsNull() {
+ data.MacDuplicationLimit = types.Int64Value(value.Int())
+ } else {
+ data.MacDuplicationLimit = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/mac/duplication/time"); value.Exists() && !data.MacDuplicationTime.IsNull() {
+ data.MacDuplicationTime = types.Int64Value(value.Int())
+ } else {
+ data.MacDuplicationTime = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/duplication/limit"); value.Exists() && !data.IpDuplicationLimit.IsNull() {
+ data.IpDuplicationLimit = types.Int64Value(value.Int())
+ } else {
+ data.IpDuplicationLimit = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/duplication/time"); value.Exists() && !data.IpDuplicationTime.IsNull() {
+ data.IpDuplicationTime = types.Int64Value(value.Int())
+ } else {
+ data.IpDuplicationTime = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/router-id/interface/Loopback"); value.Exists() && !data.RouterIdLoopback.IsNull() {
+ data.RouterIdLoopback = types.Int64Value(value.Int())
+ } else {
+ data.RouterIdLoopback = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/default-gateway/advertise"); !data.DefaultGatewayAdvertise.IsNull() {
+ if value.Exists() {
+ data.DefaultGatewayAdvertise = types.BoolValue(true)
+ } else {
+ data.DefaultGatewayAdvertise = types.BoolValue(false)
+ }
+ } else {
+ data.DefaultGatewayAdvertise = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/logging/peer/state"); !data.LoggingPeerState.IsNull() {
+ if value.Exists() {
+ data.LoggingPeerState = types.BoolValue(true)
+ } else {
+ data.LoggingPeerState = types.BoolValue(false)
+ }
+ } else {
+ data.LoggingPeerState = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/route-target/auto/vni"); !data.RouteTargetAutoVni.IsNull() {
+ if value.Exists() {
+ data.RouteTargetAutoVni = types.BoolValue(true)
+ } else {
+ data.RouteTargetAutoVni = types.BoolValue(false)
+ }
+ } else {
+ data.RouteTargetAutoVni = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/anycast-gateway/mac/auto"); !data.AnycastGatewayMacAuto.IsNull() {
+ if value.Exists() {
+ data.AnycastGatewayMacAuto = types.BoolValue(true)
+ } else {
+ data.AnycastGatewayMacAuto = types.BoolValue(false)
+ }
+ } else {
+ data.AnycastGatewayMacAuto = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/flooding-suppression/address-resolution/disable"); !data.FloodingSuppressionAddressResolutionDisable.IsNull() {
+ if value.Exists() {
+ data.FloodingSuppressionAddressResolutionDisable = types.BoolValue(true)
+ } else {
+ data.FloodingSuppressionAddressResolutionDisable = types.BoolValue(false)
+ }
+ } else {
+ data.FloodingSuppressionAddressResolutionDisable = types.BoolNull()
+ }
+}
+
+// End of section. //template:end updateFromBodyXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin fromBody
func (data *EVPN) fromBody(ctx context.Context, res gjson.Result) {
@@ -427,6 +645,140 @@ func (data *EVPNData) fromBody(ctx context.Context, res gjson.Result) {
// End of section. //template:end fromBodyData
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyXML
+
+func (data *EVPN) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/replication-type/ingress"); value.Exists() {
+ data.ReplicationTypeIngress = types.BoolValue(true)
+ } else {
+ data.ReplicationTypeIngress = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/replication-type/static"); value.Exists() {
+ data.ReplicationTypeStatic = types.BoolValue(true)
+ } else {
+ data.ReplicationTypeStatic = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/replication-type/p2mp"); value.Exists() {
+ data.ReplicationTypeP2mp = types.BoolValue(true)
+ } else {
+ data.ReplicationTypeP2mp = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/replication-type/mp2mp"); value.Exists() {
+ data.ReplicationTypeMp2mp = types.BoolValue(true)
+ } else {
+ data.ReplicationTypeMp2mp = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/mac/duplication/limit"); value.Exists() {
+ data.MacDuplicationLimit = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/mac/duplication/time"); value.Exists() {
+ data.MacDuplicationTime = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/duplication/limit"); value.Exists() {
+ data.IpDuplicationLimit = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/duplication/time"); value.Exists() {
+ data.IpDuplicationTime = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/router-id/interface/Loopback"); value.Exists() {
+ data.RouterIdLoopback = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/default-gateway/advertise"); value.Exists() {
+ data.DefaultGatewayAdvertise = types.BoolValue(true)
+ } else {
+ data.DefaultGatewayAdvertise = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/logging/peer/state"); value.Exists() {
+ data.LoggingPeerState = types.BoolValue(true)
+ } else {
+ data.LoggingPeerState = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/route-target/auto/vni"); value.Exists() {
+ data.RouteTargetAutoVni = types.BoolValue(true)
+ } else {
+ data.RouteTargetAutoVni = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/anycast-gateway/mac/auto"); value.Exists() {
+ data.AnycastGatewayMacAuto = types.BoolValue(true)
+ } else {
+ data.AnycastGatewayMacAuto = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/flooding-suppression/address-resolution/disable"); value.Exists() {
+ data.FloodingSuppressionAddressResolutionDisable = types.BoolValue(true)
+ } else {
+ data.FloodingSuppressionAddressResolutionDisable = types.BoolValue(false)
+ }
+}
+
+// End of section. //template:end fromBodyXML
+
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyDataXML
+
+func (data *EVPNData) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/replication-type/ingress"); value.Exists() {
+ data.ReplicationTypeIngress = types.BoolValue(true)
+ } else {
+ data.ReplicationTypeIngress = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/replication-type/static"); value.Exists() {
+ data.ReplicationTypeStatic = types.BoolValue(true)
+ } else {
+ data.ReplicationTypeStatic = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/replication-type/p2mp"); value.Exists() {
+ data.ReplicationTypeP2mp = types.BoolValue(true)
+ } else {
+ data.ReplicationTypeP2mp = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/replication-type/mp2mp"); value.Exists() {
+ data.ReplicationTypeMp2mp = types.BoolValue(true)
+ } else {
+ data.ReplicationTypeMp2mp = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/mac/duplication/limit"); value.Exists() {
+ data.MacDuplicationLimit = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/mac/duplication/time"); value.Exists() {
+ data.MacDuplicationTime = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/duplication/limit"); value.Exists() {
+ data.IpDuplicationLimit = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/duplication/time"); value.Exists() {
+ data.IpDuplicationTime = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/router-id/interface/Loopback"); value.Exists() {
+ data.RouterIdLoopback = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/default-gateway/advertise"); value.Exists() {
+ data.DefaultGatewayAdvertise = types.BoolValue(true)
+ } else {
+ data.DefaultGatewayAdvertise = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/logging/peer/state"); value.Exists() {
+ data.LoggingPeerState = types.BoolValue(true)
+ } else {
+ data.LoggingPeerState = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/route-target/auto/vni"); value.Exists() {
+ data.RouteTargetAutoVni = types.BoolValue(true)
+ } else {
+ data.RouteTargetAutoVni = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/anycast-gateway/mac/auto"); value.Exists() {
+ data.AnycastGatewayMacAuto = types.BoolValue(true)
+ } else {
+ data.AnycastGatewayMacAuto = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/flooding-suppression/address-resolution/disable"); value.Exists() {
+ data.FloodingSuppressionAddressResolutionDisable = types.BoolValue(true)
+ } else {
+ data.FloodingSuppressionAddressResolutionDisable = types.BoolValue(false)
+ }
+}
+
+// End of section. //template:end fromBodyDataXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin getDeletedItems
func (data *EVPN) getDeletedItems(ctx context.Context, state EVPN) []string {
@@ -479,6 +831,58 @@ func (data *EVPN) getDeletedItems(ctx context.Context, state EVPN) []string {
// End of section. //template:end getDeletedItems
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletedItemsXML
+
+func (data *EVPN) addDeletedItemsXML(ctx context.Context, state EVPN, body string) string {
+ b := netconf.NewBody(body)
+ if !state.ReplicationTypeIngress.IsNull() && data.ReplicationTypeIngress.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/replication-type/ingress")
+ }
+ if !state.ReplicationTypeStatic.IsNull() && data.ReplicationTypeStatic.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/replication-type/static")
+ }
+ if !state.ReplicationTypeP2mp.IsNull() && data.ReplicationTypeP2mp.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/replication-type/p2mp")
+ }
+ if !state.ReplicationTypeMp2mp.IsNull() && data.ReplicationTypeMp2mp.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/replication-type/mp2mp")
+ }
+ if !state.MacDuplicationLimit.IsNull() && data.MacDuplicationLimit.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/mac/duplication/limit")
+ }
+ if !state.MacDuplicationTime.IsNull() && data.MacDuplicationTime.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/mac/duplication/time")
+ }
+ if !state.IpDuplicationLimit.IsNull() && data.IpDuplicationLimit.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ip/duplication/limit")
+ }
+ if !state.IpDuplicationTime.IsNull() && data.IpDuplicationTime.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ip/duplication/time")
+ }
+ if !state.RouterIdLoopback.IsNull() && data.RouterIdLoopback.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/router-id/interface/Loopback")
+ }
+ if !state.DefaultGatewayAdvertise.IsNull() && data.DefaultGatewayAdvertise.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/default-gateway/advertise")
+ }
+ if !state.LoggingPeerState.IsNull() && data.LoggingPeerState.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/logging/peer/state")
+ }
+ if !state.RouteTargetAutoVni.IsNull() && data.RouteTargetAutoVni.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/route-target/auto/vni")
+ }
+ if !state.AnycastGatewayMacAuto.IsNull() && data.AnycastGatewayMacAuto.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/anycast-gateway/mac/auto")
+ }
+ if !state.FloodingSuppressionAddressResolutionDisable.IsNull() && data.FloodingSuppressionAddressResolutionDisable.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/flooding-suppression/address-resolution/disable")
+ }
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletedItemsXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin getEmptyLeafsDelete
func (data *EVPN) getEmptyLeafsDelete(ctx context.Context) []string {
@@ -567,3 +971,55 @@ func (data *EVPN) getDeletePaths(ctx context.Context) []string {
}
// End of section. //template:end getDeletePaths
+
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletePathsXML
+
+func (data *EVPN) addDeletePathsXML(ctx context.Context, body string) string {
+ b := netconf.NewBody(body)
+ if !data.ReplicationTypeIngress.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/replication-type/ingress")
+ }
+ if !data.ReplicationTypeStatic.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/replication-type/static")
+ }
+ if !data.ReplicationTypeP2mp.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/replication-type/p2mp")
+ }
+ if !data.ReplicationTypeMp2mp.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/replication-type/mp2mp")
+ }
+ if !data.MacDuplicationLimit.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/mac/duplication/limit")
+ }
+ if !data.MacDuplicationTime.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/mac/duplication/time")
+ }
+ if !data.IpDuplicationLimit.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ip/duplication/limit")
+ }
+ if !data.IpDuplicationTime.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ip/duplication/time")
+ }
+ if !data.RouterIdLoopback.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/router-id/interface/Loopback")
+ }
+ if !data.DefaultGatewayAdvertise.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/default-gateway/advertise")
+ }
+ if !data.LoggingPeerState.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/logging/peer/state")
+ }
+ if !data.RouteTargetAutoVni.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/route-target/auto/vni")
+ }
+ if !data.AnycastGatewayMacAuto.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/anycast-gateway/mac/auto")
+ }
+ if !data.FloodingSuppressionAddressResolutionDisable.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/flooding-suppression/address-resolution/disable")
+ }
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletePathsXML
diff --git a/internal/provider/model_iosxe_evpn_instance.go b/internal/provider/model_iosxe_evpn_instance.go
index e68be2b1..d71d4ad1 100644
--- a/internal/provider/model_iosxe_evpn_instance.go
+++ b/internal/provider/model_iosxe_evpn_instance.go
@@ -31,6 +31,9 @@ import (
"github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/types"
+ "github.com/hashicorp/terraform-plugin-log/tflog"
+ "github.com/netascode/go-netconf"
+ "github.com/netascode/xmldot"
"github.com/tidwall/gjson"
"github.com/tidwall/sjson"
)
@@ -115,6 +118,19 @@ func (data EVPNInstance) getPathShort() string {
return matches[1]
}
+// getXPath returns the XPath for NETCONF operations
+func (data EVPNInstance) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/l2vpn/Cisco-IOS-XE-l2vpn:evpn_cont/evpn-instance/evpn/instance/instance[evpn-instance-num=%v]"
+ path = fmt.Sprintf(path, fmt.Sprintf("%v", data.EvpnInstanceNum.ValueInt64()))
+ return path
+}
+
+func (data EVPNInstanceData) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/l2vpn/Cisco-IOS-XE-l2vpn:evpn_cont/evpn-instance/evpn/instance/instance[evpn-instance-num=%v]"
+ path = fmt.Sprintf(path, fmt.Sprintf("%v", data.EvpnInstanceNum.ValueInt64()))
+ return path
+}
+
// End of section. //template:end getPath
// Section below is generated&owned by "gen/generator.go". //template:begin toBody
@@ -209,6 +225,120 @@ func (data EVPNInstance) toBody(ctx context.Context) string {
// End of section. //template:end toBody
+// Section below is generated&owned by "gen/generator.go". //template:begin toBodyXML
+
+func (data EVPNInstance) toBodyXML(ctx context.Context) string {
+ body := netconf.Body{}
+ if !data.EvpnInstanceNum.IsNull() && !data.EvpnInstanceNum.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/evpn-instance-num", strconv.FormatInt(data.EvpnInstanceNum.ValueInt64(), 10))
+ }
+ if !data.VlanBasedReplicationTypeIngress.IsNull() && !data.VlanBasedReplicationTypeIngress.IsUnknown() {
+ if data.VlanBasedReplicationTypeIngress.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/vlan-based/replication-type/ingress", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/vlan-based/replication-type/ingress")
+ }
+ }
+ if !data.VlanBasedReplicationTypeStatic.IsNull() && !data.VlanBasedReplicationTypeStatic.IsUnknown() {
+ if data.VlanBasedReplicationTypeStatic.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/vlan-based/replication-type/static", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/vlan-based/replication-type/static")
+ }
+ }
+ if !data.VlanBasedReplicationTypeP2mp.IsNull() && !data.VlanBasedReplicationTypeP2mp.IsUnknown() {
+ if data.VlanBasedReplicationTypeP2mp.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/vlan-based/replication-type/p2mp", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/vlan-based/replication-type/p2mp")
+ }
+ }
+ if !data.VlanBasedReplicationTypeMp2mp.IsNull() && !data.VlanBasedReplicationTypeMp2mp.IsUnknown() {
+ if data.VlanBasedReplicationTypeMp2mp.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/vlan-based/replication-type/mp2mp", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/vlan-based/replication-type/mp2mp")
+ }
+ }
+ if !data.VlanBasedEncapsulation.IsNull() && !data.VlanBasedEncapsulation.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/vlan-based/encapsulation", data.VlanBasedEncapsulation.ValueString())
+ }
+ if !data.VlanBasedAutoRouteTargetLegacy.IsNull() && !data.VlanBasedAutoRouteTargetLegacy.IsUnknown() {
+ if data.VlanBasedAutoRouteTargetLegacy.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/vlan-based/auto-route-target_cont/auto-route-target", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/vlan-based/auto-route-target_cont/auto-route-target")
+ }
+ }
+ if !data.VlanBasedAutoRouteTarget.IsNull() && !data.VlanBasedAutoRouteTarget.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/vlan-based/auto-route-target_cont/auto-route-target-boolean", data.VlanBasedAutoRouteTarget.ValueBool())
+ }
+ if !data.VlanBasedRd.IsNull() && !data.VlanBasedRd.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/vlan-based/rd/rd-value", data.VlanBasedRd.ValueString())
+ }
+ if !data.VlanBasedRouteTargetLegacy.IsNull() && !data.VlanBasedRouteTargetLegacy.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/vlan-based/route-target/rt-value", data.VlanBasedRouteTargetLegacy.ValueString())
+ }
+ if !data.VlanBasedRouteTargetBothLegacy.IsNull() && !data.VlanBasedRouteTargetBothLegacy.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/vlan-based/route-target/both/rt-value", data.VlanBasedRouteTargetBothLegacy.ValueString())
+ }
+ if !data.VlanBasedRouteTargetImportLegacy.IsNull() && !data.VlanBasedRouteTargetImportLegacy.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/vlan-based/route-target/import/rt-value", data.VlanBasedRouteTargetImportLegacy.ValueString())
+ }
+ if !data.VlanBasedRouteTargetExportLegacy.IsNull() && !data.VlanBasedRouteTargetExportLegacy.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/vlan-based/route-target/export/rt-value", data.VlanBasedRouteTargetExportLegacy.ValueString())
+ }
+ if len(data.VlanBasedRouteTargetExports) > 0 {
+ for _, item := range data.VlanBasedRouteTargetExports {
+ cBody := netconf.Body{}
+ if !item.RouteTarget.IsNull() && !item.RouteTarget.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "rt-value", item.RouteTarget.ValueString())
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/vlan-based/route-target-v2/export", cBody.Res())
+ }
+ }
+ if len(data.VlanBasedRouteTargetImports) > 0 {
+ for _, item := range data.VlanBasedRouteTargetImports {
+ cBody := netconf.Body{}
+ if !item.RouteTarget.IsNull() && !item.RouteTarget.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "rt-value", item.RouteTarget.ValueString())
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/vlan-based/route-target-v2/import", cBody.Res())
+ }
+ }
+ if !data.VlanBasedIpLocalLearningDisable.IsNull() && !data.VlanBasedIpLocalLearningDisable.IsUnknown() {
+ if data.VlanBasedIpLocalLearningDisable.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/vlan-based/ip/local-learning/disable", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/vlan-based/ip/local-learning/disable")
+ }
+ }
+ if !data.VlanBasedIpLocalLearningEnable.IsNull() && !data.VlanBasedIpLocalLearningEnable.IsUnknown() {
+ if data.VlanBasedIpLocalLearningEnable.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/vlan-based/ip/local-learning/enable", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/vlan-based/ip/local-learning/enable")
+ }
+ }
+ if !data.VlanBasedDefaultGatewayAdvertise.IsNull() && !data.VlanBasedDefaultGatewayAdvertise.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/vlan-based/default-gateway/advertise", data.VlanBasedDefaultGatewayAdvertise.ValueString())
+ }
+ if !data.VlanBasedReOriginateRouteType5.IsNull() && !data.VlanBasedReOriginateRouteType5.IsUnknown() {
+ if data.VlanBasedReOriginateRouteType5.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/vlan-based/re-originate/route-type5", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/vlan-based/re-originate/route-type5")
+ }
+ }
+ bodyString, err := body.String()
+ if err != nil {
+ tflog.Error(ctx, fmt.Sprintf("Error converting body to string: %s", err))
+ }
+ return bodyString
+}
+
+// End of section. //template:end toBodyXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBody
func (data *EVPNInstance) updateFromBody(ctx context.Context, res gjson.Result) {
@@ -397,6 +527,190 @@ func (data *EVPNInstance) updateFromBody(ctx context.Context, res gjson.Result)
// End of section. //template:end updateFromBody
+// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBodyXML
+
+func (data *EVPNInstance) updateFromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/evpn-instance-num"); value.Exists() && !data.EvpnInstanceNum.IsNull() {
+ data.EvpnInstanceNum = types.Int64Value(value.Int())
+ } else {
+ data.EvpnInstanceNum = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/vlan-based/replication-type/ingress"); !data.VlanBasedReplicationTypeIngress.IsNull() {
+ if value.Exists() {
+ data.VlanBasedReplicationTypeIngress = types.BoolValue(true)
+ } else {
+ data.VlanBasedReplicationTypeIngress = types.BoolValue(false)
+ }
+ } else {
+ data.VlanBasedReplicationTypeIngress = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/vlan-based/replication-type/static"); !data.VlanBasedReplicationTypeStatic.IsNull() {
+ if value.Exists() {
+ data.VlanBasedReplicationTypeStatic = types.BoolValue(true)
+ } else {
+ data.VlanBasedReplicationTypeStatic = types.BoolValue(false)
+ }
+ } else {
+ data.VlanBasedReplicationTypeStatic = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/vlan-based/replication-type/p2mp"); !data.VlanBasedReplicationTypeP2mp.IsNull() {
+ if value.Exists() {
+ data.VlanBasedReplicationTypeP2mp = types.BoolValue(true)
+ } else {
+ data.VlanBasedReplicationTypeP2mp = types.BoolValue(false)
+ }
+ } else {
+ data.VlanBasedReplicationTypeP2mp = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/vlan-based/replication-type/mp2mp"); !data.VlanBasedReplicationTypeMp2mp.IsNull() {
+ if value.Exists() {
+ data.VlanBasedReplicationTypeMp2mp = types.BoolValue(true)
+ } else {
+ data.VlanBasedReplicationTypeMp2mp = types.BoolValue(false)
+ }
+ } else {
+ data.VlanBasedReplicationTypeMp2mp = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/vlan-based/encapsulation"); value.Exists() && !data.VlanBasedEncapsulation.IsNull() {
+ data.VlanBasedEncapsulation = types.StringValue(value.String())
+ } else {
+ data.VlanBasedEncapsulation = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/vlan-based/auto-route-target_cont/auto-route-target"); !data.VlanBasedAutoRouteTargetLegacy.IsNull() {
+ if value.Exists() {
+ data.VlanBasedAutoRouteTargetLegacy = types.BoolValue(true)
+ } else {
+ data.VlanBasedAutoRouteTargetLegacy = types.BoolValue(false)
+ }
+ } else {
+ data.VlanBasedAutoRouteTargetLegacy = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/vlan-based/auto-route-target_cont/auto-route-target-boolean"); !data.VlanBasedAutoRouteTarget.IsNull() {
+ if value.Exists() {
+ data.VlanBasedAutoRouteTarget = types.BoolValue(value.Bool())
+ }
+ } else {
+ data.VlanBasedAutoRouteTarget = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/vlan-based/rd/rd-value"); value.Exists() && !data.VlanBasedRd.IsNull() {
+ data.VlanBasedRd = types.StringValue(value.String())
+ } else {
+ data.VlanBasedRd = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/vlan-based/route-target/rt-value"); value.Exists() && !data.VlanBasedRouteTargetLegacy.IsNull() {
+ data.VlanBasedRouteTargetLegacy = types.StringValue(value.String())
+ } else {
+ data.VlanBasedRouteTargetLegacy = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/vlan-based/route-target/both/rt-value"); value.Exists() && !data.VlanBasedRouteTargetBothLegacy.IsNull() {
+ data.VlanBasedRouteTargetBothLegacy = types.StringValue(value.String())
+ } else {
+ data.VlanBasedRouteTargetBothLegacy = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/vlan-based/route-target/import/rt-value"); value.Exists() && !data.VlanBasedRouteTargetImportLegacy.IsNull() {
+ data.VlanBasedRouteTargetImportLegacy = types.StringValue(value.String())
+ } else {
+ data.VlanBasedRouteTargetImportLegacy = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/vlan-based/route-target/export/rt-value"); value.Exists() && !data.VlanBasedRouteTargetExportLegacy.IsNull() {
+ data.VlanBasedRouteTargetExportLegacy = types.StringValue(value.String())
+ } else {
+ data.VlanBasedRouteTargetExportLegacy = types.StringNull()
+ }
+ for i := range data.VlanBasedRouteTargetExports {
+ keys := [...]string{"rt-value"}
+ keyValues := [...]string{data.VlanBasedRouteTargetExports[i].RouteTarget.ValueString()}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/vlan-based/route-target-v2/export").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, "rt-value"); value.Exists() && !data.VlanBasedRouteTargetExports[i].RouteTarget.IsNull() {
+ data.VlanBasedRouteTargetExports[i].RouteTarget = types.StringValue(value.String())
+ } else {
+ data.VlanBasedRouteTargetExports[i].RouteTarget = types.StringNull()
+ }
+ }
+ for i := range data.VlanBasedRouteTargetImports {
+ keys := [...]string{"rt-value"}
+ keyValues := [...]string{data.VlanBasedRouteTargetImports[i].RouteTarget.ValueString()}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/vlan-based/route-target-v2/import").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, "rt-value"); value.Exists() && !data.VlanBasedRouteTargetImports[i].RouteTarget.IsNull() {
+ data.VlanBasedRouteTargetImports[i].RouteTarget = types.StringValue(value.String())
+ } else {
+ data.VlanBasedRouteTargetImports[i].RouteTarget = types.StringNull()
+ }
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/vlan-based/ip/local-learning/disable"); !data.VlanBasedIpLocalLearningDisable.IsNull() {
+ if value.Exists() {
+ data.VlanBasedIpLocalLearningDisable = types.BoolValue(true)
+ } else {
+ data.VlanBasedIpLocalLearningDisable = types.BoolValue(false)
+ }
+ } else {
+ data.VlanBasedIpLocalLearningDisable = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/vlan-based/ip/local-learning/enable"); !data.VlanBasedIpLocalLearningEnable.IsNull() {
+ if value.Exists() {
+ data.VlanBasedIpLocalLearningEnable = types.BoolValue(true)
+ } else {
+ data.VlanBasedIpLocalLearningEnable = types.BoolValue(false)
+ }
+ } else {
+ data.VlanBasedIpLocalLearningEnable = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/vlan-based/default-gateway/advertise"); value.Exists() && !data.VlanBasedDefaultGatewayAdvertise.IsNull() {
+ data.VlanBasedDefaultGatewayAdvertise = types.StringValue(value.String())
+ } else {
+ data.VlanBasedDefaultGatewayAdvertise = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/vlan-based/re-originate/route-type5"); !data.VlanBasedReOriginateRouteType5.IsNull() {
+ if value.Exists() {
+ data.VlanBasedReOriginateRouteType5 = types.BoolValue(true)
+ } else {
+ data.VlanBasedReOriginateRouteType5 = types.BoolValue(false)
+ }
+ } else {
+ data.VlanBasedReOriginateRouteType5 = types.BoolNull()
+ }
+}
+
+// End of section. //template:end updateFromBodyXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin fromBody
func (data *EVPNInstance) fromBody(ctx context.Context, res gjson.Result) {
@@ -595,6 +909,196 @@ func (data *EVPNInstanceData) fromBody(ctx context.Context, res gjson.Result) {
// End of section. //template:end fromBodyData
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyXML
+
+func (data *EVPNInstance) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/vlan-based/replication-type/ingress"); value.Exists() {
+ data.VlanBasedReplicationTypeIngress = types.BoolValue(true)
+ } else {
+ data.VlanBasedReplicationTypeIngress = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/vlan-based/replication-type/static"); value.Exists() {
+ data.VlanBasedReplicationTypeStatic = types.BoolValue(true)
+ } else {
+ data.VlanBasedReplicationTypeStatic = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/vlan-based/replication-type/p2mp"); value.Exists() {
+ data.VlanBasedReplicationTypeP2mp = types.BoolValue(true)
+ } else {
+ data.VlanBasedReplicationTypeP2mp = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/vlan-based/replication-type/mp2mp"); value.Exists() {
+ data.VlanBasedReplicationTypeMp2mp = types.BoolValue(true)
+ } else {
+ data.VlanBasedReplicationTypeMp2mp = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/vlan-based/encapsulation"); value.Exists() {
+ data.VlanBasedEncapsulation = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/vlan-based/auto-route-target_cont/auto-route-target"); value.Exists() {
+ data.VlanBasedAutoRouteTargetLegacy = types.BoolValue(true)
+ } else {
+ data.VlanBasedAutoRouteTargetLegacy = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/vlan-based/auto-route-target_cont/auto-route-target-boolean"); value.Exists() {
+ data.VlanBasedAutoRouteTarget = types.BoolValue(value.Bool())
+ } else {
+ data.VlanBasedAutoRouteTarget = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/vlan-based/rd/rd-value"); value.Exists() {
+ data.VlanBasedRd = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/vlan-based/route-target/rt-value"); value.Exists() {
+ data.VlanBasedRouteTargetLegacy = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/vlan-based/route-target/both/rt-value"); value.Exists() {
+ data.VlanBasedRouteTargetBothLegacy = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/vlan-based/route-target/import/rt-value"); value.Exists() {
+ data.VlanBasedRouteTargetImportLegacy = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/vlan-based/route-target/export/rt-value"); value.Exists() {
+ data.VlanBasedRouteTargetExportLegacy = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/vlan-based/route-target-v2/export"); value.Exists() {
+ data.VlanBasedRouteTargetExports = make([]EVPNInstanceVlanBasedRouteTargetExports, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := EVPNInstanceVlanBasedRouteTargetExports{}
+ if cValue := helpers.GetFromXPath(v, "rt-value"); cValue.Exists() {
+ item.RouteTarget = types.StringValue(cValue.String())
+ }
+ data.VlanBasedRouteTargetExports = append(data.VlanBasedRouteTargetExports, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/vlan-based/route-target-v2/import"); value.Exists() {
+ data.VlanBasedRouteTargetImports = make([]EVPNInstanceVlanBasedRouteTargetImports, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := EVPNInstanceVlanBasedRouteTargetImports{}
+ if cValue := helpers.GetFromXPath(v, "rt-value"); cValue.Exists() {
+ item.RouteTarget = types.StringValue(cValue.String())
+ }
+ data.VlanBasedRouteTargetImports = append(data.VlanBasedRouteTargetImports, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/vlan-based/ip/local-learning/disable"); value.Exists() {
+ data.VlanBasedIpLocalLearningDisable = types.BoolValue(true)
+ } else {
+ data.VlanBasedIpLocalLearningDisable = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/vlan-based/ip/local-learning/enable"); value.Exists() {
+ data.VlanBasedIpLocalLearningEnable = types.BoolValue(true)
+ } else {
+ data.VlanBasedIpLocalLearningEnable = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/vlan-based/default-gateway/advertise"); value.Exists() {
+ data.VlanBasedDefaultGatewayAdvertise = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/vlan-based/re-originate/route-type5"); value.Exists() {
+ data.VlanBasedReOriginateRouteType5 = types.BoolValue(true)
+ } else {
+ data.VlanBasedReOriginateRouteType5 = types.BoolValue(false)
+ }
+}
+
+// End of section. //template:end fromBodyXML
+
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyDataXML
+
+func (data *EVPNInstanceData) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/vlan-based/replication-type/ingress"); value.Exists() {
+ data.VlanBasedReplicationTypeIngress = types.BoolValue(true)
+ } else {
+ data.VlanBasedReplicationTypeIngress = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/vlan-based/replication-type/static"); value.Exists() {
+ data.VlanBasedReplicationTypeStatic = types.BoolValue(true)
+ } else {
+ data.VlanBasedReplicationTypeStatic = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/vlan-based/replication-type/p2mp"); value.Exists() {
+ data.VlanBasedReplicationTypeP2mp = types.BoolValue(true)
+ } else {
+ data.VlanBasedReplicationTypeP2mp = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/vlan-based/replication-type/mp2mp"); value.Exists() {
+ data.VlanBasedReplicationTypeMp2mp = types.BoolValue(true)
+ } else {
+ data.VlanBasedReplicationTypeMp2mp = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/vlan-based/encapsulation"); value.Exists() {
+ data.VlanBasedEncapsulation = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/vlan-based/auto-route-target_cont/auto-route-target"); value.Exists() {
+ data.VlanBasedAutoRouteTargetLegacy = types.BoolValue(true)
+ } else {
+ data.VlanBasedAutoRouteTargetLegacy = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/vlan-based/auto-route-target_cont/auto-route-target-boolean"); value.Exists() {
+ data.VlanBasedAutoRouteTarget = types.BoolValue(value.Bool())
+ } else {
+ data.VlanBasedAutoRouteTarget = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/vlan-based/rd/rd-value"); value.Exists() {
+ data.VlanBasedRd = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/vlan-based/route-target/rt-value"); value.Exists() {
+ data.VlanBasedRouteTargetLegacy = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/vlan-based/route-target/both/rt-value"); value.Exists() {
+ data.VlanBasedRouteTargetBothLegacy = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/vlan-based/route-target/import/rt-value"); value.Exists() {
+ data.VlanBasedRouteTargetImportLegacy = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/vlan-based/route-target/export/rt-value"); value.Exists() {
+ data.VlanBasedRouteTargetExportLegacy = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/vlan-based/route-target-v2/export"); value.Exists() {
+ data.VlanBasedRouteTargetExports = make([]EVPNInstanceVlanBasedRouteTargetExports, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := EVPNInstanceVlanBasedRouteTargetExports{}
+ if cValue := helpers.GetFromXPath(v, "rt-value"); cValue.Exists() {
+ item.RouteTarget = types.StringValue(cValue.String())
+ }
+ data.VlanBasedRouteTargetExports = append(data.VlanBasedRouteTargetExports, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/vlan-based/route-target-v2/import"); value.Exists() {
+ data.VlanBasedRouteTargetImports = make([]EVPNInstanceVlanBasedRouteTargetImports, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := EVPNInstanceVlanBasedRouteTargetImports{}
+ if cValue := helpers.GetFromXPath(v, "rt-value"); cValue.Exists() {
+ item.RouteTarget = types.StringValue(cValue.String())
+ }
+ data.VlanBasedRouteTargetImports = append(data.VlanBasedRouteTargetImports, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/vlan-based/ip/local-learning/disable"); value.Exists() {
+ data.VlanBasedIpLocalLearningDisable = types.BoolValue(true)
+ } else {
+ data.VlanBasedIpLocalLearningDisable = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/vlan-based/ip/local-learning/enable"); value.Exists() {
+ data.VlanBasedIpLocalLearningEnable = types.BoolValue(true)
+ } else {
+ data.VlanBasedIpLocalLearningEnable = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/vlan-based/default-gateway/advertise"); value.Exists() {
+ data.VlanBasedDefaultGatewayAdvertise = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/vlan-based/re-originate/route-type5"); value.Exists() {
+ data.VlanBasedReOriginateRouteType5 = types.BoolValue(true)
+ } else {
+ data.VlanBasedReOriginateRouteType5 = types.BoolValue(false)
+ }
+}
+
+// End of section. //template:end fromBodyDataXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin getDeletedItems
func (data *EVPNInstance) getDeletedItems(ctx context.Context, state EVPNInstance) []string {
@@ -703,6 +1207,124 @@ func (data *EVPNInstance) getDeletedItems(ctx context.Context, state EVPNInstanc
// End of section. //template:end getDeletedItems
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletedItemsXML
+
+func (data *EVPNInstance) addDeletedItemsXML(ctx context.Context, state EVPNInstance, body string) string {
+ b := netconf.NewBody(body)
+ if !state.VlanBasedReplicationTypeIngress.IsNull() && data.VlanBasedReplicationTypeIngress.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/vlan-based/replication-type/ingress")
+ }
+ if !state.VlanBasedReplicationTypeStatic.IsNull() && data.VlanBasedReplicationTypeStatic.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/vlan-based/replication-type/static")
+ }
+ if !state.VlanBasedReplicationTypeP2mp.IsNull() && data.VlanBasedReplicationTypeP2mp.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/vlan-based/replication-type/p2mp")
+ }
+ if !state.VlanBasedReplicationTypeMp2mp.IsNull() && data.VlanBasedReplicationTypeMp2mp.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/vlan-based/replication-type/mp2mp")
+ }
+ if !state.VlanBasedEncapsulation.IsNull() && data.VlanBasedEncapsulation.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/vlan-based/encapsulation")
+ }
+ if !state.VlanBasedAutoRouteTargetLegacy.IsNull() && data.VlanBasedAutoRouteTargetLegacy.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/vlan-based/auto-route-target_cont/auto-route-target")
+ }
+ if !state.VlanBasedAutoRouteTarget.IsNull() && data.VlanBasedAutoRouteTarget.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/vlan-based/auto-route-target_cont/auto-route-target-boolean")
+ }
+ if !state.VlanBasedRd.IsNull() && data.VlanBasedRd.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/vlan-based/rd/rd-value")
+ }
+ if !state.VlanBasedRouteTargetLegacy.IsNull() && data.VlanBasedRouteTargetLegacy.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/vlan-based/route-target/rt-value")
+ }
+ if !state.VlanBasedRouteTargetBothLegacy.IsNull() && data.VlanBasedRouteTargetBothLegacy.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/vlan-based/route-target/both/rt-value")
+ }
+ if !state.VlanBasedRouteTargetImportLegacy.IsNull() && data.VlanBasedRouteTargetImportLegacy.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/vlan-based/route-target/import/rt-value")
+ }
+ if !state.VlanBasedRouteTargetExportLegacy.IsNull() && data.VlanBasedRouteTargetExportLegacy.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/vlan-based/route-target/export/rt-value")
+ }
+ for i := range state.VlanBasedRouteTargetExports {
+ stateKeys := [...]string{"rt-value"}
+ stateKeyValues := [...]string{state.VlanBasedRouteTargetExports[i].RouteTarget.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.VlanBasedRouteTargetExports[i].RouteTarget.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.VlanBasedRouteTargetExports {
+ found = true
+ if state.VlanBasedRouteTargetExports[i].RouteTarget.ValueString() != data.VlanBasedRouteTargetExports[j].RouteTarget.ValueString() {
+ found = false
+ }
+ if found {
+ break
+ }
+ }
+ if !found {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/vlan-based/route-target-v2/export%v", predicates))
+ }
+ }
+ for i := range state.VlanBasedRouteTargetImports {
+ stateKeys := [...]string{"rt-value"}
+ stateKeyValues := [...]string{state.VlanBasedRouteTargetImports[i].RouteTarget.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.VlanBasedRouteTargetImports[i].RouteTarget.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.VlanBasedRouteTargetImports {
+ found = true
+ if state.VlanBasedRouteTargetImports[i].RouteTarget.ValueString() != data.VlanBasedRouteTargetImports[j].RouteTarget.ValueString() {
+ found = false
+ }
+ if found {
+ break
+ }
+ }
+ if !found {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/vlan-based/route-target-v2/import%v", predicates))
+ }
+ }
+ if !state.VlanBasedIpLocalLearningDisable.IsNull() && data.VlanBasedIpLocalLearningDisable.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/vlan-based/ip/local-learning/disable")
+ }
+ if !state.VlanBasedIpLocalLearningEnable.IsNull() && data.VlanBasedIpLocalLearningEnable.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/vlan-based/ip/local-learning/enable")
+ }
+ if !state.VlanBasedDefaultGatewayAdvertise.IsNull() && data.VlanBasedDefaultGatewayAdvertise.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/vlan-based/default-gateway/advertise")
+ }
+ if !state.VlanBasedReOriginateRouteType5.IsNull() && data.VlanBasedReOriginateRouteType5.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/vlan-based/re-originate/route-type5")
+ }
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletedItemsXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin getEmptyLeafsDelete
func (data *EVPNInstance) getEmptyLeafsDelete(ctx context.Context) []string {
@@ -805,3 +1427,81 @@ func (data *EVPNInstance) getDeletePaths(ctx context.Context) []string {
}
// End of section. //template:end getDeletePaths
+
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletePathsXML
+
+func (data *EVPNInstance) addDeletePathsXML(ctx context.Context, body string) string {
+ b := netconf.NewBody(body)
+ if !data.VlanBasedReplicationTypeIngress.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/vlan-based/replication-type/ingress")
+ }
+ if !data.VlanBasedReplicationTypeStatic.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/vlan-based/replication-type/static")
+ }
+ if !data.VlanBasedReplicationTypeP2mp.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/vlan-based/replication-type/p2mp")
+ }
+ if !data.VlanBasedReplicationTypeMp2mp.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/vlan-based/replication-type/mp2mp")
+ }
+ if !data.VlanBasedEncapsulation.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/vlan-based/encapsulation")
+ }
+ if !data.VlanBasedAutoRouteTargetLegacy.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/vlan-based/auto-route-target_cont/auto-route-target")
+ }
+ if !data.VlanBasedAutoRouteTarget.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/vlan-based/auto-route-target_cont/auto-route-target-boolean")
+ }
+ if !data.VlanBasedRd.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/vlan-based/rd/rd-value")
+ }
+ if !data.VlanBasedRouteTargetLegacy.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/vlan-based/route-target/rt-value")
+ }
+ if !data.VlanBasedRouteTargetBothLegacy.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/vlan-based/route-target/both/rt-value")
+ }
+ if !data.VlanBasedRouteTargetImportLegacy.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/vlan-based/route-target/import/rt-value")
+ }
+ if !data.VlanBasedRouteTargetExportLegacy.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/vlan-based/route-target/export/rt-value")
+ }
+ for i := range data.VlanBasedRouteTargetExports {
+ keys := [...]string{"rt-value"}
+ keyValues := [...]string{data.VlanBasedRouteTargetExports[i].RouteTarget.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/vlan-based/route-target-v2/export%v", predicates))
+ }
+ for i := range data.VlanBasedRouteTargetImports {
+ keys := [...]string{"rt-value"}
+ keyValues := [...]string{data.VlanBasedRouteTargetImports[i].RouteTarget.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/vlan-based/route-target-v2/import%v", predicates))
+ }
+ if !data.VlanBasedIpLocalLearningDisable.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/vlan-based/ip/local-learning/disable")
+ }
+ if !data.VlanBasedIpLocalLearningEnable.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/vlan-based/ip/local-learning/enable")
+ }
+ if !data.VlanBasedDefaultGatewayAdvertise.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/vlan-based/default-gateway/advertise")
+ }
+ if !data.VlanBasedReOriginateRouteType5.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/vlan-based/re-originate/route-type5")
+ }
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletePathsXML
diff --git a/internal/provider/model_iosxe_flow_exporter.go b/internal/provider/model_iosxe_flow_exporter.go
index 0d458f70..d5d362c3 100644
--- a/internal/provider/model_iosxe_flow_exporter.go
+++ b/internal/provider/model_iosxe_flow_exporter.go
@@ -29,6 +29,9 @@ import (
"github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/types"
+ "github.com/hashicorp/terraform-plugin-log/tflog"
+ "github.com/netascode/go-netconf"
+ "github.com/netascode/xmldot"
"github.com/tidwall/gjson"
"github.com/tidwall/sjson"
)
@@ -94,6 +97,19 @@ func (data FlowExporter) getPathShort() string {
return matches[1]
}
+// getXPath returns the XPath for NETCONF operations
+func (data FlowExporter) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/flow/Cisco-IOS-XE-flow:exporter[name=%v]"
+ path = fmt.Sprintf(path, fmt.Sprintf("%v", data.Name.ValueString()))
+ return path
+}
+
+func (data FlowExporterData) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/flow/Cisco-IOS-XE-flow:exporter[name=%v]"
+ path = fmt.Sprintf(path, fmt.Sprintf("%v", data.Name.ValueString()))
+ return path
+}
+
// End of section. //template:end getPath
// Section below is generated&owned by "gen/generator.go". //template:begin toBody
@@ -143,6 +159,59 @@ func (data FlowExporter) toBody(ctx context.Context) string {
// End of section. //template:end toBody
+// Section below is generated&owned by "gen/generator.go". //template:begin toBodyXML
+
+func (data FlowExporter) toBodyXML(ctx context.Context) string {
+ body := netconf.Body{}
+ if !data.Name.IsNull() && !data.Name.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/name", data.Name.ValueString())
+ }
+ if !data.Description.IsNull() && !data.Description.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/description", data.Description.ValueString())
+ }
+ if !data.DestinationIp.IsNull() && !data.DestinationIp.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/destination/ipdest/ip", data.DestinationIp.ValueString())
+ }
+ if !data.SourceLoopback.IsNull() && !data.SourceLoopback.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/source/Loopback", strconv.FormatInt(data.SourceLoopback.ValueInt64(), 10))
+ }
+ if !data.TransportUdp.IsNull() && !data.TransportUdp.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/transport/udp", strconv.FormatInt(data.TransportUdp.ValueInt64(), 10))
+ }
+ if !data.TemplateDataTimeout.IsNull() && !data.TemplateDataTimeout.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/template/data/timeout", strconv.FormatInt(data.TemplateDataTimeout.ValueInt64(), 10))
+ }
+ if !data.ExportProtocol.IsNull() && !data.ExportProtocol.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/export-protocol", data.ExportProtocol.ValueString())
+ }
+ if !data.OptionInterfaceTableTimeout.IsNull() && !data.OptionInterfaceTableTimeout.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/option/interface-table/timeout", strconv.FormatInt(data.OptionInterfaceTableTimeout.ValueInt64(), 10))
+ }
+ if !data.OptionVrfTableTimeout.IsNull() && !data.OptionVrfTableTimeout.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/option/vrf-table/timeout", strconv.FormatInt(data.OptionVrfTableTimeout.ValueInt64(), 10))
+ }
+ if !data.OptionSamplerTable.IsNull() && !data.OptionSamplerTable.IsUnknown() {
+ if data.OptionSamplerTable.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/option/sampler-table", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/option/sampler-table")
+ }
+ }
+ if !data.OptionApplicationTableTimeout.IsNull() && !data.OptionApplicationTableTimeout.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/option/application-table/timeout", strconv.FormatInt(data.OptionApplicationTableTimeout.ValueInt64(), 10))
+ }
+ if !data.OptionApplicationAttributesTimeout.IsNull() && !data.OptionApplicationAttributesTimeout.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/option/application-attributes/timeout", strconv.FormatInt(data.OptionApplicationAttributesTimeout.ValueInt64(), 10))
+ }
+ bodyString, err := body.String()
+ if err != nil {
+ tflog.Error(ctx, fmt.Sprintf("Error converting body to string: %s", err))
+ }
+ return bodyString
+}
+
+// End of section. //template:end toBodyXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBody
func (data *FlowExporter) updateFromBody(ctx context.Context, res gjson.Result) {
@@ -218,6 +287,77 @@ func (data *FlowExporter) updateFromBody(ctx context.Context, res gjson.Result)
// End of section. //template:end updateFromBody
+// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBodyXML
+
+func (data *FlowExporter) updateFromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/name"); value.Exists() && !data.Name.IsNull() {
+ data.Name = types.StringValue(value.String())
+ } else {
+ data.Name = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/description"); value.Exists() && !data.Description.IsNull() {
+ data.Description = types.StringValue(value.String())
+ } else {
+ data.Description = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/destination/ipdest/ip"); value.Exists() && !data.DestinationIp.IsNull() {
+ data.DestinationIp = types.StringValue(value.String())
+ } else {
+ data.DestinationIp = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/source/Loopback"); value.Exists() && !data.SourceLoopback.IsNull() {
+ data.SourceLoopback = types.Int64Value(value.Int())
+ } else {
+ data.SourceLoopback = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/transport/udp"); value.Exists() && !data.TransportUdp.IsNull() {
+ data.TransportUdp = types.Int64Value(value.Int())
+ } else {
+ data.TransportUdp = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/template/data/timeout"); value.Exists() && !data.TemplateDataTimeout.IsNull() {
+ data.TemplateDataTimeout = types.Int64Value(value.Int())
+ } else {
+ data.TemplateDataTimeout = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/export-protocol"); value.Exists() && !data.ExportProtocol.IsNull() {
+ data.ExportProtocol = types.StringValue(value.String())
+ } else {
+ data.ExportProtocol = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/option/interface-table/timeout"); value.Exists() && !data.OptionInterfaceTableTimeout.IsNull() {
+ data.OptionInterfaceTableTimeout = types.Int64Value(value.Int())
+ } else {
+ data.OptionInterfaceTableTimeout = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/option/vrf-table/timeout"); value.Exists() && !data.OptionVrfTableTimeout.IsNull() {
+ data.OptionVrfTableTimeout = types.Int64Value(value.Int())
+ } else {
+ data.OptionVrfTableTimeout = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/option/sampler-table"); !data.OptionSamplerTable.IsNull() {
+ if value.Exists() {
+ data.OptionSamplerTable = types.BoolValue(true)
+ } else {
+ data.OptionSamplerTable = types.BoolValue(false)
+ }
+ } else {
+ data.OptionSamplerTable = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/option/application-table/timeout"); value.Exists() && !data.OptionApplicationTableTimeout.IsNull() {
+ data.OptionApplicationTableTimeout = types.Int64Value(value.Int())
+ } else {
+ data.OptionApplicationTableTimeout = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/option/application-attributes/timeout"); value.Exists() && !data.OptionApplicationAttributesTimeout.IsNull() {
+ data.OptionApplicationAttributesTimeout = types.Int64Value(value.Int())
+ } else {
+ data.OptionApplicationAttributesTimeout = types.Int64Null()
+ }
+}
+
+// End of section. //template:end updateFromBodyXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin fromBody
func (data *FlowExporter) fromBody(ctx context.Context, res gjson.Result) {
@@ -310,6 +450,90 @@ func (data *FlowExporterData) fromBody(ctx context.Context, res gjson.Result) {
// End of section. //template:end fromBodyData
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyXML
+
+func (data *FlowExporter) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/description"); value.Exists() {
+ data.Description = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/destination/ipdest/ip"); value.Exists() {
+ data.DestinationIp = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/source/Loopback"); value.Exists() {
+ data.SourceLoopback = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/transport/udp"); value.Exists() {
+ data.TransportUdp = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/template/data/timeout"); value.Exists() {
+ data.TemplateDataTimeout = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/export-protocol"); value.Exists() {
+ data.ExportProtocol = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/option/interface-table/timeout"); value.Exists() {
+ data.OptionInterfaceTableTimeout = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/option/vrf-table/timeout"); value.Exists() {
+ data.OptionVrfTableTimeout = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/option/sampler-table"); value.Exists() {
+ data.OptionSamplerTable = types.BoolValue(true)
+ } else {
+ data.OptionSamplerTable = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/option/application-table/timeout"); value.Exists() {
+ data.OptionApplicationTableTimeout = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/option/application-attributes/timeout"); value.Exists() {
+ data.OptionApplicationAttributesTimeout = types.Int64Value(value.Int())
+ }
+}
+
+// End of section. //template:end fromBodyXML
+
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyDataXML
+
+func (data *FlowExporterData) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/description"); value.Exists() {
+ data.Description = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/destination/ipdest/ip"); value.Exists() {
+ data.DestinationIp = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/source/Loopback"); value.Exists() {
+ data.SourceLoopback = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/transport/udp"); value.Exists() {
+ data.TransportUdp = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/template/data/timeout"); value.Exists() {
+ data.TemplateDataTimeout = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/export-protocol"); value.Exists() {
+ data.ExportProtocol = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/option/interface-table/timeout"); value.Exists() {
+ data.OptionInterfaceTableTimeout = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/option/vrf-table/timeout"); value.Exists() {
+ data.OptionVrfTableTimeout = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/option/sampler-table"); value.Exists() {
+ data.OptionSamplerTable = types.BoolValue(true)
+ } else {
+ data.OptionSamplerTable = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/option/application-table/timeout"); value.Exists() {
+ data.OptionApplicationTableTimeout = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/option/application-attributes/timeout"); value.Exists() {
+ data.OptionApplicationAttributesTimeout = types.Int64Value(value.Int())
+ }
+}
+
+// End of section. //template:end fromBodyDataXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin getDeletedItems
func (data *FlowExporter) getDeletedItems(ctx context.Context, state FlowExporter) []string {
@@ -353,6 +577,49 @@ func (data *FlowExporter) getDeletedItems(ctx context.Context, state FlowExporte
// End of section. //template:end getDeletedItems
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletedItemsXML
+
+func (data *FlowExporter) addDeletedItemsXML(ctx context.Context, state FlowExporter, body string) string {
+ b := netconf.NewBody(body)
+ if !state.Description.IsNull() && data.Description.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/description")
+ }
+ if !state.DestinationIp.IsNull() && data.DestinationIp.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/destination/ipdest/ip")
+ }
+ if !state.SourceLoopback.IsNull() && data.SourceLoopback.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/source/Loopback")
+ }
+ if !state.TransportUdp.IsNull() && data.TransportUdp.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/transport/udp")
+ }
+ if !state.TemplateDataTimeout.IsNull() && data.TemplateDataTimeout.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/template/data/timeout")
+ }
+ if !state.ExportProtocol.IsNull() && data.ExportProtocol.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/export-protocol")
+ }
+ if !state.OptionInterfaceTableTimeout.IsNull() && data.OptionInterfaceTableTimeout.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/option/interface-table/timeout")
+ }
+ if !state.OptionVrfTableTimeout.IsNull() && data.OptionVrfTableTimeout.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/option/vrf-table/timeout")
+ }
+ if !state.OptionSamplerTable.IsNull() && data.OptionSamplerTable.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/option/sampler-table")
+ }
+ if !state.OptionApplicationTableTimeout.IsNull() && data.OptionApplicationTableTimeout.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/option/application-table/timeout")
+ }
+ if !state.OptionApplicationAttributesTimeout.IsNull() && data.OptionApplicationAttributesTimeout.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/option/application-attributes/timeout")
+ }
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletedItemsXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin getEmptyLeafsDelete
func (data *FlowExporter) getEmptyLeafsDelete(ctx context.Context) []string {
@@ -408,3 +675,46 @@ func (data *FlowExporter) getDeletePaths(ctx context.Context) []string {
}
// End of section. //template:end getDeletePaths
+
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletePathsXML
+
+func (data *FlowExporter) addDeletePathsXML(ctx context.Context, body string) string {
+ b := netconf.NewBody(body)
+ if !data.Description.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/description")
+ }
+ if !data.DestinationIp.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/destination/ipdest/ip")
+ }
+ if !data.SourceLoopback.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/source/Loopback")
+ }
+ if !data.TransportUdp.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/transport/udp")
+ }
+ if !data.TemplateDataTimeout.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/template/data/timeout")
+ }
+ if !data.ExportProtocol.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/export-protocol")
+ }
+ if !data.OptionInterfaceTableTimeout.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/option/interface-table/timeout")
+ }
+ if !data.OptionVrfTableTimeout.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/option/vrf-table/timeout")
+ }
+ if !data.OptionSamplerTable.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/option/sampler-table")
+ }
+ if !data.OptionApplicationTableTimeout.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/option/application-table/timeout")
+ }
+ if !data.OptionApplicationAttributesTimeout.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/option/application-attributes/timeout")
+ }
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletePathsXML
diff --git a/internal/provider/model_iosxe_flow_monitor.go b/internal/provider/model_iosxe_flow_monitor.go
index 91e3b72c..08dcaa68 100644
--- a/internal/provider/model_iosxe_flow_monitor.go
+++ b/internal/provider/model_iosxe_flow_monitor.go
@@ -31,6 +31,9 @@ import (
"github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/types"
+ "github.com/hashicorp/terraform-plugin-log/tflog"
+ "github.com/netascode/go-netconf"
+ "github.com/netascode/xmldot"
"github.com/tidwall/gjson"
"github.com/tidwall/sjson"
)
@@ -87,6 +90,19 @@ func (data FlowMonitor) getPathShort() string {
return matches[1]
}
+// getXPath returns the XPath for NETCONF operations
+func (data FlowMonitor) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/flow/Cisco-IOS-XE-flow:monitor[name=%v]"
+ path = fmt.Sprintf(path, fmt.Sprintf("%v", data.Name.ValueString()))
+ return path
+}
+
+func (data FlowMonitorData) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/flow/Cisco-IOS-XE-flow:monitor[name=%v]"
+ path = fmt.Sprintf(path, fmt.Sprintf("%v", data.Name.ValueString()))
+ return path
+}
+
// End of section. //template:end getPath
// Section below is generated&owned by "gen/generator.go". //template:begin toBody
@@ -121,6 +137,43 @@ func (data FlowMonitor) toBody(ctx context.Context) string {
// End of section. //template:end toBody
+// Section below is generated&owned by "gen/generator.go". //template:begin toBodyXML
+
+func (data FlowMonitor) toBodyXML(ctx context.Context) string {
+ body := netconf.Body{}
+ if !data.Name.IsNull() && !data.Name.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/name", data.Name.ValueString())
+ }
+ if !data.Description.IsNull() && !data.Description.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/description", data.Description.ValueString())
+ }
+ if len(data.Exporters) > 0 {
+ for _, item := range data.Exporters {
+ cBody := netconf.Body{}
+ if !item.Name.IsNull() && !item.Name.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "name", item.Name.ValueString())
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/exporter", cBody.Res())
+ }
+ }
+ if !data.CacheTimeoutActive.IsNull() && !data.CacheTimeoutActive.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/cache/timeout/active", strconv.FormatInt(data.CacheTimeoutActive.ValueInt64(), 10))
+ }
+ if !data.CacheTimeoutInactive.IsNull() && !data.CacheTimeoutInactive.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/cache/timeout/inactive", strconv.FormatInt(data.CacheTimeoutInactive.ValueInt64(), 10))
+ }
+ if !data.Record.IsNull() && !data.Record.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/record/type", data.Record.ValueString())
+ }
+ bodyString, err := body.String()
+ if err != nil {
+ tflog.Error(ctx, fmt.Sprintf("Error converting body to string: %s", err))
+ }
+ return bodyString
+}
+
+// End of section. //template:end toBodyXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBody
func (data *FlowMonitor) updateFromBody(ctx context.Context, res gjson.Result) {
@@ -186,6 +239,67 @@ func (data *FlowMonitor) updateFromBody(ctx context.Context, res gjson.Result) {
// End of section. //template:end updateFromBody
+// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBodyXML
+
+func (data *FlowMonitor) updateFromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/name"); value.Exists() && !data.Name.IsNull() {
+ data.Name = types.StringValue(value.String())
+ } else {
+ data.Name = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/description"); value.Exists() && !data.Description.IsNull() {
+ data.Description = types.StringValue(value.String())
+ } else {
+ data.Description = types.StringNull()
+ }
+ for i := range data.Exporters {
+ keys := [...]string{"name"}
+ keyValues := [...]string{data.Exporters[i].Name.ValueString()}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/exporter").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, "name"); value.Exists() && !data.Exporters[i].Name.IsNull() {
+ data.Exporters[i].Name = types.StringValue(value.String())
+ } else {
+ data.Exporters[i].Name = types.StringNull()
+ }
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/cache/timeout/active"); value.Exists() && !data.CacheTimeoutActive.IsNull() {
+ data.CacheTimeoutActive = types.Int64Value(value.Int())
+ } else {
+ data.CacheTimeoutActive = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/cache/timeout/inactive"); value.Exists() && !data.CacheTimeoutInactive.IsNull() {
+ data.CacheTimeoutInactive = types.Int64Value(value.Int())
+ } else {
+ data.CacheTimeoutInactive = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/record/type"); value.Exists() && !data.Record.IsNull() {
+ data.Record = types.StringValue(value.String())
+ } else {
+ data.Record = types.StringNull()
+ }
+}
+
+// End of section. //template:end updateFromBodyXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin fromBody
func (data *FlowMonitor) fromBody(ctx context.Context, res gjson.Result) {
@@ -254,6 +368,66 @@ func (data *FlowMonitorData) fromBody(ctx context.Context, res gjson.Result) {
// End of section. //template:end fromBodyData
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyXML
+
+func (data *FlowMonitor) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/description"); value.Exists() {
+ data.Description = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/exporter"); value.Exists() {
+ data.Exporters = make([]FlowMonitorExporters, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := FlowMonitorExporters{}
+ if cValue := helpers.GetFromXPath(v, "name"); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ data.Exporters = append(data.Exporters, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/cache/timeout/active"); value.Exists() {
+ data.CacheTimeoutActive = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/cache/timeout/inactive"); value.Exists() {
+ data.CacheTimeoutInactive = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/record/type"); value.Exists() {
+ data.Record = types.StringValue(value.String())
+ }
+}
+
+// End of section. //template:end fromBodyXML
+
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyDataXML
+
+func (data *FlowMonitorData) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/description"); value.Exists() {
+ data.Description = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/exporter"); value.Exists() {
+ data.Exporters = make([]FlowMonitorExporters, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := FlowMonitorExporters{}
+ if cValue := helpers.GetFromXPath(v, "name"); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ data.Exporters = append(data.Exporters, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/cache/timeout/active"); value.Exists() {
+ data.CacheTimeoutActive = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/cache/timeout/inactive"); value.Exists() {
+ data.CacheTimeoutInactive = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/record/type"); value.Exists() {
+ data.Record = types.StringValue(value.String())
+ }
+}
+
+// End of section. //template:end fromBodyDataXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin getDeletedItems
func (data *FlowMonitor) getDeletedItems(ctx context.Context, state FlowMonitor) []string {
@@ -301,6 +475,58 @@ func (data *FlowMonitor) getDeletedItems(ctx context.Context, state FlowMonitor)
// End of section. //template:end getDeletedItems
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletedItemsXML
+
+func (data *FlowMonitor) addDeletedItemsXML(ctx context.Context, state FlowMonitor, body string) string {
+ b := netconf.NewBody(body)
+ if !state.Description.IsNull() && data.Description.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/description")
+ }
+ for i := range state.Exporters {
+ stateKeys := [...]string{"name"}
+ stateKeyValues := [...]string{state.Exporters[i].Name.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.Exporters[i].Name.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.Exporters {
+ found = true
+ if state.Exporters[i].Name.ValueString() != data.Exporters[j].Name.ValueString() {
+ found = false
+ }
+ if found {
+ break
+ }
+ }
+ if !found {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/exporter%v", predicates))
+ }
+ }
+ if !state.CacheTimeoutActive.IsNull() && data.CacheTimeoutActive.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/cache/timeout/active")
+ }
+ if !state.CacheTimeoutInactive.IsNull() && data.CacheTimeoutInactive.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/cache/timeout/inactive")
+ }
+ if !state.Record.IsNull() && data.Record.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/record/type")
+ }
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletedItemsXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin getEmptyLeafsDelete
func (data *FlowMonitor) getEmptyLeafsDelete(ctx context.Context) []string {
@@ -337,3 +563,35 @@ func (data *FlowMonitor) getDeletePaths(ctx context.Context) []string {
}
// End of section. //template:end getDeletePaths
+
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletePathsXML
+
+func (data *FlowMonitor) addDeletePathsXML(ctx context.Context, body string) string {
+ b := netconf.NewBody(body)
+ if !data.Description.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/description")
+ }
+ for i := range data.Exporters {
+ keys := [...]string{"name"}
+ keyValues := [...]string{data.Exporters[i].Name.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/exporter%v", predicates))
+ }
+ if !data.CacheTimeoutActive.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/cache/timeout/active")
+ }
+ if !data.CacheTimeoutInactive.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/cache/timeout/inactive")
+ }
+ if !data.Record.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/record/type")
+ }
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletePathsXML
diff --git a/internal/provider/model_iosxe_flow_record.go b/internal/provider/model_iosxe_flow_record.go
index 1cf9fee7..cd4998cd 100644
--- a/internal/provider/model_iosxe_flow_record.go
+++ b/internal/provider/model_iosxe_flow_record.go
@@ -28,6 +28,9 @@ import (
"github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/types"
+ "github.com/hashicorp/terraform-plugin-log/tflog"
+ "github.com/netascode/go-netconf"
+ "github.com/netascode/xmldot"
"github.com/tidwall/gjson"
"github.com/tidwall/sjson"
)
@@ -137,6 +140,19 @@ func (data FlowRecord) getPathShort() string {
return matches[1]
}
+// getXPath returns the XPath for NETCONF operations
+func (data FlowRecord) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/flow/Cisco-IOS-XE-flow:record[name=%v]"
+ path = fmt.Sprintf(path, fmt.Sprintf("%v", data.Name.ValueString()))
+ return path
+}
+
+func (data FlowRecordData) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/flow/Cisco-IOS-XE-flow:record[name=%v]"
+ path = fmt.Sprintf(path, fmt.Sprintf("%v", data.Name.ValueString()))
+ return path
+}
+
// End of section. //template:end getPath
// Section below is generated&owned by "gen/generator.go". //template:begin toBody
@@ -314,6 +330,249 @@ func (data FlowRecord) toBody(ctx context.Context) string {
// End of section. //template:end toBody
+// Section below is generated&owned by "gen/generator.go". //template:begin toBodyXML
+
+func (data FlowRecord) toBodyXML(ctx context.Context) string {
+ body := netconf.Body{}
+ if !data.Name.IsNull() && !data.Name.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/name", data.Name.ValueString())
+ }
+ if !data.Description.IsNull() && !data.Description.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/description", data.Description.ValueString())
+ }
+ if !data.MatchIpv4SourceAddress.IsNull() && !data.MatchIpv4SourceAddress.IsUnknown() {
+ if data.MatchIpv4SourceAddress.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/match/ipv4/source/address", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/match/ipv4/source/address")
+ }
+ }
+ if !data.MatchIpv4DestinationAddress.IsNull() && !data.MatchIpv4DestinationAddress.IsUnknown() {
+ if data.MatchIpv4DestinationAddress.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/match/ipv4/destination/address", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/match/ipv4/destination/address")
+ }
+ }
+ if !data.MatchIpv4Protocol.IsNull() && !data.MatchIpv4Protocol.IsUnknown() {
+ if data.MatchIpv4Protocol.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/match/ipv4/protocol", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/match/ipv4/protocol")
+ }
+ }
+ if !data.MatchIpv4Tos.IsNull() && !data.MatchIpv4Tos.IsUnknown() {
+ if data.MatchIpv4Tos.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/match/ipv4/tos", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/match/ipv4/tos")
+ }
+ }
+ if !data.MatchIpv6SourceAddress.IsNull() && !data.MatchIpv6SourceAddress.IsUnknown() {
+ if data.MatchIpv6SourceAddress.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/match/ipv6/source/address", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/match/ipv6/source/address")
+ }
+ }
+ if !data.MatchIpv6DestinationAddress.IsNull() && !data.MatchIpv6DestinationAddress.IsUnknown() {
+ if data.MatchIpv6DestinationAddress.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/match/ipv6/destination/address", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/match/ipv6/destination/address")
+ }
+ }
+ if !data.MatchTransportSourcePort.IsNull() && !data.MatchTransportSourcePort.IsUnknown() {
+ if data.MatchTransportSourcePort.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/match/transport/source-port", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/match/transport/source-port")
+ }
+ }
+ if !data.MatchTransportDestinationPort.IsNull() && !data.MatchTransportDestinationPort.IsUnknown() {
+ if data.MatchTransportDestinationPort.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/match/transport/destination-port", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/match/transport/destination-port")
+ }
+ }
+ if !data.MatchInterfaceInput.IsNull() && !data.MatchInterfaceInput.IsUnknown() {
+ if data.MatchInterfaceInput.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/match/interface/input", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/match/interface/input")
+ }
+ }
+ if !data.MatchFlowDirection.IsNull() && !data.MatchFlowDirection.IsUnknown() {
+ if data.MatchFlowDirection.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/match/flow/direction", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/match/flow/direction")
+ }
+ }
+ if !data.MatchApplicationName.IsNull() && !data.MatchApplicationName.IsUnknown() {
+ if data.MatchApplicationName.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/match/application/name", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/match/application/name")
+ }
+ }
+ if !data.MatchFlowObservationPoint.IsNull() && !data.MatchFlowObservationPoint.IsUnknown() {
+ if data.MatchFlowObservationPoint.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/match/flow/observation/point", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/match/flow/observation/point")
+ }
+ }
+ if !data.MatchIpv4Version.IsNull() && !data.MatchIpv4Version.IsUnknown() {
+ if data.MatchIpv4Version.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/match/ipv4/version", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/match/ipv4/version")
+ }
+ }
+ if !data.MatchIpv6Version.IsNull() && !data.MatchIpv6Version.IsUnknown() {
+ if data.MatchIpv6Version.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/match/ipv6/version", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/match/ipv6/version")
+ }
+ }
+ if !data.MatchIpv6Protocol.IsNull() && !data.MatchIpv6Protocol.IsUnknown() {
+ if data.MatchIpv6Protocol.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/match/ipv6/protocol", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/match/ipv6/protocol")
+ }
+ }
+ if !data.MatchConnectionClientIpv4Address.IsNull() && !data.MatchConnectionClientIpv4Address.IsUnknown() {
+ if data.MatchConnectionClientIpv4Address.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/match/connection/client/ipv4/address", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/match/connection/client/ipv4/address")
+ }
+ }
+ if !data.MatchConnectionServerIpv4Address.IsNull() && !data.MatchConnectionServerIpv4Address.IsUnknown() {
+ if data.MatchConnectionServerIpv4Address.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/match/connection/server/ipv4/address", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/match/connection/server/ipv4/address")
+ }
+ }
+ if !data.MatchConnectionClientIpv6Address.IsNull() && !data.MatchConnectionClientIpv6Address.IsUnknown() {
+ if data.MatchConnectionClientIpv6Address.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/match/connection/client/ipv6/address", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/match/connection/client/ipv6/address")
+ }
+ }
+ if !data.MatchConnectionServerIpv6Address.IsNull() && !data.MatchConnectionServerIpv6Address.IsUnknown() {
+ if data.MatchConnectionServerIpv6Address.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/match/connection/server/ipv6/address", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/match/connection/server/ipv6/address")
+ }
+ }
+ if !data.MatchConnectionServerTransportPort.IsNull() && !data.MatchConnectionServerTransportPort.IsUnknown() {
+ if data.MatchConnectionServerTransportPort.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/match/connection/server/transport/port", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/match/connection/server/transport/port")
+ }
+ }
+ if !data.CollectInterfaceOutput.IsNull() && !data.CollectInterfaceOutput.IsUnknown() {
+ if data.CollectInterfaceOutput.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/collect/interface/output", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/collect/interface/output")
+ }
+ }
+ if !data.CollectCounterBytesLong.IsNull() && !data.CollectCounterBytesLong.IsUnknown() {
+ if data.CollectCounterBytesLong.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/collect/counter/bytes/long", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/collect/counter/bytes/long")
+ }
+ }
+ if !data.CollectCounterPacketsLong.IsNull() && !data.CollectCounterPacketsLong.IsUnknown() {
+ if data.CollectCounterPacketsLong.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/collect/counter/packets/long", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/collect/counter/packets/long")
+ }
+ }
+ if !data.CollectTransportTcpFlags.IsNull() && !data.CollectTransportTcpFlags.IsUnknown() {
+ if data.CollectTransportTcpFlags.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/collect/transport/tcp/flags", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/collect/transport/tcp/flags")
+ }
+ }
+ if !data.CollectTimestampAbsoluteFirst.IsNull() && !data.CollectTimestampAbsoluteFirst.IsUnknown() {
+ if data.CollectTimestampAbsoluteFirst.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/collect/timestamp/absolute/first", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/collect/timestamp/absolute/first")
+ }
+ }
+ if !data.CollectTimestampAbsoluteLast.IsNull() && !data.CollectTimestampAbsoluteLast.IsUnknown() {
+ if data.CollectTimestampAbsoluteLast.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/collect/timestamp/absolute/last", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/collect/timestamp/absolute/last")
+ }
+ }
+ if !data.CollectConnectionInitiator.IsNull() && !data.CollectConnectionInitiator.IsUnknown() {
+ if data.CollectConnectionInitiator.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/collect/connection/initiator", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/collect/connection/initiator")
+ }
+ }
+ if !data.CollectConnectionNewConnections.IsNull() && !data.CollectConnectionNewConnections.IsUnknown() {
+ if data.CollectConnectionNewConnections.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/collect/connection/new-connections", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/collect/connection/new-connections")
+ }
+ }
+ if !data.CollectConnectionServerCounterBytesNetworkLong.IsNull() && !data.CollectConnectionServerCounterBytesNetworkLong.IsUnknown() {
+ if data.CollectConnectionServerCounterBytesNetworkLong.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/collect/connection/server/counter/bytes/network/long", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/collect/connection/server/counter/bytes/network/long")
+ }
+ }
+ if !data.CollectConnectionServerCounterPacketsLong.IsNull() && !data.CollectConnectionServerCounterPacketsLong.IsUnknown() {
+ if data.CollectConnectionServerCounterPacketsLong.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/collect/connection/server/counter/packets/long", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/collect/connection/server/counter/packets/long")
+ }
+ }
+ if !data.CollectDatalinkMacSourceAddressInput.IsNull() && !data.CollectDatalinkMacSourceAddressInput.IsUnknown() {
+ if data.CollectDatalinkMacSourceAddressInput.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/collect/datalink/mac/source/address/input", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/collect/datalink/mac/source/address/input")
+ }
+ }
+ if !data.CollectFlowDirection.IsNull() && !data.CollectFlowDirection.IsUnknown() {
+ if data.CollectFlowDirection.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/collect/flow/direction", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/collect/flow/direction")
+ }
+ }
+ bodyString, err := body.String()
+ if err != nil {
+ tflog.Error(ctx, fmt.Sprintf("Error converting body to string: %s", err))
+ }
+ return bodyString
+}
+
+// End of section. //template:end toBodyXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBody
func (data *FlowRecord) updateFromBody(ctx context.Context, res gjson.Result) {
@@ -590,386 +849,1031 @@ func (data *FlowRecord) updateFromBody(ctx context.Context, res gjson.Result) {
data.CollectConnectionServerCounterBytesNetworkLong = types.BoolValue(false)
}
} else {
- data.CollectConnectionServerCounterBytesNetworkLong = types.BoolNull()
+ data.CollectConnectionServerCounterBytesNetworkLong = types.BoolNull()
+ }
+ if value := res.Get(prefix + "collect.connection.server.counter.packets.long"); !data.CollectConnectionServerCounterPacketsLong.IsNull() {
+ if value.Exists() {
+ data.CollectConnectionServerCounterPacketsLong = types.BoolValue(true)
+ } else {
+ data.CollectConnectionServerCounterPacketsLong = types.BoolValue(false)
+ }
+ } else {
+ data.CollectConnectionServerCounterPacketsLong = types.BoolNull()
+ }
+ if value := res.Get(prefix + "collect.datalink.mac.source.address.input"); !data.CollectDatalinkMacSourceAddressInput.IsNull() {
+ if value.Exists() {
+ data.CollectDatalinkMacSourceAddressInput = types.BoolValue(true)
+ } else {
+ data.CollectDatalinkMacSourceAddressInput = types.BoolValue(false)
+ }
+ } else {
+ data.CollectDatalinkMacSourceAddressInput = types.BoolNull()
+ }
+ if value := res.Get(prefix + "collect.flow.direction"); !data.CollectFlowDirection.IsNull() {
+ if value.Exists() {
+ data.CollectFlowDirection = types.BoolValue(true)
+ } else {
+ data.CollectFlowDirection = types.BoolValue(false)
+ }
+ } else {
+ data.CollectFlowDirection = types.BoolNull()
+ }
+}
+
+// End of section. //template:end updateFromBody
+
+// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBodyXML
+
+func (data *FlowRecord) updateFromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/name"); value.Exists() && !data.Name.IsNull() {
+ data.Name = types.StringValue(value.String())
+ } else {
+ data.Name = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/description"); value.Exists() && !data.Description.IsNull() {
+ data.Description = types.StringValue(value.String())
+ } else {
+ data.Description = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/match/ipv4/source/address"); !data.MatchIpv4SourceAddress.IsNull() {
+ if value.Exists() {
+ data.MatchIpv4SourceAddress = types.BoolValue(true)
+ } else {
+ data.MatchIpv4SourceAddress = types.BoolValue(false)
+ }
+ } else {
+ data.MatchIpv4SourceAddress = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/match/ipv4/destination/address"); !data.MatchIpv4DestinationAddress.IsNull() {
+ if value.Exists() {
+ data.MatchIpv4DestinationAddress = types.BoolValue(true)
+ } else {
+ data.MatchIpv4DestinationAddress = types.BoolValue(false)
+ }
+ } else {
+ data.MatchIpv4DestinationAddress = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/match/ipv4/protocol"); !data.MatchIpv4Protocol.IsNull() {
+ if value.Exists() {
+ data.MatchIpv4Protocol = types.BoolValue(true)
+ } else {
+ data.MatchIpv4Protocol = types.BoolValue(false)
+ }
+ } else {
+ data.MatchIpv4Protocol = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/match/ipv4/tos"); !data.MatchIpv4Tos.IsNull() {
+ if value.Exists() {
+ data.MatchIpv4Tos = types.BoolValue(true)
+ } else {
+ data.MatchIpv4Tos = types.BoolValue(false)
+ }
+ } else {
+ data.MatchIpv4Tos = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/match/ipv6/source/address"); !data.MatchIpv6SourceAddress.IsNull() {
+ if value.Exists() {
+ data.MatchIpv6SourceAddress = types.BoolValue(true)
+ } else {
+ data.MatchIpv6SourceAddress = types.BoolValue(false)
+ }
+ } else {
+ data.MatchIpv6SourceAddress = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/match/ipv6/destination/address"); !data.MatchIpv6DestinationAddress.IsNull() {
+ if value.Exists() {
+ data.MatchIpv6DestinationAddress = types.BoolValue(true)
+ } else {
+ data.MatchIpv6DestinationAddress = types.BoolValue(false)
+ }
+ } else {
+ data.MatchIpv6DestinationAddress = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/match/transport/source-port"); !data.MatchTransportSourcePort.IsNull() {
+ if value.Exists() {
+ data.MatchTransportSourcePort = types.BoolValue(true)
+ } else {
+ data.MatchTransportSourcePort = types.BoolValue(false)
+ }
+ } else {
+ data.MatchTransportSourcePort = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/match/transport/destination-port"); !data.MatchTransportDestinationPort.IsNull() {
+ if value.Exists() {
+ data.MatchTransportDestinationPort = types.BoolValue(true)
+ } else {
+ data.MatchTransportDestinationPort = types.BoolValue(false)
+ }
+ } else {
+ data.MatchTransportDestinationPort = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/match/interface/input"); !data.MatchInterfaceInput.IsNull() {
+ if value.Exists() {
+ data.MatchInterfaceInput = types.BoolValue(true)
+ } else {
+ data.MatchInterfaceInput = types.BoolValue(false)
+ }
+ } else {
+ data.MatchInterfaceInput = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/match/flow/direction"); !data.MatchFlowDirection.IsNull() {
+ if value.Exists() {
+ data.MatchFlowDirection = types.BoolValue(true)
+ } else {
+ data.MatchFlowDirection = types.BoolValue(false)
+ }
+ } else {
+ data.MatchFlowDirection = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/match/application/name"); !data.MatchApplicationName.IsNull() {
+ if value.Exists() {
+ data.MatchApplicationName = types.BoolValue(true)
+ } else {
+ data.MatchApplicationName = types.BoolValue(false)
+ }
+ } else {
+ data.MatchApplicationName = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/match/flow/observation/point"); !data.MatchFlowObservationPoint.IsNull() {
+ if value.Exists() {
+ data.MatchFlowObservationPoint = types.BoolValue(true)
+ } else {
+ data.MatchFlowObservationPoint = types.BoolValue(false)
+ }
+ } else {
+ data.MatchFlowObservationPoint = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/match/ipv4/version"); !data.MatchIpv4Version.IsNull() {
+ if value.Exists() {
+ data.MatchIpv4Version = types.BoolValue(true)
+ } else {
+ data.MatchIpv4Version = types.BoolValue(false)
+ }
+ } else {
+ data.MatchIpv4Version = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/match/ipv6/version"); !data.MatchIpv6Version.IsNull() {
+ if value.Exists() {
+ data.MatchIpv6Version = types.BoolValue(true)
+ } else {
+ data.MatchIpv6Version = types.BoolValue(false)
+ }
+ } else {
+ data.MatchIpv6Version = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/match/ipv6/protocol"); !data.MatchIpv6Protocol.IsNull() {
+ if value.Exists() {
+ data.MatchIpv6Protocol = types.BoolValue(true)
+ } else {
+ data.MatchIpv6Protocol = types.BoolValue(false)
+ }
+ } else {
+ data.MatchIpv6Protocol = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/match/connection/client/ipv4/address"); !data.MatchConnectionClientIpv4Address.IsNull() {
+ if value.Exists() {
+ data.MatchConnectionClientIpv4Address = types.BoolValue(true)
+ } else {
+ data.MatchConnectionClientIpv4Address = types.BoolValue(false)
+ }
+ } else {
+ data.MatchConnectionClientIpv4Address = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/match/connection/server/ipv4/address"); !data.MatchConnectionServerIpv4Address.IsNull() {
+ if value.Exists() {
+ data.MatchConnectionServerIpv4Address = types.BoolValue(true)
+ } else {
+ data.MatchConnectionServerIpv4Address = types.BoolValue(false)
+ }
+ } else {
+ data.MatchConnectionServerIpv4Address = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/match/connection/client/ipv6/address"); !data.MatchConnectionClientIpv6Address.IsNull() {
+ if value.Exists() {
+ data.MatchConnectionClientIpv6Address = types.BoolValue(true)
+ } else {
+ data.MatchConnectionClientIpv6Address = types.BoolValue(false)
+ }
+ } else {
+ data.MatchConnectionClientIpv6Address = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/match/connection/server/ipv6/address"); !data.MatchConnectionServerIpv6Address.IsNull() {
+ if value.Exists() {
+ data.MatchConnectionServerIpv6Address = types.BoolValue(true)
+ } else {
+ data.MatchConnectionServerIpv6Address = types.BoolValue(false)
+ }
+ } else {
+ data.MatchConnectionServerIpv6Address = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/match/connection/server/transport/port"); !data.MatchConnectionServerTransportPort.IsNull() {
+ if value.Exists() {
+ data.MatchConnectionServerTransportPort = types.BoolValue(true)
+ } else {
+ data.MatchConnectionServerTransportPort = types.BoolValue(false)
+ }
+ } else {
+ data.MatchConnectionServerTransportPort = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/collect/interface/output"); !data.CollectInterfaceOutput.IsNull() {
+ if value.Exists() {
+ data.CollectInterfaceOutput = types.BoolValue(true)
+ } else {
+ data.CollectInterfaceOutput = types.BoolValue(false)
+ }
+ } else {
+ data.CollectInterfaceOutput = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/collect/counter/bytes/long"); !data.CollectCounterBytesLong.IsNull() {
+ if value.Exists() {
+ data.CollectCounterBytesLong = types.BoolValue(true)
+ } else {
+ data.CollectCounterBytesLong = types.BoolValue(false)
+ }
+ } else {
+ data.CollectCounterBytesLong = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/collect/counter/packets/long"); !data.CollectCounterPacketsLong.IsNull() {
+ if value.Exists() {
+ data.CollectCounterPacketsLong = types.BoolValue(true)
+ } else {
+ data.CollectCounterPacketsLong = types.BoolValue(false)
+ }
+ } else {
+ data.CollectCounterPacketsLong = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/collect/transport/tcp/flags"); !data.CollectTransportTcpFlags.IsNull() {
+ if value.Exists() {
+ data.CollectTransportTcpFlags = types.BoolValue(true)
+ } else {
+ data.CollectTransportTcpFlags = types.BoolValue(false)
+ }
+ } else {
+ data.CollectTransportTcpFlags = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/collect/timestamp/absolute/first"); !data.CollectTimestampAbsoluteFirst.IsNull() {
+ if value.Exists() {
+ data.CollectTimestampAbsoluteFirst = types.BoolValue(true)
+ } else {
+ data.CollectTimestampAbsoluteFirst = types.BoolValue(false)
+ }
+ } else {
+ data.CollectTimestampAbsoluteFirst = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/collect/timestamp/absolute/last"); !data.CollectTimestampAbsoluteLast.IsNull() {
+ if value.Exists() {
+ data.CollectTimestampAbsoluteLast = types.BoolValue(true)
+ } else {
+ data.CollectTimestampAbsoluteLast = types.BoolValue(false)
+ }
+ } else {
+ data.CollectTimestampAbsoluteLast = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/collect/connection/initiator"); !data.CollectConnectionInitiator.IsNull() {
+ if value.Exists() {
+ data.CollectConnectionInitiator = types.BoolValue(true)
+ } else {
+ data.CollectConnectionInitiator = types.BoolValue(false)
+ }
+ } else {
+ data.CollectConnectionInitiator = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/collect/connection/new-connections"); !data.CollectConnectionNewConnections.IsNull() {
+ if value.Exists() {
+ data.CollectConnectionNewConnections = types.BoolValue(true)
+ } else {
+ data.CollectConnectionNewConnections = types.BoolValue(false)
+ }
+ } else {
+ data.CollectConnectionNewConnections = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/collect/connection/server/counter/bytes/network/long"); !data.CollectConnectionServerCounterBytesNetworkLong.IsNull() {
+ if value.Exists() {
+ data.CollectConnectionServerCounterBytesNetworkLong = types.BoolValue(true)
+ } else {
+ data.CollectConnectionServerCounterBytesNetworkLong = types.BoolValue(false)
+ }
+ } else {
+ data.CollectConnectionServerCounterBytesNetworkLong = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/collect/connection/server/counter/packets/long"); !data.CollectConnectionServerCounterPacketsLong.IsNull() {
+ if value.Exists() {
+ data.CollectConnectionServerCounterPacketsLong = types.BoolValue(true)
+ } else {
+ data.CollectConnectionServerCounterPacketsLong = types.BoolValue(false)
+ }
+ } else {
+ data.CollectConnectionServerCounterPacketsLong = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/collect/datalink/mac/source/address/input"); !data.CollectDatalinkMacSourceAddressInput.IsNull() {
+ if value.Exists() {
+ data.CollectDatalinkMacSourceAddressInput = types.BoolValue(true)
+ } else {
+ data.CollectDatalinkMacSourceAddressInput = types.BoolValue(false)
+ }
+ } else {
+ data.CollectDatalinkMacSourceAddressInput = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/collect/flow/direction"); !data.CollectFlowDirection.IsNull() {
+ if value.Exists() {
+ data.CollectFlowDirection = types.BoolValue(true)
+ } else {
+ data.CollectFlowDirection = types.BoolValue(false)
+ }
+ } else {
+ data.CollectFlowDirection = types.BoolNull()
+ }
+}
+
+// End of section. //template:end updateFromBodyXML
+
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBody
+
+func (data *FlowRecord) fromBody(ctx context.Context, res gjson.Result) {
+ prefix := helpers.LastElement(data.getPath()) + "."
+ if res.Get(helpers.LastElement(data.getPath())).IsArray() {
+ prefix += "0."
+ }
+ if value := res.Get(prefix + "description"); value.Exists() {
+ data.Description = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "match.ipv4.source.address"); value.Exists() {
+ data.MatchIpv4SourceAddress = types.BoolValue(true)
+ } else {
+ data.MatchIpv4SourceAddress = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "match.ipv4.destination.address"); value.Exists() {
+ data.MatchIpv4DestinationAddress = types.BoolValue(true)
+ } else {
+ data.MatchIpv4DestinationAddress = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "match.ipv4.protocol"); value.Exists() {
+ data.MatchIpv4Protocol = types.BoolValue(true)
+ } else {
+ data.MatchIpv4Protocol = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "match.ipv4.tos"); value.Exists() {
+ data.MatchIpv4Tos = types.BoolValue(true)
+ } else {
+ data.MatchIpv4Tos = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "match.ipv6.source.address"); value.Exists() {
+ data.MatchIpv6SourceAddress = types.BoolValue(true)
+ } else {
+ data.MatchIpv6SourceAddress = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "match.ipv6.destination.address"); value.Exists() {
+ data.MatchIpv6DestinationAddress = types.BoolValue(true)
+ } else {
+ data.MatchIpv6DestinationAddress = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "match.transport.source-port"); value.Exists() {
+ data.MatchTransportSourcePort = types.BoolValue(true)
+ } else {
+ data.MatchTransportSourcePort = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "match.transport.destination-port"); value.Exists() {
+ data.MatchTransportDestinationPort = types.BoolValue(true)
+ } else {
+ data.MatchTransportDestinationPort = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "match.interface.input"); value.Exists() {
+ data.MatchInterfaceInput = types.BoolValue(true)
+ } else {
+ data.MatchInterfaceInput = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "match.flow.direction"); value.Exists() {
+ data.MatchFlowDirection = types.BoolValue(true)
+ } else {
+ data.MatchFlowDirection = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "match.application.name"); value.Exists() {
+ data.MatchApplicationName = types.BoolValue(true)
+ } else {
+ data.MatchApplicationName = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "match.flow.observation.point"); value.Exists() {
+ data.MatchFlowObservationPoint = types.BoolValue(true)
+ } else {
+ data.MatchFlowObservationPoint = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "match.ipv4.version"); value.Exists() {
+ data.MatchIpv4Version = types.BoolValue(true)
+ } else {
+ data.MatchIpv4Version = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "match.ipv6.version"); value.Exists() {
+ data.MatchIpv6Version = types.BoolValue(true)
+ } else {
+ data.MatchIpv6Version = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "match.ipv6.protocol"); value.Exists() {
+ data.MatchIpv6Protocol = types.BoolValue(true)
+ } else {
+ data.MatchIpv6Protocol = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "match.connection.client.ipv4.address"); value.Exists() {
+ data.MatchConnectionClientIpv4Address = types.BoolValue(true)
+ } else {
+ data.MatchConnectionClientIpv4Address = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "match.connection.server.ipv4.address"); value.Exists() {
+ data.MatchConnectionServerIpv4Address = types.BoolValue(true)
+ } else {
+ data.MatchConnectionServerIpv4Address = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "match.connection.client.ipv6.address"); value.Exists() {
+ data.MatchConnectionClientIpv6Address = types.BoolValue(true)
+ } else {
+ data.MatchConnectionClientIpv6Address = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "match.connection.server.ipv6.address"); value.Exists() {
+ data.MatchConnectionServerIpv6Address = types.BoolValue(true)
+ } else {
+ data.MatchConnectionServerIpv6Address = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "match.connection.server.transport.port"); value.Exists() {
+ data.MatchConnectionServerTransportPort = types.BoolValue(true)
+ } else {
+ data.MatchConnectionServerTransportPort = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "collect.interface.output"); value.Exists() {
+ data.CollectInterfaceOutput = types.BoolValue(true)
+ } else {
+ data.CollectInterfaceOutput = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "collect.counter.bytes.long"); value.Exists() {
+ data.CollectCounterBytesLong = types.BoolValue(true)
+ } else {
+ data.CollectCounterBytesLong = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "collect.counter.packets.long"); value.Exists() {
+ data.CollectCounterPacketsLong = types.BoolValue(true)
+ } else {
+ data.CollectCounterPacketsLong = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "collect.transport.tcp.flags"); value.Exists() {
+ data.CollectTransportTcpFlags = types.BoolValue(true)
+ } else {
+ data.CollectTransportTcpFlags = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "collect.timestamp.absolute.first"); value.Exists() {
+ data.CollectTimestampAbsoluteFirst = types.BoolValue(true)
+ } else {
+ data.CollectTimestampAbsoluteFirst = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "collect.timestamp.absolute.last"); value.Exists() {
+ data.CollectTimestampAbsoluteLast = types.BoolValue(true)
+ } else {
+ data.CollectTimestampAbsoluteLast = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "collect.connection.initiator"); value.Exists() {
+ data.CollectConnectionInitiator = types.BoolValue(true)
+ } else {
+ data.CollectConnectionInitiator = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "collect.connection.new-connections"); value.Exists() {
+ data.CollectConnectionNewConnections = types.BoolValue(true)
+ } else {
+ data.CollectConnectionNewConnections = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "collect.connection.server.counter.bytes.network.long"); value.Exists() {
+ data.CollectConnectionServerCounterBytesNetworkLong = types.BoolValue(true)
+ } else {
+ data.CollectConnectionServerCounterBytesNetworkLong = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "collect.connection.server.counter.packets.long"); value.Exists() {
+ data.CollectConnectionServerCounterPacketsLong = types.BoolValue(true)
+ } else {
+ data.CollectConnectionServerCounterPacketsLong = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "collect.datalink.mac.source.address.input"); value.Exists() {
+ data.CollectDatalinkMacSourceAddressInput = types.BoolValue(true)
+ } else {
+ data.CollectDatalinkMacSourceAddressInput = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "collect.flow.direction"); value.Exists() {
+ data.CollectFlowDirection = types.BoolValue(true)
+ } else {
+ data.CollectFlowDirection = types.BoolValue(false)
+ }
+}
+
+// End of section. //template:end fromBody
+
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyData
+
+func (data *FlowRecordData) fromBody(ctx context.Context, res gjson.Result) {
+ prefix := helpers.LastElement(data.getPath()) + "."
+ if res.Get(helpers.LastElement(data.getPath())).IsArray() {
+ prefix += "0."
+ }
+ if value := res.Get(prefix + "description"); value.Exists() {
+ data.Description = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "match.ipv4.source.address"); value.Exists() {
+ data.MatchIpv4SourceAddress = types.BoolValue(true)
+ } else {
+ data.MatchIpv4SourceAddress = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "match.ipv4.destination.address"); value.Exists() {
+ data.MatchIpv4DestinationAddress = types.BoolValue(true)
+ } else {
+ data.MatchIpv4DestinationAddress = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "match.ipv4.protocol"); value.Exists() {
+ data.MatchIpv4Protocol = types.BoolValue(true)
+ } else {
+ data.MatchIpv4Protocol = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "match.ipv4.tos"); value.Exists() {
+ data.MatchIpv4Tos = types.BoolValue(true)
+ } else {
+ data.MatchIpv4Tos = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "match.ipv6.source.address"); value.Exists() {
+ data.MatchIpv6SourceAddress = types.BoolValue(true)
+ } else {
+ data.MatchIpv6SourceAddress = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "match.ipv6.destination.address"); value.Exists() {
+ data.MatchIpv6DestinationAddress = types.BoolValue(true)
+ } else {
+ data.MatchIpv6DestinationAddress = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "match.transport.source-port"); value.Exists() {
+ data.MatchTransportSourcePort = types.BoolValue(true)
+ } else {
+ data.MatchTransportSourcePort = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "match.transport.destination-port"); value.Exists() {
+ data.MatchTransportDestinationPort = types.BoolValue(true)
+ } else {
+ data.MatchTransportDestinationPort = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "match.interface.input"); value.Exists() {
+ data.MatchInterfaceInput = types.BoolValue(true)
+ } else {
+ data.MatchInterfaceInput = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "match.flow.direction"); value.Exists() {
+ data.MatchFlowDirection = types.BoolValue(true)
+ } else {
+ data.MatchFlowDirection = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "match.application.name"); value.Exists() {
+ data.MatchApplicationName = types.BoolValue(true)
+ } else {
+ data.MatchApplicationName = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "match.flow.observation.point"); value.Exists() {
+ data.MatchFlowObservationPoint = types.BoolValue(true)
+ } else {
+ data.MatchFlowObservationPoint = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "match.ipv4.version"); value.Exists() {
+ data.MatchIpv4Version = types.BoolValue(true)
+ } else {
+ data.MatchIpv4Version = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "match.ipv6.version"); value.Exists() {
+ data.MatchIpv6Version = types.BoolValue(true)
+ } else {
+ data.MatchIpv6Version = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "match.ipv6.protocol"); value.Exists() {
+ data.MatchIpv6Protocol = types.BoolValue(true)
+ } else {
+ data.MatchIpv6Protocol = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "match.connection.client.ipv4.address"); value.Exists() {
+ data.MatchConnectionClientIpv4Address = types.BoolValue(true)
+ } else {
+ data.MatchConnectionClientIpv4Address = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "match.connection.server.ipv4.address"); value.Exists() {
+ data.MatchConnectionServerIpv4Address = types.BoolValue(true)
+ } else {
+ data.MatchConnectionServerIpv4Address = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "match.connection.client.ipv6.address"); value.Exists() {
+ data.MatchConnectionClientIpv6Address = types.BoolValue(true)
+ } else {
+ data.MatchConnectionClientIpv6Address = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "match.connection.server.ipv6.address"); value.Exists() {
+ data.MatchConnectionServerIpv6Address = types.BoolValue(true)
+ } else {
+ data.MatchConnectionServerIpv6Address = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "match.connection.server.transport.port"); value.Exists() {
+ data.MatchConnectionServerTransportPort = types.BoolValue(true)
+ } else {
+ data.MatchConnectionServerTransportPort = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "collect.interface.output"); value.Exists() {
+ data.CollectInterfaceOutput = types.BoolValue(true)
+ } else {
+ data.CollectInterfaceOutput = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "collect.counter.bytes.long"); value.Exists() {
+ data.CollectCounterBytesLong = types.BoolValue(true)
+ } else {
+ data.CollectCounterBytesLong = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "collect.counter.packets.long"); value.Exists() {
+ data.CollectCounterPacketsLong = types.BoolValue(true)
+ } else {
+ data.CollectCounterPacketsLong = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "collect.transport.tcp.flags"); value.Exists() {
+ data.CollectTransportTcpFlags = types.BoolValue(true)
+ } else {
+ data.CollectTransportTcpFlags = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "collect.timestamp.absolute.first"); value.Exists() {
+ data.CollectTimestampAbsoluteFirst = types.BoolValue(true)
+ } else {
+ data.CollectTimestampAbsoluteFirst = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "collect.timestamp.absolute.last"); value.Exists() {
+ data.CollectTimestampAbsoluteLast = types.BoolValue(true)
+ } else {
+ data.CollectTimestampAbsoluteLast = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "collect.connection.initiator"); value.Exists() {
+ data.CollectConnectionInitiator = types.BoolValue(true)
+ } else {
+ data.CollectConnectionInitiator = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "collect.connection.new-connections"); value.Exists() {
+ data.CollectConnectionNewConnections = types.BoolValue(true)
+ } else {
+ data.CollectConnectionNewConnections = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "collect.connection.server.counter.bytes.network.long"); value.Exists() {
+ data.CollectConnectionServerCounterBytesNetworkLong = types.BoolValue(true)
+ } else {
+ data.CollectConnectionServerCounterBytesNetworkLong = types.BoolValue(false)
}
- if value := res.Get(prefix + "collect.connection.server.counter.packets.long"); !data.CollectConnectionServerCounterPacketsLong.IsNull() {
- if value.Exists() {
- data.CollectConnectionServerCounterPacketsLong = types.BoolValue(true)
- } else {
- data.CollectConnectionServerCounterPacketsLong = types.BoolValue(false)
- }
+ if value := res.Get(prefix + "collect.connection.server.counter.packets.long"); value.Exists() {
+ data.CollectConnectionServerCounterPacketsLong = types.BoolValue(true)
} else {
- data.CollectConnectionServerCounterPacketsLong = types.BoolNull()
+ data.CollectConnectionServerCounterPacketsLong = types.BoolValue(false)
}
- if value := res.Get(prefix + "collect.datalink.mac.source.address.input"); !data.CollectDatalinkMacSourceAddressInput.IsNull() {
- if value.Exists() {
- data.CollectDatalinkMacSourceAddressInput = types.BoolValue(true)
- } else {
- data.CollectDatalinkMacSourceAddressInput = types.BoolValue(false)
- }
+ if value := res.Get(prefix + "collect.datalink.mac.source.address.input"); value.Exists() {
+ data.CollectDatalinkMacSourceAddressInput = types.BoolValue(true)
} else {
- data.CollectDatalinkMacSourceAddressInput = types.BoolNull()
+ data.CollectDatalinkMacSourceAddressInput = types.BoolValue(false)
}
- if value := res.Get(prefix + "collect.flow.direction"); !data.CollectFlowDirection.IsNull() {
- if value.Exists() {
- data.CollectFlowDirection = types.BoolValue(true)
- } else {
- data.CollectFlowDirection = types.BoolValue(false)
- }
+ if value := res.Get(prefix + "collect.flow.direction"); value.Exists() {
+ data.CollectFlowDirection = types.BoolValue(true)
} else {
- data.CollectFlowDirection = types.BoolNull()
+ data.CollectFlowDirection = types.BoolValue(false)
}
}
-// End of section. //template:end updateFromBody
+// End of section. //template:end fromBodyData
-// Section below is generated&owned by "gen/generator.go". //template:begin fromBody
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyXML
-func (data *FlowRecord) fromBody(ctx context.Context, res gjson.Result) {
- prefix := helpers.LastElement(data.getPath()) + "."
- if res.Get(helpers.LastElement(data.getPath())).IsArray() {
- prefix += "0."
- }
- if value := res.Get(prefix + "description"); value.Exists() {
+func (data *FlowRecord) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/description"); value.Exists() {
data.Description = types.StringValue(value.String())
}
- if value := res.Get(prefix + "match.ipv4.source.address"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/match/ipv4/source/address"); value.Exists() {
data.MatchIpv4SourceAddress = types.BoolValue(true)
} else {
data.MatchIpv4SourceAddress = types.BoolValue(false)
}
- if value := res.Get(prefix + "match.ipv4.destination.address"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/match/ipv4/destination/address"); value.Exists() {
data.MatchIpv4DestinationAddress = types.BoolValue(true)
} else {
data.MatchIpv4DestinationAddress = types.BoolValue(false)
}
- if value := res.Get(prefix + "match.ipv4.protocol"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/match/ipv4/protocol"); value.Exists() {
data.MatchIpv4Protocol = types.BoolValue(true)
} else {
data.MatchIpv4Protocol = types.BoolValue(false)
}
- if value := res.Get(prefix + "match.ipv4.tos"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/match/ipv4/tos"); value.Exists() {
data.MatchIpv4Tos = types.BoolValue(true)
} else {
data.MatchIpv4Tos = types.BoolValue(false)
}
- if value := res.Get(prefix + "match.ipv6.source.address"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/match/ipv6/source/address"); value.Exists() {
data.MatchIpv6SourceAddress = types.BoolValue(true)
} else {
data.MatchIpv6SourceAddress = types.BoolValue(false)
}
- if value := res.Get(prefix + "match.ipv6.destination.address"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/match/ipv6/destination/address"); value.Exists() {
data.MatchIpv6DestinationAddress = types.BoolValue(true)
} else {
data.MatchIpv6DestinationAddress = types.BoolValue(false)
}
- if value := res.Get(prefix + "match.transport.source-port"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/match/transport/source-port"); value.Exists() {
data.MatchTransportSourcePort = types.BoolValue(true)
} else {
data.MatchTransportSourcePort = types.BoolValue(false)
}
- if value := res.Get(prefix + "match.transport.destination-port"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/match/transport/destination-port"); value.Exists() {
data.MatchTransportDestinationPort = types.BoolValue(true)
} else {
data.MatchTransportDestinationPort = types.BoolValue(false)
}
- if value := res.Get(prefix + "match.interface.input"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/match/interface/input"); value.Exists() {
data.MatchInterfaceInput = types.BoolValue(true)
} else {
data.MatchInterfaceInput = types.BoolValue(false)
}
- if value := res.Get(prefix + "match.flow.direction"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/match/flow/direction"); value.Exists() {
data.MatchFlowDirection = types.BoolValue(true)
} else {
data.MatchFlowDirection = types.BoolValue(false)
}
- if value := res.Get(prefix + "match.application.name"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/match/application/name"); value.Exists() {
data.MatchApplicationName = types.BoolValue(true)
} else {
data.MatchApplicationName = types.BoolValue(false)
}
- if value := res.Get(prefix + "match.flow.observation.point"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/match/flow/observation/point"); value.Exists() {
data.MatchFlowObservationPoint = types.BoolValue(true)
} else {
data.MatchFlowObservationPoint = types.BoolValue(false)
}
- if value := res.Get(prefix + "match.ipv4.version"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/match/ipv4/version"); value.Exists() {
data.MatchIpv4Version = types.BoolValue(true)
} else {
data.MatchIpv4Version = types.BoolValue(false)
}
- if value := res.Get(prefix + "match.ipv6.version"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/match/ipv6/version"); value.Exists() {
data.MatchIpv6Version = types.BoolValue(true)
} else {
data.MatchIpv6Version = types.BoolValue(false)
}
- if value := res.Get(prefix + "match.ipv6.protocol"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/match/ipv6/protocol"); value.Exists() {
data.MatchIpv6Protocol = types.BoolValue(true)
} else {
data.MatchIpv6Protocol = types.BoolValue(false)
}
- if value := res.Get(prefix + "match.connection.client.ipv4.address"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/match/connection/client/ipv4/address"); value.Exists() {
data.MatchConnectionClientIpv4Address = types.BoolValue(true)
} else {
data.MatchConnectionClientIpv4Address = types.BoolValue(false)
}
- if value := res.Get(prefix + "match.connection.server.ipv4.address"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/match/connection/server/ipv4/address"); value.Exists() {
data.MatchConnectionServerIpv4Address = types.BoolValue(true)
} else {
data.MatchConnectionServerIpv4Address = types.BoolValue(false)
}
- if value := res.Get(prefix + "match.connection.client.ipv6.address"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/match/connection/client/ipv6/address"); value.Exists() {
data.MatchConnectionClientIpv6Address = types.BoolValue(true)
} else {
data.MatchConnectionClientIpv6Address = types.BoolValue(false)
}
- if value := res.Get(prefix + "match.connection.server.ipv6.address"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/match/connection/server/ipv6/address"); value.Exists() {
data.MatchConnectionServerIpv6Address = types.BoolValue(true)
} else {
data.MatchConnectionServerIpv6Address = types.BoolValue(false)
}
- if value := res.Get(prefix + "match.connection.server.transport.port"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/match/connection/server/transport/port"); value.Exists() {
data.MatchConnectionServerTransportPort = types.BoolValue(true)
} else {
data.MatchConnectionServerTransportPort = types.BoolValue(false)
}
- if value := res.Get(prefix + "collect.interface.output"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/collect/interface/output"); value.Exists() {
data.CollectInterfaceOutput = types.BoolValue(true)
} else {
data.CollectInterfaceOutput = types.BoolValue(false)
}
- if value := res.Get(prefix + "collect.counter.bytes.long"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/collect/counter/bytes/long"); value.Exists() {
data.CollectCounterBytesLong = types.BoolValue(true)
} else {
data.CollectCounterBytesLong = types.BoolValue(false)
}
- if value := res.Get(prefix + "collect.counter.packets.long"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/collect/counter/packets/long"); value.Exists() {
data.CollectCounterPacketsLong = types.BoolValue(true)
} else {
data.CollectCounterPacketsLong = types.BoolValue(false)
}
- if value := res.Get(prefix + "collect.transport.tcp.flags"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/collect/transport/tcp/flags"); value.Exists() {
data.CollectTransportTcpFlags = types.BoolValue(true)
} else {
data.CollectTransportTcpFlags = types.BoolValue(false)
}
- if value := res.Get(prefix + "collect.timestamp.absolute.first"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/collect/timestamp/absolute/first"); value.Exists() {
data.CollectTimestampAbsoluteFirst = types.BoolValue(true)
} else {
data.CollectTimestampAbsoluteFirst = types.BoolValue(false)
}
- if value := res.Get(prefix + "collect.timestamp.absolute.last"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/collect/timestamp/absolute/last"); value.Exists() {
data.CollectTimestampAbsoluteLast = types.BoolValue(true)
} else {
data.CollectTimestampAbsoluteLast = types.BoolValue(false)
}
- if value := res.Get(prefix + "collect.connection.initiator"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/collect/connection/initiator"); value.Exists() {
data.CollectConnectionInitiator = types.BoolValue(true)
} else {
data.CollectConnectionInitiator = types.BoolValue(false)
}
- if value := res.Get(prefix + "collect.connection.new-connections"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/collect/connection/new-connections"); value.Exists() {
data.CollectConnectionNewConnections = types.BoolValue(true)
} else {
data.CollectConnectionNewConnections = types.BoolValue(false)
}
- if value := res.Get(prefix + "collect.connection.server.counter.bytes.network.long"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/collect/connection/server/counter/bytes/network/long"); value.Exists() {
data.CollectConnectionServerCounterBytesNetworkLong = types.BoolValue(true)
} else {
data.CollectConnectionServerCounterBytesNetworkLong = types.BoolValue(false)
}
- if value := res.Get(prefix + "collect.connection.server.counter.packets.long"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/collect/connection/server/counter/packets/long"); value.Exists() {
data.CollectConnectionServerCounterPacketsLong = types.BoolValue(true)
} else {
data.CollectConnectionServerCounterPacketsLong = types.BoolValue(false)
}
- if value := res.Get(prefix + "collect.datalink.mac.source.address.input"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/collect/datalink/mac/source/address/input"); value.Exists() {
data.CollectDatalinkMacSourceAddressInput = types.BoolValue(true)
} else {
data.CollectDatalinkMacSourceAddressInput = types.BoolValue(false)
}
- if value := res.Get(prefix + "collect.flow.direction"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/collect/flow/direction"); value.Exists() {
data.CollectFlowDirection = types.BoolValue(true)
} else {
data.CollectFlowDirection = types.BoolValue(false)
}
}
-// End of section. //template:end fromBody
+// End of section. //template:end fromBodyXML
-// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyData
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyDataXML
-func (data *FlowRecordData) fromBody(ctx context.Context, res gjson.Result) {
- prefix := helpers.LastElement(data.getPath()) + "."
- if res.Get(helpers.LastElement(data.getPath())).IsArray() {
- prefix += "0."
- }
- if value := res.Get(prefix + "description"); value.Exists() {
+func (data *FlowRecordData) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/description"); value.Exists() {
data.Description = types.StringValue(value.String())
}
- if value := res.Get(prefix + "match.ipv4.source.address"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/match/ipv4/source/address"); value.Exists() {
data.MatchIpv4SourceAddress = types.BoolValue(true)
} else {
data.MatchIpv4SourceAddress = types.BoolValue(false)
}
- if value := res.Get(prefix + "match.ipv4.destination.address"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/match/ipv4/destination/address"); value.Exists() {
data.MatchIpv4DestinationAddress = types.BoolValue(true)
} else {
data.MatchIpv4DestinationAddress = types.BoolValue(false)
}
- if value := res.Get(prefix + "match.ipv4.protocol"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/match/ipv4/protocol"); value.Exists() {
data.MatchIpv4Protocol = types.BoolValue(true)
} else {
data.MatchIpv4Protocol = types.BoolValue(false)
}
- if value := res.Get(prefix + "match.ipv4.tos"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/match/ipv4/tos"); value.Exists() {
data.MatchIpv4Tos = types.BoolValue(true)
} else {
data.MatchIpv4Tos = types.BoolValue(false)
}
- if value := res.Get(prefix + "match.ipv6.source.address"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/match/ipv6/source/address"); value.Exists() {
data.MatchIpv6SourceAddress = types.BoolValue(true)
} else {
data.MatchIpv6SourceAddress = types.BoolValue(false)
}
- if value := res.Get(prefix + "match.ipv6.destination.address"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/match/ipv6/destination/address"); value.Exists() {
data.MatchIpv6DestinationAddress = types.BoolValue(true)
} else {
data.MatchIpv6DestinationAddress = types.BoolValue(false)
}
- if value := res.Get(prefix + "match.transport.source-port"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/match/transport/source-port"); value.Exists() {
data.MatchTransportSourcePort = types.BoolValue(true)
} else {
data.MatchTransportSourcePort = types.BoolValue(false)
}
- if value := res.Get(prefix + "match.transport.destination-port"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/match/transport/destination-port"); value.Exists() {
data.MatchTransportDestinationPort = types.BoolValue(true)
} else {
data.MatchTransportDestinationPort = types.BoolValue(false)
}
- if value := res.Get(prefix + "match.interface.input"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/match/interface/input"); value.Exists() {
data.MatchInterfaceInput = types.BoolValue(true)
} else {
data.MatchInterfaceInput = types.BoolValue(false)
}
- if value := res.Get(prefix + "match.flow.direction"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/match/flow/direction"); value.Exists() {
data.MatchFlowDirection = types.BoolValue(true)
} else {
data.MatchFlowDirection = types.BoolValue(false)
}
- if value := res.Get(prefix + "match.application.name"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/match/application/name"); value.Exists() {
data.MatchApplicationName = types.BoolValue(true)
} else {
data.MatchApplicationName = types.BoolValue(false)
}
- if value := res.Get(prefix + "match.flow.observation.point"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/match/flow/observation/point"); value.Exists() {
data.MatchFlowObservationPoint = types.BoolValue(true)
} else {
data.MatchFlowObservationPoint = types.BoolValue(false)
}
- if value := res.Get(prefix + "match.ipv4.version"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/match/ipv4/version"); value.Exists() {
data.MatchIpv4Version = types.BoolValue(true)
} else {
data.MatchIpv4Version = types.BoolValue(false)
}
- if value := res.Get(prefix + "match.ipv6.version"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/match/ipv6/version"); value.Exists() {
data.MatchIpv6Version = types.BoolValue(true)
} else {
data.MatchIpv6Version = types.BoolValue(false)
}
- if value := res.Get(prefix + "match.ipv6.protocol"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/match/ipv6/protocol"); value.Exists() {
data.MatchIpv6Protocol = types.BoolValue(true)
} else {
data.MatchIpv6Protocol = types.BoolValue(false)
}
- if value := res.Get(prefix + "match.connection.client.ipv4.address"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/match/connection/client/ipv4/address"); value.Exists() {
data.MatchConnectionClientIpv4Address = types.BoolValue(true)
} else {
data.MatchConnectionClientIpv4Address = types.BoolValue(false)
}
- if value := res.Get(prefix + "match.connection.server.ipv4.address"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/match/connection/server/ipv4/address"); value.Exists() {
data.MatchConnectionServerIpv4Address = types.BoolValue(true)
} else {
data.MatchConnectionServerIpv4Address = types.BoolValue(false)
}
- if value := res.Get(prefix + "match.connection.client.ipv6.address"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/match/connection/client/ipv6/address"); value.Exists() {
data.MatchConnectionClientIpv6Address = types.BoolValue(true)
} else {
data.MatchConnectionClientIpv6Address = types.BoolValue(false)
}
- if value := res.Get(prefix + "match.connection.server.ipv6.address"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/match/connection/server/ipv6/address"); value.Exists() {
data.MatchConnectionServerIpv6Address = types.BoolValue(true)
} else {
data.MatchConnectionServerIpv6Address = types.BoolValue(false)
}
- if value := res.Get(prefix + "match.connection.server.transport.port"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/match/connection/server/transport/port"); value.Exists() {
data.MatchConnectionServerTransportPort = types.BoolValue(true)
} else {
data.MatchConnectionServerTransportPort = types.BoolValue(false)
}
- if value := res.Get(prefix + "collect.interface.output"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/collect/interface/output"); value.Exists() {
data.CollectInterfaceOutput = types.BoolValue(true)
} else {
data.CollectInterfaceOutput = types.BoolValue(false)
}
- if value := res.Get(prefix + "collect.counter.bytes.long"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/collect/counter/bytes/long"); value.Exists() {
data.CollectCounterBytesLong = types.BoolValue(true)
} else {
data.CollectCounterBytesLong = types.BoolValue(false)
}
- if value := res.Get(prefix + "collect.counter.packets.long"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/collect/counter/packets/long"); value.Exists() {
data.CollectCounterPacketsLong = types.BoolValue(true)
} else {
data.CollectCounterPacketsLong = types.BoolValue(false)
}
- if value := res.Get(prefix + "collect.transport.tcp.flags"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/collect/transport/tcp/flags"); value.Exists() {
data.CollectTransportTcpFlags = types.BoolValue(true)
} else {
data.CollectTransportTcpFlags = types.BoolValue(false)
}
- if value := res.Get(prefix + "collect.timestamp.absolute.first"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/collect/timestamp/absolute/first"); value.Exists() {
data.CollectTimestampAbsoluteFirst = types.BoolValue(true)
} else {
data.CollectTimestampAbsoluteFirst = types.BoolValue(false)
}
- if value := res.Get(prefix + "collect.timestamp.absolute.last"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/collect/timestamp/absolute/last"); value.Exists() {
data.CollectTimestampAbsoluteLast = types.BoolValue(true)
} else {
data.CollectTimestampAbsoluteLast = types.BoolValue(false)
}
- if value := res.Get(prefix + "collect.connection.initiator"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/collect/connection/initiator"); value.Exists() {
data.CollectConnectionInitiator = types.BoolValue(true)
} else {
data.CollectConnectionInitiator = types.BoolValue(false)
}
- if value := res.Get(prefix + "collect.connection.new-connections"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/collect/connection/new-connections"); value.Exists() {
data.CollectConnectionNewConnections = types.BoolValue(true)
} else {
data.CollectConnectionNewConnections = types.BoolValue(false)
}
- if value := res.Get(prefix + "collect.connection.server.counter.bytes.network.long"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/collect/connection/server/counter/bytes/network/long"); value.Exists() {
data.CollectConnectionServerCounterBytesNetworkLong = types.BoolValue(true)
} else {
data.CollectConnectionServerCounterBytesNetworkLong = types.BoolValue(false)
}
- if value := res.Get(prefix + "collect.connection.server.counter.packets.long"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/collect/connection/server/counter/packets/long"); value.Exists() {
data.CollectConnectionServerCounterPacketsLong = types.BoolValue(true)
} else {
data.CollectConnectionServerCounterPacketsLong = types.BoolValue(false)
}
- if value := res.Get(prefix + "collect.datalink.mac.source.address.input"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/collect/datalink/mac/source/address/input"); value.Exists() {
data.CollectDatalinkMacSourceAddressInput = types.BoolValue(true)
} else {
data.CollectDatalinkMacSourceAddressInput = types.BoolValue(false)
}
- if value := res.Get(prefix + "collect.flow.direction"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/collect/flow/direction"); value.Exists() {
data.CollectFlowDirection = types.BoolValue(true)
} else {
data.CollectFlowDirection = types.BoolValue(false)
}
}
-// End of section. //template:end fromBodyData
+// End of section. //template:end fromBodyDataXML
// Section below is generated&owned by "gen/generator.go". //template:begin getDeletedItems
@@ -1080,6 +1984,115 @@ func (data *FlowRecord) getDeletedItems(ctx context.Context, state FlowRecord) [
// End of section. //template:end getDeletedItems
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletedItemsXML
+
+func (data *FlowRecord) addDeletedItemsXML(ctx context.Context, state FlowRecord, body string) string {
+ b := netconf.NewBody(body)
+ if !state.Description.IsNull() && data.Description.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/description")
+ }
+ if !state.MatchIpv4SourceAddress.IsNull() && data.MatchIpv4SourceAddress.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/match/ipv4/source/address")
+ }
+ if !state.MatchIpv4DestinationAddress.IsNull() && data.MatchIpv4DestinationAddress.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/match/ipv4/destination/address")
+ }
+ if !state.MatchIpv4Protocol.IsNull() && data.MatchIpv4Protocol.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/match/ipv4/protocol")
+ }
+ if !state.MatchIpv4Tos.IsNull() && data.MatchIpv4Tos.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/match/ipv4/tos")
+ }
+ if !state.MatchIpv6SourceAddress.IsNull() && data.MatchIpv6SourceAddress.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/match/ipv6/source/address")
+ }
+ if !state.MatchIpv6DestinationAddress.IsNull() && data.MatchIpv6DestinationAddress.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/match/ipv6/destination/address")
+ }
+ if !state.MatchTransportSourcePort.IsNull() && data.MatchTransportSourcePort.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/match/transport/source-port")
+ }
+ if !state.MatchTransportDestinationPort.IsNull() && data.MatchTransportDestinationPort.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/match/transport/destination-port")
+ }
+ if !state.MatchInterfaceInput.IsNull() && data.MatchInterfaceInput.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/match/interface/input")
+ }
+ if !state.MatchFlowDirection.IsNull() && data.MatchFlowDirection.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/match/flow/direction")
+ }
+ if !state.MatchApplicationName.IsNull() && data.MatchApplicationName.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/match/application/name")
+ }
+ if !state.MatchFlowObservationPoint.IsNull() && data.MatchFlowObservationPoint.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/match/flow/observation/point")
+ }
+ if !state.MatchIpv4Version.IsNull() && data.MatchIpv4Version.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/match/ipv4/version")
+ }
+ if !state.MatchIpv6Version.IsNull() && data.MatchIpv6Version.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/match/ipv6/version")
+ }
+ if !state.MatchIpv6Protocol.IsNull() && data.MatchIpv6Protocol.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/match/ipv6/protocol")
+ }
+ if !state.MatchConnectionClientIpv4Address.IsNull() && data.MatchConnectionClientIpv4Address.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/match/connection/client/ipv4/address")
+ }
+ if !state.MatchConnectionServerIpv4Address.IsNull() && data.MatchConnectionServerIpv4Address.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/match/connection/server/ipv4/address")
+ }
+ if !state.MatchConnectionClientIpv6Address.IsNull() && data.MatchConnectionClientIpv6Address.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/match/connection/client/ipv6/address")
+ }
+ if !state.MatchConnectionServerIpv6Address.IsNull() && data.MatchConnectionServerIpv6Address.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/match/connection/server/ipv6/address")
+ }
+ if !state.MatchConnectionServerTransportPort.IsNull() && data.MatchConnectionServerTransportPort.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/match/connection/server/transport/port")
+ }
+ if !state.CollectInterfaceOutput.IsNull() && data.CollectInterfaceOutput.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/collect/interface/output")
+ }
+ if !state.CollectCounterBytesLong.IsNull() && data.CollectCounterBytesLong.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/collect/counter/bytes/long")
+ }
+ if !state.CollectCounterPacketsLong.IsNull() && data.CollectCounterPacketsLong.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/collect/counter/packets/long")
+ }
+ if !state.CollectTransportTcpFlags.IsNull() && data.CollectTransportTcpFlags.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/collect/transport/tcp/flags")
+ }
+ if !state.CollectTimestampAbsoluteFirst.IsNull() && data.CollectTimestampAbsoluteFirst.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/collect/timestamp/absolute/first")
+ }
+ if !state.CollectTimestampAbsoluteLast.IsNull() && data.CollectTimestampAbsoluteLast.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/collect/timestamp/absolute/last")
+ }
+ if !state.CollectConnectionInitiator.IsNull() && data.CollectConnectionInitiator.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/collect/connection/initiator")
+ }
+ if !state.CollectConnectionNewConnections.IsNull() && data.CollectConnectionNewConnections.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/collect/connection/new-connections")
+ }
+ if !state.CollectConnectionServerCounterBytesNetworkLong.IsNull() && data.CollectConnectionServerCounterBytesNetworkLong.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/collect/connection/server/counter/bytes/network/long")
+ }
+ if !state.CollectConnectionServerCounterPacketsLong.IsNull() && data.CollectConnectionServerCounterPacketsLong.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/collect/connection/server/counter/packets/long")
+ }
+ if !state.CollectDatalinkMacSourceAddressInput.IsNull() && data.CollectDatalinkMacSourceAddressInput.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/collect/datalink/mac/source/address/input")
+ }
+ if !state.CollectFlowDirection.IsNull() && data.CollectFlowDirection.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/collect/flow/direction")
+ }
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletedItemsXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin getEmptyLeafsDelete
func (data *FlowRecord) getEmptyLeafsDelete(ctx context.Context) []string {
@@ -1294,3 +2307,112 @@ func (data *FlowRecord) getDeletePaths(ctx context.Context) []string {
}
// End of section. //template:end getDeletePaths
+
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletePathsXML
+
+func (data *FlowRecord) addDeletePathsXML(ctx context.Context, body string) string {
+ b := netconf.NewBody(body)
+ if !data.Description.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/description")
+ }
+ if !data.MatchIpv4SourceAddress.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/match/ipv4/source/address")
+ }
+ if !data.MatchIpv4DestinationAddress.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/match/ipv4/destination/address")
+ }
+ if !data.MatchIpv4Protocol.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/match/ipv4/protocol")
+ }
+ if !data.MatchIpv4Tos.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/match/ipv4/tos")
+ }
+ if !data.MatchIpv6SourceAddress.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/match/ipv6/source/address")
+ }
+ if !data.MatchIpv6DestinationAddress.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/match/ipv6/destination/address")
+ }
+ if !data.MatchTransportSourcePort.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/match/transport/source-port")
+ }
+ if !data.MatchTransportDestinationPort.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/match/transport/destination-port")
+ }
+ if !data.MatchInterfaceInput.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/match/interface/input")
+ }
+ if !data.MatchFlowDirection.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/match/flow/direction")
+ }
+ if !data.MatchApplicationName.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/match/application/name")
+ }
+ if !data.MatchFlowObservationPoint.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/match/flow/observation/point")
+ }
+ if !data.MatchIpv4Version.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/match/ipv4/version")
+ }
+ if !data.MatchIpv6Version.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/match/ipv6/version")
+ }
+ if !data.MatchIpv6Protocol.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/match/ipv6/protocol")
+ }
+ if !data.MatchConnectionClientIpv4Address.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/match/connection/client/ipv4/address")
+ }
+ if !data.MatchConnectionServerIpv4Address.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/match/connection/server/ipv4/address")
+ }
+ if !data.MatchConnectionClientIpv6Address.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/match/connection/client/ipv6/address")
+ }
+ if !data.MatchConnectionServerIpv6Address.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/match/connection/server/ipv6/address")
+ }
+ if !data.MatchConnectionServerTransportPort.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/match/connection/server/transport/port")
+ }
+ if !data.CollectInterfaceOutput.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/collect/interface/output")
+ }
+ if !data.CollectCounterBytesLong.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/collect/counter/bytes/long")
+ }
+ if !data.CollectCounterPacketsLong.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/collect/counter/packets/long")
+ }
+ if !data.CollectTransportTcpFlags.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/collect/transport/tcp/flags")
+ }
+ if !data.CollectTimestampAbsoluteFirst.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/collect/timestamp/absolute/first")
+ }
+ if !data.CollectTimestampAbsoluteLast.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/collect/timestamp/absolute/last")
+ }
+ if !data.CollectConnectionInitiator.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/collect/connection/initiator")
+ }
+ if !data.CollectConnectionNewConnections.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/collect/connection/new-connections")
+ }
+ if !data.CollectConnectionServerCounterBytesNetworkLong.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/collect/connection/server/counter/bytes/network/long")
+ }
+ if !data.CollectConnectionServerCounterPacketsLong.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/collect/connection/server/counter/packets/long")
+ }
+ if !data.CollectDatalinkMacSourceAddressInput.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/collect/datalink/mac/source/address/input")
+ }
+ if !data.CollectFlowDirection.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/collect/flow/direction")
+ }
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletePathsXML
diff --git a/internal/provider/model_iosxe_interface_ethernet.go b/internal/provider/model_iosxe_interface_ethernet.go
index 9528ac5d..8efbbf4a 100644
--- a/internal/provider/model_iosxe_interface_ethernet.go
+++ b/internal/provider/model_iosxe_interface_ethernet.go
@@ -31,6 +31,9 @@ import (
"github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/types"
+ "github.com/hashicorp/terraform-plugin-log/tflog"
+ "github.com/netascode/go-netconf"
+ "github.com/netascode/xmldot"
"github.com/tidwall/gjson"
"github.com/tidwall/sjson"
)
@@ -361,6 +364,19 @@ func (data InterfaceEthernet) getPathShort() string {
return matches[1]
}
+// getXPath returns the XPath for NETCONF operations
+func (data InterfaceEthernet) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/interface/%s[name=%v]"
+ path = fmt.Sprintf(path, fmt.Sprintf("%v", data.Type.ValueString()), fmt.Sprintf("%v", data.Name.ValueString()))
+ return path
+}
+
+func (data InterfaceEthernetData) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/interface/%s[name=%v]"
+ path = fmt.Sprintf(path, fmt.Sprintf("%v", data.Type.ValueString()), fmt.Sprintf("%v", data.Name.ValueString()))
+ return path
+}
+
// End of section. //template:end getPath
// Section below is generated&owned by "gen/generator.go". //template:begin toBody
@@ -952,1020 +968,1001 @@ func (data InterfaceEthernet) toBody(ctx context.Context) string {
// End of section. //template:end toBody
-// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBody
+// Section below is generated&owned by "gen/generator.go". //template:begin toBodyXML
-func (data *InterfaceEthernet) updateFromBody(ctx context.Context, res gjson.Result) {
- prefix := helpers.LastElement(data.getPath()) + "."
- if res.Get(helpers.LastElement(data.getPath())).IsArray() {
- prefix += "0."
- }
- if value := res.Get(prefix + "name"); value.Exists() && !data.Name.IsNull() {
- data.Name = types.StringValue(value.String())
- } else {
- data.Name = types.StringNull()
+func (data InterfaceEthernet) toBodyXML(ctx context.Context) string {
+ body := netconf.Body{}
+ if !data.Name.IsNull() && !data.Name.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/name", data.Name.ValueString())
}
- if value := res.Get(prefix + "media-type"); value.Exists() && !data.MediaType.IsNull() {
- data.MediaType = types.StringValue(value.String())
- } else {
- data.MediaType = types.StringNull()
+ if !data.MediaType.IsNull() && !data.MediaType.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/media-type", data.MediaType.ValueString())
}
- if value := res.Get(prefix + "mtu"); value.Exists() && !data.Mtu.IsNull() {
- data.Mtu = types.Int64Value(value.Int())
- } else {
- data.Mtu = types.Int64Null()
+ if !data.Mtu.IsNull() && !data.Mtu.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/mtu", strconv.FormatInt(data.Mtu.ValueInt64(), 10))
}
- if value := res.Get(prefix + "bandwidth.kilobits"); value.Exists() && !data.Bandwidth.IsNull() {
- data.Bandwidth = types.Int64Value(value.Int())
- } else {
- data.Bandwidth = types.Int64Null()
+ if !data.Bandwidth.IsNull() && !data.Bandwidth.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/bandwidth/kilobits", strconv.FormatInt(data.Bandwidth.ValueInt64(), 10))
}
- if value := res.Get(prefix + "switchport-conf.switchport"); !data.Switchport.IsNull() {
- if value.Exists() {
- data.Switchport = types.BoolValue(value.Bool())
- }
- } else {
- data.Switchport = types.BoolNull()
+ if !data.Switchport.IsNull() && !data.Switchport.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/switchport-conf/switchport", data.Switchport.ValueBool())
}
- if value := res.Get(prefix + "description"); value.Exists() && !data.Description.IsNull() {
- data.Description = types.StringValue(value.String())
- } else {
- data.Description = types.StringNull()
+ if !data.Description.IsNull() && !data.Description.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/description", data.Description.ValueString())
}
- if value := res.Get(prefix + "shutdown"); !data.Shutdown.IsNull() {
- if value.Exists() {
- data.Shutdown = types.BoolValue(true)
+ if !data.Shutdown.IsNull() && !data.Shutdown.IsUnknown() {
+ if data.Shutdown.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/shutdown", "")
} else {
- data.Shutdown = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/shutdown")
}
- } else {
- data.Shutdown = types.BoolNull()
}
- if value := res.Get(prefix + "ip.proxy-arp"); !data.IpProxyArp.IsNull() {
- if value.Exists() {
- data.IpProxyArp = types.BoolValue(value.Bool())
- }
- } else {
- data.IpProxyArp = types.BoolNull()
+ if !data.IpProxyArp.IsNull() && !data.IpProxyArp.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ip/proxy-arp", data.IpProxyArp.ValueBool())
}
- if value := res.Get(prefix + "ip.redirects"); !data.IpRedirects.IsNull() {
- if value.Exists() {
- data.IpRedirects = types.BoolValue(value.Bool())
- }
- } else {
- data.IpRedirects = types.BoolNull()
+ if !data.IpRedirects.IsNull() && !data.IpRedirects.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ip/redirects", data.IpRedirects.ValueBool())
}
- if value := res.Get(prefix + "ip.Cisco-IOS-XE-icmp:unreachables"); !data.IpUnreachables.IsNull() {
- if value.Exists() {
- data.IpUnreachables = types.BoolValue(value.Bool())
- }
- } else {
- data.IpUnreachables = types.BoolNull()
+ if !data.IpUnreachables.IsNull() && !data.IpUnreachables.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ip/Cisco-IOS-XE-icmp:unreachables", data.IpUnreachables.ValueBool())
}
- if value := res.Get(prefix + "vrf.forwarding"); value.Exists() && !data.VrfForwarding.IsNull() {
- data.VrfForwarding = types.StringValue(value.String())
- } else {
- data.VrfForwarding = types.StringNull()
+ if !data.VrfForwarding.IsNull() && !data.VrfForwarding.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/vrf/forwarding", data.VrfForwarding.ValueString())
}
- if value := res.Get(prefix + "ip.address.primary.address"); value.Exists() && !data.Ipv4Address.IsNull() {
- data.Ipv4Address = types.StringValue(value.String())
- } else {
- data.Ipv4Address = types.StringNull()
+ if !data.Ipv4Address.IsNull() && !data.Ipv4Address.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ip/address/primary/address", data.Ipv4Address.ValueString())
}
- if value := res.Get(prefix + "ip.address.primary.mask"); value.Exists() && !data.Ipv4AddressMask.IsNull() {
- data.Ipv4AddressMask = types.StringValue(value.String())
- } else {
- data.Ipv4AddressMask = types.StringNull()
+ if !data.Ipv4AddressMask.IsNull() && !data.Ipv4AddressMask.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ip/address/primary/mask", data.Ipv4AddressMask.ValueString())
}
- if value := res.Get(prefix + "ip.unnumbered"); value.Exists() && !data.Unnumbered.IsNull() {
- data.Unnumbered = types.StringValue(value.String())
- } else {
- data.Unnumbered = types.StringNull()
+ if !data.Unnumbered.IsNull() && !data.Unnumbered.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ip/unnumbered", data.Unnumbered.ValueString())
}
- if value := res.Get(prefix + "encapsulation.dot1Q.vlan-id"); value.Exists() && !data.EncapsulationDot1qVlanId.IsNull() {
- data.EncapsulationDot1qVlanId = types.Int64Value(value.Int())
- } else {
- data.EncapsulationDot1qVlanId = types.Int64Null()
+ if !data.EncapsulationDot1qVlanId.IsNull() && !data.EncapsulationDot1qVlanId.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/encapsulation/dot1Q/vlan-id", strconv.FormatInt(data.EncapsulationDot1qVlanId.ValueInt64(), 10))
}
- if value := res.Get(prefix + "Cisco-IOS-XE-ethernet:channel-group.number"); value.Exists() && !data.ChannelGroupNumber.IsNull() {
- data.ChannelGroupNumber = types.Int64Value(value.Int())
- } else {
- data.ChannelGroupNumber = types.Int64Null()
+ if !data.ChannelGroupNumber.IsNull() && !data.ChannelGroupNumber.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-ethernet:channel-group/number", strconv.FormatInt(data.ChannelGroupNumber.ValueInt64(), 10))
}
- if value := res.Get(prefix + "Cisco-IOS-XE-ethernet:channel-group.mode"); value.Exists() && !data.ChannelGroupMode.IsNull() {
- data.ChannelGroupMode = types.StringValue(value.String())
- } else {
- data.ChannelGroupMode = types.StringNull()
+ if !data.ChannelGroupMode.IsNull() && !data.ChannelGroupMode.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-ethernet:channel-group/mode", data.ChannelGroupMode.ValueString())
}
- if value := res.Get(prefix + "ip.dhcp.Cisco-IOS-XE-dhcp:relay.source-interface"); value.Exists() && !data.IpDhcpRelaySourceInterface.IsNull() {
- data.IpDhcpRelaySourceInterface = types.StringValue(value.String())
- } else {
- data.IpDhcpRelaySourceInterface = types.StringNull()
+ if !data.IpDhcpRelaySourceInterface.IsNull() && !data.IpDhcpRelaySourceInterface.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ip/dhcp/Cisco-IOS-XE-dhcp:relay/source-interface", data.IpDhcpRelaySourceInterface.ValueString())
}
- if value := res.Get(prefix + "ip.access-group.in.acl.in"); !data.IpAccessGroupInEnable.IsNull() {
- if value.Exists() {
- data.IpAccessGroupInEnable = types.BoolValue(true)
+ if !data.IpAccessGroupInEnable.IsNull() && !data.IpAccessGroupInEnable.IsUnknown() {
+ if data.IpAccessGroupInEnable.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ip/access-group/in/acl/in", "")
} else {
- data.IpAccessGroupInEnable = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/ip/access-group/in/acl/in")
}
- } else {
- data.IpAccessGroupInEnable = types.BoolNull()
}
- if value := res.Get(prefix + "ip.access-group.in.acl.acl-name"); value.Exists() && !data.IpAccessGroupIn.IsNull() {
- data.IpAccessGroupIn = types.StringValue(value.String())
- } else {
- data.IpAccessGroupIn = types.StringNull()
+ if !data.IpAccessGroupIn.IsNull() && !data.IpAccessGroupIn.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ip/access-group/in/acl/acl-name", data.IpAccessGroupIn.ValueString())
}
- if value := res.Get(prefix + "ip.access-group.out.acl.out"); !data.IpAccessGroupOutEnable.IsNull() {
- if value.Exists() {
- data.IpAccessGroupOutEnable = types.BoolValue(true)
+ if !data.IpAccessGroupOutEnable.IsNull() && !data.IpAccessGroupOutEnable.IsUnknown() {
+ if data.IpAccessGroupOutEnable.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ip/access-group/out/acl/out", "")
} else {
- data.IpAccessGroupOutEnable = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/ip/access-group/out/acl/out")
}
- } else {
- data.IpAccessGroupOutEnable = types.BoolNull()
}
- if value := res.Get(prefix + "ip.access-group.out.acl.acl-name"); value.Exists() && !data.IpAccessGroupOut.IsNull() {
- data.IpAccessGroupOut = types.StringValue(value.String())
- } else {
- data.IpAccessGroupOut = types.StringNull()
+ if !data.IpAccessGroupOut.IsNull() && !data.IpAccessGroupOut.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ip/access-group/out/acl/acl-name", data.IpAccessGroupOut.ValueString())
}
- if value := res.Get(prefix + "Cisco-IOS-XE-spanning-tree:spanning-tree.guard"); value.Exists() && !data.SpanningTreeGuard.IsNull() {
- data.SpanningTreeGuard = types.StringValue(value.String())
- } else {
- data.SpanningTreeGuard = types.StringNull()
+ if !data.SpanningTreeGuard.IsNull() && !data.SpanningTreeGuard.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-spanning-tree:spanning-tree/guard", data.SpanningTreeGuard.ValueString())
}
- if value := res.Get(prefix + "Cisco-IOS-XE-switch:auto.qos.classify"); !data.AutoQosClassify.IsNull() {
- if value.Exists() {
- data.AutoQosClassify = types.BoolValue(true)
+ if !data.AutoQosClassify.IsNull() && !data.AutoQosClassify.IsUnknown() {
+ if data.AutoQosClassify.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/classify", "")
} else {
- data.AutoQosClassify = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/classify")
}
- } else {
- data.AutoQosClassify = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-switch:auto.qos.classify.police"); !data.AutoQosClassifyPolice.IsNull() {
- if value.Exists() {
- data.AutoQosClassifyPolice = types.BoolValue(true)
+ if !data.AutoQosClassifyPolice.IsNull() && !data.AutoQosClassifyPolice.IsUnknown() {
+ if data.AutoQosClassifyPolice.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/classify/police", "")
} else {
- data.AutoQosClassifyPolice = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/classify/police")
}
- } else {
- data.AutoQosClassifyPolice = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-switch:auto.qos.trust"); !data.AutoQosTrust.IsNull() {
- if value.Exists() {
- data.AutoQosTrust = types.BoolValue(true)
+ if !data.AutoQosTrust.IsNull() && !data.AutoQosTrust.IsUnknown() {
+ if data.AutoQosTrust.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/trust", "")
} else {
- data.AutoQosTrust = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/trust")
}
- } else {
- data.AutoQosTrust = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-switch:auto.qos.trust.cos"); !data.AutoQosTrustCos.IsNull() {
- if value.Exists() {
- data.AutoQosTrustCos = types.BoolValue(true)
+ if !data.AutoQosTrustCos.IsNull() && !data.AutoQosTrustCos.IsUnknown() {
+ if data.AutoQosTrustCos.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/trust/cos", "")
} else {
- data.AutoQosTrustCos = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/trust/cos")
}
- } else {
- data.AutoQosTrustCos = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-switch:auto.qos.trust.dscp"); !data.AutoQosTrustDscp.IsNull() {
- if value.Exists() {
- data.AutoQosTrustDscp = types.BoolValue(true)
+ if !data.AutoQosTrustDscp.IsNull() && !data.AutoQosTrustDscp.IsUnknown() {
+ if data.AutoQosTrustDscp.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/trust/dscp", "")
} else {
- data.AutoQosTrustDscp = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/trust/dscp")
}
- } else {
- data.AutoQosTrustDscp = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-switch:auto.qos.video.cts"); !data.AutoQosVideoCts.IsNull() {
- if value.Exists() {
- data.AutoQosVideoCts = types.BoolValue(true)
+ if !data.AutoQosVideoCts.IsNull() && !data.AutoQosVideoCts.IsUnknown() {
+ if data.AutoQosVideoCts.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/video/cts", "")
} else {
- data.AutoQosVideoCts = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/video/cts")
}
- } else {
- data.AutoQosVideoCts = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-switch:auto.qos.video.ip-camera"); !data.AutoQosVideoIpCamera.IsNull() {
- if value.Exists() {
- data.AutoQosVideoIpCamera = types.BoolValue(true)
+ if !data.AutoQosVideoIpCamera.IsNull() && !data.AutoQosVideoIpCamera.IsUnknown() {
+ if data.AutoQosVideoIpCamera.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/video/ip-camera", "")
} else {
- data.AutoQosVideoIpCamera = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/video/ip-camera")
}
- } else {
- data.AutoQosVideoIpCamera = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-switch:auto.qos.video.media-player"); !data.AutoQosVideoMediaPlayer.IsNull() {
- if value.Exists() {
- data.AutoQosVideoMediaPlayer = types.BoolValue(true)
+ if !data.AutoQosVideoMediaPlayer.IsNull() && !data.AutoQosVideoMediaPlayer.IsUnknown() {
+ if data.AutoQosVideoMediaPlayer.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/video/media-player", "")
} else {
- data.AutoQosVideoMediaPlayer = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/video/media-player")
}
- } else {
- data.AutoQosVideoMediaPlayer = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-switch:auto.qos.voip"); !data.AutoQosVoip.IsNull() {
- if value.Exists() {
- data.AutoQosVoip = types.BoolValue(true)
+ if !data.AutoQosVoip.IsNull() && !data.AutoQosVoip.IsUnknown() {
+ if data.AutoQosVoip.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/voip", "")
} else {
- data.AutoQosVoip = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/voip")
}
- } else {
- data.AutoQosVoip = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-switch:auto.qos.voip.cisco-phone"); !data.AutoQosVoipCiscoPhone.IsNull() {
- if value.Exists() {
- data.AutoQosVoipCiscoPhone = types.BoolValue(true)
+ if !data.AutoQosVoipCiscoPhone.IsNull() && !data.AutoQosVoipCiscoPhone.IsUnknown() {
+ if data.AutoQosVoipCiscoPhone.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/voip/cisco-phone", "")
} else {
- data.AutoQosVoipCiscoPhone = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/voip/cisco-phone")
}
- } else {
- data.AutoQosVoipCiscoPhone = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-switch:auto.qos.voip.cisco-softphone"); !data.AutoQosVoipCiscoSoftphone.IsNull() {
- if value.Exists() {
- data.AutoQosVoipCiscoSoftphone = types.BoolValue(true)
+ if !data.AutoQosVoipCiscoSoftphone.IsNull() && !data.AutoQosVoipCiscoSoftphone.IsUnknown() {
+ if data.AutoQosVoipCiscoSoftphone.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/voip/cisco-softphone", "")
} else {
- data.AutoQosVoipCiscoSoftphone = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/voip/cisco-softphone")
}
- } else {
- data.AutoQosVoipCiscoSoftphone = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-switch:auto.qos.voip.trust"); !data.AutoQosVoipTrust.IsNull() {
- if value.Exists() {
- data.AutoQosVoipTrust = types.BoolValue(true)
+ if !data.AutoQosVoipTrust.IsNull() && !data.AutoQosVoipTrust.IsUnknown() {
+ if data.AutoQosVoipTrust.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/voip/trust", "")
} else {
- data.AutoQosVoipTrust = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/voip/trust")
}
- } else {
- data.AutoQosVoipTrust = types.BoolNull()
}
- if value := res.Get(prefix + "trust.device"); value.Exists() && !data.TrustDevice.IsNull() {
- data.TrustDevice = types.StringValue(value.String())
- } else {
- data.TrustDevice = types.StringNull()
+ if !data.TrustDevice.IsNull() && !data.TrustDevice.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/trust/device", data.TrustDevice.ValueString())
}
- for i := range data.HelperAddresses {
- keys := [...]string{"address"}
- keyValues := [...]string{data.HelperAddresses[i].Address.ValueString()}
-
- var r gjson.Result
- res.Get(prefix + "ip.helper-address").ForEach(
- func(_, v gjson.Result) bool {
- found := false
- for ik := range keys {
- if v.Get(keys[ik]).String() == keyValues[ik] {
- found = true
- continue
- }
- found = false
- break
+ if len(data.HelperAddresses) > 0 {
+ for _, item := range data.HelperAddresses {
+ cBody := netconf.Body{}
+ if !item.Address.IsNull() && !item.Address.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "address", item.Address.ValueString())
+ }
+ if !item.Global.IsNull() && !item.Global.IsUnknown() {
+ if item.Global.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "global", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "global")
}
- if found {
- r = v
- return false
+ }
+ if !item.Vrf.IsNull() && !item.Vrf.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "vrf", item.Vrf.ValueString())
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/ip/helper-address", cBody.Res())
+ }
+ }
+ if len(data.SourceTemplate) > 0 {
+ for _, item := range data.SourceTemplate {
+ cBody := netconf.Body{}
+ if !item.TemplateName.IsNull() && !item.TemplateName.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "template-name", item.TemplateName.ValueString())
+ }
+ if !item.Merge.IsNull() && !item.Merge.IsUnknown() {
+ if item.Merge.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "merge", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "merge")
}
- return true
- },
- )
- if value := r.Get("address"); value.Exists() && !data.HelperAddresses[i].Address.IsNull() {
- data.HelperAddresses[i].Address = types.StringValue(value.String())
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/source/template/template-name", cBody.Res())
+ }
+ }
+ if !data.BfdTemplate.IsNull() && !data.BfdTemplate.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/bfd/Cisco-IOS-XE-bfd:template", data.BfdTemplate.ValueString())
+ }
+ if !data.BfdEnable.IsNull() && !data.BfdEnable.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/bfd/Cisco-IOS-XE-bfd:enable", data.BfdEnable.ValueBool())
+ }
+ if !data.BfdLocalAddress.IsNull() && !data.BfdLocalAddress.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/bfd/Cisco-IOS-XE-bfd:local-address", data.BfdLocalAddress.ValueString())
+ }
+ if !data.BfdInterval.IsNull() && !data.BfdInterval.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/bfd/Cisco-IOS-XE-bfd:interval-interface/msecs", strconv.FormatInt(data.BfdInterval.ValueInt64(), 10))
+ }
+ if !data.BfdIntervalMinRx.IsNull() && !data.BfdIntervalMinRx.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/bfd/Cisco-IOS-XE-bfd:interval-interface/min_rx", strconv.FormatInt(data.BfdIntervalMinRx.ValueInt64(), 10))
+ }
+ if !data.BfdIntervalMultiplier.IsNull() && !data.BfdIntervalMultiplier.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/bfd/Cisco-IOS-XE-bfd:interval-interface/multiplier", strconv.FormatInt(data.BfdIntervalMultiplier.ValueInt64(), 10))
+ }
+ if !data.BfdEcho.IsNull() && !data.BfdEcho.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/bfd/Cisco-IOS-XE-bfd:echo", data.BfdEcho.ValueBool())
+ }
+ if !data.Ipv6Enable.IsNull() && !data.Ipv6Enable.IsUnknown() {
+ if data.Ipv6Enable.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ipv6/enable", "")
} else {
- data.HelperAddresses[i].Address = types.StringNull()
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/ipv6/enable")
}
- if value := r.Get("global"); !data.HelperAddresses[i].Global.IsNull() {
- if value.Exists() {
- data.HelperAddresses[i].Global = types.BoolValue(true)
- } else {
- data.HelperAddresses[i].Global = types.BoolValue(false)
- }
+ }
+ if !data.Ipv6Mtu.IsNull() && !data.Ipv6Mtu.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ipv6/mtu", strconv.FormatInt(data.Ipv6Mtu.ValueInt64(), 10))
+ }
+ if !data.Ipv6NdRaSuppressAll.IsNull() && !data.Ipv6NdRaSuppressAll.IsUnknown() {
+ if data.Ipv6NdRaSuppressAll.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ipv6/nd/Cisco-IOS-XE-nd:ra/suppress/all", "")
} else {
- data.HelperAddresses[i].Global = types.BoolNull()
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/ipv6/nd/Cisco-IOS-XE-nd:ra/suppress/all")
}
- if value := r.Get("vrf"); value.Exists() && !data.HelperAddresses[i].Vrf.IsNull() {
- data.HelperAddresses[i].Vrf = types.StringValue(value.String())
+ }
+ if !data.Ipv6AddressAutoconfigDefault.IsNull() && !data.Ipv6AddressAutoconfigDefault.IsUnknown() {
+ if data.Ipv6AddressAutoconfigDefault.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ipv6/address/autoconfig/default", "")
} else {
- data.HelperAddresses[i].Vrf = types.StringNull()
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/ipv6/address/autoconfig/default")
}
}
- for i := range data.SourceTemplate {
- keys := [...]string{"template-name"}
- keyValues := [...]string{data.SourceTemplate[i].TemplateName.ValueString()}
-
- var r gjson.Result
- res.Get(prefix + "source.template.template-name").ForEach(
- func(_, v gjson.Result) bool {
- found := false
- for ik := range keys {
- if v.Get(keys[ik]).String() == keyValues[ik] {
- found = true
- continue
- }
- found = false
- break
+ if !data.Ipv6AddressDhcp.IsNull() && !data.Ipv6AddressDhcp.IsUnknown() {
+ if data.Ipv6AddressDhcp.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ipv6/address/dhcp", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/ipv6/address/dhcp")
+ }
+ }
+ if len(data.Ipv6LinkLocalAddresses) > 0 {
+ for _, item := range data.Ipv6LinkLocalAddresses {
+ cBody := netconf.Body{}
+ if !item.Address.IsNull() && !item.Address.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "address", item.Address.ValueString())
+ }
+ if !item.LinkLocal.IsNull() && !item.LinkLocal.IsUnknown() {
+ if item.LinkLocal.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "link-local", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "link-local")
}
- if found {
- r = v
- return false
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/ipv6/address/link-local-address", cBody.Res())
+ }
+ }
+ if len(data.Ipv6Addresses) > 0 {
+ for _, item := range data.Ipv6Addresses {
+ cBody := netconf.Body{}
+ if !item.Prefix.IsNull() && !item.Prefix.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "prefix", item.Prefix.ValueString())
+ }
+ if !item.Eui64.IsNull() && !item.Eui64.IsUnknown() {
+ if item.Eui64.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "eui-64", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "eui-64")
}
- return true
- },
- )
- if value := r.Get("template-name"); value.Exists() && !data.SourceTemplate[i].TemplateName.IsNull() {
- data.SourceTemplate[i].TemplateName = types.StringValue(value.String())
- } else {
- data.SourceTemplate[i].TemplateName = types.StringNull()
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/ipv6/address/prefix-list", cBody.Res())
}
- if value := r.Get("merge"); !data.SourceTemplate[i].Merge.IsNull() {
- if value.Exists() {
- data.SourceTemplate[i].Merge = types.BoolValue(true)
- } else {
- data.SourceTemplate[i].Merge = types.BoolValue(false)
+ }
+ if len(data.Ipv6FlowMonitors) > 0 {
+ for _, item := range data.Ipv6FlowMonitors {
+ cBody := netconf.Body{}
+ if !item.Name.IsNull() && !item.Name.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "name", item.Name.ValueString())
}
- } else {
- data.SourceTemplate[i].Merge = types.BoolNull()
+ if !item.Direction.IsNull() && !item.Direction.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "direction", item.Direction.ValueString())
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/ipv6/Cisco-IOS-XE-flow:flow/monitor-new", cBody.Res())
}
}
- if value := res.Get(prefix + "bfd.Cisco-IOS-XE-bfd:template"); value.Exists() && !data.BfdTemplate.IsNull() {
- data.BfdTemplate = types.StringValue(value.String())
- } else {
- data.BfdTemplate = types.StringNull()
+ if !data.ArpTimeout.IsNull() && !data.ArpTimeout.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/arp/timeout", strconv.FormatInt(data.ArpTimeout.ValueInt64(), 10))
}
- if value := res.Get(prefix + "bfd.Cisco-IOS-XE-bfd:enable"); !data.BfdEnable.IsNull() {
- if value.Exists() {
- data.BfdEnable = types.BoolValue(value.Bool())
+ if !data.SpanningTreeLinkType.IsNull() && !data.SpanningTreeLinkType.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-spanning-tree:spanning-tree/link-type", data.SpanningTreeLinkType.ValueString())
+ }
+ if !data.BpduguardEnable.IsNull() && !data.BpduguardEnable.IsUnknown() {
+ if data.BpduguardEnable.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-spanning-tree:spanning-tree/bpduguard/enable", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-spanning-tree:spanning-tree/bpduguard/enable")
}
- } else {
- data.BfdEnable = types.BoolNull()
}
- if value := res.Get(prefix + "bfd.Cisco-IOS-XE-bfd:local-address"); value.Exists() && !data.BfdLocalAddress.IsNull() {
- data.BfdLocalAddress = types.StringValue(value.String())
- } else {
- data.BfdLocalAddress = types.StringNull()
+ if !data.BpduguardDisable.IsNull() && !data.BpduguardDisable.IsUnknown() {
+ if data.BpduguardDisable.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-spanning-tree:spanning-tree/bpduguard/disable", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-spanning-tree:spanning-tree/bpduguard/disable")
+ }
}
- if value := res.Get(prefix + "bfd.Cisco-IOS-XE-bfd:interval-interface.msecs"); value.Exists() && !data.BfdInterval.IsNull() {
- data.BfdInterval = types.Int64Value(value.Int())
- } else {
- data.BfdInterval = types.Int64Null()
+ if !data.SpanningTreePortfast.IsNull() && !data.SpanningTreePortfast.IsUnknown() {
+ if data.SpanningTreePortfast.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-spanning-tree:spanning-tree/portfast", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-spanning-tree:spanning-tree/portfast")
+ }
}
- if value := res.Get(prefix + "bfd.Cisco-IOS-XE-bfd:interval-interface.min_rx"); value.Exists() && !data.BfdIntervalMinRx.IsNull() {
- data.BfdIntervalMinRx = types.Int64Value(value.Int())
- } else {
- data.BfdIntervalMinRx = types.Int64Null()
+ if !data.SpanningTreePortfastDisable.IsNull() && !data.SpanningTreePortfastDisable.IsUnknown() {
+ if data.SpanningTreePortfastDisable.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-spanning-tree:spanning-tree/portfast/disable", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-spanning-tree:spanning-tree/portfast/disable")
+ }
}
- if value := res.Get(prefix + "bfd.Cisco-IOS-XE-bfd:interval-interface.multiplier"); value.Exists() && !data.BfdIntervalMultiplier.IsNull() {
- data.BfdIntervalMultiplier = types.Int64Value(value.Int())
- } else {
- data.BfdIntervalMultiplier = types.Int64Null()
+ if !data.SpanningTreePortfastTrunk.IsNull() && !data.SpanningTreePortfastTrunk.IsUnknown() {
+ if data.SpanningTreePortfastTrunk.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-spanning-tree:spanning-tree/portfast/trunk", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-spanning-tree:spanning-tree/portfast/trunk")
+ }
}
- if value := res.Get(prefix + "bfd.Cisco-IOS-XE-bfd:echo"); !data.BfdEcho.IsNull() {
- if value.Exists() {
- data.BfdEcho = types.BoolValue(value.Bool())
+ if !data.SpanningTreePortfastEdge.IsNull() && !data.SpanningTreePortfastEdge.IsUnknown() {
+ if data.SpanningTreePortfastEdge.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-spanning-tree:spanning-tree/portfast/edge", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-spanning-tree:spanning-tree/portfast/edge")
}
- } else {
- data.BfdEcho = types.BoolNull()
}
- if value := res.Get(prefix + "ipv6.enable"); !data.Ipv6Enable.IsNull() {
- if value.Exists() {
- data.Ipv6Enable = types.BoolValue(true)
+ if !data.IpArpInspectionTrust.IsNull() && !data.IpArpInspectionTrust.IsUnknown() {
+ if data.IpArpInspectionTrust.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ip/arp/inspection/trust", "")
} else {
- data.Ipv6Enable = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/ip/arp/inspection/trust")
}
- } else {
- data.Ipv6Enable = types.BoolNull()
}
- if value := res.Get(prefix + "ipv6.mtu"); value.Exists() && !data.Ipv6Mtu.IsNull() {
- data.Ipv6Mtu = types.Int64Value(value.Int())
- } else {
- data.Ipv6Mtu = types.Int64Null()
+ if !data.IpArpInspectionLimitRate.IsNull() && !data.IpArpInspectionLimitRate.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ip/arp/inspection/limit/rate", strconv.FormatInt(data.IpArpInspectionLimitRate.ValueInt64(), 10))
}
- if value := res.Get(prefix + "ipv6.nd.Cisco-IOS-XE-nd:ra.suppress.all"); !data.Ipv6NdRaSuppressAll.IsNull() {
- if value.Exists() {
- data.Ipv6NdRaSuppressAll = types.BoolValue(true)
+ if !data.IpDhcpSnoopingTrust.IsNull() && !data.IpDhcpSnoopingTrust.IsUnknown() {
+ if data.IpDhcpSnoopingTrust.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ip/dhcp/Cisco-IOS-XE-dhcp:snooping/trust", "")
} else {
- data.Ipv6NdRaSuppressAll = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/ip/dhcp/Cisco-IOS-XE-dhcp:snooping/trust")
}
- } else {
- data.Ipv6NdRaSuppressAll = types.BoolNull()
}
- if value := res.Get(prefix + "ipv6.address.autoconfig.default"); !data.Ipv6AddressAutoconfigDefault.IsNull() {
- if value.Exists() {
- data.Ipv6AddressAutoconfigDefault = types.BoolValue(true)
+ if !data.Speed100.IsNull() && !data.Speed100.IsUnknown() {
+ if data.Speed100.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-ethernet:speed/value-100", "")
} else {
- data.Ipv6AddressAutoconfigDefault = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-ethernet:speed/value-100")
}
- } else {
- data.Ipv6AddressAutoconfigDefault = types.BoolNull()
}
- if value := res.Get(prefix + "ipv6.address.dhcp"); !data.Ipv6AddressDhcp.IsNull() {
- if value.Exists() {
- data.Ipv6AddressDhcp = types.BoolValue(true)
+ if !data.Speed1000.IsNull() && !data.Speed1000.IsUnknown() {
+ if data.Speed1000.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-ethernet:speed/value-1000", "")
} else {
- data.Ipv6AddressDhcp = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-ethernet:speed/value-1000")
}
- } else {
- data.Ipv6AddressDhcp = types.BoolNull()
}
- for i := range data.Ipv6LinkLocalAddresses {
- keys := [...]string{"address"}
- keyValues := [...]string{data.Ipv6LinkLocalAddresses[i].Address.ValueString()}
-
- var r gjson.Result
- res.Get(prefix + "ipv6.address.link-local-address").ForEach(
- func(_, v gjson.Result) bool {
- found := false
- for ik := range keys {
- if v.Get(keys[ik]).String() == keyValues[ik] {
- found = true
- continue
- }
- found = false
- break
- }
- if found {
- r = v
- return false
- }
- return true
- },
- )
- if value := r.Get("address"); value.Exists() && !data.Ipv6LinkLocalAddresses[i].Address.IsNull() {
- data.Ipv6LinkLocalAddresses[i].Address = types.StringValue(value.String())
+ if !data.Speed2500.IsNull() && !data.Speed2500.IsUnknown() {
+ if data.Speed2500.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-ethernet:speed/value-2500", "")
} else {
- data.Ipv6LinkLocalAddresses[i].Address = types.StringNull()
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-ethernet:speed/value-2500")
}
- if value := r.Get("link-local"); !data.Ipv6LinkLocalAddresses[i].LinkLocal.IsNull() {
- if value.Exists() {
- data.Ipv6LinkLocalAddresses[i].LinkLocal = types.BoolValue(true)
- } else {
- data.Ipv6LinkLocalAddresses[i].LinkLocal = types.BoolValue(false)
- }
+ }
+ if !data.Speed5000.IsNull() && !data.Speed5000.IsUnknown() {
+ if data.Speed5000.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-ethernet:speed/value-5000", "")
} else {
- data.Ipv6LinkLocalAddresses[i].LinkLocal = types.BoolNull()
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-ethernet:speed/value-5000")
}
}
- for i := range data.Ipv6Addresses {
- keys := [...]string{"prefix"}
- keyValues := [...]string{data.Ipv6Addresses[i].Prefix.ValueString()}
-
- var r gjson.Result
- res.Get(prefix + "ipv6.address.prefix-list").ForEach(
- func(_, v gjson.Result) bool {
- found := false
- for ik := range keys {
- if v.Get(keys[ik]).String() == keyValues[ik] {
- found = true
- continue
- }
- found = false
- break
- }
- if found {
- r = v
- return false
- }
- return true
- },
- )
- if value := r.Get("prefix"); value.Exists() && !data.Ipv6Addresses[i].Prefix.IsNull() {
- data.Ipv6Addresses[i].Prefix = types.StringValue(value.String())
+ if !data.Speed10000.IsNull() && !data.Speed10000.IsUnknown() {
+ if data.Speed10000.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-ethernet:speed/value-10000", "")
} else {
- data.Ipv6Addresses[i].Prefix = types.StringNull()
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-ethernet:speed/value-10000")
}
- if value := r.Get("eui-64"); !data.Ipv6Addresses[i].Eui64.IsNull() {
- if value.Exists() {
- data.Ipv6Addresses[i].Eui64 = types.BoolValue(true)
- } else {
- data.Ipv6Addresses[i].Eui64 = types.BoolValue(false)
- }
+ }
+ if !data.Speed25000.IsNull() && !data.Speed25000.IsUnknown() {
+ if data.Speed25000.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-ethernet:speed/value-25000", "")
} else {
- data.Ipv6Addresses[i].Eui64 = types.BoolNull()
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-ethernet:speed/value-25000")
}
}
- for i := range data.Ipv6FlowMonitors {
- keys := [...]string{"name", "direction"}
- keyValues := [...]string{data.Ipv6FlowMonitors[i].Name.ValueString(), data.Ipv6FlowMonitors[i].Direction.ValueString()}
-
- var r gjson.Result
- res.Get(prefix + "ipv6.Cisco-IOS-XE-flow:flow.monitor-new").ForEach(
- func(_, v gjson.Result) bool {
- found := false
- for ik := range keys {
- if v.Get(keys[ik]).String() == keyValues[ik] {
- found = true
- continue
- }
- found = false
- break
- }
- if found {
- r = v
- return false
- }
- return true
- },
- )
- if value := r.Get("name"); value.Exists() && !data.Ipv6FlowMonitors[i].Name.IsNull() {
- data.Ipv6FlowMonitors[i].Name = types.StringValue(value.String())
+ if !data.Speed40000.IsNull() && !data.Speed40000.IsUnknown() {
+ if data.Speed40000.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-ethernet:speed/value-40000", "")
} else {
- data.Ipv6FlowMonitors[i].Name = types.StringNull()
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-ethernet:speed/value-40000")
}
- if value := r.Get("direction"); value.Exists() && !data.Ipv6FlowMonitors[i].Direction.IsNull() {
- data.Ipv6FlowMonitors[i].Direction = types.StringValue(value.String())
+ }
+ if !data.Speed100000.IsNull() && !data.Speed100000.IsUnknown() {
+ if data.Speed100000.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-ethernet:speed/value-100000", "")
} else {
- data.Ipv6FlowMonitors[i].Direction = types.StringNull()
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-ethernet:speed/value-100000")
}
}
- if value := res.Get(prefix + "arp.timeout"); value.Exists() && !data.ArpTimeout.IsNull() {
- data.ArpTimeout = types.Int64Value(value.Int())
- } else {
- data.ArpTimeout = types.Int64Null()
- }
- if value := res.Get(prefix + "Cisco-IOS-XE-spanning-tree:spanning-tree.link-type"); value.Exists() && !data.SpanningTreeLinkType.IsNull() {
- data.SpanningTreeLinkType = types.StringValue(value.String())
- } else {
- data.SpanningTreeLinkType = types.StringNull()
+ if !data.NegotiationAuto.IsNull() && !data.NegotiationAuto.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-ethernet:negotiation/auto", data.NegotiationAuto.ValueBool())
}
- if value := res.Get(prefix + "Cisco-IOS-XE-spanning-tree:spanning-tree.bpduguard.enable"); !data.BpduguardEnable.IsNull() {
- if value.Exists() {
- data.BpduguardEnable = types.BoolValue(true)
+ if !data.SpeedNonegotiate.IsNull() && !data.SpeedNonegotiate.IsUnknown() {
+ if data.SpeedNonegotiate.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-ethernet:speed/nonegotiate", "")
} else {
- data.BpduguardEnable = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-ethernet:speed/nonegotiate")
}
- } else {
- data.BpduguardEnable = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-spanning-tree:spanning-tree.bpduguard.disable"); !data.BpduguardDisable.IsNull() {
- if value.Exists() {
- data.BpduguardDisable = types.BoolValue(true)
- } else {
- data.BpduguardDisable = types.BoolValue(false)
- }
- } else {
- data.BpduguardDisable = types.BoolNull()
+ if !data.AuthenticationHostMode.IsNull() && !data.AuthenticationHostMode.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-sanet:authentication/host-mode", data.AuthenticationHostMode.ValueString())
}
- if value := res.Get(prefix + "Cisco-IOS-XE-spanning-tree:spanning-tree.portfast"); !data.SpanningTreePortfast.IsNull() {
- if value.Exists() {
- data.SpanningTreePortfast = types.BoolValue(true)
+ if !data.AuthenticationOrderDot1x.IsNull() && !data.AuthenticationOrderDot1x.IsUnknown() {
+ if data.AuthenticationOrderDot1x.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-sanet:authentication/order-config/dot1x-config", "")
} else {
- data.SpanningTreePortfast = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-sanet:authentication/order-config/dot1x-config")
}
- } else {
- data.SpanningTreePortfast = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-spanning-tree:spanning-tree.portfast.disable"); !data.SpanningTreePortfastDisable.IsNull() {
- if value.Exists() {
- data.SpanningTreePortfastDisable = types.BoolValue(true)
+ if !data.AuthenticationOrderDot1xMab.IsNull() && !data.AuthenticationOrderDot1xMab.IsUnknown() {
+ if data.AuthenticationOrderDot1xMab.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-sanet:authentication/order-config/dot1x-config/mab", "")
} else {
- data.SpanningTreePortfastDisable = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-sanet:authentication/order-config/dot1x-config/mab")
}
- } else {
- data.SpanningTreePortfastDisable = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-spanning-tree:spanning-tree.portfast.trunk"); !data.SpanningTreePortfastTrunk.IsNull() {
- if value.Exists() {
- data.SpanningTreePortfastTrunk = types.BoolValue(true)
+ if !data.AuthenticationOrderDot1xWebauth.IsNull() && !data.AuthenticationOrderDot1xWebauth.IsUnknown() {
+ if data.AuthenticationOrderDot1xWebauth.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-sanet:authentication/order-config/dot1x-config/webauth", "")
} else {
- data.SpanningTreePortfastTrunk = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-sanet:authentication/order-config/dot1x-config/webauth")
}
- } else {
- data.SpanningTreePortfastTrunk = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-spanning-tree:spanning-tree.portfast.edge"); !data.SpanningTreePortfastEdge.IsNull() {
- if value.Exists() {
- data.SpanningTreePortfastEdge = types.BoolValue(true)
+ if !data.AuthenticationOrderMab.IsNull() && !data.AuthenticationOrderMab.IsUnknown() {
+ if data.AuthenticationOrderMab.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-sanet:authentication/order-config/mab-config", "")
} else {
- data.SpanningTreePortfastEdge = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-sanet:authentication/order-config/mab-config")
}
- } else {
- data.SpanningTreePortfastEdge = types.BoolNull()
}
- if value := res.Get(prefix + "ip.arp.inspection.trust"); !data.IpArpInspectionTrust.IsNull() {
- if value.Exists() {
- data.IpArpInspectionTrust = types.BoolValue(true)
+ if !data.AuthenticationOrderMabDot1x.IsNull() && !data.AuthenticationOrderMabDot1x.IsUnknown() {
+ if data.AuthenticationOrderMabDot1x.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-sanet:authentication/order-config/mab-config/dot1x", "")
} else {
- data.IpArpInspectionTrust = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-sanet:authentication/order-config/mab-config/dot1x")
}
- } else {
- data.IpArpInspectionTrust = types.BoolNull()
- }
- if value := res.Get(prefix + "ip.arp.inspection.limit.rate"); value.Exists() && !data.IpArpInspectionLimitRate.IsNull() {
- data.IpArpInspectionLimitRate = types.Int64Value(value.Int())
- } else {
- data.IpArpInspectionLimitRate = types.Int64Null()
}
- if value := res.Get(prefix + "ip.dhcp.Cisco-IOS-XE-dhcp:snooping.trust"); !data.IpDhcpSnoopingTrust.IsNull() {
- if value.Exists() {
- data.IpDhcpSnoopingTrust = types.BoolValue(true)
+ if !data.AuthenticationOrderMabWebauth.IsNull() && !data.AuthenticationOrderMabWebauth.IsUnknown() {
+ if data.AuthenticationOrderMabWebauth.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-sanet:authentication/order-config/mab-config/webauth", "")
} else {
- data.IpDhcpSnoopingTrust = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-sanet:authentication/order-config/mab-config/webauth")
}
- } else {
- data.IpDhcpSnoopingTrust = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-ethernet:speed.value-100"); !data.Speed100.IsNull() {
- if value.Exists() {
- data.Speed100 = types.BoolValue(true)
+ if !data.AuthenticationOrderWebauth.IsNull() && !data.AuthenticationOrderWebauth.IsUnknown() {
+ if data.AuthenticationOrderWebauth.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-sanet:authentication/order-config/webauth-config", "")
} else {
- data.Speed100 = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-sanet:authentication/order-config/webauth-config")
}
- } else {
- data.Speed100 = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-ethernet:speed.value-1000"); !data.Speed1000.IsNull() {
- if value.Exists() {
- data.Speed1000 = types.BoolValue(true)
+ if !data.AuthenticationPriorityDot1x.IsNull() && !data.AuthenticationPriorityDot1x.IsUnknown() {
+ if data.AuthenticationPriorityDot1x.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-sanet:authentication/priority-config/dot1x-config", "")
} else {
- data.Speed1000 = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-sanet:authentication/priority-config/dot1x-config")
}
- } else {
- data.Speed1000 = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-ethernet:speed.value-2500"); !data.Speed2500.IsNull() {
- if value.Exists() {
- data.Speed2500 = types.BoolValue(true)
+ if !data.AuthenticationPriorityDot1xMab.IsNull() && !data.AuthenticationPriorityDot1xMab.IsUnknown() {
+ if data.AuthenticationPriorityDot1xMab.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-sanet:authentication/priority-config/dot1x-config/mab", "")
} else {
- data.Speed2500 = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-sanet:authentication/priority-config/dot1x-config/mab")
}
- } else {
- data.Speed2500 = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-ethernet:speed.value-5000"); !data.Speed5000.IsNull() {
- if value.Exists() {
- data.Speed5000 = types.BoolValue(true)
+ if !data.AuthenticationPriorityDot1xWebauth.IsNull() && !data.AuthenticationPriorityDot1xWebauth.IsUnknown() {
+ if data.AuthenticationPriorityDot1xWebauth.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-sanet:authentication/priority-config/dot1x-config/webauth", "")
} else {
- data.Speed5000 = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-sanet:authentication/priority-config/dot1x-config/webauth")
}
- } else {
- data.Speed5000 = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-ethernet:speed.value-10000"); !data.Speed10000.IsNull() {
- if value.Exists() {
- data.Speed10000 = types.BoolValue(true)
+ if !data.AuthenticationPriorityMab.IsNull() && !data.AuthenticationPriorityMab.IsUnknown() {
+ if data.AuthenticationPriorityMab.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-sanet:authentication/priority-config/mab-config", "")
} else {
- data.Speed10000 = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-sanet:authentication/priority-config/mab-config")
}
- } else {
- data.Speed10000 = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-ethernet:speed.value-25000"); !data.Speed25000.IsNull() {
- if value.Exists() {
- data.Speed25000 = types.BoolValue(true)
+ if !data.AuthenticationPriorityMabDot1x.IsNull() && !data.AuthenticationPriorityMabDot1x.IsUnknown() {
+ if data.AuthenticationPriorityMabDot1x.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-sanet:authentication/priority-config/mab-config/dot1x", "")
} else {
- data.Speed25000 = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-sanet:authentication/priority-config/mab-config/dot1x")
}
- } else {
- data.Speed25000 = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-ethernet:speed.value-40000"); !data.Speed40000.IsNull() {
- if value.Exists() {
- data.Speed40000 = types.BoolValue(true)
+ if !data.AuthenticationPriorityMabWebauth.IsNull() && !data.AuthenticationPriorityMabWebauth.IsUnknown() {
+ if data.AuthenticationPriorityMabWebauth.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-sanet:authentication/priority-config/mab-config/webauth", "")
} else {
- data.Speed40000 = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-sanet:authentication/priority-config/mab-config/webauth")
}
- } else {
- data.Speed40000 = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-ethernet:speed.value-100000"); !data.Speed100000.IsNull() {
- if value.Exists() {
- data.Speed100000 = types.BoolValue(true)
+ if !data.AuthenticationPriorityWebauth.IsNull() && !data.AuthenticationPriorityWebauth.IsUnknown() {
+ if data.AuthenticationPriorityWebauth.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-sanet:authentication/priority-config/webauth-config", "")
} else {
- data.Speed100000 = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-sanet:authentication/priority-config/webauth-config")
}
- } else {
- data.Speed100000 = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-ethernet:negotiation.auto"); !data.NegotiationAuto.IsNull() {
- if value.Exists() {
- data.NegotiationAuto = types.BoolValue(value.Bool())
- }
- } else {
- data.NegotiationAuto = types.BoolNull()
+ if !data.AuthenticationPortControl.IsNull() && !data.AuthenticationPortControl.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-sanet:authentication/port-control", data.AuthenticationPortControl.ValueString())
}
- if value := res.Get(prefix + "Cisco-IOS-XE-ethernet:speed.nonegotiate"); !data.SpeedNonegotiate.IsNull() {
- if value.Exists() {
- data.SpeedNonegotiate = types.BoolValue(true)
+ if !data.AuthenticationPeriodic.IsNull() && !data.AuthenticationPeriodic.IsUnknown() {
+ if data.AuthenticationPeriodic.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-sanet:authentication/periodic", "")
} else {
- data.SpeedNonegotiate = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-sanet:authentication/periodic")
}
- } else {
- data.SpeedNonegotiate = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-sanet:authentication.host-mode"); value.Exists() && !data.AuthenticationHostMode.IsNull() {
- data.AuthenticationHostMode = types.StringValue(value.String())
- } else {
- data.AuthenticationHostMode = types.StringNull()
+ if !data.AuthenticationTimerReauthenticate.IsNull() && !data.AuthenticationTimerReauthenticate.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-sanet:authentication/timer/reauthenticate/value-config", strconv.FormatInt(data.AuthenticationTimerReauthenticate.ValueInt64(), 10))
}
- if value := res.Get(prefix + "Cisco-IOS-XE-sanet:authentication.order-config.dot1x-config"); !data.AuthenticationOrderDot1x.IsNull() {
- if value.Exists() {
- data.AuthenticationOrderDot1x = types.BoolValue(true)
+ if !data.AuthenticationTimerReauthenticateServer.IsNull() && !data.AuthenticationTimerReauthenticateServer.IsUnknown() {
+ if data.AuthenticationTimerReauthenticateServer.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-sanet:authentication/timer/reauthenticate/server-config", "")
} else {
- data.AuthenticationOrderDot1x = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-sanet:authentication/timer/reauthenticate/server-config")
}
- } else {
- data.AuthenticationOrderDot1x = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-sanet:authentication.order-config.dot1x-config.mab"); !data.AuthenticationOrderDot1xMab.IsNull() {
- if value.Exists() {
- data.AuthenticationOrderDot1xMab = types.BoolValue(true)
+ if !data.AuthenticationEventServerAliveActionReinitialize.IsNull() && !data.AuthenticationEventServerAliveActionReinitialize.IsUnknown() {
+ if data.AuthenticationEventServerAliveActionReinitialize.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-sanet:authentication/event/server/alive/action/reinitialize", "")
} else {
- data.AuthenticationOrderDot1xMab = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-sanet:authentication/event/server/alive/action/reinitialize")
}
- } else {
- data.AuthenticationOrderDot1xMab = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-sanet:authentication.order-config.dot1x-config.webauth"); !data.AuthenticationOrderDot1xWebauth.IsNull() {
- if value.Exists() {
- data.AuthenticationOrderDot1xWebauth = types.BoolValue(true)
+ if !data.AuthenticationEventServerDeadActionAuthorize.IsNull() && !data.AuthenticationEventServerDeadActionAuthorize.IsUnknown() {
+ if data.AuthenticationEventServerDeadActionAuthorize.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-sanet:authentication/event/server/dead/action/authorize", "")
} else {
- data.AuthenticationOrderDot1xWebauth = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-sanet:authentication/event/server/dead/action/authorize")
}
- } else {
- data.AuthenticationOrderDot1xWebauth = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-sanet:authentication.order-config.mab-config"); !data.AuthenticationOrderMab.IsNull() {
- if value.Exists() {
- data.AuthenticationOrderMab = types.BoolValue(true)
+ if !data.AuthenticationEventServerDeadActionAuthorizeVlan.IsNull() && !data.AuthenticationEventServerDeadActionAuthorizeVlan.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-sanet:authentication/event/server/dead/action/authorize/vlan", strconv.FormatInt(data.AuthenticationEventServerDeadActionAuthorizeVlan.ValueInt64(), 10))
+ }
+ if !data.AuthenticationEventServerDeadActionAuthorizeVoice.IsNull() && !data.AuthenticationEventServerDeadActionAuthorizeVoice.IsUnknown() {
+ if data.AuthenticationEventServerDeadActionAuthorizeVoice.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-sanet:authentication/event/server/dead/action/authorize/voice", "")
} else {
- data.AuthenticationOrderMab = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-sanet:authentication/event/server/dead/action/authorize/voice")
}
- } else {
- data.AuthenticationOrderMab = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-sanet:authentication.order-config.mab-config.dot1x"); !data.AuthenticationOrderMabDot1x.IsNull() {
- if value.Exists() {
- data.AuthenticationOrderMabDot1x = types.BoolValue(true)
+ if !data.AuthenticationEventServerDeadActionReinitializeVlan.IsNull() && !data.AuthenticationEventServerDeadActionReinitializeVlan.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-sanet:authentication/event/server/dead/action/reinitialize/vlan", strconv.FormatInt(data.AuthenticationEventServerDeadActionReinitializeVlan.ValueInt64(), 10))
+ }
+ if !data.AuthenticationEventFailActionAuthorizeVlan.IsNull() && !data.AuthenticationEventFailActionAuthorizeVlan.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-sanet:authentication/event/fail-config/action/authorize/vlan", strconv.FormatInt(data.AuthenticationEventFailActionAuthorizeVlan.ValueInt64(), 10))
+ }
+ if !data.AuthenticationEventFailActionNextMethod.IsNull() && !data.AuthenticationEventFailActionNextMethod.IsUnknown() {
+ if data.AuthenticationEventFailActionNextMethod.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-sanet:authentication/event/fail-config/action/next-method", "")
} else {
- data.AuthenticationOrderMabDot1x = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-sanet:authentication/event/fail-config/action/next-method")
}
- } else {
- data.AuthenticationOrderMabDot1x = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-sanet:authentication.order-config.mab-config.webauth"); !data.AuthenticationOrderMabWebauth.IsNull() {
- if value.Exists() {
- data.AuthenticationOrderMabWebauth = types.BoolValue(true)
+ if !data.AuthenticationEventNoResponseActionAuthorizeVlan.IsNull() && !data.AuthenticationEventNoResponseActionAuthorizeVlan.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-sanet:authentication/event/no-response/action/authorize/vlan", strconv.FormatInt(data.AuthenticationEventNoResponseActionAuthorizeVlan.ValueInt64(), 10))
+ }
+ if !data.AuthenticationEventLinksecFailActionNextMethod.IsNull() && !data.AuthenticationEventLinksecFailActionNextMethod.IsUnknown() {
+ if data.AuthenticationEventLinksecFailActionNextMethod.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-sanet:authentication/event/linksec/fail/action/next-method", "")
} else {
- data.AuthenticationOrderMabWebauth = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-sanet:authentication/event/linksec/fail/action/next-method")
}
- } else {
- data.AuthenticationOrderMabWebauth = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-sanet:authentication.order-config.webauth-config"); !data.AuthenticationOrderWebauth.IsNull() {
- if value.Exists() {
- data.AuthenticationOrderWebauth = types.BoolValue(true)
+ if !data.Mab.IsNull() && !data.Mab.IsUnknown() {
+ if data.Mab.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-sanet:mab", "")
} else {
- data.AuthenticationOrderWebauth = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-sanet:mab")
}
- } else {
- data.AuthenticationOrderWebauth = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-sanet:authentication.priority-config.dot1x-config"); !data.AuthenticationPriorityDot1x.IsNull() {
- if value.Exists() {
- data.AuthenticationPriorityDot1x = types.BoolValue(true)
+ if !data.MabEap.IsNull() && !data.MabEap.IsUnknown() {
+ if data.MabEap.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-sanet:mab/eap", "")
} else {
- data.AuthenticationPriorityDot1x = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-sanet:mab/eap")
}
- } else {
- data.AuthenticationPriorityDot1x = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-sanet:authentication.priority-config.dot1x-config.mab"); !data.AuthenticationPriorityDot1xMab.IsNull() {
- if value.Exists() {
- data.AuthenticationPriorityDot1xMab = types.BoolValue(true)
- } else {
- data.AuthenticationPriorityDot1xMab = types.BoolValue(false)
+ if !data.Dot1xPae.IsNull() && !data.Dot1xPae.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-dot1x:dot1x/pae", data.Dot1xPae.ValueString())
+ }
+ if !data.Dot1xTimeoutAuthPeriod.IsNull() && !data.Dot1xTimeoutAuthPeriod.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-dot1x:dot1x/timeout/auth-period", strconv.FormatInt(data.Dot1xTimeoutAuthPeriod.ValueInt64(), 10))
+ }
+ if !data.Dot1xTimeoutHeldPeriod.IsNull() && !data.Dot1xTimeoutHeldPeriod.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-dot1x:dot1x/timeout/held-period", strconv.FormatInt(data.Dot1xTimeoutHeldPeriod.ValueInt64(), 10))
+ }
+ if !data.Dot1xTimeoutQuietPeriod.IsNull() && !data.Dot1xTimeoutQuietPeriod.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-dot1x:dot1x/timeout/quiet-period", strconv.FormatInt(data.Dot1xTimeoutQuietPeriod.ValueInt64(), 10))
+ }
+ if !data.Dot1xTimeoutRatelimitPeriod.IsNull() && !data.Dot1xTimeoutRatelimitPeriod.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-dot1x:dot1x/timeout/ratelimit-period", strconv.FormatInt(data.Dot1xTimeoutRatelimitPeriod.ValueInt64(), 10))
+ }
+ if !data.Dot1xTimeoutServerTimeout.IsNull() && !data.Dot1xTimeoutServerTimeout.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-dot1x:dot1x/timeout/server-timeout", strconv.FormatInt(data.Dot1xTimeoutServerTimeout.ValueInt64(), 10))
+ }
+ if !data.Dot1xTimeoutStartPeriod.IsNull() && !data.Dot1xTimeoutStartPeriod.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-dot1x:dot1x/timeout/start-period", strconv.FormatInt(data.Dot1xTimeoutStartPeriod.ValueInt64(), 10))
+ }
+ if !data.Dot1xTimeoutSuppTimeout.IsNull() && !data.Dot1xTimeoutSuppTimeout.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-dot1x:dot1x/timeout/supp-timeout", strconv.FormatInt(data.Dot1xTimeoutSuppTimeout.ValueInt64(), 10))
+ }
+ if !data.Dot1xTimeoutTxPeriod.IsNull() && !data.Dot1xTimeoutTxPeriod.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-dot1x:dot1x/timeout/tx-period", strconv.FormatInt(data.Dot1xTimeoutTxPeriod.ValueInt64(), 10))
+ }
+ if !data.Dot1xMaxReq.IsNull() && !data.Dot1xMaxReq.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-dot1x:dot1x/max-req", strconv.FormatInt(data.Dot1xMaxReq.ValueInt64(), 10))
+ }
+ if !data.Dot1xMaxReauthReq.IsNull() && !data.Dot1xMaxReauthReq.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-dot1x:dot1x/max-reauth-req", strconv.FormatInt(data.Dot1xMaxReauthReq.ValueInt64(), 10))
+ }
+ if !data.ServicePolicyInput.IsNull() && !data.ServicePolicyInput.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-policy:service-policy/input", data.ServicePolicyInput.ValueString())
+ }
+ if !data.ServicePolicyOutput.IsNull() && !data.ServicePolicyOutput.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-policy:service-policy/output", data.ServicePolicyOutput.ValueString())
+ }
+ if len(data.IpFlowMonitors) > 0 {
+ for _, item := range data.IpFlowMonitors {
+ cBody := netconf.Body{}
+ if !item.Name.IsNull() && !item.Name.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "name", item.Name.ValueString())
+ }
+ if !item.Direction.IsNull() && !item.Direction.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "direction", item.Direction.ValueString())
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/ip/Cisco-IOS-XE-flow:flow/monitor-new", cBody.Res())
}
- } else {
- data.AuthenticationPriorityDot1xMab = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-sanet:authentication.priority-config.dot1x-config.webauth"); !data.AuthenticationPriorityDot1xWebauth.IsNull() {
- if value.Exists() {
- data.AuthenticationPriorityDot1xWebauth = types.BoolValue(true)
+ if !data.LoadInterval.IsNull() && !data.LoadInterval.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/load-interval", strconv.FormatInt(data.LoadInterval.ValueInt64(), 10))
+ }
+ if !data.SnmpTrapLinkStatus.IsNull() && !data.SnmpTrapLinkStatus.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:snmp/trap/link-status", data.SnmpTrapLinkStatus.ValueBool())
+ }
+ if !data.LoggingEventLinkStatusEnable.IsNull() && !data.LoggingEventLinkStatusEnable.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/logging/event/link-status-enable", data.LoggingEventLinkStatusEnable.ValueBool())
+ }
+ if !data.IpNbarProtocolDiscovery.IsNull() && !data.IpNbarProtocolDiscovery.IsUnknown() {
+ if data.IpNbarProtocolDiscovery.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ip/Cisco-IOS-XE-nbar:nbar/protocol-discovery", "")
} else {
- data.AuthenticationPriorityDot1xWebauth = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/ip/Cisco-IOS-XE-nbar:nbar/protocol-discovery")
}
- } else {
- data.AuthenticationPriorityDot1xWebauth = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-sanet:authentication.priority-config.mab-config"); !data.AuthenticationPriorityMab.IsNull() {
- if value.Exists() {
- data.AuthenticationPriorityMab = types.BoolValue(true)
+ if !data.DeviceTracking.IsNull() && !data.DeviceTracking.IsUnknown() {
+ if data.DeviceTracking.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-switch:device-tracking", "")
} else {
- data.AuthenticationPriorityMab = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-switch:device-tracking")
}
- } else {
- data.AuthenticationPriorityMab = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-sanet:authentication.priority-config.mab-config.dot1x"); !data.AuthenticationPriorityMabDot1x.IsNull() {
- if value.Exists() {
- data.AuthenticationPriorityMabDot1x = types.BoolValue(true)
- } else {
- data.AuthenticationPriorityMabDot1x = types.BoolValue(false)
+ if len(data.DeviceTrackingAttachedPolicies) > 0 {
+ for _, item := range data.DeviceTrackingAttachedPolicies {
+ cBody := netconf.Body{}
+ if !item.Name.IsNull() && !item.Name.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "attach-policy", item.Name.ValueString())
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-switch:device-tracking/attached-policies", cBody.Res())
}
- } else {
- data.AuthenticationPriorityMabDot1x = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-sanet:authentication.priority-config.mab-config.webauth"); !data.AuthenticationPriorityMabWebauth.IsNull() {
- if value.Exists() {
- data.AuthenticationPriorityMabWebauth = types.BoolValue(true)
+ if !data.CdpEnable.IsNull() && !data.CdpEnable.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-cdp:cdp/enable", data.CdpEnable.ValueBool())
+ }
+ if !data.CdpTlvApp.IsNull() && !data.CdpTlvApp.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-cdp:cdp/tlv/default-wrp/app", data.CdpTlvApp.ValueBool())
+ }
+ if !data.CdpTlvLocation.IsNull() && !data.CdpTlvLocation.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-cdp:cdp/tlv/location-config", data.CdpTlvLocation.ValueBool())
+ }
+ if !data.CdpTlvServerLocation.IsNull() && !data.CdpTlvServerLocation.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-cdp:cdp/tlv/server-location-config", data.CdpTlvServerLocation.ValueBool())
+ }
+ if !data.IpNatInside.IsNull() && !data.IpNatInside.IsUnknown() {
+ if data.IpNatInside.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ip/Cisco-IOS-XE-nat:nat/inside", "")
} else {
- data.AuthenticationPriorityMabWebauth = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/ip/Cisco-IOS-XE-nat:nat/inside")
}
- } else {
- data.AuthenticationPriorityMabWebauth = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-sanet:authentication.priority-config.webauth-config"); !data.AuthenticationPriorityWebauth.IsNull() {
- if value.Exists() {
- data.AuthenticationPriorityWebauth = types.BoolValue(true)
+ if !data.IpNatOutside.IsNull() && !data.IpNatOutside.IsUnknown() {
+ if data.IpNatOutside.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ip/Cisco-IOS-XE-nat:nat/outside", "")
} else {
- data.AuthenticationPriorityWebauth = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/ip/Cisco-IOS-XE-nat:nat/outside")
}
+ }
+ bodyString, err := body.String()
+ if err != nil {
+ tflog.Error(ctx, fmt.Sprintf("Error converting body to string: %s", err))
+ }
+ return bodyString
+}
+
+// End of section. //template:end toBodyXML
+
+// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBody
+
+func (data *InterfaceEthernet) updateFromBody(ctx context.Context, res gjson.Result) {
+ prefix := helpers.LastElement(data.getPath()) + "."
+ if res.Get(helpers.LastElement(data.getPath())).IsArray() {
+ prefix += "0."
+ }
+ if value := res.Get(prefix + "name"); value.Exists() && !data.Name.IsNull() {
+ data.Name = types.StringValue(value.String())
} else {
- data.AuthenticationPriorityWebauth = types.BoolNull()
+ data.Name = types.StringNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-sanet:authentication.port-control"); value.Exists() && !data.AuthenticationPortControl.IsNull() {
- data.AuthenticationPortControl = types.StringValue(value.String())
+ if value := res.Get(prefix + "media-type"); value.Exists() && !data.MediaType.IsNull() {
+ data.MediaType = types.StringValue(value.String())
} else {
- data.AuthenticationPortControl = types.StringNull()
+ data.MediaType = types.StringNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-sanet:authentication.periodic"); !data.AuthenticationPeriodic.IsNull() {
- if value.Exists() {
- data.AuthenticationPeriodic = types.BoolValue(true)
- } else {
- data.AuthenticationPeriodic = types.BoolValue(false)
- }
+ if value := res.Get(prefix + "mtu"); value.Exists() && !data.Mtu.IsNull() {
+ data.Mtu = types.Int64Value(value.Int())
} else {
- data.AuthenticationPeriodic = types.BoolNull()
+ data.Mtu = types.Int64Null()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-sanet:authentication.timer.reauthenticate.value-config"); value.Exists() && !data.AuthenticationTimerReauthenticate.IsNull() {
- data.AuthenticationTimerReauthenticate = types.Int64Value(value.Int())
+ if value := res.Get(prefix + "bandwidth.kilobits"); value.Exists() && !data.Bandwidth.IsNull() {
+ data.Bandwidth = types.Int64Value(value.Int())
} else {
- data.AuthenticationTimerReauthenticate = types.Int64Null()
+ data.Bandwidth = types.Int64Null()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-sanet:authentication.timer.reauthenticate.server-config"); !data.AuthenticationTimerReauthenticateServer.IsNull() {
+ if value := res.Get(prefix + "switchport-conf.switchport"); !data.Switchport.IsNull() {
if value.Exists() {
- data.AuthenticationTimerReauthenticateServer = types.BoolValue(true)
- } else {
- data.AuthenticationTimerReauthenticateServer = types.BoolValue(false)
+ data.Switchport = types.BoolValue(value.Bool())
}
} else {
- data.AuthenticationTimerReauthenticateServer = types.BoolNull()
+ data.Switchport = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-sanet:authentication.event.server.alive.action.reinitialize"); !data.AuthenticationEventServerAliveActionReinitialize.IsNull() {
+ if value := res.Get(prefix + "description"); value.Exists() && !data.Description.IsNull() {
+ data.Description = types.StringValue(value.String())
+ } else {
+ data.Description = types.StringNull()
+ }
+ if value := res.Get(prefix + "shutdown"); !data.Shutdown.IsNull() {
if value.Exists() {
- data.AuthenticationEventServerAliveActionReinitialize = types.BoolValue(true)
+ data.Shutdown = types.BoolValue(true)
} else {
- data.AuthenticationEventServerAliveActionReinitialize = types.BoolValue(false)
+ data.Shutdown = types.BoolValue(false)
}
} else {
- data.AuthenticationEventServerAliveActionReinitialize = types.BoolNull()
+ data.Shutdown = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-sanet:authentication.event.server.dead.action.authorize"); !data.AuthenticationEventServerDeadActionAuthorize.IsNull() {
+ if value := res.Get(prefix + "ip.proxy-arp"); !data.IpProxyArp.IsNull() {
if value.Exists() {
- data.AuthenticationEventServerDeadActionAuthorize = types.BoolValue(true)
- } else {
- data.AuthenticationEventServerDeadActionAuthorize = types.BoolValue(false)
+ data.IpProxyArp = types.BoolValue(value.Bool())
}
} else {
- data.AuthenticationEventServerDeadActionAuthorize = types.BoolNull()
+ data.IpProxyArp = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-sanet:authentication.event.server.dead.action.authorize.vlan"); value.Exists() && !data.AuthenticationEventServerDeadActionAuthorizeVlan.IsNull() {
- data.AuthenticationEventServerDeadActionAuthorizeVlan = types.Int64Value(value.Int())
+ if value := res.Get(prefix + "ip.redirects"); !data.IpRedirects.IsNull() {
+ if value.Exists() {
+ data.IpRedirects = types.BoolValue(value.Bool())
+ }
} else {
- data.AuthenticationEventServerDeadActionAuthorizeVlan = types.Int64Null()
+ data.IpRedirects = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-sanet:authentication.event.server.dead.action.authorize.voice"); !data.AuthenticationEventServerDeadActionAuthorizeVoice.IsNull() {
+ if value := res.Get(prefix + "ip.Cisco-IOS-XE-icmp:unreachables"); !data.IpUnreachables.IsNull() {
if value.Exists() {
- data.AuthenticationEventServerDeadActionAuthorizeVoice = types.BoolValue(true)
- } else {
- data.AuthenticationEventServerDeadActionAuthorizeVoice = types.BoolValue(false)
+ data.IpUnreachables = types.BoolValue(value.Bool())
}
} else {
- data.AuthenticationEventServerDeadActionAuthorizeVoice = types.BoolNull()
+ data.IpUnreachables = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-sanet:authentication.event.server.dead.action.reinitialize.vlan"); value.Exists() && !data.AuthenticationEventServerDeadActionReinitializeVlan.IsNull() {
- data.AuthenticationEventServerDeadActionReinitializeVlan = types.Int64Value(value.Int())
+ if value := res.Get(prefix + "vrf.forwarding"); value.Exists() && !data.VrfForwarding.IsNull() {
+ data.VrfForwarding = types.StringValue(value.String())
} else {
- data.AuthenticationEventServerDeadActionReinitializeVlan = types.Int64Null()
+ data.VrfForwarding = types.StringNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-sanet:authentication.event.fail-config.action.authorize.vlan"); value.Exists() && !data.AuthenticationEventFailActionAuthorizeVlan.IsNull() {
- data.AuthenticationEventFailActionAuthorizeVlan = types.Int64Value(value.Int())
+ if value := res.Get(prefix + "ip.address.primary.address"); value.Exists() && !data.Ipv4Address.IsNull() {
+ data.Ipv4Address = types.StringValue(value.String())
} else {
- data.AuthenticationEventFailActionAuthorizeVlan = types.Int64Null()
+ data.Ipv4Address = types.StringNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-sanet:authentication.event.fail-config.action.next-method"); !data.AuthenticationEventFailActionNextMethod.IsNull() {
- if value.Exists() {
- data.AuthenticationEventFailActionNextMethod = types.BoolValue(true)
- } else {
- data.AuthenticationEventFailActionNextMethod = types.BoolValue(false)
- }
+ if value := res.Get(prefix + "ip.address.primary.mask"); value.Exists() && !data.Ipv4AddressMask.IsNull() {
+ data.Ipv4AddressMask = types.StringValue(value.String())
} else {
- data.AuthenticationEventFailActionNextMethod = types.BoolNull()
+ data.Ipv4AddressMask = types.StringNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-sanet:authentication.event.no-response.action.authorize.vlan"); value.Exists() && !data.AuthenticationEventNoResponseActionAuthorizeVlan.IsNull() {
- data.AuthenticationEventNoResponseActionAuthorizeVlan = types.Int64Value(value.Int())
+ if value := res.Get(prefix + "ip.unnumbered"); value.Exists() && !data.Unnumbered.IsNull() {
+ data.Unnumbered = types.StringValue(value.String())
} else {
- data.AuthenticationEventNoResponseActionAuthorizeVlan = types.Int64Null()
+ data.Unnumbered = types.StringNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-sanet:authentication.event.linksec.fail.action.next-method"); !data.AuthenticationEventLinksecFailActionNextMethod.IsNull() {
- if value.Exists() {
- data.AuthenticationEventLinksecFailActionNextMethod = types.BoolValue(true)
- } else {
- data.AuthenticationEventLinksecFailActionNextMethod = types.BoolValue(false)
- }
+ if value := res.Get(prefix + "encapsulation.dot1Q.vlan-id"); value.Exists() && !data.EncapsulationDot1qVlanId.IsNull() {
+ data.EncapsulationDot1qVlanId = types.Int64Value(value.Int())
} else {
- data.AuthenticationEventLinksecFailActionNextMethod = types.BoolNull()
+ data.EncapsulationDot1qVlanId = types.Int64Null()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-sanet:mab"); !data.Mab.IsNull() {
+ if value := res.Get(prefix + "Cisco-IOS-XE-ethernet:channel-group.number"); value.Exists() && !data.ChannelGroupNumber.IsNull() {
+ data.ChannelGroupNumber = types.Int64Value(value.Int())
+ } else {
+ data.ChannelGroupNumber = types.Int64Null()
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-ethernet:channel-group.mode"); value.Exists() && !data.ChannelGroupMode.IsNull() {
+ data.ChannelGroupMode = types.StringValue(value.String())
+ } else {
+ data.ChannelGroupMode = types.StringNull()
+ }
+ if value := res.Get(prefix + "ip.dhcp.Cisco-IOS-XE-dhcp:relay.source-interface"); value.Exists() && !data.IpDhcpRelaySourceInterface.IsNull() {
+ data.IpDhcpRelaySourceInterface = types.StringValue(value.String())
+ } else {
+ data.IpDhcpRelaySourceInterface = types.StringNull()
+ }
+ if value := res.Get(prefix + "ip.access-group.in.acl.in"); !data.IpAccessGroupInEnable.IsNull() {
if value.Exists() {
- data.Mab = types.BoolValue(true)
+ data.IpAccessGroupInEnable = types.BoolValue(true)
} else {
- data.Mab = types.BoolValue(false)
+ data.IpAccessGroupInEnable = types.BoolValue(false)
}
} else {
- data.Mab = types.BoolNull()
+ data.IpAccessGroupInEnable = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-sanet:mab.eap"); !data.MabEap.IsNull() {
+ if value := res.Get(prefix + "ip.access-group.in.acl.acl-name"); value.Exists() && !data.IpAccessGroupIn.IsNull() {
+ data.IpAccessGroupIn = types.StringValue(value.String())
+ } else {
+ data.IpAccessGroupIn = types.StringNull()
+ }
+ if value := res.Get(prefix + "ip.access-group.out.acl.out"); !data.IpAccessGroupOutEnable.IsNull() {
if value.Exists() {
- data.MabEap = types.BoolValue(true)
+ data.IpAccessGroupOutEnable = types.BoolValue(true)
} else {
- data.MabEap = types.BoolValue(false)
+ data.IpAccessGroupOutEnable = types.BoolValue(false)
}
} else {
- data.MabEap = types.BoolNull()
+ data.IpAccessGroupOutEnable = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-dot1x:dot1x.pae"); value.Exists() && !data.Dot1xPae.IsNull() {
- data.Dot1xPae = types.StringValue(value.String())
+ if value := res.Get(prefix + "ip.access-group.out.acl.acl-name"); value.Exists() && !data.IpAccessGroupOut.IsNull() {
+ data.IpAccessGroupOut = types.StringValue(value.String())
} else {
- data.Dot1xPae = types.StringNull()
+ data.IpAccessGroupOut = types.StringNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-dot1x:dot1x.timeout.auth-period"); value.Exists() && !data.Dot1xTimeoutAuthPeriod.IsNull() {
- data.Dot1xTimeoutAuthPeriod = types.Int64Value(value.Int())
+ if value := res.Get(prefix + "Cisco-IOS-XE-spanning-tree:spanning-tree.guard"); value.Exists() && !data.SpanningTreeGuard.IsNull() {
+ data.SpanningTreeGuard = types.StringValue(value.String())
} else {
- data.Dot1xTimeoutAuthPeriod = types.Int64Null()
+ data.SpanningTreeGuard = types.StringNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-dot1x:dot1x.timeout.held-period"); value.Exists() && !data.Dot1xTimeoutHeldPeriod.IsNull() {
- data.Dot1xTimeoutHeldPeriod = types.Int64Value(value.Int())
+ if value := res.Get(prefix + "Cisco-IOS-XE-switch:auto.qos.classify"); !data.AutoQosClassify.IsNull() {
+ if value.Exists() {
+ data.AutoQosClassify = types.BoolValue(true)
+ } else {
+ data.AutoQosClassify = types.BoolValue(false)
+ }
} else {
- data.Dot1xTimeoutHeldPeriod = types.Int64Null()
+ data.AutoQosClassify = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-dot1x:dot1x.timeout.quiet-period"); value.Exists() && !data.Dot1xTimeoutQuietPeriod.IsNull() {
- data.Dot1xTimeoutQuietPeriod = types.Int64Value(value.Int())
+ if value := res.Get(prefix + "Cisco-IOS-XE-switch:auto.qos.classify.police"); !data.AutoQosClassifyPolice.IsNull() {
+ if value.Exists() {
+ data.AutoQosClassifyPolice = types.BoolValue(true)
+ } else {
+ data.AutoQosClassifyPolice = types.BoolValue(false)
+ }
} else {
- data.Dot1xTimeoutQuietPeriod = types.Int64Null()
+ data.AutoQosClassifyPolice = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-dot1x:dot1x.timeout.ratelimit-period"); value.Exists() && !data.Dot1xTimeoutRatelimitPeriod.IsNull() {
- data.Dot1xTimeoutRatelimitPeriod = types.Int64Value(value.Int())
+ if value := res.Get(prefix + "Cisco-IOS-XE-switch:auto.qos.trust"); !data.AutoQosTrust.IsNull() {
+ if value.Exists() {
+ data.AutoQosTrust = types.BoolValue(true)
+ } else {
+ data.AutoQosTrust = types.BoolValue(false)
+ }
} else {
- data.Dot1xTimeoutRatelimitPeriod = types.Int64Null()
+ data.AutoQosTrust = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-dot1x:dot1x.timeout.server-timeout"); value.Exists() && !data.Dot1xTimeoutServerTimeout.IsNull() {
- data.Dot1xTimeoutServerTimeout = types.Int64Value(value.Int())
+ if value := res.Get(prefix + "Cisco-IOS-XE-switch:auto.qos.trust.cos"); !data.AutoQosTrustCos.IsNull() {
+ if value.Exists() {
+ data.AutoQosTrustCos = types.BoolValue(true)
+ } else {
+ data.AutoQosTrustCos = types.BoolValue(false)
+ }
} else {
- data.Dot1xTimeoutServerTimeout = types.Int64Null()
+ data.AutoQosTrustCos = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-dot1x:dot1x.timeout.start-period"); value.Exists() && !data.Dot1xTimeoutStartPeriod.IsNull() {
- data.Dot1xTimeoutStartPeriod = types.Int64Value(value.Int())
+ if value := res.Get(prefix + "Cisco-IOS-XE-switch:auto.qos.trust.dscp"); !data.AutoQosTrustDscp.IsNull() {
+ if value.Exists() {
+ data.AutoQosTrustDscp = types.BoolValue(true)
+ } else {
+ data.AutoQosTrustDscp = types.BoolValue(false)
+ }
} else {
- data.Dot1xTimeoutStartPeriod = types.Int64Null()
+ data.AutoQosTrustDscp = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-dot1x:dot1x.timeout.supp-timeout"); value.Exists() && !data.Dot1xTimeoutSuppTimeout.IsNull() {
- data.Dot1xTimeoutSuppTimeout = types.Int64Value(value.Int())
+ if value := res.Get(prefix + "Cisco-IOS-XE-switch:auto.qos.video.cts"); !data.AutoQosVideoCts.IsNull() {
+ if value.Exists() {
+ data.AutoQosVideoCts = types.BoolValue(true)
+ } else {
+ data.AutoQosVideoCts = types.BoolValue(false)
+ }
} else {
- data.Dot1xTimeoutSuppTimeout = types.Int64Null()
+ data.AutoQosVideoCts = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-dot1x:dot1x.timeout.tx-period"); value.Exists() && !data.Dot1xTimeoutTxPeriod.IsNull() {
- data.Dot1xTimeoutTxPeriod = types.Int64Value(value.Int())
+ if value := res.Get(prefix + "Cisco-IOS-XE-switch:auto.qos.video.ip-camera"); !data.AutoQosVideoIpCamera.IsNull() {
+ if value.Exists() {
+ data.AutoQosVideoIpCamera = types.BoolValue(true)
+ } else {
+ data.AutoQosVideoIpCamera = types.BoolValue(false)
+ }
} else {
- data.Dot1xTimeoutTxPeriod = types.Int64Null()
+ data.AutoQosVideoIpCamera = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-dot1x:dot1x.max-req"); value.Exists() && !data.Dot1xMaxReq.IsNull() {
- data.Dot1xMaxReq = types.Int64Value(value.Int())
+ if value := res.Get(prefix + "Cisco-IOS-XE-switch:auto.qos.video.media-player"); !data.AutoQosVideoMediaPlayer.IsNull() {
+ if value.Exists() {
+ data.AutoQosVideoMediaPlayer = types.BoolValue(true)
+ } else {
+ data.AutoQosVideoMediaPlayer = types.BoolValue(false)
+ }
} else {
- data.Dot1xMaxReq = types.Int64Null()
+ data.AutoQosVideoMediaPlayer = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-dot1x:dot1x.max-reauth-req"); value.Exists() && !data.Dot1xMaxReauthReq.IsNull() {
- data.Dot1xMaxReauthReq = types.Int64Value(value.Int())
+ if value := res.Get(prefix + "Cisco-IOS-XE-switch:auto.qos.voip"); !data.AutoQosVoip.IsNull() {
+ if value.Exists() {
+ data.AutoQosVoip = types.BoolValue(true)
+ } else {
+ data.AutoQosVoip = types.BoolValue(false)
+ }
} else {
- data.Dot1xMaxReauthReq = types.Int64Null()
+ data.AutoQosVoip = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-policy:service-policy.input"); value.Exists() && !data.ServicePolicyInput.IsNull() {
- data.ServicePolicyInput = types.StringValue(value.String())
+ if value := res.Get(prefix + "Cisco-IOS-XE-switch:auto.qos.voip.cisco-phone"); !data.AutoQosVoipCiscoPhone.IsNull() {
+ if value.Exists() {
+ data.AutoQosVoipCiscoPhone = types.BoolValue(true)
+ } else {
+ data.AutoQosVoipCiscoPhone = types.BoolValue(false)
+ }
} else {
- data.ServicePolicyInput = types.StringNull()
+ data.AutoQosVoipCiscoPhone = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-policy:service-policy.output"); value.Exists() && !data.ServicePolicyOutput.IsNull() {
- data.ServicePolicyOutput = types.StringValue(value.String())
+ if value := res.Get(prefix + "Cisco-IOS-XE-switch:auto.qos.voip.cisco-softphone"); !data.AutoQosVoipCiscoSoftphone.IsNull() {
+ if value.Exists() {
+ data.AutoQosVoipCiscoSoftphone = types.BoolValue(true)
+ } else {
+ data.AutoQosVoipCiscoSoftphone = types.BoolValue(false)
+ }
} else {
- data.ServicePolicyOutput = types.StringNull()
+ data.AutoQosVoipCiscoSoftphone = types.BoolNull()
}
- for i := range data.IpFlowMonitors {
- keys := [...]string{"name", "direction"}
- keyValues := [...]string{data.IpFlowMonitors[i].Name.ValueString(), data.IpFlowMonitors[i].Direction.ValueString()}
+ if value := res.Get(prefix + "Cisco-IOS-XE-switch:auto.qos.voip.trust"); !data.AutoQosVoipTrust.IsNull() {
+ if value.Exists() {
+ data.AutoQosVoipTrust = types.BoolValue(true)
+ } else {
+ data.AutoQosVoipTrust = types.BoolValue(false)
+ }
+ } else {
+ data.AutoQosVoipTrust = types.BoolNull()
+ }
+ if value := res.Get(prefix + "trust.device"); value.Exists() && !data.TrustDevice.IsNull() {
+ data.TrustDevice = types.StringValue(value.String())
+ } else {
+ data.TrustDevice = types.StringNull()
+ }
+ for i := range data.HelperAddresses {
+ keys := [...]string{"address"}
+ keyValues := [...]string{data.HelperAddresses[i].Address.ValueString()}
var r gjson.Result
- res.Get(prefix + "ip.Cisco-IOS-XE-flow:flow.monitor-new").ForEach(
+ res.Get(prefix + "ip.helper-address").ForEach(
func(_, v gjson.Result) bool {
found := false
for ik := range keys {
@@ -1983,60 +1980,32 @@ func (data *InterfaceEthernet) updateFromBody(ctx context.Context, res gjson.Res
return true
},
)
- if value := r.Get("name"); value.Exists() && !data.IpFlowMonitors[i].Name.IsNull() {
- data.IpFlowMonitors[i].Name = types.StringValue(value.String())
- } else {
- data.IpFlowMonitors[i].Name = types.StringNull()
- }
- if value := r.Get("direction"); value.Exists() && !data.IpFlowMonitors[i].Direction.IsNull() {
- data.IpFlowMonitors[i].Direction = types.StringValue(value.String())
+ if value := r.Get("address"); value.Exists() && !data.HelperAddresses[i].Address.IsNull() {
+ data.HelperAddresses[i].Address = types.StringValue(value.String())
} else {
- data.IpFlowMonitors[i].Direction = types.StringNull()
- }
- }
- if value := res.Get(prefix + "load-interval"); value.Exists() && !data.LoadInterval.IsNull() {
- data.LoadInterval = types.Int64Value(value.Int())
- } else {
- data.LoadInterval = types.Int64Null()
- }
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:snmp.trap.link-status"); !data.SnmpTrapLinkStatus.IsNull() {
- if value.Exists() {
- data.SnmpTrapLinkStatus = types.BoolValue(value.Bool())
- }
- } else {
- data.SnmpTrapLinkStatus = types.BoolNull()
- }
- if value := res.Get(prefix + "logging.event.link-status-enable"); !data.LoggingEventLinkStatusEnable.IsNull() {
- if value.Exists() {
- data.LoggingEventLinkStatusEnable = types.BoolValue(value.Bool())
+ data.HelperAddresses[i].Address = types.StringNull()
}
- } else {
- data.LoggingEventLinkStatusEnable = types.BoolNull()
- }
- if value := res.Get(prefix + "ip.Cisco-IOS-XE-nbar:nbar.protocol-discovery"); !data.IpNbarProtocolDiscovery.IsNull() {
- if value.Exists() {
- data.IpNbarProtocolDiscovery = types.BoolValue(true)
+ if value := r.Get("global"); !data.HelperAddresses[i].Global.IsNull() {
+ if value.Exists() {
+ data.HelperAddresses[i].Global = types.BoolValue(true)
+ } else {
+ data.HelperAddresses[i].Global = types.BoolValue(false)
+ }
} else {
- data.IpNbarProtocolDiscovery = types.BoolValue(false)
+ data.HelperAddresses[i].Global = types.BoolNull()
}
- } else {
- data.IpNbarProtocolDiscovery = types.BoolNull()
- }
- if value := res.Get(prefix + "Cisco-IOS-XE-switch:device-tracking"); !data.DeviceTracking.IsNull() {
- if value.Exists() {
- data.DeviceTracking = types.BoolValue(true)
+ if value := r.Get("vrf"); value.Exists() && !data.HelperAddresses[i].Vrf.IsNull() {
+ data.HelperAddresses[i].Vrf = types.StringValue(value.String())
} else {
- data.DeviceTracking = types.BoolValue(false)
+ data.HelperAddresses[i].Vrf = types.StringNull()
}
- } else {
- data.DeviceTracking = types.BoolNull()
}
- for i := range data.DeviceTrackingAttachedPolicies {
- keys := [...]string{"attach-policy"}
- keyValues := [...]string{data.DeviceTrackingAttachedPolicies[i].Name.ValueString()}
+ for i := range data.SourceTemplate {
+ keys := [...]string{"template-name"}
+ keyValues := [...]string{data.SourceTemplate[i].TemplateName.ValueString()}
var r gjson.Result
- res.Get(prefix + "Cisco-IOS-XE-switch:device-tracking.attached-policies").ForEach(
+ res.Get(prefix + "source.template.template-name").ForEach(
func(_, v gjson.Result) bool {
found := false
for ik := range keys {
@@ -2054,1359 +2023,5628 @@ func (data *InterfaceEthernet) updateFromBody(ctx context.Context, res gjson.Res
return true
},
)
- if value := r.Get("attach-policy"); value.Exists() && !data.DeviceTrackingAttachedPolicies[i].Name.IsNull() {
- data.DeviceTrackingAttachedPolicies[i].Name = types.StringValue(value.String())
+ if value := r.Get("template-name"); value.Exists() && !data.SourceTemplate[i].TemplateName.IsNull() {
+ data.SourceTemplate[i].TemplateName = types.StringValue(value.String())
} else {
- data.DeviceTrackingAttachedPolicies[i].Name = types.StringNull()
- }
- }
- if value := res.Get(prefix + "Cisco-IOS-XE-cdp:cdp.enable"); !data.CdpEnable.IsNull() {
- if value.Exists() {
- data.CdpEnable = types.BoolValue(value.Bool())
+ data.SourceTemplate[i].TemplateName = types.StringNull()
+ }
+ if value := r.Get("merge"); !data.SourceTemplate[i].Merge.IsNull() {
+ if value.Exists() {
+ data.SourceTemplate[i].Merge = types.BoolValue(true)
+ } else {
+ data.SourceTemplate[i].Merge = types.BoolValue(false)
+ }
+ } else {
+ data.SourceTemplate[i].Merge = types.BoolNull()
}
- } else {
- data.CdpEnable = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-cdp:cdp.tlv.default-wrp.app"); !data.CdpTlvApp.IsNull() {
+ if value := res.Get(prefix + "bfd.Cisco-IOS-XE-bfd:template"); value.Exists() && !data.BfdTemplate.IsNull() {
+ data.BfdTemplate = types.StringValue(value.String())
+ } else {
+ data.BfdTemplate = types.StringNull()
+ }
+ if value := res.Get(prefix + "bfd.Cisco-IOS-XE-bfd:enable"); !data.BfdEnable.IsNull() {
if value.Exists() {
- data.CdpTlvApp = types.BoolValue(value.Bool())
+ data.BfdEnable = types.BoolValue(value.Bool())
}
} else {
- data.CdpTlvApp = types.BoolNull()
+ data.BfdEnable = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-cdp:cdp.tlv.location-config"); !data.CdpTlvLocation.IsNull() {
+ if value := res.Get(prefix + "bfd.Cisco-IOS-XE-bfd:local-address"); value.Exists() && !data.BfdLocalAddress.IsNull() {
+ data.BfdLocalAddress = types.StringValue(value.String())
+ } else {
+ data.BfdLocalAddress = types.StringNull()
+ }
+ if value := res.Get(prefix + "bfd.Cisco-IOS-XE-bfd:interval-interface.msecs"); value.Exists() && !data.BfdInterval.IsNull() {
+ data.BfdInterval = types.Int64Value(value.Int())
+ } else {
+ data.BfdInterval = types.Int64Null()
+ }
+ if value := res.Get(prefix + "bfd.Cisco-IOS-XE-bfd:interval-interface.min_rx"); value.Exists() && !data.BfdIntervalMinRx.IsNull() {
+ data.BfdIntervalMinRx = types.Int64Value(value.Int())
+ } else {
+ data.BfdIntervalMinRx = types.Int64Null()
+ }
+ if value := res.Get(prefix + "bfd.Cisco-IOS-XE-bfd:interval-interface.multiplier"); value.Exists() && !data.BfdIntervalMultiplier.IsNull() {
+ data.BfdIntervalMultiplier = types.Int64Value(value.Int())
+ } else {
+ data.BfdIntervalMultiplier = types.Int64Null()
+ }
+ if value := res.Get(prefix + "bfd.Cisco-IOS-XE-bfd:echo"); !data.BfdEcho.IsNull() {
if value.Exists() {
- data.CdpTlvLocation = types.BoolValue(value.Bool())
+ data.BfdEcho = types.BoolValue(value.Bool())
}
} else {
- data.CdpTlvLocation = types.BoolNull()
+ data.BfdEcho = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-cdp:cdp.tlv.server-location-config"); !data.CdpTlvServerLocation.IsNull() {
+ if value := res.Get(prefix + "ipv6.enable"); !data.Ipv6Enable.IsNull() {
if value.Exists() {
- data.CdpTlvServerLocation = types.BoolValue(value.Bool())
+ data.Ipv6Enable = types.BoolValue(true)
+ } else {
+ data.Ipv6Enable = types.BoolValue(false)
}
} else {
- data.CdpTlvServerLocation = types.BoolNull()
+ data.Ipv6Enable = types.BoolNull()
}
- if value := res.Get(prefix + "ip.Cisco-IOS-XE-nat:nat.inside"); !data.IpNatInside.IsNull() {
+ if value := res.Get(prefix + "ipv6.mtu"); value.Exists() && !data.Ipv6Mtu.IsNull() {
+ data.Ipv6Mtu = types.Int64Value(value.Int())
+ } else {
+ data.Ipv6Mtu = types.Int64Null()
+ }
+ if value := res.Get(prefix + "ipv6.nd.Cisco-IOS-XE-nd:ra.suppress.all"); !data.Ipv6NdRaSuppressAll.IsNull() {
if value.Exists() {
- data.IpNatInside = types.BoolValue(true)
+ data.Ipv6NdRaSuppressAll = types.BoolValue(true)
} else {
- data.IpNatInside = types.BoolValue(false)
+ data.Ipv6NdRaSuppressAll = types.BoolValue(false)
}
} else {
- data.IpNatInside = types.BoolNull()
+ data.Ipv6NdRaSuppressAll = types.BoolNull()
}
- if value := res.Get(prefix + "ip.Cisco-IOS-XE-nat:nat.outside"); !data.IpNatOutside.IsNull() {
+ if value := res.Get(prefix + "ipv6.address.autoconfig.default"); !data.Ipv6AddressAutoconfigDefault.IsNull() {
if value.Exists() {
- data.IpNatOutside = types.BoolValue(true)
+ data.Ipv6AddressAutoconfigDefault = types.BoolValue(true)
} else {
- data.IpNatOutside = types.BoolValue(false)
+ data.Ipv6AddressAutoconfigDefault = types.BoolValue(false)
}
} else {
- data.IpNatOutside = types.BoolNull()
+ data.Ipv6AddressAutoconfigDefault = types.BoolNull()
}
-}
-
-// End of section. //template:end updateFromBody
-
-// Section below is generated&owned by "gen/generator.go". //template:begin fromBody
-
-func (data *InterfaceEthernet) fromBody(ctx context.Context, res gjson.Result) {
- prefix := helpers.LastElement(data.getPath()) + "."
- if res.Get(helpers.LastElement(data.getPath())).IsArray() {
- prefix += "0."
+ if value := res.Get(prefix + "ipv6.address.dhcp"); !data.Ipv6AddressDhcp.IsNull() {
+ if value.Exists() {
+ data.Ipv6AddressDhcp = types.BoolValue(true)
+ } else {
+ data.Ipv6AddressDhcp = types.BoolValue(false)
+ }
+ } else {
+ data.Ipv6AddressDhcp = types.BoolNull()
}
- if value := res.Get(prefix + "media-type"); value.Exists() {
- data.MediaType = types.StringValue(value.String())
+ for i := range data.Ipv6LinkLocalAddresses {
+ keys := [...]string{"address"}
+ keyValues := [...]string{data.Ipv6LinkLocalAddresses[i].Address.ValueString()}
+
+ var r gjson.Result
+ res.Get(prefix + "ipv6.address.link-local-address").ForEach(
+ func(_, v gjson.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := r.Get("address"); value.Exists() && !data.Ipv6LinkLocalAddresses[i].Address.IsNull() {
+ data.Ipv6LinkLocalAddresses[i].Address = types.StringValue(value.String())
+ } else {
+ data.Ipv6LinkLocalAddresses[i].Address = types.StringNull()
+ }
+ if value := r.Get("link-local"); !data.Ipv6LinkLocalAddresses[i].LinkLocal.IsNull() {
+ if value.Exists() {
+ data.Ipv6LinkLocalAddresses[i].LinkLocal = types.BoolValue(true)
+ } else {
+ data.Ipv6LinkLocalAddresses[i].LinkLocal = types.BoolValue(false)
+ }
+ } else {
+ data.Ipv6LinkLocalAddresses[i].LinkLocal = types.BoolNull()
+ }
}
- if value := res.Get(prefix + "mtu"); value.Exists() {
- data.Mtu = types.Int64Value(value.Int())
+ for i := range data.Ipv6Addresses {
+ keys := [...]string{"prefix"}
+ keyValues := [...]string{data.Ipv6Addresses[i].Prefix.ValueString()}
+
+ var r gjson.Result
+ res.Get(prefix + "ipv6.address.prefix-list").ForEach(
+ func(_, v gjson.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := r.Get("prefix"); value.Exists() && !data.Ipv6Addresses[i].Prefix.IsNull() {
+ data.Ipv6Addresses[i].Prefix = types.StringValue(value.String())
+ } else {
+ data.Ipv6Addresses[i].Prefix = types.StringNull()
+ }
+ if value := r.Get("eui-64"); !data.Ipv6Addresses[i].Eui64.IsNull() {
+ if value.Exists() {
+ data.Ipv6Addresses[i].Eui64 = types.BoolValue(true)
+ } else {
+ data.Ipv6Addresses[i].Eui64 = types.BoolValue(false)
+ }
+ } else {
+ data.Ipv6Addresses[i].Eui64 = types.BoolNull()
+ }
}
- if value := res.Get(prefix + "bandwidth.kilobits"); value.Exists() {
- data.Bandwidth = types.Int64Value(value.Int())
+ for i := range data.Ipv6FlowMonitors {
+ keys := [...]string{"name", "direction"}
+ keyValues := [...]string{data.Ipv6FlowMonitors[i].Name.ValueString(), data.Ipv6FlowMonitors[i].Direction.ValueString()}
+
+ var r gjson.Result
+ res.Get(prefix + "ipv6.Cisco-IOS-XE-flow:flow.monitor-new").ForEach(
+ func(_, v gjson.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := r.Get("name"); value.Exists() && !data.Ipv6FlowMonitors[i].Name.IsNull() {
+ data.Ipv6FlowMonitors[i].Name = types.StringValue(value.String())
+ } else {
+ data.Ipv6FlowMonitors[i].Name = types.StringNull()
+ }
+ if value := r.Get("direction"); value.Exists() && !data.Ipv6FlowMonitors[i].Direction.IsNull() {
+ data.Ipv6FlowMonitors[i].Direction = types.StringValue(value.String())
+ } else {
+ data.Ipv6FlowMonitors[i].Direction = types.StringNull()
+ }
}
- if value := res.Get(prefix + "switchport-conf.switchport"); value.Exists() {
- data.Switchport = types.BoolValue(value.Bool())
+ if value := res.Get(prefix + "arp.timeout"); value.Exists() && !data.ArpTimeout.IsNull() {
+ data.ArpTimeout = types.Int64Value(value.Int())
} else {
- data.Switchport = types.BoolNull()
- }
- if value := res.Get(prefix + "description"); value.Exists() {
- data.Description = types.StringValue(value.String())
+ data.ArpTimeout = types.Int64Null()
}
- if value := res.Get(prefix + "shutdown"); value.Exists() {
- data.Shutdown = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-spanning-tree:spanning-tree.link-type"); value.Exists() && !data.SpanningTreeLinkType.IsNull() {
+ data.SpanningTreeLinkType = types.StringValue(value.String())
} else {
- data.Shutdown = types.BoolValue(false)
+ data.SpanningTreeLinkType = types.StringNull()
}
- if value := res.Get(prefix + "ip.proxy-arp"); value.Exists() {
- data.IpProxyArp = types.BoolValue(value.Bool())
+ if value := res.Get(prefix + "Cisco-IOS-XE-spanning-tree:spanning-tree.bpduguard.enable"); !data.BpduguardEnable.IsNull() {
+ if value.Exists() {
+ data.BpduguardEnable = types.BoolValue(true)
+ } else {
+ data.BpduguardEnable = types.BoolValue(false)
+ }
} else {
- data.IpProxyArp = types.BoolNull()
+ data.BpduguardEnable = types.BoolNull()
}
- if value := res.Get(prefix + "ip.redirects"); value.Exists() {
- data.IpRedirects = types.BoolValue(value.Bool())
+ if value := res.Get(prefix + "Cisco-IOS-XE-spanning-tree:spanning-tree.bpduguard.disable"); !data.BpduguardDisable.IsNull() {
+ if value.Exists() {
+ data.BpduguardDisable = types.BoolValue(true)
+ } else {
+ data.BpduguardDisable = types.BoolValue(false)
+ }
} else {
- data.IpRedirects = types.BoolNull()
+ data.BpduguardDisable = types.BoolNull()
}
- if value := res.Get(prefix + "ip.Cisco-IOS-XE-icmp:unreachables"); value.Exists() {
- data.IpUnreachables = types.BoolValue(value.Bool())
+ if value := res.Get(prefix + "Cisco-IOS-XE-spanning-tree:spanning-tree.portfast"); !data.SpanningTreePortfast.IsNull() {
+ if value.Exists() {
+ data.SpanningTreePortfast = types.BoolValue(true)
+ } else {
+ data.SpanningTreePortfast = types.BoolValue(false)
+ }
} else {
- data.IpUnreachables = types.BoolNull()
- }
- if value := res.Get(prefix + "vrf.forwarding"); value.Exists() {
- data.VrfForwarding = types.StringValue(value.String())
+ data.SpanningTreePortfast = types.BoolNull()
}
- if value := res.Get(prefix + "ip.address.primary.address"); value.Exists() {
- data.Ipv4Address = types.StringValue(value.String())
+ if value := res.Get(prefix + "Cisco-IOS-XE-spanning-tree:spanning-tree.portfast.disable"); !data.SpanningTreePortfastDisable.IsNull() {
+ if value.Exists() {
+ data.SpanningTreePortfastDisable = types.BoolValue(true)
+ } else {
+ data.SpanningTreePortfastDisable = types.BoolValue(false)
+ }
+ } else {
+ data.SpanningTreePortfastDisable = types.BoolNull()
}
- if value := res.Get(prefix + "ip.address.primary.mask"); value.Exists() {
- data.Ipv4AddressMask = types.StringValue(value.String())
+ if value := res.Get(prefix + "Cisco-IOS-XE-spanning-tree:spanning-tree.portfast.trunk"); !data.SpanningTreePortfastTrunk.IsNull() {
+ if value.Exists() {
+ data.SpanningTreePortfastTrunk = types.BoolValue(true)
+ } else {
+ data.SpanningTreePortfastTrunk = types.BoolValue(false)
+ }
+ } else {
+ data.SpanningTreePortfastTrunk = types.BoolNull()
}
- if value := res.Get(prefix + "ip.unnumbered"); value.Exists() {
- data.Unnumbered = types.StringValue(value.String())
+ if value := res.Get(prefix + "Cisco-IOS-XE-spanning-tree:spanning-tree.portfast.edge"); !data.SpanningTreePortfastEdge.IsNull() {
+ if value.Exists() {
+ data.SpanningTreePortfastEdge = types.BoolValue(true)
+ } else {
+ data.SpanningTreePortfastEdge = types.BoolValue(false)
+ }
+ } else {
+ data.SpanningTreePortfastEdge = types.BoolNull()
}
- if value := res.Get(prefix + "encapsulation.dot1Q.vlan-id"); value.Exists() {
- data.EncapsulationDot1qVlanId = types.Int64Value(value.Int())
+ if value := res.Get(prefix + "ip.arp.inspection.trust"); !data.IpArpInspectionTrust.IsNull() {
+ if value.Exists() {
+ data.IpArpInspectionTrust = types.BoolValue(true)
+ } else {
+ data.IpArpInspectionTrust = types.BoolValue(false)
+ }
+ } else {
+ data.IpArpInspectionTrust = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-ethernet:channel-group.number"); value.Exists() {
- data.ChannelGroupNumber = types.Int64Value(value.Int())
+ if value := res.Get(prefix + "ip.arp.inspection.limit.rate"); value.Exists() && !data.IpArpInspectionLimitRate.IsNull() {
+ data.IpArpInspectionLimitRate = types.Int64Value(value.Int())
+ } else {
+ data.IpArpInspectionLimitRate = types.Int64Null()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-ethernet:channel-group.mode"); value.Exists() {
- data.ChannelGroupMode = types.StringValue(value.String())
+ if value := res.Get(prefix + "ip.dhcp.Cisco-IOS-XE-dhcp:snooping.trust"); !data.IpDhcpSnoopingTrust.IsNull() {
+ if value.Exists() {
+ data.IpDhcpSnoopingTrust = types.BoolValue(true)
+ } else {
+ data.IpDhcpSnoopingTrust = types.BoolValue(false)
+ }
+ } else {
+ data.IpDhcpSnoopingTrust = types.BoolNull()
}
- if value := res.Get(prefix + "ip.dhcp.Cisco-IOS-XE-dhcp:relay.source-interface"); value.Exists() {
- data.IpDhcpRelaySourceInterface = types.StringValue(value.String())
+ if value := res.Get(prefix + "Cisco-IOS-XE-ethernet:speed.value-100"); !data.Speed100.IsNull() {
+ if value.Exists() {
+ data.Speed100 = types.BoolValue(true)
+ } else {
+ data.Speed100 = types.BoolValue(false)
+ }
+ } else {
+ data.Speed100 = types.BoolNull()
}
- if value := res.Get(prefix + "ip.access-group.in.acl.in"); value.Exists() {
- data.IpAccessGroupInEnable = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-ethernet:speed.value-1000"); !data.Speed1000.IsNull() {
+ if value.Exists() {
+ data.Speed1000 = types.BoolValue(true)
+ } else {
+ data.Speed1000 = types.BoolValue(false)
+ }
} else {
- data.IpAccessGroupInEnable = types.BoolValue(false)
+ data.Speed1000 = types.BoolNull()
}
- if value := res.Get(prefix + "ip.access-group.in.acl.acl-name"); value.Exists() {
- data.IpAccessGroupIn = types.StringValue(value.String())
+ if value := res.Get(prefix + "Cisco-IOS-XE-ethernet:speed.value-2500"); !data.Speed2500.IsNull() {
+ if value.Exists() {
+ data.Speed2500 = types.BoolValue(true)
+ } else {
+ data.Speed2500 = types.BoolValue(false)
+ }
+ } else {
+ data.Speed2500 = types.BoolNull()
}
- if value := res.Get(prefix + "ip.access-group.out.acl.out"); value.Exists() {
- data.IpAccessGroupOutEnable = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-ethernet:speed.value-5000"); !data.Speed5000.IsNull() {
+ if value.Exists() {
+ data.Speed5000 = types.BoolValue(true)
+ } else {
+ data.Speed5000 = types.BoolValue(false)
+ }
} else {
- data.IpAccessGroupOutEnable = types.BoolValue(false)
+ data.Speed5000 = types.BoolNull()
}
- if value := res.Get(prefix + "ip.access-group.out.acl.acl-name"); value.Exists() {
- data.IpAccessGroupOut = types.StringValue(value.String())
+ if value := res.Get(prefix + "Cisco-IOS-XE-ethernet:speed.value-10000"); !data.Speed10000.IsNull() {
+ if value.Exists() {
+ data.Speed10000 = types.BoolValue(true)
+ } else {
+ data.Speed10000 = types.BoolValue(false)
+ }
+ } else {
+ data.Speed10000 = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-spanning-tree:spanning-tree.guard"); value.Exists() {
- data.SpanningTreeGuard = types.StringValue(value.String())
+ if value := res.Get(prefix + "Cisco-IOS-XE-ethernet:speed.value-25000"); !data.Speed25000.IsNull() {
+ if value.Exists() {
+ data.Speed25000 = types.BoolValue(true)
+ } else {
+ data.Speed25000 = types.BoolValue(false)
+ }
+ } else {
+ data.Speed25000 = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-switch:auto.qos.classify"); value.Exists() {
- data.AutoQosClassify = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-ethernet:speed.value-40000"); !data.Speed40000.IsNull() {
+ if value.Exists() {
+ data.Speed40000 = types.BoolValue(true)
+ } else {
+ data.Speed40000 = types.BoolValue(false)
+ }
} else {
- data.AutoQosClassify = types.BoolValue(false)
+ data.Speed40000 = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-switch:auto.qos.classify.police"); value.Exists() {
- data.AutoQosClassifyPolice = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-ethernet:speed.value-100000"); !data.Speed100000.IsNull() {
+ if value.Exists() {
+ data.Speed100000 = types.BoolValue(true)
+ } else {
+ data.Speed100000 = types.BoolValue(false)
+ }
} else {
- data.AutoQosClassifyPolice = types.BoolValue(false)
+ data.Speed100000 = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-switch:auto.qos.trust"); value.Exists() {
- data.AutoQosTrust = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-ethernet:negotiation.auto"); !data.NegotiationAuto.IsNull() {
+ if value.Exists() {
+ data.NegotiationAuto = types.BoolValue(value.Bool())
+ }
} else {
- data.AutoQosTrust = types.BoolValue(false)
+ data.NegotiationAuto = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-switch:auto.qos.trust.cos"); value.Exists() {
- data.AutoQosTrustCos = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-ethernet:speed.nonegotiate"); !data.SpeedNonegotiate.IsNull() {
+ if value.Exists() {
+ data.SpeedNonegotiate = types.BoolValue(true)
+ } else {
+ data.SpeedNonegotiate = types.BoolValue(false)
+ }
} else {
- data.AutoQosTrustCos = types.BoolValue(false)
+ data.SpeedNonegotiate = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-switch:auto.qos.trust.dscp"); value.Exists() {
- data.AutoQosTrustDscp = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-sanet:authentication.host-mode"); value.Exists() && !data.AuthenticationHostMode.IsNull() {
+ data.AuthenticationHostMode = types.StringValue(value.String())
} else {
- data.AutoQosTrustDscp = types.BoolValue(false)
+ data.AuthenticationHostMode = types.StringNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-switch:auto.qos.video.cts"); value.Exists() {
- data.AutoQosVideoCts = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-sanet:authentication.order-config.dot1x-config"); !data.AuthenticationOrderDot1x.IsNull() {
+ if value.Exists() {
+ data.AuthenticationOrderDot1x = types.BoolValue(true)
+ } else {
+ data.AuthenticationOrderDot1x = types.BoolValue(false)
+ }
} else {
- data.AutoQosVideoCts = types.BoolValue(false)
+ data.AuthenticationOrderDot1x = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-switch:auto.qos.video.ip-camera"); value.Exists() {
- data.AutoQosVideoIpCamera = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-sanet:authentication.order-config.dot1x-config.mab"); !data.AuthenticationOrderDot1xMab.IsNull() {
+ if value.Exists() {
+ data.AuthenticationOrderDot1xMab = types.BoolValue(true)
+ } else {
+ data.AuthenticationOrderDot1xMab = types.BoolValue(false)
+ }
} else {
- data.AutoQosVideoIpCamera = types.BoolValue(false)
+ data.AuthenticationOrderDot1xMab = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-switch:auto.qos.video.media-player"); value.Exists() {
- data.AutoQosVideoMediaPlayer = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-sanet:authentication.order-config.dot1x-config.webauth"); !data.AuthenticationOrderDot1xWebauth.IsNull() {
+ if value.Exists() {
+ data.AuthenticationOrderDot1xWebauth = types.BoolValue(true)
+ } else {
+ data.AuthenticationOrderDot1xWebauth = types.BoolValue(false)
+ }
} else {
- data.AutoQosVideoMediaPlayer = types.BoolValue(false)
+ data.AuthenticationOrderDot1xWebauth = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-switch:auto.qos.voip"); value.Exists() {
- data.AutoQosVoip = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-sanet:authentication.order-config.mab-config"); !data.AuthenticationOrderMab.IsNull() {
+ if value.Exists() {
+ data.AuthenticationOrderMab = types.BoolValue(true)
+ } else {
+ data.AuthenticationOrderMab = types.BoolValue(false)
+ }
} else {
- data.AutoQosVoip = types.BoolValue(false)
+ data.AuthenticationOrderMab = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-switch:auto.qos.voip.cisco-phone"); value.Exists() {
- data.AutoQosVoipCiscoPhone = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-sanet:authentication.order-config.mab-config.dot1x"); !data.AuthenticationOrderMabDot1x.IsNull() {
+ if value.Exists() {
+ data.AuthenticationOrderMabDot1x = types.BoolValue(true)
+ } else {
+ data.AuthenticationOrderMabDot1x = types.BoolValue(false)
+ }
} else {
- data.AutoQosVoipCiscoPhone = types.BoolValue(false)
+ data.AuthenticationOrderMabDot1x = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-switch:auto.qos.voip.cisco-softphone"); value.Exists() {
- data.AutoQosVoipCiscoSoftphone = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-sanet:authentication.order-config.mab-config.webauth"); !data.AuthenticationOrderMabWebauth.IsNull() {
+ if value.Exists() {
+ data.AuthenticationOrderMabWebauth = types.BoolValue(true)
+ } else {
+ data.AuthenticationOrderMabWebauth = types.BoolValue(false)
+ }
} else {
- data.AutoQosVoipCiscoSoftphone = types.BoolValue(false)
+ data.AuthenticationOrderMabWebauth = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-switch:auto.qos.voip.trust"); value.Exists() {
- data.AutoQosVoipTrust = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-sanet:authentication.order-config.webauth-config"); !data.AuthenticationOrderWebauth.IsNull() {
+ if value.Exists() {
+ data.AuthenticationOrderWebauth = types.BoolValue(true)
+ } else {
+ data.AuthenticationOrderWebauth = types.BoolValue(false)
+ }
} else {
- data.AutoQosVoipTrust = types.BoolValue(false)
+ data.AuthenticationOrderWebauth = types.BoolNull()
}
- if value := res.Get(prefix + "trust.device"); value.Exists() {
- data.TrustDevice = types.StringValue(value.String())
+ if value := res.Get(prefix + "Cisco-IOS-XE-sanet:authentication.priority-config.dot1x-config"); !data.AuthenticationPriorityDot1x.IsNull() {
+ if value.Exists() {
+ data.AuthenticationPriorityDot1x = types.BoolValue(true)
+ } else {
+ data.AuthenticationPriorityDot1x = types.BoolValue(false)
+ }
+ } else {
+ data.AuthenticationPriorityDot1x = types.BoolNull()
}
- if value := res.Get(prefix + "ip.helper-address"); value.Exists() {
- data.HelperAddresses = make([]InterfaceEthernetHelperAddresses, 0)
- value.ForEach(func(k, v gjson.Result) bool {
- item := InterfaceEthernetHelperAddresses{}
- if cValue := v.Get("address"); cValue.Exists() {
- item.Address = types.StringValue(cValue.String())
- }
- if cValue := v.Get("global"); cValue.Exists() {
- item.Global = types.BoolValue(true)
- } else {
- item.Global = types.BoolValue(false)
- }
- if cValue := v.Get("vrf"); cValue.Exists() {
- item.Vrf = types.StringValue(cValue.String())
- }
- data.HelperAddresses = append(data.HelperAddresses, item)
- return true
- })
- }
- if value := res.Get(prefix + "source.template.template-name"); value.Exists() {
- data.SourceTemplate = make([]InterfaceEthernetSourceTemplate, 0)
- value.ForEach(func(k, v gjson.Result) bool {
- item := InterfaceEthernetSourceTemplate{}
- if cValue := v.Get("template-name"); cValue.Exists() {
- item.TemplateName = types.StringValue(cValue.String())
- }
- if cValue := v.Get("merge"); cValue.Exists() {
- item.Merge = types.BoolValue(true)
- } else {
- item.Merge = types.BoolValue(false)
- }
- data.SourceTemplate = append(data.SourceTemplate, item)
- return true
- })
- }
- if value := res.Get(prefix + "bfd.Cisco-IOS-XE-bfd:template"); value.Exists() {
- data.BfdTemplate = types.StringValue(value.String())
- }
- if value := res.Get(prefix + "bfd.Cisco-IOS-XE-bfd:enable"); value.Exists() {
- data.BfdEnable = types.BoolValue(value.Bool())
+ if value := res.Get(prefix + "Cisco-IOS-XE-sanet:authentication.priority-config.dot1x-config.mab"); !data.AuthenticationPriorityDot1xMab.IsNull() {
+ if value.Exists() {
+ data.AuthenticationPriorityDot1xMab = types.BoolValue(true)
+ } else {
+ data.AuthenticationPriorityDot1xMab = types.BoolValue(false)
+ }
} else {
- data.BfdEnable = types.BoolNull()
- }
- if value := res.Get(prefix + "bfd.Cisco-IOS-XE-bfd:local-address"); value.Exists() {
- data.BfdLocalAddress = types.StringValue(value.String())
- }
- if value := res.Get(prefix + "bfd.Cisco-IOS-XE-bfd:interval-interface.msecs"); value.Exists() {
- data.BfdInterval = types.Int64Value(value.Int())
- }
- if value := res.Get(prefix + "bfd.Cisco-IOS-XE-bfd:interval-interface.min_rx"); value.Exists() {
- data.BfdIntervalMinRx = types.Int64Value(value.Int())
- }
- if value := res.Get(prefix + "bfd.Cisco-IOS-XE-bfd:interval-interface.multiplier"); value.Exists() {
- data.BfdIntervalMultiplier = types.Int64Value(value.Int())
+ data.AuthenticationPriorityDot1xMab = types.BoolNull()
}
- if value := res.Get(prefix + "bfd.Cisco-IOS-XE-bfd:echo"); value.Exists() {
- data.BfdEcho = types.BoolValue(value.Bool())
+ if value := res.Get(prefix + "Cisco-IOS-XE-sanet:authentication.priority-config.dot1x-config.webauth"); !data.AuthenticationPriorityDot1xWebauth.IsNull() {
+ if value.Exists() {
+ data.AuthenticationPriorityDot1xWebauth = types.BoolValue(true)
+ } else {
+ data.AuthenticationPriorityDot1xWebauth = types.BoolValue(false)
+ }
} else {
- data.BfdEcho = types.BoolNull()
+ data.AuthenticationPriorityDot1xWebauth = types.BoolNull()
}
- if value := res.Get(prefix + "ipv6.enable"); value.Exists() {
- data.Ipv6Enable = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-sanet:authentication.priority-config.mab-config"); !data.AuthenticationPriorityMab.IsNull() {
+ if value.Exists() {
+ data.AuthenticationPriorityMab = types.BoolValue(true)
+ } else {
+ data.AuthenticationPriorityMab = types.BoolValue(false)
+ }
} else {
- data.Ipv6Enable = types.BoolValue(false)
- }
- if value := res.Get(prefix + "ipv6.mtu"); value.Exists() {
- data.Ipv6Mtu = types.Int64Value(value.Int())
+ data.AuthenticationPriorityMab = types.BoolNull()
}
- if value := res.Get(prefix + "ipv6.nd.Cisco-IOS-XE-nd:ra.suppress.all"); value.Exists() {
- data.Ipv6NdRaSuppressAll = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-sanet:authentication.priority-config.mab-config.dot1x"); !data.AuthenticationPriorityMabDot1x.IsNull() {
+ if value.Exists() {
+ data.AuthenticationPriorityMabDot1x = types.BoolValue(true)
+ } else {
+ data.AuthenticationPriorityMabDot1x = types.BoolValue(false)
+ }
} else {
- data.Ipv6NdRaSuppressAll = types.BoolValue(false)
+ data.AuthenticationPriorityMabDot1x = types.BoolNull()
}
- if value := res.Get(prefix + "ipv6.address.autoconfig.default"); value.Exists() {
- data.Ipv6AddressAutoconfigDefault = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-sanet:authentication.priority-config.mab-config.webauth"); !data.AuthenticationPriorityMabWebauth.IsNull() {
+ if value.Exists() {
+ data.AuthenticationPriorityMabWebauth = types.BoolValue(true)
+ } else {
+ data.AuthenticationPriorityMabWebauth = types.BoolValue(false)
+ }
} else {
- data.Ipv6AddressAutoconfigDefault = types.BoolValue(false)
+ data.AuthenticationPriorityMabWebauth = types.BoolNull()
}
- if value := res.Get(prefix + "ipv6.address.dhcp"); value.Exists() {
- data.Ipv6AddressDhcp = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-sanet:authentication.priority-config.webauth-config"); !data.AuthenticationPriorityWebauth.IsNull() {
+ if value.Exists() {
+ data.AuthenticationPriorityWebauth = types.BoolValue(true)
+ } else {
+ data.AuthenticationPriorityWebauth = types.BoolValue(false)
+ }
} else {
- data.Ipv6AddressDhcp = types.BoolValue(false)
- }
- if value := res.Get(prefix + "ipv6.address.link-local-address"); value.Exists() {
- data.Ipv6LinkLocalAddresses = make([]InterfaceEthernetIpv6LinkLocalAddresses, 0)
- value.ForEach(func(k, v gjson.Result) bool {
- item := InterfaceEthernetIpv6LinkLocalAddresses{}
- if cValue := v.Get("address"); cValue.Exists() {
- item.Address = types.StringValue(cValue.String())
- }
- if cValue := v.Get("link-local"); cValue.Exists() {
- item.LinkLocal = types.BoolValue(true)
- } else {
- item.LinkLocal = types.BoolValue(false)
- }
- data.Ipv6LinkLocalAddresses = append(data.Ipv6LinkLocalAddresses, item)
- return true
- })
- }
- if value := res.Get(prefix + "ipv6.address.prefix-list"); value.Exists() {
- data.Ipv6Addresses = make([]InterfaceEthernetIpv6Addresses, 0)
- value.ForEach(func(k, v gjson.Result) bool {
- item := InterfaceEthernetIpv6Addresses{}
- if cValue := v.Get("prefix"); cValue.Exists() {
- item.Prefix = types.StringValue(cValue.String())
- }
- if cValue := v.Get("eui-64"); cValue.Exists() {
- item.Eui64 = types.BoolValue(true)
- } else {
- item.Eui64 = types.BoolValue(false)
- }
- data.Ipv6Addresses = append(data.Ipv6Addresses, item)
- return true
- })
- }
- if value := res.Get(prefix + "ipv6.Cisco-IOS-XE-flow:flow.monitor-new"); value.Exists() {
- data.Ipv6FlowMonitors = make([]InterfaceEthernetIpv6FlowMonitors, 0)
- value.ForEach(func(k, v gjson.Result) bool {
- item := InterfaceEthernetIpv6FlowMonitors{}
- if cValue := v.Get("name"); cValue.Exists() {
- item.Name = types.StringValue(cValue.String())
- }
- if cValue := v.Get("direction"); cValue.Exists() {
- item.Direction = types.StringValue(cValue.String())
- }
- data.Ipv6FlowMonitors = append(data.Ipv6FlowMonitors, item)
- return true
- })
- }
- if value := res.Get(prefix + "arp.timeout"); value.Exists() {
- data.ArpTimeout = types.Int64Value(value.Int())
- }
- if value := res.Get(prefix + "Cisco-IOS-XE-spanning-tree:spanning-tree.link-type"); value.Exists() {
- data.SpanningTreeLinkType = types.StringValue(value.String())
+ data.AuthenticationPriorityWebauth = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-spanning-tree:spanning-tree.bpduguard.enable"); value.Exists() {
- data.BpduguardEnable = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-sanet:authentication.port-control"); value.Exists() && !data.AuthenticationPortControl.IsNull() {
+ data.AuthenticationPortControl = types.StringValue(value.String())
} else {
- data.BpduguardEnable = types.BoolValue(false)
+ data.AuthenticationPortControl = types.StringNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-spanning-tree:spanning-tree.bpduguard.disable"); value.Exists() {
- data.BpduguardDisable = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-sanet:authentication.periodic"); !data.AuthenticationPeriodic.IsNull() {
+ if value.Exists() {
+ data.AuthenticationPeriodic = types.BoolValue(true)
+ } else {
+ data.AuthenticationPeriodic = types.BoolValue(false)
+ }
} else {
- data.BpduguardDisable = types.BoolValue(false)
+ data.AuthenticationPeriodic = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-spanning-tree:spanning-tree.portfast"); value.Exists() {
- data.SpanningTreePortfast = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-sanet:authentication.timer.reauthenticate.value-config"); value.Exists() && !data.AuthenticationTimerReauthenticate.IsNull() {
+ data.AuthenticationTimerReauthenticate = types.Int64Value(value.Int())
} else {
- data.SpanningTreePortfast = types.BoolValue(false)
+ data.AuthenticationTimerReauthenticate = types.Int64Null()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-spanning-tree:spanning-tree.portfast.disable"); value.Exists() {
- data.SpanningTreePortfastDisable = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-sanet:authentication.timer.reauthenticate.server-config"); !data.AuthenticationTimerReauthenticateServer.IsNull() {
+ if value.Exists() {
+ data.AuthenticationTimerReauthenticateServer = types.BoolValue(true)
+ } else {
+ data.AuthenticationTimerReauthenticateServer = types.BoolValue(false)
+ }
} else {
- data.SpanningTreePortfastDisable = types.BoolValue(false)
+ data.AuthenticationTimerReauthenticateServer = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-spanning-tree:spanning-tree.portfast.trunk"); value.Exists() {
- data.SpanningTreePortfastTrunk = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-sanet:authentication.event.server.alive.action.reinitialize"); !data.AuthenticationEventServerAliveActionReinitialize.IsNull() {
+ if value.Exists() {
+ data.AuthenticationEventServerAliveActionReinitialize = types.BoolValue(true)
+ } else {
+ data.AuthenticationEventServerAliveActionReinitialize = types.BoolValue(false)
+ }
} else {
- data.SpanningTreePortfastTrunk = types.BoolValue(false)
+ data.AuthenticationEventServerAliveActionReinitialize = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-spanning-tree:spanning-tree.portfast.edge"); value.Exists() {
- data.SpanningTreePortfastEdge = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-sanet:authentication.event.server.dead.action.authorize"); !data.AuthenticationEventServerDeadActionAuthorize.IsNull() {
+ if value.Exists() {
+ data.AuthenticationEventServerDeadActionAuthorize = types.BoolValue(true)
+ } else {
+ data.AuthenticationEventServerDeadActionAuthorize = types.BoolValue(false)
+ }
} else {
- data.SpanningTreePortfastEdge = types.BoolValue(false)
+ data.AuthenticationEventServerDeadActionAuthorize = types.BoolNull()
}
- if value := res.Get(prefix + "ip.arp.inspection.trust"); value.Exists() {
- data.IpArpInspectionTrust = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-sanet:authentication.event.server.dead.action.authorize.vlan"); value.Exists() && !data.AuthenticationEventServerDeadActionAuthorizeVlan.IsNull() {
+ data.AuthenticationEventServerDeadActionAuthorizeVlan = types.Int64Value(value.Int())
} else {
- data.IpArpInspectionTrust = types.BoolValue(false)
- }
- if value := res.Get(prefix + "ip.arp.inspection.limit.rate"); value.Exists() {
- data.IpArpInspectionLimitRate = types.Int64Value(value.Int())
+ data.AuthenticationEventServerDeadActionAuthorizeVlan = types.Int64Null()
}
- if value := res.Get(prefix + "ip.dhcp.Cisco-IOS-XE-dhcp:snooping.trust"); value.Exists() {
- data.IpDhcpSnoopingTrust = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-sanet:authentication.event.server.dead.action.authorize.voice"); !data.AuthenticationEventServerDeadActionAuthorizeVoice.IsNull() {
+ if value.Exists() {
+ data.AuthenticationEventServerDeadActionAuthorizeVoice = types.BoolValue(true)
+ } else {
+ data.AuthenticationEventServerDeadActionAuthorizeVoice = types.BoolValue(false)
+ }
} else {
- data.IpDhcpSnoopingTrust = types.BoolValue(false)
+ data.AuthenticationEventServerDeadActionAuthorizeVoice = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-ethernet:speed.value-100"); value.Exists() {
- data.Speed100 = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-sanet:authentication.event.server.dead.action.reinitialize.vlan"); value.Exists() && !data.AuthenticationEventServerDeadActionReinitializeVlan.IsNull() {
+ data.AuthenticationEventServerDeadActionReinitializeVlan = types.Int64Value(value.Int())
} else {
- data.Speed100 = types.BoolValue(false)
+ data.AuthenticationEventServerDeadActionReinitializeVlan = types.Int64Null()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-ethernet:speed.value-1000"); value.Exists() {
- data.Speed1000 = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-sanet:authentication.event.fail-config.action.authorize.vlan"); value.Exists() && !data.AuthenticationEventFailActionAuthorizeVlan.IsNull() {
+ data.AuthenticationEventFailActionAuthorizeVlan = types.Int64Value(value.Int())
} else {
- data.Speed1000 = types.BoolValue(false)
+ data.AuthenticationEventFailActionAuthorizeVlan = types.Int64Null()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-ethernet:speed.value-2500"); value.Exists() {
- data.Speed2500 = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-sanet:authentication.event.fail-config.action.next-method"); !data.AuthenticationEventFailActionNextMethod.IsNull() {
+ if value.Exists() {
+ data.AuthenticationEventFailActionNextMethod = types.BoolValue(true)
+ } else {
+ data.AuthenticationEventFailActionNextMethod = types.BoolValue(false)
+ }
} else {
- data.Speed2500 = types.BoolValue(false)
+ data.AuthenticationEventFailActionNextMethod = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-ethernet:speed.value-5000"); value.Exists() {
- data.Speed5000 = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-sanet:authentication.event.no-response.action.authorize.vlan"); value.Exists() && !data.AuthenticationEventNoResponseActionAuthorizeVlan.IsNull() {
+ data.AuthenticationEventNoResponseActionAuthorizeVlan = types.Int64Value(value.Int())
} else {
- data.Speed5000 = types.BoolValue(false)
+ data.AuthenticationEventNoResponseActionAuthorizeVlan = types.Int64Null()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-ethernet:speed.value-10000"); value.Exists() {
- data.Speed10000 = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-sanet:authentication.event.linksec.fail.action.next-method"); !data.AuthenticationEventLinksecFailActionNextMethod.IsNull() {
+ if value.Exists() {
+ data.AuthenticationEventLinksecFailActionNextMethod = types.BoolValue(true)
+ } else {
+ data.AuthenticationEventLinksecFailActionNextMethod = types.BoolValue(false)
+ }
} else {
- data.Speed10000 = types.BoolValue(false)
+ data.AuthenticationEventLinksecFailActionNextMethod = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-ethernet:speed.value-25000"); value.Exists() {
- data.Speed25000 = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-sanet:mab"); !data.Mab.IsNull() {
+ if value.Exists() {
+ data.Mab = types.BoolValue(true)
+ } else {
+ data.Mab = types.BoolValue(false)
+ }
} else {
- data.Speed25000 = types.BoolValue(false)
+ data.Mab = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-ethernet:speed.value-40000"); value.Exists() {
- data.Speed40000 = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-sanet:mab.eap"); !data.MabEap.IsNull() {
+ if value.Exists() {
+ data.MabEap = types.BoolValue(true)
+ } else {
+ data.MabEap = types.BoolValue(false)
+ }
} else {
- data.Speed40000 = types.BoolValue(false)
+ data.MabEap = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-ethernet:speed.value-100000"); value.Exists() {
- data.Speed100000 = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-dot1x:dot1x.pae"); value.Exists() && !data.Dot1xPae.IsNull() {
+ data.Dot1xPae = types.StringValue(value.String())
} else {
- data.Speed100000 = types.BoolValue(false)
+ data.Dot1xPae = types.StringNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-ethernet:negotiation.auto"); value.Exists() {
- data.NegotiationAuto = types.BoolValue(value.Bool())
+ if value := res.Get(prefix + "Cisco-IOS-XE-dot1x:dot1x.timeout.auth-period"); value.Exists() && !data.Dot1xTimeoutAuthPeriod.IsNull() {
+ data.Dot1xTimeoutAuthPeriod = types.Int64Value(value.Int())
} else {
- data.NegotiationAuto = types.BoolNull()
+ data.Dot1xTimeoutAuthPeriod = types.Int64Null()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-ethernet:speed.nonegotiate"); value.Exists() {
- data.SpeedNonegotiate = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-dot1x:dot1x.timeout.held-period"); value.Exists() && !data.Dot1xTimeoutHeldPeriod.IsNull() {
+ data.Dot1xTimeoutHeldPeriod = types.Int64Value(value.Int())
} else {
- data.SpeedNonegotiate = types.BoolValue(false)
- }
- if value := res.Get(prefix + "Cisco-IOS-XE-sanet:authentication.host-mode"); value.Exists() {
- data.AuthenticationHostMode = types.StringValue(value.String())
+ data.Dot1xTimeoutHeldPeriod = types.Int64Null()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-sanet:authentication.order-config.dot1x-config"); value.Exists() {
- data.AuthenticationOrderDot1x = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-dot1x:dot1x.timeout.quiet-period"); value.Exists() && !data.Dot1xTimeoutQuietPeriod.IsNull() {
+ data.Dot1xTimeoutQuietPeriod = types.Int64Value(value.Int())
} else {
- data.AuthenticationOrderDot1x = types.BoolValue(false)
+ data.Dot1xTimeoutQuietPeriod = types.Int64Null()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-sanet:authentication.order-config.dot1x-config.mab"); value.Exists() {
- data.AuthenticationOrderDot1xMab = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-dot1x:dot1x.timeout.ratelimit-period"); value.Exists() && !data.Dot1xTimeoutRatelimitPeriod.IsNull() {
+ data.Dot1xTimeoutRatelimitPeriod = types.Int64Value(value.Int())
} else {
- data.AuthenticationOrderDot1xMab = types.BoolValue(false)
+ data.Dot1xTimeoutRatelimitPeriod = types.Int64Null()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-sanet:authentication.order-config.dot1x-config.webauth"); value.Exists() {
- data.AuthenticationOrderDot1xWebauth = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-dot1x:dot1x.timeout.server-timeout"); value.Exists() && !data.Dot1xTimeoutServerTimeout.IsNull() {
+ data.Dot1xTimeoutServerTimeout = types.Int64Value(value.Int())
} else {
- data.AuthenticationOrderDot1xWebauth = types.BoolValue(false)
+ data.Dot1xTimeoutServerTimeout = types.Int64Null()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-sanet:authentication.order-config.mab-config"); value.Exists() {
- data.AuthenticationOrderMab = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-dot1x:dot1x.timeout.start-period"); value.Exists() && !data.Dot1xTimeoutStartPeriod.IsNull() {
+ data.Dot1xTimeoutStartPeriod = types.Int64Value(value.Int())
} else {
- data.AuthenticationOrderMab = types.BoolValue(false)
+ data.Dot1xTimeoutStartPeriod = types.Int64Null()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-sanet:authentication.order-config.mab-config.dot1x"); value.Exists() {
- data.AuthenticationOrderMabDot1x = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-dot1x:dot1x.timeout.supp-timeout"); value.Exists() && !data.Dot1xTimeoutSuppTimeout.IsNull() {
+ data.Dot1xTimeoutSuppTimeout = types.Int64Value(value.Int())
} else {
- data.AuthenticationOrderMabDot1x = types.BoolValue(false)
+ data.Dot1xTimeoutSuppTimeout = types.Int64Null()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-sanet:authentication.order-config.mab-config.webauth"); value.Exists() {
- data.AuthenticationOrderMabWebauth = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-dot1x:dot1x.timeout.tx-period"); value.Exists() && !data.Dot1xTimeoutTxPeriod.IsNull() {
+ data.Dot1xTimeoutTxPeriod = types.Int64Value(value.Int())
} else {
- data.AuthenticationOrderMabWebauth = types.BoolValue(false)
+ data.Dot1xTimeoutTxPeriod = types.Int64Null()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-sanet:authentication.order-config.webauth-config"); value.Exists() {
- data.AuthenticationOrderWebauth = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-dot1x:dot1x.max-req"); value.Exists() && !data.Dot1xMaxReq.IsNull() {
+ data.Dot1xMaxReq = types.Int64Value(value.Int())
} else {
- data.AuthenticationOrderWebauth = types.BoolValue(false)
+ data.Dot1xMaxReq = types.Int64Null()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-sanet:authentication.priority-config.dot1x-config"); value.Exists() {
- data.AuthenticationPriorityDot1x = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-dot1x:dot1x.max-reauth-req"); value.Exists() && !data.Dot1xMaxReauthReq.IsNull() {
+ data.Dot1xMaxReauthReq = types.Int64Value(value.Int())
} else {
- data.AuthenticationPriorityDot1x = types.BoolValue(false)
+ data.Dot1xMaxReauthReq = types.Int64Null()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-sanet:authentication.priority-config.dot1x-config.mab"); value.Exists() {
- data.AuthenticationPriorityDot1xMab = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-policy:service-policy.input"); value.Exists() && !data.ServicePolicyInput.IsNull() {
+ data.ServicePolicyInput = types.StringValue(value.String())
} else {
- data.AuthenticationPriorityDot1xMab = types.BoolValue(false)
+ data.ServicePolicyInput = types.StringNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-sanet:authentication.priority-config.dot1x-config.webauth"); value.Exists() {
- data.AuthenticationPriorityDot1xWebauth = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-policy:service-policy.output"); value.Exists() && !data.ServicePolicyOutput.IsNull() {
+ data.ServicePolicyOutput = types.StringValue(value.String())
} else {
- data.AuthenticationPriorityDot1xWebauth = types.BoolValue(false)
+ data.ServicePolicyOutput = types.StringNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-sanet:authentication.priority-config.mab-config"); value.Exists() {
- data.AuthenticationPriorityMab = types.BoolValue(true)
- } else {
- data.AuthenticationPriorityMab = types.BoolValue(false)
+ for i := range data.IpFlowMonitors {
+ keys := [...]string{"name", "direction"}
+ keyValues := [...]string{data.IpFlowMonitors[i].Name.ValueString(), data.IpFlowMonitors[i].Direction.ValueString()}
+
+ var r gjson.Result
+ res.Get(prefix + "ip.Cisco-IOS-XE-flow:flow.monitor-new").ForEach(
+ func(_, v gjson.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := r.Get("name"); value.Exists() && !data.IpFlowMonitors[i].Name.IsNull() {
+ data.IpFlowMonitors[i].Name = types.StringValue(value.String())
+ } else {
+ data.IpFlowMonitors[i].Name = types.StringNull()
+ }
+ if value := r.Get("direction"); value.Exists() && !data.IpFlowMonitors[i].Direction.IsNull() {
+ data.IpFlowMonitors[i].Direction = types.StringValue(value.String())
+ } else {
+ data.IpFlowMonitors[i].Direction = types.StringNull()
+ }
}
- if value := res.Get(prefix + "Cisco-IOS-XE-sanet:authentication.priority-config.mab-config.dot1x"); value.Exists() {
- data.AuthenticationPriorityMabDot1x = types.BoolValue(true)
+ if value := res.Get(prefix + "load-interval"); value.Exists() && !data.LoadInterval.IsNull() {
+ data.LoadInterval = types.Int64Value(value.Int())
} else {
- data.AuthenticationPriorityMabDot1x = types.BoolValue(false)
+ data.LoadInterval = types.Int64Null()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-sanet:authentication.priority-config.mab-config.webauth"); value.Exists() {
- data.AuthenticationPriorityMabWebauth = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:snmp.trap.link-status"); !data.SnmpTrapLinkStatus.IsNull() {
+ if value.Exists() {
+ data.SnmpTrapLinkStatus = types.BoolValue(value.Bool())
+ }
} else {
- data.AuthenticationPriorityMabWebauth = types.BoolValue(false)
+ data.SnmpTrapLinkStatus = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-sanet:authentication.priority-config.webauth-config"); value.Exists() {
- data.AuthenticationPriorityWebauth = types.BoolValue(true)
+ if value := res.Get(prefix + "logging.event.link-status-enable"); !data.LoggingEventLinkStatusEnable.IsNull() {
+ if value.Exists() {
+ data.LoggingEventLinkStatusEnable = types.BoolValue(value.Bool())
+ }
} else {
- data.AuthenticationPriorityWebauth = types.BoolValue(false)
+ data.LoggingEventLinkStatusEnable = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-sanet:authentication.port-control"); value.Exists() {
- data.AuthenticationPortControl = types.StringValue(value.String())
+ if value := res.Get(prefix + "ip.Cisco-IOS-XE-nbar:nbar.protocol-discovery"); !data.IpNbarProtocolDiscovery.IsNull() {
+ if value.Exists() {
+ data.IpNbarProtocolDiscovery = types.BoolValue(true)
+ } else {
+ data.IpNbarProtocolDiscovery = types.BoolValue(false)
+ }
+ } else {
+ data.IpNbarProtocolDiscovery = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-sanet:authentication.periodic"); value.Exists() {
- data.AuthenticationPeriodic = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-switch:device-tracking"); !data.DeviceTracking.IsNull() {
+ if value.Exists() {
+ data.DeviceTracking = types.BoolValue(true)
+ } else {
+ data.DeviceTracking = types.BoolValue(false)
+ }
} else {
- data.AuthenticationPeriodic = types.BoolValue(false)
+ data.DeviceTracking = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-sanet:authentication.timer.reauthenticate.value-config"); value.Exists() {
- data.AuthenticationTimerReauthenticate = types.Int64Value(value.Int())
+ for i := range data.DeviceTrackingAttachedPolicies {
+ keys := [...]string{"attach-policy"}
+ keyValues := [...]string{data.DeviceTrackingAttachedPolicies[i].Name.ValueString()}
+
+ var r gjson.Result
+ res.Get(prefix + "Cisco-IOS-XE-switch:device-tracking.attached-policies").ForEach(
+ func(_, v gjson.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := r.Get("attach-policy"); value.Exists() && !data.DeviceTrackingAttachedPolicies[i].Name.IsNull() {
+ data.DeviceTrackingAttachedPolicies[i].Name = types.StringValue(value.String())
+ } else {
+ data.DeviceTrackingAttachedPolicies[i].Name = types.StringNull()
+ }
}
- if value := res.Get(prefix + "Cisco-IOS-XE-sanet:authentication.timer.reauthenticate.server-config"); value.Exists() {
- data.AuthenticationTimerReauthenticateServer = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-cdp:cdp.enable"); !data.CdpEnable.IsNull() {
+ if value.Exists() {
+ data.CdpEnable = types.BoolValue(value.Bool())
+ }
} else {
- data.AuthenticationTimerReauthenticateServer = types.BoolValue(false)
+ data.CdpEnable = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-sanet:authentication.event.server.alive.action.reinitialize"); value.Exists() {
- data.AuthenticationEventServerAliveActionReinitialize = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-cdp:cdp.tlv.default-wrp.app"); !data.CdpTlvApp.IsNull() {
+ if value.Exists() {
+ data.CdpTlvApp = types.BoolValue(value.Bool())
+ }
} else {
- data.AuthenticationEventServerAliveActionReinitialize = types.BoolValue(false)
+ data.CdpTlvApp = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-sanet:authentication.event.server.dead.action.authorize"); value.Exists() {
- data.AuthenticationEventServerDeadActionAuthorize = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-cdp:cdp.tlv.location-config"); !data.CdpTlvLocation.IsNull() {
+ if value.Exists() {
+ data.CdpTlvLocation = types.BoolValue(value.Bool())
+ }
} else {
- data.AuthenticationEventServerDeadActionAuthorize = types.BoolValue(false)
- }
- if value := res.Get(prefix + "Cisco-IOS-XE-sanet:authentication.event.server.dead.action.authorize.vlan"); value.Exists() {
- data.AuthenticationEventServerDeadActionAuthorizeVlan = types.Int64Value(value.Int())
+ data.CdpTlvLocation = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-sanet:authentication.event.server.dead.action.authorize.voice"); value.Exists() {
- data.AuthenticationEventServerDeadActionAuthorizeVoice = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-cdp:cdp.tlv.server-location-config"); !data.CdpTlvServerLocation.IsNull() {
+ if value.Exists() {
+ data.CdpTlvServerLocation = types.BoolValue(value.Bool())
+ }
} else {
- data.AuthenticationEventServerDeadActionAuthorizeVoice = types.BoolValue(false)
+ data.CdpTlvServerLocation = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-sanet:authentication.event.server.dead.action.reinitialize.vlan"); value.Exists() {
- data.AuthenticationEventServerDeadActionReinitializeVlan = types.Int64Value(value.Int())
+ if value := res.Get(prefix + "ip.Cisco-IOS-XE-nat:nat.inside"); !data.IpNatInside.IsNull() {
+ if value.Exists() {
+ data.IpNatInside = types.BoolValue(true)
+ } else {
+ data.IpNatInside = types.BoolValue(false)
+ }
+ } else {
+ data.IpNatInside = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-sanet:authentication.event.fail-config.action.authorize.vlan"); value.Exists() {
- data.AuthenticationEventFailActionAuthorizeVlan = types.Int64Value(value.Int())
- }
- if value := res.Get(prefix + "Cisco-IOS-XE-sanet:authentication.event.fail-config.action.next-method"); value.Exists() {
- data.AuthenticationEventFailActionNextMethod = types.BoolValue(true)
- } else {
- data.AuthenticationEventFailActionNextMethod = types.BoolValue(false)
- }
- if value := res.Get(prefix + "Cisco-IOS-XE-sanet:authentication.event.no-response.action.authorize.vlan"); value.Exists() {
- data.AuthenticationEventNoResponseActionAuthorizeVlan = types.Int64Value(value.Int())
- }
- if value := res.Get(prefix + "Cisco-IOS-XE-sanet:authentication.event.linksec.fail.action.next-method"); value.Exists() {
- data.AuthenticationEventLinksecFailActionNextMethod = types.BoolValue(true)
- } else {
- data.AuthenticationEventLinksecFailActionNextMethod = types.BoolValue(false)
- }
- if value := res.Get(prefix + "Cisco-IOS-XE-sanet:mab"); value.Exists() {
- data.Mab = types.BoolValue(true)
- } else {
- data.Mab = types.BoolValue(false)
- }
- if value := res.Get(prefix + "Cisco-IOS-XE-sanet:mab.eap"); value.Exists() {
- data.MabEap = types.BoolValue(true)
- } else {
- data.MabEap = types.BoolValue(false)
- }
- if value := res.Get(prefix + "Cisco-IOS-XE-dot1x:dot1x.pae"); value.Exists() {
- data.Dot1xPae = types.StringValue(value.String())
- }
- if value := res.Get(prefix + "Cisco-IOS-XE-dot1x:dot1x.timeout.auth-period"); value.Exists() {
- data.Dot1xTimeoutAuthPeriod = types.Int64Value(value.Int())
- }
- if value := res.Get(prefix + "Cisco-IOS-XE-dot1x:dot1x.timeout.held-period"); value.Exists() {
- data.Dot1xTimeoutHeldPeriod = types.Int64Value(value.Int())
- }
- if value := res.Get(prefix + "Cisco-IOS-XE-dot1x:dot1x.timeout.quiet-period"); value.Exists() {
- data.Dot1xTimeoutQuietPeriod = types.Int64Value(value.Int())
- }
- if value := res.Get(prefix + "Cisco-IOS-XE-dot1x:dot1x.timeout.ratelimit-period"); value.Exists() {
- data.Dot1xTimeoutRatelimitPeriod = types.Int64Value(value.Int())
- }
- if value := res.Get(prefix + "Cisco-IOS-XE-dot1x:dot1x.timeout.server-timeout"); value.Exists() {
- data.Dot1xTimeoutServerTimeout = types.Int64Value(value.Int())
- }
- if value := res.Get(prefix + "Cisco-IOS-XE-dot1x:dot1x.timeout.start-period"); value.Exists() {
- data.Dot1xTimeoutStartPeriod = types.Int64Value(value.Int())
- }
- if value := res.Get(prefix + "Cisco-IOS-XE-dot1x:dot1x.timeout.supp-timeout"); value.Exists() {
- data.Dot1xTimeoutSuppTimeout = types.Int64Value(value.Int())
- }
- if value := res.Get(prefix + "Cisco-IOS-XE-dot1x:dot1x.timeout.tx-period"); value.Exists() {
- data.Dot1xTimeoutTxPeriod = types.Int64Value(value.Int())
- }
- if value := res.Get(prefix + "Cisco-IOS-XE-dot1x:dot1x.max-req"); value.Exists() {
- data.Dot1xMaxReq = types.Int64Value(value.Int())
- }
- if value := res.Get(prefix + "Cisco-IOS-XE-dot1x:dot1x.max-reauth-req"); value.Exists() {
- data.Dot1xMaxReauthReq = types.Int64Value(value.Int())
- }
- if value := res.Get(prefix + "Cisco-IOS-XE-policy:service-policy.input"); value.Exists() {
- data.ServicePolicyInput = types.StringValue(value.String())
- }
- if value := res.Get(prefix + "Cisco-IOS-XE-policy:service-policy.output"); value.Exists() {
- data.ServicePolicyOutput = types.StringValue(value.String())
- }
- if value := res.Get(prefix + "ip.Cisco-IOS-XE-flow:flow.monitor-new"); value.Exists() {
- data.IpFlowMonitors = make([]InterfaceEthernetIpFlowMonitors, 0)
- value.ForEach(func(k, v gjson.Result) bool {
- item := InterfaceEthernetIpFlowMonitors{}
- if cValue := v.Get("name"); cValue.Exists() {
- item.Name = types.StringValue(cValue.String())
- }
- if cValue := v.Get("direction"); cValue.Exists() {
- item.Direction = types.StringValue(cValue.String())
- }
- data.IpFlowMonitors = append(data.IpFlowMonitors, item)
- return true
- })
- }
- if value := res.Get(prefix + "load-interval"); value.Exists() {
- data.LoadInterval = types.Int64Value(value.Int())
- }
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:snmp.trap.link-status"); value.Exists() {
- data.SnmpTrapLinkStatus = types.BoolValue(value.Bool())
- } else {
- data.SnmpTrapLinkStatus = types.BoolNull()
- }
- if value := res.Get(prefix + "logging.event.link-status-enable"); value.Exists() {
- data.LoggingEventLinkStatusEnable = types.BoolValue(value.Bool())
- } else {
- data.LoggingEventLinkStatusEnable = types.BoolNull()
- }
- if value := res.Get(prefix + "ip.Cisco-IOS-XE-nbar:nbar.protocol-discovery"); value.Exists() {
- data.IpNbarProtocolDiscovery = types.BoolValue(true)
- } else {
- data.IpNbarProtocolDiscovery = types.BoolValue(false)
- }
- if value := res.Get(prefix + "Cisco-IOS-XE-switch:device-tracking"); value.Exists() {
- data.DeviceTracking = types.BoolValue(true)
- } else {
- data.DeviceTracking = types.BoolValue(false)
- }
- if value := res.Get(prefix + "Cisco-IOS-XE-switch:device-tracking.attached-policies"); value.Exists() {
- data.DeviceTrackingAttachedPolicies = make([]InterfaceEthernetDeviceTrackingAttachedPolicies, 0)
- value.ForEach(func(k, v gjson.Result) bool {
- item := InterfaceEthernetDeviceTrackingAttachedPolicies{}
- if cValue := v.Get("attach-policy"); cValue.Exists() {
- item.Name = types.StringValue(cValue.String())
- }
- data.DeviceTrackingAttachedPolicies = append(data.DeviceTrackingAttachedPolicies, item)
- return true
- })
- }
- if value := res.Get(prefix + "Cisco-IOS-XE-cdp:cdp.enable"); value.Exists() {
- data.CdpEnable = types.BoolValue(value.Bool())
- } else {
- data.CdpEnable = types.BoolNull()
- }
- if value := res.Get(prefix + "Cisco-IOS-XE-cdp:cdp.tlv.default-wrp.app"); value.Exists() {
- data.CdpTlvApp = types.BoolValue(value.Bool())
- } else {
- data.CdpTlvApp = types.BoolNull()
- }
- if value := res.Get(prefix + "Cisco-IOS-XE-cdp:cdp.tlv.location-config"); value.Exists() {
- data.CdpTlvLocation = types.BoolValue(value.Bool())
- } else {
- data.CdpTlvLocation = types.BoolNull()
- }
- if value := res.Get(prefix + "Cisco-IOS-XE-cdp:cdp.tlv.server-location-config"); value.Exists() {
- data.CdpTlvServerLocation = types.BoolValue(value.Bool())
- } else {
- data.CdpTlvServerLocation = types.BoolNull()
- }
- if value := res.Get(prefix + "ip.Cisco-IOS-XE-nat:nat.inside"); value.Exists() {
- data.IpNatInside = types.BoolValue(true)
- } else {
- data.IpNatInside = types.BoolValue(false)
- }
- if value := res.Get(prefix + "ip.Cisco-IOS-XE-nat:nat.outside"); value.Exists() {
- data.IpNatOutside = types.BoolValue(true)
+ if value := res.Get(prefix + "ip.Cisco-IOS-XE-nat:nat.outside"); !data.IpNatOutside.IsNull() {
+ if value.Exists() {
+ data.IpNatOutside = types.BoolValue(true)
+ } else {
+ data.IpNatOutside = types.BoolValue(false)
+ }
} else {
- data.IpNatOutside = types.BoolValue(false)
+ data.IpNatOutside = types.BoolNull()
}
}
-// End of section. //template:end fromBody
+// End of section. //template:end updateFromBody
-// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyData
+// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBodyXML
-func (data *InterfaceEthernetData) fromBody(ctx context.Context, res gjson.Result) {
- prefix := helpers.LastElement(data.getPath()) + "."
- if res.Get(helpers.LastElement(data.getPath())).IsArray() {
- prefix += "0."
+func (data *InterfaceEthernet) updateFromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/name"); value.Exists() && !data.Name.IsNull() {
+ data.Name = types.StringValue(value.String())
+ } else {
+ data.Name = types.StringNull()
}
- if value := res.Get(prefix + "media-type"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/media-type"); value.Exists() && !data.MediaType.IsNull() {
data.MediaType = types.StringValue(value.String())
+ } else {
+ data.MediaType = types.StringNull()
}
- if value := res.Get(prefix + "mtu"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/mtu"); value.Exists() && !data.Mtu.IsNull() {
data.Mtu = types.Int64Value(value.Int())
+ } else {
+ data.Mtu = types.Int64Null()
}
- if value := res.Get(prefix + "bandwidth.kilobits"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/bandwidth/kilobits"); value.Exists() && !data.Bandwidth.IsNull() {
data.Bandwidth = types.Int64Value(value.Int())
+ } else {
+ data.Bandwidth = types.Int64Null()
}
- if value := res.Get(prefix + "switchport-conf.switchport"); value.Exists() {
- data.Switchport = types.BoolValue(value.Bool())
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/switchport-conf/switchport"); !data.Switchport.IsNull() {
+ if value.Exists() {
+ data.Switchport = types.BoolValue(value.Bool())
+ }
} else {
data.Switchport = types.BoolNull()
}
- if value := res.Get(prefix + "description"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/description"); value.Exists() && !data.Description.IsNull() {
data.Description = types.StringValue(value.String())
+ } else {
+ data.Description = types.StringNull()
}
- if value := res.Get(prefix + "shutdown"); value.Exists() {
- data.Shutdown = types.BoolValue(true)
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/shutdown"); !data.Shutdown.IsNull() {
+ if value.Exists() {
+ data.Shutdown = types.BoolValue(true)
+ } else {
+ data.Shutdown = types.BoolValue(false)
+ }
} else {
- data.Shutdown = types.BoolValue(false)
+ data.Shutdown = types.BoolNull()
}
- if value := res.Get(prefix + "ip.proxy-arp"); value.Exists() {
- data.IpProxyArp = types.BoolValue(value.Bool())
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/proxy-arp"); !data.IpProxyArp.IsNull() {
+ if value.Exists() {
+ data.IpProxyArp = types.BoolValue(value.Bool())
+ }
} else {
data.IpProxyArp = types.BoolNull()
}
- if value := res.Get(prefix + "ip.redirects"); value.Exists() {
- data.IpRedirects = types.BoolValue(value.Bool())
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/redirects"); !data.IpRedirects.IsNull() {
+ if value.Exists() {
+ data.IpRedirects = types.BoolValue(value.Bool())
+ }
} else {
data.IpRedirects = types.BoolNull()
}
- if value := res.Get(prefix + "ip.Cisco-IOS-XE-icmp:unreachables"); value.Exists() {
- data.IpUnreachables = types.BoolValue(value.Bool())
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/Cisco-IOS-XE-icmp:unreachables"); !data.IpUnreachables.IsNull() {
+ if value.Exists() {
+ data.IpUnreachables = types.BoolValue(value.Bool())
+ }
} else {
data.IpUnreachables = types.BoolNull()
}
- if value := res.Get(prefix + "vrf.forwarding"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/vrf/forwarding"); value.Exists() && !data.VrfForwarding.IsNull() {
data.VrfForwarding = types.StringValue(value.String())
+ } else {
+ data.VrfForwarding = types.StringNull()
}
- if value := res.Get(prefix + "ip.address.primary.address"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/address/primary/address"); value.Exists() && !data.Ipv4Address.IsNull() {
data.Ipv4Address = types.StringValue(value.String())
+ } else {
+ data.Ipv4Address = types.StringNull()
}
- if value := res.Get(prefix + "ip.address.primary.mask"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/address/primary/mask"); value.Exists() && !data.Ipv4AddressMask.IsNull() {
data.Ipv4AddressMask = types.StringValue(value.String())
+ } else {
+ data.Ipv4AddressMask = types.StringNull()
}
- if value := res.Get(prefix + "ip.unnumbered"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/unnumbered"); value.Exists() && !data.Unnumbered.IsNull() {
data.Unnumbered = types.StringValue(value.String())
+ } else {
+ data.Unnumbered = types.StringNull()
}
- if value := res.Get(prefix + "encapsulation.dot1Q.vlan-id"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/encapsulation/dot1Q/vlan-id"); value.Exists() && !data.EncapsulationDot1qVlanId.IsNull() {
data.EncapsulationDot1qVlanId = types.Int64Value(value.Int())
+ } else {
+ data.EncapsulationDot1qVlanId = types.Int64Null()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-ethernet:channel-group.number"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-ethernet:channel-group/number"); value.Exists() && !data.ChannelGroupNumber.IsNull() {
data.ChannelGroupNumber = types.Int64Value(value.Int())
+ } else {
+ data.ChannelGroupNumber = types.Int64Null()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-ethernet:channel-group.mode"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-ethernet:channel-group/mode"); value.Exists() && !data.ChannelGroupMode.IsNull() {
data.ChannelGroupMode = types.StringValue(value.String())
+ } else {
+ data.ChannelGroupMode = types.StringNull()
}
- if value := res.Get(prefix + "ip.dhcp.Cisco-IOS-XE-dhcp:relay.source-interface"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/dhcp/Cisco-IOS-XE-dhcp:relay/source-interface"); value.Exists() && !data.IpDhcpRelaySourceInterface.IsNull() {
data.IpDhcpRelaySourceInterface = types.StringValue(value.String())
+ } else {
+ data.IpDhcpRelaySourceInterface = types.StringNull()
}
- if value := res.Get(prefix + "ip.access-group.in.acl.in"); value.Exists() {
- data.IpAccessGroupInEnable = types.BoolValue(true)
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/access-group/in/acl/in"); !data.IpAccessGroupInEnable.IsNull() {
+ if value.Exists() {
+ data.IpAccessGroupInEnable = types.BoolValue(true)
+ } else {
+ data.IpAccessGroupInEnable = types.BoolValue(false)
+ }
} else {
- data.IpAccessGroupInEnable = types.BoolValue(false)
+ data.IpAccessGroupInEnable = types.BoolNull()
}
- if value := res.Get(prefix + "ip.access-group.in.acl.acl-name"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/access-group/in/acl/acl-name"); value.Exists() && !data.IpAccessGroupIn.IsNull() {
data.IpAccessGroupIn = types.StringValue(value.String())
+ } else {
+ data.IpAccessGroupIn = types.StringNull()
}
- if value := res.Get(prefix + "ip.access-group.out.acl.out"); value.Exists() {
- data.IpAccessGroupOutEnable = types.BoolValue(true)
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/access-group/out/acl/out"); !data.IpAccessGroupOutEnable.IsNull() {
+ if value.Exists() {
+ data.IpAccessGroupOutEnable = types.BoolValue(true)
+ } else {
+ data.IpAccessGroupOutEnable = types.BoolValue(false)
+ }
} else {
- data.IpAccessGroupOutEnable = types.BoolValue(false)
+ data.IpAccessGroupOutEnable = types.BoolNull()
}
- if value := res.Get(prefix + "ip.access-group.out.acl.acl-name"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/access-group/out/acl/acl-name"); value.Exists() && !data.IpAccessGroupOut.IsNull() {
data.IpAccessGroupOut = types.StringValue(value.String())
+ } else {
+ data.IpAccessGroupOut = types.StringNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-spanning-tree:spanning-tree.guard"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-spanning-tree:spanning-tree/guard"); value.Exists() && !data.SpanningTreeGuard.IsNull() {
data.SpanningTreeGuard = types.StringValue(value.String())
- }
- if value := res.Get(prefix + "Cisco-IOS-XE-switch:auto.qos.classify"); value.Exists() {
- data.AutoQosClassify = types.BoolValue(true)
} else {
- data.AutoQosClassify = types.BoolValue(false)
+ data.SpanningTreeGuard = types.StringNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-switch:auto.qos.classify.police"); value.Exists() {
- data.AutoQosClassifyPolice = types.BoolValue(true)
- } else {
- data.AutoQosClassifyPolice = types.BoolValue(false)
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/classify"); !data.AutoQosClassify.IsNull() {
+ if value.Exists() {
+ data.AutoQosClassify = types.BoolValue(true)
+ } else {
+ data.AutoQosClassify = types.BoolValue(false)
+ }
+ } else {
+ data.AutoQosClassify = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-switch:auto.qos.trust"); value.Exists() {
- data.AutoQosTrust = types.BoolValue(true)
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/classify/police"); !data.AutoQosClassifyPolice.IsNull() {
+ if value.Exists() {
+ data.AutoQosClassifyPolice = types.BoolValue(true)
+ } else {
+ data.AutoQosClassifyPolice = types.BoolValue(false)
+ }
} else {
- data.AutoQosTrust = types.BoolValue(false)
+ data.AutoQosClassifyPolice = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-switch:auto.qos.trust.cos"); value.Exists() {
- data.AutoQosTrustCos = types.BoolValue(true)
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/trust"); !data.AutoQosTrust.IsNull() {
+ if value.Exists() {
+ data.AutoQosTrust = types.BoolValue(true)
+ } else {
+ data.AutoQosTrust = types.BoolValue(false)
+ }
} else {
- data.AutoQosTrustCos = types.BoolValue(false)
+ data.AutoQosTrust = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-switch:auto.qos.trust.dscp"); value.Exists() {
- data.AutoQosTrustDscp = types.BoolValue(true)
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/trust/cos"); !data.AutoQosTrustCos.IsNull() {
+ if value.Exists() {
+ data.AutoQosTrustCos = types.BoolValue(true)
+ } else {
+ data.AutoQosTrustCos = types.BoolValue(false)
+ }
} else {
- data.AutoQosTrustDscp = types.BoolValue(false)
+ data.AutoQosTrustCos = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-switch:auto.qos.video.cts"); value.Exists() {
- data.AutoQosVideoCts = types.BoolValue(true)
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/trust/dscp"); !data.AutoQosTrustDscp.IsNull() {
+ if value.Exists() {
+ data.AutoQosTrustDscp = types.BoolValue(true)
+ } else {
+ data.AutoQosTrustDscp = types.BoolValue(false)
+ }
} else {
- data.AutoQosVideoCts = types.BoolValue(false)
+ data.AutoQosTrustDscp = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-switch:auto.qos.video.ip-camera"); value.Exists() {
- data.AutoQosVideoIpCamera = types.BoolValue(true)
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/video/cts"); !data.AutoQosVideoCts.IsNull() {
+ if value.Exists() {
+ data.AutoQosVideoCts = types.BoolValue(true)
+ } else {
+ data.AutoQosVideoCts = types.BoolValue(false)
+ }
} else {
- data.AutoQosVideoIpCamera = types.BoolValue(false)
+ data.AutoQosVideoCts = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-switch:auto.qos.video.media-player"); value.Exists() {
- data.AutoQosVideoMediaPlayer = types.BoolValue(true)
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/video/ip-camera"); !data.AutoQosVideoIpCamera.IsNull() {
+ if value.Exists() {
+ data.AutoQosVideoIpCamera = types.BoolValue(true)
+ } else {
+ data.AutoQosVideoIpCamera = types.BoolValue(false)
+ }
} else {
- data.AutoQosVideoMediaPlayer = types.BoolValue(false)
+ data.AutoQosVideoIpCamera = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-switch:auto.qos.voip"); value.Exists() {
- data.AutoQosVoip = types.BoolValue(true)
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/video/media-player"); !data.AutoQosVideoMediaPlayer.IsNull() {
+ if value.Exists() {
+ data.AutoQosVideoMediaPlayer = types.BoolValue(true)
+ } else {
+ data.AutoQosVideoMediaPlayer = types.BoolValue(false)
+ }
} else {
- data.AutoQosVoip = types.BoolValue(false)
+ data.AutoQosVideoMediaPlayer = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-switch:auto.qos.voip.cisco-phone"); value.Exists() {
- data.AutoQosVoipCiscoPhone = types.BoolValue(true)
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/voip"); !data.AutoQosVoip.IsNull() {
+ if value.Exists() {
+ data.AutoQosVoip = types.BoolValue(true)
+ } else {
+ data.AutoQosVoip = types.BoolValue(false)
+ }
} else {
- data.AutoQosVoipCiscoPhone = types.BoolValue(false)
+ data.AutoQosVoip = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-switch:auto.qos.voip.cisco-softphone"); value.Exists() {
- data.AutoQosVoipCiscoSoftphone = types.BoolValue(true)
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/voip/cisco-phone"); !data.AutoQosVoipCiscoPhone.IsNull() {
+ if value.Exists() {
+ data.AutoQosVoipCiscoPhone = types.BoolValue(true)
+ } else {
+ data.AutoQosVoipCiscoPhone = types.BoolValue(false)
+ }
} else {
- data.AutoQosVoipCiscoSoftphone = types.BoolValue(false)
+ data.AutoQosVoipCiscoPhone = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-switch:auto.qos.voip.trust"); value.Exists() {
- data.AutoQosVoipTrust = types.BoolValue(true)
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/voip/cisco-softphone"); !data.AutoQosVoipCiscoSoftphone.IsNull() {
+ if value.Exists() {
+ data.AutoQosVoipCiscoSoftphone = types.BoolValue(true)
+ } else {
+ data.AutoQosVoipCiscoSoftphone = types.BoolValue(false)
+ }
} else {
- data.AutoQosVoipTrust = types.BoolValue(false)
+ data.AutoQosVoipCiscoSoftphone = types.BoolNull()
}
- if value := res.Get(prefix + "trust.device"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/voip/trust"); !data.AutoQosVoipTrust.IsNull() {
+ if value.Exists() {
+ data.AutoQosVoipTrust = types.BoolValue(true)
+ } else {
+ data.AutoQosVoipTrust = types.BoolValue(false)
+ }
+ } else {
+ data.AutoQosVoipTrust = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/trust/device"); value.Exists() && !data.TrustDevice.IsNull() {
data.TrustDevice = types.StringValue(value.String())
+ } else {
+ data.TrustDevice = types.StringNull()
}
- if value := res.Get(prefix + "ip.helper-address"); value.Exists() {
- data.HelperAddresses = make([]InterfaceEthernetHelperAddresses, 0)
- value.ForEach(func(k, v gjson.Result) bool {
- item := InterfaceEthernetHelperAddresses{}
- if cValue := v.Get("address"); cValue.Exists() {
- item.Address = types.StringValue(cValue.String())
- }
- if cValue := v.Get("global"); cValue.Exists() {
- item.Global = types.BoolValue(true)
+ for i := range data.HelperAddresses {
+ keys := [...]string{"address"}
+ keyValues := [...]string{data.HelperAddresses[i].Address.ValueString()}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/helper-address").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, "address"); value.Exists() && !data.HelperAddresses[i].Address.IsNull() {
+ data.HelperAddresses[i].Address = types.StringValue(value.String())
+ } else {
+ data.HelperAddresses[i].Address = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "global"); !data.HelperAddresses[i].Global.IsNull() {
+ if value.Exists() {
+ data.HelperAddresses[i].Global = types.BoolValue(true)
} else {
- item.Global = types.BoolValue(false)
- }
- if cValue := v.Get("vrf"); cValue.Exists() {
- item.Vrf = types.StringValue(cValue.String())
+ data.HelperAddresses[i].Global = types.BoolValue(false)
}
- data.HelperAddresses = append(data.HelperAddresses, item)
- return true
- })
+ } else {
+ data.HelperAddresses[i].Global = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "vrf"); value.Exists() && !data.HelperAddresses[i].Vrf.IsNull() {
+ data.HelperAddresses[i].Vrf = types.StringValue(value.String())
+ } else {
+ data.HelperAddresses[i].Vrf = types.StringNull()
+ }
}
- if value := res.Get(prefix + "source.template.template-name"); value.Exists() {
- data.SourceTemplate = make([]InterfaceEthernetSourceTemplate, 0)
- value.ForEach(func(k, v gjson.Result) bool {
- item := InterfaceEthernetSourceTemplate{}
- if cValue := v.Get("template-name"); cValue.Exists() {
- item.TemplateName = types.StringValue(cValue.String())
- }
- if cValue := v.Get("merge"); cValue.Exists() {
- item.Merge = types.BoolValue(true)
+ for i := range data.SourceTemplate {
+ keys := [...]string{"template-name"}
+ keyValues := [...]string{data.SourceTemplate[i].TemplateName.ValueString()}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/source/template/template-name").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, "template-name"); value.Exists() && !data.SourceTemplate[i].TemplateName.IsNull() {
+ data.SourceTemplate[i].TemplateName = types.StringValue(value.String())
+ } else {
+ data.SourceTemplate[i].TemplateName = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "merge"); !data.SourceTemplate[i].Merge.IsNull() {
+ if value.Exists() {
+ data.SourceTemplate[i].Merge = types.BoolValue(true)
} else {
- item.Merge = types.BoolValue(false)
+ data.SourceTemplate[i].Merge = types.BoolValue(false)
}
- data.SourceTemplate = append(data.SourceTemplate, item)
- return true
- })
+ } else {
+ data.SourceTemplate[i].Merge = types.BoolNull()
+ }
}
- if value := res.Get(prefix + "bfd.Cisco-IOS-XE-bfd:template"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/bfd/Cisco-IOS-XE-bfd:template"); value.Exists() && !data.BfdTemplate.IsNull() {
data.BfdTemplate = types.StringValue(value.String())
+ } else {
+ data.BfdTemplate = types.StringNull()
}
- if value := res.Get(prefix + "bfd.Cisco-IOS-XE-bfd:enable"); value.Exists() {
- data.BfdEnable = types.BoolValue(value.Bool())
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/bfd/Cisco-IOS-XE-bfd:enable"); !data.BfdEnable.IsNull() {
+ if value.Exists() {
+ data.BfdEnable = types.BoolValue(value.Bool())
+ }
} else {
data.BfdEnable = types.BoolNull()
}
- if value := res.Get(prefix + "bfd.Cisco-IOS-XE-bfd:local-address"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/bfd/Cisco-IOS-XE-bfd:local-address"); value.Exists() && !data.BfdLocalAddress.IsNull() {
data.BfdLocalAddress = types.StringValue(value.String())
+ } else {
+ data.BfdLocalAddress = types.StringNull()
}
- if value := res.Get(prefix + "bfd.Cisco-IOS-XE-bfd:interval-interface.msecs"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/bfd/Cisco-IOS-XE-bfd:interval-interface/msecs"); value.Exists() && !data.BfdInterval.IsNull() {
data.BfdInterval = types.Int64Value(value.Int())
+ } else {
+ data.BfdInterval = types.Int64Null()
}
- if value := res.Get(prefix + "bfd.Cisco-IOS-XE-bfd:interval-interface.min_rx"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/bfd/Cisco-IOS-XE-bfd:interval-interface/min_rx"); value.Exists() && !data.BfdIntervalMinRx.IsNull() {
data.BfdIntervalMinRx = types.Int64Value(value.Int())
+ } else {
+ data.BfdIntervalMinRx = types.Int64Null()
}
- if value := res.Get(prefix + "bfd.Cisco-IOS-XE-bfd:interval-interface.multiplier"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/bfd/Cisco-IOS-XE-bfd:interval-interface/multiplier"); value.Exists() && !data.BfdIntervalMultiplier.IsNull() {
data.BfdIntervalMultiplier = types.Int64Value(value.Int())
+ } else {
+ data.BfdIntervalMultiplier = types.Int64Null()
}
- if value := res.Get(prefix + "bfd.Cisco-IOS-XE-bfd:echo"); value.Exists() {
- data.BfdEcho = types.BoolValue(value.Bool())
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/bfd/Cisco-IOS-XE-bfd:echo"); !data.BfdEcho.IsNull() {
+ if value.Exists() {
+ data.BfdEcho = types.BoolValue(value.Bool())
+ }
} else {
data.BfdEcho = types.BoolNull()
}
- if value := res.Get(prefix + "ipv6.enable"); value.Exists() {
- data.Ipv6Enable = types.BoolValue(true)
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ipv6/enable"); !data.Ipv6Enable.IsNull() {
+ if value.Exists() {
+ data.Ipv6Enable = types.BoolValue(true)
+ } else {
+ data.Ipv6Enable = types.BoolValue(false)
+ }
} else {
- data.Ipv6Enable = types.BoolValue(false)
+ data.Ipv6Enable = types.BoolNull()
}
- if value := res.Get(prefix + "ipv6.mtu"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ipv6/mtu"); value.Exists() && !data.Ipv6Mtu.IsNull() {
data.Ipv6Mtu = types.Int64Value(value.Int())
- }
- if value := res.Get(prefix + "ipv6.nd.Cisco-IOS-XE-nd:ra.suppress.all"); value.Exists() {
- data.Ipv6NdRaSuppressAll = types.BoolValue(true)
} else {
- data.Ipv6NdRaSuppressAll = types.BoolValue(false)
- }
- if value := res.Get(prefix + "ipv6.address.autoconfig.default"); value.Exists() {
- data.Ipv6AddressAutoconfigDefault = types.BoolValue(true)
- } else {
- data.Ipv6AddressAutoconfigDefault = types.BoolValue(false)
+ data.Ipv6Mtu = types.Int64Null()
}
- if value := res.Get(prefix + "ipv6.address.dhcp"); value.Exists() {
- data.Ipv6AddressDhcp = types.BoolValue(true)
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ipv6/nd/Cisco-IOS-XE-nd:ra/suppress/all"); !data.Ipv6NdRaSuppressAll.IsNull() {
+ if value.Exists() {
+ data.Ipv6NdRaSuppressAll = types.BoolValue(true)
+ } else {
+ data.Ipv6NdRaSuppressAll = types.BoolValue(false)
+ }
} else {
- data.Ipv6AddressDhcp = types.BoolValue(false)
+ data.Ipv6NdRaSuppressAll = types.BoolNull()
}
- if value := res.Get(prefix + "ipv6.address.link-local-address"); value.Exists() {
- data.Ipv6LinkLocalAddresses = make([]InterfaceEthernetIpv6LinkLocalAddresses, 0)
- value.ForEach(func(k, v gjson.Result) bool {
- item := InterfaceEthernetIpv6LinkLocalAddresses{}
- if cValue := v.Get("address"); cValue.Exists() {
- item.Address = types.StringValue(cValue.String())
- }
- if cValue := v.Get("link-local"); cValue.Exists() {
- item.LinkLocal = types.BoolValue(true)
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ipv6/address/autoconfig/default"); !data.Ipv6AddressAutoconfigDefault.IsNull() {
+ if value.Exists() {
+ data.Ipv6AddressAutoconfigDefault = types.BoolValue(true)
+ } else {
+ data.Ipv6AddressAutoconfigDefault = types.BoolValue(false)
+ }
+ } else {
+ data.Ipv6AddressAutoconfigDefault = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ipv6/address/dhcp"); !data.Ipv6AddressDhcp.IsNull() {
+ if value.Exists() {
+ data.Ipv6AddressDhcp = types.BoolValue(true)
+ } else {
+ data.Ipv6AddressDhcp = types.BoolValue(false)
+ }
+ } else {
+ data.Ipv6AddressDhcp = types.BoolNull()
+ }
+ for i := range data.Ipv6LinkLocalAddresses {
+ keys := [...]string{"address"}
+ keyValues := [...]string{data.Ipv6LinkLocalAddresses[i].Address.ValueString()}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ipv6/address/link-local-address").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, "address"); value.Exists() && !data.Ipv6LinkLocalAddresses[i].Address.IsNull() {
+ data.Ipv6LinkLocalAddresses[i].Address = types.StringValue(value.String())
+ } else {
+ data.Ipv6LinkLocalAddresses[i].Address = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "link-local"); !data.Ipv6LinkLocalAddresses[i].LinkLocal.IsNull() {
+ if value.Exists() {
+ data.Ipv6LinkLocalAddresses[i].LinkLocal = types.BoolValue(true)
} else {
- item.LinkLocal = types.BoolValue(false)
+ data.Ipv6LinkLocalAddresses[i].LinkLocal = types.BoolValue(false)
}
- data.Ipv6LinkLocalAddresses = append(data.Ipv6LinkLocalAddresses, item)
- return true
- })
+ } else {
+ data.Ipv6LinkLocalAddresses[i].LinkLocal = types.BoolNull()
+ }
}
- if value := res.Get(prefix + "ipv6.address.prefix-list"); value.Exists() {
- data.Ipv6Addresses = make([]InterfaceEthernetIpv6Addresses, 0)
- value.ForEach(func(k, v gjson.Result) bool {
- item := InterfaceEthernetIpv6Addresses{}
- if cValue := v.Get("prefix"); cValue.Exists() {
- item.Prefix = types.StringValue(cValue.String())
- }
- if cValue := v.Get("eui-64"); cValue.Exists() {
- item.Eui64 = types.BoolValue(true)
+ for i := range data.Ipv6Addresses {
+ keys := [...]string{"prefix"}
+ keyValues := [...]string{data.Ipv6Addresses[i].Prefix.ValueString()}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ipv6/address/prefix-list").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, "prefix"); value.Exists() && !data.Ipv6Addresses[i].Prefix.IsNull() {
+ data.Ipv6Addresses[i].Prefix = types.StringValue(value.String())
+ } else {
+ data.Ipv6Addresses[i].Prefix = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "eui-64"); !data.Ipv6Addresses[i].Eui64.IsNull() {
+ if value.Exists() {
+ data.Ipv6Addresses[i].Eui64 = types.BoolValue(true)
} else {
- item.Eui64 = types.BoolValue(false)
+ data.Ipv6Addresses[i].Eui64 = types.BoolValue(false)
}
- data.Ipv6Addresses = append(data.Ipv6Addresses, item)
- return true
- })
+ } else {
+ data.Ipv6Addresses[i].Eui64 = types.BoolNull()
+ }
}
- if value := res.Get(prefix + "ipv6.Cisco-IOS-XE-flow:flow.monitor-new"); value.Exists() {
- data.Ipv6FlowMonitors = make([]InterfaceEthernetIpv6FlowMonitors, 0)
- value.ForEach(func(k, v gjson.Result) bool {
- item := InterfaceEthernetIpv6FlowMonitors{}
- if cValue := v.Get("name"); cValue.Exists() {
- item.Name = types.StringValue(cValue.String())
- }
- if cValue := v.Get("direction"); cValue.Exists() {
- item.Direction = types.StringValue(cValue.String())
- }
- data.Ipv6FlowMonitors = append(data.Ipv6FlowMonitors, item)
- return true
- })
+ for i := range data.Ipv6FlowMonitors {
+ keys := [...]string{"name", "direction"}
+ keyValues := [...]string{data.Ipv6FlowMonitors[i].Name.ValueString(), data.Ipv6FlowMonitors[i].Direction.ValueString()}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ipv6/Cisco-IOS-XE-flow:flow/monitor-new").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, "name"); value.Exists() && !data.Ipv6FlowMonitors[i].Name.IsNull() {
+ data.Ipv6FlowMonitors[i].Name = types.StringValue(value.String())
+ } else {
+ data.Ipv6FlowMonitors[i].Name = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "direction"); value.Exists() && !data.Ipv6FlowMonitors[i].Direction.IsNull() {
+ data.Ipv6FlowMonitors[i].Direction = types.StringValue(value.String())
+ } else {
+ data.Ipv6FlowMonitors[i].Direction = types.StringNull()
+ }
}
- if value := res.Get(prefix + "arp.timeout"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/arp/timeout"); value.Exists() && !data.ArpTimeout.IsNull() {
data.ArpTimeout = types.Int64Value(value.Int())
+ } else {
+ data.ArpTimeout = types.Int64Null()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-spanning-tree:spanning-tree.link-type"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-spanning-tree:spanning-tree/link-type"); value.Exists() && !data.SpanningTreeLinkType.IsNull() {
data.SpanningTreeLinkType = types.StringValue(value.String())
+ } else {
+ data.SpanningTreeLinkType = types.StringNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-spanning-tree:spanning-tree.bpduguard.enable"); value.Exists() {
- data.BpduguardEnable = types.BoolValue(true)
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-spanning-tree:spanning-tree/bpduguard/enable"); !data.BpduguardEnable.IsNull() {
+ if value.Exists() {
+ data.BpduguardEnable = types.BoolValue(true)
+ } else {
+ data.BpduguardEnable = types.BoolValue(false)
+ }
} else {
- data.BpduguardEnable = types.BoolValue(false)
+ data.BpduguardEnable = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-spanning-tree:spanning-tree.bpduguard.disable"); value.Exists() {
- data.BpduguardDisable = types.BoolValue(true)
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-spanning-tree:spanning-tree/bpduguard/disable"); !data.BpduguardDisable.IsNull() {
+ if value.Exists() {
+ data.BpduguardDisable = types.BoolValue(true)
+ } else {
+ data.BpduguardDisable = types.BoolValue(false)
+ }
} else {
- data.BpduguardDisable = types.BoolValue(false)
+ data.BpduguardDisable = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-spanning-tree:spanning-tree.portfast"); value.Exists() {
- data.SpanningTreePortfast = types.BoolValue(true)
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-spanning-tree:spanning-tree/portfast"); !data.SpanningTreePortfast.IsNull() {
+ if value.Exists() {
+ data.SpanningTreePortfast = types.BoolValue(true)
+ } else {
+ data.SpanningTreePortfast = types.BoolValue(false)
+ }
} else {
- data.SpanningTreePortfast = types.BoolValue(false)
+ data.SpanningTreePortfast = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-spanning-tree:spanning-tree.portfast.disable"); value.Exists() {
- data.SpanningTreePortfastDisable = types.BoolValue(true)
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-spanning-tree:spanning-tree/portfast/disable"); !data.SpanningTreePortfastDisable.IsNull() {
+ if value.Exists() {
+ data.SpanningTreePortfastDisable = types.BoolValue(true)
+ } else {
+ data.SpanningTreePortfastDisable = types.BoolValue(false)
+ }
} else {
- data.SpanningTreePortfastDisable = types.BoolValue(false)
+ data.SpanningTreePortfastDisable = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-spanning-tree:spanning-tree.portfast.trunk"); value.Exists() {
- data.SpanningTreePortfastTrunk = types.BoolValue(true)
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-spanning-tree:spanning-tree/portfast/trunk"); !data.SpanningTreePortfastTrunk.IsNull() {
+ if value.Exists() {
+ data.SpanningTreePortfastTrunk = types.BoolValue(true)
+ } else {
+ data.SpanningTreePortfastTrunk = types.BoolValue(false)
+ }
} else {
- data.SpanningTreePortfastTrunk = types.BoolValue(false)
+ data.SpanningTreePortfastTrunk = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-spanning-tree:spanning-tree.portfast.edge"); value.Exists() {
- data.SpanningTreePortfastEdge = types.BoolValue(true)
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-spanning-tree:spanning-tree/portfast/edge"); !data.SpanningTreePortfastEdge.IsNull() {
+ if value.Exists() {
+ data.SpanningTreePortfastEdge = types.BoolValue(true)
+ } else {
+ data.SpanningTreePortfastEdge = types.BoolValue(false)
+ }
} else {
- data.SpanningTreePortfastEdge = types.BoolValue(false)
+ data.SpanningTreePortfastEdge = types.BoolNull()
}
- if value := res.Get(prefix + "ip.arp.inspection.trust"); value.Exists() {
- data.IpArpInspectionTrust = types.BoolValue(true)
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/arp/inspection/trust"); !data.IpArpInspectionTrust.IsNull() {
+ if value.Exists() {
+ data.IpArpInspectionTrust = types.BoolValue(true)
+ } else {
+ data.IpArpInspectionTrust = types.BoolValue(false)
+ }
} else {
- data.IpArpInspectionTrust = types.BoolValue(false)
+ data.IpArpInspectionTrust = types.BoolNull()
}
- if value := res.Get(prefix + "ip.arp.inspection.limit.rate"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/arp/inspection/limit/rate"); value.Exists() && !data.IpArpInspectionLimitRate.IsNull() {
data.IpArpInspectionLimitRate = types.Int64Value(value.Int())
- }
- if value := res.Get(prefix + "ip.dhcp.Cisco-IOS-XE-dhcp:snooping.trust"); value.Exists() {
- data.IpDhcpSnoopingTrust = types.BoolValue(true)
} else {
- data.IpDhcpSnoopingTrust = types.BoolValue(false)
+ data.IpArpInspectionLimitRate = types.Int64Null()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-ethernet:speed.value-100"); value.Exists() {
- data.Speed100 = types.BoolValue(true)
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/dhcp/Cisco-IOS-XE-dhcp:snooping/trust"); !data.IpDhcpSnoopingTrust.IsNull() {
+ if value.Exists() {
+ data.IpDhcpSnoopingTrust = types.BoolValue(true)
+ } else {
+ data.IpDhcpSnoopingTrust = types.BoolValue(false)
+ }
} else {
- data.Speed100 = types.BoolValue(false)
+ data.IpDhcpSnoopingTrust = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-ethernet:speed.value-1000"); value.Exists() {
- data.Speed1000 = types.BoolValue(true)
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-ethernet:speed/value-100"); !data.Speed100.IsNull() {
+ if value.Exists() {
+ data.Speed100 = types.BoolValue(true)
+ } else {
+ data.Speed100 = types.BoolValue(false)
+ }
} else {
- data.Speed1000 = types.BoolValue(false)
+ data.Speed100 = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-ethernet:speed.value-2500"); value.Exists() {
- data.Speed2500 = types.BoolValue(true)
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-ethernet:speed/value-1000"); !data.Speed1000.IsNull() {
+ if value.Exists() {
+ data.Speed1000 = types.BoolValue(true)
+ } else {
+ data.Speed1000 = types.BoolValue(false)
+ }
} else {
- data.Speed2500 = types.BoolValue(false)
+ data.Speed1000 = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-ethernet:speed.value-5000"); value.Exists() {
- data.Speed5000 = types.BoolValue(true)
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-ethernet:speed/value-2500"); !data.Speed2500.IsNull() {
+ if value.Exists() {
+ data.Speed2500 = types.BoolValue(true)
+ } else {
+ data.Speed2500 = types.BoolValue(false)
+ }
} else {
- data.Speed5000 = types.BoolValue(false)
+ data.Speed2500 = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-ethernet:speed.value-10000"); value.Exists() {
- data.Speed10000 = types.BoolValue(true)
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-ethernet:speed/value-5000"); !data.Speed5000.IsNull() {
+ if value.Exists() {
+ data.Speed5000 = types.BoolValue(true)
+ } else {
+ data.Speed5000 = types.BoolValue(false)
+ }
} else {
- data.Speed10000 = types.BoolValue(false)
+ data.Speed5000 = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-ethernet:speed.value-25000"); value.Exists() {
- data.Speed25000 = types.BoolValue(true)
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-ethernet:speed/value-10000"); !data.Speed10000.IsNull() {
+ if value.Exists() {
+ data.Speed10000 = types.BoolValue(true)
+ } else {
+ data.Speed10000 = types.BoolValue(false)
+ }
} else {
- data.Speed25000 = types.BoolValue(false)
+ data.Speed10000 = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-ethernet:speed.value-40000"); value.Exists() {
- data.Speed40000 = types.BoolValue(true)
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-ethernet:speed/value-25000"); !data.Speed25000.IsNull() {
+ if value.Exists() {
+ data.Speed25000 = types.BoolValue(true)
+ } else {
+ data.Speed25000 = types.BoolValue(false)
+ }
} else {
- data.Speed40000 = types.BoolValue(false)
+ data.Speed25000 = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-ethernet:speed.value-100000"); value.Exists() {
- data.Speed100000 = types.BoolValue(true)
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-ethernet:speed/value-40000"); !data.Speed40000.IsNull() {
+ if value.Exists() {
+ data.Speed40000 = types.BoolValue(true)
+ } else {
+ data.Speed40000 = types.BoolValue(false)
+ }
} else {
- data.Speed100000 = types.BoolValue(false)
+ data.Speed40000 = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-ethernet:negotiation.auto"); value.Exists() {
- data.NegotiationAuto = types.BoolValue(value.Bool())
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-ethernet:speed/value-100000"); !data.Speed100000.IsNull() {
+ if value.Exists() {
+ data.Speed100000 = types.BoolValue(true)
+ } else {
+ data.Speed100000 = types.BoolValue(false)
+ }
+ } else {
+ data.Speed100000 = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-ethernet:negotiation/auto"); !data.NegotiationAuto.IsNull() {
+ if value.Exists() {
+ data.NegotiationAuto = types.BoolValue(value.Bool())
+ }
} else {
data.NegotiationAuto = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-ethernet:speed.nonegotiate"); value.Exists() {
- data.SpeedNonegotiate = types.BoolValue(true)
- } else {
- data.SpeedNonegotiate = types.BoolValue(false)
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-ethernet:speed/nonegotiate"); !data.SpeedNonegotiate.IsNull() {
+ if value.Exists() {
+ data.SpeedNonegotiate = types.BoolValue(true)
+ } else {
+ data.SpeedNonegotiate = types.BoolValue(false)
+ }
+ } else {
+ data.SpeedNonegotiate = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-sanet:authentication/host-mode"); value.Exists() && !data.AuthenticationHostMode.IsNull() {
+ data.AuthenticationHostMode = types.StringValue(value.String())
+ } else {
+ data.AuthenticationHostMode = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-sanet:authentication/order-config/dot1x-config"); !data.AuthenticationOrderDot1x.IsNull() {
+ if value.Exists() {
+ data.AuthenticationOrderDot1x = types.BoolValue(true)
+ } else {
+ data.AuthenticationOrderDot1x = types.BoolValue(false)
+ }
+ } else {
+ data.AuthenticationOrderDot1x = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-sanet:authentication/order-config/dot1x-config/mab"); !data.AuthenticationOrderDot1xMab.IsNull() {
+ if value.Exists() {
+ data.AuthenticationOrderDot1xMab = types.BoolValue(true)
+ } else {
+ data.AuthenticationOrderDot1xMab = types.BoolValue(false)
+ }
+ } else {
+ data.AuthenticationOrderDot1xMab = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-sanet:authentication/order-config/dot1x-config/webauth"); !data.AuthenticationOrderDot1xWebauth.IsNull() {
+ if value.Exists() {
+ data.AuthenticationOrderDot1xWebauth = types.BoolValue(true)
+ } else {
+ data.AuthenticationOrderDot1xWebauth = types.BoolValue(false)
+ }
+ } else {
+ data.AuthenticationOrderDot1xWebauth = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-sanet:authentication/order-config/mab-config"); !data.AuthenticationOrderMab.IsNull() {
+ if value.Exists() {
+ data.AuthenticationOrderMab = types.BoolValue(true)
+ } else {
+ data.AuthenticationOrderMab = types.BoolValue(false)
+ }
+ } else {
+ data.AuthenticationOrderMab = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-sanet:authentication/order-config/mab-config/dot1x"); !data.AuthenticationOrderMabDot1x.IsNull() {
+ if value.Exists() {
+ data.AuthenticationOrderMabDot1x = types.BoolValue(true)
+ } else {
+ data.AuthenticationOrderMabDot1x = types.BoolValue(false)
+ }
+ } else {
+ data.AuthenticationOrderMabDot1x = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-sanet:authentication/order-config/mab-config/webauth"); !data.AuthenticationOrderMabWebauth.IsNull() {
+ if value.Exists() {
+ data.AuthenticationOrderMabWebauth = types.BoolValue(true)
+ } else {
+ data.AuthenticationOrderMabWebauth = types.BoolValue(false)
+ }
+ } else {
+ data.AuthenticationOrderMabWebauth = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-sanet:authentication/order-config/webauth-config"); !data.AuthenticationOrderWebauth.IsNull() {
+ if value.Exists() {
+ data.AuthenticationOrderWebauth = types.BoolValue(true)
+ } else {
+ data.AuthenticationOrderWebauth = types.BoolValue(false)
+ }
+ } else {
+ data.AuthenticationOrderWebauth = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-sanet:authentication/priority-config/dot1x-config"); !data.AuthenticationPriorityDot1x.IsNull() {
+ if value.Exists() {
+ data.AuthenticationPriorityDot1x = types.BoolValue(true)
+ } else {
+ data.AuthenticationPriorityDot1x = types.BoolValue(false)
+ }
+ } else {
+ data.AuthenticationPriorityDot1x = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-sanet:authentication/priority-config/dot1x-config/mab"); !data.AuthenticationPriorityDot1xMab.IsNull() {
+ if value.Exists() {
+ data.AuthenticationPriorityDot1xMab = types.BoolValue(true)
+ } else {
+ data.AuthenticationPriorityDot1xMab = types.BoolValue(false)
+ }
+ } else {
+ data.AuthenticationPriorityDot1xMab = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-sanet:authentication/priority-config/dot1x-config/webauth"); !data.AuthenticationPriorityDot1xWebauth.IsNull() {
+ if value.Exists() {
+ data.AuthenticationPriorityDot1xWebauth = types.BoolValue(true)
+ } else {
+ data.AuthenticationPriorityDot1xWebauth = types.BoolValue(false)
+ }
+ } else {
+ data.AuthenticationPriorityDot1xWebauth = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-sanet:authentication/priority-config/mab-config"); !data.AuthenticationPriorityMab.IsNull() {
+ if value.Exists() {
+ data.AuthenticationPriorityMab = types.BoolValue(true)
+ } else {
+ data.AuthenticationPriorityMab = types.BoolValue(false)
+ }
+ } else {
+ data.AuthenticationPriorityMab = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-sanet:authentication/priority-config/mab-config/dot1x"); !data.AuthenticationPriorityMabDot1x.IsNull() {
+ if value.Exists() {
+ data.AuthenticationPriorityMabDot1x = types.BoolValue(true)
+ } else {
+ data.AuthenticationPriorityMabDot1x = types.BoolValue(false)
+ }
+ } else {
+ data.AuthenticationPriorityMabDot1x = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-sanet:authentication/priority-config/mab-config/webauth"); !data.AuthenticationPriorityMabWebauth.IsNull() {
+ if value.Exists() {
+ data.AuthenticationPriorityMabWebauth = types.BoolValue(true)
+ } else {
+ data.AuthenticationPriorityMabWebauth = types.BoolValue(false)
+ }
+ } else {
+ data.AuthenticationPriorityMabWebauth = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-sanet:authentication/priority-config/webauth-config"); !data.AuthenticationPriorityWebauth.IsNull() {
+ if value.Exists() {
+ data.AuthenticationPriorityWebauth = types.BoolValue(true)
+ } else {
+ data.AuthenticationPriorityWebauth = types.BoolValue(false)
+ }
+ } else {
+ data.AuthenticationPriorityWebauth = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-sanet:authentication/port-control"); value.Exists() && !data.AuthenticationPortControl.IsNull() {
+ data.AuthenticationPortControl = types.StringValue(value.String())
+ } else {
+ data.AuthenticationPortControl = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-sanet:authentication/periodic"); !data.AuthenticationPeriodic.IsNull() {
+ if value.Exists() {
+ data.AuthenticationPeriodic = types.BoolValue(true)
+ } else {
+ data.AuthenticationPeriodic = types.BoolValue(false)
+ }
+ } else {
+ data.AuthenticationPeriodic = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-sanet:authentication/timer/reauthenticate/value-config"); value.Exists() && !data.AuthenticationTimerReauthenticate.IsNull() {
+ data.AuthenticationTimerReauthenticate = types.Int64Value(value.Int())
+ } else {
+ data.AuthenticationTimerReauthenticate = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-sanet:authentication/timer/reauthenticate/server-config"); !data.AuthenticationTimerReauthenticateServer.IsNull() {
+ if value.Exists() {
+ data.AuthenticationTimerReauthenticateServer = types.BoolValue(true)
+ } else {
+ data.AuthenticationTimerReauthenticateServer = types.BoolValue(false)
+ }
+ } else {
+ data.AuthenticationTimerReauthenticateServer = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-sanet:authentication/event/server/alive/action/reinitialize"); !data.AuthenticationEventServerAliveActionReinitialize.IsNull() {
+ if value.Exists() {
+ data.AuthenticationEventServerAliveActionReinitialize = types.BoolValue(true)
+ } else {
+ data.AuthenticationEventServerAliveActionReinitialize = types.BoolValue(false)
+ }
+ } else {
+ data.AuthenticationEventServerAliveActionReinitialize = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-sanet:authentication/event/server/dead/action/authorize"); !data.AuthenticationEventServerDeadActionAuthorize.IsNull() {
+ if value.Exists() {
+ data.AuthenticationEventServerDeadActionAuthorize = types.BoolValue(true)
+ } else {
+ data.AuthenticationEventServerDeadActionAuthorize = types.BoolValue(false)
+ }
+ } else {
+ data.AuthenticationEventServerDeadActionAuthorize = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-sanet:authentication/event/server/dead/action/authorize/vlan"); value.Exists() && !data.AuthenticationEventServerDeadActionAuthorizeVlan.IsNull() {
+ data.AuthenticationEventServerDeadActionAuthorizeVlan = types.Int64Value(value.Int())
+ } else {
+ data.AuthenticationEventServerDeadActionAuthorizeVlan = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-sanet:authentication/event/server/dead/action/authorize/voice"); !data.AuthenticationEventServerDeadActionAuthorizeVoice.IsNull() {
+ if value.Exists() {
+ data.AuthenticationEventServerDeadActionAuthorizeVoice = types.BoolValue(true)
+ } else {
+ data.AuthenticationEventServerDeadActionAuthorizeVoice = types.BoolValue(false)
+ }
+ } else {
+ data.AuthenticationEventServerDeadActionAuthorizeVoice = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-sanet:authentication/event/server/dead/action/reinitialize/vlan"); value.Exists() && !data.AuthenticationEventServerDeadActionReinitializeVlan.IsNull() {
+ data.AuthenticationEventServerDeadActionReinitializeVlan = types.Int64Value(value.Int())
+ } else {
+ data.AuthenticationEventServerDeadActionReinitializeVlan = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-sanet:authentication/event/fail-config/action/authorize/vlan"); value.Exists() && !data.AuthenticationEventFailActionAuthorizeVlan.IsNull() {
+ data.AuthenticationEventFailActionAuthorizeVlan = types.Int64Value(value.Int())
+ } else {
+ data.AuthenticationEventFailActionAuthorizeVlan = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-sanet:authentication/event/fail-config/action/next-method"); !data.AuthenticationEventFailActionNextMethod.IsNull() {
+ if value.Exists() {
+ data.AuthenticationEventFailActionNextMethod = types.BoolValue(true)
+ } else {
+ data.AuthenticationEventFailActionNextMethod = types.BoolValue(false)
+ }
+ } else {
+ data.AuthenticationEventFailActionNextMethod = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-sanet:authentication/event/no-response/action/authorize/vlan"); value.Exists() && !data.AuthenticationEventNoResponseActionAuthorizeVlan.IsNull() {
+ data.AuthenticationEventNoResponseActionAuthorizeVlan = types.Int64Value(value.Int())
+ } else {
+ data.AuthenticationEventNoResponseActionAuthorizeVlan = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-sanet:authentication/event/linksec/fail/action/next-method"); !data.AuthenticationEventLinksecFailActionNextMethod.IsNull() {
+ if value.Exists() {
+ data.AuthenticationEventLinksecFailActionNextMethod = types.BoolValue(true)
+ } else {
+ data.AuthenticationEventLinksecFailActionNextMethod = types.BoolValue(false)
+ }
+ } else {
+ data.AuthenticationEventLinksecFailActionNextMethod = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-sanet:mab"); !data.Mab.IsNull() {
+ if value.Exists() {
+ data.Mab = types.BoolValue(true)
+ } else {
+ data.Mab = types.BoolValue(false)
+ }
+ } else {
+ data.Mab = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-sanet:mab/eap"); !data.MabEap.IsNull() {
+ if value.Exists() {
+ data.MabEap = types.BoolValue(true)
+ } else {
+ data.MabEap = types.BoolValue(false)
+ }
+ } else {
+ data.MabEap = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-dot1x:dot1x/pae"); value.Exists() && !data.Dot1xPae.IsNull() {
+ data.Dot1xPae = types.StringValue(value.String())
+ } else {
+ data.Dot1xPae = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-dot1x:dot1x/timeout/auth-period"); value.Exists() && !data.Dot1xTimeoutAuthPeriod.IsNull() {
+ data.Dot1xTimeoutAuthPeriod = types.Int64Value(value.Int())
+ } else {
+ data.Dot1xTimeoutAuthPeriod = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-dot1x:dot1x/timeout/held-period"); value.Exists() && !data.Dot1xTimeoutHeldPeriod.IsNull() {
+ data.Dot1xTimeoutHeldPeriod = types.Int64Value(value.Int())
+ } else {
+ data.Dot1xTimeoutHeldPeriod = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-dot1x:dot1x/timeout/quiet-period"); value.Exists() && !data.Dot1xTimeoutQuietPeriod.IsNull() {
+ data.Dot1xTimeoutQuietPeriod = types.Int64Value(value.Int())
+ } else {
+ data.Dot1xTimeoutQuietPeriod = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-dot1x:dot1x/timeout/ratelimit-period"); value.Exists() && !data.Dot1xTimeoutRatelimitPeriod.IsNull() {
+ data.Dot1xTimeoutRatelimitPeriod = types.Int64Value(value.Int())
+ } else {
+ data.Dot1xTimeoutRatelimitPeriod = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-dot1x:dot1x/timeout/server-timeout"); value.Exists() && !data.Dot1xTimeoutServerTimeout.IsNull() {
+ data.Dot1xTimeoutServerTimeout = types.Int64Value(value.Int())
+ } else {
+ data.Dot1xTimeoutServerTimeout = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-dot1x:dot1x/timeout/start-period"); value.Exists() && !data.Dot1xTimeoutStartPeriod.IsNull() {
+ data.Dot1xTimeoutStartPeriod = types.Int64Value(value.Int())
+ } else {
+ data.Dot1xTimeoutStartPeriod = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-dot1x:dot1x/timeout/supp-timeout"); value.Exists() && !data.Dot1xTimeoutSuppTimeout.IsNull() {
+ data.Dot1xTimeoutSuppTimeout = types.Int64Value(value.Int())
+ } else {
+ data.Dot1xTimeoutSuppTimeout = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-dot1x:dot1x/timeout/tx-period"); value.Exists() && !data.Dot1xTimeoutTxPeriod.IsNull() {
+ data.Dot1xTimeoutTxPeriod = types.Int64Value(value.Int())
+ } else {
+ data.Dot1xTimeoutTxPeriod = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-dot1x:dot1x/max-req"); value.Exists() && !data.Dot1xMaxReq.IsNull() {
+ data.Dot1xMaxReq = types.Int64Value(value.Int())
+ } else {
+ data.Dot1xMaxReq = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-dot1x:dot1x/max-reauth-req"); value.Exists() && !data.Dot1xMaxReauthReq.IsNull() {
+ data.Dot1xMaxReauthReq = types.Int64Value(value.Int())
+ } else {
+ data.Dot1xMaxReauthReq = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-policy:service-policy/input"); value.Exists() && !data.ServicePolicyInput.IsNull() {
+ data.ServicePolicyInput = types.StringValue(value.String())
+ } else {
+ data.ServicePolicyInput = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-policy:service-policy/output"); value.Exists() && !data.ServicePolicyOutput.IsNull() {
+ data.ServicePolicyOutput = types.StringValue(value.String())
+ } else {
+ data.ServicePolicyOutput = types.StringNull()
+ }
+ for i := range data.IpFlowMonitors {
+ keys := [...]string{"name", "direction"}
+ keyValues := [...]string{data.IpFlowMonitors[i].Name.ValueString(), data.IpFlowMonitors[i].Direction.ValueString()}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/Cisco-IOS-XE-flow:flow/monitor-new").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, "name"); value.Exists() && !data.IpFlowMonitors[i].Name.IsNull() {
+ data.IpFlowMonitors[i].Name = types.StringValue(value.String())
+ } else {
+ data.IpFlowMonitors[i].Name = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "direction"); value.Exists() && !data.IpFlowMonitors[i].Direction.IsNull() {
+ data.IpFlowMonitors[i].Direction = types.StringValue(value.String())
+ } else {
+ data.IpFlowMonitors[i].Direction = types.StringNull()
+ }
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/load-interval"); value.Exists() && !data.LoadInterval.IsNull() {
+ data.LoadInterval = types.Int64Value(value.Int())
+ } else {
+ data.LoadInterval = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:snmp/trap/link-status"); !data.SnmpTrapLinkStatus.IsNull() {
+ if value.Exists() {
+ data.SnmpTrapLinkStatus = types.BoolValue(value.Bool())
+ }
+ } else {
+ data.SnmpTrapLinkStatus = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/logging/event/link-status-enable"); !data.LoggingEventLinkStatusEnable.IsNull() {
+ if value.Exists() {
+ data.LoggingEventLinkStatusEnable = types.BoolValue(value.Bool())
+ }
+ } else {
+ data.LoggingEventLinkStatusEnable = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/Cisco-IOS-XE-nbar:nbar/protocol-discovery"); !data.IpNbarProtocolDiscovery.IsNull() {
+ if value.Exists() {
+ data.IpNbarProtocolDiscovery = types.BoolValue(true)
+ } else {
+ data.IpNbarProtocolDiscovery = types.BoolValue(false)
+ }
+ } else {
+ data.IpNbarProtocolDiscovery = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-switch:device-tracking"); !data.DeviceTracking.IsNull() {
+ if value.Exists() {
+ data.DeviceTracking = types.BoolValue(true)
+ } else {
+ data.DeviceTracking = types.BoolValue(false)
+ }
+ } else {
+ data.DeviceTracking = types.BoolNull()
+ }
+ for i := range data.DeviceTrackingAttachedPolicies {
+ keys := [...]string{"attach-policy"}
+ keyValues := [...]string{data.DeviceTrackingAttachedPolicies[i].Name.ValueString()}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-switch:device-tracking/attached-policies").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, "attach-policy"); value.Exists() && !data.DeviceTrackingAttachedPolicies[i].Name.IsNull() {
+ data.DeviceTrackingAttachedPolicies[i].Name = types.StringValue(value.String())
+ } else {
+ data.DeviceTrackingAttachedPolicies[i].Name = types.StringNull()
+ }
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-cdp:cdp/enable"); !data.CdpEnable.IsNull() {
+ if value.Exists() {
+ data.CdpEnable = types.BoolValue(value.Bool())
+ }
+ } else {
+ data.CdpEnable = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-cdp:cdp/tlv/default-wrp/app"); !data.CdpTlvApp.IsNull() {
+ if value.Exists() {
+ data.CdpTlvApp = types.BoolValue(value.Bool())
+ }
+ } else {
+ data.CdpTlvApp = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-cdp:cdp/tlv/location-config"); !data.CdpTlvLocation.IsNull() {
+ if value.Exists() {
+ data.CdpTlvLocation = types.BoolValue(value.Bool())
+ }
+ } else {
+ data.CdpTlvLocation = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-cdp:cdp/tlv/server-location-config"); !data.CdpTlvServerLocation.IsNull() {
+ if value.Exists() {
+ data.CdpTlvServerLocation = types.BoolValue(value.Bool())
+ }
+ } else {
+ data.CdpTlvServerLocation = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/Cisco-IOS-XE-nat:nat/inside"); !data.IpNatInside.IsNull() {
+ if value.Exists() {
+ data.IpNatInside = types.BoolValue(true)
+ } else {
+ data.IpNatInside = types.BoolValue(false)
+ }
+ } else {
+ data.IpNatInside = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/Cisco-IOS-XE-nat:nat/outside"); !data.IpNatOutside.IsNull() {
+ if value.Exists() {
+ data.IpNatOutside = types.BoolValue(true)
+ } else {
+ data.IpNatOutside = types.BoolValue(false)
+ }
+ } else {
+ data.IpNatOutside = types.BoolNull()
+ }
+}
+
+// End of section. //template:end updateFromBodyXML
+
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBody
+
+func (data *InterfaceEthernet) fromBody(ctx context.Context, res gjson.Result) {
+ prefix := helpers.LastElement(data.getPath()) + "."
+ if res.Get(helpers.LastElement(data.getPath())).IsArray() {
+ prefix += "0."
+ }
+ if value := res.Get(prefix + "media-type"); value.Exists() {
+ data.MediaType = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "mtu"); value.Exists() {
+ data.Mtu = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "bandwidth.kilobits"); value.Exists() {
+ data.Bandwidth = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "switchport-conf.switchport"); value.Exists() {
+ data.Switchport = types.BoolValue(value.Bool())
+ } else {
+ data.Switchport = types.BoolNull()
+ }
+ if value := res.Get(prefix + "description"); value.Exists() {
+ data.Description = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "shutdown"); value.Exists() {
+ data.Shutdown = types.BoolValue(true)
+ } else {
+ data.Shutdown = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "ip.proxy-arp"); value.Exists() {
+ data.IpProxyArp = types.BoolValue(value.Bool())
+ } else {
+ data.IpProxyArp = types.BoolNull()
+ }
+ if value := res.Get(prefix + "ip.redirects"); value.Exists() {
+ data.IpRedirects = types.BoolValue(value.Bool())
+ } else {
+ data.IpRedirects = types.BoolNull()
+ }
+ if value := res.Get(prefix + "ip.Cisco-IOS-XE-icmp:unreachables"); value.Exists() {
+ data.IpUnreachables = types.BoolValue(value.Bool())
+ } else {
+ data.IpUnreachables = types.BoolNull()
+ }
+ if value := res.Get(prefix + "vrf.forwarding"); value.Exists() {
+ data.VrfForwarding = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "ip.address.primary.address"); value.Exists() {
+ data.Ipv4Address = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "ip.address.primary.mask"); value.Exists() {
+ data.Ipv4AddressMask = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "ip.unnumbered"); value.Exists() {
+ data.Unnumbered = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "encapsulation.dot1Q.vlan-id"); value.Exists() {
+ data.EncapsulationDot1qVlanId = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-ethernet:channel-group.number"); value.Exists() {
+ data.ChannelGroupNumber = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-ethernet:channel-group.mode"); value.Exists() {
+ data.ChannelGroupMode = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "ip.dhcp.Cisco-IOS-XE-dhcp:relay.source-interface"); value.Exists() {
+ data.IpDhcpRelaySourceInterface = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "ip.access-group.in.acl.in"); value.Exists() {
+ data.IpAccessGroupInEnable = types.BoolValue(true)
+ } else {
+ data.IpAccessGroupInEnable = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "ip.access-group.in.acl.acl-name"); value.Exists() {
+ data.IpAccessGroupIn = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "ip.access-group.out.acl.out"); value.Exists() {
+ data.IpAccessGroupOutEnable = types.BoolValue(true)
+ } else {
+ data.IpAccessGroupOutEnable = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "ip.access-group.out.acl.acl-name"); value.Exists() {
+ data.IpAccessGroupOut = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-spanning-tree:spanning-tree.guard"); value.Exists() {
+ data.SpanningTreeGuard = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-switch:auto.qos.classify"); value.Exists() {
+ data.AutoQosClassify = types.BoolValue(true)
+ } else {
+ data.AutoQosClassify = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-switch:auto.qos.classify.police"); value.Exists() {
+ data.AutoQosClassifyPolice = types.BoolValue(true)
+ } else {
+ data.AutoQosClassifyPolice = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-switch:auto.qos.trust"); value.Exists() {
+ data.AutoQosTrust = types.BoolValue(true)
+ } else {
+ data.AutoQosTrust = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-switch:auto.qos.trust.cos"); value.Exists() {
+ data.AutoQosTrustCos = types.BoolValue(true)
+ } else {
+ data.AutoQosTrustCos = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-switch:auto.qos.trust.dscp"); value.Exists() {
+ data.AutoQosTrustDscp = types.BoolValue(true)
+ } else {
+ data.AutoQosTrustDscp = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-switch:auto.qos.video.cts"); value.Exists() {
+ data.AutoQosVideoCts = types.BoolValue(true)
+ } else {
+ data.AutoQosVideoCts = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-switch:auto.qos.video.ip-camera"); value.Exists() {
+ data.AutoQosVideoIpCamera = types.BoolValue(true)
+ } else {
+ data.AutoQosVideoIpCamera = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-switch:auto.qos.video.media-player"); value.Exists() {
+ data.AutoQosVideoMediaPlayer = types.BoolValue(true)
+ } else {
+ data.AutoQosVideoMediaPlayer = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-switch:auto.qos.voip"); value.Exists() {
+ data.AutoQosVoip = types.BoolValue(true)
+ } else {
+ data.AutoQosVoip = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-switch:auto.qos.voip.cisco-phone"); value.Exists() {
+ data.AutoQosVoipCiscoPhone = types.BoolValue(true)
+ } else {
+ data.AutoQosVoipCiscoPhone = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-switch:auto.qos.voip.cisco-softphone"); value.Exists() {
+ data.AutoQosVoipCiscoSoftphone = types.BoolValue(true)
+ } else {
+ data.AutoQosVoipCiscoSoftphone = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-switch:auto.qos.voip.trust"); value.Exists() {
+ data.AutoQosVoipTrust = types.BoolValue(true)
+ } else {
+ data.AutoQosVoipTrust = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "trust.device"); value.Exists() {
+ data.TrustDevice = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "ip.helper-address"); value.Exists() {
+ data.HelperAddresses = make([]InterfaceEthernetHelperAddresses, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := InterfaceEthernetHelperAddresses{}
+ if cValue := v.Get("address"); cValue.Exists() {
+ item.Address = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("global"); cValue.Exists() {
+ item.Global = types.BoolValue(true)
+ } else {
+ item.Global = types.BoolValue(false)
+ }
+ if cValue := v.Get("vrf"); cValue.Exists() {
+ item.Vrf = types.StringValue(cValue.String())
+ }
+ data.HelperAddresses = append(data.HelperAddresses, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + "source.template.template-name"); value.Exists() {
+ data.SourceTemplate = make([]InterfaceEthernetSourceTemplate, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := InterfaceEthernetSourceTemplate{}
+ if cValue := v.Get("template-name"); cValue.Exists() {
+ item.TemplateName = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("merge"); cValue.Exists() {
+ item.Merge = types.BoolValue(true)
+ } else {
+ item.Merge = types.BoolValue(false)
+ }
+ data.SourceTemplate = append(data.SourceTemplate, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + "bfd.Cisco-IOS-XE-bfd:template"); value.Exists() {
+ data.BfdTemplate = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "bfd.Cisco-IOS-XE-bfd:enable"); value.Exists() {
+ data.BfdEnable = types.BoolValue(value.Bool())
+ } else {
+ data.BfdEnable = types.BoolNull()
+ }
+ if value := res.Get(prefix + "bfd.Cisco-IOS-XE-bfd:local-address"); value.Exists() {
+ data.BfdLocalAddress = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "bfd.Cisco-IOS-XE-bfd:interval-interface.msecs"); value.Exists() {
+ data.BfdInterval = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "bfd.Cisco-IOS-XE-bfd:interval-interface.min_rx"); value.Exists() {
+ data.BfdIntervalMinRx = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "bfd.Cisco-IOS-XE-bfd:interval-interface.multiplier"); value.Exists() {
+ data.BfdIntervalMultiplier = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "bfd.Cisco-IOS-XE-bfd:echo"); value.Exists() {
+ data.BfdEcho = types.BoolValue(value.Bool())
+ } else {
+ data.BfdEcho = types.BoolNull()
+ }
+ if value := res.Get(prefix + "ipv6.enable"); value.Exists() {
+ data.Ipv6Enable = types.BoolValue(true)
+ } else {
+ data.Ipv6Enable = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "ipv6.mtu"); value.Exists() {
+ data.Ipv6Mtu = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "ipv6.nd.Cisco-IOS-XE-nd:ra.suppress.all"); value.Exists() {
+ data.Ipv6NdRaSuppressAll = types.BoolValue(true)
+ } else {
+ data.Ipv6NdRaSuppressAll = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "ipv6.address.autoconfig.default"); value.Exists() {
+ data.Ipv6AddressAutoconfigDefault = types.BoolValue(true)
+ } else {
+ data.Ipv6AddressAutoconfigDefault = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "ipv6.address.dhcp"); value.Exists() {
+ data.Ipv6AddressDhcp = types.BoolValue(true)
+ } else {
+ data.Ipv6AddressDhcp = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "ipv6.address.link-local-address"); value.Exists() {
+ data.Ipv6LinkLocalAddresses = make([]InterfaceEthernetIpv6LinkLocalAddresses, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := InterfaceEthernetIpv6LinkLocalAddresses{}
+ if cValue := v.Get("address"); cValue.Exists() {
+ item.Address = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("link-local"); cValue.Exists() {
+ item.LinkLocal = types.BoolValue(true)
+ } else {
+ item.LinkLocal = types.BoolValue(false)
+ }
+ data.Ipv6LinkLocalAddresses = append(data.Ipv6LinkLocalAddresses, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + "ipv6.address.prefix-list"); value.Exists() {
+ data.Ipv6Addresses = make([]InterfaceEthernetIpv6Addresses, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := InterfaceEthernetIpv6Addresses{}
+ if cValue := v.Get("prefix"); cValue.Exists() {
+ item.Prefix = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("eui-64"); cValue.Exists() {
+ item.Eui64 = types.BoolValue(true)
+ } else {
+ item.Eui64 = types.BoolValue(false)
+ }
+ data.Ipv6Addresses = append(data.Ipv6Addresses, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + "ipv6.Cisco-IOS-XE-flow:flow.monitor-new"); value.Exists() {
+ data.Ipv6FlowMonitors = make([]InterfaceEthernetIpv6FlowMonitors, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := InterfaceEthernetIpv6FlowMonitors{}
+ if cValue := v.Get("name"); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("direction"); cValue.Exists() {
+ item.Direction = types.StringValue(cValue.String())
+ }
+ data.Ipv6FlowMonitors = append(data.Ipv6FlowMonitors, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + "arp.timeout"); value.Exists() {
+ data.ArpTimeout = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-spanning-tree:spanning-tree.link-type"); value.Exists() {
+ data.SpanningTreeLinkType = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-spanning-tree:spanning-tree.bpduguard.enable"); value.Exists() {
+ data.BpduguardEnable = types.BoolValue(true)
+ } else {
+ data.BpduguardEnable = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-spanning-tree:spanning-tree.bpduguard.disable"); value.Exists() {
+ data.BpduguardDisable = types.BoolValue(true)
+ } else {
+ data.BpduguardDisable = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-spanning-tree:spanning-tree.portfast"); value.Exists() {
+ data.SpanningTreePortfast = types.BoolValue(true)
+ } else {
+ data.SpanningTreePortfast = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-spanning-tree:spanning-tree.portfast.disable"); value.Exists() {
+ data.SpanningTreePortfastDisable = types.BoolValue(true)
+ } else {
+ data.SpanningTreePortfastDisable = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-spanning-tree:spanning-tree.portfast.trunk"); value.Exists() {
+ data.SpanningTreePortfastTrunk = types.BoolValue(true)
+ } else {
+ data.SpanningTreePortfastTrunk = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-spanning-tree:spanning-tree.portfast.edge"); value.Exists() {
+ data.SpanningTreePortfastEdge = types.BoolValue(true)
+ } else {
+ data.SpanningTreePortfastEdge = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "ip.arp.inspection.trust"); value.Exists() {
+ data.IpArpInspectionTrust = types.BoolValue(true)
+ } else {
+ data.IpArpInspectionTrust = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "ip.arp.inspection.limit.rate"); value.Exists() {
+ data.IpArpInspectionLimitRate = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "ip.dhcp.Cisco-IOS-XE-dhcp:snooping.trust"); value.Exists() {
+ data.IpDhcpSnoopingTrust = types.BoolValue(true)
+ } else {
+ data.IpDhcpSnoopingTrust = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-ethernet:speed.value-100"); value.Exists() {
+ data.Speed100 = types.BoolValue(true)
+ } else {
+ data.Speed100 = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-ethernet:speed.value-1000"); value.Exists() {
+ data.Speed1000 = types.BoolValue(true)
+ } else {
+ data.Speed1000 = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-ethernet:speed.value-2500"); value.Exists() {
+ data.Speed2500 = types.BoolValue(true)
+ } else {
+ data.Speed2500 = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-ethernet:speed.value-5000"); value.Exists() {
+ data.Speed5000 = types.BoolValue(true)
+ } else {
+ data.Speed5000 = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-ethernet:speed.value-10000"); value.Exists() {
+ data.Speed10000 = types.BoolValue(true)
+ } else {
+ data.Speed10000 = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-ethernet:speed.value-25000"); value.Exists() {
+ data.Speed25000 = types.BoolValue(true)
+ } else {
+ data.Speed25000 = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-ethernet:speed.value-40000"); value.Exists() {
+ data.Speed40000 = types.BoolValue(true)
+ } else {
+ data.Speed40000 = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-ethernet:speed.value-100000"); value.Exists() {
+ data.Speed100000 = types.BoolValue(true)
+ } else {
+ data.Speed100000 = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-ethernet:negotiation.auto"); value.Exists() {
+ data.NegotiationAuto = types.BoolValue(value.Bool())
+ } else {
+ data.NegotiationAuto = types.BoolNull()
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-ethernet:speed.nonegotiate"); value.Exists() {
+ data.SpeedNonegotiate = types.BoolValue(true)
+ } else {
+ data.SpeedNonegotiate = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-sanet:authentication.host-mode"); value.Exists() {
+ data.AuthenticationHostMode = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-sanet:authentication.order-config.dot1x-config"); value.Exists() {
+ data.AuthenticationOrderDot1x = types.BoolValue(true)
+ } else {
+ data.AuthenticationOrderDot1x = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-sanet:authentication.order-config.dot1x-config.mab"); value.Exists() {
+ data.AuthenticationOrderDot1xMab = types.BoolValue(true)
+ } else {
+ data.AuthenticationOrderDot1xMab = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-sanet:authentication.order-config.dot1x-config.webauth"); value.Exists() {
+ data.AuthenticationOrderDot1xWebauth = types.BoolValue(true)
+ } else {
+ data.AuthenticationOrderDot1xWebauth = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-sanet:authentication.order-config.mab-config"); value.Exists() {
+ data.AuthenticationOrderMab = types.BoolValue(true)
+ } else {
+ data.AuthenticationOrderMab = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-sanet:authentication.order-config.mab-config.dot1x"); value.Exists() {
+ data.AuthenticationOrderMabDot1x = types.BoolValue(true)
+ } else {
+ data.AuthenticationOrderMabDot1x = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-sanet:authentication.order-config.mab-config.webauth"); value.Exists() {
+ data.AuthenticationOrderMabWebauth = types.BoolValue(true)
+ } else {
+ data.AuthenticationOrderMabWebauth = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-sanet:authentication.order-config.webauth-config"); value.Exists() {
+ data.AuthenticationOrderWebauth = types.BoolValue(true)
+ } else {
+ data.AuthenticationOrderWebauth = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-sanet:authentication.priority-config.dot1x-config"); value.Exists() {
+ data.AuthenticationPriorityDot1x = types.BoolValue(true)
+ } else {
+ data.AuthenticationPriorityDot1x = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-sanet:authentication.priority-config.dot1x-config.mab"); value.Exists() {
+ data.AuthenticationPriorityDot1xMab = types.BoolValue(true)
+ } else {
+ data.AuthenticationPriorityDot1xMab = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-sanet:authentication.priority-config.dot1x-config.webauth"); value.Exists() {
+ data.AuthenticationPriorityDot1xWebauth = types.BoolValue(true)
+ } else {
+ data.AuthenticationPriorityDot1xWebauth = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-sanet:authentication.priority-config.mab-config"); value.Exists() {
+ data.AuthenticationPriorityMab = types.BoolValue(true)
+ } else {
+ data.AuthenticationPriorityMab = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-sanet:authentication.priority-config.mab-config.dot1x"); value.Exists() {
+ data.AuthenticationPriorityMabDot1x = types.BoolValue(true)
+ } else {
+ data.AuthenticationPriorityMabDot1x = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-sanet:authentication.priority-config.mab-config.webauth"); value.Exists() {
+ data.AuthenticationPriorityMabWebauth = types.BoolValue(true)
+ } else {
+ data.AuthenticationPriorityMabWebauth = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-sanet:authentication.priority-config.webauth-config"); value.Exists() {
+ data.AuthenticationPriorityWebauth = types.BoolValue(true)
+ } else {
+ data.AuthenticationPriorityWebauth = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-sanet:authentication.port-control"); value.Exists() {
+ data.AuthenticationPortControl = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-sanet:authentication.periodic"); value.Exists() {
+ data.AuthenticationPeriodic = types.BoolValue(true)
+ } else {
+ data.AuthenticationPeriodic = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-sanet:authentication.timer.reauthenticate.value-config"); value.Exists() {
+ data.AuthenticationTimerReauthenticate = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-sanet:authentication.timer.reauthenticate.server-config"); value.Exists() {
+ data.AuthenticationTimerReauthenticateServer = types.BoolValue(true)
+ } else {
+ data.AuthenticationTimerReauthenticateServer = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-sanet:authentication.event.server.alive.action.reinitialize"); value.Exists() {
+ data.AuthenticationEventServerAliveActionReinitialize = types.BoolValue(true)
+ } else {
+ data.AuthenticationEventServerAliveActionReinitialize = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-sanet:authentication.event.server.dead.action.authorize"); value.Exists() {
+ data.AuthenticationEventServerDeadActionAuthorize = types.BoolValue(true)
+ } else {
+ data.AuthenticationEventServerDeadActionAuthorize = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-sanet:authentication.event.server.dead.action.authorize.vlan"); value.Exists() {
+ data.AuthenticationEventServerDeadActionAuthorizeVlan = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-sanet:authentication.event.server.dead.action.authorize.voice"); value.Exists() {
+ data.AuthenticationEventServerDeadActionAuthorizeVoice = types.BoolValue(true)
+ } else {
+ data.AuthenticationEventServerDeadActionAuthorizeVoice = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-sanet:authentication.event.server.dead.action.reinitialize.vlan"); value.Exists() {
+ data.AuthenticationEventServerDeadActionReinitializeVlan = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-sanet:authentication.event.fail-config.action.authorize.vlan"); value.Exists() {
+ data.AuthenticationEventFailActionAuthorizeVlan = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-sanet:authentication.event.fail-config.action.next-method"); value.Exists() {
+ data.AuthenticationEventFailActionNextMethod = types.BoolValue(true)
+ } else {
+ data.AuthenticationEventFailActionNextMethod = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-sanet:authentication.event.no-response.action.authorize.vlan"); value.Exists() {
+ data.AuthenticationEventNoResponseActionAuthorizeVlan = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-sanet:authentication.event.linksec.fail.action.next-method"); value.Exists() {
+ data.AuthenticationEventLinksecFailActionNextMethod = types.BoolValue(true)
+ } else {
+ data.AuthenticationEventLinksecFailActionNextMethod = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-sanet:mab"); value.Exists() {
+ data.Mab = types.BoolValue(true)
+ } else {
+ data.Mab = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-sanet:mab.eap"); value.Exists() {
+ data.MabEap = types.BoolValue(true)
+ } else {
+ data.MabEap = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-dot1x:dot1x.pae"); value.Exists() {
+ data.Dot1xPae = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-dot1x:dot1x.timeout.auth-period"); value.Exists() {
+ data.Dot1xTimeoutAuthPeriod = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-dot1x:dot1x.timeout.held-period"); value.Exists() {
+ data.Dot1xTimeoutHeldPeriod = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-dot1x:dot1x.timeout.quiet-period"); value.Exists() {
+ data.Dot1xTimeoutQuietPeriod = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-dot1x:dot1x.timeout.ratelimit-period"); value.Exists() {
+ data.Dot1xTimeoutRatelimitPeriod = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-dot1x:dot1x.timeout.server-timeout"); value.Exists() {
+ data.Dot1xTimeoutServerTimeout = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-dot1x:dot1x.timeout.start-period"); value.Exists() {
+ data.Dot1xTimeoutStartPeriod = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-dot1x:dot1x.timeout.supp-timeout"); value.Exists() {
+ data.Dot1xTimeoutSuppTimeout = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-dot1x:dot1x.timeout.tx-period"); value.Exists() {
+ data.Dot1xTimeoutTxPeriod = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-dot1x:dot1x.max-req"); value.Exists() {
+ data.Dot1xMaxReq = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-dot1x:dot1x.max-reauth-req"); value.Exists() {
+ data.Dot1xMaxReauthReq = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-policy:service-policy.input"); value.Exists() {
+ data.ServicePolicyInput = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-policy:service-policy.output"); value.Exists() {
+ data.ServicePolicyOutput = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "ip.Cisco-IOS-XE-flow:flow.monitor-new"); value.Exists() {
+ data.IpFlowMonitors = make([]InterfaceEthernetIpFlowMonitors, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := InterfaceEthernetIpFlowMonitors{}
+ if cValue := v.Get("name"); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("direction"); cValue.Exists() {
+ item.Direction = types.StringValue(cValue.String())
+ }
+ data.IpFlowMonitors = append(data.IpFlowMonitors, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + "load-interval"); value.Exists() {
+ data.LoadInterval = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:snmp.trap.link-status"); value.Exists() {
+ data.SnmpTrapLinkStatus = types.BoolValue(value.Bool())
+ } else {
+ data.SnmpTrapLinkStatus = types.BoolNull()
+ }
+ if value := res.Get(prefix + "logging.event.link-status-enable"); value.Exists() {
+ data.LoggingEventLinkStatusEnable = types.BoolValue(value.Bool())
+ } else {
+ data.LoggingEventLinkStatusEnable = types.BoolNull()
+ }
+ if value := res.Get(prefix + "ip.Cisco-IOS-XE-nbar:nbar.protocol-discovery"); value.Exists() {
+ data.IpNbarProtocolDiscovery = types.BoolValue(true)
+ } else {
+ data.IpNbarProtocolDiscovery = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-switch:device-tracking"); value.Exists() {
+ data.DeviceTracking = types.BoolValue(true)
+ } else {
+ data.DeviceTracking = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-switch:device-tracking.attached-policies"); value.Exists() {
+ data.DeviceTrackingAttachedPolicies = make([]InterfaceEthernetDeviceTrackingAttachedPolicies, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := InterfaceEthernetDeviceTrackingAttachedPolicies{}
+ if cValue := v.Get("attach-policy"); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ data.DeviceTrackingAttachedPolicies = append(data.DeviceTrackingAttachedPolicies, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-cdp:cdp.enable"); value.Exists() {
+ data.CdpEnable = types.BoolValue(value.Bool())
+ } else {
+ data.CdpEnable = types.BoolNull()
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-cdp:cdp.tlv.default-wrp.app"); value.Exists() {
+ data.CdpTlvApp = types.BoolValue(value.Bool())
+ } else {
+ data.CdpTlvApp = types.BoolNull()
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-cdp:cdp.tlv.location-config"); value.Exists() {
+ data.CdpTlvLocation = types.BoolValue(value.Bool())
+ } else {
+ data.CdpTlvLocation = types.BoolNull()
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-cdp:cdp.tlv.server-location-config"); value.Exists() {
+ data.CdpTlvServerLocation = types.BoolValue(value.Bool())
+ } else {
+ data.CdpTlvServerLocation = types.BoolNull()
+ }
+ if value := res.Get(prefix + "ip.Cisco-IOS-XE-nat:nat.inside"); value.Exists() {
+ data.IpNatInside = types.BoolValue(true)
+ } else {
+ data.IpNatInside = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "ip.Cisco-IOS-XE-nat:nat.outside"); value.Exists() {
+ data.IpNatOutside = types.BoolValue(true)
+ } else {
+ data.IpNatOutside = types.BoolValue(false)
+ }
+}
+
+// End of section. //template:end fromBody
+
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyData
+
+func (data *InterfaceEthernetData) fromBody(ctx context.Context, res gjson.Result) {
+ prefix := helpers.LastElement(data.getPath()) + "."
+ if res.Get(helpers.LastElement(data.getPath())).IsArray() {
+ prefix += "0."
+ }
+ if value := res.Get(prefix + "media-type"); value.Exists() {
+ data.MediaType = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "mtu"); value.Exists() {
+ data.Mtu = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "bandwidth.kilobits"); value.Exists() {
+ data.Bandwidth = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "switchport-conf.switchport"); value.Exists() {
+ data.Switchport = types.BoolValue(value.Bool())
+ } else {
+ data.Switchport = types.BoolNull()
+ }
+ if value := res.Get(prefix + "description"); value.Exists() {
+ data.Description = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "shutdown"); value.Exists() {
+ data.Shutdown = types.BoolValue(true)
+ } else {
+ data.Shutdown = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "ip.proxy-arp"); value.Exists() {
+ data.IpProxyArp = types.BoolValue(value.Bool())
+ } else {
+ data.IpProxyArp = types.BoolNull()
+ }
+ if value := res.Get(prefix + "ip.redirects"); value.Exists() {
+ data.IpRedirects = types.BoolValue(value.Bool())
+ } else {
+ data.IpRedirects = types.BoolNull()
+ }
+ if value := res.Get(prefix + "ip.Cisco-IOS-XE-icmp:unreachables"); value.Exists() {
+ data.IpUnreachables = types.BoolValue(value.Bool())
+ } else {
+ data.IpUnreachables = types.BoolNull()
+ }
+ if value := res.Get(prefix + "vrf.forwarding"); value.Exists() {
+ data.VrfForwarding = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "ip.address.primary.address"); value.Exists() {
+ data.Ipv4Address = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "ip.address.primary.mask"); value.Exists() {
+ data.Ipv4AddressMask = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "ip.unnumbered"); value.Exists() {
+ data.Unnumbered = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "encapsulation.dot1Q.vlan-id"); value.Exists() {
+ data.EncapsulationDot1qVlanId = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-ethernet:channel-group.number"); value.Exists() {
+ data.ChannelGroupNumber = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-ethernet:channel-group.mode"); value.Exists() {
+ data.ChannelGroupMode = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "ip.dhcp.Cisco-IOS-XE-dhcp:relay.source-interface"); value.Exists() {
+ data.IpDhcpRelaySourceInterface = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "ip.access-group.in.acl.in"); value.Exists() {
+ data.IpAccessGroupInEnable = types.BoolValue(true)
+ } else {
+ data.IpAccessGroupInEnable = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "ip.access-group.in.acl.acl-name"); value.Exists() {
+ data.IpAccessGroupIn = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "ip.access-group.out.acl.out"); value.Exists() {
+ data.IpAccessGroupOutEnable = types.BoolValue(true)
+ } else {
+ data.IpAccessGroupOutEnable = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "ip.access-group.out.acl.acl-name"); value.Exists() {
+ data.IpAccessGroupOut = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-spanning-tree:spanning-tree.guard"); value.Exists() {
+ data.SpanningTreeGuard = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-switch:auto.qos.classify"); value.Exists() {
+ data.AutoQosClassify = types.BoolValue(true)
+ } else {
+ data.AutoQosClassify = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-switch:auto.qos.classify.police"); value.Exists() {
+ data.AutoQosClassifyPolice = types.BoolValue(true)
+ } else {
+ data.AutoQosClassifyPolice = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-switch:auto.qos.trust"); value.Exists() {
+ data.AutoQosTrust = types.BoolValue(true)
+ } else {
+ data.AutoQosTrust = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-switch:auto.qos.trust.cos"); value.Exists() {
+ data.AutoQosTrustCos = types.BoolValue(true)
+ } else {
+ data.AutoQosTrustCos = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-switch:auto.qos.trust.dscp"); value.Exists() {
+ data.AutoQosTrustDscp = types.BoolValue(true)
+ } else {
+ data.AutoQosTrustDscp = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-switch:auto.qos.video.cts"); value.Exists() {
+ data.AutoQosVideoCts = types.BoolValue(true)
+ } else {
+ data.AutoQosVideoCts = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-switch:auto.qos.video.ip-camera"); value.Exists() {
+ data.AutoQosVideoIpCamera = types.BoolValue(true)
+ } else {
+ data.AutoQosVideoIpCamera = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-switch:auto.qos.video.media-player"); value.Exists() {
+ data.AutoQosVideoMediaPlayer = types.BoolValue(true)
+ } else {
+ data.AutoQosVideoMediaPlayer = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-switch:auto.qos.voip"); value.Exists() {
+ data.AutoQosVoip = types.BoolValue(true)
+ } else {
+ data.AutoQosVoip = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-switch:auto.qos.voip.cisco-phone"); value.Exists() {
+ data.AutoQosVoipCiscoPhone = types.BoolValue(true)
+ } else {
+ data.AutoQosVoipCiscoPhone = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-switch:auto.qos.voip.cisco-softphone"); value.Exists() {
+ data.AutoQosVoipCiscoSoftphone = types.BoolValue(true)
+ } else {
+ data.AutoQosVoipCiscoSoftphone = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-switch:auto.qos.voip.trust"); value.Exists() {
+ data.AutoQosVoipTrust = types.BoolValue(true)
+ } else {
+ data.AutoQosVoipTrust = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "trust.device"); value.Exists() {
+ data.TrustDevice = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "ip.helper-address"); value.Exists() {
+ data.HelperAddresses = make([]InterfaceEthernetHelperAddresses, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := InterfaceEthernetHelperAddresses{}
+ if cValue := v.Get("address"); cValue.Exists() {
+ item.Address = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("global"); cValue.Exists() {
+ item.Global = types.BoolValue(true)
+ } else {
+ item.Global = types.BoolValue(false)
+ }
+ if cValue := v.Get("vrf"); cValue.Exists() {
+ item.Vrf = types.StringValue(cValue.String())
+ }
+ data.HelperAddresses = append(data.HelperAddresses, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + "source.template.template-name"); value.Exists() {
+ data.SourceTemplate = make([]InterfaceEthernetSourceTemplate, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := InterfaceEthernetSourceTemplate{}
+ if cValue := v.Get("template-name"); cValue.Exists() {
+ item.TemplateName = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("merge"); cValue.Exists() {
+ item.Merge = types.BoolValue(true)
+ } else {
+ item.Merge = types.BoolValue(false)
+ }
+ data.SourceTemplate = append(data.SourceTemplate, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + "bfd.Cisco-IOS-XE-bfd:template"); value.Exists() {
+ data.BfdTemplate = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "bfd.Cisco-IOS-XE-bfd:enable"); value.Exists() {
+ data.BfdEnable = types.BoolValue(value.Bool())
+ } else {
+ data.BfdEnable = types.BoolNull()
+ }
+ if value := res.Get(prefix + "bfd.Cisco-IOS-XE-bfd:local-address"); value.Exists() {
+ data.BfdLocalAddress = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "bfd.Cisco-IOS-XE-bfd:interval-interface.msecs"); value.Exists() {
+ data.BfdInterval = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "bfd.Cisco-IOS-XE-bfd:interval-interface.min_rx"); value.Exists() {
+ data.BfdIntervalMinRx = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "bfd.Cisco-IOS-XE-bfd:interval-interface.multiplier"); value.Exists() {
+ data.BfdIntervalMultiplier = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "bfd.Cisco-IOS-XE-bfd:echo"); value.Exists() {
+ data.BfdEcho = types.BoolValue(value.Bool())
+ } else {
+ data.BfdEcho = types.BoolNull()
+ }
+ if value := res.Get(prefix + "ipv6.enable"); value.Exists() {
+ data.Ipv6Enable = types.BoolValue(true)
+ } else {
+ data.Ipv6Enable = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "ipv6.mtu"); value.Exists() {
+ data.Ipv6Mtu = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "ipv6.nd.Cisco-IOS-XE-nd:ra.suppress.all"); value.Exists() {
+ data.Ipv6NdRaSuppressAll = types.BoolValue(true)
+ } else {
+ data.Ipv6NdRaSuppressAll = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "ipv6.address.autoconfig.default"); value.Exists() {
+ data.Ipv6AddressAutoconfigDefault = types.BoolValue(true)
+ } else {
+ data.Ipv6AddressAutoconfigDefault = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "ipv6.address.dhcp"); value.Exists() {
+ data.Ipv6AddressDhcp = types.BoolValue(true)
+ } else {
+ data.Ipv6AddressDhcp = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "ipv6.address.link-local-address"); value.Exists() {
+ data.Ipv6LinkLocalAddresses = make([]InterfaceEthernetIpv6LinkLocalAddresses, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := InterfaceEthernetIpv6LinkLocalAddresses{}
+ if cValue := v.Get("address"); cValue.Exists() {
+ item.Address = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("link-local"); cValue.Exists() {
+ item.LinkLocal = types.BoolValue(true)
+ } else {
+ item.LinkLocal = types.BoolValue(false)
+ }
+ data.Ipv6LinkLocalAddresses = append(data.Ipv6LinkLocalAddresses, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + "ipv6.address.prefix-list"); value.Exists() {
+ data.Ipv6Addresses = make([]InterfaceEthernetIpv6Addresses, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := InterfaceEthernetIpv6Addresses{}
+ if cValue := v.Get("prefix"); cValue.Exists() {
+ item.Prefix = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("eui-64"); cValue.Exists() {
+ item.Eui64 = types.BoolValue(true)
+ } else {
+ item.Eui64 = types.BoolValue(false)
+ }
+ data.Ipv6Addresses = append(data.Ipv6Addresses, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + "ipv6.Cisco-IOS-XE-flow:flow.monitor-new"); value.Exists() {
+ data.Ipv6FlowMonitors = make([]InterfaceEthernetIpv6FlowMonitors, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := InterfaceEthernetIpv6FlowMonitors{}
+ if cValue := v.Get("name"); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("direction"); cValue.Exists() {
+ item.Direction = types.StringValue(cValue.String())
+ }
+ data.Ipv6FlowMonitors = append(data.Ipv6FlowMonitors, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + "arp.timeout"); value.Exists() {
+ data.ArpTimeout = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-spanning-tree:spanning-tree.link-type"); value.Exists() {
+ data.SpanningTreeLinkType = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-spanning-tree:spanning-tree.bpduguard.enable"); value.Exists() {
+ data.BpduguardEnable = types.BoolValue(true)
+ } else {
+ data.BpduguardEnable = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-spanning-tree:spanning-tree.bpduguard.disable"); value.Exists() {
+ data.BpduguardDisable = types.BoolValue(true)
+ } else {
+ data.BpduguardDisable = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-spanning-tree:spanning-tree.portfast"); value.Exists() {
+ data.SpanningTreePortfast = types.BoolValue(true)
+ } else {
+ data.SpanningTreePortfast = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-spanning-tree:spanning-tree.portfast.disable"); value.Exists() {
+ data.SpanningTreePortfastDisable = types.BoolValue(true)
+ } else {
+ data.SpanningTreePortfastDisable = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-spanning-tree:spanning-tree.portfast.trunk"); value.Exists() {
+ data.SpanningTreePortfastTrunk = types.BoolValue(true)
+ } else {
+ data.SpanningTreePortfastTrunk = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-spanning-tree:spanning-tree.portfast.edge"); value.Exists() {
+ data.SpanningTreePortfastEdge = types.BoolValue(true)
+ } else {
+ data.SpanningTreePortfastEdge = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "ip.arp.inspection.trust"); value.Exists() {
+ data.IpArpInspectionTrust = types.BoolValue(true)
+ } else {
+ data.IpArpInspectionTrust = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "ip.arp.inspection.limit.rate"); value.Exists() {
+ data.IpArpInspectionLimitRate = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "ip.dhcp.Cisco-IOS-XE-dhcp:snooping.trust"); value.Exists() {
+ data.IpDhcpSnoopingTrust = types.BoolValue(true)
+ } else {
+ data.IpDhcpSnoopingTrust = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-ethernet:speed.value-100"); value.Exists() {
+ data.Speed100 = types.BoolValue(true)
+ } else {
+ data.Speed100 = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-ethernet:speed.value-1000"); value.Exists() {
+ data.Speed1000 = types.BoolValue(true)
+ } else {
+ data.Speed1000 = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-ethernet:speed.value-2500"); value.Exists() {
+ data.Speed2500 = types.BoolValue(true)
+ } else {
+ data.Speed2500 = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-ethernet:speed.value-5000"); value.Exists() {
+ data.Speed5000 = types.BoolValue(true)
+ } else {
+ data.Speed5000 = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-ethernet:speed.value-10000"); value.Exists() {
+ data.Speed10000 = types.BoolValue(true)
+ } else {
+ data.Speed10000 = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-ethernet:speed.value-25000"); value.Exists() {
+ data.Speed25000 = types.BoolValue(true)
+ } else {
+ data.Speed25000 = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-ethernet:speed.value-40000"); value.Exists() {
+ data.Speed40000 = types.BoolValue(true)
+ } else {
+ data.Speed40000 = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-ethernet:speed.value-100000"); value.Exists() {
+ data.Speed100000 = types.BoolValue(true)
+ } else {
+ data.Speed100000 = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-ethernet:negotiation.auto"); value.Exists() {
+ data.NegotiationAuto = types.BoolValue(value.Bool())
+ } else {
+ data.NegotiationAuto = types.BoolNull()
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-ethernet:speed.nonegotiate"); value.Exists() {
+ data.SpeedNonegotiate = types.BoolValue(true)
+ } else {
+ data.SpeedNonegotiate = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-sanet:authentication.host-mode"); value.Exists() {
+ data.AuthenticationHostMode = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-sanet:authentication.order-config.dot1x-config"); value.Exists() {
+ data.AuthenticationOrderDot1x = types.BoolValue(true)
+ } else {
+ data.AuthenticationOrderDot1x = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-sanet:authentication.order-config.dot1x-config.mab"); value.Exists() {
+ data.AuthenticationOrderDot1xMab = types.BoolValue(true)
+ } else {
+ data.AuthenticationOrderDot1xMab = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-sanet:authentication.order-config.dot1x-config.webauth"); value.Exists() {
+ data.AuthenticationOrderDot1xWebauth = types.BoolValue(true)
+ } else {
+ data.AuthenticationOrderDot1xWebauth = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-sanet:authentication.order-config.mab-config"); value.Exists() {
+ data.AuthenticationOrderMab = types.BoolValue(true)
+ } else {
+ data.AuthenticationOrderMab = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-sanet:authentication.order-config.mab-config.dot1x"); value.Exists() {
+ data.AuthenticationOrderMabDot1x = types.BoolValue(true)
+ } else {
+ data.AuthenticationOrderMabDot1x = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-sanet:authentication.order-config.mab-config.webauth"); value.Exists() {
+ data.AuthenticationOrderMabWebauth = types.BoolValue(true)
+ } else {
+ data.AuthenticationOrderMabWebauth = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-sanet:authentication.order-config.webauth-config"); value.Exists() {
+ data.AuthenticationOrderWebauth = types.BoolValue(true)
+ } else {
+ data.AuthenticationOrderWebauth = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-sanet:authentication.priority-config.dot1x-config"); value.Exists() {
+ data.AuthenticationPriorityDot1x = types.BoolValue(true)
+ } else {
+ data.AuthenticationPriorityDot1x = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-sanet:authentication.priority-config.dot1x-config.mab"); value.Exists() {
+ data.AuthenticationPriorityDot1xMab = types.BoolValue(true)
+ } else {
+ data.AuthenticationPriorityDot1xMab = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-sanet:authentication.priority-config.dot1x-config.webauth"); value.Exists() {
+ data.AuthenticationPriorityDot1xWebauth = types.BoolValue(true)
+ } else {
+ data.AuthenticationPriorityDot1xWebauth = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-sanet:authentication.priority-config.mab-config"); value.Exists() {
+ data.AuthenticationPriorityMab = types.BoolValue(true)
+ } else {
+ data.AuthenticationPriorityMab = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-sanet:authentication.priority-config.mab-config.dot1x"); value.Exists() {
+ data.AuthenticationPriorityMabDot1x = types.BoolValue(true)
+ } else {
+ data.AuthenticationPriorityMabDot1x = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-sanet:authentication.priority-config.mab-config.webauth"); value.Exists() {
+ data.AuthenticationPriorityMabWebauth = types.BoolValue(true)
+ } else {
+ data.AuthenticationPriorityMabWebauth = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-sanet:authentication.priority-config.webauth-config"); value.Exists() {
+ data.AuthenticationPriorityWebauth = types.BoolValue(true)
+ } else {
+ data.AuthenticationPriorityWebauth = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-sanet:authentication.port-control"); value.Exists() {
+ data.AuthenticationPortControl = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-sanet:authentication.periodic"); value.Exists() {
+ data.AuthenticationPeriodic = types.BoolValue(true)
+ } else {
+ data.AuthenticationPeriodic = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-sanet:authentication.timer.reauthenticate.value-config"); value.Exists() {
+ data.AuthenticationTimerReauthenticate = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-sanet:authentication.timer.reauthenticate.server-config"); value.Exists() {
+ data.AuthenticationTimerReauthenticateServer = types.BoolValue(true)
+ } else {
+ data.AuthenticationTimerReauthenticateServer = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-sanet:authentication.event.server.alive.action.reinitialize"); value.Exists() {
+ data.AuthenticationEventServerAliveActionReinitialize = types.BoolValue(true)
+ } else {
+ data.AuthenticationEventServerAliveActionReinitialize = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-sanet:authentication.event.server.dead.action.authorize"); value.Exists() {
+ data.AuthenticationEventServerDeadActionAuthorize = types.BoolValue(true)
+ } else {
+ data.AuthenticationEventServerDeadActionAuthorize = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-sanet:authentication.event.server.dead.action.authorize.vlan"); value.Exists() {
+ data.AuthenticationEventServerDeadActionAuthorizeVlan = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-sanet:authentication.event.server.dead.action.authorize.voice"); value.Exists() {
+ data.AuthenticationEventServerDeadActionAuthorizeVoice = types.BoolValue(true)
+ } else {
+ data.AuthenticationEventServerDeadActionAuthorizeVoice = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-sanet:authentication.event.server.dead.action.reinitialize.vlan"); value.Exists() {
+ data.AuthenticationEventServerDeadActionReinitializeVlan = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-sanet:authentication.event.fail-config.action.authorize.vlan"); value.Exists() {
+ data.AuthenticationEventFailActionAuthorizeVlan = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-sanet:authentication.event.fail-config.action.next-method"); value.Exists() {
+ data.AuthenticationEventFailActionNextMethod = types.BoolValue(true)
+ } else {
+ data.AuthenticationEventFailActionNextMethod = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-sanet:authentication.event.no-response.action.authorize.vlan"); value.Exists() {
+ data.AuthenticationEventNoResponseActionAuthorizeVlan = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-sanet:authentication.event.linksec.fail.action.next-method"); value.Exists() {
+ data.AuthenticationEventLinksecFailActionNextMethod = types.BoolValue(true)
+ } else {
+ data.AuthenticationEventLinksecFailActionNextMethod = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-sanet:mab"); value.Exists() {
+ data.Mab = types.BoolValue(true)
+ } else {
+ data.Mab = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-sanet:mab.eap"); value.Exists() {
+ data.MabEap = types.BoolValue(true)
+ } else {
+ data.MabEap = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-dot1x:dot1x.pae"); value.Exists() {
+ data.Dot1xPae = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-dot1x:dot1x.timeout.auth-period"); value.Exists() {
+ data.Dot1xTimeoutAuthPeriod = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-dot1x:dot1x.timeout.held-period"); value.Exists() {
+ data.Dot1xTimeoutHeldPeriod = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-dot1x:dot1x.timeout.quiet-period"); value.Exists() {
+ data.Dot1xTimeoutQuietPeriod = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-dot1x:dot1x.timeout.ratelimit-period"); value.Exists() {
+ data.Dot1xTimeoutRatelimitPeriod = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-dot1x:dot1x.timeout.server-timeout"); value.Exists() {
+ data.Dot1xTimeoutServerTimeout = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-dot1x:dot1x.timeout.start-period"); value.Exists() {
+ data.Dot1xTimeoutStartPeriod = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-dot1x:dot1x.timeout.supp-timeout"); value.Exists() {
+ data.Dot1xTimeoutSuppTimeout = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-dot1x:dot1x.timeout.tx-period"); value.Exists() {
+ data.Dot1xTimeoutTxPeriod = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-dot1x:dot1x.max-req"); value.Exists() {
+ data.Dot1xMaxReq = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-dot1x:dot1x.max-reauth-req"); value.Exists() {
+ data.Dot1xMaxReauthReq = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-policy:service-policy.input"); value.Exists() {
+ data.ServicePolicyInput = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-policy:service-policy.output"); value.Exists() {
+ data.ServicePolicyOutput = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "ip.Cisco-IOS-XE-flow:flow.monitor-new"); value.Exists() {
+ data.IpFlowMonitors = make([]InterfaceEthernetIpFlowMonitors, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := InterfaceEthernetIpFlowMonitors{}
+ if cValue := v.Get("name"); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("direction"); cValue.Exists() {
+ item.Direction = types.StringValue(cValue.String())
+ }
+ data.IpFlowMonitors = append(data.IpFlowMonitors, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + "load-interval"); value.Exists() {
+ data.LoadInterval = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:snmp.trap.link-status"); value.Exists() {
+ data.SnmpTrapLinkStatus = types.BoolValue(value.Bool())
+ } else {
+ data.SnmpTrapLinkStatus = types.BoolNull()
+ }
+ if value := res.Get(prefix + "logging.event.link-status-enable"); value.Exists() {
+ data.LoggingEventLinkStatusEnable = types.BoolValue(value.Bool())
+ } else {
+ data.LoggingEventLinkStatusEnable = types.BoolNull()
+ }
+ if value := res.Get(prefix + "ip.Cisco-IOS-XE-nbar:nbar.protocol-discovery"); value.Exists() {
+ data.IpNbarProtocolDiscovery = types.BoolValue(true)
+ } else {
+ data.IpNbarProtocolDiscovery = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-switch:device-tracking"); value.Exists() {
+ data.DeviceTracking = types.BoolValue(true)
+ } else {
+ data.DeviceTracking = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-switch:device-tracking.attached-policies"); value.Exists() {
+ data.DeviceTrackingAttachedPolicies = make([]InterfaceEthernetDeviceTrackingAttachedPolicies, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := InterfaceEthernetDeviceTrackingAttachedPolicies{}
+ if cValue := v.Get("attach-policy"); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ data.DeviceTrackingAttachedPolicies = append(data.DeviceTrackingAttachedPolicies, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-cdp:cdp.enable"); value.Exists() {
+ data.CdpEnable = types.BoolValue(value.Bool())
+ } else {
+ data.CdpEnable = types.BoolNull()
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-cdp:cdp.tlv.default-wrp.app"); value.Exists() {
+ data.CdpTlvApp = types.BoolValue(value.Bool())
+ } else {
+ data.CdpTlvApp = types.BoolNull()
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-cdp:cdp.tlv.location-config"); value.Exists() {
+ data.CdpTlvLocation = types.BoolValue(value.Bool())
+ } else {
+ data.CdpTlvLocation = types.BoolNull()
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-cdp:cdp.tlv.server-location-config"); value.Exists() {
+ data.CdpTlvServerLocation = types.BoolValue(value.Bool())
+ } else {
+ data.CdpTlvServerLocation = types.BoolNull()
+ }
+ if value := res.Get(prefix + "ip.Cisco-IOS-XE-nat:nat.inside"); value.Exists() {
+ data.IpNatInside = types.BoolValue(true)
+ } else {
+ data.IpNatInside = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "ip.Cisco-IOS-XE-nat:nat.outside"); value.Exists() {
+ data.IpNatOutside = types.BoolValue(true)
+ } else {
+ data.IpNatOutside = types.BoolValue(false)
+ }
+}
+
+// End of section. //template:end fromBodyData
+
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyXML
+
+func (data *InterfaceEthernet) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/media-type"); value.Exists() {
+ data.MediaType = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/mtu"); value.Exists() {
+ data.Mtu = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/bandwidth/kilobits"); value.Exists() {
+ data.Bandwidth = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/switchport-conf/switchport"); value.Exists() {
+ data.Switchport = types.BoolValue(value.Bool())
+ } else {
+ data.Switchport = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/description"); value.Exists() {
+ data.Description = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/shutdown"); value.Exists() {
+ data.Shutdown = types.BoolValue(true)
+ } else {
+ data.Shutdown = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/proxy-arp"); value.Exists() {
+ data.IpProxyArp = types.BoolValue(value.Bool())
+ } else {
+ data.IpProxyArp = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/redirects"); value.Exists() {
+ data.IpRedirects = types.BoolValue(value.Bool())
+ } else {
+ data.IpRedirects = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/Cisco-IOS-XE-icmp:unreachables"); value.Exists() {
+ data.IpUnreachables = types.BoolValue(value.Bool())
+ } else {
+ data.IpUnreachables = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/vrf/forwarding"); value.Exists() {
+ data.VrfForwarding = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/address/primary/address"); value.Exists() {
+ data.Ipv4Address = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/address/primary/mask"); value.Exists() {
+ data.Ipv4AddressMask = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/unnumbered"); value.Exists() {
+ data.Unnumbered = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/encapsulation/dot1Q/vlan-id"); value.Exists() {
+ data.EncapsulationDot1qVlanId = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-ethernet:channel-group/number"); value.Exists() {
+ data.ChannelGroupNumber = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-ethernet:channel-group/mode"); value.Exists() {
+ data.ChannelGroupMode = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/dhcp/Cisco-IOS-XE-dhcp:relay/source-interface"); value.Exists() {
+ data.IpDhcpRelaySourceInterface = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/access-group/in/acl/in"); value.Exists() {
+ data.IpAccessGroupInEnable = types.BoolValue(true)
+ } else {
+ data.IpAccessGroupInEnable = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/access-group/in/acl/acl-name"); value.Exists() {
+ data.IpAccessGroupIn = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/access-group/out/acl/out"); value.Exists() {
+ data.IpAccessGroupOutEnable = types.BoolValue(true)
+ } else {
+ data.IpAccessGroupOutEnable = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/access-group/out/acl/acl-name"); value.Exists() {
+ data.IpAccessGroupOut = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-spanning-tree:spanning-tree/guard"); value.Exists() {
+ data.SpanningTreeGuard = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/classify"); value.Exists() {
+ data.AutoQosClassify = types.BoolValue(true)
+ } else {
+ data.AutoQosClassify = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/classify/police"); value.Exists() {
+ data.AutoQosClassifyPolice = types.BoolValue(true)
+ } else {
+ data.AutoQosClassifyPolice = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/trust"); value.Exists() {
+ data.AutoQosTrust = types.BoolValue(true)
+ } else {
+ data.AutoQosTrust = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/trust/cos"); value.Exists() {
+ data.AutoQosTrustCos = types.BoolValue(true)
+ } else {
+ data.AutoQosTrustCos = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/trust/dscp"); value.Exists() {
+ data.AutoQosTrustDscp = types.BoolValue(true)
+ } else {
+ data.AutoQosTrustDscp = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/video/cts"); value.Exists() {
+ data.AutoQosVideoCts = types.BoolValue(true)
+ } else {
+ data.AutoQosVideoCts = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/video/ip-camera"); value.Exists() {
+ data.AutoQosVideoIpCamera = types.BoolValue(true)
+ } else {
+ data.AutoQosVideoIpCamera = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/video/media-player"); value.Exists() {
+ data.AutoQosVideoMediaPlayer = types.BoolValue(true)
+ } else {
+ data.AutoQosVideoMediaPlayer = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/voip"); value.Exists() {
+ data.AutoQosVoip = types.BoolValue(true)
+ } else {
+ data.AutoQosVoip = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/voip/cisco-phone"); value.Exists() {
+ data.AutoQosVoipCiscoPhone = types.BoolValue(true)
+ } else {
+ data.AutoQosVoipCiscoPhone = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/voip/cisco-softphone"); value.Exists() {
+ data.AutoQosVoipCiscoSoftphone = types.BoolValue(true)
+ } else {
+ data.AutoQosVoipCiscoSoftphone = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/voip/trust"); value.Exists() {
+ data.AutoQosVoipTrust = types.BoolValue(true)
+ } else {
+ data.AutoQosVoipTrust = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/trust/device"); value.Exists() {
+ data.TrustDevice = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/helper-address"); value.Exists() {
+ data.HelperAddresses = make([]InterfaceEthernetHelperAddresses, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := InterfaceEthernetHelperAddresses{}
+ if cValue := helpers.GetFromXPath(v, "address"); cValue.Exists() {
+ item.Address = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "global"); cValue.Exists() {
+ item.Global = types.BoolValue(true)
+ } else {
+ item.Global = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "vrf"); cValue.Exists() {
+ item.Vrf = types.StringValue(cValue.String())
+ }
+ data.HelperAddresses = append(data.HelperAddresses, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/source/template/template-name"); value.Exists() {
+ data.SourceTemplate = make([]InterfaceEthernetSourceTemplate, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := InterfaceEthernetSourceTemplate{}
+ if cValue := helpers.GetFromXPath(v, "template-name"); cValue.Exists() {
+ item.TemplateName = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "merge"); cValue.Exists() {
+ item.Merge = types.BoolValue(true)
+ } else {
+ item.Merge = types.BoolValue(false)
+ }
+ data.SourceTemplate = append(data.SourceTemplate, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/bfd/Cisco-IOS-XE-bfd:template"); value.Exists() {
+ data.BfdTemplate = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/bfd/Cisco-IOS-XE-bfd:enable"); value.Exists() {
+ data.BfdEnable = types.BoolValue(value.Bool())
+ } else {
+ data.BfdEnable = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/bfd/Cisco-IOS-XE-bfd:local-address"); value.Exists() {
+ data.BfdLocalAddress = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/bfd/Cisco-IOS-XE-bfd:interval-interface/msecs"); value.Exists() {
+ data.BfdInterval = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/bfd/Cisco-IOS-XE-bfd:interval-interface/min_rx"); value.Exists() {
+ data.BfdIntervalMinRx = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/bfd/Cisco-IOS-XE-bfd:interval-interface/multiplier"); value.Exists() {
+ data.BfdIntervalMultiplier = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/bfd/Cisco-IOS-XE-bfd:echo"); value.Exists() {
+ data.BfdEcho = types.BoolValue(value.Bool())
+ } else {
+ data.BfdEcho = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ipv6/enable"); value.Exists() {
+ data.Ipv6Enable = types.BoolValue(true)
+ } else {
+ data.Ipv6Enable = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ipv6/mtu"); value.Exists() {
+ data.Ipv6Mtu = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ipv6/nd/Cisco-IOS-XE-nd:ra/suppress/all"); value.Exists() {
+ data.Ipv6NdRaSuppressAll = types.BoolValue(true)
+ } else {
+ data.Ipv6NdRaSuppressAll = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ipv6/address/autoconfig/default"); value.Exists() {
+ data.Ipv6AddressAutoconfigDefault = types.BoolValue(true)
+ } else {
+ data.Ipv6AddressAutoconfigDefault = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ipv6/address/dhcp"); value.Exists() {
+ data.Ipv6AddressDhcp = types.BoolValue(true)
+ } else {
+ data.Ipv6AddressDhcp = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ipv6/address/link-local-address"); value.Exists() {
+ data.Ipv6LinkLocalAddresses = make([]InterfaceEthernetIpv6LinkLocalAddresses, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := InterfaceEthernetIpv6LinkLocalAddresses{}
+ if cValue := helpers.GetFromXPath(v, "address"); cValue.Exists() {
+ item.Address = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "link-local"); cValue.Exists() {
+ item.LinkLocal = types.BoolValue(true)
+ } else {
+ item.LinkLocal = types.BoolValue(false)
+ }
+ data.Ipv6LinkLocalAddresses = append(data.Ipv6LinkLocalAddresses, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ipv6/address/prefix-list"); value.Exists() {
+ data.Ipv6Addresses = make([]InterfaceEthernetIpv6Addresses, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := InterfaceEthernetIpv6Addresses{}
+ if cValue := helpers.GetFromXPath(v, "prefix"); cValue.Exists() {
+ item.Prefix = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "eui-64"); cValue.Exists() {
+ item.Eui64 = types.BoolValue(true)
+ } else {
+ item.Eui64 = types.BoolValue(false)
+ }
+ data.Ipv6Addresses = append(data.Ipv6Addresses, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ipv6/Cisco-IOS-XE-flow:flow/monitor-new"); value.Exists() {
+ data.Ipv6FlowMonitors = make([]InterfaceEthernetIpv6FlowMonitors, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := InterfaceEthernetIpv6FlowMonitors{}
+ if cValue := helpers.GetFromXPath(v, "name"); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "direction"); cValue.Exists() {
+ item.Direction = types.StringValue(cValue.String())
+ }
+ data.Ipv6FlowMonitors = append(data.Ipv6FlowMonitors, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/arp/timeout"); value.Exists() {
+ data.ArpTimeout = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-spanning-tree:spanning-tree/link-type"); value.Exists() {
+ data.SpanningTreeLinkType = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-spanning-tree:spanning-tree/bpduguard/enable"); value.Exists() {
+ data.BpduguardEnable = types.BoolValue(true)
+ } else {
+ data.BpduguardEnable = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-spanning-tree:spanning-tree/bpduguard/disable"); value.Exists() {
+ data.BpduguardDisable = types.BoolValue(true)
+ } else {
+ data.BpduguardDisable = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-spanning-tree:spanning-tree/portfast"); value.Exists() {
+ data.SpanningTreePortfast = types.BoolValue(true)
+ } else {
+ data.SpanningTreePortfast = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-spanning-tree:spanning-tree/portfast/disable"); value.Exists() {
+ data.SpanningTreePortfastDisable = types.BoolValue(true)
+ } else {
+ data.SpanningTreePortfastDisable = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-spanning-tree:spanning-tree/portfast/trunk"); value.Exists() {
+ data.SpanningTreePortfastTrunk = types.BoolValue(true)
+ } else {
+ data.SpanningTreePortfastTrunk = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-spanning-tree:spanning-tree/portfast/edge"); value.Exists() {
+ data.SpanningTreePortfastEdge = types.BoolValue(true)
+ } else {
+ data.SpanningTreePortfastEdge = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/arp/inspection/trust"); value.Exists() {
+ data.IpArpInspectionTrust = types.BoolValue(true)
+ } else {
+ data.IpArpInspectionTrust = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/arp/inspection/limit/rate"); value.Exists() {
+ data.IpArpInspectionLimitRate = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/dhcp/Cisco-IOS-XE-dhcp:snooping/trust"); value.Exists() {
+ data.IpDhcpSnoopingTrust = types.BoolValue(true)
+ } else {
+ data.IpDhcpSnoopingTrust = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-ethernet:speed/value-100"); value.Exists() {
+ data.Speed100 = types.BoolValue(true)
+ } else {
+ data.Speed100 = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-ethernet:speed/value-1000"); value.Exists() {
+ data.Speed1000 = types.BoolValue(true)
+ } else {
+ data.Speed1000 = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-ethernet:speed/value-2500"); value.Exists() {
+ data.Speed2500 = types.BoolValue(true)
+ } else {
+ data.Speed2500 = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-ethernet:speed/value-5000"); value.Exists() {
+ data.Speed5000 = types.BoolValue(true)
+ } else {
+ data.Speed5000 = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-ethernet:speed/value-10000"); value.Exists() {
+ data.Speed10000 = types.BoolValue(true)
+ } else {
+ data.Speed10000 = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-ethernet:speed/value-25000"); value.Exists() {
+ data.Speed25000 = types.BoolValue(true)
+ } else {
+ data.Speed25000 = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-ethernet:speed/value-40000"); value.Exists() {
+ data.Speed40000 = types.BoolValue(true)
+ } else {
+ data.Speed40000 = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-ethernet:speed/value-100000"); value.Exists() {
+ data.Speed100000 = types.BoolValue(true)
+ } else {
+ data.Speed100000 = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-ethernet:negotiation/auto"); value.Exists() {
+ data.NegotiationAuto = types.BoolValue(value.Bool())
+ } else {
+ data.NegotiationAuto = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-ethernet:speed/nonegotiate"); value.Exists() {
+ data.SpeedNonegotiate = types.BoolValue(true)
+ } else {
+ data.SpeedNonegotiate = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-sanet:authentication/host-mode"); value.Exists() {
+ data.AuthenticationHostMode = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-sanet:authentication/order-config/dot1x-config"); value.Exists() {
+ data.AuthenticationOrderDot1x = types.BoolValue(true)
+ } else {
+ data.AuthenticationOrderDot1x = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-sanet:authentication/order-config/dot1x-config/mab"); value.Exists() {
+ data.AuthenticationOrderDot1xMab = types.BoolValue(true)
+ } else {
+ data.AuthenticationOrderDot1xMab = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-sanet:authentication/order-config/dot1x-config/webauth"); value.Exists() {
+ data.AuthenticationOrderDot1xWebauth = types.BoolValue(true)
+ } else {
+ data.AuthenticationOrderDot1xWebauth = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-sanet:authentication/order-config/mab-config"); value.Exists() {
+ data.AuthenticationOrderMab = types.BoolValue(true)
+ } else {
+ data.AuthenticationOrderMab = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-sanet:authentication/order-config/mab-config/dot1x"); value.Exists() {
+ data.AuthenticationOrderMabDot1x = types.BoolValue(true)
+ } else {
+ data.AuthenticationOrderMabDot1x = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-sanet:authentication/order-config/mab-config/webauth"); value.Exists() {
+ data.AuthenticationOrderMabWebauth = types.BoolValue(true)
+ } else {
+ data.AuthenticationOrderMabWebauth = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-sanet:authentication/order-config/webauth-config"); value.Exists() {
+ data.AuthenticationOrderWebauth = types.BoolValue(true)
+ } else {
+ data.AuthenticationOrderWebauth = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-sanet:authentication/priority-config/dot1x-config"); value.Exists() {
+ data.AuthenticationPriorityDot1x = types.BoolValue(true)
+ } else {
+ data.AuthenticationPriorityDot1x = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-sanet:authentication/priority-config/dot1x-config/mab"); value.Exists() {
+ data.AuthenticationPriorityDot1xMab = types.BoolValue(true)
+ } else {
+ data.AuthenticationPriorityDot1xMab = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-sanet:authentication/priority-config/dot1x-config/webauth"); value.Exists() {
+ data.AuthenticationPriorityDot1xWebauth = types.BoolValue(true)
+ } else {
+ data.AuthenticationPriorityDot1xWebauth = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-sanet:authentication/priority-config/mab-config"); value.Exists() {
+ data.AuthenticationPriorityMab = types.BoolValue(true)
+ } else {
+ data.AuthenticationPriorityMab = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-sanet:authentication/priority-config/mab-config/dot1x"); value.Exists() {
+ data.AuthenticationPriorityMabDot1x = types.BoolValue(true)
+ } else {
+ data.AuthenticationPriorityMabDot1x = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-sanet:authentication/priority-config/mab-config/webauth"); value.Exists() {
+ data.AuthenticationPriorityMabWebauth = types.BoolValue(true)
+ } else {
+ data.AuthenticationPriorityMabWebauth = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-sanet:authentication/priority-config/webauth-config"); value.Exists() {
+ data.AuthenticationPriorityWebauth = types.BoolValue(true)
+ } else {
+ data.AuthenticationPriorityWebauth = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-sanet:authentication/port-control"); value.Exists() {
+ data.AuthenticationPortControl = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-sanet:authentication/periodic"); value.Exists() {
+ data.AuthenticationPeriodic = types.BoolValue(true)
+ } else {
+ data.AuthenticationPeriodic = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-sanet:authentication/timer/reauthenticate/value-config"); value.Exists() {
+ data.AuthenticationTimerReauthenticate = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-sanet:authentication/timer/reauthenticate/server-config"); value.Exists() {
+ data.AuthenticationTimerReauthenticateServer = types.BoolValue(true)
+ } else {
+ data.AuthenticationTimerReauthenticateServer = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-sanet:authentication/event/server/alive/action/reinitialize"); value.Exists() {
+ data.AuthenticationEventServerAliveActionReinitialize = types.BoolValue(true)
+ } else {
+ data.AuthenticationEventServerAliveActionReinitialize = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-sanet:authentication/event/server/dead/action/authorize"); value.Exists() {
+ data.AuthenticationEventServerDeadActionAuthorize = types.BoolValue(true)
+ } else {
+ data.AuthenticationEventServerDeadActionAuthorize = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-sanet:authentication/event/server/dead/action/authorize/vlan"); value.Exists() {
+ data.AuthenticationEventServerDeadActionAuthorizeVlan = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-sanet:authentication/event/server/dead/action/authorize/voice"); value.Exists() {
+ data.AuthenticationEventServerDeadActionAuthorizeVoice = types.BoolValue(true)
+ } else {
+ data.AuthenticationEventServerDeadActionAuthorizeVoice = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-sanet:authentication/event/server/dead/action/reinitialize/vlan"); value.Exists() {
+ data.AuthenticationEventServerDeadActionReinitializeVlan = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-sanet:authentication/event/fail-config/action/authorize/vlan"); value.Exists() {
+ data.AuthenticationEventFailActionAuthorizeVlan = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-sanet:authentication/event/fail-config/action/next-method"); value.Exists() {
+ data.AuthenticationEventFailActionNextMethod = types.BoolValue(true)
+ } else {
+ data.AuthenticationEventFailActionNextMethod = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-sanet:authentication/event/no-response/action/authorize/vlan"); value.Exists() {
+ data.AuthenticationEventNoResponseActionAuthorizeVlan = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-sanet:authentication/event/linksec/fail/action/next-method"); value.Exists() {
+ data.AuthenticationEventLinksecFailActionNextMethod = types.BoolValue(true)
+ } else {
+ data.AuthenticationEventLinksecFailActionNextMethod = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-sanet:mab"); value.Exists() {
+ data.Mab = types.BoolValue(true)
+ } else {
+ data.Mab = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-sanet:mab/eap"); value.Exists() {
+ data.MabEap = types.BoolValue(true)
+ } else {
+ data.MabEap = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-dot1x:dot1x/pae"); value.Exists() {
+ data.Dot1xPae = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-dot1x:dot1x/timeout/auth-period"); value.Exists() {
+ data.Dot1xTimeoutAuthPeriod = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-dot1x:dot1x/timeout/held-period"); value.Exists() {
+ data.Dot1xTimeoutHeldPeriod = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-dot1x:dot1x/timeout/quiet-period"); value.Exists() {
+ data.Dot1xTimeoutQuietPeriod = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-dot1x:dot1x/timeout/ratelimit-period"); value.Exists() {
+ data.Dot1xTimeoutRatelimitPeriod = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-dot1x:dot1x/timeout/server-timeout"); value.Exists() {
+ data.Dot1xTimeoutServerTimeout = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-dot1x:dot1x/timeout/start-period"); value.Exists() {
+ data.Dot1xTimeoutStartPeriod = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-dot1x:dot1x/timeout/supp-timeout"); value.Exists() {
+ data.Dot1xTimeoutSuppTimeout = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-dot1x:dot1x/timeout/tx-period"); value.Exists() {
+ data.Dot1xTimeoutTxPeriod = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-dot1x:dot1x/max-req"); value.Exists() {
+ data.Dot1xMaxReq = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-dot1x:dot1x/max-reauth-req"); value.Exists() {
+ data.Dot1xMaxReauthReq = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-policy:service-policy/input"); value.Exists() {
+ data.ServicePolicyInput = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-policy:service-policy/output"); value.Exists() {
+ data.ServicePolicyOutput = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/Cisco-IOS-XE-flow:flow/monitor-new"); value.Exists() {
+ data.IpFlowMonitors = make([]InterfaceEthernetIpFlowMonitors, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := InterfaceEthernetIpFlowMonitors{}
+ if cValue := helpers.GetFromXPath(v, "name"); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "direction"); cValue.Exists() {
+ item.Direction = types.StringValue(cValue.String())
+ }
+ data.IpFlowMonitors = append(data.IpFlowMonitors, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/load-interval"); value.Exists() {
+ data.LoadInterval = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:snmp/trap/link-status"); value.Exists() {
+ data.SnmpTrapLinkStatus = types.BoolValue(value.Bool())
+ } else {
+ data.SnmpTrapLinkStatus = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/logging/event/link-status-enable"); value.Exists() {
+ data.LoggingEventLinkStatusEnable = types.BoolValue(value.Bool())
+ } else {
+ data.LoggingEventLinkStatusEnable = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/Cisco-IOS-XE-nbar:nbar/protocol-discovery"); value.Exists() {
+ data.IpNbarProtocolDiscovery = types.BoolValue(true)
+ } else {
+ data.IpNbarProtocolDiscovery = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-switch:device-tracking"); value.Exists() {
+ data.DeviceTracking = types.BoolValue(true)
+ } else {
+ data.DeviceTracking = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-switch:device-tracking/attached-policies"); value.Exists() {
+ data.DeviceTrackingAttachedPolicies = make([]InterfaceEthernetDeviceTrackingAttachedPolicies, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := InterfaceEthernetDeviceTrackingAttachedPolicies{}
+ if cValue := helpers.GetFromXPath(v, "attach-policy"); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ data.DeviceTrackingAttachedPolicies = append(data.DeviceTrackingAttachedPolicies, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-cdp:cdp/enable"); value.Exists() {
+ data.CdpEnable = types.BoolValue(value.Bool())
+ } else {
+ data.CdpEnable = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-cdp:cdp/tlv/default-wrp/app"); value.Exists() {
+ data.CdpTlvApp = types.BoolValue(value.Bool())
+ } else {
+ data.CdpTlvApp = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-cdp:cdp/tlv/location-config"); value.Exists() {
+ data.CdpTlvLocation = types.BoolValue(value.Bool())
+ } else {
+ data.CdpTlvLocation = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-cdp:cdp/tlv/server-location-config"); value.Exists() {
+ data.CdpTlvServerLocation = types.BoolValue(value.Bool())
+ } else {
+ data.CdpTlvServerLocation = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/Cisco-IOS-XE-nat:nat/inside"); value.Exists() {
+ data.IpNatInside = types.BoolValue(true)
+ } else {
+ data.IpNatInside = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/Cisco-IOS-XE-nat:nat/outside"); value.Exists() {
+ data.IpNatOutside = types.BoolValue(true)
+ } else {
+ data.IpNatOutside = types.BoolValue(false)
+ }
+}
+
+// End of section. //template:end fromBodyXML
+
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyDataXML
+
+func (data *InterfaceEthernetData) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/media-type"); value.Exists() {
+ data.MediaType = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/mtu"); value.Exists() {
+ data.Mtu = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/bandwidth/kilobits"); value.Exists() {
+ data.Bandwidth = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/switchport-conf/switchport"); value.Exists() {
+ data.Switchport = types.BoolValue(value.Bool())
+ } else {
+ data.Switchport = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/description"); value.Exists() {
+ data.Description = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/shutdown"); value.Exists() {
+ data.Shutdown = types.BoolValue(true)
+ } else {
+ data.Shutdown = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/proxy-arp"); value.Exists() {
+ data.IpProxyArp = types.BoolValue(value.Bool())
+ } else {
+ data.IpProxyArp = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/redirects"); value.Exists() {
+ data.IpRedirects = types.BoolValue(value.Bool())
+ } else {
+ data.IpRedirects = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/Cisco-IOS-XE-icmp:unreachables"); value.Exists() {
+ data.IpUnreachables = types.BoolValue(value.Bool())
+ } else {
+ data.IpUnreachables = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/vrf/forwarding"); value.Exists() {
+ data.VrfForwarding = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/address/primary/address"); value.Exists() {
+ data.Ipv4Address = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/address/primary/mask"); value.Exists() {
+ data.Ipv4AddressMask = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/unnumbered"); value.Exists() {
+ data.Unnumbered = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/encapsulation/dot1Q/vlan-id"); value.Exists() {
+ data.EncapsulationDot1qVlanId = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-ethernet:channel-group/number"); value.Exists() {
+ data.ChannelGroupNumber = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-ethernet:channel-group/mode"); value.Exists() {
+ data.ChannelGroupMode = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/dhcp/Cisco-IOS-XE-dhcp:relay/source-interface"); value.Exists() {
+ data.IpDhcpRelaySourceInterface = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/access-group/in/acl/in"); value.Exists() {
+ data.IpAccessGroupInEnable = types.BoolValue(true)
+ } else {
+ data.IpAccessGroupInEnable = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/access-group/in/acl/acl-name"); value.Exists() {
+ data.IpAccessGroupIn = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/access-group/out/acl/out"); value.Exists() {
+ data.IpAccessGroupOutEnable = types.BoolValue(true)
+ } else {
+ data.IpAccessGroupOutEnable = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/access-group/out/acl/acl-name"); value.Exists() {
+ data.IpAccessGroupOut = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-spanning-tree:spanning-tree/guard"); value.Exists() {
+ data.SpanningTreeGuard = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/classify"); value.Exists() {
+ data.AutoQosClassify = types.BoolValue(true)
+ } else {
+ data.AutoQosClassify = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/classify/police"); value.Exists() {
+ data.AutoQosClassifyPolice = types.BoolValue(true)
+ } else {
+ data.AutoQosClassifyPolice = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/trust"); value.Exists() {
+ data.AutoQosTrust = types.BoolValue(true)
+ } else {
+ data.AutoQosTrust = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/trust/cos"); value.Exists() {
+ data.AutoQosTrustCos = types.BoolValue(true)
+ } else {
+ data.AutoQosTrustCos = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/trust/dscp"); value.Exists() {
+ data.AutoQosTrustDscp = types.BoolValue(true)
+ } else {
+ data.AutoQosTrustDscp = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/video/cts"); value.Exists() {
+ data.AutoQosVideoCts = types.BoolValue(true)
+ } else {
+ data.AutoQosVideoCts = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/video/ip-camera"); value.Exists() {
+ data.AutoQosVideoIpCamera = types.BoolValue(true)
+ } else {
+ data.AutoQosVideoIpCamera = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/video/media-player"); value.Exists() {
+ data.AutoQosVideoMediaPlayer = types.BoolValue(true)
+ } else {
+ data.AutoQosVideoMediaPlayer = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/voip"); value.Exists() {
+ data.AutoQosVoip = types.BoolValue(true)
+ } else {
+ data.AutoQosVoip = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/voip/cisco-phone"); value.Exists() {
+ data.AutoQosVoipCiscoPhone = types.BoolValue(true)
+ } else {
+ data.AutoQosVoipCiscoPhone = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/voip/cisco-softphone"); value.Exists() {
+ data.AutoQosVoipCiscoSoftphone = types.BoolValue(true)
+ } else {
+ data.AutoQosVoipCiscoSoftphone = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/voip/trust"); value.Exists() {
+ data.AutoQosVoipTrust = types.BoolValue(true)
+ } else {
+ data.AutoQosVoipTrust = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/trust/device"); value.Exists() {
+ data.TrustDevice = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/helper-address"); value.Exists() {
+ data.HelperAddresses = make([]InterfaceEthernetHelperAddresses, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := InterfaceEthernetHelperAddresses{}
+ if cValue := helpers.GetFromXPath(v, "address"); cValue.Exists() {
+ item.Address = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "global"); cValue.Exists() {
+ item.Global = types.BoolValue(true)
+ } else {
+ item.Global = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "vrf"); cValue.Exists() {
+ item.Vrf = types.StringValue(cValue.String())
+ }
+ data.HelperAddresses = append(data.HelperAddresses, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/source/template/template-name"); value.Exists() {
+ data.SourceTemplate = make([]InterfaceEthernetSourceTemplate, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := InterfaceEthernetSourceTemplate{}
+ if cValue := helpers.GetFromXPath(v, "template-name"); cValue.Exists() {
+ item.TemplateName = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "merge"); cValue.Exists() {
+ item.Merge = types.BoolValue(true)
+ } else {
+ item.Merge = types.BoolValue(false)
+ }
+ data.SourceTemplate = append(data.SourceTemplate, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/bfd/Cisco-IOS-XE-bfd:template"); value.Exists() {
+ data.BfdTemplate = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/bfd/Cisco-IOS-XE-bfd:enable"); value.Exists() {
+ data.BfdEnable = types.BoolValue(value.Bool())
+ } else {
+ data.BfdEnable = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/bfd/Cisco-IOS-XE-bfd:local-address"); value.Exists() {
+ data.BfdLocalAddress = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/bfd/Cisco-IOS-XE-bfd:interval-interface/msecs"); value.Exists() {
+ data.BfdInterval = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/bfd/Cisco-IOS-XE-bfd:interval-interface/min_rx"); value.Exists() {
+ data.BfdIntervalMinRx = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/bfd/Cisco-IOS-XE-bfd:interval-interface/multiplier"); value.Exists() {
+ data.BfdIntervalMultiplier = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/bfd/Cisco-IOS-XE-bfd:echo"); value.Exists() {
+ data.BfdEcho = types.BoolValue(value.Bool())
+ } else {
+ data.BfdEcho = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ipv6/enable"); value.Exists() {
+ data.Ipv6Enable = types.BoolValue(true)
+ } else {
+ data.Ipv6Enable = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ipv6/mtu"); value.Exists() {
+ data.Ipv6Mtu = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ipv6/nd/Cisco-IOS-XE-nd:ra/suppress/all"); value.Exists() {
+ data.Ipv6NdRaSuppressAll = types.BoolValue(true)
+ } else {
+ data.Ipv6NdRaSuppressAll = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ipv6/address/autoconfig/default"); value.Exists() {
+ data.Ipv6AddressAutoconfigDefault = types.BoolValue(true)
+ } else {
+ data.Ipv6AddressAutoconfigDefault = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ipv6/address/dhcp"); value.Exists() {
+ data.Ipv6AddressDhcp = types.BoolValue(true)
+ } else {
+ data.Ipv6AddressDhcp = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ipv6/address/link-local-address"); value.Exists() {
+ data.Ipv6LinkLocalAddresses = make([]InterfaceEthernetIpv6LinkLocalAddresses, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := InterfaceEthernetIpv6LinkLocalAddresses{}
+ if cValue := helpers.GetFromXPath(v, "address"); cValue.Exists() {
+ item.Address = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "link-local"); cValue.Exists() {
+ item.LinkLocal = types.BoolValue(true)
+ } else {
+ item.LinkLocal = types.BoolValue(false)
+ }
+ data.Ipv6LinkLocalAddresses = append(data.Ipv6LinkLocalAddresses, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ipv6/address/prefix-list"); value.Exists() {
+ data.Ipv6Addresses = make([]InterfaceEthernetIpv6Addresses, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := InterfaceEthernetIpv6Addresses{}
+ if cValue := helpers.GetFromXPath(v, "prefix"); cValue.Exists() {
+ item.Prefix = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "eui-64"); cValue.Exists() {
+ item.Eui64 = types.BoolValue(true)
+ } else {
+ item.Eui64 = types.BoolValue(false)
+ }
+ data.Ipv6Addresses = append(data.Ipv6Addresses, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ipv6/Cisco-IOS-XE-flow:flow/monitor-new"); value.Exists() {
+ data.Ipv6FlowMonitors = make([]InterfaceEthernetIpv6FlowMonitors, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := InterfaceEthernetIpv6FlowMonitors{}
+ if cValue := helpers.GetFromXPath(v, "name"); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "direction"); cValue.Exists() {
+ item.Direction = types.StringValue(cValue.String())
+ }
+ data.Ipv6FlowMonitors = append(data.Ipv6FlowMonitors, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/arp/timeout"); value.Exists() {
+ data.ArpTimeout = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-spanning-tree:spanning-tree/link-type"); value.Exists() {
+ data.SpanningTreeLinkType = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-spanning-tree:spanning-tree/bpduguard/enable"); value.Exists() {
+ data.BpduguardEnable = types.BoolValue(true)
+ } else {
+ data.BpduguardEnable = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-spanning-tree:spanning-tree/bpduguard/disable"); value.Exists() {
+ data.BpduguardDisable = types.BoolValue(true)
+ } else {
+ data.BpduguardDisable = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-spanning-tree:spanning-tree/portfast"); value.Exists() {
+ data.SpanningTreePortfast = types.BoolValue(true)
+ } else {
+ data.SpanningTreePortfast = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-spanning-tree:spanning-tree/portfast/disable"); value.Exists() {
+ data.SpanningTreePortfastDisable = types.BoolValue(true)
+ } else {
+ data.SpanningTreePortfastDisable = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-spanning-tree:spanning-tree/portfast/trunk"); value.Exists() {
+ data.SpanningTreePortfastTrunk = types.BoolValue(true)
+ } else {
+ data.SpanningTreePortfastTrunk = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-spanning-tree:spanning-tree/portfast/edge"); value.Exists() {
+ data.SpanningTreePortfastEdge = types.BoolValue(true)
+ } else {
+ data.SpanningTreePortfastEdge = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/arp/inspection/trust"); value.Exists() {
+ data.IpArpInspectionTrust = types.BoolValue(true)
+ } else {
+ data.IpArpInspectionTrust = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/arp/inspection/limit/rate"); value.Exists() {
+ data.IpArpInspectionLimitRate = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/dhcp/Cisco-IOS-XE-dhcp:snooping/trust"); value.Exists() {
+ data.IpDhcpSnoopingTrust = types.BoolValue(true)
+ } else {
+ data.IpDhcpSnoopingTrust = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-ethernet:speed/value-100"); value.Exists() {
+ data.Speed100 = types.BoolValue(true)
+ } else {
+ data.Speed100 = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-ethernet:speed/value-1000"); value.Exists() {
+ data.Speed1000 = types.BoolValue(true)
+ } else {
+ data.Speed1000 = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-ethernet:speed/value-2500"); value.Exists() {
+ data.Speed2500 = types.BoolValue(true)
+ } else {
+ data.Speed2500 = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-ethernet:speed/value-5000"); value.Exists() {
+ data.Speed5000 = types.BoolValue(true)
+ } else {
+ data.Speed5000 = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-ethernet:speed/value-10000"); value.Exists() {
+ data.Speed10000 = types.BoolValue(true)
+ } else {
+ data.Speed10000 = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-ethernet:speed/value-25000"); value.Exists() {
+ data.Speed25000 = types.BoolValue(true)
+ } else {
+ data.Speed25000 = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-ethernet:speed/value-40000"); value.Exists() {
+ data.Speed40000 = types.BoolValue(true)
+ } else {
+ data.Speed40000 = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-ethernet:speed/value-100000"); value.Exists() {
+ data.Speed100000 = types.BoolValue(true)
+ } else {
+ data.Speed100000 = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-ethernet:negotiation/auto"); value.Exists() {
+ data.NegotiationAuto = types.BoolValue(value.Bool())
+ } else {
+ data.NegotiationAuto = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-ethernet:speed/nonegotiate"); value.Exists() {
+ data.SpeedNonegotiate = types.BoolValue(true)
+ } else {
+ data.SpeedNonegotiate = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-sanet:authentication/host-mode"); value.Exists() {
+ data.AuthenticationHostMode = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-sanet:authentication/order-config/dot1x-config"); value.Exists() {
+ data.AuthenticationOrderDot1x = types.BoolValue(true)
+ } else {
+ data.AuthenticationOrderDot1x = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-sanet:authentication/order-config/dot1x-config/mab"); value.Exists() {
+ data.AuthenticationOrderDot1xMab = types.BoolValue(true)
+ } else {
+ data.AuthenticationOrderDot1xMab = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-sanet:authentication/order-config/dot1x-config/webauth"); value.Exists() {
+ data.AuthenticationOrderDot1xWebauth = types.BoolValue(true)
+ } else {
+ data.AuthenticationOrderDot1xWebauth = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-sanet:authentication/order-config/mab-config"); value.Exists() {
+ data.AuthenticationOrderMab = types.BoolValue(true)
+ } else {
+ data.AuthenticationOrderMab = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-sanet:authentication/order-config/mab-config/dot1x"); value.Exists() {
+ data.AuthenticationOrderMabDot1x = types.BoolValue(true)
+ } else {
+ data.AuthenticationOrderMabDot1x = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-sanet:authentication/order-config/mab-config/webauth"); value.Exists() {
+ data.AuthenticationOrderMabWebauth = types.BoolValue(true)
+ } else {
+ data.AuthenticationOrderMabWebauth = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-sanet:authentication/order-config/webauth-config"); value.Exists() {
+ data.AuthenticationOrderWebauth = types.BoolValue(true)
+ } else {
+ data.AuthenticationOrderWebauth = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-sanet:authentication/priority-config/dot1x-config"); value.Exists() {
+ data.AuthenticationPriorityDot1x = types.BoolValue(true)
+ } else {
+ data.AuthenticationPriorityDot1x = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-sanet:authentication/priority-config/dot1x-config/mab"); value.Exists() {
+ data.AuthenticationPriorityDot1xMab = types.BoolValue(true)
+ } else {
+ data.AuthenticationPriorityDot1xMab = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-sanet:authentication/priority-config/dot1x-config/webauth"); value.Exists() {
+ data.AuthenticationPriorityDot1xWebauth = types.BoolValue(true)
+ } else {
+ data.AuthenticationPriorityDot1xWebauth = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-sanet:authentication/priority-config/mab-config"); value.Exists() {
+ data.AuthenticationPriorityMab = types.BoolValue(true)
+ } else {
+ data.AuthenticationPriorityMab = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-sanet:authentication/priority-config/mab-config/dot1x"); value.Exists() {
+ data.AuthenticationPriorityMabDot1x = types.BoolValue(true)
+ } else {
+ data.AuthenticationPriorityMabDot1x = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-sanet:authentication/priority-config/mab-config/webauth"); value.Exists() {
+ data.AuthenticationPriorityMabWebauth = types.BoolValue(true)
+ } else {
+ data.AuthenticationPriorityMabWebauth = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-sanet:authentication/priority-config/webauth-config"); value.Exists() {
+ data.AuthenticationPriorityWebauth = types.BoolValue(true)
+ } else {
+ data.AuthenticationPriorityWebauth = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-sanet:authentication/port-control"); value.Exists() {
+ data.AuthenticationPortControl = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-sanet:authentication/periodic"); value.Exists() {
+ data.AuthenticationPeriodic = types.BoolValue(true)
+ } else {
+ data.AuthenticationPeriodic = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-sanet:authentication/timer/reauthenticate/value-config"); value.Exists() {
+ data.AuthenticationTimerReauthenticate = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-sanet:authentication/timer/reauthenticate/server-config"); value.Exists() {
+ data.AuthenticationTimerReauthenticateServer = types.BoolValue(true)
+ } else {
+ data.AuthenticationTimerReauthenticateServer = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-sanet:authentication/event/server/alive/action/reinitialize"); value.Exists() {
+ data.AuthenticationEventServerAliveActionReinitialize = types.BoolValue(true)
+ } else {
+ data.AuthenticationEventServerAliveActionReinitialize = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-sanet:authentication/event/server/dead/action/authorize"); value.Exists() {
+ data.AuthenticationEventServerDeadActionAuthorize = types.BoolValue(true)
+ } else {
+ data.AuthenticationEventServerDeadActionAuthorize = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-sanet:authentication/event/server/dead/action/authorize/vlan"); value.Exists() {
+ data.AuthenticationEventServerDeadActionAuthorizeVlan = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-sanet:authentication/event/server/dead/action/authorize/voice"); value.Exists() {
+ data.AuthenticationEventServerDeadActionAuthorizeVoice = types.BoolValue(true)
+ } else {
+ data.AuthenticationEventServerDeadActionAuthorizeVoice = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-sanet:authentication/event/server/dead/action/reinitialize/vlan"); value.Exists() {
+ data.AuthenticationEventServerDeadActionReinitializeVlan = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-sanet:authentication/event/fail-config/action/authorize/vlan"); value.Exists() {
+ data.AuthenticationEventFailActionAuthorizeVlan = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-sanet:authentication/event/fail-config/action/next-method"); value.Exists() {
+ data.AuthenticationEventFailActionNextMethod = types.BoolValue(true)
+ } else {
+ data.AuthenticationEventFailActionNextMethod = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-sanet:authentication/event/no-response/action/authorize/vlan"); value.Exists() {
+ data.AuthenticationEventNoResponseActionAuthorizeVlan = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-sanet:authentication/event/linksec/fail/action/next-method"); value.Exists() {
+ data.AuthenticationEventLinksecFailActionNextMethod = types.BoolValue(true)
+ } else {
+ data.AuthenticationEventLinksecFailActionNextMethod = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-sanet:mab"); value.Exists() {
+ data.Mab = types.BoolValue(true)
+ } else {
+ data.Mab = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-sanet:mab/eap"); value.Exists() {
+ data.MabEap = types.BoolValue(true)
+ } else {
+ data.MabEap = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-dot1x:dot1x/pae"); value.Exists() {
+ data.Dot1xPae = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-dot1x:dot1x/timeout/auth-period"); value.Exists() {
+ data.Dot1xTimeoutAuthPeriod = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-dot1x:dot1x/timeout/held-period"); value.Exists() {
+ data.Dot1xTimeoutHeldPeriod = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-dot1x:dot1x/timeout/quiet-period"); value.Exists() {
+ data.Dot1xTimeoutQuietPeriod = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-dot1x:dot1x/timeout/ratelimit-period"); value.Exists() {
+ data.Dot1xTimeoutRatelimitPeriod = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-dot1x:dot1x/timeout/server-timeout"); value.Exists() {
+ data.Dot1xTimeoutServerTimeout = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-dot1x:dot1x/timeout/start-period"); value.Exists() {
+ data.Dot1xTimeoutStartPeriod = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-dot1x:dot1x/timeout/supp-timeout"); value.Exists() {
+ data.Dot1xTimeoutSuppTimeout = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-dot1x:dot1x/timeout/tx-period"); value.Exists() {
+ data.Dot1xTimeoutTxPeriod = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-dot1x:dot1x/max-req"); value.Exists() {
+ data.Dot1xMaxReq = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-dot1x:dot1x/max-reauth-req"); value.Exists() {
+ data.Dot1xMaxReauthReq = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-policy:service-policy/input"); value.Exists() {
+ data.ServicePolicyInput = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-policy:service-policy/output"); value.Exists() {
+ data.ServicePolicyOutput = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/Cisco-IOS-XE-flow:flow/monitor-new"); value.Exists() {
+ data.IpFlowMonitors = make([]InterfaceEthernetIpFlowMonitors, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := InterfaceEthernetIpFlowMonitors{}
+ if cValue := helpers.GetFromXPath(v, "name"); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "direction"); cValue.Exists() {
+ item.Direction = types.StringValue(cValue.String())
+ }
+ data.IpFlowMonitors = append(data.IpFlowMonitors, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/load-interval"); value.Exists() {
+ data.LoadInterval = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:snmp/trap/link-status"); value.Exists() {
+ data.SnmpTrapLinkStatus = types.BoolValue(value.Bool())
+ } else {
+ data.SnmpTrapLinkStatus = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/logging/event/link-status-enable"); value.Exists() {
+ data.LoggingEventLinkStatusEnable = types.BoolValue(value.Bool())
+ } else {
+ data.LoggingEventLinkStatusEnable = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/Cisco-IOS-XE-nbar:nbar/protocol-discovery"); value.Exists() {
+ data.IpNbarProtocolDiscovery = types.BoolValue(true)
+ } else {
+ data.IpNbarProtocolDiscovery = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-switch:device-tracking"); value.Exists() {
+ data.DeviceTracking = types.BoolValue(true)
+ } else {
+ data.DeviceTracking = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-switch:device-tracking/attached-policies"); value.Exists() {
+ data.DeviceTrackingAttachedPolicies = make([]InterfaceEthernetDeviceTrackingAttachedPolicies, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := InterfaceEthernetDeviceTrackingAttachedPolicies{}
+ if cValue := helpers.GetFromXPath(v, "attach-policy"); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ data.DeviceTrackingAttachedPolicies = append(data.DeviceTrackingAttachedPolicies, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-cdp:cdp/enable"); value.Exists() {
+ data.CdpEnable = types.BoolValue(value.Bool())
+ } else {
+ data.CdpEnable = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-cdp:cdp/tlv/default-wrp/app"); value.Exists() {
+ data.CdpTlvApp = types.BoolValue(value.Bool())
+ } else {
+ data.CdpTlvApp = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-cdp:cdp/tlv/location-config"); value.Exists() {
+ data.CdpTlvLocation = types.BoolValue(value.Bool())
+ } else {
+ data.CdpTlvLocation = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-cdp:cdp/tlv/server-location-config"); value.Exists() {
+ data.CdpTlvServerLocation = types.BoolValue(value.Bool())
+ } else {
+ data.CdpTlvServerLocation = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/Cisco-IOS-XE-nat:nat/inside"); value.Exists() {
+ data.IpNatInside = types.BoolValue(true)
+ } else {
+ data.IpNatInside = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/Cisco-IOS-XE-nat:nat/outside"); value.Exists() {
+ data.IpNatOutside = types.BoolValue(true)
+ } else {
+ data.IpNatOutside = types.BoolValue(false)
+ }
+}
+
+// End of section. //template:end fromBodyDataXML
+
+// Section below is generated&owned by "gen/generator.go". //template:begin getDeletedItems
+
+func (data *InterfaceEthernet) getDeletedItems(ctx context.Context, state InterfaceEthernet) []string {
+ deletedItems := make([]string, 0)
+ if !state.IpNatOutside.IsNull() && data.IpNatOutside.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/Cisco-IOS-XE-nat:nat/outside", state.getPath()))
+ }
+ if !state.IpNatInside.IsNull() && data.IpNatInside.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/Cisco-IOS-XE-nat:nat/inside", state.getPath()))
+ }
+ if !state.CdpTlvServerLocation.IsNull() && data.CdpTlvServerLocation.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-cdp:cdp/tlv/server-location-config", state.getPath()))
+ }
+ if !state.CdpTlvLocation.IsNull() && data.CdpTlvLocation.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-cdp:cdp/tlv/location-config", state.getPath()))
+ }
+ if !state.CdpTlvApp.IsNull() && data.CdpTlvApp.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-cdp:cdp/tlv/default-wrp/app", state.getPath()))
+ }
+ if !state.CdpEnable.IsNull() && data.CdpEnable.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-cdp:cdp/enable", state.getPath()))
+ }
+ for i := range state.DeviceTrackingAttachedPolicies {
+ stateKeyValues := [...]string{state.DeviceTrackingAttachedPolicies[i].Name.ValueString()}
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.DeviceTrackingAttachedPolicies[i].Name.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.DeviceTrackingAttachedPolicies {
+ found = true
+ if state.DeviceTrackingAttachedPolicies[i].Name.ValueString() != data.DeviceTrackingAttachedPolicies[j].Name.ValueString() {
+ found = false
+ }
+ if found {
+ break
+ }
+ }
+ if !found {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-switch:device-tracking/attached-policies=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ }
+ if !state.DeviceTracking.IsNull() && data.DeviceTracking.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-switch:device-tracking", state.getPath()))
+ }
+ if !state.IpNbarProtocolDiscovery.IsNull() && data.IpNbarProtocolDiscovery.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/Cisco-IOS-XE-nbar:nbar/protocol-discovery", state.getPath()))
+ }
+ if !state.LoggingEventLinkStatusEnable.IsNull() && data.LoggingEventLinkStatusEnable.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/logging/event/link-status-enable", state.getPath()))
+ }
+ if !state.SnmpTrapLinkStatus.IsNull() && data.SnmpTrapLinkStatus.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:snmp/trap/link-status", state.getPath()))
+ }
+ if !state.LoadInterval.IsNull() && data.LoadInterval.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/load-interval", state.getPath()))
+ }
+ for i := range state.IpFlowMonitors {
+ stateKeyValues := [...]string{state.IpFlowMonitors[i].Name.ValueString(), state.IpFlowMonitors[i].Direction.ValueString()}
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.IpFlowMonitors[i].Name.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if !reflect.ValueOf(state.IpFlowMonitors[i].Direction.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.IpFlowMonitors {
+ found = true
+ if state.IpFlowMonitors[i].Name.ValueString() != data.IpFlowMonitors[j].Name.ValueString() {
+ found = false
+ }
+ if state.IpFlowMonitors[i].Direction.ValueString() != data.IpFlowMonitors[j].Direction.ValueString() {
+ found = false
+ }
+ if found {
+ break
+ }
+ }
+ if !found {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/Cisco-IOS-XE-flow:flow/monitor-new=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ }
+ if !state.ServicePolicyOutput.IsNull() && data.ServicePolicyOutput.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-policy:service-policy/output", state.getPath()))
+ }
+ if !state.ServicePolicyInput.IsNull() && data.ServicePolicyInput.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-policy:service-policy/input", state.getPath()))
+ }
+ if !state.Dot1xMaxReauthReq.IsNull() && data.Dot1xMaxReauthReq.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-dot1x:dot1x/max-reauth-req", state.getPath()))
+ }
+ if !state.Dot1xMaxReq.IsNull() && data.Dot1xMaxReq.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-dot1x:dot1x/max-req", state.getPath()))
+ }
+ if !state.Dot1xTimeoutTxPeriod.IsNull() && data.Dot1xTimeoutTxPeriod.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-dot1x:dot1x/timeout/tx-period", state.getPath()))
+ }
+ if !state.Dot1xTimeoutSuppTimeout.IsNull() && data.Dot1xTimeoutSuppTimeout.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-dot1x:dot1x/timeout/supp-timeout", state.getPath()))
+ }
+ if !state.Dot1xTimeoutStartPeriod.IsNull() && data.Dot1xTimeoutStartPeriod.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-dot1x:dot1x/timeout/start-period", state.getPath()))
+ }
+ if !state.Dot1xTimeoutServerTimeout.IsNull() && data.Dot1xTimeoutServerTimeout.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-dot1x:dot1x/timeout/server-timeout", state.getPath()))
+ }
+ if !state.Dot1xTimeoutRatelimitPeriod.IsNull() && data.Dot1xTimeoutRatelimitPeriod.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-dot1x:dot1x/timeout/ratelimit-period", state.getPath()))
+ }
+ if !state.Dot1xTimeoutQuietPeriod.IsNull() && data.Dot1xTimeoutQuietPeriod.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-dot1x:dot1x/timeout/quiet-period", state.getPath()))
+ }
+ if !state.Dot1xTimeoutHeldPeriod.IsNull() && data.Dot1xTimeoutHeldPeriod.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-dot1x:dot1x/timeout/held-period", state.getPath()))
+ }
+ if !state.Dot1xTimeoutAuthPeriod.IsNull() && data.Dot1xTimeoutAuthPeriod.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-dot1x:dot1x/timeout/auth-period", state.getPath()))
+ }
+ if !state.Dot1xPae.IsNull() && data.Dot1xPae.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-dot1x:dot1x/pae", state.getPath()))
+ }
+ if !state.MabEap.IsNull() && data.MabEap.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-sanet:mab/eap", state.getPath()))
+ }
+ if !state.Mab.IsNull() && data.Mab.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-sanet:mab", state.getPath()))
+ }
+ if !state.AuthenticationEventLinksecFailActionNextMethod.IsNull() && data.AuthenticationEventLinksecFailActionNextMethod.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-sanet:authentication/event/linksec/fail/action/next-method", state.getPath()))
+ }
+ if !state.AuthenticationEventNoResponseActionAuthorizeVlan.IsNull() && data.AuthenticationEventNoResponseActionAuthorizeVlan.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-sanet:authentication/event/no-response/action/authorize/vlan", state.getPath()))
+ }
+ if !state.AuthenticationEventFailActionNextMethod.IsNull() && data.AuthenticationEventFailActionNextMethod.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-sanet:authentication/event/fail-config/action/next-method", state.getPath()))
+ }
+ if !state.AuthenticationEventFailActionAuthorizeVlan.IsNull() && data.AuthenticationEventFailActionAuthorizeVlan.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-sanet:authentication/event/fail-config/action/authorize/vlan", state.getPath()))
+ }
+ if !state.AuthenticationEventServerDeadActionReinitializeVlan.IsNull() && data.AuthenticationEventServerDeadActionReinitializeVlan.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-sanet:authentication/event/server/dead/action/reinitialize/vlan", state.getPath()))
+ }
+ if !state.AuthenticationEventServerDeadActionAuthorizeVoice.IsNull() && data.AuthenticationEventServerDeadActionAuthorizeVoice.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-sanet:authentication/event/server/dead/action/authorize/voice", state.getPath()))
+ }
+ if !state.AuthenticationEventServerDeadActionAuthorizeVlan.IsNull() && data.AuthenticationEventServerDeadActionAuthorizeVlan.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-sanet:authentication/event/server/dead/action/authorize/vlan", state.getPath()))
+ }
+ if !state.AuthenticationEventServerDeadActionAuthorize.IsNull() && data.AuthenticationEventServerDeadActionAuthorize.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-sanet:authentication/event/server/dead/action/authorize", state.getPath()))
+ }
+ if !state.AuthenticationEventServerAliveActionReinitialize.IsNull() && data.AuthenticationEventServerAliveActionReinitialize.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-sanet:authentication/event/server/alive/action/reinitialize", state.getPath()))
+ }
+ if !state.AuthenticationTimerReauthenticateServer.IsNull() && data.AuthenticationTimerReauthenticateServer.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-sanet:authentication/timer/reauthenticate/server-config", state.getPath()))
+ }
+ if !state.AuthenticationTimerReauthenticate.IsNull() && data.AuthenticationTimerReauthenticate.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-sanet:authentication/timer/reauthenticate/value-config", state.getPath()))
+ }
+ if !state.AuthenticationPeriodic.IsNull() && data.AuthenticationPeriodic.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-sanet:authentication/periodic", state.getPath()))
+ }
+ if !state.AuthenticationPortControl.IsNull() && data.AuthenticationPortControl.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-sanet:authentication/port-control", state.getPath()))
+ }
+ if !state.AuthenticationPriorityWebauth.IsNull() && data.AuthenticationPriorityWebauth.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-sanet:authentication/priority-config/webauth-config", state.getPath()))
+ }
+ if !state.AuthenticationPriorityMabWebauth.IsNull() && data.AuthenticationPriorityMabWebauth.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-sanet:authentication/priority-config/mab-config/webauth", state.getPath()))
+ }
+ if !state.AuthenticationPriorityMabDot1x.IsNull() && data.AuthenticationPriorityMabDot1x.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-sanet:authentication/priority-config/mab-config/dot1x", state.getPath()))
+ }
+ if !state.AuthenticationPriorityMab.IsNull() && data.AuthenticationPriorityMab.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-sanet:authentication/priority-config/mab-config", state.getPath()))
+ }
+ if !state.AuthenticationPriorityDot1xWebauth.IsNull() && data.AuthenticationPriorityDot1xWebauth.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-sanet:authentication/priority-config/dot1x-config/webauth", state.getPath()))
+ }
+ if !state.AuthenticationPriorityDot1xMab.IsNull() && data.AuthenticationPriorityDot1xMab.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-sanet:authentication/priority-config/dot1x-config/mab", state.getPath()))
+ }
+ if !state.AuthenticationPriorityDot1x.IsNull() && data.AuthenticationPriorityDot1x.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-sanet:authentication/priority-config/dot1x-config", state.getPath()))
+ }
+ if !state.AuthenticationOrderWebauth.IsNull() && data.AuthenticationOrderWebauth.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-sanet:authentication/order-config/webauth-config", state.getPath()))
+ }
+ if !state.AuthenticationOrderMabWebauth.IsNull() && data.AuthenticationOrderMabWebauth.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-sanet:authentication/order-config/mab-config/webauth", state.getPath()))
+ }
+ if !state.AuthenticationOrderMabDot1x.IsNull() && data.AuthenticationOrderMabDot1x.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-sanet:authentication/order-config/mab-config/dot1x", state.getPath()))
+ }
+ if !state.AuthenticationOrderMab.IsNull() && data.AuthenticationOrderMab.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-sanet:authentication/order-config/mab-config", state.getPath()))
+ }
+ if !state.AuthenticationOrderDot1xWebauth.IsNull() && data.AuthenticationOrderDot1xWebauth.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-sanet:authentication/order-config/dot1x-config/webauth", state.getPath()))
+ }
+ if !state.AuthenticationOrderDot1xMab.IsNull() && data.AuthenticationOrderDot1xMab.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-sanet:authentication/order-config/dot1x-config/mab", state.getPath()))
+ }
+ if !state.AuthenticationOrderDot1x.IsNull() && data.AuthenticationOrderDot1x.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-sanet:authentication/order-config/dot1x-config", state.getPath()))
+ }
+ if !state.AuthenticationHostMode.IsNull() && data.AuthenticationHostMode.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-sanet:authentication/host-mode", state.getPath()))
+ }
+ if !state.SpeedNonegotiate.IsNull() && data.SpeedNonegotiate.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-ethernet:speed/nonegotiate", state.getPath()))
+ }
+ if !state.NegotiationAuto.IsNull() && data.NegotiationAuto.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-ethernet:negotiation/auto", state.getPath()))
+ }
+ if !state.Speed100000.IsNull() && data.Speed100000.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-ethernet:speed/value-100000", state.getPath()))
+ }
+ if !state.Speed40000.IsNull() && data.Speed40000.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-ethernet:speed/value-40000", state.getPath()))
+ }
+ if !state.Speed25000.IsNull() && data.Speed25000.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-ethernet:speed/value-25000", state.getPath()))
+ }
+ if !state.Speed10000.IsNull() && data.Speed10000.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-ethernet:speed/value-10000", state.getPath()))
+ }
+ if !state.Speed5000.IsNull() && data.Speed5000.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-ethernet:speed/value-5000", state.getPath()))
+ }
+ if !state.Speed2500.IsNull() && data.Speed2500.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-ethernet:speed/value-2500", state.getPath()))
+ }
+ if !state.Speed1000.IsNull() && data.Speed1000.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-ethernet:speed/value-1000", state.getPath()))
+ }
+ if !state.Speed100.IsNull() && data.Speed100.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-ethernet:speed/value-100", state.getPath()))
+ }
+ if !state.IpDhcpSnoopingTrust.IsNull() && data.IpDhcpSnoopingTrust.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/dhcp/Cisco-IOS-XE-dhcp:snooping/trust", state.getPath()))
+ }
+ if !state.IpArpInspectionLimitRate.IsNull() && data.IpArpInspectionLimitRate.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/arp/inspection/limit/rate", state.getPath()))
+ }
+ if !state.IpArpInspectionTrust.IsNull() && data.IpArpInspectionTrust.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/arp/inspection/trust", state.getPath()))
+ }
+ if !state.SpanningTreePortfastEdge.IsNull() && data.SpanningTreePortfastEdge.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-spanning-tree:spanning-tree/portfast/edge", state.getPath()))
+ }
+ if !state.SpanningTreePortfastTrunk.IsNull() && data.SpanningTreePortfastTrunk.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-spanning-tree:spanning-tree/portfast/trunk", state.getPath()))
+ }
+ if !state.SpanningTreePortfastDisable.IsNull() && data.SpanningTreePortfastDisable.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-spanning-tree:spanning-tree/portfast/disable", state.getPath()))
+ }
+ if !state.SpanningTreePortfast.IsNull() && data.SpanningTreePortfast.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-spanning-tree:spanning-tree/portfast", state.getPath()))
+ }
+ if !state.BpduguardDisable.IsNull() && data.BpduguardDisable.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-spanning-tree:spanning-tree/bpduguard/disable", state.getPath()))
+ }
+ if !state.BpduguardEnable.IsNull() && data.BpduguardEnable.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-spanning-tree:spanning-tree/bpduguard/enable", state.getPath()))
+ }
+ if !state.SpanningTreeLinkType.IsNull() && data.SpanningTreeLinkType.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-spanning-tree:spanning-tree/link-type", state.getPath()))
+ }
+ if !state.ArpTimeout.IsNull() && data.ArpTimeout.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/arp/timeout", state.getPath()))
+ }
+ for i := range state.Ipv6FlowMonitors {
+ stateKeyValues := [...]string{state.Ipv6FlowMonitors[i].Name.ValueString(), state.Ipv6FlowMonitors[i].Direction.ValueString()}
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.Ipv6FlowMonitors[i].Name.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if !reflect.ValueOf(state.Ipv6FlowMonitors[i].Direction.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.Ipv6FlowMonitors {
+ found = true
+ if state.Ipv6FlowMonitors[i].Name.ValueString() != data.Ipv6FlowMonitors[j].Name.ValueString() {
+ found = false
+ }
+ if state.Ipv6FlowMonitors[i].Direction.ValueString() != data.Ipv6FlowMonitors[j].Direction.ValueString() {
+ found = false
+ }
+ if found {
+ break
+ }
+ }
+ if !found {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ipv6/Cisco-IOS-XE-flow:flow/monitor-new=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ }
+ for i := range state.Ipv6Addresses {
+ stateKeyValues := [...]string{state.Ipv6Addresses[i].Prefix.ValueString()}
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.Ipv6Addresses[i].Prefix.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.Ipv6Addresses {
+ found = true
+ if state.Ipv6Addresses[i].Prefix.ValueString() != data.Ipv6Addresses[j].Prefix.ValueString() {
+ found = false
+ }
+ if found {
+ if !state.Ipv6Addresses[i].Eui64.IsNull() && data.Ipv6Addresses[j].Eui64.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ipv6/address/prefix-list=%v/eui-64", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ break
+ }
+ }
+ if !found {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ipv6/address/prefix-list=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ }
+ for i := range state.Ipv6LinkLocalAddresses {
+ stateKeyValues := [...]string{state.Ipv6LinkLocalAddresses[i].Address.ValueString()}
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.Ipv6LinkLocalAddresses[i].Address.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.Ipv6LinkLocalAddresses {
+ found = true
+ if state.Ipv6LinkLocalAddresses[i].Address.ValueString() != data.Ipv6LinkLocalAddresses[j].Address.ValueString() {
+ found = false
+ }
+ if found {
+ if !state.Ipv6LinkLocalAddresses[i].LinkLocal.IsNull() && data.Ipv6LinkLocalAddresses[j].LinkLocal.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ipv6/address/link-local-address=%v/link-local", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ break
+ }
+ }
+ if !found {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ipv6/address/link-local-address=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ }
+ if !state.Ipv6AddressDhcp.IsNull() && data.Ipv6AddressDhcp.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ipv6/address/dhcp", state.getPath()))
+ }
+ if !state.Ipv6AddressAutoconfigDefault.IsNull() && data.Ipv6AddressAutoconfigDefault.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ipv6/address/autoconfig/default", state.getPath()))
+ }
+ if !state.Ipv6NdRaSuppressAll.IsNull() && data.Ipv6NdRaSuppressAll.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ipv6/nd/Cisco-IOS-XE-nd:ra/suppress/all", state.getPath()))
+ }
+ if !state.Ipv6Mtu.IsNull() && data.Ipv6Mtu.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ipv6/mtu", state.getPath()))
+ }
+ if !state.Ipv6Enable.IsNull() && data.Ipv6Enable.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ipv6/enable", state.getPath()))
+ }
+ if !state.BfdEcho.IsNull() && data.BfdEcho.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/bfd/Cisco-IOS-XE-bfd:echo", state.getPath()))
+ }
+ if !state.BfdIntervalMultiplier.IsNull() && data.BfdIntervalMultiplier.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/bfd/Cisco-IOS-XE-bfd:interval-interface", state.getPath()))
+ }
+ if !state.BfdIntervalMinRx.IsNull() && data.BfdIntervalMinRx.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/bfd/Cisco-IOS-XE-bfd:interval-interface", state.getPath()))
+ }
+ if !state.BfdInterval.IsNull() && data.BfdInterval.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/bfd/Cisco-IOS-XE-bfd:interval-interface", state.getPath()))
+ }
+ if !state.BfdLocalAddress.IsNull() && data.BfdLocalAddress.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/bfd/Cisco-IOS-XE-bfd:local-address", state.getPath()))
+ }
+ if !state.BfdEnable.IsNull() && data.BfdEnable.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/bfd/Cisco-IOS-XE-bfd:enable", state.getPath()))
+ }
+ if !state.BfdTemplate.IsNull() && data.BfdTemplate.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/bfd/Cisco-IOS-XE-bfd:template", state.getPath()))
+ }
+ for i := range state.SourceTemplate {
+ stateKeyValues := [...]string{state.SourceTemplate[i].TemplateName.ValueString()}
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.SourceTemplate[i].TemplateName.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.SourceTemplate {
+ found = true
+ if state.SourceTemplate[i].TemplateName.ValueString() != data.SourceTemplate[j].TemplateName.ValueString() {
+ found = false
+ }
+ if found {
+ if !state.SourceTemplate[i].Merge.IsNull() && data.SourceTemplate[j].Merge.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/source/template/template-name=%v/merge", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ break
+ }
+ }
+ if !found {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/source/template/template-name=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ }
+ for i := range state.HelperAddresses {
+ stateKeyValues := [...]string{state.HelperAddresses[i].Address.ValueString()}
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.HelperAddresses[i].Address.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.HelperAddresses {
+ found = true
+ if state.HelperAddresses[i].Address.ValueString() != data.HelperAddresses[j].Address.ValueString() {
+ found = false
+ }
+ if found {
+ if !state.HelperAddresses[i].Vrf.IsNull() && data.HelperAddresses[j].Vrf.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/helper-address=%v/vrf", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ if !state.HelperAddresses[i].Global.IsNull() && data.HelperAddresses[j].Global.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/helper-address=%v/global", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ break
+ }
+ }
+ if !found {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/helper-address=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ }
+ if !state.TrustDevice.IsNull() && data.TrustDevice.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/trust/device", state.getPath()))
+ }
+ if !state.AutoQosVoipTrust.IsNull() && data.AutoQosVoipTrust.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-switch:auto/qos/voip/trust", state.getPath()))
+ }
+ if !state.AutoQosVoipCiscoSoftphone.IsNull() && data.AutoQosVoipCiscoSoftphone.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-switch:auto/qos/voip/cisco-softphone", state.getPath()))
+ }
+ if !state.AutoQosVoipCiscoPhone.IsNull() && data.AutoQosVoipCiscoPhone.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-switch:auto/qos/voip/cisco-phone", state.getPath()))
+ }
+ if !state.AutoQosVoip.IsNull() && data.AutoQosVoip.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-switch:auto/qos/voip", state.getPath()))
+ }
+ if !state.AutoQosVideoMediaPlayer.IsNull() && data.AutoQosVideoMediaPlayer.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-switch:auto/qos/video/media-player", state.getPath()))
+ }
+ if !state.AutoQosVideoIpCamera.IsNull() && data.AutoQosVideoIpCamera.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-switch:auto/qos/video/ip-camera", state.getPath()))
+ }
+ if !state.AutoQosVideoCts.IsNull() && data.AutoQosVideoCts.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-switch:auto/qos/video/cts", state.getPath()))
+ }
+ if !state.AutoQosTrustDscp.IsNull() && data.AutoQosTrustDscp.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-switch:auto/qos/trust/dscp", state.getPath()))
+ }
+ if !state.AutoQosTrustCos.IsNull() && data.AutoQosTrustCos.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-switch:auto/qos/trust/cos", state.getPath()))
+ }
+ if !state.AutoQosTrust.IsNull() && data.AutoQosTrust.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-switch:auto/qos/trust", state.getPath()))
+ }
+ if !state.AutoQosClassifyPolice.IsNull() && data.AutoQosClassifyPolice.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-switch:auto/qos/classify/police", state.getPath()))
+ }
+ if !state.AutoQosClassify.IsNull() && data.AutoQosClassify.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-switch:auto/qos/classify", state.getPath()))
+ }
+ if !state.SpanningTreeGuard.IsNull() && data.SpanningTreeGuard.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-spanning-tree:spanning-tree/guard", state.getPath()))
+ }
+ if !state.IpAccessGroupOut.IsNull() && data.IpAccessGroupOut.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/access-group/out/acl", state.getPath()))
+ }
+ if !state.IpAccessGroupOutEnable.IsNull() && data.IpAccessGroupOutEnable.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/access-group/out/acl/out", state.getPath()))
+ }
+ if !state.IpAccessGroupIn.IsNull() && data.IpAccessGroupIn.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/access-group/in/acl", state.getPath()))
+ }
+ if !state.IpAccessGroupInEnable.IsNull() && data.IpAccessGroupInEnable.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/access-group/in/acl/in", state.getPath()))
+ }
+ if !state.IpDhcpRelaySourceInterface.IsNull() && data.IpDhcpRelaySourceInterface.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/dhcp/Cisco-IOS-XE-dhcp:relay/source-interface", state.getPath()))
+ }
+ if !state.ChannelGroupMode.IsNull() && data.ChannelGroupMode.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-ethernet:channel-group", state.getPath()))
+ }
+ if !state.ChannelGroupNumber.IsNull() && data.ChannelGroupNumber.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-ethernet:channel-group", state.getPath()))
+ }
+ if !state.EncapsulationDot1qVlanId.IsNull() && data.EncapsulationDot1qVlanId.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/encapsulation/dot1Q/vlan-id", state.getPath()))
+ }
+ if !state.Unnumbered.IsNull() && data.Unnumbered.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/unnumbered", state.getPath()))
+ }
+ if !state.Ipv4AddressMask.IsNull() && data.Ipv4AddressMask.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/address/primary", state.getPath()))
+ }
+ if !state.Ipv4Address.IsNull() && data.Ipv4Address.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/address/primary", state.getPath()))
+ }
+ if !state.VrfForwarding.IsNull() && data.VrfForwarding.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/vrf/forwarding", state.getPath()))
+ }
+ if !state.IpUnreachables.IsNull() && data.IpUnreachables.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/Cisco-IOS-XE-icmp:unreachables", state.getPath()))
+ }
+ if !state.IpRedirects.IsNull() && data.IpRedirects.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/redirects", state.getPath()))
+ }
+ if !state.IpProxyArp.IsNull() && data.IpProxyArp.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/proxy-arp", state.getPath()))
+ }
+ if !state.Shutdown.IsNull() && data.Shutdown.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/shutdown", state.getPath()))
+ }
+ if !state.Description.IsNull() && data.Description.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/description", state.getPath()))
+ }
+ if !state.Switchport.IsNull() && data.Switchport.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/switchport-conf/switchport", state.getPath()))
+ }
+ if !state.Bandwidth.IsNull() && data.Bandwidth.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/bandwidth/kilobits", state.getPath()))
+ }
+ if !state.Mtu.IsNull() && data.Mtu.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/mtu", state.getPath()))
+ }
+ if !state.MediaType.IsNull() && data.MediaType.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/media-type", state.getPath()))
+ }
+
+ return deletedItems
+}
+
+// End of section. //template:end getDeletedItems
+
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletedItemsXML
+
+func (data *InterfaceEthernet) addDeletedItemsXML(ctx context.Context, state InterfaceEthernet, body string) string {
+ b := netconf.NewBody(body)
+ if !state.MediaType.IsNull() && data.MediaType.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/media-type")
+ }
+ if !state.Mtu.IsNull() && data.Mtu.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/mtu")
+ }
+ if !state.Bandwidth.IsNull() && data.Bandwidth.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/bandwidth/kilobits")
+ }
+ if !state.Switchport.IsNull() && data.Switchport.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/switchport-conf/switchport")
+ }
+ if !state.Description.IsNull() && data.Description.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/description")
+ }
+ if !state.Shutdown.IsNull() && data.Shutdown.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/shutdown")
+ }
+ if !state.IpProxyArp.IsNull() && data.IpProxyArp.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ip/proxy-arp")
+ }
+ if !state.IpRedirects.IsNull() && data.IpRedirects.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ip/redirects")
+ }
+ if !state.IpUnreachables.IsNull() && data.IpUnreachables.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ip/Cisco-IOS-XE-icmp:unreachables")
+ }
+ if !state.VrfForwarding.IsNull() && data.VrfForwarding.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/vrf/forwarding")
+ }
+ if !state.Ipv4Address.IsNull() && data.Ipv4Address.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ip/address/primary/address")
+ }
+ if !state.Ipv4AddressMask.IsNull() && data.Ipv4AddressMask.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ip/address/primary/mask")
+ }
+ if !state.Unnumbered.IsNull() && data.Unnumbered.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ip/unnumbered")
+ }
+ if !state.EncapsulationDot1qVlanId.IsNull() && data.EncapsulationDot1qVlanId.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/encapsulation/dot1Q/vlan-id")
+ }
+ if !state.ChannelGroupNumber.IsNull() && data.ChannelGroupNumber.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-ethernet:channel-group/number")
+ }
+ if !state.ChannelGroupMode.IsNull() && data.ChannelGroupMode.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-ethernet:channel-group/mode")
+ }
+ if !state.IpDhcpRelaySourceInterface.IsNull() && data.IpDhcpRelaySourceInterface.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ip/dhcp/Cisco-IOS-XE-dhcp:relay/source-interface")
+ }
+ if !state.IpAccessGroupInEnable.IsNull() && data.IpAccessGroupInEnable.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ip/access-group/in/acl/in")
+ }
+ if !state.IpAccessGroupIn.IsNull() && data.IpAccessGroupIn.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ip/access-group/in/acl/acl-name")
+ }
+ if !state.IpAccessGroupOutEnable.IsNull() && data.IpAccessGroupOutEnable.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ip/access-group/out/acl/out")
+ }
+ if !state.IpAccessGroupOut.IsNull() && data.IpAccessGroupOut.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ip/access-group/out/acl/acl-name")
+ }
+ if !state.SpanningTreeGuard.IsNull() && data.SpanningTreeGuard.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-spanning-tree:spanning-tree/guard")
+ }
+ if !state.AutoQosClassify.IsNull() && data.AutoQosClassify.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/classify")
+ }
+ if !state.AutoQosClassifyPolice.IsNull() && data.AutoQosClassifyPolice.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/classify/police")
+ }
+ if !state.AutoQosTrust.IsNull() && data.AutoQosTrust.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/trust")
+ }
+ if !state.AutoQosTrustCos.IsNull() && data.AutoQosTrustCos.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/trust/cos")
+ }
+ if !state.AutoQosTrustDscp.IsNull() && data.AutoQosTrustDscp.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/trust/dscp")
+ }
+ if !state.AutoQosVideoCts.IsNull() && data.AutoQosVideoCts.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/video/cts")
+ }
+ if !state.AutoQosVideoIpCamera.IsNull() && data.AutoQosVideoIpCamera.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/video/ip-camera")
+ }
+ if !state.AutoQosVideoMediaPlayer.IsNull() && data.AutoQosVideoMediaPlayer.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/video/media-player")
+ }
+ if !state.AutoQosVoip.IsNull() && data.AutoQosVoip.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/voip")
+ }
+ if !state.AutoQosVoipCiscoPhone.IsNull() && data.AutoQosVoipCiscoPhone.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/voip/cisco-phone")
+ }
+ if !state.AutoQosVoipCiscoSoftphone.IsNull() && data.AutoQosVoipCiscoSoftphone.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/voip/cisco-softphone")
+ }
+ if !state.AutoQosVoipTrust.IsNull() && data.AutoQosVoipTrust.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/voip/trust")
+ }
+ if !state.TrustDevice.IsNull() && data.TrustDevice.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/trust/device")
+ }
+ for i := range state.HelperAddresses {
+ stateKeys := [...]string{"address"}
+ stateKeyValues := [...]string{state.HelperAddresses[i].Address.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.HelperAddresses[i].Address.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.HelperAddresses {
+ found = true
+ if state.HelperAddresses[i].Address.ValueString() != data.HelperAddresses[j].Address.ValueString() {
+ found = false
+ }
+ if found {
+ if !state.HelperAddresses[i].Global.IsNull() && data.HelperAddresses[j].Global.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/ip/helper-address%v/global", predicates))
+ }
+ if !state.HelperAddresses[i].Vrf.IsNull() && data.HelperAddresses[j].Vrf.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/ip/helper-address%v/vrf", predicates))
+ }
+ break
+ }
+ }
+ if !found {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/ip/helper-address%v", predicates))
+ }
+ }
+ for i := range state.SourceTemplate {
+ stateKeys := [...]string{"template-name"}
+ stateKeyValues := [...]string{state.SourceTemplate[i].TemplateName.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.SourceTemplate[i].TemplateName.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.SourceTemplate {
+ found = true
+ if state.SourceTemplate[i].TemplateName.ValueString() != data.SourceTemplate[j].TemplateName.ValueString() {
+ found = false
+ }
+ if found {
+ if !state.SourceTemplate[i].Merge.IsNull() && data.SourceTemplate[j].Merge.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/source/template/template-name%v/merge", predicates))
+ }
+ break
+ }
+ }
+ if !found {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/source/template/template-name%v", predicates))
+ }
+ }
+ if !state.BfdTemplate.IsNull() && data.BfdTemplate.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/bfd/Cisco-IOS-XE-bfd:template")
+ }
+ if !state.BfdEnable.IsNull() && data.BfdEnable.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/bfd/Cisco-IOS-XE-bfd:enable")
+ }
+ if !state.BfdLocalAddress.IsNull() && data.BfdLocalAddress.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/bfd/Cisco-IOS-XE-bfd:local-address")
+ }
+ if !state.BfdInterval.IsNull() && data.BfdInterval.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/bfd/Cisco-IOS-XE-bfd:interval-interface/msecs")
+ }
+ if !state.BfdIntervalMinRx.IsNull() && data.BfdIntervalMinRx.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/bfd/Cisco-IOS-XE-bfd:interval-interface/min_rx")
+ }
+ if !state.BfdIntervalMultiplier.IsNull() && data.BfdIntervalMultiplier.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/bfd/Cisco-IOS-XE-bfd:interval-interface/multiplier")
+ }
+ if !state.BfdEcho.IsNull() && data.BfdEcho.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/bfd/Cisco-IOS-XE-bfd:echo")
+ }
+ if !state.Ipv6Enable.IsNull() && data.Ipv6Enable.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ipv6/enable")
+ }
+ if !state.Ipv6Mtu.IsNull() && data.Ipv6Mtu.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ipv6/mtu")
+ }
+ if !state.Ipv6NdRaSuppressAll.IsNull() && data.Ipv6NdRaSuppressAll.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ipv6/nd/Cisco-IOS-XE-nd:ra/suppress/all")
+ }
+ if !state.Ipv6AddressAutoconfigDefault.IsNull() && data.Ipv6AddressAutoconfigDefault.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ipv6/address/autoconfig/default")
+ }
+ if !state.Ipv6AddressDhcp.IsNull() && data.Ipv6AddressDhcp.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ipv6/address/dhcp")
+ }
+ for i := range state.Ipv6LinkLocalAddresses {
+ stateKeys := [...]string{"address"}
+ stateKeyValues := [...]string{state.Ipv6LinkLocalAddresses[i].Address.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.Ipv6LinkLocalAddresses[i].Address.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.Ipv6LinkLocalAddresses {
+ found = true
+ if state.Ipv6LinkLocalAddresses[i].Address.ValueString() != data.Ipv6LinkLocalAddresses[j].Address.ValueString() {
+ found = false
+ }
+ if found {
+ if !state.Ipv6LinkLocalAddresses[i].LinkLocal.IsNull() && data.Ipv6LinkLocalAddresses[j].LinkLocal.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/ipv6/address/link-local-address%v/link-local", predicates))
+ }
+ break
+ }
+ }
+ if !found {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/ipv6/address/link-local-address%v", predicates))
+ }
+ }
+ for i := range state.Ipv6Addresses {
+ stateKeys := [...]string{"prefix"}
+ stateKeyValues := [...]string{state.Ipv6Addresses[i].Prefix.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.Ipv6Addresses[i].Prefix.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.Ipv6Addresses {
+ found = true
+ if state.Ipv6Addresses[i].Prefix.ValueString() != data.Ipv6Addresses[j].Prefix.ValueString() {
+ found = false
+ }
+ if found {
+ if !state.Ipv6Addresses[i].Eui64.IsNull() && data.Ipv6Addresses[j].Eui64.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/ipv6/address/prefix-list%v/eui-64", predicates))
+ }
+ break
+ }
+ }
+ if !found {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/ipv6/address/prefix-list%v", predicates))
+ }
+ }
+ for i := range state.Ipv6FlowMonitors {
+ stateKeys := [...]string{"name", "direction"}
+ stateKeyValues := [...]string{state.Ipv6FlowMonitors[i].Name.ValueString(), state.Ipv6FlowMonitors[i].Direction.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.Ipv6FlowMonitors[i].Name.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if !reflect.ValueOf(state.Ipv6FlowMonitors[i].Direction.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.Ipv6FlowMonitors {
+ found = true
+ if state.Ipv6FlowMonitors[i].Name.ValueString() != data.Ipv6FlowMonitors[j].Name.ValueString() {
+ found = false
+ }
+ if state.Ipv6FlowMonitors[i].Direction.ValueString() != data.Ipv6FlowMonitors[j].Direction.ValueString() {
+ found = false
+ }
+ if found {
+ break
+ }
+ }
+ if !found {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/ipv6/Cisco-IOS-XE-flow:flow/monitor-new%v", predicates))
+ }
}
- if value := res.Get(prefix + "Cisco-IOS-XE-sanet:authentication.host-mode"); value.Exists() {
- data.AuthenticationHostMode = types.StringValue(value.String())
+ if !state.ArpTimeout.IsNull() && data.ArpTimeout.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/arp/timeout")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-sanet:authentication.order-config.dot1x-config"); value.Exists() {
- data.AuthenticationOrderDot1x = types.BoolValue(true)
- } else {
- data.AuthenticationOrderDot1x = types.BoolValue(false)
+ if !state.SpanningTreeLinkType.IsNull() && data.SpanningTreeLinkType.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-spanning-tree:spanning-tree/link-type")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-sanet:authentication.order-config.dot1x-config.mab"); value.Exists() {
- data.AuthenticationOrderDot1xMab = types.BoolValue(true)
- } else {
- data.AuthenticationOrderDot1xMab = types.BoolValue(false)
+ if !state.BpduguardEnable.IsNull() && data.BpduguardEnable.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-spanning-tree:spanning-tree/bpduguard/enable")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-sanet:authentication.order-config.dot1x-config.webauth"); value.Exists() {
- data.AuthenticationOrderDot1xWebauth = types.BoolValue(true)
- } else {
- data.AuthenticationOrderDot1xWebauth = types.BoolValue(false)
+ if !state.BpduguardDisable.IsNull() && data.BpduguardDisable.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-spanning-tree:spanning-tree/bpduguard/disable")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-sanet:authentication.order-config.mab-config"); value.Exists() {
- data.AuthenticationOrderMab = types.BoolValue(true)
- } else {
- data.AuthenticationOrderMab = types.BoolValue(false)
+ if !state.SpanningTreePortfast.IsNull() && data.SpanningTreePortfast.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-spanning-tree:spanning-tree/portfast")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-sanet:authentication.order-config.mab-config.dot1x"); value.Exists() {
- data.AuthenticationOrderMabDot1x = types.BoolValue(true)
- } else {
- data.AuthenticationOrderMabDot1x = types.BoolValue(false)
+ if !state.SpanningTreePortfastDisable.IsNull() && data.SpanningTreePortfastDisable.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-spanning-tree:spanning-tree/portfast/disable")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-sanet:authentication.order-config.mab-config.webauth"); value.Exists() {
- data.AuthenticationOrderMabWebauth = types.BoolValue(true)
- } else {
- data.AuthenticationOrderMabWebauth = types.BoolValue(false)
+ if !state.SpanningTreePortfastTrunk.IsNull() && data.SpanningTreePortfastTrunk.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-spanning-tree:spanning-tree/portfast/trunk")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-sanet:authentication.order-config.webauth-config"); value.Exists() {
- data.AuthenticationOrderWebauth = types.BoolValue(true)
- } else {
- data.AuthenticationOrderWebauth = types.BoolValue(false)
+ if !state.SpanningTreePortfastEdge.IsNull() && data.SpanningTreePortfastEdge.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-spanning-tree:spanning-tree/portfast/edge")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-sanet:authentication.priority-config.dot1x-config"); value.Exists() {
- data.AuthenticationPriorityDot1x = types.BoolValue(true)
- } else {
- data.AuthenticationPriorityDot1x = types.BoolValue(false)
+ if !state.IpArpInspectionTrust.IsNull() && data.IpArpInspectionTrust.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ip/arp/inspection/trust")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-sanet:authentication.priority-config.dot1x-config.mab"); value.Exists() {
- data.AuthenticationPriorityDot1xMab = types.BoolValue(true)
- } else {
- data.AuthenticationPriorityDot1xMab = types.BoolValue(false)
+ if !state.IpArpInspectionLimitRate.IsNull() && data.IpArpInspectionLimitRate.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ip/arp/inspection/limit/rate")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-sanet:authentication.priority-config.dot1x-config.webauth"); value.Exists() {
- data.AuthenticationPriorityDot1xWebauth = types.BoolValue(true)
- } else {
- data.AuthenticationPriorityDot1xWebauth = types.BoolValue(false)
+ if !state.IpDhcpSnoopingTrust.IsNull() && data.IpDhcpSnoopingTrust.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ip/dhcp/Cisco-IOS-XE-dhcp:snooping/trust")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-sanet:authentication.priority-config.mab-config"); value.Exists() {
- data.AuthenticationPriorityMab = types.BoolValue(true)
- } else {
- data.AuthenticationPriorityMab = types.BoolValue(false)
+ if !state.Speed100.IsNull() && data.Speed100.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-ethernet:speed/value-100")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-sanet:authentication.priority-config.mab-config.dot1x"); value.Exists() {
- data.AuthenticationPriorityMabDot1x = types.BoolValue(true)
- } else {
- data.AuthenticationPriorityMabDot1x = types.BoolValue(false)
+ if !state.Speed1000.IsNull() && data.Speed1000.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-ethernet:speed/value-1000")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-sanet:authentication.priority-config.mab-config.webauth"); value.Exists() {
- data.AuthenticationPriorityMabWebauth = types.BoolValue(true)
- } else {
- data.AuthenticationPriorityMabWebauth = types.BoolValue(false)
+ if !state.Speed2500.IsNull() && data.Speed2500.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-ethernet:speed/value-2500")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-sanet:authentication.priority-config.webauth-config"); value.Exists() {
- data.AuthenticationPriorityWebauth = types.BoolValue(true)
- } else {
- data.AuthenticationPriorityWebauth = types.BoolValue(false)
+ if !state.Speed5000.IsNull() && data.Speed5000.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-ethernet:speed/value-5000")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-sanet:authentication.port-control"); value.Exists() {
- data.AuthenticationPortControl = types.StringValue(value.String())
+ if !state.Speed10000.IsNull() && data.Speed10000.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-ethernet:speed/value-10000")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-sanet:authentication.periodic"); value.Exists() {
- data.AuthenticationPeriodic = types.BoolValue(true)
- } else {
- data.AuthenticationPeriodic = types.BoolValue(false)
+ if !state.Speed25000.IsNull() && data.Speed25000.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-ethernet:speed/value-25000")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-sanet:authentication.timer.reauthenticate.value-config"); value.Exists() {
- data.AuthenticationTimerReauthenticate = types.Int64Value(value.Int())
+ if !state.Speed40000.IsNull() && data.Speed40000.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-ethernet:speed/value-40000")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-sanet:authentication.timer.reauthenticate.server-config"); value.Exists() {
- data.AuthenticationTimerReauthenticateServer = types.BoolValue(true)
- } else {
- data.AuthenticationTimerReauthenticateServer = types.BoolValue(false)
+ if !state.Speed100000.IsNull() && data.Speed100000.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-ethernet:speed/value-100000")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-sanet:authentication.event.server.alive.action.reinitialize"); value.Exists() {
- data.AuthenticationEventServerAliveActionReinitialize = types.BoolValue(true)
- } else {
- data.AuthenticationEventServerAliveActionReinitialize = types.BoolValue(false)
+ if !state.NegotiationAuto.IsNull() && data.NegotiationAuto.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-ethernet:negotiation/auto")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-sanet:authentication.event.server.dead.action.authorize"); value.Exists() {
- data.AuthenticationEventServerDeadActionAuthorize = types.BoolValue(true)
- } else {
- data.AuthenticationEventServerDeadActionAuthorize = types.BoolValue(false)
+ if !state.SpeedNonegotiate.IsNull() && data.SpeedNonegotiate.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-ethernet:speed/nonegotiate")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-sanet:authentication.event.server.dead.action.authorize.vlan"); value.Exists() {
- data.AuthenticationEventServerDeadActionAuthorizeVlan = types.Int64Value(value.Int())
+ if !state.AuthenticationHostMode.IsNull() && data.AuthenticationHostMode.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-sanet:authentication/host-mode")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-sanet:authentication.event.server.dead.action.authorize.voice"); value.Exists() {
- data.AuthenticationEventServerDeadActionAuthorizeVoice = types.BoolValue(true)
- } else {
- data.AuthenticationEventServerDeadActionAuthorizeVoice = types.BoolValue(false)
+ if !state.AuthenticationOrderDot1x.IsNull() && data.AuthenticationOrderDot1x.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-sanet:authentication/order-config/dot1x-config")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-sanet:authentication.event.server.dead.action.reinitialize.vlan"); value.Exists() {
- data.AuthenticationEventServerDeadActionReinitializeVlan = types.Int64Value(value.Int())
+ if !state.AuthenticationOrderDot1xMab.IsNull() && data.AuthenticationOrderDot1xMab.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-sanet:authentication/order-config/dot1x-config/mab")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-sanet:authentication.event.fail-config.action.authorize.vlan"); value.Exists() {
- data.AuthenticationEventFailActionAuthorizeVlan = types.Int64Value(value.Int())
+ if !state.AuthenticationOrderDot1xWebauth.IsNull() && data.AuthenticationOrderDot1xWebauth.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-sanet:authentication/order-config/dot1x-config/webauth")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-sanet:authentication.event.fail-config.action.next-method"); value.Exists() {
- data.AuthenticationEventFailActionNextMethod = types.BoolValue(true)
- } else {
- data.AuthenticationEventFailActionNextMethod = types.BoolValue(false)
+ if !state.AuthenticationOrderMab.IsNull() && data.AuthenticationOrderMab.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-sanet:authentication/order-config/mab-config")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-sanet:authentication.event.no-response.action.authorize.vlan"); value.Exists() {
- data.AuthenticationEventNoResponseActionAuthorizeVlan = types.Int64Value(value.Int())
+ if !state.AuthenticationOrderMabDot1x.IsNull() && data.AuthenticationOrderMabDot1x.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-sanet:authentication/order-config/mab-config/dot1x")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-sanet:authentication.event.linksec.fail.action.next-method"); value.Exists() {
- data.AuthenticationEventLinksecFailActionNextMethod = types.BoolValue(true)
- } else {
- data.AuthenticationEventLinksecFailActionNextMethod = types.BoolValue(false)
+ if !state.AuthenticationOrderMabWebauth.IsNull() && data.AuthenticationOrderMabWebauth.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-sanet:authentication/order-config/mab-config/webauth")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-sanet:mab"); value.Exists() {
- data.Mab = types.BoolValue(true)
- } else {
- data.Mab = types.BoolValue(false)
+ if !state.AuthenticationOrderWebauth.IsNull() && data.AuthenticationOrderWebauth.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-sanet:authentication/order-config/webauth-config")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-sanet:mab.eap"); value.Exists() {
- data.MabEap = types.BoolValue(true)
- } else {
- data.MabEap = types.BoolValue(false)
+ if !state.AuthenticationPriorityDot1x.IsNull() && data.AuthenticationPriorityDot1x.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-sanet:authentication/priority-config/dot1x-config")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-dot1x:dot1x.pae"); value.Exists() {
- data.Dot1xPae = types.StringValue(value.String())
+ if !state.AuthenticationPriorityDot1xMab.IsNull() && data.AuthenticationPriorityDot1xMab.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-sanet:authentication/priority-config/dot1x-config/mab")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-dot1x:dot1x.timeout.auth-period"); value.Exists() {
- data.Dot1xTimeoutAuthPeriod = types.Int64Value(value.Int())
+ if !state.AuthenticationPriorityDot1xWebauth.IsNull() && data.AuthenticationPriorityDot1xWebauth.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-sanet:authentication/priority-config/dot1x-config/webauth")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-dot1x:dot1x.timeout.held-period"); value.Exists() {
- data.Dot1xTimeoutHeldPeriod = types.Int64Value(value.Int())
+ if !state.AuthenticationPriorityMab.IsNull() && data.AuthenticationPriorityMab.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-sanet:authentication/priority-config/mab-config")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-dot1x:dot1x.timeout.quiet-period"); value.Exists() {
- data.Dot1xTimeoutQuietPeriod = types.Int64Value(value.Int())
+ if !state.AuthenticationPriorityMabDot1x.IsNull() && data.AuthenticationPriorityMabDot1x.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-sanet:authentication/priority-config/mab-config/dot1x")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-dot1x:dot1x.timeout.ratelimit-period"); value.Exists() {
- data.Dot1xTimeoutRatelimitPeriod = types.Int64Value(value.Int())
+ if !state.AuthenticationPriorityMabWebauth.IsNull() && data.AuthenticationPriorityMabWebauth.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-sanet:authentication/priority-config/mab-config/webauth")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-dot1x:dot1x.timeout.server-timeout"); value.Exists() {
- data.Dot1xTimeoutServerTimeout = types.Int64Value(value.Int())
+ if !state.AuthenticationPriorityWebauth.IsNull() && data.AuthenticationPriorityWebauth.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-sanet:authentication/priority-config/webauth-config")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-dot1x:dot1x.timeout.start-period"); value.Exists() {
- data.Dot1xTimeoutStartPeriod = types.Int64Value(value.Int())
+ if !state.AuthenticationPortControl.IsNull() && data.AuthenticationPortControl.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-sanet:authentication/port-control")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-dot1x:dot1x.timeout.supp-timeout"); value.Exists() {
- data.Dot1xTimeoutSuppTimeout = types.Int64Value(value.Int())
+ if !state.AuthenticationPeriodic.IsNull() && data.AuthenticationPeriodic.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-sanet:authentication/periodic")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-dot1x:dot1x.timeout.tx-period"); value.Exists() {
- data.Dot1xTimeoutTxPeriod = types.Int64Value(value.Int())
+ if !state.AuthenticationTimerReauthenticate.IsNull() && data.AuthenticationTimerReauthenticate.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-sanet:authentication/timer/reauthenticate/value-config")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-dot1x:dot1x.max-req"); value.Exists() {
- data.Dot1xMaxReq = types.Int64Value(value.Int())
+ if !state.AuthenticationTimerReauthenticateServer.IsNull() && data.AuthenticationTimerReauthenticateServer.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-sanet:authentication/timer/reauthenticate/server-config")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-dot1x:dot1x.max-reauth-req"); value.Exists() {
- data.Dot1xMaxReauthReq = types.Int64Value(value.Int())
+ if !state.AuthenticationEventServerAliveActionReinitialize.IsNull() && data.AuthenticationEventServerAliveActionReinitialize.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-sanet:authentication/event/server/alive/action/reinitialize")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-policy:service-policy.input"); value.Exists() {
- data.ServicePolicyInput = types.StringValue(value.String())
+ if !state.AuthenticationEventServerDeadActionAuthorize.IsNull() && data.AuthenticationEventServerDeadActionAuthorize.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-sanet:authentication/event/server/dead/action/authorize")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-policy:service-policy.output"); value.Exists() {
- data.ServicePolicyOutput = types.StringValue(value.String())
+ if !state.AuthenticationEventServerDeadActionAuthorizeVlan.IsNull() && data.AuthenticationEventServerDeadActionAuthorizeVlan.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-sanet:authentication/event/server/dead/action/authorize/vlan")
}
- if value := res.Get(prefix + "ip.Cisco-IOS-XE-flow:flow.monitor-new"); value.Exists() {
- data.IpFlowMonitors = make([]InterfaceEthernetIpFlowMonitors, 0)
- value.ForEach(func(k, v gjson.Result) bool {
- item := InterfaceEthernetIpFlowMonitors{}
- if cValue := v.Get("name"); cValue.Exists() {
- item.Name = types.StringValue(cValue.String())
- }
- if cValue := v.Get("direction"); cValue.Exists() {
- item.Direction = types.StringValue(cValue.String())
- }
- data.IpFlowMonitors = append(data.IpFlowMonitors, item)
- return true
- })
+ if !state.AuthenticationEventServerDeadActionAuthorizeVoice.IsNull() && data.AuthenticationEventServerDeadActionAuthorizeVoice.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-sanet:authentication/event/server/dead/action/authorize/voice")
}
- if value := res.Get(prefix + "load-interval"); value.Exists() {
- data.LoadInterval = types.Int64Value(value.Int())
+ if !state.AuthenticationEventServerDeadActionReinitializeVlan.IsNull() && data.AuthenticationEventServerDeadActionReinitializeVlan.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-sanet:authentication/event/server/dead/action/reinitialize/vlan")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:snmp.trap.link-status"); value.Exists() {
- data.SnmpTrapLinkStatus = types.BoolValue(value.Bool())
- } else {
- data.SnmpTrapLinkStatus = types.BoolNull()
+ if !state.AuthenticationEventFailActionAuthorizeVlan.IsNull() && data.AuthenticationEventFailActionAuthorizeVlan.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-sanet:authentication/event/fail-config/action/authorize/vlan")
}
- if value := res.Get(prefix + "logging.event.link-status-enable"); value.Exists() {
- data.LoggingEventLinkStatusEnable = types.BoolValue(value.Bool())
- } else {
- data.LoggingEventLinkStatusEnable = types.BoolNull()
+ if !state.AuthenticationEventFailActionNextMethod.IsNull() && data.AuthenticationEventFailActionNextMethod.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-sanet:authentication/event/fail-config/action/next-method")
}
- if value := res.Get(prefix + "ip.Cisco-IOS-XE-nbar:nbar.protocol-discovery"); value.Exists() {
- data.IpNbarProtocolDiscovery = types.BoolValue(true)
- } else {
- data.IpNbarProtocolDiscovery = types.BoolValue(false)
+ if !state.AuthenticationEventNoResponseActionAuthorizeVlan.IsNull() && data.AuthenticationEventNoResponseActionAuthorizeVlan.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-sanet:authentication/event/no-response/action/authorize/vlan")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-switch:device-tracking"); value.Exists() {
- data.DeviceTracking = types.BoolValue(true)
- } else {
- data.DeviceTracking = types.BoolValue(false)
+ if !state.AuthenticationEventLinksecFailActionNextMethod.IsNull() && data.AuthenticationEventLinksecFailActionNextMethod.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-sanet:authentication/event/linksec/fail/action/next-method")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-switch:device-tracking.attached-policies"); value.Exists() {
- data.DeviceTrackingAttachedPolicies = make([]InterfaceEthernetDeviceTrackingAttachedPolicies, 0)
- value.ForEach(func(k, v gjson.Result) bool {
- item := InterfaceEthernetDeviceTrackingAttachedPolicies{}
- if cValue := v.Get("attach-policy"); cValue.Exists() {
- item.Name = types.StringValue(cValue.String())
- }
- data.DeviceTrackingAttachedPolicies = append(data.DeviceTrackingAttachedPolicies, item)
- return true
- })
+ if !state.Mab.IsNull() && data.Mab.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-sanet:mab")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-cdp:cdp.enable"); value.Exists() {
- data.CdpEnable = types.BoolValue(value.Bool())
- } else {
- data.CdpEnable = types.BoolNull()
+ if !state.MabEap.IsNull() && data.MabEap.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-sanet:mab/eap")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-cdp:cdp.tlv.default-wrp.app"); value.Exists() {
- data.CdpTlvApp = types.BoolValue(value.Bool())
- } else {
- data.CdpTlvApp = types.BoolNull()
+ if !state.Dot1xPae.IsNull() && data.Dot1xPae.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-dot1x:dot1x/pae")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-cdp:cdp.tlv.location-config"); value.Exists() {
- data.CdpTlvLocation = types.BoolValue(value.Bool())
- } else {
- data.CdpTlvLocation = types.BoolNull()
+ if !state.Dot1xTimeoutAuthPeriod.IsNull() && data.Dot1xTimeoutAuthPeriod.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-dot1x:dot1x/timeout/auth-period")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-cdp:cdp.tlv.server-location-config"); value.Exists() {
- data.CdpTlvServerLocation = types.BoolValue(value.Bool())
- } else {
- data.CdpTlvServerLocation = types.BoolNull()
+ if !state.Dot1xTimeoutHeldPeriod.IsNull() && data.Dot1xTimeoutHeldPeriod.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-dot1x:dot1x/timeout/held-period")
}
- if value := res.Get(prefix + "ip.Cisco-IOS-XE-nat:nat.inside"); value.Exists() {
- data.IpNatInside = types.BoolValue(true)
- } else {
- data.IpNatInside = types.BoolValue(false)
+ if !state.Dot1xTimeoutQuietPeriod.IsNull() && data.Dot1xTimeoutQuietPeriod.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-dot1x:dot1x/timeout/quiet-period")
}
- if value := res.Get(prefix + "ip.Cisco-IOS-XE-nat:nat.outside"); value.Exists() {
- data.IpNatOutside = types.BoolValue(true)
- } else {
- data.IpNatOutside = types.BoolValue(false)
+ if !state.Dot1xTimeoutRatelimitPeriod.IsNull() && data.Dot1xTimeoutRatelimitPeriod.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-dot1x:dot1x/timeout/ratelimit-period")
}
-}
-
-// End of section. //template:end fromBodyData
-
-// Section below is generated&owned by "gen/generator.go". //template:begin getDeletedItems
-
-func (data *InterfaceEthernet) getDeletedItems(ctx context.Context, state InterfaceEthernet) []string {
- deletedItems := make([]string, 0)
- if !state.IpNatOutside.IsNull() && data.IpNatOutside.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/Cisco-IOS-XE-nat:nat/outside", state.getPath()))
+ if !state.Dot1xTimeoutServerTimeout.IsNull() && data.Dot1xTimeoutServerTimeout.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-dot1x:dot1x/timeout/server-timeout")
}
- if !state.IpNatInside.IsNull() && data.IpNatInside.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/Cisco-IOS-XE-nat:nat/inside", state.getPath()))
+ if !state.Dot1xTimeoutStartPeriod.IsNull() && data.Dot1xTimeoutStartPeriod.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-dot1x:dot1x/timeout/start-period")
}
- if !state.CdpTlvServerLocation.IsNull() && data.CdpTlvServerLocation.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-cdp:cdp/tlv/server-location-config", state.getPath()))
+ if !state.Dot1xTimeoutSuppTimeout.IsNull() && data.Dot1xTimeoutSuppTimeout.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-dot1x:dot1x/timeout/supp-timeout")
}
- if !state.CdpTlvLocation.IsNull() && data.CdpTlvLocation.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-cdp:cdp/tlv/location-config", state.getPath()))
+ if !state.Dot1xTimeoutTxPeriod.IsNull() && data.Dot1xTimeoutTxPeriod.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-dot1x:dot1x/timeout/tx-period")
}
- if !state.CdpTlvApp.IsNull() && data.CdpTlvApp.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-cdp:cdp/tlv/default-wrp/app", state.getPath()))
+ if !state.Dot1xMaxReq.IsNull() && data.Dot1xMaxReq.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-dot1x:dot1x/max-req")
}
- if !state.CdpEnable.IsNull() && data.CdpEnable.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-cdp:cdp/enable", state.getPath()))
+ if !state.Dot1xMaxReauthReq.IsNull() && data.Dot1xMaxReauthReq.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-dot1x:dot1x/max-reauth-req")
}
- for i := range state.DeviceTrackingAttachedPolicies {
- stateKeyValues := [...]string{state.DeviceTrackingAttachedPolicies[i].Name.ValueString()}
+ if !state.ServicePolicyInput.IsNull() && data.ServicePolicyInput.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-policy:service-policy/input")
+ }
+ if !state.ServicePolicyOutput.IsNull() && data.ServicePolicyOutput.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-policy:service-policy/output")
+ }
+ for i := range state.IpFlowMonitors {
+ stateKeys := [...]string{"name", "direction"}
+ stateKeyValues := [...]string{state.IpFlowMonitors[i].Name.ValueString(), state.IpFlowMonitors[i].Direction.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
emptyKeys := true
- if !reflect.ValueOf(state.DeviceTrackingAttachedPolicies[i].Name.ValueString()).IsZero() {
+ if !reflect.ValueOf(state.IpFlowMonitors[i].Name.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if !reflect.ValueOf(state.IpFlowMonitors[i].Direction.ValueString()).IsZero() {
emptyKeys = false
}
if emptyKeys {
@@ -3414,9 +7652,12 @@ func (data *InterfaceEthernet) getDeletedItems(ctx context.Context, state Interf
}
found := false
- for j := range data.DeviceTrackingAttachedPolicies {
+ for j := range data.IpFlowMonitors {
found = true
- if state.DeviceTrackingAttachedPolicies[i].Name.ValueString() != data.DeviceTrackingAttachedPolicies[j].Name.ValueString() {
+ if state.IpFlowMonitors[i].Name.ValueString() != data.IpFlowMonitors[j].Name.ValueString() {
+ found = false
+ }
+ if state.IpFlowMonitors[i].Direction.ValueString() != data.IpFlowMonitors[j].Direction.ValueString() {
found = false
}
if found {
@@ -3424,32 +7665,34 @@ func (data *InterfaceEthernet) getDeletedItems(ctx context.Context, state Interf
}
}
if !found {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-switch:device-tracking/attached-policies=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/ip/Cisco-IOS-XE-flow:flow/monitor-new%v", predicates))
}
}
- if !state.DeviceTracking.IsNull() && data.DeviceTracking.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-switch:device-tracking", state.getPath()))
+ if !state.LoadInterval.IsNull() && data.LoadInterval.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/load-interval")
}
- if !state.IpNbarProtocolDiscovery.IsNull() && data.IpNbarProtocolDiscovery.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/Cisco-IOS-XE-nbar:nbar/protocol-discovery", state.getPath()))
+ if !state.SnmpTrapLinkStatus.IsNull() && data.SnmpTrapLinkStatus.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:snmp/trap/link-status")
}
if !state.LoggingEventLinkStatusEnable.IsNull() && data.LoggingEventLinkStatusEnable.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/logging/event/link-status-enable", state.getPath()))
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/logging/event/link-status-enable")
}
- if !state.SnmpTrapLinkStatus.IsNull() && data.SnmpTrapLinkStatus.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:snmp/trap/link-status", state.getPath()))
+ if !state.IpNbarProtocolDiscovery.IsNull() && data.IpNbarProtocolDiscovery.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ip/Cisco-IOS-XE-nbar:nbar/protocol-discovery")
}
- if !state.LoadInterval.IsNull() && data.LoadInterval.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/load-interval", state.getPath()))
+ if !state.DeviceTracking.IsNull() && data.DeviceTracking.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-switch:device-tracking")
}
- for i := range state.IpFlowMonitors {
- stateKeyValues := [...]string{state.IpFlowMonitors[i].Name.ValueString(), state.IpFlowMonitors[i].Direction.ValueString()}
+ for i := range state.DeviceTrackingAttachedPolicies {
+ stateKeys := [...]string{"attach-policy"}
+ stateKeyValues := [...]string{state.DeviceTrackingAttachedPolicies[i].Name.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
emptyKeys := true
- if !reflect.ValueOf(state.IpFlowMonitors[i].Name.ValueString()).IsZero() {
- emptyKeys = false
- }
- if !reflect.ValueOf(state.IpFlowMonitors[i].Direction.ValueString()).IsZero() {
+ if !reflect.ValueOf(state.DeviceTrackingAttachedPolicies[i].Name.ValueString()).IsZero() {
emptyKeys = false
}
if emptyKeys {
@@ -3457,12 +7700,9 @@ func (data *InterfaceEthernet) getDeletedItems(ctx context.Context, state Interf
}
found := false
- for j := range data.IpFlowMonitors {
+ for j := range data.DeviceTrackingAttachedPolicies {
found = true
- if state.IpFlowMonitors[i].Name.ValueString() != data.IpFlowMonitors[j].Name.ValueString() {
- found = false
- }
- if state.IpFlowMonitors[i].Direction.ValueString() != data.IpFlowMonitors[j].Direction.ValueString() {
+ if state.DeviceTrackingAttachedPolicies[i].Name.ValueString() != data.DeviceTrackingAttachedPolicies[j].Name.ValueString() {
found = false
}
if found {
@@ -3470,1130 +7710,1115 @@ func (data *InterfaceEthernet) getDeletedItems(ctx context.Context, state Interf
}
}
if !found {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/Cisco-IOS-XE-flow:flow/monitor-new=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-switch:device-tracking/attached-policies%v", predicates))
}
}
- if !state.ServicePolicyOutput.IsNull() && data.ServicePolicyOutput.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-policy:service-policy/output", state.getPath()))
+ if !state.CdpEnable.IsNull() && data.CdpEnable.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-cdp:cdp/enable")
}
- if !state.ServicePolicyInput.IsNull() && data.ServicePolicyInput.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-policy:service-policy/input", state.getPath()))
+ if !state.CdpTlvApp.IsNull() && data.CdpTlvApp.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-cdp:cdp/tlv/default-wrp/app")
}
- if !state.Dot1xMaxReauthReq.IsNull() && data.Dot1xMaxReauthReq.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-dot1x:dot1x/max-reauth-req", state.getPath()))
+ if !state.CdpTlvLocation.IsNull() && data.CdpTlvLocation.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-cdp:cdp/tlv/location-config")
}
- if !state.Dot1xMaxReq.IsNull() && data.Dot1xMaxReq.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-dot1x:dot1x/max-req", state.getPath()))
+ if !state.CdpTlvServerLocation.IsNull() && data.CdpTlvServerLocation.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-cdp:cdp/tlv/server-location-config")
}
- if !state.Dot1xTimeoutTxPeriod.IsNull() && data.Dot1xTimeoutTxPeriod.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-dot1x:dot1x/timeout/tx-period", state.getPath()))
+ if !state.IpNatInside.IsNull() && data.IpNatInside.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ip/Cisco-IOS-XE-nat:nat/inside")
}
- if !state.Dot1xTimeoutSuppTimeout.IsNull() && data.Dot1xTimeoutSuppTimeout.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-dot1x:dot1x/timeout/supp-timeout", state.getPath()))
+ if !state.IpNatOutside.IsNull() && data.IpNatOutside.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ip/Cisco-IOS-XE-nat:nat/outside")
}
- if !state.Dot1xTimeoutStartPeriod.IsNull() && data.Dot1xTimeoutStartPeriod.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-dot1x:dot1x/timeout/start-period", state.getPath()))
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletedItemsXML
+
+// Section below is generated&owned by "gen/generator.go". //template:begin getEmptyLeafsDelete
+
+func (data *InterfaceEthernet) getEmptyLeafsDelete(ctx context.Context) []string {
+ emptyLeafsDelete := make([]string, 0)
+ if !data.IpNatOutside.IsNull() && !data.IpNatOutside.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/ip/Cisco-IOS-XE-nat:nat/outside", data.getPath()))
}
- if !state.Dot1xTimeoutServerTimeout.IsNull() && data.Dot1xTimeoutServerTimeout.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-dot1x:dot1x/timeout/server-timeout", state.getPath()))
+ if !data.IpNatInside.IsNull() && !data.IpNatInside.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/ip/Cisco-IOS-XE-nat:nat/inside", data.getPath()))
}
- if !state.Dot1xTimeoutRatelimitPeriod.IsNull() && data.Dot1xTimeoutRatelimitPeriod.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-dot1x:dot1x/timeout/ratelimit-period", state.getPath()))
+
+ if !data.DeviceTracking.IsNull() && !data.DeviceTracking.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-switch:device-tracking", data.getPath()))
}
- if !state.Dot1xTimeoutQuietPeriod.IsNull() && data.Dot1xTimeoutQuietPeriod.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-dot1x:dot1x/timeout/quiet-period", state.getPath()))
+ if !data.IpNbarProtocolDiscovery.IsNull() && !data.IpNbarProtocolDiscovery.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/ip/Cisco-IOS-XE-nbar:nbar/protocol-discovery", data.getPath()))
}
- if !state.Dot1xTimeoutHeldPeriod.IsNull() && data.Dot1xTimeoutHeldPeriod.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-dot1x:dot1x/timeout/held-period", state.getPath()))
+
+ if !data.MabEap.IsNull() && !data.MabEap.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-sanet:mab/eap", data.getPath()))
}
- if !state.Dot1xTimeoutAuthPeriod.IsNull() && data.Dot1xTimeoutAuthPeriod.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-dot1x:dot1x/timeout/auth-period", state.getPath()))
+ if !data.Mab.IsNull() && !data.Mab.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-sanet:mab", data.getPath()))
}
- if !state.Dot1xPae.IsNull() && data.Dot1xPae.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-dot1x:dot1x/pae", state.getPath()))
+ if !data.AuthenticationEventLinksecFailActionNextMethod.IsNull() && !data.AuthenticationEventLinksecFailActionNextMethod.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-sanet:authentication/event/linksec/fail/action/next-method", data.getPath()))
}
- if !state.MabEap.IsNull() && data.MabEap.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-sanet:mab/eap", state.getPath()))
+ if !data.AuthenticationEventFailActionNextMethod.IsNull() && !data.AuthenticationEventFailActionNextMethod.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-sanet:authentication/event/fail-config/action/next-method", data.getPath()))
}
- if !state.Mab.IsNull() && data.Mab.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-sanet:mab", state.getPath()))
+ if !data.AuthenticationEventServerDeadActionAuthorizeVoice.IsNull() && !data.AuthenticationEventServerDeadActionAuthorizeVoice.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-sanet:authentication/event/server/dead/action/authorize/voice", data.getPath()))
}
- if !state.AuthenticationEventLinksecFailActionNextMethod.IsNull() && data.AuthenticationEventLinksecFailActionNextMethod.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-sanet:authentication/event/linksec/fail/action/next-method", state.getPath()))
+ if !data.AuthenticationEventServerDeadActionAuthorize.IsNull() && !data.AuthenticationEventServerDeadActionAuthorize.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-sanet:authentication/event/server/dead/action/authorize", data.getPath()))
}
- if !state.AuthenticationEventNoResponseActionAuthorizeVlan.IsNull() && data.AuthenticationEventNoResponseActionAuthorizeVlan.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-sanet:authentication/event/no-response/action/authorize/vlan", state.getPath()))
+ if !data.AuthenticationEventServerAliveActionReinitialize.IsNull() && !data.AuthenticationEventServerAliveActionReinitialize.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-sanet:authentication/event/server/alive/action/reinitialize", data.getPath()))
}
- if !state.AuthenticationEventFailActionNextMethod.IsNull() && data.AuthenticationEventFailActionNextMethod.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-sanet:authentication/event/fail-config/action/next-method", state.getPath()))
+ if !data.AuthenticationTimerReauthenticateServer.IsNull() && !data.AuthenticationTimerReauthenticateServer.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-sanet:authentication/timer/reauthenticate/server-config", data.getPath()))
}
- if !state.AuthenticationEventFailActionAuthorizeVlan.IsNull() && data.AuthenticationEventFailActionAuthorizeVlan.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-sanet:authentication/event/fail-config/action/authorize/vlan", state.getPath()))
+ if !data.AuthenticationPeriodic.IsNull() && !data.AuthenticationPeriodic.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-sanet:authentication/periodic", data.getPath()))
}
- if !state.AuthenticationEventServerDeadActionReinitializeVlan.IsNull() && data.AuthenticationEventServerDeadActionReinitializeVlan.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-sanet:authentication/event/server/dead/action/reinitialize/vlan", state.getPath()))
+ if !data.AuthenticationPriorityWebauth.IsNull() && !data.AuthenticationPriorityWebauth.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-sanet:authentication/priority-config/webauth-config", data.getPath()))
}
- if !state.AuthenticationEventServerDeadActionAuthorizeVoice.IsNull() && data.AuthenticationEventServerDeadActionAuthorizeVoice.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-sanet:authentication/event/server/dead/action/authorize/voice", state.getPath()))
+ if !data.AuthenticationPriorityMabWebauth.IsNull() && !data.AuthenticationPriorityMabWebauth.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-sanet:authentication/priority-config/mab-config/webauth", data.getPath()))
}
- if !state.AuthenticationEventServerDeadActionAuthorizeVlan.IsNull() && data.AuthenticationEventServerDeadActionAuthorizeVlan.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-sanet:authentication/event/server/dead/action/authorize/vlan", state.getPath()))
+ if !data.AuthenticationPriorityMabDot1x.IsNull() && !data.AuthenticationPriorityMabDot1x.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-sanet:authentication/priority-config/mab-config/dot1x", data.getPath()))
+ }
+ if !data.AuthenticationPriorityMab.IsNull() && !data.AuthenticationPriorityMab.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-sanet:authentication/priority-config/mab-config", data.getPath()))
+ }
+ if !data.AuthenticationPriorityDot1xWebauth.IsNull() && !data.AuthenticationPriorityDot1xWebauth.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-sanet:authentication/priority-config/dot1x-config/webauth", data.getPath()))
+ }
+ if !data.AuthenticationPriorityDot1xMab.IsNull() && !data.AuthenticationPriorityDot1xMab.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-sanet:authentication/priority-config/dot1x-config/mab", data.getPath()))
+ }
+ if !data.AuthenticationPriorityDot1x.IsNull() && !data.AuthenticationPriorityDot1x.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-sanet:authentication/priority-config/dot1x-config", data.getPath()))
+ }
+ if !data.AuthenticationOrderWebauth.IsNull() && !data.AuthenticationOrderWebauth.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-sanet:authentication/order-config/webauth-config", data.getPath()))
+ }
+ if !data.AuthenticationOrderMabWebauth.IsNull() && !data.AuthenticationOrderMabWebauth.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-sanet:authentication/order-config/mab-config/webauth", data.getPath()))
+ }
+ if !data.AuthenticationOrderMabDot1x.IsNull() && !data.AuthenticationOrderMabDot1x.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-sanet:authentication/order-config/mab-config/dot1x", data.getPath()))
+ }
+ if !data.AuthenticationOrderMab.IsNull() && !data.AuthenticationOrderMab.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-sanet:authentication/order-config/mab-config", data.getPath()))
+ }
+ if !data.AuthenticationOrderDot1xWebauth.IsNull() && !data.AuthenticationOrderDot1xWebauth.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-sanet:authentication/order-config/dot1x-config/webauth", data.getPath()))
+ }
+ if !data.AuthenticationOrderDot1xMab.IsNull() && !data.AuthenticationOrderDot1xMab.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-sanet:authentication/order-config/dot1x-config/mab", data.getPath()))
+ }
+ if !data.AuthenticationOrderDot1x.IsNull() && !data.AuthenticationOrderDot1x.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-sanet:authentication/order-config/dot1x-config", data.getPath()))
+ }
+ if !data.SpeedNonegotiate.IsNull() && !data.SpeedNonegotiate.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-ethernet:speed/nonegotiate", data.getPath()))
+ }
+ if !data.Speed100000.IsNull() && !data.Speed100000.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-ethernet:speed/value-100000", data.getPath()))
+ }
+ if !data.Speed40000.IsNull() && !data.Speed40000.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-ethernet:speed/value-40000", data.getPath()))
+ }
+ if !data.Speed25000.IsNull() && !data.Speed25000.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-ethernet:speed/value-25000", data.getPath()))
+ }
+ if !data.Speed10000.IsNull() && !data.Speed10000.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-ethernet:speed/value-10000", data.getPath()))
+ }
+ if !data.Speed5000.IsNull() && !data.Speed5000.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-ethernet:speed/value-5000", data.getPath()))
+ }
+ if !data.Speed2500.IsNull() && !data.Speed2500.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-ethernet:speed/value-2500", data.getPath()))
}
- if !state.AuthenticationEventServerDeadActionAuthorize.IsNull() && data.AuthenticationEventServerDeadActionAuthorize.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-sanet:authentication/event/server/dead/action/authorize", state.getPath()))
+ if !data.Speed1000.IsNull() && !data.Speed1000.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-ethernet:speed/value-1000", data.getPath()))
}
- if !state.AuthenticationEventServerAliveActionReinitialize.IsNull() && data.AuthenticationEventServerAliveActionReinitialize.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-sanet:authentication/event/server/alive/action/reinitialize", state.getPath()))
+ if !data.Speed100.IsNull() && !data.Speed100.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-ethernet:speed/value-100", data.getPath()))
}
- if !state.AuthenticationTimerReauthenticateServer.IsNull() && data.AuthenticationTimerReauthenticateServer.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-sanet:authentication/timer/reauthenticate/server-config", state.getPath()))
+ if !data.IpDhcpSnoopingTrust.IsNull() && !data.IpDhcpSnoopingTrust.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/ip/dhcp/Cisco-IOS-XE-dhcp:snooping/trust", data.getPath()))
}
- if !state.AuthenticationTimerReauthenticate.IsNull() && data.AuthenticationTimerReauthenticate.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-sanet:authentication/timer/reauthenticate/value-config", state.getPath()))
+ if !data.IpArpInspectionTrust.IsNull() && !data.IpArpInspectionTrust.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/ip/arp/inspection/trust", data.getPath()))
}
- if !state.AuthenticationPeriodic.IsNull() && data.AuthenticationPeriodic.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-sanet:authentication/periodic", state.getPath()))
+ if !data.SpanningTreePortfastEdge.IsNull() && !data.SpanningTreePortfastEdge.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-spanning-tree:spanning-tree/portfast/edge", data.getPath()))
}
- if !state.AuthenticationPortControl.IsNull() && data.AuthenticationPortControl.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-sanet:authentication/port-control", state.getPath()))
+ if !data.SpanningTreePortfastTrunk.IsNull() && !data.SpanningTreePortfastTrunk.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-spanning-tree:spanning-tree/portfast/trunk", data.getPath()))
}
- if !state.AuthenticationPriorityWebauth.IsNull() && data.AuthenticationPriorityWebauth.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-sanet:authentication/priority-config/webauth-config", state.getPath()))
+ if !data.SpanningTreePortfastDisable.IsNull() && !data.SpanningTreePortfastDisable.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-spanning-tree:spanning-tree/portfast/disable", data.getPath()))
}
- if !state.AuthenticationPriorityMabWebauth.IsNull() && data.AuthenticationPriorityMabWebauth.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-sanet:authentication/priority-config/mab-config/webauth", state.getPath()))
+ if !data.SpanningTreePortfast.IsNull() && !data.SpanningTreePortfast.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-spanning-tree:spanning-tree/portfast", data.getPath()))
}
- if !state.AuthenticationPriorityMabDot1x.IsNull() && data.AuthenticationPriorityMabDot1x.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-sanet:authentication/priority-config/mab-config/dot1x", state.getPath()))
+ if !data.BpduguardDisable.IsNull() && !data.BpduguardDisable.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-spanning-tree:spanning-tree/bpduguard/disable", data.getPath()))
}
- if !state.AuthenticationPriorityMab.IsNull() && data.AuthenticationPriorityMab.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-sanet:authentication/priority-config/mab-config", state.getPath()))
+ if !data.BpduguardEnable.IsNull() && !data.BpduguardEnable.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-spanning-tree:spanning-tree/bpduguard/enable", data.getPath()))
}
- if !state.AuthenticationPriorityDot1xWebauth.IsNull() && data.AuthenticationPriorityDot1xWebauth.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-sanet:authentication/priority-config/dot1x-config/webauth", state.getPath()))
+
+ for i := range data.Ipv6Addresses {
+ keyValues := [...]string{data.Ipv6Addresses[i].Prefix.ValueString()}
+ if !data.Ipv6Addresses[i].Eui64.IsNull() && !data.Ipv6Addresses[i].Eui64.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/ipv6/address/prefix-list=%v/eui-64", data.getPath(), strings.Join(keyValues[:], ",")))
+ }
}
- if !state.AuthenticationPriorityDot1xMab.IsNull() && data.AuthenticationPriorityDot1xMab.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-sanet:authentication/priority-config/dot1x-config/mab", state.getPath()))
+
+ for i := range data.Ipv6LinkLocalAddresses {
+ keyValues := [...]string{data.Ipv6LinkLocalAddresses[i].Address.ValueString()}
+ if !data.Ipv6LinkLocalAddresses[i].LinkLocal.IsNull() && !data.Ipv6LinkLocalAddresses[i].LinkLocal.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/ipv6/address/link-local-address=%v/link-local", data.getPath(), strings.Join(keyValues[:], ",")))
+ }
}
- if !state.AuthenticationPriorityDot1x.IsNull() && data.AuthenticationPriorityDot1x.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-sanet:authentication/priority-config/dot1x-config", state.getPath()))
+ if !data.Ipv6AddressDhcp.IsNull() && !data.Ipv6AddressDhcp.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/ipv6/address/dhcp", data.getPath()))
}
- if !state.AuthenticationOrderWebauth.IsNull() && data.AuthenticationOrderWebauth.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-sanet:authentication/order-config/webauth-config", state.getPath()))
+ if !data.Ipv6AddressAutoconfigDefault.IsNull() && !data.Ipv6AddressAutoconfigDefault.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/ipv6/address/autoconfig/default", data.getPath()))
}
- if !state.AuthenticationOrderMabWebauth.IsNull() && data.AuthenticationOrderMabWebauth.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-sanet:authentication/order-config/mab-config/webauth", state.getPath()))
+ if !data.Ipv6NdRaSuppressAll.IsNull() && !data.Ipv6NdRaSuppressAll.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/ipv6/nd/Cisco-IOS-XE-nd:ra/suppress/all", data.getPath()))
}
- if !state.AuthenticationOrderMabDot1x.IsNull() && data.AuthenticationOrderMabDot1x.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-sanet:authentication/order-config/mab-config/dot1x", state.getPath()))
+ if !data.Ipv6Enable.IsNull() && !data.Ipv6Enable.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/ipv6/enable", data.getPath()))
}
- if !state.AuthenticationOrderMab.IsNull() && data.AuthenticationOrderMab.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-sanet:authentication/order-config/mab-config", state.getPath()))
+
+ for i := range data.SourceTemplate {
+ keyValues := [...]string{data.SourceTemplate[i].TemplateName.ValueString()}
+ if !data.SourceTemplate[i].Merge.IsNull() && !data.SourceTemplate[i].Merge.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/source/template/template-name=%v/merge", data.getPath(), strings.Join(keyValues[:], ",")))
+ }
}
- if !state.AuthenticationOrderDot1xWebauth.IsNull() && data.AuthenticationOrderDot1xWebauth.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-sanet:authentication/order-config/dot1x-config/webauth", state.getPath()))
+
+ for i := range data.HelperAddresses {
+ keyValues := [...]string{data.HelperAddresses[i].Address.ValueString()}
+ if !data.HelperAddresses[i].Global.IsNull() && !data.HelperAddresses[i].Global.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/ip/helper-address=%v/global", data.getPath(), strings.Join(keyValues[:], ",")))
+ }
}
- if !state.AuthenticationOrderDot1xMab.IsNull() && data.AuthenticationOrderDot1xMab.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-sanet:authentication/order-config/dot1x-config/mab", state.getPath()))
+ if !data.AutoQosVoipTrust.IsNull() && !data.AutoQosVoipTrust.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-switch:auto/qos/voip/trust", data.getPath()))
}
- if !state.AuthenticationOrderDot1x.IsNull() && data.AuthenticationOrderDot1x.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-sanet:authentication/order-config/dot1x-config", state.getPath()))
+ if !data.AutoQosVoipCiscoSoftphone.IsNull() && !data.AutoQosVoipCiscoSoftphone.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-switch:auto/qos/voip/cisco-softphone", data.getPath()))
}
- if !state.AuthenticationHostMode.IsNull() && data.AuthenticationHostMode.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-sanet:authentication/host-mode", state.getPath()))
+ if !data.AutoQosVoipCiscoPhone.IsNull() && !data.AutoQosVoipCiscoPhone.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-switch:auto/qos/voip/cisco-phone", data.getPath()))
}
- if !state.SpeedNonegotiate.IsNull() && data.SpeedNonegotiate.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-ethernet:speed/nonegotiate", state.getPath()))
+ if !data.AutoQosVoip.IsNull() && !data.AutoQosVoip.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-switch:auto/qos/voip", data.getPath()))
}
- if !state.NegotiationAuto.IsNull() && data.NegotiationAuto.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-ethernet:negotiation/auto", state.getPath()))
+ if !data.AutoQosVideoMediaPlayer.IsNull() && !data.AutoQosVideoMediaPlayer.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-switch:auto/qos/video/media-player", data.getPath()))
}
- if !state.Speed100000.IsNull() && data.Speed100000.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-ethernet:speed/value-100000", state.getPath()))
+ if !data.AutoQosVideoIpCamera.IsNull() && !data.AutoQosVideoIpCamera.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-switch:auto/qos/video/ip-camera", data.getPath()))
}
- if !state.Speed40000.IsNull() && data.Speed40000.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-ethernet:speed/value-40000", state.getPath()))
+ if !data.AutoQosVideoCts.IsNull() && !data.AutoQosVideoCts.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-switch:auto/qos/video/cts", data.getPath()))
}
- if !state.Speed25000.IsNull() && data.Speed25000.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-ethernet:speed/value-25000", state.getPath()))
+ if !data.AutoQosTrustDscp.IsNull() && !data.AutoQosTrustDscp.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-switch:auto/qos/trust/dscp", data.getPath()))
}
- if !state.Speed10000.IsNull() && data.Speed10000.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-ethernet:speed/value-10000", state.getPath()))
+ if !data.AutoQosTrustCos.IsNull() && !data.AutoQosTrustCos.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-switch:auto/qos/trust/cos", data.getPath()))
}
- if !state.Speed5000.IsNull() && data.Speed5000.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-ethernet:speed/value-5000", state.getPath()))
+ if !data.AutoQosTrust.IsNull() && !data.AutoQosTrust.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-switch:auto/qos/trust", data.getPath()))
}
- if !state.Speed2500.IsNull() && data.Speed2500.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-ethernet:speed/value-2500", state.getPath()))
+ if !data.AutoQosClassifyPolice.IsNull() && !data.AutoQosClassifyPolice.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-switch:auto/qos/classify/police", data.getPath()))
}
- if !state.Speed1000.IsNull() && data.Speed1000.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-ethernet:speed/value-1000", state.getPath()))
+ if !data.AutoQosClassify.IsNull() && !data.AutoQosClassify.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-switch:auto/qos/classify", data.getPath()))
}
- if !state.Speed100.IsNull() && data.Speed100.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-ethernet:speed/value-100", state.getPath()))
+ if !data.IpAccessGroupOutEnable.IsNull() && !data.IpAccessGroupOutEnable.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/ip/access-group/out/acl/out", data.getPath()))
}
- if !state.IpDhcpSnoopingTrust.IsNull() && data.IpDhcpSnoopingTrust.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/dhcp/Cisco-IOS-XE-dhcp:snooping/trust", state.getPath()))
+ if !data.IpAccessGroupInEnable.IsNull() && !data.IpAccessGroupInEnable.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/ip/access-group/in/acl/in", data.getPath()))
}
- if !state.IpArpInspectionLimitRate.IsNull() && data.IpArpInspectionLimitRate.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/arp/inspection/limit/rate", state.getPath()))
+ if !data.Shutdown.IsNull() && !data.Shutdown.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/shutdown", data.getPath()))
}
- if !state.IpArpInspectionTrust.IsNull() && data.IpArpInspectionTrust.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/arp/inspection/trust", state.getPath()))
+
+ return emptyLeafsDelete
+}
+
+// End of section. //template:end getEmptyLeafsDelete
+
+// Section below is generated&owned by "gen/generator.go". //template:begin getDeletePaths
+
+func (data *InterfaceEthernet) getDeletePaths(ctx context.Context) []string {
+ var deletePaths []string
+ if !data.IpNatOutside.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/Cisco-IOS-XE-nat:nat/outside", data.getPath()))
}
- if !state.SpanningTreePortfastEdge.IsNull() && data.SpanningTreePortfastEdge.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-spanning-tree:spanning-tree/portfast/edge", state.getPath()))
+ if !data.IpNatInside.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/Cisco-IOS-XE-nat:nat/inside", data.getPath()))
}
- if !state.SpanningTreePortfastTrunk.IsNull() && data.SpanningTreePortfastTrunk.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-spanning-tree:spanning-tree/portfast/trunk", state.getPath()))
+ if !data.CdpTlvServerLocation.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-cdp:cdp/tlv/server-location-config", data.getPath()))
}
- if !state.SpanningTreePortfastDisable.IsNull() && data.SpanningTreePortfastDisable.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-spanning-tree:spanning-tree/portfast/disable", state.getPath()))
+ if !data.CdpTlvLocation.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-cdp:cdp/tlv/location-config", data.getPath()))
}
- if !state.SpanningTreePortfast.IsNull() && data.SpanningTreePortfast.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-spanning-tree:spanning-tree/portfast", state.getPath()))
+ if !data.CdpTlvApp.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-cdp:cdp/tlv/default-wrp/app", data.getPath()))
}
- if !state.BpduguardDisable.IsNull() && data.BpduguardDisable.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-spanning-tree:spanning-tree/bpduguard/disable", state.getPath()))
+ if !data.CdpEnable.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-cdp:cdp/enable", data.getPath()))
}
- if !state.BpduguardEnable.IsNull() && data.BpduguardEnable.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-spanning-tree:spanning-tree/bpduguard/enable", state.getPath()))
+ for i := range data.DeviceTrackingAttachedPolicies {
+ keyValues := [...]string{data.DeviceTrackingAttachedPolicies[i].Name.ValueString()}
+
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-switch:device-tracking/attached-policies=%v", data.getPath(), strings.Join(keyValues[:], ",")))
}
- if !state.SpanningTreeLinkType.IsNull() && data.SpanningTreeLinkType.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-spanning-tree:spanning-tree/link-type", state.getPath()))
+ if !data.DeviceTracking.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-switch:device-tracking", data.getPath()))
}
- if !state.ArpTimeout.IsNull() && data.ArpTimeout.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/arp/timeout", state.getPath()))
+ if !data.IpNbarProtocolDiscovery.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/Cisco-IOS-XE-nbar:nbar/protocol-discovery", data.getPath()))
}
- for i := range state.Ipv6FlowMonitors {
- stateKeyValues := [...]string{state.Ipv6FlowMonitors[i].Name.ValueString(), state.Ipv6FlowMonitors[i].Direction.ValueString()}
-
- emptyKeys := true
- if !reflect.ValueOf(state.Ipv6FlowMonitors[i].Name.ValueString()).IsZero() {
- emptyKeys = false
- }
- if !reflect.ValueOf(state.Ipv6FlowMonitors[i].Direction.ValueString()).IsZero() {
- emptyKeys = false
- }
- if emptyKeys {
- continue
- }
-
- found := false
- for j := range data.Ipv6FlowMonitors {
- found = true
- if state.Ipv6FlowMonitors[i].Name.ValueString() != data.Ipv6FlowMonitors[j].Name.ValueString() {
- found = false
- }
- if state.Ipv6FlowMonitors[i].Direction.ValueString() != data.Ipv6FlowMonitors[j].Direction.ValueString() {
- found = false
- }
- if found {
- break
- }
- }
- if !found {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ipv6/Cisco-IOS-XE-flow:flow/monitor-new=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
- }
+ if !data.LoggingEventLinkStatusEnable.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/logging/event/link-status-enable", data.getPath()))
}
- for i := range state.Ipv6Addresses {
- stateKeyValues := [...]string{state.Ipv6Addresses[i].Prefix.ValueString()}
-
- emptyKeys := true
- if !reflect.ValueOf(state.Ipv6Addresses[i].Prefix.ValueString()).IsZero() {
- emptyKeys = false
- }
- if emptyKeys {
- continue
- }
-
- found := false
- for j := range data.Ipv6Addresses {
- found = true
- if state.Ipv6Addresses[i].Prefix.ValueString() != data.Ipv6Addresses[j].Prefix.ValueString() {
- found = false
- }
- if found {
- if !state.Ipv6Addresses[i].Eui64.IsNull() && data.Ipv6Addresses[j].Eui64.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ipv6/address/prefix-list=%v/eui-64", state.getPath(), strings.Join(stateKeyValues[:], ",")))
- }
- break
- }
- }
- if !found {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ipv6/address/prefix-list=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
- }
+ if !data.SnmpTrapLinkStatus.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:snmp/trap/link-status", data.getPath()))
}
- for i := range state.Ipv6LinkLocalAddresses {
- stateKeyValues := [...]string{state.Ipv6LinkLocalAddresses[i].Address.ValueString()}
-
- emptyKeys := true
- if !reflect.ValueOf(state.Ipv6LinkLocalAddresses[i].Address.ValueString()).IsZero() {
- emptyKeys = false
- }
- if emptyKeys {
- continue
- }
+ if !data.LoadInterval.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/load-interval", data.getPath()))
+ }
+ for i := range data.IpFlowMonitors {
+ keyValues := [...]string{data.IpFlowMonitors[i].Name.ValueString(), data.IpFlowMonitors[i].Direction.ValueString()}
- found := false
- for j := range data.Ipv6LinkLocalAddresses {
- found = true
- if state.Ipv6LinkLocalAddresses[i].Address.ValueString() != data.Ipv6LinkLocalAddresses[j].Address.ValueString() {
- found = false
- }
- if found {
- if !state.Ipv6LinkLocalAddresses[i].LinkLocal.IsNull() && data.Ipv6LinkLocalAddresses[j].LinkLocal.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ipv6/address/link-local-address=%v/link-local", state.getPath(), strings.Join(stateKeyValues[:], ",")))
- }
- break
- }
- }
- if !found {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ipv6/address/link-local-address=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
- }
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/Cisco-IOS-XE-flow:flow/monitor-new=%v", data.getPath(), strings.Join(keyValues[:], ",")))
}
- if !state.Ipv6AddressDhcp.IsNull() && data.Ipv6AddressDhcp.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ipv6/address/dhcp", state.getPath()))
+ if !data.ServicePolicyOutput.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-policy:service-policy/output", data.getPath()))
}
- if !state.Ipv6AddressAutoconfigDefault.IsNull() && data.Ipv6AddressAutoconfigDefault.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ipv6/address/autoconfig/default", state.getPath()))
+ if !data.ServicePolicyInput.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-policy:service-policy/input", data.getPath()))
}
- if !state.Ipv6NdRaSuppressAll.IsNull() && data.Ipv6NdRaSuppressAll.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ipv6/nd/Cisco-IOS-XE-nd:ra/suppress/all", state.getPath()))
+ if !data.Dot1xMaxReauthReq.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-dot1x:dot1x/max-reauth-req", data.getPath()))
}
- if !state.Ipv6Mtu.IsNull() && data.Ipv6Mtu.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ipv6/mtu", state.getPath()))
+ if !data.Dot1xMaxReq.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-dot1x:dot1x/max-req", data.getPath()))
}
- if !state.Ipv6Enable.IsNull() && data.Ipv6Enable.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ipv6/enable", state.getPath()))
+ if !data.Dot1xTimeoutTxPeriod.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-dot1x:dot1x/timeout/tx-period", data.getPath()))
}
- if !state.BfdEcho.IsNull() && data.BfdEcho.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/bfd/Cisco-IOS-XE-bfd:echo", state.getPath()))
+ if !data.Dot1xTimeoutSuppTimeout.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-dot1x:dot1x/timeout/supp-timeout", data.getPath()))
}
- if !state.BfdIntervalMultiplier.IsNull() && data.BfdIntervalMultiplier.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/bfd/Cisco-IOS-XE-bfd:interval-interface", state.getPath()))
+ if !data.Dot1xTimeoutStartPeriod.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-dot1x:dot1x/timeout/start-period", data.getPath()))
}
- if !state.BfdIntervalMinRx.IsNull() && data.BfdIntervalMinRx.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/bfd/Cisco-IOS-XE-bfd:interval-interface", state.getPath()))
+ if !data.Dot1xTimeoutServerTimeout.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-dot1x:dot1x/timeout/server-timeout", data.getPath()))
}
- if !state.BfdInterval.IsNull() && data.BfdInterval.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/bfd/Cisco-IOS-XE-bfd:interval-interface", state.getPath()))
+ if !data.Dot1xTimeoutRatelimitPeriod.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-dot1x:dot1x/timeout/ratelimit-period", data.getPath()))
}
- if !state.BfdLocalAddress.IsNull() && data.BfdLocalAddress.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/bfd/Cisco-IOS-XE-bfd:local-address", state.getPath()))
+ if !data.Dot1xTimeoutQuietPeriod.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-dot1x:dot1x/timeout/quiet-period", data.getPath()))
}
- if !state.BfdEnable.IsNull() && data.BfdEnable.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/bfd/Cisco-IOS-XE-bfd:enable", state.getPath()))
+ if !data.Dot1xTimeoutHeldPeriod.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-dot1x:dot1x/timeout/held-period", data.getPath()))
}
- if !state.BfdTemplate.IsNull() && data.BfdTemplate.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/bfd/Cisco-IOS-XE-bfd:template", state.getPath()))
+ if !data.Dot1xTimeoutAuthPeriod.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-dot1x:dot1x/timeout/auth-period", data.getPath()))
}
- for i := range state.SourceTemplate {
- stateKeyValues := [...]string{state.SourceTemplate[i].TemplateName.ValueString()}
-
- emptyKeys := true
- if !reflect.ValueOf(state.SourceTemplate[i].TemplateName.ValueString()).IsZero() {
- emptyKeys = false
- }
- if emptyKeys {
- continue
- }
-
- found := false
- for j := range data.SourceTemplate {
- found = true
- if state.SourceTemplate[i].TemplateName.ValueString() != data.SourceTemplate[j].TemplateName.ValueString() {
- found = false
- }
- if found {
- if !state.SourceTemplate[i].Merge.IsNull() && data.SourceTemplate[j].Merge.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/source/template/template-name=%v/merge", state.getPath(), strings.Join(stateKeyValues[:], ",")))
- }
- break
- }
- }
- if !found {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/source/template/template-name=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
- }
+ if !data.Dot1xPae.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-dot1x:dot1x/pae", data.getPath()))
}
- for i := range state.HelperAddresses {
- stateKeyValues := [...]string{state.HelperAddresses[i].Address.ValueString()}
-
- emptyKeys := true
- if !reflect.ValueOf(state.HelperAddresses[i].Address.ValueString()).IsZero() {
- emptyKeys = false
- }
- if emptyKeys {
- continue
- }
-
- found := false
- for j := range data.HelperAddresses {
- found = true
- if state.HelperAddresses[i].Address.ValueString() != data.HelperAddresses[j].Address.ValueString() {
- found = false
- }
- if found {
- if !state.HelperAddresses[i].Vrf.IsNull() && data.HelperAddresses[j].Vrf.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/helper-address=%v/vrf", state.getPath(), strings.Join(stateKeyValues[:], ",")))
- }
- if !state.HelperAddresses[i].Global.IsNull() && data.HelperAddresses[j].Global.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/helper-address=%v/global", state.getPath(), strings.Join(stateKeyValues[:], ",")))
- }
- break
- }
- }
- if !found {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/helper-address=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
- }
+ if !data.MabEap.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-sanet:mab/eap", data.getPath()))
}
- if !state.TrustDevice.IsNull() && data.TrustDevice.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/trust/device", state.getPath()))
+ if !data.Mab.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-sanet:mab", data.getPath()))
}
- if !state.AutoQosVoipTrust.IsNull() && data.AutoQosVoipTrust.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-switch:auto/qos/voip/trust", state.getPath()))
+ if !data.AuthenticationEventLinksecFailActionNextMethod.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-sanet:authentication/event/linksec/fail/action/next-method", data.getPath()))
}
- if !state.AutoQosVoipCiscoSoftphone.IsNull() && data.AutoQosVoipCiscoSoftphone.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-switch:auto/qos/voip/cisco-softphone", state.getPath()))
+ if !data.AuthenticationEventNoResponseActionAuthorizeVlan.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-sanet:authentication/event/no-response/action/authorize/vlan", data.getPath()))
}
- if !state.AutoQosVoipCiscoPhone.IsNull() && data.AutoQosVoipCiscoPhone.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-switch:auto/qos/voip/cisco-phone", state.getPath()))
+ if !data.AuthenticationEventFailActionNextMethod.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-sanet:authentication/event/fail-config/action/next-method", data.getPath()))
}
- if !state.AutoQosVoip.IsNull() && data.AutoQosVoip.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-switch:auto/qos/voip", state.getPath()))
+ if !data.AuthenticationEventFailActionAuthorizeVlan.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-sanet:authentication/event/fail-config/action/authorize/vlan", data.getPath()))
}
- if !state.AutoQosVideoMediaPlayer.IsNull() && data.AutoQosVideoMediaPlayer.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-switch:auto/qos/video/media-player", state.getPath()))
+ if !data.AuthenticationEventServerDeadActionReinitializeVlan.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-sanet:authentication/event/server/dead/action/reinitialize/vlan", data.getPath()))
}
- if !state.AutoQosVideoIpCamera.IsNull() && data.AutoQosVideoIpCamera.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-switch:auto/qos/video/ip-camera", state.getPath()))
+ if !data.AuthenticationEventServerDeadActionAuthorizeVoice.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-sanet:authentication/event/server/dead/action/authorize/voice", data.getPath()))
}
- if !state.AutoQosVideoCts.IsNull() && data.AutoQosVideoCts.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-switch:auto/qos/video/cts", state.getPath()))
+ if !data.AuthenticationEventServerDeadActionAuthorizeVlan.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-sanet:authentication/event/server/dead/action/authorize/vlan", data.getPath()))
}
- if !state.AutoQosTrustDscp.IsNull() && data.AutoQosTrustDscp.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-switch:auto/qos/trust/dscp", state.getPath()))
+ if !data.AuthenticationEventServerDeadActionAuthorize.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-sanet:authentication/event/server/dead/action/authorize", data.getPath()))
}
- if !state.AutoQosTrustCos.IsNull() && data.AutoQosTrustCos.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-switch:auto/qos/trust/cos", state.getPath()))
+ if !data.AuthenticationEventServerAliveActionReinitialize.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-sanet:authentication/event/server/alive/action/reinitialize", data.getPath()))
}
- if !state.AutoQosTrust.IsNull() && data.AutoQosTrust.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-switch:auto/qos/trust", state.getPath()))
+ if !data.AuthenticationTimerReauthenticateServer.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-sanet:authentication/timer/reauthenticate/server-config", data.getPath()))
}
- if !state.AutoQosClassifyPolice.IsNull() && data.AutoQosClassifyPolice.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-switch:auto/qos/classify/police", state.getPath()))
+ if !data.AuthenticationTimerReauthenticate.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-sanet:authentication/timer/reauthenticate/value-config", data.getPath()))
}
- if !state.AutoQosClassify.IsNull() && data.AutoQosClassify.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-switch:auto/qos/classify", state.getPath()))
+ if !data.AuthenticationPeriodic.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-sanet:authentication/periodic", data.getPath()))
}
- if !state.SpanningTreeGuard.IsNull() && data.SpanningTreeGuard.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-spanning-tree:spanning-tree/guard", state.getPath()))
+ if !data.AuthenticationPortControl.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-sanet:authentication/port-control", data.getPath()))
}
- if !state.IpAccessGroupOut.IsNull() && data.IpAccessGroupOut.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/access-group/out/acl", state.getPath()))
+ if !data.AuthenticationPriorityWebauth.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-sanet:authentication/priority-config/webauth-config", data.getPath()))
}
- if !state.IpAccessGroupOutEnable.IsNull() && data.IpAccessGroupOutEnable.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/access-group/out/acl/out", state.getPath()))
+ if !data.AuthenticationPriorityMabWebauth.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-sanet:authentication/priority-config/mab-config/webauth", data.getPath()))
}
- if !state.IpAccessGroupIn.IsNull() && data.IpAccessGroupIn.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/access-group/in/acl", state.getPath()))
+ if !data.AuthenticationPriorityMabDot1x.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-sanet:authentication/priority-config/mab-config/dot1x", data.getPath()))
}
- if !state.IpAccessGroupInEnable.IsNull() && data.IpAccessGroupInEnable.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/access-group/in/acl/in", state.getPath()))
+ if !data.AuthenticationPriorityMab.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-sanet:authentication/priority-config/mab-config", data.getPath()))
}
- if !state.IpDhcpRelaySourceInterface.IsNull() && data.IpDhcpRelaySourceInterface.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/dhcp/Cisco-IOS-XE-dhcp:relay/source-interface", state.getPath()))
+ if !data.AuthenticationPriorityDot1xWebauth.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-sanet:authentication/priority-config/dot1x-config/webauth", data.getPath()))
}
- if !state.ChannelGroupMode.IsNull() && data.ChannelGroupMode.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-ethernet:channel-group", state.getPath()))
+ if !data.AuthenticationPriorityDot1xMab.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-sanet:authentication/priority-config/dot1x-config/mab", data.getPath()))
}
- if !state.ChannelGroupNumber.IsNull() && data.ChannelGroupNumber.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-ethernet:channel-group", state.getPath()))
+ if !data.AuthenticationPriorityDot1x.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-sanet:authentication/priority-config/dot1x-config", data.getPath()))
}
- if !state.EncapsulationDot1qVlanId.IsNull() && data.EncapsulationDot1qVlanId.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/encapsulation/dot1Q/vlan-id", state.getPath()))
+ if !data.AuthenticationOrderWebauth.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-sanet:authentication/order-config/webauth-config", data.getPath()))
}
- if !state.Unnumbered.IsNull() && data.Unnumbered.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/unnumbered", state.getPath()))
+ if !data.AuthenticationOrderMabWebauth.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-sanet:authentication/order-config/mab-config/webauth", data.getPath()))
}
- if !state.Ipv4AddressMask.IsNull() && data.Ipv4AddressMask.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/address/primary", state.getPath()))
+ if !data.AuthenticationOrderMabDot1x.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-sanet:authentication/order-config/mab-config/dot1x", data.getPath()))
}
- if !state.Ipv4Address.IsNull() && data.Ipv4Address.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/address/primary", state.getPath()))
+ if !data.AuthenticationOrderMab.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-sanet:authentication/order-config/mab-config", data.getPath()))
}
- if !state.VrfForwarding.IsNull() && data.VrfForwarding.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/vrf/forwarding", state.getPath()))
+ if !data.AuthenticationOrderDot1xWebauth.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-sanet:authentication/order-config/dot1x-config/webauth", data.getPath()))
}
- if !state.IpUnreachables.IsNull() && data.IpUnreachables.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/Cisco-IOS-XE-icmp:unreachables", state.getPath()))
+ if !data.AuthenticationOrderDot1xMab.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-sanet:authentication/order-config/dot1x-config/mab", data.getPath()))
}
- if !state.IpRedirects.IsNull() && data.IpRedirects.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/redirects", state.getPath()))
+ if !data.AuthenticationOrderDot1x.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-sanet:authentication/order-config/dot1x-config", data.getPath()))
}
- if !state.IpProxyArp.IsNull() && data.IpProxyArp.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/proxy-arp", state.getPath()))
+ if !data.AuthenticationHostMode.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-sanet:authentication/host-mode", data.getPath()))
}
- if !state.Shutdown.IsNull() && data.Shutdown.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/shutdown", state.getPath()))
+ if !data.SpeedNonegotiate.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-ethernet:speed/nonegotiate", data.getPath()))
}
- if !state.Description.IsNull() && data.Description.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/description", state.getPath()))
+ if !data.NegotiationAuto.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-ethernet:negotiation/auto", data.getPath()))
}
- if !state.Switchport.IsNull() && data.Switchport.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/switchport-conf/switchport", state.getPath()))
+ if !data.Speed100000.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-ethernet:speed/value-100000", data.getPath()))
}
- if !state.Bandwidth.IsNull() && data.Bandwidth.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/bandwidth/kilobits", state.getPath()))
+ if !data.Speed40000.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-ethernet:speed/value-40000", data.getPath()))
}
- if !state.Mtu.IsNull() && data.Mtu.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/mtu", state.getPath()))
+ if !data.Speed25000.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-ethernet:speed/value-25000", data.getPath()))
}
- if !state.MediaType.IsNull() && data.MediaType.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/media-type", state.getPath()))
+ if !data.Speed10000.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-ethernet:speed/value-10000", data.getPath()))
}
-
- return deletedItems
-}
-
-// End of section. //template:end getDeletedItems
-
-// Section below is generated&owned by "gen/generator.go". //template:begin getEmptyLeafsDelete
-
-func (data *InterfaceEthernet) getEmptyLeafsDelete(ctx context.Context) []string {
- emptyLeafsDelete := make([]string, 0)
- if !data.IpNatOutside.IsNull() && !data.IpNatOutside.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/ip/Cisco-IOS-XE-nat:nat/outside", data.getPath()))
+ if !data.Speed5000.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-ethernet:speed/value-5000", data.getPath()))
}
- if !data.IpNatInside.IsNull() && !data.IpNatInside.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/ip/Cisco-IOS-XE-nat:nat/inside", data.getPath()))
+ if !data.Speed2500.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-ethernet:speed/value-2500", data.getPath()))
}
-
- if !data.DeviceTracking.IsNull() && !data.DeviceTracking.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-switch:device-tracking", data.getPath()))
+ if !data.Speed1000.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-ethernet:speed/value-1000", data.getPath()))
}
- if !data.IpNbarProtocolDiscovery.IsNull() && !data.IpNbarProtocolDiscovery.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/ip/Cisco-IOS-XE-nbar:nbar/protocol-discovery", data.getPath()))
+ if !data.Speed100.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-ethernet:speed/value-100", data.getPath()))
}
-
- if !data.MabEap.IsNull() && !data.MabEap.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-sanet:mab/eap", data.getPath()))
+ if !data.IpDhcpSnoopingTrust.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/dhcp/Cisco-IOS-XE-dhcp:snooping/trust", data.getPath()))
}
- if !data.Mab.IsNull() && !data.Mab.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-sanet:mab", data.getPath()))
+ if !data.IpArpInspectionLimitRate.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/arp/inspection/limit/rate", data.getPath()))
}
- if !data.AuthenticationEventLinksecFailActionNextMethod.IsNull() && !data.AuthenticationEventLinksecFailActionNextMethod.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-sanet:authentication/event/linksec/fail/action/next-method", data.getPath()))
+ if !data.IpArpInspectionTrust.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/arp/inspection/trust", data.getPath()))
}
- if !data.AuthenticationEventFailActionNextMethod.IsNull() && !data.AuthenticationEventFailActionNextMethod.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-sanet:authentication/event/fail-config/action/next-method", data.getPath()))
+ if !data.SpanningTreePortfastEdge.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-spanning-tree:spanning-tree/portfast/edge", data.getPath()))
}
- if !data.AuthenticationEventServerDeadActionAuthorizeVoice.IsNull() && !data.AuthenticationEventServerDeadActionAuthorizeVoice.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-sanet:authentication/event/server/dead/action/authorize/voice", data.getPath()))
+ if !data.SpanningTreePortfastTrunk.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-spanning-tree:spanning-tree/portfast/trunk", data.getPath()))
}
- if !data.AuthenticationEventServerDeadActionAuthorize.IsNull() && !data.AuthenticationEventServerDeadActionAuthorize.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-sanet:authentication/event/server/dead/action/authorize", data.getPath()))
+ if !data.SpanningTreePortfastDisable.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-spanning-tree:spanning-tree/portfast/disable", data.getPath()))
}
- if !data.AuthenticationEventServerAliveActionReinitialize.IsNull() && !data.AuthenticationEventServerAliveActionReinitialize.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-sanet:authentication/event/server/alive/action/reinitialize", data.getPath()))
+ if !data.SpanningTreePortfast.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-spanning-tree:spanning-tree/portfast", data.getPath()))
}
- if !data.AuthenticationTimerReauthenticateServer.IsNull() && !data.AuthenticationTimerReauthenticateServer.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-sanet:authentication/timer/reauthenticate/server-config", data.getPath()))
+ if !data.BpduguardDisable.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-spanning-tree:spanning-tree/bpduguard/disable", data.getPath()))
}
- if !data.AuthenticationPeriodic.IsNull() && !data.AuthenticationPeriodic.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-sanet:authentication/periodic", data.getPath()))
+ if !data.BpduguardEnable.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-spanning-tree:spanning-tree/bpduguard/enable", data.getPath()))
}
- if !data.AuthenticationPriorityWebauth.IsNull() && !data.AuthenticationPriorityWebauth.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-sanet:authentication/priority-config/webauth-config", data.getPath()))
+ if !data.SpanningTreeLinkType.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-spanning-tree:spanning-tree/link-type", data.getPath()))
}
- if !data.AuthenticationPriorityMabWebauth.IsNull() && !data.AuthenticationPriorityMabWebauth.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-sanet:authentication/priority-config/mab-config/webauth", data.getPath()))
+ if !data.ArpTimeout.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/arp/timeout", data.getPath()))
}
- if !data.AuthenticationPriorityMabDot1x.IsNull() && !data.AuthenticationPriorityMabDot1x.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-sanet:authentication/priority-config/mab-config/dot1x", data.getPath()))
+ for i := range data.Ipv6FlowMonitors {
+ keyValues := [...]string{data.Ipv6FlowMonitors[i].Name.ValueString(), data.Ipv6FlowMonitors[i].Direction.ValueString()}
+
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/ipv6/Cisco-IOS-XE-flow:flow/monitor-new=%v", data.getPath(), strings.Join(keyValues[:], ",")))
}
- if !data.AuthenticationPriorityMab.IsNull() && !data.AuthenticationPriorityMab.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-sanet:authentication/priority-config/mab-config", data.getPath()))
+ for i := range data.Ipv6Addresses {
+ keyValues := [...]string{data.Ipv6Addresses[i].Prefix.ValueString()}
+
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/ipv6/address/prefix-list=%v", data.getPath(), strings.Join(keyValues[:], ",")))
}
- if !data.AuthenticationPriorityDot1xWebauth.IsNull() && !data.AuthenticationPriorityDot1xWebauth.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-sanet:authentication/priority-config/dot1x-config/webauth", data.getPath()))
+ for i := range data.Ipv6LinkLocalAddresses {
+ keyValues := [...]string{data.Ipv6LinkLocalAddresses[i].Address.ValueString()}
+
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/ipv6/address/link-local-address=%v", data.getPath(), strings.Join(keyValues[:], ",")))
}
- if !data.AuthenticationPriorityDot1xMab.IsNull() && !data.AuthenticationPriorityDot1xMab.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-sanet:authentication/priority-config/dot1x-config/mab", data.getPath()))
+ if !data.Ipv6AddressDhcp.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/ipv6/address/dhcp", data.getPath()))
}
- if !data.AuthenticationPriorityDot1x.IsNull() && !data.AuthenticationPriorityDot1x.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-sanet:authentication/priority-config/dot1x-config", data.getPath()))
+ if !data.Ipv6AddressAutoconfigDefault.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/ipv6/address/autoconfig/default", data.getPath()))
}
- if !data.AuthenticationOrderWebauth.IsNull() && !data.AuthenticationOrderWebauth.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-sanet:authentication/order-config/webauth-config", data.getPath()))
+ if !data.Ipv6NdRaSuppressAll.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/ipv6/nd/Cisco-IOS-XE-nd:ra/suppress/all", data.getPath()))
}
- if !data.AuthenticationOrderMabWebauth.IsNull() && !data.AuthenticationOrderMabWebauth.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-sanet:authentication/order-config/mab-config/webauth", data.getPath()))
+ if !data.Ipv6Mtu.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/ipv6/mtu", data.getPath()))
}
- if !data.AuthenticationOrderMabDot1x.IsNull() && !data.AuthenticationOrderMabDot1x.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-sanet:authentication/order-config/mab-config/dot1x", data.getPath()))
+ if !data.Ipv6Enable.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/ipv6/enable", data.getPath()))
}
- if !data.AuthenticationOrderMab.IsNull() && !data.AuthenticationOrderMab.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-sanet:authentication/order-config/mab-config", data.getPath()))
+ if !data.BfdEcho.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/bfd/Cisco-IOS-XE-bfd:echo", data.getPath()))
}
- if !data.AuthenticationOrderDot1xWebauth.IsNull() && !data.AuthenticationOrderDot1xWebauth.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-sanet:authentication/order-config/dot1x-config/webauth", data.getPath()))
+ if !data.BfdIntervalMultiplier.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/bfd/Cisco-IOS-XE-bfd:interval-interface", data.getPath()))
}
- if !data.AuthenticationOrderDot1xMab.IsNull() && !data.AuthenticationOrderDot1xMab.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-sanet:authentication/order-config/dot1x-config/mab", data.getPath()))
+ if !data.BfdIntervalMinRx.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/bfd/Cisco-IOS-XE-bfd:interval-interface", data.getPath()))
}
- if !data.AuthenticationOrderDot1x.IsNull() && !data.AuthenticationOrderDot1x.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-sanet:authentication/order-config/dot1x-config", data.getPath()))
+ if !data.BfdInterval.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/bfd/Cisco-IOS-XE-bfd:interval-interface", data.getPath()))
}
- if !data.SpeedNonegotiate.IsNull() && !data.SpeedNonegotiate.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-ethernet:speed/nonegotiate", data.getPath()))
+ if !data.BfdLocalAddress.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/bfd/Cisco-IOS-XE-bfd:local-address", data.getPath()))
}
- if !data.Speed100000.IsNull() && !data.Speed100000.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-ethernet:speed/value-100000", data.getPath()))
+ if !data.BfdEnable.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/bfd/Cisco-IOS-XE-bfd:enable", data.getPath()))
}
- if !data.Speed40000.IsNull() && !data.Speed40000.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-ethernet:speed/value-40000", data.getPath()))
+ if !data.BfdTemplate.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/bfd/Cisco-IOS-XE-bfd:template", data.getPath()))
}
- if !data.Speed25000.IsNull() && !data.Speed25000.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-ethernet:speed/value-25000", data.getPath()))
+ for i := range data.SourceTemplate {
+ keyValues := [...]string{data.SourceTemplate[i].TemplateName.ValueString()}
+
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/source/template/template-name=%v", data.getPath(), strings.Join(keyValues[:], ",")))
}
- if !data.Speed10000.IsNull() && !data.Speed10000.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-ethernet:speed/value-10000", data.getPath()))
+ for i := range data.HelperAddresses {
+ keyValues := [...]string{data.HelperAddresses[i].Address.ValueString()}
+
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/helper-address=%v", data.getPath(), strings.Join(keyValues[:], ",")))
}
- if !data.Speed5000.IsNull() && !data.Speed5000.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-ethernet:speed/value-5000", data.getPath()))
+ if !data.TrustDevice.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/trust/device", data.getPath()))
}
- if !data.Speed2500.IsNull() && !data.Speed2500.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-ethernet:speed/value-2500", data.getPath()))
+ if !data.AutoQosVoipTrust.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-switch:auto/qos/voip/trust", data.getPath()))
}
- if !data.Speed1000.IsNull() && !data.Speed1000.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-ethernet:speed/value-1000", data.getPath()))
+ if !data.AutoQosVoipCiscoSoftphone.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-switch:auto/qos/voip/cisco-softphone", data.getPath()))
}
- if !data.Speed100.IsNull() && !data.Speed100.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-ethernet:speed/value-100", data.getPath()))
+ if !data.AutoQosVoipCiscoPhone.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-switch:auto/qos/voip/cisco-phone", data.getPath()))
}
- if !data.IpDhcpSnoopingTrust.IsNull() && !data.IpDhcpSnoopingTrust.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/ip/dhcp/Cisco-IOS-XE-dhcp:snooping/trust", data.getPath()))
+ if !data.AutoQosVoip.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-switch:auto/qos/voip", data.getPath()))
}
- if !data.IpArpInspectionTrust.IsNull() && !data.IpArpInspectionTrust.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/ip/arp/inspection/trust", data.getPath()))
+ if !data.AutoQosVideoMediaPlayer.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-switch:auto/qos/video/media-player", data.getPath()))
}
- if !data.SpanningTreePortfastEdge.IsNull() && !data.SpanningTreePortfastEdge.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-spanning-tree:spanning-tree/portfast/edge", data.getPath()))
+ if !data.AutoQosVideoIpCamera.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-switch:auto/qos/video/ip-camera", data.getPath()))
}
- if !data.SpanningTreePortfastTrunk.IsNull() && !data.SpanningTreePortfastTrunk.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-spanning-tree:spanning-tree/portfast/trunk", data.getPath()))
+ if !data.AutoQosVideoCts.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-switch:auto/qos/video/cts", data.getPath()))
}
- if !data.SpanningTreePortfastDisable.IsNull() && !data.SpanningTreePortfastDisable.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-spanning-tree:spanning-tree/portfast/disable", data.getPath()))
+ if !data.AutoQosTrustDscp.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-switch:auto/qos/trust/dscp", data.getPath()))
}
- if !data.SpanningTreePortfast.IsNull() && !data.SpanningTreePortfast.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-spanning-tree:spanning-tree/portfast", data.getPath()))
+ if !data.AutoQosTrustCos.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-switch:auto/qos/trust/cos", data.getPath()))
}
- if !data.BpduguardDisable.IsNull() && !data.BpduguardDisable.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-spanning-tree:spanning-tree/bpduguard/disable", data.getPath()))
+ if !data.AutoQosTrust.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-switch:auto/qos/trust", data.getPath()))
}
- if !data.BpduguardEnable.IsNull() && !data.BpduguardEnable.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-spanning-tree:spanning-tree/bpduguard/enable", data.getPath()))
+ if !data.AutoQosClassifyPolice.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-switch:auto/qos/classify/police", data.getPath()))
}
-
- for i := range data.Ipv6Addresses {
- keyValues := [...]string{data.Ipv6Addresses[i].Prefix.ValueString()}
- if !data.Ipv6Addresses[i].Eui64.IsNull() && !data.Ipv6Addresses[i].Eui64.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/ipv6/address/prefix-list=%v/eui-64", data.getPath(), strings.Join(keyValues[:], ",")))
- }
+ if !data.AutoQosClassify.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-switch:auto/qos/classify", data.getPath()))
}
-
- for i := range data.Ipv6LinkLocalAddresses {
- keyValues := [...]string{data.Ipv6LinkLocalAddresses[i].Address.ValueString()}
- if !data.Ipv6LinkLocalAddresses[i].LinkLocal.IsNull() && !data.Ipv6LinkLocalAddresses[i].LinkLocal.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/ipv6/address/link-local-address=%v/link-local", data.getPath(), strings.Join(keyValues[:], ",")))
- }
+ if !data.SpanningTreeGuard.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-spanning-tree:spanning-tree/guard", data.getPath()))
}
- if !data.Ipv6AddressDhcp.IsNull() && !data.Ipv6AddressDhcp.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/ipv6/address/dhcp", data.getPath()))
+ if !data.IpAccessGroupOut.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/access-group/out/acl", data.getPath()))
}
- if !data.Ipv6AddressAutoconfigDefault.IsNull() && !data.Ipv6AddressAutoconfigDefault.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/ipv6/address/autoconfig/default", data.getPath()))
+ if !data.IpAccessGroupOutEnable.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/access-group/out/acl/out", data.getPath()))
}
- if !data.Ipv6NdRaSuppressAll.IsNull() && !data.Ipv6NdRaSuppressAll.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/ipv6/nd/Cisco-IOS-XE-nd:ra/suppress/all", data.getPath()))
+ if !data.IpAccessGroupIn.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/access-group/in/acl", data.getPath()))
}
- if !data.Ipv6Enable.IsNull() && !data.Ipv6Enable.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/ipv6/enable", data.getPath()))
+ if !data.IpAccessGroupInEnable.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/access-group/in/acl/in", data.getPath()))
}
-
- for i := range data.SourceTemplate {
- keyValues := [...]string{data.SourceTemplate[i].TemplateName.ValueString()}
- if !data.SourceTemplate[i].Merge.IsNull() && !data.SourceTemplate[i].Merge.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/source/template/template-name=%v/merge", data.getPath(), strings.Join(keyValues[:], ",")))
- }
+ if !data.IpDhcpRelaySourceInterface.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/dhcp/Cisco-IOS-XE-dhcp:relay/source-interface", data.getPath()))
}
-
- for i := range data.HelperAddresses {
- keyValues := [...]string{data.HelperAddresses[i].Address.ValueString()}
- if !data.HelperAddresses[i].Global.IsNull() && !data.HelperAddresses[i].Global.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/ip/helper-address=%v/global", data.getPath(), strings.Join(keyValues[:], ",")))
- }
+ if !data.ChannelGroupMode.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-ethernet:channel-group", data.getPath()))
}
- if !data.AutoQosVoipTrust.IsNull() && !data.AutoQosVoipTrust.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-switch:auto/qos/voip/trust", data.getPath()))
+ if !data.ChannelGroupNumber.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-ethernet:channel-group", data.getPath()))
}
- if !data.AutoQosVoipCiscoSoftphone.IsNull() && !data.AutoQosVoipCiscoSoftphone.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-switch:auto/qos/voip/cisco-softphone", data.getPath()))
+ if !data.EncapsulationDot1qVlanId.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/encapsulation/dot1Q/vlan-id", data.getPath()))
}
- if !data.AutoQosVoipCiscoPhone.IsNull() && !data.AutoQosVoipCiscoPhone.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-switch:auto/qos/voip/cisco-phone", data.getPath()))
+ if !data.Unnumbered.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/unnumbered", data.getPath()))
}
- if !data.AutoQosVoip.IsNull() && !data.AutoQosVoip.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-switch:auto/qos/voip", data.getPath()))
+ if !data.Ipv4AddressMask.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/address/primary", data.getPath()))
}
- if !data.AutoQosVideoMediaPlayer.IsNull() && !data.AutoQosVideoMediaPlayer.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-switch:auto/qos/video/media-player", data.getPath()))
+ if !data.Ipv4Address.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/address/primary", data.getPath()))
}
- if !data.AutoQosVideoIpCamera.IsNull() && !data.AutoQosVideoIpCamera.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-switch:auto/qos/video/ip-camera", data.getPath()))
+ if !data.VrfForwarding.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/vrf/forwarding", data.getPath()))
}
- if !data.AutoQosVideoCts.IsNull() && !data.AutoQosVideoCts.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-switch:auto/qos/video/cts", data.getPath()))
+ if !data.IpUnreachables.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/Cisco-IOS-XE-icmp:unreachables", data.getPath()))
}
- if !data.AutoQosTrustDscp.IsNull() && !data.AutoQosTrustDscp.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-switch:auto/qos/trust/dscp", data.getPath()))
+ if !data.IpRedirects.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/redirects", data.getPath()))
}
- if !data.AutoQosTrustCos.IsNull() && !data.AutoQosTrustCos.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-switch:auto/qos/trust/cos", data.getPath()))
+ if !data.IpProxyArp.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/proxy-arp", data.getPath()))
}
- if !data.AutoQosTrust.IsNull() && !data.AutoQosTrust.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-switch:auto/qos/trust", data.getPath()))
+ if !data.Shutdown.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/shutdown", data.getPath()))
}
- if !data.AutoQosClassifyPolice.IsNull() && !data.AutoQosClassifyPolice.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-switch:auto/qos/classify/police", data.getPath()))
+ if !data.Description.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/description", data.getPath()))
}
- if !data.AutoQosClassify.IsNull() && !data.AutoQosClassify.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-switch:auto/qos/classify", data.getPath()))
+ if !data.Switchport.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/switchport-conf/switchport", data.getPath()))
}
- if !data.IpAccessGroupOutEnable.IsNull() && !data.IpAccessGroupOutEnable.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/ip/access-group/out/acl/out", data.getPath()))
+ if !data.Bandwidth.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/bandwidth/kilobits", data.getPath()))
}
- if !data.IpAccessGroupInEnable.IsNull() && !data.IpAccessGroupInEnable.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/ip/access-group/in/acl/in", data.getPath()))
+ if !data.Mtu.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/mtu", data.getPath()))
}
- if !data.Shutdown.IsNull() && !data.Shutdown.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/shutdown", data.getPath()))
+ if !data.MediaType.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/media-type", data.getPath()))
}
- return emptyLeafsDelete
+ return deletePaths
}
-// End of section. //template:end getEmptyLeafsDelete
+// End of section. //template:end getDeletePaths
-// Section below is generated&owned by "gen/generator.go". //template:begin getDeletePaths
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletePathsXML
-func (data *InterfaceEthernet) getDeletePaths(ctx context.Context) []string {
- var deletePaths []string
- if !data.IpNatOutside.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/Cisco-IOS-XE-nat:nat/outside", data.getPath()))
+func (data *InterfaceEthernet) addDeletePathsXML(ctx context.Context, body string) string {
+ b := netconf.NewBody(body)
+ if !data.MediaType.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/media-type")
}
- if !data.IpNatInside.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/Cisco-IOS-XE-nat:nat/inside", data.getPath()))
+ if !data.Mtu.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/mtu")
}
- if !data.CdpTlvServerLocation.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-cdp:cdp/tlv/server-location-config", data.getPath()))
+ if !data.Bandwidth.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/bandwidth/kilobits")
}
- if !data.CdpTlvLocation.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-cdp:cdp/tlv/location-config", data.getPath()))
+ if !data.Switchport.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/switchport-conf/switchport")
}
- if !data.CdpTlvApp.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-cdp:cdp/tlv/default-wrp/app", data.getPath()))
+ if !data.Description.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/description")
}
- if !data.CdpEnable.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-cdp:cdp/enable", data.getPath()))
+ if !data.Shutdown.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/shutdown")
}
- for i := range data.DeviceTrackingAttachedPolicies {
- keyValues := [...]string{data.DeviceTrackingAttachedPolicies[i].Name.ValueString()}
-
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-switch:device-tracking/attached-policies=%v", data.getPath(), strings.Join(keyValues[:], ",")))
+ if !data.IpProxyArp.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ip/proxy-arp")
}
- if !data.DeviceTracking.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-switch:device-tracking", data.getPath()))
+ if !data.IpRedirects.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ip/redirects")
}
- if !data.IpNbarProtocolDiscovery.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/Cisco-IOS-XE-nbar:nbar/protocol-discovery", data.getPath()))
+ if !data.IpUnreachables.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ip/Cisco-IOS-XE-icmp:unreachables")
}
- if !data.LoggingEventLinkStatusEnable.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/logging/event/link-status-enable", data.getPath()))
+ if !data.VrfForwarding.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/vrf/forwarding")
}
- if !data.SnmpTrapLinkStatus.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:snmp/trap/link-status", data.getPath()))
+ if !data.Ipv4Address.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ip/address/primary/address")
}
- if !data.LoadInterval.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/load-interval", data.getPath()))
+ if !data.Ipv4AddressMask.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ip/address/primary/mask")
}
- for i := range data.IpFlowMonitors {
- keyValues := [...]string{data.IpFlowMonitors[i].Name.ValueString(), data.IpFlowMonitors[i].Direction.ValueString()}
-
- deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/Cisco-IOS-XE-flow:flow/monitor-new=%v", data.getPath(), strings.Join(keyValues[:], ",")))
+ if !data.Unnumbered.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ip/unnumbered")
}
- if !data.ServicePolicyOutput.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-policy:service-policy/output", data.getPath()))
+ if !data.EncapsulationDot1qVlanId.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/encapsulation/dot1Q/vlan-id")
}
- if !data.ServicePolicyInput.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-policy:service-policy/input", data.getPath()))
+ if !data.ChannelGroupNumber.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-ethernet:channel-group/number")
}
- if !data.Dot1xMaxReauthReq.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-dot1x:dot1x/max-reauth-req", data.getPath()))
+ if !data.ChannelGroupMode.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-ethernet:channel-group/mode")
}
- if !data.Dot1xMaxReq.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-dot1x:dot1x/max-req", data.getPath()))
+ if !data.IpDhcpRelaySourceInterface.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ip/dhcp/Cisco-IOS-XE-dhcp:relay/source-interface")
}
- if !data.Dot1xTimeoutTxPeriod.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-dot1x:dot1x/timeout/tx-period", data.getPath()))
+ if !data.IpAccessGroupInEnable.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ip/access-group/in/acl/in")
}
- if !data.Dot1xTimeoutSuppTimeout.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-dot1x:dot1x/timeout/supp-timeout", data.getPath()))
+ if !data.IpAccessGroupIn.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ip/access-group/in/acl/acl-name")
}
- if !data.Dot1xTimeoutStartPeriod.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-dot1x:dot1x/timeout/start-period", data.getPath()))
+ if !data.IpAccessGroupOutEnable.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ip/access-group/out/acl/out")
}
- if !data.Dot1xTimeoutServerTimeout.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-dot1x:dot1x/timeout/server-timeout", data.getPath()))
+ if !data.IpAccessGroupOut.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ip/access-group/out/acl/acl-name")
}
- if !data.Dot1xTimeoutRatelimitPeriod.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-dot1x:dot1x/timeout/ratelimit-period", data.getPath()))
+ if !data.SpanningTreeGuard.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-spanning-tree:spanning-tree/guard")
}
- if !data.Dot1xTimeoutQuietPeriod.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-dot1x:dot1x/timeout/quiet-period", data.getPath()))
+ if !data.AutoQosClassify.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/classify")
}
- if !data.Dot1xTimeoutHeldPeriod.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-dot1x:dot1x/timeout/held-period", data.getPath()))
+ if !data.AutoQosClassifyPolice.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/classify/police")
}
- if !data.Dot1xTimeoutAuthPeriod.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-dot1x:dot1x/timeout/auth-period", data.getPath()))
+ if !data.AutoQosTrust.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/trust")
}
- if !data.Dot1xPae.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-dot1x:dot1x/pae", data.getPath()))
+ if !data.AutoQosTrustCos.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/trust/cos")
}
- if !data.MabEap.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-sanet:mab/eap", data.getPath()))
+ if !data.AutoQosTrustDscp.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/trust/dscp")
}
- if !data.Mab.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-sanet:mab", data.getPath()))
+ if !data.AutoQosVideoCts.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/video/cts")
}
- if !data.AuthenticationEventLinksecFailActionNextMethod.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-sanet:authentication/event/linksec/fail/action/next-method", data.getPath()))
+ if !data.AutoQosVideoIpCamera.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/video/ip-camera")
}
- if !data.AuthenticationEventNoResponseActionAuthorizeVlan.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-sanet:authentication/event/no-response/action/authorize/vlan", data.getPath()))
+ if !data.AutoQosVideoMediaPlayer.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/video/media-player")
}
- if !data.AuthenticationEventFailActionNextMethod.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-sanet:authentication/event/fail-config/action/next-method", data.getPath()))
+ if !data.AutoQosVoip.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/voip")
}
- if !data.AuthenticationEventFailActionAuthorizeVlan.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-sanet:authentication/event/fail-config/action/authorize/vlan", data.getPath()))
+ if !data.AutoQosVoipCiscoPhone.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/voip/cisco-phone")
}
- if !data.AuthenticationEventServerDeadActionReinitializeVlan.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-sanet:authentication/event/server/dead/action/reinitialize/vlan", data.getPath()))
+ if !data.AutoQosVoipCiscoSoftphone.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/voip/cisco-softphone")
}
- if !data.AuthenticationEventServerDeadActionAuthorizeVoice.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-sanet:authentication/event/server/dead/action/authorize/voice", data.getPath()))
+ if !data.AutoQosVoipTrust.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/voip/trust")
}
- if !data.AuthenticationEventServerDeadActionAuthorizeVlan.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-sanet:authentication/event/server/dead/action/authorize/vlan", data.getPath()))
+ if !data.TrustDevice.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/trust/device")
}
- if !data.AuthenticationEventServerDeadActionAuthorize.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-sanet:authentication/event/server/dead/action/authorize", data.getPath()))
+ for i := range data.HelperAddresses {
+ keys := [...]string{"address"}
+ keyValues := [...]string{data.HelperAddresses[i].Address.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/ip/helper-address%v", predicates))
}
- if !data.AuthenticationEventServerAliveActionReinitialize.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-sanet:authentication/event/server/alive/action/reinitialize", data.getPath()))
+ for i := range data.SourceTemplate {
+ keys := [...]string{"template-name"}
+ keyValues := [...]string{data.SourceTemplate[i].TemplateName.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/source/template/template-name%v", predicates))
}
- if !data.AuthenticationTimerReauthenticateServer.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-sanet:authentication/timer/reauthenticate/server-config", data.getPath()))
+ if !data.BfdTemplate.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/bfd/Cisco-IOS-XE-bfd:template")
}
- if !data.AuthenticationTimerReauthenticate.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-sanet:authentication/timer/reauthenticate/value-config", data.getPath()))
+ if !data.BfdEnable.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/bfd/Cisco-IOS-XE-bfd:enable")
}
- if !data.AuthenticationPeriodic.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-sanet:authentication/periodic", data.getPath()))
+ if !data.BfdLocalAddress.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/bfd/Cisco-IOS-XE-bfd:local-address")
}
- if !data.AuthenticationPortControl.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-sanet:authentication/port-control", data.getPath()))
+ if !data.BfdInterval.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/bfd/Cisco-IOS-XE-bfd:interval-interface/msecs")
}
- if !data.AuthenticationPriorityWebauth.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-sanet:authentication/priority-config/webauth-config", data.getPath()))
+ if !data.BfdIntervalMinRx.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/bfd/Cisco-IOS-XE-bfd:interval-interface/min_rx")
}
- if !data.AuthenticationPriorityMabWebauth.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-sanet:authentication/priority-config/mab-config/webauth", data.getPath()))
+ if !data.BfdIntervalMultiplier.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/bfd/Cisco-IOS-XE-bfd:interval-interface/multiplier")
}
- if !data.AuthenticationPriorityMabDot1x.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-sanet:authentication/priority-config/mab-config/dot1x", data.getPath()))
+ if !data.BfdEcho.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/bfd/Cisco-IOS-XE-bfd:echo")
}
- if !data.AuthenticationPriorityMab.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-sanet:authentication/priority-config/mab-config", data.getPath()))
+ if !data.Ipv6Enable.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ipv6/enable")
}
- if !data.AuthenticationPriorityDot1xWebauth.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-sanet:authentication/priority-config/dot1x-config/webauth", data.getPath()))
+ if !data.Ipv6Mtu.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ipv6/mtu")
}
- if !data.AuthenticationPriorityDot1xMab.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-sanet:authentication/priority-config/dot1x-config/mab", data.getPath()))
+ if !data.Ipv6NdRaSuppressAll.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ipv6/nd/Cisco-IOS-XE-nd:ra/suppress/all")
}
- if !data.AuthenticationPriorityDot1x.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-sanet:authentication/priority-config/dot1x-config", data.getPath()))
+ if !data.Ipv6AddressAutoconfigDefault.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ipv6/address/autoconfig/default")
}
- if !data.AuthenticationOrderWebauth.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-sanet:authentication/order-config/webauth-config", data.getPath()))
+ if !data.Ipv6AddressDhcp.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ipv6/address/dhcp")
}
- if !data.AuthenticationOrderMabWebauth.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-sanet:authentication/order-config/mab-config/webauth", data.getPath()))
+ for i := range data.Ipv6LinkLocalAddresses {
+ keys := [...]string{"address"}
+ keyValues := [...]string{data.Ipv6LinkLocalAddresses[i].Address.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/ipv6/address/link-local-address%v", predicates))
}
- if !data.AuthenticationOrderMabDot1x.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-sanet:authentication/order-config/mab-config/dot1x", data.getPath()))
+ for i := range data.Ipv6Addresses {
+ keys := [...]string{"prefix"}
+ keyValues := [...]string{data.Ipv6Addresses[i].Prefix.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/ipv6/address/prefix-list%v", predicates))
}
- if !data.AuthenticationOrderMab.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-sanet:authentication/order-config/mab-config", data.getPath()))
+ for i := range data.Ipv6FlowMonitors {
+ keys := [...]string{"name", "direction"}
+ keyValues := [...]string{data.Ipv6FlowMonitors[i].Name.ValueString(), data.Ipv6FlowMonitors[i].Direction.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/ipv6/Cisco-IOS-XE-flow:flow/monitor-new%v", predicates))
}
- if !data.AuthenticationOrderDot1xWebauth.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-sanet:authentication/order-config/dot1x-config/webauth", data.getPath()))
+ if !data.ArpTimeout.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/arp/timeout")
}
- if !data.AuthenticationOrderDot1xMab.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-sanet:authentication/order-config/dot1x-config/mab", data.getPath()))
+ if !data.SpanningTreeLinkType.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-spanning-tree:spanning-tree/link-type")
}
- if !data.AuthenticationOrderDot1x.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-sanet:authentication/order-config/dot1x-config", data.getPath()))
+ if !data.BpduguardEnable.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-spanning-tree:spanning-tree/bpduguard/enable")
}
- if !data.AuthenticationHostMode.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-sanet:authentication/host-mode", data.getPath()))
+ if !data.BpduguardDisable.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-spanning-tree:spanning-tree/bpduguard/disable")
}
- if !data.SpeedNonegotiate.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-ethernet:speed/nonegotiate", data.getPath()))
+ if !data.SpanningTreePortfast.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-spanning-tree:spanning-tree/portfast")
}
- if !data.NegotiationAuto.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-ethernet:negotiation/auto", data.getPath()))
+ if !data.SpanningTreePortfastDisable.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-spanning-tree:spanning-tree/portfast/disable")
}
- if !data.Speed100000.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-ethernet:speed/value-100000", data.getPath()))
+ if !data.SpanningTreePortfastTrunk.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-spanning-tree:spanning-tree/portfast/trunk")
}
- if !data.Speed40000.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-ethernet:speed/value-40000", data.getPath()))
+ if !data.SpanningTreePortfastEdge.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-spanning-tree:spanning-tree/portfast/edge")
}
- if !data.Speed25000.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-ethernet:speed/value-25000", data.getPath()))
+ if !data.IpArpInspectionTrust.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ip/arp/inspection/trust")
}
- if !data.Speed10000.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-ethernet:speed/value-10000", data.getPath()))
+ if !data.IpArpInspectionLimitRate.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ip/arp/inspection/limit/rate")
}
- if !data.Speed5000.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-ethernet:speed/value-5000", data.getPath()))
+ if !data.IpDhcpSnoopingTrust.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ip/dhcp/Cisco-IOS-XE-dhcp:snooping/trust")
}
- if !data.Speed2500.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-ethernet:speed/value-2500", data.getPath()))
+ if !data.Speed100.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-ethernet:speed/value-100")
}
if !data.Speed1000.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-ethernet:speed/value-1000", data.getPath()))
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-ethernet:speed/value-1000")
}
- if !data.Speed100.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-ethernet:speed/value-100", data.getPath()))
+ if !data.Speed2500.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-ethernet:speed/value-2500")
}
- if !data.IpDhcpSnoopingTrust.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/dhcp/Cisco-IOS-XE-dhcp:snooping/trust", data.getPath()))
+ if !data.Speed5000.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-ethernet:speed/value-5000")
}
- if !data.IpArpInspectionLimitRate.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/arp/inspection/limit/rate", data.getPath()))
+ if !data.Speed10000.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-ethernet:speed/value-10000")
}
- if !data.IpArpInspectionTrust.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/arp/inspection/trust", data.getPath()))
+ if !data.Speed25000.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-ethernet:speed/value-25000")
}
- if !data.SpanningTreePortfastEdge.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-spanning-tree:spanning-tree/portfast/edge", data.getPath()))
+ if !data.Speed40000.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-ethernet:speed/value-40000")
}
- if !data.SpanningTreePortfastTrunk.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-spanning-tree:spanning-tree/portfast/trunk", data.getPath()))
+ if !data.Speed100000.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-ethernet:speed/value-100000")
}
- if !data.SpanningTreePortfastDisable.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-spanning-tree:spanning-tree/portfast/disable", data.getPath()))
+ if !data.NegotiationAuto.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-ethernet:negotiation/auto")
}
- if !data.SpanningTreePortfast.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-spanning-tree:spanning-tree/portfast", data.getPath()))
+ if !data.SpeedNonegotiate.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-ethernet:speed/nonegotiate")
}
- if !data.BpduguardDisable.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-spanning-tree:spanning-tree/bpduguard/disable", data.getPath()))
+ if !data.AuthenticationHostMode.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-sanet:authentication/host-mode")
}
- if !data.BpduguardEnable.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-spanning-tree:spanning-tree/bpduguard/enable", data.getPath()))
+ if !data.AuthenticationOrderDot1x.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-sanet:authentication/order-config/dot1x-config")
}
- if !data.SpanningTreeLinkType.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-spanning-tree:spanning-tree/link-type", data.getPath()))
+ if !data.AuthenticationOrderDot1xMab.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-sanet:authentication/order-config/dot1x-config/mab")
}
- if !data.ArpTimeout.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/arp/timeout", data.getPath()))
+ if !data.AuthenticationOrderDot1xWebauth.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-sanet:authentication/order-config/dot1x-config/webauth")
}
- for i := range data.Ipv6FlowMonitors {
- keyValues := [...]string{data.Ipv6FlowMonitors[i].Name.ValueString(), data.Ipv6FlowMonitors[i].Direction.ValueString()}
-
- deletePaths = append(deletePaths, fmt.Sprintf("%v/ipv6/Cisco-IOS-XE-flow:flow/monitor-new=%v", data.getPath(), strings.Join(keyValues[:], ",")))
+ if !data.AuthenticationOrderMab.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-sanet:authentication/order-config/mab-config")
}
- for i := range data.Ipv6Addresses {
- keyValues := [...]string{data.Ipv6Addresses[i].Prefix.ValueString()}
-
- deletePaths = append(deletePaths, fmt.Sprintf("%v/ipv6/address/prefix-list=%v", data.getPath(), strings.Join(keyValues[:], ",")))
+ if !data.AuthenticationOrderMabDot1x.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-sanet:authentication/order-config/mab-config/dot1x")
}
- for i := range data.Ipv6LinkLocalAddresses {
- keyValues := [...]string{data.Ipv6LinkLocalAddresses[i].Address.ValueString()}
-
- deletePaths = append(deletePaths, fmt.Sprintf("%v/ipv6/address/link-local-address=%v", data.getPath(), strings.Join(keyValues[:], ",")))
+ if !data.AuthenticationOrderMabWebauth.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-sanet:authentication/order-config/mab-config/webauth")
}
- if !data.Ipv6AddressDhcp.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/ipv6/address/dhcp", data.getPath()))
+ if !data.AuthenticationOrderWebauth.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-sanet:authentication/order-config/webauth-config")
}
- if !data.Ipv6AddressAutoconfigDefault.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/ipv6/address/autoconfig/default", data.getPath()))
+ if !data.AuthenticationPriorityDot1x.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-sanet:authentication/priority-config/dot1x-config")
}
- if !data.Ipv6NdRaSuppressAll.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/ipv6/nd/Cisco-IOS-XE-nd:ra/suppress/all", data.getPath()))
+ if !data.AuthenticationPriorityDot1xMab.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-sanet:authentication/priority-config/dot1x-config/mab")
}
- if !data.Ipv6Mtu.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/ipv6/mtu", data.getPath()))
+ if !data.AuthenticationPriorityDot1xWebauth.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-sanet:authentication/priority-config/dot1x-config/webauth")
}
- if !data.Ipv6Enable.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/ipv6/enable", data.getPath()))
+ if !data.AuthenticationPriorityMab.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-sanet:authentication/priority-config/mab-config")
}
- if !data.BfdEcho.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/bfd/Cisco-IOS-XE-bfd:echo", data.getPath()))
+ if !data.AuthenticationPriorityMabDot1x.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-sanet:authentication/priority-config/mab-config/dot1x")
}
- if !data.BfdIntervalMultiplier.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/bfd/Cisco-IOS-XE-bfd:interval-interface", data.getPath()))
+ if !data.AuthenticationPriorityMabWebauth.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-sanet:authentication/priority-config/mab-config/webauth")
}
- if !data.BfdIntervalMinRx.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/bfd/Cisco-IOS-XE-bfd:interval-interface", data.getPath()))
+ if !data.AuthenticationPriorityWebauth.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-sanet:authentication/priority-config/webauth-config")
}
- if !data.BfdInterval.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/bfd/Cisco-IOS-XE-bfd:interval-interface", data.getPath()))
+ if !data.AuthenticationPortControl.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-sanet:authentication/port-control")
}
- if !data.BfdLocalAddress.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/bfd/Cisco-IOS-XE-bfd:local-address", data.getPath()))
+ if !data.AuthenticationPeriodic.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-sanet:authentication/periodic")
}
- if !data.BfdEnable.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/bfd/Cisco-IOS-XE-bfd:enable", data.getPath()))
+ if !data.AuthenticationTimerReauthenticate.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-sanet:authentication/timer/reauthenticate/value-config")
}
- if !data.BfdTemplate.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/bfd/Cisco-IOS-XE-bfd:template", data.getPath()))
+ if !data.AuthenticationTimerReauthenticateServer.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-sanet:authentication/timer/reauthenticate/server-config")
}
- for i := range data.SourceTemplate {
- keyValues := [...]string{data.SourceTemplate[i].TemplateName.ValueString()}
-
- deletePaths = append(deletePaths, fmt.Sprintf("%v/source/template/template-name=%v", data.getPath(), strings.Join(keyValues[:], ",")))
+ if !data.AuthenticationEventServerAliveActionReinitialize.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-sanet:authentication/event/server/alive/action/reinitialize")
}
- for i := range data.HelperAddresses {
- keyValues := [...]string{data.HelperAddresses[i].Address.ValueString()}
-
- deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/helper-address=%v", data.getPath(), strings.Join(keyValues[:], ",")))
+ if !data.AuthenticationEventServerDeadActionAuthorize.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-sanet:authentication/event/server/dead/action/authorize")
}
- if !data.TrustDevice.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/trust/device", data.getPath()))
+ if !data.AuthenticationEventServerDeadActionAuthorizeVlan.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-sanet:authentication/event/server/dead/action/authorize/vlan")
}
- if !data.AutoQosVoipTrust.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-switch:auto/qos/voip/trust", data.getPath()))
+ if !data.AuthenticationEventServerDeadActionAuthorizeVoice.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-sanet:authentication/event/server/dead/action/authorize/voice")
}
- if !data.AutoQosVoipCiscoSoftphone.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-switch:auto/qos/voip/cisco-softphone", data.getPath()))
+ if !data.AuthenticationEventServerDeadActionReinitializeVlan.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-sanet:authentication/event/server/dead/action/reinitialize/vlan")
}
- if !data.AutoQosVoipCiscoPhone.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-switch:auto/qos/voip/cisco-phone", data.getPath()))
+ if !data.AuthenticationEventFailActionAuthorizeVlan.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-sanet:authentication/event/fail-config/action/authorize/vlan")
}
- if !data.AutoQosVoip.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-switch:auto/qos/voip", data.getPath()))
+ if !data.AuthenticationEventFailActionNextMethod.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-sanet:authentication/event/fail-config/action/next-method")
}
- if !data.AutoQosVideoMediaPlayer.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-switch:auto/qos/video/media-player", data.getPath()))
+ if !data.AuthenticationEventNoResponseActionAuthorizeVlan.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-sanet:authentication/event/no-response/action/authorize/vlan")
}
- if !data.AutoQosVideoIpCamera.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-switch:auto/qos/video/ip-camera", data.getPath()))
+ if !data.AuthenticationEventLinksecFailActionNextMethod.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-sanet:authentication/event/linksec/fail/action/next-method")
}
- if !data.AutoQosVideoCts.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-switch:auto/qos/video/cts", data.getPath()))
+ if !data.Mab.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-sanet:mab")
}
- if !data.AutoQosTrustDscp.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-switch:auto/qos/trust/dscp", data.getPath()))
+ if !data.MabEap.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-sanet:mab/eap")
}
- if !data.AutoQosTrustCos.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-switch:auto/qos/trust/cos", data.getPath()))
+ if !data.Dot1xPae.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-dot1x:dot1x/pae")
}
- if !data.AutoQosTrust.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-switch:auto/qos/trust", data.getPath()))
+ if !data.Dot1xTimeoutAuthPeriod.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-dot1x:dot1x/timeout/auth-period")
}
- if !data.AutoQosClassifyPolice.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-switch:auto/qos/classify/police", data.getPath()))
+ if !data.Dot1xTimeoutHeldPeriod.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-dot1x:dot1x/timeout/held-period")
}
- if !data.AutoQosClassify.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-switch:auto/qos/classify", data.getPath()))
+ if !data.Dot1xTimeoutQuietPeriod.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-dot1x:dot1x/timeout/quiet-period")
}
- if !data.SpanningTreeGuard.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-spanning-tree:spanning-tree/guard", data.getPath()))
+ if !data.Dot1xTimeoutRatelimitPeriod.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-dot1x:dot1x/timeout/ratelimit-period")
}
- if !data.IpAccessGroupOut.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/access-group/out/acl", data.getPath()))
+ if !data.Dot1xTimeoutServerTimeout.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-dot1x:dot1x/timeout/server-timeout")
}
- if !data.IpAccessGroupOutEnable.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/access-group/out/acl/out", data.getPath()))
+ if !data.Dot1xTimeoutStartPeriod.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-dot1x:dot1x/timeout/start-period")
}
- if !data.IpAccessGroupIn.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/access-group/in/acl", data.getPath()))
+ if !data.Dot1xTimeoutSuppTimeout.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-dot1x:dot1x/timeout/supp-timeout")
}
- if !data.IpAccessGroupInEnable.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/access-group/in/acl/in", data.getPath()))
+ if !data.Dot1xTimeoutTxPeriod.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-dot1x:dot1x/timeout/tx-period")
}
- if !data.IpDhcpRelaySourceInterface.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/dhcp/Cisco-IOS-XE-dhcp:relay/source-interface", data.getPath()))
+ if !data.Dot1xMaxReq.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-dot1x:dot1x/max-req")
}
- if !data.ChannelGroupMode.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-ethernet:channel-group", data.getPath()))
+ if !data.Dot1xMaxReauthReq.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-dot1x:dot1x/max-reauth-req")
}
- if !data.ChannelGroupNumber.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-ethernet:channel-group", data.getPath()))
+ if !data.ServicePolicyInput.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-policy:service-policy/input")
}
- if !data.EncapsulationDot1qVlanId.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/encapsulation/dot1Q/vlan-id", data.getPath()))
+ if !data.ServicePolicyOutput.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-policy:service-policy/output")
}
- if !data.Unnumbered.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/unnumbered", data.getPath()))
+ for i := range data.IpFlowMonitors {
+ keys := [...]string{"name", "direction"}
+ keyValues := [...]string{data.IpFlowMonitors[i].Name.ValueString(), data.IpFlowMonitors[i].Direction.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/ip/Cisco-IOS-XE-flow:flow/monitor-new%v", predicates))
}
- if !data.Ipv4AddressMask.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/address/primary", data.getPath()))
+ if !data.LoadInterval.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/load-interval")
}
- if !data.Ipv4Address.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/address/primary", data.getPath()))
+ if !data.SnmpTrapLinkStatus.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:snmp/trap/link-status")
}
- if !data.VrfForwarding.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/vrf/forwarding", data.getPath()))
+ if !data.LoggingEventLinkStatusEnable.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/logging/event/link-status-enable")
}
- if !data.IpUnreachables.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/Cisco-IOS-XE-icmp:unreachables", data.getPath()))
+ if !data.IpNbarProtocolDiscovery.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ip/Cisco-IOS-XE-nbar:nbar/protocol-discovery")
}
- if !data.IpRedirects.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/redirects", data.getPath()))
+ if !data.DeviceTracking.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-switch:device-tracking")
}
- if !data.IpProxyArp.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/proxy-arp", data.getPath()))
+ for i := range data.DeviceTrackingAttachedPolicies {
+ keys := [...]string{"attach-policy"}
+ keyValues := [...]string{data.DeviceTrackingAttachedPolicies[i].Name.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/Cisco-IOS-XE-switch:device-tracking/attached-policies%v", predicates))
}
- if !data.Shutdown.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/shutdown", data.getPath()))
+ if !data.CdpEnable.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-cdp:cdp/enable")
}
- if !data.Description.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/description", data.getPath()))
+ if !data.CdpTlvApp.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-cdp:cdp/tlv/default-wrp/app")
}
- if !data.Switchport.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/switchport-conf/switchport", data.getPath()))
+ if !data.CdpTlvLocation.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-cdp:cdp/tlv/location-config")
}
- if !data.Bandwidth.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/bandwidth/kilobits", data.getPath()))
+ if !data.CdpTlvServerLocation.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-cdp:cdp/tlv/server-location-config")
}
- if !data.Mtu.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/mtu", data.getPath()))
+ if !data.IpNatInside.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ip/Cisco-IOS-XE-nat:nat/inside")
}
- if !data.MediaType.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/media-type", data.getPath()))
+ if !data.IpNatOutside.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ip/Cisco-IOS-XE-nat:nat/outside")
}
- return deletePaths
+ return b.Res()
}
-// End of section. //template:end getDeletePaths
+// End of section. //template:end addDeletePathsXML
diff --git a/internal/provider/model_iosxe_interface_loopback.go b/internal/provider/model_iosxe_interface_loopback.go
index ab513101..8d2ebe48 100644
--- a/internal/provider/model_iosxe_interface_loopback.go
+++ b/internal/provider/model_iosxe_interface_loopback.go
@@ -31,6 +31,9 @@ import (
"github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/types"
+ "github.com/hashicorp/terraform-plugin-log/tflog"
+ "github.com/netascode/go-netconf"
+ "github.com/netascode/xmldot"
"github.com/tidwall/gjson"
"github.com/tidwall/sjson"
)
@@ -122,6 +125,19 @@ func (data InterfaceLoopback) getPathShort() string {
return matches[1]
}
+// getXPath returns the XPath for NETCONF operations
+func (data InterfaceLoopback) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/interface/Loopback[name=%v]"
+ path = fmt.Sprintf(path, fmt.Sprintf("%v", data.Name.ValueInt64()))
+ return path
+}
+
+func (data InterfaceLoopbackData) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/interface/Loopback[name=%v]"
+ path = fmt.Sprintf(path, fmt.Sprintf("%v", data.Name.ValueInt64()))
+ return path
+}
+
// End of section. //template:end getPath
// Section below is generated&owned by "gen/generator.go". //template:begin toBody
@@ -230,6 +246,136 @@ func (data InterfaceLoopback) toBody(ctx context.Context) string {
// End of section. //template:end toBody
+// Section below is generated&owned by "gen/generator.go". //template:begin toBodyXML
+
+func (data InterfaceLoopback) toBodyXML(ctx context.Context) string {
+ body := netconf.Body{}
+ if !data.Name.IsNull() && !data.Name.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/name", strconv.FormatInt(data.Name.ValueInt64(), 10))
+ }
+ if !data.Description.IsNull() && !data.Description.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/description", data.Description.ValueString())
+ }
+ if !data.Shutdown.IsNull() && !data.Shutdown.IsUnknown() {
+ if data.Shutdown.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/shutdown", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/shutdown")
+ }
+ }
+ if !data.IpProxyArp.IsNull() && !data.IpProxyArp.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ip/proxy-arp", data.IpProxyArp.ValueBool())
+ }
+ if !data.IpRedirects.IsNull() && !data.IpRedirects.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ip/redirects", data.IpRedirects.ValueBool())
+ }
+ if !data.IpUnreachables.IsNull() && !data.IpUnreachables.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ip/Cisco-IOS-XE-icmp:unreachables", data.IpUnreachables.ValueBool())
+ }
+ if !data.VrfForwarding.IsNull() && !data.VrfForwarding.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/vrf/forwarding", data.VrfForwarding.ValueString())
+ }
+ if !data.Ipv4Address.IsNull() && !data.Ipv4Address.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ip/address/primary/address", data.Ipv4Address.ValueString())
+ }
+ if !data.Ipv4AddressMask.IsNull() && !data.Ipv4AddressMask.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ip/address/primary/mask", data.Ipv4AddressMask.ValueString())
+ }
+ if !data.IpAccessGroupInEnable.IsNull() && !data.IpAccessGroupInEnable.IsUnknown() {
+ if data.IpAccessGroupInEnable.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ip/access-group/in/acl/in", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/ip/access-group/in/acl/in")
+ }
+ }
+ if !data.IpAccessGroupIn.IsNull() && !data.IpAccessGroupIn.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ip/access-group/in/acl/acl-name", data.IpAccessGroupIn.ValueString())
+ }
+ if !data.IpAccessGroupOutEnable.IsNull() && !data.IpAccessGroupOutEnable.IsUnknown() {
+ if data.IpAccessGroupOutEnable.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ip/access-group/out/acl/out", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/ip/access-group/out/acl/out")
+ }
+ }
+ if !data.IpAccessGroupOut.IsNull() && !data.IpAccessGroupOut.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ip/access-group/out/acl/acl-name", data.IpAccessGroupOut.ValueString())
+ }
+ if !data.Ipv6Enable.IsNull() && !data.Ipv6Enable.IsUnknown() {
+ if data.Ipv6Enable.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ipv6/enable", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/ipv6/enable")
+ }
+ }
+ if !data.Ipv6Mtu.IsNull() && !data.Ipv6Mtu.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ipv6/mtu", strconv.FormatInt(data.Ipv6Mtu.ValueInt64(), 10))
+ }
+ if !data.Ipv6NdRaSuppressAll.IsNull() && !data.Ipv6NdRaSuppressAll.IsUnknown() {
+ if data.Ipv6NdRaSuppressAll.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ipv6/nd/Cisco-IOS-XE-nd:ra/suppress/all", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/ipv6/nd/Cisco-IOS-XE-nd:ra/suppress/all")
+ }
+ }
+ if !data.Ipv6AddressAutoconfigDefault.IsNull() && !data.Ipv6AddressAutoconfigDefault.IsUnknown() {
+ if data.Ipv6AddressAutoconfigDefault.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ipv6/address/autoconfig/default", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/ipv6/address/autoconfig/default")
+ }
+ }
+ if !data.Ipv6AddressDhcp.IsNull() && !data.Ipv6AddressDhcp.IsUnknown() {
+ if data.Ipv6AddressDhcp.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ipv6/address/dhcp", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/ipv6/address/dhcp")
+ }
+ }
+ if len(data.Ipv6LinkLocalAddresses) > 0 {
+ for _, item := range data.Ipv6LinkLocalAddresses {
+ cBody := netconf.Body{}
+ if !item.Address.IsNull() && !item.Address.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "address", item.Address.ValueString())
+ }
+ if !item.LinkLocal.IsNull() && !item.LinkLocal.IsUnknown() {
+ if item.LinkLocal.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "link-local", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "link-local")
+ }
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/ipv6/address/link-local-address", cBody.Res())
+ }
+ }
+ if len(data.Ipv6Addresses) > 0 {
+ for _, item := range data.Ipv6Addresses {
+ cBody := netconf.Body{}
+ if !item.Prefix.IsNull() && !item.Prefix.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "prefix", item.Prefix.ValueString())
+ }
+ if !item.Eui64.IsNull() && !item.Eui64.IsUnknown() {
+ if item.Eui64.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "eui-64", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "eui-64")
+ }
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/ipv6/address/prefix-list", cBody.Res())
+ }
+ }
+ if !data.ArpTimeout.IsNull() && !data.ArpTimeout.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/arp/timeout", strconv.FormatInt(data.ArpTimeout.ValueInt64(), 10))
+ }
+ bodyString, err := body.String()
+ if err != nil {
+ tflog.Error(ctx, fmt.Sprintf("Error converting body to string: %s", err))
+ }
+ return bodyString
+}
+
+// End of section. //template:end toBodyXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBody
func (data *InterfaceLoopback) updateFromBody(ctx context.Context, res gjson.Result) {
@@ -431,107 +577,549 @@ func (data *InterfaceLoopback) updateFromBody(ctx context.Context, res gjson.Res
if value.Exists() {
data.Ipv6Addresses[i].Eui64 = types.BoolValue(true)
} else {
- data.Ipv6Addresses[i].Eui64 = types.BoolValue(false)
+ data.Ipv6Addresses[i].Eui64 = types.BoolValue(false)
+ }
+ } else {
+ data.Ipv6Addresses[i].Eui64 = types.BoolNull()
+ }
+ }
+ if value := res.Get(prefix + "arp.timeout"); value.Exists() && !data.ArpTimeout.IsNull() {
+ data.ArpTimeout = types.Int64Value(value.Int())
+ } else {
+ data.ArpTimeout = types.Int64Null()
+ }
+}
+
+// End of section. //template:end updateFromBody
+
+// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBodyXML
+
+func (data *InterfaceLoopback) updateFromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/name"); value.Exists() && !data.Name.IsNull() {
+ data.Name = types.Int64Value(value.Int())
+ } else {
+ data.Name = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/description"); value.Exists() && !data.Description.IsNull() {
+ data.Description = types.StringValue(value.String())
+ } else {
+ data.Description = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/shutdown"); !data.Shutdown.IsNull() {
+ if value.Exists() {
+ data.Shutdown = types.BoolValue(true)
+ } else {
+ data.Shutdown = types.BoolValue(false)
+ }
+ } else {
+ data.Shutdown = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/proxy-arp"); !data.IpProxyArp.IsNull() {
+ if value.Exists() {
+ data.IpProxyArp = types.BoolValue(value.Bool())
+ }
+ } else {
+ data.IpProxyArp = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/redirects"); !data.IpRedirects.IsNull() {
+ if value.Exists() {
+ data.IpRedirects = types.BoolValue(value.Bool())
+ }
+ } else {
+ data.IpRedirects = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/Cisco-IOS-XE-icmp:unreachables"); !data.IpUnreachables.IsNull() {
+ if value.Exists() {
+ data.IpUnreachables = types.BoolValue(value.Bool())
+ }
+ } else {
+ data.IpUnreachables = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/vrf/forwarding"); value.Exists() && !data.VrfForwarding.IsNull() {
+ data.VrfForwarding = types.StringValue(value.String())
+ } else {
+ data.VrfForwarding = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/address/primary/address"); value.Exists() && !data.Ipv4Address.IsNull() {
+ data.Ipv4Address = types.StringValue(value.String())
+ } else {
+ data.Ipv4Address = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/address/primary/mask"); value.Exists() && !data.Ipv4AddressMask.IsNull() {
+ data.Ipv4AddressMask = types.StringValue(value.String())
+ } else {
+ data.Ipv4AddressMask = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/access-group/in/acl/in"); !data.IpAccessGroupInEnable.IsNull() {
+ if value.Exists() {
+ data.IpAccessGroupInEnable = types.BoolValue(true)
+ } else {
+ data.IpAccessGroupInEnable = types.BoolValue(false)
+ }
+ } else {
+ data.IpAccessGroupInEnable = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/access-group/in/acl/acl-name"); value.Exists() && !data.IpAccessGroupIn.IsNull() {
+ data.IpAccessGroupIn = types.StringValue(value.String())
+ } else {
+ data.IpAccessGroupIn = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/access-group/out/acl/out"); !data.IpAccessGroupOutEnable.IsNull() {
+ if value.Exists() {
+ data.IpAccessGroupOutEnable = types.BoolValue(true)
+ } else {
+ data.IpAccessGroupOutEnable = types.BoolValue(false)
+ }
+ } else {
+ data.IpAccessGroupOutEnable = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/access-group/out/acl/acl-name"); value.Exists() && !data.IpAccessGroupOut.IsNull() {
+ data.IpAccessGroupOut = types.StringValue(value.String())
+ } else {
+ data.IpAccessGroupOut = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ipv6/enable"); !data.Ipv6Enable.IsNull() {
+ if value.Exists() {
+ data.Ipv6Enable = types.BoolValue(true)
+ } else {
+ data.Ipv6Enable = types.BoolValue(false)
+ }
+ } else {
+ data.Ipv6Enable = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ipv6/mtu"); value.Exists() && !data.Ipv6Mtu.IsNull() {
+ data.Ipv6Mtu = types.Int64Value(value.Int())
+ } else {
+ data.Ipv6Mtu = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ipv6/nd/Cisco-IOS-XE-nd:ra/suppress/all"); !data.Ipv6NdRaSuppressAll.IsNull() {
+ if value.Exists() {
+ data.Ipv6NdRaSuppressAll = types.BoolValue(true)
+ } else {
+ data.Ipv6NdRaSuppressAll = types.BoolValue(false)
+ }
+ } else {
+ data.Ipv6NdRaSuppressAll = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ipv6/address/autoconfig/default"); !data.Ipv6AddressAutoconfigDefault.IsNull() {
+ if value.Exists() {
+ data.Ipv6AddressAutoconfigDefault = types.BoolValue(true)
+ } else {
+ data.Ipv6AddressAutoconfigDefault = types.BoolValue(false)
+ }
+ } else {
+ data.Ipv6AddressAutoconfigDefault = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ipv6/address/dhcp"); !data.Ipv6AddressDhcp.IsNull() {
+ if value.Exists() {
+ data.Ipv6AddressDhcp = types.BoolValue(true)
+ } else {
+ data.Ipv6AddressDhcp = types.BoolValue(false)
+ }
+ } else {
+ data.Ipv6AddressDhcp = types.BoolNull()
+ }
+ for i := range data.Ipv6LinkLocalAddresses {
+ keys := [...]string{"address"}
+ keyValues := [...]string{data.Ipv6LinkLocalAddresses[i].Address.ValueString()}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ipv6/address/link-local-address").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, "address"); value.Exists() && !data.Ipv6LinkLocalAddresses[i].Address.IsNull() {
+ data.Ipv6LinkLocalAddresses[i].Address = types.StringValue(value.String())
+ } else {
+ data.Ipv6LinkLocalAddresses[i].Address = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "link-local"); !data.Ipv6LinkLocalAddresses[i].LinkLocal.IsNull() {
+ if value.Exists() {
+ data.Ipv6LinkLocalAddresses[i].LinkLocal = types.BoolValue(true)
+ } else {
+ data.Ipv6LinkLocalAddresses[i].LinkLocal = types.BoolValue(false)
+ }
+ } else {
+ data.Ipv6LinkLocalAddresses[i].LinkLocal = types.BoolNull()
+ }
+ }
+ for i := range data.Ipv6Addresses {
+ keys := [...]string{"prefix"}
+ keyValues := [...]string{data.Ipv6Addresses[i].Prefix.ValueString()}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ipv6/address/prefix-list").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, "prefix"); value.Exists() && !data.Ipv6Addresses[i].Prefix.IsNull() {
+ data.Ipv6Addresses[i].Prefix = types.StringValue(value.String())
+ } else {
+ data.Ipv6Addresses[i].Prefix = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "eui-64"); !data.Ipv6Addresses[i].Eui64.IsNull() {
+ if value.Exists() {
+ data.Ipv6Addresses[i].Eui64 = types.BoolValue(true)
+ } else {
+ data.Ipv6Addresses[i].Eui64 = types.BoolValue(false)
+ }
+ } else {
+ data.Ipv6Addresses[i].Eui64 = types.BoolNull()
+ }
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/arp/timeout"); value.Exists() && !data.ArpTimeout.IsNull() {
+ data.ArpTimeout = types.Int64Value(value.Int())
+ } else {
+ data.ArpTimeout = types.Int64Null()
+ }
+}
+
+// End of section. //template:end updateFromBodyXML
+
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBody
+
+func (data *InterfaceLoopback) fromBody(ctx context.Context, res gjson.Result) {
+ prefix := helpers.LastElement(data.getPath()) + "."
+ if res.Get(helpers.LastElement(data.getPath())).IsArray() {
+ prefix += "0."
+ }
+ if value := res.Get(prefix + "description"); value.Exists() {
+ data.Description = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "shutdown"); value.Exists() {
+ data.Shutdown = types.BoolValue(true)
+ } else {
+ data.Shutdown = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "ip.proxy-arp"); value.Exists() {
+ data.IpProxyArp = types.BoolValue(value.Bool())
+ } else {
+ data.IpProxyArp = types.BoolNull()
+ }
+ if value := res.Get(prefix + "ip.redirects"); value.Exists() {
+ data.IpRedirects = types.BoolValue(value.Bool())
+ } else {
+ data.IpRedirects = types.BoolNull()
+ }
+ if value := res.Get(prefix + "ip.Cisco-IOS-XE-icmp:unreachables"); value.Exists() {
+ data.IpUnreachables = types.BoolValue(value.Bool())
+ } else {
+ data.IpUnreachables = types.BoolNull()
+ }
+ if value := res.Get(prefix + "vrf.forwarding"); value.Exists() {
+ data.VrfForwarding = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "ip.address.primary.address"); value.Exists() {
+ data.Ipv4Address = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "ip.address.primary.mask"); value.Exists() {
+ data.Ipv4AddressMask = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "ip.access-group.in.acl.in"); value.Exists() {
+ data.IpAccessGroupInEnable = types.BoolValue(true)
+ } else {
+ data.IpAccessGroupInEnable = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "ip.access-group.in.acl.acl-name"); value.Exists() {
+ data.IpAccessGroupIn = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "ip.access-group.out.acl.out"); value.Exists() {
+ data.IpAccessGroupOutEnable = types.BoolValue(true)
+ } else {
+ data.IpAccessGroupOutEnable = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "ip.access-group.out.acl.acl-name"); value.Exists() {
+ data.IpAccessGroupOut = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "ipv6.enable"); value.Exists() {
+ data.Ipv6Enable = types.BoolValue(true)
+ } else {
+ data.Ipv6Enable = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "ipv6.mtu"); value.Exists() {
+ data.Ipv6Mtu = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "ipv6.nd.Cisco-IOS-XE-nd:ra.suppress.all"); value.Exists() {
+ data.Ipv6NdRaSuppressAll = types.BoolValue(true)
+ } else {
+ data.Ipv6NdRaSuppressAll = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "ipv6.address.autoconfig.default"); value.Exists() {
+ data.Ipv6AddressAutoconfigDefault = types.BoolValue(true)
+ } else {
+ data.Ipv6AddressAutoconfigDefault = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "ipv6.address.dhcp"); value.Exists() {
+ data.Ipv6AddressDhcp = types.BoolValue(true)
+ } else {
+ data.Ipv6AddressDhcp = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "ipv6.address.link-local-address"); value.Exists() {
+ data.Ipv6LinkLocalAddresses = make([]InterfaceLoopbackIpv6LinkLocalAddresses, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := InterfaceLoopbackIpv6LinkLocalAddresses{}
+ if cValue := v.Get("address"); cValue.Exists() {
+ item.Address = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("link-local"); cValue.Exists() {
+ item.LinkLocal = types.BoolValue(true)
+ } else {
+ item.LinkLocal = types.BoolValue(false)
+ }
+ data.Ipv6LinkLocalAddresses = append(data.Ipv6LinkLocalAddresses, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + "ipv6.address.prefix-list"); value.Exists() {
+ data.Ipv6Addresses = make([]InterfaceLoopbackIpv6Addresses, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := InterfaceLoopbackIpv6Addresses{}
+ if cValue := v.Get("prefix"); cValue.Exists() {
+ item.Prefix = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("eui-64"); cValue.Exists() {
+ item.Eui64 = types.BoolValue(true)
+ } else {
+ item.Eui64 = types.BoolValue(false)
+ }
+ data.Ipv6Addresses = append(data.Ipv6Addresses, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + "arp.timeout"); value.Exists() {
+ data.ArpTimeout = types.Int64Value(value.Int())
+ }
+}
+
+// End of section. //template:end fromBody
+
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyData
+
+func (data *InterfaceLoopbackData) fromBody(ctx context.Context, res gjson.Result) {
+ prefix := helpers.LastElement(data.getPath()) + "."
+ if res.Get(helpers.LastElement(data.getPath())).IsArray() {
+ prefix += "0."
+ }
+ if value := res.Get(prefix + "description"); value.Exists() {
+ data.Description = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "shutdown"); value.Exists() {
+ data.Shutdown = types.BoolValue(true)
+ } else {
+ data.Shutdown = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "ip.proxy-arp"); value.Exists() {
+ data.IpProxyArp = types.BoolValue(value.Bool())
+ } else {
+ data.IpProxyArp = types.BoolNull()
+ }
+ if value := res.Get(prefix + "ip.redirects"); value.Exists() {
+ data.IpRedirects = types.BoolValue(value.Bool())
+ } else {
+ data.IpRedirects = types.BoolNull()
+ }
+ if value := res.Get(prefix + "ip.Cisco-IOS-XE-icmp:unreachables"); value.Exists() {
+ data.IpUnreachables = types.BoolValue(value.Bool())
+ } else {
+ data.IpUnreachables = types.BoolNull()
+ }
+ if value := res.Get(prefix + "vrf.forwarding"); value.Exists() {
+ data.VrfForwarding = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "ip.address.primary.address"); value.Exists() {
+ data.Ipv4Address = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "ip.address.primary.mask"); value.Exists() {
+ data.Ipv4AddressMask = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "ip.access-group.in.acl.in"); value.Exists() {
+ data.IpAccessGroupInEnable = types.BoolValue(true)
+ } else {
+ data.IpAccessGroupInEnable = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "ip.access-group.in.acl.acl-name"); value.Exists() {
+ data.IpAccessGroupIn = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "ip.access-group.out.acl.out"); value.Exists() {
+ data.IpAccessGroupOutEnable = types.BoolValue(true)
+ } else {
+ data.IpAccessGroupOutEnable = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "ip.access-group.out.acl.acl-name"); value.Exists() {
+ data.IpAccessGroupOut = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "ipv6.enable"); value.Exists() {
+ data.Ipv6Enable = types.BoolValue(true)
+ } else {
+ data.Ipv6Enable = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "ipv6.mtu"); value.Exists() {
+ data.Ipv6Mtu = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "ipv6.nd.Cisco-IOS-XE-nd:ra.suppress.all"); value.Exists() {
+ data.Ipv6NdRaSuppressAll = types.BoolValue(true)
+ } else {
+ data.Ipv6NdRaSuppressAll = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "ipv6.address.autoconfig.default"); value.Exists() {
+ data.Ipv6AddressAutoconfigDefault = types.BoolValue(true)
+ } else {
+ data.Ipv6AddressAutoconfigDefault = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "ipv6.address.dhcp"); value.Exists() {
+ data.Ipv6AddressDhcp = types.BoolValue(true)
+ } else {
+ data.Ipv6AddressDhcp = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "ipv6.address.link-local-address"); value.Exists() {
+ data.Ipv6LinkLocalAddresses = make([]InterfaceLoopbackIpv6LinkLocalAddresses, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := InterfaceLoopbackIpv6LinkLocalAddresses{}
+ if cValue := v.Get("address"); cValue.Exists() {
+ item.Address = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("link-local"); cValue.Exists() {
+ item.LinkLocal = types.BoolValue(true)
+ } else {
+ item.LinkLocal = types.BoolValue(false)
}
- } else {
- data.Ipv6Addresses[i].Eui64 = types.BoolNull()
- }
+ data.Ipv6LinkLocalAddresses = append(data.Ipv6LinkLocalAddresses, item)
+ return true
+ })
}
- if value := res.Get(prefix + "arp.timeout"); value.Exists() && !data.ArpTimeout.IsNull() {
+ if value := res.Get(prefix + "ipv6.address.prefix-list"); value.Exists() {
+ data.Ipv6Addresses = make([]InterfaceLoopbackIpv6Addresses, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := InterfaceLoopbackIpv6Addresses{}
+ if cValue := v.Get("prefix"); cValue.Exists() {
+ item.Prefix = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("eui-64"); cValue.Exists() {
+ item.Eui64 = types.BoolValue(true)
+ } else {
+ item.Eui64 = types.BoolValue(false)
+ }
+ data.Ipv6Addresses = append(data.Ipv6Addresses, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + "arp.timeout"); value.Exists() {
data.ArpTimeout = types.Int64Value(value.Int())
- } else {
- data.ArpTimeout = types.Int64Null()
}
}
-// End of section. //template:end updateFromBody
+// End of section. //template:end fromBodyData
-// Section below is generated&owned by "gen/generator.go". //template:begin fromBody
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyXML
-func (data *InterfaceLoopback) fromBody(ctx context.Context, res gjson.Result) {
- prefix := helpers.LastElement(data.getPath()) + "."
- if res.Get(helpers.LastElement(data.getPath())).IsArray() {
- prefix += "0."
- }
- if value := res.Get(prefix + "description"); value.Exists() {
+func (data *InterfaceLoopback) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/description"); value.Exists() {
data.Description = types.StringValue(value.String())
}
- if value := res.Get(prefix + "shutdown"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/shutdown"); value.Exists() {
data.Shutdown = types.BoolValue(true)
} else {
data.Shutdown = types.BoolValue(false)
}
- if value := res.Get(prefix + "ip.proxy-arp"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/proxy-arp"); value.Exists() {
data.IpProxyArp = types.BoolValue(value.Bool())
} else {
data.IpProxyArp = types.BoolNull()
}
- if value := res.Get(prefix + "ip.redirects"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/redirects"); value.Exists() {
data.IpRedirects = types.BoolValue(value.Bool())
} else {
data.IpRedirects = types.BoolNull()
}
- if value := res.Get(prefix + "ip.Cisco-IOS-XE-icmp:unreachables"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/Cisco-IOS-XE-icmp:unreachables"); value.Exists() {
data.IpUnreachables = types.BoolValue(value.Bool())
} else {
data.IpUnreachables = types.BoolNull()
}
- if value := res.Get(prefix + "vrf.forwarding"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/vrf/forwarding"); value.Exists() {
data.VrfForwarding = types.StringValue(value.String())
}
- if value := res.Get(prefix + "ip.address.primary.address"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/address/primary/address"); value.Exists() {
data.Ipv4Address = types.StringValue(value.String())
}
- if value := res.Get(prefix + "ip.address.primary.mask"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/address/primary/mask"); value.Exists() {
data.Ipv4AddressMask = types.StringValue(value.String())
}
- if value := res.Get(prefix + "ip.access-group.in.acl.in"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/access-group/in/acl/in"); value.Exists() {
data.IpAccessGroupInEnable = types.BoolValue(true)
} else {
data.IpAccessGroupInEnable = types.BoolValue(false)
}
- if value := res.Get(prefix + "ip.access-group.in.acl.acl-name"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/access-group/in/acl/acl-name"); value.Exists() {
data.IpAccessGroupIn = types.StringValue(value.String())
}
- if value := res.Get(prefix + "ip.access-group.out.acl.out"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/access-group/out/acl/out"); value.Exists() {
data.IpAccessGroupOutEnable = types.BoolValue(true)
} else {
data.IpAccessGroupOutEnable = types.BoolValue(false)
}
- if value := res.Get(prefix + "ip.access-group.out.acl.acl-name"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/access-group/out/acl/acl-name"); value.Exists() {
data.IpAccessGroupOut = types.StringValue(value.String())
}
- if value := res.Get(prefix + "ipv6.enable"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ipv6/enable"); value.Exists() {
data.Ipv6Enable = types.BoolValue(true)
} else {
data.Ipv6Enable = types.BoolValue(false)
}
- if value := res.Get(prefix + "ipv6.mtu"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ipv6/mtu"); value.Exists() {
data.Ipv6Mtu = types.Int64Value(value.Int())
}
- if value := res.Get(prefix + "ipv6.nd.Cisco-IOS-XE-nd:ra.suppress.all"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ipv6/nd/Cisco-IOS-XE-nd:ra/suppress/all"); value.Exists() {
data.Ipv6NdRaSuppressAll = types.BoolValue(true)
} else {
data.Ipv6NdRaSuppressAll = types.BoolValue(false)
}
- if value := res.Get(prefix + "ipv6.address.autoconfig.default"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ipv6/address/autoconfig/default"); value.Exists() {
data.Ipv6AddressAutoconfigDefault = types.BoolValue(true)
} else {
data.Ipv6AddressAutoconfigDefault = types.BoolValue(false)
}
- if value := res.Get(prefix + "ipv6.address.dhcp"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ipv6/address/dhcp"); value.Exists() {
data.Ipv6AddressDhcp = types.BoolValue(true)
} else {
data.Ipv6AddressDhcp = types.BoolValue(false)
}
- if value := res.Get(prefix + "ipv6.address.link-local-address"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ipv6/address/link-local-address"); value.Exists() {
data.Ipv6LinkLocalAddresses = make([]InterfaceLoopbackIpv6LinkLocalAddresses, 0)
- value.ForEach(func(k, v gjson.Result) bool {
+ value.ForEach(func(_ int, v xmldot.Result) bool {
item := InterfaceLoopbackIpv6LinkLocalAddresses{}
- if cValue := v.Get("address"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "address"); cValue.Exists() {
item.Address = types.StringValue(cValue.String())
}
- if cValue := v.Get("link-local"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "link-local"); cValue.Exists() {
item.LinkLocal = types.BoolValue(true)
} else {
item.LinkLocal = types.BoolValue(false)
@@ -540,14 +1128,14 @@ func (data *InterfaceLoopback) fromBody(ctx context.Context, res gjson.Result) {
return true
})
}
- if value := res.Get(prefix + "ipv6.address.prefix-list"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ipv6/address/prefix-list"); value.Exists() {
data.Ipv6Addresses = make([]InterfaceLoopbackIpv6Addresses, 0)
- value.ForEach(func(k, v gjson.Result) bool {
+ value.ForEach(func(_ int, v xmldot.Result) bool {
item := InterfaceLoopbackIpv6Addresses{}
- if cValue := v.Get("prefix"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "prefix"); cValue.Exists() {
item.Prefix = types.StringValue(cValue.String())
}
- if cValue := v.Get("eui-64"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "eui-64"); cValue.Exists() {
item.Eui64 = types.BoolValue(true)
} else {
item.Eui64 = types.BoolValue(false)
@@ -556,99 +1144,95 @@ func (data *InterfaceLoopback) fromBody(ctx context.Context, res gjson.Result) {
return true
})
}
- if value := res.Get(prefix + "arp.timeout"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/arp/timeout"); value.Exists() {
data.ArpTimeout = types.Int64Value(value.Int())
}
}
-// End of section. //template:end fromBody
+// End of section. //template:end fromBodyXML
-// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyData
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyDataXML
-func (data *InterfaceLoopbackData) fromBody(ctx context.Context, res gjson.Result) {
- prefix := helpers.LastElement(data.getPath()) + "."
- if res.Get(helpers.LastElement(data.getPath())).IsArray() {
- prefix += "0."
- }
- if value := res.Get(prefix + "description"); value.Exists() {
+func (data *InterfaceLoopbackData) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/description"); value.Exists() {
data.Description = types.StringValue(value.String())
}
- if value := res.Get(prefix + "shutdown"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/shutdown"); value.Exists() {
data.Shutdown = types.BoolValue(true)
} else {
data.Shutdown = types.BoolValue(false)
}
- if value := res.Get(prefix + "ip.proxy-arp"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/proxy-arp"); value.Exists() {
data.IpProxyArp = types.BoolValue(value.Bool())
} else {
data.IpProxyArp = types.BoolNull()
}
- if value := res.Get(prefix + "ip.redirects"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/redirects"); value.Exists() {
data.IpRedirects = types.BoolValue(value.Bool())
} else {
data.IpRedirects = types.BoolNull()
}
- if value := res.Get(prefix + "ip.Cisco-IOS-XE-icmp:unreachables"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/Cisco-IOS-XE-icmp:unreachables"); value.Exists() {
data.IpUnreachables = types.BoolValue(value.Bool())
} else {
data.IpUnreachables = types.BoolNull()
}
- if value := res.Get(prefix + "vrf.forwarding"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/vrf/forwarding"); value.Exists() {
data.VrfForwarding = types.StringValue(value.String())
}
- if value := res.Get(prefix + "ip.address.primary.address"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/address/primary/address"); value.Exists() {
data.Ipv4Address = types.StringValue(value.String())
}
- if value := res.Get(prefix + "ip.address.primary.mask"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/address/primary/mask"); value.Exists() {
data.Ipv4AddressMask = types.StringValue(value.String())
}
- if value := res.Get(prefix + "ip.access-group.in.acl.in"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/access-group/in/acl/in"); value.Exists() {
data.IpAccessGroupInEnable = types.BoolValue(true)
} else {
data.IpAccessGroupInEnable = types.BoolValue(false)
}
- if value := res.Get(prefix + "ip.access-group.in.acl.acl-name"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/access-group/in/acl/acl-name"); value.Exists() {
data.IpAccessGroupIn = types.StringValue(value.String())
}
- if value := res.Get(prefix + "ip.access-group.out.acl.out"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/access-group/out/acl/out"); value.Exists() {
data.IpAccessGroupOutEnable = types.BoolValue(true)
} else {
data.IpAccessGroupOutEnable = types.BoolValue(false)
}
- if value := res.Get(prefix + "ip.access-group.out.acl.acl-name"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/access-group/out/acl/acl-name"); value.Exists() {
data.IpAccessGroupOut = types.StringValue(value.String())
}
- if value := res.Get(prefix + "ipv6.enable"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ipv6/enable"); value.Exists() {
data.Ipv6Enable = types.BoolValue(true)
} else {
data.Ipv6Enable = types.BoolValue(false)
}
- if value := res.Get(prefix + "ipv6.mtu"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ipv6/mtu"); value.Exists() {
data.Ipv6Mtu = types.Int64Value(value.Int())
}
- if value := res.Get(prefix + "ipv6.nd.Cisco-IOS-XE-nd:ra.suppress.all"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ipv6/nd/Cisco-IOS-XE-nd:ra/suppress/all"); value.Exists() {
data.Ipv6NdRaSuppressAll = types.BoolValue(true)
} else {
data.Ipv6NdRaSuppressAll = types.BoolValue(false)
}
- if value := res.Get(prefix + "ipv6.address.autoconfig.default"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ipv6/address/autoconfig/default"); value.Exists() {
data.Ipv6AddressAutoconfigDefault = types.BoolValue(true)
} else {
data.Ipv6AddressAutoconfigDefault = types.BoolValue(false)
}
- if value := res.Get(prefix + "ipv6.address.dhcp"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ipv6/address/dhcp"); value.Exists() {
data.Ipv6AddressDhcp = types.BoolValue(true)
} else {
data.Ipv6AddressDhcp = types.BoolValue(false)
}
- if value := res.Get(prefix + "ipv6.address.link-local-address"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ipv6/address/link-local-address"); value.Exists() {
data.Ipv6LinkLocalAddresses = make([]InterfaceLoopbackIpv6LinkLocalAddresses, 0)
- value.ForEach(func(k, v gjson.Result) bool {
+ value.ForEach(func(_ int, v xmldot.Result) bool {
item := InterfaceLoopbackIpv6LinkLocalAddresses{}
- if cValue := v.Get("address"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "address"); cValue.Exists() {
item.Address = types.StringValue(cValue.String())
}
- if cValue := v.Get("link-local"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "link-local"); cValue.Exists() {
item.LinkLocal = types.BoolValue(true)
} else {
item.LinkLocal = types.BoolValue(false)
@@ -657,14 +1241,14 @@ func (data *InterfaceLoopbackData) fromBody(ctx context.Context, res gjson.Resul
return true
})
}
- if value := res.Get(prefix + "ipv6.address.prefix-list"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ipv6/address/prefix-list"); value.Exists() {
data.Ipv6Addresses = make([]InterfaceLoopbackIpv6Addresses, 0)
- value.ForEach(func(k, v gjson.Result) bool {
+ value.ForEach(func(_ int, v xmldot.Result) bool {
item := InterfaceLoopbackIpv6Addresses{}
- if cValue := v.Get("prefix"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "prefix"); cValue.Exists() {
item.Prefix = types.StringValue(cValue.String())
}
- if cValue := v.Get("eui-64"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "eui-64"); cValue.Exists() {
item.Eui64 = types.BoolValue(true)
} else {
item.Eui64 = types.BoolValue(false)
@@ -673,12 +1257,12 @@ func (data *InterfaceLoopbackData) fromBody(ctx context.Context, res gjson.Resul
return true
})
}
- if value := res.Get(prefix + "arp.timeout"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/arp/timeout"); value.Exists() {
data.ArpTimeout = types.Int64Value(value.Int())
}
}
-// End of section. //template:end fromBodyData
+// End of section. //template:end fromBodyDataXML
// Section below is generated&owned by "gen/generator.go". //template:begin getDeletedItems
@@ -800,6 +1384,136 @@ func (data *InterfaceLoopback) getDeletedItems(ctx context.Context, state Interf
// End of section. //template:end getDeletedItems
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletedItemsXML
+
+func (data *InterfaceLoopback) addDeletedItemsXML(ctx context.Context, state InterfaceLoopback, body string) string {
+ b := netconf.NewBody(body)
+ if !state.Description.IsNull() && data.Description.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/description")
+ }
+ if !state.Shutdown.IsNull() && data.Shutdown.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/shutdown")
+ }
+ if !state.IpProxyArp.IsNull() && data.IpProxyArp.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ip/proxy-arp")
+ }
+ if !state.IpRedirects.IsNull() && data.IpRedirects.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ip/redirects")
+ }
+ if !state.IpUnreachables.IsNull() && data.IpUnreachables.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ip/Cisco-IOS-XE-icmp:unreachables")
+ }
+ if !state.VrfForwarding.IsNull() && data.VrfForwarding.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/vrf/forwarding")
+ }
+ if !state.Ipv4Address.IsNull() && data.Ipv4Address.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ip/address/primary/address")
+ }
+ if !state.Ipv4AddressMask.IsNull() && data.Ipv4AddressMask.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ip/address/primary/mask")
+ }
+ if !state.IpAccessGroupInEnable.IsNull() && data.IpAccessGroupInEnable.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ip/access-group/in/acl/in")
+ }
+ if !state.IpAccessGroupIn.IsNull() && data.IpAccessGroupIn.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ip/access-group/in/acl/acl-name")
+ }
+ if !state.IpAccessGroupOutEnable.IsNull() && data.IpAccessGroupOutEnable.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ip/access-group/out/acl/out")
+ }
+ if !state.IpAccessGroupOut.IsNull() && data.IpAccessGroupOut.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ip/access-group/out/acl/acl-name")
+ }
+ if !state.Ipv6Enable.IsNull() && data.Ipv6Enable.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ipv6/enable")
+ }
+ if !state.Ipv6Mtu.IsNull() && data.Ipv6Mtu.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ipv6/mtu")
+ }
+ if !state.Ipv6NdRaSuppressAll.IsNull() && data.Ipv6NdRaSuppressAll.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ipv6/nd/Cisco-IOS-XE-nd:ra/suppress/all")
+ }
+ if !state.Ipv6AddressAutoconfigDefault.IsNull() && data.Ipv6AddressAutoconfigDefault.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ipv6/address/autoconfig/default")
+ }
+ if !state.Ipv6AddressDhcp.IsNull() && data.Ipv6AddressDhcp.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ipv6/address/dhcp")
+ }
+ for i := range state.Ipv6LinkLocalAddresses {
+ stateKeys := [...]string{"address"}
+ stateKeyValues := [...]string{state.Ipv6LinkLocalAddresses[i].Address.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.Ipv6LinkLocalAddresses[i].Address.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.Ipv6LinkLocalAddresses {
+ found = true
+ if state.Ipv6LinkLocalAddresses[i].Address.ValueString() != data.Ipv6LinkLocalAddresses[j].Address.ValueString() {
+ found = false
+ }
+ if found {
+ if !state.Ipv6LinkLocalAddresses[i].LinkLocal.IsNull() && data.Ipv6LinkLocalAddresses[j].LinkLocal.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/ipv6/address/link-local-address%v/link-local", predicates))
+ }
+ break
+ }
+ }
+ if !found {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/ipv6/address/link-local-address%v", predicates))
+ }
+ }
+ for i := range state.Ipv6Addresses {
+ stateKeys := [...]string{"prefix"}
+ stateKeyValues := [...]string{state.Ipv6Addresses[i].Prefix.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.Ipv6Addresses[i].Prefix.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.Ipv6Addresses {
+ found = true
+ if state.Ipv6Addresses[i].Prefix.ValueString() != data.Ipv6Addresses[j].Prefix.ValueString() {
+ found = false
+ }
+ if found {
+ if !state.Ipv6Addresses[i].Eui64.IsNull() && data.Ipv6Addresses[j].Eui64.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/ipv6/address/prefix-list%v/eui-64", predicates))
+ }
+ break
+ }
+ }
+ if !found {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/ipv6/address/prefix-list%v", predicates))
+ }
+ }
+ if !state.ArpTimeout.IsNull() && data.ArpTimeout.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/arp/timeout")
+ }
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletedItemsXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin getEmptyLeafsDelete
func (data *InterfaceLoopback) getEmptyLeafsDelete(ctx context.Context) []string {
@@ -918,3 +1632,87 @@ func (data *InterfaceLoopback) getDeletePaths(ctx context.Context) []string {
}
// End of section. //template:end getDeletePaths
+
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletePathsXML
+
+func (data *InterfaceLoopback) addDeletePathsXML(ctx context.Context, body string) string {
+ b := netconf.NewBody(body)
+ if !data.Description.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/description")
+ }
+ if !data.Shutdown.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/shutdown")
+ }
+ if !data.IpProxyArp.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ip/proxy-arp")
+ }
+ if !data.IpRedirects.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ip/redirects")
+ }
+ if !data.IpUnreachables.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ip/Cisco-IOS-XE-icmp:unreachables")
+ }
+ if !data.VrfForwarding.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/vrf/forwarding")
+ }
+ if !data.Ipv4Address.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ip/address/primary/address")
+ }
+ if !data.Ipv4AddressMask.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ip/address/primary/mask")
+ }
+ if !data.IpAccessGroupInEnable.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ip/access-group/in/acl/in")
+ }
+ if !data.IpAccessGroupIn.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ip/access-group/in/acl/acl-name")
+ }
+ if !data.IpAccessGroupOutEnable.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ip/access-group/out/acl/out")
+ }
+ if !data.IpAccessGroupOut.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ip/access-group/out/acl/acl-name")
+ }
+ if !data.Ipv6Enable.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ipv6/enable")
+ }
+ if !data.Ipv6Mtu.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ipv6/mtu")
+ }
+ if !data.Ipv6NdRaSuppressAll.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ipv6/nd/Cisco-IOS-XE-nd:ra/suppress/all")
+ }
+ if !data.Ipv6AddressAutoconfigDefault.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ipv6/address/autoconfig/default")
+ }
+ if !data.Ipv6AddressDhcp.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ipv6/address/dhcp")
+ }
+ for i := range data.Ipv6LinkLocalAddresses {
+ keys := [...]string{"address"}
+ keyValues := [...]string{data.Ipv6LinkLocalAddresses[i].Address.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/ipv6/address/link-local-address%v", predicates))
+ }
+ for i := range data.Ipv6Addresses {
+ keys := [...]string{"prefix"}
+ keyValues := [...]string{data.Ipv6Addresses[i].Prefix.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/ipv6/address/prefix-list%v", predicates))
+ }
+ if !data.ArpTimeout.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/arp/timeout")
+ }
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletePathsXML
diff --git a/internal/provider/model_iosxe_interface_mpls.go b/internal/provider/model_iosxe_interface_mpls.go
index 8b29d7e9..a3e563a6 100644
--- a/internal/provider/model_iosxe_interface_mpls.go
+++ b/internal/provider/model_iosxe_interface_mpls.go
@@ -28,6 +28,9 @@ import (
"github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/types"
+ "github.com/hashicorp/terraform-plugin-log/tflog"
+ "github.com/netascode/go-netconf"
+ "github.com/netascode/xmldot"
"github.com/tidwall/gjson"
"github.com/tidwall/sjson"
)
@@ -77,6 +80,19 @@ func (data InterfaceMPLS) getPathShort() string {
return matches[1]
}
+// getXPath returns the XPath for NETCONF operations
+func (data InterfaceMPLS) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/interface/%s[name=%v]/mpls"
+ path = fmt.Sprintf(path, fmt.Sprintf("%v", data.Type.ValueString()), fmt.Sprintf("%v", data.Name.ValueString()))
+ return path
+}
+
+func (data InterfaceMPLSData) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/interface/%s[name=%v]/mpls"
+ path = fmt.Sprintf(path, fmt.Sprintf("%v", data.Type.ValueString()), fmt.Sprintf("%v", data.Name.ValueString()))
+ return path
+}
+
// End of section. //template:end getPath
// Section below is generated&owned by "gen/generator.go". //template:begin toBody
@@ -96,6 +112,29 @@ func (data InterfaceMPLS) toBody(ctx context.Context) string {
// End of section. //template:end toBody
+// Section below is generated&owned by "gen/generator.go". //template:begin toBodyXML
+
+func (data InterfaceMPLS) toBodyXML(ctx context.Context) string {
+ body := netconf.Body{}
+ if !data.Ip.IsNull() && !data.Ip.IsUnknown() {
+ if data.Ip.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-mpls:ip", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-mpls:ip")
+ }
+ }
+ if !data.Mtu.IsNull() && !data.Mtu.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-mpls:mtu", data.Mtu.ValueString())
+ }
+ bodyString, err := body.String()
+ if err != nil {
+ tflog.Error(ctx, fmt.Sprintf("Error converting body to string: %s", err))
+ }
+ return bodyString
+}
+
+// End of section. //template:end toBodyXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBody
func (data *InterfaceMPLS) updateFromBody(ctx context.Context, res gjson.Result) {
@@ -121,6 +160,27 @@ func (data *InterfaceMPLS) updateFromBody(ctx context.Context, res gjson.Result)
// End of section. //template:end updateFromBody
+// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBodyXML
+
+func (data *InterfaceMPLS) updateFromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-mpls:ip"); !data.Ip.IsNull() {
+ if value.Exists() {
+ data.Ip = types.BoolValue(true)
+ } else {
+ data.Ip = types.BoolValue(false)
+ }
+ } else {
+ data.Ip = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-mpls:mtu"); value.Exists() && !data.Mtu.IsNull() {
+ data.Mtu = types.StringValue(value.String())
+ } else {
+ data.Mtu = types.StringNull()
+ }
+}
+
+// End of section. //template:end updateFromBodyXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin fromBody
func (data *InterfaceMPLS) fromBody(ctx context.Context, res gjson.Result) {
@@ -159,6 +219,36 @@ func (data *InterfaceMPLSData) fromBody(ctx context.Context, res gjson.Result) {
// End of section. //template:end fromBodyData
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyXML
+
+func (data *InterfaceMPLS) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-mpls:ip"); value.Exists() {
+ data.Ip = types.BoolValue(true)
+ } else {
+ data.Ip = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-mpls:mtu"); value.Exists() {
+ data.Mtu = types.StringValue(value.String())
+ }
+}
+
+// End of section. //template:end fromBodyXML
+
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyDataXML
+
+func (data *InterfaceMPLSData) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-mpls:ip"); value.Exists() {
+ data.Ip = types.BoolValue(true)
+ } else {
+ data.Ip = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-mpls:mtu"); value.Exists() {
+ data.Mtu = types.StringValue(value.String())
+ }
+}
+
+// End of section. //template:end fromBodyDataXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin getDeletedItems
func (data *InterfaceMPLS) getDeletedItems(ctx context.Context, state InterfaceMPLS) []string {
@@ -175,6 +265,22 @@ func (data *InterfaceMPLS) getDeletedItems(ctx context.Context, state InterfaceM
// End of section. //template:end getDeletedItems
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletedItemsXML
+
+func (data *InterfaceMPLS) addDeletedItemsXML(ctx context.Context, state InterfaceMPLS, body string) string {
+ b := netconf.NewBody(body)
+ if !state.Ip.IsNull() && data.Ip.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-mpls:ip")
+ }
+ if !state.Mtu.IsNull() && data.Mtu.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-mpls:mtu")
+ }
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletedItemsXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin getEmptyLeafsDelete
func (data *InterfaceMPLS) getEmptyLeafsDelete(ctx context.Context) []string {
@@ -203,3 +309,19 @@ func (data *InterfaceMPLS) getDeletePaths(ctx context.Context) []string {
}
// End of section. //template:end getDeletePaths
+
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletePathsXML
+
+func (data *InterfaceMPLS) addDeletePathsXML(ctx context.Context, body string) string {
+ b := netconf.NewBody(body)
+ if !data.Ip.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-mpls:ip")
+ }
+ if !data.Mtu.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-mpls:mtu")
+ }
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletePathsXML
diff --git a/internal/provider/model_iosxe_interface_nve.go b/internal/provider/model_iosxe_interface_nve.go
index 680514d4..73f0c95f 100644
--- a/internal/provider/model_iosxe_interface_nve.go
+++ b/internal/provider/model_iosxe_interface_nve.go
@@ -31,6 +31,9 @@ import (
"github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/types"
+ "github.com/hashicorp/terraform-plugin-log/tflog"
+ "github.com/netascode/go-netconf"
+ "github.com/netascode/xmldot"
"github.com/tidwall/gjson"
"github.com/tidwall/sjson"
)
@@ -95,6 +98,19 @@ func (data InterfaceNVE) getPathShort() string {
return matches[1]
}
+// getXPath returns the XPath for NETCONF operations
+func (data InterfaceNVE) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/interface/nve[name=%v]"
+ path = fmt.Sprintf(path, fmt.Sprintf("%v", data.Name.ValueInt64()))
+ return path
+}
+
+func (data InterfaceNVEData) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/interface/nve[name=%v]"
+ path = fmt.Sprintf(path, fmt.Sprintf("%v", data.Name.ValueInt64()))
+ return path
+}
+
// End of section. //template:end getPath
// Section below is generated&owned by "gen/generator.go". //template:begin toBody
@@ -152,6 +168,73 @@ func (data InterfaceNVE) toBody(ctx context.Context) string {
// End of section. //template:end toBody
+// Section below is generated&owned by "gen/generator.go". //template:begin toBodyXML
+
+func (data InterfaceNVE) toBodyXML(ctx context.Context) string {
+ body := netconf.Body{}
+ if !data.Name.IsNull() && !data.Name.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/name", strconv.FormatInt(data.Name.ValueInt64(), 10))
+ }
+ if !data.Description.IsNull() && !data.Description.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/description", data.Description.ValueString())
+ }
+ if !data.Shutdown.IsNull() && !data.Shutdown.IsUnknown() {
+ if data.Shutdown.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/shutdown", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/shutdown")
+ }
+ }
+ if !data.HostReachabilityProtocolBgp.IsNull() && !data.HostReachabilityProtocolBgp.IsUnknown() {
+ if data.HostReachabilityProtocolBgp.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/host-reachability/protocol/bgp", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/host-reachability/protocol/bgp")
+ }
+ }
+ if !data.SourceInterfaceLoopback.IsNull() && !data.SourceInterfaceLoopback.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/source-interface/Loopback", strconv.FormatInt(data.SourceInterfaceLoopback.ValueInt64(), 10))
+ }
+ if len(data.VniVrfs) > 0 {
+ for _, item := range data.VniVrfs {
+ cBody := netconf.Body{}
+ if !item.VniRange.IsNull() && !item.VniRange.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "vni-range", item.VniRange.ValueString())
+ }
+ if !item.Vrf.IsNull() && !item.Vrf.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "vrf", item.Vrf.ValueString())
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/member-in-one-line/member/vni", cBody.Res())
+ }
+ }
+ if len(data.Vnis) > 0 {
+ for _, item := range data.Vnis {
+ cBody := netconf.Body{}
+ if !item.VniRange.IsNull() && !item.VniRange.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "vni-range", item.VniRange.ValueString())
+ }
+ if !item.Ipv4MulticastGroup.IsNull() && !item.Ipv4MulticastGroup.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "mcast-group/multicast-group-min", item.Ipv4MulticastGroup.ValueString())
+ }
+ if !item.IngressReplication.IsNull() && !item.IngressReplication.IsUnknown() {
+ if item.IngressReplication.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "ir-cp-config/ingress-replication", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "ir-cp-config/ingress-replication")
+ }
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/member/vni", cBody.Res())
+ }
+ }
+ bodyString, err := body.String()
+ if err != nil {
+ tflog.Error(ctx, fmt.Sprintf("Error converting body to string: %s", err))
+ }
+ return bodyString
+}
+
+// End of section. //template:end toBodyXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBody
func (data *InterfaceNVE) updateFromBody(ctx context.Context, res gjson.Result) {
@@ -273,6 +356,123 @@ func (data *InterfaceNVE) updateFromBody(ctx context.Context, res gjson.Result)
// End of section. //template:end updateFromBody
+// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBodyXML
+
+func (data *InterfaceNVE) updateFromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/name"); value.Exists() && !data.Name.IsNull() {
+ data.Name = types.Int64Value(value.Int())
+ } else {
+ data.Name = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/description"); value.Exists() && !data.Description.IsNull() {
+ data.Description = types.StringValue(value.String())
+ } else {
+ data.Description = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/shutdown"); !data.Shutdown.IsNull() {
+ if value.Exists() {
+ data.Shutdown = types.BoolValue(true)
+ } else {
+ data.Shutdown = types.BoolValue(false)
+ }
+ } else {
+ data.Shutdown = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/host-reachability/protocol/bgp"); !data.HostReachabilityProtocolBgp.IsNull() {
+ if value.Exists() {
+ data.HostReachabilityProtocolBgp = types.BoolValue(true)
+ } else {
+ data.HostReachabilityProtocolBgp = types.BoolValue(false)
+ }
+ } else {
+ data.HostReachabilityProtocolBgp = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/source-interface/Loopback"); value.Exists() && !data.SourceInterfaceLoopback.IsNull() {
+ data.SourceInterfaceLoopback = types.Int64Value(value.Int())
+ } else {
+ data.SourceInterfaceLoopback = types.Int64Null()
+ }
+ for i := range data.VniVrfs {
+ keys := [...]string{"vni-range"}
+ keyValues := [...]string{data.VniVrfs[i].VniRange.ValueString()}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/member-in-one-line/member/vni").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, "vni-range"); value.Exists() && !data.VniVrfs[i].VniRange.IsNull() {
+ data.VniVrfs[i].VniRange = types.StringValue(value.String())
+ } else {
+ data.VniVrfs[i].VniRange = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "vrf"); value.Exists() && !data.VniVrfs[i].Vrf.IsNull() {
+ data.VniVrfs[i].Vrf = types.StringValue(value.String())
+ } else {
+ data.VniVrfs[i].Vrf = types.StringNull()
+ }
+ }
+ for i := range data.Vnis {
+ keys := [...]string{"vni-range"}
+ keyValues := [...]string{data.Vnis[i].VniRange.ValueString()}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/member/vni").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, "vni-range"); value.Exists() && !data.Vnis[i].VniRange.IsNull() {
+ data.Vnis[i].VniRange = types.StringValue(value.String())
+ } else {
+ data.Vnis[i].VniRange = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "mcast-group/multicast-group-min"); value.Exists() && !data.Vnis[i].Ipv4MulticastGroup.IsNull() {
+ data.Vnis[i].Ipv4MulticastGroup = types.StringValue(value.String())
+ } else {
+ data.Vnis[i].Ipv4MulticastGroup = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "ir-cp-config/ingress-replication"); !data.Vnis[i].IngressReplication.IsNull() {
+ if value.Exists() {
+ data.Vnis[i].IngressReplication = types.BoolValue(true)
+ } else {
+ data.Vnis[i].IngressReplication = types.BoolValue(false)
+ }
+ } else {
+ data.Vnis[i].IngressReplication = types.BoolNull()
+ }
+ }
+}
+
+// End of section. //template:end updateFromBodyXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin fromBody
func (data *InterfaceNVE) fromBody(ctx context.Context, res gjson.Result) {
@@ -393,6 +593,118 @@ func (data *InterfaceNVEData) fromBody(ctx context.Context, res gjson.Result) {
// End of section. //template:end fromBodyData
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyXML
+
+func (data *InterfaceNVE) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/description"); value.Exists() {
+ data.Description = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/shutdown"); value.Exists() {
+ data.Shutdown = types.BoolValue(true)
+ } else {
+ data.Shutdown = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/host-reachability/protocol/bgp"); value.Exists() {
+ data.HostReachabilityProtocolBgp = types.BoolValue(true)
+ } else {
+ data.HostReachabilityProtocolBgp = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/source-interface/Loopback"); value.Exists() {
+ data.SourceInterfaceLoopback = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/member-in-one-line/member/vni"); value.Exists() {
+ data.VniVrfs = make([]InterfaceNVEVniVrfs, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := InterfaceNVEVniVrfs{}
+ if cValue := helpers.GetFromXPath(v, "vni-range"); cValue.Exists() {
+ item.VniRange = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "vrf"); cValue.Exists() {
+ item.Vrf = types.StringValue(cValue.String())
+ }
+ data.VniVrfs = append(data.VniVrfs, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/member/vni"); value.Exists() {
+ data.Vnis = make([]InterfaceNVEVnis, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := InterfaceNVEVnis{}
+ if cValue := helpers.GetFromXPath(v, "vni-range"); cValue.Exists() {
+ item.VniRange = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "mcast-group/multicast-group-min"); cValue.Exists() {
+ item.Ipv4MulticastGroup = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "ir-cp-config/ingress-replication"); cValue.Exists() {
+ item.IngressReplication = types.BoolValue(true)
+ } else {
+ item.IngressReplication = types.BoolValue(false)
+ }
+ data.Vnis = append(data.Vnis, item)
+ return true
+ })
+ }
+}
+
+// End of section. //template:end fromBodyXML
+
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyDataXML
+
+func (data *InterfaceNVEData) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/description"); value.Exists() {
+ data.Description = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/shutdown"); value.Exists() {
+ data.Shutdown = types.BoolValue(true)
+ } else {
+ data.Shutdown = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/host-reachability/protocol/bgp"); value.Exists() {
+ data.HostReachabilityProtocolBgp = types.BoolValue(true)
+ } else {
+ data.HostReachabilityProtocolBgp = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/source-interface/Loopback"); value.Exists() {
+ data.SourceInterfaceLoopback = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/member-in-one-line/member/vni"); value.Exists() {
+ data.VniVrfs = make([]InterfaceNVEVniVrfs, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := InterfaceNVEVniVrfs{}
+ if cValue := helpers.GetFromXPath(v, "vni-range"); cValue.Exists() {
+ item.VniRange = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "vrf"); cValue.Exists() {
+ item.Vrf = types.StringValue(cValue.String())
+ }
+ data.VniVrfs = append(data.VniVrfs, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/member/vni"); value.Exists() {
+ data.Vnis = make([]InterfaceNVEVnis, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := InterfaceNVEVnis{}
+ if cValue := helpers.GetFromXPath(v, "vni-range"); cValue.Exists() {
+ item.VniRange = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "mcast-group/multicast-group-min"); cValue.Exists() {
+ item.Ipv4MulticastGroup = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "ir-cp-config/ingress-replication"); cValue.Exists() {
+ item.IngressReplication = types.BoolValue(true)
+ } else {
+ item.IngressReplication = types.BoolValue(false)
+ }
+ data.Vnis = append(data.Vnis, item)
+ return true
+ })
+ }
+}
+
+// End of section. //template:end fromBodyDataXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin getDeletedItems
func (data *InterfaceNVE) getDeletedItems(ctx context.Context, state InterfaceNVE) []string {
@@ -471,6 +783,94 @@ func (data *InterfaceNVE) getDeletedItems(ctx context.Context, state InterfaceNV
// End of section. //template:end getDeletedItems
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletedItemsXML
+
+func (data *InterfaceNVE) addDeletedItemsXML(ctx context.Context, state InterfaceNVE, body string) string {
+ b := netconf.NewBody(body)
+ if !state.Description.IsNull() && data.Description.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/description")
+ }
+ if !state.Shutdown.IsNull() && data.Shutdown.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/shutdown")
+ }
+ if !state.SourceInterfaceLoopback.IsNull() && data.SourceInterfaceLoopback.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/source-interface/Loopback")
+ }
+ for i := range state.VniVrfs {
+ stateKeys := [...]string{"vni-range"}
+ stateKeyValues := [...]string{state.VniVrfs[i].VniRange.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.VniVrfs[i].VniRange.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.VniVrfs {
+ found = true
+ if state.VniVrfs[i].VniRange.ValueString() != data.VniVrfs[j].VniRange.ValueString() {
+ found = false
+ }
+ if found {
+ if !state.VniVrfs[i].Vrf.IsNull() && data.VniVrfs[j].Vrf.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/member-in-one-line/member/vni%v/vrf", predicates))
+ }
+ break
+ }
+ }
+ if !found {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/member-in-one-line/member/vni%v", predicates))
+ }
+ }
+ for i := range state.Vnis {
+ stateKeys := [...]string{"vni-range"}
+ stateKeyValues := [...]string{state.Vnis[i].VniRange.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.Vnis[i].VniRange.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.Vnis {
+ found = true
+ if state.Vnis[i].VniRange.ValueString() != data.Vnis[j].VniRange.ValueString() {
+ found = false
+ }
+ if found {
+ if !state.Vnis[i].Ipv4MulticastGroup.IsNull() && data.Vnis[j].Ipv4MulticastGroup.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/member/vni%v/mcast-group/multicast-group-min", predicates))
+ }
+ if !state.Vnis[i].IngressReplication.IsNull() && data.Vnis[j].IngressReplication.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/member/vni%v/ir-cp-config/ingress-replication", predicates))
+ }
+ break
+ }
+ }
+ if !found {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/member/vni%v", predicates))
+ }
+ }
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletedItemsXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin getEmptyLeafsDelete
func (data *InterfaceNVE) getEmptyLeafsDelete(ctx context.Context) []string {
@@ -523,3 +923,42 @@ func (data *InterfaceNVE) getDeletePaths(ctx context.Context) []string {
}
// End of section. //template:end getDeletePaths
+
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletePathsXML
+
+func (data *InterfaceNVE) addDeletePathsXML(ctx context.Context, body string) string {
+ b := netconf.NewBody(body)
+ if !data.Description.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/description")
+ }
+ if !data.Shutdown.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/shutdown")
+ }
+ if !data.SourceInterfaceLoopback.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/source-interface/Loopback")
+ }
+ for i := range data.VniVrfs {
+ keys := [...]string{"vni-range"}
+ keyValues := [...]string{data.VniVrfs[i].VniRange.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/member-in-one-line/member/vni%v", predicates))
+ }
+ for i := range data.Vnis {
+ keys := [...]string{"vni-range"}
+ keyValues := [...]string{data.Vnis[i].VniRange.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/member/vni%v", predicates))
+ }
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletePathsXML
diff --git a/internal/provider/model_iosxe_interface_ospf.go b/internal/provider/model_iosxe_interface_ospf.go
index 00445af0..5d790c60 100644
--- a/internal/provider/model_iosxe_interface_ospf.go
+++ b/internal/provider/model_iosxe_interface_ospf.go
@@ -31,6 +31,9 @@ import (
"github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/types"
+ "github.com/hashicorp/terraform-plugin-log/tflog"
+ "github.com/netascode/go-netconf"
+ "github.com/netascode/xmldot"
"github.com/tidwall/gjson"
"github.com/tidwall/sjson"
)
@@ -112,6 +115,19 @@ func (data InterfaceOSPF) getPathShort() string {
return matches[1]
}
+// getXPath returns the XPath for NETCONF operations
+func (data InterfaceOSPF) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/interface/%s[name=%v]/ip/Cisco-IOS-XE-ospf:router-ospf/ospf"
+ path = fmt.Sprintf(path, fmt.Sprintf("%v", data.Type.ValueString()), fmt.Sprintf("%v", data.Name.ValueString()))
+ return path
+}
+
+func (data InterfaceOSPFData) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/interface/%s[name=%v]/ip/Cisco-IOS-XE-ospf:router-ospf/ospf"
+ path = fmt.Sprintf(path, fmt.Sprintf("%v", data.Type.ValueString()), fmt.Sprintf("%v", data.Name.ValueString()))
+ return path
+}
+
// End of section. //template:end getPath
// Section below is generated&owned by "gen/generator.go". //template:begin toBody
@@ -191,6 +207,98 @@ func (data InterfaceOSPF) toBody(ctx context.Context) string {
// End of section. //template:end toBody
+// Section below is generated&owned by "gen/generator.go". //template:begin toBodyXML
+
+func (data InterfaceOSPF) toBodyXML(ctx context.Context) string {
+ body := netconf.Body{}
+ if !data.Cost.IsNull() && !data.Cost.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/cost", strconv.FormatInt(data.Cost.ValueInt64(), 10))
+ }
+ if !data.DeadInterval.IsNull() && !data.DeadInterval.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/dead-interval", strconv.FormatInt(data.DeadInterval.ValueInt64(), 10))
+ }
+ if !data.HelloInterval.IsNull() && !data.HelloInterval.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/hello-interval", strconv.FormatInt(data.HelloInterval.ValueInt64(), 10))
+ }
+ if !data.MtuIgnore.IsNull() && !data.MtuIgnore.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/mtu-ignore", data.MtuIgnore.ValueBool())
+ }
+ if !data.NetworkTypeBroadcast.IsNull() && !data.NetworkTypeBroadcast.IsUnknown() {
+ if data.NetworkTypeBroadcast.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/network/broadcast", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/network/broadcast")
+ }
+ }
+ if !data.NetworkTypeNonBroadcast.IsNull() && !data.NetworkTypeNonBroadcast.IsUnknown() {
+ if data.NetworkTypeNonBroadcast.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/network/non-broadcast", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/network/non-broadcast")
+ }
+ }
+ if !data.NetworkTypePointToMultipoint.IsNull() && !data.NetworkTypePointToMultipoint.IsUnknown() {
+ if data.NetworkTypePointToMultipoint.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/network/point-to-multipoint", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/network/point-to-multipoint")
+ }
+ }
+ if !data.NetworkTypePointToPoint.IsNull() && !data.NetworkTypePointToPoint.IsUnknown() {
+ if data.NetworkTypePointToPoint.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/network/point-to-point", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/network/point-to-point")
+ }
+ }
+ if !data.Priority.IsNull() && !data.Priority.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/priority", strconv.FormatInt(data.Priority.ValueInt64(), 10))
+ }
+ if !data.TtlSecurityHops.IsNull() && !data.TtlSecurityHops.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ttl-security/hops", strconv.FormatInt(data.TtlSecurityHops.ValueInt64(), 10))
+ }
+ if len(data.ProcessIds) > 0 {
+ for _, item := range data.ProcessIds {
+ cBody := netconf.Body{}
+ if !item.Id.IsNull() && !item.Id.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "id", strconv.FormatInt(item.Id.ValueInt64(), 10))
+ }
+ if len(item.Areas) > 0 {
+ for _, citem := range item.Areas {
+ ccBody := netconf.Body{}
+ if !citem.AreaId.IsNull() && !citem.AreaId.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "area-id", citem.AreaId.ValueString())
+ }
+ cBody = helpers.SetRawFromXPath(cBody, "area", ccBody.Res())
+ }
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/process-id", cBody.Res())
+ }
+ }
+ if len(data.MessageDigestKeys) > 0 {
+ for _, item := range data.MessageDigestKeys {
+ cBody := netconf.Body{}
+ if !item.Id.IsNull() && !item.Id.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "id", strconv.FormatInt(item.Id.ValueInt64(), 10))
+ }
+ if !item.Md5AuthKey.IsNull() && !item.Md5AuthKey.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "md5/auth-key", item.Md5AuthKey.ValueString())
+ }
+ if !item.Md5AuthType.IsNull() && !item.Md5AuthType.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "md5/auth-type", strconv.FormatInt(item.Md5AuthType.ValueInt64(), 10))
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/message-digest-key", cBody.Res())
+ }
+ }
+ bodyString, err := body.String()
+ if err != nil {
+ tflog.Error(ctx, fmt.Sprintf("Error converting body to string: %s", err))
+ }
+ return bodyString
+}
+
+// End of section. //template:end toBodyXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBody
func (data *InterfaceOSPF) updateFromBody(ctx context.Context, res gjson.Result) {
@@ -357,6 +465,168 @@ func (data *InterfaceOSPF) updateFromBody(ctx context.Context, res gjson.Result)
// End of section. //template:end updateFromBody
+// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBodyXML
+
+func (data *InterfaceOSPF) updateFromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/cost"); value.Exists() && !data.Cost.IsNull() {
+ data.Cost = types.Int64Value(value.Int())
+ } else {
+ data.Cost = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/dead-interval"); value.Exists() && !data.DeadInterval.IsNull() {
+ data.DeadInterval = types.Int64Value(value.Int())
+ } else {
+ data.DeadInterval = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/hello-interval"); value.Exists() && !data.HelloInterval.IsNull() {
+ data.HelloInterval = types.Int64Value(value.Int())
+ } else {
+ data.HelloInterval = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/mtu-ignore"); !data.MtuIgnore.IsNull() {
+ if value.Exists() {
+ data.MtuIgnore = types.BoolValue(value.Bool())
+ }
+ } else {
+ data.MtuIgnore = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/network/broadcast"); !data.NetworkTypeBroadcast.IsNull() {
+ if value.Exists() {
+ data.NetworkTypeBroadcast = types.BoolValue(true)
+ } else {
+ data.NetworkTypeBroadcast = types.BoolValue(false)
+ }
+ } else {
+ data.NetworkTypeBroadcast = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/network/non-broadcast"); !data.NetworkTypeNonBroadcast.IsNull() {
+ if value.Exists() {
+ data.NetworkTypeNonBroadcast = types.BoolValue(true)
+ } else {
+ data.NetworkTypeNonBroadcast = types.BoolValue(false)
+ }
+ } else {
+ data.NetworkTypeNonBroadcast = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/network/point-to-multipoint"); !data.NetworkTypePointToMultipoint.IsNull() {
+ if value.Exists() {
+ data.NetworkTypePointToMultipoint = types.BoolValue(true)
+ } else {
+ data.NetworkTypePointToMultipoint = types.BoolValue(false)
+ }
+ } else {
+ data.NetworkTypePointToMultipoint = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/network/point-to-point"); !data.NetworkTypePointToPoint.IsNull() {
+ if value.Exists() {
+ data.NetworkTypePointToPoint = types.BoolValue(true)
+ } else {
+ data.NetworkTypePointToPoint = types.BoolValue(false)
+ }
+ } else {
+ data.NetworkTypePointToPoint = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/priority"); value.Exists() && !data.Priority.IsNull() {
+ data.Priority = types.Int64Value(value.Int())
+ } else {
+ data.Priority = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ttl-security/hops"); value.Exists() && !data.TtlSecurityHops.IsNull() {
+ data.TtlSecurityHops = types.Int64Value(value.Int())
+ } else {
+ data.TtlSecurityHops = types.Int64Null()
+ }
+ for i := range data.ProcessIds {
+ keys := [...]string{"id"}
+ keyValues := [...]string{strconv.FormatInt(data.ProcessIds[i].Id.ValueInt64(), 10)}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/process-id").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, "id"); value.Exists() && !data.ProcessIds[i].Id.IsNull() {
+ data.ProcessIds[i].Id = types.Int64Value(value.Int())
+ } else {
+ data.ProcessIds[i].Id = types.Int64Null()
+ }
+ for ci := range data.ProcessIds[i].Areas {
+ keys := [...]string{"area-id"}
+ keyValues := [...]string{data.ProcessIds[i].Areas[ci].AreaId.ValueString()}
+
+ var cr xmldot.Result
+ helpers.GetFromXPath(r, "area").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ cr = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(cr, "area-id"); value.Exists() && !data.ProcessIds[i].Areas[ci].AreaId.IsNull() {
+ data.ProcessIds[i].Areas[ci].AreaId = types.StringValue(value.String())
+ } else {
+ data.ProcessIds[i].Areas[ci].AreaId = types.StringNull()
+ }
+ }
+ }
+ for i := range data.MessageDigestKeys {
+ keys := [...]string{"id"}
+ keyValues := [...]string{strconv.FormatInt(data.MessageDigestKeys[i].Id.ValueInt64(), 10)}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/message-digest-key").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, "id"); value.Exists() && !data.MessageDigestKeys[i].Id.IsNull() {
+ data.MessageDigestKeys[i].Id = types.Int64Value(value.Int())
+ } else {
+ data.MessageDigestKeys[i].Id = types.Int64Null()
+ }
+ }
+}
+
+// End of section. //template:end updateFromBodyXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin fromBody
func (data *InterfaceOSPF) fromBody(ctx context.Context, res gjson.Result) {
@@ -537,6 +807,178 @@ func (data *InterfaceOSPFData) fromBody(ctx context.Context, res gjson.Result) {
// End of section. //template:end fromBodyData
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyXML
+
+func (data *InterfaceOSPF) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/cost"); value.Exists() {
+ data.Cost = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/dead-interval"); value.Exists() {
+ data.DeadInterval = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/hello-interval"); value.Exists() {
+ data.HelloInterval = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/mtu-ignore"); value.Exists() {
+ data.MtuIgnore = types.BoolValue(value.Bool())
+ } else {
+ data.MtuIgnore = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/network/broadcast"); value.Exists() {
+ data.NetworkTypeBroadcast = types.BoolValue(true)
+ } else {
+ data.NetworkTypeBroadcast = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/network/non-broadcast"); value.Exists() {
+ data.NetworkTypeNonBroadcast = types.BoolValue(true)
+ } else {
+ data.NetworkTypeNonBroadcast = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/network/point-to-multipoint"); value.Exists() {
+ data.NetworkTypePointToMultipoint = types.BoolValue(true)
+ } else {
+ data.NetworkTypePointToMultipoint = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/network/point-to-point"); value.Exists() {
+ data.NetworkTypePointToPoint = types.BoolValue(true)
+ } else {
+ data.NetworkTypePointToPoint = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/priority"); value.Exists() {
+ data.Priority = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ttl-security/hops"); value.Exists() {
+ data.TtlSecurityHops = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/process-id"); value.Exists() {
+ data.ProcessIds = make([]InterfaceOSPFProcessIds, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := InterfaceOSPFProcessIds{}
+ if cValue := helpers.GetFromXPath(v, "id"); cValue.Exists() {
+ item.Id = types.Int64Value(cValue.Int())
+ }
+ if cValue := helpers.GetFromXPath(v, "area"); cValue.Exists() {
+ item.Areas = make([]InterfaceOSPFProcessIdsAreas, 0)
+ cValue.ForEach(func(_ int, cv xmldot.Result) bool {
+ cItem := InterfaceOSPFProcessIdsAreas{}
+ if ccValue := helpers.GetFromXPath(cv, "area-id"); ccValue.Exists() {
+ cItem.AreaId = types.StringValue(ccValue.String())
+ }
+ item.Areas = append(item.Areas, cItem)
+ return true
+ })
+ }
+ data.ProcessIds = append(data.ProcessIds, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/message-digest-key"); value.Exists() {
+ data.MessageDigestKeys = make([]InterfaceOSPFMessageDigestKeys, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := InterfaceOSPFMessageDigestKeys{}
+ if cValue := helpers.GetFromXPath(v, "id"); cValue.Exists() {
+ item.Id = types.Int64Value(cValue.Int())
+ }
+ if cValue := helpers.GetFromXPath(v, "md5/auth-key"); cValue.Exists() {
+ item.Md5AuthKey = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "md5/auth-type"); cValue.Exists() {
+ item.Md5AuthType = types.Int64Value(cValue.Int())
+ }
+ data.MessageDigestKeys = append(data.MessageDigestKeys, item)
+ return true
+ })
+ }
+}
+
+// End of section. //template:end fromBodyXML
+
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyDataXML
+
+func (data *InterfaceOSPFData) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/cost"); value.Exists() {
+ data.Cost = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/dead-interval"); value.Exists() {
+ data.DeadInterval = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/hello-interval"); value.Exists() {
+ data.HelloInterval = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/mtu-ignore"); value.Exists() {
+ data.MtuIgnore = types.BoolValue(value.Bool())
+ } else {
+ data.MtuIgnore = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/network/broadcast"); value.Exists() {
+ data.NetworkTypeBroadcast = types.BoolValue(true)
+ } else {
+ data.NetworkTypeBroadcast = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/network/non-broadcast"); value.Exists() {
+ data.NetworkTypeNonBroadcast = types.BoolValue(true)
+ } else {
+ data.NetworkTypeNonBroadcast = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/network/point-to-multipoint"); value.Exists() {
+ data.NetworkTypePointToMultipoint = types.BoolValue(true)
+ } else {
+ data.NetworkTypePointToMultipoint = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/network/point-to-point"); value.Exists() {
+ data.NetworkTypePointToPoint = types.BoolValue(true)
+ } else {
+ data.NetworkTypePointToPoint = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/priority"); value.Exists() {
+ data.Priority = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ttl-security/hops"); value.Exists() {
+ data.TtlSecurityHops = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/process-id"); value.Exists() {
+ data.ProcessIds = make([]InterfaceOSPFProcessIds, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := InterfaceOSPFProcessIds{}
+ if cValue := helpers.GetFromXPath(v, "id"); cValue.Exists() {
+ item.Id = types.Int64Value(cValue.Int())
+ }
+ if cValue := helpers.GetFromXPath(v, "area"); cValue.Exists() {
+ item.Areas = make([]InterfaceOSPFProcessIdsAreas, 0)
+ cValue.ForEach(func(_ int, cv xmldot.Result) bool {
+ cItem := InterfaceOSPFProcessIdsAreas{}
+ if ccValue := helpers.GetFromXPath(cv, "area-id"); ccValue.Exists() {
+ cItem.AreaId = types.StringValue(ccValue.String())
+ }
+ item.Areas = append(item.Areas, cItem)
+ return true
+ })
+ }
+ data.ProcessIds = append(data.ProcessIds, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/message-digest-key"); value.Exists() {
+ data.MessageDigestKeys = make([]InterfaceOSPFMessageDigestKeys, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := InterfaceOSPFMessageDigestKeys{}
+ if cValue := helpers.GetFromXPath(v, "id"); cValue.Exists() {
+ item.Id = types.Int64Value(cValue.Int())
+ }
+ if cValue := helpers.GetFromXPath(v, "md5/auth-key"); cValue.Exists() {
+ item.Md5AuthKey = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "md5/auth-type"); cValue.Exists() {
+ item.Md5AuthType = types.Int64Value(cValue.Int())
+ }
+ data.MessageDigestKeys = append(data.MessageDigestKeys, item)
+ return true
+ })
+ }
+}
+
+// End of section. //template:end fromBodyDataXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin getDeletedItems
func (data *InterfaceOSPF) getDeletedItems(ctx context.Context, state InterfaceOSPF) []string {
@@ -655,6 +1097,139 @@ func (data *InterfaceOSPF) getDeletedItems(ctx context.Context, state InterfaceO
// End of section. //template:end getDeletedItems
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletedItemsXML
+
+func (data *InterfaceOSPF) addDeletedItemsXML(ctx context.Context, state InterfaceOSPF, body string) string {
+ b := netconf.NewBody(body)
+ if !state.Cost.IsNull() && data.Cost.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/cost")
+ }
+ if !state.DeadInterval.IsNull() && data.DeadInterval.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/dead-interval")
+ }
+ if !state.HelloInterval.IsNull() && data.HelloInterval.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/hello-interval")
+ }
+ if !state.MtuIgnore.IsNull() && data.MtuIgnore.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/mtu-ignore")
+ }
+ if !state.NetworkTypeBroadcast.IsNull() && data.NetworkTypeBroadcast.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/network/broadcast")
+ }
+ if !state.NetworkTypeNonBroadcast.IsNull() && data.NetworkTypeNonBroadcast.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/network/non-broadcast")
+ }
+ if !state.NetworkTypePointToMultipoint.IsNull() && data.NetworkTypePointToMultipoint.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/network/point-to-multipoint")
+ }
+ if !state.NetworkTypePointToPoint.IsNull() && data.NetworkTypePointToPoint.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/network/point-to-point")
+ }
+ if !state.Priority.IsNull() && data.Priority.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/priority")
+ }
+ if !state.TtlSecurityHops.IsNull() && data.TtlSecurityHops.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ttl-security/hops")
+ }
+ for i := range state.ProcessIds {
+ stateKeys := [...]string{"id"}
+ stateKeyValues := [...]string{strconv.FormatInt(state.ProcessIds[i].Id.ValueInt64(), 10)}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.ProcessIds[i].Id.ValueInt64()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.ProcessIds {
+ found = true
+ if state.ProcessIds[i].Id.ValueInt64() != data.ProcessIds[j].Id.ValueInt64() {
+ found = false
+ }
+ if found {
+ for ci := range state.ProcessIds[i].Areas {
+ cstateKeys := [...]string{"area-id"}
+ cstateKeyValues := [...]string{state.ProcessIds[i].Areas[ci].AreaId.ValueString()}
+ cpredicates := ""
+ for i := range cstateKeys {
+ cpredicates += fmt.Sprintf("[%s='%s']", cstateKeys[i], cstateKeyValues[i])
+ }
+
+ cemptyKeys := true
+ if !reflect.ValueOf(state.ProcessIds[i].Areas[ci].AreaId.ValueString()).IsZero() {
+ cemptyKeys = false
+ }
+ if cemptyKeys {
+ continue
+ }
+
+ found := false
+ for cj := range data.ProcessIds[j].Areas {
+ found = true
+ if state.ProcessIds[i].Areas[ci].AreaId.ValueString() != data.ProcessIds[j].Areas[cj].AreaId.ValueString() {
+ found = false
+ }
+ if found {
+ break
+ }
+ }
+ if !found {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/process-id%v/area%v", predicates, cpredicates))
+ }
+ }
+ break
+ }
+ }
+ if !found {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/process-id%v", predicates))
+ }
+ }
+ for i := range state.MessageDigestKeys {
+ stateKeys := [...]string{"id"}
+ stateKeyValues := [...]string{strconv.FormatInt(state.MessageDigestKeys[i].Id.ValueInt64(), 10)}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.MessageDigestKeys[i].Id.ValueInt64()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.MessageDigestKeys {
+ found = true
+ if state.MessageDigestKeys[i].Id.ValueInt64() != data.MessageDigestKeys[j].Id.ValueInt64() {
+ found = false
+ }
+ if found {
+ if !state.MessageDigestKeys[i].Md5AuthKey.IsNull() && data.MessageDigestKeys[j].Md5AuthKey.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/message-digest-key%v/md5/auth-key", predicates))
+ }
+ break
+ }
+ }
+ if !found {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/message-digest-key%v", predicates))
+ }
+ }
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletedItemsXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin getEmptyLeafsDelete
func (data *InterfaceOSPF) getEmptyLeafsDelete(ctx context.Context) []string {
@@ -727,3 +1302,63 @@ func (data *InterfaceOSPF) getDeletePaths(ctx context.Context) []string {
}
// End of section. //template:end getDeletePaths
+
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletePathsXML
+
+func (data *InterfaceOSPF) addDeletePathsXML(ctx context.Context, body string) string {
+ b := netconf.NewBody(body)
+ if !data.Cost.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/cost")
+ }
+ if !data.DeadInterval.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/dead-interval")
+ }
+ if !data.HelloInterval.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/hello-interval")
+ }
+ if !data.MtuIgnore.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/mtu-ignore")
+ }
+ if !data.NetworkTypeBroadcast.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/network/broadcast")
+ }
+ if !data.NetworkTypeNonBroadcast.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/network/non-broadcast")
+ }
+ if !data.NetworkTypePointToMultipoint.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/network/point-to-multipoint")
+ }
+ if !data.NetworkTypePointToPoint.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/network/point-to-point")
+ }
+ if !data.Priority.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/priority")
+ }
+ if !data.TtlSecurityHops.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ttl-security/hops")
+ }
+ for i := range data.ProcessIds {
+ keys := [...]string{"id"}
+ keyValues := [...]string{strconv.FormatInt(data.ProcessIds[i].Id.ValueInt64(), 10)}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/process-id%v", predicates))
+ }
+ for i := range data.MessageDigestKeys {
+ keys := [...]string{"id"}
+ keyValues := [...]string{strconv.FormatInt(data.MessageDigestKeys[i].Id.ValueInt64(), 10)}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/message-digest-key%v", predicates))
+ }
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletePathsXML
diff --git a/internal/provider/model_iosxe_interface_ospfv3.go b/internal/provider/model_iosxe_interface_ospfv3.go
index 3712e6ec..43b75a23 100644
--- a/internal/provider/model_iosxe_interface_ospfv3.go
+++ b/internal/provider/model_iosxe_interface_ospfv3.go
@@ -29,6 +29,9 @@ import (
"github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/types"
+ "github.com/hashicorp/terraform-plugin-log/tflog"
+ "github.com/netascode/go-netconf"
+ "github.com/netascode/xmldot"
"github.com/tidwall/gjson"
"github.com/tidwall/sjson"
)
@@ -84,6 +87,19 @@ func (data InterfaceOSPFv3) getPathShort() string {
return matches[1]
}
+// getXPath returns the XPath for NETCONF operations
+func (data InterfaceOSPFv3) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/interface/%s[name=%v]/Cisco-IOS-XE-ospfv3:ospfv3"
+ path = fmt.Sprintf(path, fmt.Sprintf("%v", data.Type.ValueString()), fmt.Sprintf("%v", data.Name.ValueString()))
+ return path
+}
+
+func (data InterfaceOSPFv3Data) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/interface/%s[name=%v]/Cisco-IOS-XE-ospfv3:ospfv3"
+ path = fmt.Sprintf(path, fmt.Sprintf("%v", data.Type.ValueString()), fmt.Sprintf("%v", data.Name.ValueString()))
+ return path
+}
+
// End of section. //template:end getPath
// Section below is generated&owned by "gen/generator.go". //template:begin toBody
@@ -118,6 +134,50 @@ func (data InterfaceOSPFv3) toBody(ctx context.Context) string {
// End of section. //template:end toBody
+// Section below is generated&owned by "gen/generator.go". //template:begin toBodyXML
+
+func (data InterfaceOSPFv3) toBodyXML(ctx context.Context) string {
+ body := netconf.Body{}
+ if !data.NetworkTypeBroadcast.IsNull() && !data.NetworkTypeBroadcast.IsUnknown() {
+ if data.NetworkTypeBroadcast.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/network-type/broadcast", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/network-type/broadcast")
+ }
+ }
+ if !data.NetworkTypeNonBroadcast.IsNull() && !data.NetworkTypeNonBroadcast.IsUnknown() {
+ if data.NetworkTypeNonBroadcast.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/network-type/non-broadcast", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/network-type/non-broadcast")
+ }
+ }
+ if !data.NetworkTypePointToMultipoint.IsNull() && !data.NetworkTypePointToMultipoint.IsUnknown() {
+ if data.NetworkTypePointToMultipoint.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/network-type/point-to-multipoint", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/network-type/point-to-multipoint")
+ }
+ }
+ if !data.NetworkTypePointToPoint.IsNull() && !data.NetworkTypePointToPoint.IsUnknown() {
+ if data.NetworkTypePointToPoint.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/network-type/point-to-point", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/network-type/point-to-point")
+ }
+ }
+ if !data.Cost.IsNull() && !data.Cost.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/cost-config/value", strconv.FormatInt(data.Cost.ValueInt64(), 10))
+ }
+ bodyString, err := body.String()
+ if err != nil {
+ tflog.Error(ctx, fmt.Sprintf("Error converting body to string: %s", err))
+ }
+ return bodyString
+}
+
+// End of section. //template:end toBodyXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBody
func (data *InterfaceOSPFv3) updateFromBody(ctx context.Context, res gjson.Result) {
@@ -170,6 +230,54 @@ func (data *InterfaceOSPFv3) updateFromBody(ctx context.Context, res gjson.Resul
// End of section. //template:end updateFromBody
+// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBodyXML
+
+func (data *InterfaceOSPFv3) updateFromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/network-type/broadcast"); !data.NetworkTypeBroadcast.IsNull() {
+ if value.Exists() {
+ data.NetworkTypeBroadcast = types.BoolValue(true)
+ } else {
+ data.NetworkTypeBroadcast = types.BoolValue(false)
+ }
+ } else {
+ data.NetworkTypeBroadcast = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/network-type/non-broadcast"); !data.NetworkTypeNonBroadcast.IsNull() {
+ if value.Exists() {
+ data.NetworkTypeNonBroadcast = types.BoolValue(true)
+ } else {
+ data.NetworkTypeNonBroadcast = types.BoolValue(false)
+ }
+ } else {
+ data.NetworkTypeNonBroadcast = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/network-type/point-to-multipoint"); !data.NetworkTypePointToMultipoint.IsNull() {
+ if value.Exists() {
+ data.NetworkTypePointToMultipoint = types.BoolValue(true)
+ } else {
+ data.NetworkTypePointToMultipoint = types.BoolValue(false)
+ }
+ } else {
+ data.NetworkTypePointToMultipoint = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/network-type/point-to-point"); !data.NetworkTypePointToPoint.IsNull() {
+ if value.Exists() {
+ data.NetworkTypePointToPoint = types.BoolValue(true)
+ } else {
+ data.NetworkTypePointToPoint = types.BoolValue(false)
+ }
+ } else {
+ data.NetworkTypePointToPoint = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/cost-config/value"); value.Exists() && !data.Cost.IsNull() {
+ data.Cost = types.Int64Value(value.Int())
+ } else {
+ data.Cost = types.Int64Null()
+ }
+}
+
+// End of section. //template:end updateFromBodyXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin fromBody
func (data *InterfaceOSPFv3) fromBody(ctx context.Context, res gjson.Result) {
@@ -238,6 +346,66 @@ func (data *InterfaceOSPFv3Data) fromBody(ctx context.Context, res gjson.Result)
// End of section. //template:end fromBodyData
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyXML
+
+func (data *InterfaceOSPFv3) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/network-type/broadcast"); value.Exists() {
+ data.NetworkTypeBroadcast = types.BoolValue(true)
+ } else {
+ data.NetworkTypeBroadcast = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/network-type/non-broadcast"); value.Exists() {
+ data.NetworkTypeNonBroadcast = types.BoolValue(true)
+ } else {
+ data.NetworkTypeNonBroadcast = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/network-type/point-to-multipoint"); value.Exists() {
+ data.NetworkTypePointToMultipoint = types.BoolValue(true)
+ } else {
+ data.NetworkTypePointToMultipoint = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/network-type/point-to-point"); value.Exists() {
+ data.NetworkTypePointToPoint = types.BoolValue(true)
+ } else {
+ data.NetworkTypePointToPoint = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/cost-config/value"); value.Exists() {
+ data.Cost = types.Int64Value(value.Int())
+ }
+}
+
+// End of section. //template:end fromBodyXML
+
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyDataXML
+
+func (data *InterfaceOSPFv3Data) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/network-type/broadcast"); value.Exists() {
+ data.NetworkTypeBroadcast = types.BoolValue(true)
+ } else {
+ data.NetworkTypeBroadcast = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/network-type/non-broadcast"); value.Exists() {
+ data.NetworkTypeNonBroadcast = types.BoolValue(true)
+ } else {
+ data.NetworkTypeNonBroadcast = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/network-type/point-to-multipoint"); value.Exists() {
+ data.NetworkTypePointToMultipoint = types.BoolValue(true)
+ } else {
+ data.NetworkTypePointToMultipoint = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/network-type/point-to-point"); value.Exists() {
+ data.NetworkTypePointToPoint = types.BoolValue(true)
+ } else {
+ data.NetworkTypePointToPoint = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/cost-config/value"); value.Exists() {
+ data.Cost = types.Int64Value(value.Int())
+ }
+}
+
+// End of section. //template:end fromBodyDataXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin getDeletedItems
func (data *InterfaceOSPFv3) getDeletedItems(ctx context.Context, state InterfaceOSPFv3) []string {
@@ -263,6 +431,31 @@ func (data *InterfaceOSPFv3) getDeletedItems(ctx context.Context, state Interfac
// End of section. //template:end getDeletedItems
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletedItemsXML
+
+func (data *InterfaceOSPFv3) addDeletedItemsXML(ctx context.Context, state InterfaceOSPFv3, body string) string {
+ b := netconf.NewBody(body)
+ if !state.NetworkTypeBroadcast.IsNull() && data.NetworkTypeBroadcast.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/network-type/broadcast")
+ }
+ if !state.NetworkTypeNonBroadcast.IsNull() && data.NetworkTypeNonBroadcast.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/network-type/non-broadcast")
+ }
+ if !state.NetworkTypePointToMultipoint.IsNull() && data.NetworkTypePointToMultipoint.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/network-type/point-to-multipoint")
+ }
+ if !state.NetworkTypePointToPoint.IsNull() && data.NetworkTypePointToPoint.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/network-type/point-to-point")
+ }
+ if !state.Cost.IsNull() && data.Cost.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/cost-config/value")
+ }
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletedItemsXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin getEmptyLeafsDelete
func (data *InterfaceOSPFv3) getEmptyLeafsDelete(ctx context.Context) []string {
@@ -309,3 +502,28 @@ func (data *InterfaceOSPFv3) getDeletePaths(ctx context.Context) []string {
}
// End of section. //template:end getDeletePaths
+
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletePathsXML
+
+func (data *InterfaceOSPFv3) addDeletePathsXML(ctx context.Context, body string) string {
+ b := netconf.NewBody(body)
+ if !data.NetworkTypeBroadcast.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/network-type/broadcast")
+ }
+ if !data.NetworkTypeNonBroadcast.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/network-type/non-broadcast")
+ }
+ if !data.NetworkTypePointToMultipoint.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/network-type/point-to-multipoint")
+ }
+ if !data.NetworkTypePointToPoint.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/network-type/point-to-point")
+ }
+ if !data.Cost.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/cost-config/value")
+ }
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletePathsXML
diff --git a/internal/provider/model_iosxe_interface_pim.go b/internal/provider/model_iosxe_interface_pim.go
index b03f95d1..8d83a034 100644
--- a/internal/provider/model_iosxe_interface_pim.go
+++ b/internal/provider/model_iosxe_interface_pim.go
@@ -29,6 +29,9 @@ import (
"github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/types"
+ "github.com/hashicorp/terraform-plugin-log/tflog"
+ "github.com/netascode/go-netconf"
+ "github.com/netascode/xmldot"
"github.com/tidwall/gjson"
"github.com/tidwall/sjson"
)
@@ -89,6 +92,19 @@ func (data InterfacePIM) getPathShort() string {
return matches[1]
}
+// getXPath returns the XPath for NETCONF operations
+func (data InterfacePIM) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/interface/%s[name=%v]/ip/pim"
+ path = fmt.Sprintf(path, fmt.Sprintf("%v", data.Type.ValueString()), fmt.Sprintf("%v", data.Name.ValueString()))
+ return path
+}
+
+func (data InterfacePIMData) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/interface/%s[name=%v]/ip/pim"
+ path = fmt.Sprintf(path, fmt.Sprintf("%v", data.Type.ValueString()), fmt.Sprintf("%v", data.Name.ValueString()))
+ return path
+}
+
// End of section. //template:end getPath
// Section below is generated&owned by "gen/generator.go". //template:begin toBody
@@ -138,6 +154,71 @@ func (data InterfacePIM) toBody(ctx context.Context) string {
// End of section. //template:end toBody
+// Section below is generated&owned by "gen/generator.go". //template:begin toBodyXML
+
+func (data InterfacePIM) toBodyXML(ctx context.Context) string {
+ body := netconf.Body{}
+ if !data.Passive.IsNull() && !data.Passive.IsUnknown() {
+ if data.Passive.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-multicast:pim-mode-choice-cfg/passive", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-multicast:pim-mode-choice-cfg/passive")
+ }
+ }
+ if !data.DenseMode.IsNull() && !data.DenseMode.IsUnknown() {
+ if data.DenseMode.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-multicast:pim-mode-choice-cfg/dense-mode", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-multicast:pim-mode-choice-cfg/dense-mode")
+ }
+ }
+ if !data.SparseMode.IsNull() && !data.SparseMode.IsUnknown() {
+ if data.SparseMode.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-multicast:pim-mode-choice-cfg/sparse-mode", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-multicast:pim-mode-choice-cfg/sparse-mode")
+ }
+ }
+ if !data.SparseDenseMode.IsNull() && !data.SparseDenseMode.IsUnknown() {
+ if data.SparseDenseMode.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-multicast:pim-mode-choice-cfg/sparse-dense-mode", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-multicast:pim-mode-choice-cfg/sparse-dense-mode")
+ }
+ }
+ if !data.Bfd.IsNull() && !data.Bfd.IsUnknown() {
+ if data.Bfd.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-multicast:bfd", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-multicast:bfd")
+ }
+ }
+ if !data.Border.IsNull() && !data.Border.IsUnknown() {
+ if data.Border.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-multicast:border", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-multicast:border")
+ }
+ }
+ if !data.BsrBorder.IsNull() && !data.BsrBorder.IsUnknown() {
+ if data.BsrBorder.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-multicast:bsr-border", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-multicast:bsr-border")
+ }
+ }
+ if !data.DrPriority.IsNull() && !data.DrPriority.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-multicast:dr-priority", strconv.FormatInt(data.DrPriority.ValueInt64(), 10))
+ }
+ bodyString, err := body.String()
+ if err != nil {
+ tflog.Error(ctx, fmt.Sprintf("Error converting body to string: %s", err))
+ }
+ return bodyString
+}
+
+// End of section. //template:end toBodyXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBody
func (data *InterfacePIM) updateFromBody(ctx context.Context, res gjson.Result) {
@@ -217,6 +298,81 @@ func (data *InterfacePIM) updateFromBody(ctx context.Context, res gjson.Result)
// End of section. //template:end updateFromBody
+// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBodyXML
+
+func (data *InterfacePIM) updateFromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-multicast:pim-mode-choice-cfg/passive"); !data.Passive.IsNull() {
+ if value.Exists() {
+ data.Passive = types.BoolValue(true)
+ } else {
+ data.Passive = types.BoolValue(false)
+ }
+ } else {
+ data.Passive = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-multicast:pim-mode-choice-cfg/dense-mode"); !data.DenseMode.IsNull() {
+ if value.Exists() {
+ data.DenseMode = types.BoolValue(true)
+ } else {
+ data.DenseMode = types.BoolValue(false)
+ }
+ } else {
+ data.DenseMode = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-multicast:pim-mode-choice-cfg/sparse-mode"); !data.SparseMode.IsNull() {
+ if value.Exists() {
+ data.SparseMode = types.BoolValue(true)
+ } else {
+ data.SparseMode = types.BoolValue(false)
+ }
+ } else {
+ data.SparseMode = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-multicast:pim-mode-choice-cfg/sparse-dense-mode"); !data.SparseDenseMode.IsNull() {
+ if value.Exists() {
+ data.SparseDenseMode = types.BoolValue(true)
+ } else {
+ data.SparseDenseMode = types.BoolValue(false)
+ }
+ } else {
+ data.SparseDenseMode = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-multicast:bfd"); !data.Bfd.IsNull() {
+ if value.Exists() {
+ data.Bfd = types.BoolValue(true)
+ } else {
+ data.Bfd = types.BoolValue(false)
+ }
+ } else {
+ data.Bfd = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-multicast:border"); !data.Border.IsNull() {
+ if value.Exists() {
+ data.Border = types.BoolValue(true)
+ } else {
+ data.Border = types.BoolValue(false)
+ }
+ } else {
+ data.Border = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-multicast:bsr-border"); !data.BsrBorder.IsNull() {
+ if value.Exists() {
+ data.BsrBorder = types.BoolValue(true)
+ } else {
+ data.BsrBorder = types.BoolValue(false)
+ }
+ } else {
+ data.BsrBorder = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-multicast:dr-priority"); value.Exists() && !data.DrPriority.IsNull() {
+ data.DrPriority = types.Int64Value(value.Int())
+ } else {
+ data.DrPriority = types.Int64Null()
+ }
+}
+
+// End of section. //template:end updateFromBodyXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin fromBody
func (data *InterfacePIM) fromBody(ctx context.Context, res gjson.Result) {
@@ -315,6 +471,96 @@ func (data *InterfacePIMData) fromBody(ctx context.Context, res gjson.Result) {
// End of section. //template:end fromBodyData
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyXML
+
+func (data *InterfacePIM) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-multicast:pim-mode-choice-cfg/passive"); value.Exists() {
+ data.Passive = types.BoolValue(true)
+ } else {
+ data.Passive = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-multicast:pim-mode-choice-cfg/dense-mode"); value.Exists() {
+ data.DenseMode = types.BoolValue(true)
+ } else {
+ data.DenseMode = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-multicast:pim-mode-choice-cfg/sparse-mode"); value.Exists() {
+ data.SparseMode = types.BoolValue(true)
+ } else {
+ data.SparseMode = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-multicast:pim-mode-choice-cfg/sparse-dense-mode"); value.Exists() {
+ data.SparseDenseMode = types.BoolValue(true)
+ } else {
+ data.SparseDenseMode = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-multicast:bfd"); value.Exists() {
+ data.Bfd = types.BoolValue(true)
+ } else {
+ data.Bfd = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-multicast:border"); value.Exists() {
+ data.Border = types.BoolValue(true)
+ } else {
+ data.Border = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-multicast:bsr-border"); value.Exists() {
+ data.BsrBorder = types.BoolValue(true)
+ } else {
+ data.BsrBorder = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-multicast:dr-priority"); value.Exists() {
+ data.DrPriority = types.Int64Value(value.Int())
+ }
+}
+
+// End of section. //template:end fromBodyXML
+
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyDataXML
+
+func (data *InterfacePIMData) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-multicast:pim-mode-choice-cfg/passive"); value.Exists() {
+ data.Passive = types.BoolValue(true)
+ } else {
+ data.Passive = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-multicast:pim-mode-choice-cfg/dense-mode"); value.Exists() {
+ data.DenseMode = types.BoolValue(true)
+ } else {
+ data.DenseMode = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-multicast:pim-mode-choice-cfg/sparse-mode"); value.Exists() {
+ data.SparseMode = types.BoolValue(true)
+ } else {
+ data.SparseMode = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-multicast:pim-mode-choice-cfg/sparse-dense-mode"); value.Exists() {
+ data.SparseDenseMode = types.BoolValue(true)
+ } else {
+ data.SparseDenseMode = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-multicast:bfd"); value.Exists() {
+ data.Bfd = types.BoolValue(true)
+ } else {
+ data.Bfd = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-multicast:border"); value.Exists() {
+ data.Border = types.BoolValue(true)
+ } else {
+ data.Border = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-multicast:bsr-border"); value.Exists() {
+ data.BsrBorder = types.BoolValue(true)
+ } else {
+ data.BsrBorder = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-multicast:dr-priority"); value.Exists() {
+ data.DrPriority = types.Int64Value(value.Int())
+ }
+}
+
+// End of section. //template:end fromBodyDataXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin getDeletedItems
func (data *InterfacePIM) getDeletedItems(ctx context.Context, state InterfacePIM) []string {
@@ -349,6 +595,40 @@ func (data *InterfacePIM) getDeletedItems(ctx context.Context, state InterfacePI
// End of section. //template:end getDeletedItems
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletedItemsXML
+
+func (data *InterfacePIM) addDeletedItemsXML(ctx context.Context, state InterfacePIM, body string) string {
+ b := netconf.NewBody(body)
+ if !state.Passive.IsNull() && data.Passive.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-multicast:pim-mode-choice-cfg/passive")
+ }
+ if !state.DenseMode.IsNull() && data.DenseMode.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-multicast:pim-mode-choice-cfg/dense-mode")
+ }
+ if !state.SparseMode.IsNull() && data.SparseMode.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-multicast:pim-mode-choice-cfg/sparse-mode")
+ }
+ if !state.SparseDenseMode.IsNull() && data.SparseDenseMode.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-multicast:pim-mode-choice-cfg/sparse-dense-mode")
+ }
+ if !state.Bfd.IsNull() && data.Bfd.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-multicast:bfd")
+ }
+ if !state.Border.IsNull() && data.Border.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-multicast:border")
+ }
+ if !state.BsrBorder.IsNull() && data.BsrBorder.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-multicast:bsr-border")
+ }
+ if !state.DrPriority.IsNull() && data.DrPriority.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-multicast:dr-priority")
+ }
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletedItemsXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin getEmptyLeafsDelete
func (data *InterfacePIM) getEmptyLeafsDelete(ctx context.Context) []string {
@@ -413,3 +693,37 @@ func (data *InterfacePIM) getDeletePaths(ctx context.Context) []string {
}
// End of section. //template:end getDeletePaths
+
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletePathsXML
+
+func (data *InterfacePIM) addDeletePathsXML(ctx context.Context, body string) string {
+ b := netconf.NewBody(body)
+ if !data.Passive.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-multicast:pim-mode-choice-cfg/passive")
+ }
+ if !data.DenseMode.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-multicast:pim-mode-choice-cfg/dense-mode")
+ }
+ if !data.SparseMode.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-multicast:pim-mode-choice-cfg/sparse-mode")
+ }
+ if !data.SparseDenseMode.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-multicast:pim-mode-choice-cfg/sparse-dense-mode")
+ }
+ if !data.Bfd.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-multicast:bfd")
+ }
+ if !data.Border.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-multicast:border")
+ }
+ if !data.BsrBorder.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-multicast:bsr-border")
+ }
+ if !data.DrPriority.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-multicast:dr-priority")
+ }
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletePathsXML
diff --git a/internal/provider/model_iosxe_interface_port_channel.go b/internal/provider/model_iosxe_interface_port_channel.go
index 5813727d..69e1b31f 100644
--- a/internal/provider/model_iosxe_interface_port_channel.go
+++ b/internal/provider/model_iosxe_interface_port_channel.go
@@ -31,6 +31,9 @@ import (
"github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/types"
+ "github.com/hashicorp/terraform-plugin-log/tflog"
+ "github.com/netascode/go-netconf"
+ "github.com/netascode/xmldot"
"github.com/tidwall/gjson"
"github.com/tidwall/sjson"
)
@@ -198,6 +201,19 @@ func (data InterfacePortChannel) getPathShort() string {
return matches[1]
}
+// getXPath returns the XPath for NETCONF operations
+func (data InterfacePortChannel) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/interface/Port-channel[name=%v]"
+ path = fmt.Sprintf(path, fmt.Sprintf("%v", data.Name.ValueInt64()))
+ return path
+}
+
+func (data InterfacePortChannelData) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/interface/Port-channel[name=%v]"
+ path = fmt.Sprintf(path, fmt.Sprintf("%v", data.Name.ValueInt64()))
+ return path
+}
+
// End of section. //template:end getPath
// Section below is generated&owned by "gen/generator.go". //template:begin toBody
@@ -456,6 +472,320 @@ func (data InterfacePortChannel) toBody(ctx context.Context) string {
// End of section. //template:end toBody
+// Section below is generated&owned by "gen/generator.go". //template:begin toBodyXML
+
+func (data InterfacePortChannel) toBodyXML(ctx context.Context) string {
+ body := netconf.Body{}
+ if !data.Name.IsNull() && !data.Name.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/name", strconv.FormatInt(data.Name.ValueInt64(), 10))
+ }
+ if !data.Description.IsNull() && !data.Description.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/description", data.Description.ValueString())
+ }
+ if !data.Shutdown.IsNull() && !data.Shutdown.IsUnknown() {
+ if data.Shutdown.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/shutdown", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/shutdown")
+ }
+ }
+ if !data.Switchport.IsNull() && !data.Switchport.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/switchport-conf/switchport", data.Switchport.ValueBool())
+ }
+ if !data.IpProxyArp.IsNull() && !data.IpProxyArp.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ip/proxy-arp", data.IpProxyArp.ValueBool())
+ }
+ if !data.IpRedirects.IsNull() && !data.IpRedirects.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ip/redirects", data.IpRedirects.ValueBool())
+ }
+ if !data.IpUnreachables.IsNull() && !data.IpUnreachables.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ip/Cisco-IOS-XE-icmp:unreachables", data.IpUnreachables.ValueBool())
+ }
+ if !data.VrfForwarding.IsNull() && !data.VrfForwarding.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/vrf/forwarding", data.VrfForwarding.ValueString())
+ }
+ if !data.Ipv4Address.IsNull() && !data.Ipv4Address.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ip/address/primary/address", data.Ipv4Address.ValueString())
+ }
+ if !data.Ipv4AddressMask.IsNull() && !data.Ipv4AddressMask.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ip/address/primary/mask", data.Ipv4AddressMask.ValueString())
+ }
+ if !data.IpAccessGroupInEnable.IsNull() && !data.IpAccessGroupInEnable.IsUnknown() {
+ if data.IpAccessGroupInEnable.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ip/access-group/in/acl/in", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/ip/access-group/in/acl/in")
+ }
+ }
+ if !data.IpAccessGroupIn.IsNull() && !data.IpAccessGroupIn.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ip/access-group/in/acl/acl-name", data.IpAccessGroupIn.ValueString())
+ }
+ if !data.IpAccessGroupOutEnable.IsNull() && !data.IpAccessGroupOutEnable.IsUnknown() {
+ if data.IpAccessGroupOutEnable.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ip/access-group/out/acl/out", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/ip/access-group/out/acl/out")
+ }
+ }
+ if !data.IpAccessGroupOut.IsNull() && !data.IpAccessGroupOut.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ip/access-group/out/acl/acl-name", data.IpAccessGroupOut.ValueString())
+ }
+ if !data.IpDhcpRelaySourceInterface.IsNull() && !data.IpDhcpRelaySourceInterface.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ip/dhcp/Cisco-IOS-XE-dhcp:relay/source-interface", data.IpDhcpRelaySourceInterface.ValueString())
+ }
+ if !data.SpanningTreeGuard.IsNull() && !data.SpanningTreeGuard.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-spanning-tree:spanning-tree/guard", data.SpanningTreeGuard.ValueString())
+ }
+ if !data.AutoQosClassify.IsNull() && !data.AutoQosClassify.IsUnknown() {
+ if data.AutoQosClassify.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/classify", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/classify")
+ }
+ }
+ if !data.AutoQosClassifyPolice.IsNull() && !data.AutoQosClassifyPolice.IsUnknown() {
+ if data.AutoQosClassifyPolice.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/classify/police", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/classify/police")
+ }
+ }
+ if !data.AutoQosTrust.IsNull() && !data.AutoQosTrust.IsUnknown() {
+ if data.AutoQosTrust.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/trust", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/trust")
+ }
+ }
+ if !data.AutoQosTrustCos.IsNull() && !data.AutoQosTrustCos.IsUnknown() {
+ if data.AutoQosTrustCos.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/trust/cos", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/trust/cos")
+ }
+ }
+ if !data.AutoQosTrustDscp.IsNull() && !data.AutoQosTrustDscp.IsUnknown() {
+ if data.AutoQosTrustDscp.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/trust/dscp", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/trust/dscp")
+ }
+ }
+ if !data.AutoQosVideoCts.IsNull() && !data.AutoQosVideoCts.IsUnknown() {
+ if data.AutoQosVideoCts.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/video/cts", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/video/cts")
+ }
+ }
+ if !data.AutoQosVideoIpCamera.IsNull() && !data.AutoQosVideoIpCamera.IsUnknown() {
+ if data.AutoQosVideoIpCamera.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/video/ip-camera", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/video/ip-camera")
+ }
+ }
+ if !data.AutoQosVideoMediaPlayer.IsNull() && !data.AutoQosVideoMediaPlayer.IsUnknown() {
+ if data.AutoQosVideoMediaPlayer.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/video/media-player", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/video/media-player")
+ }
+ }
+ if !data.AutoQosVoip.IsNull() && !data.AutoQosVoip.IsUnknown() {
+ if data.AutoQosVoip.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/voip", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/voip")
+ }
+ }
+ if !data.AutoQosVoipCiscoPhone.IsNull() && !data.AutoQosVoipCiscoPhone.IsUnknown() {
+ if data.AutoQosVoipCiscoPhone.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/voip/cisco-phone", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/voip/cisco-phone")
+ }
+ }
+ if !data.AutoQosVoipCiscoSoftphone.IsNull() && !data.AutoQosVoipCiscoSoftphone.IsUnknown() {
+ if data.AutoQosVoipCiscoSoftphone.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/voip/cisco-softphone", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/voip/cisco-softphone")
+ }
+ }
+ if !data.AutoQosVoipTrust.IsNull() && !data.AutoQosVoipTrust.IsUnknown() {
+ if data.AutoQosVoipTrust.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/voip/trust", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/voip/trust")
+ }
+ }
+ if !data.TrustDevice.IsNull() && !data.TrustDevice.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/trust/device", data.TrustDevice.ValueString())
+ }
+ if len(data.HelperAddresses) > 0 {
+ for _, item := range data.HelperAddresses {
+ cBody := netconf.Body{}
+ if !item.Address.IsNull() && !item.Address.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "address", item.Address.ValueString())
+ }
+ if !item.Global.IsNull() && !item.Global.IsUnknown() {
+ if item.Global.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "global", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "global")
+ }
+ }
+ if !item.Vrf.IsNull() && !item.Vrf.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "vrf", item.Vrf.ValueString())
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/ip/helper-address", cBody.Res())
+ }
+ }
+ if !data.BfdTemplate.IsNull() && !data.BfdTemplate.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/bfd/Cisco-IOS-XE-bfd:template", data.BfdTemplate.ValueString())
+ }
+ if !data.BfdEnable.IsNull() && !data.BfdEnable.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/bfd/Cisco-IOS-XE-bfd:enable", data.BfdEnable.ValueBool())
+ }
+ if !data.BfdLocalAddress.IsNull() && !data.BfdLocalAddress.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/bfd/Cisco-IOS-XE-bfd:local-address", data.BfdLocalAddress.ValueString())
+ }
+ if !data.BfdInterval.IsNull() && !data.BfdInterval.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/bfd/Cisco-IOS-XE-bfd:interval-interface/msecs", strconv.FormatInt(data.BfdInterval.ValueInt64(), 10))
+ }
+ if !data.BfdIntervalMinRx.IsNull() && !data.BfdIntervalMinRx.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/bfd/Cisco-IOS-XE-bfd:interval-interface/min_rx", strconv.FormatInt(data.BfdIntervalMinRx.ValueInt64(), 10))
+ }
+ if !data.BfdIntervalMultiplier.IsNull() && !data.BfdIntervalMultiplier.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/bfd/Cisco-IOS-XE-bfd:interval-interface/multiplier", strconv.FormatInt(data.BfdIntervalMultiplier.ValueInt64(), 10))
+ }
+ if !data.BfdEcho.IsNull() && !data.BfdEcho.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/bfd/Cisco-IOS-XE-bfd:echo", data.BfdEcho.ValueBool())
+ }
+ if !data.Ipv6Enable.IsNull() && !data.Ipv6Enable.IsUnknown() {
+ if data.Ipv6Enable.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ipv6/enable", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/ipv6/enable")
+ }
+ }
+ if !data.Ipv6Mtu.IsNull() && !data.Ipv6Mtu.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ipv6/mtu", strconv.FormatInt(data.Ipv6Mtu.ValueInt64(), 10))
+ }
+ if !data.Ipv6NdRaSuppressAll.IsNull() && !data.Ipv6NdRaSuppressAll.IsUnknown() {
+ if data.Ipv6NdRaSuppressAll.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ipv6/nd/Cisco-IOS-XE-nd:ra/suppress/all", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/ipv6/nd/Cisco-IOS-XE-nd:ra/suppress/all")
+ }
+ }
+ if !data.Ipv6AddressAutoconfigDefault.IsNull() && !data.Ipv6AddressAutoconfigDefault.IsUnknown() {
+ if data.Ipv6AddressAutoconfigDefault.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ipv6/address/autoconfig/default", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/ipv6/address/autoconfig/default")
+ }
+ }
+ if !data.Ipv6AddressDhcp.IsNull() && !data.Ipv6AddressDhcp.IsUnknown() {
+ if data.Ipv6AddressDhcp.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ipv6/address/dhcp", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/ipv6/address/dhcp")
+ }
+ }
+ if len(data.Ipv6LinkLocalAddresses) > 0 {
+ for _, item := range data.Ipv6LinkLocalAddresses {
+ cBody := netconf.Body{}
+ if !item.Address.IsNull() && !item.Address.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "address", item.Address.ValueString())
+ }
+ if !item.LinkLocal.IsNull() && !item.LinkLocal.IsUnknown() {
+ if item.LinkLocal.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "link-local", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "link-local")
+ }
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/ipv6/address/link-local-address", cBody.Res())
+ }
+ }
+ if len(data.Ipv6Addresses) > 0 {
+ for _, item := range data.Ipv6Addresses {
+ cBody := netconf.Body{}
+ if !item.Prefix.IsNull() && !item.Prefix.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "prefix", item.Prefix.ValueString())
+ }
+ if !item.Eui64.IsNull() && !item.Eui64.IsUnknown() {
+ if item.Eui64.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "eui-64", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "eui-64")
+ }
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/ipv6/address/prefix-list", cBody.Res())
+ }
+ }
+ if !data.ArpTimeout.IsNull() && !data.ArpTimeout.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/arp/timeout", strconv.FormatInt(data.ArpTimeout.ValueInt64(), 10))
+ }
+ if !data.IpArpInspectionTrust.IsNull() && !data.IpArpInspectionTrust.IsUnknown() {
+ if data.IpArpInspectionTrust.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ip/arp/inspection/trust", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/ip/arp/inspection/trust")
+ }
+ }
+ if !data.IpArpInspectionLimitRate.IsNull() && !data.IpArpInspectionLimitRate.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ip/arp/inspection/limit/rate", strconv.FormatInt(data.IpArpInspectionLimitRate.ValueInt64(), 10))
+ }
+ if !data.SpanningTreeLinkType.IsNull() && !data.SpanningTreeLinkType.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-spanning-tree:spanning-tree/link-type", data.SpanningTreeLinkType.ValueString())
+ }
+ if !data.IpDhcpSnoopingTrust.IsNull() && !data.IpDhcpSnoopingTrust.IsUnknown() {
+ if data.IpDhcpSnoopingTrust.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ip/dhcp/Cisco-IOS-XE-dhcp:snooping/trust", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/ip/dhcp/Cisco-IOS-XE-dhcp:snooping/trust")
+ }
+ }
+ if !data.LoadInterval.IsNull() && !data.LoadInterval.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/load-interval", strconv.FormatInt(data.LoadInterval.ValueInt64(), 10))
+ }
+ if !data.SnmpTrapLinkStatus.IsNull() && !data.SnmpTrapLinkStatus.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:snmp/trap/link-status", data.SnmpTrapLinkStatus.ValueBool())
+ }
+ if !data.LoggingEventLinkStatusEnable.IsNull() && !data.LoggingEventLinkStatusEnable.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/logging/event/link-status-enable", data.LoggingEventLinkStatusEnable.ValueBool())
+ }
+ if !data.DeviceTracking.IsNull() && !data.DeviceTracking.IsUnknown() {
+ if data.DeviceTracking.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-switch:device-tracking", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-switch:device-tracking")
+ }
+ }
+ if len(data.DeviceTrackingAttachedPolicies) > 0 {
+ for _, item := range data.DeviceTrackingAttachedPolicies {
+ cBody := netconf.Body{}
+ if !item.Name.IsNull() && !item.Name.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "attach-policy", item.Name.ValueString())
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-switch:device-tracking/attached-policies", cBody.Res())
+ }
+ }
+ if !data.NegotiationAuto.IsNull() && !data.NegotiationAuto.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-ethernet:negotiation/auto", data.NegotiationAuto.ValueBool())
+ }
+ bodyString, err := body.String()
+ if err != nil {
+ tflog.Error(ctx, fmt.Sprintf("Error converting body to string: %s", err))
+ }
+ return bodyString
+}
+
+// End of section. //template:end toBodyXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBody
func (data *InterfacePortChannel) updateFromBody(ctx context.Context, res gjson.Result) {
@@ -976,294 +1306,525 @@ func (data *InterfacePortChannel) updateFromBody(ctx context.Context, res gjson.
// End of section. //template:end updateFromBody
-// Section below is generated&owned by "gen/generator.go". //template:begin fromBody
+// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBodyXML
-func (data *InterfacePortChannel) fromBody(ctx context.Context, res gjson.Result) {
- prefix := helpers.LastElement(data.getPath()) + "."
- if res.Get(helpers.LastElement(data.getPath())).IsArray() {
- prefix += "0."
+func (data *InterfacePortChannel) updateFromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/name"); value.Exists() && !data.Name.IsNull() {
+ data.Name = types.Int64Value(value.Int())
+ } else {
+ data.Name = types.Int64Null()
}
- if value := res.Get(prefix + "description"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/description"); value.Exists() && !data.Description.IsNull() {
data.Description = types.StringValue(value.String())
+ } else {
+ data.Description = types.StringNull()
}
- if value := res.Get(prefix + "shutdown"); value.Exists() {
- data.Shutdown = types.BoolValue(true)
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/shutdown"); !data.Shutdown.IsNull() {
+ if value.Exists() {
+ data.Shutdown = types.BoolValue(true)
+ } else {
+ data.Shutdown = types.BoolValue(false)
+ }
} else {
- data.Shutdown = types.BoolValue(false)
+ data.Shutdown = types.BoolNull()
}
- if value := res.Get(prefix + "switchport-conf.switchport"); value.Exists() {
- data.Switchport = types.BoolValue(value.Bool())
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/switchport-conf/switchport"); !data.Switchport.IsNull() {
+ if value.Exists() {
+ data.Switchport = types.BoolValue(value.Bool())
+ }
} else {
data.Switchport = types.BoolNull()
}
- if value := res.Get(prefix + "ip.proxy-arp"); value.Exists() {
- data.IpProxyArp = types.BoolValue(value.Bool())
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/proxy-arp"); !data.IpProxyArp.IsNull() {
+ if value.Exists() {
+ data.IpProxyArp = types.BoolValue(value.Bool())
+ }
} else {
data.IpProxyArp = types.BoolNull()
}
- if value := res.Get(prefix + "ip.redirects"); value.Exists() {
- data.IpRedirects = types.BoolValue(value.Bool())
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/redirects"); !data.IpRedirects.IsNull() {
+ if value.Exists() {
+ data.IpRedirects = types.BoolValue(value.Bool())
+ }
} else {
data.IpRedirects = types.BoolNull()
}
- if value := res.Get(prefix + "ip.Cisco-IOS-XE-icmp:unreachables"); value.Exists() {
- data.IpUnreachables = types.BoolValue(value.Bool())
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/Cisco-IOS-XE-icmp:unreachables"); !data.IpUnreachables.IsNull() {
+ if value.Exists() {
+ data.IpUnreachables = types.BoolValue(value.Bool())
+ }
} else {
data.IpUnreachables = types.BoolNull()
}
- if value := res.Get(prefix + "vrf.forwarding"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/vrf/forwarding"); value.Exists() && !data.VrfForwarding.IsNull() {
data.VrfForwarding = types.StringValue(value.String())
+ } else {
+ data.VrfForwarding = types.StringNull()
}
- if value := res.Get(prefix + "ip.address.primary.address"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/address/primary/address"); value.Exists() && !data.Ipv4Address.IsNull() {
data.Ipv4Address = types.StringValue(value.String())
- }
- if value := res.Get(prefix + "ip.address.primary.mask"); value.Exists() {
+ } else {
+ data.Ipv4Address = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/address/primary/mask"); value.Exists() && !data.Ipv4AddressMask.IsNull() {
data.Ipv4AddressMask = types.StringValue(value.String())
+ } else {
+ data.Ipv4AddressMask = types.StringNull()
}
- if value := res.Get(prefix + "ip.access-group.in.acl.in"); value.Exists() {
- data.IpAccessGroupInEnable = types.BoolValue(true)
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/access-group/in/acl/in"); !data.IpAccessGroupInEnable.IsNull() {
+ if value.Exists() {
+ data.IpAccessGroupInEnable = types.BoolValue(true)
+ } else {
+ data.IpAccessGroupInEnable = types.BoolValue(false)
+ }
} else {
- data.IpAccessGroupInEnable = types.BoolValue(false)
+ data.IpAccessGroupInEnable = types.BoolNull()
}
- if value := res.Get(prefix + "ip.access-group.in.acl.acl-name"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/access-group/in/acl/acl-name"); value.Exists() && !data.IpAccessGroupIn.IsNull() {
data.IpAccessGroupIn = types.StringValue(value.String())
+ } else {
+ data.IpAccessGroupIn = types.StringNull()
}
- if value := res.Get(prefix + "ip.access-group.out.acl.out"); value.Exists() {
- data.IpAccessGroupOutEnable = types.BoolValue(true)
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/access-group/out/acl/out"); !data.IpAccessGroupOutEnable.IsNull() {
+ if value.Exists() {
+ data.IpAccessGroupOutEnable = types.BoolValue(true)
+ } else {
+ data.IpAccessGroupOutEnable = types.BoolValue(false)
+ }
} else {
- data.IpAccessGroupOutEnable = types.BoolValue(false)
+ data.IpAccessGroupOutEnable = types.BoolNull()
}
- if value := res.Get(prefix + "ip.access-group.out.acl.acl-name"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/access-group/out/acl/acl-name"); value.Exists() && !data.IpAccessGroupOut.IsNull() {
data.IpAccessGroupOut = types.StringValue(value.String())
+ } else {
+ data.IpAccessGroupOut = types.StringNull()
}
- if value := res.Get(prefix + "ip.dhcp.Cisco-IOS-XE-dhcp:relay.source-interface"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/dhcp/Cisco-IOS-XE-dhcp:relay/source-interface"); value.Exists() && !data.IpDhcpRelaySourceInterface.IsNull() {
data.IpDhcpRelaySourceInterface = types.StringValue(value.String())
+ } else {
+ data.IpDhcpRelaySourceInterface = types.StringNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-spanning-tree:spanning-tree.guard"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-spanning-tree:spanning-tree/guard"); value.Exists() && !data.SpanningTreeGuard.IsNull() {
data.SpanningTreeGuard = types.StringValue(value.String())
+ } else {
+ data.SpanningTreeGuard = types.StringNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-switch:auto.qos.classify"); value.Exists() {
- data.AutoQosClassify = types.BoolValue(true)
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/classify"); !data.AutoQosClassify.IsNull() {
+ if value.Exists() {
+ data.AutoQosClassify = types.BoolValue(true)
+ } else {
+ data.AutoQosClassify = types.BoolValue(false)
+ }
} else {
- data.AutoQosClassify = types.BoolValue(false)
+ data.AutoQosClassify = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-switch:auto.qos.classify.police"); value.Exists() {
- data.AutoQosClassifyPolice = types.BoolValue(true)
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/classify/police"); !data.AutoQosClassifyPolice.IsNull() {
+ if value.Exists() {
+ data.AutoQosClassifyPolice = types.BoolValue(true)
+ } else {
+ data.AutoQosClassifyPolice = types.BoolValue(false)
+ }
} else {
- data.AutoQosClassifyPolice = types.BoolValue(false)
+ data.AutoQosClassifyPolice = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-switch:auto.qos.trust"); value.Exists() {
- data.AutoQosTrust = types.BoolValue(true)
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/trust"); !data.AutoQosTrust.IsNull() {
+ if value.Exists() {
+ data.AutoQosTrust = types.BoolValue(true)
+ } else {
+ data.AutoQosTrust = types.BoolValue(false)
+ }
} else {
- data.AutoQosTrust = types.BoolValue(false)
+ data.AutoQosTrust = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-switch:auto.qos.trust.cos"); value.Exists() {
- data.AutoQosTrustCos = types.BoolValue(true)
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/trust/cos"); !data.AutoQosTrustCos.IsNull() {
+ if value.Exists() {
+ data.AutoQosTrustCos = types.BoolValue(true)
+ } else {
+ data.AutoQosTrustCos = types.BoolValue(false)
+ }
} else {
- data.AutoQosTrustCos = types.BoolValue(false)
+ data.AutoQosTrustCos = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-switch:auto.qos.trust.dscp"); value.Exists() {
- data.AutoQosTrustDscp = types.BoolValue(true)
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/trust/dscp"); !data.AutoQosTrustDscp.IsNull() {
+ if value.Exists() {
+ data.AutoQosTrustDscp = types.BoolValue(true)
+ } else {
+ data.AutoQosTrustDscp = types.BoolValue(false)
+ }
} else {
- data.AutoQosTrustDscp = types.BoolValue(false)
+ data.AutoQosTrustDscp = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-switch:auto.qos.video.cts"); value.Exists() {
- data.AutoQosVideoCts = types.BoolValue(true)
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/video/cts"); !data.AutoQosVideoCts.IsNull() {
+ if value.Exists() {
+ data.AutoQosVideoCts = types.BoolValue(true)
+ } else {
+ data.AutoQosVideoCts = types.BoolValue(false)
+ }
} else {
- data.AutoQosVideoCts = types.BoolValue(false)
+ data.AutoQosVideoCts = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-switch:auto.qos.video.ip-camera"); value.Exists() {
- data.AutoQosVideoIpCamera = types.BoolValue(true)
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/video/ip-camera"); !data.AutoQosVideoIpCamera.IsNull() {
+ if value.Exists() {
+ data.AutoQosVideoIpCamera = types.BoolValue(true)
+ } else {
+ data.AutoQosVideoIpCamera = types.BoolValue(false)
+ }
} else {
- data.AutoQosVideoIpCamera = types.BoolValue(false)
+ data.AutoQosVideoIpCamera = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-switch:auto.qos.video.media-player"); value.Exists() {
- data.AutoQosVideoMediaPlayer = types.BoolValue(true)
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/video/media-player"); !data.AutoQosVideoMediaPlayer.IsNull() {
+ if value.Exists() {
+ data.AutoQosVideoMediaPlayer = types.BoolValue(true)
+ } else {
+ data.AutoQosVideoMediaPlayer = types.BoolValue(false)
+ }
} else {
- data.AutoQosVideoMediaPlayer = types.BoolValue(false)
+ data.AutoQosVideoMediaPlayer = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-switch:auto.qos.voip"); value.Exists() {
- data.AutoQosVoip = types.BoolValue(true)
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/voip"); !data.AutoQosVoip.IsNull() {
+ if value.Exists() {
+ data.AutoQosVoip = types.BoolValue(true)
+ } else {
+ data.AutoQosVoip = types.BoolValue(false)
+ }
} else {
- data.AutoQosVoip = types.BoolValue(false)
+ data.AutoQosVoip = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-switch:auto.qos.voip.cisco-phone"); value.Exists() {
- data.AutoQosVoipCiscoPhone = types.BoolValue(true)
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/voip/cisco-phone"); !data.AutoQosVoipCiscoPhone.IsNull() {
+ if value.Exists() {
+ data.AutoQosVoipCiscoPhone = types.BoolValue(true)
+ } else {
+ data.AutoQosVoipCiscoPhone = types.BoolValue(false)
+ }
} else {
- data.AutoQosVoipCiscoPhone = types.BoolValue(false)
+ data.AutoQosVoipCiscoPhone = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-switch:auto.qos.voip.cisco-softphone"); value.Exists() {
- data.AutoQosVoipCiscoSoftphone = types.BoolValue(true)
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/voip/cisco-softphone"); !data.AutoQosVoipCiscoSoftphone.IsNull() {
+ if value.Exists() {
+ data.AutoQosVoipCiscoSoftphone = types.BoolValue(true)
+ } else {
+ data.AutoQosVoipCiscoSoftphone = types.BoolValue(false)
+ }
} else {
- data.AutoQosVoipCiscoSoftphone = types.BoolValue(false)
+ data.AutoQosVoipCiscoSoftphone = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-switch:auto.qos.voip.trust"); value.Exists() {
- data.AutoQosVoipTrust = types.BoolValue(true)
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/voip/trust"); !data.AutoQosVoipTrust.IsNull() {
+ if value.Exists() {
+ data.AutoQosVoipTrust = types.BoolValue(true)
+ } else {
+ data.AutoQosVoipTrust = types.BoolValue(false)
+ }
} else {
- data.AutoQosVoipTrust = types.BoolValue(false)
+ data.AutoQosVoipTrust = types.BoolNull()
}
- if value := res.Get(prefix + "trust.device"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/trust/device"); value.Exists() && !data.TrustDevice.IsNull() {
data.TrustDevice = types.StringValue(value.String())
+ } else {
+ data.TrustDevice = types.StringNull()
}
- if value := res.Get(prefix + "ip.helper-address"); value.Exists() {
- data.HelperAddresses = make([]InterfacePortChannelHelperAddresses, 0)
- value.ForEach(func(k, v gjson.Result) bool {
- item := InterfacePortChannelHelperAddresses{}
- if cValue := v.Get("address"); cValue.Exists() {
- item.Address = types.StringValue(cValue.String())
- }
- if cValue := v.Get("global"); cValue.Exists() {
- item.Global = types.BoolValue(true)
+ for i := range data.HelperAddresses {
+ keys := [...]string{"address"}
+ keyValues := [...]string{data.HelperAddresses[i].Address.ValueString()}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/helper-address").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, "address"); value.Exists() && !data.HelperAddresses[i].Address.IsNull() {
+ data.HelperAddresses[i].Address = types.StringValue(value.String())
+ } else {
+ data.HelperAddresses[i].Address = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "global"); !data.HelperAddresses[i].Global.IsNull() {
+ if value.Exists() {
+ data.HelperAddresses[i].Global = types.BoolValue(true)
} else {
- item.Global = types.BoolValue(false)
- }
- if cValue := v.Get("vrf"); cValue.Exists() {
- item.Vrf = types.StringValue(cValue.String())
+ data.HelperAddresses[i].Global = types.BoolValue(false)
}
- data.HelperAddresses = append(data.HelperAddresses, item)
- return true
- })
+ } else {
+ data.HelperAddresses[i].Global = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "vrf"); value.Exists() && !data.HelperAddresses[i].Vrf.IsNull() {
+ data.HelperAddresses[i].Vrf = types.StringValue(value.String())
+ } else {
+ data.HelperAddresses[i].Vrf = types.StringNull()
+ }
}
- if value := res.Get(prefix + "bfd.Cisco-IOS-XE-bfd:template"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/bfd/Cisco-IOS-XE-bfd:template"); value.Exists() && !data.BfdTemplate.IsNull() {
data.BfdTemplate = types.StringValue(value.String())
+ } else {
+ data.BfdTemplate = types.StringNull()
}
- if value := res.Get(prefix + "bfd.Cisco-IOS-XE-bfd:enable"); value.Exists() {
- data.BfdEnable = types.BoolValue(value.Bool())
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/bfd/Cisco-IOS-XE-bfd:enable"); !data.BfdEnable.IsNull() {
+ if value.Exists() {
+ data.BfdEnable = types.BoolValue(value.Bool())
+ }
} else {
data.BfdEnable = types.BoolNull()
}
- if value := res.Get(prefix + "bfd.Cisco-IOS-XE-bfd:local-address"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/bfd/Cisco-IOS-XE-bfd:local-address"); value.Exists() && !data.BfdLocalAddress.IsNull() {
data.BfdLocalAddress = types.StringValue(value.String())
+ } else {
+ data.BfdLocalAddress = types.StringNull()
}
- if value := res.Get(prefix + "bfd.Cisco-IOS-XE-bfd:interval-interface.msecs"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/bfd/Cisco-IOS-XE-bfd:interval-interface/msecs"); value.Exists() && !data.BfdInterval.IsNull() {
data.BfdInterval = types.Int64Value(value.Int())
+ } else {
+ data.BfdInterval = types.Int64Null()
}
- if value := res.Get(prefix + "bfd.Cisco-IOS-XE-bfd:interval-interface.min_rx"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/bfd/Cisco-IOS-XE-bfd:interval-interface/min_rx"); value.Exists() && !data.BfdIntervalMinRx.IsNull() {
data.BfdIntervalMinRx = types.Int64Value(value.Int())
+ } else {
+ data.BfdIntervalMinRx = types.Int64Null()
}
- if value := res.Get(prefix + "bfd.Cisco-IOS-XE-bfd:interval-interface.multiplier"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/bfd/Cisco-IOS-XE-bfd:interval-interface/multiplier"); value.Exists() && !data.BfdIntervalMultiplier.IsNull() {
data.BfdIntervalMultiplier = types.Int64Value(value.Int())
+ } else {
+ data.BfdIntervalMultiplier = types.Int64Null()
}
- if value := res.Get(prefix + "bfd.Cisco-IOS-XE-bfd:echo"); value.Exists() {
- data.BfdEcho = types.BoolValue(value.Bool())
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/bfd/Cisco-IOS-XE-bfd:echo"); !data.BfdEcho.IsNull() {
+ if value.Exists() {
+ data.BfdEcho = types.BoolValue(value.Bool())
+ }
} else {
data.BfdEcho = types.BoolNull()
}
- if value := res.Get(prefix + "ipv6.enable"); value.Exists() {
- data.Ipv6Enable = types.BoolValue(true)
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ipv6/enable"); !data.Ipv6Enable.IsNull() {
+ if value.Exists() {
+ data.Ipv6Enable = types.BoolValue(true)
+ } else {
+ data.Ipv6Enable = types.BoolValue(false)
+ }
} else {
- data.Ipv6Enable = types.BoolValue(false)
+ data.Ipv6Enable = types.BoolNull()
}
- if value := res.Get(prefix + "ipv6.mtu"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ipv6/mtu"); value.Exists() && !data.Ipv6Mtu.IsNull() {
data.Ipv6Mtu = types.Int64Value(value.Int())
- }
- if value := res.Get(prefix + "ipv6.nd.Cisco-IOS-XE-nd:ra.suppress.all"); value.Exists() {
- data.Ipv6NdRaSuppressAll = types.BoolValue(true)
} else {
- data.Ipv6NdRaSuppressAll = types.BoolValue(false)
+ data.Ipv6Mtu = types.Int64Null()
}
- if value := res.Get(prefix + "ipv6.address.autoconfig.default"); value.Exists() {
- data.Ipv6AddressAutoconfigDefault = types.BoolValue(true)
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ipv6/nd/Cisco-IOS-XE-nd:ra/suppress/all"); !data.Ipv6NdRaSuppressAll.IsNull() {
+ if value.Exists() {
+ data.Ipv6NdRaSuppressAll = types.BoolValue(true)
+ } else {
+ data.Ipv6NdRaSuppressAll = types.BoolValue(false)
+ }
} else {
- data.Ipv6AddressAutoconfigDefault = types.BoolValue(false)
+ data.Ipv6NdRaSuppressAll = types.BoolNull()
}
- if value := res.Get(prefix + "ipv6.address.dhcp"); value.Exists() {
- data.Ipv6AddressDhcp = types.BoolValue(true)
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ipv6/address/autoconfig/default"); !data.Ipv6AddressAutoconfigDefault.IsNull() {
+ if value.Exists() {
+ data.Ipv6AddressAutoconfigDefault = types.BoolValue(true)
+ } else {
+ data.Ipv6AddressAutoconfigDefault = types.BoolValue(false)
+ }
} else {
- data.Ipv6AddressDhcp = types.BoolValue(false)
+ data.Ipv6AddressAutoconfigDefault = types.BoolNull()
}
- if value := res.Get(prefix + "ipv6.address.link-local-address"); value.Exists() {
- data.Ipv6LinkLocalAddresses = make([]InterfacePortChannelIpv6LinkLocalAddresses, 0)
- value.ForEach(func(k, v gjson.Result) bool {
- item := InterfacePortChannelIpv6LinkLocalAddresses{}
- if cValue := v.Get("address"); cValue.Exists() {
- item.Address = types.StringValue(cValue.String())
- }
- if cValue := v.Get("link-local"); cValue.Exists() {
- item.LinkLocal = types.BoolValue(true)
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ipv6/address/dhcp"); !data.Ipv6AddressDhcp.IsNull() {
+ if value.Exists() {
+ data.Ipv6AddressDhcp = types.BoolValue(true)
+ } else {
+ data.Ipv6AddressDhcp = types.BoolValue(false)
+ }
+ } else {
+ data.Ipv6AddressDhcp = types.BoolNull()
+ }
+ for i := range data.Ipv6LinkLocalAddresses {
+ keys := [...]string{"address"}
+ keyValues := [...]string{data.Ipv6LinkLocalAddresses[i].Address.ValueString()}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ipv6/address/link-local-address").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, "address"); value.Exists() && !data.Ipv6LinkLocalAddresses[i].Address.IsNull() {
+ data.Ipv6LinkLocalAddresses[i].Address = types.StringValue(value.String())
+ } else {
+ data.Ipv6LinkLocalAddresses[i].Address = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "link-local"); !data.Ipv6LinkLocalAddresses[i].LinkLocal.IsNull() {
+ if value.Exists() {
+ data.Ipv6LinkLocalAddresses[i].LinkLocal = types.BoolValue(true)
} else {
- item.LinkLocal = types.BoolValue(false)
+ data.Ipv6LinkLocalAddresses[i].LinkLocal = types.BoolValue(false)
}
- data.Ipv6LinkLocalAddresses = append(data.Ipv6LinkLocalAddresses, item)
- return true
- })
+ } else {
+ data.Ipv6LinkLocalAddresses[i].LinkLocal = types.BoolNull()
+ }
}
- if value := res.Get(prefix + "ipv6.address.prefix-list"); value.Exists() {
- data.Ipv6Addresses = make([]InterfacePortChannelIpv6Addresses, 0)
- value.ForEach(func(k, v gjson.Result) bool {
- item := InterfacePortChannelIpv6Addresses{}
- if cValue := v.Get("prefix"); cValue.Exists() {
- item.Prefix = types.StringValue(cValue.String())
- }
- if cValue := v.Get("eui-64"); cValue.Exists() {
- item.Eui64 = types.BoolValue(true)
+ for i := range data.Ipv6Addresses {
+ keys := [...]string{"prefix"}
+ keyValues := [...]string{data.Ipv6Addresses[i].Prefix.ValueString()}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ipv6/address/prefix-list").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, "prefix"); value.Exists() && !data.Ipv6Addresses[i].Prefix.IsNull() {
+ data.Ipv6Addresses[i].Prefix = types.StringValue(value.String())
+ } else {
+ data.Ipv6Addresses[i].Prefix = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "eui-64"); !data.Ipv6Addresses[i].Eui64.IsNull() {
+ if value.Exists() {
+ data.Ipv6Addresses[i].Eui64 = types.BoolValue(true)
} else {
- item.Eui64 = types.BoolValue(false)
+ data.Ipv6Addresses[i].Eui64 = types.BoolValue(false)
}
- data.Ipv6Addresses = append(data.Ipv6Addresses, item)
- return true
- })
+ } else {
+ data.Ipv6Addresses[i].Eui64 = types.BoolNull()
+ }
}
- if value := res.Get(prefix + "arp.timeout"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/arp/timeout"); value.Exists() && !data.ArpTimeout.IsNull() {
data.ArpTimeout = types.Int64Value(value.Int())
+ } else {
+ data.ArpTimeout = types.Int64Null()
}
- if value := res.Get(prefix + "ip.arp.inspection.trust"); value.Exists() {
- data.IpArpInspectionTrust = types.BoolValue(true)
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/arp/inspection/trust"); !data.IpArpInspectionTrust.IsNull() {
+ if value.Exists() {
+ data.IpArpInspectionTrust = types.BoolValue(true)
+ } else {
+ data.IpArpInspectionTrust = types.BoolValue(false)
+ }
} else {
- data.IpArpInspectionTrust = types.BoolValue(false)
+ data.IpArpInspectionTrust = types.BoolNull()
}
- if value := res.Get(prefix + "ip.arp.inspection.limit.rate"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/arp/inspection/limit/rate"); value.Exists() && !data.IpArpInspectionLimitRate.IsNull() {
data.IpArpInspectionLimitRate = types.Int64Value(value.Int())
+ } else {
+ data.IpArpInspectionLimitRate = types.Int64Null()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-spanning-tree:spanning-tree.link-type"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-spanning-tree:spanning-tree/link-type"); value.Exists() && !data.SpanningTreeLinkType.IsNull() {
data.SpanningTreeLinkType = types.StringValue(value.String())
+ } else {
+ data.SpanningTreeLinkType = types.StringNull()
}
- if value := res.Get(prefix + "ip.dhcp.Cisco-IOS-XE-dhcp:snooping.trust"); value.Exists() {
- data.IpDhcpSnoopingTrust = types.BoolValue(true)
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/dhcp/Cisco-IOS-XE-dhcp:snooping/trust"); !data.IpDhcpSnoopingTrust.IsNull() {
+ if value.Exists() {
+ data.IpDhcpSnoopingTrust = types.BoolValue(true)
+ } else {
+ data.IpDhcpSnoopingTrust = types.BoolValue(false)
+ }
} else {
- data.IpDhcpSnoopingTrust = types.BoolValue(false)
+ data.IpDhcpSnoopingTrust = types.BoolNull()
}
- if value := res.Get(prefix + "load-interval"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/load-interval"); value.Exists() && !data.LoadInterval.IsNull() {
data.LoadInterval = types.Int64Value(value.Int())
+ } else {
+ data.LoadInterval = types.Int64Null()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:snmp.trap.link-status"); value.Exists() {
- data.SnmpTrapLinkStatus = types.BoolValue(value.Bool())
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:snmp/trap/link-status"); !data.SnmpTrapLinkStatus.IsNull() {
+ if value.Exists() {
+ data.SnmpTrapLinkStatus = types.BoolValue(value.Bool())
+ }
} else {
data.SnmpTrapLinkStatus = types.BoolNull()
}
- if value := res.Get(prefix + "logging.event.link-status-enable"); value.Exists() {
- data.LoggingEventLinkStatusEnable = types.BoolValue(value.Bool())
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/logging/event/link-status-enable"); !data.LoggingEventLinkStatusEnable.IsNull() {
+ if value.Exists() {
+ data.LoggingEventLinkStatusEnable = types.BoolValue(value.Bool())
+ }
} else {
data.LoggingEventLinkStatusEnable = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-switch:device-tracking"); value.Exists() {
- data.DeviceTracking = types.BoolValue(true)
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-switch:device-tracking"); !data.DeviceTracking.IsNull() {
+ if value.Exists() {
+ data.DeviceTracking = types.BoolValue(true)
+ } else {
+ data.DeviceTracking = types.BoolValue(false)
+ }
} else {
- data.DeviceTracking = types.BoolValue(false)
+ data.DeviceTracking = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-switch:device-tracking.attached-policies"); value.Exists() {
- data.DeviceTrackingAttachedPolicies = make([]InterfacePortChannelDeviceTrackingAttachedPolicies, 0)
- value.ForEach(func(k, v gjson.Result) bool {
- item := InterfacePortChannelDeviceTrackingAttachedPolicies{}
- if cValue := v.Get("attach-policy"); cValue.Exists() {
- item.Name = types.StringValue(cValue.String())
- }
- data.DeviceTrackingAttachedPolicies = append(data.DeviceTrackingAttachedPolicies, item)
- return true
- })
+ for i := range data.DeviceTrackingAttachedPolicies {
+ keys := [...]string{"attach-policy"}
+ keyValues := [...]string{data.DeviceTrackingAttachedPolicies[i].Name.ValueString()}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-switch:device-tracking/attached-policies").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, "attach-policy"); value.Exists() && !data.DeviceTrackingAttachedPolicies[i].Name.IsNull() {
+ data.DeviceTrackingAttachedPolicies[i].Name = types.StringValue(value.String())
+ } else {
+ data.DeviceTrackingAttachedPolicies[i].Name = types.StringNull()
+ }
}
- if value := res.Get(prefix + "Cisco-IOS-XE-ethernet:negotiation.auto"); value.Exists() {
- data.NegotiationAuto = types.BoolValue(value.Bool())
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-ethernet:negotiation/auto"); !data.NegotiationAuto.IsNull() {
+ if value.Exists() {
+ data.NegotiationAuto = types.BoolValue(value.Bool())
+ }
} else {
data.NegotiationAuto = types.BoolNull()
}
}
-// End of section. //template:end fromBody
+// End of section. //template:end updateFromBodyXML
-// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyData
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBody
-func (data *InterfacePortChannelData) fromBody(ctx context.Context, res gjson.Result) {
+func (data *InterfacePortChannel) fromBody(ctx context.Context, res gjson.Result) {
prefix := helpers.LastElement(data.getPath()) + "."
if res.Get(helpers.LastElement(data.getPath())).IsArray() {
prefix += "0."
@@ -1412,152 +1973,1357 @@ func (data *InterfacePortChannelData) fromBody(ctx context.Context, res gjson.Re
if value := res.Get(prefix + "bfd.Cisco-IOS-XE-bfd:template"); value.Exists() {
data.BfdTemplate = types.StringValue(value.String())
}
- if value := res.Get(prefix + "bfd.Cisco-IOS-XE-bfd:enable"); value.Exists() {
- data.BfdEnable = types.BoolValue(value.Bool())
- } else {
- data.BfdEnable = types.BoolNull()
+ if value := res.Get(prefix + "bfd.Cisco-IOS-XE-bfd:enable"); value.Exists() {
+ data.BfdEnable = types.BoolValue(value.Bool())
+ } else {
+ data.BfdEnable = types.BoolNull()
+ }
+ if value := res.Get(prefix + "bfd.Cisco-IOS-XE-bfd:local-address"); value.Exists() {
+ data.BfdLocalAddress = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "bfd.Cisco-IOS-XE-bfd:interval-interface.msecs"); value.Exists() {
+ data.BfdInterval = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "bfd.Cisco-IOS-XE-bfd:interval-interface.min_rx"); value.Exists() {
+ data.BfdIntervalMinRx = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "bfd.Cisco-IOS-XE-bfd:interval-interface.multiplier"); value.Exists() {
+ data.BfdIntervalMultiplier = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "bfd.Cisco-IOS-XE-bfd:echo"); value.Exists() {
+ data.BfdEcho = types.BoolValue(value.Bool())
+ } else {
+ data.BfdEcho = types.BoolNull()
+ }
+ if value := res.Get(prefix + "ipv6.enable"); value.Exists() {
+ data.Ipv6Enable = types.BoolValue(true)
+ } else {
+ data.Ipv6Enable = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "ipv6.mtu"); value.Exists() {
+ data.Ipv6Mtu = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "ipv6.nd.Cisco-IOS-XE-nd:ra.suppress.all"); value.Exists() {
+ data.Ipv6NdRaSuppressAll = types.BoolValue(true)
+ } else {
+ data.Ipv6NdRaSuppressAll = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "ipv6.address.autoconfig.default"); value.Exists() {
+ data.Ipv6AddressAutoconfigDefault = types.BoolValue(true)
+ } else {
+ data.Ipv6AddressAutoconfigDefault = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "ipv6.address.dhcp"); value.Exists() {
+ data.Ipv6AddressDhcp = types.BoolValue(true)
+ } else {
+ data.Ipv6AddressDhcp = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "ipv6.address.link-local-address"); value.Exists() {
+ data.Ipv6LinkLocalAddresses = make([]InterfacePortChannelIpv6LinkLocalAddresses, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := InterfacePortChannelIpv6LinkLocalAddresses{}
+ if cValue := v.Get("address"); cValue.Exists() {
+ item.Address = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("link-local"); cValue.Exists() {
+ item.LinkLocal = types.BoolValue(true)
+ } else {
+ item.LinkLocal = types.BoolValue(false)
+ }
+ data.Ipv6LinkLocalAddresses = append(data.Ipv6LinkLocalAddresses, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + "ipv6.address.prefix-list"); value.Exists() {
+ data.Ipv6Addresses = make([]InterfacePortChannelIpv6Addresses, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := InterfacePortChannelIpv6Addresses{}
+ if cValue := v.Get("prefix"); cValue.Exists() {
+ item.Prefix = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("eui-64"); cValue.Exists() {
+ item.Eui64 = types.BoolValue(true)
+ } else {
+ item.Eui64 = types.BoolValue(false)
+ }
+ data.Ipv6Addresses = append(data.Ipv6Addresses, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + "arp.timeout"); value.Exists() {
+ data.ArpTimeout = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "ip.arp.inspection.trust"); value.Exists() {
+ data.IpArpInspectionTrust = types.BoolValue(true)
+ } else {
+ data.IpArpInspectionTrust = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "ip.arp.inspection.limit.rate"); value.Exists() {
+ data.IpArpInspectionLimitRate = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-spanning-tree:spanning-tree.link-type"); value.Exists() {
+ data.SpanningTreeLinkType = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "ip.dhcp.Cisco-IOS-XE-dhcp:snooping.trust"); value.Exists() {
+ data.IpDhcpSnoopingTrust = types.BoolValue(true)
+ } else {
+ data.IpDhcpSnoopingTrust = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "load-interval"); value.Exists() {
+ data.LoadInterval = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:snmp.trap.link-status"); value.Exists() {
+ data.SnmpTrapLinkStatus = types.BoolValue(value.Bool())
+ } else {
+ data.SnmpTrapLinkStatus = types.BoolNull()
+ }
+ if value := res.Get(prefix + "logging.event.link-status-enable"); value.Exists() {
+ data.LoggingEventLinkStatusEnable = types.BoolValue(value.Bool())
+ } else {
+ data.LoggingEventLinkStatusEnable = types.BoolNull()
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-switch:device-tracking"); value.Exists() {
+ data.DeviceTracking = types.BoolValue(true)
+ } else {
+ data.DeviceTracking = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-switch:device-tracking.attached-policies"); value.Exists() {
+ data.DeviceTrackingAttachedPolicies = make([]InterfacePortChannelDeviceTrackingAttachedPolicies, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := InterfacePortChannelDeviceTrackingAttachedPolicies{}
+ if cValue := v.Get("attach-policy"); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ data.DeviceTrackingAttachedPolicies = append(data.DeviceTrackingAttachedPolicies, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-ethernet:negotiation.auto"); value.Exists() {
+ data.NegotiationAuto = types.BoolValue(value.Bool())
+ } else {
+ data.NegotiationAuto = types.BoolNull()
+ }
+}
+
+// End of section. //template:end fromBody
+
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyData
+
+func (data *InterfacePortChannelData) fromBody(ctx context.Context, res gjson.Result) {
+ prefix := helpers.LastElement(data.getPath()) + "."
+ if res.Get(helpers.LastElement(data.getPath())).IsArray() {
+ prefix += "0."
+ }
+ if value := res.Get(prefix + "description"); value.Exists() {
+ data.Description = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "shutdown"); value.Exists() {
+ data.Shutdown = types.BoolValue(true)
+ } else {
+ data.Shutdown = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "switchport-conf.switchport"); value.Exists() {
+ data.Switchport = types.BoolValue(value.Bool())
+ } else {
+ data.Switchport = types.BoolNull()
+ }
+ if value := res.Get(prefix + "ip.proxy-arp"); value.Exists() {
+ data.IpProxyArp = types.BoolValue(value.Bool())
+ } else {
+ data.IpProxyArp = types.BoolNull()
+ }
+ if value := res.Get(prefix + "ip.redirects"); value.Exists() {
+ data.IpRedirects = types.BoolValue(value.Bool())
+ } else {
+ data.IpRedirects = types.BoolNull()
+ }
+ if value := res.Get(prefix + "ip.Cisco-IOS-XE-icmp:unreachables"); value.Exists() {
+ data.IpUnreachables = types.BoolValue(value.Bool())
+ } else {
+ data.IpUnreachables = types.BoolNull()
+ }
+ if value := res.Get(prefix + "vrf.forwarding"); value.Exists() {
+ data.VrfForwarding = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "ip.address.primary.address"); value.Exists() {
+ data.Ipv4Address = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "ip.address.primary.mask"); value.Exists() {
+ data.Ipv4AddressMask = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "ip.access-group.in.acl.in"); value.Exists() {
+ data.IpAccessGroupInEnable = types.BoolValue(true)
+ } else {
+ data.IpAccessGroupInEnable = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "ip.access-group.in.acl.acl-name"); value.Exists() {
+ data.IpAccessGroupIn = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "ip.access-group.out.acl.out"); value.Exists() {
+ data.IpAccessGroupOutEnable = types.BoolValue(true)
+ } else {
+ data.IpAccessGroupOutEnable = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "ip.access-group.out.acl.acl-name"); value.Exists() {
+ data.IpAccessGroupOut = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "ip.dhcp.Cisco-IOS-XE-dhcp:relay.source-interface"); value.Exists() {
+ data.IpDhcpRelaySourceInterface = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-spanning-tree:spanning-tree.guard"); value.Exists() {
+ data.SpanningTreeGuard = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-switch:auto.qos.classify"); value.Exists() {
+ data.AutoQosClassify = types.BoolValue(true)
+ } else {
+ data.AutoQosClassify = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-switch:auto.qos.classify.police"); value.Exists() {
+ data.AutoQosClassifyPolice = types.BoolValue(true)
+ } else {
+ data.AutoQosClassifyPolice = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-switch:auto.qos.trust"); value.Exists() {
+ data.AutoQosTrust = types.BoolValue(true)
+ } else {
+ data.AutoQosTrust = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-switch:auto.qos.trust.cos"); value.Exists() {
+ data.AutoQosTrustCos = types.BoolValue(true)
+ } else {
+ data.AutoQosTrustCos = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-switch:auto.qos.trust.dscp"); value.Exists() {
+ data.AutoQosTrustDscp = types.BoolValue(true)
+ } else {
+ data.AutoQosTrustDscp = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-switch:auto.qos.video.cts"); value.Exists() {
+ data.AutoQosVideoCts = types.BoolValue(true)
+ } else {
+ data.AutoQosVideoCts = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-switch:auto.qos.video.ip-camera"); value.Exists() {
+ data.AutoQosVideoIpCamera = types.BoolValue(true)
+ } else {
+ data.AutoQosVideoIpCamera = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-switch:auto.qos.video.media-player"); value.Exists() {
+ data.AutoQosVideoMediaPlayer = types.BoolValue(true)
+ } else {
+ data.AutoQosVideoMediaPlayer = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-switch:auto.qos.voip"); value.Exists() {
+ data.AutoQosVoip = types.BoolValue(true)
+ } else {
+ data.AutoQosVoip = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-switch:auto.qos.voip.cisco-phone"); value.Exists() {
+ data.AutoQosVoipCiscoPhone = types.BoolValue(true)
+ } else {
+ data.AutoQosVoipCiscoPhone = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-switch:auto.qos.voip.cisco-softphone"); value.Exists() {
+ data.AutoQosVoipCiscoSoftphone = types.BoolValue(true)
+ } else {
+ data.AutoQosVoipCiscoSoftphone = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-switch:auto.qos.voip.trust"); value.Exists() {
+ data.AutoQosVoipTrust = types.BoolValue(true)
+ } else {
+ data.AutoQosVoipTrust = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "trust.device"); value.Exists() {
+ data.TrustDevice = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "ip.helper-address"); value.Exists() {
+ data.HelperAddresses = make([]InterfacePortChannelHelperAddresses, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := InterfacePortChannelHelperAddresses{}
+ if cValue := v.Get("address"); cValue.Exists() {
+ item.Address = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("global"); cValue.Exists() {
+ item.Global = types.BoolValue(true)
+ } else {
+ item.Global = types.BoolValue(false)
+ }
+ if cValue := v.Get("vrf"); cValue.Exists() {
+ item.Vrf = types.StringValue(cValue.String())
+ }
+ data.HelperAddresses = append(data.HelperAddresses, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + "bfd.Cisco-IOS-XE-bfd:template"); value.Exists() {
+ data.BfdTemplate = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "bfd.Cisco-IOS-XE-bfd:enable"); value.Exists() {
+ data.BfdEnable = types.BoolValue(value.Bool())
+ } else {
+ data.BfdEnable = types.BoolNull()
+ }
+ if value := res.Get(prefix + "bfd.Cisco-IOS-XE-bfd:local-address"); value.Exists() {
+ data.BfdLocalAddress = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "bfd.Cisco-IOS-XE-bfd:interval-interface.msecs"); value.Exists() {
+ data.BfdInterval = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "bfd.Cisco-IOS-XE-bfd:interval-interface.min_rx"); value.Exists() {
+ data.BfdIntervalMinRx = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "bfd.Cisco-IOS-XE-bfd:interval-interface.multiplier"); value.Exists() {
+ data.BfdIntervalMultiplier = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "bfd.Cisco-IOS-XE-bfd:echo"); value.Exists() {
+ data.BfdEcho = types.BoolValue(value.Bool())
+ } else {
+ data.BfdEcho = types.BoolNull()
+ }
+ if value := res.Get(prefix + "ipv6.enable"); value.Exists() {
+ data.Ipv6Enable = types.BoolValue(true)
+ } else {
+ data.Ipv6Enable = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "ipv6.mtu"); value.Exists() {
+ data.Ipv6Mtu = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "ipv6.nd.Cisco-IOS-XE-nd:ra.suppress.all"); value.Exists() {
+ data.Ipv6NdRaSuppressAll = types.BoolValue(true)
+ } else {
+ data.Ipv6NdRaSuppressAll = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "ipv6.address.autoconfig.default"); value.Exists() {
+ data.Ipv6AddressAutoconfigDefault = types.BoolValue(true)
+ } else {
+ data.Ipv6AddressAutoconfigDefault = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "ipv6.address.dhcp"); value.Exists() {
+ data.Ipv6AddressDhcp = types.BoolValue(true)
+ } else {
+ data.Ipv6AddressDhcp = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "ipv6.address.link-local-address"); value.Exists() {
+ data.Ipv6LinkLocalAddresses = make([]InterfacePortChannelIpv6LinkLocalAddresses, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := InterfacePortChannelIpv6LinkLocalAddresses{}
+ if cValue := v.Get("address"); cValue.Exists() {
+ item.Address = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("link-local"); cValue.Exists() {
+ item.LinkLocal = types.BoolValue(true)
+ } else {
+ item.LinkLocal = types.BoolValue(false)
+ }
+ data.Ipv6LinkLocalAddresses = append(data.Ipv6LinkLocalAddresses, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + "ipv6.address.prefix-list"); value.Exists() {
+ data.Ipv6Addresses = make([]InterfacePortChannelIpv6Addresses, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := InterfacePortChannelIpv6Addresses{}
+ if cValue := v.Get("prefix"); cValue.Exists() {
+ item.Prefix = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("eui-64"); cValue.Exists() {
+ item.Eui64 = types.BoolValue(true)
+ } else {
+ item.Eui64 = types.BoolValue(false)
+ }
+ data.Ipv6Addresses = append(data.Ipv6Addresses, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + "arp.timeout"); value.Exists() {
+ data.ArpTimeout = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "ip.arp.inspection.trust"); value.Exists() {
+ data.IpArpInspectionTrust = types.BoolValue(true)
+ } else {
+ data.IpArpInspectionTrust = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "ip.arp.inspection.limit.rate"); value.Exists() {
+ data.IpArpInspectionLimitRate = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-spanning-tree:spanning-tree.link-type"); value.Exists() {
+ data.SpanningTreeLinkType = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "ip.dhcp.Cisco-IOS-XE-dhcp:snooping.trust"); value.Exists() {
+ data.IpDhcpSnoopingTrust = types.BoolValue(true)
+ } else {
+ data.IpDhcpSnoopingTrust = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "load-interval"); value.Exists() {
+ data.LoadInterval = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:snmp.trap.link-status"); value.Exists() {
+ data.SnmpTrapLinkStatus = types.BoolValue(value.Bool())
+ } else {
+ data.SnmpTrapLinkStatus = types.BoolNull()
+ }
+ if value := res.Get(prefix + "logging.event.link-status-enable"); value.Exists() {
+ data.LoggingEventLinkStatusEnable = types.BoolValue(value.Bool())
+ } else {
+ data.LoggingEventLinkStatusEnable = types.BoolNull()
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-switch:device-tracking"); value.Exists() {
+ data.DeviceTracking = types.BoolValue(true)
+ } else {
+ data.DeviceTracking = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-switch:device-tracking.attached-policies"); value.Exists() {
+ data.DeviceTrackingAttachedPolicies = make([]InterfacePortChannelDeviceTrackingAttachedPolicies, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := InterfacePortChannelDeviceTrackingAttachedPolicies{}
+ if cValue := v.Get("attach-policy"); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ data.DeviceTrackingAttachedPolicies = append(data.DeviceTrackingAttachedPolicies, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-ethernet:negotiation.auto"); value.Exists() {
+ data.NegotiationAuto = types.BoolValue(value.Bool())
+ } else {
+ data.NegotiationAuto = types.BoolNull()
+ }
+}
+
+// End of section. //template:end fromBodyData
+
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyXML
+
+func (data *InterfacePortChannel) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/description"); value.Exists() {
+ data.Description = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/shutdown"); value.Exists() {
+ data.Shutdown = types.BoolValue(true)
+ } else {
+ data.Shutdown = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/switchport-conf/switchport"); value.Exists() {
+ data.Switchport = types.BoolValue(value.Bool())
+ } else {
+ data.Switchport = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/proxy-arp"); value.Exists() {
+ data.IpProxyArp = types.BoolValue(value.Bool())
+ } else {
+ data.IpProxyArp = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/redirects"); value.Exists() {
+ data.IpRedirects = types.BoolValue(value.Bool())
+ } else {
+ data.IpRedirects = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/Cisco-IOS-XE-icmp:unreachables"); value.Exists() {
+ data.IpUnreachables = types.BoolValue(value.Bool())
+ } else {
+ data.IpUnreachables = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/vrf/forwarding"); value.Exists() {
+ data.VrfForwarding = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/address/primary/address"); value.Exists() {
+ data.Ipv4Address = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/address/primary/mask"); value.Exists() {
+ data.Ipv4AddressMask = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/access-group/in/acl/in"); value.Exists() {
+ data.IpAccessGroupInEnable = types.BoolValue(true)
+ } else {
+ data.IpAccessGroupInEnable = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/access-group/in/acl/acl-name"); value.Exists() {
+ data.IpAccessGroupIn = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/access-group/out/acl/out"); value.Exists() {
+ data.IpAccessGroupOutEnable = types.BoolValue(true)
+ } else {
+ data.IpAccessGroupOutEnable = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/access-group/out/acl/acl-name"); value.Exists() {
+ data.IpAccessGroupOut = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/dhcp/Cisco-IOS-XE-dhcp:relay/source-interface"); value.Exists() {
+ data.IpDhcpRelaySourceInterface = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-spanning-tree:spanning-tree/guard"); value.Exists() {
+ data.SpanningTreeGuard = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/classify"); value.Exists() {
+ data.AutoQosClassify = types.BoolValue(true)
+ } else {
+ data.AutoQosClassify = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/classify/police"); value.Exists() {
+ data.AutoQosClassifyPolice = types.BoolValue(true)
+ } else {
+ data.AutoQosClassifyPolice = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/trust"); value.Exists() {
+ data.AutoQosTrust = types.BoolValue(true)
+ } else {
+ data.AutoQosTrust = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/trust/cos"); value.Exists() {
+ data.AutoQosTrustCos = types.BoolValue(true)
+ } else {
+ data.AutoQosTrustCos = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/trust/dscp"); value.Exists() {
+ data.AutoQosTrustDscp = types.BoolValue(true)
+ } else {
+ data.AutoQosTrustDscp = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/video/cts"); value.Exists() {
+ data.AutoQosVideoCts = types.BoolValue(true)
+ } else {
+ data.AutoQosVideoCts = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/video/ip-camera"); value.Exists() {
+ data.AutoQosVideoIpCamera = types.BoolValue(true)
+ } else {
+ data.AutoQosVideoIpCamera = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/video/media-player"); value.Exists() {
+ data.AutoQosVideoMediaPlayer = types.BoolValue(true)
+ } else {
+ data.AutoQosVideoMediaPlayer = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/voip"); value.Exists() {
+ data.AutoQosVoip = types.BoolValue(true)
+ } else {
+ data.AutoQosVoip = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/voip/cisco-phone"); value.Exists() {
+ data.AutoQosVoipCiscoPhone = types.BoolValue(true)
+ } else {
+ data.AutoQosVoipCiscoPhone = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/voip/cisco-softphone"); value.Exists() {
+ data.AutoQosVoipCiscoSoftphone = types.BoolValue(true)
+ } else {
+ data.AutoQosVoipCiscoSoftphone = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/voip/trust"); value.Exists() {
+ data.AutoQosVoipTrust = types.BoolValue(true)
+ } else {
+ data.AutoQosVoipTrust = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/trust/device"); value.Exists() {
+ data.TrustDevice = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/helper-address"); value.Exists() {
+ data.HelperAddresses = make([]InterfacePortChannelHelperAddresses, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := InterfacePortChannelHelperAddresses{}
+ if cValue := helpers.GetFromXPath(v, "address"); cValue.Exists() {
+ item.Address = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "global"); cValue.Exists() {
+ item.Global = types.BoolValue(true)
+ } else {
+ item.Global = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "vrf"); cValue.Exists() {
+ item.Vrf = types.StringValue(cValue.String())
+ }
+ data.HelperAddresses = append(data.HelperAddresses, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/bfd/Cisco-IOS-XE-bfd:template"); value.Exists() {
+ data.BfdTemplate = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/bfd/Cisco-IOS-XE-bfd:enable"); value.Exists() {
+ data.BfdEnable = types.BoolValue(value.Bool())
+ } else {
+ data.BfdEnable = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/bfd/Cisco-IOS-XE-bfd:local-address"); value.Exists() {
+ data.BfdLocalAddress = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/bfd/Cisco-IOS-XE-bfd:interval-interface/msecs"); value.Exists() {
+ data.BfdInterval = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/bfd/Cisco-IOS-XE-bfd:interval-interface/min_rx"); value.Exists() {
+ data.BfdIntervalMinRx = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/bfd/Cisco-IOS-XE-bfd:interval-interface/multiplier"); value.Exists() {
+ data.BfdIntervalMultiplier = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/bfd/Cisco-IOS-XE-bfd:echo"); value.Exists() {
+ data.BfdEcho = types.BoolValue(value.Bool())
+ } else {
+ data.BfdEcho = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ipv6/enable"); value.Exists() {
+ data.Ipv6Enable = types.BoolValue(true)
+ } else {
+ data.Ipv6Enable = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ipv6/mtu"); value.Exists() {
+ data.Ipv6Mtu = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ipv6/nd/Cisco-IOS-XE-nd:ra/suppress/all"); value.Exists() {
+ data.Ipv6NdRaSuppressAll = types.BoolValue(true)
+ } else {
+ data.Ipv6NdRaSuppressAll = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ipv6/address/autoconfig/default"); value.Exists() {
+ data.Ipv6AddressAutoconfigDefault = types.BoolValue(true)
+ } else {
+ data.Ipv6AddressAutoconfigDefault = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ipv6/address/dhcp"); value.Exists() {
+ data.Ipv6AddressDhcp = types.BoolValue(true)
+ } else {
+ data.Ipv6AddressDhcp = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ipv6/address/link-local-address"); value.Exists() {
+ data.Ipv6LinkLocalAddresses = make([]InterfacePortChannelIpv6LinkLocalAddresses, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := InterfacePortChannelIpv6LinkLocalAddresses{}
+ if cValue := helpers.GetFromXPath(v, "address"); cValue.Exists() {
+ item.Address = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "link-local"); cValue.Exists() {
+ item.LinkLocal = types.BoolValue(true)
+ } else {
+ item.LinkLocal = types.BoolValue(false)
+ }
+ data.Ipv6LinkLocalAddresses = append(data.Ipv6LinkLocalAddresses, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ipv6/address/prefix-list"); value.Exists() {
+ data.Ipv6Addresses = make([]InterfacePortChannelIpv6Addresses, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := InterfacePortChannelIpv6Addresses{}
+ if cValue := helpers.GetFromXPath(v, "prefix"); cValue.Exists() {
+ item.Prefix = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "eui-64"); cValue.Exists() {
+ item.Eui64 = types.BoolValue(true)
+ } else {
+ item.Eui64 = types.BoolValue(false)
+ }
+ data.Ipv6Addresses = append(data.Ipv6Addresses, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/arp/timeout"); value.Exists() {
+ data.ArpTimeout = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/arp/inspection/trust"); value.Exists() {
+ data.IpArpInspectionTrust = types.BoolValue(true)
+ } else {
+ data.IpArpInspectionTrust = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/arp/inspection/limit/rate"); value.Exists() {
+ data.IpArpInspectionLimitRate = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-spanning-tree:spanning-tree/link-type"); value.Exists() {
+ data.SpanningTreeLinkType = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/dhcp/Cisco-IOS-XE-dhcp:snooping/trust"); value.Exists() {
+ data.IpDhcpSnoopingTrust = types.BoolValue(true)
+ } else {
+ data.IpDhcpSnoopingTrust = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/load-interval"); value.Exists() {
+ data.LoadInterval = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:snmp/trap/link-status"); value.Exists() {
+ data.SnmpTrapLinkStatus = types.BoolValue(value.Bool())
+ } else {
+ data.SnmpTrapLinkStatus = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/logging/event/link-status-enable"); value.Exists() {
+ data.LoggingEventLinkStatusEnable = types.BoolValue(value.Bool())
+ } else {
+ data.LoggingEventLinkStatusEnable = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-switch:device-tracking"); value.Exists() {
+ data.DeviceTracking = types.BoolValue(true)
+ } else {
+ data.DeviceTracking = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-switch:device-tracking/attached-policies"); value.Exists() {
+ data.DeviceTrackingAttachedPolicies = make([]InterfacePortChannelDeviceTrackingAttachedPolicies, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := InterfacePortChannelDeviceTrackingAttachedPolicies{}
+ if cValue := helpers.GetFromXPath(v, "attach-policy"); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ data.DeviceTrackingAttachedPolicies = append(data.DeviceTrackingAttachedPolicies, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-ethernet:negotiation/auto"); value.Exists() {
+ data.NegotiationAuto = types.BoolValue(value.Bool())
+ } else {
+ data.NegotiationAuto = types.BoolNull()
+ }
+}
+
+// End of section. //template:end fromBodyXML
+
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyDataXML
+
+func (data *InterfacePortChannelData) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/description"); value.Exists() {
+ data.Description = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/shutdown"); value.Exists() {
+ data.Shutdown = types.BoolValue(true)
+ } else {
+ data.Shutdown = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/switchport-conf/switchport"); value.Exists() {
+ data.Switchport = types.BoolValue(value.Bool())
+ } else {
+ data.Switchport = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/proxy-arp"); value.Exists() {
+ data.IpProxyArp = types.BoolValue(value.Bool())
+ } else {
+ data.IpProxyArp = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/redirects"); value.Exists() {
+ data.IpRedirects = types.BoolValue(value.Bool())
+ } else {
+ data.IpRedirects = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/Cisco-IOS-XE-icmp:unreachables"); value.Exists() {
+ data.IpUnreachables = types.BoolValue(value.Bool())
+ } else {
+ data.IpUnreachables = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/vrf/forwarding"); value.Exists() {
+ data.VrfForwarding = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/address/primary/address"); value.Exists() {
+ data.Ipv4Address = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/address/primary/mask"); value.Exists() {
+ data.Ipv4AddressMask = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/access-group/in/acl/in"); value.Exists() {
+ data.IpAccessGroupInEnable = types.BoolValue(true)
+ } else {
+ data.IpAccessGroupInEnable = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/access-group/in/acl/acl-name"); value.Exists() {
+ data.IpAccessGroupIn = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/access-group/out/acl/out"); value.Exists() {
+ data.IpAccessGroupOutEnable = types.BoolValue(true)
+ } else {
+ data.IpAccessGroupOutEnable = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/access-group/out/acl/acl-name"); value.Exists() {
+ data.IpAccessGroupOut = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/dhcp/Cisco-IOS-XE-dhcp:relay/source-interface"); value.Exists() {
+ data.IpDhcpRelaySourceInterface = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-spanning-tree:spanning-tree/guard"); value.Exists() {
+ data.SpanningTreeGuard = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/classify"); value.Exists() {
+ data.AutoQosClassify = types.BoolValue(true)
+ } else {
+ data.AutoQosClassify = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/classify/police"); value.Exists() {
+ data.AutoQosClassifyPolice = types.BoolValue(true)
+ } else {
+ data.AutoQosClassifyPolice = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/trust"); value.Exists() {
+ data.AutoQosTrust = types.BoolValue(true)
+ } else {
+ data.AutoQosTrust = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/trust/cos"); value.Exists() {
+ data.AutoQosTrustCos = types.BoolValue(true)
+ } else {
+ data.AutoQosTrustCos = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/trust/dscp"); value.Exists() {
+ data.AutoQosTrustDscp = types.BoolValue(true)
+ } else {
+ data.AutoQosTrustDscp = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/video/cts"); value.Exists() {
+ data.AutoQosVideoCts = types.BoolValue(true)
+ } else {
+ data.AutoQosVideoCts = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/video/ip-camera"); value.Exists() {
+ data.AutoQosVideoIpCamera = types.BoolValue(true)
+ } else {
+ data.AutoQosVideoIpCamera = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/video/media-player"); value.Exists() {
+ data.AutoQosVideoMediaPlayer = types.BoolValue(true)
+ } else {
+ data.AutoQosVideoMediaPlayer = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/voip"); value.Exists() {
+ data.AutoQosVoip = types.BoolValue(true)
+ } else {
+ data.AutoQosVoip = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/voip/cisco-phone"); value.Exists() {
+ data.AutoQosVoipCiscoPhone = types.BoolValue(true)
+ } else {
+ data.AutoQosVoipCiscoPhone = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/voip/cisco-softphone"); value.Exists() {
+ data.AutoQosVoipCiscoSoftphone = types.BoolValue(true)
+ } else {
+ data.AutoQosVoipCiscoSoftphone = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/voip/trust"); value.Exists() {
+ data.AutoQosVoipTrust = types.BoolValue(true)
+ } else {
+ data.AutoQosVoipTrust = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/trust/device"); value.Exists() {
+ data.TrustDevice = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/helper-address"); value.Exists() {
+ data.HelperAddresses = make([]InterfacePortChannelHelperAddresses, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := InterfacePortChannelHelperAddresses{}
+ if cValue := helpers.GetFromXPath(v, "address"); cValue.Exists() {
+ item.Address = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "global"); cValue.Exists() {
+ item.Global = types.BoolValue(true)
+ } else {
+ item.Global = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "vrf"); cValue.Exists() {
+ item.Vrf = types.StringValue(cValue.String())
+ }
+ data.HelperAddresses = append(data.HelperAddresses, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/bfd/Cisco-IOS-XE-bfd:template"); value.Exists() {
+ data.BfdTemplate = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/bfd/Cisco-IOS-XE-bfd:enable"); value.Exists() {
+ data.BfdEnable = types.BoolValue(value.Bool())
+ } else {
+ data.BfdEnable = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/bfd/Cisco-IOS-XE-bfd:local-address"); value.Exists() {
+ data.BfdLocalAddress = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/bfd/Cisco-IOS-XE-bfd:interval-interface/msecs"); value.Exists() {
+ data.BfdInterval = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/bfd/Cisco-IOS-XE-bfd:interval-interface/min_rx"); value.Exists() {
+ data.BfdIntervalMinRx = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/bfd/Cisco-IOS-XE-bfd:interval-interface/multiplier"); value.Exists() {
+ data.BfdIntervalMultiplier = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/bfd/Cisco-IOS-XE-bfd:echo"); value.Exists() {
+ data.BfdEcho = types.BoolValue(value.Bool())
+ } else {
+ data.BfdEcho = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ipv6/enable"); value.Exists() {
+ data.Ipv6Enable = types.BoolValue(true)
+ } else {
+ data.Ipv6Enable = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ipv6/mtu"); value.Exists() {
+ data.Ipv6Mtu = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ipv6/nd/Cisco-IOS-XE-nd:ra/suppress/all"); value.Exists() {
+ data.Ipv6NdRaSuppressAll = types.BoolValue(true)
+ } else {
+ data.Ipv6NdRaSuppressAll = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ipv6/address/autoconfig/default"); value.Exists() {
+ data.Ipv6AddressAutoconfigDefault = types.BoolValue(true)
+ } else {
+ data.Ipv6AddressAutoconfigDefault = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ipv6/address/dhcp"); value.Exists() {
+ data.Ipv6AddressDhcp = types.BoolValue(true)
+ } else {
+ data.Ipv6AddressDhcp = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ipv6/address/link-local-address"); value.Exists() {
+ data.Ipv6LinkLocalAddresses = make([]InterfacePortChannelIpv6LinkLocalAddresses, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := InterfacePortChannelIpv6LinkLocalAddresses{}
+ if cValue := helpers.GetFromXPath(v, "address"); cValue.Exists() {
+ item.Address = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "link-local"); cValue.Exists() {
+ item.LinkLocal = types.BoolValue(true)
+ } else {
+ item.LinkLocal = types.BoolValue(false)
+ }
+ data.Ipv6LinkLocalAddresses = append(data.Ipv6LinkLocalAddresses, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ipv6/address/prefix-list"); value.Exists() {
+ data.Ipv6Addresses = make([]InterfacePortChannelIpv6Addresses, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := InterfacePortChannelIpv6Addresses{}
+ if cValue := helpers.GetFromXPath(v, "prefix"); cValue.Exists() {
+ item.Prefix = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "eui-64"); cValue.Exists() {
+ item.Eui64 = types.BoolValue(true)
+ } else {
+ item.Eui64 = types.BoolValue(false)
+ }
+ data.Ipv6Addresses = append(data.Ipv6Addresses, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/arp/timeout"); value.Exists() {
+ data.ArpTimeout = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/arp/inspection/trust"); value.Exists() {
+ data.IpArpInspectionTrust = types.BoolValue(true)
+ } else {
+ data.IpArpInspectionTrust = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/arp/inspection/limit/rate"); value.Exists() {
+ data.IpArpInspectionLimitRate = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-spanning-tree:spanning-tree/link-type"); value.Exists() {
+ data.SpanningTreeLinkType = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/dhcp/Cisco-IOS-XE-dhcp:snooping/trust"); value.Exists() {
+ data.IpDhcpSnoopingTrust = types.BoolValue(true)
+ } else {
+ data.IpDhcpSnoopingTrust = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/load-interval"); value.Exists() {
+ data.LoadInterval = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:snmp/trap/link-status"); value.Exists() {
+ data.SnmpTrapLinkStatus = types.BoolValue(value.Bool())
+ } else {
+ data.SnmpTrapLinkStatus = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/logging/event/link-status-enable"); value.Exists() {
+ data.LoggingEventLinkStatusEnable = types.BoolValue(value.Bool())
+ } else {
+ data.LoggingEventLinkStatusEnable = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-switch:device-tracking"); value.Exists() {
+ data.DeviceTracking = types.BoolValue(true)
+ } else {
+ data.DeviceTracking = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-switch:device-tracking/attached-policies"); value.Exists() {
+ data.DeviceTrackingAttachedPolicies = make([]InterfacePortChannelDeviceTrackingAttachedPolicies, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := InterfacePortChannelDeviceTrackingAttachedPolicies{}
+ if cValue := helpers.GetFromXPath(v, "attach-policy"); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ data.DeviceTrackingAttachedPolicies = append(data.DeviceTrackingAttachedPolicies, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-ethernet:negotiation/auto"); value.Exists() {
+ data.NegotiationAuto = types.BoolValue(value.Bool())
+ } else {
+ data.NegotiationAuto = types.BoolNull()
+ }
+}
+
+// End of section. //template:end fromBodyDataXML
+
+// Section below is generated&owned by "gen/generator.go". //template:begin getDeletedItems
+
+func (data *InterfacePortChannel) getDeletedItems(ctx context.Context, state InterfacePortChannel) []string {
+ deletedItems := make([]string, 0)
+ if !state.NegotiationAuto.IsNull() && data.NegotiationAuto.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-ethernet:negotiation/auto", state.getPath()))
+ }
+ for i := range state.DeviceTrackingAttachedPolicies {
+ stateKeyValues := [...]string{state.DeviceTrackingAttachedPolicies[i].Name.ValueString()}
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.DeviceTrackingAttachedPolicies[i].Name.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.DeviceTrackingAttachedPolicies {
+ found = true
+ if state.DeviceTrackingAttachedPolicies[i].Name.ValueString() != data.DeviceTrackingAttachedPolicies[j].Name.ValueString() {
+ found = false
+ }
+ if found {
+ break
+ }
+ }
+ if !found {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-switch:device-tracking/attached-policies=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ }
+ if !state.DeviceTracking.IsNull() && data.DeviceTracking.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-switch:device-tracking", state.getPath()))
+ }
+ if !state.LoggingEventLinkStatusEnable.IsNull() && data.LoggingEventLinkStatusEnable.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/logging/event/link-status-enable", state.getPath()))
+ }
+ if !state.SnmpTrapLinkStatus.IsNull() && data.SnmpTrapLinkStatus.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:snmp/trap/link-status", state.getPath()))
+ }
+ if !state.LoadInterval.IsNull() && data.LoadInterval.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/load-interval", state.getPath()))
+ }
+ if !state.IpDhcpSnoopingTrust.IsNull() && data.IpDhcpSnoopingTrust.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/dhcp/Cisco-IOS-XE-dhcp:snooping/trust", state.getPath()))
+ }
+ if !state.SpanningTreeLinkType.IsNull() && data.SpanningTreeLinkType.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-spanning-tree:spanning-tree/link-type", state.getPath()))
+ }
+ if !state.IpArpInspectionLimitRate.IsNull() && data.IpArpInspectionLimitRate.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/arp/inspection/limit/rate", state.getPath()))
+ }
+ if !state.IpArpInspectionTrust.IsNull() && data.IpArpInspectionTrust.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/arp/inspection/trust", state.getPath()))
+ }
+ if !state.ArpTimeout.IsNull() && data.ArpTimeout.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/arp/timeout", state.getPath()))
+ }
+ for i := range state.Ipv6Addresses {
+ stateKeyValues := [...]string{state.Ipv6Addresses[i].Prefix.ValueString()}
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.Ipv6Addresses[i].Prefix.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.Ipv6Addresses {
+ found = true
+ if state.Ipv6Addresses[i].Prefix.ValueString() != data.Ipv6Addresses[j].Prefix.ValueString() {
+ found = false
+ }
+ if found {
+ if !state.Ipv6Addresses[i].Eui64.IsNull() && data.Ipv6Addresses[j].Eui64.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ipv6/address/prefix-list=%v/eui-64", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ break
+ }
+ }
+ if !found {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ipv6/address/prefix-list=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ }
+ for i := range state.Ipv6LinkLocalAddresses {
+ stateKeyValues := [...]string{state.Ipv6LinkLocalAddresses[i].Address.ValueString()}
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.Ipv6LinkLocalAddresses[i].Address.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.Ipv6LinkLocalAddresses {
+ found = true
+ if state.Ipv6LinkLocalAddresses[i].Address.ValueString() != data.Ipv6LinkLocalAddresses[j].Address.ValueString() {
+ found = false
+ }
+ if found {
+ if !state.Ipv6LinkLocalAddresses[i].LinkLocal.IsNull() && data.Ipv6LinkLocalAddresses[j].LinkLocal.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ipv6/address/link-local-address=%v/link-local", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ break
+ }
+ }
+ if !found {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ipv6/address/link-local-address=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ }
+ if !state.Ipv6AddressDhcp.IsNull() && data.Ipv6AddressDhcp.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ipv6/address/dhcp", state.getPath()))
+ }
+ if !state.Ipv6AddressAutoconfigDefault.IsNull() && data.Ipv6AddressAutoconfigDefault.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ipv6/address/autoconfig/default", state.getPath()))
+ }
+ if !state.Ipv6NdRaSuppressAll.IsNull() && data.Ipv6NdRaSuppressAll.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ipv6/nd/Cisco-IOS-XE-nd:ra/suppress/all", state.getPath()))
+ }
+ if !state.Ipv6Mtu.IsNull() && data.Ipv6Mtu.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ipv6/mtu", state.getPath()))
+ }
+ if !state.Ipv6Enable.IsNull() && data.Ipv6Enable.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ipv6/enable", state.getPath()))
+ }
+ if !state.BfdEcho.IsNull() && data.BfdEcho.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/bfd/Cisco-IOS-XE-bfd:echo", state.getPath()))
+ }
+ if !state.BfdIntervalMultiplier.IsNull() && data.BfdIntervalMultiplier.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/bfd/Cisco-IOS-XE-bfd:interval-interface", state.getPath()))
+ }
+ if !state.BfdIntervalMinRx.IsNull() && data.BfdIntervalMinRx.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/bfd/Cisco-IOS-XE-bfd:interval-interface", state.getPath()))
+ }
+ if !state.BfdInterval.IsNull() && data.BfdInterval.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/bfd/Cisco-IOS-XE-bfd:interval-interface", state.getPath()))
+ }
+ if !state.BfdLocalAddress.IsNull() && data.BfdLocalAddress.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/bfd/Cisco-IOS-XE-bfd:local-address", state.getPath()))
+ }
+ if !state.BfdEnable.IsNull() && data.BfdEnable.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/bfd/Cisco-IOS-XE-bfd:enable", state.getPath()))
+ }
+ if !state.BfdTemplate.IsNull() && data.BfdTemplate.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/bfd/Cisco-IOS-XE-bfd:template", state.getPath()))
+ }
+ for i := range state.HelperAddresses {
+ stateKeyValues := [...]string{state.HelperAddresses[i].Address.ValueString()}
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.HelperAddresses[i].Address.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.HelperAddresses {
+ found = true
+ if state.HelperAddresses[i].Address.ValueString() != data.HelperAddresses[j].Address.ValueString() {
+ found = false
+ }
+ if found {
+ if !state.HelperAddresses[i].Vrf.IsNull() && data.HelperAddresses[j].Vrf.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/helper-address=%v/vrf", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ if !state.HelperAddresses[i].Global.IsNull() && data.HelperAddresses[j].Global.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/helper-address=%v/global", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ break
+ }
+ }
+ if !found {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/helper-address=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ }
+ if !state.TrustDevice.IsNull() && data.TrustDevice.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/trust/device", state.getPath()))
+ }
+ if !state.AutoQosVoipTrust.IsNull() && data.AutoQosVoipTrust.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-switch:auto/qos/voip/trust", state.getPath()))
+ }
+ if !state.AutoQosVoipCiscoSoftphone.IsNull() && data.AutoQosVoipCiscoSoftphone.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-switch:auto/qos/voip/cisco-softphone", state.getPath()))
+ }
+ if !state.AutoQosVoipCiscoPhone.IsNull() && data.AutoQosVoipCiscoPhone.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-switch:auto/qos/voip/cisco-phone", state.getPath()))
+ }
+ if !state.AutoQosVoip.IsNull() && data.AutoQosVoip.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-switch:auto/qos/voip", state.getPath()))
+ }
+ if !state.AutoQosVideoMediaPlayer.IsNull() && data.AutoQosVideoMediaPlayer.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-switch:auto/qos/video/media-player", state.getPath()))
+ }
+ if !state.AutoQosVideoIpCamera.IsNull() && data.AutoQosVideoIpCamera.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-switch:auto/qos/video/ip-camera", state.getPath()))
+ }
+ if !state.AutoQosVideoCts.IsNull() && data.AutoQosVideoCts.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-switch:auto/qos/video/cts", state.getPath()))
+ }
+ if !state.AutoQosTrustDscp.IsNull() && data.AutoQosTrustDscp.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-switch:auto/qos/trust/dscp", state.getPath()))
+ }
+ if !state.AutoQosTrustCos.IsNull() && data.AutoQosTrustCos.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-switch:auto/qos/trust/cos", state.getPath()))
+ }
+ if !state.AutoQosTrust.IsNull() && data.AutoQosTrust.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-switch:auto/qos/trust", state.getPath()))
+ }
+ if !state.AutoQosClassifyPolice.IsNull() && data.AutoQosClassifyPolice.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-switch:auto/qos/classify/police", state.getPath()))
+ }
+ if !state.AutoQosClassify.IsNull() && data.AutoQosClassify.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-switch:auto/qos/classify", state.getPath()))
+ }
+ if !state.SpanningTreeGuard.IsNull() && data.SpanningTreeGuard.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-spanning-tree:spanning-tree/guard", state.getPath()))
+ }
+ if !state.IpDhcpRelaySourceInterface.IsNull() && data.IpDhcpRelaySourceInterface.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/dhcp/Cisco-IOS-XE-dhcp:relay/source-interface", state.getPath()))
+ }
+ if !state.IpAccessGroupOut.IsNull() && data.IpAccessGroupOut.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/access-group/out/acl", state.getPath()))
+ }
+ if !state.IpAccessGroupOutEnable.IsNull() && data.IpAccessGroupOutEnable.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/access-group/out/acl/out", state.getPath()))
+ }
+ if !state.IpAccessGroupIn.IsNull() && data.IpAccessGroupIn.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/access-group/in/acl", state.getPath()))
+ }
+ if !state.IpAccessGroupInEnable.IsNull() && data.IpAccessGroupInEnable.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/access-group/in/acl/in", state.getPath()))
+ }
+ if !state.Ipv4AddressMask.IsNull() && data.Ipv4AddressMask.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/address/primary", state.getPath()))
+ }
+ if !state.Ipv4Address.IsNull() && data.Ipv4Address.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/address/primary", state.getPath()))
+ }
+ if !state.VrfForwarding.IsNull() && data.VrfForwarding.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/vrf", state.getPath()))
+ }
+ if !state.IpUnreachables.IsNull() && data.IpUnreachables.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/Cisco-IOS-XE-icmp:unreachables", state.getPath()))
+ }
+ if !state.IpRedirects.IsNull() && data.IpRedirects.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/redirects", state.getPath()))
+ }
+ if !state.IpProxyArp.IsNull() && data.IpProxyArp.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/proxy-arp", state.getPath()))
+ }
+ if !state.Switchport.IsNull() && data.Switchport.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/switchport-conf/switchport", state.getPath()))
+ }
+ if !state.Shutdown.IsNull() && data.Shutdown.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/shutdown", state.getPath()))
+ }
+ if !state.Description.IsNull() && data.Description.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/description", state.getPath()))
+ }
+
+ return deletedItems
+}
+
+// End of section. //template:end getDeletedItems
+
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletedItemsXML
+
+func (data *InterfacePortChannel) addDeletedItemsXML(ctx context.Context, state InterfacePortChannel, body string) string {
+ b := netconf.NewBody(body)
+ if !state.Description.IsNull() && data.Description.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/description")
+ }
+ if !state.Shutdown.IsNull() && data.Shutdown.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/shutdown")
+ }
+ if !state.Switchport.IsNull() && data.Switchport.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/switchport-conf/switchport")
+ }
+ if !state.IpProxyArp.IsNull() && data.IpProxyArp.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ip/proxy-arp")
}
- if value := res.Get(prefix + "bfd.Cisco-IOS-XE-bfd:local-address"); value.Exists() {
- data.BfdLocalAddress = types.StringValue(value.String())
+ if !state.IpRedirects.IsNull() && data.IpRedirects.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ip/redirects")
}
- if value := res.Get(prefix + "bfd.Cisco-IOS-XE-bfd:interval-interface.msecs"); value.Exists() {
- data.BfdInterval = types.Int64Value(value.Int())
+ if !state.IpUnreachables.IsNull() && data.IpUnreachables.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ip/Cisco-IOS-XE-icmp:unreachables")
}
- if value := res.Get(prefix + "bfd.Cisco-IOS-XE-bfd:interval-interface.min_rx"); value.Exists() {
- data.BfdIntervalMinRx = types.Int64Value(value.Int())
+ if !state.VrfForwarding.IsNull() && data.VrfForwarding.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/vrf/forwarding")
}
- if value := res.Get(prefix + "bfd.Cisco-IOS-XE-bfd:interval-interface.multiplier"); value.Exists() {
- data.BfdIntervalMultiplier = types.Int64Value(value.Int())
+ if !state.Ipv4Address.IsNull() && data.Ipv4Address.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ip/address/primary/address")
}
- if value := res.Get(prefix + "bfd.Cisco-IOS-XE-bfd:echo"); value.Exists() {
- data.BfdEcho = types.BoolValue(value.Bool())
- } else {
- data.BfdEcho = types.BoolNull()
+ if !state.Ipv4AddressMask.IsNull() && data.Ipv4AddressMask.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ip/address/primary/mask")
}
- if value := res.Get(prefix + "ipv6.enable"); value.Exists() {
- data.Ipv6Enable = types.BoolValue(true)
- } else {
- data.Ipv6Enable = types.BoolValue(false)
+ if !state.IpAccessGroupInEnable.IsNull() && data.IpAccessGroupInEnable.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ip/access-group/in/acl/in")
}
- if value := res.Get(prefix + "ipv6.mtu"); value.Exists() {
- data.Ipv6Mtu = types.Int64Value(value.Int())
+ if !state.IpAccessGroupIn.IsNull() && data.IpAccessGroupIn.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ip/access-group/in/acl/acl-name")
}
- if value := res.Get(prefix + "ipv6.nd.Cisco-IOS-XE-nd:ra.suppress.all"); value.Exists() {
- data.Ipv6NdRaSuppressAll = types.BoolValue(true)
- } else {
- data.Ipv6NdRaSuppressAll = types.BoolValue(false)
+ if !state.IpAccessGroupOutEnable.IsNull() && data.IpAccessGroupOutEnable.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ip/access-group/out/acl/out")
}
- if value := res.Get(prefix + "ipv6.address.autoconfig.default"); value.Exists() {
- data.Ipv6AddressAutoconfigDefault = types.BoolValue(true)
- } else {
- data.Ipv6AddressAutoconfigDefault = types.BoolValue(false)
+ if !state.IpAccessGroupOut.IsNull() && data.IpAccessGroupOut.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ip/access-group/out/acl/acl-name")
}
- if value := res.Get(prefix + "ipv6.address.dhcp"); value.Exists() {
- data.Ipv6AddressDhcp = types.BoolValue(true)
- } else {
- data.Ipv6AddressDhcp = types.BoolValue(false)
+ if !state.IpDhcpRelaySourceInterface.IsNull() && data.IpDhcpRelaySourceInterface.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ip/dhcp/Cisco-IOS-XE-dhcp:relay/source-interface")
}
- if value := res.Get(prefix + "ipv6.address.link-local-address"); value.Exists() {
- data.Ipv6LinkLocalAddresses = make([]InterfacePortChannelIpv6LinkLocalAddresses, 0)
- value.ForEach(func(k, v gjson.Result) bool {
- item := InterfacePortChannelIpv6LinkLocalAddresses{}
- if cValue := v.Get("address"); cValue.Exists() {
- item.Address = types.StringValue(cValue.String())
- }
- if cValue := v.Get("link-local"); cValue.Exists() {
- item.LinkLocal = types.BoolValue(true)
- } else {
- item.LinkLocal = types.BoolValue(false)
- }
- data.Ipv6LinkLocalAddresses = append(data.Ipv6LinkLocalAddresses, item)
- return true
- })
+ if !state.SpanningTreeGuard.IsNull() && data.SpanningTreeGuard.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-spanning-tree:spanning-tree/guard")
}
- if value := res.Get(prefix + "ipv6.address.prefix-list"); value.Exists() {
- data.Ipv6Addresses = make([]InterfacePortChannelIpv6Addresses, 0)
- value.ForEach(func(k, v gjson.Result) bool {
- item := InterfacePortChannelIpv6Addresses{}
- if cValue := v.Get("prefix"); cValue.Exists() {
- item.Prefix = types.StringValue(cValue.String())
- }
- if cValue := v.Get("eui-64"); cValue.Exists() {
- item.Eui64 = types.BoolValue(true)
- } else {
- item.Eui64 = types.BoolValue(false)
- }
- data.Ipv6Addresses = append(data.Ipv6Addresses, item)
- return true
- })
+ if !state.AutoQosClassify.IsNull() && data.AutoQosClassify.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/classify")
}
- if value := res.Get(prefix + "arp.timeout"); value.Exists() {
- data.ArpTimeout = types.Int64Value(value.Int())
+ if !state.AutoQosClassifyPolice.IsNull() && data.AutoQosClassifyPolice.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/classify/police")
}
- if value := res.Get(prefix + "ip.arp.inspection.trust"); value.Exists() {
- data.IpArpInspectionTrust = types.BoolValue(true)
- } else {
- data.IpArpInspectionTrust = types.BoolValue(false)
+ if !state.AutoQosTrust.IsNull() && data.AutoQosTrust.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/trust")
}
- if value := res.Get(prefix + "ip.arp.inspection.limit.rate"); value.Exists() {
- data.IpArpInspectionLimitRate = types.Int64Value(value.Int())
+ if !state.AutoQosTrustCos.IsNull() && data.AutoQosTrustCos.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/trust/cos")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-spanning-tree:spanning-tree.link-type"); value.Exists() {
- data.SpanningTreeLinkType = types.StringValue(value.String())
+ if !state.AutoQosTrustDscp.IsNull() && data.AutoQosTrustDscp.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/trust/dscp")
}
- if value := res.Get(prefix + "ip.dhcp.Cisco-IOS-XE-dhcp:snooping.trust"); value.Exists() {
- data.IpDhcpSnoopingTrust = types.BoolValue(true)
- } else {
- data.IpDhcpSnoopingTrust = types.BoolValue(false)
+ if !state.AutoQosVideoCts.IsNull() && data.AutoQosVideoCts.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/video/cts")
}
- if value := res.Get(prefix + "load-interval"); value.Exists() {
- data.LoadInterval = types.Int64Value(value.Int())
+ if !state.AutoQosVideoIpCamera.IsNull() && data.AutoQosVideoIpCamera.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/video/ip-camera")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:snmp.trap.link-status"); value.Exists() {
- data.SnmpTrapLinkStatus = types.BoolValue(value.Bool())
- } else {
- data.SnmpTrapLinkStatus = types.BoolNull()
+ if !state.AutoQosVideoMediaPlayer.IsNull() && data.AutoQosVideoMediaPlayer.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/video/media-player")
}
- if value := res.Get(prefix + "logging.event.link-status-enable"); value.Exists() {
- data.LoggingEventLinkStatusEnable = types.BoolValue(value.Bool())
- } else {
- data.LoggingEventLinkStatusEnable = types.BoolNull()
+ if !state.AutoQosVoip.IsNull() && data.AutoQosVoip.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/voip")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-switch:device-tracking"); value.Exists() {
- data.DeviceTracking = types.BoolValue(true)
- } else {
- data.DeviceTracking = types.BoolValue(false)
+ if !state.AutoQosVoipCiscoPhone.IsNull() && data.AutoQosVoipCiscoPhone.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/voip/cisco-phone")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-switch:device-tracking.attached-policies"); value.Exists() {
- data.DeviceTrackingAttachedPolicies = make([]InterfacePortChannelDeviceTrackingAttachedPolicies, 0)
- value.ForEach(func(k, v gjson.Result) bool {
- item := InterfacePortChannelDeviceTrackingAttachedPolicies{}
- if cValue := v.Get("attach-policy"); cValue.Exists() {
- item.Name = types.StringValue(cValue.String())
- }
- data.DeviceTrackingAttachedPolicies = append(data.DeviceTrackingAttachedPolicies, item)
- return true
- })
+ if !state.AutoQosVoipCiscoSoftphone.IsNull() && data.AutoQosVoipCiscoSoftphone.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/voip/cisco-softphone")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-ethernet:negotiation.auto"); value.Exists() {
- data.NegotiationAuto = types.BoolValue(value.Bool())
- } else {
- data.NegotiationAuto = types.BoolNull()
+ if !state.AutoQosVoipTrust.IsNull() && data.AutoQosVoipTrust.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/voip/trust")
}
-}
-
-// End of section. //template:end fromBodyData
-
-// Section below is generated&owned by "gen/generator.go". //template:begin getDeletedItems
-
-func (data *InterfacePortChannel) getDeletedItems(ctx context.Context, state InterfacePortChannel) []string {
- deletedItems := make([]string, 0)
- if !state.NegotiationAuto.IsNull() && data.NegotiationAuto.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-ethernet:negotiation/auto", state.getPath()))
+ if !state.TrustDevice.IsNull() && data.TrustDevice.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/trust/device")
}
- for i := range state.DeviceTrackingAttachedPolicies {
- stateKeyValues := [...]string{state.DeviceTrackingAttachedPolicies[i].Name.ValueString()}
+ for i := range state.HelperAddresses {
+ stateKeys := [...]string{"address"}
+ stateKeyValues := [...]string{state.HelperAddresses[i].Address.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
emptyKeys := true
- if !reflect.ValueOf(state.DeviceTrackingAttachedPolicies[i].Name.ValueString()).IsZero() {
+ if !reflect.ValueOf(state.HelperAddresses[i].Address.ValueString()).IsZero() {
emptyKeys = false
}
if emptyKeys {
@@ -1565,76 +3331,68 @@ func (data *InterfacePortChannel) getDeletedItems(ctx context.Context, state Int
}
found := false
- for j := range data.DeviceTrackingAttachedPolicies {
+ for j := range data.HelperAddresses {
found = true
- if state.DeviceTrackingAttachedPolicies[i].Name.ValueString() != data.DeviceTrackingAttachedPolicies[j].Name.ValueString() {
+ if state.HelperAddresses[i].Address.ValueString() != data.HelperAddresses[j].Address.ValueString() {
found = false
}
if found {
+ if !state.HelperAddresses[i].Global.IsNull() && data.HelperAddresses[j].Global.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/ip/helper-address%v/global", predicates))
+ }
+ if !state.HelperAddresses[i].Vrf.IsNull() && data.HelperAddresses[j].Vrf.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/ip/helper-address%v/vrf", predicates))
+ }
break
}
}
if !found {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-switch:device-tracking/attached-policies=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/ip/helper-address%v", predicates))
}
}
- if !state.DeviceTracking.IsNull() && data.DeviceTracking.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-switch:device-tracking", state.getPath()))
+ if !state.BfdTemplate.IsNull() && data.BfdTemplate.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/bfd/Cisco-IOS-XE-bfd:template")
}
- if !state.LoggingEventLinkStatusEnable.IsNull() && data.LoggingEventLinkStatusEnable.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/logging/event/link-status-enable", state.getPath()))
+ if !state.BfdEnable.IsNull() && data.BfdEnable.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/bfd/Cisco-IOS-XE-bfd:enable")
}
- if !state.SnmpTrapLinkStatus.IsNull() && data.SnmpTrapLinkStatus.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:snmp/trap/link-status", state.getPath()))
+ if !state.BfdLocalAddress.IsNull() && data.BfdLocalAddress.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/bfd/Cisco-IOS-XE-bfd:local-address")
}
- if !state.LoadInterval.IsNull() && data.LoadInterval.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/load-interval", state.getPath()))
+ if !state.BfdInterval.IsNull() && data.BfdInterval.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/bfd/Cisco-IOS-XE-bfd:interval-interface/msecs")
}
- if !state.IpDhcpSnoopingTrust.IsNull() && data.IpDhcpSnoopingTrust.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/dhcp/Cisco-IOS-XE-dhcp:snooping/trust", state.getPath()))
+ if !state.BfdIntervalMinRx.IsNull() && data.BfdIntervalMinRx.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/bfd/Cisco-IOS-XE-bfd:interval-interface/min_rx")
}
- if !state.SpanningTreeLinkType.IsNull() && data.SpanningTreeLinkType.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-spanning-tree:spanning-tree/link-type", state.getPath()))
+ if !state.BfdIntervalMultiplier.IsNull() && data.BfdIntervalMultiplier.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/bfd/Cisco-IOS-XE-bfd:interval-interface/multiplier")
}
- if !state.IpArpInspectionLimitRate.IsNull() && data.IpArpInspectionLimitRate.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/arp/inspection/limit/rate", state.getPath()))
+ if !state.BfdEcho.IsNull() && data.BfdEcho.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/bfd/Cisco-IOS-XE-bfd:echo")
}
- if !state.IpArpInspectionTrust.IsNull() && data.IpArpInspectionTrust.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/arp/inspection/trust", state.getPath()))
+ if !state.Ipv6Enable.IsNull() && data.Ipv6Enable.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ipv6/enable")
}
- if !state.ArpTimeout.IsNull() && data.ArpTimeout.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/arp/timeout", state.getPath()))
+ if !state.Ipv6Mtu.IsNull() && data.Ipv6Mtu.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ipv6/mtu")
}
- for i := range state.Ipv6Addresses {
- stateKeyValues := [...]string{state.Ipv6Addresses[i].Prefix.ValueString()}
-
- emptyKeys := true
- if !reflect.ValueOf(state.Ipv6Addresses[i].Prefix.ValueString()).IsZero() {
- emptyKeys = false
- }
- if emptyKeys {
- continue
- }
-
- found := false
- for j := range data.Ipv6Addresses {
- found = true
- if state.Ipv6Addresses[i].Prefix.ValueString() != data.Ipv6Addresses[j].Prefix.ValueString() {
- found = false
- }
- if found {
- if !state.Ipv6Addresses[i].Eui64.IsNull() && data.Ipv6Addresses[j].Eui64.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ipv6/address/prefix-list=%v/eui-64", state.getPath(), strings.Join(stateKeyValues[:], ",")))
- }
- break
- }
- }
- if !found {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ipv6/address/prefix-list=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
- }
+ if !state.Ipv6NdRaSuppressAll.IsNull() && data.Ipv6NdRaSuppressAll.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ipv6/nd/Cisco-IOS-XE-nd:ra/suppress/all")
+ }
+ if !state.Ipv6AddressAutoconfigDefault.IsNull() && data.Ipv6AddressAutoconfigDefault.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ipv6/address/autoconfig/default")
+ }
+ if !state.Ipv6AddressDhcp.IsNull() && data.Ipv6AddressDhcp.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ipv6/address/dhcp")
}
for i := range state.Ipv6LinkLocalAddresses {
+ stateKeys := [...]string{"address"}
stateKeyValues := [...]string{state.Ipv6LinkLocalAddresses[i].Address.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
emptyKeys := true
if !reflect.ValueOf(state.Ipv6LinkLocalAddresses[i].Address.ValueString()).IsZero() {
@@ -1652,56 +3410,25 @@ func (data *InterfacePortChannel) getDeletedItems(ctx context.Context, state Int
}
if found {
if !state.Ipv6LinkLocalAddresses[i].LinkLocal.IsNull() && data.Ipv6LinkLocalAddresses[j].LinkLocal.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ipv6/address/link-local-address=%v/link-local", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/ipv6/address/link-local-address%v/link-local", predicates))
}
break
}
}
if !found {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ipv6/address/link-local-address=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/ipv6/address/link-local-address%v", predicates))
}
}
- if !state.Ipv6AddressDhcp.IsNull() && data.Ipv6AddressDhcp.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ipv6/address/dhcp", state.getPath()))
- }
- if !state.Ipv6AddressAutoconfigDefault.IsNull() && data.Ipv6AddressAutoconfigDefault.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ipv6/address/autoconfig/default", state.getPath()))
- }
- if !state.Ipv6NdRaSuppressAll.IsNull() && data.Ipv6NdRaSuppressAll.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ipv6/nd/Cisco-IOS-XE-nd:ra/suppress/all", state.getPath()))
- }
- if !state.Ipv6Mtu.IsNull() && data.Ipv6Mtu.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ipv6/mtu", state.getPath()))
- }
- if !state.Ipv6Enable.IsNull() && data.Ipv6Enable.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ipv6/enable", state.getPath()))
- }
- if !state.BfdEcho.IsNull() && data.BfdEcho.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/bfd/Cisco-IOS-XE-bfd:echo", state.getPath()))
- }
- if !state.BfdIntervalMultiplier.IsNull() && data.BfdIntervalMultiplier.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/bfd/Cisco-IOS-XE-bfd:interval-interface", state.getPath()))
- }
- if !state.BfdIntervalMinRx.IsNull() && data.BfdIntervalMinRx.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/bfd/Cisco-IOS-XE-bfd:interval-interface", state.getPath()))
- }
- if !state.BfdInterval.IsNull() && data.BfdInterval.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/bfd/Cisco-IOS-XE-bfd:interval-interface", state.getPath()))
- }
- if !state.BfdLocalAddress.IsNull() && data.BfdLocalAddress.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/bfd/Cisco-IOS-XE-bfd:local-address", state.getPath()))
- }
- if !state.BfdEnable.IsNull() && data.BfdEnable.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/bfd/Cisco-IOS-XE-bfd:enable", state.getPath()))
- }
- if !state.BfdTemplate.IsNull() && data.BfdTemplate.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/bfd/Cisco-IOS-XE-bfd:template", state.getPath()))
- }
- for i := range state.HelperAddresses {
- stateKeyValues := [...]string{state.HelperAddresses[i].Address.ValueString()}
+ for i := range state.Ipv6Addresses {
+ stateKeys := [...]string{"prefix"}
+ stateKeyValues := [...]string{state.Ipv6Addresses[i].Prefix.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
emptyKeys := true
- if !reflect.ValueOf(state.HelperAddresses[i].Address.ValueString()).IsZero() {
+ if !reflect.ValueOf(state.Ipv6Addresses[i].Prefix.ValueString()).IsZero() {
emptyKeys = false
}
if emptyKeys {
@@ -1709,114 +3436,87 @@ func (data *InterfacePortChannel) getDeletedItems(ctx context.Context, state Int
}
found := false
- for j := range data.HelperAddresses {
+ for j := range data.Ipv6Addresses {
found = true
- if state.HelperAddresses[i].Address.ValueString() != data.HelperAddresses[j].Address.ValueString() {
+ if state.Ipv6Addresses[i].Prefix.ValueString() != data.Ipv6Addresses[j].Prefix.ValueString() {
found = false
}
if found {
- if !state.HelperAddresses[i].Vrf.IsNull() && data.HelperAddresses[j].Vrf.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/helper-address=%v/vrf", state.getPath(), strings.Join(stateKeyValues[:], ",")))
- }
- if !state.HelperAddresses[i].Global.IsNull() && data.HelperAddresses[j].Global.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/helper-address=%v/global", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ if !state.Ipv6Addresses[i].Eui64.IsNull() && data.Ipv6Addresses[j].Eui64.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/ipv6/address/prefix-list%v/eui-64", predicates))
}
break
}
}
if !found {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/helper-address=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/ipv6/address/prefix-list%v", predicates))
}
}
- if !state.TrustDevice.IsNull() && data.TrustDevice.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/trust/device", state.getPath()))
- }
- if !state.AutoQosVoipTrust.IsNull() && data.AutoQosVoipTrust.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-switch:auto/qos/voip/trust", state.getPath()))
- }
- if !state.AutoQosVoipCiscoSoftphone.IsNull() && data.AutoQosVoipCiscoSoftphone.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-switch:auto/qos/voip/cisco-softphone", state.getPath()))
- }
- if !state.AutoQosVoipCiscoPhone.IsNull() && data.AutoQosVoipCiscoPhone.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-switch:auto/qos/voip/cisco-phone", state.getPath()))
- }
- if !state.AutoQosVoip.IsNull() && data.AutoQosVoip.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-switch:auto/qos/voip", state.getPath()))
- }
- if !state.AutoQosVideoMediaPlayer.IsNull() && data.AutoQosVideoMediaPlayer.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-switch:auto/qos/video/media-player", state.getPath()))
- }
- if !state.AutoQosVideoIpCamera.IsNull() && data.AutoQosVideoIpCamera.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-switch:auto/qos/video/ip-camera", state.getPath()))
- }
- if !state.AutoQosVideoCts.IsNull() && data.AutoQosVideoCts.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-switch:auto/qos/video/cts", state.getPath()))
- }
- if !state.AutoQosTrustDscp.IsNull() && data.AutoQosTrustDscp.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-switch:auto/qos/trust/dscp", state.getPath()))
- }
- if !state.AutoQosTrustCos.IsNull() && data.AutoQosTrustCos.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-switch:auto/qos/trust/cos", state.getPath()))
- }
- if !state.AutoQosTrust.IsNull() && data.AutoQosTrust.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-switch:auto/qos/trust", state.getPath()))
- }
- if !state.AutoQosClassifyPolice.IsNull() && data.AutoQosClassifyPolice.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-switch:auto/qos/classify/police", state.getPath()))
- }
- if !state.AutoQosClassify.IsNull() && data.AutoQosClassify.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-switch:auto/qos/classify", state.getPath()))
- }
- if !state.SpanningTreeGuard.IsNull() && data.SpanningTreeGuard.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-spanning-tree:spanning-tree/guard", state.getPath()))
- }
- if !state.IpDhcpRelaySourceInterface.IsNull() && data.IpDhcpRelaySourceInterface.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/dhcp/Cisco-IOS-XE-dhcp:relay/source-interface", state.getPath()))
- }
- if !state.IpAccessGroupOut.IsNull() && data.IpAccessGroupOut.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/access-group/out/acl", state.getPath()))
- }
- if !state.IpAccessGroupOutEnable.IsNull() && data.IpAccessGroupOutEnable.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/access-group/out/acl/out", state.getPath()))
- }
- if !state.IpAccessGroupIn.IsNull() && data.IpAccessGroupIn.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/access-group/in/acl", state.getPath()))
+ if !state.ArpTimeout.IsNull() && data.ArpTimeout.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/arp/timeout")
}
- if !state.IpAccessGroupInEnable.IsNull() && data.IpAccessGroupInEnable.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/access-group/in/acl/in", state.getPath()))
+ if !state.IpArpInspectionTrust.IsNull() && data.IpArpInspectionTrust.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ip/arp/inspection/trust")
}
- if !state.Ipv4AddressMask.IsNull() && data.Ipv4AddressMask.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/address/primary", state.getPath()))
+ if !state.IpArpInspectionLimitRate.IsNull() && data.IpArpInspectionLimitRate.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ip/arp/inspection/limit/rate")
}
- if !state.Ipv4Address.IsNull() && data.Ipv4Address.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/address/primary", state.getPath()))
+ if !state.SpanningTreeLinkType.IsNull() && data.SpanningTreeLinkType.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-spanning-tree:spanning-tree/link-type")
}
- if !state.VrfForwarding.IsNull() && data.VrfForwarding.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/vrf", state.getPath()))
+ if !state.IpDhcpSnoopingTrust.IsNull() && data.IpDhcpSnoopingTrust.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ip/dhcp/Cisco-IOS-XE-dhcp:snooping/trust")
}
- if !state.IpUnreachables.IsNull() && data.IpUnreachables.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/Cisco-IOS-XE-icmp:unreachables", state.getPath()))
+ if !state.LoadInterval.IsNull() && data.LoadInterval.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/load-interval")
}
- if !state.IpRedirects.IsNull() && data.IpRedirects.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/redirects", state.getPath()))
+ if !state.SnmpTrapLinkStatus.IsNull() && data.SnmpTrapLinkStatus.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:snmp/trap/link-status")
}
- if !state.IpProxyArp.IsNull() && data.IpProxyArp.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/proxy-arp", state.getPath()))
+ if !state.LoggingEventLinkStatusEnable.IsNull() && data.LoggingEventLinkStatusEnable.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/logging/event/link-status-enable")
}
- if !state.Switchport.IsNull() && data.Switchport.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/switchport-conf/switchport", state.getPath()))
+ if !state.DeviceTracking.IsNull() && data.DeviceTracking.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-switch:device-tracking")
}
- if !state.Shutdown.IsNull() && data.Shutdown.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/shutdown", state.getPath()))
+ for i := range state.DeviceTrackingAttachedPolicies {
+ stateKeys := [...]string{"attach-policy"}
+ stateKeyValues := [...]string{state.DeviceTrackingAttachedPolicies[i].Name.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.DeviceTrackingAttachedPolicies[i].Name.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.DeviceTrackingAttachedPolicies {
+ found = true
+ if state.DeviceTrackingAttachedPolicies[i].Name.ValueString() != data.DeviceTrackingAttachedPolicies[j].Name.ValueString() {
+ found = false
+ }
+ if found {
+ break
+ }
+ }
+ if !found {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-switch:device-tracking/attached-policies%v", predicates))
+ }
}
- if !state.Description.IsNull() && data.Description.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/description", state.getPath()))
+ if !state.NegotiationAuto.IsNull() && data.NegotiationAuto.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-ethernet:negotiation/auto")
}
- return deletedItems
+ return b.Res()
}
-// End of section. //template:end getDeletedItems
+// End of section. //template:end addDeletedItemsXML
// Section below is generated&owned by "gen/generator.go". //template:begin getEmptyLeafsDelete
@@ -2095,3 +3795,203 @@ func (data *InterfacePortChannel) getDeletePaths(ctx context.Context) []string {
}
// End of section. //template:end getDeletePaths
+
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletePathsXML
+
+func (data *InterfacePortChannel) addDeletePathsXML(ctx context.Context, body string) string {
+ b := netconf.NewBody(body)
+ if !data.Description.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/description")
+ }
+ if !data.Shutdown.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/shutdown")
+ }
+ if !data.Switchport.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/switchport-conf/switchport")
+ }
+ if !data.IpProxyArp.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ip/proxy-arp")
+ }
+ if !data.IpRedirects.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ip/redirects")
+ }
+ if !data.IpUnreachables.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ip/Cisco-IOS-XE-icmp:unreachables")
+ }
+ if !data.VrfForwarding.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/vrf/forwarding")
+ }
+ if !data.Ipv4Address.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ip/address/primary/address")
+ }
+ if !data.Ipv4AddressMask.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ip/address/primary/mask")
+ }
+ if !data.IpAccessGroupInEnable.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ip/access-group/in/acl/in")
+ }
+ if !data.IpAccessGroupIn.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ip/access-group/in/acl/acl-name")
+ }
+ if !data.IpAccessGroupOutEnable.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ip/access-group/out/acl/out")
+ }
+ if !data.IpAccessGroupOut.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ip/access-group/out/acl/acl-name")
+ }
+ if !data.IpDhcpRelaySourceInterface.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ip/dhcp/Cisco-IOS-XE-dhcp:relay/source-interface")
+ }
+ if !data.SpanningTreeGuard.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-spanning-tree:spanning-tree/guard")
+ }
+ if !data.AutoQosClassify.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/classify")
+ }
+ if !data.AutoQosClassifyPolice.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/classify/police")
+ }
+ if !data.AutoQosTrust.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/trust")
+ }
+ if !data.AutoQosTrustCos.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/trust/cos")
+ }
+ if !data.AutoQosTrustDscp.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/trust/dscp")
+ }
+ if !data.AutoQosVideoCts.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/video/cts")
+ }
+ if !data.AutoQosVideoIpCamera.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/video/ip-camera")
+ }
+ if !data.AutoQosVideoMediaPlayer.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/video/media-player")
+ }
+ if !data.AutoQosVoip.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/voip")
+ }
+ if !data.AutoQosVoipCiscoPhone.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/voip/cisco-phone")
+ }
+ if !data.AutoQosVoipCiscoSoftphone.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/voip/cisco-softphone")
+ }
+ if !data.AutoQosVoipTrust.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/voip/trust")
+ }
+ if !data.TrustDevice.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/trust/device")
+ }
+ for i := range data.HelperAddresses {
+ keys := [...]string{"address"}
+ keyValues := [...]string{data.HelperAddresses[i].Address.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/ip/helper-address%v", predicates))
+ }
+ if !data.BfdTemplate.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/bfd/Cisco-IOS-XE-bfd:template")
+ }
+ if !data.BfdEnable.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/bfd/Cisco-IOS-XE-bfd:enable")
+ }
+ if !data.BfdLocalAddress.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/bfd/Cisco-IOS-XE-bfd:local-address")
+ }
+ if !data.BfdInterval.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/bfd/Cisco-IOS-XE-bfd:interval-interface/msecs")
+ }
+ if !data.BfdIntervalMinRx.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/bfd/Cisco-IOS-XE-bfd:interval-interface/min_rx")
+ }
+ if !data.BfdIntervalMultiplier.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/bfd/Cisco-IOS-XE-bfd:interval-interface/multiplier")
+ }
+ if !data.BfdEcho.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/bfd/Cisco-IOS-XE-bfd:echo")
+ }
+ if !data.Ipv6Enable.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ipv6/enable")
+ }
+ if !data.Ipv6Mtu.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ipv6/mtu")
+ }
+ if !data.Ipv6NdRaSuppressAll.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ipv6/nd/Cisco-IOS-XE-nd:ra/suppress/all")
+ }
+ if !data.Ipv6AddressAutoconfigDefault.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ipv6/address/autoconfig/default")
+ }
+ if !data.Ipv6AddressDhcp.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ipv6/address/dhcp")
+ }
+ for i := range data.Ipv6LinkLocalAddresses {
+ keys := [...]string{"address"}
+ keyValues := [...]string{data.Ipv6LinkLocalAddresses[i].Address.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/ipv6/address/link-local-address%v", predicates))
+ }
+ for i := range data.Ipv6Addresses {
+ keys := [...]string{"prefix"}
+ keyValues := [...]string{data.Ipv6Addresses[i].Prefix.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/ipv6/address/prefix-list%v", predicates))
+ }
+ if !data.ArpTimeout.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/arp/timeout")
+ }
+ if !data.IpArpInspectionTrust.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ip/arp/inspection/trust")
+ }
+ if !data.IpArpInspectionLimitRate.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ip/arp/inspection/limit/rate")
+ }
+ if !data.SpanningTreeLinkType.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-spanning-tree:spanning-tree/link-type")
+ }
+ if !data.IpDhcpSnoopingTrust.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ip/dhcp/Cisco-IOS-XE-dhcp:snooping/trust")
+ }
+ if !data.LoadInterval.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/load-interval")
+ }
+ if !data.SnmpTrapLinkStatus.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:snmp/trap/link-status")
+ }
+ if !data.LoggingEventLinkStatusEnable.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/logging/event/link-status-enable")
+ }
+ if !data.DeviceTracking.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-switch:device-tracking")
+ }
+ for i := range data.DeviceTrackingAttachedPolicies {
+ keys := [...]string{"attach-policy"}
+ keyValues := [...]string{data.DeviceTrackingAttachedPolicies[i].Name.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/Cisco-IOS-XE-switch:device-tracking/attached-policies%v", predicates))
+ }
+ if !data.NegotiationAuto.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-ethernet:negotiation/auto")
+ }
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletePathsXML
diff --git a/internal/provider/model_iosxe_interface_port_channel_subinterface.go b/internal/provider/model_iosxe_interface_port_channel_subinterface.go
index ace41963..d1d870c1 100644
--- a/internal/provider/model_iosxe_interface_port_channel_subinterface.go
+++ b/internal/provider/model_iosxe_interface_port_channel_subinterface.go
@@ -31,6 +31,9 @@ import (
"github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/types"
+ "github.com/hashicorp/terraform-plugin-log/tflog"
+ "github.com/netascode/go-netconf"
+ "github.com/netascode/xmldot"
"github.com/tidwall/gjson"
"github.com/tidwall/sjson"
)
@@ -175,6 +178,19 @@ func (data InterfacePortChannelSubinterface) getPathShort() string {
return matches[1]
}
+// getXPath returns the XPath for NETCONF operations
+func (data InterfacePortChannelSubinterface) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/interface/Port-channel-subinterface/Port-channel[name=%v]"
+ path = fmt.Sprintf(path, fmt.Sprintf("%v", data.Name.ValueString()))
+ return path
+}
+
+func (data InterfacePortChannelSubinterfaceData) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/interface/Port-channel-subinterface/Port-channel[name=%v]"
+ path = fmt.Sprintf(path, fmt.Sprintf("%v", data.Name.ValueString()))
+ return path
+}
+
// End of section. //template:end getPath
// Section below is generated&owned by "gen/generator.go". //template:begin toBody
@@ -394,6 +410,276 @@ func (data InterfacePortChannelSubinterface) toBody(ctx context.Context) string
// End of section. //template:end toBody
+// Section below is generated&owned by "gen/generator.go". //template:begin toBodyXML
+
+func (data InterfacePortChannelSubinterface) toBodyXML(ctx context.Context) string {
+ body := netconf.Body{}
+ if !data.Name.IsNull() && !data.Name.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/name", data.Name.ValueString())
+ }
+ if !data.EncapsulationDot1qVlanId.IsNull() && !data.EncapsulationDot1qVlanId.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/encapsulation/dot1Q/vlan-id", strconv.FormatInt(data.EncapsulationDot1qVlanId.ValueInt64(), 10))
+ }
+ if !data.Description.IsNull() && !data.Description.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/description", data.Description.ValueString())
+ }
+ if !data.Shutdown.IsNull() && !data.Shutdown.IsUnknown() {
+ if data.Shutdown.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/shutdown", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/shutdown")
+ }
+ }
+ if !data.IpProxyArp.IsNull() && !data.IpProxyArp.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ip/proxy-arp", data.IpProxyArp.ValueBool())
+ }
+ if !data.IpRedirects.IsNull() && !data.IpRedirects.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ip/redirects", data.IpRedirects.ValueBool())
+ }
+ if !data.IpUnreachables.IsNull() && !data.IpUnreachables.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ip/Cisco-IOS-XE-icmp:unreachables", data.IpUnreachables.ValueBool())
+ }
+ if !data.VrfForwarding.IsNull() && !data.VrfForwarding.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/vrf/forwarding", data.VrfForwarding.ValueString())
+ }
+ if !data.Ipv4Address.IsNull() && !data.Ipv4Address.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ip/address/primary/address", data.Ipv4Address.ValueString())
+ }
+ if !data.Ipv4AddressMask.IsNull() && !data.Ipv4AddressMask.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ip/address/primary/mask", data.Ipv4AddressMask.ValueString())
+ }
+ if !data.IpAccessGroupInEnable.IsNull() && !data.IpAccessGroupInEnable.IsUnknown() {
+ if data.IpAccessGroupInEnable.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ip/access-group/in/acl/in", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/ip/access-group/in/acl/in")
+ }
+ }
+ if !data.IpAccessGroupIn.IsNull() && !data.IpAccessGroupIn.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ip/access-group/in/acl/acl-name", data.IpAccessGroupIn.ValueString())
+ }
+ if !data.IpAccessGroupOutEnable.IsNull() && !data.IpAccessGroupOutEnable.IsUnknown() {
+ if data.IpAccessGroupOutEnable.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ip/access-group/out/acl/out", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/ip/access-group/out/acl/out")
+ }
+ }
+ if !data.IpAccessGroupOut.IsNull() && !data.IpAccessGroupOut.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ip/access-group/out/acl/acl-name", data.IpAccessGroupOut.ValueString())
+ }
+ if !data.AutoQosClassify.IsNull() && !data.AutoQosClassify.IsUnknown() {
+ if data.AutoQosClassify.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/classify", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/classify")
+ }
+ }
+ if !data.AutoQosClassifyPolice.IsNull() && !data.AutoQosClassifyPolice.IsUnknown() {
+ if data.AutoQosClassifyPolice.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/classify/police", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/classify/police")
+ }
+ }
+ if !data.AutoQosTrust.IsNull() && !data.AutoQosTrust.IsUnknown() {
+ if data.AutoQosTrust.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/trust", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/trust")
+ }
+ }
+ if !data.AutoQosTrustCos.IsNull() && !data.AutoQosTrustCos.IsUnknown() {
+ if data.AutoQosTrustCos.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/trust/cos", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/trust/cos")
+ }
+ }
+ if !data.AutoQosTrustDscp.IsNull() && !data.AutoQosTrustDscp.IsUnknown() {
+ if data.AutoQosTrustDscp.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/trust/dscp", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/trust/dscp")
+ }
+ }
+ if !data.AutoQosVideoCts.IsNull() && !data.AutoQosVideoCts.IsUnknown() {
+ if data.AutoQosVideoCts.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/video/cts", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/video/cts")
+ }
+ }
+ if !data.AutoQosVideoIpCamera.IsNull() && !data.AutoQosVideoIpCamera.IsUnknown() {
+ if data.AutoQosVideoIpCamera.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/video/ip-camera", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/video/ip-camera")
+ }
+ }
+ if !data.AutoQosVideoMediaPlayer.IsNull() && !data.AutoQosVideoMediaPlayer.IsUnknown() {
+ if data.AutoQosVideoMediaPlayer.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/video/media-player", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/video/media-player")
+ }
+ }
+ if !data.AutoQosVoip.IsNull() && !data.AutoQosVoip.IsUnknown() {
+ if data.AutoQosVoip.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/voip", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/voip")
+ }
+ }
+ if !data.AutoQosVoipCiscoPhone.IsNull() && !data.AutoQosVoipCiscoPhone.IsUnknown() {
+ if data.AutoQosVoipCiscoPhone.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/voip/cisco-phone", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/voip/cisco-phone")
+ }
+ }
+ if !data.AutoQosVoipCiscoSoftphone.IsNull() && !data.AutoQosVoipCiscoSoftphone.IsUnknown() {
+ if data.AutoQosVoipCiscoSoftphone.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/voip/cisco-softphone", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/voip/cisco-softphone")
+ }
+ }
+ if !data.AutoQosVoipTrust.IsNull() && !data.AutoQosVoipTrust.IsUnknown() {
+ if data.AutoQosVoipTrust.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/voip/trust", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/voip/trust")
+ }
+ }
+ if !data.TrustDevice.IsNull() && !data.TrustDevice.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/trust/device", data.TrustDevice.ValueString())
+ }
+ if len(data.HelperAddresses) > 0 {
+ for _, item := range data.HelperAddresses {
+ cBody := netconf.Body{}
+ if !item.Address.IsNull() && !item.Address.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "address", item.Address.ValueString())
+ }
+ if !item.Global.IsNull() && !item.Global.IsUnknown() {
+ if item.Global.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "global", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "global")
+ }
+ }
+ if !item.Vrf.IsNull() && !item.Vrf.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "vrf", item.Vrf.ValueString())
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/ip/helper-address", cBody.Res())
+ }
+ }
+ if !data.BfdTemplate.IsNull() && !data.BfdTemplate.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/bfd/Cisco-IOS-XE-bfd:template", data.BfdTemplate.ValueString())
+ }
+ if !data.BfdEnable.IsNull() && !data.BfdEnable.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/bfd/Cisco-IOS-XE-bfd:enable", data.BfdEnable.ValueBool())
+ }
+ if !data.BfdLocalAddress.IsNull() && !data.BfdLocalAddress.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/bfd/Cisco-IOS-XE-bfd:local-address", data.BfdLocalAddress.ValueString())
+ }
+ if !data.BfdInterval.IsNull() && !data.BfdInterval.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/bfd/Cisco-IOS-XE-bfd:interval-interface/msecs", strconv.FormatInt(data.BfdInterval.ValueInt64(), 10))
+ }
+ if !data.BfdIntervalMinRx.IsNull() && !data.BfdIntervalMinRx.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/bfd/Cisco-IOS-XE-bfd:interval-interface/min_rx", strconv.FormatInt(data.BfdIntervalMinRx.ValueInt64(), 10))
+ }
+ if !data.BfdIntervalMultiplier.IsNull() && !data.BfdIntervalMultiplier.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/bfd/Cisco-IOS-XE-bfd:interval-interface/multiplier", strconv.FormatInt(data.BfdIntervalMultiplier.ValueInt64(), 10))
+ }
+ if !data.BfdEcho.IsNull() && !data.BfdEcho.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/bfd/Cisco-IOS-XE-bfd:echo", data.BfdEcho.ValueBool())
+ }
+ if !data.Ipv6Enable.IsNull() && !data.Ipv6Enable.IsUnknown() {
+ if data.Ipv6Enable.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ipv6/enable", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/ipv6/enable")
+ }
+ }
+ if !data.Ipv6Mtu.IsNull() && !data.Ipv6Mtu.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ipv6/mtu", strconv.FormatInt(data.Ipv6Mtu.ValueInt64(), 10))
+ }
+ if !data.Ipv6NdRaSuppressAll.IsNull() && !data.Ipv6NdRaSuppressAll.IsUnknown() {
+ if data.Ipv6NdRaSuppressAll.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ipv6/nd/Cisco-IOS-XE-nd:ra/suppress/all", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/ipv6/nd/Cisco-IOS-XE-nd:ra/suppress/all")
+ }
+ }
+ if !data.Ipv6AddressAutoconfigDefault.IsNull() && !data.Ipv6AddressAutoconfigDefault.IsUnknown() {
+ if data.Ipv6AddressAutoconfigDefault.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ipv6/address/autoconfig/default", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/ipv6/address/autoconfig/default")
+ }
+ }
+ if !data.Ipv6AddressDhcp.IsNull() && !data.Ipv6AddressDhcp.IsUnknown() {
+ if data.Ipv6AddressDhcp.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ipv6/address/dhcp", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/ipv6/address/dhcp")
+ }
+ }
+ if len(data.Ipv6LinkLocalAddresses) > 0 {
+ for _, item := range data.Ipv6LinkLocalAddresses {
+ cBody := netconf.Body{}
+ if !item.Address.IsNull() && !item.Address.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "address", item.Address.ValueString())
+ }
+ if !item.LinkLocal.IsNull() && !item.LinkLocal.IsUnknown() {
+ if item.LinkLocal.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "link-local", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "link-local")
+ }
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/ipv6/address/link-local-address", cBody.Res())
+ }
+ }
+ if len(data.Ipv6Addresses) > 0 {
+ for _, item := range data.Ipv6Addresses {
+ cBody := netconf.Body{}
+ if !item.Prefix.IsNull() && !item.Prefix.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "prefix", item.Prefix.ValueString())
+ }
+ if !item.Eui64.IsNull() && !item.Eui64.IsUnknown() {
+ if item.Eui64.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "eui-64", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "eui-64")
+ }
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/ipv6/address/prefix-list", cBody.Res())
+ }
+ }
+ if !data.ArpTimeout.IsNull() && !data.ArpTimeout.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/arp/timeout", strconv.FormatInt(data.ArpTimeout.ValueInt64(), 10))
+ }
+ if !data.IpArpInspectionTrust.IsNull() && !data.IpArpInspectionTrust.IsUnknown() {
+ if data.IpArpInspectionTrust.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ip/arp/inspection/trust", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/ip/arp/inspection/trust")
+ }
+ }
+ if !data.IpArpInspectionLimitRate.IsNull() && !data.IpArpInspectionLimitRate.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ip/arp/inspection/limit/rate", strconv.FormatInt(data.IpArpInspectionLimitRate.ValueInt64(), 10))
+ }
+ bodyString, err := body.String()
+ if err != nil {
+ tflog.Error(ctx, fmt.Sprintf("Error converting body to string: %s", err))
+ }
+ return bodyString
+}
+
+// End of section. //template:end toBodyXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBody
func (data *InterfacePortChannelSubinterface) updateFromBody(ctx context.Context, res gjson.Result) {
@@ -824,202 +1110,1325 @@ func (data *InterfacePortChannelSubinterface) updateFromBody(ctx context.Context
// End of section. //template:end updateFromBody
-// Section below is generated&owned by "gen/generator.go". //template:begin fromBody
+// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBodyXML
-func (data *InterfacePortChannelSubinterface) fromBody(ctx context.Context, res gjson.Result) {
- prefix := helpers.LastElement(data.getPath()) + "."
- if res.Get(helpers.LastElement(data.getPath())).IsArray() {
- prefix += "0."
+func (data *InterfacePortChannelSubinterface) updateFromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/name"); value.Exists() && !data.Name.IsNull() {
+ data.Name = types.StringValue(value.String())
+ } else {
+ data.Name = types.StringNull()
}
- if value := res.Get(prefix + "encapsulation.dot1Q.vlan-id"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/encapsulation/dot1Q/vlan-id"); value.Exists() && !data.EncapsulationDot1qVlanId.IsNull() {
data.EncapsulationDot1qVlanId = types.Int64Value(value.Int())
+ } else {
+ data.EncapsulationDot1qVlanId = types.Int64Null()
}
- if value := res.Get(prefix + "description"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/description"); value.Exists() && !data.Description.IsNull() {
data.Description = types.StringValue(value.String())
+ } else {
+ data.Description = types.StringNull()
}
- if value := res.Get(prefix + "shutdown"); value.Exists() {
- data.Shutdown = types.BoolValue(true)
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/shutdown"); !data.Shutdown.IsNull() {
+ if value.Exists() {
+ data.Shutdown = types.BoolValue(true)
+ } else {
+ data.Shutdown = types.BoolValue(false)
+ }
} else {
- data.Shutdown = types.BoolValue(false)
+ data.Shutdown = types.BoolNull()
}
- if value := res.Get(prefix + "ip.proxy-arp"); value.Exists() {
- data.IpProxyArp = types.BoolValue(value.Bool())
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/proxy-arp"); !data.IpProxyArp.IsNull() {
+ if value.Exists() {
+ data.IpProxyArp = types.BoolValue(value.Bool())
+ }
} else {
data.IpProxyArp = types.BoolNull()
}
- if value := res.Get(prefix + "ip.redirects"); value.Exists() {
- data.IpRedirects = types.BoolValue(value.Bool())
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/redirects"); !data.IpRedirects.IsNull() {
+ if value.Exists() {
+ data.IpRedirects = types.BoolValue(value.Bool())
+ }
} else {
data.IpRedirects = types.BoolNull()
}
- if value := res.Get(prefix + "ip.Cisco-IOS-XE-icmp:unreachables"); value.Exists() {
- data.IpUnreachables = types.BoolValue(value.Bool())
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/Cisco-IOS-XE-icmp:unreachables"); !data.IpUnreachables.IsNull() {
+ if value.Exists() {
+ data.IpUnreachables = types.BoolValue(value.Bool())
+ }
} else {
data.IpUnreachables = types.BoolNull()
}
- if value := res.Get(prefix + "vrf.forwarding"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/vrf/forwarding"); value.Exists() && !data.VrfForwarding.IsNull() {
data.VrfForwarding = types.StringValue(value.String())
+ } else {
+ data.VrfForwarding = types.StringNull()
}
- if value := res.Get(prefix + "ip.address.primary.address"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/address/primary/address"); value.Exists() && !data.Ipv4Address.IsNull() {
data.Ipv4Address = types.StringValue(value.String())
+ } else {
+ data.Ipv4Address = types.StringNull()
}
- if value := res.Get(prefix + "ip.address.primary.mask"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/address/primary/mask"); value.Exists() && !data.Ipv4AddressMask.IsNull() {
data.Ipv4AddressMask = types.StringValue(value.String())
+ } else {
+ data.Ipv4AddressMask = types.StringNull()
}
- if value := res.Get(prefix + "ip.access-group.in.acl.in"); value.Exists() {
- data.IpAccessGroupInEnable = types.BoolValue(true)
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/access-group/in/acl/in"); !data.IpAccessGroupInEnable.IsNull() {
+ if value.Exists() {
+ data.IpAccessGroupInEnable = types.BoolValue(true)
+ } else {
+ data.IpAccessGroupInEnable = types.BoolValue(false)
+ }
} else {
- data.IpAccessGroupInEnable = types.BoolValue(false)
+ data.IpAccessGroupInEnable = types.BoolNull()
}
- if value := res.Get(prefix + "ip.access-group.in.acl.acl-name"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/access-group/in/acl/acl-name"); value.Exists() && !data.IpAccessGroupIn.IsNull() {
data.IpAccessGroupIn = types.StringValue(value.String())
+ } else {
+ data.IpAccessGroupIn = types.StringNull()
}
- if value := res.Get(prefix + "ip.access-group.out.acl.out"); value.Exists() {
- data.IpAccessGroupOutEnable = types.BoolValue(true)
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/access-group/out/acl/out"); !data.IpAccessGroupOutEnable.IsNull() {
+ if value.Exists() {
+ data.IpAccessGroupOutEnable = types.BoolValue(true)
+ } else {
+ data.IpAccessGroupOutEnable = types.BoolValue(false)
+ }
} else {
- data.IpAccessGroupOutEnable = types.BoolValue(false)
+ data.IpAccessGroupOutEnable = types.BoolNull()
}
- if value := res.Get(prefix + "ip.access-group.out.acl.acl-name"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/access-group/out/acl/acl-name"); value.Exists() && !data.IpAccessGroupOut.IsNull() {
data.IpAccessGroupOut = types.StringValue(value.String())
- }
- if value := res.Get(prefix + "Cisco-IOS-XE-switch:auto.qos.classify"); value.Exists() {
- data.AutoQosClassify = types.BoolValue(true)
} else {
- data.AutoQosClassify = types.BoolValue(false)
+ data.IpAccessGroupOut = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/classify"); !data.AutoQosClassify.IsNull() {
+ if value.Exists() {
+ data.AutoQosClassify = types.BoolValue(true)
+ } else {
+ data.AutoQosClassify = types.BoolValue(false)
+ }
+ } else {
+ data.AutoQosClassify = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/classify/police"); !data.AutoQosClassifyPolice.IsNull() {
+ if value.Exists() {
+ data.AutoQosClassifyPolice = types.BoolValue(true)
+ } else {
+ data.AutoQosClassifyPolice = types.BoolValue(false)
+ }
+ } else {
+ data.AutoQosClassifyPolice = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/trust"); !data.AutoQosTrust.IsNull() {
+ if value.Exists() {
+ data.AutoQosTrust = types.BoolValue(true)
+ } else {
+ data.AutoQosTrust = types.BoolValue(false)
+ }
+ } else {
+ data.AutoQosTrust = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/trust/cos"); !data.AutoQosTrustCos.IsNull() {
+ if value.Exists() {
+ data.AutoQosTrustCos = types.BoolValue(true)
+ } else {
+ data.AutoQosTrustCos = types.BoolValue(false)
+ }
+ } else {
+ data.AutoQosTrustCos = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/trust/dscp"); !data.AutoQosTrustDscp.IsNull() {
+ if value.Exists() {
+ data.AutoQosTrustDscp = types.BoolValue(true)
+ } else {
+ data.AutoQosTrustDscp = types.BoolValue(false)
+ }
+ } else {
+ data.AutoQosTrustDscp = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/video/cts"); !data.AutoQosVideoCts.IsNull() {
+ if value.Exists() {
+ data.AutoQosVideoCts = types.BoolValue(true)
+ } else {
+ data.AutoQosVideoCts = types.BoolValue(false)
+ }
+ } else {
+ data.AutoQosVideoCts = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/video/ip-camera"); !data.AutoQosVideoIpCamera.IsNull() {
+ if value.Exists() {
+ data.AutoQosVideoIpCamera = types.BoolValue(true)
+ } else {
+ data.AutoQosVideoIpCamera = types.BoolValue(false)
+ }
+ } else {
+ data.AutoQosVideoIpCamera = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/video/media-player"); !data.AutoQosVideoMediaPlayer.IsNull() {
+ if value.Exists() {
+ data.AutoQosVideoMediaPlayer = types.BoolValue(true)
+ } else {
+ data.AutoQosVideoMediaPlayer = types.BoolValue(false)
+ }
+ } else {
+ data.AutoQosVideoMediaPlayer = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/voip"); !data.AutoQosVoip.IsNull() {
+ if value.Exists() {
+ data.AutoQosVoip = types.BoolValue(true)
+ } else {
+ data.AutoQosVoip = types.BoolValue(false)
+ }
+ } else {
+ data.AutoQosVoip = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/voip/cisco-phone"); !data.AutoQosVoipCiscoPhone.IsNull() {
+ if value.Exists() {
+ data.AutoQosVoipCiscoPhone = types.BoolValue(true)
+ } else {
+ data.AutoQosVoipCiscoPhone = types.BoolValue(false)
+ }
+ } else {
+ data.AutoQosVoipCiscoPhone = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/voip/cisco-softphone"); !data.AutoQosVoipCiscoSoftphone.IsNull() {
+ if value.Exists() {
+ data.AutoQosVoipCiscoSoftphone = types.BoolValue(true)
+ } else {
+ data.AutoQosVoipCiscoSoftphone = types.BoolValue(false)
+ }
+ } else {
+ data.AutoQosVoipCiscoSoftphone = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/voip/trust"); !data.AutoQosVoipTrust.IsNull() {
+ if value.Exists() {
+ data.AutoQosVoipTrust = types.BoolValue(true)
+ } else {
+ data.AutoQosVoipTrust = types.BoolValue(false)
+ }
+ } else {
+ data.AutoQosVoipTrust = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/trust/device"); value.Exists() && !data.TrustDevice.IsNull() {
+ data.TrustDevice = types.StringValue(value.String())
+ } else {
+ data.TrustDevice = types.StringNull()
+ }
+ for i := range data.HelperAddresses {
+ keys := [...]string{"address"}
+ keyValues := [...]string{data.HelperAddresses[i].Address.ValueString()}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/helper-address").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, "address"); value.Exists() && !data.HelperAddresses[i].Address.IsNull() {
+ data.HelperAddresses[i].Address = types.StringValue(value.String())
+ } else {
+ data.HelperAddresses[i].Address = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "global"); !data.HelperAddresses[i].Global.IsNull() {
+ if value.Exists() {
+ data.HelperAddresses[i].Global = types.BoolValue(true)
+ } else {
+ data.HelperAddresses[i].Global = types.BoolValue(false)
+ }
+ } else {
+ data.HelperAddresses[i].Global = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "vrf"); value.Exists() && !data.HelperAddresses[i].Vrf.IsNull() {
+ data.HelperAddresses[i].Vrf = types.StringValue(value.String())
+ } else {
+ data.HelperAddresses[i].Vrf = types.StringNull()
+ }
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/bfd/Cisco-IOS-XE-bfd:template"); value.Exists() && !data.BfdTemplate.IsNull() {
+ data.BfdTemplate = types.StringValue(value.String())
+ } else {
+ data.BfdTemplate = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/bfd/Cisco-IOS-XE-bfd:enable"); !data.BfdEnable.IsNull() {
+ if value.Exists() {
+ data.BfdEnable = types.BoolValue(value.Bool())
+ }
+ } else {
+ data.BfdEnable = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/bfd/Cisco-IOS-XE-bfd:local-address"); value.Exists() && !data.BfdLocalAddress.IsNull() {
+ data.BfdLocalAddress = types.StringValue(value.String())
+ } else {
+ data.BfdLocalAddress = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/bfd/Cisco-IOS-XE-bfd:interval-interface/msecs"); value.Exists() && !data.BfdInterval.IsNull() {
+ data.BfdInterval = types.Int64Value(value.Int())
+ } else {
+ data.BfdInterval = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/bfd/Cisco-IOS-XE-bfd:interval-interface/min_rx"); value.Exists() && !data.BfdIntervalMinRx.IsNull() {
+ data.BfdIntervalMinRx = types.Int64Value(value.Int())
+ } else {
+ data.BfdIntervalMinRx = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/bfd/Cisco-IOS-XE-bfd:interval-interface/multiplier"); value.Exists() && !data.BfdIntervalMultiplier.IsNull() {
+ data.BfdIntervalMultiplier = types.Int64Value(value.Int())
+ } else {
+ data.BfdIntervalMultiplier = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/bfd/Cisco-IOS-XE-bfd:echo"); !data.BfdEcho.IsNull() {
+ if value.Exists() {
+ data.BfdEcho = types.BoolValue(value.Bool())
+ }
+ } else {
+ data.BfdEcho = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ipv6/enable"); !data.Ipv6Enable.IsNull() {
+ if value.Exists() {
+ data.Ipv6Enable = types.BoolValue(true)
+ } else {
+ data.Ipv6Enable = types.BoolValue(false)
+ }
+ } else {
+ data.Ipv6Enable = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ipv6/mtu"); value.Exists() && !data.Ipv6Mtu.IsNull() {
+ data.Ipv6Mtu = types.Int64Value(value.Int())
+ } else {
+ data.Ipv6Mtu = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ipv6/nd/Cisco-IOS-XE-nd:ra/suppress/all"); !data.Ipv6NdRaSuppressAll.IsNull() {
+ if value.Exists() {
+ data.Ipv6NdRaSuppressAll = types.BoolValue(true)
+ } else {
+ data.Ipv6NdRaSuppressAll = types.BoolValue(false)
+ }
+ } else {
+ data.Ipv6NdRaSuppressAll = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ipv6/address/autoconfig/default"); !data.Ipv6AddressAutoconfigDefault.IsNull() {
+ if value.Exists() {
+ data.Ipv6AddressAutoconfigDefault = types.BoolValue(true)
+ } else {
+ data.Ipv6AddressAutoconfigDefault = types.BoolValue(false)
+ }
+ } else {
+ data.Ipv6AddressAutoconfigDefault = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ipv6/address/dhcp"); !data.Ipv6AddressDhcp.IsNull() {
+ if value.Exists() {
+ data.Ipv6AddressDhcp = types.BoolValue(true)
+ } else {
+ data.Ipv6AddressDhcp = types.BoolValue(false)
+ }
+ } else {
+ data.Ipv6AddressDhcp = types.BoolNull()
+ }
+ for i := range data.Ipv6LinkLocalAddresses {
+ keys := [...]string{"address"}
+ keyValues := [...]string{data.Ipv6LinkLocalAddresses[i].Address.ValueString()}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ipv6/address/link-local-address").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, "address"); value.Exists() && !data.Ipv6LinkLocalAddresses[i].Address.IsNull() {
+ data.Ipv6LinkLocalAddresses[i].Address = types.StringValue(value.String())
+ } else {
+ data.Ipv6LinkLocalAddresses[i].Address = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "link-local"); !data.Ipv6LinkLocalAddresses[i].LinkLocal.IsNull() {
+ if value.Exists() {
+ data.Ipv6LinkLocalAddresses[i].LinkLocal = types.BoolValue(true)
+ } else {
+ data.Ipv6LinkLocalAddresses[i].LinkLocal = types.BoolValue(false)
+ }
+ } else {
+ data.Ipv6LinkLocalAddresses[i].LinkLocal = types.BoolNull()
+ }
+ }
+ for i := range data.Ipv6Addresses {
+ keys := [...]string{"prefix"}
+ keyValues := [...]string{data.Ipv6Addresses[i].Prefix.ValueString()}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ipv6/address/prefix-list").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, "prefix"); value.Exists() && !data.Ipv6Addresses[i].Prefix.IsNull() {
+ data.Ipv6Addresses[i].Prefix = types.StringValue(value.String())
+ } else {
+ data.Ipv6Addresses[i].Prefix = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "eui-64"); !data.Ipv6Addresses[i].Eui64.IsNull() {
+ if value.Exists() {
+ data.Ipv6Addresses[i].Eui64 = types.BoolValue(true)
+ } else {
+ data.Ipv6Addresses[i].Eui64 = types.BoolValue(false)
+ }
+ } else {
+ data.Ipv6Addresses[i].Eui64 = types.BoolNull()
+ }
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/arp/timeout"); value.Exists() && !data.ArpTimeout.IsNull() {
+ data.ArpTimeout = types.Int64Value(value.Int())
+ } else {
+ data.ArpTimeout = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/arp/inspection/trust"); !data.IpArpInspectionTrust.IsNull() {
+ if value.Exists() {
+ data.IpArpInspectionTrust = types.BoolValue(true)
+ } else {
+ data.IpArpInspectionTrust = types.BoolValue(false)
+ }
+ } else {
+ data.IpArpInspectionTrust = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/arp/inspection/limit/rate"); value.Exists() && !data.IpArpInspectionLimitRate.IsNull() {
+ data.IpArpInspectionLimitRate = types.Int64Value(value.Int())
+ } else {
+ data.IpArpInspectionLimitRate = types.Int64Null()
+ }
+}
+
+// End of section. //template:end updateFromBodyXML
+
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBody
+
+func (data *InterfacePortChannelSubinterface) fromBody(ctx context.Context, res gjson.Result) {
+ prefix := helpers.LastElement(data.getPath()) + "."
+ if res.Get(helpers.LastElement(data.getPath())).IsArray() {
+ prefix += "0."
+ }
+ if value := res.Get(prefix + "encapsulation.dot1Q.vlan-id"); value.Exists() {
+ data.EncapsulationDot1qVlanId = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "description"); value.Exists() {
+ data.Description = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "shutdown"); value.Exists() {
+ data.Shutdown = types.BoolValue(true)
+ } else {
+ data.Shutdown = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "ip.proxy-arp"); value.Exists() {
+ data.IpProxyArp = types.BoolValue(value.Bool())
+ } else {
+ data.IpProxyArp = types.BoolNull()
+ }
+ if value := res.Get(prefix + "ip.redirects"); value.Exists() {
+ data.IpRedirects = types.BoolValue(value.Bool())
+ } else {
+ data.IpRedirects = types.BoolNull()
+ }
+ if value := res.Get(prefix + "ip.Cisco-IOS-XE-icmp:unreachables"); value.Exists() {
+ data.IpUnreachables = types.BoolValue(value.Bool())
+ } else {
+ data.IpUnreachables = types.BoolNull()
+ }
+ if value := res.Get(prefix + "vrf.forwarding"); value.Exists() {
+ data.VrfForwarding = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "ip.address.primary.address"); value.Exists() {
+ data.Ipv4Address = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "ip.address.primary.mask"); value.Exists() {
+ data.Ipv4AddressMask = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "ip.access-group.in.acl.in"); value.Exists() {
+ data.IpAccessGroupInEnable = types.BoolValue(true)
+ } else {
+ data.IpAccessGroupInEnable = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "ip.access-group.in.acl.acl-name"); value.Exists() {
+ data.IpAccessGroupIn = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "ip.access-group.out.acl.out"); value.Exists() {
+ data.IpAccessGroupOutEnable = types.BoolValue(true)
+ } else {
+ data.IpAccessGroupOutEnable = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "ip.access-group.out.acl.acl-name"); value.Exists() {
+ data.IpAccessGroupOut = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-switch:auto.qos.classify"); value.Exists() {
+ data.AutoQosClassify = types.BoolValue(true)
+ } else {
+ data.AutoQosClassify = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-switch:auto.qos.classify.police"); value.Exists() {
+ data.AutoQosClassifyPolice = types.BoolValue(true)
+ } else {
+ data.AutoQosClassifyPolice = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-switch:auto.qos.trust"); value.Exists() {
+ data.AutoQosTrust = types.BoolValue(true)
+ } else {
+ data.AutoQosTrust = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-switch:auto.qos.trust.cos"); value.Exists() {
+ data.AutoQosTrustCos = types.BoolValue(true)
+ } else {
+ data.AutoQosTrustCos = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-switch:auto.qos.trust.dscp"); value.Exists() {
+ data.AutoQosTrustDscp = types.BoolValue(true)
+ } else {
+ data.AutoQosTrustDscp = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-switch:auto.qos.video.cts"); value.Exists() {
+ data.AutoQosVideoCts = types.BoolValue(true)
+ } else {
+ data.AutoQosVideoCts = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-switch:auto.qos.video.ip-camera"); value.Exists() {
+ data.AutoQosVideoIpCamera = types.BoolValue(true)
+ } else {
+ data.AutoQosVideoIpCamera = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-switch:auto.qos.video.media-player"); value.Exists() {
+ data.AutoQosVideoMediaPlayer = types.BoolValue(true)
+ } else {
+ data.AutoQosVideoMediaPlayer = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-switch:auto.qos.voip"); value.Exists() {
+ data.AutoQosVoip = types.BoolValue(true)
+ } else {
+ data.AutoQosVoip = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-switch:auto.qos.voip.cisco-phone"); value.Exists() {
+ data.AutoQosVoipCiscoPhone = types.BoolValue(true)
+ } else {
+ data.AutoQosVoipCiscoPhone = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-switch:auto.qos.voip.cisco-softphone"); value.Exists() {
+ data.AutoQosVoipCiscoSoftphone = types.BoolValue(true)
+ } else {
+ data.AutoQosVoipCiscoSoftphone = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-switch:auto.qos.voip.trust"); value.Exists() {
+ data.AutoQosVoipTrust = types.BoolValue(true)
+ } else {
+ data.AutoQosVoipTrust = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "trust.device"); value.Exists() {
+ data.TrustDevice = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "ip.helper-address"); value.Exists() {
+ data.HelperAddresses = make([]InterfacePortChannelSubinterfaceHelperAddresses, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := InterfacePortChannelSubinterfaceHelperAddresses{}
+ if cValue := v.Get("address"); cValue.Exists() {
+ item.Address = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("global"); cValue.Exists() {
+ item.Global = types.BoolValue(true)
+ } else {
+ item.Global = types.BoolValue(false)
+ }
+ if cValue := v.Get("vrf"); cValue.Exists() {
+ item.Vrf = types.StringValue(cValue.String())
+ }
+ data.HelperAddresses = append(data.HelperAddresses, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + "bfd.Cisco-IOS-XE-bfd:template"); value.Exists() {
+ data.BfdTemplate = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "bfd.Cisco-IOS-XE-bfd:enable"); value.Exists() {
+ data.BfdEnable = types.BoolValue(value.Bool())
+ } else {
+ data.BfdEnable = types.BoolNull()
+ }
+ if value := res.Get(prefix + "bfd.Cisco-IOS-XE-bfd:local-address"); value.Exists() {
+ data.BfdLocalAddress = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "bfd.Cisco-IOS-XE-bfd:interval-interface.msecs"); value.Exists() {
+ data.BfdInterval = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "bfd.Cisco-IOS-XE-bfd:interval-interface.min_rx"); value.Exists() {
+ data.BfdIntervalMinRx = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "bfd.Cisco-IOS-XE-bfd:interval-interface.multiplier"); value.Exists() {
+ data.BfdIntervalMultiplier = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "bfd.Cisco-IOS-XE-bfd:echo"); value.Exists() {
+ data.BfdEcho = types.BoolValue(value.Bool())
+ } else {
+ data.BfdEcho = types.BoolNull()
+ }
+ if value := res.Get(prefix + "ipv6.enable"); value.Exists() {
+ data.Ipv6Enable = types.BoolValue(true)
+ } else {
+ data.Ipv6Enable = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "ipv6.mtu"); value.Exists() {
+ data.Ipv6Mtu = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "ipv6.nd.Cisco-IOS-XE-nd:ra.suppress.all"); value.Exists() {
+ data.Ipv6NdRaSuppressAll = types.BoolValue(true)
+ } else {
+ data.Ipv6NdRaSuppressAll = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "ipv6.address.autoconfig.default"); value.Exists() {
+ data.Ipv6AddressAutoconfigDefault = types.BoolValue(true)
+ } else {
+ data.Ipv6AddressAutoconfigDefault = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "ipv6.address.dhcp"); value.Exists() {
+ data.Ipv6AddressDhcp = types.BoolValue(true)
+ } else {
+ data.Ipv6AddressDhcp = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "ipv6.address.link-local-address"); value.Exists() {
+ data.Ipv6LinkLocalAddresses = make([]InterfacePortChannelSubinterfaceIpv6LinkLocalAddresses, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := InterfacePortChannelSubinterfaceIpv6LinkLocalAddresses{}
+ if cValue := v.Get("address"); cValue.Exists() {
+ item.Address = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("link-local"); cValue.Exists() {
+ item.LinkLocal = types.BoolValue(true)
+ } else {
+ item.LinkLocal = types.BoolValue(false)
+ }
+ data.Ipv6LinkLocalAddresses = append(data.Ipv6LinkLocalAddresses, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + "ipv6.address.prefix-list"); value.Exists() {
+ data.Ipv6Addresses = make([]InterfacePortChannelSubinterfaceIpv6Addresses, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := InterfacePortChannelSubinterfaceIpv6Addresses{}
+ if cValue := v.Get("prefix"); cValue.Exists() {
+ item.Prefix = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("eui-64"); cValue.Exists() {
+ item.Eui64 = types.BoolValue(true)
+ } else {
+ item.Eui64 = types.BoolValue(false)
+ }
+ data.Ipv6Addresses = append(data.Ipv6Addresses, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + "arp.timeout"); value.Exists() {
+ data.ArpTimeout = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "ip.arp.inspection.trust"); value.Exists() {
+ data.IpArpInspectionTrust = types.BoolValue(true)
+ } else {
+ data.IpArpInspectionTrust = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "ip.arp.inspection.limit.rate"); value.Exists() {
+ data.IpArpInspectionLimitRate = types.Int64Value(value.Int())
+ }
+}
+
+// End of section. //template:end fromBody
+
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyData
+
+func (data *InterfacePortChannelSubinterfaceData) fromBody(ctx context.Context, res gjson.Result) {
+ prefix := helpers.LastElement(data.getPath()) + "."
+ if res.Get(helpers.LastElement(data.getPath())).IsArray() {
+ prefix += "0."
+ }
+ if value := res.Get(prefix + "encapsulation.dot1Q.vlan-id"); value.Exists() {
+ data.EncapsulationDot1qVlanId = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "description"); value.Exists() {
+ data.Description = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "shutdown"); value.Exists() {
+ data.Shutdown = types.BoolValue(true)
+ } else {
+ data.Shutdown = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "ip.proxy-arp"); value.Exists() {
+ data.IpProxyArp = types.BoolValue(value.Bool())
+ } else {
+ data.IpProxyArp = types.BoolNull()
+ }
+ if value := res.Get(prefix + "ip.redirects"); value.Exists() {
+ data.IpRedirects = types.BoolValue(value.Bool())
+ } else {
+ data.IpRedirects = types.BoolNull()
+ }
+ if value := res.Get(prefix + "ip.Cisco-IOS-XE-icmp:unreachables"); value.Exists() {
+ data.IpUnreachables = types.BoolValue(value.Bool())
+ } else {
+ data.IpUnreachables = types.BoolNull()
+ }
+ if value := res.Get(prefix + "vrf.forwarding"); value.Exists() {
+ data.VrfForwarding = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "ip.address.primary.address"); value.Exists() {
+ data.Ipv4Address = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "ip.address.primary.mask"); value.Exists() {
+ data.Ipv4AddressMask = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "ip.access-group.in.acl.in"); value.Exists() {
+ data.IpAccessGroupInEnable = types.BoolValue(true)
+ } else {
+ data.IpAccessGroupInEnable = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "ip.access-group.in.acl.acl-name"); value.Exists() {
+ data.IpAccessGroupIn = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "ip.access-group.out.acl.out"); value.Exists() {
+ data.IpAccessGroupOutEnable = types.BoolValue(true)
+ } else {
+ data.IpAccessGroupOutEnable = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "ip.access-group.out.acl.acl-name"); value.Exists() {
+ data.IpAccessGroupOut = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-switch:auto.qos.classify"); value.Exists() {
+ data.AutoQosClassify = types.BoolValue(true)
+ } else {
+ data.AutoQosClassify = types.BoolValue(false)
}
if value := res.Get(prefix + "Cisco-IOS-XE-switch:auto.qos.classify.police"); value.Exists() {
data.AutoQosClassifyPolice = types.BoolValue(true)
} else {
data.AutoQosClassifyPolice = types.BoolValue(false)
}
- if value := res.Get(prefix + "Cisco-IOS-XE-switch:auto.qos.trust"); value.Exists() {
+ if value := res.Get(prefix + "Cisco-IOS-XE-switch:auto.qos.trust"); value.Exists() {
+ data.AutoQosTrust = types.BoolValue(true)
+ } else {
+ data.AutoQosTrust = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-switch:auto.qos.trust.cos"); value.Exists() {
+ data.AutoQosTrustCos = types.BoolValue(true)
+ } else {
+ data.AutoQosTrustCos = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-switch:auto.qos.trust.dscp"); value.Exists() {
+ data.AutoQosTrustDscp = types.BoolValue(true)
+ } else {
+ data.AutoQosTrustDscp = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-switch:auto.qos.video.cts"); value.Exists() {
+ data.AutoQosVideoCts = types.BoolValue(true)
+ } else {
+ data.AutoQosVideoCts = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-switch:auto.qos.video.ip-camera"); value.Exists() {
+ data.AutoQosVideoIpCamera = types.BoolValue(true)
+ } else {
+ data.AutoQosVideoIpCamera = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-switch:auto.qos.video.media-player"); value.Exists() {
+ data.AutoQosVideoMediaPlayer = types.BoolValue(true)
+ } else {
+ data.AutoQosVideoMediaPlayer = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-switch:auto.qos.voip"); value.Exists() {
+ data.AutoQosVoip = types.BoolValue(true)
+ } else {
+ data.AutoQosVoip = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-switch:auto.qos.voip.cisco-phone"); value.Exists() {
+ data.AutoQosVoipCiscoPhone = types.BoolValue(true)
+ } else {
+ data.AutoQosVoipCiscoPhone = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-switch:auto.qos.voip.cisco-softphone"); value.Exists() {
+ data.AutoQosVoipCiscoSoftphone = types.BoolValue(true)
+ } else {
+ data.AutoQosVoipCiscoSoftphone = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-switch:auto.qos.voip.trust"); value.Exists() {
+ data.AutoQosVoipTrust = types.BoolValue(true)
+ } else {
+ data.AutoQosVoipTrust = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "trust.device"); value.Exists() {
+ data.TrustDevice = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "ip.helper-address"); value.Exists() {
+ data.HelperAddresses = make([]InterfacePortChannelSubinterfaceHelperAddresses, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := InterfacePortChannelSubinterfaceHelperAddresses{}
+ if cValue := v.Get("address"); cValue.Exists() {
+ item.Address = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("global"); cValue.Exists() {
+ item.Global = types.BoolValue(true)
+ } else {
+ item.Global = types.BoolValue(false)
+ }
+ if cValue := v.Get("vrf"); cValue.Exists() {
+ item.Vrf = types.StringValue(cValue.String())
+ }
+ data.HelperAddresses = append(data.HelperAddresses, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + "bfd.Cisco-IOS-XE-bfd:template"); value.Exists() {
+ data.BfdTemplate = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "bfd.Cisco-IOS-XE-bfd:enable"); value.Exists() {
+ data.BfdEnable = types.BoolValue(value.Bool())
+ } else {
+ data.BfdEnable = types.BoolNull()
+ }
+ if value := res.Get(prefix + "bfd.Cisco-IOS-XE-bfd:local-address"); value.Exists() {
+ data.BfdLocalAddress = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "bfd.Cisco-IOS-XE-bfd:interval-interface.msecs"); value.Exists() {
+ data.BfdInterval = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "bfd.Cisco-IOS-XE-bfd:interval-interface.min_rx"); value.Exists() {
+ data.BfdIntervalMinRx = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "bfd.Cisco-IOS-XE-bfd:interval-interface.multiplier"); value.Exists() {
+ data.BfdIntervalMultiplier = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "bfd.Cisco-IOS-XE-bfd:echo"); value.Exists() {
+ data.BfdEcho = types.BoolValue(value.Bool())
+ } else {
+ data.BfdEcho = types.BoolNull()
+ }
+ if value := res.Get(prefix + "ipv6.enable"); value.Exists() {
+ data.Ipv6Enable = types.BoolValue(true)
+ } else {
+ data.Ipv6Enable = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "ipv6.mtu"); value.Exists() {
+ data.Ipv6Mtu = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "ipv6.nd.Cisco-IOS-XE-nd:ra.suppress.all"); value.Exists() {
+ data.Ipv6NdRaSuppressAll = types.BoolValue(true)
+ } else {
+ data.Ipv6NdRaSuppressAll = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "ipv6.address.autoconfig.default"); value.Exists() {
+ data.Ipv6AddressAutoconfigDefault = types.BoolValue(true)
+ } else {
+ data.Ipv6AddressAutoconfigDefault = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "ipv6.address.dhcp"); value.Exists() {
+ data.Ipv6AddressDhcp = types.BoolValue(true)
+ } else {
+ data.Ipv6AddressDhcp = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "ipv6.address.link-local-address"); value.Exists() {
+ data.Ipv6LinkLocalAddresses = make([]InterfacePortChannelSubinterfaceIpv6LinkLocalAddresses, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := InterfacePortChannelSubinterfaceIpv6LinkLocalAddresses{}
+ if cValue := v.Get("address"); cValue.Exists() {
+ item.Address = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("link-local"); cValue.Exists() {
+ item.LinkLocal = types.BoolValue(true)
+ } else {
+ item.LinkLocal = types.BoolValue(false)
+ }
+ data.Ipv6LinkLocalAddresses = append(data.Ipv6LinkLocalAddresses, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + "ipv6.address.prefix-list"); value.Exists() {
+ data.Ipv6Addresses = make([]InterfacePortChannelSubinterfaceIpv6Addresses, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := InterfacePortChannelSubinterfaceIpv6Addresses{}
+ if cValue := v.Get("prefix"); cValue.Exists() {
+ item.Prefix = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("eui-64"); cValue.Exists() {
+ item.Eui64 = types.BoolValue(true)
+ } else {
+ item.Eui64 = types.BoolValue(false)
+ }
+ data.Ipv6Addresses = append(data.Ipv6Addresses, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + "arp.timeout"); value.Exists() {
+ data.ArpTimeout = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "ip.arp.inspection.trust"); value.Exists() {
+ data.IpArpInspectionTrust = types.BoolValue(true)
+ } else {
+ data.IpArpInspectionTrust = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "ip.arp.inspection.limit.rate"); value.Exists() {
+ data.IpArpInspectionLimitRate = types.Int64Value(value.Int())
+ }
+}
+
+// End of section. //template:end fromBodyData
+
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyXML
+
+func (data *InterfacePortChannelSubinterface) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/encapsulation/dot1Q/vlan-id"); value.Exists() {
+ data.EncapsulationDot1qVlanId = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/description"); value.Exists() {
+ data.Description = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/shutdown"); value.Exists() {
+ data.Shutdown = types.BoolValue(true)
+ } else {
+ data.Shutdown = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/proxy-arp"); value.Exists() {
+ data.IpProxyArp = types.BoolValue(value.Bool())
+ } else {
+ data.IpProxyArp = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/redirects"); value.Exists() {
+ data.IpRedirects = types.BoolValue(value.Bool())
+ } else {
+ data.IpRedirects = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/Cisco-IOS-XE-icmp:unreachables"); value.Exists() {
+ data.IpUnreachables = types.BoolValue(value.Bool())
+ } else {
+ data.IpUnreachables = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/vrf/forwarding"); value.Exists() {
+ data.VrfForwarding = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/address/primary/address"); value.Exists() {
+ data.Ipv4Address = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/address/primary/mask"); value.Exists() {
+ data.Ipv4AddressMask = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/access-group/in/acl/in"); value.Exists() {
+ data.IpAccessGroupInEnable = types.BoolValue(true)
+ } else {
+ data.IpAccessGroupInEnable = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/access-group/in/acl/acl-name"); value.Exists() {
+ data.IpAccessGroupIn = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/access-group/out/acl/out"); value.Exists() {
+ data.IpAccessGroupOutEnable = types.BoolValue(true)
+ } else {
+ data.IpAccessGroupOutEnable = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/access-group/out/acl/acl-name"); value.Exists() {
+ data.IpAccessGroupOut = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/classify"); value.Exists() {
+ data.AutoQosClassify = types.BoolValue(true)
+ } else {
+ data.AutoQosClassify = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/classify/police"); value.Exists() {
+ data.AutoQosClassifyPolice = types.BoolValue(true)
+ } else {
+ data.AutoQosClassifyPolice = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/trust"); value.Exists() {
+ data.AutoQosTrust = types.BoolValue(true)
+ } else {
+ data.AutoQosTrust = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/trust/cos"); value.Exists() {
+ data.AutoQosTrustCos = types.BoolValue(true)
+ } else {
+ data.AutoQosTrustCos = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/trust/dscp"); value.Exists() {
+ data.AutoQosTrustDscp = types.BoolValue(true)
+ } else {
+ data.AutoQosTrustDscp = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/video/cts"); value.Exists() {
+ data.AutoQosVideoCts = types.BoolValue(true)
+ } else {
+ data.AutoQosVideoCts = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/video/ip-camera"); value.Exists() {
+ data.AutoQosVideoIpCamera = types.BoolValue(true)
+ } else {
+ data.AutoQosVideoIpCamera = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/video/media-player"); value.Exists() {
+ data.AutoQosVideoMediaPlayer = types.BoolValue(true)
+ } else {
+ data.AutoQosVideoMediaPlayer = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/voip"); value.Exists() {
+ data.AutoQosVoip = types.BoolValue(true)
+ } else {
+ data.AutoQosVoip = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/voip/cisco-phone"); value.Exists() {
+ data.AutoQosVoipCiscoPhone = types.BoolValue(true)
+ } else {
+ data.AutoQosVoipCiscoPhone = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/voip/cisco-softphone"); value.Exists() {
+ data.AutoQosVoipCiscoSoftphone = types.BoolValue(true)
+ } else {
+ data.AutoQosVoipCiscoSoftphone = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/voip/trust"); value.Exists() {
+ data.AutoQosVoipTrust = types.BoolValue(true)
+ } else {
+ data.AutoQosVoipTrust = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/trust/device"); value.Exists() {
+ data.TrustDevice = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/helper-address"); value.Exists() {
+ data.HelperAddresses = make([]InterfacePortChannelSubinterfaceHelperAddresses, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := InterfacePortChannelSubinterfaceHelperAddresses{}
+ if cValue := helpers.GetFromXPath(v, "address"); cValue.Exists() {
+ item.Address = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "global"); cValue.Exists() {
+ item.Global = types.BoolValue(true)
+ } else {
+ item.Global = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "vrf"); cValue.Exists() {
+ item.Vrf = types.StringValue(cValue.String())
+ }
+ data.HelperAddresses = append(data.HelperAddresses, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/bfd/Cisco-IOS-XE-bfd:template"); value.Exists() {
+ data.BfdTemplate = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/bfd/Cisco-IOS-XE-bfd:enable"); value.Exists() {
+ data.BfdEnable = types.BoolValue(value.Bool())
+ } else {
+ data.BfdEnable = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/bfd/Cisco-IOS-XE-bfd:local-address"); value.Exists() {
+ data.BfdLocalAddress = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/bfd/Cisco-IOS-XE-bfd:interval-interface/msecs"); value.Exists() {
+ data.BfdInterval = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/bfd/Cisco-IOS-XE-bfd:interval-interface/min_rx"); value.Exists() {
+ data.BfdIntervalMinRx = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/bfd/Cisco-IOS-XE-bfd:interval-interface/multiplier"); value.Exists() {
+ data.BfdIntervalMultiplier = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/bfd/Cisco-IOS-XE-bfd:echo"); value.Exists() {
+ data.BfdEcho = types.BoolValue(value.Bool())
+ } else {
+ data.BfdEcho = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ipv6/enable"); value.Exists() {
+ data.Ipv6Enable = types.BoolValue(true)
+ } else {
+ data.Ipv6Enable = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ipv6/mtu"); value.Exists() {
+ data.Ipv6Mtu = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ipv6/nd/Cisco-IOS-XE-nd:ra/suppress/all"); value.Exists() {
+ data.Ipv6NdRaSuppressAll = types.BoolValue(true)
+ } else {
+ data.Ipv6NdRaSuppressAll = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ipv6/address/autoconfig/default"); value.Exists() {
+ data.Ipv6AddressAutoconfigDefault = types.BoolValue(true)
+ } else {
+ data.Ipv6AddressAutoconfigDefault = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ipv6/address/dhcp"); value.Exists() {
+ data.Ipv6AddressDhcp = types.BoolValue(true)
+ } else {
+ data.Ipv6AddressDhcp = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ipv6/address/link-local-address"); value.Exists() {
+ data.Ipv6LinkLocalAddresses = make([]InterfacePortChannelSubinterfaceIpv6LinkLocalAddresses, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := InterfacePortChannelSubinterfaceIpv6LinkLocalAddresses{}
+ if cValue := helpers.GetFromXPath(v, "address"); cValue.Exists() {
+ item.Address = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "link-local"); cValue.Exists() {
+ item.LinkLocal = types.BoolValue(true)
+ } else {
+ item.LinkLocal = types.BoolValue(false)
+ }
+ data.Ipv6LinkLocalAddresses = append(data.Ipv6LinkLocalAddresses, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ipv6/address/prefix-list"); value.Exists() {
+ data.Ipv6Addresses = make([]InterfacePortChannelSubinterfaceIpv6Addresses, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := InterfacePortChannelSubinterfaceIpv6Addresses{}
+ if cValue := helpers.GetFromXPath(v, "prefix"); cValue.Exists() {
+ item.Prefix = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "eui-64"); cValue.Exists() {
+ item.Eui64 = types.BoolValue(true)
+ } else {
+ item.Eui64 = types.BoolValue(false)
+ }
+ data.Ipv6Addresses = append(data.Ipv6Addresses, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/arp/timeout"); value.Exists() {
+ data.ArpTimeout = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/arp/inspection/trust"); value.Exists() {
+ data.IpArpInspectionTrust = types.BoolValue(true)
+ } else {
+ data.IpArpInspectionTrust = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/arp/inspection/limit/rate"); value.Exists() {
+ data.IpArpInspectionLimitRate = types.Int64Value(value.Int())
+ }
+}
+
+// End of section. //template:end fromBodyXML
+
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyDataXML
+
+func (data *InterfacePortChannelSubinterfaceData) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/encapsulation/dot1Q/vlan-id"); value.Exists() {
+ data.EncapsulationDot1qVlanId = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/description"); value.Exists() {
+ data.Description = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/shutdown"); value.Exists() {
+ data.Shutdown = types.BoolValue(true)
+ } else {
+ data.Shutdown = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/proxy-arp"); value.Exists() {
+ data.IpProxyArp = types.BoolValue(value.Bool())
+ } else {
+ data.IpProxyArp = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/redirects"); value.Exists() {
+ data.IpRedirects = types.BoolValue(value.Bool())
+ } else {
+ data.IpRedirects = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/Cisco-IOS-XE-icmp:unreachables"); value.Exists() {
+ data.IpUnreachables = types.BoolValue(value.Bool())
+ } else {
+ data.IpUnreachables = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/vrf/forwarding"); value.Exists() {
+ data.VrfForwarding = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/address/primary/address"); value.Exists() {
+ data.Ipv4Address = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/address/primary/mask"); value.Exists() {
+ data.Ipv4AddressMask = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/access-group/in/acl/in"); value.Exists() {
+ data.IpAccessGroupInEnable = types.BoolValue(true)
+ } else {
+ data.IpAccessGroupInEnable = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/access-group/in/acl/acl-name"); value.Exists() {
+ data.IpAccessGroupIn = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/access-group/out/acl/out"); value.Exists() {
+ data.IpAccessGroupOutEnable = types.BoolValue(true)
+ } else {
+ data.IpAccessGroupOutEnable = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/access-group/out/acl/acl-name"); value.Exists() {
+ data.IpAccessGroupOut = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/classify"); value.Exists() {
+ data.AutoQosClassify = types.BoolValue(true)
+ } else {
+ data.AutoQosClassify = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/classify/police"); value.Exists() {
+ data.AutoQosClassifyPolice = types.BoolValue(true)
+ } else {
+ data.AutoQosClassifyPolice = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/trust"); value.Exists() {
data.AutoQosTrust = types.BoolValue(true)
} else {
data.AutoQosTrust = types.BoolValue(false)
}
- if value := res.Get(prefix + "Cisco-IOS-XE-switch:auto.qos.trust.cos"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/trust/cos"); value.Exists() {
data.AutoQosTrustCos = types.BoolValue(true)
} else {
data.AutoQosTrustCos = types.BoolValue(false)
}
- if value := res.Get(prefix + "Cisco-IOS-XE-switch:auto.qos.trust.dscp"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/trust/dscp"); value.Exists() {
data.AutoQosTrustDscp = types.BoolValue(true)
} else {
data.AutoQosTrustDscp = types.BoolValue(false)
}
- if value := res.Get(prefix + "Cisco-IOS-XE-switch:auto.qos.video.cts"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/video/cts"); value.Exists() {
data.AutoQosVideoCts = types.BoolValue(true)
} else {
data.AutoQosVideoCts = types.BoolValue(false)
}
- if value := res.Get(prefix + "Cisco-IOS-XE-switch:auto.qos.video.ip-camera"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/video/ip-camera"); value.Exists() {
data.AutoQosVideoIpCamera = types.BoolValue(true)
} else {
data.AutoQosVideoIpCamera = types.BoolValue(false)
}
- if value := res.Get(prefix + "Cisco-IOS-XE-switch:auto.qos.video.media-player"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/video/media-player"); value.Exists() {
data.AutoQosVideoMediaPlayer = types.BoolValue(true)
} else {
data.AutoQosVideoMediaPlayer = types.BoolValue(false)
}
- if value := res.Get(prefix + "Cisco-IOS-XE-switch:auto.qos.voip"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/voip"); value.Exists() {
data.AutoQosVoip = types.BoolValue(true)
} else {
data.AutoQosVoip = types.BoolValue(false)
}
- if value := res.Get(prefix + "Cisco-IOS-XE-switch:auto.qos.voip.cisco-phone"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/voip/cisco-phone"); value.Exists() {
data.AutoQosVoipCiscoPhone = types.BoolValue(true)
} else {
data.AutoQosVoipCiscoPhone = types.BoolValue(false)
}
- if value := res.Get(prefix + "Cisco-IOS-XE-switch:auto.qos.voip.cisco-softphone"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/voip/cisco-softphone"); value.Exists() {
data.AutoQosVoipCiscoSoftphone = types.BoolValue(true)
} else {
data.AutoQosVoipCiscoSoftphone = types.BoolValue(false)
}
- if value := res.Get(prefix + "Cisco-IOS-XE-switch:auto.qos.voip.trust"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/voip/trust"); value.Exists() {
data.AutoQosVoipTrust = types.BoolValue(true)
} else {
data.AutoQosVoipTrust = types.BoolValue(false)
}
- if value := res.Get(prefix + "trust.device"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/trust/device"); value.Exists() {
data.TrustDevice = types.StringValue(value.String())
}
- if value := res.Get(prefix + "ip.helper-address"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/helper-address"); value.Exists() {
data.HelperAddresses = make([]InterfacePortChannelSubinterfaceHelperAddresses, 0)
- value.ForEach(func(k, v gjson.Result) bool {
+ value.ForEach(func(_ int, v xmldot.Result) bool {
item := InterfacePortChannelSubinterfaceHelperAddresses{}
- if cValue := v.Get("address"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "address"); cValue.Exists() {
item.Address = types.StringValue(cValue.String())
}
- if cValue := v.Get("global"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "global"); cValue.Exists() {
item.Global = types.BoolValue(true)
} else {
item.Global = types.BoolValue(false)
}
- if cValue := v.Get("vrf"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "vrf"); cValue.Exists() {
item.Vrf = types.StringValue(cValue.String())
}
data.HelperAddresses = append(data.HelperAddresses, item)
return true
})
}
- if value := res.Get(prefix + "bfd.Cisco-IOS-XE-bfd:template"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/bfd/Cisco-IOS-XE-bfd:template"); value.Exists() {
data.BfdTemplate = types.StringValue(value.String())
}
- if value := res.Get(prefix + "bfd.Cisco-IOS-XE-bfd:enable"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/bfd/Cisco-IOS-XE-bfd:enable"); value.Exists() {
data.BfdEnable = types.BoolValue(value.Bool())
} else {
data.BfdEnable = types.BoolNull()
}
- if value := res.Get(prefix + "bfd.Cisco-IOS-XE-bfd:local-address"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/bfd/Cisco-IOS-XE-bfd:local-address"); value.Exists() {
data.BfdLocalAddress = types.StringValue(value.String())
}
- if value := res.Get(prefix + "bfd.Cisco-IOS-XE-bfd:interval-interface.msecs"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/bfd/Cisco-IOS-XE-bfd:interval-interface/msecs"); value.Exists() {
data.BfdInterval = types.Int64Value(value.Int())
}
- if value := res.Get(prefix + "bfd.Cisco-IOS-XE-bfd:interval-interface.min_rx"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/bfd/Cisco-IOS-XE-bfd:interval-interface/min_rx"); value.Exists() {
data.BfdIntervalMinRx = types.Int64Value(value.Int())
}
- if value := res.Get(prefix + "bfd.Cisco-IOS-XE-bfd:interval-interface.multiplier"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/bfd/Cisco-IOS-XE-bfd:interval-interface/multiplier"); value.Exists() {
data.BfdIntervalMultiplier = types.Int64Value(value.Int())
}
- if value := res.Get(prefix + "bfd.Cisco-IOS-XE-bfd:echo"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/bfd/Cisco-IOS-XE-bfd:echo"); value.Exists() {
data.BfdEcho = types.BoolValue(value.Bool())
} else {
data.BfdEcho = types.BoolNull()
}
- if value := res.Get(prefix + "ipv6.enable"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ipv6/enable"); value.Exists() {
data.Ipv6Enable = types.BoolValue(true)
} else {
data.Ipv6Enable = types.BoolValue(false)
}
- if value := res.Get(prefix + "ipv6.mtu"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ipv6/mtu"); value.Exists() {
data.Ipv6Mtu = types.Int64Value(value.Int())
}
- if value := res.Get(prefix + "ipv6.nd.Cisco-IOS-XE-nd:ra.suppress.all"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ipv6/nd/Cisco-IOS-XE-nd:ra/suppress/all"); value.Exists() {
data.Ipv6NdRaSuppressAll = types.BoolValue(true)
} else {
data.Ipv6NdRaSuppressAll = types.BoolValue(false)
}
- if value := res.Get(prefix + "ipv6.address.autoconfig.default"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ipv6/address/autoconfig/default"); value.Exists() {
data.Ipv6AddressAutoconfigDefault = types.BoolValue(true)
} else {
data.Ipv6AddressAutoconfigDefault = types.BoolValue(false)
}
- if value := res.Get(prefix + "ipv6.address.dhcp"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ipv6/address/dhcp"); value.Exists() {
data.Ipv6AddressDhcp = types.BoolValue(true)
} else {
data.Ipv6AddressDhcp = types.BoolValue(false)
}
- if value := res.Get(prefix + "ipv6.address.link-local-address"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ipv6/address/link-local-address"); value.Exists() {
data.Ipv6LinkLocalAddresses = make([]InterfacePortChannelSubinterfaceIpv6LinkLocalAddresses, 0)
- value.ForEach(func(k, v gjson.Result) bool {
+ value.ForEach(func(_ int, v xmldot.Result) bool {
item := InterfacePortChannelSubinterfaceIpv6LinkLocalAddresses{}
- if cValue := v.Get("address"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "address"); cValue.Exists() {
item.Address = types.StringValue(cValue.String())
}
- if cValue := v.Get("link-local"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "link-local"); cValue.Exists() {
item.LinkLocal = types.BoolValue(true)
} else {
item.LinkLocal = types.BoolValue(false)
@@ -1028,14 +2437,14 @@ func (data *InterfacePortChannelSubinterface) fromBody(ctx context.Context, res
return true
})
}
- if value := res.Get(prefix + "ipv6.address.prefix-list"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ipv6/address/prefix-list"); value.Exists() {
data.Ipv6Addresses = make([]InterfacePortChannelSubinterfaceIpv6Addresses, 0)
- value.ForEach(func(k, v gjson.Result) bool {
+ value.ForEach(func(_ int, v xmldot.Result) bool {
item := InterfacePortChannelSubinterfaceIpv6Addresses{}
- if cValue := v.Get("prefix"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "prefix"); cValue.Exists() {
item.Prefix = types.StringValue(cValue.String())
}
- if cValue := v.Get("eui-64"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "eui-64"); cValue.Exists() {
item.Eui64 = types.BoolValue(true)
} else {
item.Eui64 = types.BoolValue(false)
@@ -1044,274 +2453,333 @@ func (data *InterfacePortChannelSubinterface) fromBody(ctx context.Context, res
return true
})
}
- if value := res.Get(prefix + "arp.timeout"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/arp/timeout"); value.Exists() {
data.ArpTimeout = types.Int64Value(value.Int())
}
- if value := res.Get(prefix + "ip.arp.inspection.trust"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/arp/inspection/trust"); value.Exists() {
data.IpArpInspectionTrust = types.BoolValue(true)
} else {
data.IpArpInspectionTrust = types.BoolValue(false)
}
- if value := res.Get(prefix + "ip.arp.inspection.limit.rate"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/arp/inspection/limit/rate"); value.Exists() {
data.IpArpInspectionLimitRate = types.Int64Value(value.Int())
}
}
-// End of section. //template:end fromBody
+// End of section. //template:end fromBodyDataXML
-// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyData
+// Section below is generated&owned by "gen/generator.go". //template:begin getDeletedItems
-func (data *InterfacePortChannelSubinterfaceData) fromBody(ctx context.Context, res gjson.Result) {
- prefix := helpers.LastElement(data.getPath()) + "."
- if res.Get(helpers.LastElement(data.getPath())).IsArray() {
- prefix += "0."
+func (data *InterfacePortChannelSubinterface) getDeletedItems(ctx context.Context, state InterfacePortChannelSubinterface) []string {
+ deletedItems := make([]string, 0)
+ if !state.IpArpInspectionLimitRate.IsNull() && data.IpArpInspectionLimitRate.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/arp/inspection/limit/rate", state.getPath()))
}
- if value := res.Get(prefix + "encapsulation.dot1Q.vlan-id"); value.Exists() {
- data.EncapsulationDot1qVlanId = types.Int64Value(value.Int())
+ if !state.IpArpInspectionTrust.IsNull() && data.IpArpInspectionTrust.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/arp/inspection/trust", state.getPath()))
}
- if value := res.Get(prefix + "description"); value.Exists() {
- data.Description = types.StringValue(value.String())
+ if !state.ArpTimeout.IsNull() && data.ArpTimeout.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/arp/timeout", state.getPath()))
}
- if value := res.Get(prefix + "shutdown"); value.Exists() {
- data.Shutdown = types.BoolValue(true)
- } else {
- data.Shutdown = types.BoolValue(false)
+ for i := range state.Ipv6Addresses {
+ stateKeyValues := [...]string{state.Ipv6Addresses[i].Prefix.ValueString()}
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.Ipv6Addresses[i].Prefix.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.Ipv6Addresses {
+ found = true
+ if state.Ipv6Addresses[i].Prefix.ValueString() != data.Ipv6Addresses[j].Prefix.ValueString() {
+ found = false
+ }
+ if found {
+ if !state.Ipv6Addresses[i].Eui64.IsNull() && data.Ipv6Addresses[j].Eui64.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ipv6/address/prefix-list=%v/eui-64", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ break
+ }
+ }
+ if !found {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ipv6/address/prefix-list=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
}
- if value := res.Get(prefix + "ip.proxy-arp"); value.Exists() {
- data.IpProxyArp = types.BoolValue(value.Bool())
- } else {
- data.IpProxyArp = types.BoolNull()
+ for i := range state.Ipv6LinkLocalAddresses {
+ stateKeyValues := [...]string{state.Ipv6LinkLocalAddresses[i].Address.ValueString()}
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.Ipv6LinkLocalAddresses[i].Address.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.Ipv6LinkLocalAddresses {
+ found = true
+ if state.Ipv6LinkLocalAddresses[i].Address.ValueString() != data.Ipv6LinkLocalAddresses[j].Address.ValueString() {
+ found = false
+ }
+ if found {
+ if !state.Ipv6LinkLocalAddresses[i].LinkLocal.IsNull() && data.Ipv6LinkLocalAddresses[j].LinkLocal.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ipv6/address/link-local-address=%v/link-local", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ break
+ }
+ }
+ if !found {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ipv6/address/link-local-address=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
}
- if value := res.Get(prefix + "ip.redirects"); value.Exists() {
- data.IpRedirects = types.BoolValue(value.Bool())
- } else {
- data.IpRedirects = types.BoolNull()
+ if !state.Ipv6AddressDhcp.IsNull() && data.Ipv6AddressDhcp.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ipv6/address/dhcp", state.getPath()))
}
- if value := res.Get(prefix + "ip.Cisco-IOS-XE-icmp:unreachables"); value.Exists() {
- data.IpUnreachables = types.BoolValue(value.Bool())
- } else {
- data.IpUnreachables = types.BoolNull()
+ if !state.Ipv6AddressAutoconfigDefault.IsNull() && data.Ipv6AddressAutoconfigDefault.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ipv6/address/autoconfig/default", state.getPath()))
}
- if value := res.Get(prefix + "vrf.forwarding"); value.Exists() {
- data.VrfForwarding = types.StringValue(value.String())
+ if !state.Ipv6NdRaSuppressAll.IsNull() && data.Ipv6NdRaSuppressAll.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ipv6/nd/Cisco-IOS-XE-nd:ra/suppress/all", state.getPath()))
}
- if value := res.Get(prefix + "ip.address.primary.address"); value.Exists() {
- data.Ipv4Address = types.StringValue(value.String())
+ if !state.Ipv6Mtu.IsNull() && data.Ipv6Mtu.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ipv6/mtu", state.getPath()))
+ }
+ if !state.Ipv6Enable.IsNull() && data.Ipv6Enable.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ipv6/enable", state.getPath()))
+ }
+ if !state.BfdEcho.IsNull() && data.BfdEcho.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/bfd/Cisco-IOS-XE-bfd:echo", state.getPath()))
+ }
+ if !state.BfdIntervalMultiplier.IsNull() && data.BfdIntervalMultiplier.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/bfd/Cisco-IOS-XE-bfd:interval-interface", state.getPath()))
+ }
+ if !state.BfdIntervalMinRx.IsNull() && data.BfdIntervalMinRx.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/bfd/Cisco-IOS-XE-bfd:interval-interface", state.getPath()))
+ }
+ if !state.BfdInterval.IsNull() && data.BfdInterval.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/bfd/Cisco-IOS-XE-bfd:interval-interface", state.getPath()))
+ }
+ if !state.BfdLocalAddress.IsNull() && data.BfdLocalAddress.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/bfd/Cisco-IOS-XE-bfd:local-address", state.getPath()))
+ }
+ if !state.BfdEnable.IsNull() && data.BfdEnable.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/bfd/Cisco-IOS-XE-bfd:enable", state.getPath()))
+ }
+ if !state.BfdTemplate.IsNull() && data.BfdTemplate.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/bfd/Cisco-IOS-XE-bfd:template", state.getPath()))
+ }
+ for i := range state.HelperAddresses {
+ stateKeyValues := [...]string{state.HelperAddresses[i].Address.ValueString()}
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.HelperAddresses[i].Address.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.HelperAddresses {
+ found = true
+ if state.HelperAddresses[i].Address.ValueString() != data.HelperAddresses[j].Address.ValueString() {
+ found = false
+ }
+ if found {
+ if !state.HelperAddresses[i].Vrf.IsNull() && data.HelperAddresses[j].Vrf.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/helper-address=%v/vrf", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ if !state.HelperAddresses[i].Global.IsNull() && data.HelperAddresses[j].Global.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/helper-address=%v/global", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ break
+ }
+ }
+ if !found {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/helper-address=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ }
+ if !state.TrustDevice.IsNull() && data.TrustDevice.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/trust/device", state.getPath()))
+ }
+ if !state.AutoQosVoipTrust.IsNull() && data.AutoQosVoipTrust.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-switch:auto/qos/voip/trust", state.getPath()))
+ }
+ if !state.AutoQosVoipCiscoSoftphone.IsNull() && data.AutoQosVoipCiscoSoftphone.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-switch:auto/qos/voip/cisco-softphone", state.getPath()))
+ }
+ if !state.AutoQosVoipCiscoPhone.IsNull() && data.AutoQosVoipCiscoPhone.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-switch:auto/qos/voip/cisco-phone", state.getPath()))
+ }
+ if !state.AutoQosVoip.IsNull() && data.AutoQosVoip.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-switch:auto/qos/voip", state.getPath()))
+ }
+ if !state.AutoQosVideoMediaPlayer.IsNull() && data.AutoQosVideoMediaPlayer.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-switch:auto/qos/video/media-player", state.getPath()))
+ }
+ if !state.AutoQosVideoIpCamera.IsNull() && data.AutoQosVideoIpCamera.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-switch:auto/qos/video/ip-camera", state.getPath()))
+ }
+ if !state.AutoQosVideoCts.IsNull() && data.AutoQosVideoCts.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-switch:auto/qos/video/cts", state.getPath()))
+ }
+ if !state.AutoQosTrustDscp.IsNull() && data.AutoQosTrustDscp.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-switch:auto/qos/trust/dscp", state.getPath()))
+ }
+ if !state.AutoQosTrustCos.IsNull() && data.AutoQosTrustCos.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-switch:auto/qos/trust/cos", state.getPath()))
+ }
+ if !state.AutoQosTrust.IsNull() && data.AutoQosTrust.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-switch:auto/qos/trust", state.getPath()))
+ }
+ if !state.AutoQosClassifyPolice.IsNull() && data.AutoQosClassifyPolice.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-switch:auto/qos/classify/police", state.getPath()))
+ }
+ if !state.AutoQosClassify.IsNull() && data.AutoQosClassify.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-switch:auto/qos/classify", state.getPath()))
}
- if value := res.Get(prefix + "ip.address.primary.mask"); value.Exists() {
- data.Ipv4AddressMask = types.StringValue(value.String())
+ if !state.IpAccessGroupOut.IsNull() && data.IpAccessGroupOut.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/access-group/out/acl", state.getPath()))
}
- if value := res.Get(prefix + "ip.access-group.in.acl.in"); value.Exists() {
- data.IpAccessGroupInEnable = types.BoolValue(true)
- } else {
- data.IpAccessGroupInEnable = types.BoolValue(false)
+ if !state.IpAccessGroupOutEnable.IsNull() && data.IpAccessGroupOutEnable.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/access-group/out/acl/out", state.getPath()))
}
- if value := res.Get(prefix + "ip.access-group.in.acl.acl-name"); value.Exists() {
- data.IpAccessGroupIn = types.StringValue(value.String())
+ if !state.IpAccessGroupIn.IsNull() && data.IpAccessGroupIn.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/access-group/in/acl", state.getPath()))
}
- if value := res.Get(prefix + "ip.access-group.out.acl.out"); value.Exists() {
- data.IpAccessGroupOutEnable = types.BoolValue(true)
- } else {
- data.IpAccessGroupOutEnable = types.BoolValue(false)
+ if !state.IpAccessGroupInEnable.IsNull() && data.IpAccessGroupInEnable.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/access-group/in/acl/in", state.getPath()))
}
- if value := res.Get(prefix + "ip.access-group.out.acl.acl-name"); value.Exists() {
- data.IpAccessGroupOut = types.StringValue(value.String())
+ if !state.Ipv4AddressMask.IsNull() && data.Ipv4AddressMask.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/address/primary", state.getPath()))
}
- if value := res.Get(prefix + "Cisco-IOS-XE-switch:auto.qos.classify"); value.Exists() {
- data.AutoQosClassify = types.BoolValue(true)
- } else {
- data.AutoQosClassify = types.BoolValue(false)
+ if !state.Ipv4Address.IsNull() && data.Ipv4Address.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/address/primary", state.getPath()))
}
- if value := res.Get(prefix + "Cisco-IOS-XE-switch:auto.qos.classify.police"); value.Exists() {
- data.AutoQosClassifyPolice = types.BoolValue(true)
- } else {
- data.AutoQosClassifyPolice = types.BoolValue(false)
+ if !state.VrfForwarding.IsNull() && data.VrfForwarding.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/vrf/forwarding", state.getPath()))
}
- if value := res.Get(prefix + "Cisco-IOS-XE-switch:auto.qos.trust"); value.Exists() {
- data.AutoQosTrust = types.BoolValue(true)
- } else {
- data.AutoQosTrust = types.BoolValue(false)
+ if !state.IpUnreachables.IsNull() && data.IpUnreachables.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/Cisco-IOS-XE-icmp:unreachables", state.getPath()))
}
- if value := res.Get(prefix + "Cisco-IOS-XE-switch:auto.qos.trust.cos"); value.Exists() {
- data.AutoQosTrustCos = types.BoolValue(true)
- } else {
- data.AutoQosTrustCos = types.BoolValue(false)
+ if !state.IpRedirects.IsNull() && data.IpRedirects.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/redirects", state.getPath()))
}
- if value := res.Get(prefix + "Cisco-IOS-XE-switch:auto.qos.trust.dscp"); value.Exists() {
- data.AutoQosTrustDscp = types.BoolValue(true)
- } else {
- data.AutoQosTrustDscp = types.BoolValue(false)
+ if !state.IpProxyArp.IsNull() && data.IpProxyArp.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/proxy-arp", state.getPath()))
}
- if value := res.Get(prefix + "Cisco-IOS-XE-switch:auto.qos.video.cts"); value.Exists() {
- data.AutoQosVideoCts = types.BoolValue(true)
- } else {
- data.AutoQosVideoCts = types.BoolValue(false)
+ if !state.Shutdown.IsNull() && data.Shutdown.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/shutdown", state.getPath()))
}
- if value := res.Get(prefix + "Cisco-IOS-XE-switch:auto.qos.video.ip-camera"); value.Exists() {
- data.AutoQosVideoIpCamera = types.BoolValue(true)
- } else {
- data.AutoQosVideoIpCamera = types.BoolValue(false)
+ if !state.Description.IsNull() && data.Description.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/description", state.getPath()))
}
- if value := res.Get(prefix + "Cisco-IOS-XE-switch:auto.qos.video.media-player"); value.Exists() {
- data.AutoQosVideoMediaPlayer = types.BoolValue(true)
- } else {
- data.AutoQosVideoMediaPlayer = types.BoolValue(false)
+ if !state.EncapsulationDot1qVlanId.IsNull() && data.EncapsulationDot1qVlanId.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/encapsulation/dot1Q/vlan-id", state.getPath()))
}
- if value := res.Get(prefix + "Cisco-IOS-XE-switch:auto.qos.voip"); value.Exists() {
- data.AutoQosVoip = types.BoolValue(true)
- } else {
- data.AutoQosVoip = types.BoolValue(false)
+
+ return deletedItems
+}
+
+// End of section. //template:end getDeletedItems
+
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletedItemsXML
+
+func (data *InterfacePortChannelSubinterface) addDeletedItemsXML(ctx context.Context, state InterfacePortChannelSubinterface, body string) string {
+ b := netconf.NewBody(body)
+ if !state.EncapsulationDot1qVlanId.IsNull() && data.EncapsulationDot1qVlanId.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/encapsulation/dot1Q/vlan-id")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-switch:auto.qos.voip.cisco-phone"); value.Exists() {
- data.AutoQosVoipCiscoPhone = types.BoolValue(true)
- } else {
- data.AutoQosVoipCiscoPhone = types.BoolValue(false)
+ if !state.Description.IsNull() && data.Description.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/description")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-switch:auto.qos.voip.cisco-softphone"); value.Exists() {
- data.AutoQosVoipCiscoSoftphone = types.BoolValue(true)
- } else {
- data.AutoQosVoipCiscoSoftphone = types.BoolValue(false)
+ if !state.Shutdown.IsNull() && data.Shutdown.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/shutdown")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-switch:auto.qos.voip.trust"); value.Exists() {
- data.AutoQosVoipTrust = types.BoolValue(true)
- } else {
- data.AutoQosVoipTrust = types.BoolValue(false)
+ if !state.IpProxyArp.IsNull() && data.IpProxyArp.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ip/proxy-arp")
}
- if value := res.Get(prefix + "trust.device"); value.Exists() {
- data.TrustDevice = types.StringValue(value.String())
+ if !state.IpRedirects.IsNull() && data.IpRedirects.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ip/redirects")
}
- if value := res.Get(prefix + "ip.helper-address"); value.Exists() {
- data.HelperAddresses = make([]InterfacePortChannelSubinterfaceHelperAddresses, 0)
- value.ForEach(func(k, v gjson.Result) bool {
- item := InterfacePortChannelSubinterfaceHelperAddresses{}
- if cValue := v.Get("address"); cValue.Exists() {
- item.Address = types.StringValue(cValue.String())
- }
- if cValue := v.Get("global"); cValue.Exists() {
- item.Global = types.BoolValue(true)
- } else {
- item.Global = types.BoolValue(false)
- }
- if cValue := v.Get("vrf"); cValue.Exists() {
- item.Vrf = types.StringValue(cValue.String())
- }
- data.HelperAddresses = append(data.HelperAddresses, item)
- return true
- })
+ if !state.IpUnreachables.IsNull() && data.IpUnreachables.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ip/Cisco-IOS-XE-icmp:unreachables")
}
- if value := res.Get(prefix + "bfd.Cisco-IOS-XE-bfd:template"); value.Exists() {
- data.BfdTemplate = types.StringValue(value.String())
+ if !state.VrfForwarding.IsNull() && data.VrfForwarding.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/vrf/forwarding")
}
- if value := res.Get(prefix + "bfd.Cisco-IOS-XE-bfd:enable"); value.Exists() {
- data.BfdEnable = types.BoolValue(value.Bool())
- } else {
- data.BfdEnable = types.BoolNull()
+ if !state.Ipv4Address.IsNull() && data.Ipv4Address.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ip/address/primary/address")
}
- if value := res.Get(prefix + "bfd.Cisco-IOS-XE-bfd:local-address"); value.Exists() {
- data.BfdLocalAddress = types.StringValue(value.String())
+ if !state.Ipv4AddressMask.IsNull() && data.Ipv4AddressMask.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ip/address/primary/mask")
}
- if value := res.Get(prefix + "bfd.Cisco-IOS-XE-bfd:interval-interface.msecs"); value.Exists() {
- data.BfdInterval = types.Int64Value(value.Int())
+ if !state.IpAccessGroupInEnable.IsNull() && data.IpAccessGroupInEnable.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ip/access-group/in/acl/in")
}
- if value := res.Get(prefix + "bfd.Cisco-IOS-XE-bfd:interval-interface.min_rx"); value.Exists() {
- data.BfdIntervalMinRx = types.Int64Value(value.Int())
+ if !state.IpAccessGroupIn.IsNull() && data.IpAccessGroupIn.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ip/access-group/in/acl/acl-name")
}
- if value := res.Get(prefix + "bfd.Cisco-IOS-XE-bfd:interval-interface.multiplier"); value.Exists() {
- data.BfdIntervalMultiplier = types.Int64Value(value.Int())
+ if !state.IpAccessGroupOutEnable.IsNull() && data.IpAccessGroupOutEnable.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ip/access-group/out/acl/out")
}
- if value := res.Get(prefix + "bfd.Cisco-IOS-XE-bfd:echo"); value.Exists() {
- data.BfdEcho = types.BoolValue(value.Bool())
- } else {
- data.BfdEcho = types.BoolNull()
+ if !state.IpAccessGroupOut.IsNull() && data.IpAccessGroupOut.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ip/access-group/out/acl/acl-name")
}
- if value := res.Get(prefix + "ipv6.enable"); value.Exists() {
- data.Ipv6Enable = types.BoolValue(true)
- } else {
- data.Ipv6Enable = types.BoolValue(false)
+ if !state.AutoQosClassify.IsNull() && data.AutoQosClassify.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/classify")
}
- if value := res.Get(prefix + "ipv6.mtu"); value.Exists() {
- data.Ipv6Mtu = types.Int64Value(value.Int())
+ if !state.AutoQosClassifyPolice.IsNull() && data.AutoQosClassifyPolice.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/classify/police")
}
- if value := res.Get(prefix + "ipv6.nd.Cisco-IOS-XE-nd:ra.suppress.all"); value.Exists() {
- data.Ipv6NdRaSuppressAll = types.BoolValue(true)
- } else {
- data.Ipv6NdRaSuppressAll = types.BoolValue(false)
+ if !state.AutoQosTrust.IsNull() && data.AutoQosTrust.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/trust")
}
- if value := res.Get(prefix + "ipv6.address.autoconfig.default"); value.Exists() {
- data.Ipv6AddressAutoconfigDefault = types.BoolValue(true)
- } else {
- data.Ipv6AddressAutoconfigDefault = types.BoolValue(false)
+ if !state.AutoQosTrustCos.IsNull() && data.AutoQosTrustCos.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/trust/cos")
}
- if value := res.Get(prefix + "ipv6.address.dhcp"); value.Exists() {
- data.Ipv6AddressDhcp = types.BoolValue(true)
- } else {
- data.Ipv6AddressDhcp = types.BoolValue(false)
+ if !state.AutoQosTrustDscp.IsNull() && data.AutoQosTrustDscp.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/trust/dscp")
}
- if value := res.Get(prefix + "ipv6.address.link-local-address"); value.Exists() {
- data.Ipv6LinkLocalAddresses = make([]InterfacePortChannelSubinterfaceIpv6LinkLocalAddresses, 0)
- value.ForEach(func(k, v gjson.Result) bool {
- item := InterfacePortChannelSubinterfaceIpv6LinkLocalAddresses{}
- if cValue := v.Get("address"); cValue.Exists() {
- item.Address = types.StringValue(cValue.String())
- }
- if cValue := v.Get("link-local"); cValue.Exists() {
- item.LinkLocal = types.BoolValue(true)
- } else {
- item.LinkLocal = types.BoolValue(false)
- }
- data.Ipv6LinkLocalAddresses = append(data.Ipv6LinkLocalAddresses, item)
- return true
- })
+ if !state.AutoQosVideoCts.IsNull() && data.AutoQosVideoCts.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/video/cts")
}
- if value := res.Get(prefix + "ipv6.address.prefix-list"); value.Exists() {
- data.Ipv6Addresses = make([]InterfacePortChannelSubinterfaceIpv6Addresses, 0)
- value.ForEach(func(k, v gjson.Result) bool {
- item := InterfacePortChannelSubinterfaceIpv6Addresses{}
- if cValue := v.Get("prefix"); cValue.Exists() {
- item.Prefix = types.StringValue(cValue.String())
- }
- if cValue := v.Get("eui-64"); cValue.Exists() {
- item.Eui64 = types.BoolValue(true)
- } else {
- item.Eui64 = types.BoolValue(false)
- }
- data.Ipv6Addresses = append(data.Ipv6Addresses, item)
- return true
- })
+ if !state.AutoQosVideoIpCamera.IsNull() && data.AutoQosVideoIpCamera.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/video/ip-camera")
}
- if value := res.Get(prefix + "arp.timeout"); value.Exists() {
- data.ArpTimeout = types.Int64Value(value.Int())
+ if !state.AutoQosVideoMediaPlayer.IsNull() && data.AutoQosVideoMediaPlayer.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/video/media-player")
}
- if value := res.Get(prefix + "ip.arp.inspection.trust"); value.Exists() {
- data.IpArpInspectionTrust = types.BoolValue(true)
- } else {
- data.IpArpInspectionTrust = types.BoolValue(false)
+ if !state.AutoQosVoip.IsNull() && data.AutoQosVoip.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/voip")
}
- if value := res.Get(prefix + "ip.arp.inspection.limit.rate"); value.Exists() {
- data.IpArpInspectionLimitRate = types.Int64Value(value.Int())
+ if !state.AutoQosVoipCiscoPhone.IsNull() && data.AutoQosVoipCiscoPhone.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/voip/cisco-phone")
}
-}
-
-// End of section. //template:end fromBodyData
-
-// Section below is generated&owned by "gen/generator.go". //template:begin getDeletedItems
-
-func (data *InterfacePortChannelSubinterface) getDeletedItems(ctx context.Context, state InterfacePortChannelSubinterface) []string {
- deletedItems := make([]string, 0)
- if !state.IpArpInspectionLimitRate.IsNull() && data.IpArpInspectionLimitRate.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/arp/inspection/limit/rate", state.getPath()))
+ if !state.AutoQosVoipCiscoSoftphone.IsNull() && data.AutoQosVoipCiscoSoftphone.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/voip/cisco-softphone")
}
- if !state.IpArpInspectionTrust.IsNull() && data.IpArpInspectionTrust.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/arp/inspection/trust", state.getPath()))
+ if !state.AutoQosVoipTrust.IsNull() && data.AutoQosVoipTrust.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/voip/trust")
}
- if !state.ArpTimeout.IsNull() && data.ArpTimeout.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/arp/timeout", state.getPath()))
+ if !state.TrustDevice.IsNull() && data.TrustDevice.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/trust/device")
}
- for i := range state.Ipv6Addresses {
- stateKeyValues := [...]string{state.Ipv6Addresses[i].Prefix.ValueString()}
+ for i := range state.HelperAddresses {
+ stateKeys := [...]string{"address"}
+ stateKeyValues := [...]string{state.HelperAddresses[i].Address.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
emptyKeys := true
- if !reflect.ValueOf(state.Ipv6Addresses[i].Prefix.ValueString()).IsZero() {
+ if !reflect.ValueOf(state.HelperAddresses[i].Address.ValueString()).IsZero() {
emptyKeys = false
}
if emptyKeys {
@@ -1319,24 +2787,68 @@ func (data *InterfacePortChannelSubinterface) getDeletedItems(ctx context.Contex
}
found := false
- for j := range data.Ipv6Addresses {
+ for j := range data.HelperAddresses {
found = true
- if state.Ipv6Addresses[i].Prefix.ValueString() != data.Ipv6Addresses[j].Prefix.ValueString() {
+ if state.HelperAddresses[i].Address.ValueString() != data.HelperAddresses[j].Address.ValueString() {
found = false
}
if found {
- if !state.Ipv6Addresses[i].Eui64.IsNull() && data.Ipv6Addresses[j].Eui64.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ipv6/address/prefix-list=%v/eui-64", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ if !state.HelperAddresses[i].Global.IsNull() && data.HelperAddresses[j].Global.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/ip/helper-address%v/global", predicates))
+ }
+ if !state.HelperAddresses[i].Vrf.IsNull() && data.HelperAddresses[j].Vrf.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/ip/helper-address%v/vrf", predicates))
}
break
}
}
if !found {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ipv6/address/prefix-list=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/ip/helper-address%v", predicates))
}
}
+ if !state.BfdTemplate.IsNull() && data.BfdTemplate.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/bfd/Cisco-IOS-XE-bfd:template")
+ }
+ if !state.BfdEnable.IsNull() && data.BfdEnable.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/bfd/Cisco-IOS-XE-bfd:enable")
+ }
+ if !state.BfdLocalAddress.IsNull() && data.BfdLocalAddress.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/bfd/Cisco-IOS-XE-bfd:local-address")
+ }
+ if !state.BfdInterval.IsNull() && data.BfdInterval.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/bfd/Cisco-IOS-XE-bfd:interval-interface/msecs")
+ }
+ if !state.BfdIntervalMinRx.IsNull() && data.BfdIntervalMinRx.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/bfd/Cisco-IOS-XE-bfd:interval-interface/min_rx")
+ }
+ if !state.BfdIntervalMultiplier.IsNull() && data.BfdIntervalMultiplier.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/bfd/Cisco-IOS-XE-bfd:interval-interface/multiplier")
+ }
+ if !state.BfdEcho.IsNull() && data.BfdEcho.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/bfd/Cisco-IOS-XE-bfd:echo")
+ }
+ if !state.Ipv6Enable.IsNull() && data.Ipv6Enable.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ipv6/enable")
+ }
+ if !state.Ipv6Mtu.IsNull() && data.Ipv6Mtu.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ipv6/mtu")
+ }
+ if !state.Ipv6NdRaSuppressAll.IsNull() && data.Ipv6NdRaSuppressAll.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ipv6/nd/Cisco-IOS-XE-nd:ra/suppress/all")
+ }
+ if !state.Ipv6AddressAutoconfigDefault.IsNull() && data.Ipv6AddressAutoconfigDefault.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ipv6/address/autoconfig/default")
+ }
+ if !state.Ipv6AddressDhcp.IsNull() && data.Ipv6AddressDhcp.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ipv6/address/dhcp")
+ }
for i := range state.Ipv6LinkLocalAddresses {
+ stateKeys := [...]string{"address"}
stateKeyValues := [...]string{state.Ipv6LinkLocalAddresses[i].Address.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
emptyKeys := true
if !reflect.ValueOf(state.Ipv6LinkLocalAddresses[i].Address.ValueString()).IsZero() {
@@ -1354,56 +2866,25 @@ func (data *InterfacePortChannelSubinterface) getDeletedItems(ctx context.Contex
}
if found {
if !state.Ipv6LinkLocalAddresses[i].LinkLocal.IsNull() && data.Ipv6LinkLocalAddresses[j].LinkLocal.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ipv6/address/link-local-address=%v/link-local", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/ipv6/address/link-local-address%v/link-local", predicates))
}
break
}
}
if !found {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ipv6/address/link-local-address=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/ipv6/address/link-local-address%v", predicates))
}
}
- if !state.Ipv6AddressDhcp.IsNull() && data.Ipv6AddressDhcp.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ipv6/address/dhcp", state.getPath()))
- }
- if !state.Ipv6AddressAutoconfigDefault.IsNull() && data.Ipv6AddressAutoconfigDefault.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ipv6/address/autoconfig/default", state.getPath()))
- }
- if !state.Ipv6NdRaSuppressAll.IsNull() && data.Ipv6NdRaSuppressAll.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ipv6/nd/Cisco-IOS-XE-nd:ra/suppress/all", state.getPath()))
- }
- if !state.Ipv6Mtu.IsNull() && data.Ipv6Mtu.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ipv6/mtu", state.getPath()))
- }
- if !state.Ipv6Enable.IsNull() && data.Ipv6Enable.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ipv6/enable", state.getPath()))
- }
- if !state.BfdEcho.IsNull() && data.BfdEcho.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/bfd/Cisco-IOS-XE-bfd:echo", state.getPath()))
- }
- if !state.BfdIntervalMultiplier.IsNull() && data.BfdIntervalMultiplier.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/bfd/Cisco-IOS-XE-bfd:interval-interface", state.getPath()))
- }
- if !state.BfdIntervalMinRx.IsNull() && data.BfdIntervalMinRx.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/bfd/Cisco-IOS-XE-bfd:interval-interface", state.getPath()))
- }
- if !state.BfdInterval.IsNull() && data.BfdInterval.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/bfd/Cisco-IOS-XE-bfd:interval-interface", state.getPath()))
- }
- if !state.BfdLocalAddress.IsNull() && data.BfdLocalAddress.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/bfd/Cisco-IOS-XE-bfd:local-address", state.getPath()))
- }
- if !state.BfdEnable.IsNull() && data.BfdEnable.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/bfd/Cisco-IOS-XE-bfd:enable", state.getPath()))
- }
- if !state.BfdTemplate.IsNull() && data.BfdTemplate.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/bfd/Cisco-IOS-XE-bfd:template", state.getPath()))
- }
- for i := range state.HelperAddresses {
- stateKeyValues := [...]string{state.HelperAddresses[i].Address.ValueString()}
+ for i := range state.Ipv6Addresses {
+ stateKeys := [...]string{"prefix"}
+ stateKeyValues := [...]string{state.Ipv6Addresses[i].Prefix.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
emptyKeys := true
- if !reflect.ValueOf(state.HelperAddresses[i].Address.ValueString()).IsZero() {
+ if !reflect.ValueOf(state.Ipv6Addresses[i].Prefix.ValueString()).IsZero() {
emptyKeys = false
}
if emptyKeys {
@@ -1411,108 +2892,36 @@ func (data *InterfacePortChannelSubinterface) getDeletedItems(ctx context.Contex
}
found := false
- for j := range data.HelperAddresses {
+ for j := range data.Ipv6Addresses {
found = true
- if state.HelperAddresses[i].Address.ValueString() != data.HelperAddresses[j].Address.ValueString() {
+ if state.Ipv6Addresses[i].Prefix.ValueString() != data.Ipv6Addresses[j].Prefix.ValueString() {
found = false
}
if found {
- if !state.HelperAddresses[i].Vrf.IsNull() && data.HelperAddresses[j].Vrf.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/helper-address=%v/vrf", state.getPath(), strings.Join(stateKeyValues[:], ",")))
- }
- if !state.HelperAddresses[i].Global.IsNull() && data.HelperAddresses[j].Global.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/helper-address=%v/global", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ if !state.Ipv6Addresses[i].Eui64.IsNull() && data.Ipv6Addresses[j].Eui64.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/ipv6/address/prefix-list%v/eui-64", predicates))
}
break
}
}
if !found {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/helper-address=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/ipv6/address/prefix-list%v", predicates))
}
}
- if !state.TrustDevice.IsNull() && data.TrustDevice.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/trust/device", state.getPath()))
- }
- if !state.AutoQosVoipTrust.IsNull() && data.AutoQosVoipTrust.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-switch:auto/qos/voip/trust", state.getPath()))
- }
- if !state.AutoQosVoipCiscoSoftphone.IsNull() && data.AutoQosVoipCiscoSoftphone.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-switch:auto/qos/voip/cisco-softphone", state.getPath()))
- }
- if !state.AutoQosVoipCiscoPhone.IsNull() && data.AutoQosVoipCiscoPhone.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-switch:auto/qos/voip/cisco-phone", state.getPath()))
- }
- if !state.AutoQosVoip.IsNull() && data.AutoQosVoip.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-switch:auto/qos/voip", state.getPath()))
- }
- if !state.AutoQosVideoMediaPlayer.IsNull() && data.AutoQosVideoMediaPlayer.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-switch:auto/qos/video/media-player", state.getPath()))
- }
- if !state.AutoQosVideoIpCamera.IsNull() && data.AutoQosVideoIpCamera.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-switch:auto/qos/video/ip-camera", state.getPath()))
- }
- if !state.AutoQosVideoCts.IsNull() && data.AutoQosVideoCts.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-switch:auto/qos/video/cts", state.getPath()))
- }
- if !state.AutoQosTrustDscp.IsNull() && data.AutoQosTrustDscp.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-switch:auto/qos/trust/dscp", state.getPath()))
- }
- if !state.AutoQosTrustCos.IsNull() && data.AutoQosTrustCos.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-switch:auto/qos/trust/cos", state.getPath()))
- }
- if !state.AutoQosTrust.IsNull() && data.AutoQosTrust.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-switch:auto/qos/trust", state.getPath()))
- }
- if !state.AutoQosClassifyPolice.IsNull() && data.AutoQosClassifyPolice.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-switch:auto/qos/classify/police", state.getPath()))
- }
- if !state.AutoQosClassify.IsNull() && data.AutoQosClassify.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-switch:auto/qos/classify", state.getPath()))
- }
- if !state.IpAccessGroupOut.IsNull() && data.IpAccessGroupOut.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/access-group/out/acl", state.getPath()))
- }
- if !state.IpAccessGroupOutEnable.IsNull() && data.IpAccessGroupOutEnable.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/access-group/out/acl/out", state.getPath()))
- }
- if !state.IpAccessGroupIn.IsNull() && data.IpAccessGroupIn.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/access-group/in/acl", state.getPath()))
- }
- if !state.IpAccessGroupInEnable.IsNull() && data.IpAccessGroupInEnable.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/access-group/in/acl/in", state.getPath()))
- }
- if !state.Ipv4AddressMask.IsNull() && data.Ipv4AddressMask.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/address/primary", state.getPath()))
- }
- if !state.Ipv4Address.IsNull() && data.Ipv4Address.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/address/primary", state.getPath()))
- }
- if !state.VrfForwarding.IsNull() && data.VrfForwarding.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/vrf/forwarding", state.getPath()))
- }
- if !state.IpUnreachables.IsNull() && data.IpUnreachables.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/Cisco-IOS-XE-icmp:unreachables", state.getPath()))
- }
- if !state.IpRedirects.IsNull() && data.IpRedirects.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/redirects", state.getPath()))
- }
- if !state.IpProxyArp.IsNull() && data.IpProxyArp.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/proxy-arp", state.getPath()))
- }
- if !state.Shutdown.IsNull() && data.Shutdown.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/shutdown", state.getPath()))
+ if !state.ArpTimeout.IsNull() && data.ArpTimeout.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/arp/timeout")
}
- if !state.Description.IsNull() && data.Description.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/description", state.getPath()))
+ if !state.IpArpInspectionTrust.IsNull() && data.IpArpInspectionTrust.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ip/arp/inspection/trust")
}
- if !state.EncapsulationDot1qVlanId.IsNull() && data.EncapsulationDot1qVlanId.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/encapsulation/dot1Q/vlan-id", state.getPath()))
+ if !state.IpArpInspectionLimitRate.IsNull() && data.IpArpInspectionLimitRate.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ip/arp/inspection/limit/rate")
}
- return deletedItems
+ return b.Res()
}
-// End of section. //template:end getDeletedItems
+// End of section. //template:end addDeletedItemsXML
// Section below is generated&owned by "gen/generator.go". //template:begin getEmptyLeafsDelete
@@ -1752,3 +3161,166 @@ func (data *InterfacePortChannelSubinterface) getDeletePaths(ctx context.Context
}
// End of section. //template:end getDeletePaths
+
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletePathsXML
+
+func (data *InterfacePortChannelSubinterface) addDeletePathsXML(ctx context.Context, body string) string {
+ b := netconf.NewBody(body)
+ if !data.EncapsulationDot1qVlanId.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/encapsulation/dot1Q/vlan-id")
+ }
+ if !data.Description.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/description")
+ }
+ if !data.Shutdown.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/shutdown")
+ }
+ if !data.IpProxyArp.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ip/proxy-arp")
+ }
+ if !data.IpRedirects.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ip/redirects")
+ }
+ if !data.IpUnreachables.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ip/Cisco-IOS-XE-icmp:unreachables")
+ }
+ if !data.VrfForwarding.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/vrf/forwarding")
+ }
+ if !data.Ipv4Address.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ip/address/primary/address")
+ }
+ if !data.Ipv4AddressMask.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ip/address/primary/mask")
+ }
+ if !data.IpAccessGroupInEnable.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ip/access-group/in/acl/in")
+ }
+ if !data.IpAccessGroupIn.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ip/access-group/in/acl/acl-name")
+ }
+ if !data.IpAccessGroupOutEnable.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ip/access-group/out/acl/out")
+ }
+ if !data.IpAccessGroupOut.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ip/access-group/out/acl/acl-name")
+ }
+ if !data.AutoQosClassify.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/classify")
+ }
+ if !data.AutoQosClassifyPolice.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/classify/police")
+ }
+ if !data.AutoQosTrust.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/trust")
+ }
+ if !data.AutoQosTrustCos.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/trust/cos")
+ }
+ if !data.AutoQosTrustDscp.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/trust/dscp")
+ }
+ if !data.AutoQosVideoCts.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/video/cts")
+ }
+ if !data.AutoQosVideoIpCamera.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/video/ip-camera")
+ }
+ if !data.AutoQosVideoMediaPlayer.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/video/media-player")
+ }
+ if !data.AutoQosVoip.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/voip")
+ }
+ if !data.AutoQosVoipCiscoPhone.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/voip/cisco-phone")
+ }
+ if !data.AutoQosVoipCiscoSoftphone.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/voip/cisco-softphone")
+ }
+ if !data.AutoQosVoipTrust.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-switch:auto/qos/voip/trust")
+ }
+ if !data.TrustDevice.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/trust/device")
+ }
+ for i := range data.HelperAddresses {
+ keys := [...]string{"address"}
+ keyValues := [...]string{data.HelperAddresses[i].Address.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/ip/helper-address%v", predicates))
+ }
+ if !data.BfdTemplate.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/bfd/Cisco-IOS-XE-bfd:template")
+ }
+ if !data.BfdEnable.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/bfd/Cisco-IOS-XE-bfd:enable")
+ }
+ if !data.BfdLocalAddress.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/bfd/Cisco-IOS-XE-bfd:local-address")
+ }
+ if !data.BfdInterval.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/bfd/Cisco-IOS-XE-bfd:interval-interface/msecs")
+ }
+ if !data.BfdIntervalMinRx.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/bfd/Cisco-IOS-XE-bfd:interval-interface/min_rx")
+ }
+ if !data.BfdIntervalMultiplier.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/bfd/Cisco-IOS-XE-bfd:interval-interface/multiplier")
+ }
+ if !data.BfdEcho.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/bfd/Cisco-IOS-XE-bfd:echo")
+ }
+ if !data.Ipv6Enable.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ipv6/enable")
+ }
+ if !data.Ipv6Mtu.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ipv6/mtu")
+ }
+ if !data.Ipv6NdRaSuppressAll.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ipv6/nd/Cisco-IOS-XE-nd:ra/suppress/all")
+ }
+ if !data.Ipv6AddressAutoconfigDefault.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ipv6/address/autoconfig/default")
+ }
+ if !data.Ipv6AddressDhcp.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ipv6/address/dhcp")
+ }
+ for i := range data.Ipv6LinkLocalAddresses {
+ keys := [...]string{"address"}
+ keyValues := [...]string{data.Ipv6LinkLocalAddresses[i].Address.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/ipv6/address/link-local-address%v", predicates))
+ }
+ for i := range data.Ipv6Addresses {
+ keys := [...]string{"prefix"}
+ keyValues := [...]string{data.Ipv6Addresses[i].Prefix.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/ipv6/address/prefix-list%v", predicates))
+ }
+ if !data.ArpTimeout.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/arp/timeout")
+ }
+ if !data.IpArpInspectionTrust.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ip/arp/inspection/trust")
+ }
+ if !data.IpArpInspectionLimitRate.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ip/arp/inspection/limit/rate")
+ }
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletePathsXML
diff --git a/internal/provider/model_iosxe_interface_switchport.go b/internal/provider/model_iosxe_interface_switchport.go
index 310ddd8e..6871f2b5 100644
--- a/internal/provider/model_iosxe_interface_switchport.go
+++ b/internal/provider/model_iosxe_interface_switchport.go
@@ -29,6 +29,9 @@ import (
"github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/types"
+ "github.com/hashicorp/terraform-plugin-log/tflog"
+ "github.com/netascode/go-netconf"
+ "github.com/netascode/xmldot"
"github.com/tidwall/gjson"
"github.com/tidwall/sjson"
)
@@ -100,6 +103,19 @@ func (data InterfaceSwitchport) getPathShort() string {
return matches[1]
}
+// getXPath returns the XPath for NETCONF operations
+func (data InterfaceSwitchport) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/interface/%s[name=%v]/switchport-config/switchport"
+ path = fmt.Sprintf(path, fmt.Sprintf("%v", data.Type.ValueString()), fmt.Sprintf("%v", data.Name.ValueString()))
+ return path
+}
+
+func (data InterfaceSwitchportData) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/interface/%s[name=%v]/switchport-config/switchport"
+ path = fmt.Sprintf(path, fmt.Sprintf("%v", data.Type.ValueString()), fmt.Sprintf("%v", data.Name.ValueString()))
+ return path
+}
+
// End of section. //template:end getPath
// Section below is generated&owned by "gen/generator.go". //template:begin toBody
@@ -168,6 +184,94 @@ func (data InterfaceSwitchport) toBody(ctx context.Context) string {
// End of section. //template:end toBody
+// Section below is generated&owned by "gen/generator.go". //template:begin toBodyXML
+
+func (data InterfaceSwitchport) toBodyXML(ctx context.Context) string {
+ body := netconf.Body{}
+ if !data.ModeAccess.IsNull() && !data.ModeAccess.IsUnknown() {
+ if data.ModeAccess.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-switch:mode/access", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-switch:mode/access")
+ }
+ }
+ if !data.ModeDot1qTunnel.IsNull() && !data.ModeDot1qTunnel.IsUnknown() {
+ if data.ModeDot1qTunnel.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-switch:mode/dot1q-tunnel", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-switch:mode/dot1q-tunnel")
+ }
+ }
+ if !data.ModePrivateVlanTrunk.IsNull() && !data.ModePrivateVlanTrunk.IsUnknown() {
+ if data.ModePrivateVlanTrunk.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-switch:mode/private-vlan/trunk", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-switch:mode/private-vlan/trunk")
+ }
+ }
+ if !data.ModePrivateVlanHost.IsNull() && !data.ModePrivateVlanHost.IsUnknown() {
+ if data.ModePrivateVlanHost.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-switch:mode/private-vlan/host", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-switch:mode/private-vlan/host")
+ }
+ }
+ if !data.ModePrivateVlanPromiscuous.IsNull() && !data.ModePrivateVlanPromiscuous.IsUnknown() {
+ if data.ModePrivateVlanPromiscuous.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-switch:mode/private-vlan/promiscuous", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-switch:mode/private-vlan/promiscuous")
+ }
+ }
+ if !data.ModeTrunk.IsNull() && !data.ModeTrunk.IsUnknown() {
+ if data.ModeTrunk.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-switch:mode/trunk", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-switch:mode/trunk")
+ }
+ }
+ if !data.Nonegotiate.IsNull() && !data.Nonegotiate.IsUnknown() {
+ if data.Nonegotiate.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-switch:nonegotiate", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-switch:nonegotiate")
+ }
+ }
+ if !data.AccessVlan.IsNull() && !data.AccessVlan.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-switch:access/vlan/vlan", data.AccessVlan.ValueString())
+ }
+ if !data.TrunkAllowedVlans.IsNull() && !data.TrunkAllowedVlans.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-switch:trunk/allowed/vlan/vlans", data.TrunkAllowedVlans.ValueString())
+ }
+ if !data.TrunkAllowedVlansNone.IsNull() && !data.TrunkAllowedVlansNone.IsUnknown() {
+ if data.TrunkAllowedVlansNone.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-switch:trunk/allowed/vlan/none", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-switch:trunk/allowed/vlan/none")
+ }
+ }
+ if !data.TrunkNativeVlanTag.IsNull() && !data.TrunkNativeVlanTag.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-switch:trunk/native/vlan/tag", data.TrunkNativeVlanTag.ValueBool())
+ }
+ if !data.TrunkNativeVlan.IsNull() && !data.TrunkNativeVlan.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-switch:trunk/native/vlan/vlan-id", strconv.FormatInt(data.TrunkNativeVlan.ValueInt64(), 10))
+ }
+ if !data.Host.IsNull() && !data.Host.IsUnknown() {
+ if data.Host.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/host", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/host")
+ }
+ }
+ bodyString, err := body.String()
+ if err != nil {
+ tflog.Error(ctx, fmt.Sprintf("Error converting body to string: %s", err))
+ }
+ return bodyString
+}
+
+// End of section. //template:end toBodyXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBody
func (data *InterfaceSwitchport) updateFromBody(ctx context.Context, res gjson.Result) {
@@ -282,6 +386,116 @@ func (data *InterfaceSwitchport) updateFromBody(ctx context.Context, res gjson.R
// End of section. //template:end updateFromBody
+// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBodyXML
+
+func (data *InterfaceSwitchport) updateFromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-switch:mode/access"); !data.ModeAccess.IsNull() {
+ if value.Exists() {
+ data.ModeAccess = types.BoolValue(true)
+ } else {
+ data.ModeAccess = types.BoolValue(false)
+ }
+ } else {
+ data.ModeAccess = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-switch:mode/dot1q-tunnel"); !data.ModeDot1qTunnel.IsNull() {
+ if value.Exists() {
+ data.ModeDot1qTunnel = types.BoolValue(true)
+ } else {
+ data.ModeDot1qTunnel = types.BoolValue(false)
+ }
+ } else {
+ data.ModeDot1qTunnel = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-switch:mode/private-vlan/trunk"); !data.ModePrivateVlanTrunk.IsNull() {
+ if value.Exists() {
+ data.ModePrivateVlanTrunk = types.BoolValue(true)
+ } else {
+ data.ModePrivateVlanTrunk = types.BoolValue(false)
+ }
+ } else {
+ data.ModePrivateVlanTrunk = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-switch:mode/private-vlan/host"); !data.ModePrivateVlanHost.IsNull() {
+ if value.Exists() {
+ data.ModePrivateVlanHost = types.BoolValue(true)
+ } else {
+ data.ModePrivateVlanHost = types.BoolValue(false)
+ }
+ } else {
+ data.ModePrivateVlanHost = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-switch:mode/private-vlan/promiscuous"); !data.ModePrivateVlanPromiscuous.IsNull() {
+ if value.Exists() {
+ data.ModePrivateVlanPromiscuous = types.BoolValue(true)
+ } else {
+ data.ModePrivateVlanPromiscuous = types.BoolValue(false)
+ }
+ } else {
+ data.ModePrivateVlanPromiscuous = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-switch:mode/trunk"); !data.ModeTrunk.IsNull() {
+ if value.Exists() {
+ data.ModeTrunk = types.BoolValue(true)
+ } else {
+ data.ModeTrunk = types.BoolValue(false)
+ }
+ } else {
+ data.ModeTrunk = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-switch:nonegotiate"); !data.Nonegotiate.IsNull() {
+ if value.Exists() {
+ data.Nonegotiate = types.BoolValue(true)
+ } else {
+ data.Nonegotiate = types.BoolValue(false)
+ }
+ } else {
+ data.Nonegotiate = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-switch:access/vlan/vlan"); value.Exists() && !data.AccessVlan.IsNull() {
+ data.AccessVlan = types.StringValue(value.String())
+ } else {
+ data.AccessVlan = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-switch:trunk/allowed/vlan/vlans"); value.Exists() && !data.TrunkAllowedVlans.IsNull() {
+ data.TrunkAllowedVlans = types.StringValue(value.String())
+ } else {
+ data.TrunkAllowedVlans = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-switch:trunk/allowed/vlan/none"); !data.TrunkAllowedVlansNone.IsNull() {
+ if value.Exists() {
+ data.TrunkAllowedVlansNone = types.BoolValue(true)
+ } else {
+ data.TrunkAllowedVlansNone = types.BoolValue(false)
+ }
+ } else {
+ data.TrunkAllowedVlansNone = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-switch:trunk/native/vlan/tag"); !data.TrunkNativeVlanTag.IsNull() {
+ if value.Exists() {
+ data.TrunkNativeVlanTag = types.BoolValue(value.Bool())
+ }
+ } else {
+ data.TrunkNativeVlanTag = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-switch:trunk/native/vlan/vlan-id"); value.Exists() && !data.TrunkNativeVlan.IsNull() {
+ data.TrunkNativeVlan = types.Int64Value(value.Int())
+ } else {
+ data.TrunkNativeVlan = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/host"); !data.Host.IsNull() {
+ if value.Exists() {
+ data.Host = types.BoolValue(true)
+ } else {
+ data.Host = types.BoolValue(false)
+ }
+ } else {
+ data.Host = types.BoolNull()
+ }
+}
+
+// End of section. //template:end updateFromBodyXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin fromBody
func (data *InterfaceSwitchport) fromBody(ctx context.Context, res gjson.Result) {
@@ -422,6 +636,138 @@ func (data *InterfaceSwitchportData) fromBody(ctx context.Context, res gjson.Res
// End of section. //template:end fromBodyData
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyXML
+
+func (data *InterfaceSwitchport) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-switch:mode/access"); value.Exists() {
+ data.ModeAccess = types.BoolValue(true)
+ } else {
+ data.ModeAccess = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-switch:mode/dot1q-tunnel"); value.Exists() {
+ data.ModeDot1qTunnel = types.BoolValue(true)
+ } else {
+ data.ModeDot1qTunnel = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-switch:mode/private-vlan/trunk"); value.Exists() {
+ data.ModePrivateVlanTrunk = types.BoolValue(true)
+ } else {
+ data.ModePrivateVlanTrunk = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-switch:mode/private-vlan/host"); value.Exists() {
+ data.ModePrivateVlanHost = types.BoolValue(true)
+ } else {
+ data.ModePrivateVlanHost = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-switch:mode/private-vlan/promiscuous"); value.Exists() {
+ data.ModePrivateVlanPromiscuous = types.BoolValue(true)
+ } else {
+ data.ModePrivateVlanPromiscuous = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-switch:mode/trunk"); value.Exists() {
+ data.ModeTrunk = types.BoolValue(true)
+ } else {
+ data.ModeTrunk = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-switch:nonegotiate"); value.Exists() {
+ data.Nonegotiate = types.BoolValue(true)
+ } else {
+ data.Nonegotiate = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-switch:access/vlan/vlan"); value.Exists() {
+ data.AccessVlan = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-switch:trunk/allowed/vlan/vlans"); value.Exists() {
+ data.TrunkAllowedVlans = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-switch:trunk/allowed/vlan/none"); value.Exists() {
+ data.TrunkAllowedVlansNone = types.BoolValue(true)
+ } else {
+ data.TrunkAllowedVlansNone = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-switch:trunk/native/vlan/tag"); value.Exists() {
+ data.TrunkNativeVlanTag = types.BoolValue(value.Bool())
+ } else {
+ data.TrunkNativeVlanTag = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-switch:trunk/native/vlan/vlan-id"); value.Exists() {
+ data.TrunkNativeVlan = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/host"); value.Exists() {
+ data.Host = types.BoolValue(true)
+ } else {
+ data.Host = types.BoolValue(false)
+ }
+}
+
+// End of section. //template:end fromBodyXML
+
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyDataXML
+
+func (data *InterfaceSwitchportData) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-switch:mode/access"); value.Exists() {
+ data.ModeAccess = types.BoolValue(true)
+ } else {
+ data.ModeAccess = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-switch:mode/dot1q-tunnel"); value.Exists() {
+ data.ModeDot1qTunnel = types.BoolValue(true)
+ } else {
+ data.ModeDot1qTunnel = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-switch:mode/private-vlan/trunk"); value.Exists() {
+ data.ModePrivateVlanTrunk = types.BoolValue(true)
+ } else {
+ data.ModePrivateVlanTrunk = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-switch:mode/private-vlan/host"); value.Exists() {
+ data.ModePrivateVlanHost = types.BoolValue(true)
+ } else {
+ data.ModePrivateVlanHost = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-switch:mode/private-vlan/promiscuous"); value.Exists() {
+ data.ModePrivateVlanPromiscuous = types.BoolValue(true)
+ } else {
+ data.ModePrivateVlanPromiscuous = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-switch:mode/trunk"); value.Exists() {
+ data.ModeTrunk = types.BoolValue(true)
+ } else {
+ data.ModeTrunk = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-switch:nonegotiate"); value.Exists() {
+ data.Nonegotiate = types.BoolValue(true)
+ } else {
+ data.Nonegotiate = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-switch:access/vlan/vlan"); value.Exists() {
+ data.AccessVlan = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-switch:trunk/allowed/vlan/vlans"); value.Exists() {
+ data.TrunkAllowedVlans = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-switch:trunk/allowed/vlan/none"); value.Exists() {
+ data.TrunkAllowedVlansNone = types.BoolValue(true)
+ } else {
+ data.TrunkAllowedVlansNone = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-switch:trunk/native/vlan/tag"); value.Exists() {
+ data.TrunkNativeVlanTag = types.BoolValue(value.Bool())
+ } else {
+ data.TrunkNativeVlanTag = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-switch:trunk/native/vlan/vlan-id"); value.Exists() {
+ data.TrunkNativeVlan = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/host"); value.Exists() {
+ data.Host = types.BoolValue(true)
+ } else {
+ data.Host = types.BoolValue(false)
+ }
+}
+
+// End of section. //template:end fromBodyDataXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin getDeletedItems
func (data *InterfaceSwitchport) getDeletedItems(ctx context.Context, state InterfaceSwitchport) []string {
@@ -471,6 +817,55 @@ func (data *InterfaceSwitchport) getDeletedItems(ctx context.Context, state Inte
// End of section. //template:end getDeletedItems
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletedItemsXML
+
+func (data *InterfaceSwitchport) addDeletedItemsXML(ctx context.Context, state InterfaceSwitchport, body string) string {
+ b := netconf.NewBody(body)
+ if !state.ModeAccess.IsNull() && data.ModeAccess.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-switch:mode/access")
+ }
+ if !state.ModeDot1qTunnel.IsNull() && data.ModeDot1qTunnel.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-switch:mode/dot1q-tunnel")
+ }
+ if !state.ModePrivateVlanTrunk.IsNull() && data.ModePrivateVlanTrunk.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-switch:mode/private-vlan/trunk")
+ }
+ if !state.ModePrivateVlanHost.IsNull() && data.ModePrivateVlanHost.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-switch:mode/private-vlan/host")
+ }
+ if !state.ModePrivateVlanPromiscuous.IsNull() && data.ModePrivateVlanPromiscuous.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-switch:mode/private-vlan/promiscuous")
+ }
+ if !state.ModeTrunk.IsNull() && data.ModeTrunk.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-switch:mode/trunk")
+ }
+ if !state.Nonegotiate.IsNull() && data.Nonegotiate.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-switch:nonegotiate")
+ }
+ if !state.AccessVlan.IsNull() && data.AccessVlan.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-switch:access/vlan/vlan")
+ }
+ if !state.TrunkAllowedVlans.IsNull() && data.TrunkAllowedVlans.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-switch:trunk/allowed/vlan/vlans")
+ }
+ if !state.TrunkAllowedVlansNone.IsNull() && data.TrunkAllowedVlansNone.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-switch:trunk/allowed/vlan/none")
+ }
+ if !state.TrunkNativeVlanTag.IsNull() && data.TrunkNativeVlanTag.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-switch:trunk/native/vlan/tag")
+ }
+ if !state.TrunkNativeVlan.IsNull() && data.TrunkNativeVlan.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-switch:trunk/native/vlan/vlan-id")
+ }
+ if !state.Host.IsNull() && data.Host.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/host")
+ }
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletedItemsXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin getEmptyLeafsDelete
func (data *InterfaceSwitchport) getEmptyLeafsDelete(ctx context.Context) []string {
@@ -556,3 +951,52 @@ func (data *InterfaceSwitchport) getDeletePaths(ctx context.Context) []string {
}
// End of section. //template:end getDeletePaths
+
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletePathsXML
+
+func (data *InterfaceSwitchport) addDeletePathsXML(ctx context.Context, body string) string {
+ b := netconf.NewBody(body)
+ if !data.ModeAccess.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-switch:mode/access")
+ }
+ if !data.ModeDot1qTunnel.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-switch:mode/dot1q-tunnel")
+ }
+ if !data.ModePrivateVlanTrunk.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-switch:mode/private-vlan/trunk")
+ }
+ if !data.ModePrivateVlanHost.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-switch:mode/private-vlan/host")
+ }
+ if !data.ModePrivateVlanPromiscuous.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-switch:mode/private-vlan/promiscuous")
+ }
+ if !data.ModeTrunk.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-switch:mode/trunk")
+ }
+ if !data.Nonegotiate.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-switch:nonegotiate")
+ }
+ if !data.AccessVlan.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-switch:access/vlan/vlan")
+ }
+ if !data.TrunkAllowedVlans.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-switch:trunk/allowed/vlan/vlans")
+ }
+ if !data.TrunkAllowedVlansNone.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-switch:trunk/allowed/vlan/none")
+ }
+ if !data.TrunkNativeVlanTag.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-switch:trunk/native/vlan/tag")
+ }
+ if !data.TrunkNativeVlan.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-switch:trunk/native/vlan/vlan-id")
+ }
+ if !data.Host.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/host")
+ }
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletePathsXML
diff --git a/internal/provider/model_iosxe_interface_tunnel.go b/internal/provider/model_iosxe_interface_tunnel.go
index 04bc85bb..4a391cc4 100644
--- a/internal/provider/model_iosxe_interface_tunnel.go
+++ b/internal/provider/model_iosxe_interface_tunnel.go
@@ -31,6 +31,9 @@ import (
"github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/types"
+ "github.com/hashicorp/terraform-plugin-log/tflog"
+ "github.com/netascode/go-netconf"
+ "github.com/netascode/xmldot"
"github.com/tidwall/gjson"
"github.com/tidwall/sjson"
)
@@ -167,6 +170,19 @@ func (data InterfaceTunnel) getPathShort() string {
return matches[1]
}
+// getXPath returns the XPath for NETCONF operations
+func (data InterfaceTunnel) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/interface/Tunnel[name=%s]"
+ path = fmt.Sprintf(path, fmt.Sprintf("%v", data.Name.ValueInt64()))
+ return path
+}
+
+func (data InterfaceTunnelData) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/interface/Tunnel[name=%s]"
+ path = fmt.Sprintf(path, fmt.Sprintf("%v", data.Name.ValueInt64()))
+ return path
+}
+
// End of section. //template:end getPath
// Section below is generated&owned by "gen/generator.go". //template:begin toBody
@@ -350,6 +366,216 @@ func (data InterfaceTunnel) toBody(ctx context.Context) string {
// End of section. //template:end toBody
+// Section below is generated&owned by "gen/generator.go". //template:begin toBodyXML
+
+func (data InterfaceTunnel) toBodyXML(ctx context.Context) string {
+ body := netconf.Body{}
+ if !data.Name.IsNull() && !data.Name.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/name", strconv.FormatInt(data.Name.ValueInt64(), 10))
+ }
+ if !data.Description.IsNull() && !data.Description.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/description", data.Description.ValueString())
+ }
+ if !data.Shutdown.IsNull() && !data.Shutdown.IsUnknown() {
+ if data.Shutdown.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/shutdown", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/shutdown")
+ }
+ }
+ if !data.IpProxyArp.IsNull() && !data.IpProxyArp.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ip/proxy-arp", data.IpProxyArp.ValueBool())
+ }
+ if !data.IpRedirects.IsNull() && !data.IpRedirects.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ip/redirects", data.IpRedirects.ValueBool())
+ }
+ if !data.IpUnreachables.IsNull() && !data.IpUnreachables.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ip/Cisco-IOS-XE-icmp:unreachables", data.IpUnreachables.ValueBool())
+ }
+ if !data.VrfForwarding.IsNull() && !data.VrfForwarding.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/vrf/forwarding", data.VrfForwarding.ValueString())
+ }
+ if !data.Ipv6Enable.IsNull() && !data.Ipv6Enable.IsUnknown() {
+ if data.Ipv6Enable.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ipv6/enable", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/ipv6/enable")
+ }
+ }
+ if !data.Ipv6Mtu.IsNull() && !data.Ipv6Mtu.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ipv6/mtu", strconv.FormatInt(data.Ipv6Mtu.ValueInt64(), 10))
+ }
+ if !data.Ipv6NdRaSuppressAll.IsNull() && !data.Ipv6NdRaSuppressAll.IsUnknown() {
+ if data.Ipv6NdRaSuppressAll.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ipv6/nd/Cisco-IOS-XE-nd:ra/suppress/all", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/ipv6/nd/Cisco-IOS-XE-nd:ra/suppress/all")
+ }
+ }
+ if !data.Ipv6AddressAutoconfigDefault.IsNull() && !data.Ipv6AddressAutoconfigDefault.IsUnknown() {
+ if data.Ipv6AddressAutoconfigDefault.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ipv6/address/autoconfig/default", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/ipv6/address/autoconfig/default")
+ }
+ }
+ if !data.Ipv6AddressDhcp.IsNull() && !data.Ipv6AddressDhcp.IsUnknown() {
+ if data.Ipv6AddressDhcp.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ipv6/address/dhcp", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/ipv6/address/dhcp")
+ }
+ }
+ if len(data.Ipv6LinkLocalAddresses) > 0 {
+ for _, item := range data.Ipv6LinkLocalAddresses {
+ cBody := netconf.Body{}
+ if !item.Address.IsNull() && !item.Address.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "address", item.Address.ValueString())
+ }
+ if !item.LinkLocal.IsNull() && !item.LinkLocal.IsUnknown() {
+ if item.LinkLocal.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "link-local", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "link-local")
+ }
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/ipv6/address/link-local-address", cBody.Res())
+ }
+ }
+ if len(data.Ipv6Addresses) > 0 {
+ for _, item := range data.Ipv6Addresses {
+ cBody := netconf.Body{}
+ if !item.Prefix.IsNull() && !item.Prefix.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "prefix", item.Prefix.ValueString())
+ }
+ if !item.Eui64.IsNull() && !item.Eui64.IsUnknown() {
+ if item.Eui64.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "eui-64", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "eui-64")
+ }
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/ipv6/address/prefix-list", cBody.Res())
+ }
+ }
+ if !data.TunnelSource.IsNull() && !data.TunnelSource.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-tunnel:tunnel/source", data.TunnelSource.ValueString())
+ }
+ if !data.TunnelDestinationIpv4.IsNull() && !data.TunnelDestinationIpv4.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-tunnel:tunnel/destination-config/ipv4", data.TunnelDestinationIpv4.ValueString())
+ }
+ if !data.TunnelProtectionIpsecProfile.IsNull() && !data.TunnelProtectionIpsecProfile.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-tunnel:tunnel/protection/Cisco-IOS-XE-crypto:ipsec/profile", data.TunnelProtectionIpsecProfile.ValueString())
+ }
+ if !data.CryptoIpsecDfBit.IsNull() && !data.CryptoIpsecDfBit.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-crypto:crypto/ipsec/df-bit", data.CryptoIpsecDfBit.ValueString())
+ }
+ if !data.ArpTimeout.IsNull() && !data.ArpTimeout.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/arp/timeout", strconv.FormatInt(data.ArpTimeout.ValueInt64(), 10))
+ }
+ if !data.Ipv4Address.IsNull() && !data.Ipv4Address.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ip/address/primary/address", data.Ipv4Address.ValueString())
+ }
+ if !data.Ipv4AddressMask.IsNull() && !data.Ipv4AddressMask.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ip/address/primary/mask", data.Ipv4AddressMask.ValueString())
+ }
+ if !data.Unnumbered.IsNull() && !data.Unnumbered.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ip/unnumbered", data.Unnumbered.ValueString())
+ }
+ if !data.IpMtu.IsNull() && !data.IpMtu.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ip/mtu", strconv.FormatInt(data.IpMtu.ValueInt64(), 10))
+ }
+ if !data.IpDhcpRelaySourceInterface.IsNull() && !data.IpDhcpRelaySourceInterface.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ip/dhcp/Cisco-IOS-XE-dhcp:relay/source-interface", data.IpDhcpRelaySourceInterface.ValueString())
+ }
+ if !data.IpAccessGroupInEnable.IsNull() && !data.IpAccessGroupInEnable.IsUnknown() {
+ if data.IpAccessGroupInEnable.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ip/access-group/in/acl/in", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/ip/access-group/in/acl/in")
+ }
+ }
+ if !data.IpAccessGroupIn.IsNull() && !data.IpAccessGroupIn.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ip/access-group/in/acl/acl-name", data.IpAccessGroupIn.ValueString())
+ }
+ if !data.IpAccessGroupOutEnable.IsNull() && !data.IpAccessGroupOutEnable.IsUnknown() {
+ if data.IpAccessGroupOutEnable.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ip/access-group/out/acl/out", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/ip/access-group/out/acl/out")
+ }
+ }
+ if !data.IpAccessGroupOut.IsNull() && !data.IpAccessGroupOut.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ip/access-group/out/acl/acl-name", data.IpAccessGroupOut.ValueString())
+ }
+ if len(data.HelperAddresses) > 0 {
+ for _, item := range data.HelperAddresses {
+ cBody := netconf.Body{}
+ if !item.Address.IsNull() && !item.Address.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "address", item.Address.ValueString())
+ }
+ if !item.Global.IsNull() && !item.Global.IsUnknown() {
+ if item.Global.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "global", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "global")
+ }
+ }
+ if !item.Vrf.IsNull() && !item.Vrf.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "vrf", item.Vrf.ValueString())
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/ip/helper-address", cBody.Res())
+ }
+ }
+ if !data.TunnelModeIpsecIpv4.IsNull() && !data.TunnelModeIpsecIpv4.IsUnknown() {
+ if data.TunnelModeIpsecIpv4.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-tunnel:tunnel/mode/ipsec/ipv4", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-tunnel:tunnel/mode/ipsec/ipv4")
+ }
+ }
+ if !data.BfdTemplate.IsNull() && !data.BfdTemplate.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/bfd/Cisco-IOS-XE-bfd:template", data.BfdTemplate.ValueString())
+ }
+ if !data.BfdEnable.IsNull() && !data.BfdEnable.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/bfd/Cisco-IOS-XE-bfd:enable", data.BfdEnable.ValueBool())
+ }
+ if !data.BfdLocalAddress.IsNull() && !data.BfdLocalAddress.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/bfd/Cisco-IOS-XE-bfd:local-address", data.BfdLocalAddress.ValueString())
+ }
+ if !data.BfdInterval.IsNull() && !data.BfdInterval.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/bfd/Cisco-IOS-XE-bfd:interval-interface/msecs", strconv.FormatInt(data.BfdInterval.ValueInt64(), 10))
+ }
+ if !data.BfdIntervalMinRx.IsNull() && !data.BfdIntervalMinRx.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/bfd/Cisco-IOS-XE-bfd:interval-interface/min_rx", strconv.FormatInt(data.BfdIntervalMinRx.ValueInt64(), 10))
+ }
+ if !data.BfdIntervalMultiplier.IsNull() && !data.BfdIntervalMultiplier.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/bfd/Cisco-IOS-XE-bfd:interval-interface/multiplier", strconv.FormatInt(data.BfdIntervalMultiplier.ValueInt64(), 10))
+ }
+ if !data.BfdEcho.IsNull() && !data.BfdEcho.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/bfd/Cisco-IOS-XE-bfd:echo", data.BfdEcho.ValueBool())
+ }
+ if !data.LoadInterval.IsNull() && !data.LoadInterval.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/load-interval", strconv.FormatInt(data.LoadInterval.ValueInt64(), 10))
+ }
+ if !data.SnmpTrapLinkStatus.IsNull() && !data.SnmpTrapLinkStatus.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:snmp/trap/link-status", data.SnmpTrapLinkStatus.ValueBool())
+ }
+ if !data.LoggingEventLinkStatusEnable.IsNull() && !data.LoggingEventLinkStatusEnable.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/logging/event/link-status-enable", data.LoggingEventLinkStatusEnable.ValueBool())
+ }
+ if !data.TunnelVrf.IsNull() && !data.TunnelVrf.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-tunnel:tunnel/vrf-config/vrf-common/vrf", data.TunnelVrf.ValueString())
+ }
+ bodyString, err := body.String()
+ if err != nil {
+ tflog.Error(ctx, fmt.Sprintf("Error converting body to string: %s", err))
+ }
+ return bodyString
+}
+
+// End of section. //template:end toBodyXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBody
func (data *InterfaceTunnel) updateFromBody(ctx context.Context, res gjson.Result) {
@@ -716,212 +942,371 @@ func (data *InterfaceTunnel) updateFromBody(ctx context.Context, res gjson.Resul
// End of section. //template:end updateFromBody
-// Section below is generated&owned by "gen/generator.go". //template:begin fromBody
+// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBodyXML
-func (data *InterfaceTunnel) fromBody(ctx context.Context, res gjson.Result) {
- prefix := helpers.LastElement(data.getPath()) + "."
- if res.Get(helpers.LastElement(data.getPath())).IsArray() {
- prefix += "0."
+func (data *InterfaceTunnel) updateFromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/name"); value.Exists() && !data.Name.IsNull() {
+ data.Name = types.Int64Value(value.Int())
+ } else {
+ data.Name = types.Int64Null()
}
- if value := res.Get(prefix + "description"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/description"); value.Exists() && !data.Description.IsNull() {
data.Description = types.StringValue(value.String())
+ } else {
+ data.Description = types.StringNull()
}
- if value := res.Get(prefix + "shutdown"); value.Exists() {
- data.Shutdown = types.BoolValue(true)
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/shutdown"); !data.Shutdown.IsNull() {
+ if value.Exists() {
+ data.Shutdown = types.BoolValue(true)
+ } else {
+ data.Shutdown = types.BoolValue(false)
+ }
} else {
- data.Shutdown = types.BoolValue(false)
+ data.Shutdown = types.BoolNull()
}
- if value := res.Get(prefix + "ip.proxy-arp"); value.Exists() {
- data.IpProxyArp = types.BoolValue(value.Bool())
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/proxy-arp"); !data.IpProxyArp.IsNull() {
+ if value.Exists() {
+ data.IpProxyArp = types.BoolValue(value.Bool())
+ }
} else {
data.IpProxyArp = types.BoolNull()
}
- if value := res.Get(prefix + "ip.redirects"); value.Exists() {
- data.IpRedirects = types.BoolValue(value.Bool())
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/redirects"); !data.IpRedirects.IsNull() {
+ if value.Exists() {
+ data.IpRedirects = types.BoolValue(value.Bool())
+ }
} else {
data.IpRedirects = types.BoolNull()
}
- if value := res.Get(prefix + "ip.Cisco-IOS-XE-icmp:unreachables"); value.Exists() {
- data.IpUnreachables = types.BoolValue(value.Bool())
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/Cisco-IOS-XE-icmp:unreachables"); !data.IpUnreachables.IsNull() {
+ if value.Exists() {
+ data.IpUnreachables = types.BoolValue(value.Bool())
+ }
} else {
data.IpUnreachables = types.BoolNull()
}
- if value := res.Get(prefix + "vrf.forwarding"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/vrf/forwarding"); value.Exists() && !data.VrfForwarding.IsNull() {
data.VrfForwarding = types.StringValue(value.String())
+ } else {
+ data.VrfForwarding = types.StringNull()
}
- if value := res.Get(prefix + "ipv6.enable"); value.Exists() {
- data.Ipv6Enable = types.BoolValue(true)
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ipv6/enable"); !data.Ipv6Enable.IsNull() {
+ if value.Exists() {
+ data.Ipv6Enable = types.BoolValue(true)
+ } else {
+ data.Ipv6Enable = types.BoolValue(false)
+ }
} else {
- data.Ipv6Enable = types.BoolValue(false)
+ data.Ipv6Enable = types.BoolNull()
}
- if value := res.Get(prefix + "ipv6.mtu"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ipv6/mtu"); value.Exists() && !data.Ipv6Mtu.IsNull() {
data.Ipv6Mtu = types.Int64Value(value.Int())
+ } else {
+ data.Ipv6Mtu = types.Int64Null()
}
- if value := res.Get(prefix + "ipv6.nd.Cisco-IOS-XE-nd:ra.suppress.all"); value.Exists() {
- data.Ipv6NdRaSuppressAll = types.BoolValue(true)
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ipv6/nd/Cisco-IOS-XE-nd:ra/suppress/all"); !data.Ipv6NdRaSuppressAll.IsNull() {
+ if value.Exists() {
+ data.Ipv6NdRaSuppressAll = types.BoolValue(true)
+ } else {
+ data.Ipv6NdRaSuppressAll = types.BoolValue(false)
+ }
} else {
- data.Ipv6NdRaSuppressAll = types.BoolValue(false)
+ data.Ipv6NdRaSuppressAll = types.BoolNull()
}
- if value := res.Get(prefix + "ipv6.address.autoconfig.default"); value.Exists() {
- data.Ipv6AddressAutoconfigDefault = types.BoolValue(true)
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ipv6/address/autoconfig/default"); !data.Ipv6AddressAutoconfigDefault.IsNull() {
+ if value.Exists() {
+ data.Ipv6AddressAutoconfigDefault = types.BoolValue(true)
+ } else {
+ data.Ipv6AddressAutoconfigDefault = types.BoolValue(false)
+ }
} else {
- data.Ipv6AddressAutoconfigDefault = types.BoolValue(false)
+ data.Ipv6AddressAutoconfigDefault = types.BoolNull()
}
- if value := res.Get(prefix + "ipv6.address.dhcp"); value.Exists() {
- data.Ipv6AddressDhcp = types.BoolValue(true)
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ipv6/address/dhcp"); !data.Ipv6AddressDhcp.IsNull() {
+ if value.Exists() {
+ data.Ipv6AddressDhcp = types.BoolValue(true)
+ } else {
+ data.Ipv6AddressDhcp = types.BoolValue(false)
+ }
} else {
- data.Ipv6AddressDhcp = types.BoolValue(false)
+ data.Ipv6AddressDhcp = types.BoolNull()
}
- if value := res.Get(prefix + "ipv6.address.link-local-address"); value.Exists() {
- data.Ipv6LinkLocalAddresses = make([]InterfaceTunnelIpv6LinkLocalAddresses, 0)
- value.ForEach(func(k, v gjson.Result) bool {
- item := InterfaceTunnelIpv6LinkLocalAddresses{}
- if cValue := v.Get("address"); cValue.Exists() {
- item.Address = types.StringValue(cValue.String())
- }
- if cValue := v.Get("link-local"); cValue.Exists() {
- item.LinkLocal = types.BoolValue(true)
+ for i := range data.Ipv6LinkLocalAddresses {
+ keys := [...]string{"address"}
+ keyValues := [...]string{data.Ipv6LinkLocalAddresses[i].Address.ValueString()}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ipv6/address/link-local-address").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, "address"); value.Exists() && !data.Ipv6LinkLocalAddresses[i].Address.IsNull() {
+ data.Ipv6LinkLocalAddresses[i].Address = types.StringValue(value.String())
+ } else {
+ data.Ipv6LinkLocalAddresses[i].Address = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "link-local"); !data.Ipv6LinkLocalAddresses[i].LinkLocal.IsNull() {
+ if value.Exists() {
+ data.Ipv6LinkLocalAddresses[i].LinkLocal = types.BoolValue(true)
} else {
- item.LinkLocal = types.BoolValue(false)
+ data.Ipv6LinkLocalAddresses[i].LinkLocal = types.BoolValue(false)
}
- data.Ipv6LinkLocalAddresses = append(data.Ipv6LinkLocalAddresses, item)
- return true
- })
- }
- if value := res.Get(prefix + "ipv6.address.prefix-list"); value.Exists() {
- data.Ipv6Addresses = make([]InterfaceTunnelIpv6Addresses, 0)
- value.ForEach(func(k, v gjson.Result) bool {
- item := InterfaceTunnelIpv6Addresses{}
- if cValue := v.Get("prefix"); cValue.Exists() {
- item.Prefix = types.StringValue(cValue.String())
- }
- if cValue := v.Get("eui-64"); cValue.Exists() {
- item.Eui64 = types.BoolValue(true)
+ } else {
+ data.Ipv6LinkLocalAddresses[i].LinkLocal = types.BoolNull()
+ }
+ }
+ for i := range data.Ipv6Addresses {
+ keys := [...]string{"prefix"}
+ keyValues := [...]string{data.Ipv6Addresses[i].Prefix.ValueString()}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ipv6/address/prefix-list").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, "prefix"); value.Exists() && !data.Ipv6Addresses[i].Prefix.IsNull() {
+ data.Ipv6Addresses[i].Prefix = types.StringValue(value.String())
+ } else {
+ data.Ipv6Addresses[i].Prefix = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "eui-64"); !data.Ipv6Addresses[i].Eui64.IsNull() {
+ if value.Exists() {
+ data.Ipv6Addresses[i].Eui64 = types.BoolValue(true)
} else {
- item.Eui64 = types.BoolValue(false)
+ data.Ipv6Addresses[i].Eui64 = types.BoolValue(false)
}
- data.Ipv6Addresses = append(data.Ipv6Addresses, item)
- return true
- })
+ } else {
+ data.Ipv6Addresses[i].Eui64 = types.BoolNull()
+ }
}
- if value := res.Get(prefix + "Cisco-IOS-XE-tunnel:tunnel.source"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-tunnel:tunnel/source"); value.Exists() && !data.TunnelSource.IsNull() {
data.TunnelSource = types.StringValue(value.String())
+ } else {
+ data.TunnelSource = types.StringNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-tunnel:tunnel.destination-config.ipv4"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-tunnel:tunnel/destination-config/ipv4"); value.Exists() && !data.TunnelDestinationIpv4.IsNull() {
data.TunnelDestinationIpv4 = types.StringValue(value.String())
+ } else {
+ data.TunnelDestinationIpv4 = types.StringNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-tunnel:tunnel.protection.Cisco-IOS-XE-crypto:ipsec.profile"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-tunnel:tunnel/protection/Cisco-IOS-XE-crypto:ipsec/profile"); value.Exists() && !data.TunnelProtectionIpsecProfile.IsNull() {
data.TunnelProtectionIpsecProfile = types.StringValue(value.String())
+ } else {
+ data.TunnelProtectionIpsecProfile = types.StringNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-crypto:crypto.ipsec.df-bit"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-crypto:crypto/ipsec/df-bit"); value.Exists() && !data.CryptoIpsecDfBit.IsNull() {
data.CryptoIpsecDfBit = types.StringValue(value.String())
+ } else {
+ data.CryptoIpsecDfBit = types.StringNull()
}
- if value := res.Get(prefix + "arp.timeout"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/arp/timeout"); value.Exists() && !data.ArpTimeout.IsNull() {
data.ArpTimeout = types.Int64Value(value.Int())
+ } else {
+ data.ArpTimeout = types.Int64Null()
}
- if value := res.Get(prefix + "ip.address.primary.address"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/address/primary/address"); value.Exists() && !data.Ipv4Address.IsNull() {
data.Ipv4Address = types.StringValue(value.String())
+ } else {
+ data.Ipv4Address = types.StringNull()
}
- if value := res.Get(prefix + "ip.address.primary.mask"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/address/primary/mask"); value.Exists() && !data.Ipv4AddressMask.IsNull() {
data.Ipv4AddressMask = types.StringValue(value.String())
+ } else {
+ data.Ipv4AddressMask = types.StringNull()
}
- if value := res.Get(prefix + "ip.unnumbered"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/unnumbered"); value.Exists() && !data.Unnumbered.IsNull() {
data.Unnumbered = types.StringValue(value.String())
+ } else {
+ data.Unnumbered = types.StringNull()
}
- if value := res.Get(prefix + "ip.mtu"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/mtu"); value.Exists() && !data.IpMtu.IsNull() {
data.IpMtu = types.Int64Value(value.Int())
+ } else {
+ data.IpMtu = types.Int64Null()
}
- if value := res.Get(prefix + "ip.dhcp.Cisco-IOS-XE-dhcp:relay.source-interface"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/dhcp/Cisco-IOS-XE-dhcp:relay/source-interface"); value.Exists() && !data.IpDhcpRelaySourceInterface.IsNull() {
data.IpDhcpRelaySourceInterface = types.StringValue(value.String())
+ } else {
+ data.IpDhcpRelaySourceInterface = types.StringNull()
}
- if value := res.Get(prefix + "ip.access-group.in.acl.in"); value.Exists() {
- data.IpAccessGroupInEnable = types.BoolValue(true)
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/access-group/in/acl/in"); !data.IpAccessGroupInEnable.IsNull() {
+ if value.Exists() {
+ data.IpAccessGroupInEnable = types.BoolValue(true)
+ } else {
+ data.IpAccessGroupInEnable = types.BoolValue(false)
+ }
} else {
- data.IpAccessGroupInEnable = types.BoolValue(false)
+ data.IpAccessGroupInEnable = types.BoolNull()
}
- if value := res.Get(prefix + "ip.access-group.in.acl.acl-name"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/access-group/in/acl/acl-name"); value.Exists() && !data.IpAccessGroupIn.IsNull() {
data.IpAccessGroupIn = types.StringValue(value.String())
+ } else {
+ data.IpAccessGroupIn = types.StringNull()
}
- if value := res.Get(prefix + "ip.access-group.out.acl.out"); value.Exists() {
- data.IpAccessGroupOutEnable = types.BoolValue(true)
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/access-group/out/acl/out"); !data.IpAccessGroupOutEnable.IsNull() {
+ if value.Exists() {
+ data.IpAccessGroupOutEnable = types.BoolValue(true)
+ } else {
+ data.IpAccessGroupOutEnable = types.BoolValue(false)
+ }
} else {
- data.IpAccessGroupOutEnable = types.BoolValue(false)
+ data.IpAccessGroupOutEnable = types.BoolNull()
}
- if value := res.Get(prefix + "ip.access-group.out.acl.acl-name"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/access-group/out/acl/acl-name"); value.Exists() && !data.IpAccessGroupOut.IsNull() {
data.IpAccessGroupOut = types.StringValue(value.String())
+ } else {
+ data.IpAccessGroupOut = types.StringNull()
}
- if value := res.Get(prefix + "ip.helper-address"); value.Exists() {
- data.HelperAddresses = make([]InterfaceTunnelHelperAddresses, 0)
- value.ForEach(func(k, v gjson.Result) bool {
- item := InterfaceTunnelHelperAddresses{}
- if cValue := v.Get("address"); cValue.Exists() {
- item.Address = types.StringValue(cValue.String())
- }
- if cValue := v.Get("global"); cValue.Exists() {
- item.Global = types.BoolValue(true)
+ for i := range data.HelperAddresses {
+ keys := [...]string{"address"}
+ keyValues := [...]string{data.HelperAddresses[i].Address.ValueString()}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/helper-address").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, "address"); value.Exists() && !data.HelperAddresses[i].Address.IsNull() {
+ data.HelperAddresses[i].Address = types.StringValue(value.String())
+ } else {
+ data.HelperAddresses[i].Address = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "global"); !data.HelperAddresses[i].Global.IsNull() {
+ if value.Exists() {
+ data.HelperAddresses[i].Global = types.BoolValue(true)
} else {
- item.Global = types.BoolValue(false)
- }
- if cValue := v.Get("vrf"); cValue.Exists() {
- item.Vrf = types.StringValue(cValue.String())
+ data.HelperAddresses[i].Global = types.BoolValue(false)
}
- data.HelperAddresses = append(data.HelperAddresses, item)
- return true
- })
+ } else {
+ data.HelperAddresses[i].Global = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "vrf"); value.Exists() && !data.HelperAddresses[i].Vrf.IsNull() {
+ data.HelperAddresses[i].Vrf = types.StringValue(value.String())
+ } else {
+ data.HelperAddresses[i].Vrf = types.StringNull()
+ }
}
- if value := res.Get(prefix + "Cisco-IOS-XE-tunnel:tunnel.mode.ipsec.ipv4"); value.Exists() {
- data.TunnelModeIpsecIpv4 = types.BoolValue(true)
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-tunnel:tunnel/mode/ipsec/ipv4"); !data.TunnelModeIpsecIpv4.IsNull() {
+ if value.Exists() {
+ data.TunnelModeIpsecIpv4 = types.BoolValue(true)
+ } else {
+ data.TunnelModeIpsecIpv4 = types.BoolValue(false)
+ }
} else {
- data.TunnelModeIpsecIpv4 = types.BoolValue(false)
+ data.TunnelModeIpsecIpv4 = types.BoolNull()
}
- if value := res.Get(prefix + "bfd.Cisco-IOS-XE-bfd:template"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/bfd/Cisco-IOS-XE-bfd:template"); value.Exists() && !data.BfdTemplate.IsNull() {
data.BfdTemplate = types.StringValue(value.String())
+ } else {
+ data.BfdTemplate = types.StringNull()
}
- if value := res.Get(prefix + "bfd.Cisco-IOS-XE-bfd:enable"); value.Exists() {
- data.BfdEnable = types.BoolValue(value.Bool())
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/bfd/Cisco-IOS-XE-bfd:enable"); !data.BfdEnable.IsNull() {
+ if value.Exists() {
+ data.BfdEnable = types.BoolValue(value.Bool())
+ }
} else {
data.BfdEnable = types.BoolNull()
}
- if value := res.Get(prefix + "bfd.Cisco-IOS-XE-bfd:local-address"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/bfd/Cisco-IOS-XE-bfd:local-address"); value.Exists() && !data.BfdLocalAddress.IsNull() {
data.BfdLocalAddress = types.StringValue(value.String())
+ } else {
+ data.BfdLocalAddress = types.StringNull()
}
- if value := res.Get(prefix + "bfd.Cisco-IOS-XE-bfd:interval-interface.msecs"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/bfd/Cisco-IOS-XE-bfd:interval-interface/msecs"); value.Exists() && !data.BfdInterval.IsNull() {
data.BfdInterval = types.Int64Value(value.Int())
+ } else {
+ data.BfdInterval = types.Int64Null()
}
- if value := res.Get(prefix + "bfd.Cisco-IOS-XE-bfd:interval-interface.min_rx"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/bfd/Cisco-IOS-XE-bfd:interval-interface/min_rx"); value.Exists() && !data.BfdIntervalMinRx.IsNull() {
data.BfdIntervalMinRx = types.Int64Value(value.Int())
+ } else {
+ data.BfdIntervalMinRx = types.Int64Null()
}
- if value := res.Get(prefix + "bfd.Cisco-IOS-XE-bfd:interval-interface.multiplier"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/bfd/Cisco-IOS-XE-bfd:interval-interface/multiplier"); value.Exists() && !data.BfdIntervalMultiplier.IsNull() {
data.BfdIntervalMultiplier = types.Int64Value(value.Int())
+ } else {
+ data.BfdIntervalMultiplier = types.Int64Null()
}
- if value := res.Get(prefix + "bfd.Cisco-IOS-XE-bfd:echo"); value.Exists() {
- data.BfdEcho = types.BoolValue(value.Bool())
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/bfd/Cisco-IOS-XE-bfd:echo"); !data.BfdEcho.IsNull() {
+ if value.Exists() {
+ data.BfdEcho = types.BoolValue(value.Bool())
+ }
} else {
data.BfdEcho = types.BoolNull()
}
- if value := res.Get(prefix + "load-interval"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/load-interval"); value.Exists() && !data.LoadInterval.IsNull() {
data.LoadInterval = types.Int64Value(value.Int())
+ } else {
+ data.LoadInterval = types.Int64Null()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:snmp.trap.link-status"); value.Exists() {
- data.SnmpTrapLinkStatus = types.BoolValue(value.Bool())
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:snmp/trap/link-status"); !data.SnmpTrapLinkStatus.IsNull() {
+ if value.Exists() {
+ data.SnmpTrapLinkStatus = types.BoolValue(value.Bool())
+ }
} else {
data.SnmpTrapLinkStatus = types.BoolNull()
}
- if value := res.Get(prefix + "logging.event.link-status-enable"); value.Exists() {
- data.LoggingEventLinkStatusEnable = types.BoolValue(value.Bool())
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/logging/event/link-status-enable"); !data.LoggingEventLinkStatusEnable.IsNull() {
+ if value.Exists() {
+ data.LoggingEventLinkStatusEnable = types.BoolValue(value.Bool())
+ }
} else {
data.LoggingEventLinkStatusEnable = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-tunnel:tunnel.vrf-config.vrf-common.vrf"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-tunnel:tunnel/vrf-config/vrf-common/vrf"); value.Exists() && !data.TunnelVrf.IsNull() {
data.TunnelVrf = types.StringValue(value.String())
+ } else {
+ data.TunnelVrf = types.StringNull()
}
}
-// End of section. //template:end fromBody
+// End of section. //template:end updateFromBodyXML
-// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyData
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBody
-func (data *InterfaceTunnelData) fromBody(ctx context.Context, res gjson.Result) {
+func (data *InterfaceTunnel) fromBody(ctx context.Context, res gjson.Result) {
prefix := helpers.LastElement(data.getPath()) + "."
if res.Get(helpers.LastElement(data.getPath())).IsArray() {
prefix += "0."
@@ -1120,53 +1505,864 @@ func (data *InterfaceTunnelData) fromBody(ctx context.Context, res gjson.Result)
}
}
-// End of section. //template:end fromBodyData
+// End of section. //template:end fromBody
-// Section below is generated&owned by "gen/generator.go". //template:begin getDeletedItems
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyData
-func (data *InterfaceTunnel) getDeletedItems(ctx context.Context, state InterfaceTunnel) []string {
- deletedItems := make([]string, 0)
- if !state.TunnelVrf.IsNull() && data.TunnelVrf.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-tunnel:tunnel/vrf-config/vrf-common/vrf", state.getPath()))
+func (data *InterfaceTunnelData) fromBody(ctx context.Context, res gjson.Result) {
+ prefix := helpers.LastElement(data.getPath()) + "."
+ if res.Get(helpers.LastElement(data.getPath())).IsArray() {
+ prefix += "0."
}
- if !state.LoggingEventLinkStatusEnable.IsNull() && data.LoggingEventLinkStatusEnable.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/logging/event/link-status-enable", state.getPath()))
+ if value := res.Get(prefix + "description"); value.Exists() {
+ data.Description = types.StringValue(value.String())
}
- if !state.SnmpTrapLinkStatus.IsNull() && data.SnmpTrapLinkStatus.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:snmp/trap/link-status", state.getPath()))
+ if value := res.Get(prefix + "shutdown"); value.Exists() {
+ data.Shutdown = types.BoolValue(true)
+ } else {
+ data.Shutdown = types.BoolValue(false)
}
- if !state.LoadInterval.IsNull() && data.LoadInterval.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/load-interval", state.getPath()))
+ if value := res.Get(prefix + "ip.proxy-arp"); value.Exists() {
+ data.IpProxyArp = types.BoolValue(value.Bool())
+ } else {
+ data.IpProxyArp = types.BoolNull()
}
- if !state.BfdEcho.IsNull() && data.BfdEcho.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/bfd/Cisco-IOS-XE-bfd:echo", state.getPath()))
+ if value := res.Get(prefix + "ip.redirects"); value.Exists() {
+ data.IpRedirects = types.BoolValue(value.Bool())
+ } else {
+ data.IpRedirects = types.BoolNull()
}
- if !state.BfdIntervalMultiplier.IsNull() && data.BfdIntervalMultiplier.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/bfd/Cisco-IOS-XE-bfd:interval-interface", state.getPath()))
+ if value := res.Get(prefix + "ip.Cisco-IOS-XE-icmp:unreachables"); value.Exists() {
+ data.IpUnreachables = types.BoolValue(value.Bool())
+ } else {
+ data.IpUnreachables = types.BoolNull()
}
- if !state.BfdIntervalMinRx.IsNull() && data.BfdIntervalMinRx.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/bfd/Cisco-IOS-XE-bfd:interval-interface", state.getPath()))
+ if value := res.Get(prefix + "vrf.forwarding"); value.Exists() {
+ data.VrfForwarding = types.StringValue(value.String())
}
- if !state.BfdInterval.IsNull() && data.BfdInterval.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/bfd/Cisco-IOS-XE-bfd:interval-interface", state.getPath()))
+ if value := res.Get(prefix + "ipv6.enable"); value.Exists() {
+ data.Ipv6Enable = types.BoolValue(true)
+ } else {
+ data.Ipv6Enable = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "ipv6.mtu"); value.Exists() {
+ data.Ipv6Mtu = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "ipv6.nd.Cisco-IOS-XE-nd:ra.suppress.all"); value.Exists() {
+ data.Ipv6NdRaSuppressAll = types.BoolValue(true)
+ } else {
+ data.Ipv6NdRaSuppressAll = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "ipv6.address.autoconfig.default"); value.Exists() {
+ data.Ipv6AddressAutoconfigDefault = types.BoolValue(true)
+ } else {
+ data.Ipv6AddressAutoconfigDefault = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "ipv6.address.dhcp"); value.Exists() {
+ data.Ipv6AddressDhcp = types.BoolValue(true)
+ } else {
+ data.Ipv6AddressDhcp = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "ipv6.address.link-local-address"); value.Exists() {
+ data.Ipv6LinkLocalAddresses = make([]InterfaceTunnelIpv6LinkLocalAddresses, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := InterfaceTunnelIpv6LinkLocalAddresses{}
+ if cValue := v.Get("address"); cValue.Exists() {
+ item.Address = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("link-local"); cValue.Exists() {
+ item.LinkLocal = types.BoolValue(true)
+ } else {
+ item.LinkLocal = types.BoolValue(false)
+ }
+ data.Ipv6LinkLocalAddresses = append(data.Ipv6LinkLocalAddresses, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + "ipv6.address.prefix-list"); value.Exists() {
+ data.Ipv6Addresses = make([]InterfaceTunnelIpv6Addresses, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := InterfaceTunnelIpv6Addresses{}
+ if cValue := v.Get("prefix"); cValue.Exists() {
+ item.Prefix = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("eui-64"); cValue.Exists() {
+ item.Eui64 = types.BoolValue(true)
+ } else {
+ item.Eui64 = types.BoolValue(false)
+ }
+ data.Ipv6Addresses = append(data.Ipv6Addresses, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-tunnel:tunnel.source"); value.Exists() {
+ data.TunnelSource = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-tunnel:tunnel.destination-config.ipv4"); value.Exists() {
+ data.TunnelDestinationIpv4 = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-tunnel:tunnel.protection.Cisco-IOS-XE-crypto:ipsec.profile"); value.Exists() {
+ data.TunnelProtectionIpsecProfile = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-crypto:crypto.ipsec.df-bit"); value.Exists() {
+ data.CryptoIpsecDfBit = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "arp.timeout"); value.Exists() {
+ data.ArpTimeout = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "ip.address.primary.address"); value.Exists() {
+ data.Ipv4Address = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "ip.address.primary.mask"); value.Exists() {
+ data.Ipv4AddressMask = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "ip.unnumbered"); value.Exists() {
+ data.Unnumbered = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "ip.mtu"); value.Exists() {
+ data.IpMtu = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "ip.dhcp.Cisco-IOS-XE-dhcp:relay.source-interface"); value.Exists() {
+ data.IpDhcpRelaySourceInterface = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "ip.access-group.in.acl.in"); value.Exists() {
+ data.IpAccessGroupInEnable = types.BoolValue(true)
+ } else {
+ data.IpAccessGroupInEnable = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "ip.access-group.in.acl.acl-name"); value.Exists() {
+ data.IpAccessGroupIn = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "ip.access-group.out.acl.out"); value.Exists() {
+ data.IpAccessGroupOutEnable = types.BoolValue(true)
+ } else {
+ data.IpAccessGroupOutEnable = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "ip.access-group.out.acl.acl-name"); value.Exists() {
+ data.IpAccessGroupOut = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "ip.helper-address"); value.Exists() {
+ data.HelperAddresses = make([]InterfaceTunnelHelperAddresses, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := InterfaceTunnelHelperAddresses{}
+ if cValue := v.Get("address"); cValue.Exists() {
+ item.Address = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("global"); cValue.Exists() {
+ item.Global = types.BoolValue(true)
+ } else {
+ item.Global = types.BoolValue(false)
+ }
+ if cValue := v.Get("vrf"); cValue.Exists() {
+ item.Vrf = types.StringValue(cValue.String())
+ }
+ data.HelperAddresses = append(data.HelperAddresses, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-tunnel:tunnel.mode.ipsec.ipv4"); value.Exists() {
+ data.TunnelModeIpsecIpv4 = types.BoolValue(true)
+ } else {
+ data.TunnelModeIpsecIpv4 = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "bfd.Cisco-IOS-XE-bfd:template"); value.Exists() {
+ data.BfdTemplate = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "bfd.Cisco-IOS-XE-bfd:enable"); value.Exists() {
+ data.BfdEnable = types.BoolValue(value.Bool())
+ } else {
+ data.BfdEnable = types.BoolNull()
+ }
+ if value := res.Get(prefix + "bfd.Cisco-IOS-XE-bfd:local-address"); value.Exists() {
+ data.BfdLocalAddress = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "bfd.Cisco-IOS-XE-bfd:interval-interface.msecs"); value.Exists() {
+ data.BfdInterval = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "bfd.Cisco-IOS-XE-bfd:interval-interface.min_rx"); value.Exists() {
+ data.BfdIntervalMinRx = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "bfd.Cisco-IOS-XE-bfd:interval-interface.multiplier"); value.Exists() {
+ data.BfdIntervalMultiplier = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "bfd.Cisco-IOS-XE-bfd:echo"); value.Exists() {
+ data.BfdEcho = types.BoolValue(value.Bool())
+ } else {
+ data.BfdEcho = types.BoolNull()
+ }
+ if value := res.Get(prefix + "load-interval"); value.Exists() {
+ data.LoadInterval = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:snmp.trap.link-status"); value.Exists() {
+ data.SnmpTrapLinkStatus = types.BoolValue(value.Bool())
+ } else {
+ data.SnmpTrapLinkStatus = types.BoolNull()
+ }
+ if value := res.Get(prefix + "logging.event.link-status-enable"); value.Exists() {
+ data.LoggingEventLinkStatusEnable = types.BoolValue(value.Bool())
+ } else {
+ data.LoggingEventLinkStatusEnable = types.BoolNull()
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-tunnel:tunnel.vrf-config.vrf-common.vrf"); value.Exists() {
+ data.TunnelVrf = types.StringValue(value.String())
+ }
+}
+
+// End of section. //template:end fromBodyData
+
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyXML
+
+func (data *InterfaceTunnel) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/description"); value.Exists() {
+ data.Description = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/shutdown"); value.Exists() {
+ data.Shutdown = types.BoolValue(true)
+ } else {
+ data.Shutdown = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/proxy-arp"); value.Exists() {
+ data.IpProxyArp = types.BoolValue(value.Bool())
+ } else {
+ data.IpProxyArp = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/redirects"); value.Exists() {
+ data.IpRedirects = types.BoolValue(value.Bool())
+ } else {
+ data.IpRedirects = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/Cisco-IOS-XE-icmp:unreachables"); value.Exists() {
+ data.IpUnreachables = types.BoolValue(value.Bool())
+ } else {
+ data.IpUnreachables = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/vrf/forwarding"); value.Exists() {
+ data.VrfForwarding = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ipv6/enable"); value.Exists() {
+ data.Ipv6Enable = types.BoolValue(true)
+ } else {
+ data.Ipv6Enable = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ipv6/mtu"); value.Exists() {
+ data.Ipv6Mtu = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ipv6/nd/Cisco-IOS-XE-nd:ra/suppress/all"); value.Exists() {
+ data.Ipv6NdRaSuppressAll = types.BoolValue(true)
+ } else {
+ data.Ipv6NdRaSuppressAll = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ipv6/address/autoconfig/default"); value.Exists() {
+ data.Ipv6AddressAutoconfigDefault = types.BoolValue(true)
+ } else {
+ data.Ipv6AddressAutoconfigDefault = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ipv6/address/dhcp"); value.Exists() {
+ data.Ipv6AddressDhcp = types.BoolValue(true)
+ } else {
+ data.Ipv6AddressDhcp = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ipv6/address/link-local-address"); value.Exists() {
+ data.Ipv6LinkLocalAddresses = make([]InterfaceTunnelIpv6LinkLocalAddresses, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := InterfaceTunnelIpv6LinkLocalAddresses{}
+ if cValue := helpers.GetFromXPath(v, "address"); cValue.Exists() {
+ item.Address = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "link-local"); cValue.Exists() {
+ item.LinkLocal = types.BoolValue(true)
+ } else {
+ item.LinkLocal = types.BoolValue(false)
+ }
+ data.Ipv6LinkLocalAddresses = append(data.Ipv6LinkLocalAddresses, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ipv6/address/prefix-list"); value.Exists() {
+ data.Ipv6Addresses = make([]InterfaceTunnelIpv6Addresses, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := InterfaceTunnelIpv6Addresses{}
+ if cValue := helpers.GetFromXPath(v, "prefix"); cValue.Exists() {
+ item.Prefix = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "eui-64"); cValue.Exists() {
+ item.Eui64 = types.BoolValue(true)
+ } else {
+ item.Eui64 = types.BoolValue(false)
+ }
+ data.Ipv6Addresses = append(data.Ipv6Addresses, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-tunnel:tunnel/source"); value.Exists() {
+ data.TunnelSource = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-tunnel:tunnel/destination-config/ipv4"); value.Exists() {
+ data.TunnelDestinationIpv4 = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-tunnel:tunnel/protection/Cisco-IOS-XE-crypto:ipsec/profile"); value.Exists() {
+ data.TunnelProtectionIpsecProfile = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-crypto:crypto/ipsec/df-bit"); value.Exists() {
+ data.CryptoIpsecDfBit = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/arp/timeout"); value.Exists() {
+ data.ArpTimeout = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/address/primary/address"); value.Exists() {
+ data.Ipv4Address = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/address/primary/mask"); value.Exists() {
+ data.Ipv4AddressMask = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/unnumbered"); value.Exists() {
+ data.Unnumbered = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/mtu"); value.Exists() {
+ data.IpMtu = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/dhcp/Cisco-IOS-XE-dhcp:relay/source-interface"); value.Exists() {
+ data.IpDhcpRelaySourceInterface = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/access-group/in/acl/in"); value.Exists() {
+ data.IpAccessGroupInEnable = types.BoolValue(true)
+ } else {
+ data.IpAccessGroupInEnable = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/access-group/in/acl/acl-name"); value.Exists() {
+ data.IpAccessGroupIn = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/access-group/out/acl/out"); value.Exists() {
+ data.IpAccessGroupOutEnable = types.BoolValue(true)
+ } else {
+ data.IpAccessGroupOutEnable = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/access-group/out/acl/acl-name"); value.Exists() {
+ data.IpAccessGroupOut = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/helper-address"); value.Exists() {
+ data.HelperAddresses = make([]InterfaceTunnelHelperAddresses, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := InterfaceTunnelHelperAddresses{}
+ if cValue := helpers.GetFromXPath(v, "address"); cValue.Exists() {
+ item.Address = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "global"); cValue.Exists() {
+ item.Global = types.BoolValue(true)
+ } else {
+ item.Global = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "vrf"); cValue.Exists() {
+ item.Vrf = types.StringValue(cValue.String())
+ }
+ data.HelperAddresses = append(data.HelperAddresses, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-tunnel:tunnel/mode/ipsec/ipv4"); value.Exists() {
+ data.TunnelModeIpsecIpv4 = types.BoolValue(true)
+ } else {
+ data.TunnelModeIpsecIpv4 = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/bfd/Cisco-IOS-XE-bfd:template"); value.Exists() {
+ data.BfdTemplate = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/bfd/Cisco-IOS-XE-bfd:enable"); value.Exists() {
+ data.BfdEnable = types.BoolValue(value.Bool())
+ } else {
+ data.BfdEnable = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/bfd/Cisco-IOS-XE-bfd:local-address"); value.Exists() {
+ data.BfdLocalAddress = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/bfd/Cisco-IOS-XE-bfd:interval-interface/msecs"); value.Exists() {
+ data.BfdInterval = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/bfd/Cisco-IOS-XE-bfd:interval-interface/min_rx"); value.Exists() {
+ data.BfdIntervalMinRx = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/bfd/Cisco-IOS-XE-bfd:interval-interface/multiplier"); value.Exists() {
+ data.BfdIntervalMultiplier = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/bfd/Cisco-IOS-XE-bfd:echo"); value.Exists() {
+ data.BfdEcho = types.BoolValue(value.Bool())
+ } else {
+ data.BfdEcho = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/load-interval"); value.Exists() {
+ data.LoadInterval = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:snmp/trap/link-status"); value.Exists() {
+ data.SnmpTrapLinkStatus = types.BoolValue(value.Bool())
+ } else {
+ data.SnmpTrapLinkStatus = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/logging/event/link-status-enable"); value.Exists() {
+ data.LoggingEventLinkStatusEnable = types.BoolValue(value.Bool())
+ } else {
+ data.LoggingEventLinkStatusEnable = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-tunnel:tunnel/vrf-config/vrf-common/vrf"); value.Exists() {
+ data.TunnelVrf = types.StringValue(value.String())
+ }
+}
+
+// End of section. //template:end fromBodyXML
+
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyDataXML
+
+func (data *InterfaceTunnelData) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/description"); value.Exists() {
+ data.Description = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/shutdown"); value.Exists() {
+ data.Shutdown = types.BoolValue(true)
+ } else {
+ data.Shutdown = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/proxy-arp"); value.Exists() {
+ data.IpProxyArp = types.BoolValue(value.Bool())
+ } else {
+ data.IpProxyArp = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/redirects"); value.Exists() {
+ data.IpRedirects = types.BoolValue(value.Bool())
+ } else {
+ data.IpRedirects = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/Cisco-IOS-XE-icmp:unreachables"); value.Exists() {
+ data.IpUnreachables = types.BoolValue(value.Bool())
+ } else {
+ data.IpUnreachables = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/vrf/forwarding"); value.Exists() {
+ data.VrfForwarding = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ipv6/enable"); value.Exists() {
+ data.Ipv6Enable = types.BoolValue(true)
+ } else {
+ data.Ipv6Enable = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ipv6/mtu"); value.Exists() {
+ data.Ipv6Mtu = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ipv6/nd/Cisco-IOS-XE-nd:ra/suppress/all"); value.Exists() {
+ data.Ipv6NdRaSuppressAll = types.BoolValue(true)
+ } else {
+ data.Ipv6NdRaSuppressAll = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ipv6/address/autoconfig/default"); value.Exists() {
+ data.Ipv6AddressAutoconfigDefault = types.BoolValue(true)
+ } else {
+ data.Ipv6AddressAutoconfigDefault = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ipv6/address/dhcp"); value.Exists() {
+ data.Ipv6AddressDhcp = types.BoolValue(true)
+ } else {
+ data.Ipv6AddressDhcp = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ipv6/address/link-local-address"); value.Exists() {
+ data.Ipv6LinkLocalAddresses = make([]InterfaceTunnelIpv6LinkLocalAddresses, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := InterfaceTunnelIpv6LinkLocalAddresses{}
+ if cValue := helpers.GetFromXPath(v, "address"); cValue.Exists() {
+ item.Address = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "link-local"); cValue.Exists() {
+ item.LinkLocal = types.BoolValue(true)
+ } else {
+ item.LinkLocal = types.BoolValue(false)
+ }
+ data.Ipv6LinkLocalAddresses = append(data.Ipv6LinkLocalAddresses, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ipv6/address/prefix-list"); value.Exists() {
+ data.Ipv6Addresses = make([]InterfaceTunnelIpv6Addresses, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := InterfaceTunnelIpv6Addresses{}
+ if cValue := helpers.GetFromXPath(v, "prefix"); cValue.Exists() {
+ item.Prefix = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "eui-64"); cValue.Exists() {
+ item.Eui64 = types.BoolValue(true)
+ } else {
+ item.Eui64 = types.BoolValue(false)
+ }
+ data.Ipv6Addresses = append(data.Ipv6Addresses, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-tunnel:tunnel/source"); value.Exists() {
+ data.TunnelSource = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-tunnel:tunnel/destination-config/ipv4"); value.Exists() {
+ data.TunnelDestinationIpv4 = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-tunnel:tunnel/protection/Cisco-IOS-XE-crypto:ipsec/profile"); value.Exists() {
+ data.TunnelProtectionIpsecProfile = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-crypto:crypto/ipsec/df-bit"); value.Exists() {
+ data.CryptoIpsecDfBit = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/arp/timeout"); value.Exists() {
+ data.ArpTimeout = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/address/primary/address"); value.Exists() {
+ data.Ipv4Address = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/address/primary/mask"); value.Exists() {
+ data.Ipv4AddressMask = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/unnumbered"); value.Exists() {
+ data.Unnumbered = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/mtu"); value.Exists() {
+ data.IpMtu = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/dhcp/Cisco-IOS-XE-dhcp:relay/source-interface"); value.Exists() {
+ data.IpDhcpRelaySourceInterface = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/access-group/in/acl/in"); value.Exists() {
+ data.IpAccessGroupInEnable = types.BoolValue(true)
+ } else {
+ data.IpAccessGroupInEnable = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/access-group/in/acl/acl-name"); value.Exists() {
+ data.IpAccessGroupIn = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/access-group/out/acl/out"); value.Exists() {
+ data.IpAccessGroupOutEnable = types.BoolValue(true)
+ } else {
+ data.IpAccessGroupOutEnable = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/access-group/out/acl/acl-name"); value.Exists() {
+ data.IpAccessGroupOut = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/helper-address"); value.Exists() {
+ data.HelperAddresses = make([]InterfaceTunnelHelperAddresses, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := InterfaceTunnelHelperAddresses{}
+ if cValue := helpers.GetFromXPath(v, "address"); cValue.Exists() {
+ item.Address = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "global"); cValue.Exists() {
+ item.Global = types.BoolValue(true)
+ } else {
+ item.Global = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "vrf"); cValue.Exists() {
+ item.Vrf = types.StringValue(cValue.String())
+ }
+ data.HelperAddresses = append(data.HelperAddresses, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-tunnel:tunnel/mode/ipsec/ipv4"); value.Exists() {
+ data.TunnelModeIpsecIpv4 = types.BoolValue(true)
+ } else {
+ data.TunnelModeIpsecIpv4 = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/bfd/Cisco-IOS-XE-bfd:template"); value.Exists() {
+ data.BfdTemplate = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/bfd/Cisco-IOS-XE-bfd:enable"); value.Exists() {
+ data.BfdEnable = types.BoolValue(value.Bool())
+ } else {
+ data.BfdEnable = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/bfd/Cisco-IOS-XE-bfd:local-address"); value.Exists() {
+ data.BfdLocalAddress = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/bfd/Cisco-IOS-XE-bfd:interval-interface/msecs"); value.Exists() {
+ data.BfdInterval = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/bfd/Cisco-IOS-XE-bfd:interval-interface/min_rx"); value.Exists() {
+ data.BfdIntervalMinRx = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/bfd/Cisco-IOS-XE-bfd:interval-interface/multiplier"); value.Exists() {
+ data.BfdIntervalMultiplier = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/bfd/Cisco-IOS-XE-bfd:echo"); value.Exists() {
+ data.BfdEcho = types.BoolValue(value.Bool())
+ } else {
+ data.BfdEcho = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/load-interval"); value.Exists() {
+ data.LoadInterval = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:snmp/trap/link-status"); value.Exists() {
+ data.SnmpTrapLinkStatus = types.BoolValue(value.Bool())
+ } else {
+ data.SnmpTrapLinkStatus = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/logging/event/link-status-enable"); value.Exists() {
+ data.LoggingEventLinkStatusEnable = types.BoolValue(value.Bool())
+ } else {
+ data.LoggingEventLinkStatusEnable = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-tunnel:tunnel/vrf-config/vrf-common/vrf"); value.Exists() {
+ data.TunnelVrf = types.StringValue(value.String())
+ }
+}
+
+// End of section. //template:end fromBodyDataXML
+
+// Section below is generated&owned by "gen/generator.go". //template:begin getDeletedItems
+
+func (data *InterfaceTunnel) getDeletedItems(ctx context.Context, state InterfaceTunnel) []string {
+ deletedItems := make([]string, 0)
+ if !state.TunnelVrf.IsNull() && data.TunnelVrf.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-tunnel:tunnel/vrf-config/vrf-common/vrf", state.getPath()))
+ }
+ if !state.LoggingEventLinkStatusEnable.IsNull() && data.LoggingEventLinkStatusEnable.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/logging/event/link-status-enable", state.getPath()))
+ }
+ if !state.SnmpTrapLinkStatus.IsNull() && data.SnmpTrapLinkStatus.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:snmp/trap/link-status", state.getPath()))
+ }
+ if !state.LoadInterval.IsNull() && data.LoadInterval.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/load-interval", state.getPath()))
+ }
+ if !state.BfdEcho.IsNull() && data.BfdEcho.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/bfd/Cisco-IOS-XE-bfd:echo", state.getPath()))
+ }
+ if !state.BfdIntervalMultiplier.IsNull() && data.BfdIntervalMultiplier.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/bfd/Cisco-IOS-XE-bfd:interval-interface", state.getPath()))
+ }
+ if !state.BfdIntervalMinRx.IsNull() && data.BfdIntervalMinRx.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/bfd/Cisco-IOS-XE-bfd:interval-interface", state.getPath()))
+ }
+ if !state.BfdInterval.IsNull() && data.BfdInterval.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/bfd/Cisco-IOS-XE-bfd:interval-interface", state.getPath()))
+ }
+ if !state.BfdLocalAddress.IsNull() && data.BfdLocalAddress.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/bfd/Cisco-IOS-XE-bfd:local-address", state.getPath()))
+ }
+ if !state.BfdEnable.IsNull() && data.BfdEnable.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/bfd/Cisco-IOS-XE-bfd:enable", state.getPath()))
+ }
+ if !state.BfdTemplate.IsNull() && data.BfdTemplate.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/bfd/Cisco-IOS-XE-bfd:template", state.getPath()))
+ }
+ if !state.TunnelModeIpsecIpv4.IsNull() && data.TunnelModeIpsecIpv4.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-tunnel:tunnel/mode/ipsec/ipv4", state.getPath()))
+ }
+ for i := range state.HelperAddresses {
+ stateKeyValues := [...]string{state.HelperAddresses[i].Address.ValueString()}
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.HelperAddresses[i].Address.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.HelperAddresses {
+ found = true
+ if state.HelperAddresses[i].Address.ValueString() != data.HelperAddresses[j].Address.ValueString() {
+ found = false
+ }
+ if found {
+ if !state.HelperAddresses[i].Vrf.IsNull() && data.HelperAddresses[j].Vrf.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/helper-address=%v/vrf", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ if !state.HelperAddresses[i].Global.IsNull() && data.HelperAddresses[j].Global.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/helper-address=%v/global", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ break
+ }
+ }
+ if !found {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/helper-address=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ }
+ if !state.IpAccessGroupOut.IsNull() && data.IpAccessGroupOut.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/access-group/out/acl", state.getPath()))
+ }
+ if !state.IpAccessGroupOutEnable.IsNull() && data.IpAccessGroupOutEnable.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/access-group/out/acl/out", state.getPath()))
+ }
+ if !state.IpAccessGroupIn.IsNull() && data.IpAccessGroupIn.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/access-group/in/acl", state.getPath()))
+ }
+ if !state.IpAccessGroupInEnable.IsNull() && data.IpAccessGroupInEnable.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/access-group/in/acl/in", state.getPath()))
+ }
+ if !state.IpDhcpRelaySourceInterface.IsNull() && data.IpDhcpRelaySourceInterface.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/dhcp/Cisco-IOS-XE-dhcp:relay/source-interface", state.getPath()))
+ }
+ if !state.IpMtu.IsNull() && data.IpMtu.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/mtu", state.getPath()))
+ }
+ if !state.Unnumbered.IsNull() && data.Unnumbered.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/unnumbered", state.getPath()))
+ }
+ if !state.Ipv4AddressMask.IsNull() && data.Ipv4AddressMask.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/address/primary", state.getPath()))
+ }
+ if !state.Ipv4Address.IsNull() && data.Ipv4Address.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/address/primary", state.getPath()))
+ }
+ if !state.ArpTimeout.IsNull() && data.ArpTimeout.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/arp/timeout", state.getPath()))
+ }
+ if !state.CryptoIpsecDfBit.IsNull() && data.CryptoIpsecDfBit.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-crypto:crypto/ipsec/df-bit", state.getPath()))
+ }
+ if !state.TunnelProtectionIpsecProfile.IsNull() && data.TunnelProtectionIpsecProfile.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-tunnel:tunnel/protection/Cisco-IOS-XE-crypto:ipsec/profile", state.getPath()))
+ }
+ if !state.TunnelDestinationIpv4.IsNull() && data.TunnelDestinationIpv4.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-tunnel:tunnel/destination-config/ipv4", state.getPath()))
+ }
+ if !state.TunnelSource.IsNull() && data.TunnelSource.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-tunnel:tunnel/source", state.getPath()))
+ }
+ for i := range state.Ipv6Addresses {
+ stateKeyValues := [...]string{state.Ipv6Addresses[i].Prefix.ValueString()}
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.Ipv6Addresses[i].Prefix.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.Ipv6Addresses {
+ found = true
+ if state.Ipv6Addresses[i].Prefix.ValueString() != data.Ipv6Addresses[j].Prefix.ValueString() {
+ found = false
+ }
+ if found {
+ if !state.Ipv6Addresses[i].Eui64.IsNull() && data.Ipv6Addresses[j].Eui64.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ipv6/address/prefix-list=%v/eui-64", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ break
+ }
+ }
+ if !found {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ipv6/address/prefix-list=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ }
+ for i := range state.Ipv6LinkLocalAddresses {
+ stateKeyValues := [...]string{state.Ipv6LinkLocalAddresses[i].Address.ValueString()}
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.Ipv6LinkLocalAddresses[i].Address.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.Ipv6LinkLocalAddresses {
+ found = true
+ if state.Ipv6LinkLocalAddresses[i].Address.ValueString() != data.Ipv6LinkLocalAddresses[j].Address.ValueString() {
+ found = false
+ }
+ if found {
+ if !state.Ipv6LinkLocalAddresses[i].LinkLocal.IsNull() && data.Ipv6LinkLocalAddresses[j].LinkLocal.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ipv6/address/link-local-address=%v/link-local", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ break
+ }
+ }
+ if !found {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ipv6/address/link-local-address=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ }
+ if !state.Ipv6AddressDhcp.IsNull() && data.Ipv6AddressDhcp.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ipv6/address/dhcp", state.getPath()))
+ }
+ if !state.Ipv6AddressAutoconfigDefault.IsNull() && data.Ipv6AddressAutoconfigDefault.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ipv6/address/autoconfig/default", state.getPath()))
+ }
+ if !state.Ipv6NdRaSuppressAll.IsNull() && data.Ipv6NdRaSuppressAll.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ipv6/nd/Cisco-IOS-XE-nd:ra/suppress/all", state.getPath()))
+ }
+ if !state.Ipv6Mtu.IsNull() && data.Ipv6Mtu.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ipv6/mtu", state.getPath()))
+ }
+ if !state.Ipv6Enable.IsNull() && data.Ipv6Enable.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ipv6/enable", state.getPath()))
+ }
+ if !state.VrfForwarding.IsNull() && data.VrfForwarding.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/vrf/forwarding", state.getPath()))
+ }
+ if !state.IpUnreachables.IsNull() && data.IpUnreachables.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/Cisco-IOS-XE-icmp:unreachables", state.getPath()))
+ }
+ if !state.IpRedirects.IsNull() && data.IpRedirects.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/redirects", state.getPath()))
+ }
+ if !state.IpProxyArp.IsNull() && data.IpProxyArp.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/proxy-arp", state.getPath()))
+ }
+ if !state.Shutdown.IsNull() && data.Shutdown.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/shutdown", state.getPath()))
+ }
+ if !state.Description.IsNull() && data.Description.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/description", state.getPath()))
+ }
+
+ return deletedItems
+}
+
+// End of section. //template:end getDeletedItems
+
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletedItemsXML
+
+func (data *InterfaceTunnel) addDeletedItemsXML(ctx context.Context, state InterfaceTunnel, body string) string {
+ b := netconf.NewBody(body)
+ if !state.Description.IsNull() && data.Description.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/description")
+ }
+ if !state.Shutdown.IsNull() && data.Shutdown.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/shutdown")
+ }
+ if !state.IpProxyArp.IsNull() && data.IpProxyArp.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ip/proxy-arp")
+ }
+ if !state.IpRedirects.IsNull() && data.IpRedirects.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ip/redirects")
+ }
+ if !state.IpUnreachables.IsNull() && data.IpUnreachables.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ip/Cisco-IOS-XE-icmp:unreachables")
+ }
+ if !state.VrfForwarding.IsNull() && data.VrfForwarding.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/vrf/forwarding")
}
- if !state.BfdLocalAddress.IsNull() && data.BfdLocalAddress.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/bfd/Cisco-IOS-XE-bfd:local-address", state.getPath()))
+ if !state.Ipv6Enable.IsNull() && data.Ipv6Enable.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ipv6/enable")
}
- if !state.BfdEnable.IsNull() && data.BfdEnable.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/bfd/Cisco-IOS-XE-bfd:enable", state.getPath()))
+ if !state.Ipv6Mtu.IsNull() && data.Ipv6Mtu.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ipv6/mtu")
}
- if !state.BfdTemplate.IsNull() && data.BfdTemplate.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/bfd/Cisco-IOS-XE-bfd:template", state.getPath()))
+ if !state.Ipv6NdRaSuppressAll.IsNull() && data.Ipv6NdRaSuppressAll.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ipv6/nd/Cisco-IOS-XE-nd:ra/suppress/all")
}
- if !state.TunnelModeIpsecIpv4.IsNull() && data.TunnelModeIpsecIpv4.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-tunnel:tunnel/mode/ipsec/ipv4", state.getPath()))
+ if !state.Ipv6AddressAutoconfigDefault.IsNull() && data.Ipv6AddressAutoconfigDefault.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ipv6/address/autoconfig/default")
}
- for i := range state.HelperAddresses {
- stateKeyValues := [...]string{state.HelperAddresses[i].Address.ValueString()}
+ if !state.Ipv6AddressDhcp.IsNull() && data.Ipv6AddressDhcp.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ipv6/address/dhcp")
+ }
+ for i := range state.Ipv6LinkLocalAddresses {
+ stateKeys := [...]string{"address"}
+ stateKeyValues := [...]string{state.Ipv6LinkLocalAddresses[i].Address.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
emptyKeys := true
- if !reflect.ValueOf(state.HelperAddresses[i].Address.ValueString()).IsZero() {
+ if !reflect.ValueOf(state.Ipv6LinkLocalAddresses[i].Address.ValueString()).IsZero() {
emptyKeys = false
}
if emptyKeys {
@@ -1174,69 +2370,29 @@ func (data *InterfaceTunnel) getDeletedItems(ctx context.Context, state Interfac
}
found := false
- for j := range data.HelperAddresses {
+ for j := range data.Ipv6LinkLocalAddresses {
found = true
- if state.HelperAddresses[i].Address.ValueString() != data.HelperAddresses[j].Address.ValueString() {
+ if state.Ipv6LinkLocalAddresses[i].Address.ValueString() != data.Ipv6LinkLocalAddresses[j].Address.ValueString() {
found = false
}
if found {
- if !state.HelperAddresses[i].Vrf.IsNull() && data.HelperAddresses[j].Vrf.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/helper-address=%v/vrf", state.getPath(), strings.Join(stateKeyValues[:], ",")))
- }
- if !state.HelperAddresses[i].Global.IsNull() && data.HelperAddresses[j].Global.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/helper-address=%v/global", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ if !state.Ipv6LinkLocalAddresses[i].LinkLocal.IsNull() && data.Ipv6LinkLocalAddresses[j].LinkLocal.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/ipv6/address/link-local-address%v/link-local", predicates))
}
break
}
}
if !found {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/helper-address=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/ipv6/address/link-local-address%v", predicates))
}
}
- if !state.IpAccessGroupOut.IsNull() && data.IpAccessGroupOut.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/access-group/out/acl", state.getPath()))
- }
- if !state.IpAccessGroupOutEnable.IsNull() && data.IpAccessGroupOutEnable.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/access-group/out/acl/out", state.getPath()))
- }
- if !state.IpAccessGroupIn.IsNull() && data.IpAccessGroupIn.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/access-group/in/acl", state.getPath()))
- }
- if !state.IpAccessGroupInEnable.IsNull() && data.IpAccessGroupInEnable.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/access-group/in/acl/in", state.getPath()))
- }
- if !state.IpDhcpRelaySourceInterface.IsNull() && data.IpDhcpRelaySourceInterface.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/dhcp/Cisco-IOS-XE-dhcp:relay/source-interface", state.getPath()))
- }
- if !state.IpMtu.IsNull() && data.IpMtu.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/mtu", state.getPath()))
- }
- if !state.Unnumbered.IsNull() && data.Unnumbered.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/unnumbered", state.getPath()))
- }
- if !state.Ipv4AddressMask.IsNull() && data.Ipv4AddressMask.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/address/primary", state.getPath()))
- }
- if !state.Ipv4Address.IsNull() && data.Ipv4Address.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/address/primary", state.getPath()))
- }
- if !state.ArpTimeout.IsNull() && data.ArpTimeout.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/arp/timeout", state.getPath()))
- }
- if !state.CryptoIpsecDfBit.IsNull() && data.CryptoIpsecDfBit.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-crypto:crypto/ipsec/df-bit", state.getPath()))
- }
- if !state.TunnelProtectionIpsecProfile.IsNull() && data.TunnelProtectionIpsecProfile.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-tunnel:tunnel/protection/Cisco-IOS-XE-crypto:ipsec/profile", state.getPath()))
- }
- if !state.TunnelDestinationIpv4.IsNull() && data.TunnelDestinationIpv4.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-tunnel:tunnel/destination-config/ipv4", state.getPath()))
- }
- if !state.TunnelSource.IsNull() && data.TunnelSource.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-tunnel:tunnel/source", state.getPath()))
- }
for i := range state.Ipv6Addresses {
+ stateKeys := [...]string{"prefix"}
stateKeyValues := [...]string{state.Ipv6Addresses[i].Prefix.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
emptyKeys := true
if !reflect.ValueOf(state.Ipv6Addresses[i].Prefix.ValueString()).IsZero() {
@@ -1254,20 +2410,67 @@ func (data *InterfaceTunnel) getDeletedItems(ctx context.Context, state Interfac
}
if found {
if !state.Ipv6Addresses[i].Eui64.IsNull() && data.Ipv6Addresses[j].Eui64.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ipv6/address/prefix-list=%v/eui-64", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/ipv6/address/prefix-list%v/eui-64", predicates))
}
break
}
}
if !found {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ipv6/address/prefix-list=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/ipv6/address/prefix-list%v", predicates))
}
}
- for i := range state.Ipv6LinkLocalAddresses {
- stateKeyValues := [...]string{state.Ipv6LinkLocalAddresses[i].Address.ValueString()}
+ if !state.TunnelSource.IsNull() && data.TunnelSource.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-tunnel:tunnel/source")
+ }
+ if !state.TunnelDestinationIpv4.IsNull() && data.TunnelDestinationIpv4.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-tunnel:tunnel/destination-config/ipv4")
+ }
+ if !state.TunnelProtectionIpsecProfile.IsNull() && data.TunnelProtectionIpsecProfile.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-tunnel:tunnel/protection/Cisco-IOS-XE-crypto:ipsec/profile")
+ }
+ if !state.CryptoIpsecDfBit.IsNull() && data.CryptoIpsecDfBit.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-crypto:crypto/ipsec/df-bit")
+ }
+ if !state.ArpTimeout.IsNull() && data.ArpTimeout.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/arp/timeout")
+ }
+ if !state.Ipv4Address.IsNull() && data.Ipv4Address.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ip/address/primary/address")
+ }
+ if !state.Ipv4AddressMask.IsNull() && data.Ipv4AddressMask.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ip/address/primary/mask")
+ }
+ if !state.Unnumbered.IsNull() && data.Unnumbered.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ip/unnumbered")
+ }
+ if !state.IpMtu.IsNull() && data.IpMtu.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ip/mtu")
+ }
+ if !state.IpDhcpRelaySourceInterface.IsNull() && data.IpDhcpRelaySourceInterface.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ip/dhcp/Cisco-IOS-XE-dhcp:relay/source-interface")
+ }
+ if !state.IpAccessGroupInEnable.IsNull() && data.IpAccessGroupInEnable.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ip/access-group/in/acl/in")
+ }
+ if !state.IpAccessGroupIn.IsNull() && data.IpAccessGroupIn.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ip/access-group/in/acl/acl-name")
+ }
+ if !state.IpAccessGroupOutEnable.IsNull() && data.IpAccessGroupOutEnable.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ip/access-group/out/acl/out")
+ }
+ if !state.IpAccessGroupOut.IsNull() && data.IpAccessGroupOut.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ip/access-group/out/acl/acl-name")
+ }
+ for i := range state.HelperAddresses {
+ stateKeys := [...]string{"address"}
+ stateKeyValues := [...]string{state.HelperAddresses[i].Address.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
emptyKeys := true
- if !reflect.ValueOf(state.Ipv6LinkLocalAddresses[i].Address.ValueString()).IsZero() {
+ if !reflect.ValueOf(state.HelperAddresses[i].Address.ValueString()).IsZero() {
emptyKeys = false
}
if emptyKeys {
@@ -1275,60 +2478,66 @@ func (data *InterfaceTunnel) getDeletedItems(ctx context.Context, state Interfac
}
found := false
- for j := range data.Ipv6LinkLocalAddresses {
+ for j := range data.HelperAddresses {
found = true
- if state.Ipv6LinkLocalAddresses[i].Address.ValueString() != data.Ipv6LinkLocalAddresses[j].Address.ValueString() {
+ if state.HelperAddresses[i].Address.ValueString() != data.HelperAddresses[j].Address.ValueString() {
found = false
}
if found {
- if !state.Ipv6LinkLocalAddresses[i].LinkLocal.IsNull() && data.Ipv6LinkLocalAddresses[j].LinkLocal.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ipv6/address/link-local-address=%v/link-local", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ if !state.HelperAddresses[i].Global.IsNull() && data.HelperAddresses[j].Global.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/ip/helper-address%v/global", predicates))
+ }
+ if !state.HelperAddresses[i].Vrf.IsNull() && data.HelperAddresses[j].Vrf.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/ip/helper-address%v/vrf", predicates))
}
break
}
}
if !found {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ipv6/address/link-local-address=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/ip/helper-address%v", predicates))
}
}
- if !state.Ipv6AddressDhcp.IsNull() && data.Ipv6AddressDhcp.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ipv6/address/dhcp", state.getPath()))
+ if !state.TunnelModeIpsecIpv4.IsNull() && data.TunnelModeIpsecIpv4.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-tunnel:tunnel/mode/ipsec/ipv4")
}
- if !state.Ipv6AddressAutoconfigDefault.IsNull() && data.Ipv6AddressAutoconfigDefault.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ipv6/address/autoconfig/default", state.getPath()))
+ if !state.BfdTemplate.IsNull() && data.BfdTemplate.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/bfd/Cisco-IOS-XE-bfd:template")
}
- if !state.Ipv6NdRaSuppressAll.IsNull() && data.Ipv6NdRaSuppressAll.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ipv6/nd/Cisco-IOS-XE-nd:ra/suppress/all", state.getPath()))
+ if !state.BfdEnable.IsNull() && data.BfdEnable.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/bfd/Cisco-IOS-XE-bfd:enable")
}
- if !state.Ipv6Mtu.IsNull() && data.Ipv6Mtu.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ipv6/mtu", state.getPath()))
+ if !state.BfdLocalAddress.IsNull() && data.BfdLocalAddress.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/bfd/Cisco-IOS-XE-bfd:local-address")
}
- if !state.Ipv6Enable.IsNull() && data.Ipv6Enable.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ipv6/enable", state.getPath()))
+ if !state.BfdInterval.IsNull() && data.BfdInterval.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/bfd/Cisco-IOS-XE-bfd:interval-interface/msecs")
}
- if !state.VrfForwarding.IsNull() && data.VrfForwarding.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/vrf/forwarding", state.getPath()))
+ if !state.BfdIntervalMinRx.IsNull() && data.BfdIntervalMinRx.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/bfd/Cisco-IOS-XE-bfd:interval-interface/min_rx")
}
- if !state.IpUnreachables.IsNull() && data.IpUnreachables.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/Cisco-IOS-XE-icmp:unreachables", state.getPath()))
+ if !state.BfdIntervalMultiplier.IsNull() && data.BfdIntervalMultiplier.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/bfd/Cisco-IOS-XE-bfd:interval-interface/multiplier")
}
- if !state.IpRedirects.IsNull() && data.IpRedirects.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/redirects", state.getPath()))
+ if !state.BfdEcho.IsNull() && data.BfdEcho.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/bfd/Cisco-IOS-XE-bfd:echo")
}
- if !state.IpProxyArp.IsNull() && data.IpProxyArp.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/proxy-arp", state.getPath()))
+ if !state.LoadInterval.IsNull() && data.LoadInterval.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/load-interval")
}
- if !state.Shutdown.IsNull() && data.Shutdown.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/shutdown", state.getPath()))
+ if !state.SnmpTrapLinkStatus.IsNull() && data.SnmpTrapLinkStatus.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:snmp/trap/link-status")
}
- if !state.Description.IsNull() && data.Description.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/description", state.getPath()))
+ if !state.LoggingEventLinkStatusEnable.IsNull() && data.LoggingEventLinkStatusEnable.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/logging/event/link-status-enable")
+ }
+ if !state.TunnelVrf.IsNull() && data.TunnelVrf.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-tunnel:tunnel/vrf-config/vrf-common/vrf")
}
- return deletedItems
+ return b.Res()
}
-// End of section. //template:end getDeletedItems
+// End of section. //template:end addDeletedItemsXML
// Section below is generated&owned by "gen/generator.go". //template:begin getEmptyLeafsDelete
@@ -1520,3 +2729,154 @@ func (data *InterfaceTunnel) getDeletePaths(ctx context.Context) []string {
}
// End of section. //template:end getDeletePaths
+
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletePathsXML
+
+func (data *InterfaceTunnel) addDeletePathsXML(ctx context.Context, body string) string {
+ b := netconf.NewBody(body)
+ if !data.Description.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/description")
+ }
+ if !data.Shutdown.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/shutdown")
+ }
+ if !data.IpProxyArp.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ip/proxy-arp")
+ }
+ if !data.IpRedirects.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ip/redirects")
+ }
+ if !data.IpUnreachables.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ip/Cisco-IOS-XE-icmp:unreachables")
+ }
+ if !data.VrfForwarding.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/vrf/forwarding")
+ }
+ if !data.Ipv6Enable.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ipv6/enable")
+ }
+ if !data.Ipv6Mtu.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ipv6/mtu")
+ }
+ if !data.Ipv6NdRaSuppressAll.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ipv6/nd/Cisco-IOS-XE-nd:ra/suppress/all")
+ }
+ if !data.Ipv6AddressAutoconfigDefault.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ipv6/address/autoconfig/default")
+ }
+ if !data.Ipv6AddressDhcp.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ipv6/address/dhcp")
+ }
+ for i := range data.Ipv6LinkLocalAddresses {
+ keys := [...]string{"address"}
+ keyValues := [...]string{data.Ipv6LinkLocalAddresses[i].Address.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/ipv6/address/link-local-address%v", predicates))
+ }
+ for i := range data.Ipv6Addresses {
+ keys := [...]string{"prefix"}
+ keyValues := [...]string{data.Ipv6Addresses[i].Prefix.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/ipv6/address/prefix-list%v", predicates))
+ }
+ if !data.TunnelSource.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-tunnel:tunnel/source")
+ }
+ if !data.TunnelDestinationIpv4.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-tunnel:tunnel/destination-config/ipv4")
+ }
+ if !data.TunnelProtectionIpsecProfile.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-tunnel:tunnel/protection/Cisco-IOS-XE-crypto:ipsec/profile")
+ }
+ if !data.CryptoIpsecDfBit.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-crypto:crypto/ipsec/df-bit")
+ }
+ if !data.ArpTimeout.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/arp/timeout")
+ }
+ if !data.Ipv4Address.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ip/address/primary/address")
+ }
+ if !data.Ipv4AddressMask.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ip/address/primary/mask")
+ }
+ if !data.Unnumbered.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ip/unnumbered")
+ }
+ if !data.IpMtu.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ip/mtu")
+ }
+ if !data.IpDhcpRelaySourceInterface.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ip/dhcp/Cisco-IOS-XE-dhcp:relay/source-interface")
+ }
+ if !data.IpAccessGroupInEnable.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ip/access-group/in/acl/in")
+ }
+ if !data.IpAccessGroupIn.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ip/access-group/in/acl/acl-name")
+ }
+ if !data.IpAccessGroupOutEnable.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ip/access-group/out/acl/out")
+ }
+ if !data.IpAccessGroupOut.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ip/access-group/out/acl/acl-name")
+ }
+ for i := range data.HelperAddresses {
+ keys := [...]string{"address"}
+ keyValues := [...]string{data.HelperAddresses[i].Address.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/ip/helper-address%v", predicates))
+ }
+ if !data.TunnelModeIpsecIpv4.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-tunnel:tunnel/mode/ipsec/ipv4")
+ }
+ if !data.BfdTemplate.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/bfd/Cisco-IOS-XE-bfd:template")
+ }
+ if !data.BfdEnable.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/bfd/Cisco-IOS-XE-bfd:enable")
+ }
+ if !data.BfdLocalAddress.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/bfd/Cisco-IOS-XE-bfd:local-address")
+ }
+ if !data.BfdInterval.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/bfd/Cisco-IOS-XE-bfd:interval-interface/msecs")
+ }
+ if !data.BfdIntervalMinRx.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/bfd/Cisco-IOS-XE-bfd:interval-interface/min_rx")
+ }
+ if !data.BfdIntervalMultiplier.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/bfd/Cisco-IOS-XE-bfd:interval-interface/multiplier")
+ }
+ if !data.BfdEcho.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/bfd/Cisco-IOS-XE-bfd:echo")
+ }
+ if !data.LoadInterval.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/load-interval")
+ }
+ if !data.SnmpTrapLinkStatus.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:snmp/trap/link-status")
+ }
+ if !data.LoggingEventLinkStatusEnable.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/logging/event/link-status-enable")
+ }
+ if !data.TunnelVrf.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-tunnel:tunnel/vrf-config/vrf-common/vrf")
+ }
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletePathsXML
diff --git a/internal/provider/model_iosxe_interface_vlan.go b/internal/provider/model_iosxe_interface_vlan.go
index edc86e92..c35f6a71 100644
--- a/internal/provider/model_iosxe_interface_vlan.go
+++ b/internal/provider/model_iosxe_interface_vlan.go
@@ -31,6 +31,9 @@ import (
"github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/types"
+ "github.com/hashicorp/terraform-plugin-log/tflog"
+ "github.com/netascode/go-netconf"
+ "github.com/netascode/xmldot"
"github.com/tidwall/gjson"
"github.com/tidwall/sjson"
)
@@ -151,6 +154,19 @@ func (data InterfaceVLAN) getPathShort() string {
return matches[1]
}
+// getXPath returns the XPath for NETCONF operations
+func (data InterfaceVLAN) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/interface/Vlan[name=%v]"
+ path = fmt.Sprintf(path, fmt.Sprintf("%v", data.Name.ValueInt64()))
+ return path
+}
+
+func (data InterfaceVLANData) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/interface/Vlan[name=%v]"
+ path = fmt.Sprintf(path, fmt.Sprintf("%v", data.Name.ValueInt64()))
+ return path
+}
+
// End of section. //template:end getPath
// Section below is generated&owned by "gen/generator.go". //template:begin toBody
@@ -308,6 +324,188 @@ func (data InterfaceVLAN) toBody(ctx context.Context) string {
// End of section. //template:end toBody
+// Section below is generated&owned by "gen/generator.go". //template:begin toBodyXML
+
+func (data InterfaceVLAN) toBodyXML(ctx context.Context) string {
+ body := netconf.Body{}
+ if !data.Name.IsNull() && !data.Name.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/name", strconv.FormatInt(data.Name.ValueInt64(), 10))
+ }
+ if !data.Autostate.IsNull() && !data.Autostate.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/autostate", data.Autostate.ValueBool())
+ }
+ if !data.Description.IsNull() && !data.Description.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/description", data.Description.ValueString())
+ }
+ if !data.Shutdown.IsNull() && !data.Shutdown.IsUnknown() {
+ if data.Shutdown.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/shutdown", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/shutdown")
+ }
+ }
+ if !data.IpProxyArp.IsNull() && !data.IpProxyArp.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ip/proxy-arp", data.IpProxyArp.ValueBool())
+ }
+ if !data.IpRedirects.IsNull() && !data.IpRedirects.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ip/redirects", data.IpRedirects.ValueBool())
+ }
+ if !data.IpUnreachables.IsNull() && !data.IpUnreachables.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ip/Cisco-IOS-XE-icmp:unreachables", data.IpUnreachables.ValueBool())
+ }
+ if !data.VrfForwarding.IsNull() && !data.VrfForwarding.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/vrf/forwarding", data.VrfForwarding.ValueString())
+ }
+ if !data.Ipv4Address.IsNull() && !data.Ipv4Address.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ip/address/primary/address", data.Ipv4Address.ValueString())
+ }
+ if !data.Ipv4AddressMask.IsNull() && !data.Ipv4AddressMask.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ip/address/primary/mask", data.Ipv4AddressMask.ValueString())
+ }
+ if !data.Unnumbered.IsNull() && !data.Unnumbered.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ip/unnumbered", data.Unnumbered.ValueString())
+ }
+ if !data.IpDhcpRelaySourceInterface.IsNull() && !data.IpDhcpRelaySourceInterface.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ip/dhcp/Cisco-IOS-XE-dhcp:relay/source-interface", data.IpDhcpRelaySourceInterface.ValueString())
+ }
+ if !data.IpAccessGroupInEnable.IsNull() && !data.IpAccessGroupInEnable.IsUnknown() {
+ if data.IpAccessGroupInEnable.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ip/access-group/in/acl/in", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/ip/access-group/in/acl/in")
+ }
+ }
+ if !data.IpAccessGroupIn.IsNull() && !data.IpAccessGroupIn.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ip/access-group/in/acl/acl-name", data.IpAccessGroupIn.ValueString())
+ }
+ if !data.IpAccessGroupOutEnable.IsNull() && !data.IpAccessGroupOutEnable.IsUnknown() {
+ if data.IpAccessGroupOutEnable.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ip/access-group/out/acl/out", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/ip/access-group/out/acl/out")
+ }
+ }
+ if !data.IpAccessGroupOut.IsNull() && !data.IpAccessGroupOut.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ip/access-group/out/acl/acl-name", data.IpAccessGroupOut.ValueString())
+ }
+ if len(data.HelperAddresses) > 0 {
+ for _, item := range data.HelperAddresses {
+ cBody := netconf.Body{}
+ if !item.Address.IsNull() && !item.Address.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "address", item.Address.ValueString())
+ }
+ if !item.Global.IsNull() && !item.Global.IsUnknown() {
+ if item.Global.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "global", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "global")
+ }
+ }
+ if !item.Vrf.IsNull() && !item.Vrf.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "vrf", item.Vrf.ValueString())
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/ip/helper-address", cBody.Res())
+ }
+ }
+ if !data.BfdTemplate.IsNull() && !data.BfdTemplate.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/bfd/Cisco-IOS-XE-bfd:template", data.BfdTemplate.ValueString())
+ }
+ if !data.BfdEnable.IsNull() && !data.BfdEnable.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/bfd/Cisco-IOS-XE-bfd:enable", data.BfdEnable.ValueBool())
+ }
+ if !data.BfdLocalAddress.IsNull() && !data.BfdLocalAddress.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/bfd/Cisco-IOS-XE-bfd:local-address", data.BfdLocalAddress.ValueString())
+ }
+ if !data.BfdInterval.IsNull() && !data.BfdInterval.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/bfd/Cisco-IOS-XE-bfd:interval-interface/msecs", strconv.FormatInt(data.BfdInterval.ValueInt64(), 10))
+ }
+ if !data.BfdIntervalMinRx.IsNull() && !data.BfdIntervalMinRx.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/bfd/Cisco-IOS-XE-bfd:interval-interface/min_rx", strconv.FormatInt(data.BfdIntervalMinRx.ValueInt64(), 10))
+ }
+ if !data.BfdIntervalMultiplier.IsNull() && !data.BfdIntervalMultiplier.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/bfd/Cisco-IOS-XE-bfd:interval-interface/multiplier", strconv.FormatInt(data.BfdIntervalMultiplier.ValueInt64(), 10))
+ }
+ if !data.BfdEcho.IsNull() && !data.BfdEcho.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/bfd/Cisco-IOS-XE-bfd:echo", data.BfdEcho.ValueBool())
+ }
+ if !data.Ipv6Enable.IsNull() && !data.Ipv6Enable.IsUnknown() {
+ if data.Ipv6Enable.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ipv6/enable", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/ipv6/enable")
+ }
+ }
+ if !data.Ipv6Mtu.IsNull() && !data.Ipv6Mtu.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ipv6/mtu", strconv.FormatInt(data.Ipv6Mtu.ValueInt64(), 10))
+ }
+ if !data.Ipv6NdRaSuppressAll.IsNull() && !data.Ipv6NdRaSuppressAll.IsUnknown() {
+ if data.Ipv6NdRaSuppressAll.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ipv6/nd/Cisco-IOS-XE-nd:ra/suppress/all", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/ipv6/nd/Cisco-IOS-XE-nd:ra/suppress/all")
+ }
+ }
+ if !data.Ipv6AddressAutoconfigDefault.IsNull() && !data.Ipv6AddressAutoconfigDefault.IsUnknown() {
+ if data.Ipv6AddressAutoconfigDefault.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ipv6/address/autoconfig/default", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/ipv6/address/autoconfig/default")
+ }
+ }
+ if !data.Ipv6AddressDhcp.IsNull() && !data.Ipv6AddressDhcp.IsUnknown() {
+ if data.Ipv6AddressDhcp.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ipv6/address/dhcp", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/ipv6/address/dhcp")
+ }
+ }
+ if len(data.Ipv6LinkLocalAddresses) > 0 {
+ for _, item := range data.Ipv6LinkLocalAddresses {
+ cBody := netconf.Body{}
+ if !item.Address.IsNull() && !item.Address.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "address", item.Address.ValueString())
+ }
+ if !item.LinkLocal.IsNull() && !item.LinkLocal.IsUnknown() {
+ if item.LinkLocal.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "link-local", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "link-local")
+ }
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/ipv6/address/link-local-address", cBody.Res())
+ }
+ }
+ if len(data.Ipv6Addresses) > 0 {
+ for _, item := range data.Ipv6Addresses {
+ cBody := netconf.Body{}
+ if !item.Prefix.IsNull() && !item.Prefix.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "prefix", item.Prefix.ValueString())
+ }
+ if !item.Eui64.IsNull() && !item.Eui64.IsUnknown() {
+ if item.Eui64.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "eui-64", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "eui-64")
+ }
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/ipv6/address/prefix-list", cBody.Res())
+ }
+ }
+ if !data.LoadInterval.IsNull() && !data.LoadInterval.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/load-interval", strconv.FormatInt(data.LoadInterval.ValueInt64(), 10))
+ }
+ if !data.MacAddress.IsNull() && !data.MacAddress.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/mac-address", data.MacAddress.ValueString())
+ }
+ bodyString, err := body.String()
+ if err != nil {
+ tflog.Error(ctx, fmt.Sprintf("Error converting body to string: %s", err))
+ }
+ return bodyString
+}
+
+// End of section. //template:end toBodyXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBody
func (data *InterfaceVLAN) updateFromBody(ctx context.Context, res gjson.Result) {
@@ -628,96 +826,412 @@ func (data *InterfaceVLAN) updateFromBody(ctx context.Context, res gjson.Result)
// End of section. //template:end updateFromBody
-// Section below is generated&owned by "gen/generator.go". //template:begin fromBody
+// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBodyXML
-func (data *InterfaceVLAN) fromBody(ctx context.Context, res gjson.Result) {
- prefix := helpers.LastElement(data.getPath()) + "."
- if res.Get(helpers.LastElement(data.getPath())).IsArray() {
- prefix += "0."
+func (data *InterfaceVLAN) updateFromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/name"); value.Exists() && !data.Name.IsNull() {
+ data.Name = types.Int64Value(value.Int())
+ } else {
+ data.Name = types.Int64Null()
}
- if value := res.Get(prefix + "autostate"); value.Exists() {
- data.Autostate = types.BoolValue(value.Bool())
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/autostate"); !data.Autostate.IsNull() {
+ if value.Exists() {
+ data.Autostate = types.BoolValue(value.Bool())
+ }
} else {
data.Autostate = types.BoolNull()
}
- if value := res.Get(prefix + "description"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/description"); value.Exists() && !data.Description.IsNull() {
data.Description = types.StringValue(value.String())
+ } else {
+ data.Description = types.StringNull()
}
- if value := res.Get(prefix + "shutdown"); value.Exists() {
- data.Shutdown = types.BoolValue(true)
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/shutdown"); !data.Shutdown.IsNull() {
+ if value.Exists() {
+ data.Shutdown = types.BoolValue(true)
+ } else {
+ data.Shutdown = types.BoolValue(false)
+ }
} else {
- data.Shutdown = types.BoolValue(false)
+ data.Shutdown = types.BoolNull()
}
- if value := res.Get(prefix + "ip.proxy-arp"); value.Exists() {
- data.IpProxyArp = types.BoolValue(value.Bool())
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/proxy-arp"); !data.IpProxyArp.IsNull() {
+ if value.Exists() {
+ data.IpProxyArp = types.BoolValue(value.Bool())
+ }
} else {
data.IpProxyArp = types.BoolNull()
}
- if value := res.Get(prefix + "ip.redirects"); value.Exists() {
- data.IpRedirects = types.BoolValue(value.Bool())
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/redirects"); !data.IpRedirects.IsNull() {
+ if value.Exists() {
+ data.IpRedirects = types.BoolValue(value.Bool())
+ }
} else {
data.IpRedirects = types.BoolNull()
}
- if value := res.Get(prefix + "ip.Cisco-IOS-XE-icmp:unreachables"); value.Exists() {
- data.IpUnreachables = types.BoolValue(value.Bool())
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/Cisco-IOS-XE-icmp:unreachables"); !data.IpUnreachables.IsNull() {
+ if value.Exists() {
+ data.IpUnreachables = types.BoolValue(value.Bool())
+ }
} else {
data.IpUnreachables = types.BoolNull()
}
- if value := res.Get(prefix + "vrf.forwarding"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/vrf/forwarding"); value.Exists() && !data.VrfForwarding.IsNull() {
data.VrfForwarding = types.StringValue(value.String())
+ } else {
+ data.VrfForwarding = types.StringNull()
}
- if value := res.Get(prefix + "ip.address.primary.address"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/address/primary/address"); value.Exists() && !data.Ipv4Address.IsNull() {
data.Ipv4Address = types.StringValue(value.String())
+ } else {
+ data.Ipv4Address = types.StringNull()
}
- if value := res.Get(prefix + "ip.address.primary.mask"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/address/primary/mask"); value.Exists() && !data.Ipv4AddressMask.IsNull() {
data.Ipv4AddressMask = types.StringValue(value.String())
+ } else {
+ data.Ipv4AddressMask = types.StringNull()
}
- if value := res.Get(prefix + "ip.unnumbered"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/unnumbered"); value.Exists() && !data.Unnumbered.IsNull() {
data.Unnumbered = types.StringValue(value.String())
+ } else {
+ data.Unnumbered = types.StringNull()
}
- if value := res.Get(prefix + "ip.dhcp.Cisco-IOS-XE-dhcp:relay.source-interface"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/dhcp/Cisco-IOS-XE-dhcp:relay/source-interface"); value.Exists() && !data.IpDhcpRelaySourceInterface.IsNull() {
data.IpDhcpRelaySourceInterface = types.StringValue(value.String())
+ } else {
+ data.IpDhcpRelaySourceInterface = types.StringNull()
}
- if value := res.Get(prefix + "ip.access-group.in.acl.in"); value.Exists() {
- data.IpAccessGroupInEnable = types.BoolValue(true)
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/access-group/in/acl/in"); !data.IpAccessGroupInEnable.IsNull() {
+ if value.Exists() {
+ data.IpAccessGroupInEnable = types.BoolValue(true)
+ } else {
+ data.IpAccessGroupInEnable = types.BoolValue(false)
+ }
} else {
- data.IpAccessGroupInEnable = types.BoolValue(false)
+ data.IpAccessGroupInEnable = types.BoolNull()
}
- if value := res.Get(prefix + "ip.access-group.in.acl.acl-name"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/access-group/in/acl/acl-name"); value.Exists() && !data.IpAccessGroupIn.IsNull() {
data.IpAccessGroupIn = types.StringValue(value.String())
+ } else {
+ data.IpAccessGroupIn = types.StringNull()
}
- if value := res.Get(prefix + "ip.access-group.out.acl.out"); value.Exists() {
- data.IpAccessGroupOutEnable = types.BoolValue(true)
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/access-group/out/acl/out"); !data.IpAccessGroupOutEnable.IsNull() {
+ if value.Exists() {
+ data.IpAccessGroupOutEnable = types.BoolValue(true)
+ } else {
+ data.IpAccessGroupOutEnable = types.BoolValue(false)
+ }
} else {
- data.IpAccessGroupOutEnable = types.BoolValue(false)
+ data.IpAccessGroupOutEnable = types.BoolNull()
}
- if value := res.Get(prefix + "ip.access-group.out.acl.acl-name"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/access-group/out/acl/acl-name"); value.Exists() && !data.IpAccessGroupOut.IsNull() {
data.IpAccessGroupOut = types.StringValue(value.String())
+ } else {
+ data.IpAccessGroupOut = types.StringNull()
}
- if value := res.Get(prefix + "ip.helper-address"); value.Exists() {
- data.HelperAddresses = make([]InterfaceVLANHelperAddresses, 0)
- value.ForEach(func(k, v gjson.Result) bool {
- item := InterfaceVLANHelperAddresses{}
- if cValue := v.Get("address"); cValue.Exists() {
- item.Address = types.StringValue(cValue.String())
- }
- if cValue := v.Get("global"); cValue.Exists() {
- item.Global = types.BoolValue(true)
+ for i := range data.HelperAddresses {
+ keys := [...]string{"address"}
+ keyValues := [...]string{data.HelperAddresses[i].Address.ValueString()}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/helper-address").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, "address"); value.Exists() && !data.HelperAddresses[i].Address.IsNull() {
+ data.HelperAddresses[i].Address = types.StringValue(value.String())
+ } else {
+ data.HelperAddresses[i].Address = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "global"); !data.HelperAddresses[i].Global.IsNull() {
+ if value.Exists() {
+ data.HelperAddresses[i].Global = types.BoolValue(true)
} else {
- item.Global = types.BoolValue(false)
- }
- if cValue := v.Get("vrf"); cValue.Exists() {
- item.Vrf = types.StringValue(cValue.String())
+ data.HelperAddresses[i].Global = types.BoolValue(false)
}
- data.HelperAddresses = append(data.HelperAddresses, item)
- return true
- })
+ } else {
+ data.HelperAddresses[i].Global = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "vrf"); value.Exists() && !data.HelperAddresses[i].Vrf.IsNull() {
+ data.HelperAddresses[i].Vrf = types.StringValue(value.String())
+ } else {
+ data.HelperAddresses[i].Vrf = types.StringNull()
+ }
}
- if value := res.Get(prefix + "bfd.Cisco-IOS-XE-bfd:template"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/bfd/Cisco-IOS-XE-bfd:template"); value.Exists() && !data.BfdTemplate.IsNull() {
data.BfdTemplate = types.StringValue(value.String())
+ } else {
+ data.BfdTemplate = types.StringNull()
}
- if value := res.Get(prefix + "bfd.Cisco-IOS-XE-bfd:enable"); value.Exists() {
- data.BfdEnable = types.BoolValue(value.Bool())
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/bfd/Cisco-IOS-XE-bfd:enable"); !data.BfdEnable.IsNull() {
+ if value.Exists() {
+ data.BfdEnable = types.BoolValue(value.Bool())
+ }
+ } else {
+ data.BfdEnable = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/bfd/Cisco-IOS-XE-bfd:local-address"); value.Exists() && !data.BfdLocalAddress.IsNull() {
+ data.BfdLocalAddress = types.StringValue(value.String())
+ } else {
+ data.BfdLocalAddress = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/bfd/Cisco-IOS-XE-bfd:interval-interface/msecs"); value.Exists() && !data.BfdInterval.IsNull() {
+ data.BfdInterval = types.Int64Value(value.Int())
+ } else {
+ data.BfdInterval = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/bfd/Cisco-IOS-XE-bfd:interval-interface/min_rx"); value.Exists() && !data.BfdIntervalMinRx.IsNull() {
+ data.BfdIntervalMinRx = types.Int64Value(value.Int())
+ } else {
+ data.BfdIntervalMinRx = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/bfd/Cisco-IOS-XE-bfd:interval-interface/multiplier"); value.Exists() && !data.BfdIntervalMultiplier.IsNull() {
+ data.BfdIntervalMultiplier = types.Int64Value(value.Int())
+ } else {
+ data.BfdIntervalMultiplier = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/bfd/Cisco-IOS-XE-bfd:echo"); !data.BfdEcho.IsNull() {
+ if value.Exists() {
+ data.BfdEcho = types.BoolValue(value.Bool())
+ }
+ } else {
+ data.BfdEcho = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ipv6/enable"); !data.Ipv6Enable.IsNull() {
+ if value.Exists() {
+ data.Ipv6Enable = types.BoolValue(true)
+ } else {
+ data.Ipv6Enable = types.BoolValue(false)
+ }
+ } else {
+ data.Ipv6Enable = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ipv6/mtu"); value.Exists() && !data.Ipv6Mtu.IsNull() {
+ data.Ipv6Mtu = types.Int64Value(value.Int())
+ } else {
+ data.Ipv6Mtu = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ipv6/nd/Cisco-IOS-XE-nd:ra/suppress/all"); !data.Ipv6NdRaSuppressAll.IsNull() {
+ if value.Exists() {
+ data.Ipv6NdRaSuppressAll = types.BoolValue(true)
+ } else {
+ data.Ipv6NdRaSuppressAll = types.BoolValue(false)
+ }
+ } else {
+ data.Ipv6NdRaSuppressAll = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ipv6/address/autoconfig/default"); !data.Ipv6AddressAutoconfigDefault.IsNull() {
+ if value.Exists() {
+ data.Ipv6AddressAutoconfigDefault = types.BoolValue(true)
+ } else {
+ data.Ipv6AddressAutoconfigDefault = types.BoolValue(false)
+ }
+ } else {
+ data.Ipv6AddressAutoconfigDefault = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ipv6/address/dhcp"); !data.Ipv6AddressDhcp.IsNull() {
+ if value.Exists() {
+ data.Ipv6AddressDhcp = types.BoolValue(true)
+ } else {
+ data.Ipv6AddressDhcp = types.BoolValue(false)
+ }
+ } else {
+ data.Ipv6AddressDhcp = types.BoolNull()
+ }
+ for i := range data.Ipv6LinkLocalAddresses {
+ keys := [...]string{"address"}
+ keyValues := [...]string{data.Ipv6LinkLocalAddresses[i].Address.ValueString()}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ipv6/address/link-local-address").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, "address"); value.Exists() && !data.Ipv6LinkLocalAddresses[i].Address.IsNull() {
+ data.Ipv6LinkLocalAddresses[i].Address = types.StringValue(value.String())
+ } else {
+ data.Ipv6LinkLocalAddresses[i].Address = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "link-local"); !data.Ipv6LinkLocalAddresses[i].LinkLocal.IsNull() {
+ if value.Exists() {
+ data.Ipv6LinkLocalAddresses[i].LinkLocal = types.BoolValue(true)
+ } else {
+ data.Ipv6LinkLocalAddresses[i].LinkLocal = types.BoolValue(false)
+ }
+ } else {
+ data.Ipv6LinkLocalAddresses[i].LinkLocal = types.BoolNull()
+ }
+ }
+ for i := range data.Ipv6Addresses {
+ keys := [...]string{"prefix"}
+ keyValues := [...]string{data.Ipv6Addresses[i].Prefix.ValueString()}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ipv6/address/prefix-list").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, "prefix"); value.Exists() && !data.Ipv6Addresses[i].Prefix.IsNull() {
+ data.Ipv6Addresses[i].Prefix = types.StringValue(value.String())
+ } else {
+ data.Ipv6Addresses[i].Prefix = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "eui-64"); !data.Ipv6Addresses[i].Eui64.IsNull() {
+ if value.Exists() {
+ data.Ipv6Addresses[i].Eui64 = types.BoolValue(true)
+ } else {
+ data.Ipv6Addresses[i].Eui64 = types.BoolValue(false)
+ }
+ } else {
+ data.Ipv6Addresses[i].Eui64 = types.BoolNull()
+ }
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/load-interval"); value.Exists() && !data.LoadInterval.IsNull() {
+ data.LoadInterval = types.Int64Value(value.Int())
+ } else {
+ data.LoadInterval = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/mac-address"); value.Exists() && !data.MacAddress.IsNull() {
+ data.MacAddress = types.StringValue(value.String())
+ } else {
+ data.MacAddress = types.StringNull()
+ }
+}
+
+// End of section. //template:end updateFromBodyXML
+
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBody
+
+func (data *InterfaceVLAN) fromBody(ctx context.Context, res gjson.Result) {
+ prefix := helpers.LastElement(data.getPath()) + "."
+ if res.Get(helpers.LastElement(data.getPath())).IsArray() {
+ prefix += "0."
+ }
+ if value := res.Get(prefix + "autostate"); value.Exists() {
+ data.Autostate = types.BoolValue(value.Bool())
+ } else {
+ data.Autostate = types.BoolNull()
+ }
+ if value := res.Get(prefix + "description"); value.Exists() {
+ data.Description = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "shutdown"); value.Exists() {
+ data.Shutdown = types.BoolValue(true)
+ } else {
+ data.Shutdown = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "ip.proxy-arp"); value.Exists() {
+ data.IpProxyArp = types.BoolValue(value.Bool())
+ } else {
+ data.IpProxyArp = types.BoolNull()
+ }
+ if value := res.Get(prefix + "ip.redirects"); value.Exists() {
+ data.IpRedirects = types.BoolValue(value.Bool())
+ } else {
+ data.IpRedirects = types.BoolNull()
+ }
+ if value := res.Get(prefix + "ip.Cisco-IOS-XE-icmp:unreachables"); value.Exists() {
+ data.IpUnreachables = types.BoolValue(value.Bool())
+ } else {
+ data.IpUnreachables = types.BoolNull()
+ }
+ if value := res.Get(prefix + "vrf.forwarding"); value.Exists() {
+ data.VrfForwarding = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "ip.address.primary.address"); value.Exists() {
+ data.Ipv4Address = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "ip.address.primary.mask"); value.Exists() {
+ data.Ipv4AddressMask = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "ip.unnumbered"); value.Exists() {
+ data.Unnumbered = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "ip.dhcp.Cisco-IOS-XE-dhcp:relay.source-interface"); value.Exists() {
+ data.IpDhcpRelaySourceInterface = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "ip.access-group.in.acl.in"); value.Exists() {
+ data.IpAccessGroupInEnable = types.BoolValue(true)
+ } else {
+ data.IpAccessGroupInEnable = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "ip.access-group.in.acl.acl-name"); value.Exists() {
+ data.IpAccessGroupIn = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "ip.access-group.out.acl.out"); value.Exists() {
+ data.IpAccessGroupOutEnable = types.BoolValue(true)
+ } else {
+ data.IpAccessGroupOutEnable = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "ip.access-group.out.acl.acl-name"); value.Exists() {
+ data.IpAccessGroupOut = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "ip.helper-address"); value.Exists() {
+ data.HelperAddresses = make([]InterfaceVLANHelperAddresses, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := InterfaceVLANHelperAddresses{}
+ if cValue := v.Get("address"); cValue.Exists() {
+ item.Address = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("global"); cValue.Exists() {
+ item.Global = types.BoolValue(true)
+ } else {
+ item.Global = types.BoolValue(false)
+ }
+ if cValue := v.Get("vrf"); cValue.Exists() {
+ item.Vrf = types.StringValue(cValue.String())
+ }
+ data.HelperAddresses = append(data.HelperAddresses, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + "bfd.Cisco-IOS-XE-bfd:template"); value.Exists() {
+ data.BfdTemplate = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "bfd.Cisco-IOS-XE-bfd:enable"); value.Exists() {
+ data.BfdEnable = types.BoolValue(value.Bool())
} else {
data.BfdEnable = types.BoolNull()
}
@@ -866,84 +1380,426 @@ func (data *InterfaceVLANData) fromBody(ctx context.Context, res gjson.Result) {
} else {
data.IpAccessGroupOutEnable = types.BoolValue(false)
}
- if value := res.Get(prefix + "ip.access-group.out.acl.acl-name"); value.Exists() {
+ if value := res.Get(prefix + "ip.access-group.out.acl.acl-name"); value.Exists() {
+ data.IpAccessGroupOut = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "ip.helper-address"); value.Exists() {
+ data.HelperAddresses = make([]InterfaceVLANHelperAddresses, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := InterfaceVLANHelperAddresses{}
+ if cValue := v.Get("address"); cValue.Exists() {
+ item.Address = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("global"); cValue.Exists() {
+ item.Global = types.BoolValue(true)
+ } else {
+ item.Global = types.BoolValue(false)
+ }
+ if cValue := v.Get("vrf"); cValue.Exists() {
+ item.Vrf = types.StringValue(cValue.String())
+ }
+ data.HelperAddresses = append(data.HelperAddresses, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + "bfd.Cisco-IOS-XE-bfd:template"); value.Exists() {
+ data.BfdTemplate = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "bfd.Cisco-IOS-XE-bfd:enable"); value.Exists() {
+ data.BfdEnable = types.BoolValue(value.Bool())
+ } else {
+ data.BfdEnable = types.BoolNull()
+ }
+ if value := res.Get(prefix + "bfd.Cisco-IOS-XE-bfd:local-address"); value.Exists() {
+ data.BfdLocalAddress = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "bfd.Cisco-IOS-XE-bfd:interval-interface.msecs"); value.Exists() {
+ data.BfdInterval = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "bfd.Cisco-IOS-XE-bfd:interval-interface.min_rx"); value.Exists() {
+ data.BfdIntervalMinRx = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "bfd.Cisco-IOS-XE-bfd:interval-interface.multiplier"); value.Exists() {
+ data.BfdIntervalMultiplier = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "bfd.Cisco-IOS-XE-bfd:echo"); value.Exists() {
+ data.BfdEcho = types.BoolValue(value.Bool())
+ } else {
+ data.BfdEcho = types.BoolNull()
+ }
+ if value := res.Get(prefix + "ipv6.enable"); value.Exists() {
+ data.Ipv6Enable = types.BoolValue(true)
+ } else {
+ data.Ipv6Enable = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "ipv6.mtu"); value.Exists() {
+ data.Ipv6Mtu = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "ipv6.nd.Cisco-IOS-XE-nd:ra.suppress.all"); value.Exists() {
+ data.Ipv6NdRaSuppressAll = types.BoolValue(true)
+ } else {
+ data.Ipv6NdRaSuppressAll = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "ipv6.address.autoconfig.default"); value.Exists() {
+ data.Ipv6AddressAutoconfigDefault = types.BoolValue(true)
+ } else {
+ data.Ipv6AddressAutoconfigDefault = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "ipv6.address.dhcp"); value.Exists() {
+ data.Ipv6AddressDhcp = types.BoolValue(true)
+ } else {
+ data.Ipv6AddressDhcp = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "ipv6.address.link-local-address"); value.Exists() {
+ data.Ipv6LinkLocalAddresses = make([]InterfaceVLANIpv6LinkLocalAddresses, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := InterfaceVLANIpv6LinkLocalAddresses{}
+ if cValue := v.Get("address"); cValue.Exists() {
+ item.Address = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("link-local"); cValue.Exists() {
+ item.LinkLocal = types.BoolValue(true)
+ } else {
+ item.LinkLocal = types.BoolValue(false)
+ }
+ data.Ipv6LinkLocalAddresses = append(data.Ipv6LinkLocalAddresses, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + "ipv6.address.prefix-list"); value.Exists() {
+ data.Ipv6Addresses = make([]InterfaceVLANIpv6Addresses, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := InterfaceVLANIpv6Addresses{}
+ if cValue := v.Get("prefix"); cValue.Exists() {
+ item.Prefix = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("eui-64"); cValue.Exists() {
+ item.Eui64 = types.BoolValue(true)
+ } else {
+ item.Eui64 = types.BoolValue(false)
+ }
+ data.Ipv6Addresses = append(data.Ipv6Addresses, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + "load-interval"); value.Exists() {
+ data.LoadInterval = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "mac-address"); value.Exists() {
+ data.MacAddress = types.StringValue(value.String())
+ }
+}
+
+// End of section. //template:end fromBodyData
+
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyXML
+
+func (data *InterfaceVLAN) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/autostate"); value.Exists() {
+ data.Autostate = types.BoolValue(value.Bool())
+ } else {
+ data.Autostate = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/description"); value.Exists() {
+ data.Description = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/shutdown"); value.Exists() {
+ data.Shutdown = types.BoolValue(true)
+ } else {
+ data.Shutdown = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/proxy-arp"); value.Exists() {
+ data.IpProxyArp = types.BoolValue(value.Bool())
+ } else {
+ data.IpProxyArp = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/redirects"); value.Exists() {
+ data.IpRedirects = types.BoolValue(value.Bool())
+ } else {
+ data.IpRedirects = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/Cisco-IOS-XE-icmp:unreachables"); value.Exists() {
+ data.IpUnreachables = types.BoolValue(value.Bool())
+ } else {
+ data.IpUnreachables = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/vrf/forwarding"); value.Exists() {
+ data.VrfForwarding = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/address/primary/address"); value.Exists() {
+ data.Ipv4Address = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/address/primary/mask"); value.Exists() {
+ data.Ipv4AddressMask = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/unnumbered"); value.Exists() {
+ data.Unnumbered = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/dhcp/Cisco-IOS-XE-dhcp:relay/source-interface"); value.Exists() {
+ data.IpDhcpRelaySourceInterface = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/access-group/in/acl/in"); value.Exists() {
+ data.IpAccessGroupInEnable = types.BoolValue(true)
+ } else {
+ data.IpAccessGroupInEnable = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/access-group/in/acl/acl-name"); value.Exists() {
+ data.IpAccessGroupIn = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/access-group/out/acl/out"); value.Exists() {
+ data.IpAccessGroupOutEnable = types.BoolValue(true)
+ } else {
+ data.IpAccessGroupOutEnable = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/access-group/out/acl/acl-name"); value.Exists() {
+ data.IpAccessGroupOut = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/helper-address"); value.Exists() {
+ data.HelperAddresses = make([]InterfaceVLANHelperAddresses, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := InterfaceVLANHelperAddresses{}
+ if cValue := helpers.GetFromXPath(v, "address"); cValue.Exists() {
+ item.Address = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "global"); cValue.Exists() {
+ item.Global = types.BoolValue(true)
+ } else {
+ item.Global = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "vrf"); cValue.Exists() {
+ item.Vrf = types.StringValue(cValue.String())
+ }
+ data.HelperAddresses = append(data.HelperAddresses, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/bfd/Cisco-IOS-XE-bfd:template"); value.Exists() {
+ data.BfdTemplate = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/bfd/Cisco-IOS-XE-bfd:enable"); value.Exists() {
+ data.BfdEnable = types.BoolValue(value.Bool())
+ } else {
+ data.BfdEnable = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/bfd/Cisco-IOS-XE-bfd:local-address"); value.Exists() {
+ data.BfdLocalAddress = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/bfd/Cisco-IOS-XE-bfd:interval-interface/msecs"); value.Exists() {
+ data.BfdInterval = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/bfd/Cisco-IOS-XE-bfd:interval-interface/min_rx"); value.Exists() {
+ data.BfdIntervalMinRx = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/bfd/Cisco-IOS-XE-bfd:interval-interface/multiplier"); value.Exists() {
+ data.BfdIntervalMultiplier = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/bfd/Cisco-IOS-XE-bfd:echo"); value.Exists() {
+ data.BfdEcho = types.BoolValue(value.Bool())
+ } else {
+ data.BfdEcho = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ipv6/enable"); value.Exists() {
+ data.Ipv6Enable = types.BoolValue(true)
+ } else {
+ data.Ipv6Enable = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ipv6/mtu"); value.Exists() {
+ data.Ipv6Mtu = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ipv6/nd/Cisco-IOS-XE-nd:ra/suppress/all"); value.Exists() {
+ data.Ipv6NdRaSuppressAll = types.BoolValue(true)
+ } else {
+ data.Ipv6NdRaSuppressAll = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ipv6/address/autoconfig/default"); value.Exists() {
+ data.Ipv6AddressAutoconfigDefault = types.BoolValue(true)
+ } else {
+ data.Ipv6AddressAutoconfigDefault = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ipv6/address/dhcp"); value.Exists() {
+ data.Ipv6AddressDhcp = types.BoolValue(true)
+ } else {
+ data.Ipv6AddressDhcp = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ipv6/address/link-local-address"); value.Exists() {
+ data.Ipv6LinkLocalAddresses = make([]InterfaceVLANIpv6LinkLocalAddresses, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := InterfaceVLANIpv6LinkLocalAddresses{}
+ if cValue := helpers.GetFromXPath(v, "address"); cValue.Exists() {
+ item.Address = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "link-local"); cValue.Exists() {
+ item.LinkLocal = types.BoolValue(true)
+ } else {
+ item.LinkLocal = types.BoolValue(false)
+ }
+ data.Ipv6LinkLocalAddresses = append(data.Ipv6LinkLocalAddresses, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ipv6/address/prefix-list"); value.Exists() {
+ data.Ipv6Addresses = make([]InterfaceVLANIpv6Addresses, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := InterfaceVLANIpv6Addresses{}
+ if cValue := helpers.GetFromXPath(v, "prefix"); cValue.Exists() {
+ item.Prefix = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "eui-64"); cValue.Exists() {
+ item.Eui64 = types.BoolValue(true)
+ } else {
+ item.Eui64 = types.BoolValue(false)
+ }
+ data.Ipv6Addresses = append(data.Ipv6Addresses, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/load-interval"); value.Exists() {
+ data.LoadInterval = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/mac-address"); value.Exists() {
+ data.MacAddress = types.StringValue(value.String())
+ }
+}
+
+// End of section. //template:end fromBodyXML
+
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyDataXML
+
+func (data *InterfaceVLANData) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/autostate"); value.Exists() {
+ data.Autostate = types.BoolValue(value.Bool())
+ } else {
+ data.Autostate = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/description"); value.Exists() {
+ data.Description = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/shutdown"); value.Exists() {
+ data.Shutdown = types.BoolValue(true)
+ } else {
+ data.Shutdown = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/proxy-arp"); value.Exists() {
+ data.IpProxyArp = types.BoolValue(value.Bool())
+ } else {
+ data.IpProxyArp = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/redirects"); value.Exists() {
+ data.IpRedirects = types.BoolValue(value.Bool())
+ } else {
+ data.IpRedirects = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/Cisco-IOS-XE-icmp:unreachables"); value.Exists() {
+ data.IpUnreachables = types.BoolValue(value.Bool())
+ } else {
+ data.IpUnreachables = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/vrf/forwarding"); value.Exists() {
+ data.VrfForwarding = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/address/primary/address"); value.Exists() {
+ data.Ipv4Address = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/address/primary/mask"); value.Exists() {
+ data.Ipv4AddressMask = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/unnumbered"); value.Exists() {
+ data.Unnumbered = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/dhcp/Cisco-IOS-XE-dhcp:relay/source-interface"); value.Exists() {
+ data.IpDhcpRelaySourceInterface = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/access-group/in/acl/in"); value.Exists() {
+ data.IpAccessGroupInEnable = types.BoolValue(true)
+ } else {
+ data.IpAccessGroupInEnable = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/access-group/in/acl/acl-name"); value.Exists() {
+ data.IpAccessGroupIn = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/access-group/out/acl/out"); value.Exists() {
+ data.IpAccessGroupOutEnable = types.BoolValue(true)
+ } else {
+ data.IpAccessGroupOutEnable = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/access-group/out/acl/acl-name"); value.Exists() {
data.IpAccessGroupOut = types.StringValue(value.String())
}
- if value := res.Get(prefix + "ip.helper-address"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/helper-address"); value.Exists() {
data.HelperAddresses = make([]InterfaceVLANHelperAddresses, 0)
- value.ForEach(func(k, v gjson.Result) bool {
+ value.ForEach(func(_ int, v xmldot.Result) bool {
item := InterfaceVLANHelperAddresses{}
- if cValue := v.Get("address"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "address"); cValue.Exists() {
item.Address = types.StringValue(cValue.String())
}
- if cValue := v.Get("global"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "global"); cValue.Exists() {
item.Global = types.BoolValue(true)
} else {
item.Global = types.BoolValue(false)
}
- if cValue := v.Get("vrf"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "vrf"); cValue.Exists() {
item.Vrf = types.StringValue(cValue.String())
}
data.HelperAddresses = append(data.HelperAddresses, item)
return true
})
}
- if value := res.Get(prefix + "bfd.Cisco-IOS-XE-bfd:template"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/bfd/Cisco-IOS-XE-bfd:template"); value.Exists() {
data.BfdTemplate = types.StringValue(value.String())
}
- if value := res.Get(prefix + "bfd.Cisco-IOS-XE-bfd:enable"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/bfd/Cisco-IOS-XE-bfd:enable"); value.Exists() {
data.BfdEnable = types.BoolValue(value.Bool())
} else {
data.BfdEnable = types.BoolNull()
}
- if value := res.Get(prefix + "bfd.Cisco-IOS-XE-bfd:local-address"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/bfd/Cisco-IOS-XE-bfd:local-address"); value.Exists() {
data.BfdLocalAddress = types.StringValue(value.String())
}
- if value := res.Get(prefix + "bfd.Cisco-IOS-XE-bfd:interval-interface.msecs"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/bfd/Cisco-IOS-XE-bfd:interval-interface/msecs"); value.Exists() {
data.BfdInterval = types.Int64Value(value.Int())
}
- if value := res.Get(prefix + "bfd.Cisco-IOS-XE-bfd:interval-interface.min_rx"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/bfd/Cisco-IOS-XE-bfd:interval-interface/min_rx"); value.Exists() {
data.BfdIntervalMinRx = types.Int64Value(value.Int())
}
- if value := res.Get(prefix + "bfd.Cisco-IOS-XE-bfd:interval-interface.multiplier"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/bfd/Cisco-IOS-XE-bfd:interval-interface/multiplier"); value.Exists() {
data.BfdIntervalMultiplier = types.Int64Value(value.Int())
}
- if value := res.Get(prefix + "bfd.Cisco-IOS-XE-bfd:echo"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/bfd/Cisco-IOS-XE-bfd:echo"); value.Exists() {
data.BfdEcho = types.BoolValue(value.Bool())
} else {
data.BfdEcho = types.BoolNull()
}
- if value := res.Get(prefix + "ipv6.enable"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ipv6/enable"); value.Exists() {
data.Ipv6Enable = types.BoolValue(true)
} else {
data.Ipv6Enable = types.BoolValue(false)
}
- if value := res.Get(prefix + "ipv6.mtu"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ipv6/mtu"); value.Exists() {
data.Ipv6Mtu = types.Int64Value(value.Int())
}
- if value := res.Get(prefix + "ipv6.nd.Cisco-IOS-XE-nd:ra.suppress.all"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ipv6/nd/Cisco-IOS-XE-nd:ra/suppress/all"); value.Exists() {
data.Ipv6NdRaSuppressAll = types.BoolValue(true)
} else {
data.Ipv6NdRaSuppressAll = types.BoolValue(false)
}
- if value := res.Get(prefix + "ipv6.address.autoconfig.default"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ipv6/address/autoconfig/default"); value.Exists() {
data.Ipv6AddressAutoconfigDefault = types.BoolValue(true)
} else {
data.Ipv6AddressAutoconfigDefault = types.BoolValue(false)
}
- if value := res.Get(prefix + "ipv6.address.dhcp"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ipv6/address/dhcp"); value.Exists() {
data.Ipv6AddressDhcp = types.BoolValue(true)
} else {
data.Ipv6AddressDhcp = types.BoolValue(false)
}
- if value := res.Get(prefix + "ipv6.address.link-local-address"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ipv6/address/link-local-address"); value.Exists() {
data.Ipv6LinkLocalAddresses = make([]InterfaceVLANIpv6LinkLocalAddresses, 0)
- value.ForEach(func(k, v gjson.Result) bool {
+ value.ForEach(func(_ int, v xmldot.Result) bool {
item := InterfaceVLANIpv6LinkLocalAddresses{}
- if cValue := v.Get("address"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "address"); cValue.Exists() {
item.Address = types.StringValue(cValue.String())
}
- if cValue := v.Get("link-local"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "link-local"); cValue.Exists() {
item.LinkLocal = types.BoolValue(true)
} else {
item.LinkLocal = types.BoolValue(false)
@@ -952,14 +1808,14 @@ func (data *InterfaceVLANData) fromBody(ctx context.Context, res gjson.Result) {
return true
})
}
- if value := res.Get(prefix + "ipv6.address.prefix-list"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ipv6/address/prefix-list"); value.Exists() {
data.Ipv6Addresses = make([]InterfaceVLANIpv6Addresses, 0)
- value.ForEach(func(k, v gjson.Result) bool {
+ value.ForEach(func(_ int, v xmldot.Result) bool {
item := InterfaceVLANIpv6Addresses{}
- if cValue := v.Get("prefix"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "prefix"); cValue.Exists() {
item.Prefix = types.StringValue(cValue.String())
}
- if cValue := v.Get("eui-64"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "eui-64"); cValue.Exists() {
item.Eui64 = types.BoolValue(true)
} else {
item.Eui64 = types.BoolValue(false)
@@ -968,15 +1824,15 @@ func (data *InterfaceVLANData) fromBody(ctx context.Context, res gjson.Result) {
return true
})
}
- if value := res.Get(prefix + "load-interval"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/load-interval"); value.Exists() {
data.LoadInterval = types.Int64Value(value.Int())
}
- if value := res.Get(prefix + "mac-address"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/mac-address"); value.Exists() {
data.MacAddress = types.StringValue(value.String())
}
}
-// End of section. //template:end fromBodyData
+// End of section. //template:end fromBodyDataXML
// Section below is generated&owned by "gen/generator.go". //template:begin getDeletedItems
@@ -1162,6 +2018,205 @@ func (data *InterfaceVLAN) getDeletedItems(ctx context.Context, state InterfaceV
// End of section. //template:end getDeletedItems
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletedItemsXML
+
+func (data *InterfaceVLAN) addDeletedItemsXML(ctx context.Context, state InterfaceVLAN, body string) string {
+ b := netconf.NewBody(body)
+ if !state.Autostate.IsNull() && data.Autostate.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/autostate")
+ }
+ if !state.Description.IsNull() && data.Description.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/description")
+ }
+ if !state.Shutdown.IsNull() && data.Shutdown.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/shutdown")
+ }
+ if !state.IpProxyArp.IsNull() && data.IpProxyArp.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ip/proxy-arp")
+ }
+ if !state.IpRedirects.IsNull() && data.IpRedirects.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ip/redirects")
+ }
+ if !state.IpUnreachables.IsNull() && data.IpUnreachables.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ip/Cisco-IOS-XE-icmp:unreachables")
+ }
+ if !state.VrfForwarding.IsNull() && data.VrfForwarding.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/vrf/forwarding")
+ }
+ if !state.Ipv4Address.IsNull() && data.Ipv4Address.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ip/address/primary/address")
+ }
+ if !state.Ipv4AddressMask.IsNull() && data.Ipv4AddressMask.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ip/address/primary/mask")
+ }
+ if !state.Unnumbered.IsNull() && data.Unnumbered.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ip/unnumbered")
+ }
+ if !state.IpDhcpRelaySourceInterface.IsNull() && data.IpDhcpRelaySourceInterface.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ip/dhcp/Cisco-IOS-XE-dhcp:relay/source-interface")
+ }
+ if !state.IpAccessGroupInEnable.IsNull() && data.IpAccessGroupInEnable.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ip/access-group/in/acl/in")
+ }
+ if !state.IpAccessGroupIn.IsNull() && data.IpAccessGroupIn.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ip/access-group/in/acl/acl-name")
+ }
+ if !state.IpAccessGroupOutEnable.IsNull() && data.IpAccessGroupOutEnable.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ip/access-group/out/acl/out")
+ }
+ if !state.IpAccessGroupOut.IsNull() && data.IpAccessGroupOut.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ip/access-group/out/acl/acl-name")
+ }
+ for i := range state.HelperAddresses {
+ stateKeys := [...]string{"address"}
+ stateKeyValues := [...]string{state.HelperAddresses[i].Address.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.HelperAddresses[i].Address.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.HelperAddresses {
+ found = true
+ if state.HelperAddresses[i].Address.ValueString() != data.HelperAddresses[j].Address.ValueString() {
+ found = false
+ }
+ if found {
+ if !state.HelperAddresses[i].Global.IsNull() && data.HelperAddresses[j].Global.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/ip/helper-address%v/global", predicates))
+ }
+ if !state.HelperAddresses[i].Vrf.IsNull() && data.HelperAddresses[j].Vrf.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/ip/helper-address%v/vrf", predicates))
+ }
+ break
+ }
+ }
+ if !found {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/ip/helper-address%v", predicates))
+ }
+ }
+ if !state.BfdTemplate.IsNull() && data.BfdTemplate.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/bfd/Cisco-IOS-XE-bfd:template")
+ }
+ if !state.BfdEnable.IsNull() && data.BfdEnable.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/bfd/Cisco-IOS-XE-bfd:enable")
+ }
+ if !state.BfdLocalAddress.IsNull() && data.BfdLocalAddress.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/bfd/Cisco-IOS-XE-bfd:local-address")
+ }
+ if !state.BfdInterval.IsNull() && data.BfdInterval.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/bfd/Cisco-IOS-XE-bfd:interval-interface/msecs")
+ }
+ if !state.BfdIntervalMinRx.IsNull() && data.BfdIntervalMinRx.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/bfd/Cisco-IOS-XE-bfd:interval-interface/min_rx")
+ }
+ if !state.BfdIntervalMultiplier.IsNull() && data.BfdIntervalMultiplier.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/bfd/Cisco-IOS-XE-bfd:interval-interface/multiplier")
+ }
+ if !state.BfdEcho.IsNull() && data.BfdEcho.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/bfd/Cisco-IOS-XE-bfd:echo")
+ }
+ if !state.Ipv6Enable.IsNull() && data.Ipv6Enable.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ipv6/enable")
+ }
+ if !state.Ipv6Mtu.IsNull() && data.Ipv6Mtu.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ipv6/mtu")
+ }
+ if !state.Ipv6NdRaSuppressAll.IsNull() && data.Ipv6NdRaSuppressAll.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ipv6/nd/Cisco-IOS-XE-nd:ra/suppress/all")
+ }
+ if !state.Ipv6AddressAutoconfigDefault.IsNull() && data.Ipv6AddressAutoconfigDefault.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ipv6/address/autoconfig/default")
+ }
+ if !state.Ipv6AddressDhcp.IsNull() && data.Ipv6AddressDhcp.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ipv6/address/dhcp")
+ }
+ for i := range state.Ipv6LinkLocalAddresses {
+ stateKeys := [...]string{"address"}
+ stateKeyValues := [...]string{state.Ipv6LinkLocalAddresses[i].Address.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.Ipv6LinkLocalAddresses[i].Address.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.Ipv6LinkLocalAddresses {
+ found = true
+ if state.Ipv6LinkLocalAddresses[i].Address.ValueString() != data.Ipv6LinkLocalAddresses[j].Address.ValueString() {
+ found = false
+ }
+ if found {
+ if !state.Ipv6LinkLocalAddresses[i].LinkLocal.IsNull() && data.Ipv6LinkLocalAddresses[j].LinkLocal.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/ipv6/address/link-local-address%v/link-local", predicates))
+ }
+ break
+ }
+ }
+ if !found {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/ipv6/address/link-local-address%v", predicates))
+ }
+ }
+ for i := range state.Ipv6Addresses {
+ stateKeys := [...]string{"prefix"}
+ stateKeyValues := [...]string{state.Ipv6Addresses[i].Prefix.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.Ipv6Addresses[i].Prefix.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.Ipv6Addresses {
+ found = true
+ if state.Ipv6Addresses[i].Prefix.ValueString() != data.Ipv6Addresses[j].Prefix.ValueString() {
+ found = false
+ }
+ if found {
+ if !state.Ipv6Addresses[i].Eui64.IsNull() && data.Ipv6Addresses[j].Eui64.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/ipv6/address/prefix-list%v/eui-64", predicates))
+ }
+ break
+ }
+ }
+ if !found {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/ipv6/address/prefix-list%v", predicates))
+ }
+ }
+ if !state.LoadInterval.IsNull() && data.LoadInterval.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/load-interval")
+ }
+ if !state.MacAddress.IsNull() && data.MacAddress.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/mac-address")
+ }
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletedItemsXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin getEmptyLeafsDelete
func (data *InterfaceVLAN) getEmptyLeafsDelete(ctx context.Context) []string {
@@ -1325,3 +2380,130 @@ func (data *InterfaceVLAN) getDeletePaths(ctx context.Context) []string {
}
// End of section. //template:end getDeletePaths
+
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletePathsXML
+
+func (data *InterfaceVLAN) addDeletePathsXML(ctx context.Context, body string) string {
+ b := netconf.NewBody(body)
+ if !data.Autostate.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/autostate")
+ }
+ if !data.Description.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/description")
+ }
+ if !data.Shutdown.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/shutdown")
+ }
+ if !data.IpProxyArp.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ip/proxy-arp")
+ }
+ if !data.IpRedirects.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ip/redirects")
+ }
+ if !data.IpUnreachables.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ip/Cisco-IOS-XE-icmp:unreachables")
+ }
+ if !data.VrfForwarding.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/vrf/forwarding")
+ }
+ if !data.Ipv4Address.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ip/address/primary/address")
+ }
+ if !data.Ipv4AddressMask.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ip/address/primary/mask")
+ }
+ if !data.Unnumbered.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ip/unnumbered")
+ }
+ if !data.IpDhcpRelaySourceInterface.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ip/dhcp/Cisco-IOS-XE-dhcp:relay/source-interface")
+ }
+ if !data.IpAccessGroupInEnable.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ip/access-group/in/acl/in")
+ }
+ if !data.IpAccessGroupIn.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ip/access-group/in/acl/acl-name")
+ }
+ if !data.IpAccessGroupOutEnable.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ip/access-group/out/acl/out")
+ }
+ if !data.IpAccessGroupOut.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ip/access-group/out/acl/acl-name")
+ }
+ for i := range data.HelperAddresses {
+ keys := [...]string{"address"}
+ keyValues := [...]string{data.HelperAddresses[i].Address.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/ip/helper-address%v", predicates))
+ }
+ if !data.BfdTemplate.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/bfd/Cisco-IOS-XE-bfd:template")
+ }
+ if !data.BfdEnable.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/bfd/Cisco-IOS-XE-bfd:enable")
+ }
+ if !data.BfdLocalAddress.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/bfd/Cisco-IOS-XE-bfd:local-address")
+ }
+ if !data.BfdInterval.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/bfd/Cisco-IOS-XE-bfd:interval-interface/msecs")
+ }
+ if !data.BfdIntervalMinRx.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/bfd/Cisco-IOS-XE-bfd:interval-interface/min_rx")
+ }
+ if !data.BfdIntervalMultiplier.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/bfd/Cisco-IOS-XE-bfd:interval-interface/multiplier")
+ }
+ if !data.BfdEcho.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/bfd/Cisco-IOS-XE-bfd:echo")
+ }
+ if !data.Ipv6Enable.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ipv6/enable")
+ }
+ if !data.Ipv6Mtu.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ipv6/mtu")
+ }
+ if !data.Ipv6NdRaSuppressAll.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ipv6/nd/Cisco-IOS-XE-nd:ra/suppress/all")
+ }
+ if !data.Ipv6AddressAutoconfigDefault.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ipv6/address/autoconfig/default")
+ }
+ if !data.Ipv6AddressDhcp.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ipv6/address/dhcp")
+ }
+ for i := range data.Ipv6LinkLocalAddresses {
+ keys := [...]string{"address"}
+ keyValues := [...]string{data.Ipv6LinkLocalAddresses[i].Address.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/ipv6/address/link-local-address%v", predicates))
+ }
+ for i := range data.Ipv6Addresses {
+ keys := [...]string{"prefix"}
+ keyValues := [...]string{data.Ipv6Addresses[i].Prefix.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/ipv6/address/prefix-list%v", predicates))
+ }
+ if !data.LoadInterval.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/load-interval")
+ }
+ if !data.MacAddress.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/mac-address")
+ }
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletePathsXML
diff --git a/internal/provider/model_iosxe_license.go b/internal/provider/model_iosxe_license.go
index cfaa2d4e..5495bd70 100644
--- a/internal/provider/model_iosxe_license.go
+++ b/internal/provider/model_iosxe_license.go
@@ -28,6 +28,9 @@ import (
"github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/types"
+ "github.com/hashicorp/terraform-plugin-log/tflog"
+ "github.com/netascode/go-netconf"
+ "github.com/netascode/xmldot"
"github.com/tidwall/gjson"
"github.com/tidwall/sjson"
)
@@ -101,6 +104,17 @@ func (data License) getPathShort() string {
return matches[1]
}
+// getXPath returns the XPath for NETCONF operations
+func (data License) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/license"
+ return path
+}
+
+func (data LicenseData) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/license"
+ return path
+}
+
// End of section. //template:end getPath
// Section below is generated&owned by "gen/generator.go". //template:begin toBody
@@ -172,6 +186,91 @@ func (data License) toBody(ctx context.Context) string {
// End of section. //template:end toBody
+// Section below is generated&owned by "gen/generator.go". //template:begin toBodyXML
+
+func (data License) toBodyXML(ctx context.Context) string {
+ body := netconf.Body{}
+ if !data.BootLevelNetworkAdvantage.IsNull() && !data.BootLevelNetworkAdvantage.IsUnknown() {
+ if data.BootLevelNetworkAdvantage.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/boot/level/network-advantage", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/boot/level/network-advantage")
+ }
+ }
+ if !data.BootLevelNetworkAdvantageAddon.IsNull() && !data.BootLevelNetworkAdvantageAddon.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/boot/level/network-advantage/addon", data.BootLevelNetworkAdvantageAddon.ValueString())
+ }
+ if !data.BootLevelNetworkEssentials.IsNull() && !data.BootLevelNetworkEssentials.IsUnknown() {
+ if data.BootLevelNetworkEssentials.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/boot/level/network-essentials", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/boot/level/network-essentials")
+ }
+ }
+ if !data.BootLevelNetworkEssentialsAddon.IsNull() && !data.BootLevelNetworkEssentialsAddon.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/boot/level/network-essentials/addon", data.BootLevelNetworkEssentialsAddon.ValueString())
+ }
+ if !data.SmartTransportType.IsNull() && !data.SmartTransportType.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/smart/transport-type", data.SmartTransportType.ValueString())
+ }
+ if !data.SmartUrlCslu.IsNull() && !data.SmartUrlCslu.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/smart/url/cslu", data.SmartUrlCslu.ValueString())
+ }
+ if !data.AcceptAgreement.IsNull() && !data.AcceptAgreement.IsUnknown() {
+ if data.AcceptAgreement.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/accept/agreement", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/accept/agreement")
+ }
+ }
+ if !data.AcceptEnd.IsNull() && !data.AcceptEnd.IsUnknown() {
+ if data.AcceptEnd.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/accept/end", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/accept/end")
+ }
+ }
+ if !data.AcceptUser.IsNull() && !data.AcceptUser.IsUnknown() {
+ if data.AcceptUser.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/accept/user", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/accept/user")
+ }
+ }
+ if !data.UdiPid.IsNull() && !data.UdiPid.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/udi/pid", data.UdiPid.ValueString())
+ }
+ if !data.UdiSn.IsNull() && !data.UdiSn.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/udi/sn", data.UdiSn.ValueString())
+ }
+ if !data.FeatureName.IsNull() && !data.FeatureName.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/feature/name", data.FeatureName.ValueString())
+ }
+ if !data.FeaturePortBulk.IsNull() && !data.FeaturePortBulk.IsUnknown() {
+ if data.FeaturePortBulk.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/feature/port/bulk", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/feature/port/bulk")
+ }
+ }
+ if !data.FeaturePortOnegig.IsNull() && !data.FeaturePortOnegig.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/feature/port/onegig", strconv.FormatInt(data.FeaturePortOnegig.ValueInt64(), 10))
+ }
+ if !data.FeaturePortB6xonegig.IsNull() && !data.FeaturePortB6xonegig.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/feature/port/b-6xonegig", strconv.FormatInt(data.FeaturePortB6xonegig.ValueInt64(), 10))
+ }
+ if !data.FeaturePortTengig.IsNull() && !data.FeaturePortTengig.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/feature/port/tengig", strconv.FormatInt(data.FeaturePortTengig.ValueInt64(), 10))
+ }
+ bodyString, err := body.String()
+ if err != nil {
+ tflog.Error(ctx, fmt.Sprintf("Error converting body to string: %s", err))
+ }
+ return bodyString
+}
+
+// End of section. //template:end toBodyXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBody
func (data *License) updateFromBody(ctx context.Context, res gjson.Result) {
@@ -287,6 +386,117 @@ func (data *License) updateFromBody(ctx context.Context, res gjson.Result) {
// End of section. //template:end updateFromBody
+// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBodyXML
+
+func (data *License) updateFromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/boot/level/network-advantage"); !data.BootLevelNetworkAdvantage.IsNull() {
+ if value.Exists() {
+ data.BootLevelNetworkAdvantage = types.BoolValue(true)
+ } else {
+ data.BootLevelNetworkAdvantage = types.BoolValue(false)
+ }
+ } else {
+ data.BootLevelNetworkAdvantage = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/boot/level/network-advantage/addon"); value.Exists() && !data.BootLevelNetworkAdvantageAddon.IsNull() {
+ data.BootLevelNetworkAdvantageAddon = types.StringValue(value.String())
+ } else {
+ data.BootLevelNetworkAdvantageAddon = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/boot/level/network-essentials"); !data.BootLevelNetworkEssentials.IsNull() {
+ if value.Exists() {
+ data.BootLevelNetworkEssentials = types.BoolValue(true)
+ } else {
+ data.BootLevelNetworkEssentials = types.BoolValue(false)
+ }
+ } else {
+ data.BootLevelNetworkEssentials = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/boot/level/network-essentials/addon"); value.Exists() && !data.BootLevelNetworkEssentialsAddon.IsNull() {
+ data.BootLevelNetworkEssentialsAddon = types.StringValue(value.String())
+ } else {
+ data.BootLevelNetworkEssentialsAddon = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/smart/transport-type"); value.Exists() && !data.SmartTransportType.IsNull() {
+ data.SmartTransportType = types.StringValue(value.String())
+ } else {
+ data.SmartTransportType = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/smart/url/cslu"); value.Exists() && !data.SmartUrlCslu.IsNull() {
+ data.SmartUrlCslu = types.StringValue(value.String())
+ } else {
+ data.SmartUrlCslu = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/accept/agreement"); !data.AcceptAgreement.IsNull() {
+ if value.Exists() {
+ data.AcceptAgreement = types.BoolValue(true)
+ } else {
+ data.AcceptAgreement = types.BoolValue(false)
+ }
+ } else {
+ data.AcceptAgreement = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/accept/end"); !data.AcceptEnd.IsNull() {
+ if value.Exists() {
+ data.AcceptEnd = types.BoolValue(true)
+ } else {
+ data.AcceptEnd = types.BoolValue(false)
+ }
+ } else {
+ data.AcceptEnd = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/accept/user"); !data.AcceptUser.IsNull() {
+ if value.Exists() {
+ data.AcceptUser = types.BoolValue(true)
+ } else {
+ data.AcceptUser = types.BoolValue(false)
+ }
+ } else {
+ data.AcceptUser = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/udi/pid"); value.Exists() && !data.UdiPid.IsNull() {
+ data.UdiPid = types.StringValue(value.String())
+ } else {
+ data.UdiPid = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/udi/sn"); value.Exists() && !data.UdiSn.IsNull() {
+ data.UdiSn = types.StringValue(value.String())
+ } else {
+ data.UdiSn = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/feature/name"); value.Exists() && !data.FeatureName.IsNull() {
+ data.FeatureName = types.StringValue(value.String())
+ } else {
+ data.FeatureName = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/feature/port/bulk"); !data.FeaturePortBulk.IsNull() {
+ if value.Exists() {
+ data.FeaturePortBulk = types.BoolValue(true)
+ } else {
+ data.FeaturePortBulk = types.BoolValue(false)
+ }
+ } else {
+ data.FeaturePortBulk = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/feature/port/onegig"); value.Exists() && !data.FeaturePortOnegig.IsNull() {
+ data.FeaturePortOnegig = types.Int64Value(value.Int())
+ } else {
+ data.FeaturePortOnegig = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/feature/port/b-6xonegig"); value.Exists() && !data.FeaturePortB6xonegig.IsNull() {
+ data.FeaturePortB6xonegig = types.Int64Value(value.Int())
+ } else {
+ data.FeaturePortB6xonegig = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/feature/port/tengig"); value.Exists() && !data.FeaturePortTengig.IsNull() {
+ data.FeaturePortTengig = types.Int64Value(value.Int())
+ } else {
+ data.FeaturePortTengig = types.Int64Null()
+ }
+}
+
+// End of section. //template:end updateFromBodyXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin fromBody
func (data *License) fromBody(ctx context.Context, res gjson.Result) {
@@ -429,6 +639,140 @@ func (data *LicenseData) fromBody(ctx context.Context, res gjson.Result) {
// End of section. //template:end fromBodyData
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyXML
+
+func (data *License) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/boot/level/network-advantage"); value.Exists() {
+ data.BootLevelNetworkAdvantage = types.BoolValue(true)
+ } else {
+ data.BootLevelNetworkAdvantage = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/boot/level/network-advantage/addon"); value.Exists() {
+ data.BootLevelNetworkAdvantageAddon = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/boot/level/network-essentials"); value.Exists() {
+ data.BootLevelNetworkEssentials = types.BoolValue(true)
+ } else {
+ data.BootLevelNetworkEssentials = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/boot/level/network-essentials/addon"); value.Exists() {
+ data.BootLevelNetworkEssentialsAddon = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/smart/transport-type"); value.Exists() {
+ data.SmartTransportType = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/smart/url/cslu"); value.Exists() {
+ data.SmartUrlCslu = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/accept/agreement"); value.Exists() {
+ data.AcceptAgreement = types.BoolValue(true)
+ } else {
+ data.AcceptAgreement = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/accept/end"); value.Exists() {
+ data.AcceptEnd = types.BoolValue(true)
+ } else {
+ data.AcceptEnd = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/accept/user"); value.Exists() {
+ data.AcceptUser = types.BoolValue(true)
+ } else {
+ data.AcceptUser = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/udi/pid"); value.Exists() {
+ data.UdiPid = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/udi/sn"); value.Exists() {
+ data.UdiSn = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/feature/name"); value.Exists() {
+ data.FeatureName = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/feature/port/bulk"); value.Exists() {
+ data.FeaturePortBulk = types.BoolValue(true)
+ } else {
+ data.FeaturePortBulk = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/feature/port/onegig"); value.Exists() {
+ data.FeaturePortOnegig = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/feature/port/b-6xonegig"); value.Exists() {
+ data.FeaturePortB6xonegig = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/feature/port/tengig"); value.Exists() {
+ data.FeaturePortTengig = types.Int64Value(value.Int())
+ }
+}
+
+// End of section. //template:end fromBodyXML
+
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyDataXML
+
+func (data *LicenseData) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/boot/level/network-advantage"); value.Exists() {
+ data.BootLevelNetworkAdvantage = types.BoolValue(true)
+ } else {
+ data.BootLevelNetworkAdvantage = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/boot/level/network-advantage/addon"); value.Exists() {
+ data.BootLevelNetworkAdvantageAddon = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/boot/level/network-essentials"); value.Exists() {
+ data.BootLevelNetworkEssentials = types.BoolValue(true)
+ } else {
+ data.BootLevelNetworkEssentials = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/boot/level/network-essentials/addon"); value.Exists() {
+ data.BootLevelNetworkEssentialsAddon = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/smart/transport-type"); value.Exists() {
+ data.SmartTransportType = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/smart/url/cslu"); value.Exists() {
+ data.SmartUrlCslu = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/accept/agreement"); value.Exists() {
+ data.AcceptAgreement = types.BoolValue(true)
+ } else {
+ data.AcceptAgreement = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/accept/end"); value.Exists() {
+ data.AcceptEnd = types.BoolValue(true)
+ } else {
+ data.AcceptEnd = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/accept/user"); value.Exists() {
+ data.AcceptUser = types.BoolValue(true)
+ } else {
+ data.AcceptUser = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/udi/pid"); value.Exists() {
+ data.UdiPid = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/udi/sn"); value.Exists() {
+ data.UdiSn = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/feature/name"); value.Exists() {
+ data.FeatureName = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/feature/port/bulk"); value.Exists() {
+ data.FeaturePortBulk = types.BoolValue(true)
+ } else {
+ data.FeaturePortBulk = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/feature/port/onegig"); value.Exists() {
+ data.FeaturePortOnegig = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/feature/port/b-6xonegig"); value.Exists() {
+ data.FeaturePortB6xonegig = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/feature/port/tengig"); value.Exists() {
+ data.FeaturePortTengig = types.Int64Value(value.Int())
+ }
+}
+
+// End of section. //template:end fromBodyDataXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin getDeletedItems
func (data *License) getDeletedItems(ctx context.Context, state License) []string {
@@ -487,6 +831,64 @@ func (data *License) getDeletedItems(ctx context.Context, state License) []strin
// End of section. //template:end getDeletedItems
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletedItemsXML
+
+func (data *License) addDeletedItemsXML(ctx context.Context, state License, body string) string {
+ b := netconf.NewBody(body)
+ if !state.BootLevelNetworkAdvantage.IsNull() && data.BootLevelNetworkAdvantage.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/boot/level/network-advantage")
+ }
+ if !state.BootLevelNetworkAdvantageAddon.IsNull() && data.BootLevelNetworkAdvantageAddon.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/boot/level/network-advantage/addon")
+ }
+ if !state.BootLevelNetworkEssentials.IsNull() && data.BootLevelNetworkEssentials.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/boot/level/network-essentials")
+ }
+ if !state.BootLevelNetworkEssentialsAddon.IsNull() && data.BootLevelNetworkEssentialsAddon.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/boot/level/network-essentials/addon")
+ }
+ if !state.SmartTransportType.IsNull() && data.SmartTransportType.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/smart/transport-type")
+ }
+ if !state.SmartUrlCslu.IsNull() && data.SmartUrlCslu.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/smart/url/cslu")
+ }
+ if !state.AcceptAgreement.IsNull() && data.AcceptAgreement.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/accept/agreement")
+ }
+ if !state.AcceptEnd.IsNull() && data.AcceptEnd.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/accept/end")
+ }
+ if !state.AcceptUser.IsNull() && data.AcceptUser.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/accept/user")
+ }
+ if !state.UdiPid.IsNull() && data.UdiPid.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/udi/pid")
+ }
+ if !state.UdiSn.IsNull() && data.UdiSn.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/udi/sn")
+ }
+ if !state.FeatureName.IsNull() && data.FeatureName.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/feature/name")
+ }
+ if !state.FeaturePortBulk.IsNull() && data.FeaturePortBulk.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/feature/port/bulk")
+ }
+ if !state.FeaturePortOnegig.IsNull() && data.FeaturePortOnegig.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/feature/port/onegig")
+ }
+ if !state.FeaturePortB6xonegig.IsNull() && data.FeaturePortB6xonegig.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/feature/port/b-6xonegig")
+ }
+ if !state.FeaturePortTengig.IsNull() && data.FeaturePortTengig.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/feature/port/tengig")
+ }
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletedItemsXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin getEmptyLeafsDelete
func (data *License) getEmptyLeafsDelete(ctx context.Context) []string {
@@ -572,3 +974,61 @@ func (data *License) getDeletePaths(ctx context.Context) []string {
}
// End of section. //template:end getDeletePaths
+
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletePathsXML
+
+func (data *License) addDeletePathsXML(ctx context.Context, body string) string {
+ b := netconf.NewBody(body)
+ if !data.BootLevelNetworkAdvantage.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/boot/level/network-advantage")
+ }
+ if !data.BootLevelNetworkAdvantageAddon.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/boot/level/network-advantage/addon")
+ }
+ if !data.BootLevelNetworkEssentials.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/boot/level/network-essentials")
+ }
+ if !data.BootLevelNetworkEssentialsAddon.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/boot/level/network-essentials/addon")
+ }
+ if !data.SmartTransportType.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/smart/transport-type")
+ }
+ if !data.SmartUrlCslu.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/smart/url/cslu")
+ }
+ if !data.AcceptAgreement.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/accept/agreement")
+ }
+ if !data.AcceptEnd.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/accept/end")
+ }
+ if !data.AcceptUser.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/accept/user")
+ }
+ if !data.UdiPid.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/udi/pid")
+ }
+ if !data.UdiSn.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/udi/sn")
+ }
+ if !data.FeatureName.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/feature/name")
+ }
+ if !data.FeaturePortBulk.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/feature/port/bulk")
+ }
+ if !data.FeaturePortOnegig.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/feature/port/onegig")
+ }
+ if !data.FeaturePortB6xonegig.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/feature/port/b-6xonegig")
+ }
+ if !data.FeaturePortTengig.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/feature/port/tengig")
+ }
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletePathsXML
diff --git a/internal/provider/model_iosxe_line.go b/internal/provider/model_iosxe_line.go
index 0564043b..c2867d21 100644
--- a/internal/provider/model_iosxe_line.go
+++ b/internal/provider/model_iosxe_line.go
@@ -30,6 +30,9 @@ import (
"github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/types"
+ "github.com/hashicorp/terraform-plugin-log/tflog"
+ "github.com/netascode/go-netconf"
+ "github.com/netascode/xmldot"
"github.com/tidwall/gjson"
"github.com/tidwall/sjson"
)
@@ -133,6 +136,17 @@ func (data Line) getPathShort() string {
return matches[1]
}
+// getXPath returns the XPath for NETCONF operations
+func (data Line) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/line"
+ return path
+}
+
+func (data LineData) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/line"
+ return path
+}
+
// End of section. //template:end getPath
// Section below is generated&owned by "gen/generator.go". //template:begin toBody
@@ -341,6 +355,256 @@ func (data Line) toBody(ctx context.Context) string {
// End of section. //template:end toBody
+// Section below is generated&owned by "gen/generator.go". //template:begin toBodyXML
+
+func (data Line) toBodyXML(ctx context.Context) string {
+ body := netconf.Body{}
+ if len(data.Console) > 0 {
+ for _, item := range data.Console {
+ cBody := netconf.Body{}
+ if !item.First.IsNull() && !item.First.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "first", item.First.ValueString())
+ }
+ if !item.ExecTimeoutMinutes.IsNull() && !item.ExecTimeoutMinutes.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "exec-timeout/minutes", strconv.FormatInt(item.ExecTimeoutMinutes.ValueInt64(), 10))
+ }
+ if !item.ExecTimeoutSeconds.IsNull() && !item.ExecTimeoutSeconds.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "exec-timeout/seconds", strconv.FormatInt(item.ExecTimeoutSeconds.ValueInt64(), 10))
+ }
+ if !item.LoginLocal.IsNull() && !item.LoginLocal.IsUnknown() {
+ if item.LoginLocal.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "login/local", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "login/local")
+ }
+ }
+ if !item.LoginAuthentication.IsNull() && !item.LoginAuthentication.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "login/authentication", item.LoginAuthentication.ValueString())
+ }
+ if !item.PrivilegeLevel.IsNull() && !item.PrivilegeLevel.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "privilege/level/number", strconv.FormatInt(item.PrivilegeLevel.ValueInt64(), 10))
+ }
+ if !item.Stopbits.IsNull() && !item.Stopbits.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "stopbits", item.Stopbits.ValueString())
+ }
+ if !item.PasswordLevel.IsNull() && !item.PasswordLevel.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "password/level", strconv.FormatInt(item.PasswordLevel.ValueInt64(), 10))
+ }
+ if !item.PasswordType.IsNull() && !item.PasswordType.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "password/type", item.PasswordType.ValueString())
+ }
+ if !item.Password.IsNull() && !item.Password.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "password/secret", item.Password.ValueString())
+ }
+ if !item.EscapeCharacter.IsNull() && !item.EscapeCharacter.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "escape-character/char", item.EscapeCharacter.ValueString())
+ }
+ if !item.LoggingSynchronous.IsNull() && !item.LoggingSynchronous.IsUnknown() {
+ if item.LoggingSynchronous.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "logging/synchronous", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "logging/synchronous")
+ }
+ }
+ if !item.TransportOutputAll.IsNull() && !item.TransportOutputAll.IsUnknown() {
+ if item.TransportOutputAll.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "transport/output/all", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "transport/output/all")
+ }
+ }
+ if !item.TransportOutputNone.IsNull() && !item.TransportOutputNone.IsUnknown() {
+ if item.TransportOutputNone.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "transport/output/none", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "transport/output/none")
+ }
+ }
+ if !item.TransportOutput.IsNull() && !item.TransportOutput.IsUnknown() {
+ var values []string
+ item.TransportOutput.ElementsAs(ctx, &values, false)
+ for _, v := range values {
+ cBody = helpers.AppendFromXPath(cBody, "transport/output/output", v)
+ }
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/console", cBody.Res())
+ }
+ }
+ if len(data.Vty) > 0 {
+ for _, item := range data.Vty {
+ cBody := netconf.Body{}
+ if !item.First.IsNull() && !item.First.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "first", strconv.FormatInt(item.First.ValueInt64(), 10))
+ }
+ if !item.Last.IsNull() && !item.Last.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "last", strconv.FormatInt(item.Last.ValueInt64(), 10))
+ }
+ if len(item.AccessClasses) > 0 {
+ for _, citem := range item.AccessClasses {
+ ccBody := netconf.Body{}
+ if !citem.Direction.IsNull() && !citem.Direction.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "direction", citem.Direction.ValueString())
+ }
+ if !citem.AccessList.IsNull() && !citem.AccessList.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "access-list", citem.AccessList.ValueString())
+ }
+ if !citem.VrfAlso.IsNull() && !citem.VrfAlso.IsUnknown() {
+ if citem.VrfAlso.ValueBool() {
+ ccBody = helpers.SetFromXPath(ccBody, "vrf-also", "")
+ } else {
+ ccBody = helpers.RemoveFromXPath(ccBody, "vrf-also")
+ }
+ }
+ cBody = helpers.SetRawFromXPath(cBody, "access-class/acccess-list", ccBody.Res())
+ }
+ }
+ if !item.ExecTimeoutMinutes.IsNull() && !item.ExecTimeoutMinutes.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "exec-timeout/minutes", strconv.FormatInt(item.ExecTimeoutMinutes.ValueInt64(), 10))
+ }
+ if !item.ExecTimeoutSeconds.IsNull() && !item.ExecTimeoutSeconds.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "exec-timeout/seconds", strconv.FormatInt(item.ExecTimeoutSeconds.ValueInt64(), 10))
+ }
+ if !item.PasswordLevel.IsNull() && !item.PasswordLevel.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "password/level", strconv.FormatInt(item.PasswordLevel.ValueInt64(), 10))
+ }
+ if !item.PasswordType.IsNull() && !item.PasswordType.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "password/type", item.PasswordType.ValueString())
+ }
+ if !item.Password.IsNull() && !item.Password.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "password/secret", item.Password.ValueString())
+ }
+ if !item.LoginAuthentication.IsNull() && !item.LoginAuthentication.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "login/authentication", item.LoginAuthentication.ValueString())
+ }
+ if !item.TransportPreferredProtocol.IsNull() && !item.TransportPreferredProtocol.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "transport/preferred/protocol", item.TransportPreferredProtocol.ValueString())
+ }
+ if !item.EscapeCharacter.IsNull() && !item.EscapeCharacter.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "escape-character/char", item.EscapeCharacter.ValueString())
+ }
+ if !item.AuthorizationExec.IsNull() && !item.AuthorizationExec.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "authorization/exec/authorization-name", item.AuthorizationExec.ValueString())
+ }
+ if !item.AuthorizationExecDefault.IsNull() && !item.AuthorizationExecDefault.IsUnknown() {
+ if item.AuthorizationExecDefault.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "authorization/exec/default", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "authorization/exec/default")
+ }
+ }
+ if !item.TransportInputAll.IsNull() && !item.TransportInputAll.IsUnknown() {
+ if item.TransportInputAll.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "transport/input/all", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "transport/input/all")
+ }
+ }
+ if !item.TransportInputNone.IsNull() && !item.TransportInputNone.IsUnknown() {
+ if item.TransportInputNone.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "transport/input/none", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "transport/input/none")
+ }
+ }
+ if !item.TransportInput.IsNull() && !item.TransportInput.IsUnknown() {
+ var values []string
+ item.TransportInput.ElementsAs(ctx, &values, false)
+ for _, v := range values {
+ cBody = helpers.AppendFromXPath(cBody, "transport/input/input", v)
+ }
+ }
+ if !item.Monitor.IsNull() && !item.Monitor.IsUnknown() {
+ if item.Monitor.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "monitor", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "monitor")
+ }
+ }
+ if !item.SessionTimeout.IsNull() && !item.SessionTimeout.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "session-timeout/session-timeout-value", strconv.FormatInt(item.SessionTimeout.ValueInt64(), 10))
+ }
+ if !item.Stopbits.IsNull() && !item.Stopbits.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "stopbits", item.Stopbits.ValueString())
+ }
+ if !item.LoggingSynchronous.IsNull() && !item.LoggingSynchronous.IsUnknown() {
+ if item.LoggingSynchronous.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "logging/synchronous", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "logging/synchronous")
+ }
+ }
+ if !item.TransportOutputAll.IsNull() && !item.TransportOutputAll.IsUnknown() {
+ if item.TransportOutputAll.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "transport/output/all", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "transport/output/all")
+ }
+ }
+ if !item.TransportOutputNone.IsNull() && !item.TransportOutputNone.IsUnknown() {
+ if item.TransportOutputNone.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "transport/output/none", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "transport/output/none")
+ }
+ }
+ if !item.TransportOutput.IsNull() && !item.TransportOutput.IsUnknown() {
+ var values []string
+ item.TransportOutput.ElementsAs(ctx, &values, false)
+ for _, v := range values {
+ cBody = helpers.AppendFromXPath(cBody, "transport/output/output", v)
+ }
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/vty", cBody.Res())
+ }
+ }
+ if len(data.Aux) > 0 {
+ for _, item := range data.Aux {
+ cBody := netconf.Body{}
+ if !item.First.IsNull() && !item.First.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "first", item.First.ValueString())
+ }
+ if !item.EscapeCharacter.IsNull() && !item.EscapeCharacter.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "escape-character/char", item.EscapeCharacter.ValueString())
+ }
+ if !item.LoggingSynchronous.IsNull() && !item.LoggingSynchronous.IsUnknown() {
+ if item.LoggingSynchronous.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "logging/synchronous", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "logging/synchronous")
+ }
+ }
+ if !item.ExecTimeoutMinutes.IsNull() && !item.ExecTimeoutMinutes.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "exec-timeout/minutes", strconv.FormatInt(item.ExecTimeoutMinutes.ValueInt64(), 10))
+ }
+ if !item.ExecTimeoutSeconds.IsNull() && !item.ExecTimeoutSeconds.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "exec-timeout/seconds", strconv.FormatInt(item.ExecTimeoutSeconds.ValueInt64(), 10))
+ }
+ if !item.Monitor.IsNull() && !item.Monitor.IsUnknown() {
+ if item.Monitor.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "monitor", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "monitor")
+ }
+ }
+ if !item.TransportOutputNone.IsNull() && !item.TransportOutputNone.IsUnknown() {
+ if item.TransportOutputNone.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "transport/output/none", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "transport/output/none")
+ }
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/aux", cBody.Res())
+ }
+ }
+ bodyString, err := body.String()
+ if err != nil {
+ tflog.Error(ctx, fmt.Sprintf("Error converting body to string: %s", err))
+ }
+ return bodyString
+}
+
+// End of section. //template:end toBodyXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBody
func (data *Line) updateFromBody(ctx context.Context, res gjson.Result) {
@@ -723,36 +987,634 @@ func (data *Line) updateFromBody(ctx context.Context, res gjson.Result) {
// End of section. //template:end updateFromBody
-// Section below is generated&owned by "gen/generator.go". //template:begin fromBody
+// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBodyXML
-func (data *Line) fromBody(ctx context.Context, res gjson.Result) {
- prefix := helpers.LastElement(data.getPath()) + "."
- if res.Get(helpers.LastElement(data.getPath())).IsArray() {
- prefix += "0."
- }
- if value := res.Get(prefix + "console"); value.Exists() {
- data.Console = make([]LineConsole, 0)
- value.ForEach(func(k, v gjson.Result) bool {
- item := LineConsole{}
- if cValue := v.Get("first"); cValue.Exists() {
- item.First = types.StringValue(cValue.String())
- }
- if cValue := v.Get("exec-timeout.minutes"); cValue.Exists() {
- item.ExecTimeoutMinutes = types.Int64Value(cValue.Int())
- }
- if cValue := v.Get("exec-timeout.seconds"); cValue.Exists() {
- item.ExecTimeoutSeconds = types.Int64Value(cValue.Int())
- }
- if cValue := v.Get("login.local"); cValue.Exists() {
- item.LoginLocal = types.BoolValue(true)
+func (data *Line) updateFromBodyXML(ctx context.Context, res xmldot.Result) {
+ for i := range data.Console {
+ keys := [...]string{"first"}
+ keyValues := [...]string{data.Console[i].First.ValueString()}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/console").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, "first"); value.Exists() && !data.Console[i].First.IsNull() {
+ data.Console[i].First = types.StringValue(value.String())
+ } else {
+ data.Console[i].First = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "exec-timeout/minutes"); value.Exists() && !data.Console[i].ExecTimeoutMinutes.IsNull() {
+ data.Console[i].ExecTimeoutMinutes = types.Int64Value(value.Int())
+ } else {
+ data.Console[i].ExecTimeoutMinutes = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(r, "exec-timeout/seconds"); value.Exists() && !data.Console[i].ExecTimeoutSeconds.IsNull() {
+ data.Console[i].ExecTimeoutSeconds = types.Int64Value(value.Int())
+ } else {
+ data.Console[i].ExecTimeoutSeconds = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(r, "login/local"); !data.Console[i].LoginLocal.IsNull() {
+ if value.Exists() {
+ data.Console[i].LoginLocal = types.BoolValue(true)
} else {
- item.LoginLocal = types.BoolValue(false)
+ data.Console[i].LoginLocal = types.BoolValue(false)
}
- if cValue := v.Get("login.authentication"); cValue.Exists() {
- item.LoginAuthentication = types.StringValue(cValue.String())
+ } else {
+ data.Console[i].LoginLocal = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "login/authentication"); value.Exists() && !data.Console[i].LoginAuthentication.IsNull() {
+ data.Console[i].LoginAuthentication = types.StringValue(value.String())
+ } else {
+ data.Console[i].LoginAuthentication = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "privilege/level/number"); value.Exists() && !data.Console[i].PrivilegeLevel.IsNull() {
+ data.Console[i].PrivilegeLevel = types.Int64Value(value.Int())
+ } else {
+ data.Console[i].PrivilegeLevel = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(r, "stopbits"); value.Exists() && !data.Console[i].Stopbits.IsNull() {
+ data.Console[i].Stopbits = types.StringValue(value.String())
+ } else {
+ data.Console[i].Stopbits = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "password/level"); value.Exists() && !data.Console[i].PasswordLevel.IsNull() {
+ data.Console[i].PasswordLevel = types.Int64Value(value.Int())
+ } else {
+ data.Console[i].PasswordLevel = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(r, "escape-character/char"); value.Exists() && !data.Console[i].EscapeCharacter.IsNull() {
+ data.Console[i].EscapeCharacter = types.StringValue(value.String())
+ } else {
+ data.Console[i].EscapeCharacter = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "logging/synchronous"); !data.Console[i].LoggingSynchronous.IsNull() {
+ if value.Exists() {
+ data.Console[i].LoggingSynchronous = types.BoolValue(true)
+ } else {
+ data.Console[i].LoggingSynchronous = types.BoolValue(false)
}
- if cValue := v.Get("privilege.level.number"); cValue.Exists() {
- item.PrivilegeLevel = types.Int64Value(cValue.Int())
+ } else {
+ data.Console[i].LoggingSynchronous = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "transport/output/all"); !data.Console[i].TransportOutputAll.IsNull() {
+ if value.Exists() {
+ data.Console[i].TransportOutputAll = types.BoolValue(true)
+ } else {
+ data.Console[i].TransportOutputAll = types.BoolValue(false)
+ }
+ } else {
+ data.Console[i].TransportOutputAll = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "transport/output/none"); !data.Console[i].TransportOutputNone.IsNull() {
+ if value.Exists() {
+ data.Console[i].TransportOutputNone = types.BoolValue(true)
+ } else {
+ data.Console[i].TransportOutputNone = types.BoolValue(false)
+ }
+ } else {
+ data.Console[i].TransportOutputNone = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "transport/output/output"); value.Exists() && !data.Console[i].TransportOutput.IsNull() {
+ data.Console[i].TransportOutput = helpers.GetStringListXML(value.Array())
+ } else {
+ data.Console[i].TransportOutput = types.ListNull(types.StringType)
+ }
+ }
+ for i := range data.Vty {
+ keys := [...]string{"first"}
+ keyValues := [...]string{strconv.FormatInt(data.Vty[i].First.ValueInt64(), 10)}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/vty").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, "first"); value.Exists() && !data.Vty[i].First.IsNull() {
+ data.Vty[i].First = types.Int64Value(value.Int())
+ } else {
+ data.Vty[i].First = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(r, "last"); value.Exists() && !data.Vty[i].Last.IsNull() {
+ data.Vty[i].Last = types.Int64Value(value.Int())
+ } else {
+ data.Vty[i].Last = types.Int64Null()
+ }
+ for ci := range data.Vty[i].AccessClasses {
+ keys := [...]string{"direction"}
+ keyValues := [...]string{data.Vty[i].AccessClasses[ci].Direction.ValueString()}
+
+ var cr xmldot.Result
+ helpers.GetFromXPath(r, "access-class/acccess-list").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ cr = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(cr, "direction"); value.Exists() && !data.Vty[i].AccessClasses[ci].Direction.IsNull() {
+ data.Vty[i].AccessClasses[ci].Direction = types.StringValue(value.String())
+ } else {
+ data.Vty[i].AccessClasses[ci].Direction = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(cr, "access-list"); value.Exists() && !data.Vty[i].AccessClasses[ci].AccessList.IsNull() {
+ data.Vty[i].AccessClasses[ci].AccessList = types.StringValue(value.String())
+ } else {
+ data.Vty[i].AccessClasses[ci].AccessList = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(cr, "vrf-also"); !data.Vty[i].AccessClasses[ci].VrfAlso.IsNull() {
+ if value.Exists() {
+ data.Vty[i].AccessClasses[ci].VrfAlso = types.BoolValue(true)
+ } else {
+ data.Vty[i].AccessClasses[ci].VrfAlso = types.BoolValue(false)
+ }
+ } else {
+ data.Vty[i].AccessClasses[ci].VrfAlso = types.BoolNull()
+ }
+ }
+ if value := helpers.GetFromXPath(r, "exec-timeout/minutes"); value.Exists() && !data.Vty[i].ExecTimeoutMinutes.IsNull() {
+ data.Vty[i].ExecTimeoutMinutes = types.Int64Value(value.Int())
+ } else {
+ data.Vty[i].ExecTimeoutMinutes = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(r, "exec-timeout/seconds"); value.Exists() && !data.Vty[i].ExecTimeoutSeconds.IsNull() {
+ data.Vty[i].ExecTimeoutSeconds = types.Int64Value(value.Int())
+ } else {
+ data.Vty[i].ExecTimeoutSeconds = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(r, "password/level"); value.Exists() && !data.Vty[i].PasswordLevel.IsNull() {
+ data.Vty[i].PasswordLevel = types.Int64Value(value.Int())
+ } else {
+ data.Vty[i].PasswordLevel = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(r, "login/authentication"); value.Exists() && !data.Vty[i].LoginAuthentication.IsNull() {
+ data.Vty[i].LoginAuthentication = types.StringValue(value.String())
+ } else {
+ data.Vty[i].LoginAuthentication = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "transport/preferred/protocol"); value.Exists() && !data.Vty[i].TransportPreferredProtocol.IsNull() {
+ data.Vty[i].TransportPreferredProtocol = types.StringValue(value.String())
+ } else {
+ data.Vty[i].TransportPreferredProtocol = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "escape-character/char"); value.Exists() && !data.Vty[i].EscapeCharacter.IsNull() {
+ data.Vty[i].EscapeCharacter = types.StringValue(value.String())
+ } else {
+ data.Vty[i].EscapeCharacter = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "authorization/exec/authorization-name"); value.Exists() && !data.Vty[i].AuthorizationExec.IsNull() {
+ data.Vty[i].AuthorizationExec = types.StringValue(value.String())
+ } else {
+ data.Vty[i].AuthorizationExec = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "authorization/exec/default"); !data.Vty[i].AuthorizationExecDefault.IsNull() {
+ if value.Exists() {
+ data.Vty[i].AuthorizationExecDefault = types.BoolValue(true)
+ } else {
+ data.Vty[i].AuthorizationExecDefault = types.BoolValue(false)
+ }
+ } else {
+ data.Vty[i].AuthorizationExecDefault = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "transport/input/all"); !data.Vty[i].TransportInputAll.IsNull() {
+ if value.Exists() {
+ data.Vty[i].TransportInputAll = types.BoolValue(true)
+ } else {
+ data.Vty[i].TransportInputAll = types.BoolValue(false)
+ }
+ } else {
+ data.Vty[i].TransportInputAll = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "transport/input/none"); !data.Vty[i].TransportInputNone.IsNull() {
+ if value.Exists() {
+ data.Vty[i].TransportInputNone = types.BoolValue(true)
+ } else {
+ data.Vty[i].TransportInputNone = types.BoolValue(false)
+ }
+ } else {
+ data.Vty[i].TransportInputNone = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "transport/input/input"); value.Exists() && !data.Vty[i].TransportInput.IsNull() {
+ data.Vty[i].TransportInput = helpers.GetStringListXML(value.Array())
+ } else {
+ data.Vty[i].TransportInput = types.ListNull(types.StringType)
+ }
+ if value := helpers.GetFromXPath(r, "monitor"); !data.Vty[i].Monitor.IsNull() {
+ if value.Exists() {
+ data.Vty[i].Monitor = types.BoolValue(true)
+ } else {
+ data.Vty[i].Monitor = types.BoolValue(false)
+ }
+ } else {
+ data.Vty[i].Monitor = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "session-timeout/session-timeout-value"); value.Exists() && !data.Vty[i].SessionTimeout.IsNull() {
+ data.Vty[i].SessionTimeout = types.Int64Value(value.Int())
+ } else {
+ data.Vty[i].SessionTimeout = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(r, "stopbits"); value.Exists() && !data.Vty[i].Stopbits.IsNull() {
+ data.Vty[i].Stopbits = types.StringValue(value.String())
+ } else {
+ data.Vty[i].Stopbits = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "logging/synchronous"); !data.Vty[i].LoggingSynchronous.IsNull() {
+ if value.Exists() {
+ data.Vty[i].LoggingSynchronous = types.BoolValue(true)
+ } else {
+ data.Vty[i].LoggingSynchronous = types.BoolValue(false)
+ }
+ } else {
+ data.Vty[i].LoggingSynchronous = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "transport/output/all"); !data.Vty[i].TransportOutputAll.IsNull() {
+ if value.Exists() {
+ data.Vty[i].TransportOutputAll = types.BoolValue(true)
+ } else {
+ data.Vty[i].TransportOutputAll = types.BoolValue(false)
+ }
+ } else {
+ data.Vty[i].TransportOutputAll = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "transport/output/none"); !data.Vty[i].TransportOutputNone.IsNull() {
+ if value.Exists() {
+ data.Vty[i].TransportOutputNone = types.BoolValue(true)
+ } else {
+ data.Vty[i].TransportOutputNone = types.BoolValue(false)
+ }
+ } else {
+ data.Vty[i].TransportOutputNone = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "transport/output/output"); value.Exists() && !data.Vty[i].TransportOutput.IsNull() {
+ data.Vty[i].TransportOutput = helpers.GetStringListXML(value.Array())
+ } else {
+ data.Vty[i].TransportOutput = types.ListNull(types.StringType)
+ }
+ }
+ for i := range data.Aux {
+ keys := [...]string{"first"}
+ keyValues := [...]string{data.Aux[i].First.ValueString()}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/aux").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, "first"); value.Exists() && !data.Aux[i].First.IsNull() {
+ data.Aux[i].First = types.StringValue(value.String())
+ } else {
+ data.Aux[i].First = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "escape-character/char"); value.Exists() && !data.Aux[i].EscapeCharacter.IsNull() {
+ data.Aux[i].EscapeCharacter = types.StringValue(value.String())
+ } else {
+ data.Aux[i].EscapeCharacter = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "logging/synchronous"); !data.Aux[i].LoggingSynchronous.IsNull() {
+ if value.Exists() {
+ data.Aux[i].LoggingSynchronous = types.BoolValue(true)
+ } else {
+ data.Aux[i].LoggingSynchronous = types.BoolValue(false)
+ }
+ } else {
+ data.Aux[i].LoggingSynchronous = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "exec-timeout/minutes"); value.Exists() && !data.Aux[i].ExecTimeoutMinutes.IsNull() {
+ data.Aux[i].ExecTimeoutMinutes = types.Int64Value(value.Int())
+ } else {
+ data.Aux[i].ExecTimeoutMinutes = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(r, "exec-timeout/seconds"); value.Exists() && !data.Aux[i].ExecTimeoutSeconds.IsNull() {
+ data.Aux[i].ExecTimeoutSeconds = types.Int64Value(value.Int())
+ } else {
+ data.Aux[i].ExecTimeoutSeconds = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(r, "monitor"); !data.Aux[i].Monitor.IsNull() {
+ if value.Exists() {
+ data.Aux[i].Monitor = types.BoolValue(true)
+ } else {
+ data.Aux[i].Monitor = types.BoolValue(false)
+ }
+ } else {
+ data.Aux[i].Monitor = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "transport/output/none"); !data.Aux[i].TransportOutputNone.IsNull() {
+ if value.Exists() {
+ data.Aux[i].TransportOutputNone = types.BoolValue(true)
+ } else {
+ data.Aux[i].TransportOutputNone = types.BoolValue(false)
+ }
+ } else {
+ data.Aux[i].TransportOutputNone = types.BoolNull()
+ }
+ }
+}
+
+// End of section. //template:end updateFromBodyXML
+
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBody
+
+func (data *Line) fromBody(ctx context.Context, res gjson.Result) {
+ prefix := helpers.LastElement(data.getPath()) + "."
+ if res.Get(helpers.LastElement(data.getPath())).IsArray() {
+ prefix += "0."
+ }
+ if value := res.Get(prefix + "console"); value.Exists() {
+ data.Console = make([]LineConsole, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := LineConsole{}
+ if cValue := v.Get("first"); cValue.Exists() {
+ item.First = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("exec-timeout.minutes"); cValue.Exists() {
+ item.ExecTimeoutMinutes = types.Int64Value(cValue.Int())
+ }
+ if cValue := v.Get("exec-timeout.seconds"); cValue.Exists() {
+ item.ExecTimeoutSeconds = types.Int64Value(cValue.Int())
+ }
+ if cValue := v.Get("login.local"); cValue.Exists() {
+ item.LoginLocal = types.BoolValue(true)
+ } else {
+ item.LoginLocal = types.BoolValue(false)
+ }
+ if cValue := v.Get("login.authentication"); cValue.Exists() {
+ item.LoginAuthentication = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("privilege.level.number"); cValue.Exists() {
+ item.PrivilegeLevel = types.Int64Value(cValue.Int())
+ }
+ if cValue := v.Get("stopbits"); cValue.Exists() {
+ item.Stopbits = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("password.level"); cValue.Exists() {
+ item.PasswordLevel = types.Int64Value(cValue.Int())
+ }
+ if cValue := v.Get("password.type"); cValue.Exists() {
+ item.PasswordType = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("password.secret"); cValue.Exists() {
+ item.Password = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("escape-character.char"); cValue.Exists() {
+ item.EscapeCharacter = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("logging.synchronous"); cValue.Exists() {
+ item.LoggingSynchronous = types.BoolValue(true)
+ } else {
+ item.LoggingSynchronous = types.BoolValue(false)
+ }
+ if cValue := v.Get("transport.output.all"); cValue.Exists() {
+ item.TransportOutputAll = types.BoolValue(true)
+ } else {
+ item.TransportOutputAll = types.BoolValue(false)
+ }
+ if cValue := v.Get("transport.output.none"); cValue.Exists() {
+ item.TransportOutputNone = types.BoolValue(true)
+ } else {
+ item.TransportOutputNone = types.BoolValue(false)
+ }
+ if cValue := v.Get("transport.output.output"); cValue.Exists() {
+ item.TransportOutput = helpers.GetStringList(cValue.Array())
+ } else {
+ item.TransportOutput = types.ListNull(types.StringType)
+ }
+ data.Console = append(data.Console, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + "vty"); value.Exists() {
+ data.Vty = make([]LineVty, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := LineVty{}
+ if cValue := v.Get("first"); cValue.Exists() {
+ item.First = types.Int64Value(cValue.Int())
+ }
+ if cValue := v.Get("last"); cValue.Exists() {
+ item.Last = types.Int64Value(cValue.Int())
+ }
+ if cValue := v.Get("access-class.acccess-list"); cValue.Exists() {
+ item.AccessClasses = make([]LineVtyAccessClasses, 0)
+ cValue.ForEach(func(ck, cv gjson.Result) bool {
+ cItem := LineVtyAccessClasses{}
+ if ccValue := cv.Get("direction"); ccValue.Exists() {
+ cItem.Direction = types.StringValue(ccValue.String())
+ }
+ if ccValue := cv.Get("access-list"); ccValue.Exists() {
+ cItem.AccessList = types.StringValue(ccValue.String())
+ }
+ if ccValue := cv.Get("vrf-also"); ccValue.Exists() {
+ cItem.VrfAlso = types.BoolValue(true)
+ } else {
+ cItem.VrfAlso = types.BoolValue(false)
+ }
+ item.AccessClasses = append(item.AccessClasses, cItem)
+ return true
+ })
+ }
+ if cValue := v.Get("exec-timeout.minutes"); cValue.Exists() {
+ item.ExecTimeoutMinutes = types.Int64Value(cValue.Int())
+ }
+ if cValue := v.Get("exec-timeout.seconds"); cValue.Exists() {
+ item.ExecTimeoutSeconds = types.Int64Value(cValue.Int())
+ }
+ if cValue := v.Get("password.level"); cValue.Exists() {
+ item.PasswordLevel = types.Int64Value(cValue.Int())
+ }
+ if cValue := v.Get("password.type"); cValue.Exists() {
+ item.PasswordType = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("password.secret"); cValue.Exists() {
+ item.Password = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("login.authentication"); cValue.Exists() {
+ item.LoginAuthentication = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("transport.preferred.protocol"); cValue.Exists() {
+ item.TransportPreferredProtocol = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("escape-character.char"); cValue.Exists() {
+ item.EscapeCharacter = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("authorization.exec.authorization-name"); cValue.Exists() {
+ item.AuthorizationExec = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("authorization.exec.default"); cValue.Exists() {
+ item.AuthorizationExecDefault = types.BoolValue(true)
+ } else {
+ item.AuthorizationExecDefault = types.BoolValue(false)
+ }
+ if cValue := v.Get("transport.input.all"); cValue.Exists() {
+ item.TransportInputAll = types.BoolValue(true)
+ } else {
+ item.TransportInputAll = types.BoolValue(false)
+ }
+ if cValue := v.Get("transport.input.none"); cValue.Exists() {
+ item.TransportInputNone = types.BoolValue(true)
+ } else {
+ item.TransportInputNone = types.BoolValue(false)
+ }
+ if cValue := v.Get("transport.input.input"); cValue.Exists() {
+ item.TransportInput = helpers.GetStringList(cValue.Array())
+ } else {
+ item.TransportInput = types.ListNull(types.StringType)
+ }
+ if cValue := v.Get("monitor"); cValue.Exists() {
+ item.Monitor = types.BoolValue(true)
+ } else {
+ item.Monitor = types.BoolValue(false)
+ }
+ if cValue := v.Get("session-timeout.session-timeout-value"); cValue.Exists() {
+ item.SessionTimeout = types.Int64Value(cValue.Int())
+ }
+ if cValue := v.Get("stopbits"); cValue.Exists() {
+ item.Stopbits = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("logging.synchronous"); cValue.Exists() {
+ item.LoggingSynchronous = types.BoolValue(true)
+ } else {
+ item.LoggingSynchronous = types.BoolValue(false)
+ }
+ if cValue := v.Get("transport.output.all"); cValue.Exists() {
+ item.TransportOutputAll = types.BoolValue(true)
+ } else {
+ item.TransportOutputAll = types.BoolValue(false)
+ }
+ if cValue := v.Get("transport.output.none"); cValue.Exists() {
+ item.TransportOutputNone = types.BoolValue(true)
+ } else {
+ item.TransportOutputNone = types.BoolValue(false)
+ }
+ if cValue := v.Get("transport.output.output"); cValue.Exists() {
+ item.TransportOutput = helpers.GetStringList(cValue.Array())
+ } else {
+ item.TransportOutput = types.ListNull(types.StringType)
+ }
+ data.Vty = append(data.Vty, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + "aux"); value.Exists() {
+ data.Aux = make([]LineAux, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := LineAux{}
+ if cValue := v.Get("first"); cValue.Exists() {
+ item.First = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("escape-character.char"); cValue.Exists() {
+ item.EscapeCharacter = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("logging.synchronous"); cValue.Exists() {
+ item.LoggingSynchronous = types.BoolValue(true)
+ } else {
+ item.LoggingSynchronous = types.BoolValue(false)
+ }
+ if cValue := v.Get("exec-timeout.minutes"); cValue.Exists() {
+ item.ExecTimeoutMinutes = types.Int64Value(cValue.Int())
+ }
+ if cValue := v.Get("exec-timeout.seconds"); cValue.Exists() {
+ item.ExecTimeoutSeconds = types.Int64Value(cValue.Int())
+ }
+ if cValue := v.Get("monitor"); cValue.Exists() {
+ item.Monitor = types.BoolValue(true)
+ } else {
+ item.Monitor = types.BoolValue(false)
+ }
+ if cValue := v.Get("transport.output.none"); cValue.Exists() {
+ item.TransportOutputNone = types.BoolValue(true)
+ } else {
+ item.TransportOutputNone = types.BoolValue(false)
+ }
+ data.Aux = append(data.Aux, item)
+ return true
+ })
+ }
+}
+
+// End of section. //template:end fromBody
+
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyData
+
+func (data *LineData) fromBody(ctx context.Context, res gjson.Result) {
+ prefix := helpers.LastElement(data.getPath()) + "."
+ if res.Get(helpers.LastElement(data.getPath())).IsArray() {
+ prefix += "0."
+ }
+ if value := res.Get(prefix + "console"); value.Exists() {
+ data.Console = make([]LineConsole, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := LineConsole{}
+ if cValue := v.Get("first"); cValue.Exists() {
+ item.First = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("exec-timeout.minutes"); cValue.Exists() {
+ item.ExecTimeoutMinutes = types.Int64Value(cValue.Int())
+ }
+ if cValue := v.Get("exec-timeout.seconds"); cValue.Exists() {
+ item.ExecTimeoutSeconds = types.Int64Value(cValue.Int())
+ }
+ if cValue := v.Get("login.local"); cValue.Exists() {
+ item.LoginLocal = types.BoolValue(true)
+ } else {
+ item.LoginLocal = types.BoolValue(false)
+ }
+ if cValue := v.Get("login.authentication"); cValue.Exists() {
+ item.LoginAuthentication = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("privilege.level.number"); cValue.Exists() {
+ item.PrivilegeLevel = types.Int64Value(cValue.Int())
}
if cValue := v.Get("stopbits"); cValue.Exists() {
item.Stopbits = types.StringValue(cValue.String())
@@ -941,71 +1803,283 @@ func (data *Line) fromBody(ctx context.Context, res gjson.Result) {
}
}
-// End of section. //template:end fromBody
+// End of section. //template:end fromBodyData
-// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyData
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyXML
-func (data *LineData) fromBody(ctx context.Context, res gjson.Result) {
- prefix := helpers.LastElement(data.getPath()) + "."
- if res.Get(helpers.LastElement(data.getPath())).IsArray() {
- prefix += "0."
+func (data *Line) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/console"); value.Exists() {
+ data.Console = make([]LineConsole, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := LineConsole{}
+ if cValue := helpers.GetFromXPath(v, "first"); cValue.Exists() {
+ item.First = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "exec-timeout/minutes"); cValue.Exists() {
+ item.ExecTimeoutMinutes = types.Int64Value(cValue.Int())
+ }
+ if cValue := helpers.GetFromXPath(v, "exec-timeout/seconds"); cValue.Exists() {
+ item.ExecTimeoutSeconds = types.Int64Value(cValue.Int())
+ }
+ if cValue := helpers.GetFromXPath(v, "login/local"); cValue.Exists() {
+ item.LoginLocal = types.BoolValue(true)
+ } else {
+ item.LoginLocal = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "login/authentication"); cValue.Exists() {
+ item.LoginAuthentication = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "privilege/level/number"); cValue.Exists() {
+ item.PrivilegeLevel = types.Int64Value(cValue.Int())
+ }
+ if cValue := helpers.GetFromXPath(v, "stopbits"); cValue.Exists() {
+ item.Stopbits = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "password/level"); cValue.Exists() {
+ item.PasswordLevel = types.Int64Value(cValue.Int())
+ }
+ if cValue := helpers.GetFromXPath(v, "password/type"); cValue.Exists() {
+ item.PasswordType = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "password/secret"); cValue.Exists() {
+ item.Password = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "escape-character/char"); cValue.Exists() {
+ item.EscapeCharacter = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "logging/synchronous"); cValue.Exists() {
+ item.LoggingSynchronous = types.BoolValue(true)
+ } else {
+ item.LoggingSynchronous = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "transport/output/all"); cValue.Exists() {
+ item.TransportOutputAll = types.BoolValue(true)
+ } else {
+ item.TransportOutputAll = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "transport/output/none"); cValue.Exists() {
+ item.TransportOutputNone = types.BoolValue(true)
+ } else {
+ item.TransportOutputNone = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "transport/output/output"); cValue.Exists() {
+ item.TransportOutput = helpers.GetStringListXML(cValue.Array())
+ } else {
+ item.TransportOutput = types.ListNull(types.StringType)
+ }
+ data.Console = append(data.Console, item)
+ return true
+ })
}
- if value := res.Get(prefix + "console"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/vty"); value.Exists() {
+ data.Vty = make([]LineVty, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := LineVty{}
+ if cValue := helpers.GetFromXPath(v, "first"); cValue.Exists() {
+ item.First = types.Int64Value(cValue.Int())
+ }
+ if cValue := helpers.GetFromXPath(v, "last"); cValue.Exists() {
+ item.Last = types.Int64Value(cValue.Int())
+ }
+ if cValue := helpers.GetFromXPath(v, "access-class/acccess-list"); cValue.Exists() {
+ item.AccessClasses = make([]LineVtyAccessClasses, 0)
+ cValue.ForEach(func(_ int, cv xmldot.Result) bool {
+ cItem := LineVtyAccessClasses{}
+ if ccValue := helpers.GetFromXPath(cv, "direction"); ccValue.Exists() {
+ cItem.Direction = types.StringValue(ccValue.String())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "access-list"); ccValue.Exists() {
+ cItem.AccessList = types.StringValue(ccValue.String())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "vrf-also"); ccValue.Exists() {
+ cItem.VrfAlso = types.BoolValue(true)
+ } else {
+ cItem.VrfAlso = types.BoolValue(false)
+ }
+ item.AccessClasses = append(item.AccessClasses, cItem)
+ return true
+ })
+ }
+ if cValue := helpers.GetFromXPath(v, "exec-timeout/minutes"); cValue.Exists() {
+ item.ExecTimeoutMinutes = types.Int64Value(cValue.Int())
+ }
+ if cValue := helpers.GetFromXPath(v, "exec-timeout/seconds"); cValue.Exists() {
+ item.ExecTimeoutSeconds = types.Int64Value(cValue.Int())
+ }
+ if cValue := helpers.GetFromXPath(v, "password/level"); cValue.Exists() {
+ item.PasswordLevel = types.Int64Value(cValue.Int())
+ }
+ if cValue := helpers.GetFromXPath(v, "password/type"); cValue.Exists() {
+ item.PasswordType = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "password/secret"); cValue.Exists() {
+ item.Password = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "login/authentication"); cValue.Exists() {
+ item.LoginAuthentication = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "transport/preferred/protocol"); cValue.Exists() {
+ item.TransportPreferredProtocol = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "escape-character/char"); cValue.Exists() {
+ item.EscapeCharacter = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "authorization/exec/authorization-name"); cValue.Exists() {
+ item.AuthorizationExec = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "authorization/exec/default"); cValue.Exists() {
+ item.AuthorizationExecDefault = types.BoolValue(true)
+ } else {
+ item.AuthorizationExecDefault = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "transport/input/all"); cValue.Exists() {
+ item.TransportInputAll = types.BoolValue(true)
+ } else {
+ item.TransportInputAll = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "transport/input/none"); cValue.Exists() {
+ item.TransportInputNone = types.BoolValue(true)
+ } else {
+ item.TransportInputNone = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "transport/input/input"); cValue.Exists() {
+ item.TransportInput = helpers.GetStringListXML(cValue.Array())
+ } else {
+ item.TransportInput = types.ListNull(types.StringType)
+ }
+ if cValue := helpers.GetFromXPath(v, "monitor"); cValue.Exists() {
+ item.Monitor = types.BoolValue(true)
+ } else {
+ item.Monitor = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "session-timeout/session-timeout-value"); cValue.Exists() {
+ item.SessionTimeout = types.Int64Value(cValue.Int())
+ }
+ if cValue := helpers.GetFromXPath(v, "stopbits"); cValue.Exists() {
+ item.Stopbits = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "logging/synchronous"); cValue.Exists() {
+ item.LoggingSynchronous = types.BoolValue(true)
+ } else {
+ item.LoggingSynchronous = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "transport/output/all"); cValue.Exists() {
+ item.TransportOutputAll = types.BoolValue(true)
+ } else {
+ item.TransportOutputAll = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "transport/output/none"); cValue.Exists() {
+ item.TransportOutputNone = types.BoolValue(true)
+ } else {
+ item.TransportOutputNone = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "transport/output/output"); cValue.Exists() {
+ item.TransportOutput = helpers.GetStringListXML(cValue.Array())
+ } else {
+ item.TransportOutput = types.ListNull(types.StringType)
+ }
+ data.Vty = append(data.Vty, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/aux"); value.Exists() {
+ data.Aux = make([]LineAux, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := LineAux{}
+ if cValue := helpers.GetFromXPath(v, "first"); cValue.Exists() {
+ item.First = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "escape-character/char"); cValue.Exists() {
+ item.EscapeCharacter = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "logging/synchronous"); cValue.Exists() {
+ item.LoggingSynchronous = types.BoolValue(true)
+ } else {
+ item.LoggingSynchronous = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "exec-timeout/minutes"); cValue.Exists() {
+ item.ExecTimeoutMinutes = types.Int64Value(cValue.Int())
+ }
+ if cValue := helpers.GetFromXPath(v, "exec-timeout/seconds"); cValue.Exists() {
+ item.ExecTimeoutSeconds = types.Int64Value(cValue.Int())
+ }
+ if cValue := helpers.GetFromXPath(v, "monitor"); cValue.Exists() {
+ item.Monitor = types.BoolValue(true)
+ } else {
+ item.Monitor = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "transport/output/none"); cValue.Exists() {
+ item.TransportOutputNone = types.BoolValue(true)
+ } else {
+ item.TransportOutputNone = types.BoolValue(false)
+ }
+ data.Aux = append(data.Aux, item)
+ return true
+ })
+ }
+}
+
+// End of section. //template:end fromBodyXML
+
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyDataXML
+
+func (data *LineData) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/console"); value.Exists() {
data.Console = make([]LineConsole, 0)
- value.ForEach(func(k, v gjson.Result) bool {
+ value.ForEach(func(_ int, v xmldot.Result) bool {
item := LineConsole{}
- if cValue := v.Get("first"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "first"); cValue.Exists() {
item.First = types.StringValue(cValue.String())
}
- if cValue := v.Get("exec-timeout.minutes"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "exec-timeout/minutes"); cValue.Exists() {
item.ExecTimeoutMinutes = types.Int64Value(cValue.Int())
}
- if cValue := v.Get("exec-timeout.seconds"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "exec-timeout/seconds"); cValue.Exists() {
item.ExecTimeoutSeconds = types.Int64Value(cValue.Int())
}
- if cValue := v.Get("login.local"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "login/local"); cValue.Exists() {
item.LoginLocal = types.BoolValue(true)
} else {
item.LoginLocal = types.BoolValue(false)
}
- if cValue := v.Get("login.authentication"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "login/authentication"); cValue.Exists() {
item.LoginAuthentication = types.StringValue(cValue.String())
}
- if cValue := v.Get("privilege.level.number"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "privilege/level/number"); cValue.Exists() {
item.PrivilegeLevel = types.Int64Value(cValue.Int())
}
- if cValue := v.Get("stopbits"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "stopbits"); cValue.Exists() {
item.Stopbits = types.StringValue(cValue.String())
}
- if cValue := v.Get("password.level"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "password/level"); cValue.Exists() {
item.PasswordLevel = types.Int64Value(cValue.Int())
}
- if cValue := v.Get("password.type"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "password/type"); cValue.Exists() {
item.PasswordType = types.StringValue(cValue.String())
}
- if cValue := v.Get("password.secret"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "password/secret"); cValue.Exists() {
item.Password = types.StringValue(cValue.String())
}
- if cValue := v.Get("escape-character.char"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "escape-character/char"); cValue.Exists() {
item.EscapeCharacter = types.StringValue(cValue.String())
}
- if cValue := v.Get("logging.synchronous"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "logging/synchronous"); cValue.Exists() {
item.LoggingSynchronous = types.BoolValue(true)
} else {
item.LoggingSynchronous = types.BoolValue(false)
}
- if cValue := v.Get("transport.output.all"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "transport/output/all"); cValue.Exists() {
item.TransportOutputAll = types.BoolValue(true)
} else {
item.TransportOutputAll = types.BoolValue(false)
}
- if cValue := v.Get("transport.output.none"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "transport/output/none"); cValue.Exists() {
item.TransportOutputNone = types.BoolValue(true)
} else {
item.TransportOutputNone = types.BoolValue(false)
}
- if cValue := v.Get("transport.output.output"); cValue.Exists() {
- item.TransportOutput = helpers.GetStringList(cValue.Array())
+ if cValue := helpers.GetFromXPath(v, "transport/output/output"); cValue.Exists() {
+ item.TransportOutput = helpers.GetStringListXML(cValue.Array())
} else {
item.TransportOutput = types.ListNull(types.StringType)
}
@@ -1013,27 +2087,27 @@ func (data *LineData) fromBody(ctx context.Context, res gjson.Result) {
return true
})
}
- if value := res.Get(prefix + "vty"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/vty"); value.Exists() {
data.Vty = make([]LineVty, 0)
- value.ForEach(func(k, v gjson.Result) bool {
+ value.ForEach(func(_ int, v xmldot.Result) bool {
item := LineVty{}
- if cValue := v.Get("first"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "first"); cValue.Exists() {
item.First = types.Int64Value(cValue.Int())
}
- if cValue := v.Get("last"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "last"); cValue.Exists() {
item.Last = types.Int64Value(cValue.Int())
}
- if cValue := v.Get("access-class.acccess-list"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "access-class/acccess-list"); cValue.Exists() {
item.AccessClasses = make([]LineVtyAccessClasses, 0)
- cValue.ForEach(func(ck, cv gjson.Result) bool {
+ cValue.ForEach(func(_ int, cv xmldot.Result) bool {
cItem := LineVtyAccessClasses{}
- if ccValue := cv.Get("direction"); ccValue.Exists() {
+ if ccValue := helpers.GetFromXPath(cv, "direction"); ccValue.Exists() {
cItem.Direction = types.StringValue(ccValue.String())
}
- if ccValue := cv.Get("access-list"); ccValue.Exists() {
+ if ccValue := helpers.GetFromXPath(cv, "access-list"); ccValue.Exists() {
cItem.AccessList = types.StringValue(ccValue.String())
}
- if ccValue := cv.Get("vrf-also"); ccValue.Exists() {
+ if ccValue := helpers.GetFromXPath(cv, "vrf-also"); ccValue.Exists() {
cItem.VrfAlso = types.BoolValue(true)
} else {
cItem.VrfAlso = types.BoolValue(false)
@@ -1042,81 +2116,81 @@ func (data *LineData) fromBody(ctx context.Context, res gjson.Result) {
return true
})
}
- if cValue := v.Get("exec-timeout.minutes"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "exec-timeout/minutes"); cValue.Exists() {
item.ExecTimeoutMinutes = types.Int64Value(cValue.Int())
}
- if cValue := v.Get("exec-timeout.seconds"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "exec-timeout/seconds"); cValue.Exists() {
item.ExecTimeoutSeconds = types.Int64Value(cValue.Int())
}
- if cValue := v.Get("password.level"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "password/level"); cValue.Exists() {
item.PasswordLevel = types.Int64Value(cValue.Int())
}
- if cValue := v.Get("password.type"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "password/type"); cValue.Exists() {
item.PasswordType = types.StringValue(cValue.String())
}
- if cValue := v.Get("password.secret"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "password/secret"); cValue.Exists() {
item.Password = types.StringValue(cValue.String())
}
- if cValue := v.Get("login.authentication"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "login/authentication"); cValue.Exists() {
item.LoginAuthentication = types.StringValue(cValue.String())
}
- if cValue := v.Get("transport.preferred.protocol"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "transport/preferred/protocol"); cValue.Exists() {
item.TransportPreferredProtocol = types.StringValue(cValue.String())
}
- if cValue := v.Get("escape-character.char"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "escape-character/char"); cValue.Exists() {
item.EscapeCharacter = types.StringValue(cValue.String())
}
- if cValue := v.Get("authorization.exec.authorization-name"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "authorization/exec/authorization-name"); cValue.Exists() {
item.AuthorizationExec = types.StringValue(cValue.String())
}
- if cValue := v.Get("authorization.exec.default"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "authorization/exec/default"); cValue.Exists() {
item.AuthorizationExecDefault = types.BoolValue(true)
} else {
item.AuthorizationExecDefault = types.BoolValue(false)
}
- if cValue := v.Get("transport.input.all"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "transport/input/all"); cValue.Exists() {
item.TransportInputAll = types.BoolValue(true)
} else {
item.TransportInputAll = types.BoolValue(false)
}
- if cValue := v.Get("transport.input.none"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "transport/input/none"); cValue.Exists() {
item.TransportInputNone = types.BoolValue(true)
} else {
item.TransportInputNone = types.BoolValue(false)
}
- if cValue := v.Get("transport.input.input"); cValue.Exists() {
- item.TransportInput = helpers.GetStringList(cValue.Array())
+ if cValue := helpers.GetFromXPath(v, "transport/input/input"); cValue.Exists() {
+ item.TransportInput = helpers.GetStringListXML(cValue.Array())
} else {
item.TransportInput = types.ListNull(types.StringType)
}
- if cValue := v.Get("monitor"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "monitor"); cValue.Exists() {
item.Monitor = types.BoolValue(true)
} else {
item.Monitor = types.BoolValue(false)
}
- if cValue := v.Get("session-timeout.session-timeout-value"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "session-timeout/session-timeout-value"); cValue.Exists() {
item.SessionTimeout = types.Int64Value(cValue.Int())
}
- if cValue := v.Get("stopbits"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "stopbits"); cValue.Exists() {
item.Stopbits = types.StringValue(cValue.String())
}
- if cValue := v.Get("logging.synchronous"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "logging/synchronous"); cValue.Exists() {
item.LoggingSynchronous = types.BoolValue(true)
} else {
item.LoggingSynchronous = types.BoolValue(false)
}
- if cValue := v.Get("transport.output.all"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "transport/output/all"); cValue.Exists() {
item.TransportOutputAll = types.BoolValue(true)
} else {
item.TransportOutputAll = types.BoolValue(false)
}
- if cValue := v.Get("transport.output.none"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "transport/output/none"); cValue.Exists() {
item.TransportOutputNone = types.BoolValue(true)
} else {
item.TransportOutputNone = types.BoolValue(false)
}
- if cValue := v.Get("transport.output.output"); cValue.Exists() {
- item.TransportOutput = helpers.GetStringList(cValue.Array())
+ if cValue := helpers.GetFromXPath(v, "transport/output/output"); cValue.Exists() {
+ item.TransportOutput = helpers.GetStringListXML(cValue.Array())
} else {
item.TransportOutput = types.ListNull(types.StringType)
}
@@ -1124,33 +2198,33 @@ func (data *LineData) fromBody(ctx context.Context, res gjson.Result) {
return true
})
}
- if value := res.Get(prefix + "aux"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/aux"); value.Exists() {
data.Aux = make([]LineAux, 0)
- value.ForEach(func(k, v gjson.Result) bool {
+ value.ForEach(func(_ int, v xmldot.Result) bool {
item := LineAux{}
- if cValue := v.Get("first"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "first"); cValue.Exists() {
item.First = types.StringValue(cValue.String())
}
- if cValue := v.Get("escape-character.char"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "escape-character/char"); cValue.Exists() {
item.EscapeCharacter = types.StringValue(cValue.String())
}
- if cValue := v.Get("logging.synchronous"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "logging/synchronous"); cValue.Exists() {
item.LoggingSynchronous = types.BoolValue(true)
} else {
item.LoggingSynchronous = types.BoolValue(false)
}
- if cValue := v.Get("exec-timeout.minutes"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "exec-timeout/minutes"); cValue.Exists() {
item.ExecTimeoutMinutes = types.Int64Value(cValue.Int())
}
- if cValue := v.Get("exec-timeout.seconds"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "exec-timeout/seconds"); cValue.Exists() {
item.ExecTimeoutSeconds = types.Int64Value(cValue.Int())
}
- if cValue := v.Get("monitor"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "monitor"); cValue.Exists() {
item.Monitor = types.BoolValue(true)
} else {
item.Monitor = types.BoolValue(false)
}
- if cValue := v.Get("transport.output.none"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "transport/output/none"); cValue.Exists() {
item.TransportOutputNone = types.BoolValue(true)
} else {
item.TransportOutputNone = types.BoolValue(false)
@@ -1161,7 +2235,7 @@ func (data *LineData) fromBody(ctx context.Context, res gjson.Result) {
}
}
-// End of section. //template:end fromBodyData
+// End of section. //template:end fromBodyDataXML
// Section below is generated&owned by "gen/generator.go". //template:begin getDeletedItems
@@ -1456,6 +2530,319 @@ func (data *Line) getDeletedItems(ctx context.Context, state Line) []string {
// End of section. //template:end getDeletedItems
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletedItemsXML
+
+func (data *Line) addDeletedItemsXML(ctx context.Context, state Line, body string) string {
+ b := netconf.NewBody(body)
+ for i := range state.Console {
+ stateKeys := [...]string{"first"}
+ stateKeyValues := [...]string{state.Console[i].First.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.Console[i].First.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.Console {
+ found = true
+ if state.Console[i].First.ValueString() != data.Console[j].First.ValueString() {
+ found = false
+ }
+ if found {
+ if !state.Console[i].ExecTimeoutMinutes.IsNull() && data.Console[j].ExecTimeoutMinutes.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/console%v/exec-timeout/minutes", predicates))
+ }
+ if !state.Console[i].ExecTimeoutSeconds.IsNull() && data.Console[j].ExecTimeoutSeconds.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/console%v/exec-timeout/seconds", predicates))
+ }
+ if !state.Console[i].LoginLocal.IsNull() && data.Console[j].LoginLocal.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/console%v/login/local", predicates))
+ }
+ if !state.Console[i].LoginAuthentication.IsNull() && data.Console[j].LoginAuthentication.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/console%v/login/authentication", predicates))
+ }
+ if !state.Console[i].PrivilegeLevel.IsNull() && data.Console[j].PrivilegeLevel.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/console%v/privilege/level/number", predicates))
+ }
+ if !state.Console[i].Stopbits.IsNull() && data.Console[j].Stopbits.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/console%v/stopbits", predicates))
+ }
+ if !state.Console[i].PasswordLevel.IsNull() && data.Console[j].PasswordLevel.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/console%v/password/level", predicates))
+ }
+ if !state.Console[i].PasswordType.IsNull() && data.Console[j].PasswordType.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/console%v/password/type", predicates))
+ }
+ if !state.Console[i].Password.IsNull() && data.Console[j].Password.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/console%v/password/secret", predicates))
+ }
+ if !state.Console[i].EscapeCharacter.IsNull() && data.Console[j].EscapeCharacter.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/console%v/escape-character/char", predicates))
+ }
+ if !state.Console[i].LoggingSynchronous.IsNull() && data.Console[j].LoggingSynchronous.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/console%v/logging/synchronous", predicates))
+ }
+ if !state.Console[i].TransportOutputAll.IsNull() && data.Console[j].TransportOutputAll.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/console%v/transport/output/all", predicates))
+ }
+ if !state.Console[i].TransportOutputNone.IsNull() && data.Console[j].TransportOutputNone.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/console%v/transport/output/none", predicates))
+ }
+ if !state.Console[i].TransportOutput.IsNull() {
+ if data.Console[j].TransportOutput.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/console%v/transport/output/output", predicates))
+ } else {
+ var dataValues, stateValues []string
+ data.Console[i].TransportOutput.ElementsAs(ctx, &dataValues, false)
+ state.Console[j].TransportOutput.ElementsAs(ctx, &stateValues, false)
+ for _, v := range stateValues {
+ found := false
+ for _, vv := range dataValues {
+ if v == vv {
+ found = true
+ break
+ }
+ }
+ if !found {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/console%v/transport/output/output[.=%v]", predicates, v))
+ }
+ }
+ }
+ }
+ break
+ }
+ }
+ if !found {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/console%v", predicates))
+ }
+ }
+ for i := range state.Vty {
+ stateKeys := [...]string{"first"}
+ stateKeyValues := [...]string{strconv.FormatInt(state.Vty[i].First.ValueInt64(), 10)}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.Vty[i].First.ValueInt64()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.Vty {
+ found = true
+ if state.Vty[i].First.ValueInt64() != data.Vty[j].First.ValueInt64() {
+ found = false
+ }
+ if found {
+ if !state.Vty[i].Last.IsNull() && data.Vty[j].Last.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/vty%v/last", predicates))
+ }
+ for ci := range state.Vty[i].AccessClasses {
+ cstateKeys := [...]string{"direction"}
+ cstateKeyValues := [...]string{state.Vty[i].AccessClasses[ci].Direction.ValueString()}
+ cpredicates := ""
+ for i := range cstateKeys {
+ cpredicates += fmt.Sprintf("[%s='%s']", cstateKeys[i], cstateKeyValues[i])
+ }
+
+ cemptyKeys := true
+ if !reflect.ValueOf(state.Vty[i].AccessClasses[ci].Direction.ValueString()).IsZero() {
+ cemptyKeys = false
+ }
+ if cemptyKeys {
+ continue
+ }
+
+ found := false
+ for cj := range data.Vty[j].AccessClasses {
+ found = true
+ if state.Vty[i].AccessClasses[ci].Direction.ValueString() != data.Vty[j].AccessClasses[cj].Direction.ValueString() {
+ found = false
+ }
+ if found {
+ if !state.Vty[i].AccessClasses[ci].AccessList.IsNull() && data.Vty[j].AccessClasses[cj].AccessList.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/vty%v/access-class/acccess-list%v/access-list", predicates, cpredicates))
+ }
+ if !state.Vty[i].AccessClasses[ci].VrfAlso.IsNull() && data.Vty[j].AccessClasses[cj].VrfAlso.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/vty%v/access-class/acccess-list%v/vrf-also", predicates, cpredicates))
+ }
+ break
+ }
+ }
+ if !found {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/vty%v/access-class/acccess-list%v", predicates, cpredicates))
+ }
+ }
+ if !state.Vty[i].ExecTimeoutMinutes.IsNull() && data.Vty[j].ExecTimeoutMinutes.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/vty%v/exec-timeout/minutes", predicates))
+ }
+ if !state.Vty[i].ExecTimeoutSeconds.IsNull() && data.Vty[j].ExecTimeoutSeconds.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/vty%v/exec-timeout/seconds", predicates))
+ }
+ if !state.Vty[i].PasswordLevel.IsNull() && data.Vty[j].PasswordLevel.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/vty%v/password/level", predicates))
+ }
+ if !state.Vty[i].PasswordType.IsNull() && data.Vty[j].PasswordType.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/vty%v/password/type", predicates))
+ }
+ if !state.Vty[i].Password.IsNull() && data.Vty[j].Password.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/vty%v/password/secret", predicates))
+ }
+ if !state.Vty[i].LoginAuthentication.IsNull() && data.Vty[j].LoginAuthentication.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/vty%v/login/authentication", predicates))
+ }
+ if !state.Vty[i].TransportPreferredProtocol.IsNull() && data.Vty[j].TransportPreferredProtocol.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/vty%v/transport/preferred/protocol", predicates))
+ }
+ if !state.Vty[i].EscapeCharacter.IsNull() && data.Vty[j].EscapeCharacter.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/vty%v/escape-character/char", predicates))
+ }
+ if !state.Vty[i].AuthorizationExec.IsNull() && data.Vty[j].AuthorizationExec.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/vty%v/authorization/exec/authorization-name", predicates))
+ }
+ if !state.Vty[i].AuthorizationExecDefault.IsNull() && data.Vty[j].AuthorizationExecDefault.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/vty%v/authorization/exec/default", predicates))
+ }
+ if !state.Vty[i].TransportInputAll.IsNull() && data.Vty[j].TransportInputAll.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/vty%v/transport/input/all", predicates))
+ }
+ if !state.Vty[i].TransportInputNone.IsNull() && data.Vty[j].TransportInputNone.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/vty%v/transport/input/none", predicates))
+ }
+ if !state.Vty[i].TransportInput.IsNull() {
+ if data.Vty[j].TransportInput.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/vty%v/transport/input/input", predicates))
+ } else {
+ var dataValues, stateValues []string
+ data.Vty[i].TransportInput.ElementsAs(ctx, &dataValues, false)
+ state.Vty[j].TransportInput.ElementsAs(ctx, &stateValues, false)
+ for _, v := range stateValues {
+ found := false
+ for _, vv := range dataValues {
+ if v == vv {
+ found = true
+ break
+ }
+ }
+ if !found {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/vty%v/transport/input/input[.=%v]", predicates, v))
+ }
+ }
+ }
+ }
+ if !state.Vty[i].Monitor.IsNull() && data.Vty[j].Monitor.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/vty%v/monitor", predicates))
+ }
+ if !state.Vty[i].SessionTimeout.IsNull() && data.Vty[j].SessionTimeout.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/vty%v/session-timeout/session-timeout-value", predicates))
+ }
+ if !state.Vty[i].Stopbits.IsNull() && data.Vty[j].Stopbits.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/vty%v/stopbits", predicates))
+ }
+ if !state.Vty[i].LoggingSynchronous.IsNull() && data.Vty[j].LoggingSynchronous.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/vty%v/logging/synchronous", predicates))
+ }
+ if !state.Vty[i].TransportOutputAll.IsNull() && data.Vty[j].TransportOutputAll.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/vty%v/transport/output/all", predicates))
+ }
+ if !state.Vty[i].TransportOutputNone.IsNull() && data.Vty[j].TransportOutputNone.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/vty%v/transport/output/none", predicates))
+ }
+ if !state.Vty[i].TransportOutput.IsNull() {
+ if data.Vty[j].TransportOutput.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/vty%v/transport/output/output", predicates))
+ } else {
+ var dataValues, stateValues []string
+ data.Vty[i].TransportOutput.ElementsAs(ctx, &dataValues, false)
+ state.Vty[j].TransportOutput.ElementsAs(ctx, &stateValues, false)
+ for _, v := range stateValues {
+ found := false
+ for _, vv := range dataValues {
+ if v == vv {
+ found = true
+ break
+ }
+ }
+ if !found {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/vty%v/transport/output/output[.=%v]", predicates, v))
+ }
+ }
+ }
+ }
+ break
+ }
+ }
+ if !found {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/vty%v", predicates))
+ }
+ }
+ for i := range state.Aux {
+ stateKeys := [...]string{"first"}
+ stateKeyValues := [...]string{state.Aux[i].First.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.Aux[i].First.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.Aux {
+ found = true
+ if state.Aux[i].First.ValueString() != data.Aux[j].First.ValueString() {
+ found = false
+ }
+ if found {
+ if !state.Aux[i].EscapeCharacter.IsNull() && data.Aux[j].EscapeCharacter.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/aux%v/escape-character/char", predicates))
+ }
+ if !state.Aux[i].LoggingSynchronous.IsNull() && data.Aux[j].LoggingSynchronous.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/aux%v/logging/synchronous", predicates))
+ }
+ if !state.Aux[i].ExecTimeoutMinutes.IsNull() && data.Aux[j].ExecTimeoutMinutes.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/aux%v/exec-timeout/minutes", predicates))
+ }
+ if !state.Aux[i].ExecTimeoutSeconds.IsNull() && data.Aux[j].ExecTimeoutSeconds.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/aux%v/exec-timeout/seconds", predicates))
+ }
+ if !state.Aux[i].Monitor.IsNull() && data.Aux[j].Monitor.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/aux%v/monitor", predicates))
+ }
+ if !state.Aux[i].TransportOutputNone.IsNull() && data.Aux[j].TransportOutputNone.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/aux%v/transport/output/none", predicates))
+ }
+ break
+ }
+ }
+ if !found {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/aux%v", predicates))
+ }
+ }
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletedItemsXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin getEmptyLeafsDelete
func (data *Line) getEmptyLeafsDelete(ctx context.Context) []string {
@@ -1536,3 +2923,13 @@ func (data *Line) getDeletePaths(ctx context.Context) []string {
}
// End of section. //template:end getDeletePaths
+
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletePathsXML
+
+func (data *Line) addDeletePathsXML(ctx context.Context, body string) string {
+ b := netconf.NewBody(body)
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletePathsXML
diff --git a/internal/provider/model_iosxe_lldp.go b/internal/provider/model_iosxe_lldp.go
index 9428986d..43db4749 100644
--- a/internal/provider/model_iosxe_lldp.go
+++ b/internal/provider/model_iosxe_lldp.go
@@ -30,6 +30,9 @@ import (
"github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/types"
+ "github.com/hashicorp/terraform-plugin-log/tflog"
+ "github.com/netascode/go-netconf"
+ "github.com/netascode/xmldot"
"github.com/tidwall/gjson"
"github.com/tidwall/sjson"
)
@@ -89,6 +92,17 @@ func (data LLDP) getPathShort() string {
return matches[1]
}
+// getXPath returns the XPath for NETCONF operations
+func (data LLDP) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/Cisco-IOS-XE-lldp:lldp"
+ return path
+}
+
+func (data LLDPData) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/Cisco-IOS-XE-lldp:lldp"
+ return path
+}
+
// End of section. //template:end getPath
// Section below is generated&owned by "gen/generator.go". //template:begin toBody
@@ -135,6 +149,61 @@ func (data LLDP) toBody(ctx context.Context) string {
// End of section. //template:end toBody
+// Section below is generated&owned by "gen/generator.go". //template:begin toBodyXML
+
+func (data LLDP) toBodyXML(ctx context.Context) string {
+ body := netconf.Body{}
+ if !data.Run.IsNull() && !data.Run.IsUnknown() {
+ if data.Run.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/run", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/run")
+ }
+ }
+ if !data.Holdtime.IsNull() && !data.Holdtime.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/holdtime", strconv.FormatInt(data.Holdtime.ValueInt64(), 10))
+ }
+ if !data.ManagementVlan.IsNull() && !data.ManagementVlan.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/management-vlan", strconv.FormatInt(data.ManagementVlan.ValueInt64(), 10))
+ }
+ if !data.Timer.IsNull() && !data.Timer.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/timer", strconv.FormatInt(data.Timer.ValueInt64(), 10))
+ }
+ if !data.Ipv4ManagementAddresses.IsNull() && !data.Ipv4ManagementAddresses.IsUnknown() {
+ var values []string
+ data.Ipv4ManagementAddresses.ElementsAs(ctx, &values, false)
+ for _, v := range values {
+ body = helpers.AppendFromXPath(body, data.getXPath()+"/management-address/ipv4", v)
+ }
+ }
+ if !data.Ipv6ManagementAddresses.IsNull() && !data.Ipv6ManagementAddresses.IsUnknown() {
+ var values []string
+ data.Ipv6ManagementAddresses.ElementsAs(ctx, &values, false)
+ for _, v := range values {
+ body = helpers.AppendFromXPath(body, data.getXPath()+"/management-address/ipv6", v)
+ }
+ }
+ if len(data.SystemNames) > 0 {
+ for _, item := range data.SystemNames {
+ cBody := netconf.Body{}
+ if !item.SwitchId.IsNull() && !item.SwitchId.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "switch-id", strconv.FormatInt(item.SwitchId.ValueInt64(), 10))
+ }
+ if !item.Name.IsNull() && !item.Name.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "name", item.Name.ValueString())
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/system-name", cBody.Res())
+ }
+ }
+ bodyString, err := body.String()
+ if err != nil {
+ tflog.Error(ctx, fmt.Sprintf("Error converting body to string: %s", err))
+ }
+ return bodyString
+}
+
+// End of section. //template:end toBodyXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBody
func (data *LLDP) updateFromBody(ctx context.Context, res gjson.Result) {
@@ -214,6 +283,81 @@ func (data *LLDP) updateFromBody(ctx context.Context, res gjson.Result) {
// End of section. //template:end updateFromBody
+// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBodyXML
+
+func (data *LLDP) updateFromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/run"); !data.Run.IsNull() {
+ if value.Exists() {
+ data.Run = types.BoolValue(true)
+ } else {
+ data.Run = types.BoolValue(false)
+ }
+ } else {
+ data.Run = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/holdtime"); value.Exists() && !data.Holdtime.IsNull() {
+ data.Holdtime = types.Int64Value(value.Int())
+ } else {
+ data.Holdtime = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/management-vlan"); value.Exists() && !data.ManagementVlan.IsNull() {
+ data.ManagementVlan = types.Int64Value(value.Int())
+ } else {
+ data.ManagementVlan = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/timer"); value.Exists() && !data.Timer.IsNull() {
+ data.Timer = types.Int64Value(value.Int())
+ } else {
+ data.Timer = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/management-address/ipv4"); value.Exists() && !data.Ipv4ManagementAddresses.IsNull() {
+ data.Ipv4ManagementAddresses = helpers.GetStringListXML(value.Array())
+ } else {
+ data.Ipv4ManagementAddresses = types.ListNull(types.StringType)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/management-address/ipv6"); value.Exists() && !data.Ipv6ManagementAddresses.IsNull() {
+ data.Ipv6ManagementAddresses = helpers.GetStringListXML(value.Array())
+ } else {
+ data.Ipv6ManagementAddresses = types.ListNull(types.StringType)
+ }
+ for i := range data.SystemNames {
+ keys := [...]string{"switch-id"}
+ keyValues := [...]string{strconv.FormatInt(data.SystemNames[i].SwitchId.ValueInt64(), 10)}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/system-name").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, "switch-id"); value.Exists() && !data.SystemNames[i].SwitchId.IsNull() {
+ data.SystemNames[i].SwitchId = types.Int64Value(value.Int())
+ } else {
+ data.SystemNames[i].SwitchId = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(r, "name"); value.Exists() && !data.SystemNames[i].Name.IsNull() {
+ data.SystemNames[i].Name = types.StringValue(value.String())
+ } else {
+ data.SystemNames[i].Name = types.StringNull()
+ }
+ }
+}
+
+// End of section. //template:end updateFromBodyXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin fromBody
func (data *LLDP) fromBody(ctx context.Context, res gjson.Result) {
@@ -312,6 +456,96 @@ func (data *LLDPData) fromBody(ctx context.Context, res gjson.Result) {
// End of section. //template:end fromBodyData
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyXML
+
+func (data *LLDP) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/run"); value.Exists() {
+ data.Run = types.BoolValue(true)
+ } else {
+ data.Run = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/holdtime"); value.Exists() {
+ data.Holdtime = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/management-vlan"); value.Exists() {
+ data.ManagementVlan = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/timer"); value.Exists() {
+ data.Timer = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/management-address/ipv4"); value.Exists() {
+ data.Ipv4ManagementAddresses = helpers.GetStringListXML(value.Array())
+ } else {
+ data.Ipv4ManagementAddresses = types.ListNull(types.StringType)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/management-address/ipv6"); value.Exists() {
+ data.Ipv6ManagementAddresses = helpers.GetStringListXML(value.Array())
+ } else {
+ data.Ipv6ManagementAddresses = types.ListNull(types.StringType)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/system-name"); value.Exists() {
+ data.SystemNames = make([]LLDPSystemNames, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := LLDPSystemNames{}
+ if cValue := helpers.GetFromXPath(v, "switch-id"); cValue.Exists() {
+ item.SwitchId = types.Int64Value(cValue.Int())
+ }
+ if cValue := helpers.GetFromXPath(v, "name"); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ data.SystemNames = append(data.SystemNames, item)
+ return true
+ })
+ }
+}
+
+// End of section. //template:end fromBodyXML
+
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyDataXML
+
+func (data *LLDPData) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/run"); value.Exists() {
+ data.Run = types.BoolValue(true)
+ } else {
+ data.Run = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/holdtime"); value.Exists() {
+ data.Holdtime = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/management-vlan"); value.Exists() {
+ data.ManagementVlan = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/timer"); value.Exists() {
+ data.Timer = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/management-address/ipv4"); value.Exists() {
+ data.Ipv4ManagementAddresses = helpers.GetStringListXML(value.Array())
+ } else {
+ data.Ipv4ManagementAddresses = types.ListNull(types.StringType)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/management-address/ipv6"); value.Exists() {
+ data.Ipv6ManagementAddresses = helpers.GetStringListXML(value.Array())
+ } else {
+ data.Ipv6ManagementAddresses = types.ListNull(types.StringType)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/system-name"); value.Exists() {
+ data.SystemNames = make([]LLDPSystemNames, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := LLDPSystemNames{}
+ if cValue := helpers.GetFromXPath(v, "switch-id"); cValue.Exists() {
+ item.SwitchId = types.Int64Value(cValue.Int())
+ }
+ if cValue := helpers.GetFromXPath(v, "name"); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ data.SystemNames = append(data.SystemNames, item)
+ return true
+ })
+ }
+}
+
+// End of section. //template:end fromBodyDataXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin getDeletedItems
func (data *LLDP) getDeletedItems(ctx context.Context, state LLDP) []string {
@@ -404,6 +638,103 @@ func (data *LLDP) getDeletedItems(ctx context.Context, state LLDP) []string {
// End of section. //template:end getDeletedItems
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletedItemsXML
+
+func (data *LLDP) addDeletedItemsXML(ctx context.Context, state LLDP, body string) string {
+ b := netconf.NewBody(body)
+ if !state.Run.IsNull() && data.Run.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/run")
+ }
+ if !state.Holdtime.IsNull() && data.Holdtime.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/holdtime")
+ }
+ if !state.ManagementVlan.IsNull() && data.ManagementVlan.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/management-vlan")
+ }
+ if !state.Timer.IsNull() && data.Timer.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/timer")
+ }
+ if !state.Ipv4ManagementAddresses.IsNull() {
+ if data.Ipv4ManagementAddresses.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/management-address/ipv4")
+ } else {
+ var dataValues, stateValues []string
+ data.Ipv4ManagementAddresses.ElementsAs(ctx, &dataValues, false)
+ state.Ipv4ManagementAddresses.ElementsAs(ctx, &stateValues, false)
+ for _, v := range stateValues {
+ found := false
+ for _, vv := range dataValues {
+ if v == vv {
+ found = true
+ break
+ }
+ }
+ if !found {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/management-address/ipv4[.=%v]", v))
+ }
+ }
+ }
+ }
+ if !state.Ipv6ManagementAddresses.IsNull() {
+ if data.Ipv6ManagementAddresses.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/management-address/ipv6")
+ } else {
+ var dataValues, stateValues []string
+ data.Ipv6ManagementAddresses.ElementsAs(ctx, &dataValues, false)
+ state.Ipv6ManagementAddresses.ElementsAs(ctx, &stateValues, false)
+ for _, v := range stateValues {
+ found := false
+ for _, vv := range dataValues {
+ if v == vv {
+ found = true
+ break
+ }
+ }
+ if !found {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/management-address/ipv6[.=%v]", v))
+ }
+ }
+ }
+ }
+ for i := range state.SystemNames {
+ stateKeys := [...]string{"switch-id"}
+ stateKeyValues := [...]string{strconv.FormatInt(state.SystemNames[i].SwitchId.ValueInt64(), 10)}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.SystemNames[i].SwitchId.ValueInt64()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.SystemNames {
+ found = true
+ if state.SystemNames[i].SwitchId.ValueInt64() != data.SystemNames[j].SwitchId.ValueInt64() {
+ found = false
+ }
+ if found {
+ if !state.SystemNames[i].Name.IsNull() && data.SystemNames[j].Name.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/system-name%v/name", predicates))
+ }
+ break
+ }
+ }
+ if !found {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/system-name%v", predicates))
+ }
+ }
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletedItemsXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin getEmptyLeafsDelete
func (data *LLDP) getEmptyLeafsDelete(ctx context.Context) []string {
@@ -450,3 +781,41 @@ func (data *LLDP) getDeletePaths(ctx context.Context) []string {
}
// End of section. //template:end getDeletePaths
+
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletePathsXML
+
+func (data *LLDP) addDeletePathsXML(ctx context.Context, body string) string {
+ b := netconf.NewBody(body)
+ if !data.Run.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/run")
+ }
+ if !data.Holdtime.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/holdtime")
+ }
+ if !data.ManagementVlan.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/management-vlan")
+ }
+ if !data.Timer.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/timer")
+ }
+ if !data.Ipv4ManagementAddresses.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/management-address/ipv4")
+ }
+ if !data.Ipv6ManagementAddresses.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/management-address/ipv6")
+ }
+ for i := range data.SystemNames {
+ keys := [...]string{"switch-id"}
+ keyValues := [...]string{strconv.FormatInt(data.SystemNames[i].SwitchId.ValueInt64(), 10)}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/system-name%v", predicates))
+ }
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletePathsXML
diff --git a/internal/provider/model_iosxe_logging.go b/internal/provider/model_iosxe_logging.go
index 73afc209..766b93e8 100644
--- a/internal/provider/model_iosxe_logging.go
+++ b/internal/provider/model_iosxe_logging.go
@@ -30,6 +30,9 @@ import (
"github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/types"
+ "github.com/hashicorp/terraform-plugin-log/tflog"
+ "github.com/netascode/go-netconf"
+ "github.com/netascode/xmldot"
"github.com/tidwall/gjson"
"github.com/tidwall/sjson"
)
@@ -206,6 +209,17 @@ func (data Logging) getPathShort() string {
return matches[1]
}
+// getXPath returns the XPath for NETCONF operations
+func (data Logging) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/logging"
+ return path
+}
+
+func (data LoggingData) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/logging"
+ return path
+}
+
// End of section. //template:end getPath
// Section below is generated&owned by "gen/generator.go". //template:begin toBody
@@ -465,6 +479,290 @@ func (data Logging) toBody(ctx context.Context) string {
// End of section. //template:end toBody
+// Section below is generated&owned by "gen/generator.go". //template:begin toBodyXML
+
+func (data Logging) toBodyXML(ctx context.Context) string {
+ body := netconf.Body{}
+ if !data.MonitorSeverity.IsNull() && !data.MonitorSeverity.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/monitor-config/common-config/monitor/severity", data.MonitorSeverity.ValueString())
+ }
+ if !data.BufferedSize.IsNull() && !data.BufferedSize.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/buffered/size-value", strconv.FormatInt(data.BufferedSize.ValueInt64(), 10))
+ }
+ if !data.BufferedSeverity.IsNull() && !data.BufferedSeverity.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/buffered/severity-level", data.BufferedSeverity.ValueString())
+ }
+ if !data.ConsoleSeverity.IsNull() && !data.ConsoleSeverity.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/console-config/common-config/console/severity", data.ConsoleSeverity.ValueString())
+ }
+ if !data.Facility.IsNull() && !data.Facility.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/facility", data.Facility.ValueString())
+ }
+ if !data.HistorySize.IsNull() && !data.HistorySize.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/history/size", strconv.FormatInt(data.HistorySize.ValueInt64(), 10))
+ }
+ if !data.HistorySeverity.IsNull() && !data.HistorySeverity.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/history/severity-level", data.HistorySeverity.ValueString())
+ }
+ if !data.Trap.IsNull() && !data.Trap.IsUnknown() {
+ if data.Trap.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/trap", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/trap")
+ }
+ }
+ if !data.TrapSeverity.IsNull() && !data.TrapSeverity.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/trap/severity", data.TrapSeverity.ValueString())
+ }
+ if !data.OriginIdType.IsNull() && !data.OriginIdType.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/origin-id/type-value", data.OriginIdType.ValueString())
+ }
+ if !data.OriginIdName.IsNull() && !data.OriginIdName.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/origin-id/string", data.OriginIdName.ValueString())
+ }
+ if !data.FileName.IsNull() && !data.FileName.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/file/name", data.FileName.ValueString())
+ }
+ if !data.FileMaxSize.IsNull() && !data.FileMaxSize.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/file/max-size", strconv.FormatInt(data.FileMaxSize.ValueInt64(), 10))
+ }
+ if !data.FileMinSize.IsNull() && !data.FileMinSize.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/file/min-size", strconv.FormatInt(data.FileMinSize.ValueInt64(), 10))
+ }
+ if !data.FileSeverity.IsNull() && !data.FileSeverity.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/file/severity", data.FileSeverity.ValueString())
+ }
+ if !data.SourceInterface.IsNull() && !data.SourceInterface.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/source-interface-conf/interface-name-non-vrf", data.SourceInterface.ValueString())
+ }
+ if !data.Console.IsNull() && !data.Console.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/console-config/console", data.Console.ValueBool())
+ }
+ if len(data.SourceInterfacesVrf) > 0 {
+ for _, item := range data.SourceInterfacesVrf {
+ cBody := netconf.Body{}
+ if !item.Vrf.IsNull() && !item.Vrf.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "vrf", item.Vrf.ValueString())
+ }
+ if !item.InterfaceName.IsNull() && !item.InterfaceName.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "interface-name", item.InterfaceName.ValueString())
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/source-interface-conf/source-interface-vrf", cBody.Res())
+ }
+ }
+ if len(data.Ipv4Hosts) > 0 {
+ for _, item := range data.Ipv4Hosts {
+ cBody := netconf.Body{}
+ if !item.Ipv4Host.IsNull() && !item.Ipv4Host.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "ipv4-host", item.Ipv4Host.ValueString())
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/host/ipv4-host-list", cBody.Res())
+ }
+ }
+ if len(data.Ipv4HostsTransport) > 0 {
+ for _, item := range data.Ipv4HostsTransport {
+ cBody := netconf.Body{}
+ if !item.Ipv4Host.IsNull() && !item.Ipv4Host.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "ipv4-host", item.Ipv4Host.ValueString())
+ }
+ if len(item.TransportUdpPorts) > 0 {
+ for _, citem := range item.TransportUdpPorts {
+ ccBody := netconf.Body{}
+ if !citem.PortNumber.IsNull() && !citem.PortNumber.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "port-number", strconv.FormatInt(citem.PortNumber.ValueInt64(), 10))
+ }
+ cBody = helpers.SetRawFromXPath(cBody, "transport/udp/port-config", ccBody.Res())
+ }
+ }
+ if len(item.TransportTcpPorts) > 0 {
+ for _, citem := range item.TransportTcpPorts {
+ ccBody := netconf.Body{}
+ if !citem.PortNumber.IsNull() && !citem.PortNumber.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "port-number", strconv.FormatInt(citem.PortNumber.ValueInt64(), 10))
+ }
+ cBody = helpers.SetRawFromXPath(cBody, "transport/tcp/port-config", ccBody.Res())
+ }
+ }
+ if len(item.TransportTlsPorts) > 0 {
+ for _, citem := range item.TransportTlsPorts {
+ ccBody := netconf.Body{}
+ if !citem.PortNumber.IsNull() && !citem.PortNumber.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "port-number", strconv.FormatInt(citem.PortNumber.ValueInt64(), 10))
+ }
+ if !citem.Profile.IsNull() && !citem.Profile.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "profile", citem.Profile.ValueString())
+ }
+ cBody = helpers.SetRawFromXPath(cBody, "transport/tls/port", ccBody.Res())
+ }
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/host/ipv4-host-transport-list", cBody.Res())
+ }
+ }
+ if len(data.Ipv4VrfHosts) > 0 {
+ for _, item := range data.Ipv4VrfHosts {
+ cBody := netconf.Body{}
+ if !item.Ipv4Host.IsNull() && !item.Ipv4Host.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "ipv4-host", item.Ipv4Host.ValueString())
+ }
+ if !item.Vrf.IsNull() && !item.Vrf.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "vrf", item.Vrf.ValueString())
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/host/ipv4-host-vrf-list", cBody.Res())
+ }
+ }
+ if len(data.Ipv4VrfHostsTransport) > 0 {
+ for _, item := range data.Ipv4VrfHostsTransport {
+ cBody := netconf.Body{}
+ if !item.Ipv4Host.IsNull() && !item.Ipv4Host.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "ipv4-host", item.Ipv4Host.ValueString())
+ }
+ if !item.Vrf.IsNull() && !item.Vrf.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "vrf", item.Vrf.ValueString())
+ }
+ if len(item.TransportUdpPorts) > 0 {
+ for _, citem := range item.TransportUdpPorts {
+ ccBody := netconf.Body{}
+ if !citem.PortNumber.IsNull() && !citem.PortNumber.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "port-number", strconv.FormatInt(citem.PortNumber.ValueInt64(), 10))
+ }
+ cBody = helpers.SetRawFromXPath(cBody, "transport/udp/port-config", ccBody.Res())
+ }
+ }
+ if len(item.TransportTcpPorts) > 0 {
+ for _, citem := range item.TransportTcpPorts {
+ ccBody := netconf.Body{}
+ if !citem.PortNumber.IsNull() && !citem.PortNumber.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "port-number", strconv.FormatInt(citem.PortNumber.ValueInt64(), 10))
+ }
+ cBody = helpers.SetRawFromXPath(cBody, "transport/tcp/port-config", ccBody.Res())
+ }
+ }
+ if len(item.TransportTlsPorts) > 0 {
+ for _, citem := range item.TransportTlsPorts {
+ ccBody := netconf.Body{}
+ if !citem.PortNumber.IsNull() && !citem.PortNumber.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "port-number", strconv.FormatInt(citem.PortNumber.ValueInt64(), 10))
+ }
+ if !citem.Profile.IsNull() && !citem.Profile.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "profile", citem.Profile.ValueString())
+ }
+ cBody = helpers.SetRawFromXPath(cBody, "transport/tls/port", ccBody.Res())
+ }
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/host/ipv4-host-vrf-transport-list", cBody.Res())
+ }
+ }
+ if len(data.Ipv6Hosts) > 0 {
+ for _, item := range data.Ipv6Hosts {
+ cBody := netconf.Body{}
+ if !item.Ipv6Host.IsNull() && !item.Ipv6Host.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "ipv6-host", item.Ipv6Host.ValueString())
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/host/ipv6/ipv6-host-list", cBody.Res())
+ }
+ }
+ if len(data.Ipv6HostsTransport) > 0 {
+ for _, item := range data.Ipv6HostsTransport {
+ cBody := netconf.Body{}
+ if !item.Ipv6Host.IsNull() && !item.Ipv6Host.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "ipv6-host", item.Ipv6Host.ValueString())
+ }
+ if len(item.TransportUdpPorts) > 0 {
+ for _, citem := range item.TransportUdpPorts {
+ ccBody := netconf.Body{}
+ if !citem.PortNumber.IsNull() && !citem.PortNumber.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "port-number", strconv.FormatInt(citem.PortNumber.ValueInt64(), 10))
+ }
+ cBody = helpers.SetRawFromXPath(cBody, "transport/udp/port-config", ccBody.Res())
+ }
+ }
+ if len(item.TransportTcpPorts) > 0 {
+ for _, citem := range item.TransportTcpPorts {
+ ccBody := netconf.Body{}
+ if !citem.PortNumber.IsNull() && !citem.PortNumber.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "port-number", strconv.FormatInt(citem.PortNumber.ValueInt64(), 10))
+ }
+ cBody = helpers.SetRawFromXPath(cBody, "transport/tcp/port-config", ccBody.Res())
+ }
+ }
+ if len(item.TransportTlsPorts) > 0 {
+ for _, citem := range item.TransportTlsPorts {
+ ccBody := netconf.Body{}
+ if !citem.PortNumber.IsNull() && !citem.PortNumber.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "port-number", strconv.FormatInt(citem.PortNumber.ValueInt64(), 10))
+ }
+ if !citem.Profile.IsNull() && !citem.Profile.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "profile", citem.Profile.ValueString())
+ }
+ cBody = helpers.SetRawFromXPath(cBody, "transport/tls/port", ccBody.Res())
+ }
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/host/ipv6/ipv6-host-transport-list", cBody.Res())
+ }
+ }
+ if len(data.Ipv6VrfHosts) > 0 {
+ for _, item := range data.Ipv6VrfHosts {
+ cBody := netconf.Body{}
+ if !item.Ipv6Host.IsNull() && !item.Ipv6Host.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "ipv6-host", item.Ipv6Host.ValueString())
+ }
+ if !item.Vrf.IsNull() && !item.Vrf.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "vrf", item.Vrf.ValueString())
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/host/ipv6/ipv6-host-vrf-list", cBody.Res())
+ }
+ }
+ if len(data.Ipv6VrfHostsTransport) > 0 {
+ for _, item := range data.Ipv6VrfHostsTransport {
+ cBody := netconf.Body{}
+ if !item.Ipv6Host.IsNull() && !item.Ipv6Host.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "ipv6-host", item.Ipv6Host.ValueString())
+ }
+ if !item.Vrf.IsNull() && !item.Vrf.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "vrf", item.Vrf.ValueString())
+ }
+ if len(item.TransportUdpPorts) > 0 {
+ for _, citem := range item.TransportUdpPorts {
+ ccBody := netconf.Body{}
+ if !citem.PortNumber.IsNull() && !citem.PortNumber.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "port-number", strconv.FormatInt(citem.PortNumber.ValueInt64(), 10))
+ }
+ cBody = helpers.SetRawFromXPath(cBody, "transport/udp/port-config", ccBody.Res())
+ }
+ }
+ if len(item.TransportTcpPorts) > 0 {
+ for _, citem := range item.TransportTcpPorts {
+ ccBody := netconf.Body{}
+ if !citem.PortNumber.IsNull() && !citem.PortNumber.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "port-number", strconv.FormatInt(citem.PortNumber.ValueInt64(), 10))
+ }
+ cBody = helpers.SetRawFromXPath(cBody, "transport/tcp/port-config", ccBody.Res())
+ }
+ }
+ if len(item.TransportTlsPorts) > 0 {
+ for _, citem := range item.TransportTlsPorts {
+ ccBody := netconf.Body{}
+ if !citem.PortNumber.IsNull() && !citem.PortNumber.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "port-number", strconv.FormatInt(citem.PortNumber.ValueInt64(), 10))
+ }
+ if !citem.Profile.IsNull() && !citem.Profile.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "profile", citem.Profile.ValueString())
+ }
+ cBody = helpers.SetRawFromXPath(cBody, "transport/tls/port", ccBody.Res())
+ }
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/host/ipv6/ipv6-host-vrf-transport-list", cBody.Res())
+ }
+ }
+ bodyString, err := body.String()
+ if err != nil {
+ tflog.Error(ctx, fmt.Sprintf("Error converting body to string: %s", err))
+ }
+ return bodyString
+}
+
+// End of section. //template:end toBodyXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBody
func (data *Logging) updateFromBody(ctx context.Context, res gjson.Result) {
@@ -1221,666 +1519,2769 @@ func (data *Logging) updateFromBody(ctx context.Context, res gjson.Result) {
// End of section. //template:end updateFromBody
-// Section below is generated&owned by "gen/generator.go". //template:begin fromBody
+// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBodyXML
-func (data *Logging) fromBody(ctx context.Context, res gjson.Result) {
- prefix := helpers.LastElement(data.getPath()) + "."
- if res.Get(helpers.LastElement(data.getPath())).IsArray() {
- prefix += "0."
- }
- if value := res.Get(prefix + "monitor-config.common-config.monitor.severity"); value.Exists() {
+func (data *Logging) updateFromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/monitor-config/common-config/monitor/severity"); value.Exists() && !data.MonitorSeverity.IsNull() {
data.MonitorSeverity = types.StringValue(value.String())
+ } else {
+ data.MonitorSeverity = types.StringNull()
}
- if value := res.Get(prefix + "buffered.size-value"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/buffered/size-value"); value.Exists() && !data.BufferedSize.IsNull() {
data.BufferedSize = types.Int64Value(value.Int())
+ } else {
+ data.BufferedSize = types.Int64Null()
}
- if value := res.Get(prefix + "buffered.severity-level"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/buffered/severity-level"); value.Exists() && !data.BufferedSeverity.IsNull() {
data.BufferedSeverity = types.StringValue(value.String())
+ } else {
+ data.BufferedSeverity = types.StringNull()
}
- if value := res.Get(prefix + "console-config.common-config.console.severity"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/console-config/common-config/console/severity"); value.Exists() && !data.ConsoleSeverity.IsNull() {
data.ConsoleSeverity = types.StringValue(value.String())
+ } else {
+ data.ConsoleSeverity = types.StringNull()
}
- if value := res.Get(prefix + "facility"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/facility"); value.Exists() && !data.Facility.IsNull() {
data.Facility = types.StringValue(value.String())
+ } else {
+ data.Facility = types.StringNull()
}
- if value := res.Get(prefix + "history.size"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/history/size"); value.Exists() && !data.HistorySize.IsNull() {
data.HistorySize = types.Int64Value(value.Int())
+ } else {
+ data.HistorySize = types.Int64Null()
}
- if value := res.Get(prefix + "history.severity-level"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/history/severity-level"); value.Exists() && !data.HistorySeverity.IsNull() {
data.HistorySeverity = types.StringValue(value.String())
+ } else {
+ data.HistorySeverity = types.StringNull()
}
- if value := res.Get(prefix + "trap"); value.Exists() {
- data.Trap = types.BoolValue(true)
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/trap"); !data.Trap.IsNull() {
+ if value.Exists() {
+ data.Trap = types.BoolValue(true)
+ } else {
+ data.Trap = types.BoolValue(false)
+ }
} else {
- data.Trap = types.BoolValue(false)
+ data.Trap = types.BoolNull()
}
- if value := res.Get(prefix + "trap.severity"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/trap/severity"); value.Exists() && !data.TrapSeverity.IsNull() {
data.TrapSeverity = types.StringValue(value.String())
+ } else {
+ data.TrapSeverity = types.StringNull()
}
- if value := res.Get(prefix + "origin-id.type-value"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/origin-id/type-value"); value.Exists() && !data.OriginIdType.IsNull() {
data.OriginIdType = types.StringValue(value.String())
+ } else {
+ data.OriginIdType = types.StringNull()
}
- if value := res.Get(prefix + "origin-id.string"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/origin-id/string"); value.Exists() && !data.OriginIdName.IsNull() {
data.OriginIdName = types.StringValue(value.String())
+ } else {
+ data.OriginIdName = types.StringNull()
}
- if value := res.Get(prefix + "file.name"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/file/name"); value.Exists() && !data.FileName.IsNull() {
data.FileName = types.StringValue(value.String())
+ } else {
+ data.FileName = types.StringNull()
}
- if value := res.Get(prefix + "file.max-size"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/file/max-size"); value.Exists() && !data.FileMaxSize.IsNull() {
data.FileMaxSize = types.Int64Value(value.Int())
+ } else {
+ data.FileMaxSize = types.Int64Null()
}
- if value := res.Get(prefix + "file.min-size"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/file/min-size"); value.Exists() && !data.FileMinSize.IsNull() {
data.FileMinSize = types.Int64Value(value.Int())
+ } else {
+ data.FileMinSize = types.Int64Null()
}
- if value := res.Get(prefix + "file.severity"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/file/severity"); value.Exists() && !data.FileSeverity.IsNull() {
data.FileSeverity = types.StringValue(value.String())
+ } else {
+ data.FileSeverity = types.StringNull()
}
- if value := res.Get(prefix + "source-interface-conf.interface-name-non-vrf"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/source-interface-conf/interface-name-non-vrf"); value.Exists() && !data.SourceInterface.IsNull() {
data.SourceInterface = types.StringValue(value.String())
+ } else {
+ data.SourceInterface = types.StringNull()
}
- if value := res.Get(prefix + "console-config.console"); value.Exists() {
- data.Console = types.BoolValue(value.Bool())
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/console-config/console"); !data.Console.IsNull() {
+ if value.Exists() {
+ data.Console = types.BoolValue(value.Bool())
+ }
} else {
data.Console = types.BoolNull()
}
- if value := res.Get(prefix + "source-interface-conf.source-interface-vrf"); value.Exists() {
- data.SourceInterfacesVrf = make([]LoggingSourceInterfacesVrf, 0)
- value.ForEach(func(k, v gjson.Result) bool {
- item := LoggingSourceInterfacesVrf{}
- if cValue := v.Get("vrf"); cValue.Exists() {
- item.Vrf = types.StringValue(cValue.String())
- }
- if cValue := v.Get("interface-name"); cValue.Exists() {
- item.InterfaceName = types.StringValue(cValue.String())
- }
- data.SourceInterfacesVrf = append(data.SourceInterfacesVrf, item)
- return true
- })
- }
- if value := res.Get(prefix + "host.ipv4-host-list"); value.Exists() {
- data.Ipv4Hosts = make([]LoggingIpv4Hosts, 0)
- value.ForEach(func(k, v gjson.Result) bool {
- item := LoggingIpv4Hosts{}
- if cValue := v.Get("ipv4-host"); cValue.Exists() {
- item.Ipv4Host = types.StringValue(cValue.String())
- }
- data.Ipv4Hosts = append(data.Ipv4Hosts, item)
- return true
- })
+ for i := range data.SourceInterfacesVrf {
+ keys := [...]string{"vrf"}
+ keyValues := [...]string{data.SourceInterfacesVrf[i].Vrf.ValueString()}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/source-interface-conf/source-interface-vrf").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, "vrf"); value.Exists() && !data.SourceInterfacesVrf[i].Vrf.IsNull() {
+ data.SourceInterfacesVrf[i].Vrf = types.StringValue(value.String())
+ } else {
+ data.SourceInterfacesVrf[i].Vrf = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "interface-name"); value.Exists() && !data.SourceInterfacesVrf[i].InterfaceName.IsNull() {
+ data.SourceInterfacesVrf[i].InterfaceName = types.StringValue(value.String())
+ } else {
+ data.SourceInterfacesVrf[i].InterfaceName = types.StringNull()
+ }
}
- if value := res.Get(prefix + "host.ipv4-host-transport-list"); value.Exists() {
- data.Ipv4HostsTransport = make([]LoggingIpv4HostsTransport, 0)
- value.ForEach(func(k, v gjson.Result) bool {
- item := LoggingIpv4HostsTransport{}
- if cValue := v.Get("ipv4-host"); cValue.Exists() {
- item.Ipv4Host = types.StringValue(cValue.String())
- }
- if cValue := v.Get("transport.udp.port-config"); cValue.Exists() {
- item.TransportUdpPorts = make([]LoggingIpv4HostsTransportTransportUdpPorts, 0)
- cValue.ForEach(func(ck, cv gjson.Result) bool {
- cItem := LoggingIpv4HostsTransportTransportUdpPorts{}
- if ccValue := cv.Get("port-number"); ccValue.Exists() {
- cItem.PortNumber = types.Int64Value(ccValue.Int())
+ for i := range data.Ipv4Hosts {
+ keys := [...]string{"ipv4-host"}
+ keyValues := [...]string{data.Ipv4Hosts[i].Ipv4Host.ValueString()}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/host/ipv4-host-list").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
}
- item.TransportUdpPorts = append(item.TransportUdpPorts, cItem)
- return true
- })
- }
- if cValue := v.Get("transport.tcp.port-config"); cValue.Exists() {
- item.TransportTcpPorts = make([]LoggingIpv4HostsTransportTransportTcpPorts, 0)
- cValue.ForEach(func(ck, cv gjson.Result) bool {
- cItem := LoggingIpv4HostsTransportTransportTcpPorts{}
- if ccValue := cv.Get("port-number"); ccValue.Exists() {
- cItem.PortNumber = types.Int64Value(ccValue.Int())
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, "ipv4-host"); value.Exists() && !data.Ipv4Hosts[i].Ipv4Host.IsNull() {
+ data.Ipv4Hosts[i].Ipv4Host = types.StringValue(value.String())
+ } else {
+ data.Ipv4Hosts[i].Ipv4Host = types.StringNull()
+ }
+ }
+ for i := range data.Ipv4HostsTransport {
+ keys := [...]string{"ipv4-host"}
+ keyValues := [...]string{data.Ipv4HostsTransport[i].Ipv4Host.ValueString()}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/host/ipv4-host-transport-list").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
}
- item.TransportTcpPorts = append(item.TransportTcpPorts, cItem)
- return true
- })
- }
- if cValue := v.Get("transport.tls.port"); cValue.Exists() {
- item.TransportTlsPorts = make([]LoggingIpv4HostsTransportTransportTlsPorts, 0)
- cValue.ForEach(func(ck, cv gjson.Result) bool {
- cItem := LoggingIpv4HostsTransportTransportTlsPorts{}
- if ccValue := cv.Get("port-number"); ccValue.Exists() {
- cItem.PortNumber = types.Int64Value(ccValue.Int())
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, "ipv4-host"); value.Exists() && !data.Ipv4HostsTransport[i].Ipv4Host.IsNull() {
+ data.Ipv4HostsTransport[i].Ipv4Host = types.StringValue(value.String())
+ } else {
+ data.Ipv4HostsTransport[i].Ipv4Host = types.StringNull()
+ }
+ for ci := range data.Ipv4HostsTransport[i].TransportUdpPorts {
+ keys := [...]string{"port-number"}
+ keyValues := [...]string{strconv.FormatInt(data.Ipv4HostsTransport[i].TransportUdpPorts[ci].PortNumber.ValueInt64(), 10)}
+
+ var cr xmldot.Result
+ helpers.GetFromXPath(r, "transport/udp/port-config").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
}
- if ccValue := cv.Get("profile"); ccValue.Exists() {
- cItem.Profile = types.StringValue(ccValue.String())
+ if found {
+ cr = v
+ return false
}
- item.TransportTlsPorts = append(item.TransportTlsPorts, cItem)
return true
- })
- }
- data.Ipv4HostsTransport = append(data.Ipv4HostsTransport, item)
- return true
- })
- }
- if value := res.Get(prefix + "host.ipv4-host-vrf-list"); value.Exists() {
- data.Ipv4VrfHosts = make([]LoggingIpv4VrfHosts, 0)
- value.ForEach(func(k, v gjson.Result) bool {
- item := LoggingIpv4VrfHosts{}
- if cValue := v.Get("ipv4-host"); cValue.Exists() {
- item.Ipv4Host = types.StringValue(cValue.String())
- }
- if cValue := v.Get("vrf"); cValue.Exists() {
- item.Vrf = types.StringValue(cValue.String())
- }
- data.Ipv4VrfHosts = append(data.Ipv4VrfHosts, item)
- return true
- })
- }
- if value := res.Get(prefix + "host.ipv4-host-vrf-transport-list"); value.Exists() {
- data.Ipv4VrfHostsTransport = make([]LoggingIpv4VrfHostsTransport, 0)
- value.ForEach(func(k, v gjson.Result) bool {
- item := LoggingIpv4VrfHostsTransport{}
- if cValue := v.Get("ipv4-host"); cValue.Exists() {
- item.Ipv4Host = types.StringValue(cValue.String())
- }
- if cValue := v.Get("vrf"); cValue.Exists() {
- item.Vrf = types.StringValue(cValue.String())
+ },
+ )
+ if value := helpers.GetFromXPath(cr, "port-number"); value.Exists() && !data.Ipv4HostsTransport[i].TransportUdpPorts[ci].PortNumber.IsNull() {
+ data.Ipv4HostsTransport[i].TransportUdpPorts[ci].PortNumber = types.Int64Value(value.Int())
+ } else {
+ data.Ipv4HostsTransport[i].TransportUdpPorts[ci].PortNumber = types.Int64Null()
}
- if cValue := v.Get("transport.udp.port-config"); cValue.Exists() {
- item.TransportUdpPorts = make([]LoggingIpv4VrfHostsTransportTransportUdpPorts, 0)
- cValue.ForEach(func(ck, cv gjson.Result) bool {
- cItem := LoggingIpv4VrfHostsTransportTransportUdpPorts{}
- if ccValue := cv.Get("port-number"); ccValue.Exists() {
- cItem.PortNumber = types.Int64Value(ccValue.Int())
+ }
+ for ci := range data.Ipv4HostsTransport[i].TransportTcpPorts {
+ keys := [...]string{"port-number"}
+ keyValues := [...]string{strconv.FormatInt(data.Ipv4HostsTransport[i].TransportTcpPorts[ci].PortNumber.ValueInt64(), 10)}
+
+ var cr xmldot.Result
+ helpers.GetFromXPath(r, "transport/tcp/port-config").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
}
- item.TransportUdpPorts = append(item.TransportUdpPorts, cItem)
- return true
- })
- }
- if cValue := v.Get("transport.tcp.port-config"); cValue.Exists() {
- item.TransportTcpPorts = make([]LoggingIpv4VrfHostsTransportTransportTcpPorts, 0)
- cValue.ForEach(func(ck, cv gjson.Result) bool {
- cItem := LoggingIpv4VrfHostsTransportTransportTcpPorts{}
- if ccValue := cv.Get("port-number"); ccValue.Exists() {
- cItem.PortNumber = types.Int64Value(ccValue.Int())
+ if found {
+ cr = v
+ return false
}
- item.TransportTcpPorts = append(item.TransportTcpPorts, cItem)
return true
- })
+ },
+ )
+ if value := helpers.GetFromXPath(cr, "port-number"); value.Exists() && !data.Ipv4HostsTransport[i].TransportTcpPorts[ci].PortNumber.IsNull() {
+ data.Ipv4HostsTransport[i].TransportTcpPorts[ci].PortNumber = types.Int64Value(value.Int())
+ } else {
+ data.Ipv4HostsTransport[i].TransportTcpPorts[ci].PortNumber = types.Int64Null()
}
- if cValue := v.Get("transport.tls.port"); cValue.Exists() {
- item.TransportTlsPorts = make([]LoggingIpv4VrfHostsTransportTransportTlsPorts, 0)
- cValue.ForEach(func(ck, cv gjson.Result) bool {
- cItem := LoggingIpv4VrfHostsTransportTransportTlsPorts{}
- if ccValue := cv.Get("port-number"); ccValue.Exists() {
- cItem.PortNumber = types.Int64Value(ccValue.Int())
+ }
+ for ci := range data.Ipv4HostsTransport[i].TransportTlsPorts {
+ keys := [...]string{"port-number"}
+ keyValues := [...]string{strconv.FormatInt(data.Ipv4HostsTransport[i].TransportTlsPorts[ci].PortNumber.ValueInt64(), 10)}
+
+ var cr xmldot.Result
+ helpers.GetFromXPath(r, "transport/tls/port").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
}
- if ccValue := cv.Get("profile"); ccValue.Exists() {
- cItem.Profile = types.StringValue(ccValue.String())
+ if found {
+ cr = v
+ return false
}
- item.TransportTlsPorts = append(item.TransportTlsPorts, cItem)
return true
- })
+ },
+ )
+ if value := helpers.GetFromXPath(cr, "port-number"); value.Exists() && !data.Ipv4HostsTransport[i].TransportTlsPorts[ci].PortNumber.IsNull() {
+ data.Ipv4HostsTransport[i].TransportTlsPorts[ci].PortNumber = types.Int64Value(value.Int())
+ } else {
+ data.Ipv4HostsTransport[i].TransportTlsPorts[ci].PortNumber = types.Int64Null()
}
- data.Ipv4VrfHostsTransport = append(data.Ipv4VrfHostsTransport, item)
- return true
- })
- }
- if value := res.Get(prefix + "host.ipv6.ipv6-host-list"); value.Exists() {
- data.Ipv6Hosts = make([]LoggingIpv6Hosts, 0)
- value.ForEach(func(k, v gjson.Result) bool {
- item := LoggingIpv6Hosts{}
- if cValue := v.Get("ipv6-host"); cValue.Exists() {
- item.Ipv6Host = types.StringValue(cValue.String())
+ if value := helpers.GetFromXPath(cr, "profile"); value.Exists() && !data.Ipv4HostsTransport[i].TransportTlsPorts[ci].Profile.IsNull() {
+ data.Ipv4HostsTransport[i].TransportTlsPorts[ci].Profile = types.StringValue(value.String())
+ } else {
+ data.Ipv4HostsTransport[i].TransportTlsPorts[ci].Profile = types.StringNull()
}
- data.Ipv6Hosts = append(data.Ipv6Hosts, item)
- return true
- })
+ }
}
- if value := res.Get(prefix + "host.ipv6.ipv6-host-transport-list"); value.Exists() {
- data.Ipv6HostsTransport = make([]LoggingIpv6HostsTransport, 0)
- value.ForEach(func(k, v gjson.Result) bool {
- item := LoggingIpv6HostsTransport{}
- if cValue := v.Get("ipv6-host"); cValue.Exists() {
- item.Ipv6Host = types.StringValue(cValue.String())
- }
- if cValue := v.Get("transport.udp.port-config"); cValue.Exists() {
- item.TransportUdpPorts = make([]LoggingIpv6HostsTransportTransportUdpPorts, 0)
- cValue.ForEach(func(ck, cv gjson.Result) bool {
- cItem := LoggingIpv6HostsTransportTransportUdpPorts{}
- if ccValue := cv.Get("port-number"); ccValue.Exists() {
- cItem.PortNumber = types.Int64Value(ccValue.Int())
+ for i := range data.Ipv4VrfHosts {
+ keys := [...]string{"ipv4-host", "vrf"}
+ keyValues := [...]string{data.Ipv4VrfHosts[i].Ipv4Host.ValueString(), data.Ipv4VrfHosts[i].Vrf.ValueString()}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/host/ipv4-host-vrf-list").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
}
- item.TransportUdpPorts = append(item.TransportUdpPorts, cItem)
- return true
- })
- }
- if cValue := v.Get("transport.tcp.port-config"); cValue.Exists() {
- item.TransportTcpPorts = make([]LoggingIpv6HostsTransportTransportTcpPorts, 0)
- cValue.ForEach(func(ck, cv gjson.Result) bool {
- cItem := LoggingIpv6HostsTransportTransportTcpPorts{}
- if ccValue := cv.Get("port-number"); ccValue.Exists() {
- cItem.PortNumber = types.Int64Value(ccValue.Int())
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, "ipv4-host"); value.Exists() && !data.Ipv4VrfHosts[i].Ipv4Host.IsNull() {
+ data.Ipv4VrfHosts[i].Ipv4Host = types.StringValue(value.String())
+ } else {
+ data.Ipv4VrfHosts[i].Ipv4Host = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "vrf"); value.Exists() && !data.Ipv4VrfHosts[i].Vrf.IsNull() {
+ data.Ipv4VrfHosts[i].Vrf = types.StringValue(value.String())
+ } else {
+ data.Ipv4VrfHosts[i].Vrf = types.StringNull()
+ }
+ }
+ for i := range data.Ipv4VrfHostsTransport {
+ keys := [...]string{"ipv4-host", "vrf"}
+ keyValues := [...]string{data.Ipv4VrfHostsTransport[i].Ipv4Host.ValueString(), data.Ipv4VrfHostsTransport[i].Vrf.ValueString()}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/host/ipv4-host-vrf-transport-list").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
}
- item.TransportTcpPorts = append(item.TransportTcpPorts, cItem)
- return true
- })
- }
- if cValue := v.Get("transport.tls.port"); cValue.Exists() {
- item.TransportTlsPorts = make([]LoggingIpv6HostsTransportTransportTlsPorts, 0)
- cValue.ForEach(func(ck, cv gjson.Result) bool {
- cItem := LoggingIpv6HostsTransportTransportTlsPorts{}
- if ccValue := cv.Get("port-number"); ccValue.Exists() {
- cItem.PortNumber = types.Int64Value(ccValue.Int())
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, "ipv4-host"); value.Exists() && !data.Ipv4VrfHostsTransport[i].Ipv4Host.IsNull() {
+ data.Ipv4VrfHostsTransport[i].Ipv4Host = types.StringValue(value.String())
+ } else {
+ data.Ipv4VrfHostsTransport[i].Ipv4Host = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "vrf"); value.Exists() && !data.Ipv4VrfHostsTransport[i].Vrf.IsNull() {
+ data.Ipv4VrfHostsTransport[i].Vrf = types.StringValue(value.String())
+ } else {
+ data.Ipv4VrfHostsTransport[i].Vrf = types.StringNull()
+ }
+ for ci := range data.Ipv4VrfHostsTransport[i].TransportUdpPorts {
+ keys := [...]string{"port-number"}
+ keyValues := [...]string{strconv.FormatInt(data.Ipv4VrfHostsTransport[i].TransportUdpPorts[ci].PortNumber.ValueInt64(), 10)}
+
+ var cr xmldot.Result
+ helpers.GetFromXPath(r, "transport/udp/port-config").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
}
- if ccValue := cv.Get("profile"); ccValue.Exists() {
- cItem.Profile = types.StringValue(ccValue.String())
+ if found {
+ cr = v
+ return false
}
- item.TransportTlsPorts = append(item.TransportTlsPorts, cItem)
return true
- })
- }
- data.Ipv6HostsTransport = append(data.Ipv6HostsTransport, item)
- return true
- })
- }
- if value := res.Get(prefix + "host.ipv6.ipv6-host-vrf-list"); value.Exists() {
- data.Ipv6VrfHosts = make([]LoggingIpv6VrfHosts, 0)
- value.ForEach(func(k, v gjson.Result) bool {
- item := LoggingIpv6VrfHosts{}
- if cValue := v.Get("ipv6-host"); cValue.Exists() {
- item.Ipv6Host = types.StringValue(cValue.String())
- }
- if cValue := v.Get("vrf"); cValue.Exists() {
- item.Vrf = types.StringValue(cValue.String())
- }
- data.Ipv6VrfHosts = append(data.Ipv6VrfHosts, item)
- return true
- })
- }
- if value := res.Get(prefix + "host.ipv6.ipv6-host-vrf-transport-list"); value.Exists() {
- data.Ipv6VrfHostsTransport = make([]LoggingIpv6VrfHostsTransport, 0)
- value.ForEach(func(k, v gjson.Result) bool {
- item := LoggingIpv6VrfHostsTransport{}
- if cValue := v.Get("ipv6-host"); cValue.Exists() {
- item.Ipv6Host = types.StringValue(cValue.String())
- }
- if cValue := v.Get("vrf"); cValue.Exists() {
- item.Vrf = types.StringValue(cValue.String())
+ },
+ )
+ if value := helpers.GetFromXPath(cr, "port-number"); value.Exists() && !data.Ipv4VrfHostsTransport[i].TransportUdpPorts[ci].PortNumber.IsNull() {
+ data.Ipv4VrfHostsTransport[i].TransportUdpPorts[ci].PortNumber = types.Int64Value(value.Int())
+ } else {
+ data.Ipv4VrfHostsTransport[i].TransportUdpPorts[ci].PortNumber = types.Int64Null()
}
- if cValue := v.Get("transport.udp.port-config"); cValue.Exists() {
- item.TransportUdpPorts = make([]LoggingIpv6VrfHostsTransportTransportUdpPorts, 0)
- cValue.ForEach(func(ck, cv gjson.Result) bool {
- cItem := LoggingIpv6VrfHostsTransportTransportUdpPorts{}
- if ccValue := cv.Get("port-number"); ccValue.Exists() {
- cItem.PortNumber = types.Int64Value(ccValue.Int())
+ }
+ for ci := range data.Ipv4VrfHostsTransport[i].TransportTcpPorts {
+ keys := [...]string{"port-number"}
+ keyValues := [...]string{strconv.FormatInt(data.Ipv4VrfHostsTransport[i].TransportTcpPorts[ci].PortNumber.ValueInt64(), 10)}
+
+ var cr xmldot.Result
+ helpers.GetFromXPath(r, "transport/tcp/port-config").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
}
- item.TransportUdpPorts = append(item.TransportUdpPorts, cItem)
- return true
- })
- }
- if cValue := v.Get("transport.tcp.port-config"); cValue.Exists() {
- item.TransportTcpPorts = make([]LoggingIpv6VrfHostsTransportTransportTcpPorts, 0)
- cValue.ForEach(func(ck, cv gjson.Result) bool {
- cItem := LoggingIpv6VrfHostsTransportTransportTcpPorts{}
- if ccValue := cv.Get("port-number"); ccValue.Exists() {
- cItem.PortNumber = types.Int64Value(ccValue.Int())
+ if found {
+ cr = v
+ return false
}
- item.TransportTcpPorts = append(item.TransportTcpPorts, cItem)
return true
- })
+ },
+ )
+ if value := helpers.GetFromXPath(cr, "port-number"); value.Exists() && !data.Ipv4VrfHostsTransport[i].TransportTcpPorts[ci].PortNumber.IsNull() {
+ data.Ipv4VrfHostsTransport[i].TransportTcpPorts[ci].PortNumber = types.Int64Value(value.Int())
+ } else {
+ data.Ipv4VrfHostsTransport[i].TransportTcpPorts[ci].PortNumber = types.Int64Null()
}
- if cValue := v.Get("transport.tls.port"); cValue.Exists() {
- item.TransportTlsPorts = make([]LoggingIpv6VrfHostsTransportTransportTlsPorts, 0)
- cValue.ForEach(func(ck, cv gjson.Result) bool {
- cItem := LoggingIpv6VrfHostsTransportTransportTlsPorts{}
- if ccValue := cv.Get("port-number"); ccValue.Exists() {
- cItem.PortNumber = types.Int64Value(ccValue.Int())
+ }
+ for ci := range data.Ipv4VrfHostsTransport[i].TransportTlsPorts {
+ keys := [...]string{"port-number"}
+ keyValues := [...]string{strconv.FormatInt(data.Ipv4VrfHostsTransport[i].TransportTlsPorts[ci].PortNumber.ValueInt64(), 10)}
+
+ var cr xmldot.Result
+ helpers.GetFromXPath(r, "transport/tls/port").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
}
- if ccValue := cv.Get("profile"); ccValue.Exists() {
- cItem.Profile = types.StringValue(ccValue.String())
+ if found {
+ cr = v
+ return false
}
- item.TransportTlsPorts = append(item.TransportTlsPorts, cItem)
return true
- })
+ },
+ )
+ if value := helpers.GetFromXPath(cr, "port-number"); value.Exists() && !data.Ipv4VrfHostsTransport[i].TransportTlsPorts[ci].PortNumber.IsNull() {
+ data.Ipv4VrfHostsTransport[i].TransportTlsPorts[ci].PortNumber = types.Int64Value(value.Int())
+ } else {
+ data.Ipv4VrfHostsTransport[i].TransportTlsPorts[ci].PortNumber = types.Int64Null()
}
- data.Ipv6VrfHostsTransport = append(data.Ipv6VrfHostsTransport, item)
- return true
- })
+ if value := helpers.GetFromXPath(cr, "profile"); value.Exists() && !data.Ipv4VrfHostsTransport[i].TransportTlsPorts[ci].Profile.IsNull() {
+ data.Ipv4VrfHostsTransport[i].TransportTlsPorts[ci].Profile = types.StringValue(value.String())
+ } else {
+ data.Ipv4VrfHostsTransport[i].TransportTlsPorts[ci].Profile = types.StringNull()
+ }
+ }
}
-}
-
-// End of section. //template:end fromBody
-
-// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyData
+ for i := range data.Ipv6Hosts {
+ keys := [...]string{"ipv6-host"}
+ keyValues := [...]string{data.Ipv6Hosts[i].Ipv6Host.ValueString()}
-func (data *LoggingData) fromBody(ctx context.Context, res gjson.Result) {
- prefix := helpers.LastElement(data.getPath()) + "."
- if res.Get(helpers.LastElement(data.getPath())).IsArray() {
- prefix += "0."
- }
- if value := res.Get(prefix + "monitor-config.common-config.monitor.severity"); value.Exists() {
- data.MonitorSeverity = types.StringValue(value.String())
- }
- if value := res.Get(prefix + "buffered.size-value"); value.Exists() {
- data.BufferedSize = types.Int64Value(value.Int())
- }
- if value := res.Get(prefix + "buffered.severity-level"); value.Exists() {
- data.BufferedSeverity = types.StringValue(value.String())
- }
- if value := res.Get(prefix + "console-config.common-config.console.severity"); value.Exists() {
- data.ConsoleSeverity = types.StringValue(value.String())
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/host/ipv6/ipv6-host-list").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, "ipv6-host"); value.Exists() && !data.Ipv6Hosts[i].Ipv6Host.IsNull() {
+ data.Ipv6Hosts[i].Ipv6Host = types.StringValue(value.String())
+ } else {
+ data.Ipv6Hosts[i].Ipv6Host = types.StringNull()
+ }
}
- if value := res.Get(prefix + "facility"); value.Exists() {
+ for i := range data.Ipv6HostsTransport {
+ keys := [...]string{"ipv6-host"}
+ keyValues := [...]string{data.Ipv6HostsTransport[i].Ipv6Host.ValueString()}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/host/ipv6/ipv6-host-transport-list").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, "ipv6-host"); value.Exists() && !data.Ipv6HostsTransport[i].Ipv6Host.IsNull() {
+ data.Ipv6HostsTransport[i].Ipv6Host = types.StringValue(value.String())
+ } else {
+ data.Ipv6HostsTransport[i].Ipv6Host = types.StringNull()
+ }
+ for ci := range data.Ipv6HostsTransport[i].TransportUdpPorts {
+ keys := [...]string{"port-number"}
+ keyValues := [...]string{strconv.FormatInt(data.Ipv6HostsTransport[i].TransportUdpPorts[ci].PortNumber.ValueInt64(), 10)}
+
+ var cr xmldot.Result
+ helpers.GetFromXPath(r, "transport/udp/port-config").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ cr = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(cr, "port-number"); value.Exists() && !data.Ipv6HostsTransport[i].TransportUdpPorts[ci].PortNumber.IsNull() {
+ data.Ipv6HostsTransport[i].TransportUdpPorts[ci].PortNumber = types.Int64Value(value.Int())
+ } else {
+ data.Ipv6HostsTransport[i].TransportUdpPorts[ci].PortNumber = types.Int64Null()
+ }
+ }
+ for ci := range data.Ipv6HostsTransport[i].TransportTcpPorts {
+ keys := [...]string{"port-number"}
+ keyValues := [...]string{strconv.FormatInt(data.Ipv6HostsTransport[i].TransportTcpPorts[ci].PortNumber.ValueInt64(), 10)}
+
+ var cr xmldot.Result
+ helpers.GetFromXPath(r, "transport/tcp/port-config").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ cr = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(cr, "port-number"); value.Exists() && !data.Ipv6HostsTransport[i].TransportTcpPorts[ci].PortNumber.IsNull() {
+ data.Ipv6HostsTransport[i].TransportTcpPorts[ci].PortNumber = types.Int64Value(value.Int())
+ } else {
+ data.Ipv6HostsTransport[i].TransportTcpPorts[ci].PortNumber = types.Int64Null()
+ }
+ }
+ for ci := range data.Ipv6HostsTransport[i].TransportTlsPorts {
+ keys := [...]string{"port-number"}
+ keyValues := [...]string{strconv.FormatInt(data.Ipv6HostsTransport[i].TransportTlsPorts[ci].PortNumber.ValueInt64(), 10)}
+
+ var cr xmldot.Result
+ helpers.GetFromXPath(r, "transport/tls/port").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ cr = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(cr, "port-number"); value.Exists() && !data.Ipv6HostsTransport[i].TransportTlsPorts[ci].PortNumber.IsNull() {
+ data.Ipv6HostsTransport[i].TransportTlsPorts[ci].PortNumber = types.Int64Value(value.Int())
+ } else {
+ data.Ipv6HostsTransport[i].TransportTlsPorts[ci].PortNumber = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(cr, "profile"); value.Exists() && !data.Ipv6HostsTransport[i].TransportTlsPorts[ci].Profile.IsNull() {
+ data.Ipv6HostsTransport[i].TransportTlsPorts[ci].Profile = types.StringValue(value.String())
+ } else {
+ data.Ipv6HostsTransport[i].TransportTlsPorts[ci].Profile = types.StringNull()
+ }
+ }
+ }
+ for i := range data.Ipv6VrfHosts {
+ keys := [...]string{"ipv6-host", "vrf"}
+ keyValues := [...]string{data.Ipv6VrfHosts[i].Ipv6Host.ValueString(), data.Ipv6VrfHosts[i].Vrf.ValueString()}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/host/ipv6/ipv6-host-vrf-list").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, "ipv6-host"); value.Exists() && !data.Ipv6VrfHosts[i].Ipv6Host.IsNull() {
+ data.Ipv6VrfHosts[i].Ipv6Host = types.StringValue(value.String())
+ } else {
+ data.Ipv6VrfHosts[i].Ipv6Host = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "vrf"); value.Exists() && !data.Ipv6VrfHosts[i].Vrf.IsNull() {
+ data.Ipv6VrfHosts[i].Vrf = types.StringValue(value.String())
+ } else {
+ data.Ipv6VrfHosts[i].Vrf = types.StringNull()
+ }
+ }
+ for i := range data.Ipv6VrfHostsTransport {
+ keys := [...]string{"ipv6-host", "vrf"}
+ keyValues := [...]string{data.Ipv6VrfHostsTransport[i].Ipv6Host.ValueString(), data.Ipv6VrfHostsTransport[i].Vrf.ValueString()}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/host/ipv6/ipv6-host-vrf-transport-list").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, "ipv6-host"); value.Exists() && !data.Ipv6VrfHostsTransport[i].Ipv6Host.IsNull() {
+ data.Ipv6VrfHostsTransport[i].Ipv6Host = types.StringValue(value.String())
+ } else {
+ data.Ipv6VrfHostsTransport[i].Ipv6Host = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "vrf"); value.Exists() && !data.Ipv6VrfHostsTransport[i].Vrf.IsNull() {
+ data.Ipv6VrfHostsTransport[i].Vrf = types.StringValue(value.String())
+ } else {
+ data.Ipv6VrfHostsTransport[i].Vrf = types.StringNull()
+ }
+ for ci := range data.Ipv6VrfHostsTransport[i].TransportUdpPorts {
+ keys := [...]string{"port-number"}
+ keyValues := [...]string{strconv.FormatInt(data.Ipv6VrfHostsTransport[i].TransportUdpPorts[ci].PortNumber.ValueInt64(), 10)}
+
+ var cr xmldot.Result
+ helpers.GetFromXPath(r, "transport/udp/port-config").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ cr = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(cr, "port-number"); value.Exists() && !data.Ipv6VrfHostsTransport[i].TransportUdpPorts[ci].PortNumber.IsNull() {
+ data.Ipv6VrfHostsTransport[i].TransportUdpPorts[ci].PortNumber = types.Int64Value(value.Int())
+ } else {
+ data.Ipv6VrfHostsTransport[i].TransportUdpPorts[ci].PortNumber = types.Int64Null()
+ }
+ }
+ for ci := range data.Ipv6VrfHostsTransport[i].TransportTcpPorts {
+ keys := [...]string{"port-number"}
+ keyValues := [...]string{strconv.FormatInt(data.Ipv6VrfHostsTransport[i].TransportTcpPorts[ci].PortNumber.ValueInt64(), 10)}
+
+ var cr xmldot.Result
+ helpers.GetFromXPath(r, "transport/tcp/port-config").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ cr = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(cr, "port-number"); value.Exists() && !data.Ipv6VrfHostsTransport[i].TransportTcpPorts[ci].PortNumber.IsNull() {
+ data.Ipv6VrfHostsTransport[i].TransportTcpPorts[ci].PortNumber = types.Int64Value(value.Int())
+ } else {
+ data.Ipv6VrfHostsTransport[i].TransportTcpPorts[ci].PortNumber = types.Int64Null()
+ }
+ }
+ for ci := range data.Ipv6VrfHostsTransport[i].TransportTlsPorts {
+ keys := [...]string{"port-number"}
+ keyValues := [...]string{strconv.FormatInt(data.Ipv6VrfHostsTransport[i].TransportTlsPorts[ci].PortNumber.ValueInt64(), 10)}
+
+ var cr xmldot.Result
+ helpers.GetFromXPath(r, "transport/tls/port").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ cr = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(cr, "port-number"); value.Exists() && !data.Ipv6VrfHostsTransport[i].TransportTlsPorts[ci].PortNumber.IsNull() {
+ data.Ipv6VrfHostsTransport[i].TransportTlsPorts[ci].PortNumber = types.Int64Value(value.Int())
+ } else {
+ data.Ipv6VrfHostsTransport[i].TransportTlsPorts[ci].PortNumber = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(cr, "profile"); value.Exists() && !data.Ipv6VrfHostsTransport[i].TransportTlsPorts[ci].Profile.IsNull() {
+ data.Ipv6VrfHostsTransport[i].TransportTlsPorts[ci].Profile = types.StringValue(value.String())
+ } else {
+ data.Ipv6VrfHostsTransport[i].TransportTlsPorts[ci].Profile = types.StringNull()
+ }
+ }
+ }
+}
+
+// End of section. //template:end updateFromBodyXML
+
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBody
+
+func (data *Logging) fromBody(ctx context.Context, res gjson.Result) {
+ prefix := helpers.LastElement(data.getPath()) + "."
+ if res.Get(helpers.LastElement(data.getPath())).IsArray() {
+ prefix += "0."
+ }
+ if value := res.Get(prefix + "monitor-config.common-config.monitor.severity"); value.Exists() {
+ data.MonitorSeverity = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "buffered.size-value"); value.Exists() {
+ data.BufferedSize = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "buffered.severity-level"); value.Exists() {
+ data.BufferedSeverity = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "console-config.common-config.console.severity"); value.Exists() {
+ data.ConsoleSeverity = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "facility"); value.Exists() {
+ data.Facility = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "history.size"); value.Exists() {
+ data.HistorySize = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "history.severity-level"); value.Exists() {
+ data.HistorySeverity = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "trap"); value.Exists() {
+ data.Trap = types.BoolValue(true)
+ } else {
+ data.Trap = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "trap.severity"); value.Exists() {
+ data.TrapSeverity = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "origin-id.type-value"); value.Exists() {
+ data.OriginIdType = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "origin-id.string"); value.Exists() {
+ data.OriginIdName = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "file.name"); value.Exists() {
+ data.FileName = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "file.max-size"); value.Exists() {
+ data.FileMaxSize = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "file.min-size"); value.Exists() {
+ data.FileMinSize = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "file.severity"); value.Exists() {
+ data.FileSeverity = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "source-interface-conf.interface-name-non-vrf"); value.Exists() {
+ data.SourceInterface = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "console-config.console"); value.Exists() {
+ data.Console = types.BoolValue(value.Bool())
+ } else {
+ data.Console = types.BoolNull()
+ }
+ if value := res.Get(prefix + "source-interface-conf.source-interface-vrf"); value.Exists() {
+ data.SourceInterfacesVrf = make([]LoggingSourceInterfacesVrf, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := LoggingSourceInterfacesVrf{}
+ if cValue := v.Get("vrf"); cValue.Exists() {
+ item.Vrf = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("interface-name"); cValue.Exists() {
+ item.InterfaceName = types.StringValue(cValue.String())
+ }
+ data.SourceInterfacesVrf = append(data.SourceInterfacesVrf, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + "host.ipv4-host-list"); value.Exists() {
+ data.Ipv4Hosts = make([]LoggingIpv4Hosts, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := LoggingIpv4Hosts{}
+ if cValue := v.Get("ipv4-host"); cValue.Exists() {
+ item.Ipv4Host = types.StringValue(cValue.String())
+ }
+ data.Ipv4Hosts = append(data.Ipv4Hosts, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + "host.ipv4-host-transport-list"); value.Exists() {
+ data.Ipv4HostsTransport = make([]LoggingIpv4HostsTransport, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := LoggingIpv4HostsTransport{}
+ if cValue := v.Get("ipv4-host"); cValue.Exists() {
+ item.Ipv4Host = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("transport.udp.port-config"); cValue.Exists() {
+ item.TransportUdpPorts = make([]LoggingIpv4HostsTransportTransportUdpPorts, 0)
+ cValue.ForEach(func(ck, cv gjson.Result) bool {
+ cItem := LoggingIpv4HostsTransportTransportUdpPorts{}
+ if ccValue := cv.Get("port-number"); ccValue.Exists() {
+ cItem.PortNumber = types.Int64Value(ccValue.Int())
+ }
+ item.TransportUdpPorts = append(item.TransportUdpPorts, cItem)
+ return true
+ })
+ }
+ if cValue := v.Get("transport.tcp.port-config"); cValue.Exists() {
+ item.TransportTcpPorts = make([]LoggingIpv4HostsTransportTransportTcpPorts, 0)
+ cValue.ForEach(func(ck, cv gjson.Result) bool {
+ cItem := LoggingIpv4HostsTransportTransportTcpPorts{}
+ if ccValue := cv.Get("port-number"); ccValue.Exists() {
+ cItem.PortNumber = types.Int64Value(ccValue.Int())
+ }
+ item.TransportTcpPorts = append(item.TransportTcpPorts, cItem)
+ return true
+ })
+ }
+ if cValue := v.Get("transport.tls.port"); cValue.Exists() {
+ item.TransportTlsPorts = make([]LoggingIpv4HostsTransportTransportTlsPorts, 0)
+ cValue.ForEach(func(ck, cv gjson.Result) bool {
+ cItem := LoggingIpv4HostsTransportTransportTlsPorts{}
+ if ccValue := cv.Get("port-number"); ccValue.Exists() {
+ cItem.PortNumber = types.Int64Value(ccValue.Int())
+ }
+ if ccValue := cv.Get("profile"); ccValue.Exists() {
+ cItem.Profile = types.StringValue(ccValue.String())
+ }
+ item.TransportTlsPorts = append(item.TransportTlsPorts, cItem)
+ return true
+ })
+ }
+ data.Ipv4HostsTransport = append(data.Ipv4HostsTransport, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + "host.ipv4-host-vrf-list"); value.Exists() {
+ data.Ipv4VrfHosts = make([]LoggingIpv4VrfHosts, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := LoggingIpv4VrfHosts{}
+ if cValue := v.Get("ipv4-host"); cValue.Exists() {
+ item.Ipv4Host = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("vrf"); cValue.Exists() {
+ item.Vrf = types.StringValue(cValue.String())
+ }
+ data.Ipv4VrfHosts = append(data.Ipv4VrfHosts, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + "host.ipv4-host-vrf-transport-list"); value.Exists() {
+ data.Ipv4VrfHostsTransport = make([]LoggingIpv4VrfHostsTransport, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := LoggingIpv4VrfHostsTransport{}
+ if cValue := v.Get("ipv4-host"); cValue.Exists() {
+ item.Ipv4Host = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("vrf"); cValue.Exists() {
+ item.Vrf = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("transport.udp.port-config"); cValue.Exists() {
+ item.TransportUdpPorts = make([]LoggingIpv4VrfHostsTransportTransportUdpPorts, 0)
+ cValue.ForEach(func(ck, cv gjson.Result) bool {
+ cItem := LoggingIpv4VrfHostsTransportTransportUdpPorts{}
+ if ccValue := cv.Get("port-number"); ccValue.Exists() {
+ cItem.PortNumber = types.Int64Value(ccValue.Int())
+ }
+ item.TransportUdpPorts = append(item.TransportUdpPorts, cItem)
+ return true
+ })
+ }
+ if cValue := v.Get("transport.tcp.port-config"); cValue.Exists() {
+ item.TransportTcpPorts = make([]LoggingIpv4VrfHostsTransportTransportTcpPorts, 0)
+ cValue.ForEach(func(ck, cv gjson.Result) bool {
+ cItem := LoggingIpv4VrfHostsTransportTransportTcpPorts{}
+ if ccValue := cv.Get("port-number"); ccValue.Exists() {
+ cItem.PortNumber = types.Int64Value(ccValue.Int())
+ }
+ item.TransportTcpPorts = append(item.TransportTcpPorts, cItem)
+ return true
+ })
+ }
+ if cValue := v.Get("transport.tls.port"); cValue.Exists() {
+ item.TransportTlsPorts = make([]LoggingIpv4VrfHostsTransportTransportTlsPorts, 0)
+ cValue.ForEach(func(ck, cv gjson.Result) bool {
+ cItem := LoggingIpv4VrfHostsTransportTransportTlsPorts{}
+ if ccValue := cv.Get("port-number"); ccValue.Exists() {
+ cItem.PortNumber = types.Int64Value(ccValue.Int())
+ }
+ if ccValue := cv.Get("profile"); ccValue.Exists() {
+ cItem.Profile = types.StringValue(ccValue.String())
+ }
+ item.TransportTlsPorts = append(item.TransportTlsPorts, cItem)
+ return true
+ })
+ }
+ data.Ipv4VrfHostsTransport = append(data.Ipv4VrfHostsTransport, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + "host.ipv6.ipv6-host-list"); value.Exists() {
+ data.Ipv6Hosts = make([]LoggingIpv6Hosts, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := LoggingIpv6Hosts{}
+ if cValue := v.Get("ipv6-host"); cValue.Exists() {
+ item.Ipv6Host = types.StringValue(cValue.String())
+ }
+ data.Ipv6Hosts = append(data.Ipv6Hosts, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + "host.ipv6.ipv6-host-transport-list"); value.Exists() {
+ data.Ipv6HostsTransport = make([]LoggingIpv6HostsTransport, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := LoggingIpv6HostsTransport{}
+ if cValue := v.Get("ipv6-host"); cValue.Exists() {
+ item.Ipv6Host = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("transport.udp.port-config"); cValue.Exists() {
+ item.TransportUdpPorts = make([]LoggingIpv6HostsTransportTransportUdpPorts, 0)
+ cValue.ForEach(func(ck, cv gjson.Result) bool {
+ cItem := LoggingIpv6HostsTransportTransportUdpPorts{}
+ if ccValue := cv.Get("port-number"); ccValue.Exists() {
+ cItem.PortNumber = types.Int64Value(ccValue.Int())
+ }
+ item.TransportUdpPorts = append(item.TransportUdpPorts, cItem)
+ return true
+ })
+ }
+ if cValue := v.Get("transport.tcp.port-config"); cValue.Exists() {
+ item.TransportTcpPorts = make([]LoggingIpv6HostsTransportTransportTcpPorts, 0)
+ cValue.ForEach(func(ck, cv gjson.Result) bool {
+ cItem := LoggingIpv6HostsTransportTransportTcpPorts{}
+ if ccValue := cv.Get("port-number"); ccValue.Exists() {
+ cItem.PortNumber = types.Int64Value(ccValue.Int())
+ }
+ item.TransportTcpPorts = append(item.TransportTcpPorts, cItem)
+ return true
+ })
+ }
+ if cValue := v.Get("transport.tls.port"); cValue.Exists() {
+ item.TransportTlsPorts = make([]LoggingIpv6HostsTransportTransportTlsPorts, 0)
+ cValue.ForEach(func(ck, cv gjson.Result) bool {
+ cItem := LoggingIpv6HostsTransportTransportTlsPorts{}
+ if ccValue := cv.Get("port-number"); ccValue.Exists() {
+ cItem.PortNumber = types.Int64Value(ccValue.Int())
+ }
+ if ccValue := cv.Get("profile"); ccValue.Exists() {
+ cItem.Profile = types.StringValue(ccValue.String())
+ }
+ item.TransportTlsPorts = append(item.TransportTlsPorts, cItem)
+ return true
+ })
+ }
+ data.Ipv6HostsTransport = append(data.Ipv6HostsTransport, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + "host.ipv6.ipv6-host-vrf-list"); value.Exists() {
+ data.Ipv6VrfHosts = make([]LoggingIpv6VrfHosts, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := LoggingIpv6VrfHosts{}
+ if cValue := v.Get("ipv6-host"); cValue.Exists() {
+ item.Ipv6Host = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("vrf"); cValue.Exists() {
+ item.Vrf = types.StringValue(cValue.String())
+ }
+ data.Ipv6VrfHosts = append(data.Ipv6VrfHosts, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + "host.ipv6.ipv6-host-vrf-transport-list"); value.Exists() {
+ data.Ipv6VrfHostsTransport = make([]LoggingIpv6VrfHostsTransport, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := LoggingIpv6VrfHostsTransport{}
+ if cValue := v.Get("ipv6-host"); cValue.Exists() {
+ item.Ipv6Host = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("vrf"); cValue.Exists() {
+ item.Vrf = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("transport.udp.port-config"); cValue.Exists() {
+ item.TransportUdpPorts = make([]LoggingIpv6VrfHostsTransportTransportUdpPorts, 0)
+ cValue.ForEach(func(ck, cv gjson.Result) bool {
+ cItem := LoggingIpv6VrfHostsTransportTransportUdpPorts{}
+ if ccValue := cv.Get("port-number"); ccValue.Exists() {
+ cItem.PortNumber = types.Int64Value(ccValue.Int())
+ }
+ item.TransportUdpPorts = append(item.TransportUdpPorts, cItem)
+ return true
+ })
+ }
+ if cValue := v.Get("transport.tcp.port-config"); cValue.Exists() {
+ item.TransportTcpPorts = make([]LoggingIpv6VrfHostsTransportTransportTcpPorts, 0)
+ cValue.ForEach(func(ck, cv gjson.Result) bool {
+ cItem := LoggingIpv6VrfHostsTransportTransportTcpPorts{}
+ if ccValue := cv.Get("port-number"); ccValue.Exists() {
+ cItem.PortNumber = types.Int64Value(ccValue.Int())
+ }
+ item.TransportTcpPorts = append(item.TransportTcpPorts, cItem)
+ return true
+ })
+ }
+ if cValue := v.Get("transport.tls.port"); cValue.Exists() {
+ item.TransportTlsPorts = make([]LoggingIpv6VrfHostsTransportTransportTlsPorts, 0)
+ cValue.ForEach(func(ck, cv gjson.Result) bool {
+ cItem := LoggingIpv6VrfHostsTransportTransportTlsPorts{}
+ if ccValue := cv.Get("port-number"); ccValue.Exists() {
+ cItem.PortNumber = types.Int64Value(ccValue.Int())
+ }
+ if ccValue := cv.Get("profile"); ccValue.Exists() {
+ cItem.Profile = types.StringValue(ccValue.String())
+ }
+ item.TransportTlsPorts = append(item.TransportTlsPorts, cItem)
+ return true
+ })
+ }
+ data.Ipv6VrfHostsTransport = append(data.Ipv6VrfHostsTransport, item)
+ return true
+ })
+ }
+}
+
+// End of section. //template:end fromBody
+
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyData
+
+func (data *LoggingData) fromBody(ctx context.Context, res gjson.Result) {
+ prefix := helpers.LastElement(data.getPath()) + "."
+ if res.Get(helpers.LastElement(data.getPath())).IsArray() {
+ prefix += "0."
+ }
+ if value := res.Get(prefix + "monitor-config.common-config.monitor.severity"); value.Exists() {
+ data.MonitorSeverity = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "buffered.size-value"); value.Exists() {
+ data.BufferedSize = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "buffered.severity-level"); value.Exists() {
+ data.BufferedSeverity = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "console-config.common-config.console.severity"); value.Exists() {
+ data.ConsoleSeverity = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "facility"); value.Exists() {
+ data.Facility = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "history.size"); value.Exists() {
+ data.HistorySize = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "history.severity-level"); value.Exists() {
+ data.HistorySeverity = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "trap"); value.Exists() {
+ data.Trap = types.BoolValue(true)
+ } else {
+ data.Trap = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "trap.severity"); value.Exists() {
+ data.TrapSeverity = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "origin-id.type-value"); value.Exists() {
+ data.OriginIdType = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "origin-id.string"); value.Exists() {
+ data.OriginIdName = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "file.name"); value.Exists() {
+ data.FileName = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "file.max-size"); value.Exists() {
+ data.FileMaxSize = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "file.min-size"); value.Exists() {
+ data.FileMinSize = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "file.severity"); value.Exists() {
+ data.FileSeverity = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "source-interface-conf.interface-name-non-vrf"); value.Exists() {
+ data.SourceInterface = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "console-config.console"); value.Exists() {
+ data.Console = types.BoolValue(value.Bool())
+ } else {
+ data.Console = types.BoolNull()
+ }
+ if value := res.Get(prefix + "source-interface-conf.source-interface-vrf"); value.Exists() {
+ data.SourceInterfacesVrf = make([]LoggingSourceInterfacesVrf, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := LoggingSourceInterfacesVrf{}
+ if cValue := v.Get("vrf"); cValue.Exists() {
+ item.Vrf = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("interface-name"); cValue.Exists() {
+ item.InterfaceName = types.StringValue(cValue.String())
+ }
+ data.SourceInterfacesVrf = append(data.SourceInterfacesVrf, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + "host.ipv4-host-list"); value.Exists() {
+ data.Ipv4Hosts = make([]LoggingIpv4Hosts, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := LoggingIpv4Hosts{}
+ if cValue := v.Get("ipv4-host"); cValue.Exists() {
+ item.Ipv4Host = types.StringValue(cValue.String())
+ }
+ data.Ipv4Hosts = append(data.Ipv4Hosts, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + "host.ipv4-host-transport-list"); value.Exists() {
+ data.Ipv4HostsTransport = make([]LoggingIpv4HostsTransport, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := LoggingIpv4HostsTransport{}
+ if cValue := v.Get("ipv4-host"); cValue.Exists() {
+ item.Ipv4Host = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("transport.udp.port-config"); cValue.Exists() {
+ item.TransportUdpPorts = make([]LoggingIpv4HostsTransportTransportUdpPorts, 0)
+ cValue.ForEach(func(ck, cv gjson.Result) bool {
+ cItem := LoggingIpv4HostsTransportTransportUdpPorts{}
+ if ccValue := cv.Get("port-number"); ccValue.Exists() {
+ cItem.PortNumber = types.Int64Value(ccValue.Int())
+ }
+ item.TransportUdpPorts = append(item.TransportUdpPorts, cItem)
+ return true
+ })
+ }
+ if cValue := v.Get("transport.tcp.port-config"); cValue.Exists() {
+ item.TransportTcpPorts = make([]LoggingIpv4HostsTransportTransportTcpPorts, 0)
+ cValue.ForEach(func(ck, cv gjson.Result) bool {
+ cItem := LoggingIpv4HostsTransportTransportTcpPorts{}
+ if ccValue := cv.Get("port-number"); ccValue.Exists() {
+ cItem.PortNumber = types.Int64Value(ccValue.Int())
+ }
+ item.TransportTcpPorts = append(item.TransportTcpPorts, cItem)
+ return true
+ })
+ }
+ if cValue := v.Get("transport.tls.port"); cValue.Exists() {
+ item.TransportTlsPorts = make([]LoggingIpv4HostsTransportTransportTlsPorts, 0)
+ cValue.ForEach(func(ck, cv gjson.Result) bool {
+ cItem := LoggingIpv4HostsTransportTransportTlsPorts{}
+ if ccValue := cv.Get("port-number"); ccValue.Exists() {
+ cItem.PortNumber = types.Int64Value(ccValue.Int())
+ }
+ if ccValue := cv.Get("profile"); ccValue.Exists() {
+ cItem.Profile = types.StringValue(ccValue.String())
+ }
+ item.TransportTlsPorts = append(item.TransportTlsPorts, cItem)
+ return true
+ })
+ }
+ data.Ipv4HostsTransport = append(data.Ipv4HostsTransport, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + "host.ipv4-host-vrf-list"); value.Exists() {
+ data.Ipv4VrfHosts = make([]LoggingIpv4VrfHosts, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := LoggingIpv4VrfHosts{}
+ if cValue := v.Get("ipv4-host"); cValue.Exists() {
+ item.Ipv4Host = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("vrf"); cValue.Exists() {
+ item.Vrf = types.StringValue(cValue.String())
+ }
+ data.Ipv4VrfHosts = append(data.Ipv4VrfHosts, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + "host.ipv4-host-vrf-transport-list"); value.Exists() {
+ data.Ipv4VrfHostsTransport = make([]LoggingIpv4VrfHostsTransport, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := LoggingIpv4VrfHostsTransport{}
+ if cValue := v.Get("ipv4-host"); cValue.Exists() {
+ item.Ipv4Host = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("vrf"); cValue.Exists() {
+ item.Vrf = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("transport.udp.port-config"); cValue.Exists() {
+ item.TransportUdpPorts = make([]LoggingIpv4VrfHostsTransportTransportUdpPorts, 0)
+ cValue.ForEach(func(ck, cv gjson.Result) bool {
+ cItem := LoggingIpv4VrfHostsTransportTransportUdpPorts{}
+ if ccValue := cv.Get("port-number"); ccValue.Exists() {
+ cItem.PortNumber = types.Int64Value(ccValue.Int())
+ }
+ item.TransportUdpPorts = append(item.TransportUdpPorts, cItem)
+ return true
+ })
+ }
+ if cValue := v.Get("transport.tcp.port-config"); cValue.Exists() {
+ item.TransportTcpPorts = make([]LoggingIpv4VrfHostsTransportTransportTcpPorts, 0)
+ cValue.ForEach(func(ck, cv gjson.Result) bool {
+ cItem := LoggingIpv4VrfHostsTransportTransportTcpPorts{}
+ if ccValue := cv.Get("port-number"); ccValue.Exists() {
+ cItem.PortNumber = types.Int64Value(ccValue.Int())
+ }
+ item.TransportTcpPorts = append(item.TransportTcpPorts, cItem)
+ return true
+ })
+ }
+ if cValue := v.Get("transport.tls.port"); cValue.Exists() {
+ item.TransportTlsPorts = make([]LoggingIpv4VrfHostsTransportTransportTlsPorts, 0)
+ cValue.ForEach(func(ck, cv gjson.Result) bool {
+ cItem := LoggingIpv4VrfHostsTransportTransportTlsPorts{}
+ if ccValue := cv.Get("port-number"); ccValue.Exists() {
+ cItem.PortNumber = types.Int64Value(ccValue.Int())
+ }
+ if ccValue := cv.Get("profile"); ccValue.Exists() {
+ cItem.Profile = types.StringValue(ccValue.String())
+ }
+ item.TransportTlsPorts = append(item.TransportTlsPorts, cItem)
+ return true
+ })
+ }
+ data.Ipv4VrfHostsTransport = append(data.Ipv4VrfHostsTransport, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + "host.ipv6.ipv6-host-list"); value.Exists() {
+ data.Ipv6Hosts = make([]LoggingIpv6Hosts, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := LoggingIpv6Hosts{}
+ if cValue := v.Get("ipv6-host"); cValue.Exists() {
+ item.Ipv6Host = types.StringValue(cValue.String())
+ }
+ data.Ipv6Hosts = append(data.Ipv6Hosts, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + "host.ipv6.ipv6-host-transport-list"); value.Exists() {
+ data.Ipv6HostsTransport = make([]LoggingIpv6HostsTransport, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := LoggingIpv6HostsTransport{}
+ if cValue := v.Get("ipv6-host"); cValue.Exists() {
+ item.Ipv6Host = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("transport.udp.port-config"); cValue.Exists() {
+ item.TransportUdpPorts = make([]LoggingIpv6HostsTransportTransportUdpPorts, 0)
+ cValue.ForEach(func(ck, cv gjson.Result) bool {
+ cItem := LoggingIpv6HostsTransportTransportUdpPorts{}
+ if ccValue := cv.Get("port-number"); ccValue.Exists() {
+ cItem.PortNumber = types.Int64Value(ccValue.Int())
+ }
+ item.TransportUdpPorts = append(item.TransportUdpPorts, cItem)
+ return true
+ })
+ }
+ if cValue := v.Get("transport.tcp.port-config"); cValue.Exists() {
+ item.TransportTcpPorts = make([]LoggingIpv6HostsTransportTransportTcpPorts, 0)
+ cValue.ForEach(func(ck, cv gjson.Result) bool {
+ cItem := LoggingIpv6HostsTransportTransportTcpPorts{}
+ if ccValue := cv.Get("port-number"); ccValue.Exists() {
+ cItem.PortNumber = types.Int64Value(ccValue.Int())
+ }
+ item.TransportTcpPorts = append(item.TransportTcpPorts, cItem)
+ return true
+ })
+ }
+ if cValue := v.Get("transport.tls.port"); cValue.Exists() {
+ item.TransportTlsPorts = make([]LoggingIpv6HostsTransportTransportTlsPorts, 0)
+ cValue.ForEach(func(ck, cv gjson.Result) bool {
+ cItem := LoggingIpv6HostsTransportTransportTlsPorts{}
+ if ccValue := cv.Get("port-number"); ccValue.Exists() {
+ cItem.PortNumber = types.Int64Value(ccValue.Int())
+ }
+ if ccValue := cv.Get("profile"); ccValue.Exists() {
+ cItem.Profile = types.StringValue(ccValue.String())
+ }
+ item.TransportTlsPorts = append(item.TransportTlsPorts, cItem)
+ return true
+ })
+ }
+ data.Ipv6HostsTransport = append(data.Ipv6HostsTransport, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + "host.ipv6.ipv6-host-vrf-list"); value.Exists() {
+ data.Ipv6VrfHosts = make([]LoggingIpv6VrfHosts, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := LoggingIpv6VrfHosts{}
+ if cValue := v.Get("ipv6-host"); cValue.Exists() {
+ item.Ipv6Host = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("vrf"); cValue.Exists() {
+ item.Vrf = types.StringValue(cValue.String())
+ }
+ data.Ipv6VrfHosts = append(data.Ipv6VrfHosts, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + "host.ipv6.ipv6-host-vrf-transport-list"); value.Exists() {
+ data.Ipv6VrfHostsTransport = make([]LoggingIpv6VrfHostsTransport, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := LoggingIpv6VrfHostsTransport{}
+ if cValue := v.Get("ipv6-host"); cValue.Exists() {
+ item.Ipv6Host = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("vrf"); cValue.Exists() {
+ item.Vrf = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("transport.udp.port-config"); cValue.Exists() {
+ item.TransportUdpPorts = make([]LoggingIpv6VrfHostsTransportTransportUdpPorts, 0)
+ cValue.ForEach(func(ck, cv gjson.Result) bool {
+ cItem := LoggingIpv6VrfHostsTransportTransportUdpPorts{}
+ if ccValue := cv.Get("port-number"); ccValue.Exists() {
+ cItem.PortNumber = types.Int64Value(ccValue.Int())
+ }
+ item.TransportUdpPorts = append(item.TransportUdpPorts, cItem)
+ return true
+ })
+ }
+ if cValue := v.Get("transport.tcp.port-config"); cValue.Exists() {
+ item.TransportTcpPorts = make([]LoggingIpv6VrfHostsTransportTransportTcpPorts, 0)
+ cValue.ForEach(func(ck, cv gjson.Result) bool {
+ cItem := LoggingIpv6VrfHostsTransportTransportTcpPorts{}
+ if ccValue := cv.Get("port-number"); ccValue.Exists() {
+ cItem.PortNumber = types.Int64Value(ccValue.Int())
+ }
+ item.TransportTcpPorts = append(item.TransportTcpPorts, cItem)
+ return true
+ })
+ }
+ if cValue := v.Get("transport.tls.port"); cValue.Exists() {
+ item.TransportTlsPorts = make([]LoggingIpv6VrfHostsTransportTransportTlsPorts, 0)
+ cValue.ForEach(func(ck, cv gjson.Result) bool {
+ cItem := LoggingIpv6VrfHostsTransportTransportTlsPorts{}
+ if ccValue := cv.Get("port-number"); ccValue.Exists() {
+ cItem.PortNumber = types.Int64Value(ccValue.Int())
+ }
+ if ccValue := cv.Get("profile"); ccValue.Exists() {
+ cItem.Profile = types.StringValue(ccValue.String())
+ }
+ item.TransportTlsPorts = append(item.TransportTlsPorts, cItem)
+ return true
+ })
+ }
+ data.Ipv6VrfHostsTransport = append(data.Ipv6VrfHostsTransport, item)
+ return true
+ })
+ }
+}
+
+// End of section. //template:end fromBodyData
+
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyXML
+
+func (data *Logging) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/monitor-config/common-config/monitor/severity"); value.Exists() {
+ data.MonitorSeverity = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/buffered/size-value"); value.Exists() {
+ data.BufferedSize = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/buffered/severity-level"); value.Exists() {
+ data.BufferedSeverity = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/console-config/common-config/console/severity"); value.Exists() {
+ data.ConsoleSeverity = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/facility"); value.Exists() {
+ data.Facility = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/history/size"); value.Exists() {
+ data.HistorySize = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/history/severity-level"); value.Exists() {
+ data.HistorySeverity = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/trap"); value.Exists() {
+ data.Trap = types.BoolValue(true)
+ } else {
+ data.Trap = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/trap/severity"); value.Exists() {
+ data.TrapSeverity = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/origin-id/type-value"); value.Exists() {
+ data.OriginIdType = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/origin-id/string"); value.Exists() {
+ data.OriginIdName = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/file/name"); value.Exists() {
+ data.FileName = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/file/max-size"); value.Exists() {
+ data.FileMaxSize = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/file/min-size"); value.Exists() {
+ data.FileMinSize = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/file/severity"); value.Exists() {
+ data.FileSeverity = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/source-interface-conf/interface-name-non-vrf"); value.Exists() {
+ data.SourceInterface = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/console-config/console"); value.Exists() {
+ data.Console = types.BoolValue(value.Bool())
+ } else {
+ data.Console = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/source-interface-conf/source-interface-vrf"); value.Exists() {
+ data.SourceInterfacesVrf = make([]LoggingSourceInterfacesVrf, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := LoggingSourceInterfacesVrf{}
+ if cValue := helpers.GetFromXPath(v, "vrf"); cValue.Exists() {
+ item.Vrf = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "interface-name"); cValue.Exists() {
+ item.InterfaceName = types.StringValue(cValue.String())
+ }
+ data.SourceInterfacesVrf = append(data.SourceInterfacesVrf, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/host/ipv4-host-list"); value.Exists() {
+ data.Ipv4Hosts = make([]LoggingIpv4Hosts, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := LoggingIpv4Hosts{}
+ if cValue := helpers.GetFromXPath(v, "ipv4-host"); cValue.Exists() {
+ item.Ipv4Host = types.StringValue(cValue.String())
+ }
+ data.Ipv4Hosts = append(data.Ipv4Hosts, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/host/ipv4-host-transport-list"); value.Exists() {
+ data.Ipv4HostsTransport = make([]LoggingIpv4HostsTransport, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := LoggingIpv4HostsTransport{}
+ if cValue := helpers.GetFromXPath(v, "ipv4-host"); cValue.Exists() {
+ item.Ipv4Host = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "transport/udp/port-config"); cValue.Exists() {
+ item.TransportUdpPorts = make([]LoggingIpv4HostsTransportTransportUdpPorts, 0)
+ cValue.ForEach(func(_ int, cv xmldot.Result) bool {
+ cItem := LoggingIpv4HostsTransportTransportUdpPorts{}
+ if ccValue := helpers.GetFromXPath(cv, "port-number"); ccValue.Exists() {
+ cItem.PortNumber = types.Int64Value(ccValue.Int())
+ }
+ item.TransportUdpPorts = append(item.TransportUdpPorts, cItem)
+ return true
+ })
+ }
+ if cValue := helpers.GetFromXPath(v, "transport/tcp/port-config"); cValue.Exists() {
+ item.TransportTcpPorts = make([]LoggingIpv4HostsTransportTransportTcpPorts, 0)
+ cValue.ForEach(func(_ int, cv xmldot.Result) bool {
+ cItem := LoggingIpv4HostsTransportTransportTcpPorts{}
+ if ccValue := helpers.GetFromXPath(cv, "port-number"); ccValue.Exists() {
+ cItem.PortNumber = types.Int64Value(ccValue.Int())
+ }
+ item.TransportTcpPorts = append(item.TransportTcpPorts, cItem)
+ return true
+ })
+ }
+ if cValue := helpers.GetFromXPath(v, "transport/tls/port"); cValue.Exists() {
+ item.TransportTlsPorts = make([]LoggingIpv4HostsTransportTransportTlsPorts, 0)
+ cValue.ForEach(func(_ int, cv xmldot.Result) bool {
+ cItem := LoggingIpv4HostsTransportTransportTlsPorts{}
+ if ccValue := helpers.GetFromXPath(cv, "port-number"); ccValue.Exists() {
+ cItem.PortNumber = types.Int64Value(ccValue.Int())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "profile"); ccValue.Exists() {
+ cItem.Profile = types.StringValue(ccValue.String())
+ }
+ item.TransportTlsPorts = append(item.TransportTlsPorts, cItem)
+ return true
+ })
+ }
+ data.Ipv4HostsTransport = append(data.Ipv4HostsTransport, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/host/ipv4-host-vrf-list"); value.Exists() {
+ data.Ipv4VrfHosts = make([]LoggingIpv4VrfHosts, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := LoggingIpv4VrfHosts{}
+ if cValue := helpers.GetFromXPath(v, "ipv4-host"); cValue.Exists() {
+ item.Ipv4Host = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "vrf"); cValue.Exists() {
+ item.Vrf = types.StringValue(cValue.String())
+ }
+ data.Ipv4VrfHosts = append(data.Ipv4VrfHosts, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/host/ipv4-host-vrf-transport-list"); value.Exists() {
+ data.Ipv4VrfHostsTransport = make([]LoggingIpv4VrfHostsTransport, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := LoggingIpv4VrfHostsTransport{}
+ if cValue := helpers.GetFromXPath(v, "ipv4-host"); cValue.Exists() {
+ item.Ipv4Host = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "vrf"); cValue.Exists() {
+ item.Vrf = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "transport/udp/port-config"); cValue.Exists() {
+ item.TransportUdpPorts = make([]LoggingIpv4VrfHostsTransportTransportUdpPorts, 0)
+ cValue.ForEach(func(_ int, cv xmldot.Result) bool {
+ cItem := LoggingIpv4VrfHostsTransportTransportUdpPorts{}
+ if ccValue := helpers.GetFromXPath(cv, "port-number"); ccValue.Exists() {
+ cItem.PortNumber = types.Int64Value(ccValue.Int())
+ }
+ item.TransportUdpPorts = append(item.TransportUdpPorts, cItem)
+ return true
+ })
+ }
+ if cValue := helpers.GetFromXPath(v, "transport/tcp/port-config"); cValue.Exists() {
+ item.TransportTcpPorts = make([]LoggingIpv4VrfHostsTransportTransportTcpPorts, 0)
+ cValue.ForEach(func(_ int, cv xmldot.Result) bool {
+ cItem := LoggingIpv4VrfHostsTransportTransportTcpPorts{}
+ if ccValue := helpers.GetFromXPath(cv, "port-number"); ccValue.Exists() {
+ cItem.PortNumber = types.Int64Value(ccValue.Int())
+ }
+ item.TransportTcpPorts = append(item.TransportTcpPorts, cItem)
+ return true
+ })
+ }
+ if cValue := helpers.GetFromXPath(v, "transport/tls/port"); cValue.Exists() {
+ item.TransportTlsPorts = make([]LoggingIpv4VrfHostsTransportTransportTlsPorts, 0)
+ cValue.ForEach(func(_ int, cv xmldot.Result) bool {
+ cItem := LoggingIpv4VrfHostsTransportTransportTlsPorts{}
+ if ccValue := helpers.GetFromXPath(cv, "port-number"); ccValue.Exists() {
+ cItem.PortNumber = types.Int64Value(ccValue.Int())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "profile"); ccValue.Exists() {
+ cItem.Profile = types.StringValue(ccValue.String())
+ }
+ item.TransportTlsPorts = append(item.TransportTlsPorts, cItem)
+ return true
+ })
+ }
+ data.Ipv4VrfHostsTransport = append(data.Ipv4VrfHostsTransport, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/host/ipv6/ipv6-host-list"); value.Exists() {
+ data.Ipv6Hosts = make([]LoggingIpv6Hosts, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := LoggingIpv6Hosts{}
+ if cValue := helpers.GetFromXPath(v, "ipv6-host"); cValue.Exists() {
+ item.Ipv6Host = types.StringValue(cValue.String())
+ }
+ data.Ipv6Hosts = append(data.Ipv6Hosts, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/host/ipv6/ipv6-host-transport-list"); value.Exists() {
+ data.Ipv6HostsTransport = make([]LoggingIpv6HostsTransport, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := LoggingIpv6HostsTransport{}
+ if cValue := helpers.GetFromXPath(v, "ipv6-host"); cValue.Exists() {
+ item.Ipv6Host = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "transport/udp/port-config"); cValue.Exists() {
+ item.TransportUdpPorts = make([]LoggingIpv6HostsTransportTransportUdpPorts, 0)
+ cValue.ForEach(func(_ int, cv xmldot.Result) bool {
+ cItem := LoggingIpv6HostsTransportTransportUdpPorts{}
+ if ccValue := helpers.GetFromXPath(cv, "port-number"); ccValue.Exists() {
+ cItem.PortNumber = types.Int64Value(ccValue.Int())
+ }
+ item.TransportUdpPorts = append(item.TransportUdpPorts, cItem)
+ return true
+ })
+ }
+ if cValue := helpers.GetFromXPath(v, "transport/tcp/port-config"); cValue.Exists() {
+ item.TransportTcpPorts = make([]LoggingIpv6HostsTransportTransportTcpPorts, 0)
+ cValue.ForEach(func(_ int, cv xmldot.Result) bool {
+ cItem := LoggingIpv6HostsTransportTransportTcpPorts{}
+ if ccValue := helpers.GetFromXPath(cv, "port-number"); ccValue.Exists() {
+ cItem.PortNumber = types.Int64Value(ccValue.Int())
+ }
+ item.TransportTcpPorts = append(item.TransportTcpPorts, cItem)
+ return true
+ })
+ }
+ if cValue := helpers.GetFromXPath(v, "transport/tls/port"); cValue.Exists() {
+ item.TransportTlsPorts = make([]LoggingIpv6HostsTransportTransportTlsPorts, 0)
+ cValue.ForEach(func(_ int, cv xmldot.Result) bool {
+ cItem := LoggingIpv6HostsTransportTransportTlsPorts{}
+ if ccValue := helpers.GetFromXPath(cv, "port-number"); ccValue.Exists() {
+ cItem.PortNumber = types.Int64Value(ccValue.Int())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "profile"); ccValue.Exists() {
+ cItem.Profile = types.StringValue(ccValue.String())
+ }
+ item.TransportTlsPorts = append(item.TransportTlsPorts, cItem)
+ return true
+ })
+ }
+ data.Ipv6HostsTransport = append(data.Ipv6HostsTransport, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/host/ipv6/ipv6-host-vrf-list"); value.Exists() {
+ data.Ipv6VrfHosts = make([]LoggingIpv6VrfHosts, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := LoggingIpv6VrfHosts{}
+ if cValue := helpers.GetFromXPath(v, "ipv6-host"); cValue.Exists() {
+ item.Ipv6Host = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "vrf"); cValue.Exists() {
+ item.Vrf = types.StringValue(cValue.String())
+ }
+ data.Ipv6VrfHosts = append(data.Ipv6VrfHosts, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/host/ipv6/ipv6-host-vrf-transport-list"); value.Exists() {
+ data.Ipv6VrfHostsTransport = make([]LoggingIpv6VrfHostsTransport, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := LoggingIpv6VrfHostsTransport{}
+ if cValue := helpers.GetFromXPath(v, "ipv6-host"); cValue.Exists() {
+ item.Ipv6Host = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "vrf"); cValue.Exists() {
+ item.Vrf = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "transport/udp/port-config"); cValue.Exists() {
+ item.TransportUdpPorts = make([]LoggingIpv6VrfHostsTransportTransportUdpPorts, 0)
+ cValue.ForEach(func(_ int, cv xmldot.Result) bool {
+ cItem := LoggingIpv6VrfHostsTransportTransportUdpPorts{}
+ if ccValue := helpers.GetFromXPath(cv, "port-number"); ccValue.Exists() {
+ cItem.PortNumber = types.Int64Value(ccValue.Int())
+ }
+ item.TransportUdpPorts = append(item.TransportUdpPorts, cItem)
+ return true
+ })
+ }
+ if cValue := helpers.GetFromXPath(v, "transport/tcp/port-config"); cValue.Exists() {
+ item.TransportTcpPorts = make([]LoggingIpv6VrfHostsTransportTransportTcpPorts, 0)
+ cValue.ForEach(func(_ int, cv xmldot.Result) bool {
+ cItem := LoggingIpv6VrfHostsTransportTransportTcpPorts{}
+ if ccValue := helpers.GetFromXPath(cv, "port-number"); ccValue.Exists() {
+ cItem.PortNumber = types.Int64Value(ccValue.Int())
+ }
+ item.TransportTcpPorts = append(item.TransportTcpPorts, cItem)
+ return true
+ })
+ }
+ if cValue := helpers.GetFromXPath(v, "transport/tls/port"); cValue.Exists() {
+ item.TransportTlsPorts = make([]LoggingIpv6VrfHostsTransportTransportTlsPorts, 0)
+ cValue.ForEach(func(_ int, cv xmldot.Result) bool {
+ cItem := LoggingIpv6VrfHostsTransportTransportTlsPorts{}
+ if ccValue := helpers.GetFromXPath(cv, "port-number"); ccValue.Exists() {
+ cItem.PortNumber = types.Int64Value(ccValue.Int())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "profile"); ccValue.Exists() {
+ cItem.Profile = types.StringValue(ccValue.String())
+ }
+ item.TransportTlsPorts = append(item.TransportTlsPorts, cItem)
+ return true
+ })
+ }
+ data.Ipv6VrfHostsTransport = append(data.Ipv6VrfHostsTransport, item)
+ return true
+ })
+ }
+}
+
+// End of section. //template:end fromBodyXML
+
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyDataXML
+
+func (data *LoggingData) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/monitor-config/common-config/monitor/severity"); value.Exists() {
+ data.MonitorSeverity = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/buffered/size-value"); value.Exists() {
+ data.BufferedSize = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/buffered/severity-level"); value.Exists() {
+ data.BufferedSeverity = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/console-config/common-config/console/severity"); value.Exists() {
+ data.ConsoleSeverity = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/facility"); value.Exists() {
data.Facility = types.StringValue(value.String())
}
- if value := res.Get(prefix + "history.size"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/history/size"); value.Exists() {
data.HistorySize = types.Int64Value(value.Int())
}
- if value := res.Get(prefix + "history.severity-level"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/history/severity-level"); value.Exists() {
data.HistorySeverity = types.StringValue(value.String())
}
- if value := res.Get(prefix + "trap"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/trap"); value.Exists() {
data.Trap = types.BoolValue(true)
} else {
data.Trap = types.BoolValue(false)
}
- if value := res.Get(prefix + "trap.severity"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/trap/severity"); value.Exists() {
data.TrapSeverity = types.StringValue(value.String())
}
- if value := res.Get(prefix + "origin-id.type-value"); value.Exists() {
- data.OriginIdType = types.StringValue(value.String())
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/origin-id/type-value"); value.Exists() {
+ data.OriginIdType = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/origin-id/string"); value.Exists() {
+ data.OriginIdName = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/file/name"); value.Exists() {
+ data.FileName = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/file/max-size"); value.Exists() {
+ data.FileMaxSize = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/file/min-size"); value.Exists() {
+ data.FileMinSize = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/file/severity"); value.Exists() {
+ data.FileSeverity = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/source-interface-conf/interface-name-non-vrf"); value.Exists() {
+ data.SourceInterface = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/console-config/console"); value.Exists() {
+ data.Console = types.BoolValue(value.Bool())
+ } else {
+ data.Console = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/source-interface-conf/source-interface-vrf"); value.Exists() {
+ data.SourceInterfacesVrf = make([]LoggingSourceInterfacesVrf, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := LoggingSourceInterfacesVrf{}
+ if cValue := helpers.GetFromXPath(v, "vrf"); cValue.Exists() {
+ item.Vrf = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "interface-name"); cValue.Exists() {
+ item.InterfaceName = types.StringValue(cValue.String())
+ }
+ data.SourceInterfacesVrf = append(data.SourceInterfacesVrf, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/host/ipv4-host-list"); value.Exists() {
+ data.Ipv4Hosts = make([]LoggingIpv4Hosts, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := LoggingIpv4Hosts{}
+ if cValue := helpers.GetFromXPath(v, "ipv4-host"); cValue.Exists() {
+ item.Ipv4Host = types.StringValue(cValue.String())
+ }
+ data.Ipv4Hosts = append(data.Ipv4Hosts, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/host/ipv4-host-transport-list"); value.Exists() {
+ data.Ipv4HostsTransport = make([]LoggingIpv4HostsTransport, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := LoggingIpv4HostsTransport{}
+ if cValue := helpers.GetFromXPath(v, "ipv4-host"); cValue.Exists() {
+ item.Ipv4Host = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "transport/udp/port-config"); cValue.Exists() {
+ item.TransportUdpPorts = make([]LoggingIpv4HostsTransportTransportUdpPorts, 0)
+ cValue.ForEach(func(_ int, cv xmldot.Result) bool {
+ cItem := LoggingIpv4HostsTransportTransportUdpPorts{}
+ if ccValue := helpers.GetFromXPath(cv, "port-number"); ccValue.Exists() {
+ cItem.PortNumber = types.Int64Value(ccValue.Int())
+ }
+ item.TransportUdpPorts = append(item.TransportUdpPorts, cItem)
+ return true
+ })
+ }
+ if cValue := helpers.GetFromXPath(v, "transport/tcp/port-config"); cValue.Exists() {
+ item.TransportTcpPorts = make([]LoggingIpv4HostsTransportTransportTcpPorts, 0)
+ cValue.ForEach(func(_ int, cv xmldot.Result) bool {
+ cItem := LoggingIpv4HostsTransportTransportTcpPorts{}
+ if ccValue := helpers.GetFromXPath(cv, "port-number"); ccValue.Exists() {
+ cItem.PortNumber = types.Int64Value(ccValue.Int())
+ }
+ item.TransportTcpPorts = append(item.TransportTcpPorts, cItem)
+ return true
+ })
+ }
+ if cValue := helpers.GetFromXPath(v, "transport/tls/port"); cValue.Exists() {
+ item.TransportTlsPorts = make([]LoggingIpv4HostsTransportTransportTlsPorts, 0)
+ cValue.ForEach(func(_ int, cv xmldot.Result) bool {
+ cItem := LoggingIpv4HostsTransportTransportTlsPorts{}
+ if ccValue := helpers.GetFromXPath(cv, "port-number"); ccValue.Exists() {
+ cItem.PortNumber = types.Int64Value(ccValue.Int())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "profile"); ccValue.Exists() {
+ cItem.Profile = types.StringValue(ccValue.String())
+ }
+ item.TransportTlsPorts = append(item.TransportTlsPorts, cItem)
+ return true
+ })
+ }
+ data.Ipv4HostsTransport = append(data.Ipv4HostsTransport, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/host/ipv4-host-vrf-list"); value.Exists() {
+ data.Ipv4VrfHosts = make([]LoggingIpv4VrfHosts, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := LoggingIpv4VrfHosts{}
+ if cValue := helpers.GetFromXPath(v, "ipv4-host"); cValue.Exists() {
+ item.Ipv4Host = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "vrf"); cValue.Exists() {
+ item.Vrf = types.StringValue(cValue.String())
+ }
+ data.Ipv4VrfHosts = append(data.Ipv4VrfHosts, item)
+ return true
+ })
}
- if value := res.Get(prefix + "origin-id.string"); value.Exists() {
- data.OriginIdName = types.StringValue(value.String())
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/host/ipv4-host-vrf-transport-list"); value.Exists() {
+ data.Ipv4VrfHostsTransport = make([]LoggingIpv4VrfHostsTransport, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := LoggingIpv4VrfHostsTransport{}
+ if cValue := helpers.GetFromXPath(v, "ipv4-host"); cValue.Exists() {
+ item.Ipv4Host = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "vrf"); cValue.Exists() {
+ item.Vrf = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "transport/udp/port-config"); cValue.Exists() {
+ item.TransportUdpPorts = make([]LoggingIpv4VrfHostsTransportTransportUdpPorts, 0)
+ cValue.ForEach(func(_ int, cv xmldot.Result) bool {
+ cItem := LoggingIpv4VrfHostsTransportTransportUdpPorts{}
+ if ccValue := helpers.GetFromXPath(cv, "port-number"); ccValue.Exists() {
+ cItem.PortNumber = types.Int64Value(ccValue.Int())
+ }
+ item.TransportUdpPorts = append(item.TransportUdpPorts, cItem)
+ return true
+ })
+ }
+ if cValue := helpers.GetFromXPath(v, "transport/tcp/port-config"); cValue.Exists() {
+ item.TransportTcpPorts = make([]LoggingIpv4VrfHostsTransportTransportTcpPorts, 0)
+ cValue.ForEach(func(_ int, cv xmldot.Result) bool {
+ cItem := LoggingIpv4VrfHostsTransportTransportTcpPorts{}
+ if ccValue := helpers.GetFromXPath(cv, "port-number"); ccValue.Exists() {
+ cItem.PortNumber = types.Int64Value(ccValue.Int())
+ }
+ item.TransportTcpPorts = append(item.TransportTcpPorts, cItem)
+ return true
+ })
+ }
+ if cValue := helpers.GetFromXPath(v, "transport/tls/port"); cValue.Exists() {
+ item.TransportTlsPorts = make([]LoggingIpv4VrfHostsTransportTransportTlsPorts, 0)
+ cValue.ForEach(func(_ int, cv xmldot.Result) bool {
+ cItem := LoggingIpv4VrfHostsTransportTransportTlsPorts{}
+ if ccValue := helpers.GetFromXPath(cv, "port-number"); ccValue.Exists() {
+ cItem.PortNumber = types.Int64Value(ccValue.Int())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "profile"); ccValue.Exists() {
+ cItem.Profile = types.StringValue(ccValue.String())
+ }
+ item.TransportTlsPorts = append(item.TransportTlsPorts, cItem)
+ return true
+ })
+ }
+ data.Ipv4VrfHostsTransport = append(data.Ipv4VrfHostsTransport, item)
+ return true
+ })
}
- if value := res.Get(prefix + "file.name"); value.Exists() {
- data.FileName = types.StringValue(value.String())
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/host/ipv6/ipv6-host-list"); value.Exists() {
+ data.Ipv6Hosts = make([]LoggingIpv6Hosts, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := LoggingIpv6Hosts{}
+ if cValue := helpers.GetFromXPath(v, "ipv6-host"); cValue.Exists() {
+ item.Ipv6Host = types.StringValue(cValue.String())
+ }
+ data.Ipv6Hosts = append(data.Ipv6Hosts, item)
+ return true
+ })
}
- if value := res.Get(prefix + "file.max-size"); value.Exists() {
- data.FileMaxSize = types.Int64Value(value.Int())
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/host/ipv6/ipv6-host-transport-list"); value.Exists() {
+ data.Ipv6HostsTransport = make([]LoggingIpv6HostsTransport, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := LoggingIpv6HostsTransport{}
+ if cValue := helpers.GetFromXPath(v, "ipv6-host"); cValue.Exists() {
+ item.Ipv6Host = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "transport/udp/port-config"); cValue.Exists() {
+ item.TransportUdpPorts = make([]LoggingIpv6HostsTransportTransportUdpPorts, 0)
+ cValue.ForEach(func(_ int, cv xmldot.Result) bool {
+ cItem := LoggingIpv6HostsTransportTransportUdpPorts{}
+ if ccValue := helpers.GetFromXPath(cv, "port-number"); ccValue.Exists() {
+ cItem.PortNumber = types.Int64Value(ccValue.Int())
+ }
+ item.TransportUdpPorts = append(item.TransportUdpPorts, cItem)
+ return true
+ })
+ }
+ if cValue := helpers.GetFromXPath(v, "transport/tcp/port-config"); cValue.Exists() {
+ item.TransportTcpPorts = make([]LoggingIpv6HostsTransportTransportTcpPorts, 0)
+ cValue.ForEach(func(_ int, cv xmldot.Result) bool {
+ cItem := LoggingIpv6HostsTransportTransportTcpPorts{}
+ if ccValue := helpers.GetFromXPath(cv, "port-number"); ccValue.Exists() {
+ cItem.PortNumber = types.Int64Value(ccValue.Int())
+ }
+ item.TransportTcpPorts = append(item.TransportTcpPorts, cItem)
+ return true
+ })
+ }
+ if cValue := helpers.GetFromXPath(v, "transport/tls/port"); cValue.Exists() {
+ item.TransportTlsPorts = make([]LoggingIpv6HostsTransportTransportTlsPorts, 0)
+ cValue.ForEach(func(_ int, cv xmldot.Result) bool {
+ cItem := LoggingIpv6HostsTransportTransportTlsPorts{}
+ if ccValue := helpers.GetFromXPath(cv, "port-number"); ccValue.Exists() {
+ cItem.PortNumber = types.Int64Value(ccValue.Int())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "profile"); ccValue.Exists() {
+ cItem.Profile = types.StringValue(ccValue.String())
+ }
+ item.TransportTlsPorts = append(item.TransportTlsPorts, cItem)
+ return true
+ })
+ }
+ data.Ipv6HostsTransport = append(data.Ipv6HostsTransport, item)
+ return true
+ })
}
- if value := res.Get(prefix + "file.min-size"); value.Exists() {
- data.FileMinSize = types.Int64Value(value.Int())
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/host/ipv6/ipv6-host-vrf-list"); value.Exists() {
+ data.Ipv6VrfHosts = make([]LoggingIpv6VrfHosts, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := LoggingIpv6VrfHosts{}
+ if cValue := helpers.GetFromXPath(v, "ipv6-host"); cValue.Exists() {
+ item.Ipv6Host = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "vrf"); cValue.Exists() {
+ item.Vrf = types.StringValue(cValue.String())
+ }
+ data.Ipv6VrfHosts = append(data.Ipv6VrfHosts, item)
+ return true
+ })
}
- if value := res.Get(prefix + "file.severity"); value.Exists() {
- data.FileSeverity = types.StringValue(value.String())
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/host/ipv6/ipv6-host-vrf-transport-list"); value.Exists() {
+ data.Ipv6VrfHostsTransport = make([]LoggingIpv6VrfHostsTransport, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := LoggingIpv6VrfHostsTransport{}
+ if cValue := helpers.GetFromXPath(v, "ipv6-host"); cValue.Exists() {
+ item.Ipv6Host = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "vrf"); cValue.Exists() {
+ item.Vrf = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "transport/udp/port-config"); cValue.Exists() {
+ item.TransportUdpPorts = make([]LoggingIpv6VrfHostsTransportTransportUdpPorts, 0)
+ cValue.ForEach(func(_ int, cv xmldot.Result) bool {
+ cItem := LoggingIpv6VrfHostsTransportTransportUdpPorts{}
+ if ccValue := helpers.GetFromXPath(cv, "port-number"); ccValue.Exists() {
+ cItem.PortNumber = types.Int64Value(ccValue.Int())
+ }
+ item.TransportUdpPorts = append(item.TransportUdpPorts, cItem)
+ return true
+ })
+ }
+ if cValue := helpers.GetFromXPath(v, "transport/tcp/port-config"); cValue.Exists() {
+ item.TransportTcpPorts = make([]LoggingIpv6VrfHostsTransportTransportTcpPorts, 0)
+ cValue.ForEach(func(_ int, cv xmldot.Result) bool {
+ cItem := LoggingIpv6VrfHostsTransportTransportTcpPorts{}
+ if ccValue := helpers.GetFromXPath(cv, "port-number"); ccValue.Exists() {
+ cItem.PortNumber = types.Int64Value(ccValue.Int())
+ }
+ item.TransportTcpPorts = append(item.TransportTcpPorts, cItem)
+ return true
+ })
+ }
+ if cValue := helpers.GetFromXPath(v, "transport/tls/port"); cValue.Exists() {
+ item.TransportTlsPorts = make([]LoggingIpv6VrfHostsTransportTransportTlsPorts, 0)
+ cValue.ForEach(func(_ int, cv xmldot.Result) bool {
+ cItem := LoggingIpv6VrfHostsTransportTransportTlsPorts{}
+ if ccValue := helpers.GetFromXPath(cv, "port-number"); ccValue.Exists() {
+ cItem.PortNumber = types.Int64Value(ccValue.Int())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "profile"); ccValue.Exists() {
+ cItem.Profile = types.StringValue(ccValue.String())
+ }
+ item.TransportTlsPorts = append(item.TransportTlsPorts, cItem)
+ return true
+ })
+ }
+ data.Ipv6VrfHostsTransport = append(data.Ipv6VrfHostsTransport, item)
+ return true
+ })
}
- if value := res.Get(prefix + "source-interface-conf.interface-name-non-vrf"); value.Exists() {
- data.SourceInterface = types.StringValue(value.String())
+}
+
+// End of section. //template:end fromBodyDataXML
+
+// Section below is generated&owned by "gen/generator.go". //template:begin getDeletedItems
+
+func (data *Logging) getDeletedItems(ctx context.Context, state Logging) []string {
+ deletedItems := make([]string, 0)
+ for i := range state.Ipv6VrfHostsTransport {
+ stateKeyValues := [...]string{state.Ipv6VrfHostsTransport[i].Ipv6Host.ValueString(), state.Ipv6VrfHostsTransport[i].Vrf.ValueString()}
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.Ipv6VrfHostsTransport[i].Ipv6Host.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if !reflect.ValueOf(state.Ipv6VrfHostsTransport[i].Vrf.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.Ipv6VrfHostsTransport {
+ found = true
+ if state.Ipv6VrfHostsTransport[i].Ipv6Host.ValueString() != data.Ipv6VrfHostsTransport[j].Ipv6Host.ValueString() {
+ found = false
+ }
+ if state.Ipv6VrfHostsTransport[i].Vrf.ValueString() != data.Ipv6VrfHostsTransport[j].Vrf.ValueString() {
+ found = false
+ }
+ if found {
+ for ci := range state.Ipv6VrfHostsTransport[i].TransportTlsPorts {
+ cstateKeyValues := [...]string{strconv.FormatInt(state.Ipv6VrfHostsTransport[i].TransportTlsPorts[ci].PortNumber.ValueInt64(), 10)}
+
+ cemptyKeys := true
+ if !reflect.ValueOf(state.Ipv6VrfHostsTransport[i].TransportTlsPorts[ci].PortNumber.ValueInt64()).IsZero() {
+ cemptyKeys = false
+ }
+ if cemptyKeys {
+ continue
+ }
+
+ found := false
+ for cj := range data.Ipv6VrfHostsTransport[j].TransportTlsPorts {
+ found = true
+ if state.Ipv6VrfHostsTransport[i].TransportTlsPorts[ci].PortNumber.ValueInt64() != data.Ipv6VrfHostsTransport[j].TransportTlsPorts[cj].PortNumber.ValueInt64() {
+ found = false
+ }
+ if found {
+ if !state.Ipv6VrfHostsTransport[i].TransportTlsPorts[ci].Profile.IsNull() && data.Ipv6VrfHostsTransport[j].TransportTlsPorts[cj].Profile.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/host/ipv6/ipv6-host-vrf-transport-list=%v/transport/tls/port=%v/profile", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ }
+ break
+ }
+ }
+ if !found {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/host/ipv6/ipv6-host-vrf-transport-list=%v/transport/tls/port=%v", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ }
+ }
+ for ci := range state.Ipv6VrfHostsTransport[i].TransportTcpPorts {
+ cstateKeyValues := [...]string{strconv.FormatInt(state.Ipv6VrfHostsTransport[i].TransportTcpPorts[ci].PortNumber.ValueInt64(), 10)}
+
+ cemptyKeys := true
+ if !reflect.ValueOf(state.Ipv6VrfHostsTransport[i].TransportTcpPorts[ci].PortNumber.ValueInt64()).IsZero() {
+ cemptyKeys = false
+ }
+ if cemptyKeys {
+ continue
+ }
+
+ found := false
+ for cj := range data.Ipv6VrfHostsTransport[j].TransportTcpPorts {
+ found = true
+ if state.Ipv6VrfHostsTransport[i].TransportTcpPorts[ci].PortNumber.ValueInt64() != data.Ipv6VrfHostsTransport[j].TransportTcpPorts[cj].PortNumber.ValueInt64() {
+ found = false
+ }
+ if found {
+ break
+ }
+ }
+ if !found {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/host/ipv6/ipv6-host-vrf-transport-list=%v/transport/tcp/port-config=%v", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ }
+ }
+ for ci := range state.Ipv6VrfHostsTransport[i].TransportUdpPorts {
+ cstateKeyValues := [...]string{strconv.FormatInt(state.Ipv6VrfHostsTransport[i].TransportUdpPorts[ci].PortNumber.ValueInt64(), 10)}
+
+ cemptyKeys := true
+ if !reflect.ValueOf(state.Ipv6VrfHostsTransport[i].TransportUdpPorts[ci].PortNumber.ValueInt64()).IsZero() {
+ cemptyKeys = false
+ }
+ if cemptyKeys {
+ continue
+ }
+
+ found := false
+ for cj := range data.Ipv6VrfHostsTransport[j].TransportUdpPorts {
+ found = true
+ if state.Ipv6VrfHostsTransport[i].TransportUdpPorts[ci].PortNumber.ValueInt64() != data.Ipv6VrfHostsTransport[j].TransportUdpPorts[cj].PortNumber.ValueInt64() {
+ found = false
+ }
+ if found {
+ break
+ }
+ }
+ if !found {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/host/ipv6/ipv6-host-vrf-transport-list=%v/transport/udp/port-config=%v", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ }
+ }
+ break
+ }
+ }
+ if !found {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/host/ipv6/ipv6-host-vrf-transport-list=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
}
- if value := res.Get(prefix + "console-config.console"); value.Exists() {
- data.Console = types.BoolValue(value.Bool())
- } else {
- data.Console = types.BoolNull()
+ for i := range state.Ipv6VrfHosts {
+ stateKeyValues := [...]string{state.Ipv6VrfHosts[i].Ipv6Host.ValueString(), state.Ipv6VrfHosts[i].Vrf.ValueString()}
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.Ipv6VrfHosts[i].Ipv6Host.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if !reflect.ValueOf(state.Ipv6VrfHosts[i].Vrf.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.Ipv6VrfHosts {
+ found = true
+ if state.Ipv6VrfHosts[i].Ipv6Host.ValueString() != data.Ipv6VrfHosts[j].Ipv6Host.ValueString() {
+ found = false
+ }
+ if state.Ipv6VrfHosts[i].Vrf.ValueString() != data.Ipv6VrfHosts[j].Vrf.ValueString() {
+ found = false
+ }
+ if found {
+ break
+ }
+ }
+ if !found {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/host/ipv6/ipv6-host-vrf-list=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
}
- if value := res.Get(prefix + "source-interface-conf.source-interface-vrf"); value.Exists() {
- data.SourceInterfacesVrf = make([]LoggingSourceInterfacesVrf, 0)
- value.ForEach(func(k, v gjson.Result) bool {
- item := LoggingSourceInterfacesVrf{}
- if cValue := v.Get("vrf"); cValue.Exists() {
- item.Vrf = types.StringValue(cValue.String())
+ for i := range state.Ipv6HostsTransport {
+ stateKeyValues := [...]string{state.Ipv6HostsTransport[i].Ipv6Host.ValueString()}
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.Ipv6HostsTransport[i].Ipv6Host.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.Ipv6HostsTransport {
+ found = true
+ if state.Ipv6HostsTransport[i].Ipv6Host.ValueString() != data.Ipv6HostsTransport[j].Ipv6Host.ValueString() {
+ found = false
}
- if cValue := v.Get("interface-name"); cValue.Exists() {
- item.InterfaceName = types.StringValue(cValue.String())
+ if found {
+ for ci := range state.Ipv6HostsTransport[i].TransportTlsPorts {
+ cstateKeyValues := [...]string{strconv.FormatInt(state.Ipv6HostsTransport[i].TransportTlsPorts[ci].PortNumber.ValueInt64(), 10)}
+
+ cemptyKeys := true
+ if !reflect.ValueOf(state.Ipv6HostsTransport[i].TransportTlsPorts[ci].PortNumber.ValueInt64()).IsZero() {
+ cemptyKeys = false
+ }
+ if cemptyKeys {
+ continue
+ }
+
+ found := false
+ for cj := range data.Ipv6HostsTransport[j].TransportTlsPorts {
+ found = true
+ if state.Ipv6HostsTransport[i].TransportTlsPorts[ci].PortNumber.ValueInt64() != data.Ipv6HostsTransport[j].TransportTlsPorts[cj].PortNumber.ValueInt64() {
+ found = false
+ }
+ if found {
+ if !state.Ipv6HostsTransport[i].TransportTlsPorts[ci].Profile.IsNull() && data.Ipv6HostsTransport[j].TransportTlsPorts[cj].Profile.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/host/ipv6/ipv6-host-transport-list=%v/transport/tls/port=%v/profile", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ }
+ break
+ }
+ }
+ if !found {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/host/ipv6/ipv6-host-transport-list=%v/transport/tls/port=%v", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ }
+ }
+ for ci := range state.Ipv6HostsTransport[i].TransportTcpPorts {
+ cstateKeyValues := [...]string{strconv.FormatInt(state.Ipv6HostsTransport[i].TransportTcpPorts[ci].PortNumber.ValueInt64(), 10)}
+
+ cemptyKeys := true
+ if !reflect.ValueOf(state.Ipv6HostsTransport[i].TransportTcpPorts[ci].PortNumber.ValueInt64()).IsZero() {
+ cemptyKeys = false
+ }
+ if cemptyKeys {
+ continue
+ }
+
+ found := false
+ for cj := range data.Ipv6HostsTransport[j].TransportTcpPorts {
+ found = true
+ if state.Ipv6HostsTransport[i].TransportTcpPorts[ci].PortNumber.ValueInt64() != data.Ipv6HostsTransport[j].TransportTcpPorts[cj].PortNumber.ValueInt64() {
+ found = false
+ }
+ if found {
+ break
+ }
+ }
+ if !found {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/host/ipv6/ipv6-host-transport-list=%v/transport/tcp/port-config=%v", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ }
+ }
+ for ci := range state.Ipv6HostsTransport[i].TransportUdpPorts {
+ cstateKeyValues := [...]string{strconv.FormatInt(state.Ipv6HostsTransport[i].TransportUdpPorts[ci].PortNumber.ValueInt64(), 10)}
+
+ cemptyKeys := true
+ if !reflect.ValueOf(state.Ipv6HostsTransport[i].TransportUdpPorts[ci].PortNumber.ValueInt64()).IsZero() {
+ cemptyKeys = false
+ }
+ if cemptyKeys {
+ continue
+ }
+
+ found := false
+ for cj := range data.Ipv6HostsTransport[j].TransportUdpPorts {
+ found = true
+ if state.Ipv6HostsTransport[i].TransportUdpPorts[ci].PortNumber.ValueInt64() != data.Ipv6HostsTransport[j].TransportUdpPorts[cj].PortNumber.ValueInt64() {
+ found = false
+ }
+ if found {
+ break
+ }
+ }
+ if !found {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/host/ipv6/ipv6-host-transport-list=%v/transport/udp/port-config=%v", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ }
+ }
+ break
}
- data.SourceInterfacesVrf = append(data.SourceInterfacesVrf, item)
- return true
- })
+ }
+ if !found {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/host/ipv6/ipv6-host-transport-list=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
}
- if value := res.Get(prefix + "host.ipv4-host-list"); value.Exists() {
- data.Ipv4Hosts = make([]LoggingIpv4Hosts, 0)
- value.ForEach(func(k, v gjson.Result) bool {
- item := LoggingIpv4Hosts{}
- if cValue := v.Get("ipv4-host"); cValue.Exists() {
- item.Ipv4Host = types.StringValue(cValue.String())
+ for i := range state.Ipv6Hosts {
+ stateKeyValues := [...]string{state.Ipv6Hosts[i].Ipv6Host.ValueString()}
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.Ipv6Hosts[i].Ipv6Host.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.Ipv6Hosts {
+ found = true
+ if state.Ipv6Hosts[i].Ipv6Host.ValueString() != data.Ipv6Hosts[j].Ipv6Host.ValueString() {
+ found = false
}
- data.Ipv4Hosts = append(data.Ipv4Hosts, item)
- return true
- })
+ if found {
+ break
+ }
+ }
+ if !found {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/host/ipv6/ipv6-host-list=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
}
- if value := res.Get(prefix + "host.ipv4-host-transport-list"); value.Exists() {
- data.Ipv4HostsTransport = make([]LoggingIpv4HostsTransport, 0)
- value.ForEach(func(k, v gjson.Result) bool {
- item := LoggingIpv4HostsTransport{}
- if cValue := v.Get("ipv4-host"); cValue.Exists() {
- item.Ipv4Host = types.StringValue(cValue.String())
+ for i := range state.Ipv4VrfHostsTransport {
+ stateKeyValues := [...]string{state.Ipv4VrfHostsTransport[i].Ipv4Host.ValueString(), state.Ipv4VrfHostsTransport[i].Vrf.ValueString()}
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.Ipv4VrfHostsTransport[i].Ipv4Host.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if !reflect.ValueOf(state.Ipv4VrfHostsTransport[i].Vrf.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.Ipv4VrfHostsTransport {
+ found = true
+ if state.Ipv4VrfHostsTransport[i].Ipv4Host.ValueString() != data.Ipv4VrfHostsTransport[j].Ipv4Host.ValueString() {
+ found = false
}
- if cValue := v.Get("transport.udp.port-config"); cValue.Exists() {
- item.TransportUdpPorts = make([]LoggingIpv4HostsTransportTransportUdpPorts, 0)
- cValue.ForEach(func(ck, cv gjson.Result) bool {
- cItem := LoggingIpv4HostsTransportTransportUdpPorts{}
- if ccValue := cv.Get("port-number"); ccValue.Exists() {
- cItem.PortNumber = types.Int64Value(ccValue.Int())
+ if state.Ipv4VrfHostsTransport[i].Vrf.ValueString() != data.Ipv4VrfHostsTransport[j].Vrf.ValueString() {
+ found = false
+ }
+ if found {
+ for ci := range state.Ipv4VrfHostsTransport[i].TransportTlsPorts {
+ cstateKeyValues := [...]string{strconv.FormatInt(state.Ipv4VrfHostsTransport[i].TransportTlsPorts[ci].PortNumber.ValueInt64(), 10)}
+
+ cemptyKeys := true
+ if !reflect.ValueOf(state.Ipv4VrfHostsTransport[i].TransportTlsPorts[ci].PortNumber.ValueInt64()).IsZero() {
+ cemptyKeys = false
+ }
+ if cemptyKeys {
+ continue
+ }
+
+ found := false
+ for cj := range data.Ipv4VrfHostsTransport[j].TransportTlsPorts {
+ found = true
+ if state.Ipv4VrfHostsTransport[i].TransportTlsPorts[ci].PortNumber.ValueInt64() != data.Ipv4VrfHostsTransport[j].TransportTlsPorts[cj].PortNumber.ValueInt64() {
+ found = false
+ }
+ if found {
+ if !state.Ipv4VrfHostsTransport[i].TransportTlsPorts[ci].Profile.IsNull() && data.Ipv4VrfHostsTransport[j].TransportTlsPorts[cj].Profile.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/host/ipv4-host-vrf-transport-list=%v/transport/tls/port=%v/profile", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ }
+ break
+ }
}
- item.TransportUdpPorts = append(item.TransportUdpPorts, cItem)
- return true
- })
- }
- if cValue := v.Get("transport.tcp.port-config"); cValue.Exists() {
- item.TransportTcpPorts = make([]LoggingIpv4HostsTransportTransportTcpPorts, 0)
- cValue.ForEach(func(ck, cv gjson.Result) bool {
- cItem := LoggingIpv4HostsTransportTransportTcpPorts{}
- if ccValue := cv.Get("port-number"); ccValue.Exists() {
- cItem.PortNumber = types.Int64Value(ccValue.Int())
+ if !found {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/host/ipv4-host-vrf-transport-list=%v/transport/tls/port=%v", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
}
- item.TransportTcpPorts = append(item.TransportTcpPorts, cItem)
- return true
- })
- }
- if cValue := v.Get("transport.tls.port"); cValue.Exists() {
- item.TransportTlsPorts = make([]LoggingIpv4HostsTransportTransportTlsPorts, 0)
- cValue.ForEach(func(ck, cv gjson.Result) bool {
- cItem := LoggingIpv4HostsTransportTransportTlsPorts{}
- if ccValue := cv.Get("port-number"); ccValue.Exists() {
- cItem.PortNumber = types.Int64Value(ccValue.Int())
+ }
+ for ci := range state.Ipv4VrfHostsTransport[i].TransportTcpPorts {
+ cstateKeyValues := [...]string{strconv.FormatInt(state.Ipv4VrfHostsTransport[i].TransportTcpPorts[ci].PortNumber.ValueInt64(), 10)}
+
+ cemptyKeys := true
+ if !reflect.ValueOf(state.Ipv4VrfHostsTransport[i].TransportTcpPorts[ci].PortNumber.ValueInt64()).IsZero() {
+ cemptyKeys = false
}
- if ccValue := cv.Get("profile"); ccValue.Exists() {
- cItem.Profile = types.StringValue(ccValue.String())
+ if cemptyKeys {
+ continue
}
- item.TransportTlsPorts = append(item.TransportTlsPorts, cItem)
- return true
- })
+
+ found := false
+ for cj := range data.Ipv4VrfHostsTransport[j].TransportTcpPorts {
+ found = true
+ if state.Ipv4VrfHostsTransport[i].TransportTcpPorts[ci].PortNumber.ValueInt64() != data.Ipv4VrfHostsTransport[j].TransportTcpPorts[cj].PortNumber.ValueInt64() {
+ found = false
+ }
+ if found {
+ break
+ }
+ }
+ if !found {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/host/ipv4-host-vrf-transport-list=%v/transport/tcp/port-config=%v", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ }
+ }
+ for ci := range state.Ipv4VrfHostsTransport[i].TransportUdpPorts {
+ cstateKeyValues := [...]string{strconv.FormatInt(state.Ipv4VrfHostsTransport[i].TransportUdpPorts[ci].PortNumber.ValueInt64(), 10)}
+
+ cemptyKeys := true
+ if !reflect.ValueOf(state.Ipv4VrfHostsTransport[i].TransportUdpPorts[ci].PortNumber.ValueInt64()).IsZero() {
+ cemptyKeys = false
+ }
+ if cemptyKeys {
+ continue
+ }
+
+ found := false
+ for cj := range data.Ipv4VrfHostsTransport[j].TransportUdpPorts {
+ found = true
+ if state.Ipv4VrfHostsTransport[i].TransportUdpPorts[ci].PortNumber.ValueInt64() != data.Ipv4VrfHostsTransport[j].TransportUdpPorts[cj].PortNumber.ValueInt64() {
+ found = false
+ }
+ if found {
+ break
+ }
+ }
+ if !found {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/host/ipv4-host-vrf-transport-list=%v/transport/udp/port-config=%v", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ }
+ }
+ break
}
- data.Ipv4HostsTransport = append(data.Ipv4HostsTransport, item)
- return true
- })
+ }
+ if !found {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/host/ipv4-host-vrf-transport-list=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
}
- if value := res.Get(prefix + "host.ipv4-host-vrf-list"); value.Exists() {
- data.Ipv4VrfHosts = make([]LoggingIpv4VrfHosts, 0)
- value.ForEach(func(k, v gjson.Result) bool {
- item := LoggingIpv4VrfHosts{}
- if cValue := v.Get("ipv4-host"); cValue.Exists() {
- item.Ipv4Host = types.StringValue(cValue.String())
+ for i := range state.Ipv4VrfHosts {
+ stateKeyValues := [...]string{state.Ipv4VrfHosts[i].Ipv4Host.ValueString(), state.Ipv4VrfHosts[i].Vrf.ValueString()}
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.Ipv4VrfHosts[i].Ipv4Host.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if !reflect.ValueOf(state.Ipv4VrfHosts[i].Vrf.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.Ipv4VrfHosts {
+ found = true
+ if state.Ipv4VrfHosts[i].Ipv4Host.ValueString() != data.Ipv4VrfHosts[j].Ipv4Host.ValueString() {
+ found = false
}
- if cValue := v.Get("vrf"); cValue.Exists() {
- item.Vrf = types.StringValue(cValue.String())
+ if state.Ipv4VrfHosts[i].Vrf.ValueString() != data.Ipv4VrfHosts[j].Vrf.ValueString() {
+ found = false
}
- data.Ipv4VrfHosts = append(data.Ipv4VrfHosts, item)
- return true
- })
- }
- if value := res.Get(prefix + "host.ipv4-host-vrf-transport-list"); value.Exists() {
- data.Ipv4VrfHostsTransport = make([]LoggingIpv4VrfHostsTransport, 0)
- value.ForEach(func(k, v gjson.Result) bool {
- item := LoggingIpv4VrfHostsTransport{}
- if cValue := v.Get("ipv4-host"); cValue.Exists() {
- item.Ipv4Host = types.StringValue(cValue.String())
+ if found {
+ break
}
- if cValue := v.Get("vrf"); cValue.Exists() {
- item.Vrf = types.StringValue(cValue.String())
+ }
+ if !found {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/host/ipv4-host-vrf-list=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ }
+ for i := range state.Ipv4HostsTransport {
+ stateKeyValues := [...]string{state.Ipv4HostsTransport[i].Ipv4Host.ValueString()}
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.Ipv4HostsTransport[i].Ipv4Host.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.Ipv4HostsTransport {
+ found = true
+ if state.Ipv4HostsTransport[i].Ipv4Host.ValueString() != data.Ipv4HostsTransport[j].Ipv4Host.ValueString() {
+ found = false
}
- if cValue := v.Get("transport.udp.port-config"); cValue.Exists() {
- item.TransportUdpPorts = make([]LoggingIpv4VrfHostsTransportTransportUdpPorts, 0)
- cValue.ForEach(func(ck, cv gjson.Result) bool {
- cItem := LoggingIpv4VrfHostsTransportTransportUdpPorts{}
- if ccValue := cv.Get("port-number"); ccValue.Exists() {
- cItem.PortNumber = types.Int64Value(ccValue.Int())
+ if found {
+ for ci := range state.Ipv4HostsTransport[i].TransportTlsPorts {
+ cstateKeyValues := [...]string{strconv.FormatInt(state.Ipv4HostsTransport[i].TransportTlsPorts[ci].PortNumber.ValueInt64(), 10)}
+
+ cemptyKeys := true
+ if !reflect.ValueOf(state.Ipv4HostsTransport[i].TransportTlsPorts[ci].PortNumber.ValueInt64()).IsZero() {
+ cemptyKeys = false
}
- item.TransportUdpPorts = append(item.TransportUdpPorts, cItem)
- return true
- })
- }
- if cValue := v.Get("transport.tcp.port-config"); cValue.Exists() {
- item.TransportTcpPorts = make([]LoggingIpv4VrfHostsTransportTransportTcpPorts, 0)
- cValue.ForEach(func(ck, cv gjson.Result) bool {
- cItem := LoggingIpv4VrfHostsTransportTransportTcpPorts{}
- if ccValue := cv.Get("port-number"); ccValue.Exists() {
- cItem.PortNumber = types.Int64Value(ccValue.Int())
+ if cemptyKeys {
+ continue
}
- item.TransportTcpPorts = append(item.TransportTcpPorts, cItem)
- return true
- })
- }
- if cValue := v.Get("transport.tls.port"); cValue.Exists() {
- item.TransportTlsPorts = make([]LoggingIpv4VrfHostsTransportTransportTlsPorts, 0)
- cValue.ForEach(func(ck, cv gjson.Result) bool {
- cItem := LoggingIpv4VrfHostsTransportTransportTlsPorts{}
- if ccValue := cv.Get("port-number"); ccValue.Exists() {
- cItem.PortNumber = types.Int64Value(ccValue.Int())
+
+ found := false
+ for cj := range data.Ipv4HostsTransport[j].TransportTlsPorts {
+ found = true
+ if state.Ipv4HostsTransport[i].TransportTlsPorts[ci].PortNumber.ValueInt64() != data.Ipv4HostsTransport[j].TransportTlsPorts[cj].PortNumber.ValueInt64() {
+ found = false
+ }
+ if found {
+ if !state.Ipv4HostsTransport[i].TransportTlsPorts[ci].Profile.IsNull() && data.Ipv4HostsTransport[j].TransportTlsPorts[cj].Profile.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/host/ipv4-host-transport-list=%v/transport/tls/port=%v/profile", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ }
+ break
+ }
}
- if ccValue := cv.Get("profile"); ccValue.Exists() {
- cItem.Profile = types.StringValue(ccValue.String())
+ if !found {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/host/ipv4-host-transport-list=%v/transport/tls/port=%v", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
}
- item.TransportTlsPorts = append(item.TransportTlsPorts, cItem)
- return true
- })
- }
- data.Ipv4VrfHostsTransport = append(data.Ipv4VrfHostsTransport, item)
- return true
- })
- }
- if value := res.Get(prefix + "host.ipv6.ipv6-host-list"); value.Exists() {
- data.Ipv6Hosts = make([]LoggingIpv6Hosts, 0)
- value.ForEach(func(k, v gjson.Result) bool {
- item := LoggingIpv6Hosts{}
- if cValue := v.Get("ipv6-host"); cValue.Exists() {
- item.Ipv6Host = types.StringValue(cValue.String())
- }
- data.Ipv6Hosts = append(data.Ipv6Hosts, item)
- return true
- })
- }
- if value := res.Get(prefix + "host.ipv6.ipv6-host-transport-list"); value.Exists() {
- data.Ipv6HostsTransport = make([]LoggingIpv6HostsTransport, 0)
- value.ForEach(func(k, v gjson.Result) bool {
- item := LoggingIpv6HostsTransport{}
- if cValue := v.Get("ipv6-host"); cValue.Exists() {
- item.Ipv6Host = types.StringValue(cValue.String())
- }
- if cValue := v.Get("transport.udp.port-config"); cValue.Exists() {
- item.TransportUdpPorts = make([]LoggingIpv6HostsTransportTransportUdpPorts, 0)
- cValue.ForEach(func(ck, cv gjson.Result) bool {
- cItem := LoggingIpv6HostsTransportTransportUdpPorts{}
- if ccValue := cv.Get("port-number"); ccValue.Exists() {
- cItem.PortNumber = types.Int64Value(ccValue.Int())
+ }
+ for ci := range state.Ipv4HostsTransport[i].TransportTcpPorts {
+ cstateKeyValues := [...]string{strconv.FormatInt(state.Ipv4HostsTransport[i].TransportTcpPorts[ci].PortNumber.ValueInt64(), 10)}
+
+ cemptyKeys := true
+ if !reflect.ValueOf(state.Ipv4HostsTransport[i].TransportTcpPorts[ci].PortNumber.ValueInt64()).IsZero() {
+ cemptyKeys = false
+ }
+ if cemptyKeys {
+ continue
+ }
+
+ found := false
+ for cj := range data.Ipv4HostsTransport[j].TransportTcpPorts {
+ found = true
+ if state.Ipv4HostsTransport[i].TransportTcpPorts[ci].PortNumber.ValueInt64() != data.Ipv4HostsTransport[j].TransportTcpPorts[cj].PortNumber.ValueInt64() {
+ found = false
+ }
+ if found {
+ break
+ }
+ }
+ if !found {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/host/ipv4-host-transport-list=%v/transport/tcp/port-config=%v", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
}
- item.TransportUdpPorts = append(item.TransportUdpPorts, cItem)
- return true
- })
- }
- if cValue := v.Get("transport.tcp.port-config"); cValue.Exists() {
- item.TransportTcpPorts = make([]LoggingIpv6HostsTransportTransportTcpPorts, 0)
- cValue.ForEach(func(ck, cv gjson.Result) bool {
- cItem := LoggingIpv6HostsTransportTransportTcpPorts{}
- if ccValue := cv.Get("port-number"); ccValue.Exists() {
- cItem.PortNumber = types.Int64Value(ccValue.Int())
+ }
+ for ci := range state.Ipv4HostsTransport[i].TransportUdpPorts {
+ cstateKeyValues := [...]string{strconv.FormatInt(state.Ipv4HostsTransport[i].TransportUdpPorts[ci].PortNumber.ValueInt64(), 10)}
+
+ cemptyKeys := true
+ if !reflect.ValueOf(state.Ipv4HostsTransport[i].TransportUdpPorts[ci].PortNumber.ValueInt64()).IsZero() {
+ cemptyKeys = false
}
- item.TransportTcpPorts = append(item.TransportTcpPorts, cItem)
- return true
- })
- }
- if cValue := v.Get("transport.tls.port"); cValue.Exists() {
- item.TransportTlsPorts = make([]LoggingIpv6HostsTransportTransportTlsPorts, 0)
- cValue.ForEach(func(ck, cv gjson.Result) bool {
- cItem := LoggingIpv6HostsTransportTransportTlsPorts{}
- if ccValue := cv.Get("port-number"); ccValue.Exists() {
- cItem.PortNumber = types.Int64Value(ccValue.Int())
+ if cemptyKeys {
+ continue
}
- if ccValue := cv.Get("profile"); ccValue.Exists() {
- cItem.Profile = types.StringValue(ccValue.String())
+
+ found := false
+ for cj := range data.Ipv4HostsTransport[j].TransportUdpPorts {
+ found = true
+ if state.Ipv4HostsTransport[i].TransportUdpPorts[ci].PortNumber.ValueInt64() != data.Ipv4HostsTransport[j].TransportUdpPorts[cj].PortNumber.ValueInt64() {
+ found = false
+ }
+ if found {
+ break
+ }
}
- item.TransportTlsPorts = append(item.TransportTlsPorts, cItem)
- return true
- })
+ if !found {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/host/ipv4-host-transport-list=%v/transport/udp/port-config=%v", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ }
+ }
+ break
}
- data.Ipv6HostsTransport = append(data.Ipv6HostsTransport, item)
- return true
- })
+ }
+ if !found {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/host/ipv4-host-transport-list=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
}
- if value := res.Get(prefix + "host.ipv6.ipv6-host-vrf-list"); value.Exists() {
- data.Ipv6VrfHosts = make([]LoggingIpv6VrfHosts, 0)
- value.ForEach(func(k, v gjson.Result) bool {
- item := LoggingIpv6VrfHosts{}
- if cValue := v.Get("ipv6-host"); cValue.Exists() {
- item.Ipv6Host = types.StringValue(cValue.String())
+ for i := range state.Ipv4Hosts {
+ stateKeyValues := [...]string{state.Ipv4Hosts[i].Ipv4Host.ValueString()}
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.Ipv4Hosts[i].Ipv4Host.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.Ipv4Hosts {
+ found = true
+ if state.Ipv4Hosts[i].Ipv4Host.ValueString() != data.Ipv4Hosts[j].Ipv4Host.ValueString() {
+ found = false
}
- if cValue := v.Get("vrf"); cValue.Exists() {
- item.Vrf = types.StringValue(cValue.String())
+ if found {
+ break
}
- data.Ipv6VrfHosts = append(data.Ipv6VrfHosts, item)
- return true
- })
+ }
+ if !found {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/host/ipv4-host-list=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
}
- if value := res.Get(prefix + "host.ipv6.ipv6-host-vrf-transport-list"); value.Exists() {
- data.Ipv6VrfHostsTransport = make([]LoggingIpv6VrfHostsTransport, 0)
- value.ForEach(func(k, v gjson.Result) bool {
- item := LoggingIpv6VrfHostsTransport{}
- if cValue := v.Get("ipv6-host"); cValue.Exists() {
- item.Ipv6Host = types.StringValue(cValue.String())
- }
- if cValue := v.Get("vrf"); cValue.Exists() {
- item.Vrf = types.StringValue(cValue.String())
- }
- if cValue := v.Get("transport.udp.port-config"); cValue.Exists() {
- item.TransportUdpPorts = make([]LoggingIpv6VrfHostsTransportTransportUdpPorts, 0)
- cValue.ForEach(func(ck, cv gjson.Result) bool {
- cItem := LoggingIpv6VrfHostsTransportTransportUdpPorts{}
- if ccValue := cv.Get("port-number"); ccValue.Exists() {
- cItem.PortNumber = types.Int64Value(ccValue.Int())
- }
- item.TransportUdpPorts = append(item.TransportUdpPorts, cItem)
- return true
- })
- }
- if cValue := v.Get("transport.tcp.port-config"); cValue.Exists() {
- item.TransportTcpPorts = make([]LoggingIpv6VrfHostsTransportTransportTcpPorts, 0)
- cValue.ForEach(func(ck, cv gjson.Result) bool {
- cItem := LoggingIpv6VrfHostsTransportTransportTcpPorts{}
- if ccValue := cv.Get("port-number"); ccValue.Exists() {
- cItem.PortNumber = types.Int64Value(ccValue.Int())
- }
- item.TransportTcpPorts = append(item.TransportTcpPorts, cItem)
- return true
- })
+ for i := range state.SourceInterfacesVrf {
+ stateKeyValues := [...]string{state.SourceInterfacesVrf[i].Vrf.ValueString()}
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.SourceInterfacesVrf[i].Vrf.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.SourceInterfacesVrf {
+ found = true
+ if state.SourceInterfacesVrf[i].Vrf.ValueString() != data.SourceInterfacesVrf[j].Vrf.ValueString() {
+ found = false
}
- if cValue := v.Get("transport.tls.port"); cValue.Exists() {
- item.TransportTlsPorts = make([]LoggingIpv6VrfHostsTransportTransportTlsPorts, 0)
- cValue.ForEach(func(ck, cv gjson.Result) bool {
- cItem := LoggingIpv6VrfHostsTransportTransportTlsPorts{}
- if ccValue := cv.Get("port-number"); ccValue.Exists() {
- cItem.PortNumber = types.Int64Value(ccValue.Int())
- }
- if ccValue := cv.Get("profile"); ccValue.Exists() {
- cItem.Profile = types.StringValue(ccValue.String())
- }
- item.TransportTlsPorts = append(item.TransportTlsPorts, cItem)
- return true
- })
+ if found {
+ if !state.SourceInterfacesVrf[i].InterfaceName.IsNull() && data.SourceInterfacesVrf[j].InterfaceName.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/source-interface-conf/source-interface-vrf=%v/interface-name", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ break
}
- data.Ipv6VrfHostsTransport = append(data.Ipv6VrfHostsTransport, item)
- return true
- })
+ }
+ if !found {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/source-interface-conf/source-interface-vrf=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ }
+ if !state.Console.IsNull() && data.Console.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/console-config/console", state.getPath()))
+ }
+ if !state.SourceInterface.IsNull() && data.SourceInterface.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/source-interface-conf/interface-name-non-vrf", state.getPath()))
+ }
+ if !state.FileSeverity.IsNull() && data.FileSeverity.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/file/severity", state.getPath()))
+ }
+ if !state.FileMinSize.IsNull() && data.FileMinSize.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/file/min-size", state.getPath()))
+ }
+ if !state.FileMaxSize.IsNull() && data.FileMaxSize.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/file/max-size", state.getPath()))
+ }
+ if !state.FileName.IsNull() && data.FileName.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/file/name", state.getPath()))
+ }
+ if !state.OriginIdName.IsNull() && data.OriginIdName.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/origin-id/string", state.getPath()))
+ }
+ if !state.OriginIdType.IsNull() && data.OriginIdType.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/origin-id/type-value", state.getPath()))
+ }
+ if !state.TrapSeverity.IsNull() && data.TrapSeverity.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/trap/severity", state.getPath()))
+ }
+ if !state.Trap.IsNull() && data.Trap.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/trap", state.getPath()))
+ }
+ if !state.HistorySeverity.IsNull() && data.HistorySeverity.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/history/severity-level", state.getPath()))
+ }
+ if !state.HistorySize.IsNull() && data.HistorySize.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/history/size", state.getPath()))
+ }
+ if !state.Facility.IsNull() && data.Facility.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/facility", state.getPath()))
+ }
+ if !state.ConsoleSeverity.IsNull() && data.ConsoleSeverity.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/console-config/common-config/console/severity", state.getPath()))
+ }
+ if !state.BufferedSeverity.IsNull() && data.BufferedSeverity.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/buffered/severity-level", state.getPath()))
+ }
+ if !state.BufferedSize.IsNull() && data.BufferedSize.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/buffered/size-value", state.getPath()))
+ }
+ if !state.MonitorSeverity.IsNull() && data.MonitorSeverity.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/monitor-config/common-config/monitor/severity", state.getPath()))
}
+
+ return deletedItems
}
-// End of section. //template:end fromBodyData
+// End of section. //template:end getDeletedItems
-// Section below is generated&owned by "gen/generator.go". //template:begin getDeletedItems
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletedItemsXML
-func (data *Logging) getDeletedItems(ctx context.Context, state Logging) []string {
- deletedItems := make([]string, 0)
- for i := range state.Ipv6VrfHostsTransport {
- stateKeyValues := [...]string{state.Ipv6VrfHostsTransport[i].Ipv6Host.ValueString(), state.Ipv6VrfHostsTransport[i].Vrf.ValueString()}
+func (data *Logging) addDeletedItemsXML(ctx context.Context, state Logging, body string) string {
+ b := netconf.NewBody(body)
+ if !state.MonitorSeverity.IsNull() && data.MonitorSeverity.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/monitor-config/common-config/monitor/severity")
+ }
+ if !state.BufferedSize.IsNull() && data.BufferedSize.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/buffered/size-value")
+ }
+ if !state.BufferedSeverity.IsNull() && data.BufferedSeverity.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/buffered/severity-level")
+ }
+ if !state.ConsoleSeverity.IsNull() && data.ConsoleSeverity.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/console-config/common-config/console/severity")
+ }
+ if !state.Facility.IsNull() && data.Facility.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/facility")
+ }
+ if !state.HistorySize.IsNull() && data.HistorySize.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/history/size")
+ }
+ if !state.HistorySeverity.IsNull() && data.HistorySeverity.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/history/severity-level")
+ }
+ if !state.Trap.IsNull() && data.Trap.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/trap")
+ }
+ if !state.TrapSeverity.IsNull() && data.TrapSeverity.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/trap/severity")
+ }
+ if !state.OriginIdType.IsNull() && data.OriginIdType.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/origin-id/type-value")
+ }
+ if !state.OriginIdName.IsNull() && data.OriginIdName.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/origin-id/string")
+ }
+ if !state.FileName.IsNull() && data.FileName.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/file/name")
+ }
+ if !state.FileMaxSize.IsNull() && data.FileMaxSize.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/file/max-size")
+ }
+ if !state.FileMinSize.IsNull() && data.FileMinSize.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/file/min-size")
+ }
+ if !state.FileSeverity.IsNull() && data.FileSeverity.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/file/severity")
+ }
+ if !state.SourceInterface.IsNull() && data.SourceInterface.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/source-interface-conf/interface-name-non-vrf")
+ }
+ if !state.Console.IsNull() && data.Console.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/console-config/console")
+ }
+ for i := range state.SourceInterfacesVrf {
+ stateKeys := [...]string{"vrf"}
+ stateKeyValues := [...]string{state.SourceInterfacesVrf[i].Vrf.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
emptyKeys := true
- if !reflect.ValueOf(state.Ipv6VrfHostsTransport[i].Ipv6Host.ValueString()).IsZero() {
+ if !reflect.ValueOf(state.SourceInterfacesVrf[i].Vrf.ValueString()).IsZero() {
emptyKeys = false
}
- if !reflect.ValueOf(state.Ipv6VrfHostsTransport[i].Vrf.ValueString()).IsZero() {
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.SourceInterfacesVrf {
+ found = true
+ if state.SourceInterfacesVrf[i].Vrf.ValueString() != data.SourceInterfacesVrf[j].Vrf.ValueString() {
+ found = false
+ }
+ if found {
+ if !state.SourceInterfacesVrf[i].InterfaceName.IsNull() && data.SourceInterfacesVrf[j].InterfaceName.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/source-interface-conf/source-interface-vrf%v/interface-name", predicates))
+ }
+ break
+ }
+ }
+ if !found {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/source-interface-conf/source-interface-vrf%v", predicates))
+ }
+ }
+ for i := range state.Ipv4Hosts {
+ stateKeys := [...]string{"ipv4-host"}
+ stateKeyValues := [...]string{state.Ipv4Hosts[i].Ipv4Host.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.Ipv4Hosts[i].Ipv4Host.ValueString()).IsZero() {
emptyKeys = false
}
if emptyKeys {
@@ -1888,20 +4289,52 @@ func (data *Logging) getDeletedItems(ctx context.Context, state Logging) []strin
}
found := false
- for j := range data.Ipv6VrfHostsTransport {
+ for j := range data.Ipv4Hosts {
found = true
- if state.Ipv6VrfHostsTransport[i].Ipv6Host.ValueString() != data.Ipv6VrfHostsTransport[j].Ipv6Host.ValueString() {
+ if state.Ipv4Hosts[i].Ipv4Host.ValueString() != data.Ipv4Hosts[j].Ipv4Host.ValueString() {
found = false
}
- if state.Ipv6VrfHostsTransport[i].Vrf.ValueString() != data.Ipv6VrfHostsTransport[j].Vrf.ValueString() {
+ if found {
+ break
+ }
+ }
+ if !found {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/host/ipv4-host-list%v", predicates))
+ }
+ }
+ for i := range state.Ipv4HostsTransport {
+ stateKeys := [...]string{"ipv4-host"}
+ stateKeyValues := [...]string{state.Ipv4HostsTransport[i].Ipv4Host.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.Ipv4HostsTransport[i].Ipv4Host.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.Ipv4HostsTransport {
+ found = true
+ if state.Ipv4HostsTransport[i].Ipv4Host.ValueString() != data.Ipv4HostsTransport[j].Ipv4Host.ValueString() {
found = false
}
if found {
- for ci := range state.Ipv6VrfHostsTransport[i].TransportTlsPorts {
- cstateKeyValues := [...]string{strconv.FormatInt(state.Ipv6VrfHostsTransport[i].TransportTlsPorts[ci].PortNumber.ValueInt64(), 10)}
+ for ci := range state.Ipv4HostsTransport[i].TransportUdpPorts {
+ cstateKeys := [...]string{"port-number"}
+ cstateKeyValues := [...]string{strconv.FormatInt(state.Ipv4HostsTransport[i].TransportUdpPorts[ci].PortNumber.ValueInt64(), 10)}
+ cpredicates := ""
+ for i := range cstateKeys {
+ cpredicates += fmt.Sprintf("[%s='%s']", cstateKeys[i], cstateKeyValues[i])
+ }
cemptyKeys := true
- if !reflect.ValueOf(state.Ipv6VrfHostsTransport[i].TransportTlsPorts[ci].PortNumber.ValueInt64()).IsZero() {
+ if !reflect.ValueOf(state.Ipv4HostsTransport[i].TransportUdpPorts[ci].PortNumber.ValueInt64()).IsZero() {
cemptyKeys = false
}
if cemptyKeys {
@@ -1909,27 +4342,29 @@ func (data *Logging) getDeletedItems(ctx context.Context, state Logging) []strin
}
found := false
- for cj := range data.Ipv6VrfHostsTransport[j].TransportTlsPorts {
+ for cj := range data.Ipv4HostsTransport[j].TransportUdpPorts {
found = true
- if state.Ipv6VrfHostsTransport[i].TransportTlsPorts[ci].PortNumber.ValueInt64() != data.Ipv6VrfHostsTransport[j].TransportTlsPorts[cj].PortNumber.ValueInt64() {
+ if state.Ipv4HostsTransport[i].TransportUdpPorts[ci].PortNumber.ValueInt64() != data.Ipv4HostsTransport[j].TransportUdpPorts[cj].PortNumber.ValueInt64() {
found = false
}
if found {
- if !state.Ipv6VrfHostsTransport[i].TransportTlsPorts[ci].Profile.IsNull() && data.Ipv6VrfHostsTransport[j].TransportTlsPorts[cj].Profile.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/host/ipv6/ipv6-host-vrf-transport-list=%v/transport/tls/port=%v/profile", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
- }
break
}
}
if !found {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/host/ipv6/ipv6-host-vrf-transport-list=%v/transport/tls/port=%v", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/host/ipv4-host-transport-list%v/transport/udp/port-config%v", predicates, cpredicates))
}
}
- for ci := range state.Ipv6VrfHostsTransport[i].TransportTcpPorts {
- cstateKeyValues := [...]string{strconv.FormatInt(state.Ipv6VrfHostsTransport[i].TransportTcpPorts[ci].PortNumber.ValueInt64(), 10)}
+ for ci := range state.Ipv4HostsTransport[i].TransportTcpPorts {
+ cstateKeys := [...]string{"port-number"}
+ cstateKeyValues := [...]string{strconv.FormatInt(state.Ipv4HostsTransport[i].TransportTcpPorts[ci].PortNumber.ValueInt64(), 10)}
+ cpredicates := ""
+ for i := range cstateKeys {
+ cpredicates += fmt.Sprintf("[%s='%s']", cstateKeys[i], cstateKeyValues[i])
+ }
cemptyKeys := true
- if !reflect.ValueOf(state.Ipv6VrfHostsTransport[i].TransportTcpPorts[ci].PortNumber.ValueInt64()).IsZero() {
+ if !reflect.ValueOf(state.Ipv4HostsTransport[i].TransportTcpPorts[ci].PortNumber.ValueInt64()).IsZero() {
cemptyKeys = false
}
if cemptyKeys {
@@ -1937,9 +4372,9 @@ func (data *Logging) getDeletedItems(ctx context.Context, state Logging) []strin
}
found := false
- for cj := range data.Ipv6VrfHostsTransport[j].TransportTcpPorts {
+ for cj := range data.Ipv4HostsTransport[j].TransportTcpPorts {
found = true
- if state.Ipv6VrfHostsTransport[i].TransportTcpPorts[ci].PortNumber.ValueInt64() != data.Ipv6VrfHostsTransport[j].TransportTcpPorts[cj].PortNumber.ValueInt64() {
+ if state.Ipv4HostsTransport[i].TransportTcpPorts[ci].PortNumber.ValueInt64() != data.Ipv4HostsTransport[j].TransportTcpPorts[cj].PortNumber.ValueInt64() {
found = false
}
if found {
@@ -1947,14 +4382,19 @@ func (data *Logging) getDeletedItems(ctx context.Context, state Logging) []strin
}
}
if !found {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/host/ipv6/ipv6-host-vrf-transport-list=%v/transport/tcp/port-config=%v", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/host/ipv4-host-transport-list%v/transport/tcp/port-config%v", predicates, cpredicates))
}
}
- for ci := range state.Ipv6VrfHostsTransport[i].TransportUdpPorts {
- cstateKeyValues := [...]string{strconv.FormatInt(state.Ipv6VrfHostsTransport[i].TransportUdpPorts[ci].PortNumber.ValueInt64(), 10)}
+ for ci := range state.Ipv4HostsTransport[i].TransportTlsPorts {
+ cstateKeys := [...]string{"port-number"}
+ cstateKeyValues := [...]string{strconv.FormatInt(state.Ipv4HostsTransport[i].TransportTlsPorts[ci].PortNumber.ValueInt64(), 10)}
+ cpredicates := ""
+ for i := range cstateKeys {
+ cpredicates += fmt.Sprintf("[%s='%s']", cstateKeys[i], cstateKeyValues[i])
+ }
cemptyKeys := true
- if !reflect.ValueOf(state.Ipv6VrfHostsTransport[i].TransportUdpPorts[ci].PortNumber.ValueInt64()).IsZero() {
+ if !reflect.ValueOf(state.Ipv4HostsTransport[i].TransportTlsPorts[ci].PortNumber.ValueInt64()).IsZero() {
cemptyKeys = false
}
if cemptyKeys {
@@ -1962,34 +4402,42 @@ func (data *Logging) getDeletedItems(ctx context.Context, state Logging) []strin
}
found := false
- for cj := range data.Ipv6VrfHostsTransport[j].TransportUdpPorts {
+ for cj := range data.Ipv4HostsTransport[j].TransportTlsPorts {
found = true
- if state.Ipv6VrfHostsTransport[i].TransportUdpPorts[ci].PortNumber.ValueInt64() != data.Ipv6VrfHostsTransport[j].TransportUdpPorts[cj].PortNumber.ValueInt64() {
+ if state.Ipv4HostsTransport[i].TransportTlsPorts[ci].PortNumber.ValueInt64() != data.Ipv4HostsTransport[j].TransportTlsPorts[cj].PortNumber.ValueInt64() {
found = false
}
if found {
+ if !state.Ipv4HostsTransport[i].TransportTlsPorts[ci].Profile.IsNull() && data.Ipv4HostsTransport[j].TransportTlsPorts[cj].Profile.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/host/ipv4-host-transport-list%v/transport/tls/port%v/profile", predicates, cpredicates))
+ }
break
}
}
if !found {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/host/ipv6/ipv6-host-vrf-transport-list=%v/transport/udp/port-config=%v", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/host/ipv4-host-transport-list%v/transport/tls/port%v", predicates, cpredicates))
}
}
break
}
}
if !found {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/host/ipv6/ipv6-host-vrf-transport-list=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/host/ipv4-host-transport-list%v", predicates))
}
}
- for i := range state.Ipv6VrfHosts {
- stateKeyValues := [...]string{state.Ipv6VrfHosts[i].Ipv6Host.ValueString(), state.Ipv6VrfHosts[i].Vrf.ValueString()}
+ for i := range state.Ipv4VrfHosts {
+ stateKeys := [...]string{"ipv4-host", "vrf"}
+ stateKeyValues := [...]string{state.Ipv4VrfHosts[i].Ipv4Host.ValueString(), state.Ipv4VrfHosts[i].Vrf.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
emptyKeys := true
- if !reflect.ValueOf(state.Ipv6VrfHosts[i].Ipv6Host.ValueString()).IsZero() {
+ if !reflect.ValueOf(state.Ipv4VrfHosts[i].Ipv4Host.ValueString()).IsZero() {
emptyKeys = false
}
- if !reflect.ValueOf(state.Ipv6VrfHosts[i].Vrf.ValueString()).IsZero() {
+ if !reflect.ValueOf(state.Ipv4VrfHosts[i].Vrf.ValueString()).IsZero() {
emptyKeys = false
}
if emptyKeys {
@@ -1997,12 +4445,12 @@ func (data *Logging) getDeletedItems(ctx context.Context, state Logging) []strin
}
found := false
- for j := range data.Ipv6VrfHosts {
+ for j := range data.Ipv4VrfHosts {
found = true
- if state.Ipv6VrfHosts[i].Ipv6Host.ValueString() != data.Ipv6VrfHosts[j].Ipv6Host.ValueString() {
+ if state.Ipv4VrfHosts[i].Ipv4Host.ValueString() != data.Ipv4VrfHosts[j].Ipv4Host.ValueString() {
found = false
}
- if state.Ipv6VrfHosts[i].Vrf.ValueString() != data.Ipv6VrfHosts[j].Vrf.ValueString() {
+ if state.Ipv4VrfHosts[i].Vrf.ValueString() != data.Ipv4VrfHosts[j].Vrf.ValueString() {
found = false
}
if found {
@@ -2010,14 +4458,22 @@ func (data *Logging) getDeletedItems(ctx context.Context, state Logging) []strin
}
}
if !found {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/host/ipv6/ipv6-host-vrf-list=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/host/ipv4-host-vrf-list%v", predicates))
}
}
- for i := range state.Ipv6HostsTransport {
- stateKeyValues := [...]string{state.Ipv6HostsTransport[i].Ipv6Host.ValueString()}
+ for i := range state.Ipv4VrfHostsTransport {
+ stateKeys := [...]string{"ipv4-host", "vrf"}
+ stateKeyValues := [...]string{state.Ipv4VrfHostsTransport[i].Ipv4Host.ValueString(), state.Ipv4VrfHostsTransport[i].Vrf.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
emptyKeys := true
- if !reflect.ValueOf(state.Ipv6HostsTransport[i].Ipv6Host.ValueString()).IsZero() {
+ if !reflect.ValueOf(state.Ipv4VrfHostsTransport[i].Ipv4Host.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if !reflect.ValueOf(state.Ipv4VrfHostsTransport[i].Vrf.ValueString()).IsZero() {
emptyKeys = false
}
if emptyKeys {
@@ -2025,17 +4481,25 @@ func (data *Logging) getDeletedItems(ctx context.Context, state Logging) []strin
}
found := false
- for j := range data.Ipv6HostsTransport {
+ for j := range data.Ipv4VrfHostsTransport {
found = true
- if state.Ipv6HostsTransport[i].Ipv6Host.ValueString() != data.Ipv6HostsTransport[j].Ipv6Host.ValueString() {
+ if state.Ipv4VrfHostsTransport[i].Ipv4Host.ValueString() != data.Ipv4VrfHostsTransport[j].Ipv4Host.ValueString() {
+ found = false
+ }
+ if state.Ipv4VrfHostsTransport[i].Vrf.ValueString() != data.Ipv4VrfHostsTransport[j].Vrf.ValueString() {
found = false
}
if found {
- for ci := range state.Ipv6HostsTransport[i].TransportTlsPorts {
- cstateKeyValues := [...]string{strconv.FormatInt(state.Ipv6HostsTransport[i].TransportTlsPorts[ci].PortNumber.ValueInt64(), 10)}
+ for ci := range state.Ipv4VrfHostsTransport[i].TransportUdpPorts {
+ cstateKeys := [...]string{"port-number"}
+ cstateKeyValues := [...]string{strconv.FormatInt(state.Ipv4VrfHostsTransport[i].TransportUdpPorts[ci].PortNumber.ValueInt64(), 10)}
+ cpredicates := ""
+ for i := range cstateKeys {
+ cpredicates += fmt.Sprintf("[%s='%s']", cstateKeys[i], cstateKeyValues[i])
+ }
cemptyKeys := true
- if !reflect.ValueOf(state.Ipv6HostsTransport[i].TransportTlsPorts[ci].PortNumber.ValueInt64()).IsZero() {
+ if !reflect.ValueOf(state.Ipv4VrfHostsTransport[i].TransportUdpPorts[ci].PortNumber.ValueInt64()).IsZero() {
cemptyKeys = false
}
if cemptyKeys {
@@ -2043,27 +4507,29 @@ func (data *Logging) getDeletedItems(ctx context.Context, state Logging) []strin
}
found := false
- for cj := range data.Ipv6HostsTransport[j].TransportTlsPorts {
+ for cj := range data.Ipv4VrfHostsTransport[j].TransportUdpPorts {
found = true
- if state.Ipv6HostsTransport[i].TransportTlsPorts[ci].PortNumber.ValueInt64() != data.Ipv6HostsTransport[j].TransportTlsPorts[cj].PortNumber.ValueInt64() {
+ if state.Ipv4VrfHostsTransport[i].TransportUdpPorts[ci].PortNumber.ValueInt64() != data.Ipv4VrfHostsTransport[j].TransportUdpPorts[cj].PortNumber.ValueInt64() {
found = false
}
if found {
- if !state.Ipv6HostsTransport[i].TransportTlsPorts[ci].Profile.IsNull() && data.Ipv6HostsTransport[j].TransportTlsPorts[cj].Profile.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/host/ipv6/ipv6-host-transport-list=%v/transport/tls/port=%v/profile", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
- }
break
}
}
if !found {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/host/ipv6/ipv6-host-transport-list=%v/transport/tls/port=%v", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/host/ipv4-host-vrf-transport-list%v/transport/udp/port-config%v", predicates, cpredicates))
}
}
- for ci := range state.Ipv6HostsTransport[i].TransportTcpPorts {
- cstateKeyValues := [...]string{strconv.FormatInt(state.Ipv6HostsTransport[i].TransportTcpPorts[ci].PortNumber.ValueInt64(), 10)}
+ for ci := range state.Ipv4VrfHostsTransport[i].TransportTcpPorts {
+ cstateKeys := [...]string{"port-number"}
+ cstateKeyValues := [...]string{strconv.FormatInt(state.Ipv4VrfHostsTransport[i].TransportTcpPorts[ci].PortNumber.ValueInt64(), 10)}
+ cpredicates := ""
+ for i := range cstateKeys {
+ cpredicates += fmt.Sprintf("[%s='%s']", cstateKeys[i], cstateKeyValues[i])
+ }
cemptyKeys := true
- if !reflect.ValueOf(state.Ipv6HostsTransport[i].TransportTcpPorts[ci].PortNumber.ValueInt64()).IsZero() {
+ if !reflect.ValueOf(state.Ipv4VrfHostsTransport[i].TransportTcpPorts[ci].PortNumber.ValueInt64()).IsZero() {
cemptyKeys = false
}
if cemptyKeys {
@@ -2071,9 +4537,9 @@ func (data *Logging) getDeletedItems(ctx context.Context, state Logging) []strin
}
found := false
- for cj := range data.Ipv6HostsTransport[j].TransportTcpPorts {
+ for cj := range data.Ipv4VrfHostsTransport[j].TransportTcpPorts {
found = true
- if state.Ipv6HostsTransport[i].TransportTcpPorts[ci].PortNumber.ValueInt64() != data.Ipv6HostsTransport[j].TransportTcpPorts[cj].PortNumber.ValueInt64() {
+ if state.Ipv4VrfHostsTransport[i].TransportTcpPorts[ci].PortNumber.ValueInt64() != data.Ipv4VrfHostsTransport[j].TransportTcpPorts[cj].PortNumber.ValueInt64() {
found = false
}
if found {
@@ -2081,14 +4547,19 @@ func (data *Logging) getDeletedItems(ctx context.Context, state Logging) []strin
}
}
if !found {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/host/ipv6/ipv6-host-transport-list=%v/transport/tcp/port-config=%v", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/host/ipv4-host-vrf-transport-list%v/transport/tcp/port-config%v", predicates, cpredicates))
}
}
- for ci := range state.Ipv6HostsTransport[i].TransportUdpPorts {
- cstateKeyValues := [...]string{strconv.FormatInt(state.Ipv6HostsTransport[i].TransportUdpPorts[ci].PortNumber.ValueInt64(), 10)}
+ for ci := range state.Ipv4VrfHostsTransport[i].TransportTlsPorts {
+ cstateKeys := [...]string{"port-number"}
+ cstateKeyValues := [...]string{strconv.FormatInt(state.Ipv4VrfHostsTransport[i].TransportTlsPorts[ci].PortNumber.ValueInt64(), 10)}
+ cpredicates := ""
+ for i := range cstateKeys {
+ cpredicates += fmt.Sprintf("[%s='%s']", cstateKeys[i], cstateKeyValues[i])
+ }
cemptyKeys := true
- if !reflect.ValueOf(state.Ipv6HostsTransport[i].TransportUdpPorts[ci].PortNumber.ValueInt64()).IsZero() {
+ if !reflect.ValueOf(state.Ipv4VrfHostsTransport[i].TransportTlsPorts[ci].PortNumber.ValueInt64()).IsZero() {
cemptyKeys = false
}
if cemptyKeys {
@@ -2096,28 +4567,36 @@ func (data *Logging) getDeletedItems(ctx context.Context, state Logging) []strin
}
found := false
- for cj := range data.Ipv6HostsTransport[j].TransportUdpPorts {
+ for cj := range data.Ipv4VrfHostsTransport[j].TransportTlsPorts {
found = true
- if state.Ipv6HostsTransport[i].TransportUdpPorts[ci].PortNumber.ValueInt64() != data.Ipv6HostsTransport[j].TransportUdpPorts[cj].PortNumber.ValueInt64() {
+ if state.Ipv4VrfHostsTransport[i].TransportTlsPorts[ci].PortNumber.ValueInt64() != data.Ipv4VrfHostsTransport[j].TransportTlsPorts[cj].PortNumber.ValueInt64() {
found = false
}
if found {
+ if !state.Ipv4VrfHostsTransport[i].TransportTlsPorts[ci].Profile.IsNull() && data.Ipv4VrfHostsTransport[j].TransportTlsPorts[cj].Profile.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/host/ipv4-host-vrf-transport-list%v/transport/tls/port%v/profile", predicates, cpredicates))
+ }
break
}
}
if !found {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/host/ipv6/ipv6-host-transport-list=%v/transport/udp/port-config=%v", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/host/ipv4-host-vrf-transport-list%v/transport/tls/port%v", predicates, cpredicates))
}
}
break
}
}
if !found {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/host/ipv6/ipv6-host-transport-list=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/host/ipv4-host-vrf-transport-list%v", predicates))
}
}
for i := range state.Ipv6Hosts {
+ stateKeys := [...]string{"ipv6-host"}
stateKeyValues := [...]string{state.Ipv6Hosts[i].Ipv6Host.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
emptyKeys := true
if !reflect.ValueOf(state.Ipv6Hosts[i].Ipv6Host.ValueString()).IsZero() {
@@ -2138,17 +4617,19 @@ func (data *Logging) getDeletedItems(ctx context.Context, state Logging) []strin
}
}
if !found {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/host/ipv6/ipv6-host-list=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/host/ipv6/ipv6-host-list%v", predicates))
}
}
- for i := range state.Ipv4VrfHostsTransport {
- stateKeyValues := [...]string{state.Ipv4VrfHostsTransport[i].Ipv4Host.ValueString(), state.Ipv4VrfHostsTransport[i].Vrf.ValueString()}
+ for i := range state.Ipv6HostsTransport {
+ stateKeys := [...]string{"ipv6-host"}
+ stateKeyValues := [...]string{state.Ipv6HostsTransport[i].Ipv6Host.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
emptyKeys := true
- if !reflect.ValueOf(state.Ipv4VrfHostsTransport[i].Ipv4Host.ValueString()).IsZero() {
- emptyKeys = false
- }
- if !reflect.ValueOf(state.Ipv4VrfHostsTransport[i].Vrf.ValueString()).IsZero() {
+ if !reflect.ValueOf(state.Ipv6HostsTransport[i].Ipv6Host.ValueString()).IsZero() {
emptyKeys = false
}
if emptyKeys {
@@ -2156,20 +4637,22 @@ func (data *Logging) getDeletedItems(ctx context.Context, state Logging) []strin
}
found := false
- for j := range data.Ipv4VrfHostsTransport {
+ for j := range data.Ipv6HostsTransport {
found = true
- if state.Ipv4VrfHostsTransport[i].Ipv4Host.ValueString() != data.Ipv4VrfHostsTransport[j].Ipv4Host.ValueString() {
- found = false
- }
- if state.Ipv4VrfHostsTransport[i].Vrf.ValueString() != data.Ipv4VrfHostsTransport[j].Vrf.ValueString() {
+ if state.Ipv6HostsTransport[i].Ipv6Host.ValueString() != data.Ipv6HostsTransport[j].Ipv6Host.ValueString() {
found = false
}
if found {
- for ci := range state.Ipv4VrfHostsTransport[i].TransportTlsPorts {
- cstateKeyValues := [...]string{strconv.FormatInt(state.Ipv4VrfHostsTransport[i].TransportTlsPorts[ci].PortNumber.ValueInt64(), 10)}
+ for ci := range state.Ipv6HostsTransport[i].TransportUdpPorts {
+ cstateKeys := [...]string{"port-number"}
+ cstateKeyValues := [...]string{strconv.FormatInt(state.Ipv6HostsTransport[i].TransportUdpPorts[ci].PortNumber.ValueInt64(), 10)}
+ cpredicates := ""
+ for i := range cstateKeys {
+ cpredicates += fmt.Sprintf("[%s='%s']", cstateKeys[i], cstateKeyValues[i])
+ }
cemptyKeys := true
- if !reflect.ValueOf(state.Ipv4VrfHostsTransport[i].TransportTlsPorts[ci].PortNumber.ValueInt64()).IsZero() {
+ if !reflect.ValueOf(state.Ipv6HostsTransport[i].TransportUdpPorts[ci].PortNumber.ValueInt64()).IsZero() {
cemptyKeys = false
}
if cemptyKeys {
@@ -2177,27 +4660,29 @@ func (data *Logging) getDeletedItems(ctx context.Context, state Logging) []strin
}
found := false
- for cj := range data.Ipv4VrfHostsTransport[j].TransportTlsPorts {
+ for cj := range data.Ipv6HostsTransport[j].TransportUdpPorts {
found = true
- if state.Ipv4VrfHostsTransport[i].TransportTlsPorts[ci].PortNumber.ValueInt64() != data.Ipv4VrfHostsTransport[j].TransportTlsPorts[cj].PortNumber.ValueInt64() {
+ if state.Ipv6HostsTransport[i].TransportUdpPorts[ci].PortNumber.ValueInt64() != data.Ipv6HostsTransport[j].TransportUdpPorts[cj].PortNumber.ValueInt64() {
found = false
}
if found {
- if !state.Ipv4VrfHostsTransport[i].TransportTlsPorts[ci].Profile.IsNull() && data.Ipv4VrfHostsTransport[j].TransportTlsPorts[cj].Profile.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/host/ipv4-host-vrf-transport-list=%v/transport/tls/port=%v/profile", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
- }
break
}
}
if !found {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/host/ipv4-host-vrf-transport-list=%v/transport/tls/port=%v", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/host/ipv6/ipv6-host-transport-list%v/transport/udp/port-config%v", predicates, cpredicates))
}
}
- for ci := range state.Ipv4VrfHostsTransport[i].TransportTcpPorts {
- cstateKeyValues := [...]string{strconv.FormatInt(state.Ipv4VrfHostsTransport[i].TransportTcpPorts[ci].PortNumber.ValueInt64(), 10)}
+ for ci := range state.Ipv6HostsTransport[i].TransportTcpPorts {
+ cstateKeys := [...]string{"port-number"}
+ cstateKeyValues := [...]string{strconv.FormatInt(state.Ipv6HostsTransport[i].TransportTcpPorts[ci].PortNumber.ValueInt64(), 10)}
+ cpredicates := ""
+ for i := range cstateKeys {
+ cpredicates += fmt.Sprintf("[%s='%s']", cstateKeys[i], cstateKeyValues[i])
+ }
cemptyKeys := true
- if !reflect.ValueOf(state.Ipv4VrfHostsTransport[i].TransportTcpPorts[ci].PortNumber.ValueInt64()).IsZero() {
+ if !reflect.ValueOf(state.Ipv6HostsTransport[i].TransportTcpPorts[ci].PortNumber.ValueInt64()).IsZero() {
cemptyKeys = false
}
if cemptyKeys {
@@ -2205,9 +4690,9 @@ func (data *Logging) getDeletedItems(ctx context.Context, state Logging) []strin
}
found := false
- for cj := range data.Ipv4VrfHostsTransport[j].TransportTcpPorts {
+ for cj := range data.Ipv6HostsTransport[j].TransportTcpPorts {
found = true
- if state.Ipv4VrfHostsTransport[i].TransportTcpPorts[ci].PortNumber.ValueInt64() != data.Ipv4VrfHostsTransport[j].TransportTcpPorts[cj].PortNumber.ValueInt64() {
+ if state.Ipv6HostsTransport[i].TransportTcpPorts[ci].PortNumber.ValueInt64() != data.Ipv6HostsTransport[j].TransportTcpPorts[cj].PortNumber.ValueInt64() {
found = false
}
if found {
@@ -2215,14 +4700,19 @@ func (data *Logging) getDeletedItems(ctx context.Context, state Logging) []strin
}
}
if !found {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/host/ipv4-host-vrf-transport-list=%v/transport/tcp/port-config=%v", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/host/ipv6/ipv6-host-transport-list%v/transport/tcp/port-config%v", predicates, cpredicates))
}
}
- for ci := range state.Ipv4VrfHostsTransport[i].TransportUdpPorts {
- cstateKeyValues := [...]string{strconv.FormatInt(state.Ipv4VrfHostsTransport[i].TransportUdpPorts[ci].PortNumber.ValueInt64(), 10)}
+ for ci := range state.Ipv6HostsTransport[i].TransportTlsPorts {
+ cstateKeys := [...]string{"port-number"}
+ cstateKeyValues := [...]string{strconv.FormatInt(state.Ipv6HostsTransport[i].TransportTlsPorts[ci].PortNumber.ValueInt64(), 10)}
+ cpredicates := ""
+ for i := range cstateKeys {
+ cpredicates += fmt.Sprintf("[%s='%s']", cstateKeys[i], cstateKeyValues[i])
+ }
cemptyKeys := true
- if !reflect.ValueOf(state.Ipv4VrfHostsTransport[i].TransportUdpPorts[ci].PortNumber.ValueInt64()).IsZero() {
+ if !reflect.ValueOf(state.Ipv6HostsTransport[i].TransportTlsPorts[ci].PortNumber.ValueInt64()).IsZero() {
cemptyKeys = false
}
if cemptyKeys {
@@ -2230,34 +4720,42 @@ func (data *Logging) getDeletedItems(ctx context.Context, state Logging) []strin
}
found := false
- for cj := range data.Ipv4VrfHostsTransport[j].TransportUdpPorts {
+ for cj := range data.Ipv6HostsTransport[j].TransportTlsPorts {
found = true
- if state.Ipv4VrfHostsTransport[i].TransportUdpPorts[ci].PortNumber.ValueInt64() != data.Ipv4VrfHostsTransport[j].TransportUdpPorts[cj].PortNumber.ValueInt64() {
+ if state.Ipv6HostsTransport[i].TransportTlsPorts[ci].PortNumber.ValueInt64() != data.Ipv6HostsTransport[j].TransportTlsPorts[cj].PortNumber.ValueInt64() {
found = false
}
if found {
+ if !state.Ipv6HostsTransport[i].TransportTlsPorts[ci].Profile.IsNull() && data.Ipv6HostsTransport[j].TransportTlsPorts[cj].Profile.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/host/ipv6/ipv6-host-transport-list%v/transport/tls/port%v/profile", predicates, cpredicates))
+ }
break
}
}
if !found {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/host/ipv4-host-vrf-transport-list=%v/transport/udp/port-config=%v", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/host/ipv6/ipv6-host-transport-list%v/transport/tls/port%v", predicates, cpredicates))
}
}
break
}
}
if !found {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/host/ipv4-host-vrf-transport-list=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/host/ipv6/ipv6-host-transport-list%v", predicates))
}
}
- for i := range state.Ipv4VrfHosts {
- stateKeyValues := [...]string{state.Ipv4VrfHosts[i].Ipv4Host.ValueString(), state.Ipv4VrfHosts[i].Vrf.ValueString()}
+ for i := range state.Ipv6VrfHosts {
+ stateKeys := [...]string{"ipv6-host", "vrf"}
+ stateKeyValues := [...]string{state.Ipv6VrfHosts[i].Ipv6Host.ValueString(), state.Ipv6VrfHosts[i].Vrf.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
emptyKeys := true
- if !reflect.ValueOf(state.Ipv4VrfHosts[i].Ipv4Host.ValueString()).IsZero() {
+ if !reflect.ValueOf(state.Ipv6VrfHosts[i].Ipv6Host.ValueString()).IsZero() {
emptyKeys = false
}
- if !reflect.ValueOf(state.Ipv4VrfHosts[i].Vrf.ValueString()).IsZero() {
+ if !reflect.ValueOf(state.Ipv6VrfHosts[i].Vrf.ValueString()).IsZero() {
emptyKeys = false
}
if emptyKeys {
@@ -2265,12 +4763,12 @@ func (data *Logging) getDeletedItems(ctx context.Context, state Logging) []strin
}
found := false
- for j := range data.Ipv4VrfHosts {
+ for j := range data.Ipv6VrfHosts {
found = true
- if state.Ipv4VrfHosts[i].Ipv4Host.ValueString() != data.Ipv4VrfHosts[j].Ipv4Host.ValueString() {
+ if state.Ipv6VrfHosts[i].Ipv6Host.ValueString() != data.Ipv6VrfHosts[j].Ipv6Host.ValueString() {
found = false
}
- if state.Ipv4VrfHosts[i].Vrf.ValueString() != data.Ipv4VrfHosts[j].Vrf.ValueString() {
+ if state.Ipv6VrfHosts[i].Vrf.ValueString() != data.Ipv6VrfHosts[j].Vrf.ValueString() {
found = false
}
if found {
@@ -2278,14 +4776,22 @@ func (data *Logging) getDeletedItems(ctx context.Context, state Logging) []strin
}
}
if !found {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/host/ipv4-host-vrf-list=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/host/ipv6/ipv6-host-vrf-list%v", predicates))
+ }
+ }
+ for i := range state.Ipv6VrfHostsTransport {
+ stateKeys := [...]string{"ipv6-host", "vrf"}
+ stateKeyValues := [...]string{state.Ipv6VrfHostsTransport[i].Ipv6Host.ValueString(), state.Ipv6VrfHostsTransport[i].Vrf.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
}
- }
- for i := range state.Ipv4HostsTransport {
- stateKeyValues := [...]string{state.Ipv4HostsTransport[i].Ipv4Host.ValueString()}
emptyKeys := true
- if !reflect.ValueOf(state.Ipv4HostsTransport[i].Ipv4Host.ValueString()).IsZero() {
+ if !reflect.ValueOf(state.Ipv6VrfHostsTransport[i].Ipv6Host.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if !reflect.ValueOf(state.Ipv6VrfHostsTransport[i].Vrf.ValueString()).IsZero() {
emptyKeys = false
}
if emptyKeys {
@@ -2293,17 +4799,25 @@ func (data *Logging) getDeletedItems(ctx context.Context, state Logging) []strin
}
found := false
- for j := range data.Ipv4HostsTransport {
+ for j := range data.Ipv6VrfHostsTransport {
found = true
- if state.Ipv4HostsTransport[i].Ipv4Host.ValueString() != data.Ipv4HostsTransport[j].Ipv4Host.ValueString() {
+ if state.Ipv6VrfHostsTransport[i].Ipv6Host.ValueString() != data.Ipv6VrfHostsTransport[j].Ipv6Host.ValueString() {
+ found = false
+ }
+ if state.Ipv6VrfHostsTransport[i].Vrf.ValueString() != data.Ipv6VrfHostsTransport[j].Vrf.ValueString() {
found = false
}
if found {
- for ci := range state.Ipv4HostsTransport[i].TransportTlsPorts {
- cstateKeyValues := [...]string{strconv.FormatInt(state.Ipv4HostsTransport[i].TransportTlsPorts[ci].PortNumber.ValueInt64(), 10)}
+ for ci := range state.Ipv6VrfHostsTransport[i].TransportUdpPorts {
+ cstateKeys := [...]string{"port-number"}
+ cstateKeyValues := [...]string{strconv.FormatInt(state.Ipv6VrfHostsTransport[i].TransportUdpPorts[ci].PortNumber.ValueInt64(), 10)}
+ cpredicates := ""
+ for i := range cstateKeys {
+ cpredicates += fmt.Sprintf("[%s='%s']", cstateKeys[i], cstateKeyValues[i])
+ }
cemptyKeys := true
- if !reflect.ValueOf(state.Ipv4HostsTransport[i].TransportTlsPorts[ci].PortNumber.ValueInt64()).IsZero() {
+ if !reflect.ValueOf(state.Ipv6VrfHostsTransport[i].TransportUdpPorts[ci].PortNumber.ValueInt64()).IsZero() {
cemptyKeys = false
}
if cemptyKeys {
@@ -2311,27 +4825,29 @@ func (data *Logging) getDeletedItems(ctx context.Context, state Logging) []strin
}
found := false
- for cj := range data.Ipv4HostsTransport[j].TransportTlsPorts {
+ for cj := range data.Ipv6VrfHostsTransport[j].TransportUdpPorts {
found = true
- if state.Ipv4HostsTransport[i].TransportTlsPorts[ci].PortNumber.ValueInt64() != data.Ipv4HostsTransport[j].TransportTlsPorts[cj].PortNumber.ValueInt64() {
+ if state.Ipv6VrfHostsTransport[i].TransportUdpPorts[ci].PortNumber.ValueInt64() != data.Ipv6VrfHostsTransport[j].TransportUdpPorts[cj].PortNumber.ValueInt64() {
found = false
}
if found {
- if !state.Ipv4HostsTransport[i].TransportTlsPorts[ci].Profile.IsNull() && data.Ipv4HostsTransport[j].TransportTlsPorts[cj].Profile.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/host/ipv4-host-transport-list=%v/transport/tls/port=%v/profile", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
- }
break
}
}
if !found {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/host/ipv4-host-transport-list=%v/transport/tls/port=%v", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/host/ipv6/ipv6-host-vrf-transport-list%v/transport/udp/port-config%v", predicates, cpredicates))
}
}
- for ci := range state.Ipv4HostsTransport[i].TransportTcpPorts {
- cstateKeyValues := [...]string{strconv.FormatInt(state.Ipv4HostsTransport[i].TransportTcpPorts[ci].PortNumber.ValueInt64(), 10)}
+ for ci := range state.Ipv6VrfHostsTransport[i].TransportTcpPorts {
+ cstateKeys := [...]string{"port-number"}
+ cstateKeyValues := [...]string{strconv.FormatInt(state.Ipv6VrfHostsTransport[i].TransportTcpPorts[ci].PortNumber.ValueInt64(), 10)}
+ cpredicates := ""
+ for i := range cstateKeys {
+ cpredicates += fmt.Sprintf("[%s='%s']", cstateKeys[i], cstateKeyValues[i])
+ }
cemptyKeys := true
- if !reflect.ValueOf(state.Ipv4HostsTransport[i].TransportTcpPorts[ci].PortNumber.ValueInt64()).IsZero() {
+ if !reflect.ValueOf(state.Ipv6VrfHostsTransport[i].TransportTcpPorts[ci].PortNumber.ValueInt64()).IsZero() {
cemptyKeys = false
}
if cemptyKeys {
@@ -2339,9 +4855,9 @@ func (data *Logging) getDeletedItems(ctx context.Context, state Logging) []strin
}
found := false
- for cj := range data.Ipv4HostsTransport[j].TransportTcpPorts {
+ for cj := range data.Ipv6VrfHostsTransport[j].TransportTcpPorts {
found = true
- if state.Ipv4HostsTransport[i].TransportTcpPorts[ci].PortNumber.ValueInt64() != data.Ipv4HostsTransport[j].TransportTcpPorts[cj].PortNumber.ValueInt64() {
+ if state.Ipv6VrfHostsTransport[i].TransportTcpPorts[ci].PortNumber.ValueInt64() != data.Ipv6VrfHostsTransport[j].TransportTcpPorts[cj].PortNumber.ValueInt64() {
found = false
}
if found {
@@ -2349,14 +4865,19 @@ func (data *Logging) getDeletedItems(ctx context.Context, state Logging) []strin
}
}
if !found {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/host/ipv4-host-transport-list=%v/transport/tcp/port-config=%v", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/host/ipv6/ipv6-host-vrf-transport-list%v/transport/tcp/port-config%v", predicates, cpredicates))
}
}
- for ci := range state.Ipv4HostsTransport[i].TransportUdpPorts {
- cstateKeyValues := [...]string{strconv.FormatInt(state.Ipv4HostsTransport[i].TransportUdpPorts[ci].PortNumber.ValueInt64(), 10)}
+ for ci := range state.Ipv6VrfHostsTransport[i].TransportTlsPorts {
+ cstateKeys := [...]string{"port-number"}
+ cstateKeyValues := [...]string{strconv.FormatInt(state.Ipv6VrfHostsTransport[i].TransportTlsPorts[ci].PortNumber.ValueInt64(), 10)}
+ cpredicates := ""
+ for i := range cstateKeys {
+ cpredicates += fmt.Sprintf("[%s='%s']", cstateKeys[i], cstateKeyValues[i])
+ }
cemptyKeys := true
- if !reflect.ValueOf(state.Ipv4HostsTransport[i].TransportUdpPorts[ci].PortNumber.ValueInt64()).IsZero() {
+ if !reflect.ValueOf(state.Ipv6VrfHostsTransport[i].TransportTlsPorts[ci].PortNumber.ValueInt64()).IsZero() {
cemptyKeys = false
}
if cemptyKeys {
@@ -2364,135 +4885,34 @@ func (data *Logging) getDeletedItems(ctx context.Context, state Logging) []strin
}
found := false
- for cj := range data.Ipv4HostsTransport[j].TransportUdpPorts {
+ for cj := range data.Ipv6VrfHostsTransport[j].TransportTlsPorts {
found = true
- if state.Ipv4HostsTransport[i].TransportUdpPorts[ci].PortNumber.ValueInt64() != data.Ipv4HostsTransport[j].TransportUdpPorts[cj].PortNumber.ValueInt64() {
+ if state.Ipv6VrfHostsTransport[i].TransportTlsPorts[ci].PortNumber.ValueInt64() != data.Ipv6VrfHostsTransport[j].TransportTlsPorts[cj].PortNumber.ValueInt64() {
found = false
}
if found {
+ if !state.Ipv6VrfHostsTransport[i].TransportTlsPorts[ci].Profile.IsNull() && data.Ipv6VrfHostsTransport[j].TransportTlsPorts[cj].Profile.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/host/ipv6/ipv6-host-vrf-transport-list%v/transport/tls/port%v/profile", predicates, cpredicates))
+ }
break
}
}
if !found {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/host/ipv4-host-transport-list=%v/transport/udp/port-config=%v", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/host/ipv6/ipv6-host-vrf-transport-list%v/transport/tls/port%v", predicates, cpredicates))
}
}
break
}
}
if !found {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/host/ipv4-host-transport-list=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
- }
- }
- for i := range state.Ipv4Hosts {
- stateKeyValues := [...]string{state.Ipv4Hosts[i].Ipv4Host.ValueString()}
-
- emptyKeys := true
- if !reflect.ValueOf(state.Ipv4Hosts[i].Ipv4Host.ValueString()).IsZero() {
- emptyKeys = false
- }
- if emptyKeys {
- continue
- }
-
- found := false
- for j := range data.Ipv4Hosts {
- found = true
- if state.Ipv4Hosts[i].Ipv4Host.ValueString() != data.Ipv4Hosts[j].Ipv4Host.ValueString() {
- found = false
- }
- if found {
- break
- }
- }
- if !found {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/host/ipv4-host-list=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
- }
- }
- for i := range state.SourceInterfacesVrf {
- stateKeyValues := [...]string{state.SourceInterfacesVrf[i].Vrf.ValueString()}
-
- emptyKeys := true
- if !reflect.ValueOf(state.SourceInterfacesVrf[i].Vrf.ValueString()).IsZero() {
- emptyKeys = false
- }
- if emptyKeys {
- continue
- }
-
- found := false
- for j := range data.SourceInterfacesVrf {
- found = true
- if state.SourceInterfacesVrf[i].Vrf.ValueString() != data.SourceInterfacesVrf[j].Vrf.ValueString() {
- found = false
- }
- if found {
- if !state.SourceInterfacesVrf[i].InterfaceName.IsNull() && data.SourceInterfacesVrf[j].InterfaceName.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/source-interface-conf/source-interface-vrf=%v/interface-name", state.getPath(), strings.Join(stateKeyValues[:], ",")))
- }
- break
- }
- }
- if !found {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/source-interface-conf/source-interface-vrf=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/host/ipv6/ipv6-host-vrf-transport-list%v", predicates))
}
}
- if !state.Console.IsNull() && data.Console.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/console-config/console", state.getPath()))
- }
- if !state.SourceInterface.IsNull() && data.SourceInterface.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/source-interface-conf/interface-name-non-vrf", state.getPath()))
- }
- if !state.FileSeverity.IsNull() && data.FileSeverity.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/file/severity", state.getPath()))
- }
- if !state.FileMinSize.IsNull() && data.FileMinSize.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/file/min-size", state.getPath()))
- }
- if !state.FileMaxSize.IsNull() && data.FileMaxSize.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/file/max-size", state.getPath()))
- }
- if !state.FileName.IsNull() && data.FileName.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/file/name", state.getPath()))
- }
- if !state.OriginIdName.IsNull() && data.OriginIdName.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/origin-id/string", state.getPath()))
- }
- if !state.OriginIdType.IsNull() && data.OriginIdType.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/origin-id/type-value", state.getPath()))
- }
- if !state.TrapSeverity.IsNull() && data.TrapSeverity.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/trap/severity", state.getPath()))
- }
- if !state.Trap.IsNull() && data.Trap.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/trap", state.getPath()))
- }
- if !state.HistorySeverity.IsNull() && data.HistorySeverity.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/history/severity-level", state.getPath()))
- }
- if !state.HistorySize.IsNull() && data.HistorySize.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/history/size", state.getPath()))
- }
- if !state.Facility.IsNull() && data.Facility.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/facility", state.getPath()))
- }
- if !state.ConsoleSeverity.IsNull() && data.ConsoleSeverity.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/console-config/common-config/console/severity", state.getPath()))
- }
- if !state.BufferedSeverity.IsNull() && data.BufferedSeverity.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/buffered/severity-level", state.getPath()))
- }
- if !state.BufferedSize.IsNull() && data.BufferedSize.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/buffered/size-value", state.getPath()))
- }
- if !state.MonitorSeverity.IsNull() && data.MonitorSeverity.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/monitor-config/common-config/monitor/severity", state.getPath()))
- }
- return deletedItems
+ return b.Res()
}
-// End of section. //template:end getDeletedItems
+// End of section. //template:end addDeletedItemsXML
// Section below is generated&owned by "gen/generator.go". //template:begin getEmptyLeafsDelete
@@ -2613,3 +5033,154 @@ func (data *Logging) getDeletePaths(ctx context.Context) []string {
}
// End of section. //template:end getDeletePaths
+
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletePathsXML
+
+func (data *Logging) addDeletePathsXML(ctx context.Context, body string) string {
+ b := netconf.NewBody(body)
+ if !data.MonitorSeverity.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/monitor-config/common-config/monitor/severity")
+ }
+ if !data.BufferedSize.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/buffered/size-value")
+ }
+ if !data.BufferedSeverity.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/buffered/severity-level")
+ }
+ if !data.ConsoleSeverity.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/console-config/common-config/console/severity")
+ }
+ if !data.Facility.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/facility")
+ }
+ if !data.HistorySize.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/history/size")
+ }
+ if !data.HistorySeverity.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/history/severity-level")
+ }
+ if !data.Trap.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/trap")
+ }
+ if !data.TrapSeverity.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/trap/severity")
+ }
+ if !data.OriginIdType.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/origin-id/type-value")
+ }
+ if !data.OriginIdName.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/origin-id/string")
+ }
+ if !data.FileName.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/file/name")
+ }
+ if !data.FileMaxSize.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/file/max-size")
+ }
+ if !data.FileMinSize.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/file/min-size")
+ }
+ if !data.FileSeverity.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/file/severity")
+ }
+ if !data.SourceInterface.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/source-interface-conf/interface-name-non-vrf")
+ }
+ if !data.Console.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/console-config/console")
+ }
+ for i := range data.SourceInterfacesVrf {
+ keys := [...]string{"vrf"}
+ keyValues := [...]string{data.SourceInterfacesVrf[i].Vrf.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/source-interface-conf/source-interface-vrf%v", predicates))
+ }
+ for i := range data.Ipv4Hosts {
+ keys := [...]string{"ipv4-host"}
+ keyValues := [...]string{data.Ipv4Hosts[i].Ipv4Host.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/host/ipv4-host-list%v", predicates))
+ }
+ for i := range data.Ipv4HostsTransport {
+ keys := [...]string{"ipv4-host"}
+ keyValues := [...]string{data.Ipv4HostsTransport[i].Ipv4Host.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/host/ipv4-host-transport-list%v", predicates))
+ }
+ for i := range data.Ipv4VrfHosts {
+ keys := [...]string{"ipv4-host", "vrf"}
+ keyValues := [...]string{data.Ipv4VrfHosts[i].Ipv4Host.ValueString(), data.Ipv4VrfHosts[i].Vrf.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/host/ipv4-host-vrf-list%v", predicates))
+ }
+ for i := range data.Ipv4VrfHostsTransport {
+ keys := [...]string{"ipv4-host", "vrf"}
+ keyValues := [...]string{data.Ipv4VrfHostsTransport[i].Ipv4Host.ValueString(), data.Ipv4VrfHostsTransport[i].Vrf.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/host/ipv4-host-vrf-transport-list%v", predicates))
+ }
+ for i := range data.Ipv6Hosts {
+ keys := [...]string{"ipv6-host"}
+ keyValues := [...]string{data.Ipv6Hosts[i].Ipv6Host.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/host/ipv6/ipv6-host-list%v", predicates))
+ }
+ for i := range data.Ipv6HostsTransport {
+ keys := [...]string{"ipv6-host"}
+ keyValues := [...]string{data.Ipv6HostsTransport[i].Ipv6Host.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/host/ipv6/ipv6-host-transport-list%v", predicates))
+ }
+ for i := range data.Ipv6VrfHosts {
+ keys := [...]string{"ipv6-host", "vrf"}
+ keyValues := [...]string{data.Ipv6VrfHosts[i].Ipv6Host.ValueString(), data.Ipv6VrfHosts[i].Vrf.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/host/ipv6/ipv6-host-vrf-list%v", predicates))
+ }
+ for i := range data.Ipv6VrfHostsTransport {
+ keys := [...]string{"ipv6-host", "vrf"}
+ keyValues := [...]string{data.Ipv6VrfHostsTransport[i].Ipv6Host.ValueString(), data.Ipv6VrfHostsTransport[i].Vrf.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/host/ipv6/ipv6-host-vrf-transport-list%v", predicates))
+ }
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletePathsXML
diff --git a/internal/provider/model_iosxe_mdt_subscription.go b/internal/provider/model_iosxe_mdt_subscription.go
index 863b16c0..a53adf99 100644
--- a/internal/provider/model_iosxe_mdt_subscription.go
+++ b/internal/provider/model_iosxe_mdt_subscription.go
@@ -31,6 +31,9 @@ import (
"github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/types"
+ "github.com/hashicorp/terraform-plugin-log/tflog"
+ "github.com/netascode/go-netconf"
+ "github.com/netascode/xmldot"
"github.com/tidwall/gjson"
"github.com/tidwall/sjson"
)
@@ -94,6 +97,19 @@ func (data MDTSubscription) getPathShort() string {
return matches[1]
}
+// getXPath returns the XPath for NETCONF operations
+func (data MDTSubscription) getXPath() string {
+ path := "/Cisco-IOS-XE-mdt-cfg:mdt-config-data/mdt-subscription[subscription-id=%s]"
+ path = fmt.Sprintf(path, fmt.Sprintf("%v", data.SubscriptionId.ValueInt64()))
+ return path
+}
+
+func (data MDTSubscriptionData) getXPath() string {
+ path := "/Cisco-IOS-XE-mdt-cfg:mdt-config-data/mdt-subscription[subscription-id=%s]"
+ path = fmt.Sprintf(path, fmt.Sprintf("%v", data.SubscriptionId.ValueInt64()))
+ return path
+}
+
// End of section. //template:end getPath
// Section below is generated&owned by "gen/generator.go". //template:begin toBody
@@ -143,6 +159,58 @@ func (data MDTSubscription) toBody(ctx context.Context) string {
// End of section. //template:end toBody
+// Section below is generated&owned by "gen/generator.go". //template:begin toBodyXML
+
+func (data MDTSubscription) toBodyXML(ctx context.Context) string {
+ body := netconf.Body{}
+ if !data.SubscriptionId.IsNull() && !data.SubscriptionId.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/subscription-id", strconv.FormatInt(data.SubscriptionId.ValueInt64(), 10))
+ }
+ if !data.Stream.IsNull() && !data.Stream.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/base/stream", data.Stream.ValueString())
+ }
+ if !data.Encoding.IsNull() && !data.Encoding.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/base/encoding", data.Encoding.ValueString())
+ }
+ if !data.SourceVrf.IsNull() && !data.SourceVrf.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/base/source-vrf", data.SourceVrf.ValueString())
+ }
+ if !data.SourceAddress.IsNull() && !data.SourceAddress.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/base/source-address", data.SourceAddress.ValueString())
+ }
+ if !data.UpdatePolicyPeriodic.IsNull() && !data.UpdatePolicyPeriodic.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/base/period", strconv.FormatInt(data.UpdatePolicyPeriodic.ValueInt64(), 10))
+ }
+ if !data.UpdatePolicyOnChange.IsNull() && !data.UpdatePolicyOnChange.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/base/no-synch-on-start", data.UpdatePolicyOnChange.ValueBool())
+ }
+ if !data.FilterXpath.IsNull() && !data.FilterXpath.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/base/xpath", data.FilterXpath.ValueString())
+ }
+ if len(data.Receivers) > 0 {
+ for _, item := range data.Receivers {
+ cBody := netconf.Body{}
+ if !item.Address.IsNull() && !item.Address.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "address", item.Address.ValueString())
+ }
+ if !item.Port.IsNull() && !item.Port.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "port", strconv.FormatInt(item.Port.ValueInt64(), 10))
+ }
+ if !item.Protocol.IsNull() && !item.Protocol.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "protocol", item.Protocol.ValueString())
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/mdt-receivers", cBody.Res())
+ }
+ }
+ bodyString, err := body.String()
+ if err != nil {
+ tflog.Error(ctx, fmt.Sprintf("Error converting body to string: %s", err))
+ }
+ return bodyString
+}
+
+// End of section. //template:end toBodyXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBody
func (data *MDTSubscription) updateFromBody(ctx context.Context, res gjson.Result) {
@@ -235,6 +303,94 @@ func (data *MDTSubscription) updateFromBody(ctx context.Context, res gjson.Resul
// End of section. //template:end updateFromBody
+// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBodyXML
+
+func (data *MDTSubscription) updateFromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/subscription-id"); value.Exists() && !data.SubscriptionId.IsNull() {
+ data.SubscriptionId = types.Int64Value(value.Int())
+ } else {
+ data.SubscriptionId = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/base/stream"); value.Exists() && !data.Stream.IsNull() {
+ data.Stream = types.StringValue(value.String())
+ } else {
+ data.Stream = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/base/encoding"); value.Exists() && !data.Encoding.IsNull() {
+ data.Encoding = types.StringValue(value.String())
+ } else {
+ data.Encoding = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/base/source-vrf"); value.Exists() && !data.SourceVrf.IsNull() {
+ data.SourceVrf = types.StringValue(value.String())
+ } else {
+ data.SourceVrf = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/base/source-address"); value.Exists() && !data.SourceAddress.IsNull() {
+ data.SourceAddress = types.StringValue(value.String())
+ } else {
+ data.SourceAddress = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/base/period"); value.Exists() && !data.UpdatePolicyPeriodic.IsNull() {
+ data.UpdatePolicyPeriodic = types.Int64Value(value.Int())
+ } else {
+ data.UpdatePolicyPeriodic = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/base/no-synch-on-start"); !data.UpdatePolicyOnChange.IsNull() {
+ if value.Exists() {
+ data.UpdatePolicyOnChange = types.BoolValue(value.Bool())
+ }
+ } else {
+ data.UpdatePolicyOnChange = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/base/xpath"); value.Exists() && !data.FilterXpath.IsNull() {
+ data.FilterXpath = types.StringValue(value.String())
+ } else {
+ data.FilterXpath = types.StringNull()
+ }
+ for i := range data.Receivers {
+ keys := [...]string{"address", "port"}
+ keyValues := [...]string{data.Receivers[i].Address.ValueString(), strconv.FormatInt(data.Receivers[i].Port.ValueInt64(), 10)}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/mdt-receivers").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, "address"); value.Exists() && !data.Receivers[i].Address.IsNull() {
+ data.Receivers[i].Address = types.StringValue(value.String())
+ } else {
+ data.Receivers[i].Address = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "port"); value.Exists() && !data.Receivers[i].Port.IsNull() {
+ data.Receivers[i].Port = types.Int64Value(value.Int())
+ } else {
+ data.Receivers[i].Port = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(r, "protocol"); value.Exists() && !data.Receivers[i].Protocol.IsNull() {
+ data.Receivers[i].Protocol = types.StringValue(value.String())
+ } else {
+ data.Receivers[i].Protocol = types.StringNull()
+ }
+ }
+}
+
+// End of section. //template:end updateFromBodyXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin fromBody
func (data *MDTSubscription) fromBody(ctx context.Context, res gjson.Result) {
@@ -337,6 +493,100 @@ func (data *MDTSubscriptionData) fromBody(ctx context.Context, res gjson.Result)
// End of section. //template:end fromBodyData
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyXML
+
+func (data *MDTSubscription) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/base/stream"); value.Exists() {
+ data.Stream = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/base/encoding"); value.Exists() {
+ data.Encoding = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/base/source-vrf"); value.Exists() {
+ data.SourceVrf = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/base/source-address"); value.Exists() {
+ data.SourceAddress = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/base/period"); value.Exists() {
+ data.UpdatePolicyPeriodic = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/base/no-synch-on-start"); value.Exists() {
+ data.UpdatePolicyOnChange = types.BoolValue(value.Bool())
+ } else {
+ data.UpdatePolicyOnChange = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/base/xpath"); value.Exists() {
+ data.FilterXpath = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/mdt-receivers"); value.Exists() {
+ data.Receivers = make([]MDTSubscriptionReceivers, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := MDTSubscriptionReceivers{}
+ if cValue := helpers.GetFromXPath(v, "address"); cValue.Exists() {
+ item.Address = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "port"); cValue.Exists() {
+ item.Port = types.Int64Value(cValue.Int())
+ }
+ if cValue := helpers.GetFromXPath(v, "protocol"); cValue.Exists() {
+ item.Protocol = types.StringValue(cValue.String())
+ }
+ data.Receivers = append(data.Receivers, item)
+ return true
+ })
+ }
+}
+
+// End of section. //template:end fromBodyXML
+
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyDataXML
+
+func (data *MDTSubscriptionData) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/base/stream"); value.Exists() {
+ data.Stream = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/base/encoding"); value.Exists() {
+ data.Encoding = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/base/source-vrf"); value.Exists() {
+ data.SourceVrf = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/base/source-address"); value.Exists() {
+ data.SourceAddress = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/base/period"); value.Exists() {
+ data.UpdatePolicyPeriodic = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/base/no-synch-on-start"); value.Exists() {
+ data.UpdatePolicyOnChange = types.BoolValue(value.Bool())
+ } else {
+ data.UpdatePolicyOnChange = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/base/xpath"); value.Exists() {
+ data.FilterXpath = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/mdt-receivers"); value.Exists() {
+ data.Receivers = make([]MDTSubscriptionReceivers, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := MDTSubscriptionReceivers{}
+ if cValue := helpers.GetFromXPath(v, "address"); cValue.Exists() {
+ item.Address = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "port"); cValue.Exists() {
+ item.Port = types.Int64Value(cValue.Int())
+ }
+ if cValue := helpers.GetFromXPath(v, "protocol"); cValue.Exists() {
+ item.Protocol = types.StringValue(cValue.String())
+ }
+ data.Receivers = append(data.Receivers, item)
+ return true
+ })
+ }
+}
+
+// End of section. //template:end fromBodyDataXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin getDeletedItems
func (data *MDTSubscription) getDeletedItems(ctx context.Context, state MDTSubscription) []string {
@@ -402,6 +652,76 @@ func (data *MDTSubscription) getDeletedItems(ctx context.Context, state MDTSubsc
// End of section. //template:end getDeletedItems
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletedItemsXML
+
+func (data *MDTSubscription) addDeletedItemsXML(ctx context.Context, state MDTSubscription, body string) string {
+ b := netconf.NewBody(body)
+ if !state.Stream.IsNull() && data.Stream.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/base/stream")
+ }
+ if !state.Encoding.IsNull() && data.Encoding.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/base/encoding")
+ }
+ if !state.SourceVrf.IsNull() && data.SourceVrf.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/base/source-vrf")
+ }
+ if !state.SourceAddress.IsNull() && data.SourceAddress.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/base/source-address")
+ }
+ if !state.UpdatePolicyPeriodic.IsNull() && data.UpdatePolicyPeriodic.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/base/period")
+ }
+ if !state.UpdatePolicyOnChange.IsNull() && data.UpdatePolicyOnChange.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/base/no-synch-on-start")
+ }
+ if !state.FilterXpath.IsNull() && data.FilterXpath.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/base/xpath")
+ }
+ for i := range state.Receivers {
+ stateKeys := [...]string{"address", "port"}
+ stateKeyValues := [...]string{state.Receivers[i].Address.ValueString(), strconv.FormatInt(state.Receivers[i].Port.ValueInt64(), 10)}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.Receivers[i].Address.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if !reflect.ValueOf(state.Receivers[i].Port.ValueInt64()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.Receivers {
+ found = true
+ if state.Receivers[i].Address.ValueString() != data.Receivers[j].Address.ValueString() {
+ found = false
+ }
+ if state.Receivers[i].Port.ValueInt64() != data.Receivers[j].Port.ValueInt64() {
+ found = false
+ }
+ if found {
+ if !state.Receivers[i].Protocol.IsNull() && data.Receivers[j].Protocol.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/mdt-receivers%v/protocol", predicates))
+ }
+ break
+ }
+ }
+ if !found {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/mdt-receivers%v", predicates))
+ }
+ }
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletedItemsXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin getEmptyLeafsDelete
func (data *MDTSubscription) getEmptyLeafsDelete(ctx context.Context) []string {
@@ -447,3 +767,44 @@ func (data *MDTSubscription) getDeletePaths(ctx context.Context) []string {
}
// End of section. //template:end getDeletePaths
+
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletePathsXML
+
+func (data *MDTSubscription) addDeletePathsXML(ctx context.Context, body string) string {
+ b := netconf.NewBody(body)
+ if !data.Stream.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/base/stream")
+ }
+ if !data.Encoding.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/base/encoding")
+ }
+ if !data.SourceVrf.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/base/source-vrf")
+ }
+ if !data.SourceAddress.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/base/source-address")
+ }
+ if !data.UpdatePolicyPeriodic.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/base/period")
+ }
+ if !data.UpdatePolicyOnChange.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/base/no-synch-on-start")
+ }
+ if !data.FilterXpath.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/base/xpath")
+ }
+ for i := range data.Receivers {
+ keys := [...]string{"address", "port"}
+ keyValues := [...]string{data.Receivers[i].Address.ValueString(), strconv.FormatInt(data.Receivers[i].Port.ValueInt64(), 10)}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/mdt-receivers%v", predicates))
+ }
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletePathsXML
diff --git a/internal/provider/model_iosxe_msdp.go b/internal/provider/model_iosxe_msdp.go
index ee96fd86..f35c74e6 100644
--- a/internal/provider/model_iosxe_msdp.go
+++ b/internal/provider/model_iosxe_msdp.go
@@ -30,6 +30,9 @@ import (
"github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/types"
+ "github.com/hashicorp/terraform-plugin-log/tflog"
+ "github.com/netascode/go-netconf"
+ "github.com/netascode/xmldot"
"github.com/tidwall/gjson"
"github.com/tidwall/sjson"
)
@@ -105,6 +108,17 @@ func (data MSDP) getPathShort() string {
return matches[1]
}
+// getXPath returns the XPath for NETCONF operations
+func (data MSDP) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/ip/Cisco-IOS-XE-multicast:msdp"
+ return path
+}
+
+func (data MSDPData) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/ip/Cisco-IOS-XE-multicast:msdp"
+ return path
+}
+
// End of section. //template:end getPath
// Section below is generated&owned by "gen/generator.go". //template:begin toBody
@@ -186,6 +200,94 @@ func (data MSDP) toBody(ctx context.Context) string {
// End of section. //template:end toBody
+// Section below is generated&owned by "gen/generator.go". //template:begin toBodyXML
+
+func (data MSDP) toBodyXML(ctx context.Context) string {
+ body := netconf.Body{}
+ if !data.OriginatorId.IsNull() && !data.OriginatorId.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/originator-id", data.OriginatorId.ValueString())
+ }
+ if len(data.Peers) > 0 {
+ for _, item := range data.Peers {
+ cBody := netconf.Body{}
+ if !item.Addr.IsNull() && !item.Addr.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "addr", item.Addr.ValueString())
+ }
+ if !item.RemoteAs.IsNull() && !item.RemoteAs.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "remote-as", strconv.FormatInt(item.RemoteAs.ValueInt64(), 10))
+ }
+ if !item.ConnectSourceLoopback.IsNull() && !item.ConnectSourceLoopback.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "connect-source/Loopback", strconv.FormatInt(item.ConnectSourceLoopback.ValueInt64(), 10))
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/peer", cBody.Res())
+ }
+ }
+ if len(data.Passwords) > 0 {
+ for _, item := range data.Passwords {
+ cBody := netconf.Body{}
+ if !item.Addr.IsNull() && !item.Addr.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "addr", item.Addr.ValueString())
+ }
+ if !item.Encryption.IsNull() && !item.Encryption.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "encryption", strconv.FormatInt(item.Encryption.ValueInt64(), 10))
+ }
+ if !item.Password.IsNull() && !item.Password.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "password", item.Password.ValueString())
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/password/peer-list", cBody.Res())
+ }
+ }
+ if len(data.Vrfs) > 0 {
+ for _, item := range data.Vrfs {
+ cBody := netconf.Body{}
+ if !item.Vrf.IsNull() && !item.Vrf.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "name", item.Vrf.ValueString())
+ }
+ if !item.OriginatorId.IsNull() && !item.OriginatorId.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "originator-id", item.OriginatorId.ValueString())
+ }
+ if len(item.Peers) > 0 {
+ for _, citem := range item.Peers {
+ ccBody := netconf.Body{}
+ if !citem.Addr.IsNull() && !citem.Addr.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "addr", citem.Addr.ValueString())
+ }
+ if !citem.RemoteAs.IsNull() && !citem.RemoteAs.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "remote-as", strconv.FormatInt(citem.RemoteAs.ValueInt64(), 10))
+ }
+ if !citem.ConnectSourceLoopback.IsNull() && !citem.ConnectSourceLoopback.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "connect-source/Loopback", strconv.FormatInt(citem.ConnectSourceLoopback.ValueInt64(), 10))
+ }
+ cBody = helpers.SetRawFromXPath(cBody, "peer", ccBody.Res())
+ }
+ }
+ if len(item.Passwords) > 0 {
+ for _, citem := range item.Passwords {
+ ccBody := netconf.Body{}
+ if !citem.Addr.IsNull() && !citem.Addr.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "addr", citem.Addr.ValueString())
+ }
+ if !citem.Encryption.IsNull() && !citem.Encryption.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "encryption", strconv.FormatInt(citem.Encryption.ValueInt64(), 10))
+ }
+ if !citem.Password.IsNull() && !citem.Password.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "password", citem.Password.ValueString())
+ }
+ cBody = helpers.SetRawFromXPath(cBody, "password/peer-list", ccBody.Res())
+ }
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/vrf", cBody.Res())
+ }
+ }
+ bodyString, err := body.String()
+ if err != nil {
+ tflog.Error(ctx, fmt.Sprintf("Error converting body to string: %s", err))
+ }
+ return bodyString
+}
+
+// End of section. //template:end toBodyXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBody
func (data *MSDP) updateFromBody(ctx context.Context, res gjson.Result) {
@@ -372,6 +474,188 @@ func (data *MSDP) updateFromBody(ctx context.Context, res gjson.Result) {
// End of section. //template:end updateFromBody
+// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBodyXML
+
+func (data *MSDP) updateFromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/originator-id"); value.Exists() && !data.OriginatorId.IsNull() {
+ data.OriginatorId = types.StringValue(value.String())
+ } else {
+ data.OriginatorId = types.StringNull()
+ }
+ for i := range data.Peers {
+ keys := [...]string{"addr"}
+ keyValues := [...]string{data.Peers[i].Addr.ValueString()}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/peer").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, "addr"); value.Exists() && !data.Peers[i].Addr.IsNull() {
+ data.Peers[i].Addr = types.StringValue(value.String())
+ } else {
+ data.Peers[i].Addr = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "remote-as"); value.Exists() && !data.Peers[i].RemoteAs.IsNull() {
+ data.Peers[i].RemoteAs = types.Int64Value(value.Int())
+ } else {
+ data.Peers[i].RemoteAs = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(r, "connect-source/Loopback"); value.Exists() && !data.Peers[i].ConnectSourceLoopback.IsNull() {
+ data.Peers[i].ConnectSourceLoopback = types.Int64Value(value.Int())
+ } else {
+ data.Peers[i].ConnectSourceLoopback = types.Int64Null()
+ }
+ }
+ for i := range data.Passwords {
+ keys := [...]string{"addr"}
+ keyValues := [...]string{data.Passwords[i].Addr.ValueString()}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/password/peer-list").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, "addr"); value.Exists() && !data.Passwords[i].Addr.IsNull() {
+ data.Passwords[i].Addr = types.StringValue(value.String())
+ } else {
+ data.Passwords[i].Addr = types.StringNull()
+ }
+ }
+ for i := range data.Vrfs {
+ keys := [...]string{"name"}
+ keyValues := [...]string{data.Vrfs[i].Vrf.ValueString()}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/vrf").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, "name"); value.Exists() && !data.Vrfs[i].Vrf.IsNull() {
+ data.Vrfs[i].Vrf = types.StringValue(value.String())
+ } else {
+ data.Vrfs[i].Vrf = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "originator-id"); value.Exists() && !data.Vrfs[i].OriginatorId.IsNull() {
+ data.Vrfs[i].OriginatorId = types.StringValue(value.String())
+ } else {
+ data.Vrfs[i].OriginatorId = types.StringNull()
+ }
+ for ci := range data.Vrfs[i].Peers {
+ keys := [...]string{"addr"}
+ keyValues := [...]string{data.Vrfs[i].Peers[ci].Addr.ValueString()}
+
+ var cr xmldot.Result
+ helpers.GetFromXPath(r, "peer").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ cr = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(cr, "addr"); value.Exists() && !data.Vrfs[i].Peers[ci].Addr.IsNull() {
+ data.Vrfs[i].Peers[ci].Addr = types.StringValue(value.String())
+ } else {
+ data.Vrfs[i].Peers[ci].Addr = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(cr, "remote-as"); value.Exists() && !data.Vrfs[i].Peers[ci].RemoteAs.IsNull() {
+ data.Vrfs[i].Peers[ci].RemoteAs = types.Int64Value(value.Int())
+ } else {
+ data.Vrfs[i].Peers[ci].RemoteAs = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(cr, "connect-source/Loopback"); value.Exists() && !data.Vrfs[i].Peers[ci].ConnectSourceLoopback.IsNull() {
+ data.Vrfs[i].Peers[ci].ConnectSourceLoopback = types.Int64Value(value.Int())
+ } else {
+ data.Vrfs[i].Peers[ci].ConnectSourceLoopback = types.Int64Null()
+ }
+ }
+ for ci := range data.Vrfs[i].Passwords {
+ keys := [...]string{"addr"}
+ keyValues := [...]string{data.Vrfs[i].Passwords[ci].Addr.ValueString()}
+
+ var cr xmldot.Result
+ helpers.GetFromXPath(r, "password/peer-list").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ cr = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(cr, "addr"); value.Exists() && !data.Vrfs[i].Passwords[ci].Addr.IsNull() {
+ data.Vrfs[i].Passwords[ci].Addr = types.StringValue(value.String())
+ } else {
+ data.Vrfs[i].Passwords[ci].Addr = types.StringNull()
+ }
+ }
+ }
+}
+
+// End of section. //template:end updateFromBodyXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin fromBody
func (data *MSDP) fromBody(ctx context.Context, res gjson.Result) {
@@ -564,6 +848,190 @@ func (data *MSDPData) fromBody(ctx context.Context, res gjson.Result) {
// End of section. //template:end fromBodyData
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyXML
+
+func (data *MSDP) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/originator-id"); value.Exists() {
+ data.OriginatorId = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/peer"); value.Exists() {
+ data.Peers = make([]MSDPPeers, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := MSDPPeers{}
+ if cValue := helpers.GetFromXPath(v, "addr"); cValue.Exists() {
+ item.Addr = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "remote-as"); cValue.Exists() {
+ item.RemoteAs = types.Int64Value(cValue.Int())
+ }
+ if cValue := helpers.GetFromXPath(v, "connect-source/Loopback"); cValue.Exists() {
+ item.ConnectSourceLoopback = types.Int64Value(cValue.Int())
+ }
+ data.Peers = append(data.Peers, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/password/peer-list"); value.Exists() {
+ data.Passwords = make([]MSDPPasswords, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := MSDPPasswords{}
+ if cValue := helpers.GetFromXPath(v, "addr"); cValue.Exists() {
+ item.Addr = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "encryption"); cValue.Exists() {
+ item.Encryption = types.Int64Value(cValue.Int())
+ }
+ if cValue := helpers.GetFromXPath(v, "password"); cValue.Exists() {
+ item.Password = types.StringValue(cValue.String())
+ }
+ data.Passwords = append(data.Passwords, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/vrf"); value.Exists() {
+ data.Vrfs = make([]MSDPVrfs, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := MSDPVrfs{}
+ if cValue := helpers.GetFromXPath(v, "name"); cValue.Exists() {
+ item.Vrf = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "originator-id"); cValue.Exists() {
+ item.OriginatorId = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "peer"); cValue.Exists() {
+ item.Peers = make([]MSDPVrfsPeers, 0)
+ cValue.ForEach(func(_ int, cv xmldot.Result) bool {
+ cItem := MSDPVrfsPeers{}
+ if ccValue := helpers.GetFromXPath(cv, "addr"); ccValue.Exists() {
+ cItem.Addr = types.StringValue(ccValue.String())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "remote-as"); ccValue.Exists() {
+ cItem.RemoteAs = types.Int64Value(ccValue.Int())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "connect-source/Loopback"); ccValue.Exists() {
+ cItem.ConnectSourceLoopback = types.Int64Value(ccValue.Int())
+ }
+ item.Peers = append(item.Peers, cItem)
+ return true
+ })
+ }
+ if cValue := helpers.GetFromXPath(v, "password/peer-list"); cValue.Exists() {
+ item.Passwords = make([]MSDPVrfsPasswords, 0)
+ cValue.ForEach(func(_ int, cv xmldot.Result) bool {
+ cItem := MSDPVrfsPasswords{}
+ if ccValue := helpers.GetFromXPath(cv, "addr"); ccValue.Exists() {
+ cItem.Addr = types.StringValue(ccValue.String())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "encryption"); ccValue.Exists() {
+ cItem.Encryption = types.Int64Value(ccValue.Int())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "password"); ccValue.Exists() {
+ cItem.Password = types.StringValue(ccValue.String())
+ }
+ item.Passwords = append(item.Passwords, cItem)
+ return true
+ })
+ }
+ data.Vrfs = append(data.Vrfs, item)
+ return true
+ })
+ }
+}
+
+// End of section. //template:end fromBodyXML
+
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyDataXML
+
+func (data *MSDPData) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/originator-id"); value.Exists() {
+ data.OriginatorId = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/peer"); value.Exists() {
+ data.Peers = make([]MSDPPeers, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := MSDPPeers{}
+ if cValue := helpers.GetFromXPath(v, "addr"); cValue.Exists() {
+ item.Addr = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "remote-as"); cValue.Exists() {
+ item.RemoteAs = types.Int64Value(cValue.Int())
+ }
+ if cValue := helpers.GetFromXPath(v, "connect-source/Loopback"); cValue.Exists() {
+ item.ConnectSourceLoopback = types.Int64Value(cValue.Int())
+ }
+ data.Peers = append(data.Peers, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/password/peer-list"); value.Exists() {
+ data.Passwords = make([]MSDPPasswords, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := MSDPPasswords{}
+ if cValue := helpers.GetFromXPath(v, "addr"); cValue.Exists() {
+ item.Addr = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "encryption"); cValue.Exists() {
+ item.Encryption = types.Int64Value(cValue.Int())
+ }
+ if cValue := helpers.GetFromXPath(v, "password"); cValue.Exists() {
+ item.Password = types.StringValue(cValue.String())
+ }
+ data.Passwords = append(data.Passwords, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/vrf"); value.Exists() {
+ data.Vrfs = make([]MSDPVrfs, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := MSDPVrfs{}
+ if cValue := helpers.GetFromXPath(v, "name"); cValue.Exists() {
+ item.Vrf = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "originator-id"); cValue.Exists() {
+ item.OriginatorId = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "peer"); cValue.Exists() {
+ item.Peers = make([]MSDPVrfsPeers, 0)
+ cValue.ForEach(func(_ int, cv xmldot.Result) bool {
+ cItem := MSDPVrfsPeers{}
+ if ccValue := helpers.GetFromXPath(cv, "addr"); ccValue.Exists() {
+ cItem.Addr = types.StringValue(ccValue.String())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "remote-as"); ccValue.Exists() {
+ cItem.RemoteAs = types.Int64Value(ccValue.Int())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "connect-source/Loopback"); ccValue.Exists() {
+ cItem.ConnectSourceLoopback = types.Int64Value(ccValue.Int())
+ }
+ item.Peers = append(item.Peers, cItem)
+ return true
+ })
+ }
+ if cValue := helpers.GetFromXPath(v, "password/peer-list"); cValue.Exists() {
+ item.Passwords = make([]MSDPVrfsPasswords, 0)
+ cValue.ForEach(func(_ int, cv xmldot.Result) bool {
+ cItem := MSDPVrfsPasswords{}
+ if ccValue := helpers.GetFromXPath(cv, "addr"); ccValue.Exists() {
+ cItem.Addr = types.StringValue(ccValue.String())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "encryption"); ccValue.Exists() {
+ cItem.Encryption = types.Int64Value(ccValue.Int())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "password"); ccValue.Exists() {
+ cItem.Password = types.StringValue(ccValue.String())
+ }
+ item.Passwords = append(item.Passwords, cItem)
+ return true
+ })
+ }
+ data.Vrfs = append(data.Vrfs, item)
+ return true
+ })
+ }
+}
+
+// End of section. //template:end fromBodyDataXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin getDeletedItems
func (data *MSDP) getDeletedItems(ctx context.Context, state MSDP) []string {
@@ -729,6 +1197,196 @@ func (data *MSDP) getDeletedItems(ctx context.Context, state MSDP) []string {
// End of section. //template:end getDeletedItems
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletedItemsXML
+
+func (data *MSDP) addDeletedItemsXML(ctx context.Context, state MSDP, body string) string {
+ b := netconf.NewBody(body)
+ if !state.OriginatorId.IsNull() && data.OriginatorId.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/originator-id")
+ }
+ for i := range state.Peers {
+ stateKeys := [...]string{"addr"}
+ stateKeyValues := [...]string{state.Peers[i].Addr.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.Peers[i].Addr.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.Peers {
+ found = true
+ if state.Peers[i].Addr.ValueString() != data.Peers[j].Addr.ValueString() {
+ found = false
+ }
+ if found {
+ if !state.Peers[i].RemoteAs.IsNull() && data.Peers[j].RemoteAs.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/peer%v/remote-as", predicates))
+ }
+ if !state.Peers[i].ConnectSourceLoopback.IsNull() && data.Peers[j].ConnectSourceLoopback.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/peer%v/connect-source/Loopback", predicates))
+ }
+ break
+ }
+ }
+ if !found {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/peer%v", predicates))
+ }
+ }
+ for i := range state.Passwords {
+ stateKeys := [...]string{"addr"}
+ stateKeyValues := [...]string{state.Passwords[i].Addr.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.Passwords[i].Addr.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.Passwords {
+ found = true
+ if state.Passwords[i].Addr.ValueString() != data.Passwords[j].Addr.ValueString() {
+ found = false
+ }
+ if found {
+ if !state.Passwords[i].Encryption.IsNull() && data.Passwords[j].Encryption.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/password/peer-list%v/encryption", predicates))
+ }
+ if !state.Passwords[i].Password.IsNull() && data.Passwords[j].Password.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/password/peer-list%v/password", predicates))
+ }
+ break
+ }
+ }
+ if !found {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/password/peer-list%v", predicates))
+ }
+ }
+ for i := range state.Vrfs {
+ stateKeys := [...]string{"name"}
+ stateKeyValues := [...]string{state.Vrfs[i].Vrf.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.Vrfs[i].Vrf.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.Vrfs {
+ found = true
+ if state.Vrfs[i].Vrf.ValueString() != data.Vrfs[j].Vrf.ValueString() {
+ found = false
+ }
+ if found {
+ if !state.Vrfs[i].OriginatorId.IsNull() && data.Vrfs[j].OriginatorId.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/vrf%v/originator-id", predicates))
+ }
+ for ci := range state.Vrfs[i].Peers {
+ cstateKeys := [...]string{"addr"}
+ cstateKeyValues := [...]string{state.Vrfs[i].Peers[ci].Addr.ValueString()}
+ cpredicates := ""
+ for i := range cstateKeys {
+ cpredicates += fmt.Sprintf("[%s='%s']", cstateKeys[i], cstateKeyValues[i])
+ }
+
+ cemptyKeys := true
+ if !reflect.ValueOf(state.Vrfs[i].Peers[ci].Addr.ValueString()).IsZero() {
+ cemptyKeys = false
+ }
+ if cemptyKeys {
+ continue
+ }
+
+ found := false
+ for cj := range data.Vrfs[j].Peers {
+ found = true
+ if state.Vrfs[i].Peers[ci].Addr.ValueString() != data.Vrfs[j].Peers[cj].Addr.ValueString() {
+ found = false
+ }
+ if found {
+ if !state.Vrfs[i].Peers[ci].RemoteAs.IsNull() && data.Vrfs[j].Peers[cj].RemoteAs.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/vrf%v/peer%v/remote-as", predicates, cpredicates))
+ }
+ if !state.Vrfs[i].Peers[ci].ConnectSourceLoopback.IsNull() && data.Vrfs[j].Peers[cj].ConnectSourceLoopback.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/vrf%v/peer%v/connect-source/Loopback", predicates, cpredicates))
+ }
+ break
+ }
+ }
+ if !found {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/vrf%v/peer%v", predicates, cpredicates))
+ }
+ }
+ for ci := range state.Vrfs[i].Passwords {
+ cstateKeys := [...]string{"addr"}
+ cstateKeyValues := [...]string{state.Vrfs[i].Passwords[ci].Addr.ValueString()}
+ cpredicates := ""
+ for i := range cstateKeys {
+ cpredicates += fmt.Sprintf("[%s='%s']", cstateKeys[i], cstateKeyValues[i])
+ }
+
+ cemptyKeys := true
+ if !reflect.ValueOf(state.Vrfs[i].Passwords[ci].Addr.ValueString()).IsZero() {
+ cemptyKeys = false
+ }
+ if cemptyKeys {
+ continue
+ }
+
+ found := false
+ for cj := range data.Vrfs[j].Passwords {
+ found = true
+ if state.Vrfs[i].Passwords[ci].Addr.ValueString() != data.Vrfs[j].Passwords[cj].Addr.ValueString() {
+ found = false
+ }
+ if found {
+ if !state.Vrfs[i].Passwords[ci].Encryption.IsNull() && data.Vrfs[j].Passwords[cj].Encryption.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/vrf%v/password/peer-list%v/encryption", predicates, cpredicates))
+ }
+ if !state.Vrfs[i].Passwords[ci].Password.IsNull() && data.Vrfs[j].Passwords[cj].Password.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/vrf%v/password/peer-list%v/password", predicates, cpredicates))
+ }
+ break
+ }
+ }
+ if !found {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/vrf%v/password/peer-list%v", predicates, cpredicates))
+ }
+ }
+ break
+ }
+ }
+ if !found {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/vrf%v", predicates))
+ }
+ }
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletedItemsXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin getEmptyLeafsDelete
func (data *MSDP) getEmptyLeafsDelete(ctx context.Context) []string {
@@ -766,3 +1424,46 @@ func (data *MSDP) getDeletePaths(ctx context.Context) []string {
}
// End of section. //template:end getDeletePaths
+
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletePathsXML
+
+func (data *MSDP) addDeletePathsXML(ctx context.Context, body string) string {
+ b := netconf.NewBody(body)
+ if !data.OriginatorId.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/originator-id")
+ }
+ for i := range data.Peers {
+ keys := [...]string{"addr"}
+ keyValues := [...]string{data.Peers[i].Addr.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/peer%v", predicates))
+ }
+ for i := range data.Passwords {
+ keys := [...]string{"addr"}
+ keyValues := [...]string{data.Passwords[i].Addr.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/password/peer-list%v", predicates))
+ }
+ for i := range data.Vrfs {
+ keys := [...]string{"name"}
+ keyValues := [...]string{data.Vrfs[i].Vrf.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/vrf%v", predicates))
+ }
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletePathsXML
diff --git a/internal/provider/model_iosxe_nat.go b/internal/provider/model_iosxe_nat.go
index bb83a93c..f28b210e 100644
--- a/internal/provider/model_iosxe_nat.go
+++ b/internal/provider/model_iosxe_nat.go
@@ -30,6 +30,9 @@ import (
"github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/types"
+ "github.com/hashicorp/terraform-plugin-log/tflog"
+ "github.com/netascode/go-netconf"
+ "github.com/netascode/xmldot"
"github.com/tidwall/gjson"
"github.com/tidwall/sjson"
)
@@ -81,6 +84,17 @@ func (data NAT) getPathShort() string {
return matches[1]
}
+// getXPath returns the XPath for NETCONF operations
+func (data NAT) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/ip/Cisco-IOS-XE-nat:nat"
+ return path
+}
+
+func (data NATData) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/ip/Cisco-IOS-XE-nat:nat"
+ return path
+}
+
// End of section. //template:end getPath
// Section below is generated&owned by "gen/generator.go". //template:begin toBody
@@ -113,6 +127,44 @@ func (data NAT) toBody(ctx context.Context) string {
// End of section. //template:end toBody
+// Section below is generated&owned by "gen/generator.go". //template:begin toBodyXML
+
+func (data NAT) toBodyXML(ctx context.Context) string {
+ body := netconf.Body{}
+ if len(data.InsideSourceInterfaces) > 0 {
+ for _, item := range data.InsideSourceInterfaces {
+ cBody := netconf.Body{}
+ if !item.Id.IsNull() && !item.Id.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "id", item.Id.ValueString())
+ }
+ if len(item.Interfaces) > 0 {
+ for _, citem := range item.Interfaces {
+ ccBody := netconf.Body{}
+ if !citem.Interface.IsNull() && !citem.Interface.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "name", citem.Interface.ValueString())
+ }
+ if !citem.Overload.IsNull() && !citem.Overload.IsUnknown() {
+ if citem.Overload.ValueBool() {
+ ccBody = helpers.SetFromXPath(ccBody, "overload-new", "")
+ } else {
+ ccBody = helpers.RemoveFromXPath(ccBody, "overload-new")
+ }
+ }
+ cBody = helpers.SetRawFromXPath(cBody, "interface", ccBody.Res())
+ }
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/inside/source/list-interface/list", cBody.Res())
+ }
+ }
+ bodyString, err := body.String()
+ if err != nil {
+ tflog.Error(ctx, fmt.Sprintf("Error converting body to string: %s", err))
+ }
+ return bodyString
+}
+
+// End of section. //template:end toBodyXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBody
func (data *NAT) updateFromBody(ctx context.Context, res gjson.Result) {
@@ -191,6 +243,80 @@ func (data *NAT) updateFromBody(ctx context.Context, res gjson.Result) {
// End of section. //template:end updateFromBody
+// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBodyXML
+
+func (data *NAT) updateFromBodyXML(ctx context.Context, res xmldot.Result) {
+ for i := range data.InsideSourceInterfaces {
+ keys := [...]string{"id"}
+ keyValues := [...]string{data.InsideSourceInterfaces[i].Id.ValueString()}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/inside/source/list-interface/list").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, "id"); value.Exists() && !data.InsideSourceInterfaces[i].Id.IsNull() {
+ data.InsideSourceInterfaces[i].Id = types.StringValue(value.String())
+ } else {
+ data.InsideSourceInterfaces[i].Id = types.StringNull()
+ }
+ for ci := range data.InsideSourceInterfaces[i].Interfaces {
+ keys := [...]string{"name"}
+ keyValues := [...]string{data.InsideSourceInterfaces[i].Interfaces[ci].Interface.ValueString()}
+
+ var cr xmldot.Result
+ helpers.GetFromXPath(r, "interface").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ cr = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(cr, "name"); value.Exists() && !data.InsideSourceInterfaces[i].Interfaces[ci].Interface.IsNull() {
+ data.InsideSourceInterfaces[i].Interfaces[ci].Interface = types.StringValue(value.String())
+ } else {
+ data.InsideSourceInterfaces[i].Interfaces[ci].Interface = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(cr, "overload-new"); !data.InsideSourceInterfaces[i].Interfaces[ci].Overload.IsNull() {
+ if value.Exists() {
+ data.InsideSourceInterfaces[i].Interfaces[ci].Overload = types.BoolValue(true)
+ } else {
+ data.InsideSourceInterfaces[i].Interfaces[ci].Overload = types.BoolValue(false)
+ }
+ } else {
+ data.InsideSourceInterfaces[i].Interfaces[ci].Overload = types.BoolNull()
+ }
+ }
+ }
+}
+
+// End of section. //template:end updateFromBodyXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin fromBody
func (data *NAT) fromBody(ctx context.Context, res gjson.Result) {
@@ -267,6 +393,74 @@ func (data *NATData) fromBody(ctx context.Context, res gjson.Result) {
// End of section. //template:end fromBodyData
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyXML
+
+func (data *NAT) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/inside/source/list-interface/list"); value.Exists() {
+ data.InsideSourceInterfaces = make([]NATInsideSourceInterfaces, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := NATInsideSourceInterfaces{}
+ if cValue := helpers.GetFromXPath(v, "id"); cValue.Exists() {
+ item.Id = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "interface"); cValue.Exists() {
+ item.Interfaces = make([]NATInsideSourceInterfacesInterfaces, 0)
+ cValue.ForEach(func(_ int, cv xmldot.Result) bool {
+ cItem := NATInsideSourceInterfacesInterfaces{}
+ if ccValue := helpers.GetFromXPath(cv, "name"); ccValue.Exists() {
+ cItem.Interface = types.StringValue(ccValue.String())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "overload-new"); ccValue.Exists() {
+ cItem.Overload = types.BoolValue(true)
+ } else {
+ cItem.Overload = types.BoolValue(false)
+ }
+ item.Interfaces = append(item.Interfaces, cItem)
+ return true
+ })
+ }
+ data.InsideSourceInterfaces = append(data.InsideSourceInterfaces, item)
+ return true
+ })
+ }
+}
+
+// End of section. //template:end fromBodyXML
+
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyDataXML
+
+func (data *NATData) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/inside/source/list-interface/list"); value.Exists() {
+ data.InsideSourceInterfaces = make([]NATInsideSourceInterfaces, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := NATInsideSourceInterfaces{}
+ if cValue := helpers.GetFromXPath(v, "id"); cValue.Exists() {
+ item.Id = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "interface"); cValue.Exists() {
+ item.Interfaces = make([]NATInsideSourceInterfacesInterfaces, 0)
+ cValue.ForEach(func(_ int, cv xmldot.Result) bool {
+ cItem := NATInsideSourceInterfacesInterfaces{}
+ if ccValue := helpers.GetFromXPath(cv, "name"); ccValue.Exists() {
+ cItem.Interface = types.StringValue(ccValue.String())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "overload-new"); ccValue.Exists() {
+ cItem.Overload = types.BoolValue(true)
+ } else {
+ cItem.Overload = types.BoolValue(false)
+ }
+ item.Interfaces = append(item.Interfaces, cItem)
+ return true
+ })
+ }
+ data.InsideSourceInterfaces = append(data.InsideSourceInterfaces, item)
+ return true
+ })
+ }
+}
+
+// End of section. //template:end fromBodyDataXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin getDeletedItems
func (data *NAT) getDeletedItems(ctx context.Context, state NAT) []string {
@@ -330,6 +524,79 @@ func (data *NAT) getDeletedItems(ctx context.Context, state NAT) []string {
// End of section. //template:end getDeletedItems
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletedItemsXML
+
+func (data *NAT) addDeletedItemsXML(ctx context.Context, state NAT, body string) string {
+ b := netconf.NewBody(body)
+ for i := range state.InsideSourceInterfaces {
+ stateKeys := [...]string{"id"}
+ stateKeyValues := [...]string{state.InsideSourceInterfaces[i].Id.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.InsideSourceInterfaces[i].Id.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.InsideSourceInterfaces {
+ found = true
+ if state.InsideSourceInterfaces[i].Id.ValueString() != data.InsideSourceInterfaces[j].Id.ValueString() {
+ found = false
+ }
+ if found {
+ for ci := range state.InsideSourceInterfaces[i].Interfaces {
+ cstateKeys := [...]string{"name"}
+ cstateKeyValues := [...]string{state.InsideSourceInterfaces[i].Interfaces[ci].Interface.ValueString()}
+ cpredicates := ""
+ for i := range cstateKeys {
+ cpredicates += fmt.Sprintf("[%s='%s']", cstateKeys[i], cstateKeyValues[i])
+ }
+
+ cemptyKeys := true
+ if !reflect.ValueOf(state.InsideSourceInterfaces[i].Interfaces[ci].Interface.ValueString()).IsZero() {
+ cemptyKeys = false
+ }
+ if cemptyKeys {
+ continue
+ }
+
+ found := false
+ for cj := range data.InsideSourceInterfaces[j].Interfaces {
+ found = true
+ if state.InsideSourceInterfaces[i].Interfaces[ci].Interface.ValueString() != data.InsideSourceInterfaces[j].Interfaces[cj].Interface.ValueString() {
+ found = false
+ }
+ if found {
+ if !state.InsideSourceInterfaces[i].Interfaces[ci].Overload.IsNull() && data.InsideSourceInterfaces[j].Interfaces[cj].Overload.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/inside/source/list-interface/list%v/interface%v/overload-new", predicates, cpredicates))
+ }
+ break
+ }
+ }
+ if !found {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/inside/source/list-interface/list%v/interface%v", predicates, cpredicates))
+ }
+ }
+ break
+ }
+ }
+ if !found {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/inside/source/list-interface/list%v", predicates))
+ }
+ }
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletedItemsXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin getEmptyLeafsDelete
func (data *NAT) getEmptyLeafsDelete(ctx context.Context) []string {
@@ -365,3 +632,23 @@ func (data *NAT) getDeletePaths(ctx context.Context) []string {
}
// End of section. //template:end getDeletePaths
+
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletePathsXML
+
+func (data *NAT) addDeletePathsXML(ctx context.Context, body string) string {
+ b := netconf.NewBody(body)
+ for i := range data.InsideSourceInterfaces {
+ keys := [...]string{"id"}
+ keyValues := [...]string{data.InsideSourceInterfaces[i].Id.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/inside/source/list-interface/list%v", predicates))
+ }
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletePathsXML
diff --git a/internal/provider/model_iosxe_ntp.go b/internal/provider/model_iosxe_ntp.go
index ff810865..719ca153 100644
--- a/internal/provider/model_iosxe_ntp.go
+++ b/internal/provider/model_iosxe_ntp.go
@@ -30,6 +30,9 @@ import (
"github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/types"
+ "github.com/hashicorp/terraform-plugin-log/tflog"
+ "github.com/netascode/go-netconf"
+ "github.com/netascode/xmldot"
"github.com/tidwall/gjson"
"github.com/tidwall/sjson"
)
@@ -174,6 +177,17 @@ func (data NTP) getPathShort() string {
return matches[1]
}
+// getXPath returns the XPath for NETCONF operations
+func (data NTP) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/ntp"
+ return path
+}
+
+func (data NTPData) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/ntp"
+ return path
+}
+
// End of section. //template:end getPath
// Section below is generated&owned by "gen/generator.go". //template:begin toBody
@@ -417,6 +431,289 @@ func (data NTP) toBody(ctx context.Context) string {
// End of section. //template:end toBody
+// Section below is generated&owned by "gen/generator.go". //template:begin toBodyXML
+
+func (data NTP) toBodyXML(ctx context.Context) string {
+ body := netconf.Body{}
+ if !data.Authenticate.IsNull() && !data.Authenticate.IsUnknown() {
+ if data.Authenticate.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-ntp:authenticate", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-ntp:authenticate")
+ }
+ }
+ if !data.Logging.IsNull() && !data.Logging.IsUnknown() {
+ if data.Logging.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-ntp:logging", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-ntp:logging")
+ }
+ }
+ if !data.AccessGroupPeerAcl.IsNull() && !data.AccessGroupPeerAcl.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-ntp:access-group/peer/acl", data.AccessGroupPeerAcl.ValueString())
+ }
+ if !data.AccessGroupQueryOnlyAcl.IsNull() && !data.AccessGroupQueryOnlyAcl.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-ntp:access-group/query-only/acl", data.AccessGroupQueryOnlyAcl.ValueString())
+ }
+ if !data.AccessGroupServeAcl.IsNull() && !data.AccessGroupServeAcl.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-ntp:access-group/serve/acl", data.AccessGroupServeAcl.ValueString())
+ }
+ if !data.AccessGroupServeOnlyAcl.IsNull() && !data.AccessGroupServeOnlyAcl.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-ntp:access-group/serve-only/acl", data.AccessGroupServeOnlyAcl.ValueString())
+ }
+ if len(data.AuthenticationKeys) > 0 {
+ for _, item := range data.AuthenticationKeys {
+ cBody := netconf.Body{}
+ if !item.Number.IsNull() && !item.Number.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "number", strconv.FormatInt(item.Number.ValueInt64(), 10))
+ }
+ if !item.Md5.IsNull() && !item.Md5.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "md5-cfg", item.Md5.ValueString())
+ }
+ if !item.CmacAes128.IsNull() && !item.CmacAes128.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "cmac-aes-128", item.CmacAes128.ValueString())
+ }
+ if !item.HmacSha1.IsNull() && !item.HmacSha1.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "hmac-sha1", item.HmacSha1.ValueString())
+ }
+ if !item.HmacSha2256.IsNull() && !item.HmacSha2256.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "hmac-sha2-256", item.HmacSha2256.ValueString())
+ }
+ if !item.Sha1.IsNull() && !item.Sha1.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "sha1", item.Sha1.ValueString())
+ }
+ if !item.Sha2.IsNull() && !item.Sha2.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "sha2", item.Sha2.ValueString())
+ }
+ if !item.EncryptionType.IsNull() && !item.EncryptionType.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "encryption-type", strconv.FormatInt(item.EncryptionType.ValueInt64(), 10))
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-ntp:authentication-key", cBody.Res())
+ }
+ }
+ if !data.ClockPeriod.IsNull() && !data.ClockPeriod.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-ntp:clock-period", strconv.FormatInt(data.ClockPeriod.ValueInt64(), 10))
+ }
+ if !data.Master.IsNull() && !data.Master.IsUnknown() {
+ if data.Master.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-ntp:master", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-ntp:master")
+ }
+ }
+ if !data.MasterStratum.IsNull() && !data.MasterStratum.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-ntp:master/stratum-number", strconv.FormatInt(data.MasterStratum.ValueInt64(), 10))
+ }
+ if !data.Passive.IsNull() && !data.Passive.IsUnknown() {
+ if data.Passive.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-ntp:passive", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-ntp:passive")
+ }
+ }
+ if !data.UpdateCalendar.IsNull() && !data.UpdateCalendar.IsUnknown() {
+ if data.UpdateCalendar.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-ntp:update-calendar", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-ntp:update-calendar")
+ }
+ }
+ if !data.SourceGigabitEthernet.IsNull() && !data.SourceGigabitEthernet.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-ntp:source/GigabitEthernet", data.SourceGigabitEthernet.ValueString())
+ }
+ if !data.SourceTenGigabitEthernet.IsNull() && !data.SourceTenGigabitEthernet.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-ntp:source/TenGigabitEthernet", data.SourceTenGigabitEthernet.ValueString())
+ }
+ if !data.SourceFortyGigabitEthernet.IsNull() && !data.SourceFortyGigabitEthernet.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-ntp:source/FortyGigabitEthernet", data.SourceFortyGigabitEthernet.ValueString())
+ }
+ if !data.SourceHundredGigabitEthernet.IsNull() && !data.SourceHundredGigabitEthernet.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-ntp:source/HundredGigE", data.SourceHundredGigabitEthernet.ValueString())
+ }
+ if !data.SourceLoopback.IsNull() && !data.SourceLoopback.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-ntp:source/Loopback", strconv.FormatInt(data.SourceLoopback.ValueInt64(), 10))
+ }
+ if !data.SourcePortChannel.IsNull() && !data.SourcePortChannel.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-ntp:source/Port-channel", strconv.FormatInt(data.SourcePortChannel.ValueInt64(), 10))
+ }
+ if !data.SourcePortChannelSubinterface.IsNull() && !data.SourcePortChannelSubinterface.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-ntp:source/Port-channel-subinterface/Port-channel", data.SourcePortChannelSubinterface.ValueString())
+ }
+ if !data.SourceVlan.IsNull() && !data.SourceVlan.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-ntp:source/Vlan", strconv.FormatInt(data.SourceVlan.ValueInt64(), 10))
+ }
+ if len(data.Servers) > 0 {
+ for _, item := range data.Servers {
+ cBody := netconf.Body{}
+ if !item.IpAddress.IsNull() && !item.IpAddress.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "ip-address", item.IpAddress.ValueString())
+ }
+ if !item.Source.IsNull() && !item.Source.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "source", item.Source.ValueString())
+ }
+ if !item.Key.IsNull() && !item.Key.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "key", strconv.FormatInt(item.Key.ValueInt64(), 10))
+ }
+ if !item.Prefer.IsNull() && !item.Prefer.IsUnknown() {
+ if item.Prefer.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "prefer", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "prefer")
+ }
+ }
+ if !item.Version.IsNull() && !item.Version.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "version", strconv.FormatInt(item.Version.ValueInt64(), 10))
+ }
+ if !item.Burst.IsNull() && !item.Burst.IsUnknown() {
+ if item.Burst.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "burst-opt", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "burst-opt")
+ }
+ }
+ if !item.Iburst.IsNull() && !item.Iburst.IsUnknown() {
+ if item.Iburst.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "iburst-opt", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "iburst-opt")
+ }
+ }
+ if !item.Periodic.IsNull() && !item.Periodic.IsUnknown() {
+ if item.Periodic.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "periodic", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "periodic")
+ }
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-ntp:server/server-list", cBody.Res())
+ }
+ }
+ if len(data.ServerVrfs) > 0 {
+ for _, item := range data.ServerVrfs {
+ cBody := netconf.Body{}
+ if !item.Name.IsNull() && !item.Name.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "name", item.Name.ValueString())
+ }
+ if len(item.Servers) > 0 {
+ for _, citem := range item.Servers {
+ ccBody := netconf.Body{}
+ if !citem.IpAddress.IsNull() && !citem.IpAddress.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "ip-address", citem.IpAddress.ValueString())
+ }
+ if !citem.Key.IsNull() && !citem.Key.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "key", strconv.FormatInt(citem.Key.ValueInt64(), 10))
+ }
+ if !citem.Prefer.IsNull() && !citem.Prefer.IsUnknown() {
+ if citem.Prefer.ValueBool() {
+ ccBody = helpers.SetFromXPath(ccBody, "prefer", "")
+ } else {
+ ccBody = helpers.RemoveFromXPath(ccBody, "prefer")
+ }
+ }
+ if !citem.Version.IsNull() && !citem.Version.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "version", strconv.FormatInt(citem.Version.ValueInt64(), 10))
+ }
+ if !citem.Burst.IsNull() && !citem.Burst.IsUnknown() {
+ if citem.Burst.ValueBool() {
+ ccBody = helpers.SetFromXPath(ccBody, "burst-opt", "")
+ } else {
+ ccBody = helpers.RemoveFromXPath(ccBody, "burst-opt")
+ }
+ }
+ if !citem.Iburst.IsNull() && !citem.Iburst.IsUnknown() {
+ if citem.Iburst.ValueBool() {
+ ccBody = helpers.SetFromXPath(ccBody, "iburst-opt", "")
+ } else {
+ ccBody = helpers.RemoveFromXPath(ccBody, "iburst-opt")
+ }
+ }
+ if !citem.Periodic.IsNull() && !citem.Periodic.IsUnknown() {
+ if citem.Periodic.ValueBool() {
+ ccBody = helpers.SetFromXPath(ccBody, "periodic", "")
+ } else {
+ ccBody = helpers.RemoveFromXPath(ccBody, "periodic")
+ }
+ }
+ cBody = helpers.SetRawFromXPath(cBody, "server-list", ccBody.Res())
+ }
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-ntp:server/vrf", cBody.Res())
+ }
+ }
+ if len(data.Peers) > 0 {
+ for _, item := range data.Peers {
+ cBody := netconf.Body{}
+ if !item.IpAddress.IsNull() && !item.IpAddress.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "ip-address", item.IpAddress.ValueString())
+ }
+ if !item.Source.IsNull() && !item.Source.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "source", item.Source.ValueString())
+ }
+ if !item.Key.IsNull() && !item.Key.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "key", strconv.FormatInt(item.Key.ValueInt64(), 10))
+ }
+ if !item.Prefer.IsNull() && !item.Prefer.IsUnknown() {
+ if item.Prefer.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "prefer", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "prefer")
+ }
+ }
+ if !item.Version.IsNull() && !item.Version.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "version", strconv.FormatInt(item.Version.ValueInt64(), 10))
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-ntp:peer/server-list", cBody.Res())
+ }
+ }
+ if len(data.PeerVrfs) > 0 {
+ for _, item := range data.PeerVrfs {
+ cBody := netconf.Body{}
+ if !item.Name.IsNull() && !item.Name.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "name", item.Name.ValueString())
+ }
+ if len(item.Peers) > 0 {
+ for _, citem := range item.Peers {
+ ccBody := netconf.Body{}
+ if !citem.IpAddress.IsNull() && !citem.IpAddress.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "ip-address", citem.IpAddress.ValueString())
+ }
+ if !citem.Key.IsNull() && !citem.Key.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "key", strconv.FormatInt(citem.Key.ValueInt64(), 10))
+ }
+ if !citem.Prefer.IsNull() && !citem.Prefer.IsUnknown() {
+ if citem.Prefer.ValueBool() {
+ ccBody = helpers.SetFromXPath(ccBody, "prefer", "")
+ } else {
+ ccBody = helpers.RemoveFromXPath(ccBody, "prefer")
+ }
+ }
+ if !citem.Version.IsNull() && !citem.Version.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "version", strconv.FormatInt(citem.Version.ValueInt64(), 10))
+ }
+ cBody = helpers.SetRawFromXPath(cBody, "server-list", ccBody.Res())
+ }
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-ntp:peer/vrf", cBody.Res())
+ }
+ }
+ if len(data.TrustedKeys) > 0 {
+ for _, item := range data.TrustedKeys {
+ cBody := netconf.Body{}
+ if !item.Number.IsNull() && !item.Number.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "number", strconv.FormatInt(item.Number.ValueInt64(), 10))
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-ntp:trusted-key", cBody.Res())
+ }
+ }
+ bodyString, err := body.String()
+ if err != nil {
+ tflog.Error(ctx, fmt.Sprintf("Error converting body to string: %s", err))
+ }
+ return bodyString
+}
+
+// End of section. //template:end toBodyXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBody
func (data *NTP) updateFromBody(ctx context.Context, res gjson.Result) {
@@ -915,276 +1212,503 @@ func (data *NTP) updateFromBody(ctx context.Context, res gjson.Result) {
// End of section. //template:end updateFromBody
-// Section below is generated&owned by "gen/generator.go". //template:begin fromBody
+// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBodyXML
-func (data *NTP) fromBody(ctx context.Context, res gjson.Result) {
- prefix := helpers.LastElement(data.getPath()) + "."
- if res.Get(helpers.LastElement(data.getPath())).IsArray() {
- prefix += "0."
- }
- if value := res.Get(prefix + "Cisco-IOS-XE-ntp:authenticate"); value.Exists() {
- data.Authenticate = types.BoolValue(true)
+func (data *NTP) updateFromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-ntp:authenticate"); !data.Authenticate.IsNull() {
+ if value.Exists() {
+ data.Authenticate = types.BoolValue(true)
+ } else {
+ data.Authenticate = types.BoolValue(false)
+ }
} else {
- data.Authenticate = types.BoolValue(false)
+ data.Authenticate = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-ntp:logging"); value.Exists() {
- data.Logging = types.BoolValue(true)
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-ntp:logging"); !data.Logging.IsNull() {
+ if value.Exists() {
+ data.Logging = types.BoolValue(true)
+ } else {
+ data.Logging = types.BoolValue(false)
+ }
} else {
- data.Logging = types.BoolValue(false)
+ data.Logging = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-ntp:access-group.peer.acl"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-ntp:access-group/peer/acl"); value.Exists() && !data.AccessGroupPeerAcl.IsNull() {
data.AccessGroupPeerAcl = types.StringValue(value.String())
+ } else {
+ data.AccessGroupPeerAcl = types.StringNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-ntp:access-group.query-only.acl"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-ntp:access-group/query-only/acl"); value.Exists() && !data.AccessGroupQueryOnlyAcl.IsNull() {
data.AccessGroupQueryOnlyAcl = types.StringValue(value.String())
+ } else {
+ data.AccessGroupQueryOnlyAcl = types.StringNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-ntp:access-group.serve.acl"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-ntp:access-group/serve/acl"); value.Exists() && !data.AccessGroupServeAcl.IsNull() {
data.AccessGroupServeAcl = types.StringValue(value.String())
+ } else {
+ data.AccessGroupServeAcl = types.StringNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-ntp:access-group.serve-only.acl"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-ntp:access-group/serve-only/acl"); value.Exists() && !data.AccessGroupServeOnlyAcl.IsNull() {
data.AccessGroupServeOnlyAcl = types.StringValue(value.String())
- }
- if value := res.Get(prefix + "Cisco-IOS-XE-ntp:authentication-key"); value.Exists() {
- data.AuthenticationKeys = make([]NTPAuthenticationKeys, 0)
- value.ForEach(func(k, v gjson.Result) bool {
- item := NTPAuthenticationKeys{}
- if cValue := v.Get("number"); cValue.Exists() {
- item.Number = types.Int64Value(cValue.Int())
- }
- if cValue := v.Get("md5-cfg"); cValue.Exists() {
- item.Md5 = types.StringValue(cValue.String())
- }
- if cValue := v.Get("cmac-aes-128"); cValue.Exists() {
- item.CmacAes128 = types.StringValue(cValue.String())
- }
- if cValue := v.Get("hmac-sha1"); cValue.Exists() {
- item.HmacSha1 = types.StringValue(cValue.String())
- }
- if cValue := v.Get("hmac-sha2-256"); cValue.Exists() {
- item.HmacSha2256 = types.StringValue(cValue.String())
- }
- if cValue := v.Get("sha1"); cValue.Exists() {
- item.Sha1 = types.StringValue(cValue.String())
- }
- if cValue := v.Get("sha2"); cValue.Exists() {
- item.Sha2 = types.StringValue(cValue.String())
- }
- if cValue := v.Get("encryption-type"); cValue.Exists() {
- item.EncryptionType = types.Int64Value(cValue.Int())
- }
- data.AuthenticationKeys = append(data.AuthenticationKeys, item)
- return true
- })
- }
- if value := res.Get(prefix + "Cisco-IOS-XE-ntp:clock-period"); value.Exists() {
- data.ClockPeriod = types.Int64Value(value.Int())
- }
- if value := res.Get(prefix + "Cisco-IOS-XE-ntp:master"); value.Exists() {
- data.Master = types.BoolValue(true)
} else {
- data.Master = types.BoolValue(false)
+ data.AccessGroupServeOnlyAcl = types.StringNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-ntp:master.stratum-number"); value.Exists() {
+ for i := range data.AuthenticationKeys {
+ keys := [...]string{"number"}
+ keyValues := [...]string{strconv.FormatInt(data.AuthenticationKeys[i].Number.ValueInt64(), 10)}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-ntp:authentication-key").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, "number"); value.Exists() && !data.AuthenticationKeys[i].Number.IsNull() {
+ data.AuthenticationKeys[i].Number = types.Int64Value(value.Int())
+ } else {
+ data.AuthenticationKeys[i].Number = types.Int64Null()
+ }
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-ntp:clock-period"); value.Exists() && !data.ClockPeriod.IsNull() {
+ data.ClockPeriod = types.Int64Value(value.Int())
+ } else {
+ data.ClockPeriod = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-ntp:master"); !data.Master.IsNull() {
+ if value.Exists() {
+ data.Master = types.BoolValue(true)
+ } else {
+ data.Master = types.BoolValue(false)
+ }
+ } else {
+ data.Master = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-ntp:master/stratum-number"); value.Exists() && !data.MasterStratum.IsNull() {
data.MasterStratum = types.Int64Value(value.Int())
+ } else {
+ data.MasterStratum = types.Int64Null()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-ntp:passive"); value.Exists() {
- data.Passive = types.BoolValue(true)
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-ntp:passive"); !data.Passive.IsNull() {
+ if value.Exists() {
+ data.Passive = types.BoolValue(true)
+ } else {
+ data.Passive = types.BoolValue(false)
+ }
} else {
- data.Passive = types.BoolValue(false)
+ data.Passive = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-ntp:update-calendar"); value.Exists() {
- data.UpdateCalendar = types.BoolValue(true)
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-ntp:update-calendar"); !data.UpdateCalendar.IsNull() {
+ if value.Exists() {
+ data.UpdateCalendar = types.BoolValue(true)
+ } else {
+ data.UpdateCalendar = types.BoolValue(false)
+ }
} else {
- data.UpdateCalendar = types.BoolValue(false)
+ data.UpdateCalendar = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-ntp:source.GigabitEthernet"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-ntp:source/GigabitEthernet"); value.Exists() && !data.SourceGigabitEthernet.IsNull() {
data.SourceGigabitEthernet = types.StringValue(value.String())
+ } else {
+ data.SourceGigabitEthernet = types.StringNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-ntp:source.TenGigabitEthernet"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-ntp:source/TenGigabitEthernet"); value.Exists() && !data.SourceTenGigabitEthernet.IsNull() {
data.SourceTenGigabitEthernet = types.StringValue(value.String())
+ } else {
+ data.SourceTenGigabitEthernet = types.StringNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-ntp:source.FortyGigabitEthernet"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-ntp:source/FortyGigabitEthernet"); value.Exists() && !data.SourceFortyGigabitEthernet.IsNull() {
data.SourceFortyGigabitEthernet = types.StringValue(value.String())
+ } else {
+ data.SourceFortyGigabitEthernet = types.StringNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-ntp:source.HundredGigE"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-ntp:source/HundredGigE"); value.Exists() && !data.SourceHundredGigabitEthernet.IsNull() {
data.SourceHundredGigabitEthernet = types.StringValue(value.String())
+ } else {
+ data.SourceHundredGigabitEthernet = types.StringNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-ntp:source.Loopback"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-ntp:source/Loopback"); value.Exists() && !data.SourceLoopback.IsNull() {
data.SourceLoopback = types.Int64Value(value.Int())
+ } else {
+ data.SourceLoopback = types.Int64Null()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-ntp:source.Port-channel"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-ntp:source/Port-channel"); value.Exists() && !data.SourcePortChannel.IsNull() {
data.SourcePortChannel = types.Int64Value(value.Int())
+ } else {
+ data.SourcePortChannel = types.Int64Null()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-ntp:source.Port-channel-subinterface.Port-channel"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-ntp:source/Port-channel-subinterface/Port-channel"); value.Exists() && !data.SourcePortChannelSubinterface.IsNull() {
data.SourcePortChannelSubinterface = types.StringValue(value.String())
+ } else {
+ data.SourcePortChannelSubinterface = types.StringNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-ntp:source.Vlan"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-ntp:source/Vlan"); value.Exists() && !data.SourceVlan.IsNull() {
data.SourceVlan = types.Int64Value(value.Int())
+ } else {
+ data.SourceVlan = types.Int64Null()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-ntp:server.server-list"); value.Exists() {
- data.Servers = make([]NTPServers, 0)
- value.ForEach(func(k, v gjson.Result) bool {
- item := NTPServers{}
- if cValue := v.Get("ip-address"); cValue.Exists() {
- item.IpAddress = types.StringValue(cValue.String())
- }
- if cValue := v.Get("source"); cValue.Exists() {
- item.Source = types.StringValue(cValue.String())
- }
- if cValue := v.Get("key"); cValue.Exists() {
- item.Key = types.Int64Value(cValue.Int())
- }
- if cValue := v.Get("prefer"); cValue.Exists() {
- item.Prefer = types.BoolValue(true)
+ for i := range data.Servers {
+ keys := [...]string{"ip-address"}
+ keyValues := [...]string{data.Servers[i].IpAddress.ValueString()}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-ntp:server/server-list").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, "ip-address"); value.Exists() && !data.Servers[i].IpAddress.IsNull() {
+ data.Servers[i].IpAddress = types.StringValue(value.String())
+ } else {
+ data.Servers[i].IpAddress = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "source"); value.Exists() && !data.Servers[i].Source.IsNull() {
+ data.Servers[i].Source = types.StringValue(value.String())
+ } else {
+ data.Servers[i].Source = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "key"); value.Exists() && !data.Servers[i].Key.IsNull() {
+ data.Servers[i].Key = types.Int64Value(value.Int())
+ } else {
+ data.Servers[i].Key = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(r, "prefer"); !data.Servers[i].Prefer.IsNull() {
+ if value.Exists() {
+ data.Servers[i].Prefer = types.BoolValue(true)
} else {
- item.Prefer = types.BoolValue(false)
- }
- if cValue := v.Get("version"); cValue.Exists() {
- item.Version = types.Int64Value(cValue.Int())
+ data.Servers[i].Prefer = types.BoolValue(false)
}
- if cValue := v.Get("burst-opt"); cValue.Exists() {
- item.Burst = types.BoolValue(true)
+ } else {
+ data.Servers[i].Prefer = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "version"); value.Exists() && !data.Servers[i].Version.IsNull() {
+ data.Servers[i].Version = types.Int64Value(value.Int())
+ } else {
+ data.Servers[i].Version = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(r, "burst-opt"); !data.Servers[i].Burst.IsNull() {
+ if value.Exists() {
+ data.Servers[i].Burst = types.BoolValue(true)
} else {
- item.Burst = types.BoolValue(false)
+ data.Servers[i].Burst = types.BoolValue(false)
}
- if cValue := v.Get("iburst-opt"); cValue.Exists() {
- item.Iburst = types.BoolValue(true)
+ } else {
+ data.Servers[i].Burst = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "iburst-opt"); !data.Servers[i].Iburst.IsNull() {
+ if value.Exists() {
+ data.Servers[i].Iburst = types.BoolValue(true)
} else {
- item.Iburst = types.BoolValue(false)
+ data.Servers[i].Iburst = types.BoolValue(false)
}
- if cValue := v.Get("periodic"); cValue.Exists() {
- item.Periodic = types.BoolValue(true)
+ } else {
+ data.Servers[i].Iburst = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "periodic"); !data.Servers[i].Periodic.IsNull() {
+ if value.Exists() {
+ data.Servers[i].Periodic = types.BoolValue(true)
} else {
- item.Periodic = types.BoolValue(false)
+ data.Servers[i].Periodic = types.BoolValue(false)
}
- data.Servers = append(data.Servers, item)
- return true
- })
+ } else {
+ data.Servers[i].Periodic = types.BoolNull()
+ }
}
- if value := res.Get(prefix + "Cisco-IOS-XE-ntp:server.vrf"); value.Exists() {
- data.ServerVrfs = make([]NTPServerVrfs, 0)
- value.ForEach(func(k, v gjson.Result) bool {
- item := NTPServerVrfs{}
- if cValue := v.Get("name"); cValue.Exists() {
- item.Name = types.StringValue(cValue.String())
- }
- if cValue := v.Get("server-list"); cValue.Exists() {
- item.Servers = make([]NTPServerVrfsServers, 0)
- cValue.ForEach(func(ck, cv gjson.Result) bool {
- cItem := NTPServerVrfsServers{}
- if ccValue := cv.Get("ip-address"); ccValue.Exists() {
- cItem.IpAddress = types.StringValue(ccValue.String())
- }
- if ccValue := cv.Get("key"); ccValue.Exists() {
- cItem.Key = types.Int64Value(ccValue.Int())
- }
- if ccValue := cv.Get("prefer"); ccValue.Exists() {
- cItem.Prefer = types.BoolValue(true)
- } else {
- cItem.Prefer = types.BoolValue(false)
- }
- if ccValue := cv.Get("version"); ccValue.Exists() {
- cItem.Version = types.Int64Value(ccValue.Int())
- }
- if ccValue := cv.Get("burst-opt"); ccValue.Exists() {
- cItem.Burst = types.BoolValue(true)
- } else {
- cItem.Burst = types.BoolValue(false)
+ for i := range data.ServerVrfs {
+ keys := [...]string{"name"}
+ keyValues := [...]string{data.ServerVrfs[i].Name.ValueString()}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-ntp:server/vrf").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
}
- if ccValue := cv.Get("iburst-opt"); ccValue.Exists() {
- cItem.Iburst = types.BoolValue(true)
- } else {
- cItem.Iburst = types.BoolValue(false)
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, "name"); value.Exists() && !data.ServerVrfs[i].Name.IsNull() {
+ data.ServerVrfs[i].Name = types.StringValue(value.String())
+ } else {
+ data.ServerVrfs[i].Name = types.StringNull()
+ }
+ for ci := range data.ServerVrfs[i].Servers {
+ keys := [...]string{"ip-address"}
+ keyValues := [...]string{data.ServerVrfs[i].Servers[ci].IpAddress.ValueString()}
+
+ var cr xmldot.Result
+ helpers.GetFromXPath(r, "server-list").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
}
- if ccValue := cv.Get("periodic"); ccValue.Exists() {
- cItem.Periodic = types.BoolValue(true)
- } else {
- cItem.Periodic = types.BoolValue(false)
+ if found {
+ cr = v
+ return false
}
- item.Servers = append(item.Servers, cItem)
return true
- })
+ },
+ )
+ if value := helpers.GetFromXPath(cr, "ip-address"); value.Exists() && !data.ServerVrfs[i].Servers[ci].IpAddress.IsNull() {
+ data.ServerVrfs[i].Servers[ci].IpAddress = types.StringValue(value.String())
+ } else {
+ data.ServerVrfs[i].Servers[ci].IpAddress = types.StringNull()
}
- data.ServerVrfs = append(data.ServerVrfs, item)
- return true
- })
- }
- if value := res.Get(prefix + "Cisco-IOS-XE-ntp:peer.server-list"); value.Exists() {
- data.Peers = make([]NTPPeers, 0)
- value.ForEach(func(k, v gjson.Result) bool {
- item := NTPPeers{}
- if cValue := v.Get("ip-address"); cValue.Exists() {
- item.IpAddress = types.StringValue(cValue.String())
+ if value := helpers.GetFromXPath(cr, "key"); value.Exists() && !data.ServerVrfs[i].Servers[ci].Key.IsNull() {
+ data.ServerVrfs[i].Servers[ci].Key = types.Int64Value(value.Int())
+ } else {
+ data.ServerVrfs[i].Servers[ci].Key = types.Int64Null()
}
- if cValue := v.Get("source"); cValue.Exists() {
- item.Source = types.StringValue(cValue.String())
+ if value := helpers.GetFromXPath(cr, "prefer"); !data.ServerVrfs[i].Servers[ci].Prefer.IsNull() {
+ if value.Exists() {
+ data.ServerVrfs[i].Servers[ci].Prefer = types.BoolValue(true)
+ } else {
+ data.ServerVrfs[i].Servers[ci].Prefer = types.BoolValue(false)
+ }
+ } else {
+ data.ServerVrfs[i].Servers[ci].Prefer = types.BoolNull()
}
- if cValue := v.Get("key"); cValue.Exists() {
- item.Key = types.Int64Value(cValue.Int())
+ if value := helpers.GetFromXPath(cr, "version"); value.Exists() && !data.ServerVrfs[i].Servers[ci].Version.IsNull() {
+ data.ServerVrfs[i].Servers[ci].Version = types.Int64Value(value.Int())
+ } else {
+ data.ServerVrfs[i].Servers[ci].Version = types.Int64Null()
}
- if cValue := v.Get("prefer"); cValue.Exists() {
- item.Prefer = types.BoolValue(true)
+ if value := helpers.GetFromXPath(cr, "burst-opt"); !data.ServerVrfs[i].Servers[ci].Burst.IsNull() {
+ if value.Exists() {
+ data.ServerVrfs[i].Servers[ci].Burst = types.BoolValue(true)
+ } else {
+ data.ServerVrfs[i].Servers[ci].Burst = types.BoolValue(false)
+ }
} else {
- item.Prefer = types.BoolValue(false)
+ data.ServerVrfs[i].Servers[ci].Burst = types.BoolNull()
}
- if cValue := v.Get("version"); cValue.Exists() {
- item.Version = types.Int64Value(cValue.Int())
+ if value := helpers.GetFromXPath(cr, "iburst-opt"); !data.ServerVrfs[i].Servers[ci].Iburst.IsNull() {
+ if value.Exists() {
+ data.ServerVrfs[i].Servers[ci].Iburst = types.BoolValue(true)
+ } else {
+ data.ServerVrfs[i].Servers[ci].Iburst = types.BoolValue(false)
+ }
+ } else {
+ data.ServerVrfs[i].Servers[ci].Iburst = types.BoolNull()
}
- data.Peers = append(data.Peers, item)
- return true
- })
- }
- if value := res.Get(prefix + "Cisco-IOS-XE-ntp:peer.vrf"); value.Exists() {
- data.PeerVrfs = make([]NTPPeerVrfs, 0)
- value.ForEach(func(k, v gjson.Result) bool {
- item := NTPPeerVrfs{}
- if cValue := v.Get("name"); cValue.Exists() {
- item.Name = types.StringValue(cValue.String())
+ if value := helpers.GetFromXPath(cr, "periodic"); !data.ServerVrfs[i].Servers[ci].Periodic.IsNull() {
+ if value.Exists() {
+ data.ServerVrfs[i].Servers[ci].Periodic = types.BoolValue(true)
+ } else {
+ data.ServerVrfs[i].Servers[ci].Periodic = types.BoolValue(false)
+ }
+ } else {
+ data.ServerVrfs[i].Servers[ci].Periodic = types.BoolNull()
}
- if cValue := v.Get("server-list"); cValue.Exists() {
- item.Peers = make([]NTPPeerVrfsPeers, 0)
- cValue.ForEach(func(ck, cv gjson.Result) bool {
- cItem := NTPPeerVrfsPeers{}
- if ccValue := cv.Get("ip-address"); ccValue.Exists() {
- cItem.IpAddress = types.StringValue(ccValue.String())
+ }
+ }
+ for i := range data.Peers {
+ keys := [...]string{"ip-address"}
+ keyValues := [...]string{data.Peers[i].IpAddress.ValueString()}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-ntp:peer/server-list").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
}
- if ccValue := cv.Get("key"); ccValue.Exists() {
- cItem.Key = types.Int64Value(ccValue.Int())
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, "ip-address"); value.Exists() && !data.Peers[i].IpAddress.IsNull() {
+ data.Peers[i].IpAddress = types.StringValue(value.String())
+ } else {
+ data.Peers[i].IpAddress = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "source"); value.Exists() && !data.Peers[i].Source.IsNull() {
+ data.Peers[i].Source = types.StringValue(value.String())
+ } else {
+ data.Peers[i].Source = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "key"); value.Exists() && !data.Peers[i].Key.IsNull() {
+ data.Peers[i].Key = types.Int64Value(value.Int())
+ } else {
+ data.Peers[i].Key = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(r, "prefer"); !data.Peers[i].Prefer.IsNull() {
+ if value.Exists() {
+ data.Peers[i].Prefer = types.BoolValue(true)
+ } else {
+ data.Peers[i].Prefer = types.BoolValue(false)
+ }
+ } else {
+ data.Peers[i].Prefer = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "version"); value.Exists() && !data.Peers[i].Version.IsNull() {
+ data.Peers[i].Version = types.Int64Value(value.Int())
+ } else {
+ data.Peers[i].Version = types.Int64Null()
+ }
+ }
+ for i := range data.PeerVrfs {
+ keys := [...]string{"name"}
+ keyValues := [...]string{data.PeerVrfs[i].Name.ValueString()}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-ntp:peer/vrf").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
}
- if ccValue := cv.Get("prefer"); ccValue.Exists() {
- cItem.Prefer = types.BoolValue(true)
- } else {
- cItem.Prefer = types.BoolValue(false)
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, "name"); value.Exists() && !data.PeerVrfs[i].Name.IsNull() {
+ data.PeerVrfs[i].Name = types.StringValue(value.String())
+ } else {
+ data.PeerVrfs[i].Name = types.StringNull()
+ }
+ for ci := range data.PeerVrfs[i].Peers {
+ keys := [...]string{"ip-address"}
+ keyValues := [...]string{data.PeerVrfs[i].Peers[ci].IpAddress.ValueString()}
+
+ var cr xmldot.Result
+ helpers.GetFromXPath(r, "server-list").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
}
- if ccValue := cv.Get("version"); ccValue.Exists() {
- cItem.Version = types.Int64Value(ccValue.Int())
+ if found {
+ cr = v
+ return false
}
- item.Peers = append(item.Peers, cItem)
return true
- })
+ },
+ )
+ if value := helpers.GetFromXPath(cr, "ip-address"); value.Exists() && !data.PeerVrfs[i].Peers[ci].IpAddress.IsNull() {
+ data.PeerVrfs[i].Peers[ci].IpAddress = types.StringValue(value.String())
+ } else {
+ data.PeerVrfs[i].Peers[ci].IpAddress = types.StringNull()
}
- data.PeerVrfs = append(data.PeerVrfs, item)
- return true
- })
- }
- if value := res.Get(prefix + "Cisco-IOS-XE-ntp:trusted-key"); value.Exists() {
- data.TrustedKeys = make([]NTPTrustedKeys, 0)
- value.ForEach(func(k, v gjson.Result) bool {
- item := NTPTrustedKeys{}
- if cValue := v.Get("number"); cValue.Exists() {
- item.Number = types.Int64Value(cValue.Int())
+ if value := helpers.GetFromXPath(cr, "key"); value.Exists() && !data.PeerVrfs[i].Peers[ci].Key.IsNull() {
+ data.PeerVrfs[i].Peers[ci].Key = types.Int64Value(value.Int())
+ } else {
+ data.PeerVrfs[i].Peers[ci].Key = types.Int64Null()
}
- data.TrustedKeys = append(data.TrustedKeys, item)
- return true
- })
+ if value := helpers.GetFromXPath(cr, "prefer"); !data.PeerVrfs[i].Peers[ci].Prefer.IsNull() {
+ if value.Exists() {
+ data.PeerVrfs[i].Peers[ci].Prefer = types.BoolValue(true)
+ } else {
+ data.PeerVrfs[i].Peers[ci].Prefer = types.BoolValue(false)
+ }
+ } else {
+ data.PeerVrfs[i].Peers[ci].Prefer = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(cr, "version"); value.Exists() && !data.PeerVrfs[i].Peers[ci].Version.IsNull() {
+ data.PeerVrfs[i].Peers[ci].Version = types.Int64Value(value.Int())
+ } else {
+ data.PeerVrfs[i].Peers[ci].Version = types.Int64Null()
+ }
+ }
+ }
+ for i := range data.TrustedKeys {
+ keys := [...]string{"number"}
+ keyValues := [...]string{strconv.FormatInt(data.TrustedKeys[i].Number.ValueInt64(), 10)}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-ntp:trusted-key").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, "number"); value.Exists() && !data.TrustedKeys[i].Number.IsNull() {
+ data.TrustedKeys[i].Number = types.Int64Value(value.Int())
+ } else {
+ data.TrustedKeys[i].Number = types.Int64Null()
+ }
}
}
-// End of section. //template:end fromBody
+// End of section. //template:end updateFromBodyXML
-// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyData
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBody
-func (data *NTPData) fromBody(ctx context.Context, res gjson.Result) {
+func (data *NTP) fromBody(ctx context.Context, res gjson.Result) {
prefix := helpers.LastElement(data.getPath()) + "."
if res.Get(helpers.LastElement(data.getPath())).IsArray() {
prefix += "0."
@@ -1394,70 +1918,1234 @@ func (data *NTPData) fromBody(ctx context.Context, res gjson.Result) {
} else {
item.Prefer = types.BoolValue(false)
}
- if cValue := v.Get("version"); cValue.Exists() {
- item.Version = types.Int64Value(cValue.Int())
+ if cValue := v.Get("version"); cValue.Exists() {
+ item.Version = types.Int64Value(cValue.Int())
+ }
+ data.Peers = append(data.Peers, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-ntp:peer.vrf"); value.Exists() {
+ data.PeerVrfs = make([]NTPPeerVrfs, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := NTPPeerVrfs{}
+ if cValue := v.Get("name"); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("server-list"); cValue.Exists() {
+ item.Peers = make([]NTPPeerVrfsPeers, 0)
+ cValue.ForEach(func(ck, cv gjson.Result) bool {
+ cItem := NTPPeerVrfsPeers{}
+ if ccValue := cv.Get("ip-address"); ccValue.Exists() {
+ cItem.IpAddress = types.StringValue(ccValue.String())
+ }
+ if ccValue := cv.Get("key"); ccValue.Exists() {
+ cItem.Key = types.Int64Value(ccValue.Int())
+ }
+ if ccValue := cv.Get("prefer"); ccValue.Exists() {
+ cItem.Prefer = types.BoolValue(true)
+ } else {
+ cItem.Prefer = types.BoolValue(false)
+ }
+ if ccValue := cv.Get("version"); ccValue.Exists() {
+ cItem.Version = types.Int64Value(ccValue.Int())
+ }
+ item.Peers = append(item.Peers, cItem)
+ return true
+ })
+ }
+ data.PeerVrfs = append(data.PeerVrfs, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-ntp:trusted-key"); value.Exists() {
+ data.TrustedKeys = make([]NTPTrustedKeys, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := NTPTrustedKeys{}
+ if cValue := v.Get("number"); cValue.Exists() {
+ item.Number = types.Int64Value(cValue.Int())
+ }
+ data.TrustedKeys = append(data.TrustedKeys, item)
+ return true
+ })
+ }
+}
+
+// End of section. //template:end fromBody
+
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyData
+
+func (data *NTPData) fromBody(ctx context.Context, res gjson.Result) {
+ prefix := helpers.LastElement(data.getPath()) + "."
+ if res.Get(helpers.LastElement(data.getPath())).IsArray() {
+ prefix += "0."
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-ntp:authenticate"); value.Exists() {
+ data.Authenticate = types.BoolValue(true)
+ } else {
+ data.Authenticate = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-ntp:logging"); value.Exists() {
+ data.Logging = types.BoolValue(true)
+ } else {
+ data.Logging = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-ntp:access-group.peer.acl"); value.Exists() {
+ data.AccessGroupPeerAcl = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-ntp:access-group.query-only.acl"); value.Exists() {
+ data.AccessGroupQueryOnlyAcl = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-ntp:access-group.serve.acl"); value.Exists() {
+ data.AccessGroupServeAcl = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-ntp:access-group.serve-only.acl"); value.Exists() {
+ data.AccessGroupServeOnlyAcl = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-ntp:authentication-key"); value.Exists() {
+ data.AuthenticationKeys = make([]NTPAuthenticationKeys, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := NTPAuthenticationKeys{}
+ if cValue := v.Get("number"); cValue.Exists() {
+ item.Number = types.Int64Value(cValue.Int())
+ }
+ if cValue := v.Get("md5-cfg"); cValue.Exists() {
+ item.Md5 = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("cmac-aes-128"); cValue.Exists() {
+ item.CmacAes128 = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("hmac-sha1"); cValue.Exists() {
+ item.HmacSha1 = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("hmac-sha2-256"); cValue.Exists() {
+ item.HmacSha2256 = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("sha1"); cValue.Exists() {
+ item.Sha1 = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("sha2"); cValue.Exists() {
+ item.Sha2 = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("encryption-type"); cValue.Exists() {
+ item.EncryptionType = types.Int64Value(cValue.Int())
+ }
+ data.AuthenticationKeys = append(data.AuthenticationKeys, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-ntp:clock-period"); value.Exists() {
+ data.ClockPeriod = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-ntp:master"); value.Exists() {
+ data.Master = types.BoolValue(true)
+ } else {
+ data.Master = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-ntp:master.stratum-number"); value.Exists() {
+ data.MasterStratum = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-ntp:passive"); value.Exists() {
+ data.Passive = types.BoolValue(true)
+ } else {
+ data.Passive = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-ntp:update-calendar"); value.Exists() {
+ data.UpdateCalendar = types.BoolValue(true)
+ } else {
+ data.UpdateCalendar = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-ntp:source.GigabitEthernet"); value.Exists() {
+ data.SourceGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-ntp:source.TenGigabitEthernet"); value.Exists() {
+ data.SourceTenGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-ntp:source.FortyGigabitEthernet"); value.Exists() {
+ data.SourceFortyGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-ntp:source.HundredGigE"); value.Exists() {
+ data.SourceHundredGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-ntp:source.Loopback"); value.Exists() {
+ data.SourceLoopback = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-ntp:source.Port-channel"); value.Exists() {
+ data.SourcePortChannel = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-ntp:source.Port-channel-subinterface.Port-channel"); value.Exists() {
+ data.SourcePortChannelSubinterface = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-ntp:source.Vlan"); value.Exists() {
+ data.SourceVlan = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-ntp:server.server-list"); value.Exists() {
+ data.Servers = make([]NTPServers, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := NTPServers{}
+ if cValue := v.Get("ip-address"); cValue.Exists() {
+ item.IpAddress = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("source"); cValue.Exists() {
+ item.Source = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("key"); cValue.Exists() {
+ item.Key = types.Int64Value(cValue.Int())
+ }
+ if cValue := v.Get("prefer"); cValue.Exists() {
+ item.Prefer = types.BoolValue(true)
+ } else {
+ item.Prefer = types.BoolValue(false)
+ }
+ if cValue := v.Get("version"); cValue.Exists() {
+ item.Version = types.Int64Value(cValue.Int())
+ }
+ if cValue := v.Get("burst-opt"); cValue.Exists() {
+ item.Burst = types.BoolValue(true)
+ } else {
+ item.Burst = types.BoolValue(false)
+ }
+ if cValue := v.Get("iburst-opt"); cValue.Exists() {
+ item.Iburst = types.BoolValue(true)
+ } else {
+ item.Iburst = types.BoolValue(false)
+ }
+ if cValue := v.Get("periodic"); cValue.Exists() {
+ item.Periodic = types.BoolValue(true)
+ } else {
+ item.Periodic = types.BoolValue(false)
+ }
+ data.Servers = append(data.Servers, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-ntp:server.vrf"); value.Exists() {
+ data.ServerVrfs = make([]NTPServerVrfs, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := NTPServerVrfs{}
+ if cValue := v.Get("name"); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("server-list"); cValue.Exists() {
+ item.Servers = make([]NTPServerVrfsServers, 0)
+ cValue.ForEach(func(ck, cv gjson.Result) bool {
+ cItem := NTPServerVrfsServers{}
+ if ccValue := cv.Get("ip-address"); ccValue.Exists() {
+ cItem.IpAddress = types.StringValue(ccValue.String())
+ }
+ if ccValue := cv.Get("key"); ccValue.Exists() {
+ cItem.Key = types.Int64Value(ccValue.Int())
+ }
+ if ccValue := cv.Get("prefer"); ccValue.Exists() {
+ cItem.Prefer = types.BoolValue(true)
+ } else {
+ cItem.Prefer = types.BoolValue(false)
+ }
+ if ccValue := cv.Get("version"); ccValue.Exists() {
+ cItem.Version = types.Int64Value(ccValue.Int())
+ }
+ if ccValue := cv.Get("burst-opt"); ccValue.Exists() {
+ cItem.Burst = types.BoolValue(true)
+ } else {
+ cItem.Burst = types.BoolValue(false)
+ }
+ if ccValue := cv.Get("iburst-opt"); ccValue.Exists() {
+ cItem.Iburst = types.BoolValue(true)
+ } else {
+ cItem.Iburst = types.BoolValue(false)
+ }
+ if ccValue := cv.Get("periodic"); ccValue.Exists() {
+ cItem.Periodic = types.BoolValue(true)
+ } else {
+ cItem.Periodic = types.BoolValue(false)
+ }
+ item.Servers = append(item.Servers, cItem)
+ return true
+ })
+ }
+ data.ServerVrfs = append(data.ServerVrfs, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-ntp:peer.server-list"); value.Exists() {
+ data.Peers = make([]NTPPeers, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := NTPPeers{}
+ if cValue := v.Get("ip-address"); cValue.Exists() {
+ item.IpAddress = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("source"); cValue.Exists() {
+ item.Source = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("key"); cValue.Exists() {
+ item.Key = types.Int64Value(cValue.Int())
+ }
+ if cValue := v.Get("prefer"); cValue.Exists() {
+ item.Prefer = types.BoolValue(true)
+ } else {
+ item.Prefer = types.BoolValue(false)
+ }
+ if cValue := v.Get("version"); cValue.Exists() {
+ item.Version = types.Int64Value(cValue.Int())
+ }
+ data.Peers = append(data.Peers, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-ntp:peer.vrf"); value.Exists() {
+ data.PeerVrfs = make([]NTPPeerVrfs, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := NTPPeerVrfs{}
+ if cValue := v.Get("name"); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("server-list"); cValue.Exists() {
+ item.Peers = make([]NTPPeerVrfsPeers, 0)
+ cValue.ForEach(func(ck, cv gjson.Result) bool {
+ cItem := NTPPeerVrfsPeers{}
+ if ccValue := cv.Get("ip-address"); ccValue.Exists() {
+ cItem.IpAddress = types.StringValue(ccValue.String())
+ }
+ if ccValue := cv.Get("key"); ccValue.Exists() {
+ cItem.Key = types.Int64Value(ccValue.Int())
+ }
+ if ccValue := cv.Get("prefer"); ccValue.Exists() {
+ cItem.Prefer = types.BoolValue(true)
+ } else {
+ cItem.Prefer = types.BoolValue(false)
+ }
+ if ccValue := cv.Get("version"); ccValue.Exists() {
+ cItem.Version = types.Int64Value(ccValue.Int())
+ }
+ item.Peers = append(item.Peers, cItem)
+ return true
+ })
+ }
+ data.PeerVrfs = append(data.PeerVrfs, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-ntp:trusted-key"); value.Exists() {
+ data.TrustedKeys = make([]NTPTrustedKeys, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := NTPTrustedKeys{}
+ if cValue := v.Get("number"); cValue.Exists() {
+ item.Number = types.Int64Value(cValue.Int())
+ }
+ data.TrustedKeys = append(data.TrustedKeys, item)
+ return true
+ })
+ }
+}
+
+// End of section. //template:end fromBodyData
+
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyXML
+
+func (data *NTP) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-ntp:authenticate"); value.Exists() {
+ data.Authenticate = types.BoolValue(true)
+ } else {
+ data.Authenticate = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-ntp:logging"); value.Exists() {
+ data.Logging = types.BoolValue(true)
+ } else {
+ data.Logging = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-ntp:access-group/peer/acl"); value.Exists() {
+ data.AccessGroupPeerAcl = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-ntp:access-group/query-only/acl"); value.Exists() {
+ data.AccessGroupQueryOnlyAcl = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-ntp:access-group/serve/acl"); value.Exists() {
+ data.AccessGroupServeAcl = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-ntp:access-group/serve-only/acl"); value.Exists() {
+ data.AccessGroupServeOnlyAcl = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-ntp:authentication-key"); value.Exists() {
+ data.AuthenticationKeys = make([]NTPAuthenticationKeys, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := NTPAuthenticationKeys{}
+ if cValue := helpers.GetFromXPath(v, "number"); cValue.Exists() {
+ item.Number = types.Int64Value(cValue.Int())
+ }
+ if cValue := helpers.GetFromXPath(v, "md5-cfg"); cValue.Exists() {
+ item.Md5 = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "cmac-aes-128"); cValue.Exists() {
+ item.CmacAes128 = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "hmac-sha1"); cValue.Exists() {
+ item.HmacSha1 = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "hmac-sha2-256"); cValue.Exists() {
+ item.HmacSha2256 = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "sha1"); cValue.Exists() {
+ item.Sha1 = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "sha2"); cValue.Exists() {
+ item.Sha2 = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "encryption-type"); cValue.Exists() {
+ item.EncryptionType = types.Int64Value(cValue.Int())
+ }
+ data.AuthenticationKeys = append(data.AuthenticationKeys, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-ntp:clock-period"); value.Exists() {
+ data.ClockPeriod = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-ntp:master"); value.Exists() {
+ data.Master = types.BoolValue(true)
+ } else {
+ data.Master = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-ntp:master/stratum-number"); value.Exists() {
+ data.MasterStratum = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-ntp:passive"); value.Exists() {
+ data.Passive = types.BoolValue(true)
+ } else {
+ data.Passive = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-ntp:update-calendar"); value.Exists() {
+ data.UpdateCalendar = types.BoolValue(true)
+ } else {
+ data.UpdateCalendar = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-ntp:source/GigabitEthernet"); value.Exists() {
+ data.SourceGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-ntp:source/TenGigabitEthernet"); value.Exists() {
+ data.SourceTenGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-ntp:source/FortyGigabitEthernet"); value.Exists() {
+ data.SourceFortyGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-ntp:source/HundredGigE"); value.Exists() {
+ data.SourceHundredGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-ntp:source/Loopback"); value.Exists() {
+ data.SourceLoopback = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-ntp:source/Port-channel"); value.Exists() {
+ data.SourcePortChannel = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-ntp:source/Port-channel-subinterface/Port-channel"); value.Exists() {
+ data.SourcePortChannelSubinterface = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-ntp:source/Vlan"); value.Exists() {
+ data.SourceVlan = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-ntp:server/server-list"); value.Exists() {
+ data.Servers = make([]NTPServers, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := NTPServers{}
+ if cValue := helpers.GetFromXPath(v, "ip-address"); cValue.Exists() {
+ item.IpAddress = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "source"); cValue.Exists() {
+ item.Source = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "key"); cValue.Exists() {
+ item.Key = types.Int64Value(cValue.Int())
+ }
+ if cValue := helpers.GetFromXPath(v, "prefer"); cValue.Exists() {
+ item.Prefer = types.BoolValue(true)
+ } else {
+ item.Prefer = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "version"); cValue.Exists() {
+ item.Version = types.Int64Value(cValue.Int())
+ }
+ if cValue := helpers.GetFromXPath(v, "burst-opt"); cValue.Exists() {
+ item.Burst = types.BoolValue(true)
+ } else {
+ item.Burst = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "iburst-opt"); cValue.Exists() {
+ item.Iburst = types.BoolValue(true)
+ } else {
+ item.Iburst = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "periodic"); cValue.Exists() {
+ item.Periodic = types.BoolValue(true)
+ } else {
+ item.Periodic = types.BoolValue(false)
+ }
+ data.Servers = append(data.Servers, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-ntp:server/vrf"); value.Exists() {
+ data.ServerVrfs = make([]NTPServerVrfs, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := NTPServerVrfs{}
+ if cValue := helpers.GetFromXPath(v, "name"); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "server-list"); cValue.Exists() {
+ item.Servers = make([]NTPServerVrfsServers, 0)
+ cValue.ForEach(func(_ int, cv xmldot.Result) bool {
+ cItem := NTPServerVrfsServers{}
+ if ccValue := helpers.GetFromXPath(cv, "ip-address"); ccValue.Exists() {
+ cItem.IpAddress = types.StringValue(ccValue.String())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "key"); ccValue.Exists() {
+ cItem.Key = types.Int64Value(ccValue.Int())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "prefer"); ccValue.Exists() {
+ cItem.Prefer = types.BoolValue(true)
+ } else {
+ cItem.Prefer = types.BoolValue(false)
+ }
+ if ccValue := helpers.GetFromXPath(cv, "version"); ccValue.Exists() {
+ cItem.Version = types.Int64Value(ccValue.Int())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "burst-opt"); ccValue.Exists() {
+ cItem.Burst = types.BoolValue(true)
+ } else {
+ cItem.Burst = types.BoolValue(false)
+ }
+ if ccValue := helpers.GetFromXPath(cv, "iburst-opt"); ccValue.Exists() {
+ cItem.Iburst = types.BoolValue(true)
+ } else {
+ cItem.Iburst = types.BoolValue(false)
+ }
+ if ccValue := helpers.GetFromXPath(cv, "periodic"); ccValue.Exists() {
+ cItem.Periodic = types.BoolValue(true)
+ } else {
+ cItem.Periodic = types.BoolValue(false)
+ }
+ item.Servers = append(item.Servers, cItem)
+ return true
+ })
+ }
+ data.ServerVrfs = append(data.ServerVrfs, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-ntp:peer/server-list"); value.Exists() {
+ data.Peers = make([]NTPPeers, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := NTPPeers{}
+ if cValue := helpers.GetFromXPath(v, "ip-address"); cValue.Exists() {
+ item.IpAddress = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "source"); cValue.Exists() {
+ item.Source = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "key"); cValue.Exists() {
+ item.Key = types.Int64Value(cValue.Int())
+ }
+ if cValue := helpers.GetFromXPath(v, "prefer"); cValue.Exists() {
+ item.Prefer = types.BoolValue(true)
+ } else {
+ item.Prefer = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "version"); cValue.Exists() {
+ item.Version = types.Int64Value(cValue.Int())
+ }
+ data.Peers = append(data.Peers, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-ntp:peer/vrf"); value.Exists() {
+ data.PeerVrfs = make([]NTPPeerVrfs, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := NTPPeerVrfs{}
+ if cValue := helpers.GetFromXPath(v, "name"); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "server-list"); cValue.Exists() {
+ item.Peers = make([]NTPPeerVrfsPeers, 0)
+ cValue.ForEach(func(_ int, cv xmldot.Result) bool {
+ cItem := NTPPeerVrfsPeers{}
+ if ccValue := helpers.GetFromXPath(cv, "ip-address"); ccValue.Exists() {
+ cItem.IpAddress = types.StringValue(ccValue.String())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "key"); ccValue.Exists() {
+ cItem.Key = types.Int64Value(ccValue.Int())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "prefer"); ccValue.Exists() {
+ cItem.Prefer = types.BoolValue(true)
+ } else {
+ cItem.Prefer = types.BoolValue(false)
+ }
+ if ccValue := helpers.GetFromXPath(cv, "version"); ccValue.Exists() {
+ cItem.Version = types.Int64Value(ccValue.Int())
+ }
+ item.Peers = append(item.Peers, cItem)
+ return true
+ })
+ }
+ data.PeerVrfs = append(data.PeerVrfs, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-ntp:trusted-key"); value.Exists() {
+ data.TrustedKeys = make([]NTPTrustedKeys, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := NTPTrustedKeys{}
+ if cValue := helpers.GetFromXPath(v, "number"); cValue.Exists() {
+ item.Number = types.Int64Value(cValue.Int())
+ }
+ data.TrustedKeys = append(data.TrustedKeys, item)
+ return true
+ })
+ }
+}
+
+// End of section. //template:end fromBodyXML
+
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyDataXML
+
+func (data *NTPData) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-ntp:authenticate"); value.Exists() {
+ data.Authenticate = types.BoolValue(true)
+ } else {
+ data.Authenticate = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-ntp:logging"); value.Exists() {
+ data.Logging = types.BoolValue(true)
+ } else {
+ data.Logging = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-ntp:access-group/peer/acl"); value.Exists() {
+ data.AccessGroupPeerAcl = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-ntp:access-group/query-only/acl"); value.Exists() {
+ data.AccessGroupQueryOnlyAcl = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-ntp:access-group/serve/acl"); value.Exists() {
+ data.AccessGroupServeAcl = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-ntp:access-group/serve-only/acl"); value.Exists() {
+ data.AccessGroupServeOnlyAcl = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-ntp:authentication-key"); value.Exists() {
+ data.AuthenticationKeys = make([]NTPAuthenticationKeys, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := NTPAuthenticationKeys{}
+ if cValue := helpers.GetFromXPath(v, "number"); cValue.Exists() {
+ item.Number = types.Int64Value(cValue.Int())
+ }
+ if cValue := helpers.GetFromXPath(v, "md5-cfg"); cValue.Exists() {
+ item.Md5 = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "cmac-aes-128"); cValue.Exists() {
+ item.CmacAes128 = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "hmac-sha1"); cValue.Exists() {
+ item.HmacSha1 = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "hmac-sha2-256"); cValue.Exists() {
+ item.HmacSha2256 = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "sha1"); cValue.Exists() {
+ item.Sha1 = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "sha2"); cValue.Exists() {
+ item.Sha2 = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "encryption-type"); cValue.Exists() {
+ item.EncryptionType = types.Int64Value(cValue.Int())
+ }
+ data.AuthenticationKeys = append(data.AuthenticationKeys, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-ntp:clock-period"); value.Exists() {
+ data.ClockPeriod = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-ntp:master"); value.Exists() {
+ data.Master = types.BoolValue(true)
+ } else {
+ data.Master = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-ntp:master/stratum-number"); value.Exists() {
+ data.MasterStratum = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-ntp:passive"); value.Exists() {
+ data.Passive = types.BoolValue(true)
+ } else {
+ data.Passive = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-ntp:update-calendar"); value.Exists() {
+ data.UpdateCalendar = types.BoolValue(true)
+ } else {
+ data.UpdateCalendar = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-ntp:source/GigabitEthernet"); value.Exists() {
+ data.SourceGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-ntp:source/TenGigabitEthernet"); value.Exists() {
+ data.SourceTenGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-ntp:source/FortyGigabitEthernet"); value.Exists() {
+ data.SourceFortyGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-ntp:source/HundredGigE"); value.Exists() {
+ data.SourceHundredGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-ntp:source/Loopback"); value.Exists() {
+ data.SourceLoopback = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-ntp:source/Port-channel"); value.Exists() {
+ data.SourcePortChannel = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-ntp:source/Port-channel-subinterface/Port-channel"); value.Exists() {
+ data.SourcePortChannelSubinterface = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-ntp:source/Vlan"); value.Exists() {
+ data.SourceVlan = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-ntp:server/server-list"); value.Exists() {
+ data.Servers = make([]NTPServers, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := NTPServers{}
+ if cValue := helpers.GetFromXPath(v, "ip-address"); cValue.Exists() {
+ item.IpAddress = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "source"); cValue.Exists() {
+ item.Source = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "key"); cValue.Exists() {
+ item.Key = types.Int64Value(cValue.Int())
+ }
+ if cValue := helpers.GetFromXPath(v, "prefer"); cValue.Exists() {
+ item.Prefer = types.BoolValue(true)
+ } else {
+ item.Prefer = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "version"); cValue.Exists() {
+ item.Version = types.Int64Value(cValue.Int())
+ }
+ if cValue := helpers.GetFromXPath(v, "burst-opt"); cValue.Exists() {
+ item.Burst = types.BoolValue(true)
+ } else {
+ item.Burst = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "iburst-opt"); cValue.Exists() {
+ item.Iburst = types.BoolValue(true)
+ } else {
+ item.Iburst = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "periodic"); cValue.Exists() {
+ item.Periodic = types.BoolValue(true)
+ } else {
+ item.Periodic = types.BoolValue(false)
+ }
+ data.Servers = append(data.Servers, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-ntp:server/vrf"); value.Exists() {
+ data.ServerVrfs = make([]NTPServerVrfs, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := NTPServerVrfs{}
+ if cValue := helpers.GetFromXPath(v, "name"); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "server-list"); cValue.Exists() {
+ item.Servers = make([]NTPServerVrfsServers, 0)
+ cValue.ForEach(func(_ int, cv xmldot.Result) bool {
+ cItem := NTPServerVrfsServers{}
+ if ccValue := helpers.GetFromXPath(cv, "ip-address"); ccValue.Exists() {
+ cItem.IpAddress = types.StringValue(ccValue.String())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "key"); ccValue.Exists() {
+ cItem.Key = types.Int64Value(ccValue.Int())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "prefer"); ccValue.Exists() {
+ cItem.Prefer = types.BoolValue(true)
+ } else {
+ cItem.Prefer = types.BoolValue(false)
+ }
+ if ccValue := helpers.GetFromXPath(cv, "version"); ccValue.Exists() {
+ cItem.Version = types.Int64Value(ccValue.Int())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "burst-opt"); ccValue.Exists() {
+ cItem.Burst = types.BoolValue(true)
+ } else {
+ cItem.Burst = types.BoolValue(false)
+ }
+ if ccValue := helpers.GetFromXPath(cv, "iburst-opt"); ccValue.Exists() {
+ cItem.Iburst = types.BoolValue(true)
+ } else {
+ cItem.Iburst = types.BoolValue(false)
+ }
+ if ccValue := helpers.GetFromXPath(cv, "periodic"); ccValue.Exists() {
+ cItem.Periodic = types.BoolValue(true)
+ } else {
+ cItem.Periodic = types.BoolValue(false)
+ }
+ item.Servers = append(item.Servers, cItem)
+ return true
+ })
+ }
+ data.ServerVrfs = append(data.ServerVrfs, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-ntp:peer/server-list"); value.Exists() {
+ data.Peers = make([]NTPPeers, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := NTPPeers{}
+ if cValue := helpers.GetFromXPath(v, "ip-address"); cValue.Exists() {
+ item.IpAddress = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "source"); cValue.Exists() {
+ item.Source = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "key"); cValue.Exists() {
+ item.Key = types.Int64Value(cValue.Int())
+ }
+ if cValue := helpers.GetFromXPath(v, "prefer"); cValue.Exists() {
+ item.Prefer = types.BoolValue(true)
+ } else {
+ item.Prefer = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "version"); cValue.Exists() {
+ item.Version = types.Int64Value(cValue.Int())
+ }
+ data.Peers = append(data.Peers, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-ntp:peer/vrf"); value.Exists() {
+ data.PeerVrfs = make([]NTPPeerVrfs, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := NTPPeerVrfs{}
+ if cValue := helpers.GetFromXPath(v, "name"); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "server-list"); cValue.Exists() {
+ item.Peers = make([]NTPPeerVrfsPeers, 0)
+ cValue.ForEach(func(_ int, cv xmldot.Result) bool {
+ cItem := NTPPeerVrfsPeers{}
+ if ccValue := helpers.GetFromXPath(cv, "ip-address"); ccValue.Exists() {
+ cItem.IpAddress = types.StringValue(ccValue.String())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "key"); ccValue.Exists() {
+ cItem.Key = types.Int64Value(ccValue.Int())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "prefer"); ccValue.Exists() {
+ cItem.Prefer = types.BoolValue(true)
+ } else {
+ cItem.Prefer = types.BoolValue(false)
+ }
+ if ccValue := helpers.GetFromXPath(cv, "version"); ccValue.Exists() {
+ cItem.Version = types.Int64Value(ccValue.Int())
+ }
+ item.Peers = append(item.Peers, cItem)
+ return true
+ })
+ }
+ data.PeerVrfs = append(data.PeerVrfs, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-ntp:trusted-key"); value.Exists() {
+ data.TrustedKeys = make([]NTPTrustedKeys, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := NTPTrustedKeys{}
+ if cValue := helpers.GetFromXPath(v, "number"); cValue.Exists() {
+ item.Number = types.Int64Value(cValue.Int())
+ }
+ data.TrustedKeys = append(data.TrustedKeys, item)
+ return true
+ })
+ }
+}
+
+// End of section. //template:end fromBodyDataXML
+
+// Section below is generated&owned by "gen/generator.go". //template:begin getDeletedItems
+
+func (data *NTP) getDeletedItems(ctx context.Context, state NTP) []string {
+ deletedItems := make([]string, 0)
+ for i := range state.TrustedKeys {
+ stateKeyValues := [...]string{strconv.FormatInt(state.TrustedKeys[i].Number.ValueInt64(), 10)}
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.TrustedKeys[i].Number.ValueInt64()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.TrustedKeys {
+ found = true
+ if state.TrustedKeys[i].Number.ValueInt64() != data.TrustedKeys[j].Number.ValueInt64() {
+ found = false
+ }
+ if found {
+ break
+ }
+ }
+ if !found {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-ntp:trusted-key=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ }
+ for i := range state.PeerVrfs {
+ stateKeyValues := [...]string{state.PeerVrfs[i].Name.ValueString()}
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.PeerVrfs[i].Name.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.PeerVrfs {
+ found = true
+ if state.PeerVrfs[i].Name.ValueString() != data.PeerVrfs[j].Name.ValueString() {
+ found = false
+ }
+ if found {
+ for ci := range state.PeerVrfs[i].Peers {
+ cstateKeyValues := [...]string{state.PeerVrfs[i].Peers[ci].IpAddress.ValueString()}
+
+ cemptyKeys := true
+ if !reflect.ValueOf(state.PeerVrfs[i].Peers[ci].IpAddress.ValueString()).IsZero() {
+ cemptyKeys = false
+ }
+ if cemptyKeys {
+ continue
+ }
+
+ found := false
+ for cj := range data.PeerVrfs[j].Peers {
+ found = true
+ if state.PeerVrfs[i].Peers[ci].IpAddress.ValueString() != data.PeerVrfs[j].Peers[cj].IpAddress.ValueString() {
+ found = false
+ }
+ if found {
+ if !state.PeerVrfs[i].Peers[ci].Version.IsNull() && data.PeerVrfs[j].Peers[cj].Version.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-ntp:peer/vrf=%v/server-list=%v/version", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ }
+ if !state.PeerVrfs[i].Peers[ci].Prefer.IsNull() && data.PeerVrfs[j].Peers[cj].Prefer.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-ntp:peer/vrf=%v/server-list=%v/prefer", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ }
+ if !state.PeerVrfs[i].Peers[ci].Key.IsNull() && data.PeerVrfs[j].Peers[cj].Key.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-ntp:peer/vrf=%v/server-list=%v/key", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ }
+ break
+ }
+ }
+ if !found {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-ntp:peer/vrf=%v/server-list=%v", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ }
+ }
+ break
+ }
+ }
+ if !found {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-ntp:peer/vrf=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ }
+ for i := range state.Peers {
+ stateKeyValues := [...]string{state.Peers[i].IpAddress.ValueString()}
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.Peers[i].IpAddress.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.Peers {
+ found = true
+ if state.Peers[i].IpAddress.ValueString() != data.Peers[j].IpAddress.ValueString() {
+ found = false
+ }
+ if found {
+ if !state.Peers[i].Version.IsNull() && data.Peers[j].Version.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-ntp:peer/server-list=%v/version", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ if !state.Peers[i].Prefer.IsNull() && data.Peers[j].Prefer.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-ntp:peer/server-list=%v/prefer", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ if !state.Peers[i].Key.IsNull() && data.Peers[j].Key.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-ntp:peer/server-list=%v/key", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ if !state.Peers[i].Source.IsNull() && data.Peers[j].Source.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-ntp:peer/server-list=%v/source", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ break
+ }
+ }
+ if !found {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-ntp:peer/server-list=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ }
+ for i := range state.ServerVrfs {
+ stateKeyValues := [...]string{state.ServerVrfs[i].Name.ValueString()}
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.ServerVrfs[i].Name.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.ServerVrfs {
+ found = true
+ if state.ServerVrfs[i].Name.ValueString() != data.ServerVrfs[j].Name.ValueString() {
+ found = false
+ }
+ if found {
+ for ci := range state.ServerVrfs[i].Servers {
+ cstateKeyValues := [...]string{state.ServerVrfs[i].Servers[ci].IpAddress.ValueString()}
+
+ cemptyKeys := true
+ if !reflect.ValueOf(state.ServerVrfs[i].Servers[ci].IpAddress.ValueString()).IsZero() {
+ cemptyKeys = false
+ }
+ if cemptyKeys {
+ continue
+ }
+
+ found := false
+ for cj := range data.ServerVrfs[j].Servers {
+ found = true
+ if state.ServerVrfs[i].Servers[ci].IpAddress.ValueString() != data.ServerVrfs[j].Servers[cj].IpAddress.ValueString() {
+ found = false
+ }
+ if found {
+ if !state.ServerVrfs[i].Servers[ci].Periodic.IsNull() && data.ServerVrfs[j].Servers[cj].Periodic.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-ntp:server/vrf=%v/server-list=%v/periodic", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ }
+ if !state.ServerVrfs[i].Servers[ci].Iburst.IsNull() && data.ServerVrfs[j].Servers[cj].Iburst.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-ntp:server/vrf=%v/server-list=%v/iburst-opt", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ }
+ if !state.ServerVrfs[i].Servers[ci].Burst.IsNull() && data.ServerVrfs[j].Servers[cj].Burst.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-ntp:server/vrf=%v/server-list=%v/burst-opt", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ }
+ if !state.ServerVrfs[i].Servers[ci].Version.IsNull() && data.ServerVrfs[j].Servers[cj].Version.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-ntp:server/vrf=%v/server-list=%v/version", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ }
+ if !state.ServerVrfs[i].Servers[ci].Prefer.IsNull() && data.ServerVrfs[j].Servers[cj].Prefer.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-ntp:server/vrf=%v/server-list=%v/prefer", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ }
+ if !state.ServerVrfs[i].Servers[ci].Key.IsNull() && data.ServerVrfs[j].Servers[cj].Key.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-ntp:server/vrf=%v/server-list=%v/key", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ }
+ break
+ }
+ }
+ if !found {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-ntp:server/vrf=%v/server-list=%v", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ }
+ }
+ break
+ }
+ }
+ if !found {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-ntp:server/vrf=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ }
+ for i := range state.Servers {
+ stateKeyValues := [...]string{state.Servers[i].IpAddress.ValueString()}
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.Servers[i].IpAddress.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.Servers {
+ found = true
+ if state.Servers[i].IpAddress.ValueString() != data.Servers[j].IpAddress.ValueString() {
+ found = false
+ }
+ if found {
+ if !state.Servers[i].Periodic.IsNull() && data.Servers[j].Periodic.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-ntp:server/server-list=%v/periodic", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ if !state.Servers[i].Iburst.IsNull() && data.Servers[j].Iburst.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-ntp:server/server-list=%v/iburst-opt", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ if !state.Servers[i].Burst.IsNull() && data.Servers[j].Burst.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-ntp:server/server-list=%v/burst-opt", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ if !state.Servers[i].Version.IsNull() && data.Servers[j].Version.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-ntp:server/server-list=%v/version", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ if !state.Servers[i].Prefer.IsNull() && data.Servers[j].Prefer.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-ntp:server/server-list=%v/prefer", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ if !state.Servers[i].Key.IsNull() && data.Servers[j].Key.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-ntp:server/server-list=%v/key", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ if !state.Servers[i].Source.IsNull() && data.Servers[j].Source.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-ntp:server/server-list=%v/source", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ break
+ }
+ }
+ if !found {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-ntp:server/server-list=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ }
+ if !state.SourceVlan.IsNull() && data.SourceVlan.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-ntp:source/Vlan", state.getPath()))
+ }
+ if !state.SourcePortChannelSubinterface.IsNull() && data.SourcePortChannelSubinterface.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-ntp:source/Port-channel-subinterface/Port-channel", state.getPath()))
+ }
+ if !state.SourcePortChannel.IsNull() && data.SourcePortChannel.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-ntp:source/Port-channel", state.getPath()))
+ }
+ if !state.SourceLoopback.IsNull() && data.SourceLoopback.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-ntp:source/Loopback", state.getPath()))
+ }
+ if !state.SourceHundredGigabitEthernet.IsNull() && data.SourceHundredGigabitEthernet.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-ntp:source/HundredGigE", state.getPath()))
+ }
+ if !state.SourceFortyGigabitEthernet.IsNull() && data.SourceFortyGigabitEthernet.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-ntp:source/FortyGigabitEthernet", state.getPath()))
+ }
+ if !state.SourceTenGigabitEthernet.IsNull() && data.SourceTenGigabitEthernet.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-ntp:source/TenGigabitEthernet", state.getPath()))
+ }
+ if !state.SourceGigabitEthernet.IsNull() && data.SourceGigabitEthernet.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-ntp:source/GigabitEthernet", state.getPath()))
+ }
+ if !state.UpdateCalendar.IsNull() && data.UpdateCalendar.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-ntp:update-calendar", state.getPath()))
+ }
+ if !state.Passive.IsNull() && data.Passive.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-ntp:passive", state.getPath()))
+ }
+ if !state.MasterStratum.IsNull() && data.MasterStratum.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-ntp:master/stratum-number", state.getPath()))
+ }
+ if !state.Master.IsNull() && data.Master.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-ntp:master", state.getPath()))
+ }
+ if !state.ClockPeriod.IsNull() && data.ClockPeriod.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-ntp:clock-period", state.getPath()))
+ }
+ for i := range state.AuthenticationKeys {
+ stateKeyValues := [...]string{strconv.FormatInt(state.AuthenticationKeys[i].Number.ValueInt64(), 10)}
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.AuthenticationKeys[i].Number.ValueInt64()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.AuthenticationKeys {
+ found = true
+ if state.AuthenticationKeys[i].Number.ValueInt64() != data.AuthenticationKeys[j].Number.ValueInt64() {
+ found = false
+ }
+ if found {
+ if !state.AuthenticationKeys[i].EncryptionType.IsNull() && data.AuthenticationKeys[j].EncryptionType.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-ntp:authentication-key=%v/encryption-type", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ if !state.AuthenticationKeys[i].Sha2.IsNull() && data.AuthenticationKeys[j].Sha2.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-ntp:authentication-key=%v/sha2", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ if !state.AuthenticationKeys[i].Sha1.IsNull() && data.AuthenticationKeys[j].Sha1.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-ntp:authentication-key=%v/sha1", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ if !state.AuthenticationKeys[i].HmacSha2256.IsNull() && data.AuthenticationKeys[j].HmacSha2256.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-ntp:authentication-key=%v/hmac-sha2-256", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ if !state.AuthenticationKeys[i].HmacSha1.IsNull() && data.AuthenticationKeys[j].HmacSha1.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-ntp:authentication-key=%v/hmac-sha1", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ if !state.AuthenticationKeys[i].CmacAes128.IsNull() && data.AuthenticationKeys[j].CmacAes128.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-ntp:authentication-key=%v/cmac-aes-128", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ if !state.AuthenticationKeys[i].Md5.IsNull() && data.AuthenticationKeys[j].Md5.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-ntp:authentication-key=%v/md5-cfg", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ break
}
- data.Peers = append(data.Peers, item)
- return true
- })
+ }
+ if !found {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-ntp:authentication-key=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
}
- if value := res.Get(prefix + "Cisco-IOS-XE-ntp:peer.vrf"); value.Exists() {
- data.PeerVrfs = make([]NTPPeerVrfs, 0)
- value.ForEach(func(k, v gjson.Result) bool {
- item := NTPPeerVrfs{}
- if cValue := v.Get("name"); cValue.Exists() {
- item.Name = types.StringValue(cValue.String())
- }
- if cValue := v.Get("server-list"); cValue.Exists() {
- item.Peers = make([]NTPPeerVrfsPeers, 0)
- cValue.ForEach(func(ck, cv gjson.Result) bool {
- cItem := NTPPeerVrfsPeers{}
- if ccValue := cv.Get("ip-address"); ccValue.Exists() {
- cItem.IpAddress = types.StringValue(ccValue.String())
- }
- if ccValue := cv.Get("key"); ccValue.Exists() {
- cItem.Key = types.Int64Value(ccValue.Int())
- }
- if ccValue := cv.Get("prefer"); ccValue.Exists() {
- cItem.Prefer = types.BoolValue(true)
- } else {
- cItem.Prefer = types.BoolValue(false)
- }
- if ccValue := cv.Get("version"); ccValue.Exists() {
- cItem.Version = types.Int64Value(ccValue.Int())
- }
- item.Peers = append(item.Peers, cItem)
- return true
- })
- }
- data.PeerVrfs = append(data.PeerVrfs, item)
- return true
- })
+ if !state.AccessGroupServeOnlyAcl.IsNull() && data.AccessGroupServeOnlyAcl.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-ntp:access-group/serve-only/acl", state.getPath()))
}
- if value := res.Get(prefix + "Cisco-IOS-XE-ntp:trusted-key"); value.Exists() {
- data.TrustedKeys = make([]NTPTrustedKeys, 0)
- value.ForEach(func(k, v gjson.Result) bool {
- item := NTPTrustedKeys{}
- if cValue := v.Get("number"); cValue.Exists() {
- item.Number = types.Int64Value(cValue.Int())
- }
- data.TrustedKeys = append(data.TrustedKeys, item)
- return true
- })
+ if !state.AccessGroupServeAcl.IsNull() && data.AccessGroupServeAcl.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-ntp:access-group/serve/acl", state.getPath()))
+ }
+ if !state.AccessGroupQueryOnlyAcl.IsNull() && data.AccessGroupQueryOnlyAcl.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-ntp:access-group/query-only/acl", state.getPath()))
+ }
+ if !state.AccessGroupPeerAcl.IsNull() && data.AccessGroupPeerAcl.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-ntp:access-group/peer/acl", state.getPath()))
+ }
+ if !state.Logging.IsNull() && data.Logging.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-ntp:logging", state.getPath()))
+ }
+ if !state.Authenticate.IsNull() && data.Authenticate.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-ntp:authenticate", state.getPath()))
}
+
+ return deletedItems
}
-// End of section. //template:end fromBodyData
+// End of section. //template:end getDeletedItems
-// Section below is generated&owned by "gen/generator.go". //template:begin getDeletedItems
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletedItemsXML
-func (data *NTP) getDeletedItems(ctx context.Context, state NTP) []string {
- deletedItems := make([]string, 0)
- for i := range state.TrustedKeys {
- stateKeyValues := [...]string{strconv.FormatInt(state.TrustedKeys[i].Number.ValueInt64(), 10)}
+func (data *NTP) addDeletedItemsXML(ctx context.Context, state NTP, body string) string {
+ b := netconf.NewBody(body)
+ if !state.Authenticate.IsNull() && data.Authenticate.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-ntp:authenticate")
+ }
+ if !state.Logging.IsNull() && data.Logging.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-ntp:logging")
+ }
+ if !state.AccessGroupPeerAcl.IsNull() && data.AccessGroupPeerAcl.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-ntp:access-group/peer/acl")
+ }
+ if !state.AccessGroupQueryOnlyAcl.IsNull() && data.AccessGroupQueryOnlyAcl.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-ntp:access-group/query-only/acl")
+ }
+ if !state.AccessGroupServeAcl.IsNull() && data.AccessGroupServeAcl.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-ntp:access-group/serve/acl")
+ }
+ if !state.AccessGroupServeOnlyAcl.IsNull() && data.AccessGroupServeOnlyAcl.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-ntp:access-group/serve-only/acl")
+ }
+ for i := range state.AuthenticationKeys {
+ stateKeys := [...]string{"number"}
+ stateKeyValues := [...]string{strconv.FormatInt(state.AuthenticationKeys[i].Number.ValueInt64(), 10)}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
emptyKeys := true
- if !reflect.ValueOf(state.TrustedKeys[i].Number.ValueInt64()).IsZero() {
+ if !reflect.ValueOf(state.AuthenticationKeys[i].Number.ValueInt64()).IsZero() {
emptyKeys = false
}
if emptyKeys {
@@ -1465,24 +3153,140 @@ func (data *NTP) getDeletedItems(ctx context.Context, state NTP) []string {
}
found := false
- for j := range data.TrustedKeys {
+ for j := range data.AuthenticationKeys {
found = true
- if state.TrustedKeys[i].Number.ValueInt64() != data.TrustedKeys[j].Number.ValueInt64() {
+ if state.AuthenticationKeys[i].Number.ValueInt64() != data.AuthenticationKeys[j].Number.ValueInt64() {
+ found = false
+ }
+ if found {
+ if !state.AuthenticationKeys[i].Md5.IsNull() && data.AuthenticationKeys[j].Md5.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-ntp:authentication-key%v/md5-cfg", predicates))
+ }
+ if !state.AuthenticationKeys[i].CmacAes128.IsNull() && data.AuthenticationKeys[j].CmacAes128.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-ntp:authentication-key%v/cmac-aes-128", predicates))
+ }
+ if !state.AuthenticationKeys[i].HmacSha1.IsNull() && data.AuthenticationKeys[j].HmacSha1.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-ntp:authentication-key%v/hmac-sha1", predicates))
+ }
+ if !state.AuthenticationKeys[i].HmacSha2256.IsNull() && data.AuthenticationKeys[j].HmacSha2256.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-ntp:authentication-key%v/hmac-sha2-256", predicates))
+ }
+ if !state.AuthenticationKeys[i].Sha1.IsNull() && data.AuthenticationKeys[j].Sha1.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-ntp:authentication-key%v/sha1", predicates))
+ }
+ if !state.AuthenticationKeys[i].Sha2.IsNull() && data.AuthenticationKeys[j].Sha2.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-ntp:authentication-key%v/sha2", predicates))
+ }
+ if !state.AuthenticationKeys[i].EncryptionType.IsNull() && data.AuthenticationKeys[j].EncryptionType.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-ntp:authentication-key%v/encryption-type", predicates))
+ }
+ break
+ }
+ }
+ if !found {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-ntp:authentication-key%v", predicates))
+ }
+ }
+ if !state.ClockPeriod.IsNull() && data.ClockPeriod.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-ntp:clock-period")
+ }
+ if !state.Master.IsNull() && data.Master.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-ntp:master")
+ }
+ if !state.MasterStratum.IsNull() && data.MasterStratum.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-ntp:master/stratum-number")
+ }
+ if !state.Passive.IsNull() && data.Passive.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-ntp:passive")
+ }
+ if !state.UpdateCalendar.IsNull() && data.UpdateCalendar.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-ntp:update-calendar")
+ }
+ if !state.SourceGigabitEthernet.IsNull() && data.SourceGigabitEthernet.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-ntp:source/GigabitEthernet")
+ }
+ if !state.SourceTenGigabitEthernet.IsNull() && data.SourceTenGigabitEthernet.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-ntp:source/TenGigabitEthernet")
+ }
+ if !state.SourceFortyGigabitEthernet.IsNull() && data.SourceFortyGigabitEthernet.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-ntp:source/FortyGigabitEthernet")
+ }
+ if !state.SourceHundredGigabitEthernet.IsNull() && data.SourceHundredGigabitEthernet.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-ntp:source/HundredGigE")
+ }
+ if !state.SourceLoopback.IsNull() && data.SourceLoopback.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-ntp:source/Loopback")
+ }
+ if !state.SourcePortChannel.IsNull() && data.SourcePortChannel.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-ntp:source/Port-channel")
+ }
+ if !state.SourcePortChannelSubinterface.IsNull() && data.SourcePortChannelSubinterface.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-ntp:source/Port-channel-subinterface/Port-channel")
+ }
+ if !state.SourceVlan.IsNull() && data.SourceVlan.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-ntp:source/Vlan")
+ }
+ for i := range state.Servers {
+ stateKeys := [...]string{"ip-address"}
+ stateKeyValues := [...]string{state.Servers[i].IpAddress.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.Servers[i].IpAddress.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.Servers {
+ found = true
+ if state.Servers[i].IpAddress.ValueString() != data.Servers[j].IpAddress.ValueString() {
found = false
}
if found {
+ if !state.Servers[i].Source.IsNull() && data.Servers[j].Source.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-ntp:server/server-list%v/source", predicates))
+ }
+ if !state.Servers[i].Key.IsNull() && data.Servers[j].Key.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-ntp:server/server-list%v/key", predicates))
+ }
+ if !state.Servers[i].Prefer.IsNull() && data.Servers[j].Prefer.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-ntp:server/server-list%v/prefer", predicates))
+ }
+ if !state.Servers[i].Version.IsNull() && data.Servers[j].Version.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-ntp:server/server-list%v/version", predicates))
+ }
+ if !state.Servers[i].Burst.IsNull() && data.Servers[j].Burst.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-ntp:server/server-list%v/burst-opt", predicates))
+ }
+ if !state.Servers[i].Iburst.IsNull() && data.Servers[j].Iburst.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-ntp:server/server-list%v/iburst-opt", predicates))
+ }
+ if !state.Servers[i].Periodic.IsNull() && data.Servers[j].Periodic.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-ntp:server/server-list%v/periodic", predicates))
+ }
break
}
}
if !found {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-ntp:trusted-key=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-ntp:server/server-list%v", predicates))
}
}
- for i := range state.PeerVrfs {
- stateKeyValues := [...]string{state.PeerVrfs[i].Name.ValueString()}
+ for i := range state.ServerVrfs {
+ stateKeys := [...]string{"name"}
+ stateKeyValues := [...]string{state.ServerVrfs[i].Name.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
emptyKeys := true
- if !reflect.ValueOf(state.PeerVrfs[i].Name.ValueString()).IsZero() {
+ if !reflect.ValueOf(state.ServerVrfs[i].Name.ValueString()).IsZero() {
emptyKeys = false
}
if emptyKeys {
@@ -1490,17 +3294,22 @@ func (data *NTP) getDeletedItems(ctx context.Context, state NTP) []string {
}
found := false
- for j := range data.PeerVrfs {
+ for j := range data.ServerVrfs {
found = true
- if state.PeerVrfs[i].Name.ValueString() != data.PeerVrfs[j].Name.ValueString() {
+ if state.ServerVrfs[i].Name.ValueString() != data.ServerVrfs[j].Name.ValueString() {
found = false
}
if found {
- for ci := range state.PeerVrfs[i].Peers {
- cstateKeyValues := [...]string{state.PeerVrfs[i].Peers[ci].IpAddress.ValueString()}
+ for ci := range state.ServerVrfs[i].Servers {
+ cstateKeys := [...]string{"ip-address"}
+ cstateKeyValues := [...]string{state.ServerVrfs[i].Servers[ci].IpAddress.ValueString()}
+ cpredicates := ""
+ for i := range cstateKeys {
+ cpredicates += fmt.Sprintf("[%s='%s']", cstateKeys[i], cstateKeyValues[i])
+ }
cemptyKeys := true
- if !reflect.ValueOf(state.PeerVrfs[i].Peers[ci].IpAddress.ValueString()).IsZero() {
+ if !reflect.ValueOf(state.ServerVrfs[i].Servers[ci].IpAddress.ValueString()).IsZero() {
cemptyKeys = false
}
if cemptyKeys {
@@ -1508,37 +3317,51 @@ func (data *NTP) getDeletedItems(ctx context.Context, state NTP) []string {
}
found := false
- for cj := range data.PeerVrfs[j].Peers {
+ for cj := range data.ServerVrfs[j].Servers {
found = true
- if state.PeerVrfs[i].Peers[ci].IpAddress.ValueString() != data.PeerVrfs[j].Peers[cj].IpAddress.ValueString() {
+ if state.ServerVrfs[i].Servers[ci].IpAddress.ValueString() != data.ServerVrfs[j].Servers[cj].IpAddress.ValueString() {
found = false
}
if found {
- if !state.PeerVrfs[i].Peers[ci].Version.IsNull() && data.PeerVrfs[j].Peers[cj].Version.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-ntp:peer/vrf=%v/server-list=%v/version", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ if !state.ServerVrfs[i].Servers[ci].Key.IsNull() && data.ServerVrfs[j].Servers[cj].Key.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-ntp:server/vrf%v/server-list%v/key", predicates, cpredicates))
}
- if !state.PeerVrfs[i].Peers[ci].Prefer.IsNull() && data.PeerVrfs[j].Peers[cj].Prefer.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-ntp:peer/vrf=%v/server-list=%v/prefer", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ if !state.ServerVrfs[i].Servers[ci].Prefer.IsNull() && data.ServerVrfs[j].Servers[cj].Prefer.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-ntp:server/vrf%v/server-list%v/prefer", predicates, cpredicates))
}
- if !state.PeerVrfs[i].Peers[ci].Key.IsNull() && data.PeerVrfs[j].Peers[cj].Key.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-ntp:peer/vrf=%v/server-list=%v/key", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ if !state.ServerVrfs[i].Servers[ci].Version.IsNull() && data.ServerVrfs[j].Servers[cj].Version.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-ntp:server/vrf%v/server-list%v/version", predicates, cpredicates))
+ }
+ if !state.ServerVrfs[i].Servers[ci].Burst.IsNull() && data.ServerVrfs[j].Servers[cj].Burst.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-ntp:server/vrf%v/server-list%v/burst-opt", predicates, cpredicates))
+ }
+ if !state.ServerVrfs[i].Servers[ci].Iburst.IsNull() && data.ServerVrfs[j].Servers[cj].Iburst.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-ntp:server/vrf%v/server-list%v/iburst-opt", predicates, cpredicates))
+ }
+ if !state.ServerVrfs[i].Servers[ci].Periodic.IsNull() && data.ServerVrfs[j].Servers[cj].Periodic.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-ntp:server/vrf%v/server-list%v/periodic", predicates, cpredicates))
}
break
}
}
if !found {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-ntp:peer/vrf=%v/server-list=%v", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-ntp:server/vrf%v/server-list%v", predicates, cpredicates))
}
}
break
}
}
if !found {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-ntp:peer/vrf=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-ntp:server/vrf%v", predicates))
}
}
for i := range state.Peers {
+ stateKeys := [...]string{"ip-address"}
stateKeyValues := [...]string{state.Peers[i].IpAddress.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
emptyKeys := true
if !reflect.ValueOf(state.Peers[i].IpAddress.ValueString()).IsZero() {
@@ -1555,30 +3378,35 @@ func (data *NTP) getDeletedItems(ctx context.Context, state NTP) []string {
found = false
}
if found {
- if !state.Peers[i].Version.IsNull() && data.Peers[j].Version.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-ntp:peer/server-list=%v/version", state.getPath(), strings.Join(stateKeyValues[:], ",")))
- }
- if !state.Peers[i].Prefer.IsNull() && data.Peers[j].Prefer.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-ntp:peer/server-list=%v/prefer", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ if !state.Peers[i].Source.IsNull() && data.Peers[j].Source.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-ntp:peer/server-list%v/source", predicates))
}
if !state.Peers[i].Key.IsNull() && data.Peers[j].Key.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-ntp:peer/server-list=%v/key", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-ntp:peer/server-list%v/key", predicates))
}
- if !state.Peers[i].Source.IsNull() && data.Peers[j].Source.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-ntp:peer/server-list=%v/source", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ if !state.Peers[i].Prefer.IsNull() && data.Peers[j].Prefer.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-ntp:peer/server-list%v/prefer", predicates))
+ }
+ if !state.Peers[i].Version.IsNull() && data.Peers[j].Version.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-ntp:peer/server-list%v/version", predicates))
}
break
}
}
if !found {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-ntp:peer/server-list=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-ntp:peer/server-list%v", predicates))
+ }
+ }
+ for i := range state.PeerVrfs {
+ stateKeys := [...]string{"name"}
+ stateKeyValues := [...]string{state.PeerVrfs[i].Name.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
}
- }
- for i := range state.ServerVrfs {
- stateKeyValues := [...]string{state.ServerVrfs[i].Name.ValueString()}
emptyKeys := true
- if !reflect.ValueOf(state.ServerVrfs[i].Name.ValueString()).IsZero() {
+ if !reflect.ValueOf(state.PeerVrfs[i].Name.ValueString()).IsZero() {
emptyKeys = false
}
if emptyKeys {
@@ -1586,17 +3414,22 @@ func (data *NTP) getDeletedItems(ctx context.Context, state NTP) []string {
}
found := false
- for j := range data.ServerVrfs {
+ for j := range data.PeerVrfs {
found = true
- if state.ServerVrfs[i].Name.ValueString() != data.ServerVrfs[j].Name.ValueString() {
+ if state.PeerVrfs[i].Name.ValueString() != data.PeerVrfs[j].Name.ValueString() {
found = false
}
if found {
- for ci := range state.ServerVrfs[i].Servers {
- cstateKeyValues := [...]string{state.ServerVrfs[i].Servers[ci].IpAddress.ValueString()}
+ for ci := range state.PeerVrfs[i].Peers {
+ cstateKeys := [...]string{"ip-address"}
+ cstateKeyValues := [...]string{state.PeerVrfs[i].Peers[ci].IpAddress.ValueString()}
+ cpredicates := ""
+ for i := range cstateKeys {
+ cpredicates += fmt.Sprintf("[%s='%s']", cstateKeys[i], cstateKeyValues[i])
+ }
cemptyKeys := true
- if !reflect.ValueOf(state.ServerVrfs[i].Servers[ci].IpAddress.ValueString()).IsZero() {
+ if !reflect.ValueOf(state.PeerVrfs[i].Peers[ci].IpAddress.ValueString()).IsZero() {
cemptyKeys = false
}
if cemptyKeys {
@@ -1604,134 +3437,45 @@ func (data *NTP) getDeletedItems(ctx context.Context, state NTP) []string {
}
found := false
- for cj := range data.ServerVrfs[j].Servers {
+ for cj := range data.PeerVrfs[j].Peers {
found = true
- if state.ServerVrfs[i].Servers[ci].IpAddress.ValueString() != data.ServerVrfs[j].Servers[cj].IpAddress.ValueString() {
+ if state.PeerVrfs[i].Peers[ci].IpAddress.ValueString() != data.PeerVrfs[j].Peers[cj].IpAddress.ValueString() {
found = false
}
if found {
- if !state.ServerVrfs[i].Servers[ci].Periodic.IsNull() && data.ServerVrfs[j].Servers[cj].Periodic.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-ntp:server/vrf=%v/server-list=%v/periodic", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
- }
- if !state.ServerVrfs[i].Servers[ci].Iburst.IsNull() && data.ServerVrfs[j].Servers[cj].Iburst.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-ntp:server/vrf=%v/server-list=%v/iburst-opt", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
- }
- if !state.ServerVrfs[i].Servers[ci].Burst.IsNull() && data.ServerVrfs[j].Servers[cj].Burst.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-ntp:server/vrf=%v/server-list=%v/burst-opt", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
- }
- if !state.ServerVrfs[i].Servers[ci].Version.IsNull() && data.ServerVrfs[j].Servers[cj].Version.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-ntp:server/vrf=%v/server-list=%v/version", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ if !state.PeerVrfs[i].Peers[ci].Key.IsNull() && data.PeerVrfs[j].Peers[cj].Key.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-ntp:peer/vrf%v/server-list%v/key", predicates, cpredicates))
}
- if !state.ServerVrfs[i].Servers[ci].Prefer.IsNull() && data.ServerVrfs[j].Servers[cj].Prefer.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-ntp:server/vrf=%v/server-list=%v/prefer", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ if !state.PeerVrfs[i].Peers[ci].Prefer.IsNull() && data.PeerVrfs[j].Peers[cj].Prefer.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-ntp:peer/vrf%v/server-list%v/prefer", predicates, cpredicates))
}
- if !state.ServerVrfs[i].Servers[ci].Key.IsNull() && data.ServerVrfs[j].Servers[cj].Key.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-ntp:server/vrf=%v/server-list=%v/key", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ if !state.PeerVrfs[i].Peers[ci].Version.IsNull() && data.PeerVrfs[j].Peers[cj].Version.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-ntp:peer/vrf%v/server-list%v/version", predicates, cpredicates))
}
break
}
}
if !found {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-ntp:server/vrf=%v/server-list=%v", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-ntp:peer/vrf%v/server-list%v", predicates, cpredicates))
}
}
break
}
}
if !found {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-ntp:server/vrf=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-ntp:peer/vrf%v", predicates))
}
}
- for i := range state.Servers {
- stateKeyValues := [...]string{state.Servers[i].IpAddress.ValueString()}
-
- emptyKeys := true
- if !reflect.ValueOf(state.Servers[i].IpAddress.ValueString()).IsZero() {
- emptyKeys = false
- }
- if emptyKeys {
- continue
- }
-
- found := false
- for j := range data.Servers {
- found = true
- if state.Servers[i].IpAddress.ValueString() != data.Servers[j].IpAddress.ValueString() {
- found = false
- }
- if found {
- if !state.Servers[i].Periodic.IsNull() && data.Servers[j].Periodic.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-ntp:server/server-list=%v/periodic", state.getPath(), strings.Join(stateKeyValues[:], ",")))
- }
- if !state.Servers[i].Iburst.IsNull() && data.Servers[j].Iburst.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-ntp:server/server-list=%v/iburst-opt", state.getPath(), strings.Join(stateKeyValues[:], ",")))
- }
- if !state.Servers[i].Burst.IsNull() && data.Servers[j].Burst.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-ntp:server/server-list=%v/burst-opt", state.getPath(), strings.Join(stateKeyValues[:], ",")))
- }
- if !state.Servers[i].Version.IsNull() && data.Servers[j].Version.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-ntp:server/server-list=%v/version", state.getPath(), strings.Join(stateKeyValues[:], ",")))
- }
- if !state.Servers[i].Prefer.IsNull() && data.Servers[j].Prefer.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-ntp:server/server-list=%v/prefer", state.getPath(), strings.Join(stateKeyValues[:], ",")))
- }
- if !state.Servers[i].Key.IsNull() && data.Servers[j].Key.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-ntp:server/server-list=%v/key", state.getPath(), strings.Join(stateKeyValues[:], ",")))
- }
- if !state.Servers[i].Source.IsNull() && data.Servers[j].Source.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-ntp:server/server-list=%v/source", state.getPath(), strings.Join(stateKeyValues[:], ",")))
- }
- break
- }
- }
- if !found {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-ntp:server/server-list=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ for i := range state.TrustedKeys {
+ stateKeys := [...]string{"number"}
+ stateKeyValues := [...]string{strconv.FormatInt(state.TrustedKeys[i].Number.ValueInt64(), 10)}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
}
- }
- if !state.SourceVlan.IsNull() && data.SourceVlan.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-ntp:source/Vlan", state.getPath()))
- }
- if !state.SourcePortChannelSubinterface.IsNull() && data.SourcePortChannelSubinterface.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-ntp:source/Port-channel-subinterface/Port-channel", state.getPath()))
- }
- if !state.SourcePortChannel.IsNull() && data.SourcePortChannel.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-ntp:source/Port-channel", state.getPath()))
- }
- if !state.SourceLoopback.IsNull() && data.SourceLoopback.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-ntp:source/Loopback", state.getPath()))
- }
- if !state.SourceHundredGigabitEthernet.IsNull() && data.SourceHundredGigabitEthernet.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-ntp:source/HundredGigE", state.getPath()))
- }
- if !state.SourceFortyGigabitEthernet.IsNull() && data.SourceFortyGigabitEthernet.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-ntp:source/FortyGigabitEthernet", state.getPath()))
- }
- if !state.SourceTenGigabitEthernet.IsNull() && data.SourceTenGigabitEthernet.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-ntp:source/TenGigabitEthernet", state.getPath()))
- }
- if !state.SourceGigabitEthernet.IsNull() && data.SourceGigabitEthernet.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-ntp:source/GigabitEthernet", state.getPath()))
- }
- if !state.UpdateCalendar.IsNull() && data.UpdateCalendar.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-ntp:update-calendar", state.getPath()))
- }
- if !state.Passive.IsNull() && data.Passive.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-ntp:passive", state.getPath()))
- }
- if !state.MasterStratum.IsNull() && data.MasterStratum.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-ntp:master/stratum-number", state.getPath()))
- }
- if !state.Master.IsNull() && data.Master.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-ntp:master", state.getPath()))
- }
- if !state.ClockPeriod.IsNull() && data.ClockPeriod.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-ntp:clock-period", state.getPath()))
- }
- for i := range state.AuthenticationKeys {
- stateKeyValues := [...]string{strconv.FormatInt(state.AuthenticationKeys[i].Number.ValueInt64(), 10)}
emptyKeys := true
- if !reflect.ValueOf(state.AuthenticationKeys[i].Number.ValueInt64()).IsZero() {
+ if !reflect.ValueOf(state.TrustedKeys[i].Number.ValueInt64()).IsZero() {
emptyKeys = false
}
if emptyKeys {
@@ -1739,63 +3483,24 @@ func (data *NTP) getDeletedItems(ctx context.Context, state NTP) []string {
}
found := false
- for j := range data.AuthenticationKeys {
+ for j := range data.TrustedKeys {
found = true
- if state.AuthenticationKeys[i].Number.ValueInt64() != data.AuthenticationKeys[j].Number.ValueInt64() {
+ if state.TrustedKeys[i].Number.ValueInt64() != data.TrustedKeys[j].Number.ValueInt64() {
found = false
}
if found {
- if !state.AuthenticationKeys[i].EncryptionType.IsNull() && data.AuthenticationKeys[j].EncryptionType.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-ntp:authentication-key=%v/encryption-type", state.getPath(), strings.Join(stateKeyValues[:], ",")))
- }
- if !state.AuthenticationKeys[i].Sha2.IsNull() && data.AuthenticationKeys[j].Sha2.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-ntp:authentication-key=%v/sha2", state.getPath(), strings.Join(stateKeyValues[:], ",")))
- }
- if !state.AuthenticationKeys[i].Sha1.IsNull() && data.AuthenticationKeys[j].Sha1.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-ntp:authentication-key=%v/sha1", state.getPath(), strings.Join(stateKeyValues[:], ",")))
- }
- if !state.AuthenticationKeys[i].HmacSha2256.IsNull() && data.AuthenticationKeys[j].HmacSha2256.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-ntp:authentication-key=%v/hmac-sha2-256", state.getPath(), strings.Join(stateKeyValues[:], ",")))
- }
- if !state.AuthenticationKeys[i].HmacSha1.IsNull() && data.AuthenticationKeys[j].HmacSha1.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-ntp:authentication-key=%v/hmac-sha1", state.getPath(), strings.Join(stateKeyValues[:], ",")))
- }
- if !state.AuthenticationKeys[i].CmacAes128.IsNull() && data.AuthenticationKeys[j].CmacAes128.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-ntp:authentication-key=%v/cmac-aes-128", state.getPath(), strings.Join(stateKeyValues[:], ",")))
- }
- if !state.AuthenticationKeys[i].Md5.IsNull() && data.AuthenticationKeys[j].Md5.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-ntp:authentication-key=%v/md5-cfg", state.getPath(), strings.Join(stateKeyValues[:], ",")))
- }
break
}
}
if !found {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-ntp:authentication-key=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-ntp:trusted-key%v", predicates))
}
}
- if !state.AccessGroupServeOnlyAcl.IsNull() && data.AccessGroupServeOnlyAcl.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-ntp:access-group/serve-only/acl", state.getPath()))
- }
- if !state.AccessGroupServeAcl.IsNull() && data.AccessGroupServeAcl.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-ntp:access-group/serve/acl", state.getPath()))
- }
- if !state.AccessGroupQueryOnlyAcl.IsNull() && data.AccessGroupQueryOnlyAcl.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-ntp:access-group/query-only/acl", state.getPath()))
- }
- if !state.AccessGroupPeerAcl.IsNull() && data.AccessGroupPeerAcl.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-ntp:access-group/peer/acl", state.getPath()))
- }
- if !state.Logging.IsNull() && data.Logging.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-ntp:logging", state.getPath()))
- }
- if !state.Authenticate.IsNull() && data.Authenticate.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-ntp:authenticate", state.getPath()))
- }
- return deletedItems
+ return b.Res()
}
-// End of section. //template:end getDeletedItems
+// End of section. //template:end addDeletedItemsXML
// Section below is generated&owned by "gen/generator.go". //template:begin getEmptyLeafsDelete
@@ -1973,3 +3678,130 @@ func (data *NTP) getDeletePaths(ctx context.Context) []string {
}
// End of section. //template:end getDeletePaths
+
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletePathsXML
+
+func (data *NTP) addDeletePathsXML(ctx context.Context, body string) string {
+ b := netconf.NewBody(body)
+ if !data.Authenticate.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-ntp:authenticate")
+ }
+ if !data.Logging.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-ntp:logging")
+ }
+ if !data.AccessGroupPeerAcl.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-ntp:access-group/peer/acl")
+ }
+ if !data.AccessGroupQueryOnlyAcl.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-ntp:access-group/query-only/acl")
+ }
+ if !data.AccessGroupServeAcl.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-ntp:access-group/serve/acl")
+ }
+ if !data.AccessGroupServeOnlyAcl.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-ntp:access-group/serve-only/acl")
+ }
+ for i := range data.AuthenticationKeys {
+ keys := [...]string{"number"}
+ keyValues := [...]string{strconv.FormatInt(data.AuthenticationKeys[i].Number.ValueInt64(), 10)}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/Cisco-IOS-XE-ntp:authentication-key%v", predicates))
+ }
+ if !data.ClockPeriod.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-ntp:clock-period")
+ }
+ if !data.Master.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-ntp:master")
+ }
+ if !data.MasterStratum.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-ntp:master/stratum-number")
+ }
+ if !data.Passive.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-ntp:passive")
+ }
+ if !data.UpdateCalendar.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-ntp:update-calendar")
+ }
+ if !data.SourceGigabitEthernet.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-ntp:source/GigabitEthernet")
+ }
+ if !data.SourceTenGigabitEthernet.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-ntp:source/TenGigabitEthernet")
+ }
+ if !data.SourceFortyGigabitEthernet.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-ntp:source/FortyGigabitEthernet")
+ }
+ if !data.SourceHundredGigabitEthernet.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-ntp:source/HundredGigE")
+ }
+ if !data.SourceLoopback.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-ntp:source/Loopback")
+ }
+ if !data.SourcePortChannel.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-ntp:source/Port-channel")
+ }
+ if !data.SourcePortChannelSubinterface.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-ntp:source/Port-channel-subinterface/Port-channel")
+ }
+ if !data.SourceVlan.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-ntp:source/Vlan")
+ }
+ for i := range data.Servers {
+ keys := [...]string{"ip-address"}
+ keyValues := [...]string{data.Servers[i].IpAddress.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/Cisco-IOS-XE-ntp:server/server-list%v", predicates))
+ }
+ for i := range data.ServerVrfs {
+ keys := [...]string{"name"}
+ keyValues := [...]string{data.ServerVrfs[i].Name.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/Cisco-IOS-XE-ntp:server/vrf%v", predicates))
+ }
+ for i := range data.Peers {
+ keys := [...]string{"ip-address"}
+ keyValues := [...]string{data.Peers[i].IpAddress.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/Cisco-IOS-XE-ntp:peer/server-list%v", predicates))
+ }
+ for i := range data.PeerVrfs {
+ keys := [...]string{"name"}
+ keyValues := [...]string{data.PeerVrfs[i].Name.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/Cisco-IOS-XE-ntp:peer/vrf%v", predicates))
+ }
+ for i := range data.TrustedKeys {
+ keys := [...]string{"number"}
+ keyValues := [...]string{strconv.FormatInt(data.TrustedKeys[i].Number.ValueInt64(), 10)}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/Cisco-IOS-XE-ntp:trusted-key%v", predicates))
+ }
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletePathsXML
diff --git a/internal/provider/model_iosxe_ospf.go b/internal/provider/model_iosxe_ospf.go
index beb94d06..c75ab291 100644
--- a/internal/provider/model_iosxe_ospf.go
+++ b/internal/provider/model_iosxe_ospf.go
@@ -31,6 +31,9 @@ import (
"github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/types"
+ "github.com/hashicorp/terraform-plugin-log/tflog"
+ "github.com/netascode/go-netconf"
+ "github.com/netascode/xmldot"
"github.com/tidwall/gjson"
"github.com/tidwall/sjson"
)
@@ -204,6 +207,19 @@ func (data OSPF) getPathShort() string {
return matches[1]
}
+// getXPath returns the XPath for NETCONF operations
+func (data OSPF) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/router/Cisco-IOS-XE-ospf:router-ospf/ospf/process-id[id=%v]"
+ path = fmt.Sprintf(path, fmt.Sprintf("%v", data.ProcessId.ValueInt64()))
+ return path
+}
+
+func (data OSPFData) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/router/Cisco-IOS-XE-ospf:router-ospf/ospf/process-id[id=%v]"
+ path = fmt.Sprintf(path, fmt.Sprintf("%v", data.ProcessId.ValueInt64()))
+ return path
+}
+
// End of section. //template:end getPath
// Section below is generated&owned by "gen/generator.go". //template:begin toBody
@@ -346,114 +362,114 @@ func (data OSPF) toBody(ctx context.Context) string {
}
}
if len(data.PassiveInterfaceDisableGigabitEthernets) > 0 {
- body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"passive-interface-config.disable-interface.GigabitEthernet", []interface{}{})
+ body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"", []interface{}{})
for index, item := range data.PassiveInterfaceDisableGigabitEthernets {
if !item.Name.IsNull() && !item.Name.IsUnknown() {
- body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"passive-interface-config.disable-interface.GigabitEthernet"+"."+strconv.Itoa(index)+"."+"name", item.Name.ValueString())
+ body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+""+"."+strconv.Itoa(index)+"."+"", item.Name.ValueString())
}
}
}
if len(data.PassiveInterfaceDisableTwoGigabitEthernets) > 0 {
- body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"passive-interface-config.disable-interface.TwoGigabitEthernet", []interface{}{})
+ body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"", []interface{}{})
for index, item := range data.PassiveInterfaceDisableTwoGigabitEthernets {
if !item.Name.IsNull() && !item.Name.IsUnknown() {
- body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"passive-interface-config.disable-interface.TwoGigabitEthernet"+"."+strconv.Itoa(index)+"."+"name", item.Name.ValueString())
+ body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+""+"."+strconv.Itoa(index)+"."+"", item.Name.ValueString())
}
}
}
if len(data.PassiveInterfaceDisableFiveGigabitEthernets) > 0 {
- body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"passive-interface-config.disable-interface.FiveGigabitEthernet", []interface{}{})
+ body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"", []interface{}{})
for index, item := range data.PassiveInterfaceDisableFiveGigabitEthernets {
if !item.Name.IsNull() && !item.Name.IsUnknown() {
- body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"passive-interface-config.disable-interface.FiveGigabitEthernet"+"."+strconv.Itoa(index)+"."+"name", item.Name.ValueString())
+ body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+""+"."+strconv.Itoa(index)+"."+"", item.Name.ValueString())
}
}
}
if len(data.PassiveInterfaceDisableTenGigabitEthernets) > 0 {
- body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"passive-interface-config.disable-interface.TenGigabitEthernet", []interface{}{})
+ body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"", []interface{}{})
for index, item := range data.PassiveInterfaceDisableTenGigabitEthernets {
if !item.Name.IsNull() && !item.Name.IsUnknown() {
- body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"passive-interface-config.disable-interface.TenGigabitEthernet"+"."+strconv.Itoa(index)+"."+"name", item.Name.ValueString())
+ body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+""+"."+strconv.Itoa(index)+"."+"", item.Name.ValueString())
}
}
}
if len(data.PassiveInterfaceDisableTwentyFiveGigabitEthernets) > 0 {
- body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"passive-interface-config.disable-interface.TwentyFiveGigabitE", []interface{}{})
+ body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"", []interface{}{})
for index, item := range data.PassiveInterfaceDisableTwentyFiveGigabitEthernets {
if !item.Name.IsNull() && !item.Name.IsUnknown() {
- body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"passive-interface-config.disable-interface.TwentyFiveGigabitE"+"."+strconv.Itoa(index)+"."+"name", item.Name.ValueString())
+ body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+""+"."+strconv.Itoa(index)+"."+"", item.Name.ValueString())
}
}
}
if len(data.PassiveInterfaceDisableFortyGigabitEthernets) > 0 {
- body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"passive-interface-config.disable-interface.FortyGigabitEthernet", []interface{}{})
+ body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"", []interface{}{})
for index, item := range data.PassiveInterfaceDisableFortyGigabitEthernets {
if !item.Name.IsNull() && !item.Name.IsUnknown() {
- body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"passive-interface-config.disable-interface.FortyGigabitEthernet"+"."+strconv.Itoa(index)+"."+"name", item.Name.ValueString())
+ body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+""+"."+strconv.Itoa(index)+"."+"", item.Name.ValueString())
}
}
}
if len(data.PassiveInterfaceDisableHundredGigabitEthernets) > 0 {
- body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"passive-interface-config.disable-interface.HundredGigabitE", []interface{}{})
+ body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"", []interface{}{})
for index, item := range data.PassiveInterfaceDisableHundredGigabitEthernets {
if !item.Name.IsNull() && !item.Name.IsUnknown() {
- body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"passive-interface-config.disable-interface.HundredGigabitE"+"."+strconv.Itoa(index)+"."+"name", item.Name.ValueString())
+ body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+""+"."+strconv.Itoa(index)+"."+"", item.Name.ValueString())
}
}
}
if len(data.PassiveInterfaceDisableTwoHundredGigabitEthernets) > 0 {
- body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"passive-interface-config.disable-interface.TwoHundredGigabitE", []interface{}{})
+ body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"", []interface{}{})
for index, item := range data.PassiveInterfaceDisableTwoHundredGigabitEthernets {
if !item.Name.IsNull() && !item.Name.IsUnknown() {
- body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"passive-interface-config.disable-interface.TwoHundredGigabitE"+"."+strconv.Itoa(index)+"."+"name", item.Name.ValueString())
+ body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+""+"."+strconv.Itoa(index)+"."+"", item.Name.ValueString())
}
}
}
if len(data.PassiveInterfaceDisableFourHundredGigabitEthernets) > 0 {
- body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"passive-interface-config.disable-interface.FourHundredGigabitE", []interface{}{})
+ body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"", []interface{}{})
for index, item := range data.PassiveInterfaceDisableFourHundredGigabitEthernets {
if !item.Name.IsNull() && !item.Name.IsUnknown() {
- body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"passive-interface-config.disable-interface.FourHundredGigabitE"+"."+strconv.Itoa(index)+"."+"name", item.Name.ValueString())
+ body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+""+"."+strconv.Itoa(index)+"."+"", item.Name.ValueString())
}
}
}
if len(data.PassiveInterfaceDisableLoopbacks) > 0 {
- body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"passive-interface-config.disable-interface.Loopback", []interface{}{})
+ body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"", []interface{}{})
for index, item := range data.PassiveInterfaceDisableLoopbacks {
if !item.Name.IsNull() && !item.Name.IsUnknown() {
- body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"passive-interface-config.disable-interface.Loopback"+"."+strconv.Itoa(index)+"."+"name", item.Name.ValueString())
+ body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+""+"."+strconv.Itoa(index)+"."+"", item.Name.ValueString())
}
}
}
if len(data.PassiveInterfaceDisableVlans) > 0 {
- body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"passive-interface-config.disable-interface.Vlan", []interface{}{})
+ body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"", []interface{}{})
for index, item := range data.PassiveInterfaceDisableVlans {
if !item.Name.IsNull() && !item.Name.IsUnknown() {
- body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"passive-interface-config.disable-interface.Vlan"+"."+strconv.Itoa(index)+"."+"name", item.Name.ValueString())
+ body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+""+"."+strconv.Itoa(index)+"."+"", item.Name.ValueString())
}
}
}
if len(data.PassiveInterfaceDisableTunnels) > 0 {
- body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"passive-interface-config.disable-interface.Tunnel", []interface{}{})
+ body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"", []interface{}{})
for index, item := range data.PassiveInterfaceDisableTunnels {
if !item.Name.IsNull() && !item.Name.IsUnknown() {
- body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"passive-interface-config.disable-interface.Tunnel"+"."+strconv.Itoa(index)+"."+"name", item.Name.ValueString())
+ body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+""+"."+strconv.Itoa(index)+"."+"", item.Name.ValueString())
}
}
}
if len(data.PassiveInterfaceDisablePortChannels) > 0 {
- body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"passive-interface-config.disable-interface.Port-channel", []interface{}{})
+ body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"", []interface{}{})
for index, item := range data.PassiveInterfaceDisablePortChannels {
if !item.Name.IsNull() && !item.Name.IsUnknown() {
- body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"passive-interface-config.disable-interface.Port-channel"+"."+strconv.Itoa(index)+"."+"name", item.Name.ValueString())
+ body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+""+"."+strconv.Itoa(index)+"."+"", item.Name.ValueString())
}
}
}
if len(data.PassiveInterfaceDisablePortChannelSubinterfaces) > 0 {
- body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"passive-interface-config.disable-interface.Port-channel-subinterface.Port-channel", []interface{}{})
+ body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"", []interface{}{})
for index, item := range data.PassiveInterfaceDisablePortChannelSubinterfaces {
if !item.Name.IsNull() && !item.Name.IsUnknown() {
- body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"passive-interface-config.disable-interface.Port-channel-subinterface.Port-channel"+"."+strconv.Itoa(index)+"."+"name", item.Name.ValueString())
+ body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+""+"."+strconv.Itoa(index)+"."+"", item.Name.ValueString())
}
}
}
@@ -462,6 +478,306 @@ func (data OSPF) toBody(ctx context.Context) string {
// End of section. //template:end toBody
+// Section below is generated&owned by "gen/generator.go". //template:begin toBodyXML
+
+func (data OSPF) toBodyXML(ctx context.Context) string {
+ body := netconf.Body{}
+ if !data.ProcessId.IsNull() && !data.ProcessId.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/id", strconv.FormatInt(data.ProcessId.ValueInt64(), 10))
+ }
+ if !data.BfdAllInterfaces.IsNull() && !data.BfdAllInterfaces.IsUnknown() {
+ if data.BfdAllInterfaces.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/bfd/all-interfaces", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/bfd/all-interfaces")
+ }
+ }
+ if !data.DefaultInformationOriginate.IsNull() && !data.DefaultInformationOriginate.IsUnknown() {
+ if data.DefaultInformationOriginate.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/default-information/originate", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/default-information/originate")
+ }
+ }
+ if !data.DefaultInformationOriginateAlways.IsNull() && !data.DefaultInformationOriginateAlways.IsUnknown() {
+ if data.DefaultInformationOriginateAlways.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/default-information/originate/always", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/default-information/originate/always")
+ }
+ }
+ if !data.DefaultMetric.IsNull() && !data.DefaultMetric.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/default-metric", strconv.FormatInt(data.DefaultMetric.ValueInt64(), 10))
+ }
+ if !data.Distance.IsNull() && !data.Distance.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/distance/distance", strconv.FormatInt(data.Distance.ValueInt64(), 10))
+ }
+ if !data.DomainTag.IsNull() && !data.DomainTag.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/domain-tag", strconv.FormatInt(data.DomainTag.ValueInt64(), 10))
+ }
+ if !data.MplsLdpAutoconfig.IsNull() && !data.MplsLdpAutoconfig.IsUnknown() {
+ if data.MplsLdpAutoconfig.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/mpls/ldp/autoconfig", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/mpls/ldp/autoconfig")
+ }
+ }
+ if !data.MplsLdpSync.IsNull() && !data.MplsLdpSync.IsUnknown() {
+ if data.MplsLdpSync.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/mpls/ldp/sync", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/mpls/ldp/sync")
+ }
+ }
+ if len(data.Neighbors) > 0 {
+ for _, item := range data.Neighbors {
+ cBody := netconf.Body{}
+ if !item.Ip.IsNull() && !item.Ip.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "ip", item.Ip.ValueString())
+ }
+ if !item.Priority.IsNull() && !item.Priority.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "priority", strconv.FormatInt(item.Priority.ValueInt64(), 10))
+ }
+ if !item.Cost.IsNull() && !item.Cost.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "cost", strconv.FormatInt(item.Cost.ValueInt64(), 10))
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/neighbor", cBody.Res())
+ }
+ }
+ if len(data.Networks) > 0 {
+ for _, item := range data.Networks {
+ cBody := netconf.Body{}
+ if !item.Ip.IsNull() && !item.Ip.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "ip", item.Ip.ValueString())
+ }
+ if !item.Wildcard.IsNull() && !item.Wildcard.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "wildcard", item.Wildcard.ValueString())
+ }
+ if !item.Area.IsNull() && !item.Area.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "area", item.Area.ValueString())
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/network", cBody.Res())
+ }
+ }
+ if !data.Priority.IsNull() && !data.Priority.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/priority", strconv.FormatInt(data.Priority.ValueInt64(), 10))
+ }
+ if !data.RouterId.IsNull() && !data.RouterId.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/router-id", data.RouterId.ValueString())
+ }
+ if !data.Shutdown.IsNull() && !data.Shutdown.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/shutdown", data.Shutdown.ValueBool())
+ }
+ if len(data.SummaryAddresses) > 0 {
+ for _, item := range data.SummaryAddresses {
+ cBody := netconf.Body{}
+ if !item.Ip.IsNull() && !item.Ip.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "ip", item.Ip.ValueString())
+ }
+ if !item.Mask.IsNull() && !item.Mask.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "mask", item.Mask.ValueString())
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/summary-address", cBody.Res())
+ }
+ }
+ if len(data.Areas) > 0 {
+ for _, item := range data.Areas {
+ cBody := netconf.Body{}
+ if !item.AreaId.IsNull() && !item.AreaId.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "area-id", item.AreaId.ValueString())
+ }
+ if !item.AuthenticationMessageDigest.IsNull() && !item.AuthenticationMessageDigest.IsUnknown() {
+ if item.AuthenticationMessageDigest.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "authentication/message-digest", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "authentication/message-digest")
+ }
+ }
+ if !item.Nssa.IsNull() && !item.Nssa.IsUnknown() {
+ if item.Nssa.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "nssa", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "nssa")
+ }
+ }
+ if !item.NssaDefaultInformationOriginate.IsNull() && !item.NssaDefaultInformationOriginate.IsUnknown() {
+ if item.NssaDefaultInformationOriginate.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "nssa/nssa-options/default-information-originate", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "nssa/nssa-options/default-information-originate")
+ }
+ }
+ if !item.NssaDefaultInformationOriginateMetric.IsNull() && !item.NssaDefaultInformationOriginateMetric.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "nssa/nssa-options/default-information-originate/metric", strconv.FormatInt(item.NssaDefaultInformationOriginateMetric.ValueInt64(), 10))
+ }
+ if !item.NssaDefaultInformationOriginateMetricType.IsNull() && !item.NssaDefaultInformationOriginateMetricType.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "nssa/nssa-options/default-information-originate/metric-type", strconv.FormatInt(item.NssaDefaultInformationOriginateMetricType.ValueInt64(), 10))
+ }
+ if !item.NssaNoSummary.IsNull() && !item.NssaNoSummary.IsUnknown() {
+ if item.NssaNoSummary.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "nssa/nssa-options/no-summary", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "nssa/nssa-options/no-summary")
+ }
+ }
+ if !item.NssaNoRedistribution.IsNull() && !item.NssaNoRedistribution.IsUnknown() {
+ if item.NssaNoRedistribution.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "nssa/nssa-options/no-redistribution", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "nssa/nssa-options/no-redistribution")
+ }
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/area", cBody.Res())
+ }
+ }
+ if !data.AutoCostReferenceBandwidth.IsNull() && !data.AutoCostReferenceBandwidth.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/auto-cost/reference-bandwidth", strconv.FormatInt(data.AutoCostReferenceBandwidth.ValueInt64(), 10))
+ }
+ if !data.PassiveInterfaceDefault.IsNull() && !data.PassiveInterfaceDefault.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/passive-interface/default", data.PassiveInterfaceDefault.ValueBool())
+ }
+ if !data.PassiveInterface.IsNull() && !data.PassiveInterface.IsUnknown() {
+ var values []string
+ data.PassiveInterface.ElementsAs(ctx, &values, false)
+ for _, v := range values {
+ body = helpers.AppendFromXPath(body, data.getXPath()+"/passive-interface/interface", v)
+ }
+ }
+ if len(data.PassiveInterfaceDisableGigabitEthernets) > 0 {
+ for _, item := range data.PassiveInterfaceDisableGigabitEthernets {
+ cBody := netconf.Body{}
+ if !item.Name.IsNull() && !item.Name.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "", item.Name.ValueString())
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/", cBody.Res())
+ }
+ }
+ if len(data.PassiveInterfaceDisableTwoGigabitEthernets) > 0 {
+ for _, item := range data.PassiveInterfaceDisableTwoGigabitEthernets {
+ cBody := netconf.Body{}
+ if !item.Name.IsNull() && !item.Name.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "", item.Name.ValueString())
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/", cBody.Res())
+ }
+ }
+ if len(data.PassiveInterfaceDisableFiveGigabitEthernets) > 0 {
+ for _, item := range data.PassiveInterfaceDisableFiveGigabitEthernets {
+ cBody := netconf.Body{}
+ if !item.Name.IsNull() && !item.Name.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "", item.Name.ValueString())
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/", cBody.Res())
+ }
+ }
+ if len(data.PassiveInterfaceDisableTenGigabitEthernets) > 0 {
+ for _, item := range data.PassiveInterfaceDisableTenGigabitEthernets {
+ cBody := netconf.Body{}
+ if !item.Name.IsNull() && !item.Name.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "", item.Name.ValueString())
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/", cBody.Res())
+ }
+ }
+ if len(data.PassiveInterfaceDisableTwentyFiveGigabitEthernets) > 0 {
+ for _, item := range data.PassiveInterfaceDisableTwentyFiveGigabitEthernets {
+ cBody := netconf.Body{}
+ if !item.Name.IsNull() && !item.Name.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "", item.Name.ValueString())
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/", cBody.Res())
+ }
+ }
+ if len(data.PassiveInterfaceDisableFortyGigabitEthernets) > 0 {
+ for _, item := range data.PassiveInterfaceDisableFortyGigabitEthernets {
+ cBody := netconf.Body{}
+ if !item.Name.IsNull() && !item.Name.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "", item.Name.ValueString())
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/", cBody.Res())
+ }
+ }
+ if len(data.PassiveInterfaceDisableHundredGigabitEthernets) > 0 {
+ for _, item := range data.PassiveInterfaceDisableHundredGigabitEthernets {
+ cBody := netconf.Body{}
+ if !item.Name.IsNull() && !item.Name.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "", item.Name.ValueString())
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/", cBody.Res())
+ }
+ }
+ if len(data.PassiveInterfaceDisableTwoHundredGigabitEthernets) > 0 {
+ for _, item := range data.PassiveInterfaceDisableTwoHundredGigabitEthernets {
+ cBody := netconf.Body{}
+ if !item.Name.IsNull() && !item.Name.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "", item.Name.ValueString())
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/", cBody.Res())
+ }
+ }
+ if len(data.PassiveInterfaceDisableFourHundredGigabitEthernets) > 0 {
+ for _, item := range data.PassiveInterfaceDisableFourHundredGigabitEthernets {
+ cBody := netconf.Body{}
+ if !item.Name.IsNull() && !item.Name.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "", item.Name.ValueString())
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/", cBody.Res())
+ }
+ }
+ if len(data.PassiveInterfaceDisableLoopbacks) > 0 {
+ for _, item := range data.PassiveInterfaceDisableLoopbacks {
+ cBody := netconf.Body{}
+ if !item.Name.IsNull() && !item.Name.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "", item.Name.ValueString())
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/", cBody.Res())
+ }
+ }
+ if len(data.PassiveInterfaceDisableVlans) > 0 {
+ for _, item := range data.PassiveInterfaceDisableVlans {
+ cBody := netconf.Body{}
+ if !item.Name.IsNull() && !item.Name.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "", item.Name.ValueString())
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/", cBody.Res())
+ }
+ }
+ if len(data.PassiveInterfaceDisableTunnels) > 0 {
+ for _, item := range data.PassiveInterfaceDisableTunnels {
+ cBody := netconf.Body{}
+ if !item.Name.IsNull() && !item.Name.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "", item.Name.ValueString())
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/", cBody.Res())
+ }
+ }
+ if len(data.PassiveInterfaceDisablePortChannels) > 0 {
+ for _, item := range data.PassiveInterfaceDisablePortChannels {
+ cBody := netconf.Body{}
+ if !item.Name.IsNull() && !item.Name.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "", item.Name.ValueString())
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/", cBody.Res())
+ }
+ }
+ if len(data.PassiveInterfaceDisablePortChannelSubinterfaces) > 0 {
+ for _, item := range data.PassiveInterfaceDisablePortChannelSubinterfaces {
+ cBody := netconf.Body{}
+ if !item.Name.IsNull() && !item.Name.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "", item.Name.ValueString())
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/", cBody.Res())
+ }
+ }
+ bodyString, err := body.String()
+ if err != nil {
+ tflog.Error(ctx, fmt.Sprintf("Error converting body to string: %s", err))
+ }
+ return bodyString
+}
+
+// End of section. //template:end toBodyXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBody
func (data *OSPF) updateFromBody(ctx context.Context, res gjson.Result) {
@@ -765,11 +1081,11 @@ func (data *OSPF) updateFromBody(ctx context.Context, res gjson.Result) {
data.PassiveInterface = types.ListNull(types.StringType)
}
for i := range data.PassiveInterfaceDisableGigabitEthernets {
- keys := [...]string{"name"}
+ keys := [...]string{""}
keyValues := [...]string{data.PassiveInterfaceDisableGigabitEthernets[i].Name.ValueString()}
var r gjson.Result
- res.Get(prefix + "passive-interface-config.disable-interface.GigabitEthernet").ForEach(
+ res.Get(prefix + "").ForEach(
func(_, v gjson.Result) bool {
found := false
for ik := range keys {
@@ -787,18 +1103,18 @@ func (data *OSPF) updateFromBody(ctx context.Context, res gjson.Result) {
return true
},
)
- if value := r.Get("name"); value.Exists() && !data.PassiveInterfaceDisableGigabitEthernets[i].Name.IsNull() {
+ if value := r.Get(""); value.Exists() && !data.PassiveInterfaceDisableGigabitEthernets[i].Name.IsNull() {
data.PassiveInterfaceDisableGigabitEthernets[i].Name = types.StringValue(value.String())
} else {
data.PassiveInterfaceDisableGigabitEthernets[i].Name = types.StringNull()
}
}
for i := range data.PassiveInterfaceDisableTwoGigabitEthernets {
- keys := [...]string{"name"}
+ keys := [...]string{""}
keyValues := [...]string{data.PassiveInterfaceDisableTwoGigabitEthernets[i].Name.ValueString()}
var r gjson.Result
- res.Get(prefix + "passive-interface-config.disable-interface.TwoGigabitEthernet").ForEach(
+ res.Get(prefix + "").ForEach(
func(_, v gjson.Result) bool {
found := false
for ik := range keys {
@@ -816,18 +1132,18 @@ func (data *OSPF) updateFromBody(ctx context.Context, res gjson.Result) {
return true
},
)
- if value := r.Get("name"); value.Exists() && !data.PassiveInterfaceDisableTwoGigabitEthernets[i].Name.IsNull() {
+ if value := r.Get(""); value.Exists() && !data.PassiveInterfaceDisableTwoGigabitEthernets[i].Name.IsNull() {
data.PassiveInterfaceDisableTwoGigabitEthernets[i].Name = types.StringValue(value.String())
} else {
data.PassiveInterfaceDisableTwoGigabitEthernets[i].Name = types.StringNull()
}
}
for i := range data.PassiveInterfaceDisableFiveGigabitEthernets {
- keys := [...]string{"name"}
+ keys := [...]string{""}
keyValues := [...]string{data.PassiveInterfaceDisableFiveGigabitEthernets[i].Name.ValueString()}
var r gjson.Result
- res.Get(prefix + "passive-interface-config.disable-interface.FiveGigabitEthernet").ForEach(
+ res.Get(prefix + "").ForEach(
func(_, v gjson.Result) bool {
found := false
for ik := range keys {
@@ -845,18 +1161,18 @@ func (data *OSPF) updateFromBody(ctx context.Context, res gjson.Result) {
return true
},
)
- if value := r.Get("name"); value.Exists() && !data.PassiveInterfaceDisableFiveGigabitEthernets[i].Name.IsNull() {
+ if value := r.Get(""); value.Exists() && !data.PassiveInterfaceDisableFiveGigabitEthernets[i].Name.IsNull() {
data.PassiveInterfaceDisableFiveGigabitEthernets[i].Name = types.StringValue(value.String())
} else {
data.PassiveInterfaceDisableFiveGigabitEthernets[i].Name = types.StringNull()
}
}
for i := range data.PassiveInterfaceDisableTenGigabitEthernets {
- keys := [...]string{"name"}
+ keys := [...]string{""}
keyValues := [...]string{data.PassiveInterfaceDisableTenGigabitEthernets[i].Name.ValueString()}
var r gjson.Result
- res.Get(prefix + "passive-interface-config.disable-interface.TenGigabitEthernet").ForEach(
+ res.Get(prefix + "").ForEach(
func(_, v gjson.Result) bool {
found := false
for ik := range keys {
@@ -874,18 +1190,18 @@ func (data *OSPF) updateFromBody(ctx context.Context, res gjson.Result) {
return true
},
)
- if value := r.Get("name"); value.Exists() && !data.PassiveInterfaceDisableTenGigabitEthernets[i].Name.IsNull() {
+ if value := r.Get(""); value.Exists() && !data.PassiveInterfaceDisableTenGigabitEthernets[i].Name.IsNull() {
data.PassiveInterfaceDisableTenGigabitEthernets[i].Name = types.StringValue(value.String())
} else {
data.PassiveInterfaceDisableTenGigabitEthernets[i].Name = types.StringNull()
}
}
for i := range data.PassiveInterfaceDisableTwentyFiveGigabitEthernets {
- keys := [...]string{"name"}
+ keys := [...]string{""}
keyValues := [...]string{data.PassiveInterfaceDisableTwentyFiveGigabitEthernets[i].Name.ValueString()}
var r gjson.Result
- res.Get(prefix + "passive-interface-config.disable-interface.TwentyFiveGigabitE").ForEach(
+ res.Get(prefix + "").ForEach(
func(_, v gjson.Result) bool {
found := false
for ik := range keys {
@@ -903,18 +1219,18 @@ func (data *OSPF) updateFromBody(ctx context.Context, res gjson.Result) {
return true
},
)
- if value := r.Get("name"); value.Exists() && !data.PassiveInterfaceDisableTwentyFiveGigabitEthernets[i].Name.IsNull() {
+ if value := r.Get(""); value.Exists() && !data.PassiveInterfaceDisableTwentyFiveGigabitEthernets[i].Name.IsNull() {
data.PassiveInterfaceDisableTwentyFiveGigabitEthernets[i].Name = types.StringValue(value.String())
} else {
data.PassiveInterfaceDisableTwentyFiveGigabitEthernets[i].Name = types.StringNull()
}
}
for i := range data.PassiveInterfaceDisableFortyGigabitEthernets {
- keys := [...]string{"name"}
+ keys := [...]string{""}
keyValues := [...]string{data.PassiveInterfaceDisableFortyGigabitEthernets[i].Name.ValueString()}
var r gjson.Result
- res.Get(prefix + "passive-interface-config.disable-interface.FortyGigabitEthernet").ForEach(
+ res.Get(prefix + "").ForEach(
func(_, v gjson.Result) bool {
found := false
for ik := range keys {
@@ -932,18 +1248,18 @@ func (data *OSPF) updateFromBody(ctx context.Context, res gjson.Result) {
return true
},
)
- if value := r.Get("name"); value.Exists() && !data.PassiveInterfaceDisableFortyGigabitEthernets[i].Name.IsNull() {
+ if value := r.Get(""); value.Exists() && !data.PassiveInterfaceDisableFortyGigabitEthernets[i].Name.IsNull() {
data.PassiveInterfaceDisableFortyGigabitEthernets[i].Name = types.StringValue(value.String())
} else {
data.PassiveInterfaceDisableFortyGigabitEthernets[i].Name = types.StringNull()
}
}
for i := range data.PassiveInterfaceDisableHundredGigabitEthernets {
- keys := [...]string{"name"}
+ keys := [...]string{""}
keyValues := [...]string{data.PassiveInterfaceDisableHundredGigabitEthernets[i].Name.ValueString()}
var r gjson.Result
- res.Get(prefix + "passive-interface-config.disable-interface.HundredGigabitE").ForEach(
+ res.Get(prefix + "").ForEach(
func(_, v gjson.Result) bool {
found := false
for ik := range keys {
@@ -961,18 +1277,18 @@ func (data *OSPF) updateFromBody(ctx context.Context, res gjson.Result) {
return true
},
)
- if value := r.Get("name"); value.Exists() && !data.PassiveInterfaceDisableHundredGigabitEthernets[i].Name.IsNull() {
+ if value := r.Get(""); value.Exists() && !data.PassiveInterfaceDisableHundredGigabitEthernets[i].Name.IsNull() {
data.PassiveInterfaceDisableHundredGigabitEthernets[i].Name = types.StringValue(value.String())
} else {
data.PassiveInterfaceDisableHundredGigabitEthernets[i].Name = types.StringNull()
}
}
for i := range data.PassiveInterfaceDisableTwoHundredGigabitEthernets {
- keys := [...]string{"name"}
+ keys := [...]string{""}
keyValues := [...]string{data.PassiveInterfaceDisableTwoHundredGigabitEthernets[i].Name.ValueString()}
var r gjson.Result
- res.Get(prefix + "passive-interface-config.disable-interface.TwoHundredGigabitE").ForEach(
+ res.Get(prefix + "").ForEach(
func(_, v gjson.Result) bool {
found := false
for ik := range keys {
@@ -990,18 +1306,18 @@ func (data *OSPF) updateFromBody(ctx context.Context, res gjson.Result) {
return true
},
)
- if value := r.Get("name"); value.Exists() && !data.PassiveInterfaceDisableTwoHundredGigabitEthernets[i].Name.IsNull() {
+ if value := r.Get(""); value.Exists() && !data.PassiveInterfaceDisableTwoHundredGigabitEthernets[i].Name.IsNull() {
data.PassiveInterfaceDisableTwoHundredGigabitEthernets[i].Name = types.StringValue(value.String())
} else {
data.PassiveInterfaceDisableTwoHundredGigabitEthernets[i].Name = types.StringNull()
}
}
for i := range data.PassiveInterfaceDisableFourHundredGigabitEthernets {
- keys := [...]string{"name"}
+ keys := [...]string{""}
keyValues := [...]string{data.PassiveInterfaceDisableFourHundredGigabitEthernets[i].Name.ValueString()}
var r gjson.Result
- res.Get(prefix + "passive-interface-config.disable-interface.FourHundredGigabitE").ForEach(
+ res.Get(prefix + "").ForEach(
func(_, v gjson.Result) bool {
found := false
for ik := range keys {
@@ -1019,18 +1335,18 @@ func (data *OSPF) updateFromBody(ctx context.Context, res gjson.Result) {
return true
},
)
- if value := r.Get("name"); value.Exists() && !data.PassiveInterfaceDisableFourHundredGigabitEthernets[i].Name.IsNull() {
+ if value := r.Get(""); value.Exists() && !data.PassiveInterfaceDisableFourHundredGigabitEthernets[i].Name.IsNull() {
data.PassiveInterfaceDisableFourHundredGigabitEthernets[i].Name = types.StringValue(value.String())
} else {
data.PassiveInterfaceDisableFourHundredGigabitEthernets[i].Name = types.StringNull()
}
}
for i := range data.PassiveInterfaceDisableLoopbacks {
- keys := [...]string{"name"}
+ keys := [...]string{""}
keyValues := [...]string{data.PassiveInterfaceDisableLoopbacks[i].Name.ValueString()}
var r gjson.Result
- res.Get(prefix + "passive-interface-config.disable-interface.Loopback").ForEach(
+ res.Get(prefix + "").ForEach(
func(_, v gjson.Result) bool {
found := false
for ik := range keys {
@@ -1048,18 +1364,18 @@ func (data *OSPF) updateFromBody(ctx context.Context, res gjson.Result) {
return true
},
)
- if value := r.Get("name"); value.Exists() && !data.PassiveInterfaceDisableLoopbacks[i].Name.IsNull() {
+ if value := r.Get(""); value.Exists() && !data.PassiveInterfaceDisableLoopbacks[i].Name.IsNull() {
data.PassiveInterfaceDisableLoopbacks[i].Name = types.StringValue(value.String())
} else {
data.PassiveInterfaceDisableLoopbacks[i].Name = types.StringNull()
}
}
for i := range data.PassiveInterfaceDisableVlans {
- keys := [...]string{"name"}
+ keys := [...]string{""}
keyValues := [...]string{data.PassiveInterfaceDisableVlans[i].Name.ValueString()}
var r gjson.Result
- res.Get(prefix + "passive-interface-config.disable-interface.Vlan").ForEach(
+ res.Get(prefix + "").ForEach(
func(_, v gjson.Result) bool {
found := false
for ik := range keys {
@@ -1077,18 +1393,18 @@ func (data *OSPF) updateFromBody(ctx context.Context, res gjson.Result) {
return true
},
)
- if value := r.Get("name"); value.Exists() && !data.PassiveInterfaceDisableVlans[i].Name.IsNull() {
+ if value := r.Get(""); value.Exists() && !data.PassiveInterfaceDisableVlans[i].Name.IsNull() {
data.PassiveInterfaceDisableVlans[i].Name = types.StringValue(value.String())
} else {
data.PassiveInterfaceDisableVlans[i].Name = types.StringNull()
}
}
for i := range data.PassiveInterfaceDisableTunnels {
- keys := [...]string{"name"}
+ keys := [...]string{""}
keyValues := [...]string{data.PassiveInterfaceDisableTunnels[i].Name.ValueString()}
var r gjson.Result
- res.Get(prefix + "passive-interface-config.disable-interface.Tunnel").ForEach(
+ res.Get(prefix + "").ForEach(
func(_, v gjson.Result) bool {
found := false
for ik := range keys {
@@ -1106,18 +1422,18 @@ func (data *OSPF) updateFromBody(ctx context.Context, res gjson.Result) {
return true
},
)
- if value := r.Get("name"); value.Exists() && !data.PassiveInterfaceDisableTunnels[i].Name.IsNull() {
+ if value := r.Get(""); value.Exists() && !data.PassiveInterfaceDisableTunnels[i].Name.IsNull() {
data.PassiveInterfaceDisableTunnels[i].Name = types.StringValue(value.String())
} else {
data.PassiveInterfaceDisableTunnels[i].Name = types.StringNull()
}
}
for i := range data.PassiveInterfaceDisablePortChannels {
- keys := [...]string{"name"}
+ keys := [...]string{""}
keyValues := [...]string{data.PassiveInterfaceDisablePortChannels[i].Name.ValueString()}
var r gjson.Result
- res.Get(prefix + "passive-interface-config.disable-interface.Port-channel").ForEach(
+ res.Get(prefix + "").ForEach(
func(_, v gjson.Result) bool {
found := false
for ik := range keys {
@@ -1135,18 +1451,18 @@ func (data *OSPF) updateFromBody(ctx context.Context, res gjson.Result) {
return true
},
)
- if value := r.Get("name"); value.Exists() && !data.PassiveInterfaceDisablePortChannels[i].Name.IsNull() {
+ if value := r.Get(""); value.Exists() && !data.PassiveInterfaceDisablePortChannels[i].Name.IsNull() {
data.PassiveInterfaceDisablePortChannels[i].Name = types.StringValue(value.String())
} else {
data.PassiveInterfaceDisablePortChannels[i].Name = types.StringNull()
}
}
for i := range data.PassiveInterfaceDisablePortChannelSubinterfaces {
- keys := [...]string{"name"}
+ keys := [...]string{""}
keyValues := [...]string{data.PassiveInterfaceDisablePortChannelSubinterfaces[i].Name.ValueString()}
var r gjson.Result
- res.Get(prefix + "passive-interface-config.disable-interface.Port-channel-subinterface.Port-channel").ForEach(
+ res.Get(prefix + "").ForEach(
func(_, v gjson.Result) bool {
found := false
for ik := range keys {
@@ -1164,7 +1480,7 @@ func (data *OSPF) updateFromBody(ctx context.Context, res gjson.Result) {
return true
},
)
- if value := r.Get("name"); value.Exists() && !data.PassiveInterfaceDisablePortChannelSubinterfaces[i].Name.IsNull() {
+ if value := r.Get(""); value.Exists() && !data.PassiveInterfaceDisablePortChannelSubinterfaces[i].Name.IsNull() {
data.PassiveInterfaceDisablePortChannelSubinterfaces[i].Name = types.StringValue(value.String())
} else {
data.PassiveInterfaceDisablePortChannelSubinterfaces[i].Name = types.StringNull()
@@ -1174,309 +1490,1948 @@ func (data *OSPF) updateFromBody(ctx context.Context, res gjson.Result) {
// End of section. //template:end updateFromBody
-// Section below is generated&owned by "gen/generator.go". //template:begin fromBody
+// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBodyXML
-func (data *OSPF) fromBody(ctx context.Context, res gjson.Result) {
- prefix := helpers.LastElement(data.getPath()) + "."
- if res.Get(helpers.LastElement(data.getPath())).IsArray() {
- prefix += "0."
+func (data *OSPF) updateFromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/id"); value.Exists() && !data.ProcessId.IsNull() {
+ data.ProcessId = types.Int64Value(value.Int())
+ } else {
+ data.ProcessId = types.Int64Null()
}
- if value := res.Get(prefix + "bfd.all-interfaces"); value.Exists() {
- data.BfdAllInterfaces = types.BoolValue(true)
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/bfd/all-interfaces"); !data.BfdAllInterfaces.IsNull() {
+ if value.Exists() {
+ data.BfdAllInterfaces = types.BoolValue(true)
+ } else {
+ data.BfdAllInterfaces = types.BoolValue(false)
+ }
} else {
- data.BfdAllInterfaces = types.BoolValue(false)
+ data.BfdAllInterfaces = types.BoolNull()
}
- if value := res.Get(prefix + "default-information.originate"); value.Exists() {
- data.DefaultInformationOriginate = types.BoolValue(true)
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/default-information/originate"); !data.DefaultInformationOriginate.IsNull() {
+ if value.Exists() {
+ data.DefaultInformationOriginate = types.BoolValue(true)
+ } else {
+ data.DefaultInformationOriginate = types.BoolValue(false)
+ }
} else {
- data.DefaultInformationOriginate = types.BoolValue(false)
+ data.DefaultInformationOriginate = types.BoolNull()
}
- if value := res.Get(prefix + "default-information.originate.always"); value.Exists() {
- data.DefaultInformationOriginateAlways = types.BoolValue(true)
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/default-information/originate/always"); !data.DefaultInformationOriginateAlways.IsNull() {
+ if value.Exists() {
+ data.DefaultInformationOriginateAlways = types.BoolValue(true)
+ } else {
+ data.DefaultInformationOriginateAlways = types.BoolValue(false)
+ }
} else {
- data.DefaultInformationOriginateAlways = types.BoolValue(false)
+ data.DefaultInformationOriginateAlways = types.BoolNull()
}
- if value := res.Get(prefix + "default-metric"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/default-metric"); value.Exists() && !data.DefaultMetric.IsNull() {
data.DefaultMetric = types.Int64Value(value.Int())
+ } else {
+ data.DefaultMetric = types.Int64Null()
}
- if value := res.Get(prefix + "distance.distance"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/distance/distance"); value.Exists() && !data.Distance.IsNull() {
data.Distance = types.Int64Value(value.Int())
+ } else {
+ data.Distance = types.Int64Null()
}
- if value := res.Get(prefix + "domain-tag"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/domain-tag"); value.Exists() && !data.DomainTag.IsNull() {
data.DomainTag = types.Int64Value(value.Int())
+ } else {
+ data.DomainTag = types.Int64Null()
}
- if value := res.Get(prefix + "mpls.ldp.autoconfig"); value.Exists() {
- data.MplsLdpAutoconfig = types.BoolValue(true)
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/mpls/ldp/autoconfig"); !data.MplsLdpAutoconfig.IsNull() {
+ if value.Exists() {
+ data.MplsLdpAutoconfig = types.BoolValue(true)
+ } else {
+ data.MplsLdpAutoconfig = types.BoolValue(false)
+ }
} else {
- data.MplsLdpAutoconfig = types.BoolValue(false)
+ data.MplsLdpAutoconfig = types.BoolNull()
}
- if value := res.Get(prefix + "mpls.ldp.sync"); value.Exists() {
- data.MplsLdpSync = types.BoolValue(true)
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/mpls/ldp/sync"); !data.MplsLdpSync.IsNull() {
+ if value.Exists() {
+ data.MplsLdpSync = types.BoolValue(true)
+ } else {
+ data.MplsLdpSync = types.BoolValue(false)
+ }
} else {
- data.MplsLdpSync = types.BoolValue(false)
+ data.MplsLdpSync = types.BoolNull()
}
- if value := res.Get(prefix + "neighbor"); value.Exists() {
- data.Neighbors = make([]OSPFNeighbors, 0)
- value.ForEach(func(k, v gjson.Result) bool {
- item := OSPFNeighbors{}
- if cValue := v.Get("ip"); cValue.Exists() {
- item.Ip = types.StringValue(cValue.String())
- }
- if cValue := v.Get("priority"); cValue.Exists() {
- item.Priority = types.Int64Value(cValue.Int())
- }
- if cValue := v.Get("cost"); cValue.Exists() {
- item.Cost = types.Int64Value(cValue.Int())
- }
- data.Neighbors = append(data.Neighbors, item)
- return true
- })
+ for i := range data.Neighbors {
+ keys := [...]string{"ip"}
+ keyValues := [...]string{data.Neighbors[i].Ip.ValueString()}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/neighbor").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, "ip"); value.Exists() && !data.Neighbors[i].Ip.IsNull() {
+ data.Neighbors[i].Ip = types.StringValue(value.String())
+ } else {
+ data.Neighbors[i].Ip = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "priority"); value.Exists() && !data.Neighbors[i].Priority.IsNull() {
+ data.Neighbors[i].Priority = types.Int64Value(value.Int())
+ } else {
+ data.Neighbors[i].Priority = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(r, "cost"); value.Exists() && !data.Neighbors[i].Cost.IsNull() {
+ data.Neighbors[i].Cost = types.Int64Value(value.Int())
+ } else {
+ data.Neighbors[i].Cost = types.Int64Null()
+ }
}
- if value := res.Get(prefix + "network"); value.Exists() {
- data.Networks = make([]OSPFNetworks, 0)
- value.ForEach(func(k, v gjson.Result) bool {
- item := OSPFNetworks{}
- if cValue := v.Get("ip"); cValue.Exists() {
- item.Ip = types.StringValue(cValue.String())
- }
- if cValue := v.Get("wildcard"); cValue.Exists() {
- item.Wildcard = types.StringValue(cValue.String())
- }
- if cValue := v.Get("area"); cValue.Exists() {
- item.Area = types.StringValue(cValue.String())
- }
- data.Networks = append(data.Networks, item)
- return true
- })
+ for i := range data.Networks {
+ keys := [...]string{"ip"}
+ keyValues := [...]string{data.Networks[i].Ip.ValueString()}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/network").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, "ip"); value.Exists() && !data.Networks[i].Ip.IsNull() {
+ data.Networks[i].Ip = types.StringValue(value.String())
+ } else {
+ data.Networks[i].Ip = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "wildcard"); value.Exists() && !data.Networks[i].Wildcard.IsNull() {
+ data.Networks[i].Wildcard = types.StringValue(value.String())
+ } else {
+ data.Networks[i].Wildcard = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "area"); value.Exists() && !data.Networks[i].Area.IsNull() {
+ data.Networks[i].Area = types.StringValue(value.String())
+ } else {
+ data.Networks[i].Area = types.StringNull()
+ }
}
- if value := res.Get(prefix + "priority"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/priority"); value.Exists() && !data.Priority.IsNull() {
data.Priority = types.Int64Value(value.Int())
+ } else {
+ data.Priority = types.Int64Null()
}
- if value := res.Get(prefix + "router-id"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/router-id"); value.Exists() && !data.RouterId.IsNull() {
data.RouterId = types.StringValue(value.String())
+ } else {
+ data.RouterId = types.StringNull()
}
- if value := res.Get(prefix + "shutdown"); value.Exists() {
- data.Shutdown = types.BoolValue(value.Bool())
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/shutdown"); !data.Shutdown.IsNull() {
+ if value.Exists() {
+ data.Shutdown = types.BoolValue(value.Bool())
+ }
} else {
data.Shutdown = types.BoolNull()
}
- if value := res.Get(prefix + "summary-address"); value.Exists() {
- data.SummaryAddresses = make([]OSPFSummaryAddresses, 0)
- value.ForEach(func(k, v gjson.Result) bool {
- item := OSPFSummaryAddresses{}
- if cValue := v.Get("ip"); cValue.Exists() {
- item.Ip = types.StringValue(cValue.String())
- }
- if cValue := v.Get("mask"); cValue.Exists() {
- item.Mask = types.StringValue(cValue.String())
- }
- data.SummaryAddresses = append(data.SummaryAddresses, item)
- return true
- })
+ for i := range data.SummaryAddresses {
+ keys := [...]string{"ip"}
+ keyValues := [...]string{data.SummaryAddresses[i].Ip.ValueString()}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/summary-address").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, "ip"); value.Exists() && !data.SummaryAddresses[i].Ip.IsNull() {
+ data.SummaryAddresses[i].Ip = types.StringValue(value.String())
+ } else {
+ data.SummaryAddresses[i].Ip = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "mask"); value.Exists() && !data.SummaryAddresses[i].Mask.IsNull() {
+ data.SummaryAddresses[i].Mask = types.StringValue(value.String())
+ } else {
+ data.SummaryAddresses[i].Mask = types.StringNull()
+ }
}
- if value := res.Get(prefix + "area"); value.Exists() {
- data.Areas = make([]OSPFAreas, 0)
- value.ForEach(func(k, v gjson.Result) bool {
- item := OSPFAreas{}
- if cValue := v.Get("area-id"); cValue.Exists() {
- item.AreaId = types.StringValue(cValue.String())
- }
- if cValue := v.Get("authentication.message-digest"); cValue.Exists() {
- item.AuthenticationMessageDigest = types.BoolValue(true)
+ for i := range data.Areas {
+ keys := [...]string{"area-id"}
+ keyValues := [...]string{data.Areas[i].AreaId.ValueString()}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/area").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, "area-id"); value.Exists() && !data.Areas[i].AreaId.IsNull() {
+ data.Areas[i].AreaId = types.StringValue(value.String())
+ } else {
+ data.Areas[i].AreaId = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "authentication/message-digest"); !data.Areas[i].AuthenticationMessageDigest.IsNull() {
+ if value.Exists() {
+ data.Areas[i].AuthenticationMessageDigest = types.BoolValue(true)
} else {
- item.AuthenticationMessageDigest = types.BoolValue(false)
+ data.Areas[i].AuthenticationMessageDigest = types.BoolValue(false)
}
- if cValue := v.Get("nssa"); cValue.Exists() {
- item.Nssa = types.BoolValue(true)
+ } else {
+ data.Areas[i].AuthenticationMessageDigest = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "nssa"); !data.Areas[i].Nssa.IsNull() {
+ if value.Exists() {
+ data.Areas[i].Nssa = types.BoolValue(true)
} else {
- item.Nssa = types.BoolValue(false)
+ data.Areas[i].Nssa = types.BoolValue(false)
}
- if cValue := v.Get("nssa.nssa-options.default-information-originate"); cValue.Exists() {
- item.NssaDefaultInformationOriginate = types.BoolValue(true)
+ } else {
+ data.Areas[i].Nssa = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "nssa/nssa-options/default-information-originate"); !data.Areas[i].NssaDefaultInformationOriginate.IsNull() {
+ if value.Exists() {
+ data.Areas[i].NssaDefaultInformationOriginate = types.BoolValue(true)
} else {
- item.NssaDefaultInformationOriginate = types.BoolValue(false)
- }
- if cValue := v.Get("nssa.nssa-options.default-information-originate.metric"); cValue.Exists() {
- item.NssaDefaultInformationOriginateMetric = types.Int64Value(cValue.Int())
- }
- if cValue := v.Get("nssa.nssa-options.default-information-originate.metric-type"); cValue.Exists() {
- item.NssaDefaultInformationOriginateMetricType = types.Int64Value(cValue.Int())
+ data.Areas[i].NssaDefaultInformationOriginate = types.BoolValue(false)
}
- if cValue := v.Get("nssa.nssa-options.no-summary"); cValue.Exists() {
- item.NssaNoSummary = types.BoolValue(true)
+ } else {
+ data.Areas[i].NssaDefaultInformationOriginate = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "nssa/nssa-options/default-information-originate/metric"); value.Exists() && !data.Areas[i].NssaDefaultInformationOriginateMetric.IsNull() {
+ data.Areas[i].NssaDefaultInformationOriginateMetric = types.Int64Value(value.Int())
+ } else {
+ data.Areas[i].NssaDefaultInformationOriginateMetric = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(r, "nssa/nssa-options/default-information-originate/metric-type"); value.Exists() && !data.Areas[i].NssaDefaultInformationOriginateMetricType.IsNull() {
+ data.Areas[i].NssaDefaultInformationOriginateMetricType = types.Int64Value(value.Int())
+ } else {
+ data.Areas[i].NssaDefaultInformationOriginateMetricType = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(r, "nssa/nssa-options/no-summary"); !data.Areas[i].NssaNoSummary.IsNull() {
+ if value.Exists() {
+ data.Areas[i].NssaNoSummary = types.BoolValue(true)
} else {
- item.NssaNoSummary = types.BoolValue(false)
+ data.Areas[i].NssaNoSummary = types.BoolValue(false)
}
- if cValue := v.Get("nssa.nssa-options.no-redistribution"); cValue.Exists() {
- item.NssaNoRedistribution = types.BoolValue(true)
+ } else {
+ data.Areas[i].NssaNoSummary = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "nssa/nssa-options/no-redistribution"); !data.Areas[i].NssaNoRedistribution.IsNull() {
+ if value.Exists() {
+ data.Areas[i].NssaNoRedistribution = types.BoolValue(true)
} else {
- item.NssaNoRedistribution = types.BoolValue(false)
+ data.Areas[i].NssaNoRedistribution = types.BoolValue(false)
}
- data.Areas = append(data.Areas, item)
- return true
- })
+ } else {
+ data.Areas[i].NssaNoRedistribution = types.BoolNull()
+ }
}
- if value := res.Get(prefix + "auto-cost.reference-bandwidth"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/auto-cost/reference-bandwidth"); value.Exists() && !data.AutoCostReferenceBandwidth.IsNull() {
data.AutoCostReferenceBandwidth = types.Int64Value(value.Int())
+ } else {
+ data.AutoCostReferenceBandwidth = types.Int64Null()
}
- if value := res.Get(prefix + "passive-interface.default"); value.Exists() {
- data.PassiveInterfaceDefault = types.BoolValue(value.Bool())
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/passive-interface/default"); !data.PassiveInterfaceDefault.IsNull() {
+ if value.Exists() {
+ data.PassiveInterfaceDefault = types.BoolValue(value.Bool())
+ }
} else {
data.PassiveInterfaceDefault = types.BoolNull()
}
- if value := res.Get(prefix + "passive-interface.interface"); value.Exists() {
- data.PassiveInterface = helpers.GetStringList(value.Array())
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/passive-interface/interface"); value.Exists() && !data.PassiveInterface.IsNull() {
+ data.PassiveInterface = helpers.GetStringListXML(value.Array())
} else {
data.PassiveInterface = types.ListNull(types.StringType)
}
- if value := res.Get(prefix + "passive-interface-config.disable-interface.GigabitEthernet"); value.Exists() {
- data.PassiveInterfaceDisableGigabitEthernets = make([]OSPFPassiveInterfaceDisableGigabitEthernets, 0)
- value.ForEach(func(k, v gjson.Result) bool {
- item := OSPFPassiveInterfaceDisableGigabitEthernets{}
- if cValue := v.Get("name"); cValue.Exists() {
- item.Name = types.StringValue(cValue.String())
- }
- data.PassiveInterfaceDisableGigabitEthernets = append(data.PassiveInterfaceDisableGigabitEthernets, item)
- return true
- })
- }
- if value := res.Get(prefix + "passive-interface-config.disable-interface.TwoGigabitEthernet"); value.Exists() {
- data.PassiveInterfaceDisableTwoGigabitEthernets = make([]OSPFPassiveInterfaceDisableTwoGigabitEthernets, 0)
- value.ForEach(func(k, v gjson.Result) bool {
- item := OSPFPassiveInterfaceDisableTwoGigabitEthernets{}
- if cValue := v.Get("name"); cValue.Exists() {
- item.Name = types.StringValue(cValue.String())
- }
- data.PassiveInterfaceDisableTwoGigabitEthernets = append(data.PassiveInterfaceDisableTwoGigabitEthernets, item)
- return true
- })
- }
- if value := res.Get(prefix + "passive-interface-config.disable-interface.FiveGigabitEthernet"); value.Exists() {
+ for i := range data.PassiveInterfaceDisableGigabitEthernets {
+ keys := [...]string{""}
+ keyValues := [...]string{data.PassiveInterfaceDisableGigabitEthernets[i].Name.ValueString()}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, ""); value.Exists() && !data.PassiveInterfaceDisableGigabitEthernets[i].Name.IsNull() {
+ data.PassiveInterfaceDisableGigabitEthernets[i].Name = types.StringValue(value.String())
+ } else {
+ data.PassiveInterfaceDisableGigabitEthernets[i].Name = types.StringNull()
+ }
+ }
+ for i := range data.PassiveInterfaceDisableTwoGigabitEthernets {
+ keys := [...]string{""}
+ keyValues := [...]string{data.PassiveInterfaceDisableTwoGigabitEthernets[i].Name.ValueString()}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, ""); value.Exists() && !data.PassiveInterfaceDisableTwoGigabitEthernets[i].Name.IsNull() {
+ data.PassiveInterfaceDisableTwoGigabitEthernets[i].Name = types.StringValue(value.String())
+ } else {
+ data.PassiveInterfaceDisableTwoGigabitEthernets[i].Name = types.StringNull()
+ }
+ }
+ for i := range data.PassiveInterfaceDisableFiveGigabitEthernets {
+ keys := [...]string{""}
+ keyValues := [...]string{data.PassiveInterfaceDisableFiveGigabitEthernets[i].Name.ValueString()}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, ""); value.Exists() && !data.PassiveInterfaceDisableFiveGigabitEthernets[i].Name.IsNull() {
+ data.PassiveInterfaceDisableFiveGigabitEthernets[i].Name = types.StringValue(value.String())
+ } else {
+ data.PassiveInterfaceDisableFiveGigabitEthernets[i].Name = types.StringNull()
+ }
+ }
+ for i := range data.PassiveInterfaceDisableTenGigabitEthernets {
+ keys := [...]string{""}
+ keyValues := [...]string{data.PassiveInterfaceDisableTenGigabitEthernets[i].Name.ValueString()}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, ""); value.Exists() && !data.PassiveInterfaceDisableTenGigabitEthernets[i].Name.IsNull() {
+ data.PassiveInterfaceDisableTenGigabitEthernets[i].Name = types.StringValue(value.String())
+ } else {
+ data.PassiveInterfaceDisableTenGigabitEthernets[i].Name = types.StringNull()
+ }
+ }
+ for i := range data.PassiveInterfaceDisableTwentyFiveGigabitEthernets {
+ keys := [...]string{""}
+ keyValues := [...]string{data.PassiveInterfaceDisableTwentyFiveGigabitEthernets[i].Name.ValueString()}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, ""); value.Exists() && !data.PassiveInterfaceDisableTwentyFiveGigabitEthernets[i].Name.IsNull() {
+ data.PassiveInterfaceDisableTwentyFiveGigabitEthernets[i].Name = types.StringValue(value.String())
+ } else {
+ data.PassiveInterfaceDisableTwentyFiveGigabitEthernets[i].Name = types.StringNull()
+ }
+ }
+ for i := range data.PassiveInterfaceDisableFortyGigabitEthernets {
+ keys := [...]string{""}
+ keyValues := [...]string{data.PassiveInterfaceDisableFortyGigabitEthernets[i].Name.ValueString()}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, ""); value.Exists() && !data.PassiveInterfaceDisableFortyGigabitEthernets[i].Name.IsNull() {
+ data.PassiveInterfaceDisableFortyGigabitEthernets[i].Name = types.StringValue(value.String())
+ } else {
+ data.PassiveInterfaceDisableFortyGigabitEthernets[i].Name = types.StringNull()
+ }
+ }
+ for i := range data.PassiveInterfaceDisableHundredGigabitEthernets {
+ keys := [...]string{""}
+ keyValues := [...]string{data.PassiveInterfaceDisableHundredGigabitEthernets[i].Name.ValueString()}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, ""); value.Exists() && !data.PassiveInterfaceDisableHundredGigabitEthernets[i].Name.IsNull() {
+ data.PassiveInterfaceDisableHundredGigabitEthernets[i].Name = types.StringValue(value.String())
+ } else {
+ data.PassiveInterfaceDisableHundredGigabitEthernets[i].Name = types.StringNull()
+ }
+ }
+ for i := range data.PassiveInterfaceDisableTwoHundredGigabitEthernets {
+ keys := [...]string{""}
+ keyValues := [...]string{data.PassiveInterfaceDisableTwoHundredGigabitEthernets[i].Name.ValueString()}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, ""); value.Exists() && !data.PassiveInterfaceDisableTwoHundredGigabitEthernets[i].Name.IsNull() {
+ data.PassiveInterfaceDisableTwoHundredGigabitEthernets[i].Name = types.StringValue(value.String())
+ } else {
+ data.PassiveInterfaceDisableTwoHundredGigabitEthernets[i].Name = types.StringNull()
+ }
+ }
+ for i := range data.PassiveInterfaceDisableFourHundredGigabitEthernets {
+ keys := [...]string{""}
+ keyValues := [...]string{data.PassiveInterfaceDisableFourHundredGigabitEthernets[i].Name.ValueString()}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, ""); value.Exists() && !data.PassiveInterfaceDisableFourHundredGigabitEthernets[i].Name.IsNull() {
+ data.PassiveInterfaceDisableFourHundredGigabitEthernets[i].Name = types.StringValue(value.String())
+ } else {
+ data.PassiveInterfaceDisableFourHundredGigabitEthernets[i].Name = types.StringNull()
+ }
+ }
+ for i := range data.PassiveInterfaceDisableLoopbacks {
+ keys := [...]string{""}
+ keyValues := [...]string{data.PassiveInterfaceDisableLoopbacks[i].Name.ValueString()}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, ""); value.Exists() && !data.PassiveInterfaceDisableLoopbacks[i].Name.IsNull() {
+ data.PassiveInterfaceDisableLoopbacks[i].Name = types.StringValue(value.String())
+ } else {
+ data.PassiveInterfaceDisableLoopbacks[i].Name = types.StringNull()
+ }
+ }
+ for i := range data.PassiveInterfaceDisableVlans {
+ keys := [...]string{""}
+ keyValues := [...]string{data.PassiveInterfaceDisableVlans[i].Name.ValueString()}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, ""); value.Exists() && !data.PassiveInterfaceDisableVlans[i].Name.IsNull() {
+ data.PassiveInterfaceDisableVlans[i].Name = types.StringValue(value.String())
+ } else {
+ data.PassiveInterfaceDisableVlans[i].Name = types.StringNull()
+ }
+ }
+ for i := range data.PassiveInterfaceDisableTunnels {
+ keys := [...]string{""}
+ keyValues := [...]string{data.PassiveInterfaceDisableTunnels[i].Name.ValueString()}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, ""); value.Exists() && !data.PassiveInterfaceDisableTunnels[i].Name.IsNull() {
+ data.PassiveInterfaceDisableTunnels[i].Name = types.StringValue(value.String())
+ } else {
+ data.PassiveInterfaceDisableTunnels[i].Name = types.StringNull()
+ }
+ }
+ for i := range data.PassiveInterfaceDisablePortChannels {
+ keys := [...]string{""}
+ keyValues := [...]string{data.PassiveInterfaceDisablePortChannels[i].Name.ValueString()}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, ""); value.Exists() && !data.PassiveInterfaceDisablePortChannels[i].Name.IsNull() {
+ data.PassiveInterfaceDisablePortChannels[i].Name = types.StringValue(value.String())
+ } else {
+ data.PassiveInterfaceDisablePortChannels[i].Name = types.StringNull()
+ }
+ }
+ for i := range data.PassiveInterfaceDisablePortChannelSubinterfaces {
+ keys := [...]string{""}
+ keyValues := [...]string{data.PassiveInterfaceDisablePortChannelSubinterfaces[i].Name.ValueString()}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, ""); value.Exists() && !data.PassiveInterfaceDisablePortChannelSubinterfaces[i].Name.IsNull() {
+ data.PassiveInterfaceDisablePortChannelSubinterfaces[i].Name = types.StringValue(value.String())
+ } else {
+ data.PassiveInterfaceDisablePortChannelSubinterfaces[i].Name = types.StringNull()
+ }
+ }
+}
+
+// End of section. //template:end updateFromBodyXML
+
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBody
+
+func (data *OSPF) fromBody(ctx context.Context, res gjson.Result) {
+ prefix := helpers.LastElement(data.getPath()) + "."
+ if res.Get(helpers.LastElement(data.getPath())).IsArray() {
+ prefix += "0."
+ }
+ if value := res.Get(prefix + "bfd.all-interfaces"); value.Exists() {
+ data.BfdAllInterfaces = types.BoolValue(true)
+ } else {
+ data.BfdAllInterfaces = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "default-information.originate"); value.Exists() {
+ data.DefaultInformationOriginate = types.BoolValue(true)
+ } else {
+ data.DefaultInformationOriginate = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "default-information.originate.always"); value.Exists() {
+ data.DefaultInformationOriginateAlways = types.BoolValue(true)
+ } else {
+ data.DefaultInformationOriginateAlways = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "default-metric"); value.Exists() {
+ data.DefaultMetric = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "distance.distance"); value.Exists() {
+ data.Distance = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "domain-tag"); value.Exists() {
+ data.DomainTag = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "mpls.ldp.autoconfig"); value.Exists() {
+ data.MplsLdpAutoconfig = types.BoolValue(true)
+ } else {
+ data.MplsLdpAutoconfig = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "mpls.ldp.sync"); value.Exists() {
+ data.MplsLdpSync = types.BoolValue(true)
+ } else {
+ data.MplsLdpSync = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "neighbor"); value.Exists() {
+ data.Neighbors = make([]OSPFNeighbors, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := OSPFNeighbors{}
+ if cValue := v.Get("ip"); cValue.Exists() {
+ item.Ip = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("priority"); cValue.Exists() {
+ item.Priority = types.Int64Value(cValue.Int())
+ }
+ if cValue := v.Get("cost"); cValue.Exists() {
+ item.Cost = types.Int64Value(cValue.Int())
+ }
+ data.Neighbors = append(data.Neighbors, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + "network"); value.Exists() {
+ data.Networks = make([]OSPFNetworks, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := OSPFNetworks{}
+ if cValue := v.Get("ip"); cValue.Exists() {
+ item.Ip = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("wildcard"); cValue.Exists() {
+ item.Wildcard = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("area"); cValue.Exists() {
+ item.Area = types.StringValue(cValue.String())
+ }
+ data.Networks = append(data.Networks, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + "priority"); value.Exists() {
+ data.Priority = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "router-id"); value.Exists() {
+ data.RouterId = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "shutdown"); value.Exists() {
+ data.Shutdown = types.BoolValue(value.Bool())
+ } else {
+ data.Shutdown = types.BoolNull()
+ }
+ if value := res.Get(prefix + "summary-address"); value.Exists() {
+ data.SummaryAddresses = make([]OSPFSummaryAddresses, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := OSPFSummaryAddresses{}
+ if cValue := v.Get("ip"); cValue.Exists() {
+ item.Ip = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("mask"); cValue.Exists() {
+ item.Mask = types.StringValue(cValue.String())
+ }
+ data.SummaryAddresses = append(data.SummaryAddresses, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + "area"); value.Exists() {
+ data.Areas = make([]OSPFAreas, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := OSPFAreas{}
+ if cValue := v.Get("area-id"); cValue.Exists() {
+ item.AreaId = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("authentication.message-digest"); cValue.Exists() {
+ item.AuthenticationMessageDigest = types.BoolValue(true)
+ } else {
+ item.AuthenticationMessageDigest = types.BoolValue(false)
+ }
+ if cValue := v.Get("nssa"); cValue.Exists() {
+ item.Nssa = types.BoolValue(true)
+ } else {
+ item.Nssa = types.BoolValue(false)
+ }
+ if cValue := v.Get("nssa.nssa-options.default-information-originate"); cValue.Exists() {
+ item.NssaDefaultInformationOriginate = types.BoolValue(true)
+ } else {
+ item.NssaDefaultInformationOriginate = types.BoolValue(false)
+ }
+ if cValue := v.Get("nssa.nssa-options.default-information-originate.metric"); cValue.Exists() {
+ item.NssaDefaultInformationOriginateMetric = types.Int64Value(cValue.Int())
+ }
+ if cValue := v.Get("nssa.nssa-options.default-information-originate.metric-type"); cValue.Exists() {
+ item.NssaDefaultInformationOriginateMetricType = types.Int64Value(cValue.Int())
+ }
+ if cValue := v.Get("nssa.nssa-options.no-summary"); cValue.Exists() {
+ item.NssaNoSummary = types.BoolValue(true)
+ } else {
+ item.NssaNoSummary = types.BoolValue(false)
+ }
+ if cValue := v.Get("nssa.nssa-options.no-redistribution"); cValue.Exists() {
+ item.NssaNoRedistribution = types.BoolValue(true)
+ } else {
+ item.NssaNoRedistribution = types.BoolValue(false)
+ }
+ data.Areas = append(data.Areas, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + "auto-cost.reference-bandwidth"); value.Exists() {
+ data.AutoCostReferenceBandwidth = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "passive-interface.default"); value.Exists() {
+ data.PassiveInterfaceDefault = types.BoolValue(value.Bool())
+ } else {
+ data.PassiveInterfaceDefault = types.BoolNull()
+ }
+ if value := res.Get(prefix + "passive-interface.interface"); value.Exists() {
+ data.PassiveInterface = helpers.GetStringList(value.Array())
+ } else {
+ data.PassiveInterface = types.ListNull(types.StringType)
+ }
+ if value := res.Get(prefix + ""); value.Exists() {
+ data.PassiveInterfaceDisableGigabitEthernets = make([]OSPFPassiveInterfaceDisableGigabitEthernets, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := OSPFPassiveInterfaceDisableGigabitEthernets{}
+ if cValue := v.Get(""); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ data.PassiveInterfaceDisableGigabitEthernets = append(data.PassiveInterfaceDisableGigabitEthernets, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + ""); value.Exists() {
+ data.PassiveInterfaceDisableTwoGigabitEthernets = make([]OSPFPassiveInterfaceDisableTwoGigabitEthernets, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := OSPFPassiveInterfaceDisableTwoGigabitEthernets{}
+ if cValue := v.Get(""); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ data.PassiveInterfaceDisableTwoGigabitEthernets = append(data.PassiveInterfaceDisableTwoGigabitEthernets, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + ""); value.Exists() {
+ data.PassiveInterfaceDisableFiveGigabitEthernets = make([]OSPFPassiveInterfaceDisableFiveGigabitEthernets, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := OSPFPassiveInterfaceDisableFiveGigabitEthernets{}
+ if cValue := v.Get(""); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ data.PassiveInterfaceDisableFiveGigabitEthernets = append(data.PassiveInterfaceDisableFiveGigabitEthernets, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + ""); value.Exists() {
+ data.PassiveInterfaceDisableTenGigabitEthernets = make([]OSPFPassiveInterfaceDisableTenGigabitEthernets, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := OSPFPassiveInterfaceDisableTenGigabitEthernets{}
+ if cValue := v.Get(""); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ data.PassiveInterfaceDisableTenGigabitEthernets = append(data.PassiveInterfaceDisableTenGigabitEthernets, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + ""); value.Exists() {
+ data.PassiveInterfaceDisableTwentyFiveGigabitEthernets = make([]OSPFPassiveInterfaceDisableTwentyFiveGigabitEthernets, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := OSPFPassiveInterfaceDisableTwentyFiveGigabitEthernets{}
+ if cValue := v.Get(""); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ data.PassiveInterfaceDisableTwentyFiveGigabitEthernets = append(data.PassiveInterfaceDisableTwentyFiveGigabitEthernets, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + ""); value.Exists() {
+ data.PassiveInterfaceDisableFortyGigabitEthernets = make([]OSPFPassiveInterfaceDisableFortyGigabitEthernets, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := OSPFPassiveInterfaceDisableFortyGigabitEthernets{}
+ if cValue := v.Get(""); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ data.PassiveInterfaceDisableFortyGigabitEthernets = append(data.PassiveInterfaceDisableFortyGigabitEthernets, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + ""); value.Exists() {
+ data.PassiveInterfaceDisableHundredGigabitEthernets = make([]OSPFPassiveInterfaceDisableHundredGigabitEthernets, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := OSPFPassiveInterfaceDisableHundredGigabitEthernets{}
+ if cValue := v.Get(""); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ data.PassiveInterfaceDisableHundredGigabitEthernets = append(data.PassiveInterfaceDisableHundredGigabitEthernets, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + ""); value.Exists() {
+ data.PassiveInterfaceDisableTwoHundredGigabitEthernets = make([]OSPFPassiveInterfaceDisableTwoHundredGigabitEthernets, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := OSPFPassiveInterfaceDisableTwoHundredGigabitEthernets{}
+ if cValue := v.Get(""); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ data.PassiveInterfaceDisableTwoHundredGigabitEthernets = append(data.PassiveInterfaceDisableTwoHundredGigabitEthernets, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + ""); value.Exists() {
+ data.PassiveInterfaceDisableFourHundredGigabitEthernets = make([]OSPFPassiveInterfaceDisableFourHundredGigabitEthernets, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := OSPFPassiveInterfaceDisableFourHundredGigabitEthernets{}
+ if cValue := v.Get(""); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ data.PassiveInterfaceDisableFourHundredGigabitEthernets = append(data.PassiveInterfaceDisableFourHundredGigabitEthernets, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + ""); value.Exists() {
+ data.PassiveInterfaceDisableLoopbacks = make([]OSPFPassiveInterfaceDisableLoopbacks, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := OSPFPassiveInterfaceDisableLoopbacks{}
+ if cValue := v.Get(""); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ data.PassiveInterfaceDisableLoopbacks = append(data.PassiveInterfaceDisableLoopbacks, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + ""); value.Exists() {
+ data.PassiveInterfaceDisableVlans = make([]OSPFPassiveInterfaceDisableVlans, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := OSPFPassiveInterfaceDisableVlans{}
+ if cValue := v.Get(""); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ data.PassiveInterfaceDisableVlans = append(data.PassiveInterfaceDisableVlans, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + ""); value.Exists() {
+ data.PassiveInterfaceDisableTunnels = make([]OSPFPassiveInterfaceDisableTunnels, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := OSPFPassiveInterfaceDisableTunnels{}
+ if cValue := v.Get(""); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ data.PassiveInterfaceDisableTunnels = append(data.PassiveInterfaceDisableTunnels, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + ""); value.Exists() {
+ data.PassiveInterfaceDisablePortChannels = make([]OSPFPassiveInterfaceDisablePortChannels, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := OSPFPassiveInterfaceDisablePortChannels{}
+ if cValue := v.Get(""); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ data.PassiveInterfaceDisablePortChannels = append(data.PassiveInterfaceDisablePortChannels, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + ""); value.Exists() {
+ data.PassiveInterfaceDisablePortChannelSubinterfaces = make([]OSPFPassiveInterfaceDisablePortChannelSubinterfaces, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := OSPFPassiveInterfaceDisablePortChannelSubinterfaces{}
+ if cValue := v.Get(""); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ data.PassiveInterfaceDisablePortChannelSubinterfaces = append(data.PassiveInterfaceDisablePortChannelSubinterfaces, item)
+ return true
+ })
+ }
+}
+
+// End of section. //template:end fromBody
+
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyData
+
+func (data *OSPFData) fromBody(ctx context.Context, res gjson.Result) {
+ prefix := helpers.LastElement(data.getPath()) + "."
+ if res.Get(helpers.LastElement(data.getPath())).IsArray() {
+ prefix += "0."
+ }
+ if value := res.Get(prefix + "bfd.all-interfaces"); value.Exists() {
+ data.BfdAllInterfaces = types.BoolValue(true)
+ } else {
+ data.BfdAllInterfaces = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "default-information.originate"); value.Exists() {
+ data.DefaultInformationOriginate = types.BoolValue(true)
+ } else {
+ data.DefaultInformationOriginate = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "default-information.originate.always"); value.Exists() {
+ data.DefaultInformationOriginateAlways = types.BoolValue(true)
+ } else {
+ data.DefaultInformationOriginateAlways = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "default-metric"); value.Exists() {
+ data.DefaultMetric = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "distance.distance"); value.Exists() {
+ data.Distance = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "domain-tag"); value.Exists() {
+ data.DomainTag = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "mpls.ldp.autoconfig"); value.Exists() {
+ data.MplsLdpAutoconfig = types.BoolValue(true)
+ } else {
+ data.MplsLdpAutoconfig = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "mpls.ldp.sync"); value.Exists() {
+ data.MplsLdpSync = types.BoolValue(true)
+ } else {
+ data.MplsLdpSync = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "neighbor"); value.Exists() {
+ data.Neighbors = make([]OSPFNeighbors, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := OSPFNeighbors{}
+ if cValue := v.Get("ip"); cValue.Exists() {
+ item.Ip = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("priority"); cValue.Exists() {
+ item.Priority = types.Int64Value(cValue.Int())
+ }
+ if cValue := v.Get("cost"); cValue.Exists() {
+ item.Cost = types.Int64Value(cValue.Int())
+ }
+ data.Neighbors = append(data.Neighbors, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + "network"); value.Exists() {
+ data.Networks = make([]OSPFNetworks, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := OSPFNetworks{}
+ if cValue := v.Get("ip"); cValue.Exists() {
+ item.Ip = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("wildcard"); cValue.Exists() {
+ item.Wildcard = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("area"); cValue.Exists() {
+ item.Area = types.StringValue(cValue.String())
+ }
+ data.Networks = append(data.Networks, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + "priority"); value.Exists() {
+ data.Priority = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "router-id"); value.Exists() {
+ data.RouterId = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "shutdown"); value.Exists() {
+ data.Shutdown = types.BoolValue(value.Bool())
+ } else {
+ data.Shutdown = types.BoolNull()
+ }
+ if value := res.Get(prefix + "summary-address"); value.Exists() {
+ data.SummaryAddresses = make([]OSPFSummaryAddresses, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := OSPFSummaryAddresses{}
+ if cValue := v.Get("ip"); cValue.Exists() {
+ item.Ip = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("mask"); cValue.Exists() {
+ item.Mask = types.StringValue(cValue.String())
+ }
+ data.SummaryAddresses = append(data.SummaryAddresses, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + "area"); value.Exists() {
+ data.Areas = make([]OSPFAreas, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := OSPFAreas{}
+ if cValue := v.Get("area-id"); cValue.Exists() {
+ item.AreaId = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("authentication.message-digest"); cValue.Exists() {
+ item.AuthenticationMessageDigest = types.BoolValue(true)
+ } else {
+ item.AuthenticationMessageDigest = types.BoolValue(false)
+ }
+ if cValue := v.Get("nssa"); cValue.Exists() {
+ item.Nssa = types.BoolValue(true)
+ } else {
+ item.Nssa = types.BoolValue(false)
+ }
+ if cValue := v.Get("nssa.nssa-options.default-information-originate"); cValue.Exists() {
+ item.NssaDefaultInformationOriginate = types.BoolValue(true)
+ } else {
+ item.NssaDefaultInformationOriginate = types.BoolValue(false)
+ }
+ if cValue := v.Get("nssa.nssa-options.default-information-originate.metric"); cValue.Exists() {
+ item.NssaDefaultInformationOriginateMetric = types.Int64Value(cValue.Int())
+ }
+ if cValue := v.Get("nssa.nssa-options.default-information-originate.metric-type"); cValue.Exists() {
+ item.NssaDefaultInformationOriginateMetricType = types.Int64Value(cValue.Int())
+ }
+ if cValue := v.Get("nssa.nssa-options.no-summary"); cValue.Exists() {
+ item.NssaNoSummary = types.BoolValue(true)
+ } else {
+ item.NssaNoSummary = types.BoolValue(false)
+ }
+ if cValue := v.Get("nssa.nssa-options.no-redistribution"); cValue.Exists() {
+ item.NssaNoRedistribution = types.BoolValue(true)
+ } else {
+ item.NssaNoRedistribution = types.BoolValue(false)
+ }
+ data.Areas = append(data.Areas, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + "auto-cost.reference-bandwidth"); value.Exists() {
+ data.AutoCostReferenceBandwidth = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "passive-interface.default"); value.Exists() {
+ data.PassiveInterfaceDefault = types.BoolValue(value.Bool())
+ } else {
+ data.PassiveInterfaceDefault = types.BoolNull()
+ }
+ if value := res.Get(prefix + "passive-interface.interface"); value.Exists() {
+ data.PassiveInterface = helpers.GetStringList(value.Array())
+ } else {
+ data.PassiveInterface = types.ListNull(types.StringType)
+ }
+ if value := res.Get(prefix + ""); value.Exists() {
+ data.PassiveInterfaceDisableGigabitEthernets = make([]OSPFPassiveInterfaceDisableGigabitEthernets, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := OSPFPassiveInterfaceDisableGigabitEthernets{}
+ if cValue := v.Get(""); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ data.PassiveInterfaceDisableGigabitEthernets = append(data.PassiveInterfaceDisableGigabitEthernets, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + ""); value.Exists() {
+ data.PassiveInterfaceDisableTwoGigabitEthernets = make([]OSPFPassiveInterfaceDisableTwoGigabitEthernets, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := OSPFPassiveInterfaceDisableTwoGigabitEthernets{}
+ if cValue := v.Get(""); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ data.PassiveInterfaceDisableTwoGigabitEthernets = append(data.PassiveInterfaceDisableTwoGigabitEthernets, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + ""); value.Exists() {
+ data.PassiveInterfaceDisableFiveGigabitEthernets = make([]OSPFPassiveInterfaceDisableFiveGigabitEthernets, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := OSPFPassiveInterfaceDisableFiveGigabitEthernets{}
+ if cValue := v.Get(""); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ data.PassiveInterfaceDisableFiveGigabitEthernets = append(data.PassiveInterfaceDisableFiveGigabitEthernets, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + ""); value.Exists() {
+ data.PassiveInterfaceDisableTenGigabitEthernets = make([]OSPFPassiveInterfaceDisableTenGigabitEthernets, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := OSPFPassiveInterfaceDisableTenGigabitEthernets{}
+ if cValue := v.Get(""); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ data.PassiveInterfaceDisableTenGigabitEthernets = append(data.PassiveInterfaceDisableTenGigabitEthernets, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + ""); value.Exists() {
+ data.PassiveInterfaceDisableTwentyFiveGigabitEthernets = make([]OSPFPassiveInterfaceDisableTwentyFiveGigabitEthernets, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := OSPFPassiveInterfaceDisableTwentyFiveGigabitEthernets{}
+ if cValue := v.Get(""); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ data.PassiveInterfaceDisableTwentyFiveGigabitEthernets = append(data.PassiveInterfaceDisableTwentyFiveGigabitEthernets, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + ""); value.Exists() {
+ data.PassiveInterfaceDisableFortyGigabitEthernets = make([]OSPFPassiveInterfaceDisableFortyGigabitEthernets, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := OSPFPassiveInterfaceDisableFortyGigabitEthernets{}
+ if cValue := v.Get(""); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ data.PassiveInterfaceDisableFortyGigabitEthernets = append(data.PassiveInterfaceDisableFortyGigabitEthernets, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + ""); value.Exists() {
+ data.PassiveInterfaceDisableHundredGigabitEthernets = make([]OSPFPassiveInterfaceDisableHundredGigabitEthernets, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := OSPFPassiveInterfaceDisableHundredGigabitEthernets{}
+ if cValue := v.Get(""); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ data.PassiveInterfaceDisableHundredGigabitEthernets = append(data.PassiveInterfaceDisableHundredGigabitEthernets, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + ""); value.Exists() {
+ data.PassiveInterfaceDisableTwoHundredGigabitEthernets = make([]OSPFPassiveInterfaceDisableTwoHundredGigabitEthernets, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := OSPFPassiveInterfaceDisableTwoHundredGigabitEthernets{}
+ if cValue := v.Get(""); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ data.PassiveInterfaceDisableTwoHundredGigabitEthernets = append(data.PassiveInterfaceDisableTwoHundredGigabitEthernets, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + ""); value.Exists() {
+ data.PassiveInterfaceDisableFourHundredGigabitEthernets = make([]OSPFPassiveInterfaceDisableFourHundredGigabitEthernets, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := OSPFPassiveInterfaceDisableFourHundredGigabitEthernets{}
+ if cValue := v.Get(""); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ data.PassiveInterfaceDisableFourHundredGigabitEthernets = append(data.PassiveInterfaceDisableFourHundredGigabitEthernets, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + ""); value.Exists() {
+ data.PassiveInterfaceDisableLoopbacks = make([]OSPFPassiveInterfaceDisableLoopbacks, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := OSPFPassiveInterfaceDisableLoopbacks{}
+ if cValue := v.Get(""); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ data.PassiveInterfaceDisableLoopbacks = append(data.PassiveInterfaceDisableLoopbacks, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + ""); value.Exists() {
+ data.PassiveInterfaceDisableVlans = make([]OSPFPassiveInterfaceDisableVlans, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := OSPFPassiveInterfaceDisableVlans{}
+ if cValue := v.Get(""); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ data.PassiveInterfaceDisableVlans = append(data.PassiveInterfaceDisableVlans, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + ""); value.Exists() {
+ data.PassiveInterfaceDisableTunnels = make([]OSPFPassiveInterfaceDisableTunnels, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := OSPFPassiveInterfaceDisableTunnels{}
+ if cValue := v.Get(""); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ data.PassiveInterfaceDisableTunnels = append(data.PassiveInterfaceDisableTunnels, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + ""); value.Exists() {
+ data.PassiveInterfaceDisablePortChannels = make([]OSPFPassiveInterfaceDisablePortChannels, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := OSPFPassiveInterfaceDisablePortChannels{}
+ if cValue := v.Get(""); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ data.PassiveInterfaceDisablePortChannels = append(data.PassiveInterfaceDisablePortChannels, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + ""); value.Exists() {
+ data.PassiveInterfaceDisablePortChannelSubinterfaces = make([]OSPFPassiveInterfaceDisablePortChannelSubinterfaces, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := OSPFPassiveInterfaceDisablePortChannelSubinterfaces{}
+ if cValue := v.Get(""); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ data.PassiveInterfaceDisablePortChannelSubinterfaces = append(data.PassiveInterfaceDisablePortChannelSubinterfaces, item)
+ return true
+ })
+ }
+}
+
+// End of section. //template:end fromBodyData
+
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyXML
+
+func (data *OSPF) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/bfd/all-interfaces"); value.Exists() {
+ data.BfdAllInterfaces = types.BoolValue(true)
+ } else {
+ data.BfdAllInterfaces = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/default-information/originate"); value.Exists() {
+ data.DefaultInformationOriginate = types.BoolValue(true)
+ } else {
+ data.DefaultInformationOriginate = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/default-information/originate/always"); value.Exists() {
+ data.DefaultInformationOriginateAlways = types.BoolValue(true)
+ } else {
+ data.DefaultInformationOriginateAlways = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/default-metric"); value.Exists() {
+ data.DefaultMetric = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/distance/distance"); value.Exists() {
+ data.Distance = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/domain-tag"); value.Exists() {
+ data.DomainTag = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/mpls/ldp/autoconfig"); value.Exists() {
+ data.MplsLdpAutoconfig = types.BoolValue(true)
+ } else {
+ data.MplsLdpAutoconfig = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/mpls/ldp/sync"); value.Exists() {
+ data.MplsLdpSync = types.BoolValue(true)
+ } else {
+ data.MplsLdpSync = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/neighbor"); value.Exists() {
+ data.Neighbors = make([]OSPFNeighbors, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := OSPFNeighbors{}
+ if cValue := helpers.GetFromXPath(v, "ip"); cValue.Exists() {
+ item.Ip = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "priority"); cValue.Exists() {
+ item.Priority = types.Int64Value(cValue.Int())
+ }
+ if cValue := helpers.GetFromXPath(v, "cost"); cValue.Exists() {
+ item.Cost = types.Int64Value(cValue.Int())
+ }
+ data.Neighbors = append(data.Neighbors, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/network"); value.Exists() {
+ data.Networks = make([]OSPFNetworks, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := OSPFNetworks{}
+ if cValue := helpers.GetFromXPath(v, "ip"); cValue.Exists() {
+ item.Ip = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "wildcard"); cValue.Exists() {
+ item.Wildcard = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "area"); cValue.Exists() {
+ item.Area = types.StringValue(cValue.String())
+ }
+ data.Networks = append(data.Networks, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/priority"); value.Exists() {
+ data.Priority = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/router-id"); value.Exists() {
+ data.RouterId = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/shutdown"); value.Exists() {
+ data.Shutdown = types.BoolValue(value.Bool())
+ } else {
+ data.Shutdown = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/summary-address"); value.Exists() {
+ data.SummaryAddresses = make([]OSPFSummaryAddresses, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := OSPFSummaryAddresses{}
+ if cValue := helpers.GetFromXPath(v, "ip"); cValue.Exists() {
+ item.Ip = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "mask"); cValue.Exists() {
+ item.Mask = types.StringValue(cValue.String())
+ }
+ data.SummaryAddresses = append(data.SummaryAddresses, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/area"); value.Exists() {
+ data.Areas = make([]OSPFAreas, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := OSPFAreas{}
+ if cValue := helpers.GetFromXPath(v, "area-id"); cValue.Exists() {
+ item.AreaId = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "authentication/message-digest"); cValue.Exists() {
+ item.AuthenticationMessageDigest = types.BoolValue(true)
+ } else {
+ item.AuthenticationMessageDigest = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "nssa"); cValue.Exists() {
+ item.Nssa = types.BoolValue(true)
+ } else {
+ item.Nssa = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "nssa/nssa-options/default-information-originate"); cValue.Exists() {
+ item.NssaDefaultInformationOriginate = types.BoolValue(true)
+ } else {
+ item.NssaDefaultInformationOriginate = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "nssa/nssa-options/default-information-originate/metric"); cValue.Exists() {
+ item.NssaDefaultInformationOriginateMetric = types.Int64Value(cValue.Int())
+ }
+ if cValue := helpers.GetFromXPath(v, "nssa/nssa-options/default-information-originate/metric-type"); cValue.Exists() {
+ item.NssaDefaultInformationOriginateMetricType = types.Int64Value(cValue.Int())
+ }
+ if cValue := helpers.GetFromXPath(v, "nssa/nssa-options/no-summary"); cValue.Exists() {
+ item.NssaNoSummary = types.BoolValue(true)
+ } else {
+ item.NssaNoSummary = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "nssa/nssa-options/no-redistribution"); cValue.Exists() {
+ item.NssaNoRedistribution = types.BoolValue(true)
+ } else {
+ item.NssaNoRedistribution = types.BoolValue(false)
+ }
+ data.Areas = append(data.Areas, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/auto-cost/reference-bandwidth"); value.Exists() {
+ data.AutoCostReferenceBandwidth = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/passive-interface/default"); value.Exists() {
+ data.PassiveInterfaceDefault = types.BoolValue(value.Bool())
+ } else {
+ data.PassiveInterfaceDefault = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/passive-interface/interface"); value.Exists() {
+ data.PassiveInterface = helpers.GetStringListXML(value.Array())
+ } else {
+ data.PassiveInterface = types.ListNull(types.StringType)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/"); value.Exists() {
+ data.PassiveInterfaceDisableGigabitEthernets = make([]OSPFPassiveInterfaceDisableGigabitEthernets, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := OSPFPassiveInterfaceDisableGigabitEthernets{}
+ if cValue := helpers.GetFromXPath(v, ""); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ data.PassiveInterfaceDisableGigabitEthernets = append(data.PassiveInterfaceDisableGigabitEthernets, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/"); value.Exists() {
+ data.PassiveInterfaceDisableTwoGigabitEthernets = make([]OSPFPassiveInterfaceDisableTwoGigabitEthernets, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := OSPFPassiveInterfaceDisableTwoGigabitEthernets{}
+ if cValue := helpers.GetFromXPath(v, ""); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ data.PassiveInterfaceDisableTwoGigabitEthernets = append(data.PassiveInterfaceDisableTwoGigabitEthernets, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/"); value.Exists() {
data.PassiveInterfaceDisableFiveGigabitEthernets = make([]OSPFPassiveInterfaceDisableFiveGigabitEthernets, 0)
- value.ForEach(func(k, v gjson.Result) bool {
+ value.ForEach(func(_ int, v xmldot.Result) bool {
item := OSPFPassiveInterfaceDisableFiveGigabitEthernets{}
- if cValue := v.Get("name"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, ""); cValue.Exists() {
item.Name = types.StringValue(cValue.String())
}
data.PassiveInterfaceDisableFiveGigabitEthernets = append(data.PassiveInterfaceDisableFiveGigabitEthernets, item)
return true
})
}
- if value := res.Get(prefix + "passive-interface-config.disable-interface.TenGigabitEthernet"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/"); value.Exists() {
data.PassiveInterfaceDisableTenGigabitEthernets = make([]OSPFPassiveInterfaceDisableTenGigabitEthernets, 0)
- value.ForEach(func(k, v gjson.Result) bool {
+ value.ForEach(func(_ int, v xmldot.Result) bool {
item := OSPFPassiveInterfaceDisableTenGigabitEthernets{}
- if cValue := v.Get("name"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, ""); cValue.Exists() {
item.Name = types.StringValue(cValue.String())
}
data.PassiveInterfaceDisableTenGigabitEthernets = append(data.PassiveInterfaceDisableTenGigabitEthernets, item)
return true
})
}
- if value := res.Get(prefix + "passive-interface-config.disable-interface.TwentyFiveGigabitE"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/"); value.Exists() {
data.PassiveInterfaceDisableTwentyFiveGigabitEthernets = make([]OSPFPassiveInterfaceDisableTwentyFiveGigabitEthernets, 0)
- value.ForEach(func(k, v gjson.Result) bool {
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := OSPFPassiveInterfaceDisableTwentyFiveGigabitEthernets{}
+ if cValue := helpers.GetFromXPath(v, ""); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ data.PassiveInterfaceDisableTwentyFiveGigabitEthernets = append(data.PassiveInterfaceDisableTwentyFiveGigabitEthernets, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/"); value.Exists() {
+ data.PassiveInterfaceDisableFortyGigabitEthernets = make([]OSPFPassiveInterfaceDisableFortyGigabitEthernets, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := OSPFPassiveInterfaceDisableFortyGigabitEthernets{}
+ if cValue := helpers.GetFromXPath(v, ""); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ data.PassiveInterfaceDisableFortyGigabitEthernets = append(data.PassiveInterfaceDisableFortyGigabitEthernets, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/"); value.Exists() {
+ data.PassiveInterfaceDisableHundredGigabitEthernets = make([]OSPFPassiveInterfaceDisableHundredGigabitEthernets, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := OSPFPassiveInterfaceDisableHundredGigabitEthernets{}
+ if cValue := helpers.GetFromXPath(v, ""); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ data.PassiveInterfaceDisableHundredGigabitEthernets = append(data.PassiveInterfaceDisableHundredGigabitEthernets, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/"); value.Exists() {
+ data.PassiveInterfaceDisableTwoHundredGigabitEthernets = make([]OSPFPassiveInterfaceDisableTwoHundredGigabitEthernets, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := OSPFPassiveInterfaceDisableTwoHundredGigabitEthernets{}
+ if cValue := helpers.GetFromXPath(v, ""); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ data.PassiveInterfaceDisableTwoHundredGigabitEthernets = append(data.PassiveInterfaceDisableTwoHundredGigabitEthernets, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/"); value.Exists() {
+ data.PassiveInterfaceDisableFourHundredGigabitEthernets = make([]OSPFPassiveInterfaceDisableFourHundredGigabitEthernets, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := OSPFPassiveInterfaceDisableFourHundredGigabitEthernets{}
+ if cValue := helpers.GetFromXPath(v, ""); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ data.PassiveInterfaceDisableFourHundredGigabitEthernets = append(data.PassiveInterfaceDisableFourHundredGigabitEthernets, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/"); value.Exists() {
+ data.PassiveInterfaceDisableLoopbacks = make([]OSPFPassiveInterfaceDisableLoopbacks, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := OSPFPassiveInterfaceDisableLoopbacks{}
+ if cValue := helpers.GetFromXPath(v, ""); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ data.PassiveInterfaceDisableLoopbacks = append(data.PassiveInterfaceDisableLoopbacks, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/"); value.Exists() {
+ data.PassiveInterfaceDisableVlans = make([]OSPFPassiveInterfaceDisableVlans, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := OSPFPassiveInterfaceDisableVlans{}
+ if cValue := helpers.GetFromXPath(v, ""); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ data.PassiveInterfaceDisableVlans = append(data.PassiveInterfaceDisableVlans, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/"); value.Exists() {
+ data.PassiveInterfaceDisableTunnels = make([]OSPFPassiveInterfaceDisableTunnels, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := OSPFPassiveInterfaceDisableTunnels{}
+ if cValue := helpers.GetFromXPath(v, ""); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ data.PassiveInterfaceDisableTunnels = append(data.PassiveInterfaceDisableTunnels, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/"); value.Exists() {
+ data.PassiveInterfaceDisablePortChannels = make([]OSPFPassiveInterfaceDisablePortChannels, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := OSPFPassiveInterfaceDisablePortChannels{}
+ if cValue := helpers.GetFromXPath(v, ""); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ data.PassiveInterfaceDisablePortChannels = append(data.PassiveInterfaceDisablePortChannels, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/"); value.Exists() {
+ data.PassiveInterfaceDisablePortChannelSubinterfaces = make([]OSPFPassiveInterfaceDisablePortChannelSubinterfaces, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := OSPFPassiveInterfaceDisablePortChannelSubinterfaces{}
+ if cValue := helpers.GetFromXPath(v, ""); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ data.PassiveInterfaceDisablePortChannelSubinterfaces = append(data.PassiveInterfaceDisablePortChannelSubinterfaces, item)
+ return true
+ })
+ }
+}
+
+// End of section. //template:end fromBodyXML
+
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyDataXML
+
+func (data *OSPFData) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/bfd/all-interfaces"); value.Exists() {
+ data.BfdAllInterfaces = types.BoolValue(true)
+ } else {
+ data.BfdAllInterfaces = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/default-information/originate"); value.Exists() {
+ data.DefaultInformationOriginate = types.BoolValue(true)
+ } else {
+ data.DefaultInformationOriginate = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/default-information/originate/always"); value.Exists() {
+ data.DefaultInformationOriginateAlways = types.BoolValue(true)
+ } else {
+ data.DefaultInformationOriginateAlways = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/default-metric"); value.Exists() {
+ data.DefaultMetric = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/distance/distance"); value.Exists() {
+ data.Distance = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/domain-tag"); value.Exists() {
+ data.DomainTag = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/mpls/ldp/autoconfig"); value.Exists() {
+ data.MplsLdpAutoconfig = types.BoolValue(true)
+ } else {
+ data.MplsLdpAutoconfig = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/mpls/ldp/sync"); value.Exists() {
+ data.MplsLdpSync = types.BoolValue(true)
+ } else {
+ data.MplsLdpSync = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/neighbor"); value.Exists() {
+ data.Neighbors = make([]OSPFNeighbors, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := OSPFNeighbors{}
+ if cValue := helpers.GetFromXPath(v, "ip"); cValue.Exists() {
+ item.Ip = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "priority"); cValue.Exists() {
+ item.Priority = types.Int64Value(cValue.Int())
+ }
+ if cValue := helpers.GetFromXPath(v, "cost"); cValue.Exists() {
+ item.Cost = types.Int64Value(cValue.Int())
+ }
+ data.Neighbors = append(data.Neighbors, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/network"); value.Exists() {
+ data.Networks = make([]OSPFNetworks, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := OSPFNetworks{}
+ if cValue := helpers.GetFromXPath(v, "ip"); cValue.Exists() {
+ item.Ip = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "wildcard"); cValue.Exists() {
+ item.Wildcard = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "area"); cValue.Exists() {
+ item.Area = types.StringValue(cValue.String())
+ }
+ data.Networks = append(data.Networks, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/priority"); value.Exists() {
+ data.Priority = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/router-id"); value.Exists() {
+ data.RouterId = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/shutdown"); value.Exists() {
+ data.Shutdown = types.BoolValue(value.Bool())
+ } else {
+ data.Shutdown = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/summary-address"); value.Exists() {
+ data.SummaryAddresses = make([]OSPFSummaryAddresses, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := OSPFSummaryAddresses{}
+ if cValue := helpers.GetFromXPath(v, "ip"); cValue.Exists() {
+ item.Ip = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "mask"); cValue.Exists() {
+ item.Mask = types.StringValue(cValue.String())
+ }
+ data.SummaryAddresses = append(data.SummaryAddresses, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/area"); value.Exists() {
+ data.Areas = make([]OSPFAreas, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := OSPFAreas{}
+ if cValue := helpers.GetFromXPath(v, "area-id"); cValue.Exists() {
+ item.AreaId = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "authentication/message-digest"); cValue.Exists() {
+ item.AuthenticationMessageDigest = types.BoolValue(true)
+ } else {
+ item.AuthenticationMessageDigest = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "nssa"); cValue.Exists() {
+ item.Nssa = types.BoolValue(true)
+ } else {
+ item.Nssa = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "nssa/nssa-options/default-information-originate"); cValue.Exists() {
+ item.NssaDefaultInformationOriginate = types.BoolValue(true)
+ } else {
+ item.NssaDefaultInformationOriginate = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "nssa/nssa-options/default-information-originate/metric"); cValue.Exists() {
+ item.NssaDefaultInformationOriginateMetric = types.Int64Value(cValue.Int())
+ }
+ if cValue := helpers.GetFromXPath(v, "nssa/nssa-options/default-information-originate/metric-type"); cValue.Exists() {
+ item.NssaDefaultInformationOriginateMetricType = types.Int64Value(cValue.Int())
+ }
+ if cValue := helpers.GetFromXPath(v, "nssa/nssa-options/no-summary"); cValue.Exists() {
+ item.NssaNoSummary = types.BoolValue(true)
+ } else {
+ item.NssaNoSummary = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "nssa/nssa-options/no-redistribution"); cValue.Exists() {
+ item.NssaNoRedistribution = types.BoolValue(true)
+ } else {
+ item.NssaNoRedistribution = types.BoolValue(false)
+ }
+ data.Areas = append(data.Areas, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/auto-cost/reference-bandwidth"); value.Exists() {
+ data.AutoCostReferenceBandwidth = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/passive-interface/default"); value.Exists() {
+ data.PassiveInterfaceDefault = types.BoolValue(value.Bool())
+ } else {
+ data.PassiveInterfaceDefault = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/passive-interface/interface"); value.Exists() {
+ data.PassiveInterface = helpers.GetStringListXML(value.Array())
+ } else {
+ data.PassiveInterface = types.ListNull(types.StringType)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/"); value.Exists() {
+ data.PassiveInterfaceDisableGigabitEthernets = make([]OSPFPassiveInterfaceDisableGigabitEthernets, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := OSPFPassiveInterfaceDisableGigabitEthernets{}
+ if cValue := helpers.GetFromXPath(v, ""); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ data.PassiveInterfaceDisableGigabitEthernets = append(data.PassiveInterfaceDisableGigabitEthernets, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/"); value.Exists() {
+ data.PassiveInterfaceDisableTwoGigabitEthernets = make([]OSPFPassiveInterfaceDisableTwoGigabitEthernets, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := OSPFPassiveInterfaceDisableTwoGigabitEthernets{}
+ if cValue := helpers.GetFromXPath(v, ""); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ data.PassiveInterfaceDisableTwoGigabitEthernets = append(data.PassiveInterfaceDisableTwoGigabitEthernets, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/"); value.Exists() {
+ data.PassiveInterfaceDisableFiveGigabitEthernets = make([]OSPFPassiveInterfaceDisableFiveGigabitEthernets, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := OSPFPassiveInterfaceDisableFiveGigabitEthernets{}
+ if cValue := helpers.GetFromXPath(v, ""); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ data.PassiveInterfaceDisableFiveGigabitEthernets = append(data.PassiveInterfaceDisableFiveGigabitEthernets, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/"); value.Exists() {
+ data.PassiveInterfaceDisableTenGigabitEthernets = make([]OSPFPassiveInterfaceDisableTenGigabitEthernets, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := OSPFPassiveInterfaceDisableTenGigabitEthernets{}
+ if cValue := helpers.GetFromXPath(v, ""); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ data.PassiveInterfaceDisableTenGigabitEthernets = append(data.PassiveInterfaceDisableTenGigabitEthernets, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/"); value.Exists() {
+ data.PassiveInterfaceDisableTwentyFiveGigabitEthernets = make([]OSPFPassiveInterfaceDisableTwentyFiveGigabitEthernets, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
item := OSPFPassiveInterfaceDisableTwentyFiveGigabitEthernets{}
- if cValue := v.Get("name"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, ""); cValue.Exists() {
item.Name = types.StringValue(cValue.String())
}
data.PassiveInterfaceDisableTwentyFiveGigabitEthernets = append(data.PassiveInterfaceDisableTwentyFiveGigabitEthernets, item)
return true
})
}
- if value := res.Get(prefix + "passive-interface-config.disable-interface.FortyGigabitEthernet"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/"); value.Exists() {
data.PassiveInterfaceDisableFortyGigabitEthernets = make([]OSPFPassiveInterfaceDisableFortyGigabitEthernets, 0)
- value.ForEach(func(k, v gjson.Result) bool {
+ value.ForEach(func(_ int, v xmldot.Result) bool {
item := OSPFPassiveInterfaceDisableFortyGigabitEthernets{}
- if cValue := v.Get("name"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, ""); cValue.Exists() {
item.Name = types.StringValue(cValue.String())
}
data.PassiveInterfaceDisableFortyGigabitEthernets = append(data.PassiveInterfaceDisableFortyGigabitEthernets, item)
return true
})
}
- if value := res.Get(prefix + "passive-interface-config.disable-interface.HundredGigabitE"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/"); value.Exists() {
data.PassiveInterfaceDisableHundredGigabitEthernets = make([]OSPFPassiveInterfaceDisableHundredGigabitEthernets, 0)
- value.ForEach(func(k, v gjson.Result) bool {
+ value.ForEach(func(_ int, v xmldot.Result) bool {
item := OSPFPassiveInterfaceDisableHundredGigabitEthernets{}
- if cValue := v.Get("name"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, ""); cValue.Exists() {
item.Name = types.StringValue(cValue.String())
}
data.PassiveInterfaceDisableHundredGigabitEthernets = append(data.PassiveInterfaceDisableHundredGigabitEthernets, item)
return true
})
}
- if value := res.Get(prefix + "passive-interface-config.disable-interface.TwoHundredGigabitE"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/"); value.Exists() {
data.PassiveInterfaceDisableTwoHundredGigabitEthernets = make([]OSPFPassiveInterfaceDisableTwoHundredGigabitEthernets, 0)
- value.ForEach(func(k, v gjson.Result) bool {
+ value.ForEach(func(_ int, v xmldot.Result) bool {
item := OSPFPassiveInterfaceDisableTwoHundredGigabitEthernets{}
- if cValue := v.Get("name"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, ""); cValue.Exists() {
item.Name = types.StringValue(cValue.String())
}
data.PassiveInterfaceDisableTwoHundredGigabitEthernets = append(data.PassiveInterfaceDisableTwoHundredGigabitEthernets, item)
return true
})
}
- if value := res.Get(prefix + "passive-interface-config.disable-interface.FourHundredGigabitE"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/"); value.Exists() {
data.PassiveInterfaceDisableFourHundredGigabitEthernets = make([]OSPFPassiveInterfaceDisableFourHundredGigabitEthernets, 0)
- value.ForEach(func(k, v gjson.Result) bool {
+ value.ForEach(func(_ int, v xmldot.Result) bool {
item := OSPFPassiveInterfaceDisableFourHundredGigabitEthernets{}
- if cValue := v.Get("name"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, ""); cValue.Exists() {
item.Name = types.StringValue(cValue.String())
}
data.PassiveInterfaceDisableFourHundredGigabitEthernets = append(data.PassiveInterfaceDisableFourHundredGigabitEthernets, item)
return true
})
}
- if value := res.Get(prefix + "passive-interface-config.disable-interface.Loopback"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/"); value.Exists() {
data.PassiveInterfaceDisableLoopbacks = make([]OSPFPassiveInterfaceDisableLoopbacks, 0)
- value.ForEach(func(k, v gjson.Result) bool {
+ value.ForEach(func(_ int, v xmldot.Result) bool {
item := OSPFPassiveInterfaceDisableLoopbacks{}
- if cValue := v.Get("name"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, ""); cValue.Exists() {
item.Name = types.StringValue(cValue.String())
}
data.PassiveInterfaceDisableLoopbacks = append(data.PassiveInterfaceDisableLoopbacks, item)
return true
})
}
- if value := res.Get(prefix + "passive-interface-config.disable-interface.Vlan"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/"); value.Exists() {
data.PassiveInterfaceDisableVlans = make([]OSPFPassiveInterfaceDisableVlans, 0)
- value.ForEach(func(k, v gjson.Result) bool {
+ value.ForEach(func(_ int, v xmldot.Result) bool {
item := OSPFPassiveInterfaceDisableVlans{}
- if cValue := v.Get("name"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, ""); cValue.Exists() {
item.Name = types.StringValue(cValue.String())
}
data.PassiveInterfaceDisableVlans = append(data.PassiveInterfaceDisableVlans, item)
return true
})
}
- if value := res.Get(prefix + "passive-interface-config.disable-interface.Tunnel"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/"); value.Exists() {
data.PassiveInterfaceDisableTunnels = make([]OSPFPassiveInterfaceDisableTunnels, 0)
- value.ForEach(func(k, v gjson.Result) bool {
+ value.ForEach(func(_ int, v xmldot.Result) bool {
item := OSPFPassiveInterfaceDisableTunnels{}
- if cValue := v.Get("name"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, ""); cValue.Exists() {
item.Name = types.StringValue(cValue.String())
}
data.PassiveInterfaceDisableTunnels = append(data.PassiveInterfaceDisableTunnels, item)
return true
})
}
- if value := res.Get(prefix + "passive-interface-config.disable-interface.Port-channel"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/"); value.Exists() {
data.PassiveInterfaceDisablePortChannels = make([]OSPFPassiveInterfaceDisablePortChannels, 0)
- value.ForEach(func(k, v gjson.Result) bool {
+ value.ForEach(func(_ int, v xmldot.Result) bool {
item := OSPFPassiveInterfaceDisablePortChannels{}
- if cValue := v.Get("name"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, ""); cValue.Exists() {
item.Name = types.StringValue(cValue.String())
}
data.PassiveInterfaceDisablePortChannels = append(data.PassiveInterfaceDisablePortChannels, item)
return true
})
}
- if value := res.Get(prefix + "passive-interface-config.disable-interface.Port-channel-subinterface.Port-channel"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/"); value.Exists() {
data.PassiveInterfaceDisablePortChannelSubinterfaces = make([]OSPFPassiveInterfaceDisablePortChannelSubinterfaces, 0)
- value.ForEach(func(k, v gjson.Result) bool {
+ value.ForEach(func(_ int, v xmldot.Result) bool {
item := OSPFPassiveInterfaceDisablePortChannelSubinterfaces{}
- if cValue := v.Get("name"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, ""); cValue.Exists() {
item.Name = types.StringValue(cValue.String())
}
data.PassiveInterfaceDisablePortChannelSubinterfaces = append(data.PassiveInterfaceDisablePortChannelSubinterfaces, item)
@@ -1485,330 +3440,602 @@ func (data *OSPF) fromBody(ctx context.Context, res gjson.Result) {
}
}
-// End of section. //template:end fromBody
+// End of section. //template:end fromBodyDataXML
-// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyData
+// Section below is generated&owned by "gen/generator.go". //template:begin getDeletedItems
-func (data *OSPFData) fromBody(ctx context.Context, res gjson.Result) {
- prefix := helpers.LastElement(data.getPath()) + "."
- if res.Get(helpers.LastElement(data.getPath())).IsArray() {
- prefix += "0."
- }
- if value := res.Get(prefix + "bfd.all-interfaces"); value.Exists() {
- data.BfdAllInterfaces = types.BoolValue(true)
- } else {
- data.BfdAllInterfaces = types.BoolValue(false)
- }
- if value := res.Get(prefix + "default-information.originate"); value.Exists() {
- data.DefaultInformationOriginate = types.BoolValue(true)
- } else {
- data.DefaultInformationOriginate = types.BoolValue(false)
+func (data *OSPF) getDeletedItems(ctx context.Context, state OSPF) []string {
+ deletedItems := make([]string, 0)
+ for i := range state.PassiveInterfaceDisablePortChannelSubinterfaces {
+ stateKeyValues := [...]string{state.PassiveInterfaceDisablePortChannelSubinterfaces[i].Name.ValueString()}
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.PassiveInterfaceDisablePortChannelSubinterfaces[i].Name.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.PassiveInterfaceDisablePortChannelSubinterfaces {
+ found = true
+ if state.PassiveInterfaceDisablePortChannelSubinterfaces[i].Name.ValueString() != data.PassiveInterfaceDisablePortChannelSubinterfaces[j].Name.ValueString() {
+ found = false
+ }
+ if found {
+ break
+ }
+ }
+ if !found {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/passive-interface-config/disable-interface/Port-channel-subinterface/Port-channel=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
}
- if value := res.Get(prefix + "default-information.originate.always"); value.Exists() {
- data.DefaultInformationOriginateAlways = types.BoolValue(true)
- } else {
- data.DefaultInformationOriginateAlways = types.BoolValue(false)
+ for i := range state.PassiveInterfaceDisablePortChannels {
+ stateKeyValues := [...]string{state.PassiveInterfaceDisablePortChannels[i].Name.ValueString()}
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.PassiveInterfaceDisablePortChannels[i].Name.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.PassiveInterfaceDisablePortChannels {
+ found = true
+ if state.PassiveInterfaceDisablePortChannels[i].Name.ValueString() != data.PassiveInterfaceDisablePortChannels[j].Name.ValueString() {
+ found = false
+ }
+ if found {
+ break
+ }
+ }
+ if !found {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/passive-interface-config/disable-interface/Port-channel=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
}
- if value := res.Get(prefix + "default-metric"); value.Exists() {
- data.DefaultMetric = types.Int64Value(value.Int())
+ for i := range state.PassiveInterfaceDisableTunnels {
+ stateKeyValues := [...]string{state.PassiveInterfaceDisableTunnels[i].Name.ValueString()}
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.PassiveInterfaceDisableTunnels[i].Name.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.PassiveInterfaceDisableTunnels {
+ found = true
+ if state.PassiveInterfaceDisableTunnels[i].Name.ValueString() != data.PassiveInterfaceDisableTunnels[j].Name.ValueString() {
+ found = false
+ }
+ if found {
+ break
+ }
+ }
+ if !found {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/passive-interface-config/disable-interface/Tunnel=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
}
- if value := res.Get(prefix + "distance.distance"); value.Exists() {
- data.Distance = types.Int64Value(value.Int())
+ for i := range state.PassiveInterfaceDisableVlans {
+ stateKeyValues := [...]string{state.PassiveInterfaceDisableVlans[i].Name.ValueString()}
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.PassiveInterfaceDisableVlans[i].Name.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.PassiveInterfaceDisableVlans {
+ found = true
+ if state.PassiveInterfaceDisableVlans[i].Name.ValueString() != data.PassiveInterfaceDisableVlans[j].Name.ValueString() {
+ found = false
+ }
+ if found {
+ break
+ }
+ }
+ if !found {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/passive-interface-config/disable-interface/Vlan=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
}
- if value := res.Get(prefix + "domain-tag"); value.Exists() {
- data.DomainTag = types.Int64Value(value.Int())
+ for i := range state.PassiveInterfaceDisableLoopbacks {
+ stateKeyValues := [...]string{state.PassiveInterfaceDisableLoopbacks[i].Name.ValueString()}
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.PassiveInterfaceDisableLoopbacks[i].Name.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.PassiveInterfaceDisableLoopbacks {
+ found = true
+ if state.PassiveInterfaceDisableLoopbacks[i].Name.ValueString() != data.PassiveInterfaceDisableLoopbacks[j].Name.ValueString() {
+ found = false
+ }
+ if found {
+ break
+ }
+ }
+ if !found {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/passive-interface-config/disable-interface/Loopback=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
}
- if value := res.Get(prefix + "mpls.ldp.autoconfig"); value.Exists() {
- data.MplsLdpAutoconfig = types.BoolValue(true)
- } else {
- data.MplsLdpAutoconfig = types.BoolValue(false)
+ for i := range state.PassiveInterfaceDisableFourHundredGigabitEthernets {
+ stateKeyValues := [...]string{state.PassiveInterfaceDisableFourHundredGigabitEthernets[i].Name.ValueString()}
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.PassiveInterfaceDisableFourHundredGigabitEthernets[i].Name.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.PassiveInterfaceDisableFourHundredGigabitEthernets {
+ found = true
+ if state.PassiveInterfaceDisableFourHundredGigabitEthernets[i].Name.ValueString() != data.PassiveInterfaceDisableFourHundredGigabitEthernets[j].Name.ValueString() {
+ found = false
+ }
+ if found {
+ break
+ }
+ }
+ if !found {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/passive-interface-config/disable-interface/FourHundredGigabitE=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
}
- if value := res.Get(prefix + "mpls.ldp.sync"); value.Exists() {
- data.MplsLdpSync = types.BoolValue(true)
- } else {
- data.MplsLdpSync = types.BoolValue(false)
+ for i := range state.PassiveInterfaceDisableTwoHundredGigabitEthernets {
+ stateKeyValues := [...]string{state.PassiveInterfaceDisableTwoHundredGigabitEthernets[i].Name.ValueString()}
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.PassiveInterfaceDisableTwoHundredGigabitEthernets[i].Name.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.PassiveInterfaceDisableTwoHundredGigabitEthernets {
+ found = true
+ if state.PassiveInterfaceDisableTwoHundredGigabitEthernets[i].Name.ValueString() != data.PassiveInterfaceDisableTwoHundredGigabitEthernets[j].Name.ValueString() {
+ found = false
+ }
+ if found {
+ break
+ }
+ }
+ if !found {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/passive-interface-config/disable-interface/TwoHundredGigabitE=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
}
- if value := res.Get(prefix + "neighbor"); value.Exists() {
- data.Neighbors = make([]OSPFNeighbors, 0)
- value.ForEach(func(k, v gjson.Result) bool {
- item := OSPFNeighbors{}
- if cValue := v.Get("ip"); cValue.Exists() {
- item.Ip = types.StringValue(cValue.String())
+ for i := range state.PassiveInterfaceDisableHundredGigabitEthernets {
+ stateKeyValues := [...]string{state.PassiveInterfaceDisableHundredGigabitEthernets[i].Name.ValueString()}
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.PassiveInterfaceDisableHundredGigabitEthernets[i].Name.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.PassiveInterfaceDisableHundredGigabitEthernets {
+ found = true
+ if state.PassiveInterfaceDisableHundredGigabitEthernets[i].Name.ValueString() != data.PassiveInterfaceDisableHundredGigabitEthernets[j].Name.ValueString() {
+ found = false
}
- if cValue := v.Get("priority"); cValue.Exists() {
- item.Priority = types.Int64Value(cValue.Int())
+ if found {
+ break
+ }
+ }
+ if !found {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/passive-interface-config/disable-interface/HundredGigabitE=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ }
+ for i := range state.PassiveInterfaceDisableFortyGigabitEthernets {
+ stateKeyValues := [...]string{state.PassiveInterfaceDisableFortyGigabitEthernets[i].Name.ValueString()}
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.PassiveInterfaceDisableFortyGigabitEthernets[i].Name.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.PassiveInterfaceDisableFortyGigabitEthernets {
+ found = true
+ if state.PassiveInterfaceDisableFortyGigabitEthernets[i].Name.ValueString() != data.PassiveInterfaceDisableFortyGigabitEthernets[j].Name.ValueString() {
+ found = false
}
- if cValue := v.Get("cost"); cValue.Exists() {
- item.Cost = types.Int64Value(cValue.Int())
+ if found {
+ break
}
- data.Neighbors = append(data.Neighbors, item)
- return true
- })
+ }
+ if !found {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/passive-interface-config/disable-interface/FortyGigabitEthernet=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
}
- if value := res.Get(prefix + "network"); value.Exists() {
- data.Networks = make([]OSPFNetworks, 0)
- value.ForEach(func(k, v gjson.Result) bool {
- item := OSPFNetworks{}
- if cValue := v.Get("ip"); cValue.Exists() {
- item.Ip = types.StringValue(cValue.String())
- }
- if cValue := v.Get("wildcard"); cValue.Exists() {
- item.Wildcard = types.StringValue(cValue.String())
+ for i := range state.PassiveInterfaceDisableTwentyFiveGigabitEthernets {
+ stateKeyValues := [...]string{state.PassiveInterfaceDisableTwentyFiveGigabitEthernets[i].Name.ValueString()}
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.PassiveInterfaceDisableTwentyFiveGigabitEthernets[i].Name.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.PassiveInterfaceDisableTwentyFiveGigabitEthernets {
+ found = true
+ if state.PassiveInterfaceDisableTwentyFiveGigabitEthernets[i].Name.ValueString() != data.PassiveInterfaceDisableTwentyFiveGigabitEthernets[j].Name.ValueString() {
+ found = false
}
- if cValue := v.Get("area"); cValue.Exists() {
- item.Area = types.StringValue(cValue.String())
+ if found {
+ break
}
- data.Networks = append(data.Networks, item)
- return true
- })
- }
- if value := res.Get(prefix + "priority"); value.Exists() {
- data.Priority = types.Int64Value(value.Int())
- }
- if value := res.Get(prefix + "router-id"); value.Exists() {
- data.RouterId = types.StringValue(value.String())
+ }
+ if !found {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/passive-interface-config/disable-interface/TwentyFiveGigabitE=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
}
- if value := res.Get(prefix + "shutdown"); value.Exists() {
- data.Shutdown = types.BoolValue(value.Bool())
- } else {
- data.Shutdown = types.BoolNull()
+ for i := range state.PassiveInterfaceDisableTenGigabitEthernets {
+ stateKeyValues := [...]string{state.PassiveInterfaceDisableTenGigabitEthernets[i].Name.ValueString()}
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.PassiveInterfaceDisableTenGigabitEthernets[i].Name.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.PassiveInterfaceDisableTenGigabitEthernets {
+ found = true
+ if state.PassiveInterfaceDisableTenGigabitEthernets[i].Name.ValueString() != data.PassiveInterfaceDisableTenGigabitEthernets[j].Name.ValueString() {
+ found = false
+ }
+ if found {
+ break
+ }
+ }
+ if !found {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/passive-interface-config/disable-interface/TenGigabitEthernet=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
}
- if value := res.Get(prefix + "summary-address"); value.Exists() {
- data.SummaryAddresses = make([]OSPFSummaryAddresses, 0)
- value.ForEach(func(k, v gjson.Result) bool {
- item := OSPFSummaryAddresses{}
- if cValue := v.Get("ip"); cValue.Exists() {
- item.Ip = types.StringValue(cValue.String())
+ for i := range state.PassiveInterfaceDisableFiveGigabitEthernets {
+ stateKeyValues := [...]string{state.PassiveInterfaceDisableFiveGigabitEthernets[i].Name.ValueString()}
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.PassiveInterfaceDisableFiveGigabitEthernets[i].Name.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.PassiveInterfaceDisableFiveGigabitEthernets {
+ found = true
+ if state.PassiveInterfaceDisableFiveGigabitEthernets[i].Name.ValueString() != data.PassiveInterfaceDisableFiveGigabitEthernets[j].Name.ValueString() {
+ found = false
}
- if cValue := v.Get("mask"); cValue.Exists() {
- item.Mask = types.StringValue(cValue.String())
+ if found {
+ break
}
- data.SummaryAddresses = append(data.SummaryAddresses, item)
- return true
- })
+ }
+ if !found {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/passive-interface-config/disable-interface/FiveGigabitEthernet=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
}
- if value := res.Get(prefix + "area"); value.Exists() {
- data.Areas = make([]OSPFAreas, 0)
- value.ForEach(func(k, v gjson.Result) bool {
- item := OSPFAreas{}
- if cValue := v.Get("area-id"); cValue.Exists() {
- item.AreaId = types.StringValue(cValue.String())
+ for i := range state.PassiveInterfaceDisableTwoGigabitEthernets {
+ stateKeyValues := [...]string{state.PassiveInterfaceDisableTwoGigabitEthernets[i].Name.ValueString()}
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.PassiveInterfaceDisableTwoGigabitEthernets[i].Name.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.PassiveInterfaceDisableTwoGigabitEthernets {
+ found = true
+ if state.PassiveInterfaceDisableTwoGigabitEthernets[i].Name.ValueString() != data.PassiveInterfaceDisableTwoGigabitEthernets[j].Name.ValueString() {
+ found = false
}
- if cValue := v.Get("authentication.message-digest"); cValue.Exists() {
- item.AuthenticationMessageDigest = types.BoolValue(true)
- } else {
- item.AuthenticationMessageDigest = types.BoolValue(false)
+ if found {
+ break
}
- if cValue := v.Get("nssa"); cValue.Exists() {
- item.Nssa = types.BoolValue(true)
- } else {
- item.Nssa = types.BoolValue(false)
+ }
+ if !found {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/passive-interface-config/disable-interface/TwoGigabitEthernet=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ }
+ for i := range state.PassiveInterfaceDisableGigabitEthernets {
+ stateKeyValues := [...]string{state.PassiveInterfaceDisableGigabitEthernets[i].Name.ValueString()}
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.PassiveInterfaceDisableGigabitEthernets[i].Name.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.PassiveInterfaceDisableGigabitEthernets {
+ found = true
+ if state.PassiveInterfaceDisableGigabitEthernets[i].Name.ValueString() != data.PassiveInterfaceDisableGigabitEthernets[j].Name.ValueString() {
+ found = false
}
- if cValue := v.Get("nssa.nssa-options.default-information-originate"); cValue.Exists() {
- item.NssaDefaultInformationOriginate = types.BoolValue(true)
- } else {
- item.NssaDefaultInformationOriginate = types.BoolValue(false)
+ if found {
+ break
}
- if cValue := v.Get("nssa.nssa-options.default-information-originate.metric"); cValue.Exists() {
- item.NssaDefaultInformationOriginateMetric = types.Int64Value(cValue.Int())
+ }
+ if !found {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/passive-interface-config/disable-interface/GigabitEthernet=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ }
+ if !state.PassiveInterface.IsNull() {
+ if data.PassiveInterface.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/passive-interface/interface", state.getPath()))
+ } else {
+ var dataValues, stateValues []string
+ data.PassiveInterface.ElementsAs(ctx, &dataValues, false)
+ state.PassiveInterface.ElementsAs(ctx, &stateValues, false)
+ for _, v := range stateValues {
+ found := false
+ for _, vv := range dataValues {
+ if v == vv {
+ found = true
+ break
+ }
+ }
+ if !found {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/passive-interface/interface=%v", state.getPath(), v))
+ }
}
- if cValue := v.Get("nssa.nssa-options.default-information-originate.metric-type"); cValue.Exists() {
- item.NssaDefaultInformationOriginateMetricType = types.Int64Value(cValue.Int())
+ }
+ }
+ if !state.PassiveInterfaceDefault.IsNull() && data.PassiveInterfaceDefault.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/passive-interface/default", state.getPath()))
+ }
+ if !state.AutoCostReferenceBandwidth.IsNull() && data.AutoCostReferenceBandwidth.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/auto-cost/reference-bandwidth", state.getPath()))
+ }
+ for i := range state.Areas {
+ stateKeyValues := [...]string{state.Areas[i].AreaId.ValueString()}
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.Areas[i].AreaId.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.Areas {
+ found = true
+ if state.Areas[i].AreaId.ValueString() != data.Areas[j].AreaId.ValueString() {
+ found = false
}
- if cValue := v.Get("nssa.nssa-options.no-summary"); cValue.Exists() {
- item.NssaNoSummary = types.BoolValue(true)
- } else {
- item.NssaNoSummary = types.BoolValue(false)
+ if found {
+ if !state.Areas[i].NssaNoRedistribution.IsNull() && data.Areas[j].NssaNoRedistribution.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/area=%v/nssa/nssa-options/no-redistribution", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ if !state.Areas[i].NssaNoSummary.IsNull() && data.Areas[j].NssaNoSummary.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/area=%v/nssa/nssa-options/no-summary", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ if !state.Areas[i].NssaDefaultInformationOriginateMetricType.IsNull() && data.Areas[j].NssaDefaultInformationOriginateMetricType.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/area=%v/nssa/nssa-options/default-information-originate/metric-type", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ if !state.Areas[i].NssaDefaultInformationOriginateMetric.IsNull() && data.Areas[j].NssaDefaultInformationOriginateMetric.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/area=%v/nssa/nssa-options/default-information-originate/metric", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ if !state.Areas[i].NssaDefaultInformationOriginate.IsNull() && data.Areas[j].NssaDefaultInformationOriginate.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/area=%v/nssa/nssa-options/default-information-originate", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ if !state.Areas[i].Nssa.IsNull() && data.Areas[j].Nssa.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/area=%v/nssa", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ if !state.Areas[i].AuthenticationMessageDigest.IsNull() && data.Areas[j].AuthenticationMessageDigest.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/area=%v/authentication/message-digest", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ break
}
- if cValue := v.Get("nssa.nssa-options.no-redistribution"); cValue.Exists() {
- item.NssaNoRedistribution = types.BoolValue(true)
- } else {
- item.NssaNoRedistribution = types.BoolValue(false)
+ }
+ if !found {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/area=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ }
+ for i := range state.SummaryAddresses {
+ stateKeyValues := [...]string{state.SummaryAddresses[i].Ip.ValueString()}
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.SummaryAddresses[i].Ip.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.SummaryAddresses {
+ found = true
+ if state.SummaryAddresses[i].Ip.ValueString() != data.SummaryAddresses[j].Ip.ValueString() {
+ found = false
}
- data.Areas = append(data.Areas, item)
- return true
- })
+ if found {
+ if !state.SummaryAddresses[i].Mask.IsNull() && data.SummaryAddresses[j].Mask.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/summary-address=%v/mask", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ break
+ }
+ }
+ if !found {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/summary-address=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
}
- if value := res.Get(prefix + "auto-cost.reference-bandwidth"); value.Exists() {
- data.AutoCostReferenceBandwidth = types.Int64Value(value.Int())
+ if !state.Shutdown.IsNull() && data.Shutdown.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/shutdown", state.getPath()))
}
- if value := res.Get(prefix + "passive-interface.default"); value.Exists() {
- data.PassiveInterfaceDefault = types.BoolValue(value.Bool())
- } else {
- data.PassiveInterfaceDefault = types.BoolNull()
+ if !state.RouterId.IsNull() && data.RouterId.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/router-id", state.getPath()))
}
- if value := res.Get(prefix + "passive-interface.interface"); value.Exists() {
- data.PassiveInterface = helpers.GetStringList(value.Array())
- } else {
- data.PassiveInterface = types.ListNull(types.StringType)
+ if !state.Priority.IsNull() && data.Priority.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/priority", state.getPath()))
}
- if value := res.Get(prefix + "passive-interface-config.disable-interface.GigabitEthernet"); value.Exists() {
- data.PassiveInterfaceDisableGigabitEthernets = make([]OSPFPassiveInterfaceDisableGigabitEthernets, 0)
- value.ForEach(func(k, v gjson.Result) bool {
- item := OSPFPassiveInterfaceDisableGigabitEthernets{}
- if cValue := v.Get("name"); cValue.Exists() {
- item.Name = types.StringValue(cValue.String())
+ for i := range state.Networks {
+ stateKeyValues := [...]string{state.Networks[i].Ip.ValueString()}
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.Networks[i].Ip.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.Networks {
+ found = true
+ if state.Networks[i].Ip.ValueString() != data.Networks[j].Ip.ValueString() {
+ found = false
}
- data.PassiveInterfaceDisableGigabitEthernets = append(data.PassiveInterfaceDisableGigabitEthernets, item)
- return true
- })
- }
- if value := res.Get(prefix + "passive-interface-config.disable-interface.TwoGigabitEthernet"); value.Exists() {
- data.PassiveInterfaceDisableTwoGigabitEthernets = make([]OSPFPassiveInterfaceDisableTwoGigabitEthernets, 0)
- value.ForEach(func(k, v gjson.Result) bool {
- item := OSPFPassiveInterfaceDisableTwoGigabitEthernets{}
- if cValue := v.Get("name"); cValue.Exists() {
- item.Name = types.StringValue(cValue.String())
+ if found {
+ if !state.Networks[i].Area.IsNull() && data.Networks[j].Area.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/network=%v/area", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ if !state.Networks[i].Wildcard.IsNull() && data.Networks[j].Wildcard.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/network=%v/wildcard", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ break
}
- data.PassiveInterfaceDisableTwoGigabitEthernets = append(data.PassiveInterfaceDisableTwoGigabitEthernets, item)
- return true
- })
+ }
+ if !found {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/network=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
}
- if value := res.Get(prefix + "passive-interface-config.disable-interface.FiveGigabitEthernet"); value.Exists() {
- data.PassiveInterfaceDisableFiveGigabitEthernets = make([]OSPFPassiveInterfaceDisableFiveGigabitEthernets, 0)
- value.ForEach(func(k, v gjson.Result) bool {
- item := OSPFPassiveInterfaceDisableFiveGigabitEthernets{}
- if cValue := v.Get("name"); cValue.Exists() {
- item.Name = types.StringValue(cValue.String())
+ for i := range state.Neighbors {
+ stateKeyValues := [...]string{state.Neighbors[i].Ip.ValueString()}
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.Neighbors[i].Ip.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.Neighbors {
+ found = true
+ if state.Neighbors[i].Ip.ValueString() != data.Neighbors[j].Ip.ValueString() {
+ found = false
}
- data.PassiveInterfaceDisableFiveGigabitEthernets = append(data.PassiveInterfaceDisableFiveGigabitEthernets, item)
- return true
- })
- }
- if value := res.Get(prefix + "passive-interface-config.disable-interface.TenGigabitEthernet"); value.Exists() {
- data.PassiveInterfaceDisableTenGigabitEthernets = make([]OSPFPassiveInterfaceDisableTenGigabitEthernets, 0)
- value.ForEach(func(k, v gjson.Result) bool {
- item := OSPFPassiveInterfaceDisableTenGigabitEthernets{}
- if cValue := v.Get("name"); cValue.Exists() {
- item.Name = types.StringValue(cValue.String())
+ if found {
+ if !state.Neighbors[i].Cost.IsNull() && data.Neighbors[j].Cost.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/neighbor=%v/cost", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ if !state.Neighbors[i].Priority.IsNull() && data.Neighbors[j].Priority.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/neighbor=%v/priority", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ break
}
- data.PassiveInterfaceDisableTenGigabitEthernets = append(data.PassiveInterfaceDisableTenGigabitEthernets, item)
- return true
- })
+ }
+ if !found {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/neighbor=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
}
- if value := res.Get(prefix + "passive-interface-config.disable-interface.TwentyFiveGigabitE"); value.Exists() {
- data.PassiveInterfaceDisableTwentyFiveGigabitEthernets = make([]OSPFPassiveInterfaceDisableTwentyFiveGigabitEthernets, 0)
- value.ForEach(func(k, v gjson.Result) bool {
- item := OSPFPassiveInterfaceDisableTwentyFiveGigabitEthernets{}
- if cValue := v.Get("name"); cValue.Exists() {
- item.Name = types.StringValue(cValue.String())
- }
- data.PassiveInterfaceDisableTwentyFiveGigabitEthernets = append(data.PassiveInterfaceDisableTwentyFiveGigabitEthernets, item)
- return true
- })
+ if !state.MplsLdpSync.IsNull() && data.MplsLdpSync.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/mpls/ldp/sync", state.getPath()))
}
- if value := res.Get(prefix + "passive-interface-config.disable-interface.FortyGigabitEthernet"); value.Exists() {
- data.PassiveInterfaceDisableFortyGigabitEthernets = make([]OSPFPassiveInterfaceDisableFortyGigabitEthernets, 0)
- value.ForEach(func(k, v gjson.Result) bool {
- item := OSPFPassiveInterfaceDisableFortyGigabitEthernets{}
- if cValue := v.Get("name"); cValue.Exists() {
- item.Name = types.StringValue(cValue.String())
- }
- data.PassiveInterfaceDisableFortyGigabitEthernets = append(data.PassiveInterfaceDisableFortyGigabitEthernets, item)
- return true
- })
+ if !state.MplsLdpAutoconfig.IsNull() && data.MplsLdpAutoconfig.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/mpls/ldp/autoconfig", state.getPath()))
}
- if value := res.Get(prefix + "passive-interface-config.disable-interface.HundredGigabitE"); value.Exists() {
- data.PassiveInterfaceDisableHundredGigabitEthernets = make([]OSPFPassiveInterfaceDisableHundredGigabitEthernets, 0)
- value.ForEach(func(k, v gjson.Result) bool {
- item := OSPFPassiveInterfaceDisableHundredGigabitEthernets{}
- if cValue := v.Get("name"); cValue.Exists() {
- item.Name = types.StringValue(cValue.String())
- }
- data.PassiveInterfaceDisableHundredGigabitEthernets = append(data.PassiveInterfaceDisableHundredGigabitEthernets, item)
- return true
- })
+ if !state.DomainTag.IsNull() && data.DomainTag.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/domain-tag", state.getPath()))
}
- if value := res.Get(prefix + "passive-interface-config.disable-interface.TwoHundredGigabitE"); value.Exists() {
- data.PassiveInterfaceDisableTwoHundredGigabitEthernets = make([]OSPFPassiveInterfaceDisableTwoHundredGigabitEthernets, 0)
- value.ForEach(func(k, v gjson.Result) bool {
- item := OSPFPassiveInterfaceDisableTwoHundredGigabitEthernets{}
- if cValue := v.Get("name"); cValue.Exists() {
- item.Name = types.StringValue(cValue.String())
- }
- data.PassiveInterfaceDisableTwoHundredGigabitEthernets = append(data.PassiveInterfaceDisableTwoHundredGigabitEthernets, item)
- return true
- })
+ if !state.Distance.IsNull() && data.Distance.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/distance/distance", state.getPath()))
}
- if value := res.Get(prefix + "passive-interface-config.disable-interface.FourHundredGigabitE"); value.Exists() {
- data.PassiveInterfaceDisableFourHundredGigabitEthernets = make([]OSPFPassiveInterfaceDisableFourHundredGigabitEthernets, 0)
- value.ForEach(func(k, v gjson.Result) bool {
- item := OSPFPassiveInterfaceDisableFourHundredGigabitEthernets{}
- if cValue := v.Get("name"); cValue.Exists() {
- item.Name = types.StringValue(cValue.String())
- }
- data.PassiveInterfaceDisableFourHundredGigabitEthernets = append(data.PassiveInterfaceDisableFourHundredGigabitEthernets, item)
- return true
- })
+ if !state.DefaultMetric.IsNull() && data.DefaultMetric.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/default-metric", state.getPath()))
}
- if value := res.Get(prefix + "passive-interface-config.disable-interface.Loopback"); value.Exists() {
- data.PassiveInterfaceDisableLoopbacks = make([]OSPFPassiveInterfaceDisableLoopbacks, 0)
- value.ForEach(func(k, v gjson.Result) bool {
- item := OSPFPassiveInterfaceDisableLoopbacks{}
- if cValue := v.Get("name"); cValue.Exists() {
- item.Name = types.StringValue(cValue.String())
- }
- data.PassiveInterfaceDisableLoopbacks = append(data.PassiveInterfaceDisableLoopbacks, item)
- return true
- })
+ if !state.DefaultInformationOriginateAlways.IsNull() && data.DefaultInformationOriginateAlways.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/default-information/originate/always", state.getPath()))
}
- if value := res.Get(prefix + "passive-interface-config.disable-interface.Vlan"); value.Exists() {
- data.PassiveInterfaceDisableVlans = make([]OSPFPassiveInterfaceDisableVlans, 0)
- value.ForEach(func(k, v gjson.Result) bool {
- item := OSPFPassiveInterfaceDisableVlans{}
- if cValue := v.Get("name"); cValue.Exists() {
- item.Name = types.StringValue(cValue.String())
- }
- data.PassiveInterfaceDisableVlans = append(data.PassiveInterfaceDisableVlans, item)
- return true
- })
+ if !state.DefaultInformationOriginate.IsNull() && data.DefaultInformationOriginate.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/default-information/originate", state.getPath()))
}
- if value := res.Get(prefix + "passive-interface-config.disable-interface.Tunnel"); value.Exists() {
- data.PassiveInterfaceDisableTunnels = make([]OSPFPassiveInterfaceDisableTunnels, 0)
- value.ForEach(func(k, v gjson.Result) bool {
- item := OSPFPassiveInterfaceDisableTunnels{}
- if cValue := v.Get("name"); cValue.Exists() {
- item.Name = types.StringValue(cValue.String())
- }
- data.PassiveInterfaceDisableTunnels = append(data.PassiveInterfaceDisableTunnels, item)
- return true
- })
+ if !state.BfdAllInterfaces.IsNull() && data.BfdAllInterfaces.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/bfd/all-interfaces", state.getPath()))
}
- if value := res.Get(prefix + "passive-interface-config.disable-interface.Port-channel"); value.Exists() {
- data.PassiveInterfaceDisablePortChannels = make([]OSPFPassiveInterfaceDisablePortChannels, 0)
- value.ForEach(func(k, v gjson.Result) bool {
- item := OSPFPassiveInterfaceDisablePortChannels{}
- if cValue := v.Get("name"); cValue.Exists() {
- item.Name = types.StringValue(cValue.String())
- }
- data.PassiveInterfaceDisablePortChannels = append(data.PassiveInterfaceDisablePortChannels, item)
- return true
- })
+
+ return deletedItems
+}
+
+// End of section. //template:end getDeletedItems
+
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletedItemsXML
+
+func (data *OSPF) addDeletedItemsXML(ctx context.Context, state OSPF, body string) string {
+ b := netconf.NewBody(body)
+ if !state.BfdAllInterfaces.IsNull() && data.BfdAllInterfaces.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/bfd/all-interfaces")
}
- if value := res.Get(prefix + "passive-interface-config.disable-interface.Port-channel-subinterface.Port-channel"); value.Exists() {
- data.PassiveInterfaceDisablePortChannelSubinterfaces = make([]OSPFPassiveInterfaceDisablePortChannelSubinterfaces, 0)
- value.ForEach(func(k, v gjson.Result) bool {
- item := OSPFPassiveInterfaceDisablePortChannelSubinterfaces{}
- if cValue := v.Get("name"); cValue.Exists() {
- item.Name = types.StringValue(cValue.String())
- }
- data.PassiveInterfaceDisablePortChannelSubinterfaces = append(data.PassiveInterfaceDisablePortChannelSubinterfaces, item)
- return true
- })
+ if !state.DefaultInformationOriginate.IsNull() && data.DefaultInformationOriginate.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/default-information/originate")
+ }
+ if !state.DefaultInformationOriginateAlways.IsNull() && data.DefaultInformationOriginateAlways.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/default-information/originate/always")
+ }
+ if !state.DefaultMetric.IsNull() && data.DefaultMetric.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/default-metric")
+ }
+ if !state.Distance.IsNull() && data.Distance.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/distance/distance")
+ }
+ if !state.DomainTag.IsNull() && data.DomainTag.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/domain-tag")
+ }
+ if !state.MplsLdpAutoconfig.IsNull() && data.MplsLdpAutoconfig.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/mpls/ldp/autoconfig")
}
-}
-
-// End of section. //template:end fromBodyData
-
-// Section below is generated&owned by "gen/generator.go". //template:begin getDeletedItems
-
-func (data *OSPF) getDeletedItems(ctx context.Context, state OSPF) []string {
- deletedItems := make([]string, 0)
- for i := range state.PassiveInterfaceDisablePortChannelSubinterfaces {
- stateKeyValues := [...]string{state.PassiveInterfaceDisablePortChannelSubinterfaces[i].Name.ValueString()}
+ if !state.MplsLdpSync.IsNull() && data.MplsLdpSync.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/mpls/ldp/sync")
+ }
+ for i := range state.Neighbors {
+ stateKeys := [...]string{"ip"}
+ stateKeyValues := [...]string{state.Neighbors[i].Ip.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
emptyKeys := true
- if !reflect.ValueOf(state.PassiveInterfaceDisablePortChannelSubinterfaces[i].Name.ValueString()).IsZero() {
+ if !reflect.ValueOf(state.Neighbors[i].Ip.ValueString()).IsZero() {
emptyKeys = false
}
if emptyKeys {
@@ -1816,24 +4043,35 @@ func (data *OSPF) getDeletedItems(ctx context.Context, state OSPF) []string {
}
found := false
- for j := range data.PassiveInterfaceDisablePortChannelSubinterfaces {
+ for j := range data.Neighbors {
found = true
- if state.PassiveInterfaceDisablePortChannelSubinterfaces[i].Name.ValueString() != data.PassiveInterfaceDisablePortChannelSubinterfaces[j].Name.ValueString() {
+ if state.Neighbors[i].Ip.ValueString() != data.Neighbors[j].Ip.ValueString() {
found = false
}
if found {
+ if !state.Neighbors[i].Priority.IsNull() && data.Neighbors[j].Priority.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/neighbor%v/priority", predicates))
+ }
+ if !state.Neighbors[i].Cost.IsNull() && data.Neighbors[j].Cost.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/neighbor%v/cost", predicates))
+ }
break
}
}
if !found {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/passive-interface-config/disable-interface/Port-channel-subinterface/Port-channel=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/neighbor%v", predicates))
}
}
- for i := range state.PassiveInterfaceDisablePortChannels {
- stateKeyValues := [...]string{state.PassiveInterfaceDisablePortChannels[i].Name.ValueString()}
+ for i := range state.Networks {
+ stateKeys := [...]string{"ip"}
+ stateKeyValues := [...]string{state.Networks[i].Ip.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
emptyKeys := true
- if !reflect.ValueOf(state.PassiveInterfaceDisablePortChannels[i].Name.ValueString()).IsZero() {
+ if !reflect.ValueOf(state.Networks[i].Ip.ValueString()).IsZero() {
emptyKeys = false
}
if emptyKeys {
@@ -1841,24 +4079,44 @@ func (data *OSPF) getDeletedItems(ctx context.Context, state OSPF) []string {
}
found := false
- for j := range data.PassiveInterfaceDisablePortChannels {
+ for j := range data.Networks {
found = true
- if state.PassiveInterfaceDisablePortChannels[i].Name.ValueString() != data.PassiveInterfaceDisablePortChannels[j].Name.ValueString() {
+ if state.Networks[i].Ip.ValueString() != data.Networks[j].Ip.ValueString() {
found = false
}
if found {
+ if !state.Networks[i].Wildcard.IsNull() && data.Networks[j].Wildcard.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/network%v/wildcard", predicates))
+ }
+ if !state.Networks[i].Area.IsNull() && data.Networks[j].Area.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/network%v/area", predicates))
+ }
break
}
}
if !found {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/passive-interface-config/disable-interface/Port-channel=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/network%v", predicates))
}
}
- for i := range state.PassiveInterfaceDisableTunnels {
- stateKeyValues := [...]string{state.PassiveInterfaceDisableTunnels[i].Name.ValueString()}
+ if !state.Priority.IsNull() && data.Priority.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/priority")
+ }
+ if !state.RouterId.IsNull() && data.RouterId.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/router-id")
+ }
+ if !state.Shutdown.IsNull() && data.Shutdown.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/shutdown")
+ }
+ for i := range state.SummaryAddresses {
+ stateKeys := [...]string{"ip"}
+ stateKeyValues := [...]string{state.SummaryAddresses[i].Ip.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
emptyKeys := true
- if !reflect.ValueOf(state.PassiveInterfaceDisableTunnels[i].Name.ValueString()).IsZero() {
+ if !reflect.ValueOf(state.SummaryAddresses[i].Ip.ValueString()).IsZero() {
emptyKeys = false
}
if emptyKeys {
@@ -1866,24 +4124,32 @@ func (data *OSPF) getDeletedItems(ctx context.Context, state OSPF) []string {
}
found := false
- for j := range data.PassiveInterfaceDisableTunnels {
+ for j := range data.SummaryAddresses {
found = true
- if state.PassiveInterfaceDisableTunnels[i].Name.ValueString() != data.PassiveInterfaceDisableTunnels[j].Name.ValueString() {
+ if state.SummaryAddresses[i].Ip.ValueString() != data.SummaryAddresses[j].Ip.ValueString() {
found = false
}
if found {
+ if !state.SummaryAddresses[i].Mask.IsNull() && data.SummaryAddresses[j].Mask.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/summary-address%v/mask", predicates))
+ }
break
}
}
if !found {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/passive-interface-config/disable-interface/Tunnel=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/summary-address%v", predicates))
}
}
- for i := range state.PassiveInterfaceDisableVlans {
- stateKeyValues := [...]string{state.PassiveInterfaceDisableVlans[i].Name.ValueString()}
+ for i := range state.Areas {
+ stateKeys := [...]string{"area-id"}
+ stateKeyValues := [...]string{state.Areas[i].AreaId.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
emptyKeys := true
- if !reflect.ValueOf(state.PassiveInterfaceDisableVlans[i].Name.ValueString()).IsZero() {
+ if !reflect.ValueOf(state.Areas[i].AreaId.ValueString()).IsZero() {
emptyKeys = false
}
if emptyKeys {
@@ -1891,24 +4157,77 @@ func (data *OSPF) getDeletedItems(ctx context.Context, state OSPF) []string {
}
found := false
- for j := range data.PassiveInterfaceDisableVlans {
+ for j := range data.Areas {
found = true
- if state.PassiveInterfaceDisableVlans[i].Name.ValueString() != data.PassiveInterfaceDisableVlans[j].Name.ValueString() {
+ if state.Areas[i].AreaId.ValueString() != data.Areas[j].AreaId.ValueString() {
found = false
}
if found {
+ if !state.Areas[i].AuthenticationMessageDigest.IsNull() && data.Areas[j].AuthenticationMessageDigest.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/area%v/authentication/message-digest", predicates))
+ }
+ if !state.Areas[i].Nssa.IsNull() && data.Areas[j].Nssa.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/area%v/nssa", predicates))
+ }
+ if !state.Areas[i].NssaDefaultInformationOriginate.IsNull() && data.Areas[j].NssaDefaultInformationOriginate.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/area%v/nssa/nssa-options/default-information-originate", predicates))
+ }
+ if !state.Areas[i].NssaDefaultInformationOriginateMetric.IsNull() && data.Areas[j].NssaDefaultInformationOriginateMetric.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/area%v/nssa/nssa-options/default-information-originate/metric", predicates))
+ }
+ if !state.Areas[i].NssaDefaultInformationOriginateMetricType.IsNull() && data.Areas[j].NssaDefaultInformationOriginateMetricType.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/area%v/nssa/nssa-options/default-information-originate/metric-type", predicates))
+ }
+ if !state.Areas[i].NssaNoSummary.IsNull() && data.Areas[j].NssaNoSummary.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/area%v/nssa/nssa-options/no-summary", predicates))
+ }
+ if !state.Areas[i].NssaNoRedistribution.IsNull() && data.Areas[j].NssaNoRedistribution.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/area%v/nssa/nssa-options/no-redistribution", predicates))
+ }
break
}
}
if !found {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/passive-interface-config/disable-interface/Vlan=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/area%v", predicates))
}
}
- for i := range state.PassiveInterfaceDisableLoopbacks {
- stateKeyValues := [...]string{state.PassiveInterfaceDisableLoopbacks[i].Name.ValueString()}
+ if !state.AutoCostReferenceBandwidth.IsNull() && data.AutoCostReferenceBandwidth.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/auto-cost/reference-bandwidth")
+ }
+ if !state.PassiveInterfaceDefault.IsNull() && data.PassiveInterfaceDefault.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/passive-interface/default")
+ }
+ if !state.PassiveInterface.IsNull() {
+ if data.PassiveInterface.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/passive-interface/interface")
+ } else {
+ var dataValues, stateValues []string
+ data.PassiveInterface.ElementsAs(ctx, &dataValues, false)
+ state.PassiveInterface.ElementsAs(ctx, &stateValues, false)
+ for _, v := range stateValues {
+ found := false
+ for _, vv := range dataValues {
+ if v == vv {
+ found = true
+ break
+ }
+ }
+ if !found {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/passive-interface/interface[.=%v]", v))
+ }
+ }
+ }
+ }
+ for i := range state.PassiveInterfaceDisableGigabitEthernets {
+ stateKeys := [...]string{""}
+ stateKeyValues := [...]string{state.PassiveInterfaceDisableGigabitEthernets[i].Name.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
emptyKeys := true
- if !reflect.ValueOf(state.PassiveInterfaceDisableLoopbacks[i].Name.ValueString()).IsZero() {
+ if !reflect.ValueOf(state.PassiveInterfaceDisableGigabitEthernets[i].Name.ValueString()).IsZero() {
emptyKeys = false
}
if emptyKeys {
@@ -1916,9 +4235,9 @@ func (data *OSPF) getDeletedItems(ctx context.Context, state OSPF) []string {
}
found := false
- for j := range data.PassiveInterfaceDisableLoopbacks {
+ for j := range data.PassiveInterfaceDisableGigabitEthernets {
found = true
- if state.PassiveInterfaceDisableLoopbacks[i].Name.ValueString() != data.PassiveInterfaceDisableLoopbacks[j].Name.ValueString() {
+ if state.PassiveInterfaceDisableGigabitEthernets[i].Name.ValueString() != data.PassiveInterfaceDisableGigabitEthernets[j].Name.ValueString() {
found = false
}
if found {
@@ -1926,14 +4245,19 @@ func (data *OSPF) getDeletedItems(ctx context.Context, state OSPF) []string {
}
}
if !found {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/passive-interface-config/disable-interface/Loopback=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/%v", predicates))
}
}
- for i := range state.PassiveInterfaceDisableFourHundredGigabitEthernets {
- stateKeyValues := [...]string{state.PassiveInterfaceDisableFourHundredGigabitEthernets[i].Name.ValueString()}
+ for i := range state.PassiveInterfaceDisableTwoGigabitEthernets {
+ stateKeys := [...]string{""}
+ stateKeyValues := [...]string{state.PassiveInterfaceDisableTwoGigabitEthernets[i].Name.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
emptyKeys := true
- if !reflect.ValueOf(state.PassiveInterfaceDisableFourHundredGigabitEthernets[i].Name.ValueString()).IsZero() {
+ if !reflect.ValueOf(state.PassiveInterfaceDisableTwoGigabitEthernets[i].Name.ValueString()).IsZero() {
emptyKeys = false
}
if emptyKeys {
@@ -1941,9 +4265,9 @@ func (data *OSPF) getDeletedItems(ctx context.Context, state OSPF) []string {
}
found := false
- for j := range data.PassiveInterfaceDisableFourHundredGigabitEthernets {
+ for j := range data.PassiveInterfaceDisableTwoGigabitEthernets {
found = true
- if state.PassiveInterfaceDisableFourHundredGigabitEthernets[i].Name.ValueString() != data.PassiveInterfaceDisableFourHundredGigabitEthernets[j].Name.ValueString() {
+ if state.PassiveInterfaceDisableTwoGigabitEthernets[i].Name.ValueString() != data.PassiveInterfaceDisableTwoGigabitEthernets[j].Name.ValueString() {
found = false
}
if found {
@@ -1951,14 +4275,19 @@ func (data *OSPF) getDeletedItems(ctx context.Context, state OSPF) []string {
}
}
if !found {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/passive-interface-config/disable-interface/FourHundredGigabitE=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/%v", predicates))
}
}
- for i := range state.PassiveInterfaceDisableTwoHundredGigabitEthernets {
- stateKeyValues := [...]string{state.PassiveInterfaceDisableTwoHundredGigabitEthernets[i].Name.ValueString()}
+ for i := range state.PassiveInterfaceDisableFiveGigabitEthernets {
+ stateKeys := [...]string{""}
+ stateKeyValues := [...]string{state.PassiveInterfaceDisableFiveGigabitEthernets[i].Name.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
emptyKeys := true
- if !reflect.ValueOf(state.PassiveInterfaceDisableTwoHundredGigabitEthernets[i].Name.ValueString()).IsZero() {
+ if !reflect.ValueOf(state.PassiveInterfaceDisableFiveGigabitEthernets[i].Name.ValueString()).IsZero() {
emptyKeys = false
}
if emptyKeys {
@@ -1966,9 +4295,9 @@ func (data *OSPF) getDeletedItems(ctx context.Context, state OSPF) []string {
}
found := false
- for j := range data.PassiveInterfaceDisableTwoHundredGigabitEthernets {
+ for j := range data.PassiveInterfaceDisableFiveGigabitEthernets {
found = true
- if state.PassiveInterfaceDisableTwoHundredGigabitEthernets[i].Name.ValueString() != data.PassiveInterfaceDisableTwoHundredGigabitEthernets[j].Name.ValueString() {
+ if state.PassiveInterfaceDisableFiveGigabitEthernets[i].Name.ValueString() != data.PassiveInterfaceDisableFiveGigabitEthernets[j].Name.ValueString() {
found = false
}
if found {
@@ -1976,14 +4305,19 @@ func (data *OSPF) getDeletedItems(ctx context.Context, state OSPF) []string {
}
}
if !found {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/passive-interface-config/disable-interface/TwoHundredGigabitE=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/%v", predicates))
}
}
- for i := range state.PassiveInterfaceDisableHundredGigabitEthernets {
- stateKeyValues := [...]string{state.PassiveInterfaceDisableHundredGigabitEthernets[i].Name.ValueString()}
+ for i := range state.PassiveInterfaceDisableTenGigabitEthernets {
+ stateKeys := [...]string{""}
+ stateKeyValues := [...]string{state.PassiveInterfaceDisableTenGigabitEthernets[i].Name.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
emptyKeys := true
- if !reflect.ValueOf(state.PassiveInterfaceDisableHundredGigabitEthernets[i].Name.ValueString()).IsZero() {
+ if !reflect.ValueOf(state.PassiveInterfaceDisableTenGigabitEthernets[i].Name.ValueString()).IsZero() {
emptyKeys = false
}
if emptyKeys {
@@ -1991,9 +4325,9 @@ func (data *OSPF) getDeletedItems(ctx context.Context, state OSPF) []string {
}
found := false
- for j := range data.PassiveInterfaceDisableHundredGigabitEthernets {
+ for j := range data.PassiveInterfaceDisableTenGigabitEthernets {
found = true
- if state.PassiveInterfaceDisableHundredGigabitEthernets[i].Name.ValueString() != data.PassiveInterfaceDisableHundredGigabitEthernets[j].Name.ValueString() {
+ if state.PassiveInterfaceDisableTenGigabitEthernets[i].Name.ValueString() != data.PassiveInterfaceDisableTenGigabitEthernets[j].Name.ValueString() {
found = false
}
if found {
@@ -2001,14 +4335,19 @@ func (data *OSPF) getDeletedItems(ctx context.Context, state OSPF) []string {
}
}
if !found {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/passive-interface-config/disable-interface/HundredGigabitE=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/%v", predicates))
}
}
- for i := range state.PassiveInterfaceDisableFortyGigabitEthernets {
- stateKeyValues := [...]string{state.PassiveInterfaceDisableFortyGigabitEthernets[i].Name.ValueString()}
+ for i := range state.PassiveInterfaceDisableTwentyFiveGigabitEthernets {
+ stateKeys := [...]string{""}
+ stateKeyValues := [...]string{state.PassiveInterfaceDisableTwentyFiveGigabitEthernets[i].Name.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
emptyKeys := true
- if !reflect.ValueOf(state.PassiveInterfaceDisableFortyGigabitEthernets[i].Name.ValueString()).IsZero() {
+ if !reflect.ValueOf(state.PassiveInterfaceDisableTwentyFiveGigabitEthernets[i].Name.ValueString()).IsZero() {
emptyKeys = false
}
if emptyKeys {
@@ -2016,9 +4355,9 @@ func (data *OSPF) getDeletedItems(ctx context.Context, state OSPF) []string {
}
found := false
- for j := range data.PassiveInterfaceDisableFortyGigabitEthernets {
+ for j := range data.PassiveInterfaceDisableTwentyFiveGigabitEthernets {
found = true
- if state.PassiveInterfaceDisableFortyGigabitEthernets[i].Name.ValueString() != data.PassiveInterfaceDisableFortyGigabitEthernets[j].Name.ValueString() {
+ if state.PassiveInterfaceDisableTwentyFiveGigabitEthernets[i].Name.ValueString() != data.PassiveInterfaceDisableTwentyFiveGigabitEthernets[j].Name.ValueString() {
found = false
}
if found {
@@ -2026,14 +4365,19 @@ func (data *OSPF) getDeletedItems(ctx context.Context, state OSPF) []string {
}
}
if !found {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/passive-interface-config/disable-interface/FortyGigabitEthernet=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/%v", predicates))
}
}
- for i := range state.PassiveInterfaceDisableTwentyFiveGigabitEthernets {
- stateKeyValues := [...]string{state.PassiveInterfaceDisableTwentyFiveGigabitEthernets[i].Name.ValueString()}
+ for i := range state.PassiveInterfaceDisableFortyGigabitEthernets {
+ stateKeys := [...]string{""}
+ stateKeyValues := [...]string{state.PassiveInterfaceDisableFortyGigabitEthernets[i].Name.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
emptyKeys := true
- if !reflect.ValueOf(state.PassiveInterfaceDisableTwentyFiveGigabitEthernets[i].Name.ValueString()).IsZero() {
+ if !reflect.ValueOf(state.PassiveInterfaceDisableFortyGigabitEthernets[i].Name.ValueString()).IsZero() {
emptyKeys = false
}
if emptyKeys {
@@ -2041,9 +4385,9 @@ func (data *OSPF) getDeletedItems(ctx context.Context, state OSPF) []string {
}
found := false
- for j := range data.PassiveInterfaceDisableTwentyFiveGigabitEthernets {
+ for j := range data.PassiveInterfaceDisableFortyGigabitEthernets {
found = true
- if state.PassiveInterfaceDisableTwentyFiveGigabitEthernets[i].Name.ValueString() != data.PassiveInterfaceDisableTwentyFiveGigabitEthernets[j].Name.ValueString() {
+ if state.PassiveInterfaceDisableFortyGigabitEthernets[i].Name.ValueString() != data.PassiveInterfaceDisableFortyGigabitEthernets[j].Name.ValueString() {
found = false
}
if found {
@@ -2051,14 +4395,19 @@ func (data *OSPF) getDeletedItems(ctx context.Context, state OSPF) []string {
}
}
if !found {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/passive-interface-config/disable-interface/TwentyFiveGigabitE=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/%v", predicates))
}
}
- for i := range state.PassiveInterfaceDisableTenGigabitEthernets {
- stateKeyValues := [...]string{state.PassiveInterfaceDisableTenGigabitEthernets[i].Name.ValueString()}
+ for i := range state.PassiveInterfaceDisableHundredGigabitEthernets {
+ stateKeys := [...]string{""}
+ stateKeyValues := [...]string{state.PassiveInterfaceDisableHundredGigabitEthernets[i].Name.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
emptyKeys := true
- if !reflect.ValueOf(state.PassiveInterfaceDisableTenGigabitEthernets[i].Name.ValueString()).IsZero() {
+ if !reflect.ValueOf(state.PassiveInterfaceDisableHundredGigabitEthernets[i].Name.ValueString()).IsZero() {
emptyKeys = false
}
if emptyKeys {
@@ -2066,9 +4415,9 @@ func (data *OSPF) getDeletedItems(ctx context.Context, state OSPF) []string {
}
found := false
- for j := range data.PassiveInterfaceDisableTenGigabitEthernets {
+ for j := range data.PassiveInterfaceDisableHundredGigabitEthernets {
found = true
- if state.PassiveInterfaceDisableTenGigabitEthernets[i].Name.ValueString() != data.PassiveInterfaceDisableTenGigabitEthernets[j].Name.ValueString() {
+ if state.PassiveInterfaceDisableHundredGigabitEthernets[i].Name.ValueString() != data.PassiveInterfaceDisableHundredGigabitEthernets[j].Name.ValueString() {
found = false
}
if found {
@@ -2076,14 +4425,19 @@ func (data *OSPF) getDeletedItems(ctx context.Context, state OSPF) []string {
}
}
if !found {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/passive-interface-config/disable-interface/TenGigabitEthernet=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/%v", predicates))
}
}
- for i := range state.PassiveInterfaceDisableFiveGigabitEthernets {
- stateKeyValues := [...]string{state.PassiveInterfaceDisableFiveGigabitEthernets[i].Name.ValueString()}
+ for i := range state.PassiveInterfaceDisableTwoHundredGigabitEthernets {
+ stateKeys := [...]string{""}
+ stateKeyValues := [...]string{state.PassiveInterfaceDisableTwoHundredGigabitEthernets[i].Name.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
emptyKeys := true
- if !reflect.ValueOf(state.PassiveInterfaceDisableFiveGigabitEthernets[i].Name.ValueString()).IsZero() {
+ if !reflect.ValueOf(state.PassiveInterfaceDisableTwoHundredGigabitEthernets[i].Name.ValueString()).IsZero() {
emptyKeys = false
}
if emptyKeys {
@@ -2091,9 +4445,9 @@ func (data *OSPF) getDeletedItems(ctx context.Context, state OSPF) []string {
}
found := false
- for j := range data.PassiveInterfaceDisableFiveGigabitEthernets {
+ for j := range data.PassiveInterfaceDisableTwoHundredGigabitEthernets {
found = true
- if state.PassiveInterfaceDisableFiveGigabitEthernets[i].Name.ValueString() != data.PassiveInterfaceDisableFiveGigabitEthernets[j].Name.ValueString() {
+ if state.PassiveInterfaceDisableTwoHundredGigabitEthernets[i].Name.ValueString() != data.PassiveInterfaceDisableTwoHundredGigabitEthernets[j].Name.ValueString() {
found = false
}
if found {
@@ -2101,14 +4455,19 @@ func (data *OSPF) getDeletedItems(ctx context.Context, state OSPF) []string {
}
}
if !found {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/passive-interface-config/disable-interface/FiveGigabitEthernet=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/%v", predicates))
}
}
- for i := range state.PassiveInterfaceDisableTwoGigabitEthernets {
- stateKeyValues := [...]string{state.PassiveInterfaceDisableTwoGigabitEthernets[i].Name.ValueString()}
+ for i := range state.PassiveInterfaceDisableFourHundredGigabitEthernets {
+ stateKeys := [...]string{""}
+ stateKeyValues := [...]string{state.PassiveInterfaceDisableFourHundredGigabitEthernets[i].Name.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
emptyKeys := true
- if !reflect.ValueOf(state.PassiveInterfaceDisableTwoGigabitEthernets[i].Name.ValueString()).IsZero() {
+ if !reflect.ValueOf(state.PassiveInterfaceDisableFourHundredGigabitEthernets[i].Name.ValueString()).IsZero() {
emptyKeys = false
}
if emptyKeys {
@@ -2116,9 +4475,9 @@ func (data *OSPF) getDeletedItems(ctx context.Context, state OSPF) []string {
}
found := false
- for j := range data.PassiveInterfaceDisableTwoGigabitEthernets {
+ for j := range data.PassiveInterfaceDisableFourHundredGigabitEthernets {
found = true
- if state.PassiveInterfaceDisableTwoGigabitEthernets[i].Name.ValueString() != data.PassiveInterfaceDisableTwoGigabitEthernets[j].Name.ValueString() {
+ if state.PassiveInterfaceDisableFourHundredGigabitEthernets[i].Name.ValueString() != data.PassiveInterfaceDisableFourHundredGigabitEthernets[j].Name.ValueString() {
found = false
}
if found {
@@ -2126,14 +4485,19 @@ func (data *OSPF) getDeletedItems(ctx context.Context, state OSPF) []string {
}
}
if !found {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/passive-interface-config/disable-interface/TwoGigabitEthernet=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/%v", predicates))
}
}
- for i := range state.PassiveInterfaceDisableGigabitEthernets {
- stateKeyValues := [...]string{state.PassiveInterfaceDisableGigabitEthernets[i].Name.ValueString()}
+ for i := range state.PassiveInterfaceDisableLoopbacks {
+ stateKeys := [...]string{""}
+ stateKeyValues := [...]string{state.PassiveInterfaceDisableLoopbacks[i].Name.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
emptyKeys := true
- if !reflect.ValueOf(state.PassiveInterfaceDisableGigabitEthernets[i].Name.ValueString()).IsZero() {
+ if !reflect.ValueOf(state.PassiveInterfaceDisableLoopbacks[i].Name.ValueString()).IsZero() {
emptyKeys = false
}
if emptyKeys {
@@ -2141,51 +4505,29 @@ func (data *OSPF) getDeletedItems(ctx context.Context, state OSPF) []string {
}
found := false
- for j := range data.PassiveInterfaceDisableGigabitEthernets {
+ for j := range data.PassiveInterfaceDisableLoopbacks {
found = true
- if state.PassiveInterfaceDisableGigabitEthernets[i].Name.ValueString() != data.PassiveInterfaceDisableGigabitEthernets[j].Name.ValueString() {
+ if state.PassiveInterfaceDisableLoopbacks[i].Name.ValueString() != data.PassiveInterfaceDisableLoopbacks[j].Name.ValueString() {
found = false
}
- if found {
- break
- }
- }
- if !found {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/passive-interface-config/disable-interface/GigabitEthernet=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
- }
- }
- if !state.PassiveInterface.IsNull() {
- if data.PassiveInterface.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/passive-interface/interface", state.getPath()))
- } else {
- var dataValues, stateValues []string
- data.PassiveInterface.ElementsAs(ctx, &dataValues, false)
- state.PassiveInterface.ElementsAs(ctx, &stateValues, false)
- for _, v := range stateValues {
- found := false
- for _, vv := range dataValues {
- if v == vv {
- found = true
- break
- }
- }
- if !found {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/passive-interface/interface=%v", state.getPath(), v))
- }
+ if found {
+ break
}
}
+ if !found {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/%v", predicates))
+ }
}
- if !state.PassiveInterfaceDefault.IsNull() && data.PassiveInterfaceDefault.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/passive-interface/default", state.getPath()))
- }
- if !state.AutoCostReferenceBandwidth.IsNull() && data.AutoCostReferenceBandwidth.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/auto-cost/reference-bandwidth", state.getPath()))
- }
- for i := range state.Areas {
- stateKeyValues := [...]string{state.Areas[i].AreaId.ValueString()}
+ for i := range state.PassiveInterfaceDisableVlans {
+ stateKeys := [...]string{""}
+ stateKeyValues := [...]string{state.PassiveInterfaceDisableVlans[i].Name.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
emptyKeys := true
- if !reflect.ValueOf(state.Areas[i].AreaId.ValueString()).IsZero() {
+ if !reflect.ValueOf(state.PassiveInterfaceDisableVlans[i].Name.ValueString()).IsZero() {
emptyKeys = false
}
if emptyKeys {
@@ -2193,45 +4535,29 @@ func (data *OSPF) getDeletedItems(ctx context.Context, state OSPF) []string {
}
found := false
- for j := range data.Areas {
+ for j := range data.PassiveInterfaceDisableVlans {
found = true
- if state.Areas[i].AreaId.ValueString() != data.Areas[j].AreaId.ValueString() {
+ if state.PassiveInterfaceDisableVlans[i].Name.ValueString() != data.PassiveInterfaceDisableVlans[j].Name.ValueString() {
found = false
}
if found {
- if !state.Areas[i].NssaNoRedistribution.IsNull() && data.Areas[j].NssaNoRedistribution.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/area=%v/nssa/nssa-options/no-redistribution", state.getPath(), strings.Join(stateKeyValues[:], ",")))
- }
- if !state.Areas[i].NssaNoSummary.IsNull() && data.Areas[j].NssaNoSummary.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/area=%v/nssa/nssa-options/no-summary", state.getPath(), strings.Join(stateKeyValues[:], ",")))
- }
- if !state.Areas[i].NssaDefaultInformationOriginateMetricType.IsNull() && data.Areas[j].NssaDefaultInformationOriginateMetricType.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/area=%v/nssa/nssa-options/default-information-originate/metric-type", state.getPath(), strings.Join(stateKeyValues[:], ",")))
- }
- if !state.Areas[i].NssaDefaultInformationOriginateMetric.IsNull() && data.Areas[j].NssaDefaultInformationOriginateMetric.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/area=%v/nssa/nssa-options/default-information-originate/metric", state.getPath(), strings.Join(stateKeyValues[:], ",")))
- }
- if !state.Areas[i].NssaDefaultInformationOriginate.IsNull() && data.Areas[j].NssaDefaultInformationOriginate.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/area=%v/nssa/nssa-options/default-information-originate", state.getPath(), strings.Join(stateKeyValues[:], ",")))
- }
- if !state.Areas[i].Nssa.IsNull() && data.Areas[j].Nssa.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/area=%v/nssa", state.getPath(), strings.Join(stateKeyValues[:], ",")))
- }
- if !state.Areas[i].AuthenticationMessageDigest.IsNull() && data.Areas[j].AuthenticationMessageDigest.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/area=%v/authentication/message-digest", state.getPath(), strings.Join(stateKeyValues[:], ",")))
- }
break
}
}
if !found {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/area=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/%v", predicates))
}
}
- for i := range state.SummaryAddresses {
- stateKeyValues := [...]string{state.SummaryAddresses[i].Ip.ValueString()}
+ for i := range state.PassiveInterfaceDisableTunnels {
+ stateKeys := [...]string{""}
+ stateKeyValues := [...]string{state.PassiveInterfaceDisableTunnels[i].Name.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
emptyKeys := true
- if !reflect.ValueOf(state.SummaryAddresses[i].Ip.ValueString()).IsZero() {
+ if !reflect.ValueOf(state.PassiveInterfaceDisableTunnels[i].Name.ValueString()).IsZero() {
emptyKeys = false
}
if emptyKeys {
@@ -2239,36 +4565,29 @@ func (data *OSPF) getDeletedItems(ctx context.Context, state OSPF) []string {
}
found := false
- for j := range data.SummaryAddresses {
+ for j := range data.PassiveInterfaceDisableTunnels {
found = true
- if state.SummaryAddresses[i].Ip.ValueString() != data.SummaryAddresses[j].Ip.ValueString() {
+ if state.PassiveInterfaceDisableTunnels[i].Name.ValueString() != data.PassiveInterfaceDisableTunnels[j].Name.ValueString() {
found = false
}
if found {
- if !state.SummaryAddresses[i].Mask.IsNull() && data.SummaryAddresses[j].Mask.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/summary-address=%v/mask", state.getPath(), strings.Join(stateKeyValues[:], ",")))
- }
break
}
}
if !found {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/summary-address=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/%v", predicates))
}
}
- if !state.Shutdown.IsNull() && data.Shutdown.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/shutdown", state.getPath()))
- }
- if !state.RouterId.IsNull() && data.RouterId.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/router-id", state.getPath()))
- }
- if !state.Priority.IsNull() && data.Priority.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/priority", state.getPath()))
- }
- for i := range state.Networks {
- stateKeyValues := [...]string{state.Networks[i].Ip.ValueString()}
+ for i := range state.PassiveInterfaceDisablePortChannels {
+ stateKeys := [...]string{""}
+ stateKeyValues := [...]string{state.PassiveInterfaceDisablePortChannels[i].Name.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
emptyKeys := true
- if !reflect.ValueOf(state.Networks[i].Ip.ValueString()).IsZero() {
+ if !reflect.ValueOf(state.PassiveInterfaceDisablePortChannels[i].Name.ValueString()).IsZero() {
emptyKeys = false
}
if emptyKeys {
@@ -2276,30 +4595,29 @@ func (data *OSPF) getDeletedItems(ctx context.Context, state OSPF) []string {
}
found := false
- for j := range data.Networks {
+ for j := range data.PassiveInterfaceDisablePortChannels {
found = true
- if state.Networks[i].Ip.ValueString() != data.Networks[j].Ip.ValueString() {
+ if state.PassiveInterfaceDisablePortChannels[i].Name.ValueString() != data.PassiveInterfaceDisablePortChannels[j].Name.ValueString() {
found = false
}
if found {
- if !state.Networks[i].Area.IsNull() && data.Networks[j].Area.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/network=%v/area", state.getPath(), strings.Join(stateKeyValues[:], ",")))
- }
- if !state.Networks[i].Wildcard.IsNull() && data.Networks[j].Wildcard.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/network=%v/wildcard", state.getPath(), strings.Join(stateKeyValues[:], ",")))
- }
break
}
}
if !found {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/network=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/%v", predicates))
}
}
- for i := range state.Neighbors {
- stateKeyValues := [...]string{state.Neighbors[i].Ip.ValueString()}
+ for i := range state.PassiveInterfaceDisablePortChannelSubinterfaces {
+ stateKeys := [...]string{""}
+ stateKeyValues := [...]string{state.PassiveInterfaceDisablePortChannelSubinterfaces[i].Name.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
emptyKeys := true
- if !reflect.ValueOf(state.Neighbors[i].Ip.ValueString()).IsZero() {
+ if !reflect.ValueOf(state.PassiveInterfaceDisablePortChannelSubinterfaces[i].Name.ValueString()).IsZero() {
emptyKeys = false
}
if emptyKeys {
@@ -2307,54 +4625,24 @@ func (data *OSPF) getDeletedItems(ctx context.Context, state OSPF) []string {
}
found := false
- for j := range data.Neighbors {
+ for j := range data.PassiveInterfaceDisablePortChannelSubinterfaces {
found = true
- if state.Neighbors[i].Ip.ValueString() != data.Neighbors[j].Ip.ValueString() {
+ if state.PassiveInterfaceDisablePortChannelSubinterfaces[i].Name.ValueString() != data.PassiveInterfaceDisablePortChannelSubinterfaces[j].Name.ValueString() {
found = false
}
if found {
- if !state.Neighbors[i].Cost.IsNull() && data.Neighbors[j].Cost.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/neighbor=%v/cost", state.getPath(), strings.Join(stateKeyValues[:], ",")))
- }
- if !state.Neighbors[i].Priority.IsNull() && data.Neighbors[j].Priority.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/neighbor=%v/priority", state.getPath(), strings.Join(stateKeyValues[:], ",")))
- }
break
}
}
if !found {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/neighbor=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/%v", predicates))
}
}
- if !state.MplsLdpSync.IsNull() && data.MplsLdpSync.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/mpls/ldp/sync", state.getPath()))
- }
- if !state.MplsLdpAutoconfig.IsNull() && data.MplsLdpAutoconfig.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/mpls/ldp/autoconfig", state.getPath()))
- }
- if !state.DomainTag.IsNull() && data.DomainTag.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/domain-tag", state.getPath()))
- }
- if !state.Distance.IsNull() && data.Distance.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/distance/distance", state.getPath()))
- }
- if !state.DefaultMetric.IsNull() && data.DefaultMetric.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/default-metric", state.getPath()))
- }
- if !state.DefaultInformationOriginateAlways.IsNull() && data.DefaultInformationOriginateAlways.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/default-information/originate/always", state.getPath()))
- }
- if !state.DefaultInformationOriginate.IsNull() && data.DefaultInformationOriginate.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/default-information/originate", state.getPath()))
- }
- if !state.BfdAllInterfaces.IsNull() && data.BfdAllInterfaces.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/bfd/all-interfaces", state.getPath()))
- }
- return deletedItems
+ return b.Res()
}
-// End of section. //template:end getDeletedItems
+// End of section. //template:end addDeletedItemsXML
// Section below is generated&owned by "gen/generator.go". //template:begin getEmptyLeafsDelete
@@ -2408,72 +4696,72 @@ func (data *OSPF) getDeletePaths(ctx context.Context) []string {
for i := range data.PassiveInterfaceDisablePortChannelSubinterfaces {
keyValues := [...]string{data.PassiveInterfaceDisablePortChannelSubinterfaces[i].Name.ValueString()}
- deletePaths = append(deletePaths, fmt.Sprintf("%v/passive-interface-config/disable-interface/Port-channel-subinterface/Port-channel=%v", data.getPath(), strings.Join(keyValues[:], ",")))
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/=%v", data.getPath(), strings.Join(keyValues[:], ",")))
}
for i := range data.PassiveInterfaceDisablePortChannels {
keyValues := [...]string{data.PassiveInterfaceDisablePortChannels[i].Name.ValueString()}
- deletePaths = append(deletePaths, fmt.Sprintf("%v/passive-interface-config/disable-interface/Port-channel=%v", data.getPath(), strings.Join(keyValues[:], ",")))
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/=%v", data.getPath(), strings.Join(keyValues[:], ",")))
}
for i := range data.PassiveInterfaceDisableTunnels {
keyValues := [...]string{data.PassiveInterfaceDisableTunnels[i].Name.ValueString()}
- deletePaths = append(deletePaths, fmt.Sprintf("%v/passive-interface-config/disable-interface/Tunnel=%v", data.getPath(), strings.Join(keyValues[:], ",")))
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/=%v", data.getPath(), strings.Join(keyValues[:], ",")))
}
for i := range data.PassiveInterfaceDisableVlans {
keyValues := [...]string{data.PassiveInterfaceDisableVlans[i].Name.ValueString()}
- deletePaths = append(deletePaths, fmt.Sprintf("%v/passive-interface-config/disable-interface/Vlan=%v", data.getPath(), strings.Join(keyValues[:], ",")))
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/=%v", data.getPath(), strings.Join(keyValues[:], ",")))
}
for i := range data.PassiveInterfaceDisableLoopbacks {
keyValues := [...]string{data.PassiveInterfaceDisableLoopbacks[i].Name.ValueString()}
- deletePaths = append(deletePaths, fmt.Sprintf("%v/passive-interface-config/disable-interface/Loopback=%v", data.getPath(), strings.Join(keyValues[:], ",")))
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/=%v", data.getPath(), strings.Join(keyValues[:], ",")))
}
for i := range data.PassiveInterfaceDisableFourHundredGigabitEthernets {
keyValues := [...]string{data.PassiveInterfaceDisableFourHundredGigabitEthernets[i].Name.ValueString()}
- deletePaths = append(deletePaths, fmt.Sprintf("%v/passive-interface-config/disable-interface/FourHundredGigabitE=%v", data.getPath(), strings.Join(keyValues[:], ",")))
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/=%v", data.getPath(), strings.Join(keyValues[:], ",")))
}
for i := range data.PassiveInterfaceDisableTwoHundredGigabitEthernets {
keyValues := [...]string{data.PassiveInterfaceDisableTwoHundredGigabitEthernets[i].Name.ValueString()}
- deletePaths = append(deletePaths, fmt.Sprintf("%v/passive-interface-config/disable-interface/TwoHundredGigabitE=%v", data.getPath(), strings.Join(keyValues[:], ",")))
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/=%v", data.getPath(), strings.Join(keyValues[:], ",")))
}
for i := range data.PassiveInterfaceDisableHundredGigabitEthernets {
keyValues := [...]string{data.PassiveInterfaceDisableHundredGigabitEthernets[i].Name.ValueString()}
- deletePaths = append(deletePaths, fmt.Sprintf("%v/passive-interface-config/disable-interface/HundredGigabitE=%v", data.getPath(), strings.Join(keyValues[:], ",")))
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/=%v", data.getPath(), strings.Join(keyValues[:], ",")))
}
for i := range data.PassiveInterfaceDisableFortyGigabitEthernets {
keyValues := [...]string{data.PassiveInterfaceDisableFortyGigabitEthernets[i].Name.ValueString()}
- deletePaths = append(deletePaths, fmt.Sprintf("%v/passive-interface-config/disable-interface/FortyGigabitEthernet=%v", data.getPath(), strings.Join(keyValues[:], ",")))
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/=%v", data.getPath(), strings.Join(keyValues[:], ",")))
}
for i := range data.PassiveInterfaceDisableTwentyFiveGigabitEthernets {
keyValues := [...]string{data.PassiveInterfaceDisableTwentyFiveGigabitEthernets[i].Name.ValueString()}
- deletePaths = append(deletePaths, fmt.Sprintf("%v/passive-interface-config/disable-interface/TwentyFiveGigabitE=%v", data.getPath(), strings.Join(keyValues[:], ",")))
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/=%v", data.getPath(), strings.Join(keyValues[:], ",")))
}
for i := range data.PassiveInterfaceDisableTenGigabitEthernets {
keyValues := [...]string{data.PassiveInterfaceDisableTenGigabitEthernets[i].Name.ValueString()}
- deletePaths = append(deletePaths, fmt.Sprintf("%v/passive-interface-config/disable-interface/TenGigabitEthernet=%v", data.getPath(), strings.Join(keyValues[:], ",")))
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/=%v", data.getPath(), strings.Join(keyValues[:], ",")))
}
for i := range data.PassiveInterfaceDisableFiveGigabitEthernets {
keyValues := [...]string{data.PassiveInterfaceDisableFiveGigabitEthernets[i].Name.ValueString()}
- deletePaths = append(deletePaths, fmt.Sprintf("%v/passive-interface-config/disable-interface/FiveGigabitEthernet=%v", data.getPath(), strings.Join(keyValues[:], ",")))
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/=%v", data.getPath(), strings.Join(keyValues[:], ",")))
}
for i := range data.PassiveInterfaceDisableTwoGigabitEthernets {
keyValues := [...]string{data.PassiveInterfaceDisableTwoGigabitEthernets[i].Name.ValueString()}
- deletePaths = append(deletePaths, fmt.Sprintf("%v/passive-interface-config/disable-interface/TwoGigabitEthernet=%v", data.getPath(), strings.Join(keyValues[:], ",")))
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/=%v", data.getPath(), strings.Join(keyValues[:], ",")))
}
for i := range data.PassiveInterfaceDisableGigabitEthernets {
keyValues := [...]string{data.PassiveInterfaceDisableGigabitEthernets[i].Name.ValueString()}
- deletePaths = append(deletePaths, fmt.Sprintf("%v/passive-interface-config/disable-interface/GigabitEthernet=%v", data.getPath(), strings.Join(keyValues[:], ",")))
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/=%v", data.getPath(), strings.Join(keyValues[:], ",")))
}
if !data.PassiveInterface.IsNull() {
deletePaths = append(deletePaths, fmt.Sprintf("%v/passive-interface/interface", data.getPath()))
@@ -2542,3 +4830,235 @@ func (data *OSPF) getDeletePaths(ctx context.Context) []string {
}
// End of section. //template:end getDeletePaths
+
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletePathsXML
+
+func (data *OSPF) addDeletePathsXML(ctx context.Context, body string) string {
+ b := netconf.NewBody(body)
+ if !data.BfdAllInterfaces.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/bfd/all-interfaces")
+ }
+ if !data.DefaultInformationOriginate.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/default-information/originate")
+ }
+ if !data.DefaultInformationOriginateAlways.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/default-information/originate/always")
+ }
+ if !data.DefaultMetric.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/default-metric")
+ }
+ if !data.Distance.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/distance/distance")
+ }
+ if !data.DomainTag.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/domain-tag")
+ }
+ if !data.MplsLdpAutoconfig.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/mpls/ldp/autoconfig")
+ }
+ if !data.MplsLdpSync.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/mpls/ldp/sync")
+ }
+ for i := range data.Neighbors {
+ keys := [...]string{"ip"}
+ keyValues := [...]string{data.Neighbors[i].Ip.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/neighbor%v", predicates))
+ }
+ for i := range data.Networks {
+ keys := [...]string{"ip"}
+ keyValues := [...]string{data.Networks[i].Ip.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/network%v", predicates))
+ }
+ if !data.Priority.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/priority")
+ }
+ if !data.RouterId.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/router-id")
+ }
+ if !data.Shutdown.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/shutdown")
+ }
+ for i := range data.SummaryAddresses {
+ keys := [...]string{"ip"}
+ keyValues := [...]string{data.SummaryAddresses[i].Ip.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/summary-address%v", predicates))
+ }
+ for i := range data.Areas {
+ keys := [...]string{"area-id"}
+ keyValues := [...]string{data.Areas[i].AreaId.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/area%v", predicates))
+ }
+ if !data.AutoCostReferenceBandwidth.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/auto-cost/reference-bandwidth")
+ }
+ if !data.PassiveInterfaceDefault.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/passive-interface/default")
+ }
+ if !data.PassiveInterface.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/passive-interface/interface")
+ }
+ for i := range data.PassiveInterfaceDisableGigabitEthernets {
+ keys := [...]string{""}
+ keyValues := [...]string{data.PassiveInterfaceDisableGigabitEthernets[i].Name.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/%v", predicates))
+ }
+ for i := range data.PassiveInterfaceDisableTwoGigabitEthernets {
+ keys := [...]string{""}
+ keyValues := [...]string{data.PassiveInterfaceDisableTwoGigabitEthernets[i].Name.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/%v", predicates))
+ }
+ for i := range data.PassiveInterfaceDisableFiveGigabitEthernets {
+ keys := [...]string{""}
+ keyValues := [...]string{data.PassiveInterfaceDisableFiveGigabitEthernets[i].Name.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/%v", predicates))
+ }
+ for i := range data.PassiveInterfaceDisableTenGigabitEthernets {
+ keys := [...]string{""}
+ keyValues := [...]string{data.PassiveInterfaceDisableTenGigabitEthernets[i].Name.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/%v", predicates))
+ }
+ for i := range data.PassiveInterfaceDisableTwentyFiveGigabitEthernets {
+ keys := [...]string{""}
+ keyValues := [...]string{data.PassiveInterfaceDisableTwentyFiveGigabitEthernets[i].Name.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/%v", predicates))
+ }
+ for i := range data.PassiveInterfaceDisableFortyGigabitEthernets {
+ keys := [...]string{""}
+ keyValues := [...]string{data.PassiveInterfaceDisableFortyGigabitEthernets[i].Name.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/%v", predicates))
+ }
+ for i := range data.PassiveInterfaceDisableHundredGigabitEthernets {
+ keys := [...]string{""}
+ keyValues := [...]string{data.PassiveInterfaceDisableHundredGigabitEthernets[i].Name.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/%v", predicates))
+ }
+ for i := range data.PassiveInterfaceDisableTwoHundredGigabitEthernets {
+ keys := [...]string{""}
+ keyValues := [...]string{data.PassiveInterfaceDisableTwoHundredGigabitEthernets[i].Name.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/%v", predicates))
+ }
+ for i := range data.PassiveInterfaceDisableFourHundredGigabitEthernets {
+ keys := [...]string{""}
+ keyValues := [...]string{data.PassiveInterfaceDisableFourHundredGigabitEthernets[i].Name.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/%v", predicates))
+ }
+ for i := range data.PassiveInterfaceDisableLoopbacks {
+ keys := [...]string{""}
+ keyValues := [...]string{data.PassiveInterfaceDisableLoopbacks[i].Name.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/%v", predicates))
+ }
+ for i := range data.PassiveInterfaceDisableVlans {
+ keys := [...]string{""}
+ keyValues := [...]string{data.PassiveInterfaceDisableVlans[i].Name.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/%v", predicates))
+ }
+ for i := range data.PassiveInterfaceDisableTunnels {
+ keys := [...]string{""}
+ keyValues := [...]string{data.PassiveInterfaceDisableTunnels[i].Name.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/%v", predicates))
+ }
+ for i := range data.PassiveInterfaceDisablePortChannels {
+ keys := [...]string{""}
+ keyValues := [...]string{data.PassiveInterfaceDisablePortChannels[i].Name.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/%v", predicates))
+ }
+ for i := range data.PassiveInterfaceDisablePortChannelSubinterfaces {
+ keys := [...]string{""}
+ keyValues := [...]string{data.PassiveInterfaceDisablePortChannelSubinterfaces[i].Name.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/%v", predicates))
+ }
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletePathsXML
diff --git a/internal/provider/model_iosxe_ospf_vrf.go b/internal/provider/model_iosxe_ospf_vrf.go
index 1b679246..e8fcc786 100644
--- a/internal/provider/model_iosxe_ospf_vrf.go
+++ b/internal/provider/model_iosxe_ospf_vrf.go
@@ -31,6 +31,9 @@ import (
"github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/types"
+ "github.com/hashicorp/terraform-plugin-log/tflog"
+ "github.com/netascode/go-netconf"
+ "github.com/netascode/xmldot"
"github.com/tidwall/gjson"
"github.com/tidwall/sjson"
)
@@ -206,6 +209,19 @@ func (data OSPFVRF) getPathShort() string {
return matches[1]
}
+// getXPath returns the XPath for NETCONF operations
+func (data OSPFVRF) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/router/Cisco-IOS-XE-ospf:router-ospf/ospf/process-id-vrf[id=%v][vrf=%s]"
+ path = fmt.Sprintf(path, fmt.Sprintf("%v", data.ProcessId.ValueInt64()), fmt.Sprintf("%v", data.Vrf.ValueString()))
+ return path
+}
+
+func (data OSPFVRFData) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/router/Cisco-IOS-XE-ospf:router-ospf/ospf/process-id-vrf[id=%v][vrf=%s]"
+ path = fmt.Sprintf(path, fmt.Sprintf("%v", data.ProcessId.ValueInt64()), fmt.Sprintf("%v", data.Vrf.ValueString()))
+ return path
+}
+
// End of section. //template:end getPath
// Section below is generated&owned by "gen/generator.go". //template:begin toBody
@@ -351,114 +367,114 @@ func (data OSPFVRF) toBody(ctx context.Context) string {
}
}
if len(data.PassiveInterfaceDisableGigabitEthernets) > 0 {
- body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"passive-interface-config.disable-interface.GigabitEthernet", []interface{}{})
+ body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"", []interface{}{})
for index, item := range data.PassiveInterfaceDisableGigabitEthernets {
if !item.Name.IsNull() && !item.Name.IsUnknown() {
- body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"passive-interface-config.disable-interface.GigabitEthernet"+"."+strconv.Itoa(index)+"."+"name", item.Name.ValueString())
+ body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+""+"."+strconv.Itoa(index)+"."+"", item.Name.ValueString())
}
}
}
if len(data.PassiveInterfaceDisableTwoGigabitEthernets) > 0 {
- body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"passive-interface-config.disable-interface.TwoGigabitEthernet", []interface{}{})
+ body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"", []interface{}{})
for index, item := range data.PassiveInterfaceDisableTwoGigabitEthernets {
if !item.Name.IsNull() && !item.Name.IsUnknown() {
- body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"passive-interface-config.disable-interface.TwoGigabitEthernet"+"."+strconv.Itoa(index)+"."+"name", item.Name.ValueString())
+ body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+""+"."+strconv.Itoa(index)+"."+"", item.Name.ValueString())
}
}
}
if len(data.PassiveInterfaceDisableFiveGigabitEthernets) > 0 {
- body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"passive-interface-config.disable-interface.FiveGigabitEthernet", []interface{}{})
+ body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"", []interface{}{})
for index, item := range data.PassiveInterfaceDisableFiveGigabitEthernets {
if !item.Name.IsNull() && !item.Name.IsUnknown() {
- body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"passive-interface-config.disable-interface.FiveGigabitEthernet"+"."+strconv.Itoa(index)+"."+"name", item.Name.ValueString())
+ body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+""+"."+strconv.Itoa(index)+"."+"", item.Name.ValueString())
}
}
}
if len(data.PassiveInterfaceDisableTenGigabitEthernets) > 0 {
- body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"passive-interface-config.disable-interface.TenGigabitEthernet", []interface{}{})
+ body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"", []interface{}{})
for index, item := range data.PassiveInterfaceDisableTenGigabitEthernets {
if !item.Name.IsNull() && !item.Name.IsUnknown() {
- body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"passive-interface-config.disable-interface.TenGigabitEthernet"+"."+strconv.Itoa(index)+"."+"name", item.Name.ValueString())
+ body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+""+"."+strconv.Itoa(index)+"."+"", item.Name.ValueString())
}
}
}
if len(data.PassiveInterfaceDisableTwentyFiveGigabitEthernets) > 0 {
- body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"passive-interface-config.disable-interface.TwentyFiveGigabitE", []interface{}{})
+ body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"", []interface{}{})
for index, item := range data.PassiveInterfaceDisableTwentyFiveGigabitEthernets {
if !item.Name.IsNull() && !item.Name.IsUnknown() {
- body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"passive-interface-config.disable-interface.TwentyFiveGigabitE"+"."+strconv.Itoa(index)+"."+"name", item.Name.ValueString())
+ body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+""+"."+strconv.Itoa(index)+"."+"", item.Name.ValueString())
}
}
}
if len(data.PassiveInterfaceDisableFortyGigabitEthernets) > 0 {
- body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"passive-interface-config.disable-interface.FortyGigabitEthernet", []interface{}{})
+ body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"", []interface{}{})
for index, item := range data.PassiveInterfaceDisableFortyGigabitEthernets {
if !item.Name.IsNull() && !item.Name.IsUnknown() {
- body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"passive-interface-config.disable-interface.FortyGigabitEthernet"+"."+strconv.Itoa(index)+"."+"name", item.Name.ValueString())
+ body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+""+"."+strconv.Itoa(index)+"."+"", item.Name.ValueString())
}
}
}
if len(data.PassiveInterfaceDisableHundredGigabitEthernets) > 0 {
- body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"passive-interface-config.disable-interface.HundredGigabitE", []interface{}{})
+ body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"", []interface{}{})
for index, item := range data.PassiveInterfaceDisableHundredGigabitEthernets {
if !item.Name.IsNull() && !item.Name.IsUnknown() {
- body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"passive-interface-config.disable-interface.HundredGigabitE"+"."+strconv.Itoa(index)+"."+"name", item.Name.ValueString())
+ body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+""+"."+strconv.Itoa(index)+"."+"", item.Name.ValueString())
}
}
}
if len(data.PassiveInterfaceDisableTwoHundredGigabitEthernets) > 0 {
- body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"passive-interface-config.disable-interface.TwoHundredGigabitE", []interface{}{})
+ body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"", []interface{}{})
for index, item := range data.PassiveInterfaceDisableTwoHundredGigabitEthernets {
if !item.Name.IsNull() && !item.Name.IsUnknown() {
- body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"passive-interface-config.disable-interface.TwoHundredGigabitE"+"."+strconv.Itoa(index)+"."+"name", item.Name.ValueString())
+ body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+""+"."+strconv.Itoa(index)+"."+"", item.Name.ValueString())
}
}
}
if len(data.PassiveInterfaceDisableFourHundredGigabitEthernets) > 0 {
- body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"passive-interface-config.disable-interface.FourHundredGigabitE", []interface{}{})
+ body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"", []interface{}{})
for index, item := range data.PassiveInterfaceDisableFourHundredGigabitEthernets {
if !item.Name.IsNull() && !item.Name.IsUnknown() {
- body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"passive-interface-config.disable-interface.FourHundredGigabitE"+"."+strconv.Itoa(index)+"."+"name", item.Name.ValueString())
+ body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+""+"."+strconv.Itoa(index)+"."+"", item.Name.ValueString())
}
}
}
if len(data.PassiveInterfaceDisableLoopbacks) > 0 {
- body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"passive-interface-config.disable-interface.Loopback", []interface{}{})
+ body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"", []interface{}{})
for index, item := range data.PassiveInterfaceDisableLoopbacks {
if !item.Name.IsNull() && !item.Name.IsUnknown() {
- body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"passive-interface-config.disable-interface.Loopback"+"."+strconv.Itoa(index)+"."+"name", item.Name.ValueString())
+ body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+""+"."+strconv.Itoa(index)+"."+"", item.Name.ValueString())
}
}
}
if len(data.PassiveInterfaceDisableVlans) > 0 {
- body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"passive-interface-config.disable-interface.Vlan", []interface{}{})
+ body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"", []interface{}{})
for index, item := range data.PassiveInterfaceDisableVlans {
if !item.Name.IsNull() && !item.Name.IsUnknown() {
- body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"passive-interface-config.disable-interface.Vlan"+"."+strconv.Itoa(index)+"."+"name", item.Name.ValueString())
+ body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+""+"."+strconv.Itoa(index)+"."+"", item.Name.ValueString())
}
}
}
if len(data.PassiveInterfaceDisableTunnels) > 0 {
- body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"passive-interface-config.disable-interface.Tunnel", []interface{}{})
+ body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"", []interface{}{})
for index, item := range data.PassiveInterfaceDisableTunnels {
if !item.Name.IsNull() && !item.Name.IsUnknown() {
- body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"passive-interface-config.disable-interface.Tunnel"+"."+strconv.Itoa(index)+"."+"name", item.Name.ValueString())
+ body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+""+"."+strconv.Itoa(index)+"."+"", item.Name.ValueString())
}
}
}
if len(data.PassiveInterfaceDisablePortChannels) > 0 {
- body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"passive-interface-config.disable-interface.Port-channel", []interface{}{})
+ body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"", []interface{}{})
for index, item := range data.PassiveInterfaceDisablePortChannels {
if !item.Name.IsNull() && !item.Name.IsUnknown() {
- body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"passive-interface-config.disable-interface.Port-channel"+"."+strconv.Itoa(index)+"."+"name", item.Name.ValueString())
+ body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+""+"."+strconv.Itoa(index)+"."+"", item.Name.ValueString())
}
}
}
if len(data.PassiveInterfaceDisablePortChannelSubinterfaces) > 0 {
- body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"passive-interface-config.disable-interface.Port-channel-subinterface.Port-channel", []interface{}{})
+ body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"", []interface{}{})
for index, item := range data.PassiveInterfaceDisablePortChannelSubinterfaces {
if !item.Name.IsNull() && !item.Name.IsUnknown() {
- body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"passive-interface-config.disable-interface.Port-channel-subinterface.Port-channel"+"."+strconv.Itoa(index)+"."+"name", item.Name.ValueString())
+ body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+""+"."+strconv.Itoa(index)+"."+"", item.Name.ValueString())
}
}
}
@@ -467,6 +483,309 @@ func (data OSPFVRF) toBody(ctx context.Context) string {
// End of section. //template:end toBody
+// Section below is generated&owned by "gen/generator.go". //template:begin toBodyXML
+
+func (data OSPFVRF) toBodyXML(ctx context.Context) string {
+ body := netconf.Body{}
+ if !data.ProcessId.IsNull() && !data.ProcessId.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/id", strconv.FormatInt(data.ProcessId.ValueInt64(), 10))
+ }
+ if !data.Vrf.IsNull() && !data.Vrf.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/vrf", data.Vrf.ValueString())
+ }
+ if !data.BfdAllInterfaces.IsNull() && !data.BfdAllInterfaces.IsUnknown() {
+ if data.BfdAllInterfaces.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/bfd/all-interfaces", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/bfd/all-interfaces")
+ }
+ }
+ if !data.DefaultInformationOriginate.IsNull() && !data.DefaultInformationOriginate.IsUnknown() {
+ if data.DefaultInformationOriginate.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/default-information/originate", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/default-information/originate")
+ }
+ }
+ if !data.DefaultInformationOriginateAlways.IsNull() && !data.DefaultInformationOriginateAlways.IsUnknown() {
+ if data.DefaultInformationOriginateAlways.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/default-information/originate/always", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/default-information/originate/always")
+ }
+ }
+ if !data.DefaultMetric.IsNull() && !data.DefaultMetric.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/default-metric", strconv.FormatInt(data.DefaultMetric.ValueInt64(), 10))
+ }
+ if !data.Distance.IsNull() && !data.Distance.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/distance/distance", strconv.FormatInt(data.Distance.ValueInt64(), 10))
+ }
+ if !data.DomainTag.IsNull() && !data.DomainTag.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/domain-tag", strconv.FormatInt(data.DomainTag.ValueInt64(), 10))
+ }
+ if !data.MplsLdpAutoconfig.IsNull() && !data.MplsLdpAutoconfig.IsUnknown() {
+ if data.MplsLdpAutoconfig.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/mpls/ldp/autoconfig", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/mpls/ldp/autoconfig")
+ }
+ }
+ if !data.MplsLdpSync.IsNull() && !data.MplsLdpSync.IsUnknown() {
+ if data.MplsLdpSync.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/mpls/ldp/sync", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/mpls/ldp/sync")
+ }
+ }
+ if len(data.Neighbor) > 0 {
+ for _, item := range data.Neighbor {
+ cBody := netconf.Body{}
+ if !item.Ip.IsNull() && !item.Ip.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "ip", item.Ip.ValueString())
+ }
+ if !item.Priority.IsNull() && !item.Priority.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "priority", strconv.FormatInt(item.Priority.ValueInt64(), 10))
+ }
+ if !item.Cost.IsNull() && !item.Cost.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "cost", strconv.FormatInt(item.Cost.ValueInt64(), 10))
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/neighbor", cBody.Res())
+ }
+ }
+ if len(data.Network) > 0 {
+ for _, item := range data.Network {
+ cBody := netconf.Body{}
+ if !item.Ip.IsNull() && !item.Ip.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "ip", item.Ip.ValueString())
+ }
+ if !item.Wildcard.IsNull() && !item.Wildcard.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "wildcard", item.Wildcard.ValueString())
+ }
+ if !item.Area.IsNull() && !item.Area.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "area", item.Area.ValueString())
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/network", cBody.Res())
+ }
+ }
+ if !data.Priority.IsNull() && !data.Priority.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/priority", strconv.FormatInt(data.Priority.ValueInt64(), 10))
+ }
+ if !data.RouterId.IsNull() && !data.RouterId.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/router-id", data.RouterId.ValueString())
+ }
+ if !data.Shutdown.IsNull() && !data.Shutdown.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/shutdown", data.Shutdown.ValueBool())
+ }
+ if len(data.SummaryAddress) > 0 {
+ for _, item := range data.SummaryAddress {
+ cBody := netconf.Body{}
+ if !item.Ip.IsNull() && !item.Ip.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "ip", item.Ip.ValueString())
+ }
+ if !item.Mask.IsNull() && !item.Mask.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "mask", item.Mask.ValueString())
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/summary-address", cBody.Res())
+ }
+ }
+ if len(data.Areas) > 0 {
+ for _, item := range data.Areas {
+ cBody := netconf.Body{}
+ if !item.AreaId.IsNull() && !item.AreaId.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "area-id", item.AreaId.ValueString())
+ }
+ if !item.AuthenticationMessageDigest.IsNull() && !item.AuthenticationMessageDigest.IsUnknown() {
+ if item.AuthenticationMessageDigest.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "authentication/message-digest", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "authentication/message-digest")
+ }
+ }
+ if !item.Nssa.IsNull() && !item.Nssa.IsUnknown() {
+ if item.Nssa.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "nssa", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "nssa")
+ }
+ }
+ if !item.NssaDefaultInformationOriginate.IsNull() && !item.NssaDefaultInformationOriginate.IsUnknown() {
+ if item.NssaDefaultInformationOriginate.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "nssa/nssa-options/default-information-originate", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "nssa/nssa-options/default-information-originate")
+ }
+ }
+ if !item.NssaDefaultInformationOriginateMetric.IsNull() && !item.NssaDefaultInformationOriginateMetric.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "nssa/nssa-options/default-information-originate/metric", strconv.FormatInt(item.NssaDefaultInformationOriginateMetric.ValueInt64(), 10))
+ }
+ if !item.NssaDefaultInformationOriginateMetricType.IsNull() && !item.NssaDefaultInformationOriginateMetricType.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "nssa/nssa-options/default-information-originate/metric-type", strconv.FormatInt(item.NssaDefaultInformationOriginateMetricType.ValueInt64(), 10))
+ }
+ if !item.NssaNoSummary.IsNull() && !item.NssaNoSummary.IsUnknown() {
+ if item.NssaNoSummary.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "nssa/nssa-options/no-summary", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "nssa/nssa-options/no-summary")
+ }
+ }
+ if !item.NssaNoRedistribution.IsNull() && !item.NssaNoRedistribution.IsUnknown() {
+ if item.NssaNoRedistribution.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "nssa/nssa-options/no-redistribution", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "nssa/nssa-options/no-redistribution")
+ }
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/area", cBody.Res())
+ }
+ }
+ if !data.AutoCostReferenceBandwidth.IsNull() && !data.AutoCostReferenceBandwidth.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/auto-cost/reference-bandwidth", strconv.FormatInt(data.AutoCostReferenceBandwidth.ValueInt64(), 10))
+ }
+ if !data.PassiveInterfaceDefault.IsNull() && !data.PassiveInterfaceDefault.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/passive-interface/default", data.PassiveInterfaceDefault.ValueBool())
+ }
+ if !data.PassiveInterface.IsNull() && !data.PassiveInterface.IsUnknown() {
+ var values []string
+ data.PassiveInterface.ElementsAs(ctx, &values, false)
+ for _, v := range values {
+ body = helpers.AppendFromXPath(body, data.getXPath()+"/passive-interface/interface", v)
+ }
+ }
+ if len(data.PassiveInterfaceDisableGigabitEthernets) > 0 {
+ for _, item := range data.PassiveInterfaceDisableGigabitEthernets {
+ cBody := netconf.Body{}
+ if !item.Name.IsNull() && !item.Name.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "", item.Name.ValueString())
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/", cBody.Res())
+ }
+ }
+ if len(data.PassiveInterfaceDisableTwoGigabitEthernets) > 0 {
+ for _, item := range data.PassiveInterfaceDisableTwoGigabitEthernets {
+ cBody := netconf.Body{}
+ if !item.Name.IsNull() && !item.Name.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "", item.Name.ValueString())
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/", cBody.Res())
+ }
+ }
+ if len(data.PassiveInterfaceDisableFiveGigabitEthernets) > 0 {
+ for _, item := range data.PassiveInterfaceDisableFiveGigabitEthernets {
+ cBody := netconf.Body{}
+ if !item.Name.IsNull() && !item.Name.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "", item.Name.ValueString())
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/", cBody.Res())
+ }
+ }
+ if len(data.PassiveInterfaceDisableTenGigabitEthernets) > 0 {
+ for _, item := range data.PassiveInterfaceDisableTenGigabitEthernets {
+ cBody := netconf.Body{}
+ if !item.Name.IsNull() && !item.Name.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "", item.Name.ValueString())
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/", cBody.Res())
+ }
+ }
+ if len(data.PassiveInterfaceDisableTwentyFiveGigabitEthernets) > 0 {
+ for _, item := range data.PassiveInterfaceDisableTwentyFiveGigabitEthernets {
+ cBody := netconf.Body{}
+ if !item.Name.IsNull() && !item.Name.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "", item.Name.ValueString())
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/", cBody.Res())
+ }
+ }
+ if len(data.PassiveInterfaceDisableFortyGigabitEthernets) > 0 {
+ for _, item := range data.PassiveInterfaceDisableFortyGigabitEthernets {
+ cBody := netconf.Body{}
+ if !item.Name.IsNull() && !item.Name.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "", item.Name.ValueString())
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/", cBody.Res())
+ }
+ }
+ if len(data.PassiveInterfaceDisableHundredGigabitEthernets) > 0 {
+ for _, item := range data.PassiveInterfaceDisableHundredGigabitEthernets {
+ cBody := netconf.Body{}
+ if !item.Name.IsNull() && !item.Name.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "", item.Name.ValueString())
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/", cBody.Res())
+ }
+ }
+ if len(data.PassiveInterfaceDisableTwoHundredGigabitEthernets) > 0 {
+ for _, item := range data.PassiveInterfaceDisableTwoHundredGigabitEthernets {
+ cBody := netconf.Body{}
+ if !item.Name.IsNull() && !item.Name.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "", item.Name.ValueString())
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/", cBody.Res())
+ }
+ }
+ if len(data.PassiveInterfaceDisableFourHundredGigabitEthernets) > 0 {
+ for _, item := range data.PassiveInterfaceDisableFourHundredGigabitEthernets {
+ cBody := netconf.Body{}
+ if !item.Name.IsNull() && !item.Name.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "", item.Name.ValueString())
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/", cBody.Res())
+ }
+ }
+ if len(data.PassiveInterfaceDisableLoopbacks) > 0 {
+ for _, item := range data.PassiveInterfaceDisableLoopbacks {
+ cBody := netconf.Body{}
+ if !item.Name.IsNull() && !item.Name.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "", item.Name.ValueString())
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/", cBody.Res())
+ }
+ }
+ if len(data.PassiveInterfaceDisableVlans) > 0 {
+ for _, item := range data.PassiveInterfaceDisableVlans {
+ cBody := netconf.Body{}
+ if !item.Name.IsNull() && !item.Name.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "", item.Name.ValueString())
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/", cBody.Res())
+ }
+ }
+ if len(data.PassiveInterfaceDisableTunnels) > 0 {
+ for _, item := range data.PassiveInterfaceDisableTunnels {
+ cBody := netconf.Body{}
+ if !item.Name.IsNull() && !item.Name.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "", item.Name.ValueString())
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/", cBody.Res())
+ }
+ }
+ if len(data.PassiveInterfaceDisablePortChannels) > 0 {
+ for _, item := range data.PassiveInterfaceDisablePortChannels {
+ cBody := netconf.Body{}
+ if !item.Name.IsNull() && !item.Name.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "", item.Name.ValueString())
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/", cBody.Res())
+ }
+ }
+ if len(data.PassiveInterfaceDisablePortChannelSubinterfaces) > 0 {
+ for _, item := range data.PassiveInterfaceDisablePortChannelSubinterfaces {
+ cBody := netconf.Body{}
+ if !item.Name.IsNull() && !item.Name.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "", item.Name.ValueString())
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/", cBody.Res())
+ }
+ }
+ bodyString, err := body.String()
+ if err != nil {
+ tflog.Error(ctx, fmt.Sprintf("Error converting body to string: %s", err))
+ }
+ return bodyString
+}
+
+// End of section. //template:end toBodyXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBody
func (data *OSPFVRF) updateFromBody(ctx context.Context, res gjson.Result) {
@@ -775,11 +1094,11 @@ func (data *OSPFVRF) updateFromBody(ctx context.Context, res gjson.Result) {
data.PassiveInterface = types.ListNull(types.StringType)
}
for i := range data.PassiveInterfaceDisableGigabitEthernets {
- keys := [...]string{"name"}
+ keys := [...]string{""}
keyValues := [...]string{data.PassiveInterfaceDisableGigabitEthernets[i].Name.ValueString()}
var r gjson.Result
- res.Get(prefix + "passive-interface-config.disable-interface.GigabitEthernet").ForEach(
+ res.Get(prefix + "").ForEach(
func(_, v gjson.Result) bool {
found := false
for ik := range keys {
@@ -797,18 +1116,18 @@ func (data *OSPFVRF) updateFromBody(ctx context.Context, res gjson.Result) {
return true
},
)
- if value := r.Get("name"); value.Exists() && !data.PassiveInterfaceDisableGigabitEthernets[i].Name.IsNull() {
+ if value := r.Get(""); value.Exists() && !data.PassiveInterfaceDisableGigabitEthernets[i].Name.IsNull() {
data.PassiveInterfaceDisableGigabitEthernets[i].Name = types.StringValue(value.String())
} else {
data.PassiveInterfaceDisableGigabitEthernets[i].Name = types.StringNull()
}
}
for i := range data.PassiveInterfaceDisableTwoGigabitEthernets {
- keys := [...]string{"name"}
+ keys := [...]string{""}
keyValues := [...]string{data.PassiveInterfaceDisableTwoGigabitEthernets[i].Name.ValueString()}
var r gjson.Result
- res.Get(prefix + "passive-interface-config.disable-interface.TwoGigabitEthernet").ForEach(
+ res.Get(prefix + "").ForEach(
func(_, v gjson.Result) bool {
found := false
for ik := range keys {
@@ -826,18 +1145,18 @@ func (data *OSPFVRF) updateFromBody(ctx context.Context, res gjson.Result) {
return true
},
)
- if value := r.Get("name"); value.Exists() && !data.PassiveInterfaceDisableTwoGigabitEthernets[i].Name.IsNull() {
+ if value := r.Get(""); value.Exists() && !data.PassiveInterfaceDisableTwoGigabitEthernets[i].Name.IsNull() {
data.PassiveInterfaceDisableTwoGigabitEthernets[i].Name = types.StringValue(value.String())
} else {
data.PassiveInterfaceDisableTwoGigabitEthernets[i].Name = types.StringNull()
}
}
for i := range data.PassiveInterfaceDisableFiveGigabitEthernets {
- keys := [...]string{"name"}
+ keys := [...]string{""}
keyValues := [...]string{data.PassiveInterfaceDisableFiveGigabitEthernets[i].Name.ValueString()}
var r gjson.Result
- res.Get(prefix + "passive-interface-config.disable-interface.FiveGigabitEthernet").ForEach(
+ res.Get(prefix + "").ForEach(
func(_, v gjson.Result) bool {
found := false
for ik := range keys {
@@ -855,18 +1174,18 @@ func (data *OSPFVRF) updateFromBody(ctx context.Context, res gjson.Result) {
return true
},
)
- if value := r.Get("name"); value.Exists() && !data.PassiveInterfaceDisableFiveGigabitEthernets[i].Name.IsNull() {
+ if value := r.Get(""); value.Exists() && !data.PassiveInterfaceDisableFiveGigabitEthernets[i].Name.IsNull() {
data.PassiveInterfaceDisableFiveGigabitEthernets[i].Name = types.StringValue(value.String())
} else {
data.PassiveInterfaceDisableFiveGigabitEthernets[i].Name = types.StringNull()
}
}
for i := range data.PassiveInterfaceDisableTenGigabitEthernets {
- keys := [...]string{"name"}
+ keys := [...]string{""}
keyValues := [...]string{data.PassiveInterfaceDisableTenGigabitEthernets[i].Name.ValueString()}
var r gjson.Result
- res.Get(prefix + "passive-interface-config.disable-interface.TenGigabitEthernet").ForEach(
+ res.Get(prefix + "").ForEach(
func(_, v gjson.Result) bool {
found := false
for ik := range keys {
@@ -884,18 +1203,18 @@ func (data *OSPFVRF) updateFromBody(ctx context.Context, res gjson.Result) {
return true
},
)
- if value := r.Get("name"); value.Exists() && !data.PassiveInterfaceDisableTenGigabitEthernets[i].Name.IsNull() {
+ if value := r.Get(""); value.Exists() && !data.PassiveInterfaceDisableTenGigabitEthernets[i].Name.IsNull() {
data.PassiveInterfaceDisableTenGigabitEthernets[i].Name = types.StringValue(value.String())
} else {
data.PassiveInterfaceDisableTenGigabitEthernets[i].Name = types.StringNull()
}
}
for i := range data.PassiveInterfaceDisableTwentyFiveGigabitEthernets {
- keys := [...]string{"name"}
+ keys := [...]string{""}
keyValues := [...]string{data.PassiveInterfaceDisableTwentyFiveGigabitEthernets[i].Name.ValueString()}
var r gjson.Result
- res.Get(prefix + "passive-interface-config.disable-interface.TwentyFiveGigabitE").ForEach(
+ res.Get(prefix + "").ForEach(
func(_, v gjson.Result) bool {
found := false
for ik := range keys {
@@ -913,18 +1232,18 @@ func (data *OSPFVRF) updateFromBody(ctx context.Context, res gjson.Result) {
return true
},
)
- if value := r.Get("name"); value.Exists() && !data.PassiveInterfaceDisableTwentyFiveGigabitEthernets[i].Name.IsNull() {
+ if value := r.Get(""); value.Exists() && !data.PassiveInterfaceDisableTwentyFiveGigabitEthernets[i].Name.IsNull() {
data.PassiveInterfaceDisableTwentyFiveGigabitEthernets[i].Name = types.StringValue(value.String())
} else {
data.PassiveInterfaceDisableTwentyFiveGigabitEthernets[i].Name = types.StringNull()
}
}
for i := range data.PassiveInterfaceDisableFortyGigabitEthernets {
- keys := [...]string{"name"}
+ keys := [...]string{""}
keyValues := [...]string{data.PassiveInterfaceDisableFortyGigabitEthernets[i].Name.ValueString()}
var r gjson.Result
- res.Get(prefix + "passive-interface-config.disable-interface.FortyGigabitEthernet").ForEach(
+ res.Get(prefix + "").ForEach(
func(_, v gjson.Result) bool {
found := false
for ik := range keys {
@@ -942,18 +1261,18 @@ func (data *OSPFVRF) updateFromBody(ctx context.Context, res gjson.Result) {
return true
},
)
- if value := r.Get("name"); value.Exists() && !data.PassiveInterfaceDisableFortyGigabitEthernets[i].Name.IsNull() {
+ if value := r.Get(""); value.Exists() && !data.PassiveInterfaceDisableFortyGigabitEthernets[i].Name.IsNull() {
data.PassiveInterfaceDisableFortyGigabitEthernets[i].Name = types.StringValue(value.String())
} else {
data.PassiveInterfaceDisableFortyGigabitEthernets[i].Name = types.StringNull()
}
}
for i := range data.PassiveInterfaceDisableHundredGigabitEthernets {
- keys := [...]string{"name"}
+ keys := [...]string{""}
keyValues := [...]string{data.PassiveInterfaceDisableHundredGigabitEthernets[i].Name.ValueString()}
var r gjson.Result
- res.Get(prefix + "passive-interface-config.disable-interface.HundredGigabitE").ForEach(
+ res.Get(prefix + "").ForEach(
func(_, v gjson.Result) bool {
found := false
for ik := range keys {
@@ -971,18 +1290,18 @@ func (data *OSPFVRF) updateFromBody(ctx context.Context, res gjson.Result) {
return true
},
)
- if value := r.Get("name"); value.Exists() && !data.PassiveInterfaceDisableHundredGigabitEthernets[i].Name.IsNull() {
+ if value := r.Get(""); value.Exists() && !data.PassiveInterfaceDisableHundredGigabitEthernets[i].Name.IsNull() {
data.PassiveInterfaceDisableHundredGigabitEthernets[i].Name = types.StringValue(value.String())
} else {
data.PassiveInterfaceDisableHundredGigabitEthernets[i].Name = types.StringNull()
}
}
for i := range data.PassiveInterfaceDisableTwoHundredGigabitEthernets {
- keys := [...]string{"name"}
+ keys := [...]string{""}
keyValues := [...]string{data.PassiveInterfaceDisableTwoHundredGigabitEthernets[i].Name.ValueString()}
var r gjson.Result
- res.Get(prefix + "passive-interface-config.disable-interface.TwoHundredGigabitE").ForEach(
+ res.Get(prefix + "").ForEach(
func(_, v gjson.Result) bool {
found := false
for ik := range keys {
@@ -1000,18 +1319,18 @@ func (data *OSPFVRF) updateFromBody(ctx context.Context, res gjson.Result) {
return true
},
)
- if value := r.Get("name"); value.Exists() && !data.PassiveInterfaceDisableTwoHundredGigabitEthernets[i].Name.IsNull() {
+ if value := r.Get(""); value.Exists() && !data.PassiveInterfaceDisableTwoHundredGigabitEthernets[i].Name.IsNull() {
data.PassiveInterfaceDisableTwoHundredGigabitEthernets[i].Name = types.StringValue(value.String())
} else {
data.PassiveInterfaceDisableTwoHundredGigabitEthernets[i].Name = types.StringNull()
}
}
for i := range data.PassiveInterfaceDisableFourHundredGigabitEthernets {
- keys := [...]string{"name"}
+ keys := [...]string{""}
keyValues := [...]string{data.PassiveInterfaceDisableFourHundredGigabitEthernets[i].Name.ValueString()}
var r gjson.Result
- res.Get(prefix + "passive-interface-config.disable-interface.FourHundredGigabitE").ForEach(
+ res.Get(prefix + "").ForEach(
func(_, v gjson.Result) bool {
found := false
for ik := range keys {
@@ -1029,18 +1348,18 @@ func (data *OSPFVRF) updateFromBody(ctx context.Context, res gjson.Result) {
return true
},
)
- if value := r.Get("name"); value.Exists() && !data.PassiveInterfaceDisableFourHundredGigabitEthernets[i].Name.IsNull() {
+ if value := r.Get(""); value.Exists() && !data.PassiveInterfaceDisableFourHundredGigabitEthernets[i].Name.IsNull() {
data.PassiveInterfaceDisableFourHundredGigabitEthernets[i].Name = types.StringValue(value.String())
} else {
data.PassiveInterfaceDisableFourHundredGigabitEthernets[i].Name = types.StringNull()
}
}
for i := range data.PassiveInterfaceDisableLoopbacks {
- keys := [...]string{"name"}
+ keys := [...]string{""}
keyValues := [...]string{data.PassiveInterfaceDisableLoopbacks[i].Name.ValueString()}
var r gjson.Result
- res.Get(prefix + "passive-interface-config.disable-interface.Loopback").ForEach(
+ res.Get(prefix + "").ForEach(
func(_, v gjson.Result) bool {
found := false
for ik := range keys {
@@ -1058,18 +1377,18 @@ func (data *OSPFVRF) updateFromBody(ctx context.Context, res gjson.Result) {
return true
},
)
- if value := r.Get("name"); value.Exists() && !data.PassiveInterfaceDisableLoopbacks[i].Name.IsNull() {
+ if value := r.Get(""); value.Exists() && !data.PassiveInterfaceDisableLoopbacks[i].Name.IsNull() {
data.PassiveInterfaceDisableLoopbacks[i].Name = types.StringValue(value.String())
} else {
data.PassiveInterfaceDisableLoopbacks[i].Name = types.StringNull()
}
}
for i := range data.PassiveInterfaceDisableVlans {
- keys := [...]string{"name"}
+ keys := [...]string{""}
keyValues := [...]string{data.PassiveInterfaceDisableVlans[i].Name.ValueString()}
var r gjson.Result
- res.Get(prefix + "passive-interface-config.disable-interface.Vlan").ForEach(
+ res.Get(prefix + "").ForEach(
func(_, v gjson.Result) bool {
found := false
for ik := range keys {
@@ -1087,18 +1406,18 @@ func (data *OSPFVRF) updateFromBody(ctx context.Context, res gjson.Result) {
return true
},
)
- if value := r.Get("name"); value.Exists() && !data.PassiveInterfaceDisableVlans[i].Name.IsNull() {
+ if value := r.Get(""); value.Exists() && !data.PassiveInterfaceDisableVlans[i].Name.IsNull() {
data.PassiveInterfaceDisableVlans[i].Name = types.StringValue(value.String())
} else {
data.PassiveInterfaceDisableVlans[i].Name = types.StringNull()
}
}
for i := range data.PassiveInterfaceDisableTunnels {
- keys := [...]string{"name"}
+ keys := [...]string{""}
keyValues := [...]string{data.PassiveInterfaceDisableTunnels[i].Name.ValueString()}
var r gjson.Result
- res.Get(prefix + "passive-interface-config.disable-interface.Tunnel").ForEach(
+ res.Get(prefix + "").ForEach(
func(_, v gjson.Result) bool {
found := false
for ik := range keys {
@@ -1116,18 +1435,18 @@ func (data *OSPFVRF) updateFromBody(ctx context.Context, res gjson.Result) {
return true
},
)
- if value := r.Get("name"); value.Exists() && !data.PassiveInterfaceDisableTunnels[i].Name.IsNull() {
+ if value := r.Get(""); value.Exists() && !data.PassiveInterfaceDisableTunnels[i].Name.IsNull() {
data.PassiveInterfaceDisableTunnels[i].Name = types.StringValue(value.String())
} else {
data.PassiveInterfaceDisableTunnels[i].Name = types.StringNull()
}
}
for i := range data.PassiveInterfaceDisablePortChannels {
- keys := [...]string{"name"}
+ keys := [...]string{""}
keyValues := [...]string{data.PassiveInterfaceDisablePortChannels[i].Name.ValueString()}
var r gjson.Result
- res.Get(prefix + "passive-interface-config.disable-interface.Port-channel").ForEach(
+ res.Get(prefix + "").ForEach(
func(_, v gjson.Result) bool {
found := false
for ik := range keys {
@@ -1145,18 +1464,18 @@ func (data *OSPFVRF) updateFromBody(ctx context.Context, res gjson.Result) {
return true
},
)
- if value := r.Get("name"); value.Exists() && !data.PassiveInterfaceDisablePortChannels[i].Name.IsNull() {
+ if value := r.Get(""); value.Exists() && !data.PassiveInterfaceDisablePortChannels[i].Name.IsNull() {
data.PassiveInterfaceDisablePortChannels[i].Name = types.StringValue(value.String())
} else {
data.PassiveInterfaceDisablePortChannels[i].Name = types.StringNull()
}
}
for i := range data.PassiveInterfaceDisablePortChannelSubinterfaces {
- keys := [...]string{"name"}
+ keys := [...]string{""}
keyValues := [...]string{data.PassiveInterfaceDisablePortChannelSubinterfaces[i].Name.ValueString()}
var r gjson.Result
- res.Get(prefix + "passive-interface-config.disable-interface.Port-channel-subinterface.Port-channel").ForEach(
+ res.Get(prefix + "").ForEach(
func(_, v gjson.Result) bool {
found := false
for ik := range keys {
@@ -1174,7 +1493,7 @@ func (data *OSPFVRF) updateFromBody(ctx context.Context, res gjson.Result) {
return true
},
)
- if value := r.Get("name"); value.Exists() && !data.PassiveInterfaceDisablePortChannelSubinterfaces[i].Name.IsNull() {
+ if value := r.Get(""); value.Exists() && !data.PassiveInterfaceDisablePortChannelSubinterfaces[i].Name.IsNull() {
data.PassiveInterfaceDisablePortChannelSubinterfaces[i].Name = types.StringValue(value.String())
} else {
data.PassiveInterfaceDisablePortChannelSubinterfaces[i].Name = types.StringNull()
@@ -1184,309 +1503,1953 @@ func (data *OSPFVRF) updateFromBody(ctx context.Context, res gjson.Result) {
// End of section. //template:end updateFromBody
-// Section below is generated&owned by "gen/generator.go". //template:begin fromBody
+// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBodyXML
-func (data *OSPFVRF) fromBody(ctx context.Context, res gjson.Result) {
- prefix := helpers.LastElement(data.getPath()) + "."
- if res.Get(helpers.LastElement(data.getPath())).IsArray() {
- prefix += "0."
+func (data *OSPFVRF) updateFromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/id"); value.Exists() && !data.ProcessId.IsNull() {
+ data.ProcessId = types.Int64Value(value.Int())
+ } else {
+ data.ProcessId = types.Int64Null()
}
- if value := res.Get(prefix + "bfd.all-interfaces"); value.Exists() {
- data.BfdAllInterfaces = types.BoolValue(true)
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/vrf"); value.Exists() && !data.Vrf.IsNull() {
+ data.Vrf = types.StringValue(value.String())
} else {
- data.BfdAllInterfaces = types.BoolValue(false)
+ data.Vrf = types.StringNull()
}
- if value := res.Get(prefix + "default-information.originate"); value.Exists() {
- data.DefaultInformationOriginate = types.BoolValue(true)
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/bfd/all-interfaces"); !data.BfdAllInterfaces.IsNull() {
+ if value.Exists() {
+ data.BfdAllInterfaces = types.BoolValue(true)
+ } else {
+ data.BfdAllInterfaces = types.BoolValue(false)
+ }
} else {
- data.DefaultInformationOriginate = types.BoolValue(false)
+ data.BfdAllInterfaces = types.BoolNull()
}
- if value := res.Get(prefix + "default-information.originate.always"); value.Exists() {
- data.DefaultInformationOriginateAlways = types.BoolValue(true)
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/default-information/originate"); !data.DefaultInformationOriginate.IsNull() {
+ if value.Exists() {
+ data.DefaultInformationOriginate = types.BoolValue(true)
+ } else {
+ data.DefaultInformationOriginate = types.BoolValue(false)
+ }
} else {
- data.DefaultInformationOriginateAlways = types.BoolValue(false)
+ data.DefaultInformationOriginate = types.BoolNull()
}
- if value := res.Get(prefix + "default-metric"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/default-information/originate/always"); !data.DefaultInformationOriginateAlways.IsNull() {
+ if value.Exists() {
+ data.DefaultInformationOriginateAlways = types.BoolValue(true)
+ } else {
+ data.DefaultInformationOriginateAlways = types.BoolValue(false)
+ }
+ } else {
+ data.DefaultInformationOriginateAlways = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/default-metric"); value.Exists() && !data.DefaultMetric.IsNull() {
data.DefaultMetric = types.Int64Value(value.Int())
+ } else {
+ data.DefaultMetric = types.Int64Null()
}
- if value := res.Get(prefix + "distance.distance"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/distance/distance"); value.Exists() && !data.Distance.IsNull() {
data.Distance = types.Int64Value(value.Int())
+ } else {
+ data.Distance = types.Int64Null()
}
- if value := res.Get(prefix + "domain-tag"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/domain-tag"); value.Exists() && !data.DomainTag.IsNull() {
data.DomainTag = types.Int64Value(value.Int())
+ } else {
+ data.DomainTag = types.Int64Null()
}
- if value := res.Get(prefix + "mpls.ldp.autoconfig"); value.Exists() {
- data.MplsLdpAutoconfig = types.BoolValue(true)
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/mpls/ldp/autoconfig"); !data.MplsLdpAutoconfig.IsNull() {
+ if value.Exists() {
+ data.MplsLdpAutoconfig = types.BoolValue(true)
+ } else {
+ data.MplsLdpAutoconfig = types.BoolValue(false)
+ }
} else {
- data.MplsLdpAutoconfig = types.BoolValue(false)
+ data.MplsLdpAutoconfig = types.BoolNull()
}
- if value := res.Get(prefix + "mpls.ldp.sync"); value.Exists() {
- data.MplsLdpSync = types.BoolValue(true)
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/mpls/ldp/sync"); !data.MplsLdpSync.IsNull() {
+ if value.Exists() {
+ data.MplsLdpSync = types.BoolValue(true)
+ } else {
+ data.MplsLdpSync = types.BoolValue(false)
+ }
} else {
- data.MplsLdpSync = types.BoolValue(false)
+ data.MplsLdpSync = types.BoolNull()
}
- if value := res.Get(prefix + "neighbor"); value.Exists() {
- data.Neighbor = make([]OSPFVRFNeighbor, 0)
- value.ForEach(func(k, v gjson.Result) bool {
- item := OSPFVRFNeighbor{}
- if cValue := v.Get("ip"); cValue.Exists() {
- item.Ip = types.StringValue(cValue.String())
- }
- if cValue := v.Get("priority"); cValue.Exists() {
- item.Priority = types.Int64Value(cValue.Int())
- }
- if cValue := v.Get("cost"); cValue.Exists() {
- item.Cost = types.Int64Value(cValue.Int())
- }
- data.Neighbor = append(data.Neighbor, item)
- return true
- })
+ for i := range data.Neighbor {
+ keys := [...]string{"ip"}
+ keyValues := [...]string{data.Neighbor[i].Ip.ValueString()}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/neighbor").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, "ip"); value.Exists() && !data.Neighbor[i].Ip.IsNull() {
+ data.Neighbor[i].Ip = types.StringValue(value.String())
+ } else {
+ data.Neighbor[i].Ip = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "priority"); value.Exists() && !data.Neighbor[i].Priority.IsNull() {
+ data.Neighbor[i].Priority = types.Int64Value(value.Int())
+ } else {
+ data.Neighbor[i].Priority = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(r, "cost"); value.Exists() && !data.Neighbor[i].Cost.IsNull() {
+ data.Neighbor[i].Cost = types.Int64Value(value.Int())
+ } else {
+ data.Neighbor[i].Cost = types.Int64Null()
+ }
}
- if value := res.Get(prefix + "network"); value.Exists() {
- data.Network = make([]OSPFVRFNetwork, 0)
- value.ForEach(func(k, v gjson.Result) bool {
- item := OSPFVRFNetwork{}
- if cValue := v.Get("ip"); cValue.Exists() {
- item.Ip = types.StringValue(cValue.String())
- }
- if cValue := v.Get("wildcard"); cValue.Exists() {
- item.Wildcard = types.StringValue(cValue.String())
- }
- if cValue := v.Get("area"); cValue.Exists() {
- item.Area = types.StringValue(cValue.String())
- }
- data.Network = append(data.Network, item)
- return true
- })
+ for i := range data.Network {
+ keys := [...]string{"ip"}
+ keyValues := [...]string{data.Network[i].Ip.ValueString()}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/network").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, "ip"); value.Exists() && !data.Network[i].Ip.IsNull() {
+ data.Network[i].Ip = types.StringValue(value.String())
+ } else {
+ data.Network[i].Ip = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "wildcard"); value.Exists() && !data.Network[i].Wildcard.IsNull() {
+ data.Network[i].Wildcard = types.StringValue(value.String())
+ } else {
+ data.Network[i].Wildcard = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "area"); value.Exists() && !data.Network[i].Area.IsNull() {
+ data.Network[i].Area = types.StringValue(value.String())
+ } else {
+ data.Network[i].Area = types.StringNull()
+ }
}
- if value := res.Get(prefix + "priority"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/priority"); value.Exists() && !data.Priority.IsNull() {
data.Priority = types.Int64Value(value.Int())
+ } else {
+ data.Priority = types.Int64Null()
}
- if value := res.Get(prefix + "router-id"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/router-id"); value.Exists() && !data.RouterId.IsNull() {
data.RouterId = types.StringValue(value.String())
+ } else {
+ data.RouterId = types.StringNull()
}
- if value := res.Get(prefix + "shutdown"); value.Exists() {
- data.Shutdown = types.BoolValue(value.Bool())
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/shutdown"); !data.Shutdown.IsNull() {
+ if value.Exists() {
+ data.Shutdown = types.BoolValue(value.Bool())
+ }
} else {
data.Shutdown = types.BoolNull()
}
- if value := res.Get(prefix + "summary-address"); value.Exists() {
- data.SummaryAddress = make([]OSPFVRFSummaryAddress, 0)
- value.ForEach(func(k, v gjson.Result) bool {
- item := OSPFVRFSummaryAddress{}
- if cValue := v.Get("ip"); cValue.Exists() {
- item.Ip = types.StringValue(cValue.String())
- }
- if cValue := v.Get("mask"); cValue.Exists() {
- item.Mask = types.StringValue(cValue.String())
- }
- data.SummaryAddress = append(data.SummaryAddress, item)
- return true
- })
+ for i := range data.SummaryAddress {
+ keys := [...]string{"ip"}
+ keyValues := [...]string{data.SummaryAddress[i].Ip.ValueString()}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/summary-address").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, "ip"); value.Exists() && !data.SummaryAddress[i].Ip.IsNull() {
+ data.SummaryAddress[i].Ip = types.StringValue(value.String())
+ } else {
+ data.SummaryAddress[i].Ip = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "mask"); value.Exists() && !data.SummaryAddress[i].Mask.IsNull() {
+ data.SummaryAddress[i].Mask = types.StringValue(value.String())
+ } else {
+ data.SummaryAddress[i].Mask = types.StringNull()
+ }
}
- if value := res.Get(prefix + "area"); value.Exists() {
- data.Areas = make([]OSPFVRFAreas, 0)
- value.ForEach(func(k, v gjson.Result) bool {
- item := OSPFVRFAreas{}
- if cValue := v.Get("area-id"); cValue.Exists() {
- item.AreaId = types.StringValue(cValue.String())
- }
- if cValue := v.Get("authentication.message-digest"); cValue.Exists() {
- item.AuthenticationMessageDigest = types.BoolValue(true)
+ for i := range data.Areas {
+ keys := [...]string{"area-id"}
+ keyValues := [...]string{data.Areas[i].AreaId.ValueString()}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/area").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, "area-id"); value.Exists() && !data.Areas[i].AreaId.IsNull() {
+ data.Areas[i].AreaId = types.StringValue(value.String())
+ } else {
+ data.Areas[i].AreaId = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "authentication/message-digest"); !data.Areas[i].AuthenticationMessageDigest.IsNull() {
+ if value.Exists() {
+ data.Areas[i].AuthenticationMessageDigest = types.BoolValue(true)
} else {
- item.AuthenticationMessageDigest = types.BoolValue(false)
+ data.Areas[i].AuthenticationMessageDigest = types.BoolValue(false)
}
- if cValue := v.Get("nssa"); cValue.Exists() {
- item.Nssa = types.BoolValue(true)
+ } else {
+ data.Areas[i].AuthenticationMessageDigest = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "nssa"); !data.Areas[i].Nssa.IsNull() {
+ if value.Exists() {
+ data.Areas[i].Nssa = types.BoolValue(true)
} else {
- item.Nssa = types.BoolValue(false)
+ data.Areas[i].Nssa = types.BoolValue(false)
}
- if cValue := v.Get("nssa.nssa-options.default-information-originate"); cValue.Exists() {
- item.NssaDefaultInformationOriginate = types.BoolValue(true)
+ } else {
+ data.Areas[i].Nssa = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "nssa/nssa-options/default-information-originate"); !data.Areas[i].NssaDefaultInformationOriginate.IsNull() {
+ if value.Exists() {
+ data.Areas[i].NssaDefaultInformationOriginate = types.BoolValue(true)
} else {
- item.NssaDefaultInformationOriginate = types.BoolValue(false)
- }
- if cValue := v.Get("nssa.nssa-options.default-information-originate.metric"); cValue.Exists() {
- item.NssaDefaultInformationOriginateMetric = types.Int64Value(cValue.Int())
- }
- if cValue := v.Get("nssa.nssa-options.default-information-originate.metric-type"); cValue.Exists() {
- item.NssaDefaultInformationOriginateMetricType = types.Int64Value(cValue.Int())
+ data.Areas[i].NssaDefaultInformationOriginate = types.BoolValue(false)
}
- if cValue := v.Get("nssa.nssa-options.no-summary"); cValue.Exists() {
- item.NssaNoSummary = types.BoolValue(true)
+ } else {
+ data.Areas[i].NssaDefaultInformationOriginate = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "nssa/nssa-options/default-information-originate/metric"); value.Exists() && !data.Areas[i].NssaDefaultInformationOriginateMetric.IsNull() {
+ data.Areas[i].NssaDefaultInformationOriginateMetric = types.Int64Value(value.Int())
+ } else {
+ data.Areas[i].NssaDefaultInformationOriginateMetric = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(r, "nssa/nssa-options/default-information-originate/metric-type"); value.Exists() && !data.Areas[i].NssaDefaultInformationOriginateMetricType.IsNull() {
+ data.Areas[i].NssaDefaultInformationOriginateMetricType = types.Int64Value(value.Int())
+ } else {
+ data.Areas[i].NssaDefaultInformationOriginateMetricType = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(r, "nssa/nssa-options/no-summary"); !data.Areas[i].NssaNoSummary.IsNull() {
+ if value.Exists() {
+ data.Areas[i].NssaNoSummary = types.BoolValue(true)
} else {
- item.NssaNoSummary = types.BoolValue(false)
+ data.Areas[i].NssaNoSummary = types.BoolValue(false)
}
- if cValue := v.Get("nssa.nssa-options.no-redistribution"); cValue.Exists() {
- item.NssaNoRedistribution = types.BoolValue(true)
+ } else {
+ data.Areas[i].NssaNoSummary = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "nssa/nssa-options/no-redistribution"); !data.Areas[i].NssaNoRedistribution.IsNull() {
+ if value.Exists() {
+ data.Areas[i].NssaNoRedistribution = types.BoolValue(true)
} else {
- item.NssaNoRedistribution = types.BoolValue(false)
+ data.Areas[i].NssaNoRedistribution = types.BoolValue(false)
}
- data.Areas = append(data.Areas, item)
- return true
- })
+ } else {
+ data.Areas[i].NssaNoRedistribution = types.BoolNull()
+ }
}
- if value := res.Get(prefix + "auto-cost.reference-bandwidth"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/auto-cost/reference-bandwidth"); value.Exists() && !data.AutoCostReferenceBandwidth.IsNull() {
data.AutoCostReferenceBandwidth = types.Int64Value(value.Int())
+ } else {
+ data.AutoCostReferenceBandwidth = types.Int64Null()
}
- if value := res.Get(prefix + "passive-interface.default"); value.Exists() {
- data.PassiveInterfaceDefault = types.BoolValue(value.Bool())
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/passive-interface/default"); !data.PassiveInterfaceDefault.IsNull() {
+ if value.Exists() {
+ data.PassiveInterfaceDefault = types.BoolValue(value.Bool())
+ }
} else {
data.PassiveInterfaceDefault = types.BoolNull()
}
- if value := res.Get(prefix + "passive-interface.interface"); value.Exists() {
- data.PassiveInterface = helpers.GetStringList(value.Array())
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/passive-interface/interface"); value.Exists() && !data.PassiveInterface.IsNull() {
+ data.PassiveInterface = helpers.GetStringListXML(value.Array())
} else {
data.PassiveInterface = types.ListNull(types.StringType)
}
- if value := res.Get(prefix + "passive-interface-config.disable-interface.GigabitEthernet"); value.Exists() {
- data.PassiveInterfaceDisableGigabitEthernets = make([]OSPFVRFPassiveInterfaceDisableGigabitEthernets, 0)
- value.ForEach(func(k, v gjson.Result) bool {
- item := OSPFVRFPassiveInterfaceDisableGigabitEthernets{}
- if cValue := v.Get("name"); cValue.Exists() {
- item.Name = types.StringValue(cValue.String())
- }
- data.PassiveInterfaceDisableGigabitEthernets = append(data.PassiveInterfaceDisableGigabitEthernets, item)
- return true
- })
- }
- if value := res.Get(prefix + "passive-interface-config.disable-interface.TwoGigabitEthernet"); value.Exists() {
- data.PassiveInterfaceDisableTwoGigabitEthernets = make([]OSPFVRFPassiveInterfaceDisableTwoGigabitEthernets, 0)
- value.ForEach(func(k, v gjson.Result) bool {
- item := OSPFVRFPassiveInterfaceDisableTwoGigabitEthernets{}
- if cValue := v.Get("name"); cValue.Exists() {
+ for i := range data.PassiveInterfaceDisableGigabitEthernets {
+ keys := [...]string{""}
+ keyValues := [...]string{data.PassiveInterfaceDisableGigabitEthernets[i].Name.ValueString()}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, ""); value.Exists() && !data.PassiveInterfaceDisableGigabitEthernets[i].Name.IsNull() {
+ data.PassiveInterfaceDisableGigabitEthernets[i].Name = types.StringValue(value.String())
+ } else {
+ data.PassiveInterfaceDisableGigabitEthernets[i].Name = types.StringNull()
+ }
+ }
+ for i := range data.PassiveInterfaceDisableTwoGigabitEthernets {
+ keys := [...]string{""}
+ keyValues := [...]string{data.PassiveInterfaceDisableTwoGigabitEthernets[i].Name.ValueString()}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, ""); value.Exists() && !data.PassiveInterfaceDisableTwoGigabitEthernets[i].Name.IsNull() {
+ data.PassiveInterfaceDisableTwoGigabitEthernets[i].Name = types.StringValue(value.String())
+ } else {
+ data.PassiveInterfaceDisableTwoGigabitEthernets[i].Name = types.StringNull()
+ }
+ }
+ for i := range data.PassiveInterfaceDisableFiveGigabitEthernets {
+ keys := [...]string{""}
+ keyValues := [...]string{data.PassiveInterfaceDisableFiveGigabitEthernets[i].Name.ValueString()}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, ""); value.Exists() && !data.PassiveInterfaceDisableFiveGigabitEthernets[i].Name.IsNull() {
+ data.PassiveInterfaceDisableFiveGigabitEthernets[i].Name = types.StringValue(value.String())
+ } else {
+ data.PassiveInterfaceDisableFiveGigabitEthernets[i].Name = types.StringNull()
+ }
+ }
+ for i := range data.PassiveInterfaceDisableTenGigabitEthernets {
+ keys := [...]string{""}
+ keyValues := [...]string{data.PassiveInterfaceDisableTenGigabitEthernets[i].Name.ValueString()}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, ""); value.Exists() && !data.PassiveInterfaceDisableTenGigabitEthernets[i].Name.IsNull() {
+ data.PassiveInterfaceDisableTenGigabitEthernets[i].Name = types.StringValue(value.String())
+ } else {
+ data.PassiveInterfaceDisableTenGigabitEthernets[i].Name = types.StringNull()
+ }
+ }
+ for i := range data.PassiveInterfaceDisableTwentyFiveGigabitEthernets {
+ keys := [...]string{""}
+ keyValues := [...]string{data.PassiveInterfaceDisableTwentyFiveGigabitEthernets[i].Name.ValueString()}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, ""); value.Exists() && !data.PassiveInterfaceDisableTwentyFiveGigabitEthernets[i].Name.IsNull() {
+ data.PassiveInterfaceDisableTwentyFiveGigabitEthernets[i].Name = types.StringValue(value.String())
+ } else {
+ data.PassiveInterfaceDisableTwentyFiveGigabitEthernets[i].Name = types.StringNull()
+ }
+ }
+ for i := range data.PassiveInterfaceDisableFortyGigabitEthernets {
+ keys := [...]string{""}
+ keyValues := [...]string{data.PassiveInterfaceDisableFortyGigabitEthernets[i].Name.ValueString()}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, ""); value.Exists() && !data.PassiveInterfaceDisableFortyGigabitEthernets[i].Name.IsNull() {
+ data.PassiveInterfaceDisableFortyGigabitEthernets[i].Name = types.StringValue(value.String())
+ } else {
+ data.PassiveInterfaceDisableFortyGigabitEthernets[i].Name = types.StringNull()
+ }
+ }
+ for i := range data.PassiveInterfaceDisableHundredGigabitEthernets {
+ keys := [...]string{""}
+ keyValues := [...]string{data.PassiveInterfaceDisableHundredGigabitEthernets[i].Name.ValueString()}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, ""); value.Exists() && !data.PassiveInterfaceDisableHundredGigabitEthernets[i].Name.IsNull() {
+ data.PassiveInterfaceDisableHundredGigabitEthernets[i].Name = types.StringValue(value.String())
+ } else {
+ data.PassiveInterfaceDisableHundredGigabitEthernets[i].Name = types.StringNull()
+ }
+ }
+ for i := range data.PassiveInterfaceDisableTwoHundredGigabitEthernets {
+ keys := [...]string{""}
+ keyValues := [...]string{data.PassiveInterfaceDisableTwoHundredGigabitEthernets[i].Name.ValueString()}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, ""); value.Exists() && !data.PassiveInterfaceDisableTwoHundredGigabitEthernets[i].Name.IsNull() {
+ data.PassiveInterfaceDisableTwoHundredGigabitEthernets[i].Name = types.StringValue(value.String())
+ } else {
+ data.PassiveInterfaceDisableTwoHundredGigabitEthernets[i].Name = types.StringNull()
+ }
+ }
+ for i := range data.PassiveInterfaceDisableFourHundredGigabitEthernets {
+ keys := [...]string{""}
+ keyValues := [...]string{data.PassiveInterfaceDisableFourHundredGigabitEthernets[i].Name.ValueString()}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, ""); value.Exists() && !data.PassiveInterfaceDisableFourHundredGigabitEthernets[i].Name.IsNull() {
+ data.PassiveInterfaceDisableFourHundredGigabitEthernets[i].Name = types.StringValue(value.String())
+ } else {
+ data.PassiveInterfaceDisableFourHundredGigabitEthernets[i].Name = types.StringNull()
+ }
+ }
+ for i := range data.PassiveInterfaceDisableLoopbacks {
+ keys := [...]string{""}
+ keyValues := [...]string{data.PassiveInterfaceDisableLoopbacks[i].Name.ValueString()}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, ""); value.Exists() && !data.PassiveInterfaceDisableLoopbacks[i].Name.IsNull() {
+ data.PassiveInterfaceDisableLoopbacks[i].Name = types.StringValue(value.String())
+ } else {
+ data.PassiveInterfaceDisableLoopbacks[i].Name = types.StringNull()
+ }
+ }
+ for i := range data.PassiveInterfaceDisableVlans {
+ keys := [...]string{""}
+ keyValues := [...]string{data.PassiveInterfaceDisableVlans[i].Name.ValueString()}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, ""); value.Exists() && !data.PassiveInterfaceDisableVlans[i].Name.IsNull() {
+ data.PassiveInterfaceDisableVlans[i].Name = types.StringValue(value.String())
+ } else {
+ data.PassiveInterfaceDisableVlans[i].Name = types.StringNull()
+ }
+ }
+ for i := range data.PassiveInterfaceDisableTunnels {
+ keys := [...]string{""}
+ keyValues := [...]string{data.PassiveInterfaceDisableTunnels[i].Name.ValueString()}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, ""); value.Exists() && !data.PassiveInterfaceDisableTunnels[i].Name.IsNull() {
+ data.PassiveInterfaceDisableTunnels[i].Name = types.StringValue(value.String())
+ } else {
+ data.PassiveInterfaceDisableTunnels[i].Name = types.StringNull()
+ }
+ }
+ for i := range data.PassiveInterfaceDisablePortChannels {
+ keys := [...]string{""}
+ keyValues := [...]string{data.PassiveInterfaceDisablePortChannels[i].Name.ValueString()}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, ""); value.Exists() && !data.PassiveInterfaceDisablePortChannels[i].Name.IsNull() {
+ data.PassiveInterfaceDisablePortChannels[i].Name = types.StringValue(value.String())
+ } else {
+ data.PassiveInterfaceDisablePortChannels[i].Name = types.StringNull()
+ }
+ }
+ for i := range data.PassiveInterfaceDisablePortChannelSubinterfaces {
+ keys := [...]string{""}
+ keyValues := [...]string{data.PassiveInterfaceDisablePortChannelSubinterfaces[i].Name.ValueString()}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, ""); value.Exists() && !data.PassiveInterfaceDisablePortChannelSubinterfaces[i].Name.IsNull() {
+ data.PassiveInterfaceDisablePortChannelSubinterfaces[i].Name = types.StringValue(value.String())
+ } else {
+ data.PassiveInterfaceDisablePortChannelSubinterfaces[i].Name = types.StringNull()
+ }
+ }
+}
+
+// End of section. //template:end updateFromBodyXML
+
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBody
+
+func (data *OSPFVRF) fromBody(ctx context.Context, res gjson.Result) {
+ prefix := helpers.LastElement(data.getPath()) + "."
+ if res.Get(helpers.LastElement(data.getPath())).IsArray() {
+ prefix += "0."
+ }
+ if value := res.Get(prefix + "bfd.all-interfaces"); value.Exists() {
+ data.BfdAllInterfaces = types.BoolValue(true)
+ } else {
+ data.BfdAllInterfaces = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "default-information.originate"); value.Exists() {
+ data.DefaultInformationOriginate = types.BoolValue(true)
+ } else {
+ data.DefaultInformationOriginate = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "default-information.originate.always"); value.Exists() {
+ data.DefaultInformationOriginateAlways = types.BoolValue(true)
+ } else {
+ data.DefaultInformationOriginateAlways = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "default-metric"); value.Exists() {
+ data.DefaultMetric = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "distance.distance"); value.Exists() {
+ data.Distance = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "domain-tag"); value.Exists() {
+ data.DomainTag = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "mpls.ldp.autoconfig"); value.Exists() {
+ data.MplsLdpAutoconfig = types.BoolValue(true)
+ } else {
+ data.MplsLdpAutoconfig = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "mpls.ldp.sync"); value.Exists() {
+ data.MplsLdpSync = types.BoolValue(true)
+ } else {
+ data.MplsLdpSync = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "neighbor"); value.Exists() {
+ data.Neighbor = make([]OSPFVRFNeighbor, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := OSPFVRFNeighbor{}
+ if cValue := v.Get("ip"); cValue.Exists() {
+ item.Ip = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("priority"); cValue.Exists() {
+ item.Priority = types.Int64Value(cValue.Int())
+ }
+ if cValue := v.Get("cost"); cValue.Exists() {
+ item.Cost = types.Int64Value(cValue.Int())
+ }
+ data.Neighbor = append(data.Neighbor, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + "network"); value.Exists() {
+ data.Network = make([]OSPFVRFNetwork, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := OSPFVRFNetwork{}
+ if cValue := v.Get("ip"); cValue.Exists() {
+ item.Ip = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("wildcard"); cValue.Exists() {
+ item.Wildcard = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("area"); cValue.Exists() {
+ item.Area = types.StringValue(cValue.String())
+ }
+ data.Network = append(data.Network, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + "priority"); value.Exists() {
+ data.Priority = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "router-id"); value.Exists() {
+ data.RouterId = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "shutdown"); value.Exists() {
+ data.Shutdown = types.BoolValue(value.Bool())
+ } else {
+ data.Shutdown = types.BoolNull()
+ }
+ if value := res.Get(prefix + "summary-address"); value.Exists() {
+ data.SummaryAddress = make([]OSPFVRFSummaryAddress, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := OSPFVRFSummaryAddress{}
+ if cValue := v.Get("ip"); cValue.Exists() {
+ item.Ip = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("mask"); cValue.Exists() {
+ item.Mask = types.StringValue(cValue.String())
+ }
+ data.SummaryAddress = append(data.SummaryAddress, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + "area"); value.Exists() {
+ data.Areas = make([]OSPFVRFAreas, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := OSPFVRFAreas{}
+ if cValue := v.Get("area-id"); cValue.Exists() {
+ item.AreaId = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("authentication.message-digest"); cValue.Exists() {
+ item.AuthenticationMessageDigest = types.BoolValue(true)
+ } else {
+ item.AuthenticationMessageDigest = types.BoolValue(false)
+ }
+ if cValue := v.Get("nssa"); cValue.Exists() {
+ item.Nssa = types.BoolValue(true)
+ } else {
+ item.Nssa = types.BoolValue(false)
+ }
+ if cValue := v.Get("nssa.nssa-options.default-information-originate"); cValue.Exists() {
+ item.NssaDefaultInformationOriginate = types.BoolValue(true)
+ } else {
+ item.NssaDefaultInformationOriginate = types.BoolValue(false)
+ }
+ if cValue := v.Get("nssa.nssa-options.default-information-originate.metric"); cValue.Exists() {
+ item.NssaDefaultInformationOriginateMetric = types.Int64Value(cValue.Int())
+ }
+ if cValue := v.Get("nssa.nssa-options.default-information-originate.metric-type"); cValue.Exists() {
+ item.NssaDefaultInformationOriginateMetricType = types.Int64Value(cValue.Int())
+ }
+ if cValue := v.Get("nssa.nssa-options.no-summary"); cValue.Exists() {
+ item.NssaNoSummary = types.BoolValue(true)
+ } else {
+ item.NssaNoSummary = types.BoolValue(false)
+ }
+ if cValue := v.Get("nssa.nssa-options.no-redistribution"); cValue.Exists() {
+ item.NssaNoRedistribution = types.BoolValue(true)
+ } else {
+ item.NssaNoRedistribution = types.BoolValue(false)
+ }
+ data.Areas = append(data.Areas, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + "auto-cost.reference-bandwidth"); value.Exists() {
+ data.AutoCostReferenceBandwidth = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "passive-interface.default"); value.Exists() {
+ data.PassiveInterfaceDefault = types.BoolValue(value.Bool())
+ } else {
+ data.PassiveInterfaceDefault = types.BoolNull()
+ }
+ if value := res.Get(prefix + "passive-interface.interface"); value.Exists() {
+ data.PassiveInterface = helpers.GetStringList(value.Array())
+ } else {
+ data.PassiveInterface = types.ListNull(types.StringType)
+ }
+ if value := res.Get(prefix + ""); value.Exists() {
+ data.PassiveInterfaceDisableGigabitEthernets = make([]OSPFVRFPassiveInterfaceDisableGigabitEthernets, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := OSPFVRFPassiveInterfaceDisableGigabitEthernets{}
+ if cValue := v.Get(""); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ data.PassiveInterfaceDisableGigabitEthernets = append(data.PassiveInterfaceDisableGigabitEthernets, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + ""); value.Exists() {
+ data.PassiveInterfaceDisableTwoGigabitEthernets = make([]OSPFVRFPassiveInterfaceDisableTwoGigabitEthernets, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := OSPFVRFPassiveInterfaceDisableTwoGigabitEthernets{}
+ if cValue := v.Get(""); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ data.PassiveInterfaceDisableTwoGigabitEthernets = append(data.PassiveInterfaceDisableTwoGigabitEthernets, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + ""); value.Exists() {
+ data.PassiveInterfaceDisableFiveGigabitEthernets = make([]OSPFVRFPassiveInterfaceDisableFiveGigabitEthernets, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := OSPFVRFPassiveInterfaceDisableFiveGigabitEthernets{}
+ if cValue := v.Get(""); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ data.PassiveInterfaceDisableFiveGigabitEthernets = append(data.PassiveInterfaceDisableFiveGigabitEthernets, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + ""); value.Exists() {
+ data.PassiveInterfaceDisableTenGigabitEthernets = make([]OSPFVRFPassiveInterfaceDisableTenGigabitEthernets, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := OSPFVRFPassiveInterfaceDisableTenGigabitEthernets{}
+ if cValue := v.Get(""); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ data.PassiveInterfaceDisableTenGigabitEthernets = append(data.PassiveInterfaceDisableTenGigabitEthernets, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + ""); value.Exists() {
+ data.PassiveInterfaceDisableTwentyFiveGigabitEthernets = make([]OSPFVRFPassiveInterfaceDisableTwentyFiveGigabitEthernets, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := OSPFVRFPassiveInterfaceDisableTwentyFiveGigabitEthernets{}
+ if cValue := v.Get(""); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ data.PassiveInterfaceDisableTwentyFiveGigabitEthernets = append(data.PassiveInterfaceDisableTwentyFiveGigabitEthernets, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + ""); value.Exists() {
+ data.PassiveInterfaceDisableFortyGigabitEthernets = make([]OSPFVRFPassiveInterfaceDisableFortyGigabitEthernets, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := OSPFVRFPassiveInterfaceDisableFortyGigabitEthernets{}
+ if cValue := v.Get(""); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ data.PassiveInterfaceDisableFortyGigabitEthernets = append(data.PassiveInterfaceDisableFortyGigabitEthernets, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + ""); value.Exists() {
+ data.PassiveInterfaceDisableHundredGigabitEthernets = make([]OSPFVRFPassiveInterfaceDisableHundredGigabitEthernets, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := OSPFVRFPassiveInterfaceDisableHundredGigabitEthernets{}
+ if cValue := v.Get(""); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ data.PassiveInterfaceDisableHundredGigabitEthernets = append(data.PassiveInterfaceDisableHundredGigabitEthernets, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + ""); value.Exists() {
+ data.PassiveInterfaceDisableTwoHundredGigabitEthernets = make([]OSPFVRFPassiveInterfaceDisableTwoHundredGigabitEthernets, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := OSPFVRFPassiveInterfaceDisableTwoHundredGigabitEthernets{}
+ if cValue := v.Get(""); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ data.PassiveInterfaceDisableTwoHundredGigabitEthernets = append(data.PassiveInterfaceDisableTwoHundredGigabitEthernets, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + ""); value.Exists() {
+ data.PassiveInterfaceDisableFourHundredGigabitEthernets = make([]OSPFVRFPassiveInterfaceDisableFourHundredGigabitEthernets, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := OSPFVRFPassiveInterfaceDisableFourHundredGigabitEthernets{}
+ if cValue := v.Get(""); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ data.PassiveInterfaceDisableFourHundredGigabitEthernets = append(data.PassiveInterfaceDisableFourHundredGigabitEthernets, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + ""); value.Exists() {
+ data.PassiveInterfaceDisableLoopbacks = make([]OSPFVRFPassiveInterfaceDisableLoopbacks, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := OSPFVRFPassiveInterfaceDisableLoopbacks{}
+ if cValue := v.Get(""); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ data.PassiveInterfaceDisableLoopbacks = append(data.PassiveInterfaceDisableLoopbacks, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + ""); value.Exists() {
+ data.PassiveInterfaceDisableVlans = make([]OSPFVRFPassiveInterfaceDisableVlans, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := OSPFVRFPassiveInterfaceDisableVlans{}
+ if cValue := v.Get(""); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ data.PassiveInterfaceDisableVlans = append(data.PassiveInterfaceDisableVlans, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + ""); value.Exists() {
+ data.PassiveInterfaceDisableTunnels = make([]OSPFVRFPassiveInterfaceDisableTunnels, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := OSPFVRFPassiveInterfaceDisableTunnels{}
+ if cValue := v.Get(""); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ data.PassiveInterfaceDisableTunnels = append(data.PassiveInterfaceDisableTunnels, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + ""); value.Exists() {
+ data.PassiveInterfaceDisablePortChannels = make([]OSPFVRFPassiveInterfaceDisablePortChannels, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := OSPFVRFPassiveInterfaceDisablePortChannels{}
+ if cValue := v.Get(""); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ data.PassiveInterfaceDisablePortChannels = append(data.PassiveInterfaceDisablePortChannels, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + ""); value.Exists() {
+ data.PassiveInterfaceDisablePortChannelSubinterfaces = make([]OSPFVRFPassiveInterfaceDisablePortChannelSubinterfaces, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := OSPFVRFPassiveInterfaceDisablePortChannelSubinterfaces{}
+ if cValue := v.Get(""); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ data.PassiveInterfaceDisablePortChannelSubinterfaces = append(data.PassiveInterfaceDisablePortChannelSubinterfaces, item)
+ return true
+ })
+ }
+}
+
+// End of section. //template:end fromBody
+
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyData
+
+func (data *OSPFVRFData) fromBody(ctx context.Context, res gjson.Result) {
+ prefix := helpers.LastElement(data.getPath()) + "."
+ if res.Get(helpers.LastElement(data.getPath())).IsArray() {
+ prefix += "0."
+ }
+ if value := res.Get(prefix + "bfd.all-interfaces"); value.Exists() {
+ data.BfdAllInterfaces = types.BoolValue(true)
+ } else {
+ data.BfdAllInterfaces = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "default-information.originate"); value.Exists() {
+ data.DefaultInformationOriginate = types.BoolValue(true)
+ } else {
+ data.DefaultInformationOriginate = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "default-information.originate.always"); value.Exists() {
+ data.DefaultInformationOriginateAlways = types.BoolValue(true)
+ } else {
+ data.DefaultInformationOriginateAlways = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "default-metric"); value.Exists() {
+ data.DefaultMetric = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "distance.distance"); value.Exists() {
+ data.Distance = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "domain-tag"); value.Exists() {
+ data.DomainTag = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "mpls.ldp.autoconfig"); value.Exists() {
+ data.MplsLdpAutoconfig = types.BoolValue(true)
+ } else {
+ data.MplsLdpAutoconfig = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "mpls.ldp.sync"); value.Exists() {
+ data.MplsLdpSync = types.BoolValue(true)
+ } else {
+ data.MplsLdpSync = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "neighbor"); value.Exists() {
+ data.Neighbor = make([]OSPFVRFNeighbor, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := OSPFVRFNeighbor{}
+ if cValue := v.Get("ip"); cValue.Exists() {
+ item.Ip = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("priority"); cValue.Exists() {
+ item.Priority = types.Int64Value(cValue.Int())
+ }
+ if cValue := v.Get("cost"); cValue.Exists() {
+ item.Cost = types.Int64Value(cValue.Int())
+ }
+ data.Neighbor = append(data.Neighbor, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + "network"); value.Exists() {
+ data.Network = make([]OSPFVRFNetwork, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := OSPFVRFNetwork{}
+ if cValue := v.Get("ip"); cValue.Exists() {
+ item.Ip = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("wildcard"); cValue.Exists() {
+ item.Wildcard = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("area"); cValue.Exists() {
+ item.Area = types.StringValue(cValue.String())
+ }
+ data.Network = append(data.Network, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + "priority"); value.Exists() {
+ data.Priority = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "router-id"); value.Exists() {
+ data.RouterId = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "shutdown"); value.Exists() {
+ data.Shutdown = types.BoolValue(value.Bool())
+ } else {
+ data.Shutdown = types.BoolNull()
+ }
+ if value := res.Get(prefix + "summary-address"); value.Exists() {
+ data.SummaryAddress = make([]OSPFVRFSummaryAddress, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := OSPFVRFSummaryAddress{}
+ if cValue := v.Get("ip"); cValue.Exists() {
+ item.Ip = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("mask"); cValue.Exists() {
+ item.Mask = types.StringValue(cValue.String())
+ }
+ data.SummaryAddress = append(data.SummaryAddress, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + "area"); value.Exists() {
+ data.Areas = make([]OSPFVRFAreas, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := OSPFVRFAreas{}
+ if cValue := v.Get("area-id"); cValue.Exists() {
+ item.AreaId = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("authentication.message-digest"); cValue.Exists() {
+ item.AuthenticationMessageDigest = types.BoolValue(true)
+ } else {
+ item.AuthenticationMessageDigest = types.BoolValue(false)
+ }
+ if cValue := v.Get("nssa"); cValue.Exists() {
+ item.Nssa = types.BoolValue(true)
+ } else {
+ item.Nssa = types.BoolValue(false)
+ }
+ if cValue := v.Get("nssa.nssa-options.default-information-originate"); cValue.Exists() {
+ item.NssaDefaultInformationOriginate = types.BoolValue(true)
+ } else {
+ item.NssaDefaultInformationOriginate = types.BoolValue(false)
+ }
+ if cValue := v.Get("nssa.nssa-options.default-information-originate.metric"); cValue.Exists() {
+ item.NssaDefaultInformationOriginateMetric = types.Int64Value(cValue.Int())
+ }
+ if cValue := v.Get("nssa.nssa-options.default-information-originate.metric-type"); cValue.Exists() {
+ item.NssaDefaultInformationOriginateMetricType = types.Int64Value(cValue.Int())
+ }
+ if cValue := v.Get("nssa.nssa-options.no-summary"); cValue.Exists() {
+ item.NssaNoSummary = types.BoolValue(true)
+ } else {
+ item.NssaNoSummary = types.BoolValue(false)
+ }
+ if cValue := v.Get("nssa.nssa-options.no-redistribution"); cValue.Exists() {
+ item.NssaNoRedistribution = types.BoolValue(true)
+ } else {
+ item.NssaNoRedistribution = types.BoolValue(false)
+ }
+ data.Areas = append(data.Areas, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + "auto-cost.reference-bandwidth"); value.Exists() {
+ data.AutoCostReferenceBandwidth = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "passive-interface.default"); value.Exists() {
+ data.PassiveInterfaceDefault = types.BoolValue(value.Bool())
+ } else {
+ data.PassiveInterfaceDefault = types.BoolNull()
+ }
+ if value := res.Get(prefix + "passive-interface.interface"); value.Exists() {
+ data.PassiveInterface = helpers.GetStringList(value.Array())
+ } else {
+ data.PassiveInterface = types.ListNull(types.StringType)
+ }
+ if value := res.Get(prefix + ""); value.Exists() {
+ data.PassiveInterfaceDisableGigabitEthernets = make([]OSPFVRFPassiveInterfaceDisableGigabitEthernets, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := OSPFVRFPassiveInterfaceDisableGigabitEthernets{}
+ if cValue := v.Get(""); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ data.PassiveInterfaceDisableGigabitEthernets = append(data.PassiveInterfaceDisableGigabitEthernets, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + ""); value.Exists() {
+ data.PassiveInterfaceDisableTwoGigabitEthernets = make([]OSPFVRFPassiveInterfaceDisableTwoGigabitEthernets, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := OSPFVRFPassiveInterfaceDisableTwoGigabitEthernets{}
+ if cValue := v.Get(""); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ data.PassiveInterfaceDisableTwoGigabitEthernets = append(data.PassiveInterfaceDisableTwoGigabitEthernets, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + ""); value.Exists() {
+ data.PassiveInterfaceDisableFiveGigabitEthernets = make([]OSPFVRFPassiveInterfaceDisableFiveGigabitEthernets, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := OSPFVRFPassiveInterfaceDisableFiveGigabitEthernets{}
+ if cValue := v.Get(""); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ data.PassiveInterfaceDisableFiveGigabitEthernets = append(data.PassiveInterfaceDisableFiveGigabitEthernets, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + ""); value.Exists() {
+ data.PassiveInterfaceDisableTenGigabitEthernets = make([]OSPFVRFPassiveInterfaceDisableTenGigabitEthernets, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := OSPFVRFPassiveInterfaceDisableTenGigabitEthernets{}
+ if cValue := v.Get(""); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ data.PassiveInterfaceDisableTenGigabitEthernets = append(data.PassiveInterfaceDisableTenGigabitEthernets, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + ""); value.Exists() {
+ data.PassiveInterfaceDisableTwentyFiveGigabitEthernets = make([]OSPFVRFPassiveInterfaceDisableTwentyFiveGigabitEthernets, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := OSPFVRFPassiveInterfaceDisableTwentyFiveGigabitEthernets{}
+ if cValue := v.Get(""); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ data.PassiveInterfaceDisableTwentyFiveGigabitEthernets = append(data.PassiveInterfaceDisableTwentyFiveGigabitEthernets, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + ""); value.Exists() {
+ data.PassiveInterfaceDisableFortyGigabitEthernets = make([]OSPFVRFPassiveInterfaceDisableFortyGigabitEthernets, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := OSPFVRFPassiveInterfaceDisableFortyGigabitEthernets{}
+ if cValue := v.Get(""); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ data.PassiveInterfaceDisableFortyGigabitEthernets = append(data.PassiveInterfaceDisableFortyGigabitEthernets, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + ""); value.Exists() {
+ data.PassiveInterfaceDisableHundredGigabitEthernets = make([]OSPFVRFPassiveInterfaceDisableHundredGigabitEthernets, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := OSPFVRFPassiveInterfaceDisableHundredGigabitEthernets{}
+ if cValue := v.Get(""); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ data.PassiveInterfaceDisableHundredGigabitEthernets = append(data.PassiveInterfaceDisableHundredGigabitEthernets, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + ""); value.Exists() {
+ data.PassiveInterfaceDisableTwoHundredGigabitEthernets = make([]OSPFVRFPassiveInterfaceDisableTwoHundredGigabitEthernets, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := OSPFVRFPassiveInterfaceDisableTwoHundredGigabitEthernets{}
+ if cValue := v.Get(""); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ data.PassiveInterfaceDisableTwoHundredGigabitEthernets = append(data.PassiveInterfaceDisableTwoHundredGigabitEthernets, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + ""); value.Exists() {
+ data.PassiveInterfaceDisableFourHundredGigabitEthernets = make([]OSPFVRFPassiveInterfaceDisableFourHundredGigabitEthernets, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := OSPFVRFPassiveInterfaceDisableFourHundredGigabitEthernets{}
+ if cValue := v.Get(""); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ data.PassiveInterfaceDisableFourHundredGigabitEthernets = append(data.PassiveInterfaceDisableFourHundredGigabitEthernets, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + ""); value.Exists() {
+ data.PassiveInterfaceDisableLoopbacks = make([]OSPFVRFPassiveInterfaceDisableLoopbacks, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := OSPFVRFPassiveInterfaceDisableLoopbacks{}
+ if cValue := v.Get(""); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ data.PassiveInterfaceDisableLoopbacks = append(data.PassiveInterfaceDisableLoopbacks, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + ""); value.Exists() {
+ data.PassiveInterfaceDisableVlans = make([]OSPFVRFPassiveInterfaceDisableVlans, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := OSPFVRFPassiveInterfaceDisableVlans{}
+ if cValue := v.Get(""); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ data.PassiveInterfaceDisableVlans = append(data.PassiveInterfaceDisableVlans, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + ""); value.Exists() {
+ data.PassiveInterfaceDisableTunnels = make([]OSPFVRFPassiveInterfaceDisableTunnels, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := OSPFVRFPassiveInterfaceDisableTunnels{}
+ if cValue := v.Get(""); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ data.PassiveInterfaceDisableTunnels = append(data.PassiveInterfaceDisableTunnels, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + ""); value.Exists() {
+ data.PassiveInterfaceDisablePortChannels = make([]OSPFVRFPassiveInterfaceDisablePortChannels, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := OSPFVRFPassiveInterfaceDisablePortChannels{}
+ if cValue := v.Get(""); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ data.PassiveInterfaceDisablePortChannels = append(data.PassiveInterfaceDisablePortChannels, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + ""); value.Exists() {
+ data.PassiveInterfaceDisablePortChannelSubinterfaces = make([]OSPFVRFPassiveInterfaceDisablePortChannelSubinterfaces, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := OSPFVRFPassiveInterfaceDisablePortChannelSubinterfaces{}
+ if cValue := v.Get(""); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ data.PassiveInterfaceDisablePortChannelSubinterfaces = append(data.PassiveInterfaceDisablePortChannelSubinterfaces, item)
+ return true
+ })
+ }
+}
+
+// End of section. //template:end fromBodyData
+
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyXML
+
+func (data *OSPFVRF) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/bfd/all-interfaces"); value.Exists() {
+ data.BfdAllInterfaces = types.BoolValue(true)
+ } else {
+ data.BfdAllInterfaces = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/default-information/originate"); value.Exists() {
+ data.DefaultInformationOriginate = types.BoolValue(true)
+ } else {
+ data.DefaultInformationOriginate = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/default-information/originate/always"); value.Exists() {
+ data.DefaultInformationOriginateAlways = types.BoolValue(true)
+ } else {
+ data.DefaultInformationOriginateAlways = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/default-metric"); value.Exists() {
+ data.DefaultMetric = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/distance/distance"); value.Exists() {
+ data.Distance = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/domain-tag"); value.Exists() {
+ data.DomainTag = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/mpls/ldp/autoconfig"); value.Exists() {
+ data.MplsLdpAutoconfig = types.BoolValue(true)
+ } else {
+ data.MplsLdpAutoconfig = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/mpls/ldp/sync"); value.Exists() {
+ data.MplsLdpSync = types.BoolValue(true)
+ } else {
+ data.MplsLdpSync = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/neighbor"); value.Exists() {
+ data.Neighbor = make([]OSPFVRFNeighbor, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := OSPFVRFNeighbor{}
+ if cValue := helpers.GetFromXPath(v, "ip"); cValue.Exists() {
+ item.Ip = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "priority"); cValue.Exists() {
+ item.Priority = types.Int64Value(cValue.Int())
+ }
+ if cValue := helpers.GetFromXPath(v, "cost"); cValue.Exists() {
+ item.Cost = types.Int64Value(cValue.Int())
+ }
+ data.Neighbor = append(data.Neighbor, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/network"); value.Exists() {
+ data.Network = make([]OSPFVRFNetwork, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := OSPFVRFNetwork{}
+ if cValue := helpers.GetFromXPath(v, "ip"); cValue.Exists() {
+ item.Ip = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "wildcard"); cValue.Exists() {
+ item.Wildcard = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "area"); cValue.Exists() {
+ item.Area = types.StringValue(cValue.String())
+ }
+ data.Network = append(data.Network, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/priority"); value.Exists() {
+ data.Priority = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/router-id"); value.Exists() {
+ data.RouterId = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/shutdown"); value.Exists() {
+ data.Shutdown = types.BoolValue(value.Bool())
+ } else {
+ data.Shutdown = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/summary-address"); value.Exists() {
+ data.SummaryAddress = make([]OSPFVRFSummaryAddress, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := OSPFVRFSummaryAddress{}
+ if cValue := helpers.GetFromXPath(v, "ip"); cValue.Exists() {
+ item.Ip = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "mask"); cValue.Exists() {
+ item.Mask = types.StringValue(cValue.String())
+ }
+ data.SummaryAddress = append(data.SummaryAddress, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/area"); value.Exists() {
+ data.Areas = make([]OSPFVRFAreas, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := OSPFVRFAreas{}
+ if cValue := helpers.GetFromXPath(v, "area-id"); cValue.Exists() {
+ item.AreaId = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "authentication/message-digest"); cValue.Exists() {
+ item.AuthenticationMessageDigest = types.BoolValue(true)
+ } else {
+ item.AuthenticationMessageDigest = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "nssa"); cValue.Exists() {
+ item.Nssa = types.BoolValue(true)
+ } else {
+ item.Nssa = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "nssa/nssa-options/default-information-originate"); cValue.Exists() {
+ item.NssaDefaultInformationOriginate = types.BoolValue(true)
+ } else {
+ item.NssaDefaultInformationOriginate = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "nssa/nssa-options/default-information-originate/metric"); cValue.Exists() {
+ item.NssaDefaultInformationOriginateMetric = types.Int64Value(cValue.Int())
+ }
+ if cValue := helpers.GetFromXPath(v, "nssa/nssa-options/default-information-originate/metric-type"); cValue.Exists() {
+ item.NssaDefaultInformationOriginateMetricType = types.Int64Value(cValue.Int())
+ }
+ if cValue := helpers.GetFromXPath(v, "nssa/nssa-options/no-summary"); cValue.Exists() {
+ item.NssaNoSummary = types.BoolValue(true)
+ } else {
+ item.NssaNoSummary = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "nssa/nssa-options/no-redistribution"); cValue.Exists() {
+ item.NssaNoRedistribution = types.BoolValue(true)
+ } else {
+ item.NssaNoRedistribution = types.BoolValue(false)
+ }
+ data.Areas = append(data.Areas, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/auto-cost/reference-bandwidth"); value.Exists() {
+ data.AutoCostReferenceBandwidth = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/passive-interface/default"); value.Exists() {
+ data.PassiveInterfaceDefault = types.BoolValue(value.Bool())
+ } else {
+ data.PassiveInterfaceDefault = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/passive-interface/interface"); value.Exists() {
+ data.PassiveInterface = helpers.GetStringListXML(value.Array())
+ } else {
+ data.PassiveInterface = types.ListNull(types.StringType)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/"); value.Exists() {
+ data.PassiveInterfaceDisableGigabitEthernets = make([]OSPFVRFPassiveInterfaceDisableGigabitEthernets, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := OSPFVRFPassiveInterfaceDisableGigabitEthernets{}
+ if cValue := helpers.GetFromXPath(v, ""); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ data.PassiveInterfaceDisableGigabitEthernets = append(data.PassiveInterfaceDisableGigabitEthernets, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/"); value.Exists() {
+ data.PassiveInterfaceDisableTwoGigabitEthernets = make([]OSPFVRFPassiveInterfaceDisableTwoGigabitEthernets, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := OSPFVRFPassiveInterfaceDisableTwoGigabitEthernets{}
+ if cValue := helpers.GetFromXPath(v, ""); cValue.Exists() {
item.Name = types.StringValue(cValue.String())
}
data.PassiveInterfaceDisableTwoGigabitEthernets = append(data.PassiveInterfaceDisableTwoGigabitEthernets, item)
return true
})
}
- if value := res.Get(prefix + "passive-interface-config.disable-interface.FiveGigabitEthernet"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/"); value.Exists() {
data.PassiveInterfaceDisableFiveGigabitEthernets = make([]OSPFVRFPassiveInterfaceDisableFiveGigabitEthernets, 0)
- value.ForEach(func(k, v gjson.Result) bool {
+ value.ForEach(func(_ int, v xmldot.Result) bool {
item := OSPFVRFPassiveInterfaceDisableFiveGigabitEthernets{}
- if cValue := v.Get("name"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, ""); cValue.Exists() {
item.Name = types.StringValue(cValue.String())
}
data.PassiveInterfaceDisableFiveGigabitEthernets = append(data.PassiveInterfaceDisableFiveGigabitEthernets, item)
return true
})
}
- if value := res.Get(prefix + "passive-interface-config.disable-interface.TenGigabitEthernet"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/"); value.Exists() {
data.PassiveInterfaceDisableTenGigabitEthernets = make([]OSPFVRFPassiveInterfaceDisableTenGigabitEthernets, 0)
- value.ForEach(func(k, v gjson.Result) bool {
+ value.ForEach(func(_ int, v xmldot.Result) bool {
item := OSPFVRFPassiveInterfaceDisableTenGigabitEthernets{}
- if cValue := v.Get("name"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, ""); cValue.Exists() {
item.Name = types.StringValue(cValue.String())
}
data.PassiveInterfaceDisableTenGigabitEthernets = append(data.PassiveInterfaceDisableTenGigabitEthernets, item)
return true
})
}
- if value := res.Get(prefix + "passive-interface-config.disable-interface.TwentyFiveGigabitE"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/"); value.Exists() {
data.PassiveInterfaceDisableTwentyFiveGigabitEthernets = make([]OSPFVRFPassiveInterfaceDisableTwentyFiveGigabitEthernets, 0)
- value.ForEach(func(k, v gjson.Result) bool {
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := OSPFVRFPassiveInterfaceDisableTwentyFiveGigabitEthernets{}
+ if cValue := helpers.GetFromXPath(v, ""); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ data.PassiveInterfaceDisableTwentyFiveGigabitEthernets = append(data.PassiveInterfaceDisableTwentyFiveGigabitEthernets, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/"); value.Exists() {
+ data.PassiveInterfaceDisableFortyGigabitEthernets = make([]OSPFVRFPassiveInterfaceDisableFortyGigabitEthernets, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := OSPFVRFPassiveInterfaceDisableFortyGigabitEthernets{}
+ if cValue := helpers.GetFromXPath(v, ""); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ data.PassiveInterfaceDisableFortyGigabitEthernets = append(data.PassiveInterfaceDisableFortyGigabitEthernets, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/"); value.Exists() {
+ data.PassiveInterfaceDisableHundredGigabitEthernets = make([]OSPFVRFPassiveInterfaceDisableHundredGigabitEthernets, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := OSPFVRFPassiveInterfaceDisableHundredGigabitEthernets{}
+ if cValue := helpers.GetFromXPath(v, ""); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ data.PassiveInterfaceDisableHundredGigabitEthernets = append(data.PassiveInterfaceDisableHundredGigabitEthernets, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/"); value.Exists() {
+ data.PassiveInterfaceDisableTwoHundredGigabitEthernets = make([]OSPFVRFPassiveInterfaceDisableTwoHundredGigabitEthernets, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := OSPFVRFPassiveInterfaceDisableTwoHundredGigabitEthernets{}
+ if cValue := helpers.GetFromXPath(v, ""); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ data.PassiveInterfaceDisableTwoHundredGigabitEthernets = append(data.PassiveInterfaceDisableTwoHundredGigabitEthernets, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/"); value.Exists() {
+ data.PassiveInterfaceDisableFourHundredGigabitEthernets = make([]OSPFVRFPassiveInterfaceDisableFourHundredGigabitEthernets, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := OSPFVRFPassiveInterfaceDisableFourHundredGigabitEthernets{}
+ if cValue := helpers.GetFromXPath(v, ""); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ data.PassiveInterfaceDisableFourHundredGigabitEthernets = append(data.PassiveInterfaceDisableFourHundredGigabitEthernets, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/"); value.Exists() {
+ data.PassiveInterfaceDisableLoopbacks = make([]OSPFVRFPassiveInterfaceDisableLoopbacks, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := OSPFVRFPassiveInterfaceDisableLoopbacks{}
+ if cValue := helpers.GetFromXPath(v, ""); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ data.PassiveInterfaceDisableLoopbacks = append(data.PassiveInterfaceDisableLoopbacks, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/"); value.Exists() {
+ data.PassiveInterfaceDisableVlans = make([]OSPFVRFPassiveInterfaceDisableVlans, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := OSPFVRFPassiveInterfaceDisableVlans{}
+ if cValue := helpers.GetFromXPath(v, ""); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ data.PassiveInterfaceDisableVlans = append(data.PassiveInterfaceDisableVlans, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/"); value.Exists() {
+ data.PassiveInterfaceDisableTunnels = make([]OSPFVRFPassiveInterfaceDisableTunnels, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := OSPFVRFPassiveInterfaceDisableTunnels{}
+ if cValue := helpers.GetFromXPath(v, ""); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ data.PassiveInterfaceDisableTunnels = append(data.PassiveInterfaceDisableTunnels, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/"); value.Exists() {
+ data.PassiveInterfaceDisablePortChannels = make([]OSPFVRFPassiveInterfaceDisablePortChannels, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := OSPFVRFPassiveInterfaceDisablePortChannels{}
+ if cValue := helpers.GetFromXPath(v, ""); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ data.PassiveInterfaceDisablePortChannels = append(data.PassiveInterfaceDisablePortChannels, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/"); value.Exists() {
+ data.PassiveInterfaceDisablePortChannelSubinterfaces = make([]OSPFVRFPassiveInterfaceDisablePortChannelSubinterfaces, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := OSPFVRFPassiveInterfaceDisablePortChannelSubinterfaces{}
+ if cValue := helpers.GetFromXPath(v, ""); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ data.PassiveInterfaceDisablePortChannelSubinterfaces = append(data.PassiveInterfaceDisablePortChannelSubinterfaces, item)
+ return true
+ })
+ }
+}
+
+// End of section. //template:end fromBodyXML
+
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyDataXML
+
+func (data *OSPFVRFData) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/bfd/all-interfaces"); value.Exists() {
+ data.BfdAllInterfaces = types.BoolValue(true)
+ } else {
+ data.BfdAllInterfaces = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/default-information/originate"); value.Exists() {
+ data.DefaultInformationOriginate = types.BoolValue(true)
+ } else {
+ data.DefaultInformationOriginate = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/default-information/originate/always"); value.Exists() {
+ data.DefaultInformationOriginateAlways = types.BoolValue(true)
+ } else {
+ data.DefaultInformationOriginateAlways = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/default-metric"); value.Exists() {
+ data.DefaultMetric = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/distance/distance"); value.Exists() {
+ data.Distance = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/domain-tag"); value.Exists() {
+ data.DomainTag = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/mpls/ldp/autoconfig"); value.Exists() {
+ data.MplsLdpAutoconfig = types.BoolValue(true)
+ } else {
+ data.MplsLdpAutoconfig = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/mpls/ldp/sync"); value.Exists() {
+ data.MplsLdpSync = types.BoolValue(true)
+ } else {
+ data.MplsLdpSync = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/neighbor"); value.Exists() {
+ data.Neighbor = make([]OSPFVRFNeighbor, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := OSPFVRFNeighbor{}
+ if cValue := helpers.GetFromXPath(v, "ip"); cValue.Exists() {
+ item.Ip = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "priority"); cValue.Exists() {
+ item.Priority = types.Int64Value(cValue.Int())
+ }
+ if cValue := helpers.GetFromXPath(v, "cost"); cValue.Exists() {
+ item.Cost = types.Int64Value(cValue.Int())
+ }
+ data.Neighbor = append(data.Neighbor, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/network"); value.Exists() {
+ data.Network = make([]OSPFVRFNetwork, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := OSPFVRFNetwork{}
+ if cValue := helpers.GetFromXPath(v, "ip"); cValue.Exists() {
+ item.Ip = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "wildcard"); cValue.Exists() {
+ item.Wildcard = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "area"); cValue.Exists() {
+ item.Area = types.StringValue(cValue.String())
+ }
+ data.Network = append(data.Network, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/priority"); value.Exists() {
+ data.Priority = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/router-id"); value.Exists() {
+ data.RouterId = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/shutdown"); value.Exists() {
+ data.Shutdown = types.BoolValue(value.Bool())
+ } else {
+ data.Shutdown = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/summary-address"); value.Exists() {
+ data.SummaryAddress = make([]OSPFVRFSummaryAddress, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := OSPFVRFSummaryAddress{}
+ if cValue := helpers.GetFromXPath(v, "ip"); cValue.Exists() {
+ item.Ip = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "mask"); cValue.Exists() {
+ item.Mask = types.StringValue(cValue.String())
+ }
+ data.SummaryAddress = append(data.SummaryAddress, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/area"); value.Exists() {
+ data.Areas = make([]OSPFVRFAreas, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := OSPFVRFAreas{}
+ if cValue := helpers.GetFromXPath(v, "area-id"); cValue.Exists() {
+ item.AreaId = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "authentication/message-digest"); cValue.Exists() {
+ item.AuthenticationMessageDigest = types.BoolValue(true)
+ } else {
+ item.AuthenticationMessageDigest = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "nssa"); cValue.Exists() {
+ item.Nssa = types.BoolValue(true)
+ } else {
+ item.Nssa = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "nssa/nssa-options/default-information-originate"); cValue.Exists() {
+ item.NssaDefaultInformationOriginate = types.BoolValue(true)
+ } else {
+ item.NssaDefaultInformationOriginate = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "nssa/nssa-options/default-information-originate/metric"); cValue.Exists() {
+ item.NssaDefaultInformationOriginateMetric = types.Int64Value(cValue.Int())
+ }
+ if cValue := helpers.GetFromXPath(v, "nssa/nssa-options/default-information-originate/metric-type"); cValue.Exists() {
+ item.NssaDefaultInformationOriginateMetricType = types.Int64Value(cValue.Int())
+ }
+ if cValue := helpers.GetFromXPath(v, "nssa/nssa-options/no-summary"); cValue.Exists() {
+ item.NssaNoSummary = types.BoolValue(true)
+ } else {
+ item.NssaNoSummary = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "nssa/nssa-options/no-redistribution"); cValue.Exists() {
+ item.NssaNoRedistribution = types.BoolValue(true)
+ } else {
+ item.NssaNoRedistribution = types.BoolValue(false)
+ }
+ data.Areas = append(data.Areas, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/auto-cost/reference-bandwidth"); value.Exists() {
+ data.AutoCostReferenceBandwidth = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/passive-interface/default"); value.Exists() {
+ data.PassiveInterfaceDefault = types.BoolValue(value.Bool())
+ } else {
+ data.PassiveInterfaceDefault = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/passive-interface/interface"); value.Exists() {
+ data.PassiveInterface = helpers.GetStringListXML(value.Array())
+ } else {
+ data.PassiveInterface = types.ListNull(types.StringType)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/"); value.Exists() {
+ data.PassiveInterfaceDisableGigabitEthernets = make([]OSPFVRFPassiveInterfaceDisableGigabitEthernets, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := OSPFVRFPassiveInterfaceDisableGigabitEthernets{}
+ if cValue := helpers.GetFromXPath(v, ""); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ data.PassiveInterfaceDisableGigabitEthernets = append(data.PassiveInterfaceDisableGigabitEthernets, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/"); value.Exists() {
+ data.PassiveInterfaceDisableTwoGigabitEthernets = make([]OSPFVRFPassiveInterfaceDisableTwoGigabitEthernets, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := OSPFVRFPassiveInterfaceDisableTwoGigabitEthernets{}
+ if cValue := helpers.GetFromXPath(v, ""); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ data.PassiveInterfaceDisableTwoGigabitEthernets = append(data.PassiveInterfaceDisableTwoGigabitEthernets, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/"); value.Exists() {
+ data.PassiveInterfaceDisableFiveGigabitEthernets = make([]OSPFVRFPassiveInterfaceDisableFiveGigabitEthernets, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := OSPFVRFPassiveInterfaceDisableFiveGigabitEthernets{}
+ if cValue := helpers.GetFromXPath(v, ""); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ data.PassiveInterfaceDisableFiveGigabitEthernets = append(data.PassiveInterfaceDisableFiveGigabitEthernets, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/"); value.Exists() {
+ data.PassiveInterfaceDisableTenGigabitEthernets = make([]OSPFVRFPassiveInterfaceDisableTenGigabitEthernets, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := OSPFVRFPassiveInterfaceDisableTenGigabitEthernets{}
+ if cValue := helpers.GetFromXPath(v, ""); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ data.PassiveInterfaceDisableTenGigabitEthernets = append(data.PassiveInterfaceDisableTenGigabitEthernets, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/"); value.Exists() {
+ data.PassiveInterfaceDisableTwentyFiveGigabitEthernets = make([]OSPFVRFPassiveInterfaceDisableTwentyFiveGigabitEthernets, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
item := OSPFVRFPassiveInterfaceDisableTwentyFiveGigabitEthernets{}
- if cValue := v.Get("name"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, ""); cValue.Exists() {
item.Name = types.StringValue(cValue.String())
}
data.PassiveInterfaceDisableTwentyFiveGigabitEthernets = append(data.PassiveInterfaceDisableTwentyFiveGigabitEthernets, item)
return true
})
}
- if value := res.Get(prefix + "passive-interface-config.disable-interface.FortyGigabitEthernet"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/"); value.Exists() {
data.PassiveInterfaceDisableFortyGigabitEthernets = make([]OSPFVRFPassiveInterfaceDisableFortyGigabitEthernets, 0)
- value.ForEach(func(k, v gjson.Result) bool {
+ value.ForEach(func(_ int, v xmldot.Result) bool {
item := OSPFVRFPassiveInterfaceDisableFortyGigabitEthernets{}
- if cValue := v.Get("name"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, ""); cValue.Exists() {
item.Name = types.StringValue(cValue.String())
}
data.PassiveInterfaceDisableFortyGigabitEthernets = append(data.PassiveInterfaceDisableFortyGigabitEthernets, item)
return true
})
}
- if value := res.Get(prefix + "passive-interface-config.disable-interface.HundredGigabitE"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/"); value.Exists() {
data.PassiveInterfaceDisableHundredGigabitEthernets = make([]OSPFVRFPassiveInterfaceDisableHundredGigabitEthernets, 0)
- value.ForEach(func(k, v gjson.Result) bool {
+ value.ForEach(func(_ int, v xmldot.Result) bool {
item := OSPFVRFPassiveInterfaceDisableHundredGigabitEthernets{}
- if cValue := v.Get("name"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, ""); cValue.Exists() {
item.Name = types.StringValue(cValue.String())
}
data.PassiveInterfaceDisableHundredGigabitEthernets = append(data.PassiveInterfaceDisableHundredGigabitEthernets, item)
return true
})
}
- if value := res.Get(prefix + "passive-interface-config.disable-interface.TwoHundredGigabitE"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/"); value.Exists() {
data.PassiveInterfaceDisableTwoHundredGigabitEthernets = make([]OSPFVRFPassiveInterfaceDisableTwoHundredGigabitEthernets, 0)
- value.ForEach(func(k, v gjson.Result) bool {
+ value.ForEach(func(_ int, v xmldot.Result) bool {
item := OSPFVRFPassiveInterfaceDisableTwoHundredGigabitEthernets{}
- if cValue := v.Get("name"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, ""); cValue.Exists() {
item.Name = types.StringValue(cValue.String())
}
data.PassiveInterfaceDisableTwoHundredGigabitEthernets = append(data.PassiveInterfaceDisableTwoHundredGigabitEthernets, item)
return true
})
}
- if value := res.Get(prefix + "passive-interface-config.disable-interface.FourHundredGigabitE"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/"); value.Exists() {
data.PassiveInterfaceDisableFourHundredGigabitEthernets = make([]OSPFVRFPassiveInterfaceDisableFourHundredGigabitEthernets, 0)
- value.ForEach(func(k, v gjson.Result) bool {
+ value.ForEach(func(_ int, v xmldot.Result) bool {
item := OSPFVRFPassiveInterfaceDisableFourHundredGigabitEthernets{}
- if cValue := v.Get("name"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, ""); cValue.Exists() {
item.Name = types.StringValue(cValue.String())
}
data.PassiveInterfaceDisableFourHundredGigabitEthernets = append(data.PassiveInterfaceDisableFourHundredGigabitEthernets, item)
return true
})
}
- if value := res.Get(prefix + "passive-interface-config.disable-interface.Loopback"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/"); value.Exists() {
data.PassiveInterfaceDisableLoopbacks = make([]OSPFVRFPassiveInterfaceDisableLoopbacks, 0)
- value.ForEach(func(k, v gjson.Result) bool {
+ value.ForEach(func(_ int, v xmldot.Result) bool {
item := OSPFVRFPassiveInterfaceDisableLoopbacks{}
- if cValue := v.Get("name"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, ""); cValue.Exists() {
item.Name = types.StringValue(cValue.String())
}
data.PassiveInterfaceDisableLoopbacks = append(data.PassiveInterfaceDisableLoopbacks, item)
return true
})
}
- if value := res.Get(prefix + "passive-interface-config.disable-interface.Vlan"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/"); value.Exists() {
data.PassiveInterfaceDisableVlans = make([]OSPFVRFPassiveInterfaceDisableVlans, 0)
- value.ForEach(func(k, v gjson.Result) bool {
+ value.ForEach(func(_ int, v xmldot.Result) bool {
item := OSPFVRFPassiveInterfaceDisableVlans{}
- if cValue := v.Get("name"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, ""); cValue.Exists() {
item.Name = types.StringValue(cValue.String())
}
data.PassiveInterfaceDisableVlans = append(data.PassiveInterfaceDisableVlans, item)
return true
})
}
- if value := res.Get(prefix + "passive-interface-config.disable-interface.Tunnel"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/"); value.Exists() {
data.PassiveInterfaceDisableTunnels = make([]OSPFVRFPassiveInterfaceDisableTunnels, 0)
- value.ForEach(func(k, v gjson.Result) bool {
+ value.ForEach(func(_ int, v xmldot.Result) bool {
item := OSPFVRFPassiveInterfaceDisableTunnels{}
- if cValue := v.Get("name"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, ""); cValue.Exists() {
item.Name = types.StringValue(cValue.String())
}
data.PassiveInterfaceDisableTunnels = append(data.PassiveInterfaceDisableTunnels, item)
return true
})
}
- if value := res.Get(prefix + "passive-interface-config.disable-interface.Port-channel"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/"); value.Exists() {
data.PassiveInterfaceDisablePortChannels = make([]OSPFVRFPassiveInterfaceDisablePortChannels, 0)
- value.ForEach(func(k, v gjson.Result) bool {
+ value.ForEach(func(_ int, v xmldot.Result) bool {
item := OSPFVRFPassiveInterfaceDisablePortChannels{}
- if cValue := v.Get("name"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, ""); cValue.Exists() {
item.Name = types.StringValue(cValue.String())
}
data.PassiveInterfaceDisablePortChannels = append(data.PassiveInterfaceDisablePortChannels, item)
return true
})
}
- if value := res.Get(prefix + "passive-interface-config.disable-interface.Port-channel-subinterface.Port-channel"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/"); value.Exists() {
data.PassiveInterfaceDisablePortChannelSubinterfaces = make([]OSPFVRFPassiveInterfaceDisablePortChannelSubinterfaces, 0)
- value.ForEach(func(k, v gjson.Result) bool {
+ value.ForEach(func(_ int, v xmldot.Result) bool {
item := OSPFVRFPassiveInterfaceDisablePortChannelSubinterfaces{}
- if cValue := v.Get("name"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, ""); cValue.Exists() {
item.Name = types.StringValue(cValue.String())
}
data.PassiveInterfaceDisablePortChannelSubinterfaces = append(data.PassiveInterfaceDisablePortChannelSubinterfaces, item)
@@ -1495,330 +3458,602 @@ func (data *OSPFVRF) fromBody(ctx context.Context, res gjson.Result) {
}
}
-// End of section. //template:end fromBody
+// End of section. //template:end fromBodyDataXML
-// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyData
+// Section below is generated&owned by "gen/generator.go". //template:begin getDeletedItems
-func (data *OSPFVRFData) fromBody(ctx context.Context, res gjson.Result) {
- prefix := helpers.LastElement(data.getPath()) + "."
- if res.Get(helpers.LastElement(data.getPath())).IsArray() {
- prefix += "0."
- }
- if value := res.Get(prefix + "bfd.all-interfaces"); value.Exists() {
- data.BfdAllInterfaces = types.BoolValue(true)
- } else {
- data.BfdAllInterfaces = types.BoolValue(false)
- }
- if value := res.Get(prefix + "default-information.originate"); value.Exists() {
- data.DefaultInformationOriginate = types.BoolValue(true)
- } else {
- data.DefaultInformationOriginate = types.BoolValue(false)
+func (data *OSPFVRF) getDeletedItems(ctx context.Context, state OSPFVRF) []string {
+ deletedItems := make([]string, 0)
+ for i := range state.PassiveInterfaceDisablePortChannelSubinterfaces {
+ stateKeyValues := [...]string{state.PassiveInterfaceDisablePortChannelSubinterfaces[i].Name.ValueString()}
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.PassiveInterfaceDisablePortChannelSubinterfaces[i].Name.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.PassiveInterfaceDisablePortChannelSubinterfaces {
+ found = true
+ if state.PassiveInterfaceDisablePortChannelSubinterfaces[i].Name.ValueString() != data.PassiveInterfaceDisablePortChannelSubinterfaces[j].Name.ValueString() {
+ found = false
+ }
+ if found {
+ break
+ }
+ }
+ if !found {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/passive-interface-config/disable-interface/Port-channel-subinterface/Port-channel=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
}
- if value := res.Get(prefix + "default-information.originate.always"); value.Exists() {
- data.DefaultInformationOriginateAlways = types.BoolValue(true)
- } else {
- data.DefaultInformationOriginateAlways = types.BoolValue(false)
+ for i := range state.PassiveInterfaceDisablePortChannels {
+ stateKeyValues := [...]string{state.PassiveInterfaceDisablePortChannels[i].Name.ValueString()}
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.PassiveInterfaceDisablePortChannels[i].Name.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.PassiveInterfaceDisablePortChannels {
+ found = true
+ if state.PassiveInterfaceDisablePortChannels[i].Name.ValueString() != data.PassiveInterfaceDisablePortChannels[j].Name.ValueString() {
+ found = false
+ }
+ if found {
+ break
+ }
+ }
+ if !found {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/passive-interface-config/disable-interface/Port-channel=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
}
- if value := res.Get(prefix + "default-metric"); value.Exists() {
- data.DefaultMetric = types.Int64Value(value.Int())
+ for i := range state.PassiveInterfaceDisableTunnels {
+ stateKeyValues := [...]string{state.PassiveInterfaceDisableTunnels[i].Name.ValueString()}
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.PassiveInterfaceDisableTunnels[i].Name.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.PassiveInterfaceDisableTunnels {
+ found = true
+ if state.PassiveInterfaceDisableTunnels[i].Name.ValueString() != data.PassiveInterfaceDisableTunnels[j].Name.ValueString() {
+ found = false
+ }
+ if found {
+ break
+ }
+ }
+ if !found {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/passive-interface-config/disable-interface/Tunnel=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
}
- if value := res.Get(prefix + "distance.distance"); value.Exists() {
- data.Distance = types.Int64Value(value.Int())
+ for i := range state.PassiveInterfaceDisableVlans {
+ stateKeyValues := [...]string{state.PassiveInterfaceDisableVlans[i].Name.ValueString()}
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.PassiveInterfaceDisableVlans[i].Name.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.PassiveInterfaceDisableVlans {
+ found = true
+ if state.PassiveInterfaceDisableVlans[i].Name.ValueString() != data.PassiveInterfaceDisableVlans[j].Name.ValueString() {
+ found = false
+ }
+ if found {
+ break
+ }
+ }
+ if !found {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/passive-interface-config/disable-interface/Vlan=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
}
- if value := res.Get(prefix + "domain-tag"); value.Exists() {
- data.DomainTag = types.Int64Value(value.Int())
+ for i := range state.PassiveInterfaceDisableLoopbacks {
+ stateKeyValues := [...]string{state.PassiveInterfaceDisableLoopbacks[i].Name.ValueString()}
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.PassiveInterfaceDisableLoopbacks[i].Name.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.PassiveInterfaceDisableLoopbacks {
+ found = true
+ if state.PassiveInterfaceDisableLoopbacks[i].Name.ValueString() != data.PassiveInterfaceDisableLoopbacks[j].Name.ValueString() {
+ found = false
+ }
+ if found {
+ break
+ }
+ }
+ if !found {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/passive-interface-config/disable-interface/Loopback=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
}
- if value := res.Get(prefix + "mpls.ldp.autoconfig"); value.Exists() {
- data.MplsLdpAutoconfig = types.BoolValue(true)
- } else {
- data.MplsLdpAutoconfig = types.BoolValue(false)
+ for i := range state.PassiveInterfaceDisableFourHundredGigabitEthernets {
+ stateKeyValues := [...]string{state.PassiveInterfaceDisableFourHundredGigabitEthernets[i].Name.ValueString()}
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.PassiveInterfaceDisableFourHundredGigabitEthernets[i].Name.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.PassiveInterfaceDisableFourHundredGigabitEthernets {
+ found = true
+ if state.PassiveInterfaceDisableFourHundredGigabitEthernets[i].Name.ValueString() != data.PassiveInterfaceDisableFourHundredGigabitEthernets[j].Name.ValueString() {
+ found = false
+ }
+ if found {
+ break
+ }
+ }
+ if !found {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/passive-interface-config/disable-interface/FourHundredGigabitE=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
}
- if value := res.Get(prefix + "mpls.ldp.sync"); value.Exists() {
- data.MplsLdpSync = types.BoolValue(true)
- } else {
- data.MplsLdpSync = types.BoolValue(false)
+ for i := range state.PassiveInterfaceDisableTwoHundredGigabitEthernets {
+ stateKeyValues := [...]string{state.PassiveInterfaceDisableTwoHundredGigabitEthernets[i].Name.ValueString()}
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.PassiveInterfaceDisableTwoHundredGigabitEthernets[i].Name.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.PassiveInterfaceDisableTwoHundredGigabitEthernets {
+ found = true
+ if state.PassiveInterfaceDisableTwoHundredGigabitEthernets[i].Name.ValueString() != data.PassiveInterfaceDisableTwoHundredGigabitEthernets[j].Name.ValueString() {
+ found = false
+ }
+ if found {
+ break
+ }
+ }
+ if !found {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/passive-interface-config/disable-interface/TwoHundredGigabitE=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
}
- if value := res.Get(prefix + "neighbor"); value.Exists() {
- data.Neighbor = make([]OSPFVRFNeighbor, 0)
- value.ForEach(func(k, v gjson.Result) bool {
- item := OSPFVRFNeighbor{}
- if cValue := v.Get("ip"); cValue.Exists() {
- item.Ip = types.StringValue(cValue.String())
+ for i := range state.PassiveInterfaceDisableHundredGigabitEthernets {
+ stateKeyValues := [...]string{state.PassiveInterfaceDisableHundredGigabitEthernets[i].Name.ValueString()}
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.PassiveInterfaceDisableHundredGigabitEthernets[i].Name.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.PassiveInterfaceDisableHundredGigabitEthernets {
+ found = true
+ if state.PassiveInterfaceDisableHundredGigabitEthernets[i].Name.ValueString() != data.PassiveInterfaceDisableHundredGigabitEthernets[j].Name.ValueString() {
+ found = false
}
- if cValue := v.Get("priority"); cValue.Exists() {
- item.Priority = types.Int64Value(cValue.Int())
+ if found {
+ break
+ }
+ }
+ if !found {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/passive-interface-config/disable-interface/HundredGigabitE=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ }
+ for i := range state.PassiveInterfaceDisableFortyGigabitEthernets {
+ stateKeyValues := [...]string{state.PassiveInterfaceDisableFortyGigabitEthernets[i].Name.ValueString()}
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.PassiveInterfaceDisableFortyGigabitEthernets[i].Name.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.PassiveInterfaceDisableFortyGigabitEthernets {
+ found = true
+ if state.PassiveInterfaceDisableFortyGigabitEthernets[i].Name.ValueString() != data.PassiveInterfaceDisableFortyGigabitEthernets[j].Name.ValueString() {
+ found = false
}
- if cValue := v.Get("cost"); cValue.Exists() {
- item.Cost = types.Int64Value(cValue.Int())
+ if found {
+ break
}
- data.Neighbor = append(data.Neighbor, item)
- return true
- })
+ }
+ if !found {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/passive-interface-config/disable-interface/FortyGigabitEthernet=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
}
- if value := res.Get(prefix + "network"); value.Exists() {
- data.Network = make([]OSPFVRFNetwork, 0)
- value.ForEach(func(k, v gjson.Result) bool {
- item := OSPFVRFNetwork{}
- if cValue := v.Get("ip"); cValue.Exists() {
- item.Ip = types.StringValue(cValue.String())
- }
- if cValue := v.Get("wildcard"); cValue.Exists() {
- item.Wildcard = types.StringValue(cValue.String())
+ for i := range state.PassiveInterfaceDisableTwentyFiveGigabitEthernets {
+ stateKeyValues := [...]string{state.PassiveInterfaceDisableTwentyFiveGigabitEthernets[i].Name.ValueString()}
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.PassiveInterfaceDisableTwentyFiveGigabitEthernets[i].Name.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.PassiveInterfaceDisableTwentyFiveGigabitEthernets {
+ found = true
+ if state.PassiveInterfaceDisableTwentyFiveGigabitEthernets[i].Name.ValueString() != data.PassiveInterfaceDisableTwentyFiveGigabitEthernets[j].Name.ValueString() {
+ found = false
}
- if cValue := v.Get("area"); cValue.Exists() {
- item.Area = types.StringValue(cValue.String())
+ if found {
+ break
}
- data.Network = append(data.Network, item)
- return true
- })
- }
- if value := res.Get(prefix + "priority"); value.Exists() {
- data.Priority = types.Int64Value(value.Int())
- }
- if value := res.Get(prefix + "router-id"); value.Exists() {
- data.RouterId = types.StringValue(value.String())
+ }
+ if !found {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/passive-interface-config/disable-interface/TwentyFiveGigabitE=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
}
- if value := res.Get(prefix + "shutdown"); value.Exists() {
- data.Shutdown = types.BoolValue(value.Bool())
- } else {
- data.Shutdown = types.BoolNull()
+ for i := range state.PassiveInterfaceDisableTenGigabitEthernets {
+ stateKeyValues := [...]string{state.PassiveInterfaceDisableTenGigabitEthernets[i].Name.ValueString()}
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.PassiveInterfaceDisableTenGigabitEthernets[i].Name.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.PassiveInterfaceDisableTenGigabitEthernets {
+ found = true
+ if state.PassiveInterfaceDisableTenGigabitEthernets[i].Name.ValueString() != data.PassiveInterfaceDisableTenGigabitEthernets[j].Name.ValueString() {
+ found = false
+ }
+ if found {
+ break
+ }
+ }
+ if !found {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/passive-interface-config/disable-interface/TenGigabitEthernet=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
}
- if value := res.Get(prefix + "summary-address"); value.Exists() {
- data.SummaryAddress = make([]OSPFVRFSummaryAddress, 0)
- value.ForEach(func(k, v gjson.Result) bool {
- item := OSPFVRFSummaryAddress{}
- if cValue := v.Get("ip"); cValue.Exists() {
- item.Ip = types.StringValue(cValue.String())
+ for i := range state.PassiveInterfaceDisableFiveGigabitEthernets {
+ stateKeyValues := [...]string{state.PassiveInterfaceDisableFiveGigabitEthernets[i].Name.ValueString()}
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.PassiveInterfaceDisableFiveGigabitEthernets[i].Name.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.PassiveInterfaceDisableFiveGigabitEthernets {
+ found = true
+ if state.PassiveInterfaceDisableFiveGigabitEthernets[i].Name.ValueString() != data.PassiveInterfaceDisableFiveGigabitEthernets[j].Name.ValueString() {
+ found = false
}
- if cValue := v.Get("mask"); cValue.Exists() {
- item.Mask = types.StringValue(cValue.String())
+ if found {
+ break
}
- data.SummaryAddress = append(data.SummaryAddress, item)
- return true
- })
+ }
+ if !found {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/passive-interface-config/disable-interface/FiveGigabitEthernet=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
}
- if value := res.Get(prefix + "area"); value.Exists() {
- data.Areas = make([]OSPFVRFAreas, 0)
- value.ForEach(func(k, v gjson.Result) bool {
- item := OSPFVRFAreas{}
- if cValue := v.Get("area-id"); cValue.Exists() {
- item.AreaId = types.StringValue(cValue.String())
+ for i := range state.PassiveInterfaceDisableTwoGigabitEthernets {
+ stateKeyValues := [...]string{state.PassiveInterfaceDisableTwoGigabitEthernets[i].Name.ValueString()}
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.PassiveInterfaceDisableTwoGigabitEthernets[i].Name.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.PassiveInterfaceDisableTwoGigabitEthernets {
+ found = true
+ if state.PassiveInterfaceDisableTwoGigabitEthernets[i].Name.ValueString() != data.PassiveInterfaceDisableTwoGigabitEthernets[j].Name.ValueString() {
+ found = false
}
- if cValue := v.Get("authentication.message-digest"); cValue.Exists() {
- item.AuthenticationMessageDigest = types.BoolValue(true)
- } else {
- item.AuthenticationMessageDigest = types.BoolValue(false)
+ if found {
+ break
}
- if cValue := v.Get("nssa"); cValue.Exists() {
- item.Nssa = types.BoolValue(true)
- } else {
- item.Nssa = types.BoolValue(false)
+ }
+ if !found {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/passive-interface-config/disable-interface/TwoGigabitEthernet=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ }
+ for i := range state.PassiveInterfaceDisableGigabitEthernets {
+ stateKeyValues := [...]string{state.PassiveInterfaceDisableGigabitEthernets[i].Name.ValueString()}
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.PassiveInterfaceDisableGigabitEthernets[i].Name.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.PassiveInterfaceDisableGigabitEthernets {
+ found = true
+ if state.PassiveInterfaceDisableGigabitEthernets[i].Name.ValueString() != data.PassiveInterfaceDisableGigabitEthernets[j].Name.ValueString() {
+ found = false
}
- if cValue := v.Get("nssa.nssa-options.default-information-originate"); cValue.Exists() {
- item.NssaDefaultInformationOriginate = types.BoolValue(true)
- } else {
- item.NssaDefaultInformationOriginate = types.BoolValue(false)
+ if found {
+ break
}
- if cValue := v.Get("nssa.nssa-options.default-information-originate.metric"); cValue.Exists() {
- item.NssaDefaultInformationOriginateMetric = types.Int64Value(cValue.Int())
+ }
+ if !found {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/passive-interface-config/disable-interface/GigabitEthernet=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ }
+ if !state.PassiveInterface.IsNull() {
+ if data.PassiveInterface.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/passive-interface/interface", state.getPath()))
+ } else {
+ var dataValues, stateValues []string
+ data.PassiveInterface.ElementsAs(ctx, &dataValues, false)
+ state.PassiveInterface.ElementsAs(ctx, &stateValues, false)
+ for _, v := range stateValues {
+ found := false
+ for _, vv := range dataValues {
+ if v == vv {
+ found = true
+ break
+ }
+ }
+ if !found {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/passive-interface/interface=%v", state.getPath(), v))
+ }
}
- if cValue := v.Get("nssa.nssa-options.default-information-originate.metric-type"); cValue.Exists() {
- item.NssaDefaultInformationOriginateMetricType = types.Int64Value(cValue.Int())
+ }
+ }
+ if !state.PassiveInterfaceDefault.IsNull() && data.PassiveInterfaceDefault.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/passive-interface/default", state.getPath()))
+ }
+ if !state.AutoCostReferenceBandwidth.IsNull() && data.AutoCostReferenceBandwidth.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/auto-cost/reference-bandwidth", state.getPath()))
+ }
+ for i := range state.Areas {
+ stateKeyValues := [...]string{state.Areas[i].AreaId.ValueString()}
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.Areas[i].AreaId.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.Areas {
+ found = true
+ if state.Areas[i].AreaId.ValueString() != data.Areas[j].AreaId.ValueString() {
+ found = false
}
- if cValue := v.Get("nssa.nssa-options.no-summary"); cValue.Exists() {
- item.NssaNoSummary = types.BoolValue(true)
- } else {
- item.NssaNoSummary = types.BoolValue(false)
+ if found {
+ if !state.Areas[i].NssaNoRedistribution.IsNull() && data.Areas[j].NssaNoRedistribution.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/area=%v/nssa/nssa-options/no-redistribution", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ if !state.Areas[i].NssaNoSummary.IsNull() && data.Areas[j].NssaNoSummary.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/area=%v/nssa/nssa-options/no-summary", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ if !state.Areas[i].NssaDefaultInformationOriginateMetricType.IsNull() && data.Areas[j].NssaDefaultInformationOriginateMetricType.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/area=%v/nssa/nssa-options/default-information-originate/metric-type", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ if !state.Areas[i].NssaDefaultInformationOriginateMetric.IsNull() && data.Areas[j].NssaDefaultInformationOriginateMetric.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/area=%v/nssa/nssa-options/default-information-originate/metric", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ if !state.Areas[i].NssaDefaultInformationOriginate.IsNull() && data.Areas[j].NssaDefaultInformationOriginate.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/area=%v/nssa/nssa-options/default-information-originate", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ if !state.Areas[i].Nssa.IsNull() && data.Areas[j].Nssa.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/area=%v/nssa", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ if !state.Areas[i].AuthenticationMessageDigest.IsNull() && data.Areas[j].AuthenticationMessageDigest.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/area=%v/authentication/message-digest", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ break
}
- if cValue := v.Get("nssa.nssa-options.no-redistribution"); cValue.Exists() {
- item.NssaNoRedistribution = types.BoolValue(true)
- } else {
- item.NssaNoRedistribution = types.BoolValue(false)
+ }
+ if !found {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/area=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ }
+ for i := range state.SummaryAddress {
+ stateKeyValues := [...]string{state.SummaryAddress[i].Ip.ValueString()}
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.SummaryAddress[i].Ip.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.SummaryAddress {
+ found = true
+ if state.SummaryAddress[i].Ip.ValueString() != data.SummaryAddress[j].Ip.ValueString() {
+ found = false
}
- data.Areas = append(data.Areas, item)
- return true
- })
+ if found {
+ if !state.SummaryAddress[i].Mask.IsNull() && data.SummaryAddress[j].Mask.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/summary-address=%v/mask", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ break
+ }
+ }
+ if !found {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/summary-address=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
}
- if value := res.Get(prefix + "auto-cost.reference-bandwidth"); value.Exists() {
- data.AutoCostReferenceBandwidth = types.Int64Value(value.Int())
+ if !state.Shutdown.IsNull() && data.Shutdown.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/shutdown", state.getPath()))
}
- if value := res.Get(prefix + "passive-interface.default"); value.Exists() {
- data.PassiveInterfaceDefault = types.BoolValue(value.Bool())
- } else {
- data.PassiveInterfaceDefault = types.BoolNull()
+ if !state.RouterId.IsNull() && data.RouterId.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/router-id", state.getPath()))
}
- if value := res.Get(prefix + "passive-interface.interface"); value.Exists() {
- data.PassiveInterface = helpers.GetStringList(value.Array())
- } else {
- data.PassiveInterface = types.ListNull(types.StringType)
+ if !state.Priority.IsNull() && data.Priority.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/priority", state.getPath()))
}
- if value := res.Get(prefix + "passive-interface-config.disable-interface.GigabitEthernet"); value.Exists() {
- data.PassiveInterfaceDisableGigabitEthernets = make([]OSPFVRFPassiveInterfaceDisableGigabitEthernets, 0)
- value.ForEach(func(k, v gjson.Result) bool {
- item := OSPFVRFPassiveInterfaceDisableGigabitEthernets{}
- if cValue := v.Get("name"); cValue.Exists() {
- item.Name = types.StringValue(cValue.String())
+ for i := range state.Network {
+ stateKeyValues := [...]string{state.Network[i].Ip.ValueString()}
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.Network[i].Ip.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.Network {
+ found = true
+ if state.Network[i].Ip.ValueString() != data.Network[j].Ip.ValueString() {
+ found = false
}
- data.PassiveInterfaceDisableGigabitEthernets = append(data.PassiveInterfaceDisableGigabitEthernets, item)
- return true
- })
- }
- if value := res.Get(prefix + "passive-interface-config.disable-interface.TwoGigabitEthernet"); value.Exists() {
- data.PassiveInterfaceDisableTwoGigabitEthernets = make([]OSPFVRFPassiveInterfaceDisableTwoGigabitEthernets, 0)
- value.ForEach(func(k, v gjson.Result) bool {
- item := OSPFVRFPassiveInterfaceDisableTwoGigabitEthernets{}
- if cValue := v.Get("name"); cValue.Exists() {
- item.Name = types.StringValue(cValue.String())
+ if found {
+ if !state.Network[i].Area.IsNull() && data.Network[j].Area.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/network=%v/area", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ if !state.Network[i].Wildcard.IsNull() && data.Network[j].Wildcard.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/network=%v/wildcard", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ break
}
- data.PassiveInterfaceDisableTwoGigabitEthernets = append(data.PassiveInterfaceDisableTwoGigabitEthernets, item)
- return true
- })
+ }
+ if !found {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/network=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
}
- if value := res.Get(prefix + "passive-interface-config.disable-interface.FiveGigabitEthernet"); value.Exists() {
- data.PassiveInterfaceDisableFiveGigabitEthernets = make([]OSPFVRFPassiveInterfaceDisableFiveGigabitEthernets, 0)
- value.ForEach(func(k, v gjson.Result) bool {
- item := OSPFVRFPassiveInterfaceDisableFiveGigabitEthernets{}
- if cValue := v.Get("name"); cValue.Exists() {
- item.Name = types.StringValue(cValue.String())
+ for i := range state.Neighbor {
+ stateKeyValues := [...]string{state.Neighbor[i].Ip.ValueString()}
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.Neighbor[i].Ip.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.Neighbor {
+ found = true
+ if state.Neighbor[i].Ip.ValueString() != data.Neighbor[j].Ip.ValueString() {
+ found = false
}
- data.PassiveInterfaceDisableFiveGigabitEthernets = append(data.PassiveInterfaceDisableFiveGigabitEthernets, item)
- return true
- })
- }
- if value := res.Get(prefix + "passive-interface-config.disable-interface.TenGigabitEthernet"); value.Exists() {
- data.PassiveInterfaceDisableTenGigabitEthernets = make([]OSPFVRFPassiveInterfaceDisableTenGigabitEthernets, 0)
- value.ForEach(func(k, v gjson.Result) bool {
- item := OSPFVRFPassiveInterfaceDisableTenGigabitEthernets{}
- if cValue := v.Get("name"); cValue.Exists() {
- item.Name = types.StringValue(cValue.String())
+ if found {
+ if !state.Neighbor[i].Cost.IsNull() && data.Neighbor[j].Cost.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/neighbor=%v/cost", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ if !state.Neighbor[i].Priority.IsNull() && data.Neighbor[j].Priority.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/neighbor=%v/priority", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ break
}
- data.PassiveInterfaceDisableTenGigabitEthernets = append(data.PassiveInterfaceDisableTenGigabitEthernets, item)
- return true
- })
+ }
+ if !found {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/neighbor=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
}
- if value := res.Get(prefix + "passive-interface-config.disable-interface.TwentyFiveGigabitE"); value.Exists() {
- data.PassiveInterfaceDisableTwentyFiveGigabitEthernets = make([]OSPFVRFPassiveInterfaceDisableTwentyFiveGigabitEthernets, 0)
- value.ForEach(func(k, v gjson.Result) bool {
- item := OSPFVRFPassiveInterfaceDisableTwentyFiveGigabitEthernets{}
- if cValue := v.Get("name"); cValue.Exists() {
- item.Name = types.StringValue(cValue.String())
- }
- data.PassiveInterfaceDisableTwentyFiveGigabitEthernets = append(data.PassiveInterfaceDisableTwentyFiveGigabitEthernets, item)
- return true
- })
+ if !state.MplsLdpSync.IsNull() && data.MplsLdpSync.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/mpls/ldp/sync", state.getPath()))
}
- if value := res.Get(prefix + "passive-interface-config.disable-interface.FortyGigabitEthernet"); value.Exists() {
- data.PassiveInterfaceDisableFortyGigabitEthernets = make([]OSPFVRFPassiveInterfaceDisableFortyGigabitEthernets, 0)
- value.ForEach(func(k, v gjson.Result) bool {
- item := OSPFVRFPassiveInterfaceDisableFortyGigabitEthernets{}
- if cValue := v.Get("name"); cValue.Exists() {
- item.Name = types.StringValue(cValue.String())
- }
- data.PassiveInterfaceDisableFortyGigabitEthernets = append(data.PassiveInterfaceDisableFortyGigabitEthernets, item)
- return true
- })
+ if !state.MplsLdpAutoconfig.IsNull() && data.MplsLdpAutoconfig.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/mpls/ldp/autoconfig", state.getPath()))
}
- if value := res.Get(prefix + "passive-interface-config.disable-interface.HundredGigabitE"); value.Exists() {
- data.PassiveInterfaceDisableHundredGigabitEthernets = make([]OSPFVRFPassiveInterfaceDisableHundredGigabitEthernets, 0)
- value.ForEach(func(k, v gjson.Result) bool {
- item := OSPFVRFPassiveInterfaceDisableHundredGigabitEthernets{}
- if cValue := v.Get("name"); cValue.Exists() {
- item.Name = types.StringValue(cValue.String())
- }
- data.PassiveInterfaceDisableHundredGigabitEthernets = append(data.PassiveInterfaceDisableHundredGigabitEthernets, item)
- return true
- })
+ if !state.DomainTag.IsNull() && data.DomainTag.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/domain-tag", state.getPath()))
}
- if value := res.Get(prefix + "passive-interface-config.disable-interface.TwoHundredGigabitE"); value.Exists() {
- data.PassiveInterfaceDisableTwoHundredGigabitEthernets = make([]OSPFVRFPassiveInterfaceDisableTwoHundredGigabitEthernets, 0)
- value.ForEach(func(k, v gjson.Result) bool {
- item := OSPFVRFPassiveInterfaceDisableTwoHundredGigabitEthernets{}
- if cValue := v.Get("name"); cValue.Exists() {
- item.Name = types.StringValue(cValue.String())
- }
- data.PassiveInterfaceDisableTwoHundredGigabitEthernets = append(data.PassiveInterfaceDisableTwoHundredGigabitEthernets, item)
- return true
- })
+ if !state.Distance.IsNull() && data.Distance.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/distance/distance", state.getPath()))
}
- if value := res.Get(prefix + "passive-interface-config.disable-interface.FourHundredGigabitE"); value.Exists() {
- data.PassiveInterfaceDisableFourHundredGigabitEthernets = make([]OSPFVRFPassiveInterfaceDisableFourHundredGigabitEthernets, 0)
- value.ForEach(func(k, v gjson.Result) bool {
- item := OSPFVRFPassiveInterfaceDisableFourHundredGigabitEthernets{}
- if cValue := v.Get("name"); cValue.Exists() {
- item.Name = types.StringValue(cValue.String())
- }
- data.PassiveInterfaceDisableFourHundredGigabitEthernets = append(data.PassiveInterfaceDisableFourHundredGigabitEthernets, item)
- return true
- })
+ if !state.DefaultMetric.IsNull() && data.DefaultMetric.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/default-metric", state.getPath()))
}
- if value := res.Get(prefix + "passive-interface-config.disable-interface.Loopback"); value.Exists() {
- data.PassiveInterfaceDisableLoopbacks = make([]OSPFVRFPassiveInterfaceDisableLoopbacks, 0)
- value.ForEach(func(k, v gjson.Result) bool {
- item := OSPFVRFPassiveInterfaceDisableLoopbacks{}
- if cValue := v.Get("name"); cValue.Exists() {
- item.Name = types.StringValue(cValue.String())
- }
- data.PassiveInterfaceDisableLoopbacks = append(data.PassiveInterfaceDisableLoopbacks, item)
- return true
- })
+ if !state.DefaultInformationOriginateAlways.IsNull() && data.DefaultInformationOriginateAlways.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/default-information/originate/always", state.getPath()))
}
- if value := res.Get(prefix + "passive-interface-config.disable-interface.Vlan"); value.Exists() {
- data.PassiveInterfaceDisableVlans = make([]OSPFVRFPassiveInterfaceDisableVlans, 0)
- value.ForEach(func(k, v gjson.Result) bool {
- item := OSPFVRFPassiveInterfaceDisableVlans{}
- if cValue := v.Get("name"); cValue.Exists() {
- item.Name = types.StringValue(cValue.String())
- }
- data.PassiveInterfaceDisableVlans = append(data.PassiveInterfaceDisableVlans, item)
- return true
- })
+ if !state.DefaultInformationOriginate.IsNull() && data.DefaultInformationOriginate.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/default-information/originate", state.getPath()))
}
- if value := res.Get(prefix + "passive-interface-config.disable-interface.Tunnel"); value.Exists() {
- data.PassiveInterfaceDisableTunnels = make([]OSPFVRFPassiveInterfaceDisableTunnels, 0)
- value.ForEach(func(k, v gjson.Result) bool {
- item := OSPFVRFPassiveInterfaceDisableTunnels{}
- if cValue := v.Get("name"); cValue.Exists() {
- item.Name = types.StringValue(cValue.String())
- }
- data.PassiveInterfaceDisableTunnels = append(data.PassiveInterfaceDisableTunnels, item)
- return true
- })
+ if !state.BfdAllInterfaces.IsNull() && data.BfdAllInterfaces.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/bfd/all-interfaces", state.getPath()))
}
- if value := res.Get(prefix + "passive-interface-config.disable-interface.Port-channel"); value.Exists() {
- data.PassiveInterfaceDisablePortChannels = make([]OSPFVRFPassiveInterfaceDisablePortChannels, 0)
- value.ForEach(func(k, v gjson.Result) bool {
- item := OSPFVRFPassiveInterfaceDisablePortChannels{}
- if cValue := v.Get("name"); cValue.Exists() {
- item.Name = types.StringValue(cValue.String())
- }
- data.PassiveInterfaceDisablePortChannels = append(data.PassiveInterfaceDisablePortChannels, item)
- return true
- })
+
+ return deletedItems
+}
+
+// End of section. //template:end getDeletedItems
+
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletedItemsXML
+
+func (data *OSPFVRF) addDeletedItemsXML(ctx context.Context, state OSPFVRF, body string) string {
+ b := netconf.NewBody(body)
+ if !state.BfdAllInterfaces.IsNull() && data.BfdAllInterfaces.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/bfd/all-interfaces")
}
- if value := res.Get(prefix + "passive-interface-config.disable-interface.Port-channel-subinterface.Port-channel"); value.Exists() {
- data.PassiveInterfaceDisablePortChannelSubinterfaces = make([]OSPFVRFPassiveInterfaceDisablePortChannelSubinterfaces, 0)
- value.ForEach(func(k, v gjson.Result) bool {
- item := OSPFVRFPassiveInterfaceDisablePortChannelSubinterfaces{}
- if cValue := v.Get("name"); cValue.Exists() {
- item.Name = types.StringValue(cValue.String())
- }
- data.PassiveInterfaceDisablePortChannelSubinterfaces = append(data.PassiveInterfaceDisablePortChannelSubinterfaces, item)
- return true
- })
+ if !state.DefaultInformationOriginate.IsNull() && data.DefaultInformationOriginate.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/default-information/originate")
+ }
+ if !state.DefaultInformationOriginateAlways.IsNull() && data.DefaultInformationOriginateAlways.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/default-information/originate/always")
+ }
+ if !state.DefaultMetric.IsNull() && data.DefaultMetric.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/default-metric")
+ }
+ if !state.Distance.IsNull() && data.Distance.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/distance/distance")
+ }
+ if !state.DomainTag.IsNull() && data.DomainTag.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/domain-tag")
+ }
+ if !state.MplsLdpAutoconfig.IsNull() && data.MplsLdpAutoconfig.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/mpls/ldp/autoconfig")
}
-}
-
-// End of section. //template:end fromBodyData
-
-// Section below is generated&owned by "gen/generator.go". //template:begin getDeletedItems
-
-func (data *OSPFVRF) getDeletedItems(ctx context.Context, state OSPFVRF) []string {
- deletedItems := make([]string, 0)
- for i := range state.PassiveInterfaceDisablePortChannelSubinterfaces {
- stateKeyValues := [...]string{state.PassiveInterfaceDisablePortChannelSubinterfaces[i].Name.ValueString()}
+ if !state.MplsLdpSync.IsNull() && data.MplsLdpSync.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/mpls/ldp/sync")
+ }
+ for i := range state.Neighbor {
+ stateKeys := [...]string{"ip"}
+ stateKeyValues := [...]string{state.Neighbor[i].Ip.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
emptyKeys := true
- if !reflect.ValueOf(state.PassiveInterfaceDisablePortChannelSubinterfaces[i].Name.ValueString()).IsZero() {
+ if !reflect.ValueOf(state.Neighbor[i].Ip.ValueString()).IsZero() {
emptyKeys = false
}
if emptyKeys {
@@ -1826,24 +4061,35 @@ func (data *OSPFVRF) getDeletedItems(ctx context.Context, state OSPFVRF) []strin
}
found := false
- for j := range data.PassiveInterfaceDisablePortChannelSubinterfaces {
+ for j := range data.Neighbor {
found = true
- if state.PassiveInterfaceDisablePortChannelSubinterfaces[i].Name.ValueString() != data.PassiveInterfaceDisablePortChannelSubinterfaces[j].Name.ValueString() {
+ if state.Neighbor[i].Ip.ValueString() != data.Neighbor[j].Ip.ValueString() {
found = false
}
if found {
+ if !state.Neighbor[i].Priority.IsNull() && data.Neighbor[j].Priority.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/neighbor%v/priority", predicates))
+ }
+ if !state.Neighbor[i].Cost.IsNull() && data.Neighbor[j].Cost.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/neighbor%v/cost", predicates))
+ }
break
}
}
if !found {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/passive-interface-config/disable-interface/Port-channel-subinterface/Port-channel=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/neighbor%v", predicates))
}
}
- for i := range state.PassiveInterfaceDisablePortChannels {
- stateKeyValues := [...]string{state.PassiveInterfaceDisablePortChannels[i].Name.ValueString()}
+ for i := range state.Network {
+ stateKeys := [...]string{"ip"}
+ stateKeyValues := [...]string{state.Network[i].Ip.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
emptyKeys := true
- if !reflect.ValueOf(state.PassiveInterfaceDisablePortChannels[i].Name.ValueString()).IsZero() {
+ if !reflect.ValueOf(state.Network[i].Ip.ValueString()).IsZero() {
emptyKeys = false
}
if emptyKeys {
@@ -1851,24 +4097,44 @@ func (data *OSPFVRF) getDeletedItems(ctx context.Context, state OSPFVRF) []strin
}
found := false
- for j := range data.PassiveInterfaceDisablePortChannels {
+ for j := range data.Network {
found = true
- if state.PassiveInterfaceDisablePortChannels[i].Name.ValueString() != data.PassiveInterfaceDisablePortChannels[j].Name.ValueString() {
+ if state.Network[i].Ip.ValueString() != data.Network[j].Ip.ValueString() {
found = false
}
if found {
+ if !state.Network[i].Wildcard.IsNull() && data.Network[j].Wildcard.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/network%v/wildcard", predicates))
+ }
+ if !state.Network[i].Area.IsNull() && data.Network[j].Area.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/network%v/area", predicates))
+ }
break
}
}
if !found {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/passive-interface-config/disable-interface/Port-channel=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/network%v", predicates))
}
}
- for i := range state.PassiveInterfaceDisableTunnels {
- stateKeyValues := [...]string{state.PassiveInterfaceDisableTunnels[i].Name.ValueString()}
+ if !state.Priority.IsNull() && data.Priority.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/priority")
+ }
+ if !state.RouterId.IsNull() && data.RouterId.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/router-id")
+ }
+ if !state.Shutdown.IsNull() && data.Shutdown.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/shutdown")
+ }
+ for i := range state.SummaryAddress {
+ stateKeys := [...]string{"ip"}
+ stateKeyValues := [...]string{state.SummaryAddress[i].Ip.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
emptyKeys := true
- if !reflect.ValueOf(state.PassiveInterfaceDisableTunnels[i].Name.ValueString()).IsZero() {
+ if !reflect.ValueOf(state.SummaryAddress[i].Ip.ValueString()).IsZero() {
emptyKeys = false
}
if emptyKeys {
@@ -1876,24 +4142,32 @@ func (data *OSPFVRF) getDeletedItems(ctx context.Context, state OSPFVRF) []strin
}
found := false
- for j := range data.PassiveInterfaceDisableTunnels {
+ for j := range data.SummaryAddress {
found = true
- if state.PassiveInterfaceDisableTunnels[i].Name.ValueString() != data.PassiveInterfaceDisableTunnels[j].Name.ValueString() {
+ if state.SummaryAddress[i].Ip.ValueString() != data.SummaryAddress[j].Ip.ValueString() {
found = false
}
if found {
+ if !state.SummaryAddress[i].Mask.IsNull() && data.SummaryAddress[j].Mask.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/summary-address%v/mask", predicates))
+ }
break
}
}
if !found {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/passive-interface-config/disable-interface/Tunnel=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/summary-address%v", predicates))
}
}
- for i := range state.PassiveInterfaceDisableVlans {
- stateKeyValues := [...]string{state.PassiveInterfaceDisableVlans[i].Name.ValueString()}
+ for i := range state.Areas {
+ stateKeys := [...]string{"area-id"}
+ stateKeyValues := [...]string{state.Areas[i].AreaId.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
emptyKeys := true
- if !reflect.ValueOf(state.PassiveInterfaceDisableVlans[i].Name.ValueString()).IsZero() {
+ if !reflect.ValueOf(state.Areas[i].AreaId.ValueString()).IsZero() {
emptyKeys = false
}
if emptyKeys {
@@ -1901,24 +4175,77 @@ func (data *OSPFVRF) getDeletedItems(ctx context.Context, state OSPFVRF) []strin
}
found := false
- for j := range data.PassiveInterfaceDisableVlans {
+ for j := range data.Areas {
found = true
- if state.PassiveInterfaceDisableVlans[i].Name.ValueString() != data.PassiveInterfaceDisableVlans[j].Name.ValueString() {
+ if state.Areas[i].AreaId.ValueString() != data.Areas[j].AreaId.ValueString() {
found = false
}
if found {
+ if !state.Areas[i].AuthenticationMessageDigest.IsNull() && data.Areas[j].AuthenticationMessageDigest.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/area%v/authentication/message-digest", predicates))
+ }
+ if !state.Areas[i].Nssa.IsNull() && data.Areas[j].Nssa.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/area%v/nssa", predicates))
+ }
+ if !state.Areas[i].NssaDefaultInformationOriginate.IsNull() && data.Areas[j].NssaDefaultInformationOriginate.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/area%v/nssa/nssa-options/default-information-originate", predicates))
+ }
+ if !state.Areas[i].NssaDefaultInformationOriginateMetric.IsNull() && data.Areas[j].NssaDefaultInformationOriginateMetric.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/area%v/nssa/nssa-options/default-information-originate/metric", predicates))
+ }
+ if !state.Areas[i].NssaDefaultInformationOriginateMetricType.IsNull() && data.Areas[j].NssaDefaultInformationOriginateMetricType.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/area%v/nssa/nssa-options/default-information-originate/metric-type", predicates))
+ }
+ if !state.Areas[i].NssaNoSummary.IsNull() && data.Areas[j].NssaNoSummary.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/area%v/nssa/nssa-options/no-summary", predicates))
+ }
+ if !state.Areas[i].NssaNoRedistribution.IsNull() && data.Areas[j].NssaNoRedistribution.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/area%v/nssa/nssa-options/no-redistribution", predicates))
+ }
break
}
}
if !found {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/passive-interface-config/disable-interface/Vlan=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/area%v", predicates))
}
}
- for i := range state.PassiveInterfaceDisableLoopbacks {
- stateKeyValues := [...]string{state.PassiveInterfaceDisableLoopbacks[i].Name.ValueString()}
+ if !state.AutoCostReferenceBandwidth.IsNull() && data.AutoCostReferenceBandwidth.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/auto-cost/reference-bandwidth")
+ }
+ if !state.PassiveInterfaceDefault.IsNull() && data.PassiveInterfaceDefault.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/passive-interface/default")
+ }
+ if !state.PassiveInterface.IsNull() {
+ if data.PassiveInterface.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/passive-interface/interface")
+ } else {
+ var dataValues, stateValues []string
+ data.PassiveInterface.ElementsAs(ctx, &dataValues, false)
+ state.PassiveInterface.ElementsAs(ctx, &stateValues, false)
+ for _, v := range stateValues {
+ found := false
+ for _, vv := range dataValues {
+ if v == vv {
+ found = true
+ break
+ }
+ }
+ if !found {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/passive-interface/interface[.=%v]", v))
+ }
+ }
+ }
+ }
+ for i := range state.PassiveInterfaceDisableGigabitEthernets {
+ stateKeys := [...]string{""}
+ stateKeyValues := [...]string{state.PassiveInterfaceDisableGigabitEthernets[i].Name.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
emptyKeys := true
- if !reflect.ValueOf(state.PassiveInterfaceDisableLoopbacks[i].Name.ValueString()).IsZero() {
+ if !reflect.ValueOf(state.PassiveInterfaceDisableGigabitEthernets[i].Name.ValueString()).IsZero() {
emptyKeys = false
}
if emptyKeys {
@@ -1926,9 +4253,9 @@ func (data *OSPFVRF) getDeletedItems(ctx context.Context, state OSPFVRF) []strin
}
found := false
- for j := range data.PassiveInterfaceDisableLoopbacks {
+ for j := range data.PassiveInterfaceDisableGigabitEthernets {
found = true
- if state.PassiveInterfaceDisableLoopbacks[i].Name.ValueString() != data.PassiveInterfaceDisableLoopbacks[j].Name.ValueString() {
+ if state.PassiveInterfaceDisableGigabitEthernets[i].Name.ValueString() != data.PassiveInterfaceDisableGigabitEthernets[j].Name.ValueString() {
found = false
}
if found {
@@ -1936,14 +4263,19 @@ func (data *OSPFVRF) getDeletedItems(ctx context.Context, state OSPFVRF) []strin
}
}
if !found {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/passive-interface-config/disable-interface/Loopback=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/%v", predicates))
}
}
- for i := range state.PassiveInterfaceDisableFourHundredGigabitEthernets {
- stateKeyValues := [...]string{state.PassiveInterfaceDisableFourHundredGigabitEthernets[i].Name.ValueString()}
+ for i := range state.PassiveInterfaceDisableTwoGigabitEthernets {
+ stateKeys := [...]string{""}
+ stateKeyValues := [...]string{state.PassiveInterfaceDisableTwoGigabitEthernets[i].Name.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
emptyKeys := true
- if !reflect.ValueOf(state.PassiveInterfaceDisableFourHundredGigabitEthernets[i].Name.ValueString()).IsZero() {
+ if !reflect.ValueOf(state.PassiveInterfaceDisableTwoGigabitEthernets[i].Name.ValueString()).IsZero() {
emptyKeys = false
}
if emptyKeys {
@@ -1951,9 +4283,9 @@ func (data *OSPFVRF) getDeletedItems(ctx context.Context, state OSPFVRF) []strin
}
found := false
- for j := range data.PassiveInterfaceDisableFourHundredGigabitEthernets {
+ for j := range data.PassiveInterfaceDisableTwoGigabitEthernets {
found = true
- if state.PassiveInterfaceDisableFourHundredGigabitEthernets[i].Name.ValueString() != data.PassiveInterfaceDisableFourHundredGigabitEthernets[j].Name.ValueString() {
+ if state.PassiveInterfaceDisableTwoGigabitEthernets[i].Name.ValueString() != data.PassiveInterfaceDisableTwoGigabitEthernets[j].Name.ValueString() {
found = false
}
if found {
@@ -1961,14 +4293,19 @@ func (data *OSPFVRF) getDeletedItems(ctx context.Context, state OSPFVRF) []strin
}
}
if !found {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/passive-interface-config/disable-interface/FourHundredGigabitE=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/%v", predicates))
}
}
- for i := range state.PassiveInterfaceDisableTwoHundredGigabitEthernets {
- stateKeyValues := [...]string{state.PassiveInterfaceDisableTwoHundredGigabitEthernets[i].Name.ValueString()}
+ for i := range state.PassiveInterfaceDisableFiveGigabitEthernets {
+ stateKeys := [...]string{""}
+ stateKeyValues := [...]string{state.PassiveInterfaceDisableFiveGigabitEthernets[i].Name.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
emptyKeys := true
- if !reflect.ValueOf(state.PassiveInterfaceDisableTwoHundredGigabitEthernets[i].Name.ValueString()).IsZero() {
+ if !reflect.ValueOf(state.PassiveInterfaceDisableFiveGigabitEthernets[i].Name.ValueString()).IsZero() {
emptyKeys = false
}
if emptyKeys {
@@ -1976,9 +4313,9 @@ func (data *OSPFVRF) getDeletedItems(ctx context.Context, state OSPFVRF) []strin
}
found := false
- for j := range data.PassiveInterfaceDisableTwoHundredGigabitEthernets {
+ for j := range data.PassiveInterfaceDisableFiveGigabitEthernets {
found = true
- if state.PassiveInterfaceDisableTwoHundredGigabitEthernets[i].Name.ValueString() != data.PassiveInterfaceDisableTwoHundredGigabitEthernets[j].Name.ValueString() {
+ if state.PassiveInterfaceDisableFiveGigabitEthernets[i].Name.ValueString() != data.PassiveInterfaceDisableFiveGigabitEthernets[j].Name.ValueString() {
found = false
}
if found {
@@ -1986,14 +4323,19 @@ func (data *OSPFVRF) getDeletedItems(ctx context.Context, state OSPFVRF) []strin
}
}
if !found {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/passive-interface-config/disable-interface/TwoHundredGigabitE=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/%v", predicates))
}
}
- for i := range state.PassiveInterfaceDisableHundredGigabitEthernets {
- stateKeyValues := [...]string{state.PassiveInterfaceDisableHundredGigabitEthernets[i].Name.ValueString()}
+ for i := range state.PassiveInterfaceDisableTenGigabitEthernets {
+ stateKeys := [...]string{""}
+ stateKeyValues := [...]string{state.PassiveInterfaceDisableTenGigabitEthernets[i].Name.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
emptyKeys := true
- if !reflect.ValueOf(state.PassiveInterfaceDisableHundredGigabitEthernets[i].Name.ValueString()).IsZero() {
+ if !reflect.ValueOf(state.PassiveInterfaceDisableTenGigabitEthernets[i].Name.ValueString()).IsZero() {
emptyKeys = false
}
if emptyKeys {
@@ -2001,9 +4343,9 @@ func (data *OSPFVRF) getDeletedItems(ctx context.Context, state OSPFVRF) []strin
}
found := false
- for j := range data.PassiveInterfaceDisableHundredGigabitEthernets {
+ for j := range data.PassiveInterfaceDisableTenGigabitEthernets {
found = true
- if state.PassiveInterfaceDisableHundredGigabitEthernets[i].Name.ValueString() != data.PassiveInterfaceDisableHundredGigabitEthernets[j].Name.ValueString() {
+ if state.PassiveInterfaceDisableTenGigabitEthernets[i].Name.ValueString() != data.PassiveInterfaceDisableTenGigabitEthernets[j].Name.ValueString() {
found = false
}
if found {
@@ -2011,14 +4353,19 @@ func (data *OSPFVRF) getDeletedItems(ctx context.Context, state OSPFVRF) []strin
}
}
if !found {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/passive-interface-config/disable-interface/HundredGigabitE=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/%v", predicates))
}
}
- for i := range state.PassiveInterfaceDisableFortyGigabitEthernets {
- stateKeyValues := [...]string{state.PassiveInterfaceDisableFortyGigabitEthernets[i].Name.ValueString()}
+ for i := range state.PassiveInterfaceDisableTwentyFiveGigabitEthernets {
+ stateKeys := [...]string{""}
+ stateKeyValues := [...]string{state.PassiveInterfaceDisableTwentyFiveGigabitEthernets[i].Name.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
emptyKeys := true
- if !reflect.ValueOf(state.PassiveInterfaceDisableFortyGigabitEthernets[i].Name.ValueString()).IsZero() {
+ if !reflect.ValueOf(state.PassiveInterfaceDisableTwentyFiveGigabitEthernets[i].Name.ValueString()).IsZero() {
emptyKeys = false
}
if emptyKeys {
@@ -2026,9 +4373,9 @@ func (data *OSPFVRF) getDeletedItems(ctx context.Context, state OSPFVRF) []strin
}
found := false
- for j := range data.PassiveInterfaceDisableFortyGigabitEthernets {
+ for j := range data.PassiveInterfaceDisableTwentyFiveGigabitEthernets {
found = true
- if state.PassiveInterfaceDisableFortyGigabitEthernets[i].Name.ValueString() != data.PassiveInterfaceDisableFortyGigabitEthernets[j].Name.ValueString() {
+ if state.PassiveInterfaceDisableTwentyFiveGigabitEthernets[i].Name.ValueString() != data.PassiveInterfaceDisableTwentyFiveGigabitEthernets[j].Name.ValueString() {
found = false
}
if found {
@@ -2036,14 +4383,19 @@ func (data *OSPFVRF) getDeletedItems(ctx context.Context, state OSPFVRF) []strin
}
}
if !found {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/passive-interface-config/disable-interface/FortyGigabitEthernet=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/%v", predicates))
}
}
- for i := range state.PassiveInterfaceDisableTwentyFiveGigabitEthernets {
- stateKeyValues := [...]string{state.PassiveInterfaceDisableTwentyFiveGigabitEthernets[i].Name.ValueString()}
+ for i := range state.PassiveInterfaceDisableFortyGigabitEthernets {
+ stateKeys := [...]string{""}
+ stateKeyValues := [...]string{state.PassiveInterfaceDisableFortyGigabitEthernets[i].Name.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
emptyKeys := true
- if !reflect.ValueOf(state.PassiveInterfaceDisableTwentyFiveGigabitEthernets[i].Name.ValueString()).IsZero() {
+ if !reflect.ValueOf(state.PassiveInterfaceDisableFortyGigabitEthernets[i].Name.ValueString()).IsZero() {
emptyKeys = false
}
if emptyKeys {
@@ -2051,9 +4403,9 @@ func (data *OSPFVRF) getDeletedItems(ctx context.Context, state OSPFVRF) []strin
}
found := false
- for j := range data.PassiveInterfaceDisableTwentyFiveGigabitEthernets {
+ for j := range data.PassiveInterfaceDisableFortyGigabitEthernets {
found = true
- if state.PassiveInterfaceDisableTwentyFiveGigabitEthernets[i].Name.ValueString() != data.PassiveInterfaceDisableTwentyFiveGigabitEthernets[j].Name.ValueString() {
+ if state.PassiveInterfaceDisableFortyGigabitEthernets[i].Name.ValueString() != data.PassiveInterfaceDisableFortyGigabitEthernets[j].Name.ValueString() {
found = false
}
if found {
@@ -2061,14 +4413,19 @@ func (data *OSPFVRF) getDeletedItems(ctx context.Context, state OSPFVRF) []strin
}
}
if !found {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/passive-interface-config/disable-interface/TwentyFiveGigabitE=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/%v", predicates))
}
}
- for i := range state.PassiveInterfaceDisableTenGigabitEthernets {
- stateKeyValues := [...]string{state.PassiveInterfaceDisableTenGigabitEthernets[i].Name.ValueString()}
+ for i := range state.PassiveInterfaceDisableHundredGigabitEthernets {
+ stateKeys := [...]string{""}
+ stateKeyValues := [...]string{state.PassiveInterfaceDisableHundredGigabitEthernets[i].Name.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
emptyKeys := true
- if !reflect.ValueOf(state.PassiveInterfaceDisableTenGigabitEthernets[i].Name.ValueString()).IsZero() {
+ if !reflect.ValueOf(state.PassiveInterfaceDisableHundredGigabitEthernets[i].Name.ValueString()).IsZero() {
emptyKeys = false
}
if emptyKeys {
@@ -2076,9 +4433,9 @@ func (data *OSPFVRF) getDeletedItems(ctx context.Context, state OSPFVRF) []strin
}
found := false
- for j := range data.PassiveInterfaceDisableTenGigabitEthernets {
+ for j := range data.PassiveInterfaceDisableHundredGigabitEthernets {
found = true
- if state.PassiveInterfaceDisableTenGigabitEthernets[i].Name.ValueString() != data.PassiveInterfaceDisableTenGigabitEthernets[j].Name.ValueString() {
+ if state.PassiveInterfaceDisableHundredGigabitEthernets[i].Name.ValueString() != data.PassiveInterfaceDisableHundredGigabitEthernets[j].Name.ValueString() {
found = false
}
if found {
@@ -2086,14 +4443,19 @@ func (data *OSPFVRF) getDeletedItems(ctx context.Context, state OSPFVRF) []strin
}
}
if !found {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/passive-interface-config/disable-interface/TenGigabitEthernet=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/%v", predicates))
}
}
- for i := range state.PassiveInterfaceDisableFiveGigabitEthernets {
- stateKeyValues := [...]string{state.PassiveInterfaceDisableFiveGigabitEthernets[i].Name.ValueString()}
+ for i := range state.PassiveInterfaceDisableTwoHundredGigabitEthernets {
+ stateKeys := [...]string{""}
+ stateKeyValues := [...]string{state.PassiveInterfaceDisableTwoHundredGigabitEthernets[i].Name.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
emptyKeys := true
- if !reflect.ValueOf(state.PassiveInterfaceDisableFiveGigabitEthernets[i].Name.ValueString()).IsZero() {
+ if !reflect.ValueOf(state.PassiveInterfaceDisableTwoHundredGigabitEthernets[i].Name.ValueString()).IsZero() {
emptyKeys = false
}
if emptyKeys {
@@ -2101,9 +4463,9 @@ func (data *OSPFVRF) getDeletedItems(ctx context.Context, state OSPFVRF) []strin
}
found := false
- for j := range data.PassiveInterfaceDisableFiveGigabitEthernets {
+ for j := range data.PassiveInterfaceDisableTwoHundredGigabitEthernets {
found = true
- if state.PassiveInterfaceDisableFiveGigabitEthernets[i].Name.ValueString() != data.PassiveInterfaceDisableFiveGigabitEthernets[j].Name.ValueString() {
+ if state.PassiveInterfaceDisableTwoHundredGigabitEthernets[i].Name.ValueString() != data.PassiveInterfaceDisableTwoHundredGigabitEthernets[j].Name.ValueString() {
found = false
}
if found {
@@ -2111,14 +4473,19 @@ func (data *OSPFVRF) getDeletedItems(ctx context.Context, state OSPFVRF) []strin
}
}
if !found {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/passive-interface-config/disable-interface/FiveGigabitEthernet=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/%v", predicates))
}
}
- for i := range state.PassiveInterfaceDisableTwoGigabitEthernets {
- stateKeyValues := [...]string{state.PassiveInterfaceDisableTwoGigabitEthernets[i].Name.ValueString()}
+ for i := range state.PassiveInterfaceDisableFourHundredGigabitEthernets {
+ stateKeys := [...]string{""}
+ stateKeyValues := [...]string{state.PassiveInterfaceDisableFourHundredGigabitEthernets[i].Name.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
emptyKeys := true
- if !reflect.ValueOf(state.PassiveInterfaceDisableTwoGigabitEthernets[i].Name.ValueString()).IsZero() {
+ if !reflect.ValueOf(state.PassiveInterfaceDisableFourHundredGigabitEthernets[i].Name.ValueString()).IsZero() {
emptyKeys = false
}
if emptyKeys {
@@ -2126,9 +4493,9 @@ func (data *OSPFVRF) getDeletedItems(ctx context.Context, state OSPFVRF) []strin
}
found := false
- for j := range data.PassiveInterfaceDisableTwoGigabitEthernets {
+ for j := range data.PassiveInterfaceDisableFourHundredGigabitEthernets {
found = true
- if state.PassiveInterfaceDisableTwoGigabitEthernets[i].Name.ValueString() != data.PassiveInterfaceDisableTwoGigabitEthernets[j].Name.ValueString() {
+ if state.PassiveInterfaceDisableFourHundredGigabitEthernets[i].Name.ValueString() != data.PassiveInterfaceDisableFourHundredGigabitEthernets[j].Name.ValueString() {
found = false
}
if found {
@@ -2136,14 +4503,19 @@ func (data *OSPFVRF) getDeletedItems(ctx context.Context, state OSPFVRF) []strin
}
}
if !found {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/passive-interface-config/disable-interface/TwoGigabitEthernet=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/%v", predicates))
}
}
- for i := range state.PassiveInterfaceDisableGigabitEthernets {
- stateKeyValues := [...]string{state.PassiveInterfaceDisableGigabitEthernets[i].Name.ValueString()}
+ for i := range state.PassiveInterfaceDisableLoopbacks {
+ stateKeys := [...]string{""}
+ stateKeyValues := [...]string{state.PassiveInterfaceDisableLoopbacks[i].Name.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
emptyKeys := true
- if !reflect.ValueOf(state.PassiveInterfaceDisableGigabitEthernets[i].Name.ValueString()).IsZero() {
+ if !reflect.ValueOf(state.PassiveInterfaceDisableLoopbacks[i].Name.ValueString()).IsZero() {
emptyKeys = false
}
if emptyKeys {
@@ -2151,51 +4523,29 @@ func (data *OSPFVRF) getDeletedItems(ctx context.Context, state OSPFVRF) []strin
}
found := false
- for j := range data.PassiveInterfaceDisableGigabitEthernets {
+ for j := range data.PassiveInterfaceDisableLoopbacks {
found = true
- if state.PassiveInterfaceDisableGigabitEthernets[i].Name.ValueString() != data.PassiveInterfaceDisableGigabitEthernets[j].Name.ValueString() {
+ if state.PassiveInterfaceDisableLoopbacks[i].Name.ValueString() != data.PassiveInterfaceDisableLoopbacks[j].Name.ValueString() {
found = false
}
- if found {
- break
- }
- }
- if !found {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/passive-interface-config/disable-interface/GigabitEthernet=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
- }
- }
- if !state.PassiveInterface.IsNull() {
- if data.PassiveInterface.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/passive-interface/interface", state.getPath()))
- } else {
- var dataValues, stateValues []string
- data.PassiveInterface.ElementsAs(ctx, &dataValues, false)
- state.PassiveInterface.ElementsAs(ctx, &stateValues, false)
- for _, v := range stateValues {
- found := false
- for _, vv := range dataValues {
- if v == vv {
- found = true
- break
- }
- }
- if !found {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/passive-interface/interface=%v", state.getPath(), v))
- }
+ if found {
+ break
}
}
+ if !found {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/%v", predicates))
+ }
}
- if !state.PassiveInterfaceDefault.IsNull() && data.PassiveInterfaceDefault.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/passive-interface/default", state.getPath()))
- }
- if !state.AutoCostReferenceBandwidth.IsNull() && data.AutoCostReferenceBandwidth.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/auto-cost/reference-bandwidth", state.getPath()))
- }
- for i := range state.Areas {
- stateKeyValues := [...]string{state.Areas[i].AreaId.ValueString()}
+ for i := range state.PassiveInterfaceDisableVlans {
+ stateKeys := [...]string{""}
+ stateKeyValues := [...]string{state.PassiveInterfaceDisableVlans[i].Name.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
emptyKeys := true
- if !reflect.ValueOf(state.Areas[i].AreaId.ValueString()).IsZero() {
+ if !reflect.ValueOf(state.PassiveInterfaceDisableVlans[i].Name.ValueString()).IsZero() {
emptyKeys = false
}
if emptyKeys {
@@ -2203,45 +4553,29 @@ func (data *OSPFVRF) getDeletedItems(ctx context.Context, state OSPFVRF) []strin
}
found := false
- for j := range data.Areas {
+ for j := range data.PassiveInterfaceDisableVlans {
found = true
- if state.Areas[i].AreaId.ValueString() != data.Areas[j].AreaId.ValueString() {
+ if state.PassiveInterfaceDisableVlans[i].Name.ValueString() != data.PassiveInterfaceDisableVlans[j].Name.ValueString() {
found = false
}
if found {
- if !state.Areas[i].NssaNoRedistribution.IsNull() && data.Areas[j].NssaNoRedistribution.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/area=%v/nssa/nssa-options/no-redistribution", state.getPath(), strings.Join(stateKeyValues[:], ",")))
- }
- if !state.Areas[i].NssaNoSummary.IsNull() && data.Areas[j].NssaNoSummary.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/area=%v/nssa/nssa-options/no-summary", state.getPath(), strings.Join(stateKeyValues[:], ",")))
- }
- if !state.Areas[i].NssaDefaultInformationOriginateMetricType.IsNull() && data.Areas[j].NssaDefaultInformationOriginateMetricType.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/area=%v/nssa/nssa-options/default-information-originate/metric-type", state.getPath(), strings.Join(stateKeyValues[:], ",")))
- }
- if !state.Areas[i].NssaDefaultInformationOriginateMetric.IsNull() && data.Areas[j].NssaDefaultInformationOriginateMetric.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/area=%v/nssa/nssa-options/default-information-originate/metric", state.getPath(), strings.Join(stateKeyValues[:], ",")))
- }
- if !state.Areas[i].NssaDefaultInformationOriginate.IsNull() && data.Areas[j].NssaDefaultInformationOriginate.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/area=%v/nssa/nssa-options/default-information-originate", state.getPath(), strings.Join(stateKeyValues[:], ",")))
- }
- if !state.Areas[i].Nssa.IsNull() && data.Areas[j].Nssa.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/area=%v/nssa", state.getPath(), strings.Join(stateKeyValues[:], ",")))
- }
- if !state.Areas[i].AuthenticationMessageDigest.IsNull() && data.Areas[j].AuthenticationMessageDigest.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/area=%v/authentication/message-digest", state.getPath(), strings.Join(stateKeyValues[:], ",")))
- }
break
}
}
if !found {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/area=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/%v", predicates))
}
}
- for i := range state.SummaryAddress {
- stateKeyValues := [...]string{state.SummaryAddress[i].Ip.ValueString()}
+ for i := range state.PassiveInterfaceDisableTunnels {
+ stateKeys := [...]string{""}
+ stateKeyValues := [...]string{state.PassiveInterfaceDisableTunnels[i].Name.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
emptyKeys := true
- if !reflect.ValueOf(state.SummaryAddress[i].Ip.ValueString()).IsZero() {
+ if !reflect.ValueOf(state.PassiveInterfaceDisableTunnels[i].Name.ValueString()).IsZero() {
emptyKeys = false
}
if emptyKeys {
@@ -2249,36 +4583,29 @@ func (data *OSPFVRF) getDeletedItems(ctx context.Context, state OSPFVRF) []strin
}
found := false
- for j := range data.SummaryAddress {
+ for j := range data.PassiveInterfaceDisableTunnels {
found = true
- if state.SummaryAddress[i].Ip.ValueString() != data.SummaryAddress[j].Ip.ValueString() {
+ if state.PassiveInterfaceDisableTunnels[i].Name.ValueString() != data.PassiveInterfaceDisableTunnels[j].Name.ValueString() {
found = false
}
if found {
- if !state.SummaryAddress[i].Mask.IsNull() && data.SummaryAddress[j].Mask.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/summary-address=%v/mask", state.getPath(), strings.Join(stateKeyValues[:], ",")))
- }
break
}
}
if !found {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/summary-address=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/%v", predicates))
}
}
- if !state.Shutdown.IsNull() && data.Shutdown.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/shutdown", state.getPath()))
- }
- if !state.RouterId.IsNull() && data.RouterId.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/router-id", state.getPath()))
- }
- if !state.Priority.IsNull() && data.Priority.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/priority", state.getPath()))
- }
- for i := range state.Network {
- stateKeyValues := [...]string{state.Network[i].Ip.ValueString()}
+ for i := range state.PassiveInterfaceDisablePortChannels {
+ stateKeys := [...]string{""}
+ stateKeyValues := [...]string{state.PassiveInterfaceDisablePortChannels[i].Name.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
emptyKeys := true
- if !reflect.ValueOf(state.Network[i].Ip.ValueString()).IsZero() {
+ if !reflect.ValueOf(state.PassiveInterfaceDisablePortChannels[i].Name.ValueString()).IsZero() {
emptyKeys = false
}
if emptyKeys {
@@ -2286,30 +4613,29 @@ func (data *OSPFVRF) getDeletedItems(ctx context.Context, state OSPFVRF) []strin
}
found := false
- for j := range data.Network {
+ for j := range data.PassiveInterfaceDisablePortChannels {
found = true
- if state.Network[i].Ip.ValueString() != data.Network[j].Ip.ValueString() {
+ if state.PassiveInterfaceDisablePortChannels[i].Name.ValueString() != data.PassiveInterfaceDisablePortChannels[j].Name.ValueString() {
found = false
}
if found {
- if !state.Network[i].Area.IsNull() && data.Network[j].Area.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/network=%v/area", state.getPath(), strings.Join(stateKeyValues[:], ",")))
- }
- if !state.Network[i].Wildcard.IsNull() && data.Network[j].Wildcard.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/network=%v/wildcard", state.getPath(), strings.Join(stateKeyValues[:], ",")))
- }
break
}
}
if !found {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/network=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/%v", predicates))
}
}
- for i := range state.Neighbor {
- stateKeyValues := [...]string{state.Neighbor[i].Ip.ValueString()}
+ for i := range state.PassiveInterfaceDisablePortChannelSubinterfaces {
+ stateKeys := [...]string{""}
+ stateKeyValues := [...]string{state.PassiveInterfaceDisablePortChannelSubinterfaces[i].Name.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
emptyKeys := true
- if !reflect.ValueOf(state.Neighbor[i].Ip.ValueString()).IsZero() {
+ if !reflect.ValueOf(state.PassiveInterfaceDisablePortChannelSubinterfaces[i].Name.ValueString()).IsZero() {
emptyKeys = false
}
if emptyKeys {
@@ -2317,54 +4643,24 @@ func (data *OSPFVRF) getDeletedItems(ctx context.Context, state OSPFVRF) []strin
}
found := false
- for j := range data.Neighbor {
+ for j := range data.PassiveInterfaceDisablePortChannelSubinterfaces {
found = true
- if state.Neighbor[i].Ip.ValueString() != data.Neighbor[j].Ip.ValueString() {
+ if state.PassiveInterfaceDisablePortChannelSubinterfaces[i].Name.ValueString() != data.PassiveInterfaceDisablePortChannelSubinterfaces[j].Name.ValueString() {
found = false
}
if found {
- if !state.Neighbor[i].Cost.IsNull() && data.Neighbor[j].Cost.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/neighbor=%v/cost", state.getPath(), strings.Join(stateKeyValues[:], ",")))
- }
- if !state.Neighbor[i].Priority.IsNull() && data.Neighbor[j].Priority.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/neighbor=%v/priority", state.getPath(), strings.Join(stateKeyValues[:], ",")))
- }
break
}
}
if !found {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/neighbor=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/%v", predicates))
}
}
- if !state.MplsLdpSync.IsNull() && data.MplsLdpSync.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/mpls/ldp/sync", state.getPath()))
- }
- if !state.MplsLdpAutoconfig.IsNull() && data.MplsLdpAutoconfig.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/mpls/ldp/autoconfig", state.getPath()))
- }
- if !state.DomainTag.IsNull() && data.DomainTag.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/domain-tag", state.getPath()))
- }
- if !state.Distance.IsNull() && data.Distance.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/distance/distance", state.getPath()))
- }
- if !state.DefaultMetric.IsNull() && data.DefaultMetric.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/default-metric", state.getPath()))
- }
- if !state.DefaultInformationOriginateAlways.IsNull() && data.DefaultInformationOriginateAlways.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/default-information/originate/always", state.getPath()))
- }
- if !state.DefaultInformationOriginate.IsNull() && data.DefaultInformationOriginate.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/default-information/originate", state.getPath()))
- }
- if !state.BfdAllInterfaces.IsNull() && data.BfdAllInterfaces.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/bfd/all-interfaces", state.getPath()))
- }
- return deletedItems
+ return b.Res()
}
-// End of section. //template:end getDeletedItems
+// End of section. //template:end addDeletedItemsXML
// Section below is generated&owned by "gen/generator.go". //template:begin getEmptyLeafsDelete
@@ -2418,72 +4714,72 @@ func (data *OSPFVRF) getDeletePaths(ctx context.Context) []string {
for i := range data.PassiveInterfaceDisablePortChannelSubinterfaces {
keyValues := [...]string{data.PassiveInterfaceDisablePortChannelSubinterfaces[i].Name.ValueString()}
- deletePaths = append(deletePaths, fmt.Sprintf("%v/passive-interface-config/disable-interface/Port-channel-subinterface/Port-channel=%v", data.getPath(), strings.Join(keyValues[:], ",")))
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/=%v", data.getPath(), strings.Join(keyValues[:], ",")))
}
for i := range data.PassiveInterfaceDisablePortChannels {
keyValues := [...]string{data.PassiveInterfaceDisablePortChannels[i].Name.ValueString()}
- deletePaths = append(deletePaths, fmt.Sprintf("%v/passive-interface-config/disable-interface/Port-channel=%v", data.getPath(), strings.Join(keyValues[:], ",")))
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/=%v", data.getPath(), strings.Join(keyValues[:], ",")))
}
for i := range data.PassiveInterfaceDisableTunnels {
keyValues := [...]string{data.PassiveInterfaceDisableTunnels[i].Name.ValueString()}
- deletePaths = append(deletePaths, fmt.Sprintf("%v/passive-interface-config/disable-interface/Tunnel=%v", data.getPath(), strings.Join(keyValues[:], ",")))
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/=%v", data.getPath(), strings.Join(keyValues[:], ",")))
}
for i := range data.PassiveInterfaceDisableVlans {
keyValues := [...]string{data.PassiveInterfaceDisableVlans[i].Name.ValueString()}
- deletePaths = append(deletePaths, fmt.Sprintf("%v/passive-interface-config/disable-interface/Vlan=%v", data.getPath(), strings.Join(keyValues[:], ",")))
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/=%v", data.getPath(), strings.Join(keyValues[:], ",")))
}
for i := range data.PassiveInterfaceDisableLoopbacks {
keyValues := [...]string{data.PassiveInterfaceDisableLoopbacks[i].Name.ValueString()}
- deletePaths = append(deletePaths, fmt.Sprintf("%v/passive-interface-config/disable-interface/Loopback=%v", data.getPath(), strings.Join(keyValues[:], ",")))
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/=%v", data.getPath(), strings.Join(keyValues[:], ",")))
}
for i := range data.PassiveInterfaceDisableFourHundredGigabitEthernets {
keyValues := [...]string{data.PassiveInterfaceDisableFourHundredGigabitEthernets[i].Name.ValueString()}
- deletePaths = append(deletePaths, fmt.Sprintf("%v/passive-interface-config/disable-interface/FourHundredGigabitE=%v", data.getPath(), strings.Join(keyValues[:], ",")))
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/=%v", data.getPath(), strings.Join(keyValues[:], ",")))
}
for i := range data.PassiveInterfaceDisableTwoHundredGigabitEthernets {
keyValues := [...]string{data.PassiveInterfaceDisableTwoHundredGigabitEthernets[i].Name.ValueString()}
- deletePaths = append(deletePaths, fmt.Sprintf("%v/passive-interface-config/disable-interface/TwoHundredGigabitE=%v", data.getPath(), strings.Join(keyValues[:], ",")))
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/=%v", data.getPath(), strings.Join(keyValues[:], ",")))
}
for i := range data.PassiveInterfaceDisableHundredGigabitEthernets {
keyValues := [...]string{data.PassiveInterfaceDisableHundredGigabitEthernets[i].Name.ValueString()}
- deletePaths = append(deletePaths, fmt.Sprintf("%v/passive-interface-config/disable-interface/HundredGigabitE=%v", data.getPath(), strings.Join(keyValues[:], ",")))
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/=%v", data.getPath(), strings.Join(keyValues[:], ",")))
}
for i := range data.PassiveInterfaceDisableFortyGigabitEthernets {
keyValues := [...]string{data.PassiveInterfaceDisableFortyGigabitEthernets[i].Name.ValueString()}
- deletePaths = append(deletePaths, fmt.Sprintf("%v/passive-interface-config/disable-interface/FortyGigabitEthernet=%v", data.getPath(), strings.Join(keyValues[:], ",")))
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/=%v", data.getPath(), strings.Join(keyValues[:], ",")))
}
for i := range data.PassiveInterfaceDisableTwentyFiveGigabitEthernets {
keyValues := [...]string{data.PassiveInterfaceDisableTwentyFiveGigabitEthernets[i].Name.ValueString()}
- deletePaths = append(deletePaths, fmt.Sprintf("%v/passive-interface-config/disable-interface/TwentyFiveGigabitE=%v", data.getPath(), strings.Join(keyValues[:], ",")))
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/=%v", data.getPath(), strings.Join(keyValues[:], ",")))
}
for i := range data.PassiveInterfaceDisableTenGigabitEthernets {
keyValues := [...]string{data.PassiveInterfaceDisableTenGigabitEthernets[i].Name.ValueString()}
- deletePaths = append(deletePaths, fmt.Sprintf("%v/passive-interface-config/disable-interface/TenGigabitEthernet=%v", data.getPath(), strings.Join(keyValues[:], ",")))
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/=%v", data.getPath(), strings.Join(keyValues[:], ",")))
}
for i := range data.PassiveInterfaceDisableFiveGigabitEthernets {
keyValues := [...]string{data.PassiveInterfaceDisableFiveGigabitEthernets[i].Name.ValueString()}
- deletePaths = append(deletePaths, fmt.Sprintf("%v/passive-interface-config/disable-interface/FiveGigabitEthernet=%v", data.getPath(), strings.Join(keyValues[:], ",")))
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/=%v", data.getPath(), strings.Join(keyValues[:], ",")))
}
for i := range data.PassiveInterfaceDisableTwoGigabitEthernets {
keyValues := [...]string{data.PassiveInterfaceDisableTwoGigabitEthernets[i].Name.ValueString()}
- deletePaths = append(deletePaths, fmt.Sprintf("%v/passive-interface-config/disable-interface/TwoGigabitEthernet=%v", data.getPath(), strings.Join(keyValues[:], ",")))
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/=%v", data.getPath(), strings.Join(keyValues[:], ",")))
}
for i := range data.PassiveInterfaceDisableGigabitEthernets {
keyValues := [...]string{data.PassiveInterfaceDisableGigabitEthernets[i].Name.ValueString()}
- deletePaths = append(deletePaths, fmt.Sprintf("%v/passive-interface-config/disable-interface/GigabitEthernet=%v", data.getPath(), strings.Join(keyValues[:], ",")))
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/=%v", data.getPath(), strings.Join(keyValues[:], ",")))
}
if !data.PassiveInterface.IsNull() {
deletePaths = append(deletePaths, fmt.Sprintf("%v/passive-interface/interface", data.getPath()))
@@ -2552,3 +4848,235 @@ func (data *OSPFVRF) getDeletePaths(ctx context.Context) []string {
}
// End of section. //template:end getDeletePaths
+
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletePathsXML
+
+func (data *OSPFVRF) addDeletePathsXML(ctx context.Context, body string) string {
+ b := netconf.NewBody(body)
+ if !data.BfdAllInterfaces.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/bfd/all-interfaces")
+ }
+ if !data.DefaultInformationOriginate.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/default-information/originate")
+ }
+ if !data.DefaultInformationOriginateAlways.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/default-information/originate/always")
+ }
+ if !data.DefaultMetric.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/default-metric")
+ }
+ if !data.Distance.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/distance/distance")
+ }
+ if !data.DomainTag.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/domain-tag")
+ }
+ if !data.MplsLdpAutoconfig.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/mpls/ldp/autoconfig")
+ }
+ if !data.MplsLdpSync.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/mpls/ldp/sync")
+ }
+ for i := range data.Neighbor {
+ keys := [...]string{"ip"}
+ keyValues := [...]string{data.Neighbor[i].Ip.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/neighbor%v", predicates))
+ }
+ for i := range data.Network {
+ keys := [...]string{"ip"}
+ keyValues := [...]string{data.Network[i].Ip.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/network%v", predicates))
+ }
+ if !data.Priority.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/priority")
+ }
+ if !data.RouterId.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/router-id")
+ }
+ if !data.Shutdown.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/shutdown")
+ }
+ for i := range data.SummaryAddress {
+ keys := [...]string{"ip"}
+ keyValues := [...]string{data.SummaryAddress[i].Ip.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/summary-address%v", predicates))
+ }
+ for i := range data.Areas {
+ keys := [...]string{"area-id"}
+ keyValues := [...]string{data.Areas[i].AreaId.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/area%v", predicates))
+ }
+ if !data.AutoCostReferenceBandwidth.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/auto-cost/reference-bandwidth")
+ }
+ if !data.PassiveInterfaceDefault.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/passive-interface/default")
+ }
+ if !data.PassiveInterface.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/passive-interface/interface")
+ }
+ for i := range data.PassiveInterfaceDisableGigabitEthernets {
+ keys := [...]string{""}
+ keyValues := [...]string{data.PassiveInterfaceDisableGigabitEthernets[i].Name.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/%v", predicates))
+ }
+ for i := range data.PassiveInterfaceDisableTwoGigabitEthernets {
+ keys := [...]string{""}
+ keyValues := [...]string{data.PassiveInterfaceDisableTwoGigabitEthernets[i].Name.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/%v", predicates))
+ }
+ for i := range data.PassiveInterfaceDisableFiveGigabitEthernets {
+ keys := [...]string{""}
+ keyValues := [...]string{data.PassiveInterfaceDisableFiveGigabitEthernets[i].Name.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/%v", predicates))
+ }
+ for i := range data.PassiveInterfaceDisableTenGigabitEthernets {
+ keys := [...]string{""}
+ keyValues := [...]string{data.PassiveInterfaceDisableTenGigabitEthernets[i].Name.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/%v", predicates))
+ }
+ for i := range data.PassiveInterfaceDisableTwentyFiveGigabitEthernets {
+ keys := [...]string{""}
+ keyValues := [...]string{data.PassiveInterfaceDisableTwentyFiveGigabitEthernets[i].Name.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/%v", predicates))
+ }
+ for i := range data.PassiveInterfaceDisableFortyGigabitEthernets {
+ keys := [...]string{""}
+ keyValues := [...]string{data.PassiveInterfaceDisableFortyGigabitEthernets[i].Name.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/%v", predicates))
+ }
+ for i := range data.PassiveInterfaceDisableHundredGigabitEthernets {
+ keys := [...]string{""}
+ keyValues := [...]string{data.PassiveInterfaceDisableHundredGigabitEthernets[i].Name.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/%v", predicates))
+ }
+ for i := range data.PassiveInterfaceDisableTwoHundredGigabitEthernets {
+ keys := [...]string{""}
+ keyValues := [...]string{data.PassiveInterfaceDisableTwoHundredGigabitEthernets[i].Name.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/%v", predicates))
+ }
+ for i := range data.PassiveInterfaceDisableFourHundredGigabitEthernets {
+ keys := [...]string{""}
+ keyValues := [...]string{data.PassiveInterfaceDisableFourHundredGigabitEthernets[i].Name.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/%v", predicates))
+ }
+ for i := range data.PassiveInterfaceDisableLoopbacks {
+ keys := [...]string{""}
+ keyValues := [...]string{data.PassiveInterfaceDisableLoopbacks[i].Name.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/%v", predicates))
+ }
+ for i := range data.PassiveInterfaceDisableVlans {
+ keys := [...]string{""}
+ keyValues := [...]string{data.PassiveInterfaceDisableVlans[i].Name.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/%v", predicates))
+ }
+ for i := range data.PassiveInterfaceDisableTunnels {
+ keys := [...]string{""}
+ keyValues := [...]string{data.PassiveInterfaceDisableTunnels[i].Name.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/%v", predicates))
+ }
+ for i := range data.PassiveInterfaceDisablePortChannels {
+ keys := [...]string{""}
+ keyValues := [...]string{data.PassiveInterfaceDisablePortChannels[i].Name.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/%v", predicates))
+ }
+ for i := range data.PassiveInterfaceDisablePortChannelSubinterfaces {
+ keys := [...]string{""}
+ keyValues := [...]string{data.PassiveInterfaceDisablePortChannelSubinterfaces[i].Name.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/%v", predicates))
+ }
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletePathsXML
diff --git a/internal/provider/model_iosxe_pim.go b/internal/provider/model_iosxe_pim.go
index 9eb26319..968d4439 100644
--- a/internal/provider/model_iosxe_pim.go
+++ b/internal/provider/model_iosxe_pim.go
@@ -30,6 +30,9 @@ import (
"github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/types"
+ "github.com/hashicorp/terraform-plugin-log/tflog"
+ "github.com/netascode/go-netconf"
+ "github.com/netascode/xmldot"
"github.com/tidwall/gjson"
"github.com/tidwall/sjson"
)
@@ -142,6 +145,17 @@ func (data PIM) getPathShort() string {
return matches[1]
}
+// getXPath returns the XPath for NETCONF operations
+func (data PIM) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/ip/pim"
+ return path
+}
+
+func (data PIMData) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/ip/pim"
+ return path
+}
+
// End of section. //template:end getPath
// Section below is generated&owned by "gen/generator.go". //template:begin toBody
@@ -334,6 +348,235 @@ func (data PIM) toBody(ctx context.Context) string {
// End of section. //template:end toBody
+// Section below is generated&owned by "gen/generator.go". //template:begin toBodyXML
+
+func (data PIM) toBodyXML(ctx context.Context) string {
+ body := netconf.Body{}
+ if !data.Autorp.IsNull() && !data.Autorp.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-multicast:autorp-container/autorp", data.Autorp.ValueBool())
+ }
+ if !data.AutorpListener.IsNull() && !data.AutorpListener.IsUnknown() {
+ if data.AutorpListener.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-multicast:autorp-container/listener", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-multicast:autorp-container/listener")
+ }
+ }
+ if !data.BsrCandidateLoopback.IsNull() && !data.BsrCandidateLoopback.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-multicast:bsr-candidate/Loopback", strconv.FormatInt(data.BsrCandidateLoopback.ValueInt64(), 10))
+ }
+ if !data.BsrCandidateMask.IsNull() && !data.BsrCandidateMask.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-multicast:bsr-candidate/mask", strconv.FormatInt(data.BsrCandidateMask.ValueInt64(), 10))
+ }
+ if !data.BsrCandidatePriority.IsNull() && !data.BsrCandidatePriority.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-multicast:bsr-candidate/priority", strconv.FormatInt(data.BsrCandidatePriority.ValueInt64(), 10))
+ }
+ if !data.BsrCandidateAcceptRpCandidate.IsNull() && !data.BsrCandidateAcceptRpCandidate.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-multicast:bsr-candidate/accept-rp-candidate", data.BsrCandidateAcceptRpCandidate.ValueString())
+ }
+ if !data.SsmRange.IsNull() && !data.SsmRange.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-multicast:ssm/range", data.SsmRange.ValueString())
+ }
+ if !data.SsmDefault.IsNull() && !data.SsmDefault.IsUnknown() {
+ if data.SsmDefault.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-multicast:ssm/default", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-multicast:ssm/default")
+ }
+ }
+ if !data.RpAddress.IsNull() && !data.RpAddress.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-multicast:rp-address-conf/address", data.RpAddress.ValueString())
+ }
+ if !data.RpAddressOverride.IsNull() && !data.RpAddressOverride.IsUnknown() {
+ if data.RpAddressOverride.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-multicast:rp-address-conf/override", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-multicast:rp-address-conf/override")
+ }
+ }
+ if !data.RpAddressBidir.IsNull() && !data.RpAddressBidir.IsUnknown() {
+ if data.RpAddressBidir.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-multicast:rp-address-conf/bidir", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-multicast:rp-address-conf/bidir")
+ }
+ }
+ if len(data.RpAddresses) > 0 {
+ for _, item := range data.RpAddresses {
+ cBody := netconf.Body{}
+ if !item.AccessList.IsNull() && !item.AccessList.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "access-list", item.AccessList.ValueString())
+ }
+ if !item.RpAddress.IsNull() && !item.RpAddress.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "rp-address", item.RpAddress.ValueString())
+ }
+ if !item.Override.IsNull() && !item.Override.IsUnknown() {
+ if item.Override.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "override", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "override")
+ }
+ }
+ if !item.Bidir.IsNull() && !item.Bidir.IsUnknown() {
+ if item.Bidir.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "bidir", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "bidir")
+ }
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-multicast:rp-address-list", cBody.Res())
+ }
+ }
+ if len(data.RpCandidates) > 0 {
+ for _, item := range data.RpCandidates {
+ cBody := netconf.Body{}
+ if !item.Interface.IsNull() && !item.Interface.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "interface", item.Interface.ValueString())
+ }
+ if !item.GroupList.IsNull() && !item.GroupList.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "group-list", item.GroupList.ValueString())
+ }
+ if !item.Interval.IsNull() && !item.Interval.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "interval", strconv.FormatInt(item.Interval.ValueInt64(), 10))
+ }
+ if !item.Priority.IsNull() && !item.Priority.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "priority", strconv.FormatInt(item.Priority.ValueInt64(), 10))
+ }
+ if !item.Bidir.IsNull() && !item.Bidir.IsUnknown() {
+ if item.Bidir.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "bidir", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "bidir")
+ }
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-multicast:rp-candidate", cBody.Res())
+ }
+ }
+ if len(data.Vrfs) > 0 {
+ for _, item := range data.Vrfs {
+ cBody := netconf.Body{}
+ if !item.Vrf.IsNull() && !item.Vrf.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "id", item.Vrf.ValueString())
+ }
+ if !item.Autorp.IsNull() && !item.Autorp.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "autorp-container/autorp", item.Autorp.ValueBool())
+ }
+ if !item.AutorpListener.IsNull() && !item.AutorpListener.IsUnknown() {
+ if item.AutorpListener.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "autorp-container/listener", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "autorp-container/listener")
+ }
+ }
+ if !item.BsrCandidateLoopback.IsNull() && !item.BsrCandidateLoopback.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "bsr-candidate/Loopback", strconv.FormatInt(item.BsrCandidateLoopback.ValueInt64(), 10))
+ }
+ if !item.BsrCandidateMask.IsNull() && !item.BsrCandidateMask.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "bsr-candidate/mask", strconv.FormatInt(item.BsrCandidateMask.ValueInt64(), 10))
+ }
+ if !item.BsrCandidatePriority.IsNull() && !item.BsrCandidatePriority.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "bsr-candidate/priority", strconv.FormatInt(item.BsrCandidatePriority.ValueInt64(), 10))
+ }
+ if !item.BsrCandidateAcceptRpCandidate.IsNull() && !item.BsrCandidateAcceptRpCandidate.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "bsr-candidate/accept-rp-candidate", item.BsrCandidateAcceptRpCandidate.ValueString())
+ }
+ if !item.SsmRange.IsNull() && !item.SsmRange.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "ssm/range", item.SsmRange.ValueString())
+ }
+ if !item.SsmDefault.IsNull() && !item.SsmDefault.IsUnknown() {
+ if item.SsmDefault.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "ssm/default", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "ssm/default")
+ }
+ }
+ if !item.RpAddress.IsNull() && !item.RpAddress.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "rp-address-conf/address", item.RpAddress.ValueString())
+ }
+ if !item.RpAddressOverride.IsNull() && !item.RpAddressOverride.IsUnknown() {
+ if item.RpAddressOverride.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "rp-address-conf/override", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "rp-address-conf/override")
+ }
+ }
+ if !item.RpAddressBidir.IsNull() && !item.RpAddressBidir.IsUnknown() {
+ if item.RpAddressBidir.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "rp-address-conf/bidir", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "rp-address-conf/bidir")
+ }
+ }
+ if !item.CacheRpfOif.IsNull() && !item.CacheRpfOif.IsUnknown() {
+ if item.CacheRpfOif.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "cache/rpf-oif", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "cache/rpf-oif")
+ }
+ }
+ if len(item.RpAddresses) > 0 {
+ for _, citem := range item.RpAddresses {
+ ccBody := netconf.Body{}
+ if !citem.AccessList.IsNull() && !citem.AccessList.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "access-list", citem.AccessList.ValueString())
+ }
+ if !citem.RpAddress.IsNull() && !citem.RpAddress.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "rp-address", citem.RpAddress.ValueString())
+ }
+ if !citem.Override.IsNull() && !citem.Override.IsUnknown() {
+ if citem.Override.ValueBool() {
+ ccBody = helpers.SetFromXPath(ccBody, "override", "")
+ } else {
+ ccBody = helpers.RemoveFromXPath(ccBody, "override")
+ }
+ }
+ if !citem.Bidir.IsNull() && !citem.Bidir.IsUnknown() {
+ if citem.Bidir.ValueBool() {
+ ccBody = helpers.SetFromXPath(ccBody, "bidir", "")
+ } else {
+ ccBody = helpers.RemoveFromXPath(ccBody, "bidir")
+ }
+ }
+ cBody = helpers.SetRawFromXPath(cBody, "rp-address-list", ccBody.Res())
+ }
+ }
+ if len(item.RpCandidates) > 0 {
+ for _, citem := range item.RpCandidates {
+ ccBody := netconf.Body{}
+ if !citem.Interface.IsNull() && !citem.Interface.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "interface", citem.Interface.ValueString())
+ }
+ if !citem.GroupList.IsNull() && !citem.GroupList.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "group-list", citem.GroupList.ValueString())
+ }
+ if !citem.Interval.IsNull() && !citem.Interval.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "interval", strconv.FormatInt(citem.Interval.ValueInt64(), 10))
+ }
+ if !citem.Priority.IsNull() && !citem.Priority.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "priority", strconv.FormatInt(citem.Priority.ValueInt64(), 10))
+ }
+ if !citem.Bidir.IsNull() && !citem.Bidir.IsUnknown() {
+ if citem.Bidir.ValueBool() {
+ ccBody = helpers.SetFromXPath(ccBody, "bidir", "")
+ } else {
+ ccBody = helpers.RemoveFromXPath(ccBody, "bidir")
+ }
+ }
+ cBody = helpers.SetRawFromXPath(cBody, "rp-candidate", ccBody.Res())
+ }
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-multicast:vrf", cBody.Res())
+ }
+ }
+ bodyString, err := body.String()
+ if err != nil {
+ tflog.Error(ctx, fmt.Sprintf("Error converting body to string: %s", err))
+ }
+ return bodyString
+}
+
+// End of section. //template:end toBodyXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBody
func (data *PIM) updateFromBody(ctx context.Context, res gjson.Result) {
@@ -739,65 +982,677 @@ func (data *PIM) updateFromBody(ctx context.Context, res gjson.Result) {
// End of section. //template:end updateFromBody
-// Section below is generated&owned by "gen/generator.go". //template:begin fromBody
+// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBodyXML
-func (data *PIM) fromBody(ctx context.Context, res gjson.Result) {
- prefix := helpers.LastElement(data.getPath()) + "."
- if res.Get(helpers.LastElement(data.getPath())).IsArray() {
- prefix += "0."
- }
- if value := res.Get(prefix + "Cisco-IOS-XE-multicast:autorp-container.autorp"); value.Exists() {
- data.Autorp = types.BoolValue(value.Bool())
+func (data *PIM) updateFromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-multicast:autorp-container/autorp"); !data.Autorp.IsNull() {
+ if value.Exists() {
+ data.Autorp = types.BoolValue(value.Bool())
+ }
} else {
data.Autorp = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-multicast:autorp-container.listener"); value.Exists() {
- data.AutorpListener = types.BoolValue(true)
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-multicast:autorp-container/listener"); !data.AutorpListener.IsNull() {
+ if value.Exists() {
+ data.AutorpListener = types.BoolValue(true)
+ } else {
+ data.AutorpListener = types.BoolValue(false)
+ }
} else {
- data.AutorpListener = types.BoolValue(false)
+ data.AutorpListener = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-multicast:bsr-candidate.Loopback"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-multicast:bsr-candidate/Loopback"); value.Exists() && !data.BsrCandidateLoopback.IsNull() {
data.BsrCandidateLoopback = types.Int64Value(value.Int())
+ } else {
+ data.BsrCandidateLoopback = types.Int64Null()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-multicast:bsr-candidate.mask"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-multicast:bsr-candidate/mask"); value.Exists() && !data.BsrCandidateMask.IsNull() {
data.BsrCandidateMask = types.Int64Value(value.Int())
+ } else {
+ data.BsrCandidateMask = types.Int64Null()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-multicast:bsr-candidate.priority"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-multicast:bsr-candidate/priority"); value.Exists() && !data.BsrCandidatePriority.IsNull() {
data.BsrCandidatePriority = types.Int64Value(value.Int())
+ } else {
+ data.BsrCandidatePriority = types.Int64Null()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-multicast:bsr-candidate.accept-rp-candidate"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-multicast:bsr-candidate/accept-rp-candidate"); value.Exists() && !data.BsrCandidateAcceptRpCandidate.IsNull() {
data.BsrCandidateAcceptRpCandidate = types.StringValue(value.String())
+ } else {
+ data.BsrCandidateAcceptRpCandidate = types.StringNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-multicast:ssm.range"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-multicast:ssm/range"); value.Exists() && !data.SsmRange.IsNull() {
data.SsmRange = types.StringValue(value.String())
+ } else {
+ data.SsmRange = types.StringNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-multicast:ssm.default"); value.Exists() {
- data.SsmDefault = types.BoolValue(true)
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-multicast:ssm/default"); !data.SsmDefault.IsNull() {
+ if value.Exists() {
+ data.SsmDefault = types.BoolValue(true)
+ } else {
+ data.SsmDefault = types.BoolValue(false)
+ }
} else {
- data.SsmDefault = types.BoolValue(false)
+ data.SsmDefault = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-multicast:rp-address-conf.address"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-multicast:rp-address-conf/address"); value.Exists() && !data.RpAddress.IsNull() {
data.RpAddress = types.StringValue(value.String())
+ } else {
+ data.RpAddress = types.StringNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-multicast:rp-address-conf.override"); value.Exists() {
- data.RpAddressOverride = types.BoolValue(true)
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-multicast:rp-address-conf/override"); !data.RpAddressOverride.IsNull() {
+ if value.Exists() {
+ data.RpAddressOverride = types.BoolValue(true)
+ } else {
+ data.RpAddressOverride = types.BoolValue(false)
+ }
} else {
- data.RpAddressOverride = types.BoolValue(false)
+ data.RpAddressOverride = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-multicast:rp-address-conf.bidir"); value.Exists() {
- data.RpAddressBidir = types.BoolValue(true)
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-multicast:rp-address-conf/bidir"); !data.RpAddressBidir.IsNull() {
+ if value.Exists() {
+ data.RpAddressBidir = types.BoolValue(true)
+ } else {
+ data.RpAddressBidir = types.BoolValue(false)
+ }
} else {
- data.RpAddressBidir = types.BoolValue(false)
+ data.RpAddressBidir = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-multicast:rp-address-list"); value.Exists() {
- data.RpAddresses = make([]PIMRpAddresses, 0)
- value.ForEach(func(k, v gjson.Result) bool {
- item := PIMRpAddresses{}
- if cValue := v.Get("access-list"); cValue.Exists() {
- item.AccessList = types.StringValue(cValue.String())
- }
- if cValue := v.Get("rp-address"); cValue.Exists() {
- item.RpAddress = types.StringValue(cValue.String())
+ for i := range data.RpAddresses {
+ keys := [...]string{"access-list"}
+ keyValues := [...]string{data.RpAddresses[i].AccessList.ValueString()}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-multicast:rp-address-list").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, "access-list"); value.Exists() && !data.RpAddresses[i].AccessList.IsNull() {
+ data.RpAddresses[i].AccessList = types.StringValue(value.String())
+ } else {
+ data.RpAddresses[i].AccessList = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "rp-address"); value.Exists() && !data.RpAddresses[i].RpAddress.IsNull() {
+ data.RpAddresses[i].RpAddress = types.StringValue(value.String())
+ } else {
+ data.RpAddresses[i].RpAddress = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "override"); !data.RpAddresses[i].Override.IsNull() {
+ if value.Exists() {
+ data.RpAddresses[i].Override = types.BoolValue(true)
+ } else {
+ data.RpAddresses[i].Override = types.BoolValue(false)
+ }
+ } else {
+ data.RpAddresses[i].Override = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "bidir"); !data.RpAddresses[i].Bidir.IsNull() {
+ if value.Exists() {
+ data.RpAddresses[i].Bidir = types.BoolValue(true)
+ } else {
+ data.RpAddresses[i].Bidir = types.BoolValue(false)
+ }
+ } else {
+ data.RpAddresses[i].Bidir = types.BoolNull()
+ }
+ }
+ for i := range data.RpCandidates {
+ keys := [...]string{"interface"}
+ keyValues := [...]string{data.RpCandidates[i].Interface.ValueString()}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-multicast:rp-candidate").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, "interface"); value.Exists() && !data.RpCandidates[i].Interface.IsNull() {
+ data.RpCandidates[i].Interface = types.StringValue(value.String())
+ } else {
+ data.RpCandidates[i].Interface = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "group-list"); value.Exists() && !data.RpCandidates[i].GroupList.IsNull() {
+ data.RpCandidates[i].GroupList = types.StringValue(value.String())
+ } else {
+ data.RpCandidates[i].GroupList = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "interval"); value.Exists() && !data.RpCandidates[i].Interval.IsNull() {
+ data.RpCandidates[i].Interval = types.Int64Value(value.Int())
+ } else {
+ data.RpCandidates[i].Interval = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(r, "priority"); value.Exists() && !data.RpCandidates[i].Priority.IsNull() {
+ data.RpCandidates[i].Priority = types.Int64Value(value.Int())
+ } else {
+ data.RpCandidates[i].Priority = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(r, "bidir"); !data.RpCandidates[i].Bidir.IsNull() {
+ if value.Exists() {
+ data.RpCandidates[i].Bidir = types.BoolValue(true)
+ } else {
+ data.RpCandidates[i].Bidir = types.BoolValue(false)
+ }
+ } else {
+ data.RpCandidates[i].Bidir = types.BoolNull()
+ }
+ }
+ for i := range data.Vrfs {
+ keys := [...]string{"id"}
+ keyValues := [...]string{data.Vrfs[i].Vrf.ValueString()}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-multicast:vrf").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, "id"); value.Exists() && !data.Vrfs[i].Vrf.IsNull() {
+ data.Vrfs[i].Vrf = types.StringValue(value.String())
+ } else {
+ data.Vrfs[i].Vrf = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "autorp-container/autorp"); !data.Vrfs[i].Autorp.IsNull() {
+ if value.Exists() {
+ data.Vrfs[i].Autorp = types.BoolValue(value.Bool())
+ }
+ } else {
+ data.Vrfs[i].Autorp = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "autorp-container/listener"); !data.Vrfs[i].AutorpListener.IsNull() {
+ if value.Exists() {
+ data.Vrfs[i].AutorpListener = types.BoolValue(true)
+ } else {
+ data.Vrfs[i].AutorpListener = types.BoolValue(false)
+ }
+ } else {
+ data.Vrfs[i].AutorpListener = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "bsr-candidate/Loopback"); value.Exists() && !data.Vrfs[i].BsrCandidateLoopback.IsNull() {
+ data.Vrfs[i].BsrCandidateLoopback = types.Int64Value(value.Int())
+ } else {
+ data.Vrfs[i].BsrCandidateLoopback = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(r, "bsr-candidate/mask"); value.Exists() && !data.Vrfs[i].BsrCandidateMask.IsNull() {
+ data.Vrfs[i].BsrCandidateMask = types.Int64Value(value.Int())
+ } else {
+ data.Vrfs[i].BsrCandidateMask = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(r, "bsr-candidate/priority"); value.Exists() && !data.Vrfs[i].BsrCandidatePriority.IsNull() {
+ data.Vrfs[i].BsrCandidatePriority = types.Int64Value(value.Int())
+ } else {
+ data.Vrfs[i].BsrCandidatePriority = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(r, "bsr-candidate/accept-rp-candidate"); value.Exists() && !data.Vrfs[i].BsrCandidateAcceptRpCandidate.IsNull() {
+ data.Vrfs[i].BsrCandidateAcceptRpCandidate = types.StringValue(value.String())
+ } else {
+ data.Vrfs[i].BsrCandidateAcceptRpCandidate = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "ssm/range"); value.Exists() && !data.Vrfs[i].SsmRange.IsNull() {
+ data.Vrfs[i].SsmRange = types.StringValue(value.String())
+ } else {
+ data.Vrfs[i].SsmRange = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "ssm/default"); !data.Vrfs[i].SsmDefault.IsNull() {
+ if value.Exists() {
+ data.Vrfs[i].SsmDefault = types.BoolValue(true)
+ } else {
+ data.Vrfs[i].SsmDefault = types.BoolValue(false)
+ }
+ } else {
+ data.Vrfs[i].SsmDefault = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "rp-address-conf/address"); value.Exists() && !data.Vrfs[i].RpAddress.IsNull() {
+ data.Vrfs[i].RpAddress = types.StringValue(value.String())
+ } else {
+ data.Vrfs[i].RpAddress = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "rp-address-conf/override"); !data.Vrfs[i].RpAddressOverride.IsNull() {
+ if value.Exists() {
+ data.Vrfs[i].RpAddressOverride = types.BoolValue(true)
+ } else {
+ data.Vrfs[i].RpAddressOverride = types.BoolValue(false)
+ }
+ } else {
+ data.Vrfs[i].RpAddressOverride = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "rp-address-conf/bidir"); !data.Vrfs[i].RpAddressBidir.IsNull() {
+ if value.Exists() {
+ data.Vrfs[i].RpAddressBidir = types.BoolValue(true)
+ } else {
+ data.Vrfs[i].RpAddressBidir = types.BoolValue(false)
+ }
+ } else {
+ data.Vrfs[i].RpAddressBidir = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "cache/rpf-oif"); !data.Vrfs[i].CacheRpfOif.IsNull() {
+ if value.Exists() {
+ data.Vrfs[i].CacheRpfOif = types.BoolValue(true)
+ } else {
+ data.Vrfs[i].CacheRpfOif = types.BoolValue(false)
+ }
+ } else {
+ data.Vrfs[i].CacheRpfOif = types.BoolNull()
+ }
+ for ci := range data.Vrfs[i].RpAddresses {
+ keys := [...]string{"access-list"}
+ keyValues := [...]string{data.Vrfs[i].RpAddresses[ci].AccessList.ValueString()}
+
+ var cr xmldot.Result
+ helpers.GetFromXPath(r, "rp-address-list").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ cr = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(cr, "access-list"); value.Exists() && !data.Vrfs[i].RpAddresses[ci].AccessList.IsNull() {
+ data.Vrfs[i].RpAddresses[ci].AccessList = types.StringValue(value.String())
+ } else {
+ data.Vrfs[i].RpAddresses[ci].AccessList = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(cr, "rp-address"); value.Exists() && !data.Vrfs[i].RpAddresses[ci].RpAddress.IsNull() {
+ data.Vrfs[i].RpAddresses[ci].RpAddress = types.StringValue(value.String())
+ } else {
+ data.Vrfs[i].RpAddresses[ci].RpAddress = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(cr, "override"); !data.Vrfs[i].RpAddresses[ci].Override.IsNull() {
+ if value.Exists() {
+ data.Vrfs[i].RpAddresses[ci].Override = types.BoolValue(true)
+ } else {
+ data.Vrfs[i].RpAddresses[ci].Override = types.BoolValue(false)
+ }
+ } else {
+ data.Vrfs[i].RpAddresses[ci].Override = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(cr, "bidir"); !data.Vrfs[i].RpAddresses[ci].Bidir.IsNull() {
+ if value.Exists() {
+ data.Vrfs[i].RpAddresses[ci].Bidir = types.BoolValue(true)
+ } else {
+ data.Vrfs[i].RpAddresses[ci].Bidir = types.BoolValue(false)
+ }
+ } else {
+ data.Vrfs[i].RpAddresses[ci].Bidir = types.BoolNull()
+ }
+ }
+ for ci := range data.Vrfs[i].RpCandidates {
+ keys := [...]string{"interface"}
+ keyValues := [...]string{data.Vrfs[i].RpCandidates[ci].Interface.ValueString()}
+
+ var cr xmldot.Result
+ helpers.GetFromXPath(r, "rp-candidate").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ cr = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(cr, "interface"); value.Exists() && !data.Vrfs[i].RpCandidates[ci].Interface.IsNull() {
+ data.Vrfs[i].RpCandidates[ci].Interface = types.StringValue(value.String())
+ } else {
+ data.Vrfs[i].RpCandidates[ci].Interface = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(cr, "group-list"); value.Exists() && !data.Vrfs[i].RpCandidates[ci].GroupList.IsNull() {
+ data.Vrfs[i].RpCandidates[ci].GroupList = types.StringValue(value.String())
+ } else {
+ data.Vrfs[i].RpCandidates[ci].GroupList = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(cr, "interval"); value.Exists() && !data.Vrfs[i].RpCandidates[ci].Interval.IsNull() {
+ data.Vrfs[i].RpCandidates[ci].Interval = types.Int64Value(value.Int())
+ } else {
+ data.Vrfs[i].RpCandidates[ci].Interval = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(cr, "priority"); value.Exists() && !data.Vrfs[i].RpCandidates[ci].Priority.IsNull() {
+ data.Vrfs[i].RpCandidates[ci].Priority = types.Int64Value(value.Int())
+ } else {
+ data.Vrfs[i].RpCandidates[ci].Priority = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(cr, "bidir"); !data.Vrfs[i].RpCandidates[ci].Bidir.IsNull() {
+ if value.Exists() {
+ data.Vrfs[i].RpCandidates[ci].Bidir = types.BoolValue(true)
+ } else {
+ data.Vrfs[i].RpCandidates[ci].Bidir = types.BoolValue(false)
+ }
+ } else {
+ data.Vrfs[i].RpCandidates[ci].Bidir = types.BoolNull()
+ }
+ }
+ }
+}
+
+// End of section. //template:end updateFromBodyXML
+
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBody
+
+func (data *PIM) fromBody(ctx context.Context, res gjson.Result) {
+ prefix := helpers.LastElement(data.getPath()) + "."
+ if res.Get(helpers.LastElement(data.getPath())).IsArray() {
+ prefix += "0."
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-multicast:autorp-container.autorp"); value.Exists() {
+ data.Autorp = types.BoolValue(value.Bool())
+ } else {
+ data.Autorp = types.BoolNull()
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-multicast:autorp-container.listener"); value.Exists() {
+ data.AutorpListener = types.BoolValue(true)
+ } else {
+ data.AutorpListener = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-multicast:bsr-candidate.Loopback"); value.Exists() {
+ data.BsrCandidateLoopback = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-multicast:bsr-candidate.mask"); value.Exists() {
+ data.BsrCandidateMask = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-multicast:bsr-candidate.priority"); value.Exists() {
+ data.BsrCandidatePriority = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-multicast:bsr-candidate.accept-rp-candidate"); value.Exists() {
+ data.BsrCandidateAcceptRpCandidate = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-multicast:ssm.range"); value.Exists() {
+ data.SsmRange = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-multicast:ssm.default"); value.Exists() {
+ data.SsmDefault = types.BoolValue(true)
+ } else {
+ data.SsmDefault = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-multicast:rp-address-conf.address"); value.Exists() {
+ data.RpAddress = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-multicast:rp-address-conf.override"); value.Exists() {
+ data.RpAddressOverride = types.BoolValue(true)
+ } else {
+ data.RpAddressOverride = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-multicast:rp-address-conf.bidir"); value.Exists() {
+ data.RpAddressBidir = types.BoolValue(true)
+ } else {
+ data.RpAddressBidir = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-multicast:rp-address-list"); value.Exists() {
+ data.RpAddresses = make([]PIMRpAddresses, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := PIMRpAddresses{}
+ if cValue := v.Get("access-list"); cValue.Exists() {
+ item.AccessList = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("rp-address"); cValue.Exists() {
+ item.RpAddress = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("override"); cValue.Exists() {
+ item.Override = types.BoolValue(true)
+ } else {
+ item.Override = types.BoolValue(false)
+ }
+ if cValue := v.Get("bidir"); cValue.Exists() {
+ item.Bidir = types.BoolValue(true)
+ } else {
+ item.Bidir = types.BoolValue(false)
+ }
+ data.RpAddresses = append(data.RpAddresses, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-multicast:rp-candidate"); value.Exists() {
+ data.RpCandidates = make([]PIMRpCandidates, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := PIMRpCandidates{}
+ if cValue := v.Get("interface"); cValue.Exists() {
+ item.Interface = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("group-list"); cValue.Exists() {
+ item.GroupList = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("interval"); cValue.Exists() {
+ item.Interval = types.Int64Value(cValue.Int())
+ }
+ if cValue := v.Get("priority"); cValue.Exists() {
+ item.Priority = types.Int64Value(cValue.Int())
+ }
+ if cValue := v.Get("bidir"); cValue.Exists() {
+ item.Bidir = types.BoolValue(true)
+ } else {
+ item.Bidir = types.BoolValue(false)
+ }
+ data.RpCandidates = append(data.RpCandidates, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-multicast:vrf"); value.Exists() {
+ data.Vrfs = make([]PIMVrfs, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := PIMVrfs{}
+ if cValue := v.Get("id"); cValue.Exists() {
+ item.Vrf = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("autorp-container.autorp"); cValue.Exists() {
+ item.Autorp = types.BoolValue(cValue.Bool())
+ } else {
+ item.Autorp = types.BoolNull()
+ }
+ if cValue := v.Get("autorp-container.listener"); cValue.Exists() {
+ item.AutorpListener = types.BoolValue(true)
+ } else {
+ item.AutorpListener = types.BoolValue(false)
+ }
+ if cValue := v.Get("bsr-candidate.Loopback"); cValue.Exists() {
+ item.BsrCandidateLoopback = types.Int64Value(cValue.Int())
+ }
+ if cValue := v.Get("bsr-candidate.mask"); cValue.Exists() {
+ item.BsrCandidateMask = types.Int64Value(cValue.Int())
+ }
+ if cValue := v.Get("bsr-candidate.priority"); cValue.Exists() {
+ item.BsrCandidatePriority = types.Int64Value(cValue.Int())
+ }
+ if cValue := v.Get("bsr-candidate.accept-rp-candidate"); cValue.Exists() {
+ item.BsrCandidateAcceptRpCandidate = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("ssm.range"); cValue.Exists() {
+ item.SsmRange = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("ssm.default"); cValue.Exists() {
+ item.SsmDefault = types.BoolValue(true)
+ } else {
+ item.SsmDefault = types.BoolValue(false)
+ }
+ if cValue := v.Get("rp-address-conf.address"); cValue.Exists() {
+ item.RpAddress = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("rp-address-conf.override"); cValue.Exists() {
+ item.RpAddressOverride = types.BoolValue(true)
+ } else {
+ item.RpAddressOverride = types.BoolValue(false)
+ }
+ if cValue := v.Get("rp-address-conf.bidir"); cValue.Exists() {
+ item.RpAddressBidir = types.BoolValue(true)
+ } else {
+ item.RpAddressBidir = types.BoolValue(false)
+ }
+ if cValue := v.Get("cache.rpf-oif"); cValue.Exists() {
+ item.CacheRpfOif = types.BoolValue(true)
+ } else {
+ item.CacheRpfOif = types.BoolValue(false)
+ }
+ if cValue := v.Get("rp-address-list"); cValue.Exists() {
+ item.RpAddresses = make([]PIMVrfsRpAddresses, 0)
+ cValue.ForEach(func(ck, cv gjson.Result) bool {
+ cItem := PIMVrfsRpAddresses{}
+ if ccValue := cv.Get("access-list"); ccValue.Exists() {
+ cItem.AccessList = types.StringValue(ccValue.String())
+ }
+ if ccValue := cv.Get("rp-address"); ccValue.Exists() {
+ cItem.RpAddress = types.StringValue(ccValue.String())
+ }
+ if ccValue := cv.Get("override"); ccValue.Exists() {
+ cItem.Override = types.BoolValue(true)
+ } else {
+ cItem.Override = types.BoolValue(false)
+ }
+ if ccValue := cv.Get("bidir"); ccValue.Exists() {
+ cItem.Bidir = types.BoolValue(true)
+ } else {
+ cItem.Bidir = types.BoolValue(false)
+ }
+ item.RpAddresses = append(item.RpAddresses, cItem)
+ return true
+ })
+ }
+ if cValue := v.Get("rp-candidate"); cValue.Exists() {
+ item.RpCandidates = make([]PIMVrfsRpCandidates, 0)
+ cValue.ForEach(func(ck, cv gjson.Result) bool {
+ cItem := PIMVrfsRpCandidates{}
+ if ccValue := cv.Get("interface"); ccValue.Exists() {
+ cItem.Interface = types.StringValue(ccValue.String())
+ }
+ if ccValue := cv.Get("group-list"); ccValue.Exists() {
+ cItem.GroupList = types.StringValue(ccValue.String())
+ }
+ if ccValue := cv.Get("interval"); ccValue.Exists() {
+ cItem.Interval = types.Int64Value(ccValue.Int())
+ }
+ if ccValue := cv.Get("priority"); ccValue.Exists() {
+ cItem.Priority = types.Int64Value(ccValue.Int())
+ }
+ if ccValue := cv.Get("bidir"); ccValue.Exists() {
+ cItem.Bidir = types.BoolValue(true)
+ } else {
+ cItem.Bidir = types.BoolValue(false)
+ }
+ item.RpCandidates = append(item.RpCandidates, cItem)
+ return true
+ })
+ }
+ data.Vrfs = append(data.Vrfs, item)
+ return true
+ })
+ }
+}
+
+// End of section. //template:end fromBody
+
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyData
+
+func (data *PIMData) fromBody(ctx context.Context, res gjson.Result) {
+ prefix := helpers.LastElement(data.getPath()) + "."
+ if res.Get(helpers.LastElement(data.getPath())).IsArray() {
+ prefix += "0."
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-multicast:autorp-container.autorp"); value.Exists() {
+ data.Autorp = types.BoolValue(value.Bool())
+ } else {
+ data.Autorp = types.BoolNull()
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-multicast:autorp-container.listener"); value.Exists() {
+ data.AutorpListener = types.BoolValue(true)
+ } else {
+ data.AutorpListener = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-multicast:bsr-candidate.Loopback"); value.Exists() {
+ data.BsrCandidateLoopback = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-multicast:bsr-candidate.mask"); value.Exists() {
+ data.BsrCandidateMask = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-multicast:bsr-candidate.priority"); value.Exists() {
+ data.BsrCandidatePriority = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-multicast:bsr-candidate.accept-rp-candidate"); value.Exists() {
+ data.BsrCandidateAcceptRpCandidate = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-multicast:ssm.range"); value.Exists() {
+ data.SsmRange = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-multicast:ssm.default"); value.Exists() {
+ data.SsmDefault = types.BoolValue(true)
+ } else {
+ data.SsmDefault = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-multicast:rp-address-conf.address"); value.Exists() {
+ data.RpAddress = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-multicast:rp-address-conf.override"); value.Exists() {
+ data.RpAddressOverride = types.BoolValue(true)
+ } else {
+ data.RpAddressOverride = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-multicast:rp-address-conf.bidir"); value.Exists() {
+ data.RpAddressBidir = types.BoolValue(true)
+ } else {
+ data.RpAddressBidir = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-multicast:rp-address-list"); value.Exists() {
+ data.RpAddresses = make([]PIMRpAddresses, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := PIMRpAddresses{}
+ if cValue := v.Get("access-list"); cValue.Exists() {
+ item.AccessList = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("rp-address"); cValue.Exists() {
+ item.RpAddress = types.StringValue(cValue.String())
}
if cValue := v.Get("override"); cValue.Exists() {
item.Override = types.BoolValue(true)
@@ -948,74 +1803,277 @@ func (data *PIM) fromBody(ctx context.Context, res gjson.Result) {
}
}
-// End of section. //template:end fromBody
+// End of section. //template:end fromBodyData
-// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyData
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyXML
-func (data *PIMData) fromBody(ctx context.Context, res gjson.Result) {
- prefix := helpers.LastElement(data.getPath()) + "."
- if res.Get(helpers.LastElement(data.getPath())).IsArray() {
- prefix += "0."
+func (data *PIM) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-multicast:autorp-container/autorp"); value.Exists() {
+ data.Autorp = types.BoolValue(value.Bool())
+ } else {
+ data.Autorp = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-multicast:autorp-container.autorp"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-multicast:autorp-container/listener"); value.Exists() {
+ data.AutorpListener = types.BoolValue(true)
+ } else {
+ data.AutorpListener = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-multicast:bsr-candidate/Loopback"); value.Exists() {
+ data.BsrCandidateLoopback = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-multicast:bsr-candidate/mask"); value.Exists() {
+ data.BsrCandidateMask = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-multicast:bsr-candidate/priority"); value.Exists() {
+ data.BsrCandidatePriority = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-multicast:bsr-candidate/accept-rp-candidate"); value.Exists() {
+ data.BsrCandidateAcceptRpCandidate = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-multicast:ssm/range"); value.Exists() {
+ data.SsmRange = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-multicast:ssm/default"); value.Exists() {
+ data.SsmDefault = types.BoolValue(true)
+ } else {
+ data.SsmDefault = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-multicast:rp-address-conf/address"); value.Exists() {
+ data.RpAddress = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-multicast:rp-address-conf/override"); value.Exists() {
+ data.RpAddressOverride = types.BoolValue(true)
+ } else {
+ data.RpAddressOverride = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-multicast:rp-address-conf/bidir"); value.Exists() {
+ data.RpAddressBidir = types.BoolValue(true)
+ } else {
+ data.RpAddressBidir = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-multicast:rp-address-list"); value.Exists() {
+ data.RpAddresses = make([]PIMRpAddresses, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := PIMRpAddresses{}
+ if cValue := helpers.GetFromXPath(v, "access-list"); cValue.Exists() {
+ item.AccessList = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "rp-address"); cValue.Exists() {
+ item.RpAddress = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "override"); cValue.Exists() {
+ item.Override = types.BoolValue(true)
+ } else {
+ item.Override = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "bidir"); cValue.Exists() {
+ item.Bidir = types.BoolValue(true)
+ } else {
+ item.Bidir = types.BoolValue(false)
+ }
+ data.RpAddresses = append(data.RpAddresses, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-multicast:rp-candidate"); value.Exists() {
+ data.RpCandidates = make([]PIMRpCandidates, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := PIMRpCandidates{}
+ if cValue := helpers.GetFromXPath(v, "interface"); cValue.Exists() {
+ item.Interface = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "group-list"); cValue.Exists() {
+ item.GroupList = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "interval"); cValue.Exists() {
+ item.Interval = types.Int64Value(cValue.Int())
+ }
+ if cValue := helpers.GetFromXPath(v, "priority"); cValue.Exists() {
+ item.Priority = types.Int64Value(cValue.Int())
+ }
+ if cValue := helpers.GetFromXPath(v, "bidir"); cValue.Exists() {
+ item.Bidir = types.BoolValue(true)
+ } else {
+ item.Bidir = types.BoolValue(false)
+ }
+ data.RpCandidates = append(data.RpCandidates, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-multicast:vrf"); value.Exists() {
+ data.Vrfs = make([]PIMVrfs, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := PIMVrfs{}
+ if cValue := helpers.GetFromXPath(v, "id"); cValue.Exists() {
+ item.Vrf = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "autorp-container/autorp"); cValue.Exists() {
+ item.Autorp = types.BoolValue(cValue.Bool())
+ } else {
+ item.Autorp = types.BoolNull()
+ }
+ if cValue := helpers.GetFromXPath(v, "autorp-container/listener"); cValue.Exists() {
+ item.AutorpListener = types.BoolValue(true)
+ } else {
+ item.AutorpListener = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "bsr-candidate/Loopback"); cValue.Exists() {
+ item.BsrCandidateLoopback = types.Int64Value(cValue.Int())
+ }
+ if cValue := helpers.GetFromXPath(v, "bsr-candidate/mask"); cValue.Exists() {
+ item.BsrCandidateMask = types.Int64Value(cValue.Int())
+ }
+ if cValue := helpers.GetFromXPath(v, "bsr-candidate/priority"); cValue.Exists() {
+ item.BsrCandidatePriority = types.Int64Value(cValue.Int())
+ }
+ if cValue := helpers.GetFromXPath(v, "bsr-candidate/accept-rp-candidate"); cValue.Exists() {
+ item.BsrCandidateAcceptRpCandidate = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "ssm/range"); cValue.Exists() {
+ item.SsmRange = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "ssm/default"); cValue.Exists() {
+ item.SsmDefault = types.BoolValue(true)
+ } else {
+ item.SsmDefault = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "rp-address-conf/address"); cValue.Exists() {
+ item.RpAddress = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "rp-address-conf/override"); cValue.Exists() {
+ item.RpAddressOverride = types.BoolValue(true)
+ } else {
+ item.RpAddressOverride = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "rp-address-conf/bidir"); cValue.Exists() {
+ item.RpAddressBidir = types.BoolValue(true)
+ } else {
+ item.RpAddressBidir = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "cache/rpf-oif"); cValue.Exists() {
+ item.CacheRpfOif = types.BoolValue(true)
+ } else {
+ item.CacheRpfOif = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "rp-address-list"); cValue.Exists() {
+ item.RpAddresses = make([]PIMVrfsRpAddresses, 0)
+ cValue.ForEach(func(_ int, cv xmldot.Result) bool {
+ cItem := PIMVrfsRpAddresses{}
+ if ccValue := helpers.GetFromXPath(cv, "access-list"); ccValue.Exists() {
+ cItem.AccessList = types.StringValue(ccValue.String())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "rp-address"); ccValue.Exists() {
+ cItem.RpAddress = types.StringValue(ccValue.String())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "override"); ccValue.Exists() {
+ cItem.Override = types.BoolValue(true)
+ } else {
+ cItem.Override = types.BoolValue(false)
+ }
+ if ccValue := helpers.GetFromXPath(cv, "bidir"); ccValue.Exists() {
+ cItem.Bidir = types.BoolValue(true)
+ } else {
+ cItem.Bidir = types.BoolValue(false)
+ }
+ item.RpAddresses = append(item.RpAddresses, cItem)
+ return true
+ })
+ }
+ if cValue := helpers.GetFromXPath(v, "rp-candidate"); cValue.Exists() {
+ item.RpCandidates = make([]PIMVrfsRpCandidates, 0)
+ cValue.ForEach(func(_ int, cv xmldot.Result) bool {
+ cItem := PIMVrfsRpCandidates{}
+ if ccValue := helpers.GetFromXPath(cv, "interface"); ccValue.Exists() {
+ cItem.Interface = types.StringValue(ccValue.String())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "group-list"); ccValue.Exists() {
+ cItem.GroupList = types.StringValue(ccValue.String())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "interval"); ccValue.Exists() {
+ cItem.Interval = types.Int64Value(ccValue.Int())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "priority"); ccValue.Exists() {
+ cItem.Priority = types.Int64Value(ccValue.Int())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "bidir"); ccValue.Exists() {
+ cItem.Bidir = types.BoolValue(true)
+ } else {
+ cItem.Bidir = types.BoolValue(false)
+ }
+ item.RpCandidates = append(item.RpCandidates, cItem)
+ return true
+ })
+ }
+ data.Vrfs = append(data.Vrfs, item)
+ return true
+ })
+ }
+}
+
+// End of section. //template:end fromBodyXML
+
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyDataXML
+
+func (data *PIMData) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-multicast:autorp-container/autorp"); value.Exists() {
data.Autorp = types.BoolValue(value.Bool())
} else {
data.Autorp = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-multicast:autorp-container.listener"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-multicast:autorp-container/listener"); value.Exists() {
data.AutorpListener = types.BoolValue(true)
} else {
data.AutorpListener = types.BoolValue(false)
}
- if value := res.Get(prefix + "Cisco-IOS-XE-multicast:bsr-candidate.Loopback"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-multicast:bsr-candidate/Loopback"); value.Exists() {
data.BsrCandidateLoopback = types.Int64Value(value.Int())
}
- if value := res.Get(prefix + "Cisco-IOS-XE-multicast:bsr-candidate.mask"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-multicast:bsr-candidate/mask"); value.Exists() {
data.BsrCandidateMask = types.Int64Value(value.Int())
}
- if value := res.Get(prefix + "Cisco-IOS-XE-multicast:bsr-candidate.priority"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-multicast:bsr-candidate/priority"); value.Exists() {
data.BsrCandidatePriority = types.Int64Value(value.Int())
}
- if value := res.Get(prefix + "Cisco-IOS-XE-multicast:bsr-candidate.accept-rp-candidate"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-multicast:bsr-candidate/accept-rp-candidate"); value.Exists() {
data.BsrCandidateAcceptRpCandidate = types.StringValue(value.String())
}
- if value := res.Get(prefix + "Cisco-IOS-XE-multicast:ssm.range"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-multicast:ssm/range"); value.Exists() {
data.SsmRange = types.StringValue(value.String())
}
- if value := res.Get(prefix + "Cisco-IOS-XE-multicast:ssm.default"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-multicast:ssm/default"); value.Exists() {
data.SsmDefault = types.BoolValue(true)
} else {
data.SsmDefault = types.BoolValue(false)
}
- if value := res.Get(prefix + "Cisco-IOS-XE-multicast:rp-address-conf.address"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-multicast:rp-address-conf/address"); value.Exists() {
data.RpAddress = types.StringValue(value.String())
}
- if value := res.Get(prefix + "Cisco-IOS-XE-multicast:rp-address-conf.override"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-multicast:rp-address-conf/override"); value.Exists() {
data.RpAddressOverride = types.BoolValue(true)
} else {
data.RpAddressOverride = types.BoolValue(false)
}
- if value := res.Get(prefix + "Cisco-IOS-XE-multicast:rp-address-conf.bidir"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-multicast:rp-address-conf/bidir"); value.Exists() {
data.RpAddressBidir = types.BoolValue(true)
} else {
data.RpAddressBidir = types.BoolValue(false)
}
- if value := res.Get(prefix + "Cisco-IOS-XE-multicast:rp-address-list"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-multicast:rp-address-list"); value.Exists() {
data.RpAddresses = make([]PIMRpAddresses, 0)
- value.ForEach(func(k, v gjson.Result) bool {
+ value.ForEach(func(_ int, v xmldot.Result) bool {
item := PIMRpAddresses{}
- if cValue := v.Get("access-list"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "access-list"); cValue.Exists() {
item.AccessList = types.StringValue(cValue.String())
}
- if cValue := v.Get("rp-address"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "rp-address"); cValue.Exists() {
item.RpAddress = types.StringValue(cValue.String())
}
- if cValue := v.Get("override"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "override"); cValue.Exists() {
item.Override = types.BoolValue(true)
} else {
item.Override = types.BoolValue(false)
}
- if cValue := v.Get("bidir"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "bidir"); cValue.Exists() {
item.Bidir = types.BoolValue(true)
} else {
item.Bidir = types.BoolValue(false)
@@ -1024,23 +2082,23 @@ func (data *PIMData) fromBody(ctx context.Context, res gjson.Result) {
return true
})
}
- if value := res.Get(prefix + "Cisco-IOS-XE-multicast:rp-candidate"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-multicast:rp-candidate"); value.Exists() {
data.RpCandidates = make([]PIMRpCandidates, 0)
- value.ForEach(func(k, v gjson.Result) bool {
+ value.ForEach(func(_ int, v xmldot.Result) bool {
item := PIMRpCandidates{}
- if cValue := v.Get("interface"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "interface"); cValue.Exists() {
item.Interface = types.StringValue(cValue.String())
}
- if cValue := v.Get("group-list"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "group-list"); cValue.Exists() {
item.GroupList = types.StringValue(cValue.String())
}
- if cValue := v.Get("interval"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "interval"); cValue.Exists() {
item.Interval = types.Int64Value(cValue.Int())
}
- if cValue := v.Get("priority"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "priority"); cValue.Exists() {
item.Priority = types.Int64Value(cValue.Int())
}
- if cValue := v.Get("bidir"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "bidir"); cValue.Exists() {
item.Bidir = types.BoolValue(true)
} else {
item.Bidir = types.BoolValue(false)
@@ -1049,77 +2107,77 @@ func (data *PIMData) fromBody(ctx context.Context, res gjson.Result) {
return true
})
}
- if value := res.Get(prefix + "Cisco-IOS-XE-multicast:vrf"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-multicast:vrf"); value.Exists() {
data.Vrfs = make([]PIMVrfs, 0)
- value.ForEach(func(k, v gjson.Result) bool {
+ value.ForEach(func(_ int, v xmldot.Result) bool {
item := PIMVrfs{}
- if cValue := v.Get("id"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "id"); cValue.Exists() {
item.Vrf = types.StringValue(cValue.String())
}
- if cValue := v.Get("autorp-container.autorp"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "autorp-container/autorp"); cValue.Exists() {
item.Autorp = types.BoolValue(cValue.Bool())
} else {
item.Autorp = types.BoolNull()
}
- if cValue := v.Get("autorp-container.listener"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "autorp-container/listener"); cValue.Exists() {
item.AutorpListener = types.BoolValue(true)
} else {
item.AutorpListener = types.BoolValue(false)
}
- if cValue := v.Get("bsr-candidate.Loopback"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "bsr-candidate/Loopback"); cValue.Exists() {
item.BsrCandidateLoopback = types.Int64Value(cValue.Int())
}
- if cValue := v.Get("bsr-candidate.mask"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "bsr-candidate/mask"); cValue.Exists() {
item.BsrCandidateMask = types.Int64Value(cValue.Int())
}
- if cValue := v.Get("bsr-candidate.priority"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "bsr-candidate/priority"); cValue.Exists() {
item.BsrCandidatePriority = types.Int64Value(cValue.Int())
}
- if cValue := v.Get("bsr-candidate.accept-rp-candidate"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "bsr-candidate/accept-rp-candidate"); cValue.Exists() {
item.BsrCandidateAcceptRpCandidate = types.StringValue(cValue.String())
}
- if cValue := v.Get("ssm.range"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ssm/range"); cValue.Exists() {
item.SsmRange = types.StringValue(cValue.String())
}
- if cValue := v.Get("ssm.default"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "ssm/default"); cValue.Exists() {
item.SsmDefault = types.BoolValue(true)
} else {
item.SsmDefault = types.BoolValue(false)
}
- if cValue := v.Get("rp-address-conf.address"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "rp-address-conf/address"); cValue.Exists() {
item.RpAddress = types.StringValue(cValue.String())
}
- if cValue := v.Get("rp-address-conf.override"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "rp-address-conf/override"); cValue.Exists() {
item.RpAddressOverride = types.BoolValue(true)
} else {
item.RpAddressOverride = types.BoolValue(false)
}
- if cValue := v.Get("rp-address-conf.bidir"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "rp-address-conf/bidir"); cValue.Exists() {
item.RpAddressBidir = types.BoolValue(true)
} else {
item.RpAddressBidir = types.BoolValue(false)
}
- if cValue := v.Get("cache.rpf-oif"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "cache/rpf-oif"); cValue.Exists() {
item.CacheRpfOif = types.BoolValue(true)
} else {
item.CacheRpfOif = types.BoolValue(false)
}
- if cValue := v.Get("rp-address-list"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "rp-address-list"); cValue.Exists() {
item.RpAddresses = make([]PIMVrfsRpAddresses, 0)
- cValue.ForEach(func(ck, cv gjson.Result) bool {
+ cValue.ForEach(func(_ int, cv xmldot.Result) bool {
cItem := PIMVrfsRpAddresses{}
- if ccValue := cv.Get("access-list"); ccValue.Exists() {
+ if ccValue := helpers.GetFromXPath(cv, "access-list"); ccValue.Exists() {
cItem.AccessList = types.StringValue(ccValue.String())
}
- if ccValue := cv.Get("rp-address"); ccValue.Exists() {
+ if ccValue := helpers.GetFromXPath(cv, "rp-address"); ccValue.Exists() {
cItem.RpAddress = types.StringValue(ccValue.String())
}
- if ccValue := cv.Get("override"); ccValue.Exists() {
+ if ccValue := helpers.GetFromXPath(cv, "override"); ccValue.Exists() {
cItem.Override = types.BoolValue(true)
} else {
cItem.Override = types.BoolValue(false)
}
- if ccValue := cv.Get("bidir"); ccValue.Exists() {
+ if ccValue := helpers.GetFromXPath(cv, "bidir"); ccValue.Exists() {
cItem.Bidir = types.BoolValue(true)
} else {
cItem.Bidir = types.BoolValue(false)
@@ -1128,23 +2186,23 @@ func (data *PIMData) fromBody(ctx context.Context, res gjson.Result) {
return true
})
}
- if cValue := v.Get("rp-candidate"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "rp-candidate"); cValue.Exists() {
item.RpCandidates = make([]PIMVrfsRpCandidates, 0)
- cValue.ForEach(func(ck, cv gjson.Result) bool {
+ cValue.ForEach(func(_ int, cv xmldot.Result) bool {
cItem := PIMVrfsRpCandidates{}
- if ccValue := cv.Get("interface"); ccValue.Exists() {
+ if ccValue := helpers.GetFromXPath(cv, "interface"); ccValue.Exists() {
cItem.Interface = types.StringValue(ccValue.String())
}
- if ccValue := cv.Get("group-list"); ccValue.Exists() {
+ if ccValue := helpers.GetFromXPath(cv, "group-list"); ccValue.Exists() {
cItem.GroupList = types.StringValue(ccValue.String())
}
- if ccValue := cv.Get("interval"); ccValue.Exists() {
+ if ccValue := helpers.GetFromXPath(cv, "interval"); ccValue.Exists() {
cItem.Interval = types.Int64Value(ccValue.Int())
}
- if ccValue := cv.Get("priority"); ccValue.Exists() {
+ if ccValue := helpers.GetFromXPath(cv, "priority"); ccValue.Exists() {
cItem.Priority = types.Int64Value(ccValue.Int())
}
- if ccValue := cv.Get("bidir"); ccValue.Exists() {
+ if ccValue := helpers.GetFromXPath(cv, "bidir"); ccValue.Exists() {
cItem.Bidir = types.BoolValue(true)
} else {
cItem.Bidir = types.BoolValue(false)
@@ -1159,7 +2217,7 @@ func (data *PIMData) fromBody(ctx context.Context, res gjson.Result) {
}
}
-// End of section. //template:end fromBodyData
+// End of section. //template:end fromBodyDataXML
// Section below is generated&owned by "gen/generator.go". //template:begin getDeletedItems
@@ -1404,6 +2462,274 @@ func (data *PIM) getDeletedItems(ctx context.Context, state PIM) []string {
// End of section. //template:end getDeletedItems
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletedItemsXML
+
+func (data *PIM) addDeletedItemsXML(ctx context.Context, state PIM, body string) string {
+ b := netconf.NewBody(body)
+ if !state.Autorp.IsNull() && data.Autorp.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-multicast:autorp-container/autorp")
+ }
+ if !state.AutorpListener.IsNull() && data.AutorpListener.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-multicast:autorp-container/listener")
+ }
+ if !state.BsrCandidateLoopback.IsNull() && data.BsrCandidateLoopback.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-multicast:bsr-candidate/Loopback")
+ }
+ if !state.BsrCandidateMask.IsNull() && data.BsrCandidateMask.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-multicast:bsr-candidate/mask")
+ }
+ if !state.BsrCandidatePriority.IsNull() && data.BsrCandidatePriority.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-multicast:bsr-candidate/priority")
+ }
+ if !state.BsrCandidateAcceptRpCandidate.IsNull() && data.BsrCandidateAcceptRpCandidate.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-multicast:bsr-candidate/accept-rp-candidate")
+ }
+ if !state.SsmRange.IsNull() && data.SsmRange.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-multicast:ssm/range")
+ }
+ if !state.SsmDefault.IsNull() && data.SsmDefault.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-multicast:ssm/default")
+ }
+ if !state.RpAddress.IsNull() && data.RpAddress.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-multicast:rp-address-conf/address")
+ }
+ if !state.RpAddressOverride.IsNull() && data.RpAddressOverride.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-multicast:rp-address-conf/override")
+ }
+ if !state.RpAddressBidir.IsNull() && data.RpAddressBidir.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-multicast:rp-address-conf/bidir")
+ }
+ for i := range state.RpAddresses {
+ stateKeys := [...]string{"access-list"}
+ stateKeyValues := [...]string{state.RpAddresses[i].AccessList.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.RpAddresses[i].AccessList.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.RpAddresses {
+ found = true
+ if state.RpAddresses[i].AccessList.ValueString() != data.RpAddresses[j].AccessList.ValueString() {
+ found = false
+ }
+ if found {
+ if !state.RpAddresses[i].RpAddress.IsNull() && data.RpAddresses[j].RpAddress.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-multicast:rp-address-list%v/rp-address", predicates))
+ }
+ if !state.RpAddresses[i].Override.IsNull() && data.RpAddresses[j].Override.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-multicast:rp-address-list%v/override", predicates))
+ }
+ if !state.RpAddresses[i].Bidir.IsNull() && data.RpAddresses[j].Bidir.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-multicast:rp-address-list%v/bidir", predicates))
+ }
+ break
+ }
+ }
+ if !found {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-multicast:rp-address-list%v", predicates))
+ }
+ }
+ for i := range state.RpCandidates {
+ stateKeys := [...]string{"interface"}
+ stateKeyValues := [...]string{state.RpCandidates[i].Interface.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.RpCandidates[i].Interface.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.RpCandidates {
+ found = true
+ if state.RpCandidates[i].Interface.ValueString() != data.RpCandidates[j].Interface.ValueString() {
+ found = false
+ }
+ if found {
+ if !state.RpCandidates[i].GroupList.IsNull() && data.RpCandidates[j].GroupList.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-multicast:rp-candidate%v/group-list", predicates))
+ }
+ if !state.RpCandidates[i].Interval.IsNull() && data.RpCandidates[j].Interval.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-multicast:rp-candidate%v/interval", predicates))
+ }
+ if !state.RpCandidates[i].Priority.IsNull() && data.RpCandidates[j].Priority.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-multicast:rp-candidate%v/priority", predicates))
+ }
+ if !state.RpCandidates[i].Bidir.IsNull() && data.RpCandidates[j].Bidir.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-multicast:rp-candidate%v/bidir", predicates))
+ }
+ break
+ }
+ }
+ if !found {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-multicast:rp-candidate%v", predicates))
+ }
+ }
+ for i := range state.Vrfs {
+ stateKeys := [...]string{"id"}
+ stateKeyValues := [...]string{state.Vrfs[i].Vrf.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.Vrfs[i].Vrf.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.Vrfs {
+ found = true
+ if state.Vrfs[i].Vrf.ValueString() != data.Vrfs[j].Vrf.ValueString() {
+ found = false
+ }
+ if found {
+ if !state.Vrfs[i].Autorp.IsNull() && data.Vrfs[j].Autorp.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-multicast:vrf%v/autorp-container/autorp", predicates))
+ }
+ if !state.Vrfs[i].AutorpListener.IsNull() && data.Vrfs[j].AutorpListener.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-multicast:vrf%v/autorp-container/listener", predicates))
+ }
+ if !state.Vrfs[i].BsrCandidateLoopback.IsNull() && data.Vrfs[j].BsrCandidateLoopback.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-multicast:vrf%v/bsr-candidate/Loopback", predicates))
+ }
+ if !state.Vrfs[i].BsrCandidateMask.IsNull() && data.Vrfs[j].BsrCandidateMask.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-multicast:vrf%v/bsr-candidate/mask", predicates))
+ }
+ if !state.Vrfs[i].BsrCandidatePriority.IsNull() && data.Vrfs[j].BsrCandidatePriority.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-multicast:vrf%v/bsr-candidate/priority", predicates))
+ }
+ if !state.Vrfs[i].BsrCandidateAcceptRpCandidate.IsNull() && data.Vrfs[j].BsrCandidateAcceptRpCandidate.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-multicast:vrf%v/bsr-candidate/accept-rp-candidate", predicates))
+ }
+ if !state.Vrfs[i].SsmRange.IsNull() && data.Vrfs[j].SsmRange.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-multicast:vrf%v/ssm/range", predicates))
+ }
+ if !state.Vrfs[i].SsmDefault.IsNull() && data.Vrfs[j].SsmDefault.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-multicast:vrf%v/ssm/default", predicates))
+ }
+ if !state.Vrfs[i].RpAddress.IsNull() && data.Vrfs[j].RpAddress.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-multicast:vrf%v/rp-address-conf/address", predicates))
+ }
+ if !state.Vrfs[i].RpAddressOverride.IsNull() && data.Vrfs[j].RpAddressOverride.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-multicast:vrf%v/rp-address-conf/override", predicates))
+ }
+ if !state.Vrfs[i].RpAddressBidir.IsNull() && data.Vrfs[j].RpAddressBidir.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-multicast:vrf%v/rp-address-conf/bidir", predicates))
+ }
+ for ci := range state.Vrfs[i].RpAddresses {
+ cstateKeys := [...]string{"access-list"}
+ cstateKeyValues := [...]string{state.Vrfs[i].RpAddresses[ci].AccessList.ValueString()}
+ cpredicates := ""
+ for i := range cstateKeys {
+ cpredicates += fmt.Sprintf("[%s='%s']", cstateKeys[i], cstateKeyValues[i])
+ }
+
+ cemptyKeys := true
+ if !reflect.ValueOf(state.Vrfs[i].RpAddresses[ci].AccessList.ValueString()).IsZero() {
+ cemptyKeys = false
+ }
+ if cemptyKeys {
+ continue
+ }
+
+ found := false
+ for cj := range data.Vrfs[j].RpAddresses {
+ found = true
+ if state.Vrfs[i].RpAddresses[ci].AccessList.ValueString() != data.Vrfs[j].RpAddresses[cj].AccessList.ValueString() {
+ found = false
+ }
+ if found {
+ if !state.Vrfs[i].RpAddresses[ci].RpAddress.IsNull() && data.Vrfs[j].RpAddresses[cj].RpAddress.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-multicast:vrf%v/rp-address-list%v/rp-address", predicates, cpredicates))
+ }
+ if !state.Vrfs[i].RpAddresses[ci].Override.IsNull() && data.Vrfs[j].RpAddresses[cj].Override.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-multicast:vrf%v/rp-address-list%v/override", predicates, cpredicates))
+ }
+ if !state.Vrfs[i].RpAddresses[ci].Bidir.IsNull() && data.Vrfs[j].RpAddresses[cj].Bidir.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-multicast:vrf%v/rp-address-list%v/bidir", predicates, cpredicates))
+ }
+ break
+ }
+ }
+ if !found {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-multicast:vrf%v/rp-address-list%v", predicates, cpredicates))
+ }
+ }
+ for ci := range state.Vrfs[i].RpCandidates {
+ cstateKeys := [...]string{"interface"}
+ cstateKeyValues := [...]string{state.Vrfs[i].RpCandidates[ci].Interface.ValueString()}
+ cpredicates := ""
+ for i := range cstateKeys {
+ cpredicates += fmt.Sprintf("[%s='%s']", cstateKeys[i], cstateKeyValues[i])
+ }
+
+ cemptyKeys := true
+ if !reflect.ValueOf(state.Vrfs[i].RpCandidates[ci].Interface.ValueString()).IsZero() {
+ cemptyKeys = false
+ }
+ if cemptyKeys {
+ continue
+ }
+
+ found := false
+ for cj := range data.Vrfs[j].RpCandidates {
+ found = true
+ if state.Vrfs[i].RpCandidates[ci].Interface.ValueString() != data.Vrfs[j].RpCandidates[cj].Interface.ValueString() {
+ found = false
+ }
+ if found {
+ if !state.Vrfs[i].RpCandidates[ci].GroupList.IsNull() && data.Vrfs[j].RpCandidates[cj].GroupList.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-multicast:vrf%v/rp-candidate%v/group-list", predicates, cpredicates))
+ }
+ if !state.Vrfs[i].RpCandidates[ci].Interval.IsNull() && data.Vrfs[j].RpCandidates[cj].Interval.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-multicast:vrf%v/rp-candidate%v/interval", predicates, cpredicates))
+ }
+ if !state.Vrfs[i].RpCandidates[ci].Priority.IsNull() && data.Vrfs[j].RpCandidates[cj].Priority.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-multicast:vrf%v/rp-candidate%v/priority", predicates, cpredicates))
+ }
+ if !state.Vrfs[i].RpCandidates[ci].Bidir.IsNull() && data.Vrfs[j].RpCandidates[cj].Bidir.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-multicast:vrf%v/rp-candidate%v/bidir", predicates, cpredicates))
+ }
+ break
+ }
+ }
+ if !found {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-multicast:vrf%v/rp-candidate%v", predicates, cpredicates))
+ }
+ }
+ break
+ }
+ }
+ if !found {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-multicast:vrf%v", predicates))
+ }
+ }
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletedItemsXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin getEmptyLeafsDelete
func (data *PIM) getEmptyLeafsDelete(ctx context.Context) []string {
@@ -1536,3 +2862,76 @@ func (data *PIM) getDeletePaths(ctx context.Context) []string {
}
// End of section. //template:end getDeletePaths
+
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletePathsXML
+
+func (data *PIM) addDeletePathsXML(ctx context.Context, body string) string {
+ b := netconf.NewBody(body)
+ if !data.Autorp.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-multicast:autorp-container/autorp")
+ }
+ if !data.AutorpListener.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-multicast:autorp-container/listener")
+ }
+ if !data.BsrCandidateLoopback.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-multicast:bsr-candidate/Loopback")
+ }
+ if !data.BsrCandidateMask.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-multicast:bsr-candidate/mask")
+ }
+ if !data.BsrCandidatePriority.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-multicast:bsr-candidate/priority")
+ }
+ if !data.BsrCandidateAcceptRpCandidate.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-multicast:bsr-candidate/accept-rp-candidate")
+ }
+ if !data.SsmRange.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-multicast:ssm/range")
+ }
+ if !data.SsmDefault.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-multicast:ssm/default")
+ }
+ if !data.RpAddress.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-multicast:rp-address-conf/address")
+ }
+ if !data.RpAddressOverride.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-multicast:rp-address-conf/override")
+ }
+ if !data.RpAddressBidir.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-multicast:rp-address-conf/bidir")
+ }
+ for i := range data.RpAddresses {
+ keys := [...]string{"access-list"}
+ keyValues := [...]string{data.RpAddresses[i].AccessList.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/Cisco-IOS-XE-multicast:rp-address-list%v", predicates))
+ }
+ for i := range data.RpCandidates {
+ keys := [...]string{"interface"}
+ keyValues := [...]string{data.RpCandidates[i].Interface.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/Cisco-IOS-XE-multicast:rp-candidate%v", predicates))
+ }
+ for i := range data.Vrfs {
+ keys := [...]string{"id"}
+ keyValues := [...]string{data.Vrfs[i].Vrf.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/Cisco-IOS-XE-multicast:vrf%v", predicates))
+ }
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletePathsXML
diff --git a/internal/provider/model_iosxe_platform.go b/internal/provider/model_iosxe_platform.go
index b9508048..8a1f9500 100644
--- a/internal/provider/model_iosxe_platform.go
+++ b/internal/provider/model_iosxe_platform.go
@@ -28,6 +28,9 @@ import (
"github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/types"
+ "github.com/hashicorp/terraform-plugin-log/tflog"
+ "github.com/netascode/go-netconf"
+ "github.com/netascode/xmldot"
"github.com/tidwall/gjson"
"github.com/tidwall/sjson"
)
@@ -76,6 +79,17 @@ func (data Platform) getPathShort() string {
return matches[1]
}
+// getXPath returns the XPath for NETCONF operations
+func (data Platform) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/platform"
+ return path
+}
+
+func (data PlatformData) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/platform"
+ return path
+}
+
// End of section. //template:end getPath
// Section below is generated&owned by "gen/generator.go". //template:begin toBody
@@ -99,6 +113,31 @@ func (data Platform) toBody(ctx context.Context) string {
// End of section. //template:end toBody
+// Section below is generated&owned by "gen/generator.go". //template:begin toBodyXML
+
+func (data Platform) toBodyXML(ctx context.Context) string {
+ body := netconf.Body{}
+ if !data.PuntKeepaliveDisableKernelCore.IsNull() && !data.PuntKeepaliveDisableKernelCore.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-platform:punt-keepalive/disable-kernel-core", data.PuntKeepaliveDisableKernelCore.ValueBool())
+ }
+ if !data.PuntKeepaliveSettingsFatalCount.IsNull() && !data.PuntKeepaliveSettingsFatalCount.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-platform:punt-keepalive/settings/fatal-count", strconv.FormatInt(data.PuntKeepaliveSettingsFatalCount.ValueInt64(), 10))
+ }
+ if !data.PuntKeepaliveSettingsTransmitInterval.IsNull() && !data.PuntKeepaliveSettingsTransmitInterval.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-platform:punt-keepalive/settings/transmit-interval", strconv.FormatInt(data.PuntKeepaliveSettingsTransmitInterval.ValueInt64(), 10))
+ }
+ if !data.PuntKeepaliveSettingsWarningCount.IsNull() && !data.PuntKeepaliveSettingsWarningCount.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-platform:punt-keepalive/settings/warning-count", strconv.FormatInt(data.PuntKeepaliveSettingsWarningCount.ValueInt64(), 10))
+ }
+ bodyString, err := body.String()
+ if err != nil {
+ tflog.Error(ctx, fmt.Sprintf("Error converting body to string: %s", err))
+ }
+ return bodyString
+}
+
+// End of section. //template:end toBodyXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBody
func (data *Platform) updateFromBody(ctx context.Context, res gjson.Result) {
@@ -132,6 +171,35 @@ func (data *Platform) updateFromBody(ctx context.Context, res gjson.Result) {
// End of section. //template:end updateFromBody
+// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBodyXML
+
+func (data *Platform) updateFromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-platform:punt-keepalive/disable-kernel-core"); !data.PuntKeepaliveDisableKernelCore.IsNull() {
+ if value.Exists() {
+ data.PuntKeepaliveDisableKernelCore = types.BoolValue(value.Bool())
+ }
+ } else {
+ data.PuntKeepaliveDisableKernelCore = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-platform:punt-keepalive/settings/fatal-count"); value.Exists() && !data.PuntKeepaliveSettingsFatalCount.IsNull() {
+ data.PuntKeepaliveSettingsFatalCount = types.Int64Value(value.Int())
+ } else {
+ data.PuntKeepaliveSettingsFatalCount = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-platform:punt-keepalive/settings/transmit-interval"); value.Exists() && !data.PuntKeepaliveSettingsTransmitInterval.IsNull() {
+ data.PuntKeepaliveSettingsTransmitInterval = types.Int64Value(value.Int())
+ } else {
+ data.PuntKeepaliveSettingsTransmitInterval = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-platform:punt-keepalive/settings/warning-count"); value.Exists() && !data.PuntKeepaliveSettingsWarningCount.IsNull() {
+ data.PuntKeepaliveSettingsWarningCount = types.Int64Value(value.Int())
+ } else {
+ data.PuntKeepaliveSettingsWarningCount = types.Int64Null()
+ }
+}
+
+// End of section. //template:end updateFromBodyXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin fromBody
func (data *Platform) fromBody(ctx context.Context, res gjson.Result) {
@@ -182,6 +250,48 @@ func (data *PlatformData) fromBody(ctx context.Context, res gjson.Result) {
// End of section. //template:end fromBodyData
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyXML
+
+func (data *Platform) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-platform:punt-keepalive/disable-kernel-core"); value.Exists() {
+ data.PuntKeepaliveDisableKernelCore = types.BoolValue(value.Bool())
+ } else {
+ data.PuntKeepaliveDisableKernelCore = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-platform:punt-keepalive/settings/fatal-count"); value.Exists() {
+ data.PuntKeepaliveSettingsFatalCount = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-platform:punt-keepalive/settings/transmit-interval"); value.Exists() {
+ data.PuntKeepaliveSettingsTransmitInterval = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-platform:punt-keepalive/settings/warning-count"); value.Exists() {
+ data.PuntKeepaliveSettingsWarningCount = types.Int64Value(value.Int())
+ }
+}
+
+// End of section. //template:end fromBodyXML
+
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyDataXML
+
+func (data *PlatformData) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-platform:punt-keepalive/disable-kernel-core"); value.Exists() {
+ data.PuntKeepaliveDisableKernelCore = types.BoolValue(value.Bool())
+ } else {
+ data.PuntKeepaliveDisableKernelCore = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-platform:punt-keepalive/settings/fatal-count"); value.Exists() {
+ data.PuntKeepaliveSettingsFatalCount = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-platform:punt-keepalive/settings/transmit-interval"); value.Exists() {
+ data.PuntKeepaliveSettingsTransmitInterval = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-platform:punt-keepalive/settings/warning-count"); value.Exists() {
+ data.PuntKeepaliveSettingsWarningCount = types.Int64Value(value.Int())
+ }
+}
+
+// End of section. //template:end fromBodyDataXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin getDeletedItems
func (data *Platform) getDeletedItems(ctx context.Context, state Platform) []string {
@@ -204,6 +314,28 @@ func (data *Platform) getDeletedItems(ctx context.Context, state Platform) []str
// End of section. //template:end getDeletedItems
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletedItemsXML
+
+func (data *Platform) addDeletedItemsXML(ctx context.Context, state Platform, body string) string {
+ b := netconf.NewBody(body)
+ if !state.PuntKeepaliveDisableKernelCore.IsNull() && data.PuntKeepaliveDisableKernelCore.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-platform:punt-keepalive/disable-kernel-core")
+ }
+ if !state.PuntKeepaliveSettingsFatalCount.IsNull() && data.PuntKeepaliveSettingsFatalCount.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-platform:punt-keepalive/settings/fatal-count")
+ }
+ if !state.PuntKeepaliveSettingsTransmitInterval.IsNull() && data.PuntKeepaliveSettingsTransmitInterval.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-platform:punt-keepalive/settings/transmit-interval")
+ }
+ if !state.PuntKeepaliveSettingsWarningCount.IsNull() && data.PuntKeepaliveSettingsWarningCount.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-platform:punt-keepalive/settings/warning-count")
+ }
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletedItemsXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin getEmptyLeafsDelete
func (data *Platform) getEmptyLeafsDelete(ctx context.Context) []string {
@@ -235,3 +367,25 @@ func (data *Platform) getDeletePaths(ctx context.Context) []string {
}
// End of section. //template:end getDeletePaths
+
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletePathsXML
+
+func (data *Platform) addDeletePathsXML(ctx context.Context, body string) string {
+ b := netconf.NewBody(body)
+ if !data.PuntKeepaliveDisableKernelCore.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-platform:punt-keepalive/disable-kernel-core")
+ }
+ if !data.PuntKeepaliveSettingsFatalCount.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-platform:punt-keepalive/settings/fatal-count")
+ }
+ if !data.PuntKeepaliveSettingsTransmitInterval.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-platform:punt-keepalive/settings/transmit-interval")
+ }
+ if !data.PuntKeepaliveSettingsWarningCount.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-platform:punt-keepalive/settings/warning-count")
+ }
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletePathsXML
diff --git a/internal/provider/model_iosxe_policy_map.go b/internal/provider/model_iosxe_policy_map.go
index a00e6a13..097c3f83 100644
--- a/internal/provider/model_iosxe_policy_map.go
+++ b/internal/provider/model_iosxe_policy_map.go
@@ -31,6 +31,9 @@ import (
"github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/types"
+ "github.com/hashicorp/terraform-plugin-log/tflog"
+ "github.com/netascode/go-netconf"
+ "github.com/netascode/xmldot"
"github.com/tidwall/gjson"
"github.com/tidwall/sjson"
)
@@ -108,6 +111,19 @@ func (data PolicyMap) getPathShort() string {
return matches[1]
}
+// getXPath returns the XPath for NETCONF operations
+func (data PolicyMap) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/policy/Cisco-IOS-XE-policy:policy-map[name=%v]"
+ path = fmt.Sprintf(path, fmt.Sprintf("%v", data.Name.ValueString()))
+ return path
+}
+
+func (data PolicyMapData) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/policy/Cisco-IOS-XE-policy:policy-map[name=%v]"
+ path = fmt.Sprintf(path, fmt.Sprintf("%v", data.Name.ValueString()))
+ return path
+}
+
// End of section. //template:end getPath
// Section below is generated&owned by "gen/generator.go". //template:begin toBody
@@ -215,6 +231,125 @@ func (data PolicyMap) toBody(ctx context.Context) string {
// End of section. //template:end toBody
+// Section below is generated&owned by "gen/generator.go". //template:begin toBodyXML
+
+func (data PolicyMap) toBodyXML(ctx context.Context) string {
+ body := netconf.Body{}
+ if !data.Name.IsNull() && !data.Name.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/name", data.Name.ValueString())
+ }
+ if !data.Type.IsNull() && !data.Type.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/type", data.Type.ValueString())
+ }
+ if !data.Subscriber.IsNull() && !data.Subscriber.IsUnknown() {
+ if data.Subscriber.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/subscriber", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/subscriber")
+ }
+ }
+ if !data.Description.IsNull() && !data.Description.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/description", data.Description.ValueString())
+ }
+ if len(data.Classes) > 0 {
+ for _, item := range data.Classes {
+ cBody := netconf.Body{}
+ if !item.Name.IsNull() && !item.Name.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "name", item.Name.ValueString())
+ }
+ if len(item.Actions) > 0 {
+ for _, citem := range item.Actions {
+ ccBody := netconf.Body{}
+ if !citem.Type.IsNull() && !citem.Type.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "action-type", citem.Type.ValueString())
+ }
+ if !citem.BandwidthBits.IsNull() && !citem.BandwidthBits.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "bandwidth/bits", strconv.FormatInt(citem.BandwidthBits.ValueInt64(), 10))
+ }
+ if !citem.BandwidthPercent.IsNull() && !citem.BandwidthPercent.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "bandwidth/percent", strconv.FormatInt(citem.BandwidthPercent.ValueInt64(), 10))
+ }
+ if !citem.BandwidthRemainingOption.IsNull() && !citem.BandwidthRemainingOption.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "bandwidth/remaining/rem-option", citem.BandwidthRemainingOption.ValueString())
+ }
+ if !citem.BandwidthRemainingPercent.IsNull() && !citem.BandwidthRemainingPercent.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "bandwidth/remaining/percent", strconv.FormatInt(citem.BandwidthRemainingPercent.ValueInt64(), 10))
+ }
+ if !citem.BandwidthRemainingRatio.IsNull() && !citem.BandwidthRemainingRatio.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "bandwidth/remaining/ratio", strconv.FormatInt(citem.BandwidthRemainingRatio.ValueInt64(), 10))
+ }
+ if !citem.PriorityLevel.IsNull() && !citem.PriorityLevel.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "priority/level", strconv.FormatInt(citem.PriorityLevel.ValueInt64(), 10))
+ }
+ if !citem.PriorityBurst.IsNull() && !citem.PriorityBurst.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "priority/burst", strconv.FormatInt(citem.PriorityBurst.ValueInt64(), 10))
+ }
+ if !citem.QueueLimit.IsNull() && !citem.QueueLimit.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "queue-limit/queue-limit-value", strconv.FormatInt(citem.QueueLimit.ValueInt64(), 10))
+ }
+ if !citem.QueueLimitType.IsNull() && !citem.QueueLimitType.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "queue-limit/queue-limit-type", citem.QueueLimitType.ValueString())
+ }
+ if !citem.ShapeAverageBitRate.IsNull() && !citem.ShapeAverageBitRate.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "shape/average/bit-rate", strconv.FormatInt(citem.ShapeAverageBitRate.ValueInt64(), 10))
+ }
+ if !citem.ShapeAverageBitsPerIntervalSustained.IsNull() && !citem.ShapeAverageBitsPerIntervalSustained.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "shape/average/bits-per-interval-sustained", strconv.FormatInt(citem.ShapeAverageBitsPerIntervalSustained.ValueInt64(), 10))
+ }
+ if !citem.ShapeAverageBitsPerIntervalExcess.IsNull() && !citem.ShapeAverageBitsPerIntervalExcess.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "shape/average/bits-per-interval-excess", strconv.FormatInt(citem.ShapeAverageBitsPerIntervalExcess.ValueInt64(), 10))
+ }
+ if !citem.ShapeAveragePercent.IsNull() && !citem.ShapeAveragePercent.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "shape/average/percent", strconv.FormatInt(citem.ShapeAveragePercent.ValueInt64(), 10))
+ }
+ if !citem.ShapeAverageBurstSizeSustained.IsNull() && !citem.ShapeAverageBurstSizeSustained.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "shape/average/burst-size-sustained", strconv.FormatInt(citem.ShapeAverageBurstSizeSustained.ValueInt64(), 10))
+ }
+ if !citem.ShapeAverageMs.IsNull() && !citem.ShapeAverageMs.IsUnknown() {
+ if citem.ShapeAverageMs.ValueBool() {
+ ccBody = helpers.SetFromXPath(ccBody, "shape/average/ms", "")
+ } else {
+ ccBody = helpers.RemoveFromXPath(ccBody, "shape/average/ms")
+ }
+ }
+ if !citem.PoliceTargetBitrateConformTransmit.IsNull() && !citem.PoliceTargetBitrateConformTransmit.IsUnknown() {
+ if citem.PoliceTargetBitrateConformTransmit.ValueBool() {
+ ccBody = helpers.SetFromXPath(ccBody, "police-target-bitrate/police/actions/conform-transmit/conform-action/transmit", "")
+ } else {
+ ccBody = helpers.RemoveFromXPath(ccBody, "police-target-bitrate/police/actions/conform-transmit/conform-action/transmit")
+ }
+ }
+ if !citem.PoliceTargetBitrateExceedTransmit.IsNull() && !citem.PoliceTargetBitrateExceedTransmit.IsUnknown() {
+ if citem.PoliceTargetBitrateExceedTransmit.ValueBool() {
+ ccBody = helpers.SetFromXPath(ccBody, "police-target-bitrate/police/actions/exceed-transmit/exceed-action/transmit", "")
+ } else {
+ ccBody = helpers.RemoveFromXPath(ccBody, "police-target-bitrate/police/actions/exceed-transmit/exceed-action/transmit")
+ }
+ }
+ if !citem.PoliceTargetBitrate.IsNull() && !citem.PoliceTargetBitrate.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "police-target-bitrate/police/bit-rate", strconv.FormatInt(citem.PoliceTargetBitrate.ValueInt64(), 10))
+ }
+ if !citem.PoliceTargetBitrateConformBurstByte.IsNull() && !citem.PoliceTargetBitrateConformBurstByte.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "police-target-bitrate/police/confirm_burst-byte", strconv.FormatInt(citem.PoliceTargetBitrateConformBurstByte.ValueInt64(), 10))
+ }
+ if !citem.PoliceTargetBitrateExcessBurstByte.IsNull() && !citem.PoliceTargetBitrateExcessBurstByte.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "police-target-bitrate/police/excess_burst-byte", strconv.FormatInt(citem.PoliceTargetBitrateExcessBurstByte.ValueInt64(), 10))
+ }
+ cBody = helpers.SetRawFromXPath(cBody, "action-list", ccBody.Res())
+ }
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/class", cBody.Res())
+ }
+ }
+ bodyString, err := body.String()
+ if err != nil {
+ tflog.Error(ctx, fmt.Sprintf("Error converting body to string: %s", err))
+ }
+ return bodyString
+}
+
+// End of section. //template:end toBodyXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBody
func (data *PolicyMap) updateFromBody(ctx context.Context, res gjson.Result) {
@@ -420,6 +555,207 @@ func (data *PolicyMap) updateFromBody(ctx context.Context, res gjson.Result) {
// End of section. //template:end updateFromBody
+// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBodyXML
+
+func (data *PolicyMap) updateFromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/name"); value.Exists() && !data.Name.IsNull() {
+ data.Name = types.StringValue(value.String())
+ } else {
+ data.Name = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/type"); value.Exists() && !data.Type.IsNull() {
+ data.Type = types.StringValue(value.String())
+ } else {
+ data.Type = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/subscriber"); !data.Subscriber.IsNull() {
+ if value.Exists() {
+ data.Subscriber = types.BoolValue(true)
+ } else {
+ data.Subscriber = types.BoolValue(false)
+ }
+ } else {
+ data.Subscriber = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/description"); value.Exists() && !data.Description.IsNull() {
+ data.Description = types.StringValue(value.String())
+ } else {
+ data.Description = types.StringNull()
+ }
+ for i := range data.Classes {
+ keys := [...]string{"name"}
+ keyValues := [...]string{data.Classes[i].Name.ValueString()}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/class").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, "name"); value.Exists() && !data.Classes[i].Name.IsNull() {
+ data.Classes[i].Name = types.StringValue(value.String())
+ } else {
+ data.Classes[i].Name = types.StringNull()
+ }
+ for ci := range data.Classes[i].Actions {
+ keys := [...]string{"action-type"}
+ keyValues := [...]string{data.Classes[i].Actions[ci].Type.ValueString()}
+
+ var cr xmldot.Result
+ helpers.GetFromXPath(r, "action-list").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ cr = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(cr, "action-type"); value.Exists() && !data.Classes[i].Actions[ci].Type.IsNull() {
+ data.Classes[i].Actions[ci].Type = types.StringValue(value.String())
+ } else {
+ data.Classes[i].Actions[ci].Type = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(cr, "bandwidth/bits"); value.Exists() && !data.Classes[i].Actions[ci].BandwidthBits.IsNull() {
+ data.Classes[i].Actions[ci].BandwidthBits = types.Int64Value(value.Int())
+ } else {
+ data.Classes[i].Actions[ci].BandwidthBits = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(cr, "bandwidth/percent"); value.Exists() && !data.Classes[i].Actions[ci].BandwidthPercent.IsNull() {
+ data.Classes[i].Actions[ci].BandwidthPercent = types.Int64Value(value.Int())
+ } else {
+ data.Classes[i].Actions[ci].BandwidthPercent = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(cr, "bandwidth/remaining/rem-option"); value.Exists() && !data.Classes[i].Actions[ci].BandwidthRemainingOption.IsNull() {
+ data.Classes[i].Actions[ci].BandwidthRemainingOption = types.StringValue(value.String())
+ } else {
+ data.Classes[i].Actions[ci].BandwidthRemainingOption = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(cr, "bandwidth/remaining/percent"); value.Exists() && !data.Classes[i].Actions[ci].BandwidthRemainingPercent.IsNull() {
+ data.Classes[i].Actions[ci].BandwidthRemainingPercent = types.Int64Value(value.Int())
+ } else {
+ data.Classes[i].Actions[ci].BandwidthRemainingPercent = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(cr, "bandwidth/remaining/ratio"); value.Exists() && !data.Classes[i].Actions[ci].BandwidthRemainingRatio.IsNull() {
+ data.Classes[i].Actions[ci].BandwidthRemainingRatio = types.Int64Value(value.Int())
+ } else {
+ data.Classes[i].Actions[ci].BandwidthRemainingRatio = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(cr, "priority/level"); value.Exists() && !data.Classes[i].Actions[ci].PriorityLevel.IsNull() {
+ data.Classes[i].Actions[ci].PriorityLevel = types.Int64Value(value.Int())
+ } else {
+ data.Classes[i].Actions[ci].PriorityLevel = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(cr, "priority/burst"); value.Exists() && !data.Classes[i].Actions[ci].PriorityBurst.IsNull() {
+ data.Classes[i].Actions[ci].PriorityBurst = types.Int64Value(value.Int())
+ } else {
+ data.Classes[i].Actions[ci].PriorityBurst = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(cr, "queue-limit/queue-limit-value"); value.Exists() && !data.Classes[i].Actions[ci].QueueLimit.IsNull() {
+ data.Classes[i].Actions[ci].QueueLimit = types.Int64Value(value.Int())
+ } else {
+ data.Classes[i].Actions[ci].QueueLimit = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(cr, "queue-limit/queue-limit-type"); value.Exists() && !data.Classes[i].Actions[ci].QueueLimitType.IsNull() {
+ data.Classes[i].Actions[ci].QueueLimitType = types.StringValue(value.String())
+ } else {
+ data.Classes[i].Actions[ci].QueueLimitType = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(cr, "shape/average/bit-rate"); value.Exists() && !data.Classes[i].Actions[ci].ShapeAverageBitRate.IsNull() {
+ data.Classes[i].Actions[ci].ShapeAverageBitRate = types.Int64Value(value.Int())
+ } else {
+ data.Classes[i].Actions[ci].ShapeAverageBitRate = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(cr, "shape/average/bits-per-interval-sustained"); value.Exists() && !data.Classes[i].Actions[ci].ShapeAverageBitsPerIntervalSustained.IsNull() {
+ data.Classes[i].Actions[ci].ShapeAverageBitsPerIntervalSustained = types.Int64Value(value.Int())
+ } else {
+ data.Classes[i].Actions[ci].ShapeAverageBitsPerIntervalSustained = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(cr, "shape/average/bits-per-interval-excess"); value.Exists() && !data.Classes[i].Actions[ci].ShapeAverageBitsPerIntervalExcess.IsNull() {
+ data.Classes[i].Actions[ci].ShapeAverageBitsPerIntervalExcess = types.Int64Value(value.Int())
+ } else {
+ data.Classes[i].Actions[ci].ShapeAverageBitsPerIntervalExcess = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(cr, "shape/average/percent"); value.Exists() && !data.Classes[i].Actions[ci].ShapeAveragePercent.IsNull() {
+ data.Classes[i].Actions[ci].ShapeAveragePercent = types.Int64Value(value.Int())
+ } else {
+ data.Classes[i].Actions[ci].ShapeAveragePercent = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(cr, "shape/average/burst-size-sustained"); value.Exists() && !data.Classes[i].Actions[ci].ShapeAverageBurstSizeSustained.IsNull() {
+ data.Classes[i].Actions[ci].ShapeAverageBurstSizeSustained = types.Int64Value(value.Int())
+ } else {
+ data.Classes[i].Actions[ci].ShapeAverageBurstSizeSustained = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(cr, "shape/average/ms"); !data.Classes[i].Actions[ci].ShapeAverageMs.IsNull() {
+ if value.Exists() {
+ data.Classes[i].Actions[ci].ShapeAverageMs = types.BoolValue(true)
+ } else {
+ data.Classes[i].Actions[ci].ShapeAverageMs = types.BoolValue(false)
+ }
+ } else {
+ data.Classes[i].Actions[ci].ShapeAverageMs = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(cr, "police-target-bitrate/police/actions/conform-transmit/conform-action/transmit"); !data.Classes[i].Actions[ci].PoliceTargetBitrateConformTransmit.IsNull() {
+ if value.Exists() {
+ data.Classes[i].Actions[ci].PoliceTargetBitrateConformTransmit = types.BoolValue(true)
+ } else {
+ data.Classes[i].Actions[ci].PoliceTargetBitrateConformTransmit = types.BoolValue(false)
+ }
+ } else {
+ data.Classes[i].Actions[ci].PoliceTargetBitrateConformTransmit = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(cr, "police-target-bitrate/police/actions/exceed-transmit/exceed-action/transmit"); !data.Classes[i].Actions[ci].PoliceTargetBitrateExceedTransmit.IsNull() {
+ if value.Exists() {
+ data.Classes[i].Actions[ci].PoliceTargetBitrateExceedTransmit = types.BoolValue(true)
+ } else {
+ data.Classes[i].Actions[ci].PoliceTargetBitrateExceedTransmit = types.BoolValue(false)
+ }
+ } else {
+ data.Classes[i].Actions[ci].PoliceTargetBitrateExceedTransmit = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(cr, "police-target-bitrate/police/bit-rate"); value.Exists() && !data.Classes[i].Actions[ci].PoliceTargetBitrate.IsNull() {
+ data.Classes[i].Actions[ci].PoliceTargetBitrate = types.Int64Value(value.Int())
+ } else {
+ data.Classes[i].Actions[ci].PoliceTargetBitrate = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(cr, "police-target-bitrate/police/confirm_burst-byte"); value.Exists() && !data.Classes[i].Actions[ci].PoliceTargetBitrateConformBurstByte.IsNull() {
+ data.Classes[i].Actions[ci].PoliceTargetBitrateConformBurstByte = types.Int64Value(value.Int())
+ } else {
+ data.Classes[i].Actions[ci].PoliceTargetBitrateConformBurstByte = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(cr, "police-target-bitrate/police/excess_burst-byte"); value.Exists() && !data.Classes[i].Actions[ci].PoliceTargetBitrateExcessBurstByte.IsNull() {
+ data.Classes[i].Actions[ci].PoliceTargetBitrateExcessBurstByte = types.Int64Value(value.Int())
+ } else {
+ data.Classes[i].Actions[ci].PoliceTargetBitrateExcessBurstByte = types.Int64Null()
+ }
+ }
+ }
+}
+
+// End of section. //template:end updateFromBodyXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin fromBody
func (data *PolicyMap) fromBody(ctx context.Context, res gjson.Result) {
@@ -640,6 +976,218 @@ func (data *PolicyMapData) fromBody(ctx context.Context, res gjson.Result) {
// End of section. //template:end fromBodyData
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyXML
+
+func (data *PolicyMap) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/type"); value.Exists() {
+ data.Type = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/subscriber"); value.Exists() {
+ data.Subscriber = types.BoolValue(true)
+ } else {
+ data.Subscriber = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/description"); value.Exists() {
+ data.Description = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/class"); value.Exists() {
+ data.Classes = make([]PolicyMapClasses, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := PolicyMapClasses{}
+ if cValue := helpers.GetFromXPath(v, "name"); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "action-list"); cValue.Exists() {
+ item.Actions = make([]PolicyMapClassesActions, 0)
+ cValue.ForEach(func(_ int, cv xmldot.Result) bool {
+ cItem := PolicyMapClassesActions{}
+ if ccValue := helpers.GetFromXPath(cv, "action-type"); ccValue.Exists() {
+ cItem.Type = types.StringValue(ccValue.String())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "bandwidth/bits"); ccValue.Exists() {
+ cItem.BandwidthBits = types.Int64Value(ccValue.Int())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "bandwidth/percent"); ccValue.Exists() {
+ cItem.BandwidthPercent = types.Int64Value(ccValue.Int())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "bandwidth/remaining/rem-option"); ccValue.Exists() {
+ cItem.BandwidthRemainingOption = types.StringValue(ccValue.String())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "bandwidth/remaining/percent"); ccValue.Exists() {
+ cItem.BandwidthRemainingPercent = types.Int64Value(ccValue.Int())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "bandwidth/remaining/ratio"); ccValue.Exists() {
+ cItem.BandwidthRemainingRatio = types.Int64Value(ccValue.Int())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "priority/level"); ccValue.Exists() {
+ cItem.PriorityLevel = types.Int64Value(ccValue.Int())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "priority/burst"); ccValue.Exists() {
+ cItem.PriorityBurst = types.Int64Value(ccValue.Int())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "queue-limit/queue-limit-value"); ccValue.Exists() {
+ cItem.QueueLimit = types.Int64Value(ccValue.Int())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "queue-limit/queue-limit-type"); ccValue.Exists() {
+ cItem.QueueLimitType = types.StringValue(ccValue.String())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "shape/average/bit-rate"); ccValue.Exists() {
+ cItem.ShapeAverageBitRate = types.Int64Value(ccValue.Int())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "shape/average/bits-per-interval-sustained"); ccValue.Exists() {
+ cItem.ShapeAverageBitsPerIntervalSustained = types.Int64Value(ccValue.Int())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "shape/average/bits-per-interval-excess"); ccValue.Exists() {
+ cItem.ShapeAverageBitsPerIntervalExcess = types.Int64Value(ccValue.Int())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "shape/average/percent"); ccValue.Exists() {
+ cItem.ShapeAveragePercent = types.Int64Value(ccValue.Int())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "shape/average/burst-size-sustained"); ccValue.Exists() {
+ cItem.ShapeAverageBurstSizeSustained = types.Int64Value(ccValue.Int())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "shape/average/ms"); ccValue.Exists() {
+ cItem.ShapeAverageMs = types.BoolValue(true)
+ } else {
+ cItem.ShapeAverageMs = types.BoolValue(false)
+ }
+ if ccValue := helpers.GetFromXPath(cv, "police-target-bitrate/police/actions/conform-transmit/conform-action/transmit"); ccValue.Exists() {
+ cItem.PoliceTargetBitrateConformTransmit = types.BoolValue(true)
+ } else {
+ cItem.PoliceTargetBitrateConformTransmit = types.BoolValue(false)
+ }
+ if ccValue := helpers.GetFromXPath(cv, "police-target-bitrate/police/actions/exceed-transmit/exceed-action/transmit"); ccValue.Exists() {
+ cItem.PoliceTargetBitrateExceedTransmit = types.BoolValue(true)
+ } else {
+ cItem.PoliceTargetBitrateExceedTransmit = types.BoolValue(false)
+ }
+ if ccValue := helpers.GetFromXPath(cv, "police-target-bitrate/police/bit-rate"); ccValue.Exists() {
+ cItem.PoliceTargetBitrate = types.Int64Value(ccValue.Int())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "police-target-bitrate/police/confirm_burst-byte"); ccValue.Exists() {
+ cItem.PoliceTargetBitrateConformBurstByte = types.Int64Value(ccValue.Int())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "police-target-bitrate/police/excess_burst-byte"); ccValue.Exists() {
+ cItem.PoliceTargetBitrateExcessBurstByte = types.Int64Value(ccValue.Int())
+ }
+ item.Actions = append(item.Actions, cItem)
+ return true
+ })
+ }
+ data.Classes = append(data.Classes, item)
+ return true
+ })
+ }
+}
+
+// End of section. //template:end fromBodyXML
+
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyDataXML
+
+func (data *PolicyMapData) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/type"); value.Exists() {
+ data.Type = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/subscriber"); value.Exists() {
+ data.Subscriber = types.BoolValue(true)
+ } else {
+ data.Subscriber = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/description"); value.Exists() {
+ data.Description = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/class"); value.Exists() {
+ data.Classes = make([]PolicyMapClasses, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := PolicyMapClasses{}
+ if cValue := helpers.GetFromXPath(v, "name"); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "action-list"); cValue.Exists() {
+ item.Actions = make([]PolicyMapClassesActions, 0)
+ cValue.ForEach(func(_ int, cv xmldot.Result) bool {
+ cItem := PolicyMapClassesActions{}
+ if ccValue := helpers.GetFromXPath(cv, "action-type"); ccValue.Exists() {
+ cItem.Type = types.StringValue(ccValue.String())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "bandwidth/bits"); ccValue.Exists() {
+ cItem.BandwidthBits = types.Int64Value(ccValue.Int())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "bandwidth/percent"); ccValue.Exists() {
+ cItem.BandwidthPercent = types.Int64Value(ccValue.Int())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "bandwidth/remaining/rem-option"); ccValue.Exists() {
+ cItem.BandwidthRemainingOption = types.StringValue(ccValue.String())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "bandwidth/remaining/percent"); ccValue.Exists() {
+ cItem.BandwidthRemainingPercent = types.Int64Value(ccValue.Int())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "bandwidth/remaining/ratio"); ccValue.Exists() {
+ cItem.BandwidthRemainingRatio = types.Int64Value(ccValue.Int())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "priority/level"); ccValue.Exists() {
+ cItem.PriorityLevel = types.Int64Value(ccValue.Int())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "priority/burst"); ccValue.Exists() {
+ cItem.PriorityBurst = types.Int64Value(ccValue.Int())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "queue-limit/queue-limit-value"); ccValue.Exists() {
+ cItem.QueueLimit = types.Int64Value(ccValue.Int())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "queue-limit/queue-limit-type"); ccValue.Exists() {
+ cItem.QueueLimitType = types.StringValue(ccValue.String())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "shape/average/bit-rate"); ccValue.Exists() {
+ cItem.ShapeAverageBitRate = types.Int64Value(ccValue.Int())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "shape/average/bits-per-interval-sustained"); ccValue.Exists() {
+ cItem.ShapeAverageBitsPerIntervalSustained = types.Int64Value(ccValue.Int())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "shape/average/bits-per-interval-excess"); ccValue.Exists() {
+ cItem.ShapeAverageBitsPerIntervalExcess = types.Int64Value(ccValue.Int())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "shape/average/percent"); ccValue.Exists() {
+ cItem.ShapeAveragePercent = types.Int64Value(ccValue.Int())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "shape/average/burst-size-sustained"); ccValue.Exists() {
+ cItem.ShapeAverageBurstSizeSustained = types.Int64Value(ccValue.Int())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "shape/average/ms"); ccValue.Exists() {
+ cItem.ShapeAverageMs = types.BoolValue(true)
+ } else {
+ cItem.ShapeAverageMs = types.BoolValue(false)
+ }
+ if ccValue := helpers.GetFromXPath(cv, "police-target-bitrate/police/actions/conform-transmit/conform-action/transmit"); ccValue.Exists() {
+ cItem.PoliceTargetBitrateConformTransmit = types.BoolValue(true)
+ } else {
+ cItem.PoliceTargetBitrateConformTransmit = types.BoolValue(false)
+ }
+ if ccValue := helpers.GetFromXPath(cv, "police-target-bitrate/police/actions/exceed-transmit/exceed-action/transmit"); ccValue.Exists() {
+ cItem.PoliceTargetBitrateExceedTransmit = types.BoolValue(true)
+ } else {
+ cItem.PoliceTargetBitrateExceedTransmit = types.BoolValue(false)
+ }
+ if ccValue := helpers.GetFromXPath(cv, "police-target-bitrate/police/bit-rate"); ccValue.Exists() {
+ cItem.PoliceTargetBitrate = types.Int64Value(ccValue.Int())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "police-target-bitrate/police/confirm_burst-byte"); ccValue.Exists() {
+ cItem.PoliceTargetBitrateConformBurstByte = types.Int64Value(ccValue.Int())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "police-target-bitrate/police/excess_burst-byte"); ccValue.Exists() {
+ cItem.PoliceTargetBitrateExcessBurstByte = types.Int64Value(ccValue.Int())
+ }
+ item.Actions = append(item.Actions, cItem)
+ return true
+ })
+ }
+ data.Classes = append(data.Classes, item)
+ return true
+ })
+ }
+}
+
+// End of section. //template:end fromBodyDataXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin getDeletedItems
func (data *PolicyMap) getDeletedItems(ctx context.Context, state PolicyMap) []string {
@@ -769,6 +1317,145 @@ func (data *PolicyMap) getDeletedItems(ctx context.Context, state PolicyMap) []s
// End of section. //template:end getDeletedItems
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletedItemsXML
+
+func (data *PolicyMap) addDeletedItemsXML(ctx context.Context, state PolicyMap, body string) string {
+ b := netconf.NewBody(body)
+ if !state.Type.IsNull() && data.Type.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/type")
+ }
+ if !state.Subscriber.IsNull() && data.Subscriber.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/subscriber")
+ }
+ if !state.Description.IsNull() && data.Description.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/description")
+ }
+ for i := range state.Classes {
+ stateKeys := [...]string{"name"}
+ stateKeyValues := [...]string{state.Classes[i].Name.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.Classes[i].Name.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.Classes {
+ found = true
+ if state.Classes[i].Name.ValueString() != data.Classes[j].Name.ValueString() {
+ found = false
+ }
+ if found {
+ for ci := range state.Classes[i].Actions {
+ cstateKeys := [...]string{"action-type"}
+ cstateKeyValues := [...]string{state.Classes[i].Actions[ci].Type.ValueString()}
+ cpredicates := ""
+ for i := range cstateKeys {
+ cpredicates += fmt.Sprintf("[%s='%s']", cstateKeys[i], cstateKeyValues[i])
+ }
+
+ cemptyKeys := true
+ if !reflect.ValueOf(state.Classes[i].Actions[ci].Type.ValueString()).IsZero() {
+ cemptyKeys = false
+ }
+ if cemptyKeys {
+ continue
+ }
+
+ found := false
+ for cj := range data.Classes[j].Actions {
+ found = true
+ if state.Classes[i].Actions[ci].Type.ValueString() != data.Classes[j].Actions[cj].Type.ValueString() {
+ found = false
+ }
+ if found {
+ if !state.Classes[i].Actions[ci].BandwidthBits.IsNull() && data.Classes[j].Actions[cj].BandwidthBits.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/class%v/action-list%v/bandwidth/bits", predicates, cpredicates))
+ }
+ if !state.Classes[i].Actions[ci].BandwidthPercent.IsNull() && data.Classes[j].Actions[cj].BandwidthPercent.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/class%v/action-list%v/bandwidth/percent", predicates, cpredicates))
+ }
+ if !state.Classes[i].Actions[ci].BandwidthRemainingOption.IsNull() && data.Classes[j].Actions[cj].BandwidthRemainingOption.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/class%v/action-list%v/bandwidth/remaining/rem-option", predicates, cpredicates))
+ }
+ if !state.Classes[i].Actions[ci].BandwidthRemainingPercent.IsNull() && data.Classes[j].Actions[cj].BandwidthRemainingPercent.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/class%v/action-list%v/bandwidth/remaining/percent", predicates, cpredicates))
+ }
+ if !state.Classes[i].Actions[ci].BandwidthRemainingRatio.IsNull() && data.Classes[j].Actions[cj].BandwidthRemainingRatio.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/class%v/action-list%v/bandwidth/remaining/ratio", predicates, cpredicates))
+ }
+ if !state.Classes[i].Actions[ci].PriorityLevel.IsNull() && data.Classes[j].Actions[cj].PriorityLevel.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/class%v/action-list%v/priority/level", predicates, cpredicates))
+ }
+ if !state.Classes[i].Actions[ci].PriorityBurst.IsNull() && data.Classes[j].Actions[cj].PriorityBurst.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/class%v/action-list%v/priority/burst", predicates, cpredicates))
+ }
+ if !state.Classes[i].Actions[ci].QueueLimit.IsNull() && data.Classes[j].Actions[cj].QueueLimit.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/class%v/action-list%v/queue-limit/queue-limit-value", predicates, cpredicates))
+ }
+ if !state.Classes[i].Actions[ci].QueueLimitType.IsNull() && data.Classes[j].Actions[cj].QueueLimitType.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/class%v/action-list%v/queue-limit/queue-limit-type", predicates, cpredicates))
+ }
+ if !state.Classes[i].Actions[ci].ShapeAverageBitRate.IsNull() && data.Classes[j].Actions[cj].ShapeAverageBitRate.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/class%v/action-list%v/shape/average/bit-rate", predicates, cpredicates))
+ }
+ if !state.Classes[i].Actions[ci].ShapeAverageBitsPerIntervalSustained.IsNull() && data.Classes[j].Actions[cj].ShapeAverageBitsPerIntervalSustained.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/class%v/action-list%v/shape/average/bits-per-interval-sustained", predicates, cpredicates))
+ }
+ if !state.Classes[i].Actions[ci].ShapeAverageBitsPerIntervalExcess.IsNull() && data.Classes[j].Actions[cj].ShapeAverageBitsPerIntervalExcess.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/class%v/action-list%v/shape/average/bits-per-interval-excess", predicates, cpredicates))
+ }
+ if !state.Classes[i].Actions[ci].ShapeAveragePercent.IsNull() && data.Classes[j].Actions[cj].ShapeAveragePercent.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/class%v/action-list%v/shape/average/percent", predicates, cpredicates))
+ }
+ if !state.Classes[i].Actions[ci].ShapeAverageBurstSizeSustained.IsNull() && data.Classes[j].Actions[cj].ShapeAverageBurstSizeSustained.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/class%v/action-list%v/shape/average/burst-size-sustained", predicates, cpredicates))
+ }
+ if !state.Classes[i].Actions[ci].ShapeAverageMs.IsNull() && data.Classes[j].Actions[cj].ShapeAverageMs.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/class%v/action-list%v/shape/average/ms", predicates, cpredicates))
+ }
+ if !state.Classes[i].Actions[ci].PoliceTargetBitrateConformTransmit.IsNull() && data.Classes[j].Actions[cj].PoliceTargetBitrateConformTransmit.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/class%v/action-list%v/police-target-bitrate/police/actions/conform-transmit/conform-action/transmit", predicates, cpredicates))
+ }
+ if !state.Classes[i].Actions[ci].PoliceTargetBitrateExceedTransmit.IsNull() && data.Classes[j].Actions[cj].PoliceTargetBitrateExceedTransmit.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/class%v/action-list%v/police-target-bitrate/police/actions/exceed-transmit/exceed-action/transmit", predicates, cpredicates))
+ }
+ if !state.Classes[i].Actions[ci].PoliceTargetBitrate.IsNull() && data.Classes[j].Actions[cj].PoliceTargetBitrate.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/class%v/action-list%v/police-target-bitrate/police/bit-rate", predicates, cpredicates))
+ }
+ if !state.Classes[i].Actions[ci].PoliceTargetBitrateConformBurstByte.IsNull() && data.Classes[j].Actions[cj].PoliceTargetBitrateConformBurstByte.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/class%v/action-list%v/police-target-bitrate/police/confirm_burst-byte", predicates, cpredicates))
+ }
+ if !state.Classes[i].Actions[ci].PoliceTargetBitrateExcessBurstByte.IsNull() && data.Classes[j].Actions[cj].PoliceTargetBitrateExcessBurstByte.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/class%v/action-list%v/police-target-bitrate/police/excess_burst-byte", predicates, cpredicates))
+ }
+ break
+ }
+ }
+ if !found {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/class%v/action-list%v", predicates, cpredicates))
+ }
+ }
+ break
+ }
+ }
+ if !found {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/class%v", predicates))
+ }
+ }
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletedItemsXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin getEmptyLeafsDelete
func (data *PolicyMap) getEmptyLeafsDelete(ctx context.Context) []string {
@@ -822,3 +1509,32 @@ func (data *PolicyMap) getDeletePaths(ctx context.Context) []string {
}
// End of section. //template:end getDeletePaths
+
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletePathsXML
+
+func (data *PolicyMap) addDeletePathsXML(ctx context.Context, body string) string {
+ b := netconf.NewBody(body)
+ if !data.Type.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/type")
+ }
+ if !data.Subscriber.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/subscriber")
+ }
+ if !data.Description.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/description")
+ }
+ for i := range data.Classes {
+ keys := [...]string{"name"}
+ keyValues := [...]string{data.Classes[i].Name.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/class%v", predicates))
+ }
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletePathsXML
diff --git a/internal/provider/model_iosxe_policy_map_event.go b/internal/provider/model_iosxe_policy_map_event.go
index b09302f7..4cb6afed 100644
--- a/internal/provider/model_iosxe_policy_map_event.go
+++ b/internal/provider/model_iosxe_policy_map_event.go
@@ -31,6 +31,9 @@ import (
"github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/types"
+ "github.com/hashicorp/terraform-plugin-log/tflog"
+ "github.com/netascode/go-netconf"
+ "github.com/netascode/xmldot"
"github.com/tidwall/gjson"
"github.com/tidwall/sjson"
)
@@ -122,6 +125,19 @@ func (data PolicyMapEvent) getPathShort() string {
return matches[1]
}
+// getXPath returns the XPath for NETCONF operations
+func (data PolicyMapEvent) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/policy/Cisco-IOS-XE-policy:policy-map[name=%s]/event[name=%v]"
+ path = fmt.Sprintf(path, fmt.Sprintf("%v", data.Name.ValueString()), fmt.Sprintf("%v", data.EventType.ValueString()))
+ return path
+}
+
+func (data PolicyMapEventData) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/policy/Cisco-IOS-XE-policy:policy-map[name=%s]/event[name=%v]"
+ path = fmt.Sprintf(path, fmt.Sprintf("%v", data.Name.ValueString()), fmt.Sprintf("%v", data.EventType.ValueString()))
+ return path
+}
+
// End of section. //template:end getPath
// Section below is generated&owned by "gen/generator.go". //template:begin toBody
@@ -289,6 +305,203 @@ func (data PolicyMapEvent) toBody(ctx context.Context) string {
// End of section. //template:end toBody
+// Section below is generated&owned by "gen/generator.go". //template:begin toBodyXML
+
+func (data PolicyMapEvent) toBodyXML(ctx context.Context) string {
+ body := netconf.Body{}
+ if !data.EventType.IsNull() && !data.EventType.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/event-type", data.EventType.ValueString())
+ }
+ if !data.MatchType.IsNull() && !data.MatchType.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/match-type", data.MatchType.ValueString())
+ }
+ if len(data.ClassNumbers) > 0 {
+ for _, item := range data.ClassNumbers {
+ cBody := netconf.Body{}
+ if !item.Number.IsNull() && !item.Number.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "number", strconv.FormatInt(item.Number.ValueInt64(), 10))
+ }
+ if !item.Class.IsNull() && !item.Class.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "class", item.Class.ValueString())
+ }
+ if !item.ExecutionType.IsNull() && !item.ExecutionType.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "execution-type", item.ExecutionType.ValueString())
+ }
+ if len(item.ActionNumbers) > 0 {
+ for _, citem := range item.ActionNumbers {
+ ccBody := netconf.Body{}
+ if !citem.Number.IsNull() && !citem.Number.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "number", strconv.FormatInt(citem.Number.ValueInt64(), 10))
+ }
+ if !citem.PauseReauthentication.IsNull() && !citem.PauseReauthentication.IsUnknown() {
+ if citem.PauseReauthentication.ValueBool() {
+ ccBody = helpers.SetFromXPath(ccBody, "pause/reauthentication", "")
+ } else {
+ ccBody = helpers.RemoveFromXPath(ccBody, "pause/reauthentication")
+ }
+ }
+ if !citem.Authorize.IsNull() && !citem.Authorize.IsUnknown() {
+ if citem.Authorize.ValueBool() {
+ ccBody = helpers.SetFromXPath(ccBody, "authorize", "")
+ } else {
+ ccBody = helpers.RemoveFromXPath(ccBody, "authorize")
+ }
+ }
+ if !citem.TerminateConfig.IsNull() && !citem.TerminateConfig.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "terminate-config", citem.TerminateConfig.ValueString())
+ }
+ if !citem.ActivateServiceTemplateConfigServiceTemplate.IsNull() && !citem.ActivateServiceTemplateConfigServiceTemplate.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "activate/service-template-config/service-template", citem.ActivateServiceTemplateConfigServiceTemplate.ValueString())
+ }
+ if !citem.ActivateServiceTemplateConfigAaaList.IsNull() && !citem.ActivateServiceTemplateConfigAaaList.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "activate/service-template-config/aaa-list", citem.ActivateServiceTemplateConfigAaaList.ValueString())
+ }
+ if !citem.ActivateServiceTemplateConfigPrecedence.IsNull() && !citem.ActivateServiceTemplateConfigPrecedence.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "activate/service-template-config/precedence", strconv.FormatInt(citem.ActivateServiceTemplateConfigPrecedence.ValueInt64(), 10))
+ }
+ if !citem.ActivateServiceTemplateConfigReplaceAll.IsNull() && !citem.ActivateServiceTemplateConfigReplaceAll.IsUnknown() {
+ if citem.ActivateServiceTemplateConfigReplaceAll.ValueBool() {
+ ccBody = helpers.SetFromXPath(ccBody, "activate/service-template-config/replace-all", "")
+ } else {
+ ccBody = helpers.RemoveFromXPath(ccBody, "activate/service-template-config/replace-all")
+ }
+ }
+ if !citem.ActivateInterfaceTemplate.IsNull() && !citem.ActivateInterfaceTemplate.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "activate/interface-template", citem.ActivateInterfaceTemplate.ValueString())
+ }
+ if !citem.ActivatePolicyTypeControlSubscriber.IsNull() && !citem.ActivatePolicyTypeControlSubscriber.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "activate/policy/type/control/subscriber", citem.ActivatePolicyTypeControlSubscriber.ValueString())
+ }
+ if !citem.DeactivateInterfaceTemplate.IsNull() && !citem.DeactivateInterfaceTemplate.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "deactivate/interface-template", citem.DeactivateInterfaceTemplate.ValueString())
+ }
+ if !citem.DeactivateServiceTemplate.IsNull() && !citem.DeactivateServiceTemplate.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "deactivate/service-template", citem.DeactivateServiceTemplate.ValueString())
+ }
+ if !citem.DeactivatePolicyTypeControlSubscriber.IsNull() && !citem.DeactivatePolicyTypeControlSubscriber.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "deactivate/policy/type/control/subscriber", citem.DeactivatePolicyTypeControlSubscriber.ValueString())
+ }
+ if !citem.AuthenticateUsingMethod.IsNull() && !citem.AuthenticateUsingMethod.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "authenticate/using/method", citem.AuthenticateUsingMethod.ValueString())
+ }
+ if !citem.AuthenticateUsingRetries.IsNull() && !citem.AuthenticateUsingRetries.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "authenticate/using/retries", strconv.FormatInt(citem.AuthenticateUsingRetries.ValueInt64(), 10))
+ }
+ if !citem.AuthenticateUsingRetryTime.IsNull() && !citem.AuthenticateUsingRetryTime.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "authenticate/using/retry-time", strconv.FormatInt(citem.AuthenticateUsingRetryTime.ValueInt64(), 10))
+ }
+ if !citem.AuthenticateUsingPriority.IsNull() && !citem.AuthenticateUsingPriority.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "authenticate/using/priority", strconv.FormatInt(citem.AuthenticateUsingPriority.ValueInt64(), 10))
+ }
+ if !citem.AuthenticateUsingAaaAuthcList.IsNull() && !citem.AuthenticateUsingAaaAuthcList.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "authenticate/using/aaa/authc-list", citem.AuthenticateUsingAaaAuthcList.ValueString())
+ }
+ if !citem.AuthenticateUsingAaaAuthzList.IsNull() && !citem.AuthenticateUsingAaaAuthzList.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "authenticate/using/aaa/authz-list", citem.AuthenticateUsingAaaAuthzList.ValueString())
+ }
+ if !citem.AuthenticateUsingBoth.IsNull() && !citem.AuthenticateUsingBoth.IsUnknown() {
+ if citem.AuthenticateUsingBoth.ValueBool() {
+ ccBody = helpers.SetFromXPath(ccBody, "authenticate/using/both", "")
+ } else {
+ ccBody = helpers.RemoveFromXPath(ccBody, "authenticate/using/both")
+ }
+ }
+ if !citem.AuthenticateUsingParameterMap.IsNull() && !citem.AuthenticateUsingParameterMap.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "authenticate/using/parameter-map", citem.AuthenticateUsingParameterMap.ValueString())
+ }
+ if !citem.Replace.IsNull() && !citem.Replace.IsUnknown() {
+ if citem.Replace.ValueBool() {
+ ccBody = helpers.SetFromXPath(ccBody, "replace", "")
+ } else {
+ ccBody = helpers.RemoveFromXPath(ccBody, "replace")
+ }
+ }
+ if !citem.Restrict.IsNull() && !citem.Restrict.IsUnknown() {
+ if citem.Restrict.ValueBool() {
+ ccBody = helpers.SetFromXPath(ccBody, "restrict", "")
+ } else {
+ ccBody = helpers.RemoveFromXPath(ccBody, "restrict")
+ }
+ }
+ if !citem.ClearSession.IsNull() && !citem.ClearSession.IsUnknown() {
+ if citem.ClearSession.ValueBool() {
+ ccBody = helpers.SetFromXPath(ccBody, "clear-session", "")
+ } else {
+ ccBody = helpers.RemoveFromXPath(ccBody, "clear-session")
+ }
+ }
+ if !citem.ClearAuthenticatedDataHostsOnPort.IsNull() && !citem.ClearAuthenticatedDataHostsOnPort.IsUnknown() {
+ if citem.ClearAuthenticatedDataHostsOnPort.ValueBool() {
+ ccBody = helpers.SetFromXPath(ccBody, "clear-authenticated-data-hosts-on-port", "")
+ } else {
+ ccBody = helpers.RemoveFromXPath(ccBody, "clear-authenticated-data-hosts-on-port")
+ }
+ }
+ if !citem.Protect.IsNull() && !citem.Protect.IsUnknown() {
+ if citem.Protect.ValueBool() {
+ ccBody = helpers.SetFromXPath(ccBody, "protect", "")
+ } else {
+ ccBody = helpers.RemoveFromXPath(ccBody, "protect")
+ }
+ }
+ if !citem.ErrDisable.IsNull() && !citem.ErrDisable.IsUnknown() {
+ if citem.ErrDisable.ValueBool() {
+ ccBody = helpers.SetFromXPath(ccBody, "err-disable", "")
+ } else {
+ ccBody = helpers.RemoveFromXPath(ccBody, "err-disable")
+ }
+ }
+ if !citem.ResumeReauthentication.IsNull() && !citem.ResumeReauthentication.IsUnknown() {
+ if citem.ResumeReauthentication.ValueBool() {
+ ccBody = helpers.SetFromXPath(ccBody, "resume/reauthentication", "")
+ } else {
+ ccBody = helpers.RemoveFromXPath(ccBody, "resume/reauthentication")
+ }
+ }
+ if !citem.AuthenticationRestart.IsNull() && !citem.AuthenticationRestart.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "authentication-restart", strconv.FormatInt(citem.AuthenticationRestart.ValueInt64(), 10))
+ }
+ if !citem.SetDomain.IsNull() && !citem.SetDomain.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "set-domain", citem.SetDomain.ValueString())
+ }
+ if !citem.Unauthorize.IsNull() && !citem.Unauthorize.IsUnknown() {
+ if citem.Unauthorize.ValueBool() {
+ ccBody = helpers.SetFromXPath(ccBody, "unauthorize", "")
+ } else {
+ ccBody = helpers.RemoveFromXPath(ccBody, "unauthorize")
+ }
+ }
+ if !citem.Notify.IsNull() && !citem.Notify.IsUnknown() {
+ if citem.Notify.ValueBool() {
+ ccBody = helpers.SetFromXPath(ccBody, "notify", "")
+ } else {
+ ccBody = helpers.RemoveFromXPath(ccBody, "notify")
+ }
+ }
+ if !citem.SetTimerName.IsNull() && !citem.SetTimerName.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "set-timer/name", citem.SetTimerName.ValueString())
+ }
+ if !citem.SetTimerValue.IsNull() && !citem.SetTimerValue.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "set-timer/value", strconv.FormatInt(citem.SetTimerValue.ValueInt64(), 10))
+ }
+ if !citem.MapAttributeToServiceTable.IsNull() && !citem.MapAttributeToServiceTable.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "map/attribute-to-service/table", citem.MapAttributeToServiceTable.ValueString())
+ }
+ cBody = helpers.SetRawFromXPath(cBody, "action-number", ccBody.Res())
+ }
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/class-number", cBody.Res())
+ }
+ }
+ bodyString, err := body.String()
+ if err != nil {
+ tflog.Error(ctx, fmt.Sprintf("Error converting body to string: %s", err))
+ }
+ return bodyString
+}
+
+// End of section. //template:end toBodyXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBody
func (data *PolicyMapEvent) updateFromBody(ctx context.Context, res gjson.Result) {
@@ -594,168 +807,811 @@ func (data *PolicyMapEvent) updateFromBody(ctx context.Context, res gjson.Result
} else {
data.ClassNumbers[i].ActionNumbers[ci].MapAttributeToServiceTable = types.StringNull()
}
- }
+ }
+ }
+}
+
+// End of section. //template:end updateFromBody
+
+// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBodyXML
+
+func (data *PolicyMapEvent) updateFromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/event-type"); value.Exists() && !data.EventType.IsNull() {
+ data.EventType = types.StringValue(value.String())
+ } else {
+ data.EventType = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/match-type"); value.Exists() && !data.MatchType.IsNull() {
+ data.MatchType = types.StringValue(value.String())
+ } else {
+ data.MatchType = types.StringNull()
+ }
+ for i := range data.ClassNumbers {
+ keys := [...]string{"number"}
+ keyValues := [...]string{strconv.FormatInt(data.ClassNumbers[i].Number.ValueInt64(), 10)}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/class-number").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, "number"); value.Exists() && !data.ClassNumbers[i].Number.IsNull() {
+ data.ClassNumbers[i].Number = types.Int64Value(value.Int())
+ } else {
+ data.ClassNumbers[i].Number = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(r, "class"); value.Exists() && !data.ClassNumbers[i].Class.IsNull() {
+ data.ClassNumbers[i].Class = types.StringValue(value.String())
+ } else {
+ data.ClassNumbers[i].Class = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "execution-type"); value.Exists() && !data.ClassNumbers[i].ExecutionType.IsNull() {
+ data.ClassNumbers[i].ExecutionType = types.StringValue(value.String())
+ } else {
+ data.ClassNumbers[i].ExecutionType = types.StringNull()
+ }
+ for ci := range data.ClassNumbers[i].ActionNumbers {
+ keys := [...]string{"number"}
+ keyValues := [...]string{strconv.FormatInt(data.ClassNumbers[i].ActionNumbers[ci].Number.ValueInt64(), 10)}
+
+ var cr xmldot.Result
+ helpers.GetFromXPath(r, "action-number").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ cr = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(cr, "number"); value.Exists() && !data.ClassNumbers[i].ActionNumbers[ci].Number.IsNull() {
+ data.ClassNumbers[i].ActionNumbers[ci].Number = types.Int64Value(value.Int())
+ } else {
+ data.ClassNumbers[i].ActionNumbers[ci].Number = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(cr, "pause/reauthentication"); !data.ClassNumbers[i].ActionNumbers[ci].PauseReauthentication.IsNull() {
+ if value.Exists() {
+ data.ClassNumbers[i].ActionNumbers[ci].PauseReauthentication = types.BoolValue(true)
+ } else {
+ data.ClassNumbers[i].ActionNumbers[ci].PauseReauthentication = types.BoolValue(false)
+ }
+ } else {
+ data.ClassNumbers[i].ActionNumbers[ci].PauseReauthentication = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(cr, "authorize"); !data.ClassNumbers[i].ActionNumbers[ci].Authorize.IsNull() {
+ if value.Exists() {
+ data.ClassNumbers[i].ActionNumbers[ci].Authorize = types.BoolValue(true)
+ } else {
+ data.ClassNumbers[i].ActionNumbers[ci].Authorize = types.BoolValue(false)
+ }
+ } else {
+ data.ClassNumbers[i].ActionNumbers[ci].Authorize = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(cr, "terminate-config"); value.Exists() && !data.ClassNumbers[i].ActionNumbers[ci].TerminateConfig.IsNull() {
+ data.ClassNumbers[i].ActionNumbers[ci].TerminateConfig = types.StringValue(value.String())
+ } else {
+ data.ClassNumbers[i].ActionNumbers[ci].TerminateConfig = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(cr, "activate/service-template-config/service-template"); value.Exists() && !data.ClassNumbers[i].ActionNumbers[ci].ActivateServiceTemplateConfigServiceTemplate.IsNull() {
+ data.ClassNumbers[i].ActionNumbers[ci].ActivateServiceTemplateConfigServiceTemplate = types.StringValue(value.String())
+ } else {
+ data.ClassNumbers[i].ActionNumbers[ci].ActivateServiceTemplateConfigServiceTemplate = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(cr, "activate/service-template-config/aaa-list"); value.Exists() && !data.ClassNumbers[i].ActionNumbers[ci].ActivateServiceTemplateConfigAaaList.IsNull() {
+ data.ClassNumbers[i].ActionNumbers[ci].ActivateServiceTemplateConfigAaaList = types.StringValue(value.String())
+ } else {
+ data.ClassNumbers[i].ActionNumbers[ci].ActivateServiceTemplateConfigAaaList = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(cr, "activate/service-template-config/precedence"); value.Exists() && !data.ClassNumbers[i].ActionNumbers[ci].ActivateServiceTemplateConfigPrecedence.IsNull() {
+ data.ClassNumbers[i].ActionNumbers[ci].ActivateServiceTemplateConfigPrecedence = types.Int64Value(value.Int())
+ } else {
+ data.ClassNumbers[i].ActionNumbers[ci].ActivateServiceTemplateConfigPrecedence = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(cr, "activate/service-template-config/replace-all"); !data.ClassNumbers[i].ActionNumbers[ci].ActivateServiceTemplateConfigReplaceAll.IsNull() {
+ if value.Exists() {
+ data.ClassNumbers[i].ActionNumbers[ci].ActivateServiceTemplateConfigReplaceAll = types.BoolValue(true)
+ } else {
+ data.ClassNumbers[i].ActionNumbers[ci].ActivateServiceTemplateConfigReplaceAll = types.BoolValue(false)
+ }
+ } else {
+ data.ClassNumbers[i].ActionNumbers[ci].ActivateServiceTemplateConfigReplaceAll = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(cr, "activate/interface-template"); value.Exists() && !data.ClassNumbers[i].ActionNumbers[ci].ActivateInterfaceTemplate.IsNull() {
+ data.ClassNumbers[i].ActionNumbers[ci].ActivateInterfaceTemplate = types.StringValue(value.String())
+ } else {
+ data.ClassNumbers[i].ActionNumbers[ci].ActivateInterfaceTemplate = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(cr, "activate/policy/type/control/subscriber"); value.Exists() && !data.ClassNumbers[i].ActionNumbers[ci].ActivatePolicyTypeControlSubscriber.IsNull() {
+ data.ClassNumbers[i].ActionNumbers[ci].ActivatePolicyTypeControlSubscriber = types.StringValue(value.String())
+ } else {
+ data.ClassNumbers[i].ActionNumbers[ci].ActivatePolicyTypeControlSubscriber = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(cr, "deactivate/interface-template"); value.Exists() && !data.ClassNumbers[i].ActionNumbers[ci].DeactivateInterfaceTemplate.IsNull() {
+ data.ClassNumbers[i].ActionNumbers[ci].DeactivateInterfaceTemplate = types.StringValue(value.String())
+ } else {
+ data.ClassNumbers[i].ActionNumbers[ci].DeactivateInterfaceTemplate = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(cr, "deactivate/service-template"); value.Exists() && !data.ClassNumbers[i].ActionNumbers[ci].DeactivateServiceTemplate.IsNull() {
+ data.ClassNumbers[i].ActionNumbers[ci].DeactivateServiceTemplate = types.StringValue(value.String())
+ } else {
+ data.ClassNumbers[i].ActionNumbers[ci].DeactivateServiceTemplate = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(cr, "deactivate/policy/type/control/subscriber"); value.Exists() && !data.ClassNumbers[i].ActionNumbers[ci].DeactivatePolicyTypeControlSubscriber.IsNull() {
+ data.ClassNumbers[i].ActionNumbers[ci].DeactivatePolicyTypeControlSubscriber = types.StringValue(value.String())
+ } else {
+ data.ClassNumbers[i].ActionNumbers[ci].DeactivatePolicyTypeControlSubscriber = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(cr, "authenticate/using/method"); value.Exists() && !data.ClassNumbers[i].ActionNumbers[ci].AuthenticateUsingMethod.IsNull() {
+ data.ClassNumbers[i].ActionNumbers[ci].AuthenticateUsingMethod = types.StringValue(value.String())
+ } else {
+ data.ClassNumbers[i].ActionNumbers[ci].AuthenticateUsingMethod = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(cr, "authenticate/using/retries"); value.Exists() && !data.ClassNumbers[i].ActionNumbers[ci].AuthenticateUsingRetries.IsNull() {
+ data.ClassNumbers[i].ActionNumbers[ci].AuthenticateUsingRetries = types.Int64Value(value.Int())
+ } else {
+ data.ClassNumbers[i].ActionNumbers[ci].AuthenticateUsingRetries = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(cr, "authenticate/using/retry-time"); value.Exists() && !data.ClassNumbers[i].ActionNumbers[ci].AuthenticateUsingRetryTime.IsNull() {
+ data.ClassNumbers[i].ActionNumbers[ci].AuthenticateUsingRetryTime = types.Int64Value(value.Int())
+ } else {
+ data.ClassNumbers[i].ActionNumbers[ci].AuthenticateUsingRetryTime = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(cr, "authenticate/using/priority"); value.Exists() && !data.ClassNumbers[i].ActionNumbers[ci].AuthenticateUsingPriority.IsNull() {
+ data.ClassNumbers[i].ActionNumbers[ci].AuthenticateUsingPriority = types.Int64Value(value.Int())
+ } else {
+ data.ClassNumbers[i].ActionNumbers[ci].AuthenticateUsingPriority = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(cr, "authenticate/using/aaa/authc-list"); value.Exists() && !data.ClassNumbers[i].ActionNumbers[ci].AuthenticateUsingAaaAuthcList.IsNull() {
+ data.ClassNumbers[i].ActionNumbers[ci].AuthenticateUsingAaaAuthcList = types.StringValue(value.String())
+ } else {
+ data.ClassNumbers[i].ActionNumbers[ci].AuthenticateUsingAaaAuthcList = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(cr, "authenticate/using/aaa/authz-list"); value.Exists() && !data.ClassNumbers[i].ActionNumbers[ci].AuthenticateUsingAaaAuthzList.IsNull() {
+ data.ClassNumbers[i].ActionNumbers[ci].AuthenticateUsingAaaAuthzList = types.StringValue(value.String())
+ } else {
+ data.ClassNumbers[i].ActionNumbers[ci].AuthenticateUsingAaaAuthzList = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(cr, "authenticate/using/both"); !data.ClassNumbers[i].ActionNumbers[ci].AuthenticateUsingBoth.IsNull() {
+ if value.Exists() {
+ data.ClassNumbers[i].ActionNumbers[ci].AuthenticateUsingBoth = types.BoolValue(true)
+ } else {
+ data.ClassNumbers[i].ActionNumbers[ci].AuthenticateUsingBoth = types.BoolValue(false)
+ }
+ } else {
+ data.ClassNumbers[i].ActionNumbers[ci].AuthenticateUsingBoth = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(cr, "authenticate/using/parameter-map"); value.Exists() && !data.ClassNumbers[i].ActionNumbers[ci].AuthenticateUsingParameterMap.IsNull() {
+ data.ClassNumbers[i].ActionNumbers[ci].AuthenticateUsingParameterMap = types.StringValue(value.String())
+ } else {
+ data.ClassNumbers[i].ActionNumbers[ci].AuthenticateUsingParameterMap = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(cr, "replace"); !data.ClassNumbers[i].ActionNumbers[ci].Replace.IsNull() {
+ if value.Exists() {
+ data.ClassNumbers[i].ActionNumbers[ci].Replace = types.BoolValue(true)
+ } else {
+ data.ClassNumbers[i].ActionNumbers[ci].Replace = types.BoolValue(false)
+ }
+ } else {
+ data.ClassNumbers[i].ActionNumbers[ci].Replace = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(cr, "restrict"); !data.ClassNumbers[i].ActionNumbers[ci].Restrict.IsNull() {
+ if value.Exists() {
+ data.ClassNumbers[i].ActionNumbers[ci].Restrict = types.BoolValue(true)
+ } else {
+ data.ClassNumbers[i].ActionNumbers[ci].Restrict = types.BoolValue(false)
+ }
+ } else {
+ data.ClassNumbers[i].ActionNumbers[ci].Restrict = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(cr, "clear-session"); !data.ClassNumbers[i].ActionNumbers[ci].ClearSession.IsNull() {
+ if value.Exists() {
+ data.ClassNumbers[i].ActionNumbers[ci].ClearSession = types.BoolValue(true)
+ } else {
+ data.ClassNumbers[i].ActionNumbers[ci].ClearSession = types.BoolValue(false)
+ }
+ } else {
+ data.ClassNumbers[i].ActionNumbers[ci].ClearSession = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(cr, "clear-authenticated-data-hosts-on-port"); !data.ClassNumbers[i].ActionNumbers[ci].ClearAuthenticatedDataHostsOnPort.IsNull() {
+ if value.Exists() {
+ data.ClassNumbers[i].ActionNumbers[ci].ClearAuthenticatedDataHostsOnPort = types.BoolValue(true)
+ } else {
+ data.ClassNumbers[i].ActionNumbers[ci].ClearAuthenticatedDataHostsOnPort = types.BoolValue(false)
+ }
+ } else {
+ data.ClassNumbers[i].ActionNumbers[ci].ClearAuthenticatedDataHostsOnPort = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(cr, "protect"); !data.ClassNumbers[i].ActionNumbers[ci].Protect.IsNull() {
+ if value.Exists() {
+ data.ClassNumbers[i].ActionNumbers[ci].Protect = types.BoolValue(true)
+ } else {
+ data.ClassNumbers[i].ActionNumbers[ci].Protect = types.BoolValue(false)
+ }
+ } else {
+ data.ClassNumbers[i].ActionNumbers[ci].Protect = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(cr, "err-disable"); !data.ClassNumbers[i].ActionNumbers[ci].ErrDisable.IsNull() {
+ if value.Exists() {
+ data.ClassNumbers[i].ActionNumbers[ci].ErrDisable = types.BoolValue(true)
+ } else {
+ data.ClassNumbers[i].ActionNumbers[ci].ErrDisable = types.BoolValue(false)
+ }
+ } else {
+ data.ClassNumbers[i].ActionNumbers[ci].ErrDisable = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(cr, "resume/reauthentication"); !data.ClassNumbers[i].ActionNumbers[ci].ResumeReauthentication.IsNull() {
+ if value.Exists() {
+ data.ClassNumbers[i].ActionNumbers[ci].ResumeReauthentication = types.BoolValue(true)
+ } else {
+ data.ClassNumbers[i].ActionNumbers[ci].ResumeReauthentication = types.BoolValue(false)
+ }
+ } else {
+ data.ClassNumbers[i].ActionNumbers[ci].ResumeReauthentication = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(cr, "authentication-restart"); value.Exists() && !data.ClassNumbers[i].ActionNumbers[ci].AuthenticationRestart.IsNull() {
+ data.ClassNumbers[i].ActionNumbers[ci].AuthenticationRestart = types.Int64Value(value.Int())
+ } else {
+ data.ClassNumbers[i].ActionNumbers[ci].AuthenticationRestart = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(cr, "set-domain"); value.Exists() && !data.ClassNumbers[i].ActionNumbers[ci].SetDomain.IsNull() {
+ data.ClassNumbers[i].ActionNumbers[ci].SetDomain = types.StringValue(value.String())
+ } else {
+ data.ClassNumbers[i].ActionNumbers[ci].SetDomain = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(cr, "unauthorize"); !data.ClassNumbers[i].ActionNumbers[ci].Unauthorize.IsNull() {
+ if value.Exists() {
+ data.ClassNumbers[i].ActionNumbers[ci].Unauthorize = types.BoolValue(true)
+ } else {
+ data.ClassNumbers[i].ActionNumbers[ci].Unauthorize = types.BoolValue(false)
+ }
+ } else {
+ data.ClassNumbers[i].ActionNumbers[ci].Unauthorize = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(cr, "notify"); !data.ClassNumbers[i].ActionNumbers[ci].Notify.IsNull() {
+ if value.Exists() {
+ data.ClassNumbers[i].ActionNumbers[ci].Notify = types.BoolValue(true)
+ } else {
+ data.ClassNumbers[i].ActionNumbers[ci].Notify = types.BoolValue(false)
+ }
+ } else {
+ data.ClassNumbers[i].ActionNumbers[ci].Notify = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(cr, "set-timer/name"); value.Exists() && !data.ClassNumbers[i].ActionNumbers[ci].SetTimerName.IsNull() {
+ data.ClassNumbers[i].ActionNumbers[ci].SetTimerName = types.StringValue(value.String())
+ } else {
+ data.ClassNumbers[i].ActionNumbers[ci].SetTimerName = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(cr, "set-timer/value"); value.Exists() && !data.ClassNumbers[i].ActionNumbers[ci].SetTimerValue.IsNull() {
+ data.ClassNumbers[i].ActionNumbers[ci].SetTimerValue = types.Int64Value(value.Int())
+ } else {
+ data.ClassNumbers[i].ActionNumbers[ci].SetTimerValue = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(cr, "map/attribute-to-service/table"); value.Exists() && !data.ClassNumbers[i].ActionNumbers[ci].MapAttributeToServiceTable.IsNull() {
+ data.ClassNumbers[i].ActionNumbers[ci].MapAttributeToServiceTable = types.StringValue(value.String())
+ } else {
+ data.ClassNumbers[i].ActionNumbers[ci].MapAttributeToServiceTable = types.StringNull()
+ }
+ }
+ }
+}
+
+// End of section. //template:end updateFromBodyXML
+
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBody
+
+func (data *PolicyMapEvent) fromBody(ctx context.Context, res gjson.Result) {
+ prefix := helpers.LastElement(data.getPath()) + "."
+ if res.Get(helpers.LastElement(data.getPath())).IsArray() {
+ prefix += "0."
+ }
+ if value := res.Get(prefix + "match-type"); value.Exists() {
+ data.MatchType = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "class-number"); value.Exists() {
+ data.ClassNumbers = make([]PolicyMapEventClassNumbers, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := PolicyMapEventClassNumbers{}
+ if cValue := v.Get("number"); cValue.Exists() {
+ item.Number = types.Int64Value(cValue.Int())
+ }
+ if cValue := v.Get("class"); cValue.Exists() {
+ item.Class = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("execution-type"); cValue.Exists() {
+ item.ExecutionType = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("action-number"); cValue.Exists() {
+ item.ActionNumbers = make([]PolicyMapEventClassNumbersActionNumbers, 0)
+ cValue.ForEach(func(ck, cv gjson.Result) bool {
+ cItem := PolicyMapEventClassNumbersActionNumbers{}
+ if ccValue := cv.Get("number"); ccValue.Exists() {
+ cItem.Number = types.Int64Value(ccValue.Int())
+ }
+ if ccValue := cv.Get("pause.reauthentication"); ccValue.Exists() {
+ cItem.PauseReauthentication = types.BoolValue(true)
+ } else {
+ cItem.PauseReauthentication = types.BoolValue(false)
+ }
+ if ccValue := cv.Get("authorize"); ccValue.Exists() {
+ cItem.Authorize = types.BoolValue(true)
+ } else {
+ cItem.Authorize = types.BoolValue(false)
+ }
+ if ccValue := cv.Get("terminate-config"); ccValue.Exists() {
+ cItem.TerminateConfig = types.StringValue(ccValue.String())
+ }
+ if ccValue := cv.Get("activate.service-template-config.service-template"); ccValue.Exists() {
+ cItem.ActivateServiceTemplateConfigServiceTemplate = types.StringValue(ccValue.String())
+ }
+ if ccValue := cv.Get("activate.service-template-config.aaa-list"); ccValue.Exists() {
+ cItem.ActivateServiceTemplateConfigAaaList = types.StringValue(ccValue.String())
+ }
+ if ccValue := cv.Get("activate.service-template-config.precedence"); ccValue.Exists() {
+ cItem.ActivateServiceTemplateConfigPrecedence = types.Int64Value(ccValue.Int())
+ }
+ if ccValue := cv.Get("activate.service-template-config.replace-all"); ccValue.Exists() {
+ cItem.ActivateServiceTemplateConfigReplaceAll = types.BoolValue(true)
+ } else {
+ cItem.ActivateServiceTemplateConfigReplaceAll = types.BoolValue(false)
+ }
+ if ccValue := cv.Get("activate.interface-template"); ccValue.Exists() {
+ cItem.ActivateInterfaceTemplate = types.StringValue(ccValue.String())
+ }
+ if ccValue := cv.Get("activate.policy.type.control.subscriber"); ccValue.Exists() {
+ cItem.ActivatePolicyTypeControlSubscriber = types.StringValue(ccValue.String())
+ }
+ if ccValue := cv.Get("deactivate.interface-template"); ccValue.Exists() {
+ cItem.DeactivateInterfaceTemplate = types.StringValue(ccValue.String())
+ }
+ if ccValue := cv.Get("deactivate.service-template"); ccValue.Exists() {
+ cItem.DeactivateServiceTemplate = types.StringValue(ccValue.String())
+ }
+ if ccValue := cv.Get("deactivate.policy.type.control.subscriber"); ccValue.Exists() {
+ cItem.DeactivatePolicyTypeControlSubscriber = types.StringValue(ccValue.String())
+ }
+ if ccValue := cv.Get("authenticate.using.method"); ccValue.Exists() {
+ cItem.AuthenticateUsingMethod = types.StringValue(ccValue.String())
+ }
+ if ccValue := cv.Get("authenticate.using.retries"); ccValue.Exists() {
+ cItem.AuthenticateUsingRetries = types.Int64Value(ccValue.Int())
+ }
+ if ccValue := cv.Get("authenticate.using.retry-time"); ccValue.Exists() {
+ cItem.AuthenticateUsingRetryTime = types.Int64Value(ccValue.Int())
+ }
+ if ccValue := cv.Get("authenticate.using.priority"); ccValue.Exists() {
+ cItem.AuthenticateUsingPriority = types.Int64Value(ccValue.Int())
+ }
+ if ccValue := cv.Get("authenticate.using.aaa.authc-list"); ccValue.Exists() {
+ cItem.AuthenticateUsingAaaAuthcList = types.StringValue(ccValue.String())
+ }
+ if ccValue := cv.Get("authenticate.using.aaa.authz-list"); ccValue.Exists() {
+ cItem.AuthenticateUsingAaaAuthzList = types.StringValue(ccValue.String())
+ }
+ if ccValue := cv.Get("authenticate.using.both"); ccValue.Exists() {
+ cItem.AuthenticateUsingBoth = types.BoolValue(true)
+ } else {
+ cItem.AuthenticateUsingBoth = types.BoolValue(false)
+ }
+ if ccValue := cv.Get("authenticate.using.parameter-map"); ccValue.Exists() {
+ cItem.AuthenticateUsingParameterMap = types.StringValue(ccValue.String())
+ }
+ if ccValue := cv.Get("replace"); ccValue.Exists() {
+ cItem.Replace = types.BoolValue(true)
+ } else {
+ cItem.Replace = types.BoolValue(false)
+ }
+ if ccValue := cv.Get("restrict"); ccValue.Exists() {
+ cItem.Restrict = types.BoolValue(true)
+ } else {
+ cItem.Restrict = types.BoolValue(false)
+ }
+ if ccValue := cv.Get("clear-session"); ccValue.Exists() {
+ cItem.ClearSession = types.BoolValue(true)
+ } else {
+ cItem.ClearSession = types.BoolValue(false)
+ }
+ if ccValue := cv.Get("clear-authenticated-data-hosts-on-port"); ccValue.Exists() {
+ cItem.ClearAuthenticatedDataHostsOnPort = types.BoolValue(true)
+ } else {
+ cItem.ClearAuthenticatedDataHostsOnPort = types.BoolValue(false)
+ }
+ if ccValue := cv.Get("protect"); ccValue.Exists() {
+ cItem.Protect = types.BoolValue(true)
+ } else {
+ cItem.Protect = types.BoolValue(false)
+ }
+ if ccValue := cv.Get("err-disable"); ccValue.Exists() {
+ cItem.ErrDisable = types.BoolValue(true)
+ } else {
+ cItem.ErrDisable = types.BoolValue(false)
+ }
+ if ccValue := cv.Get("resume.reauthentication"); ccValue.Exists() {
+ cItem.ResumeReauthentication = types.BoolValue(true)
+ } else {
+ cItem.ResumeReauthentication = types.BoolValue(false)
+ }
+ if ccValue := cv.Get("authentication-restart"); ccValue.Exists() {
+ cItem.AuthenticationRestart = types.Int64Value(ccValue.Int())
+ }
+ if ccValue := cv.Get("set-domain"); ccValue.Exists() {
+ cItem.SetDomain = types.StringValue(ccValue.String())
+ }
+ if ccValue := cv.Get("unauthorize"); ccValue.Exists() {
+ cItem.Unauthorize = types.BoolValue(true)
+ } else {
+ cItem.Unauthorize = types.BoolValue(false)
+ }
+ if ccValue := cv.Get("notify"); ccValue.Exists() {
+ cItem.Notify = types.BoolValue(true)
+ } else {
+ cItem.Notify = types.BoolValue(false)
+ }
+ if ccValue := cv.Get("set-timer.name"); ccValue.Exists() {
+ cItem.SetTimerName = types.StringValue(ccValue.String())
+ }
+ if ccValue := cv.Get("set-timer.value"); ccValue.Exists() {
+ cItem.SetTimerValue = types.Int64Value(ccValue.Int())
+ }
+ if ccValue := cv.Get("map.attribute-to-service.table"); ccValue.Exists() {
+ cItem.MapAttributeToServiceTable = types.StringValue(ccValue.String())
+ }
+ item.ActionNumbers = append(item.ActionNumbers, cItem)
+ return true
+ })
+ }
+ data.ClassNumbers = append(data.ClassNumbers, item)
+ return true
+ })
+ }
+}
+
+// End of section. //template:end fromBody
+
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyData
+
+func (data *PolicyMapEventData) fromBody(ctx context.Context, res gjson.Result) {
+ prefix := helpers.LastElement(data.getPath()) + "."
+ if res.Get(helpers.LastElement(data.getPath())).IsArray() {
+ prefix += "0."
+ }
+ if value := res.Get(prefix + "match-type"); value.Exists() {
+ data.MatchType = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "class-number"); value.Exists() {
+ data.ClassNumbers = make([]PolicyMapEventClassNumbers, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := PolicyMapEventClassNumbers{}
+ if cValue := v.Get("number"); cValue.Exists() {
+ item.Number = types.Int64Value(cValue.Int())
+ }
+ if cValue := v.Get("class"); cValue.Exists() {
+ item.Class = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("execution-type"); cValue.Exists() {
+ item.ExecutionType = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("action-number"); cValue.Exists() {
+ item.ActionNumbers = make([]PolicyMapEventClassNumbersActionNumbers, 0)
+ cValue.ForEach(func(ck, cv gjson.Result) bool {
+ cItem := PolicyMapEventClassNumbersActionNumbers{}
+ if ccValue := cv.Get("number"); ccValue.Exists() {
+ cItem.Number = types.Int64Value(ccValue.Int())
+ }
+ if ccValue := cv.Get("pause.reauthentication"); ccValue.Exists() {
+ cItem.PauseReauthentication = types.BoolValue(true)
+ } else {
+ cItem.PauseReauthentication = types.BoolValue(false)
+ }
+ if ccValue := cv.Get("authorize"); ccValue.Exists() {
+ cItem.Authorize = types.BoolValue(true)
+ } else {
+ cItem.Authorize = types.BoolValue(false)
+ }
+ if ccValue := cv.Get("terminate-config"); ccValue.Exists() {
+ cItem.TerminateConfig = types.StringValue(ccValue.String())
+ }
+ if ccValue := cv.Get("activate.service-template-config.service-template"); ccValue.Exists() {
+ cItem.ActivateServiceTemplateConfigServiceTemplate = types.StringValue(ccValue.String())
+ }
+ if ccValue := cv.Get("activate.service-template-config.aaa-list"); ccValue.Exists() {
+ cItem.ActivateServiceTemplateConfigAaaList = types.StringValue(ccValue.String())
+ }
+ if ccValue := cv.Get("activate.service-template-config.precedence"); ccValue.Exists() {
+ cItem.ActivateServiceTemplateConfigPrecedence = types.Int64Value(ccValue.Int())
+ }
+ if ccValue := cv.Get("activate.service-template-config.replace-all"); ccValue.Exists() {
+ cItem.ActivateServiceTemplateConfigReplaceAll = types.BoolValue(true)
+ } else {
+ cItem.ActivateServiceTemplateConfigReplaceAll = types.BoolValue(false)
+ }
+ if ccValue := cv.Get("activate.interface-template"); ccValue.Exists() {
+ cItem.ActivateInterfaceTemplate = types.StringValue(ccValue.String())
+ }
+ if ccValue := cv.Get("activate.policy.type.control.subscriber"); ccValue.Exists() {
+ cItem.ActivatePolicyTypeControlSubscriber = types.StringValue(ccValue.String())
+ }
+ if ccValue := cv.Get("deactivate.interface-template"); ccValue.Exists() {
+ cItem.DeactivateInterfaceTemplate = types.StringValue(ccValue.String())
+ }
+ if ccValue := cv.Get("deactivate.service-template"); ccValue.Exists() {
+ cItem.DeactivateServiceTemplate = types.StringValue(ccValue.String())
+ }
+ if ccValue := cv.Get("deactivate.policy.type.control.subscriber"); ccValue.Exists() {
+ cItem.DeactivatePolicyTypeControlSubscriber = types.StringValue(ccValue.String())
+ }
+ if ccValue := cv.Get("authenticate.using.method"); ccValue.Exists() {
+ cItem.AuthenticateUsingMethod = types.StringValue(ccValue.String())
+ }
+ if ccValue := cv.Get("authenticate.using.retries"); ccValue.Exists() {
+ cItem.AuthenticateUsingRetries = types.Int64Value(ccValue.Int())
+ }
+ if ccValue := cv.Get("authenticate.using.retry-time"); ccValue.Exists() {
+ cItem.AuthenticateUsingRetryTime = types.Int64Value(ccValue.Int())
+ }
+ if ccValue := cv.Get("authenticate.using.priority"); ccValue.Exists() {
+ cItem.AuthenticateUsingPriority = types.Int64Value(ccValue.Int())
+ }
+ if ccValue := cv.Get("authenticate.using.aaa.authc-list"); ccValue.Exists() {
+ cItem.AuthenticateUsingAaaAuthcList = types.StringValue(ccValue.String())
+ }
+ if ccValue := cv.Get("authenticate.using.aaa.authz-list"); ccValue.Exists() {
+ cItem.AuthenticateUsingAaaAuthzList = types.StringValue(ccValue.String())
+ }
+ if ccValue := cv.Get("authenticate.using.both"); ccValue.Exists() {
+ cItem.AuthenticateUsingBoth = types.BoolValue(true)
+ } else {
+ cItem.AuthenticateUsingBoth = types.BoolValue(false)
+ }
+ if ccValue := cv.Get("authenticate.using.parameter-map"); ccValue.Exists() {
+ cItem.AuthenticateUsingParameterMap = types.StringValue(ccValue.String())
+ }
+ if ccValue := cv.Get("replace"); ccValue.Exists() {
+ cItem.Replace = types.BoolValue(true)
+ } else {
+ cItem.Replace = types.BoolValue(false)
+ }
+ if ccValue := cv.Get("restrict"); ccValue.Exists() {
+ cItem.Restrict = types.BoolValue(true)
+ } else {
+ cItem.Restrict = types.BoolValue(false)
+ }
+ if ccValue := cv.Get("clear-session"); ccValue.Exists() {
+ cItem.ClearSession = types.BoolValue(true)
+ } else {
+ cItem.ClearSession = types.BoolValue(false)
+ }
+ if ccValue := cv.Get("clear-authenticated-data-hosts-on-port"); ccValue.Exists() {
+ cItem.ClearAuthenticatedDataHostsOnPort = types.BoolValue(true)
+ } else {
+ cItem.ClearAuthenticatedDataHostsOnPort = types.BoolValue(false)
+ }
+ if ccValue := cv.Get("protect"); ccValue.Exists() {
+ cItem.Protect = types.BoolValue(true)
+ } else {
+ cItem.Protect = types.BoolValue(false)
+ }
+ if ccValue := cv.Get("err-disable"); ccValue.Exists() {
+ cItem.ErrDisable = types.BoolValue(true)
+ } else {
+ cItem.ErrDisable = types.BoolValue(false)
+ }
+ if ccValue := cv.Get("resume.reauthentication"); ccValue.Exists() {
+ cItem.ResumeReauthentication = types.BoolValue(true)
+ } else {
+ cItem.ResumeReauthentication = types.BoolValue(false)
+ }
+ if ccValue := cv.Get("authentication-restart"); ccValue.Exists() {
+ cItem.AuthenticationRestart = types.Int64Value(ccValue.Int())
+ }
+ if ccValue := cv.Get("set-domain"); ccValue.Exists() {
+ cItem.SetDomain = types.StringValue(ccValue.String())
+ }
+ if ccValue := cv.Get("unauthorize"); ccValue.Exists() {
+ cItem.Unauthorize = types.BoolValue(true)
+ } else {
+ cItem.Unauthorize = types.BoolValue(false)
+ }
+ if ccValue := cv.Get("notify"); ccValue.Exists() {
+ cItem.Notify = types.BoolValue(true)
+ } else {
+ cItem.Notify = types.BoolValue(false)
+ }
+ if ccValue := cv.Get("set-timer.name"); ccValue.Exists() {
+ cItem.SetTimerName = types.StringValue(ccValue.String())
+ }
+ if ccValue := cv.Get("set-timer.value"); ccValue.Exists() {
+ cItem.SetTimerValue = types.Int64Value(ccValue.Int())
+ }
+ if ccValue := cv.Get("map.attribute-to-service.table"); ccValue.Exists() {
+ cItem.MapAttributeToServiceTable = types.StringValue(ccValue.String())
+ }
+ item.ActionNumbers = append(item.ActionNumbers, cItem)
+ return true
+ })
+ }
+ data.ClassNumbers = append(data.ClassNumbers, item)
+ return true
+ })
}
}
-// End of section. //template:end updateFromBody
+// End of section. //template:end fromBodyData
-// Section below is generated&owned by "gen/generator.go". //template:begin fromBody
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyXML
-func (data *PolicyMapEvent) fromBody(ctx context.Context, res gjson.Result) {
- prefix := helpers.LastElement(data.getPath()) + "."
- if res.Get(helpers.LastElement(data.getPath())).IsArray() {
- prefix += "0."
- }
- if value := res.Get(prefix + "match-type"); value.Exists() {
+func (data *PolicyMapEvent) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/match-type"); value.Exists() {
data.MatchType = types.StringValue(value.String())
}
- if value := res.Get(prefix + "class-number"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/class-number"); value.Exists() {
data.ClassNumbers = make([]PolicyMapEventClassNumbers, 0)
- value.ForEach(func(k, v gjson.Result) bool {
+ value.ForEach(func(_ int, v xmldot.Result) bool {
item := PolicyMapEventClassNumbers{}
- if cValue := v.Get("number"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "number"); cValue.Exists() {
item.Number = types.Int64Value(cValue.Int())
}
- if cValue := v.Get("class"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "class"); cValue.Exists() {
item.Class = types.StringValue(cValue.String())
}
- if cValue := v.Get("execution-type"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "execution-type"); cValue.Exists() {
item.ExecutionType = types.StringValue(cValue.String())
}
- if cValue := v.Get("action-number"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "action-number"); cValue.Exists() {
item.ActionNumbers = make([]PolicyMapEventClassNumbersActionNumbers, 0)
- cValue.ForEach(func(ck, cv gjson.Result) bool {
+ cValue.ForEach(func(_ int, cv xmldot.Result) bool {
cItem := PolicyMapEventClassNumbersActionNumbers{}
- if ccValue := cv.Get("number"); ccValue.Exists() {
+ if ccValue := helpers.GetFromXPath(cv, "number"); ccValue.Exists() {
cItem.Number = types.Int64Value(ccValue.Int())
}
- if ccValue := cv.Get("pause.reauthentication"); ccValue.Exists() {
+ if ccValue := helpers.GetFromXPath(cv, "pause/reauthentication"); ccValue.Exists() {
cItem.PauseReauthentication = types.BoolValue(true)
} else {
cItem.PauseReauthentication = types.BoolValue(false)
}
- if ccValue := cv.Get("authorize"); ccValue.Exists() {
+ if ccValue := helpers.GetFromXPath(cv, "authorize"); ccValue.Exists() {
cItem.Authorize = types.BoolValue(true)
} else {
cItem.Authorize = types.BoolValue(false)
}
- if ccValue := cv.Get("terminate-config"); ccValue.Exists() {
+ if ccValue := helpers.GetFromXPath(cv, "terminate-config"); ccValue.Exists() {
cItem.TerminateConfig = types.StringValue(ccValue.String())
}
- if ccValue := cv.Get("activate.service-template-config.service-template"); ccValue.Exists() {
+ if ccValue := helpers.GetFromXPath(cv, "activate/service-template-config/service-template"); ccValue.Exists() {
cItem.ActivateServiceTemplateConfigServiceTemplate = types.StringValue(ccValue.String())
}
- if ccValue := cv.Get("activate.service-template-config.aaa-list"); ccValue.Exists() {
+ if ccValue := helpers.GetFromXPath(cv, "activate/service-template-config/aaa-list"); ccValue.Exists() {
cItem.ActivateServiceTemplateConfigAaaList = types.StringValue(ccValue.String())
}
- if ccValue := cv.Get("activate.service-template-config.precedence"); ccValue.Exists() {
+ if ccValue := helpers.GetFromXPath(cv, "activate/service-template-config/precedence"); ccValue.Exists() {
cItem.ActivateServiceTemplateConfigPrecedence = types.Int64Value(ccValue.Int())
}
- if ccValue := cv.Get("activate.service-template-config.replace-all"); ccValue.Exists() {
+ if ccValue := helpers.GetFromXPath(cv, "activate/service-template-config/replace-all"); ccValue.Exists() {
cItem.ActivateServiceTemplateConfigReplaceAll = types.BoolValue(true)
} else {
cItem.ActivateServiceTemplateConfigReplaceAll = types.BoolValue(false)
}
- if ccValue := cv.Get("activate.interface-template"); ccValue.Exists() {
+ if ccValue := helpers.GetFromXPath(cv, "activate/interface-template"); ccValue.Exists() {
cItem.ActivateInterfaceTemplate = types.StringValue(ccValue.String())
}
- if ccValue := cv.Get("activate.policy.type.control.subscriber"); ccValue.Exists() {
+ if ccValue := helpers.GetFromXPath(cv, "activate/policy/type/control/subscriber"); ccValue.Exists() {
cItem.ActivatePolicyTypeControlSubscriber = types.StringValue(ccValue.String())
}
- if ccValue := cv.Get("deactivate.interface-template"); ccValue.Exists() {
+ if ccValue := helpers.GetFromXPath(cv, "deactivate/interface-template"); ccValue.Exists() {
cItem.DeactivateInterfaceTemplate = types.StringValue(ccValue.String())
}
- if ccValue := cv.Get("deactivate.service-template"); ccValue.Exists() {
+ if ccValue := helpers.GetFromXPath(cv, "deactivate/service-template"); ccValue.Exists() {
cItem.DeactivateServiceTemplate = types.StringValue(ccValue.String())
}
- if ccValue := cv.Get("deactivate.policy.type.control.subscriber"); ccValue.Exists() {
+ if ccValue := helpers.GetFromXPath(cv, "deactivate/policy/type/control/subscriber"); ccValue.Exists() {
cItem.DeactivatePolicyTypeControlSubscriber = types.StringValue(ccValue.String())
}
- if ccValue := cv.Get("authenticate.using.method"); ccValue.Exists() {
+ if ccValue := helpers.GetFromXPath(cv, "authenticate/using/method"); ccValue.Exists() {
cItem.AuthenticateUsingMethod = types.StringValue(ccValue.String())
}
- if ccValue := cv.Get("authenticate.using.retries"); ccValue.Exists() {
+ if ccValue := helpers.GetFromXPath(cv, "authenticate/using/retries"); ccValue.Exists() {
cItem.AuthenticateUsingRetries = types.Int64Value(ccValue.Int())
}
- if ccValue := cv.Get("authenticate.using.retry-time"); ccValue.Exists() {
+ if ccValue := helpers.GetFromXPath(cv, "authenticate/using/retry-time"); ccValue.Exists() {
cItem.AuthenticateUsingRetryTime = types.Int64Value(ccValue.Int())
}
- if ccValue := cv.Get("authenticate.using.priority"); ccValue.Exists() {
+ if ccValue := helpers.GetFromXPath(cv, "authenticate/using/priority"); ccValue.Exists() {
cItem.AuthenticateUsingPriority = types.Int64Value(ccValue.Int())
}
- if ccValue := cv.Get("authenticate.using.aaa.authc-list"); ccValue.Exists() {
+ if ccValue := helpers.GetFromXPath(cv, "authenticate/using/aaa/authc-list"); ccValue.Exists() {
cItem.AuthenticateUsingAaaAuthcList = types.StringValue(ccValue.String())
}
- if ccValue := cv.Get("authenticate.using.aaa.authz-list"); ccValue.Exists() {
+ if ccValue := helpers.GetFromXPath(cv, "authenticate/using/aaa/authz-list"); ccValue.Exists() {
cItem.AuthenticateUsingAaaAuthzList = types.StringValue(ccValue.String())
}
- if ccValue := cv.Get("authenticate.using.both"); ccValue.Exists() {
+ if ccValue := helpers.GetFromXPath(cv, "authenticate/using/both"); ccValue.Exists() {
cItem.AuthenticateUsingBoth = types.BoolValue(true)
} else {
cItem.AuthenticateUsingBoth = types.BoolValue(false)
}
- if ccValue := cv.Get("authenticate.using.parameter-map"); ccValue.Exists() {
+ if ccValue := helpers.GetFromXPath(cv, "authenticate/using/parameter-map"); ccValue.Exists() {
cItem.AuthenticateUsingParameterMap = types.StringValue(ccValue.String())
}
- if ccValue := cv.Get("replace"); ccValue.Exists() {
+ if ccValue := helpers.GetFromXPath(cv, "replace"); ccValue.Exists() {
cItem.Replace = types.BoolValue(true)
} else {
cItem.Replace = types.BoolValue(false)
}
- if ccValue := cv.Get("restrict"); ccValue.Exists() {
+ if ccValue := helpers.GetFromXPath(cv, "restrict"); ccValue.Exists() {
cItem.Restrict = types.BoolValue(true)
} else {
cItem.Restrict = types.BoolValue(false)
}
- if ccValue := cv.Get("clear-session"); ccValue.Exists() {
+ if ccValue := helpers.GetFromXPath(cv, "clear-session"); ccValue.Exists() {
cItem.ClearSession = types.BoolValue(true)
} else {
cItem.ClearSession = types.BoolValue(false)
}
- if ccValue := cv.Get("clear-authenticated-data-hosts-on-port"); ccValue.Exists() {
+ if ccValue := helpers.GetFromXPath(cv, "clear-authenticated-data-hosts-on-port"); ccValue.Exists() {
cItem.ClearAuthenticatedDataHostsOnPort = types.BoolValue(true)
} else {
cItem.ClearAuthenticatedDataHostsOnPort = types.BoolValue(false)
}
- if ccValue := cv.Get("protect"); ccValue.Exists() {
+ if ccValue := helpers.GetFromXPath(cv, "protect"); ccValue.Exists() {
cItem.Protect = types.BoolValue(true)
} else {
cItem.Protect = types.BoolValue(false)
}
- if ccValue := cv.Get("err-disable"); ccValue.Exists() {
+ if ccValue := helpers.GetFromXPath(cv, "err-disable"); ccValue.Exists() {
cItem.ErrDisable = types.BoolValue(true)
} else {
cItem.ErrDisable = types.BoolValue(false)
}
- if ccValue := cv.Get("resume.reauthentication"); ccValue.Exists() {
+ if ccValue := helpers.GetFromXPath(cv, "resume/reauthentication"); ccValue.Exists() {
cItem.ResumeReauthentication = types.BoolValue(true)
} else {
cItem.ResumeReauthentication = types.BoolValue(false)
}
- if ccValue := cv.Get("authentication-restart"); ccValue.Exists() {
+ if ccValue := helpers.GetFromXPath(cv, "authentication-restart"); ccValue.Exists() {
cItem.AuthenticationRestart = types.Int64Value(ccValue.Int())
}
- if ccValue := cv.Get("set-domain"); ccValue.Exists() {
+ if ccValue := helpers.GetFromXPath(cv, "set-domain"); ccValue.Exists() {
cItem.SetDomain = types.StringValue(ccValue.String())
}
- if ccValue := cv.Get("unauthorize"); ccValue.Exists() {
+ if ccValue := helpers.GetFromXPath(cv, "unauthorize"); ccValue.Exists() {
cItem.Unauthorize = types.BoolValue(true)
} else {
cItem.Unauthorize = types.BoolValue(false)
}
- if ccValue := cv.Get("notify"); ccValue.Exists() {
+ if ccValue := helpers.GetFromXPath(cv, "notify"); ccValue.Exists() {
cItem.Notify = types.BoolValue(true)
} else {
cItem.Notify = types.BoolValue(false)
}
- if ccValue := cv.Get("set-timer.name"); ccValue.Exists() {
+ if ccValue := helpers.GetFromXPath(cv, "set-timer/name"); ccValue.Exists() {
cItem.SetTimerName = types.StringValue(ccValue.String())
}
- if ccValue := cv.Get("set-timer.value"); ccValue.Exists() {
+ if ccValue := helpers.GetFromXPath(cv, "set-timer/value"); ccValue.Exists() {
cItem.SetTimerValue = types.Int64Value(ccValue.Int())
}
- if ccValue := cv.Get("map.attribute-to-service.table"); ccValue.Exists() {
+ if ccValue := helpers.GetFromXPath(cv, "map/attribute-to-service/table"); ccValue.Exists() {
cItem.MapAttributeToServiceTable = types.StringValue(ccValue.String())
}
item.ActionNumbers = append(item.ActionNumbers, cItem)
@@ -768,164 +1624,160 @@ func (data *PolicyMapEvent) fromBody(ctx context.Context, res gjson.Result) {
}
}
-// End of section. //template:end fromBody
+// End of section. //template:end fromBodyXML
-// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyData
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyDataXML
-func (data *PolicyMapEventData) fromBody(ctx context.Context, res gjson.Result) {
- prefix := helpers.LastElement(data.getPath()) + "."
- if res.Get(helpers.LastElement(data.getPath())).IsArray() {
- prefix += "0."
- }
- if value := res.Get(prefix + "match-type"); value.Exists() {
+func (data *PolicyMapEventData) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/match-type"); value.Exists() {
data.MatchType = types.StringValue(value.String())
}
- if value := res.Get(prefix + "class-number"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/class-number"); value.Exists() {
data.ClassNumbers = make([]PolicyMapEventClassNumbers, 0)
- value.ForEach(func(k, v gjson.Result) bool {
+ value.ForEach(func(_ int, v xmldot.Result) bool {
item := PolicyMapEventClassNumbers{}
- if cValue := v.Get("number"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "number"); cValue.Exists() {
item.Number = types.Int64Value(cValue.Int())
}
- if cValue := v.Get("class"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "class"); cValue.Exists() {
item.Class = types.StringValue(cValue.String())
}
- if cValue := v.Get("execution-type"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "execution-type"); cValue.Exists() {
item.ExecutionType = types.StringValue(cValue.String())
}
- if cValue := v.Get("action-number"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "action-number"); cValue.Exists() {
item.ActionNumbers = make([]PolicyMapEventClassNumbersActionNumbers, 0)
- cValue.ForEach(func(ck, cv gjson.Result) bool {
+ cValue.ForEach(func(_ int, cv xmldot.Result) bool {
cItem := PolicyMapEventClassNumbersActionNumbers{}
- if ccValue := cv.Get("number"); ccValue.Exists() {
+ if ccValue := helpers.GetFromXPath(cv, "number"); ccValue.Exists() {
cItem.Number = types.Int64Value(ccValue.Int())
}
- if ccValue := cv.Get("pause.reauthentication"); ccValue.Exists() {
+ if ccValue := helpers.GetFromXPath(cv, "pause/reauthentication"); ccValue.Exists() {
cItem.PauseReauthentication = types.BoolValue(true)
} else {
cItem.PauseReauthentication = types.BoolValue(false)
}
- if ccValue := cv.Get("authorize"); ccValue.Exists() {
+ if ccValue := helpers.GetFromXPath(cv, "authorize"); ccValue.Exists() {
cItem.Authorize = types.BoolValue(true)
} else {
cItem.Authorize = types.BoolValue(false)
}
- if ccValue := cv.Get("terminate-config"); ccValue.Exists() {
+ if ccValue := helpers.GetFromXPath(cv, "terminate-config"); ccValue.Exists() {
cItem.TerminateConfig = types.StringValue(ccValue.String())
}
- if ccValue := cv.Get("activate.service-template-config.service-template"); ccValue.Exists() {
+ if ccValue := helpers.GetFromXPath(cv, "activate/service-template-config/service-template"); ccValue.Exists() {
cItem.ActivateServiceTemplateConfigServiceTemplate = types.StringValue(ccValue.String())
}
- if ccValue := cv.Get("activate.service-template-config.aaa-list"); ccValue.Exists() {
+ if ccValue := helpers.GetFromXPath(cv, "activate/service-template-config/aaa-list"); ccValue.Exists() {
cItem.ActivateServiceTemplateConfigAaaList = types.StringValue(ccValue.String())
}
- if ccValue := cv.Get("activate.service-template-config.precedence"); ccValue.Exists() {
+ if ccValue := helpers.GetFromXPath(cv, "activate/service-template-config/precedence"); ccValue.Exists() {
cItem.ActivateServiceTemplateConfigPrecedence = types.Int64Value(ccValue.Int())
}
- if ccValue := cv.Get("activate.service-template-config.replace-all"); ccValue.Exists() {
+ if ccValue := helpers.GetFromXPath(cv, "activate/service-template-config/replace-all"); ccValue.Exists() {
cItem.ActivateServiceTemplateConfigReplaceAll = types.BoolValue(true)
} else {
cItem.ActivateServiceTemplateConfigReplaceAll = types.BoolValue(false)
}
- if ccValue := cv.Get("activate.interface-template"); ccValue.Exists() {
+ if ccValue := helpers.GetFromXPath(cv, "activate/interface-template"); ccValue.Exists() {
cItem.ActivateInterfaceTemplate = types.StringValue(ccValue.String())
}
- if ccValue := cv.Get("activate.policy.type.control.subscriber"); ccValue.Exists() {
+ if ccValue := helpers.GetFromXPath(cv, "activate/policy/type/control/subscriber"); ccValue.Exists() {
cItem.ActivatePolicyTypeControlSubscriber = types.StringValue(ccValue.String())
}
- if ccValue := cv.Get("deactivate.interface-template"); ccValue.Exists() {
+ if ccValue := helpers.GetFromXPath(cv, "deactivate/interface-template"); ccValue.Exists() {
cItem.DeactivateInterfaceTemplate = types.StringValue(ccValue.String())
}
- if ccValue := cv.Get("deactivate.service-template"); ccValue.Exists() {
+ if ccValue := helpers.GetFromXPath(cv, "deactivate/service-template"); ccValue.Exists() {
cItem.DeactivateServiceTemplate = types.StringValue(ccValue.String())
}
- if ccValue := cv.Get("deactivate.policy.type.control.subscriber"); ccValue.Exists() {
+ if ccValue := helpers.GetFromXPath(cv, "deactivate/policy/type/control/subscriber"); ccValue.Exists() {
cItem.DeactivatePolicyTypeControlSubscriber = types.StringValue(ccValue.String())
}
- if ccValue := cv.Get("authenticate.using.method"); ccValue.Exists() {
+ if ccValue := helpers.GetFromXPath(cv, "authenticate/using/method"); ccValue.Exists() {
cItem.AuthenticateUsingMethod = types.StringValue(ccValue.String())
}
- if ccValue := cv.Get("authenticate.using.retries"); ccValue.Exists() {
+ if ccValue := helpers.GetFromXPath(cv, "authenticate/using/retries"); ccValue.Exists() {
cItem.AuthenticateUsingRetries = types.Int64Value(ccValue.Int())
}
- if ccValue := cv.Get("authenticate.using.retry-time"); ccValue.Exists() {
+ if ccValue := helpers.GetFromXPath(cv, "authenticate/using/retry-time"); ccValue.Exists() {
cItem.AuthenticateUsingRetryTime = types.Int64Value(ccValue.Int())
}
- if ccValue := cv.Get("authenticate.using.priority"); ccValue.Exists() {
+ if ccValue := helpers.GetFromXPath(cv, "authenticate/using/priority"); ccValue.Exists() {
cItem.AuthenticateUsingPriority = types.Int64Value(ccValue.Int())
}
- if ccValue := cv.Get("authenticate.using.aaa.authc-list"); ccValue.Exists() {
+ if ccValue := helpers.GetFromXPath(cv, "authenticate/using/aaa/authc-list"); ccValue.Exists() {
cItem.AuthenticateUsingAaaAuthcList = types.StringValue(ccValue.String())
}
- if ccValue := cv.Get("authenticate.using.aaa.authz-list"); ccValue.Exists() {
+ if ccValue := helpers.GetFromXPath(cv, "authenticate/using/aaa/authz-list"); ccValue.Exists() {
cItem.AuthenticateUsingAaaAuthzList = types.StringValue(ccValue.String())
}
- if ccValue := cv.Get("authenticate.using.both"); ccValue.Exists() {
+ if ccValue := helpers.GetFromXPath(cv, "authenticate/using/both"); ccValue.Exists() {
cItem.AuthenticateUsingBoth = types.BoolValue(true)
} else {
cItem.AuthenticateUsingBoth = types.BoolValue(false)
}
- if ccValue := cv.Get("authenticate.using.parameter-map"); ccValue.Exists() {
+ if ccValue := helpers.GetFromXPath(cv, "authenticate/using/parameter-map"); ccValue.Exists() {
cItem.AuthenticateUsingParameterMap = types.StringValue(ccValue.String())
}
- if ccValue := cv.Get("replace"); ccValue.Exists() {
+ if ccValue := helpers.GetFromXPath(cv, "replace"); ccValue.Exists() {
cItem.Replace = types.BoolValue(true)
} else {
cItem.Replace = types.BoolValue(false)
}
- if ccValue := cv.Get("restrict"); ccValue.Exists() {
+ if ccValue := helpers.GetFromXPath(cv, "restrict"); ccValue.Exists() {
cItem.Restrict = types.BoolValue(true)
} else {
cItem.Restrict = types.BoolValue(false)
}
- if ccValue := cv.Get("clear-session"); ccValue.Exists() {
+ if ccValue := helpers.GetFromXPath(cv, "clear-session"); ccValue.Exists() {
cItem.ClearSession = types.BoolValue(true)
} else {
cItem.ClearSession = types.BoolValue(false)
}
- if ccValue := cv.Get("clear-authenticated-data-hosts-on-port"); ccValue.Exists() {
+ if ccValue := helpers.GetFromXPath(cv, "clear-authenticated-data-hosts-on-port"); ccValue.Exists() {
cItem.ClearAuthenticatedDataHostsOnPort = types.BoolValue(true)
} else {
cItem.ClearAuthenticatedDataHostsOnPort = types.BoolValue(false)
}
- if ccValue := cv.Get("protect"); ccValue.Exists() {
+ if ccValue := helpers.GetFromXPath(cv, "protect"); ccValue.Exists() {
cItem.Protect = types.BoolValue(true)
} else {
cItem.Protect = types.BoolValue(false)
}
- if ccValue := cv.Get("err-disable"); ccValue.Exists() {
+ if ccValue := helpers.GetFromXPath(cv, "err-disable"); ccValue.Exists() {
cItem.ErrDisable = types.BoolValue(true)
} else {
cItem.ErrDisable = types.BoolValue(false)
}
- if ccValue := cv.Get("resume.reauthentication"); ccValue.Exists() {
+ if ccValue := helpers.GetFromXPath(cv, "resume/reauthentication"); ccValue.Exists() {
cItem.ResumeReauthentication = types.BoolValue(true)
} else {
cItem.ResumeReauthentication = types.BoolValue(false)
}
- if ccValue := cv.Get("authentication-restart"); ccValue.Exists() {
+ if ccValue := helpers.GetFromXPath(cv, "authentication-restart"); ccValue.Exists() {
cItem.AuthenticationRestart = types.Int64Value(ccValue.Int())
}
- if ccValue := cv.Get("set-domain"); ccValue.Exists() {
+ if ccValue := helpers.GetFromXPath(cv, "set-domain"); ccValue.Exists() {
cItem.SetDomain = types.StringValue(ccValue.String())
}
- if ccValue := cv.Get("unauthorize"); ccValue.Exists() {
+ if ccValue := helpers.GetFromXPath(cv, "unauthorize"); ccValue.Exists() {
cItem.Unauthorize = types.BoolValue(true)
} else {
cItem.Unauthorize = types.BoolValue(false)
}
- if ccValue := cv.Get("notify"); ccValue.Exists() {
+ if ccValue := helpers.GetFromXPath(cv, "notify"); ccValue.Exists() {
cItem.Notify = types.BoolValue(true)
} else {
cItem.Notify = types.BoolValue(false)
}
- if ccValue := cv.Get("set-timer.name"); ccValue.Exists() {
+ if ccValue := helpers.GetFromXPath(cv, "set-timer/name"); ccValue.Exists() {
cItem.SetTimerName = types.StringValue(ccValue.String())
}
- if ccValue := cv.Get("set-timer.value"); ccValue.Exists() {
+ if ccValue := helpers.GetFromXPath(cv, "set-timer/value"); ccValue.Exists() {
cItem.SetTimerValue = types.Int64Value(ccValue.Int())
}
- if ccValue := cv.Get("map.attribute-to-service.table"); ccValue.Exists() {
+ if ccValue := helpers.GetFromXPath(cv, "map/attribute-to-service/table"); ccValue.Exists() {
cItem.MapAttributeToServiceTable = types.StringValue(ccValue.String())
}
item.ActionNumbers = append(item.ActionNumbers, cItem)
@@ -938,7 +1790,7 @@ func (data *PolicyMapEventData) fromBody(ctx context.Context, res gjson.Result)
}
}
-// End of section. //template:end fromBodyData
+// End of section. //template:end fromBodyDataXML
// Section below is generated&owned by "gen/generator.go". //template:begin getDeletedItems
@@ -1111,6 +1963,187 @@ func (data *PolicyMapEvent) getDeletedItems(ctx context.Context, state PolicyMap
// End of section. //template:end getDeletedItems
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletedItemsXML
+
+func (data *PolicyMapEvent) addDeletedItemsXML(ctx context.Context, state PolicyMapEvent, body string) string {
+ b := netconf.NewBody(body)
+ if !state.MatchType.IsNull() && data.MatchType.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/match-type")
+ }
+ for i := range state.ClassNumbers {
+ stateKeys := [...]string{"number"}
+ stateKeyValues := [...]string{strconv.FormatInt(state.ClassNumbers[i].Number.ValueInt64(), 10)}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.ClassNumbers[i].Number.ValueInt64()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.ClassNumbers {
+ found = true
+ if state.ClassNumbers[i].Number.ValueInt64() != data.ClassNumbers[j].Number.ValueInt64() {
+ found = false
+ }
+ if found {
+ if !state.ClassNumbers[i].Class.IsNull() && data.ClassNumbers[j].Class.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/class-number%v/class", predicates))
+ }
+ if !state.ClassNumbers[i].ExecutionType.IsNull() && data.ClassNumbers[j].ExecutionType.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/class-number%v/execution-type", predicates))
+ }
+ for ci := range state.ClassNumbers[i].ActionNumbers {
+ cstateKeys := [...]string{"number"}
+ cstateKeyValues := [...]string{strconv.FormatInt(state.ClassNumbers[i].ActionNumbers[ci].Number.ValueInt64(), 10)}
+ cpredicates := ""
+ for i := range cstateKeys {
+ cpredicates += fmt.Sprintf("[%s='%s']", cstateKeys[i], cstateKeyValues[i])
+ }
+
+ cemptyKeys := true
+ if !reflect.ValueOf(state.ClassNumbers[i].ActionNumbers[ci].Number.ValueInt64()).IsZero() {
+ cemptyKeys = false
+ }
+ if cemptyKeys {
+ continue
+ }
+
+ found := false
+ for cj := range data.ClassNumbers[j].ActionNumbers {
+ found = true
+ if state.ClassNumbers[i].ActionNumbers[ci].Number.ValueInt64() != data.ClassNumbers[j].ActionNumbers[cj].Number.ValueInt64() {
+ found = false
+ }
+ if found {
+ if !state.ClassNumbers[i].ActionNumbers[ci].PauseReauthentication.IsNull() && data.ClassNumbers[j].ActionNumbers[cj].PauseReauthentication.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/class-number%v/action-number%v/pause/reauthentication", predicates, cpredicates))
+ }
+ if !state.ClassNumbers[i].ActionNumbers[ci].Authorize.IsNull() && data.ClassNumbers[j].ActionNumbers[cj].Authorize.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/class-number%v/action-number%v/authorize", predicates, cpredicates))
+ }
+ if !state.ClassNumbers[i].ActionNumbers[ci].TerminateConfig.IsNull() && data.ClassNumbers[j].ActionNumbers[cj].TerminateConfig.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/class-number%v/action-number%v/terminate-config", predicates, cpredicates))
+ }
+ if !state.ClassNumbers[i].ActionNumbers[ci].ActivateServiceTemplateConfigServiceTemplate.IsNull() && data.ClassNumbers[j].ActionNumbers[cj].ActivateServiceTemplateConfigServiceTemplate.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/class-number%v/action-number%v/activate/service-template-config/service-template", predicates, cpredicates))
+ }
+ if !state.ClassNumbers[i].ActionNumbers[ci].ActivateServiceTemplateConfigAaaList.IsNull() && data.ClassNumbers[j].ActionNumbers[cj].ActivateServiceTemplateConfigAaaList.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/class-number%v/action-number%v/activate/service-template-config/aaa-list", predicates, cpredicates))
+ }
+ if !state.ClassNumbers[i].ActionNumbers[ci].ActivateServiceTemplateConfigPrecedence.IsNull() && data.ClassNumbers[j].ActionNumbers[cj].ActivateServiceTemplateConfigPrecedence.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/class-number%v/action-number%v/activate/service-template-config/precedence", predicates, cpredicates))
+ }
+ if !state.ClassNumbers[i].ActionNumbers[ci].ActivateServiceTemplateConfigReplaceAll.IsNull() && data.ClassNumbers[j].ActionNumbers[cj].ActivateServiceTemplateConfigReplaceAll.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/class-number%v/action-number%v/activate/service-template-config/replace-all", predicates, cpredicates))
+ }
+ if !state.ClassNumbers[i].ActionNumbers[ci].ActivateInterfaceTemplate.IsNull() && data.ClassNumbers[j].ActionNumbers[cj].ActivateInterfaceTemplate.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/class-number%v/action-number%v/activate/interface-template", predicates, cpredicates))
+ }
+ if !state.ClassNumbers[i].ActionNumbers[ci].ActivatePolicyTypeControlSubscriber.IsNull() && data.ClassNumbers[j].ActionNumbers[cj].ActivatePolicyTypeControlSubscriber.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/class-number%v/action-number%v/activate/policy/type/control/subscriber", predicates, cpredicates))
+ }
+ if !state.ClassNumbers[i].ActionNumbers[ci].DeactivateInterfaceTemplate.IsNull() && data.ClassNumbers[j].ActionNumbers[cj].DeactivateInterfaceTemplate.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/class-number%v/action-number%v/deactivate/interface-template", predicates, cpredicates))
+ }
+ if !state.ClassNumbers[i].ActionNumbers[ci].DeactivateServiceTemplate.IsNull() && data.ClassNumbers[j].ActionNumbers[cj].DeactivateServiceTemplate.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/class-number%v/action-number%v/deactivate/service-template", predicates, cpredicates))
+ }
+ if !state.ClassNumbers[i].ActionNumbers[ci].DeactivatePolicyTypeControlSubscriber.IsNull() && data.ClassNumbers[j].ActionNumbers[cj].DeactivatePolicyTypeControlSubscriber.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/class-number%v/action-number%v/deactivate/policy/type/control/subscriber", predicates, cpredicates))
+ }
+ if !state.ClassNumbers[i].ActionNumbers[ci].AuthenticateUsingMethod.IsNull() && data.ClassNumbers[j].ActionNumbers[cj].AuthenticateUsingMethod.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/class-number%v/action-number%v/authenticate/using/method", predicates, cpredicates))
+ }
+ if !state.ClassNumbers[i].ActionNumbers[ci].AuthenticateUsingRetries.IsNull() && data.ClassNumbers[j].ActionNumbers[cj].AuthenticateUsingRetries.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/class-number%v/action-number%v/authenticate/using/retries", predicates, cpredicates))
+ }
+ if !state.ClassNumbers[i].ActionNumbers[ci].AuthenticateUsingRetryTime.IsNull() && data.ClassNumbers[j].ActionNumbers[cj].AuthenticateUsingRetryTime.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/class-number%v/action-number%v/authenticate/using/retry-time", predicates, cpredicates))
+ }
+ if !state.ClassNumbers[i].ActionNumbers[ci].AuthenticateUsingPriority.IsNull() && data.ClassNumbers[j].ActionNumbers[cj].AuthenticateUsingPriority.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/class-number%v/action-number%v/authenticate/using/priority", predicates, cpredicates))
+ }
+ if !state.ClassNumbers[i].ActionNumbers[ci].AuthenticateUsingAaaAuthcList.IsNull() && data.ClassNumbers[j].ActionNumbers[cj].AuthenticateUsingAaaAuthcList.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/class-number%v/action-number%v/authenticate/using/aaa/authc-list", predicates, cpredicates))
+ }
+ if !state.ClassNumbers[i].ActionNumbers[ci].AuthenticateUsingAaaAuthzList.IsNull() && data.ClassNumbers[j].ActionNumbers[cj].AuthenticateUsingAaaAuthzList.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/class-number%v/action-number%v/authenticate/using/aaa/authz-list", predicates, cpredicates))
+ }
+ if !state.ClassNumbers[i].ActionNumbers[ci].AuthenticateUsingBoth.IsNull() && data.ClassNumbers[j].ActionNumbers[cj].AuthenticateUsingBoth.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/class-number%v/action-number%v/authenticate/using/both", predicates, cpredicates))
+ }
+ if !state.ClassNumbers[i].ActionNumbers[ci].AuthenticateUsingParameterMap.IsNull() && data.ClassNumbers[j].ActionNumbers[cj].AuthenticateUsingParameterMap.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/class-number%v/action-number%v/authenticate/using/parameter-map", predicates, cpredicates))
+ }
+ if !state.ClassNumbers[i].ActionNumbers[ci].Replace.IsNull() && data.ClassNumbers[j].ActionNumbers[cj].Replace.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/class-number%v/action-number%v/replace", predicates, cpredicates))
+ }
+ if !state.ClassNumbers[i].ActionNumbers[ci].Restrict.IsNull() && data.ClassNumbers[j].ActionNumbers[cj].Restrict.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/class-number%v/action-number%v/restrict", predicates, cpredicates))
+ }
+ if !state.ClassNumbers[i].ActionNumbers[ci].ClearSession.IsNull() && data.ClassNumbers[j].ActionNumbers[cj].ClearSession.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/class-number%v/action-number%v/clear-session", predicates, cpredicates))
+ }
+ if !state.ClassNumbers[i].ActionNumbers[ci].ClearAuthenticatedDataHostsOnPort.IsNull() && data.ClassNumbers[j].ActionNumbers[cj].ClearAuthenticatedDataHostsOnPort.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/class-number%v/action-number%v/clear-authenticated-data-hosts-on-port", predicates, cpredicates))
+ }
+ if !state.ClassNumbers[i].ActionNumbers[ci].Protect.IsNull() && data.ClassNumbers[j].ActionNumbers[cj].Protect.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/class-number%v/action-number%v/protect", predicates, cpredicates))
+ }
+ if !state.ClassNumbers[i].ActionNumbers[ci].ErrDisable.IsNull() && data.ClassNumbers[j].ActionNumbers[cj].ErrDisable.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/class-number%v/action-number%v/err-disable", predicates, cpredicates))
+ }
+ if !state.ClassNumbers[i].ActionNumbers[ci].ResumeReauthentication.IsNull() && data.ClassNumbers[j].ActionNumbers[cj].ResumeReauthentication.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/class-number%v/action-number%v/resume/reauthentication", predicates, cpredicates))
+ }
+ if !state.ClassNumbers[i].ActionNumbers[ci].AuthenticationRestart.IsNull() && data.ClassNumbers[j].ActionNumbers[cj].AuthenticationRestart.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/class-number%v/action-number%v/authentication-restart", predicates, cpredicates))
+ }
+ if !state.ClassNumbers[i].ActionNumbers[ci].SetDomain.IsNull() && data.ClassNumbers[j].ActionNumbers[cj].SetDomain.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/class-number%v/action-number%v/set-domain", predicates, cpredicates))
+ }
+ if !state.ClassNumbers[i].ActionNumbers[ci].Unauthorize.IsNull() && data.ClassNumbers[j].ActionNumbers[cj].Unauthorize.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/class-number%v/action-number%v/unauthorize", predicates, cpredicates))
+ }
+ if !state.ClassNumbers[i].ActionNumbers[ci].Notify.IsNull() && data.ClassNumbers[j].ActionNumbers[cj].Notify.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/class-number%v/action-number%v/notify", predicates, cpredicates))
+ }
+ if !state.ClassNumbers[i].ActionNumbers[ci].SetTimerName.IsNull() && data.ClassNumbers[j].ActionNumbers[cj].SetTimerName.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/class-number%v/action-number%v/set-timer/name", predicates, cpredicates))
+ }
+ if !state.ClassNumbers[i].ActionNumbers[ci].SetTimerValue.IsNull() && data.ClassNumbers[j].ActionNumbers[cj].SetTimerValue.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/class-number%v/action-number%v/set-timer/value", predicates, cpredicates))
+ }
+ if !state.ClassNumbers[i].ActionNumbers[ci].MapAttributeToServiceTable.IsNull() && data.ClassNumbers[j].ActionNumbers[cj].MapAttributeToServiceTable.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/class-number%v/action-number%v/map/attribute-to-service/table", predicates, cpredicates))
+ }
+ break
+ }
+ }
+ if !found {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/class-number%v/action-number%v", predicates, cpredicates))
+ }
+ }
+ break
+ }
+ }
+ if !found {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/class-number%v", predicates))
+ }
+ }
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletedItemsXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin getEmptyLeafsDelete
func (data *PolicyMapEvent) getEmptyLeafsDelete(ctx context.Context) []string {
@@ -1185,3 +2218,26 @@ func (data *PolicyMapEvent) getDeletePaths(ctx context.Context) []string {
}
// End of section. //template:end getDeletePaths
+
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletePathsXML
+
+func (data *PolicyMapEvent) addDeletePathsXML(ctx context.Context, body string) string {
+ b := netconf.NewBody(body)
+ if !data.MatchType.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/match-type")
+ }
+ for i := range data.ClassNumbers {
+ keys := [...]string{"number"}
+ keyValues := [...]string{strconv.FormatInt(data.ClassNumbers[i].Number.ValueInt64(), 10)}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/class-number%v", predicates))
+ }
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletePathsXML
diff --git a/internal/provider/model_iosxe_prefix_list.go b/internal/provider/model_iosxe_prefix_list.go
index bd09e075..c240a7da 100644
--- a/internal/provider/model_iosxe_prefix_list.go
+++ b/internal/provider/model_iosxe_prefix_list.go
@@ -30,6 +30,9 @@ import (
"github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/types"
+ "github.com/hashicorp/terraform-plugin-log/tflog"
+ "github.com/netascode/go-netconf"
+ "github.com/netascode/xmldot"
"github.com/tidwall/gjson"
"github.com/tidwall/sjson"
)
@@ -86,6 +89,17 @@ func (data PrefixList) getPathShort() string {
return matches[1]
}
+// getXPath returns the XPath for NETCONF operations
+func (data PrefixList) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/ip/prefix-lists"
+ return path
+}
+
+func (data PrefixListData) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/ip/prefix-lists"
+ return path
+}
+
// End of section. //template:end getPath
// Section below is generated&owned by "gen/generator.go". //template:begin toBody
@@ -131,6 +145,55 @@ func (data PrefixList) toBody(ctx context.Context) string {
// End of section. //template:end toBody
+// Section below is generated&owned by "gen/generator.go". //template:begin toBodyXML
+
+func (data PrefixList) toBodyXML(ctx context.Context) string {
+ body := netconf.Body{}
+ if len(data.Prefixes) > 0 {
+ for _, item := range data.Prefixes {
+ cBody := netconf.Body{}
+ if !item.Name.IsNull() && !item.Name.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "name", item.Name.ValueString())
+ }
+ if !item.Seq.IsNull() && !item.Seq.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "no", strconv.FormatInt(item.Seq.ValueInt64(), 10))
+ }
+ if !item.Action.IsNull() && !item.Action.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "action", item.Action.ValueString())
+ }
+ if !item.Ip.IsNull() && !item.Ip.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "ip", item.Ip.ValueString())
+ }
+ if !item.Ge.IsNull() && !item.Ge.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "ge", strconv.FormatInt(item.Ge.ValueInt64(), 10))
+ }
+ if !item.Le.IsNull() && !item.Le.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "le", strconv.FormatInt(item.Le.ValueInt64(), 10))
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/prefixes", cBody.Res())
+ }
+ }
+ if len(data.PrefixListDescription) > 0 {
+ for _, item := range data.PrefixListDescription {
+ cBody := netconf.Body{}
+ if !item.Name.IsNull() && !item.Name.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "name", item.Name.ValueString())
+ }
+ if !item.Description.IsNull() && !item.Description.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "description", item.Description.ValueString())
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/prefix-list-description", cBody.Res())
+ }
+ }
+ bodyString, err := body.String()
+ if err != nil {
+ tflog.Error(ctx, fmt.Sprintf("Error converting body to string: %s", err))
+ }
+ return bodyString
+}
+
+// End of section. //template:end toBodyXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBody
func (data *PrefixList) updateFromBody(ctx context.Context, res gjson.Result) {
@@ -230,6 +293,101 @@ func (data *PrefixList) updateFromBody(ctx context.Context, res gjson.Result) {
// End of section. //template:end updateFromBody
+// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBodyXML
+
+func (data *PrefixList) updateFromBodyXML(ctx context.Context, res xmldot.Result) {
+ for i := range data.Prefixes {
+ keys := [...]string{"name", "no"}
+ keyValues := [...]string{data.Prefixes[i].Name.ValueString(), strconv.FormatInt(data.Prefixes[i].Seq.ValueInt64(), 10)}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/prefixes").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, "name"); value.Exists() && !data.Prefixes[i].Name.IsNull() {
+ data.Prefixes[i].Name = types.StringValue(value.String())
+ } else {
+ data.Prefixes[i].Name = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "no"); value.Exists() && !data.Prefixes[i].Seq.IsNull() {
+ data.Prefixes[i].Seq = types.Int64Value(value.Int())
+ } else {
+ data.Prefixes[i].Seq = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(r, "action"); value.Exists() && !data.Prefixes[i].Action.IsNull() {
+ data.Prefixes[i].Action = types.StringValue(value.String())
+ } else {
+ data.Prefixes[i].Action = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "ip"); value.Exists() && !data.Prefixes[i].Ip.IsNull() {
+ data.Prefixes[i].Ip = types.StringValue(value.String())
+ } else {
+ data.Prefixes[i].Ip = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "ge"); value.Exists() && !data.Prefixes[i].Ge.IsNull() {
+ data.Prefixes[i].Ge = types.Int64Value(value.Int())
+ } else {
+ data.Prefixes[i].Ge = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(r, "le"); value.Exists() && !data.Prefixes[i].Le.IsNull() {
+ data.Prefixes[i].Le = types.Int64Value(value.Int())
+ } else {
+ data.Prefixes[i].Le = types.Int64Null()
+ }
+ }
+ for i := range data.PrefixListDescription {
+ keys := [...]string{"name"}
+ keyValues := [...]string{data.PrefixListDescription[i].Name.ValueString()}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/prefix-list-description").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, "name"); value.Exists() && !data.PrefixListDescription[i].Name.IsNull() {
+ data.PrefixListDescription[i].Name = types.StringValue(value.String())
+ } else {
+ data.PrefixListDescription[i].Name = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "description"); value.Exists() && !data.PrefixListDescription[i].Description.IsNull() {
+ data.PrefixListDescription[i].Description = types.StringValue(value.String())
+ } else {
+ data.PrefixListDescription[i].Description = types.StringNull()
+ }
+ }
+}
+
+// End of section. //template:end updateFromBodyXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin fromBody
func (data *PrefixList) fromBody(ctx context.Context, res gjson.Result) {
@@ -332,6 +490,100 @@ func (data *PrefixListData) fromBody(ctx context.Context, res gjson.Result) {
// End of section. //template:end fromBodyData
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyXML
+
+func (data *PrefixList) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/prefixes"); value.Exists() {
+ data.Prefixes = make([]PrefixListPrefixes, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := PrefixListPrefixes{}
+ if cValue := helpers.GetFromXPath(v, "name"); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "no"); cValue.Exists() {
+ item.Seq = types.Int64Value(cValue.Int())
+ }
+ if cValue := helpers.GetFromXPath(v, "action"); cValue.Exists() {
+ item.Action = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "ip"); cValue.Exists() {
+ item.Ip = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "ge"); cValue.Exists() {
+ item.Ge = types.Int64Value(cValue.Int())
+ }
+ if cValue := helpers.GetFromXPath(v, "le"); cValue.Exists() {
+ item.Le = types.Int64Value(cValue.Int())
+ }
+ data.Prefixes = append(data.Prefixes, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/prefix-list-description"); value.Exists() {
+ data.PrefixListDescription = make([]PrefixListPrefixListDescription, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := PrefixListPrefixListDescription{}
+ if cValue := helpers.GetFromXPath(v, "name"); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "description"); cValue.Exists() {
+ item.Description = types.StringValue(cValue.String())
+ }
+ data.PrefixListDescription = append(data.PrefixListDescription, item)
+ return true
+ })
+ }
+}
+
+// End of section. //template:end fromBodyXML
+
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyDataXML
+
+func (data *PrefixListData) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/prefixes"); value.Exists() {
+ data.Prefixes = make([]PrefixListPrefixes, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := PrefixListPrefixes{}
+ if cValue := helpers.GetFromXPath(v, "name"); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "no"); cValue.Exists() {
+ item.Seq = types.Int64Value(cValue.Int())
+ }
+ if cValue := helpers.GetFromXPath(v, "action"); cValue.Exists() {
+ item.Action = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "ip"); cValue.Exists() {
+ item.Ip = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "ge"); cValue.Exists() {
+ item.Ge = types.Int64Value(cValue.Int())
+ }
+ if cValue := helpers.GetFromXPath(v, "le"); cValue.Exists() {
+ item.Le = types.Int64Value(cValue.Int())
+ }
+ data.Prefixes = append(data.Prefixes, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/prefix-list-description"); value.Exists() {
+ data.PrefixListDescription = make([]PrefixListPrefixListDescription, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := PrefixListPrefixListDescription{}
+ if cValue := helpers.GetFromXPath(v, "name"); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "description"); cValue.Exists() {
+ item.Description = types.StringValue(cValue.String())
+ }
+ data.PrefixListDescription = append(data.PrefixListDescription, item)
+ return true
+ })
+ }
+}
+
+// End of section. //template:end fromBodyDataXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin getDeletedItems
func (data *PrefixList) getDeletedItems(ctx context.Context, state PrefixList) []string {
@@ -413,6 +665,97 @@ func (data *PrefixList) getDeletedItems(ctx context.Context, state PrefixList) [
// End of section. //template:end getDeletedItems
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletedItemsXML
+
+func (data *PrefixList) addDeletedItemsXML(ctx context.Context, state PrefixList, body string) string {
+ b := netconf.NewBody(body)
+ for i := range state.Prefixes {
+ stateKeys := [...]string{"name", "no"}
+ stateKeyValues := [...]string{state.Prefixes[i].Name.ValueString(), strconv.FormatInt(state.Prefixes[i].Seq.ValueInt64(), 10)}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.Prefixes[i].Name.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if !reflect.ValueOf(state.Prefixes[i].Seq.ValueInt64()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.Prefixes {
+ found = true
+ if state.Prefixes[i].Name.ValueString() != data.Prefixes[j].Name.ValueString() {
+ found = false
+ }
+ if state.Prefixes[i].Seq.ValueInt64() != data.Prefixes[j].Seq.ValueInt64() {
+ found = false
+ }
+ if found {
+ if !state.Prefixes[i].Action.IsNull() && data.Prefixes[j].Action.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/prefixes%v/action", predicates))
+ }
+ if !state.Prefixes[i].Ip.IsNull() && data.Prefixes[j].Ip.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/prefixes%v/ip", predicates))
+ }
+ if !state.Prefixes[i].Ge.IsNull() && data.Prefixes[j].Ge.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/prefixes%v/ge", predicates))
+ }
+ if !state.Prefixes[i].Le.IsNull() && data.Prefixes[j].Le.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/prefixes%v/le", predicates))
+ }
+ break
+ }
+ }
+ if !found {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/prefixes%v", predicates))
+ }
+ }
+ for i := range state.PrefixListDescription {
+ stateKeys := [...]string{"name"}
+ stateKeyValues := [...]string{state.PrefixListDescription[i].Name.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.PrefixListDescription[i].Name.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.PrefixListDescription {
+ found = true
+ if state.PrefixListDescription[i].Name.ValueString() != data.PrefixListDescription[j].Name.ValueString() {
+ found = false
+ }
+ if found {
+ if !state.PrefixListDescription[i].Description.IsNull() && data.PrefixListDescription[j].Description.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/prefix-list-description%v/description", predicates))
+ }
+ break
+ }
+ }
+ if !found {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/prefix-list-description%v", predicates))
+ }
+ }
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletedItemsXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin getEmptyLeafsDelete
func (data *PrefixList) getEmptyLeafsDelete(ctx context.Context) []string {
@@ -442,3 +785,33 @@ func (data *PrefixList) getDeletePaths(ctx context.Context) []string {
}
// End of section. //template:end getDeletePaths
+
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletePathsXML
+
+func (data *PrefixList) addDeletePathsXML(ctx context.Context, body string) string {
+ b := netconf.NewBody(body)
+ for i := range data.Prefixes {
+ keys := [...]string{"name", "no"}
+ keyValues := [...]string{data.Prefixes[i].Name.ValueString(), strconv.FormatInt(data.Prefixes[i].Seq.ValueInt64(), 10)}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/prefixes%v", predicates))
+ }
+ for i := range data.PrefixListDescription {
+ keys := [...]string{"name"}
+ keyValues := [...]string{data.PrefixListDescription[i].Name.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/prefix-list-description%v", predicates))
+ }
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletePathsXML
diff --git a/internal/provider/model_iosxe_radius.go b/internal/provider/model_iosxe_radius.go
index f311b6e7..0b4aa440 100644
--- a/internal/provider/model_iosxe_radius.go
+++ b/internal/provider/model_iosxe_radius.go
@@ -29,6 +29,9 @@ import (
"github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/types"
+ "github.com/hashicorp/terraform-plugin-log/tflog"
+ "github.com/netascode/go-netconf"
+ "github.com/netascode/xmldot"
"github.com/tidwall/gjson"
"github.com/tidwall/sjson"
)
@@ -93,6 +96,19 @@ func (data Radius) getPathShort() string {
return matches[1]
}
+// getXPath returns the XPath for NETCONF operations
+func (data Radius) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/radius/Cisco-IOS-XE-aaa:server[id=%v]"
+ path = fmt.Sprintf(path, fmt.Sprintf("%v", data.Name.ValueString()))
+ return path
+}
+
+func (data RadiusData) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/radius/Cisco-IOS-XE-aaa:server[id=%v]"
+ path = fmt.Sprintf(path, fmt.Sprintf("%v", data.Name.ValueString()))
+ return path
+}
+
// End of section. //template:end getPath
// Section below is generated&owned by "gen/generator.go". //template:begin toBody
@@ -144,6 +160,63 @@ func (data Radius) toBody(ctx context.Context) string {
// End of section. //template:end toBody
+// Section below is generated&owned by "gen/generator.go". //template:begin toBodyXML
+
+func (data Radius) toBodyXML(ctx context.Context) string {
+ body := netconf.Body{}
+ if !data.Name.IsNull() && !data.Name.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/id", data.Name.ValueString())
+ }
+ if !data.Ipv4Address.IsNull() && !data.Ipv4Address.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/address/ipv4", data.Ipv4Address.ValueString())
+ }
+ if !data.AuthenticationPort.IsNull() && !data.AuthenticationPort.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/address/auth-port", strconv.FormatInt(data.AuthenticationPort.ValueInt64(), 10))
+ }
+ if !data.AccountingPort.IsNull() && !data.AccountingPort.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/address/acct-port", strconv.FormatInt(data.AccountingPort.ValueInt64(), 10))
+ }
+ if !data.Timeout.IsNull() && !data.Timeout.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/timeout", strconv.FormatInt(data.Timeout.ValueInt64(), 10))
+ }
+ if !data.Retransmit.IsNull() && !data.Retransmit.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/retransmit", strconv.FormatInt(data.Retransmit.ValueInt64(), 10))
+ }
+ if !data.Key.IsNull() && !data.Key.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/key/key", data.Key.ValueString())
+ }
+ if !data.AutomateTesterUsername.IsNull() && !data.AutomateTesterUsername.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/automate-tester/username", data.AutomateTesterUsername.ValueString())
+ }
+ if !data.AutomateTesterIgnoreAcctPort.IsNull() && !data.AutomateTesterIgnoreAcctPort.IsUnknown() {
+ if data.AutomateTesterIgnoreAcctPort.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/automate-tester/ignore-acct-port", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/automate-tester/ignore-acct-port")
+ }
+ }
+ if !data.AutomateTesterProbeOnConfig.IsNull() && !data.AutomateTesterProbeOnConfig.IsUnknown() {
+ if data.AutomateTesterProbeOnConfig.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/automate-tester/probe-on-config", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/automate-tester/probe-on-config")
+ }
+ }
+ if !data.PacKey.IsNull() && !data.PacKey.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/pac/key/key", data.PacKey.ValueString())
+ }
+ if !data.PacKeyEncryption.IsNull() && !data.PacKeyEncryption.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/pac/key/encryption", data.PacKeyEncryption.ValueString())
+ }
+ bodyString, err := body.String()
+ if err != nil {
+ tflog.Error(ctx, fmt.Sprintf("Error converting body to string: %s", err))
+ }
+ return bodyString
+}
+
+// End of section. //template:end toBodyXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBody
func (data *Radius) updateFromBody(ctx context.Context, res gjson.Result) {
@@ -213,6 +286,71 @@ func (data *Radius) updateFromBody(ctx context.Context, res gjson.Result) {
// End of section. //template:end updateFromBody
+// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBodyXML
+
+func (data *Radius) updateFromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/id"); value.Exists() && !data.Name.IsNull() {
+ data.Name = types.StringValue(value.String())
+ } else {
+ data.Name = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/address/ipv4"); value.Exists() && !data.Ipv4Address.IsNull() {
+ data.Ipv4Address = types.StringValue(value.String())
+ } else {
+ data.Ipv4Address = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/address/auth-port"); value.Exists() && !data.AuthenticationPort.IsNull() {
+ data.AuthenticationPort = types.Int64Value(value.Int())
+ } else {
+ data.AuthenticationPort = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/address/acct-port"); value.Exists() && !data.AccountingPort.IsNull() {
+ data.AccountingPort = types.Int64Value(value.Int())
+ } else {
+ data.AccountingPort = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/timeout"); value.Exists() && !data.Timeout.IsNull() {
+ data.Timeout = types.Int64Value(value.Int())
+ } else {
+ data.Timeout = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/retransmit"); value.Exists() && !data.Retransmit.IsNull() {
+ data.Retransmit = types.Int64Value(value.Int())
+ } else {
+ data.Retransmit = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/automate-tester/username"); value.Exists() && !data.AutomateTesterUsername.IsNull() {
+ data.AutomateTesterUsername = types.StringValue(value.String())
+ } else {
+ data.AutomateTesterUsername = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/automate-tester/ignore-acct-port"); !data.AutomateTesterIgnoreAcctPort.IsNull() {
+ if value.Exists() {
+ data.AutomateTesterIgnoreAcctPort = types.BoolValue(true)
+ } else {
+ data.AutomateTesterIgnoreAcctPort = types.BoolValue(false)
+ }
+ } else {
+ data.AutomateTesterIgnoreAcctPort = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/automate-tester/probe-on-config"); !data.AutomateTesterProbeOnConfig.IsNull() {
+ if value.Exists() {
+ data.AutomateTesterProbeOnConfig = types.BoolValue(true)
+ } else {
+ data.AutomateTesterProbeOnConfig = types.BoolValue(false)
+ }
+ } else {
+ data.AutomateTesterProbeOnConfig = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/pac/key/encryption"); value.Exists() && !data.PacKeyEncryption.IsNull() {
+ data.PacKeyEncryption = types.StringValue(value.String())
+ } else {
+ data.PacKeyEncryption = types.StringNull()
+ }
+}
+
+// End of section. //template:end updateFromBodyXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin fromBody
func (data *Radius) fromBody(ctx context.Context, res gjson.Result) {
@@ -309,6 +447,94 @@ func (data *RadiusData) fromBody(ctx context.Context, res gjson.Result) {
// End of section. //template:end fromBodyData
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyXML
+
+func (data *Radius) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/address/ipv4"); value.Exists() {
+ data.Ipv4Address = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/address/auth-port"); value.Exists() {
+ data.AuthenticationPort = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/address/acct-port"); value.Exists() {
+ data.AccountingPort = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/timeout"); value.Exists() {
+ data.Timeout = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/retransmit"); value.Exists() {
+ data.Retransmit = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/key/key"); value.Exists() {
+ data.Key = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/automate-tester/username"); value.Exists() {
+ data.AutomateTesterUsername = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/automate-tester/ignore-acct-port"); value.Exists() {
+ data.AutomateTesterIgnoreAcctPort = types.BoolValue(true)
+ } else {
+ data.AutomateTesterIgnoreAcctPort = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/automate-tester/probe-on-config"); value.Exists() {
+ data.AutomateTesterProbeOnConfig = types.BoolValue(true)
+ } else {
+ data.AutomateTesterProbeOnConfig = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/pac/key/key"); value.Exists() {
+ data.PacKey = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/pac/key/encryption"); value.Exists() {
+ data.PacKeyEncryption = types.StringValue(value.String())
+ }
+}
+
+// End of section. //template:end fromBodyXML
+
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyDataXML
+
+func (data *RadiusData) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/address/ipv4"); value.Exists() {
+ data.Ipv4Address = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/address/auth-port"); value.Exists() {
+ data.AuthenticationPort = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/address/acct-port"); value.Exists() {
+ data.AccountingPort = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/timeout"); value.Exists() {
+ data.Timeout = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/retransmit"); value.Exists() {
+ data.Retransmit = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/key/key"); value.Exists() {
+ data.Key = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/automate-tester/username"); value.Exists() {
+ data.AutomateTesterUsername = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/automate-tester/ignore-acct-port"); value.Exists() {
+ data.AutomateTesterIgnoreAcctPort = types.BoolValue(true)
+ } else {
+ data.AutomateTesterIgnoreAcctPort = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/automate-tester/probe-on-config"); value.Exists() {
+ data.AutomateTesterProbeOnConfig = types.BoolValue(true)
+ } else {
+ data.AutomateTesterProbeOnConfig = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/pac/key/key"); value.Exists() {
+ data.PacKey = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/pac/key/encryption"); value.Exists() {
+ data.PacKeyEncryption = types.StringValue(value.String())
+ }
+}
+
+// End of section. //template:end fromBodyDataXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin getDeletedItems
func (data *Radius) getDeletedItems(ctx context.Context, state Radius) []string {
@@ -352,6 +578,49 @@ func (data *Radius) getDeletedItems(ctx context.Context, state Radius) []string
// End of section. //template:end getDeletedItems
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletedItemsXML
+
+func (data *Radius) addDeletedItemsXML(ctx context.Context, state Radius, body string) string {
+ b := netconf.NewBody(body)
+ if !state.Ipv4Address.IsNull() && data.Ipv4Address.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/address/ipv4")
+ }
+ if !state.AuthenticationPort.IsNull() && data.AuthenticationPort.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/address/auth-port")
+ }
+ if !state.AccountingPort.IsNull() && data.AccountingPort.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/address/acct-port")
+ }
+ if !state.Timeout.IsNull() && data.Timeout.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/timeout")
+ }
+ if !state.Retransmit.IsNull() && data.Retransmit.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/retransmit")
+ }
+ if !state.Key.IsNull() && data.Key.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/key/key")
+ }
+ if !state.AutomateTesterUsername.IsNull() && data.AutomateTesterUsername.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/automate-tester/username")
+ }
+ if !state.AutomateTesterIgnoreAcctPort.IsNull() && data.AutomateTesterIgnoreAcctPort.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/automate-tester/ignore-acct-port")
+ }
+ if !state.AutomateTesterProbeOnConfig.IsNull() && data.AutomateTesterProbeOnConfig.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/automate-tester/probe-on-config")
+ }
+ if !state.PacKey.IsNull() && data.PacKey.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/pac/key/key")
+ }
+ if !state.PacKeyEncryption.IsNull() && data.PacKeyEncryption.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/pac/key/encryption")
+ }
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletedItemsXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin getEmptyLeafsDelete
func (data *Radius) getEmptyLeafsDelete(ctx context.Context) []string {
@@ -410,3 +679,46 @@ func (data *Radius) getDeletePaths(ctx context.Context) []string {
}
// End of section. //template:end getDeletePaths
+
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletePathsXML
+
+func (data *Radius) addDeletePathsXML(ctx context.Context, body string) string {
+ b := netconf.NewBody(body)
+ if !data.Ipv4Address.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/address/ipv4")
+ }
+ if !data.AuthenticationPort.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/address/auth-port")
+ }
+ if !data.AccountingPort.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/address/acct-port")
+ }
+ if !data.Timeout.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/timeout")
+ }
+ if !data.Retransmit.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/retransmit")
+ }
+ if !data.Key.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/key/key")
+ }
+ if !data.AutomateTesterUsername.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/automate-tester/username")
+ }
+ if !data.AutomateTesterIgnoreAcctPort.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/automate-tester/ignore-acct-port")
+ }
+ if !data.AutomateTesterProbeOnConfig.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/automate-tester/probe-on-config")
+ }
+ if !data.PacKey.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/pac/key/key")
+ }
+ if !data.PacKeyEncryption.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/pac/key/encryption")
+ }
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletePathsXML
diff --git a/internal/provider/model_iosxe_radius_server.go b/internal/provider/model_iosxe_radius_server.go
index be57579d..1dbb07e8 100644
--- a/internal/provider/model_iosxe_radius_server.go
+++ b/internal/provider/model_iosxe_radius_server.go
@@ -30,6 +30,9 @@ import (
"github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/types"
+ "github.com/hashicorp/terraform-plugin-log/tflog"
+ "github.com/netascode/go-netconf"
+ "github.com/netascode/xmldot"
"github.com/tidwall/gjson"
"github.com/tidwall/sjson"
)
@@ -91,6 +94,17 @@ func (data RadiusServer) getPathShort() string {
return matches[1]
}
+// getXPath returns the XPath for NETCONF operations
+func (data RadiusServer) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/radius-server"
+ return path
+}
+
+func (data RadiusServerData) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/radius-server"
+ return path
+}
+
// End of section. //template:end getPath
// Section below is generated&owned by "gen/generator.go". //template:begin toBody
@@ -153,6 +167,80 @@ func (data RadiusServer) toBody(ctx context.Context) string {
// End of section. //template:end toBody
+// Section below is generated&owned by "gen/generator.go". //template:begin toBodyXML
+
+func (data RadiusServer) toBodyXML(ctx context.Context) string {
+ body := netconf.Body{}
+ if len(data.Attributes) > 0 {
+ for _, item := range data.Attributes {
+ cBody := netconf.Body{}
+ if !item.Number.IsNull() && !item.Number.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "number", item.Number.ValueString())
+ }
+ if !item.AccessRequestInclude.IsNull() && !item.AccessRequestInclude.IsUnknown() {
+ if item.AccessRequestInclude.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "access-request/include", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "access-request/include")
+ }
+ }
+ if len(item.Attribute31Parameters) > 0 {
+ for _, citem := range item.Attribute31Parameters {
+ ccBody := netconf.Body{}
+ if !citem.CallingStationId.IsNull() && !citem.CallingStationId.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "calling-station-id", citem.CallingStationId.ValueString())
+ }
+ if !citem.IdMacFormat.IsNull() && !citem.IdMacFormat.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "id-mac/format", citem.IdMacFormat.ValueString())
+ }
+ if !citem.IdMacLuCase.IsNull() && !citem.IdMacLuCase.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "id-mac/lu-case", citem.IdMacLuCase.ValueString())
+ }
+ if !citem.IdSendNasPortDetail.IsNull() && !citem.IdSendNasPortDetail.IsUnknown() {
+ if citem.IdSendNasPortDetail.ValueBool() {
+ ccBody = helpers.SetFromXPath(ccBody, "id-send/nas-port-detail", "")
+ } else {
+ ccBody = helpers.RemoveFromXPath(ccBody, "id-send/nas-port-detail")
+ }
+ }
+ if !citem.IdSendMacOnly.IsNull() && !citem.IdSendMacOnly.IsUnknown() {
+ if citem.IdSendMacOnly.ValueBool() {
+ ccBody = helpers.SetFromXPath(ccBody, "id-send/mac-only", "")
+ } else {
+ ccBody = helpers.RemoveFromXPath(ccBody, "id-send/mac-only")
+ }
+ }
+ cBody = helpers.SetRawFromXPath(cBody, "attri31/attri31-list", ccBody.Res())
+ }
+ }
+ if !item.SendAttributes.IsNull() && !item.SendAttributes.IsUnknown() {
+ var values []string
+ item.SendAttributes.ElementsAs(ctx, &values, false)
+ for _, v := range values {
+ cBody = helpers.AppendFromXPath(cBody, "send-attribute", v)
+ }
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-aaa:attribute", cBody.Res())
+ }
+ }
+ if !data.DeadCriteriaTime.IsNull() && !data.DeadCriteriaTime.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-aaa:dead-criteria/time", strconv.FormatInt(data.DeadCriteriaTime.ValueInt64(), 10))
+ }
+ if !data.DeadCriteriaTries.IsNull() && !data.DeadCriteriaTries.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-aaa:dead-criteria/tries", strconv.FormatInt(data.DeadCriteriaTries.ValueInt64(), 10))
+ }
+ if !data.Deadtime.IsNull() && !data.Deadtime.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-aaa:deadtime", strconv.FormatInt(data.Deadtime.ValueInt64(), 10))
+ }
+ bodyString, err := body.String()
+ if err != nil {
+ tflog.Error(ctx, fmt.Sprintf("Error converting body to string: %s", err))
+ }
+ return bodyString
+}
+
+// End of section. //template:end toBodyXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBody
func (data *RadiusServer) updateFromBody(ctx context.Context, res gjson.Result) {
@@ -279,6 +367,128 @@ func (data *RadiusServer) updateFromBody(ctx context.Context, res gjson.Result)
// End of section. //template:end updateFromBody
+// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBodyXML
+
+func (data *RadiusServer) updateFromBodyXML(ctx context.Context, res xmldot.Result) {
+ for i := range data.Attributes {
+ keys := [...]string{"number"}
+ keyValues := [...]string{data.Attributes[i].Number.ValueString()}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-aaa:attribute").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, "number"); value.Exists() && !data.Attributes[i].Number.IsNull() {
+ data.Attributes[i].Number = types.StringValue(value.String())
+ } else {
+ data.Attributes[i].Number = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "access-request/include"); !data.Attributes[i].AccessRequestInclude.IsNull() {
+ if value.Exists() {
+ data.Attributes[i].AccessRequestInclude = types.BoolValue(true)
+ } else {
+ data.Attributes[i].AccessRequestInclude = types.BoolValue(false)
+ }
+ } else {
+ data.Attributes[i].AccessRequestInclude = types.BoolNull()
+ }
+ for ci := range data.Attributes[i].Attribute31Parameters {
+ keys := [...]string{"calling-station-id"}
+ keyValues := [...]string{data.Attributes[i].Attribute31Parameters[ci].CallingStationId.ValueString()}
+
+ var cr xmldot.Result
+ helpers.GetFromXPath(r, "attri31/attri31-list").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ cr = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(cr, "calling-station-id"); value.Exists() && !data.Attributes[i].Attribute31Parameters[ci].CallingStationId.IsNull() {
+ data.Attributes[i].Attribute31Parameters[ci].CallingStationId = types.StringValue(value.String())
+ } else {
+ data.Attributes[i].Attribute31Parameters[ci].CallingStationId = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(cr, "id-mac/format"); value.Exists() && !data.Attributes[i].Attribute31Parameters[ci].IdMacFormat.IsNull() {
+ data.Attributes[i].Attribute31Parameters[ci].IdMacFormat = types.StringValue(value.String())
+ } else {
+ data.Attributes[i].Attribute31Parameters[ci].IdMacFormat = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(cr, "id-mac/lu-case"); value.Exists() && !data.Attributes[i].Attribute31Parameters[ci].IdMacLuCase.IsNull() {
+ data.Attributes[i].Attribute31Parameters[ci].IdMacLuCase = types.StringValue(value.String())
+ } else {
+ data.Attributes[i].Attribute31Parameters[ci].IdMacLuCase = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(cr, "id-send/nas-port-detail"); !data.Attributes[i].Attribute31Parameters[ci].IdSendNasPortDetail.IsNull() {
+ if value.Exists() {
+ data.Attributes[i].Attribute31Parameters[ci].IdSendNasPortDetail = types.BoolValue(true)
+ } else {
+ data.Attributes[i].Attribute31Parameters[ci].IdSendNasPortDetail = types.BoolValue(false)
+ }
+ } else {
+ data.Attributes[i].Attribute31Parameters[ci].IdSendNasPortDetail = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(cr, "id-send/mac-only"); !data.Attributes[i].Attribute31Parameters[ci].IdSendMacOnly.IsNull() {
+ if value.Exists() {
+ data.Attributes[i].Attribute31Parameters[ci].IdSendMacOnly = types.BoolValue(true)
+ } else {
+ data.Attributes[i].Attribute31Parameters[ci].IdSendMacOnly = types.BoolValue(false)
+ }
+ } else {
+ data.Attributes[i].Attribute31Parameters[ci].IdSendMacOnly = types.BoolNull()
+ }
+ }
+ if value := helpers.GetFromXPath(r, "send-attribute"); value.Exists() && !data.Attributes[i].SendAttributes.IsNull() {
+ data.Attributes[i].SendAttributes = helpers.GetStringListXML(value.Array())
+ } else {
+ data.Attributes[i].SendAttributes = types.ListNull(types.StringType)
+ }
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-aaa:dead-criteria/time"); value.Exists() && !data.DeadCriteriaTime.IsNull() {
+ data.DeadCriteriaTime = types.Int64Value(value.Int())
+ } else {
+ data.DeadCriteriaTime = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-aaa:dead-criteria/tries"); value.Exists() && !data.DeadCriteriaTries.IsNull() {
+ data.DeadCriteriaTries = types.Int64Value(value.Int())
+ } else {
+ data.DeadCriteriaTries = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-aaa:deadtime"); value.Exists() && !data.Deadtime.IsNull() {
+ data.Deadtime = types.Int64Value(value.Int())
+ } else {
+ data.Deadtime = types.Int64Null()
+ }
+}
+
+// End of section. //template:end updateFromBodyXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin fromBody
func (data *RadiusServer) fromBody(ctx context.Context, res gjson.Result) {
@@ -415,6 +625,134 @@ func (data *RadiusServerData) fromBody(ctx context.Context, res gjson.Result) {
// End of section. //template:end fromBodyData
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyXML
+
+func (data *RadiusServer) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-aaa:attribute"); value.Exists() {
+ data.Attributes = make([]RadiusServerAttributes, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := RadiusServerAttributes{}
+ if cValue := helpers.GetFromXPath(v, "number"); cValue.Exists() {
+ item.Number = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "access-request/include"); cValue.Exists() {
+ item.AccessRequestInclude = types.BoolValue(true)
+ } else {
+ item.AccessRequestInclude = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "attri31/attri31-list"); cValue.Exists() {
+ item.Attribute31Parameters = make([]RadiusServerAttributesAttribute31Parameters, 0)
+ cValue.ForEach(func(_ int, cv xmldot.Result) bool {
+ cItem := RadiusServerAttributesAttribute31Parameters{}
+ if ccValue := helpers.GetFromXPath(cv, "calling-station-id"); ccValue.Exists() {
+ cItem.CallingStationId = types.StringValue(ccValue.String())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "id-mac/format"); ccValue.Exists() {
+ cItem.IdMacFormat = types.StringValue(ccValue.String())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "id-mac/lu-case"); ccValue.Exists() {
+ cItem.IdMacLuCase = types.StringValue(ccValue.String())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "id-send/nas-port-detail"); ccValue.Exists() {
+ cItem.IdSendNasPortDetail = types.BoolValue(true)
+ } else {
+ cItem.IdSendNasPortDetail = types.BoolValue(false)
+ }
+ if ccValue := helpers.GetFromXPath(cv, "id-send/mac-only"); ccValue.Exists() {
+ cItem.IdSendMacOnly = types.BoolValue(true)
+ } else {
+ cItem.IdSendMacOnly = types.BoolValue(false)
+ }
+ item.Attribute31Parameters = append(item.Attribute31Parameters, cItem)
+ return true
+ })
+ }
+ if cValue := helpers.GetFromXPath(v, "send-attribute"); cValue.Exists() {
+ item.SendAttributes = helpers.GetStringListXML(cValue.Array())
+ } else {
+ item.SendAttributes = types.ListNull(types.StringType)
+ }
+ data.Attributes = append(data.Attributes, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-aaa:dead-criteria/time"); value.Exists() {
+ data.DeadCriteriaTime = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-aaa:dead-criteria/tries"); value.Exists() {
+ data.DeadCriteriaTries = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-aaa:deadtime"); value.Exists() {
+ data.Deadtime = types.Int64Value(value.Int())
+ }
+}
+
+// End of section. //template:end fromBodyXML
+
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyDataXML
+
+func (data *RadiusServerData) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-aaa:attribute"); value.Exists() {
+ data.Attributes = make([]RadiusServerAttributes, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := RadiusServerAttributes{}
+ if cValue := helpers.GetFromXPath(v, "number"); cValue.Exists() {
+ item.Number = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "access-request/include"); cValue.Exists() {
+ item.AccessRequestInclude = types.BoolValue(true)
+ } else {
+ item.AccessRequestInclude = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "attri31/attri31-list"); cValue.Exists() {
+ item.Attribute31Parameters = make([]RadiusServerAttributesAttribute31Parameters, 0)
+ cValue.ForEach(func(_ int, cv xmldot.Result) bool {
+ cItem := RadiusServerAttributesAttribute31Parameters{}
+ if ccValue := helpers.GetFromXPath(cv, "calling-station-id"); ccValue.Exists() {
+ cItem.CallingStationId = types.StringValue(ccValue.String())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "id-mac/format"); ccValue.Exists() {
+ cItem.IdMacFormat = types.StringValue(ccValue.String())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "id-mac/lu-case"); ccValue.Exists() {
+ cItem.IdMacLuCase = types.StringValue(ccValue.String())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "id-send/nas-port-detail"); ccValue.Exists() {
+ cItem.IdSendNasPortDetail = types.BoolValue(true)
+ } else {
+ cItem.IdSendNasPortDetail = types.BoolValue(false)
+ }
+ if ccValue := helpers.GetFromXPath(cv, "id-send/mac-only"); ccValue.Exists() {
+ cItem.IdSendMacOnly = types.BoolValue(true)
+ } else {
+ cItem.IdSendMacOnly = types.BoolValue(false)
+ }
+ item.Attribute31Parameters = append(item.Attribute31Parameters, cItem)
+ return true
+ })
+ }
+ if cValue := helpers.GetFromXPath(v, "send-attribute"); cValue.Exists() {
+ item.SendAttributes = helpers.GetStringListXML(cValue.Array())
+ } else {
+ item.SendAttributes = types.ListNull(types.StringType)
+ }
+ data.Attributes = append(data.Attributes, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-aaa:dead-criteria/time"); value.Exists() {
+ data.DeadCriteriaTime = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-aaa:dead-criteria/tries"); value.Exists() {
+ data.DeadCriteriaTries = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-aaa:deadtime"); value.Exists() {
+ data.Deadtime = types.Int64Value(value.Int())
+ }
+}
+
+// End of section. //template:end fromBodyDataXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin getDeletedItems
func (data *RadiusServer) getDeletedItems(ctx context.Context, state RadiusServer) []string {
@@ -520,6 +858,121 @@ func (data *RadiusServer) getDeletedItems(ctx context.Context, state RadiusServe
// End of section. //template:end getDeletedItems
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletedItemsXML
+
+func (data *RadiusServer) addDeletedItemsXML(ctx context.Context, state RadiusServer, body string) string {
+ b := netconf.NewBody(body)
+ for i := range state.Attributes {
+ stateKeys := [...]string{"number"}
+ stateKeyValues := [...]string{state.Attributes[i].Number.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.Attributes[i].Number.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.Attributes {
+ found = true
+ if state.Attributes[i].Number.ValueString() != data.Attributes[j].Number.ValueString() {
+ found = false
+ }
+ if found {
+ if !state.Attributes[i].AccessRequestInclude.IsNull() && data.Attributes[j].AccessRequestInclude.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-aaa:attribute%v/access-request/include", predicates))
+ }
+ for ci := range state.Attributes[i].Attribute31Parameters {
+ cstateKeys := [...]string{"calling-station-id"}
+ cstateKeyValues := [...]string{state.Attributes[i].Attribute31Parameters[ci].CallingStationId.ValueString()}
+ cpredicates := ""
+ for i := range cstateKeys {
+ cpredicates += fmt.Sprintf("[%s='%s']", cstateKeys[i], cstateKeyValues[i])
+ }
+
+ cemptyKeys := true
+ if !reflect.ValueOf(state.Attributes[i].Attribute31Parameters[ci].CallingStationId.ValueString()).IsZero() {
+ cemptyKeys = false
+ }
+ if cemptyKeys {
+ continue
+ }
+
+ found := false
+ for cj := range data.Attributes[j].Attribute31Parameters {
+ found = true
+ if state.Attributes[i].Attribute31Parameters[ci].CallingStationId.ValueString() != data.Attributes[j].Attribute31Parameters[cj].CallingStationId.ValueString() {
+ found = false
+ }
+ if found {
+ if !state.Attributes[i].Attribute31Parameters[ci].IdMacFormat.IsNull() && data.Attributes[j].Attribute31Parameters[cj].IdMacFormat.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-aaa:attribute%v/attri31/attri31-list%v/id-mac/format", predicates, cpredicates))
+ }
+ if !state.Attributes[i].Attribute31Parameters[ci].IdMacLuCase.IsNull() && data.Attributes[j].Attribute31Parameters[cj].IdMacLuCase.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-aaa:attribute%v/attri31/attri31-list%v/id-mac/lu-case", predicates, cpredicates))
+ }
+ if !state.Attributes[i].Attribute31Parameters[ci].IdSendNasPortDetail.IsNull() && data.Attributes[j].Attribute31Parameters[cj].IdSendNasPortDetail.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-aaa:attribute%v/attri31/attri31-list%v/id-send/nas-port-detail", predicates, cpredicates))
+ }
+ if !state.Attributes[i].Attribute31Parameters[ci].IdSendMacOnly.IsNull() && data.Attributes[j].Attribute31Parameters[cj].IdSendMacOnly.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-aaa:attribute%v/attri31/attri31-list%v/id-send/mac-only", predicates, cpredicates))
+ }
+ break
+ }
+ }
+ if !found {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-aaa:attribute%v/attri31/attri31-list%v", predicates, cpredicates))
+ }
+ }
+ if !state.Attributes[i].SendAttributes.IsNull() {
+ if data.Attributes[j].SendAttributes.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-aaa:attribute%v/send-attribute", predicates))
+ } else {
+ var dataValues, stateValues []string
+ data.Attributes[i].SendAttributes.ElementsAs(ctx, &dataValues, false)
+ state.Attributes[j].SendAttributes.ElementsAs(ctx, &stateValues, false)
+ for _, v := range stateValues {
+ found := false
+ for _, vv := range dataValues {
+ if v == vv {
+ found = true
+ break
+ }
+ }
+ if !found {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-aaa:attribute%v/send-attribute[.=%v]", predicates, v))
+ }
+ }
+ }
+ }
+ break
+ }
+ }
+ if !found {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-aaa:attribute%v", predicates))
+ }
+ }
+ if !state.DeadCriteriaTime.IsNull() && data.DeadCriteriaTime.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-aaa:dead-criteria/time")
+ }
+ if !state.DeadCriteriaTries.IsNull() && data.DeadCriteriaTries.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-aaa:dead-criteria/tries")
+ }
+ if !state.Deadtime.IsNull() && data.Deadtime.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-aaa:deadtime")
+ }
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletedItemsXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin getEmptyLeafsDelete
func (data *RadiusServer) getEmptyLeafsDelete(ctx context.Context) []string {
@@ -570,3 +1023,32 @@ func (data *RadiusServer) getDeletePaths(ctx context.Context) []string {
}
// End of section. //template:end getDeletePaths
+
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletePathsXML
+
+func (data *RadiusServer) addDeletePathsXML(ctx context.Context, body string) string {
+ b := netconf.NewBody(body)
+ for i := range data.Attributes {
+ keys := [...]string{"number"}
+ keyValues := [...]string{data.Attributes[i].Number.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/Cisco-IOS-XE-aaa:attribute%v", predicates))
+ }
+ if !data.DeadCriteriaTime.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-aaa:dead-criteria/time")
+ }
+ if !data.DeadCriteriaTries.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-aaa:dead-criteria/tries")
+ }
+ if !data.Deadtime.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-aaa:deadtime")
+ }
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletePathsXML
diff --git a/internal/provider/model_iosxe_route_map.go b/internal/provider/model_iosxe_route_map.go
index c5e90a65..a04ab2d5 100644
--- a/internal/provider/model_iosxe_route_map.go
+++ b/internal/provider/model_iosxe_route_map.go
@@ -31,6 +31,9 @@ import (
"github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/types"
+ "github.com/hashicorp/terraform-plugin-log/tflog"
+ "github.com/netascode/go-netconf"
+ "github.com/netascode/xmldot"
"github.com/tidwall/gjson"
"github.com/tidwall/sjson"
)
@@ -181,6 +184,19 @@ func (data RouteMap) getPathShort() string {
return matches[1]
}
+// getXPath returns the XPath for NETCONF operations
+func (data RouteMap) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/route-map[name=%v]"
+ path = fmt.Sprintf(path, fmt.Sprintf("%v", data.Name.ValueString()))
+ return path
+}
+
+func (data RouteMapData) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/route-map[name=%v]"
+ path = fmt.Sprintf(path, fmt.Sprintf("%v", data.Name.ValueString()))
+ return path
+}
+
// End of section. //template:end getPath
// Section below is generated&owned by "gen/generator.go". //template:begin toBody
@@ -630,1605 +646,4681 @@ func (data RouteMap) toBody(ctx context.Context) string {
// End of section. //template:end toBody
-// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBody
+// Section below is generated&owned by "gen/generator.go". //template:begin toBodyXML
-func (data *RouteMap) updateFromBody(ctx context.Context, res gjson.Result) {
- prefix := helpers.LastElement(data.getPath()) + "."
- if res.Get(helpers.LastElement(data.getPath())).IsArray() {
- prefix += "0."
- }
- if value := res.Get(prefix + "name"); value.Exists() && !data.Name.IsNull() {
- data.Name = types.StringValue(value.String())
- } else {
- data.Name = types.StringNull()
+func (data RouteMap) toBodyXML(ctx context.Context) string {
+ body := netconf.Body{}
+ if !data.Name.IsNull() && !data.Name.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/name", data.Name.ValueString())
}
- for i := range data.Entries {
- keys := [...]string{"seq_no"}
- keyValues := [...]string{strconv.FormatInt(data.Entries[i].Seq.ValueInt64(), 10)}
-
- var r gjson.Result
- res.Get(prefix + "Cisco-IOS-XE-route-map:route-map-without-order-seq").ForEach(
- func(_, v gjson.Result) bool {
- found := false
- for ik := range keys {
- if v.Get(keys[ik]).String() == keyValues[ik] {
- found = true
- continue
- }
- found = false
- break
+ if len(data.Entries) > 0 {
+ for _, item := range data.Entries {
+ cBody := netconf.Body{}
+ if !item.Seq.IsNull() && !item.Seq.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "seq_no", strconv.FormatInt(item.Seq.ValueInt64(), 10))
+ }
+ if !item.Operation.IsNull() && !item.Operation.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "operation", item.Operation.ValueString())
+ }
+ if !item.Description.IsNull() && !item.Description.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "description", item.Description.ValueString())
+ }
+ if !item.Continue.IsNull() && !item.Continue.IsUnknown() {
+ if item.Continue.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "continue", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "continue")
}
- if found {
- r = v
- return false
+ }
+ if !item.ContinueSequenceNumber.IsNull() && !item.ContinueSequenceNumber.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "continue/sequence-number", strconv.FormatInt(item.ContinueSequenceNumber.ValueInt64(), 10))
+ }
+ if !item.MatchInterfaces.IsNull() && !item.MatchInterfaces.IsUnknown() {
+ var values []string
+ item.MatchInterfaces.ElementsAs(ctx, &values, false)
+ for _, v := range values {
+ cBody = helpers.AppendFromXPath(cBody, "match/interface/interface", v)
}
- return true
- },
- )
- if value := r.Get("seq_no"); value.Exists() && !data.Entries[i].Seq.IsNull() {
- data.Entries[i].Seq = types.Int64Value(value.Int())
- } else {
- data.Entries[i].Seq = types.Int64Null()
- }
- if value := r.Get("operation"); value.Exists() && !data.Entries[i].Operation.IsNull() {
- data.Entries[i].Operation = types.StringValue(value.String())
- } else {
- data.Entries[i].Operation = types.StringNull()
- }
- if value := r.Get("description"); value.Exists() && !data.Entries[i].Description.IsNull() {
- data.Entries[i].Description = types.StringValue(value.String())
- } else {
- data.Entries[i].Description = types.StringNull()
- }
- if value := r.Get("continue"); !data.Entries[i].Continue.IsNull() {
- if value.Exists() {
- data.Entries[i].Continue = types.BoolValue(true)
- } else {
- data.Entries[i].Continue = types.BoolValue(false)
}
- } else {
- data.Entries[i].Continue = types.BoolNull()
- }
- if value := r.Get("continue.sequence-number"); value.Exists() && !data.Entries[i].ContinueSequenceNumber.IsNull() {
- data.Entries[i].ContinueSequenceNumber = types.Int64Value(value.Int())
- } else {
- data.Entries[i].ContinueSequenceNumber = types.Int64Null()
- }
- if value := r.Get("match.interface.interface"); value.Exists() && !data.Entries[i].MatchInterfaces.IsNull() {
- data.Entries[i].MatchInterfaces = helpers.GetStringList(value.Array())
- } else {
- data.Entries[i].MatchInterfaces = types.ListNull(types.StringType)
- }
- if value := r.Get("match.ip.address.access-list"); value.Exists() && !data.Entries[i].MatchIpAddressAccessLists.IsNull() {
- data.Entries[i].MatchIpAddressAccessLists = helpers.GetStringList(value.Array())
- } else {
- data.Entries[i].MatchIpAddressAccessLists = types.ListNull(types.StringType)
- }
- if value := r.Get("match.ip.address.prefix-list"); value.Exists() && !data.Entries[i].MatchIpAddressPrefixLists.IsNull() {
- data.Entries[i].MatchIpAddressPrefixLists = helpers.GetStringList(value.Array())
- } else {
- data.Entries[i].MatchIpAddressPrefixLists = types.ListNull(types.StringType)
- }
- if value := r.Get("match.ip.next-hop.access-list"); value.Exists() && !data.Entries[i].MatchIpNextHopAccessLists.IsNull() {
- data.Entries[i].MatchIpNextHopAccessLists = helpers.GetStringList(value.Array())
- } else {
- data.Entries[i].MatchIpNextHopAccessLists = types.ListNull(types.StringType)
- }
- if value := r.Get("match.ip.next-hop.prefix-list"); value.Exists() && !data.Entries[i].MatchIpNextHopPrefixLists.IsNull() {
- data.Entries[i].MatchIpNextHopPrefixLists = helpers.GetStringList(value.Array())
- } else {
- data.Entries[i].MatchIpNextHopPrefixLists = types.ListNull(types.StringType)
- }
- if value := r.Get("match.ipv6.address.access-list"); value.Exists() && !data.Entries[i].MatchIpv6AddressAccessLists.IsNull() {
- data.Entries[i].MatchIpv6AddressAccessLists = types.StringValue(value.String())
- } else {
- data.Entries[i].MatchIpv6AddressAccessLists = types.StringNull()
- }
- if value := r.Get("match.ipv6.address.prefix-list"); value.Exists() && !data.Entries[i].MatchIpv6AddressPrefixLists.IsNull() {
- data.Entries[i].MatchIpv6AddressPrefixLists = types.StringValue(value.String())
- } else {
- data.Entries[i].MatchIpv6AddressPrefixLists = types.StringNull()
- }
- if value := r.Get("match.ipv6.next-hop.access-list"); value.Exists() && !data.Entries[i].MatchIpv6NextHopAccessLists.IsNull() {
- data.Entries[i].MatchIpv6NextHopAccessLists = types.StringValue(value.String())
- } else {
- data.Entries[i].MatchIpv6NextHopAccessLists = types.StringNull()
- }
- if value := r.Get("match.ipv6.next-hop.prefix-list"); value.Exists() && !data.Entries[i].MatchIpv6NextHopPrefixLists.IsNull() {
- data.Entries[i].MatchIpv6NextHopPrefixLists = types.StringValue(value.String())
- } else {
- data.Entries[i].MatchIpv6NextHopPrefixLists = types.StringNull()
- }
- if value := r.Get("match.route-type.external"); !data.Entries[i].MatchRouteTypeExternal.IsNull() {
- if value.Exists() {
- data.Entries[i].MatchRouteTypeExternal = types.BoolValue(true)
- } else {
- data.Entries[i].MatchRouteTypeExternal = types.BoolValue(false)
+ if !item.MatchIpAddressAccessLists.IsNull() && !item.MatchIpAddressAccessLists.IsUnknown() {
+ var values []string
+ item.MatchIpAddressAccessLists.ElementsAs(ctx, &values, false)
+ for _, v := range values {
+ cBody = helpers.AppendFromXPath(cBody, "match/ip/address/access-list", v)
+ }
}
- } else {
- data.Entries[i].MatchRouteTypeExternal = types.BoolNull()
- }
- if value := r.Get("match.route-type.external.type-1"); !data.Entries[i].MatchRouteTypeExternalType1.IsNull() {
- if value.Exists() {
- data.Entries[i].MatchRouteTypeExternalType1 = types.BoolValue(true)
- } else {
- data.Entries[i].MatchRouteTypeExternalType1 = types.BoolValue(false)
+ if !item.MatchIpAddressPrefixLists.IsNull() && !item.MatchIpAddressPrefixLists.IsUnknown() {
+ var values []string
+ item.MatchIpAddressPrefixLists.ElementsAs(ctx, &values, false)
+ for _, v := range values {
+ cBody = helpers.AppendFromXPath(cBody, "match/ip/address/prefix-list", v)
+ }
}
- } else {
- data.Entries[i].MatchRouteTypeExternalType1 = types.BoolNull()
- }
- if value := r.Get("match.route-type.external.type-2"); !data.Entries[i].MatchRouteTypeExternalType2.IsNull() {
- if value.Exists() {
- data.Entries[i].MatchRouteTypeExternalType2 = types.BoolValue(true)
- } else {
- data.Entries[i].MatchRouteTypeExternalType2 = types.BoolValue(false)
+ if !item.MatchIpNextHopAccessLists.IsNull() && !item.MatchIpNextHopAccessLists.IsUnknown() {
+ var values []string
+ item.MatchIpNextHopAccessLists.ElementsAs(ctx, &values, false)
+ for _, v := range values {
+ cBody = helpers.AppendFromXPath(cBody, "match/ip/next-hop/access-list", v)
+ }
}
- } else {
- data.Entries[i].MatchRouteTypeExternalType2 = types.BoolNull()
- }
- if value := r.Get("match.route-type.internal"); !data.Entries[i].MatchRouteTypeInternal.IsNull() {
- if value.Exists() {
- data.Entries[i].MatchRouteTypeInternal = types.BoolValue(true)
- } else {
- data.Entries[i].MatchRouteTypeInternal = types.BoolValue(false)
+ if !item.MatchIpNextHopPrefixLists.IsNull() && !item.MatchIpNextHopPrefixLists.IsUnknown() {
+ var values []string
+ item.MatchIpNextHopPrefixLists.ElementsAs(ctx, &values, false)
+ for _, v := range values {
+ cBody = helpers.AppendFromXPath(cBody, "match/ip/next-hop/prefix-list", v)
+ }
}
- } else {
- data.Entries[i].MatchRouteTypeInternal = types.BoolNull()
- }
- if value := r.Get("match.route-type.level-1"); !data.Entries[i].MatchRouteTypeLevel1.IsNull() {
- if value.Exists() {
- data.Entries[i].MatchRouteTypeLevel1 = types.BoolValue(true)
- } else {
- data.Entries[i].MatchRouteTypeLevel1 = types.BoolValue(false)
+ if !item.MatchIpv6AddressAccessLists.IsNull() && !item.MatchIpv6AddressAccessLists.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "match/ipv6/address/access-list", item.MatchIpv6AddressAccessLists.ValueString())
}
- } else {
- data.Entries[i].MatchRouteTypeLevel1 = types.BoolNull()
- }
- if value := r.Get("match.route-type.level-2"); !data.Entries[i].MatchRouteTypeLevel2.IsNull() {
- if value.Exists() {
- data.Entries[i].MatchRouteTypeLevel2 = types.BoolValue(true)
- } else {
- data.Entries[i].MatchRouteTypeLevel2 = types.BoolValue(false)
+ if !item.MatchIpv6AddressPrefixLists.IsNull() && !item.MatchIpv6AddressPrefixLists.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "match/ipv6/address/prefix-list", item.MatchIpv6AddressPrefixLists.ValueString())
}
- } else {
- data.Entries[i].MatchRouteTypeLevel2 = types.BoolNull()
- }
- if value := r.Get("match.route-type.local"); !data.Entries[i].MatchRouteTypeLocalLegacy.IsNull() {
- if value.Exists() {
- data.Entries[i].MatchRouteTypeLocalLegacy = types.BoolValue(true)
- } else {
- data.Entries[i].MatchRouteTypeLocalLegacy = types.BoolValue(false)
+ if !item.MatchIpv6NextHopAccessLists.IsNull() && !item.MatchIpv6NextHopAccessLists.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "match/ipv6/next-hop/access-list", item.MatchIpv6NextHopAccessLists.ValueString())
}
- } else {
- data.Entries[i].MatchRouteTypeLocalLegacy = types.BoolNull()
- }
- if value := r.Get("match.Cisco-IOS-XE-bgp:bgp-route-map-match.route-type.local"); !data.Entries[i].MatchRouteTypeLocal.IsNull() {
- if value.Exists() {
- data.Entries[i].MatchRouteTypeLocal = types.BoolValue(true)
- } else {
- data.Entries[i].MatchRouteTypeLocal = types.BoolValue(false)
+ if !item.MatchIpv6NextHopPrefixLists.IsNull() && !item.MatchIpv6NextHopPrefixLists.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "match/ipv6/next-hop/prefix-list", item.MatchIpv6NextHopPrefixLists.ValueString())
}
- } else {
- data.Entries[i].MatchRouteTypeLocal = types.BoolNull()
- }
- if value := r.Get("match.source-protocol.bgp"); value.Exists() && !data.Entries[i].MatchSourceProtocolBgp.IsNull() {
- data.Entries[i].MatchSourceProtocolBgp = helpers.GetStringList(value.Array())
- } else {
- data.Entries[i].MatchSourceProtocolBgp = types.ListNull(types.StringType)
- }
- if value := r.Get("match.source-protocol.connected"); !data.Entries[i].MatchSourceProtocolConnected.IsNull() {
- if value.Exists() {
- data.Entries[i].MatchSourceProtocolConnected = types.BoolValue(true)
- } else {
- data.Entries[i].MatchSourceProtocolConnected = types.BoolValue(false)
+ if !item.MatchRouteTypeExternal.IsNull() && !item.MatchRouteTypeExternal.IsUnknown() {
+ if item.MatchRouteTypeExternal.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "match/route-type/external", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "match/route-type/external")
+ }
}
- } else {
- data.Entries[i].MatchSourceProtocolConnected = types.BoolNull()
- }
- if value := r.Get("match.source-protocol.eigrp"); value.Exists() && !data.Entries[i].MatchSourceProtocolEigrp.IsNull() {
- data.Entries[i].MatchSourceProtocolEigrp = helpers.GetStringList(value.Array())
- } else {
- data.Entries[i].MatchSourceProtocolEigrp = types.ListNull(types.StringType)
- }
- if value := r.Get("match.source-protocol.isis"); !data.Entries[i].MatchSourceProtocolIsis.IsNull() {
- if value.Exists() {
- data.Entries[i].MatchSourceProtocolIsis = types.BoolValue(true)
- } else {
- data.Entries[i].MatchSourceProtocolIsis = types.BoolValue(false)
+ if !item.MatchRouteTypeExternalType1.IsNull() && !item.MatchRouteTypeExternalType1.IsUnknown() {
+ if item.MatchRouteTypeExternalType1.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "match/route-type/external/type-1", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "match/route-type/external/type-1")
+ }
}
- } else {
- data.Entries[i].MatchSourceProtocolIsis = types.BoolNull()
- }
- if value := r.Get("match.source-protocol.lisp"); !data.Entries[i].MatchSourceProtocolLisp.IsNull() {
- if value.Exists() {
- data.Entries[i].MatchSourceProtocolLisp = types.BoolValue(true)
- } else {
- data.Entries[i].MatchSourceProtocolLisp = types.BoolValue(false)
+ if !item.MatchRouteTypeExternalType2.IsNull() && !item.MatchRouteTypeExternalType2.IsUnknown() {
+ if item.MatchRouteTypeExternalType2.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "match/route-type/external/type-2", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "match/route-type/external/type-2")
+ }
}
- } else {
- data.Entries[i].MatchSourceProtocolLisp = types.BoolNull()
- }
- if value := r.Get("match.source-protocol.ospf"); value.Exists() && !data.Entries[i].MatchSourceProtocolOspf.IsNull() {
- data.Entries[i].MatchSourceProtocolOspf = helpers.GetStringList(value.Array())
- } else {
- data.Entries[i].MatchSourceProtocolOspf = types.ListNull(types.StringType)
- }
- if value := r.Get("match.source-protocol.ospfv3"); value.Exists() && !data.Entries[i].MatchSourceProtocolOspfv3.IsNull() {
- data.Entries[i].MatchSourceProtocolOspfv3 = helpers.GetStringList(value.Array())
- } else {
- data.Entries[i].MatchSourceProtocolOspfv3 = types.ListNull(types.StringType)
- }
- if value := r.Get("match.source-protocol.rip"); !data.Entries[i].MatchSourceProtocolRip.IsNull() {
- if value.Exists() {
- data.Entries[i].MatchSourceProtocolRip = types.BoolValue(true)
- } else {
- data.Entries[i].MatchSourceProtocolRip = types.BoolValue(false)
+ if !item.MatchRouteTypeInternal.IsNull() && !item.MatchRouteTypeInternal.IsUnknown() {
+ if item.MatchRouteTypeInternal.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "match/route-type/internal", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "match/route-type/internal")
+ }
}
- } else {
- data.Entries[i].MatchSourceProtocolRip = types.BoolNull()
- }
- if value := r.Get("match.source-protocol.static"); !data.Entries[i].MatchSourceProtocolStatic.IsNull() {
- if value.Exists() {
- data.Entries[i].MatchSourceProtocolStatic = types.BoolValue(true)
- } else {
- data.Entries[i].MatchSourceProtocolStatic = types.BoolValue(false)
+ if !item.MatchRouteTypeLevel1.IsNull() && !item.MatchRouteTypeLevel1.IsUnknown() {
+ if item.MatchRouteTypeLevel1.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "match/route-type/level-1", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "match/route-type/level-1")
+ }
}
- } else {
- data.Entries[i].MatchSourceProtocolStatic = types.BoolNull()
- }
- if value := r.Get("match.tag.tag_value"); value.Exists() && !data.Entries[i].MatchTags.IsNull() {
- data.Entries[i].MatchTags = helpers.GetInt64List(value.Array())
- } else {
- data.Entries[i].MatchTags = types.ListNull(types.Int64Type)
- }
- if value := r.Get("match.track"); value.Exists() && !data.Entries[i].MatchTrack.IsNull() {
- data.Entries[i].MatchTrack = types.Int64Value(value.Int())
- } else {
- data.Entries[i].MatchTrack = types.Int64Null()
- }
- if value := r.Get("match.as-path.access-list"); value.Exists() && !data.Entries[i].MatchAsPathsLegacy.IsNull() {
- data.Entries[i].MatchAsPathsLegacy = helpers.GetInt64List(value.Array())
- } else {
- data.Entries[i].MatchAsPathsLegacy = types.ListNull(types.Int64Type)
- }
- if value := r.Get("match.community.name"); value.Exists() && !data.Entries[i].MatchCommunityListsLegacy.IsNull() {
- data.Entries[i].MatchCommunityListsLegacy = helpers.GetStringList(value.Array())
- } else {
- data.Entries[i].MatchCommunityListsLegacy = types.ListNull(types.StringType)
- }
- if value := r.Get("match.extcommunity.name"); value.Exists() && !data.Entries[i].MatchExtcommunityListsLegacy.IsNull() {
- data.Entries[i].MatchExtcommunityListsLegacy = helpers.GetStringList(value.Array())
- } else {
- data.Entries[i].MatchExtcommunityListsLegacy = types.ListNull(types.StringType)
- }
- if value := r.Get("match.local-preference.values"); value.Exists() && !data.Entries[i].MatchLocalPreferencesLegacy.IsNull() {
- data.Entries[i].MatchLocalPreferencesLegacy = helpers.GetInt64List(value.Array())
- } else {
- data.Entries[i].MatchLocalPreferencesLegacy = types.ListNull(types.Int64Type)
- }
- if value := r.Get("match.Cisco-IOS-XE-bgp:bgp-route-map-match.as-path.access-list"); value.Exists() && !data.Entries[i].MatchAsPaths.IsNull() {
- data.Entries[i].MatchAsPaths = helpers.GetInt64List(value.Array())
- } else {
- data.Entries[i].MatchAsPaths = types.ListNull(types.Int64Type)
- }
- if value := r.Get("match.Cisco-IOS-XE-bgp:bgp-route-map-match.bgp-community.community-list"); value.Exists() && !data.Entries[i].MatchCommunityLists.IsNull() {
- data.Entries[i].MatchCommunityLists = helpers.GetStringList(value.Array())
- } else {
- data.Entries[i].MatchCommunityLists = types.ListNull(types.StringType)
- }
- if value := r.Get("match.Cisco-IOS-XE-bgp:bgp-route-map-match.bgp-community.exact-match"); !data.Entries[i].MatchCommunityListExactMatch.IsNull() {
- if value.Exists() {
- data.Entries[i].MatchCommunityListExactMatch = types.BoolValue(true)
- } else {
- data.Entries[i].MatchCommunityListExactMatch = types.BoolValue(false)
+ if !item.MatchRouteTypeLevel2.IsNull() && !item.MatchRouteTypeLevel2.IsUnknown() {
+ if item.MatchRouteTypeLevel2.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "match/route-type/level-2", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "match/route-type/level-2")
+ }
}
- } else {
- data.Entries[i].MatchCommunityListExactMatch = types.BoolNull()
- }
- if value := r.Get("match.Cisco-IOS-XE-bgp:bgp-route-map-match.extcommunity.extcommunity-list"); value.Exists() && !data.Entries[i].MatchExtcommunityLists.IsNull() {
- data.Entries[i].MatchExtcommunityLists = helpers.GetStringList(value.Array())
- } else {
- data.Entries[i].MatchExtcommunityLists = types.ListNull(types.StringType)
- }
- if value := r.Get("match.Cisco-IOS-XE-bgp:bgp-route-map-match.local-preference.values"); value.Exists() && !data.Entries[i].MatchLocalPreferences.IsNull() {
- data.Entries[i].MatchLocalPreferences = helpers.GetInt64List(value.Array())
- } else {
- data.Entries[i].MatchLocalPreferences = types.ListNull(types.Int64Type)
- }
- if value := r.Get("set.default.interface-list"); value.Exists() && !data.Entries[i].SetDefaultInterfaces.IsNull() {
- data.Entries[i].SetDefaultInterfaces = helpers.GetStringList(value.Array())
- } else {
- data.Entries[i].SetDefaultInterfaces = types.ListNull(types.StringType)
- }
- if value := r.Get("set.global"); !data.Entries[i].SetGlobal.IsNull() {
- if value.Exists() {
- data.Entries[i].SetGlobal = types.BoolValue(true)
- } else {
- data.Entries[i].SetGlobal = types.BoolValue(false)
+ if !item.MatchRouteTypeLocalLegacy.IsNull() && !item.MatchRouteTypeLocalLegacy.IsUnknown() {
+ if item.MatchRouteTypeLocalLegacy.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "match/route-type/local", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "match/route-type/local")
+ }
}
- } else {
- data.Entries[i].SetGlobal = types.BoolNull()
- }
- if value := r.Get("set.interface-list"); value.Exists() && !data.Entries[i].SetInterfaces.IsNull() {
- data.Entries[i].SetInterfaces = helpers.GetStringList(value.Array())
- } else {
- data.Entries[i].SetInterfaces = types.ListNull(types.StringType)
- }
- if value := r.Get("set.ip.address.prefix-list"); value.Exists() && !data.Entries[i].SetIpAddress.IsNull() {
- data.Entries[i].SetIpAddress = types.StringValue(value.String())
- } else {
- data.Entries[i].SetIpAddress = types.StringNull()
- }
- if value := r.Get("set.ip.default.global.next-hop.address"); value.Exists() && !data.Entries[i].SetIpDefaultGlobalNextHopAddress.IsNull() {
- data.Entries[i].SetIpDefaultGlobalNextHopAddress = helpers.GetStringList(value.Array())
- } else {
- data.Entries[i].SetIpDefaultGlobalNextHopAddress = types.ListNull(types.StringType)
- }
- if value := r.Get("set.ip.default.next-hop.address"); value.Exists() && !data.Entries[i].SetIpDefaultNextHopAddress.IsNull() {
- data.Entries[i].SetIpDefaultNextHopAddress = helpers.GetStringList(value.Array())
- } else {
- data.Entries[i].SetIpDefaultNextHopAddress = types.ListNull(types.StringType)
- }
- if value := r.Get("set.ip.global.next-hop.address"); value.Exists() && !data.Entries[i].SetIpGlobalNextHopAddress.IsNull() {
- data.Entries[i].SetIpGlobalNextHopAddress = helpers.GetStringList(value.Array())
- } else {
- data.Entries[i].SetIpGlobalNextHopAddress = types.ListNull(types.StringType)
- }
- if value := r.Get("set.ip.next-hop.address"); value.Exists() && !data.Entries[i].SetIpNextHopAddress.IsNull() {
- data.Entries[i].SetIpNextHopAddress = helpers.GetStringList(value.Array())
- } else {
- data.Entries[i].SetIpNextHopAddress = types.ListNull(types.StringType)
- }
- if value := r.Get("set.ip.next-hop.self"); !data.Entries[i].SetIpNextHopSelf.IsNull() {
- if value.Exists() {
- data.Entries[i].SetIpNextHopSelf = types.BoolValue(true)
- } else {
- data.Entries[i].SetIpNextHopSelf = types.BoolValue(false)
+ if !item.MatchRouteTypeLocal.IsNull() && !item.MatchRouteTypeLocal.IsUnknown() {
+ if item.MatchRouteTypeLocal.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "match/Cisco-IOS-XE-bgp:bgp-route-map-match/route-type/local", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "match/Cisco-IOS-XE-bgp:bgp-route-map-match/route-type/local")
+ }
}
- } else {
- data.Entries[i].SetIpNextHopSelf = types.BoolNull()
- }
- if value := r.Get("set.ip.qos-group.qos-id"); value.Exists() && !data.Entries[i].SetIpQosGroup.IsNull() {
- data.Entries[i].SetIpQosGroup = types.Int64Value(value.Int())
- } else {
- data.Entries[i].SetIpQosGroup = types.Int64Null()
- }
- if value := r.Get("set.ipv6.address.prefix-list"); value.Exists() && !data.Entries[i].SetIpv6Address.IsNull() {
- data.Entries[i].SetIpv6Address = helpers.GetStringList(value.Array())
- } else {
- data.Entries[i].SetIpv6Address = types.ListNull(types.StringType)
- }
- if value := r.Get("set.ipv6.default.global.next-hop"); value.Exists() && !data.Entries[i].SetIpv6DefaultGlobalNextHop.IsNull() {
- data.Entries[i].SetIpv6DefaultGlobalNextHop = types.StringValue(value.String())
- } else {
- data.Entries[i].SetIpv6DefaultGlobalNextHop = types.StringNull()
- }
- if value := r.Get("set.ipv6.default.next-hop.ipv6"); value.Exists() && !data.Entries[i].SetIpv6DefaultNextHop.IsNull() {
- data.Entries[i].SetIpv6DefaultNextHop = helpers.GetStringList(value.Array())
- } else {
- data.Entries[i].SetIpv6DefaultNextHop = types.ListNull(types.StringType)
- }
- if value := r.Get("set.ipv6.next-hop.ipv6"); value.Exists() && !data.Entries[i].SetIpv6NextHop.IsNull() {
- data.Entries[i].SetIpv6NextHop = helpers.GetStringList(value.Array())
- } else {
- data.Entries[i].SetIpv6NextHop = types.ListNull(types.StringType)
- }
- if value := r.Get("set.level.level-1"); !data.Entries[i].SetLevel1.IsNull() {
- if value.Exists() {
- data.Entries[i].SetLevel1 = types.BoolValue(true)
- } else {
- data.Entries[i].SetLevel1 = types.BoolValue(false)
+ if !item.MatchSourceProtocolBgp.IsNull() && !item.MatchSourceProtocolBgp.IsUnknown() {
+ var values []string
+ item.MatchSourceProtocolBgp.ElementsAs(ctx, &values, false)
+ for _, v := range values {
+ cBody = helpers.AppendFromXPath(cBody, "match/source-protocol/bgp", v)
+ }
}
- } else {
- data.Entries[i].SetLevel1 = types.BoolNull()
- }
- if value := r.Get("set.level.level-1-2"); !data.Entries[i].SetLevel12.IsNull() {
- if value.Exists() {
- data.Entries[i].SetLevel12 = types.BoolValue(true)
- } else {
- data.Entries[i].SetLevel12 = types.BoolValue(false)
+ if !item.MatchSourceProtocolConnected.IsNull() && !item.MatchSourceProtocolConnected.IsUnknown() {
+ if item.MatchSourceProtocolConnected.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "match/source-protocol/connected", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "match/source-protocol/connected")
+ }
}
- } else {
- data.Entries[i].SetLevel12 = types.BoolNull()
- }
- if value := r.Get("set.level.level-2"); !data.Entries[i].SetLevel2.IsNull() {
- if value.Exists() {
- data.Entries[i].SetLevel2 = types.BoolValue(true)
- } else {
- data.Entries[i].SetLevel2 = types.BoolValue(false)
+ if !item.MatchSourceProtocolEigrp.IsNull() && !item.MatchSourceProtocolEigrp.IsUnknown() {
+ var values []string
+ item.MatchSourceProtocolEigrp.ElementsAs(ctx, &values, false)
+ for _, v := range values {
+ cBody = helpers.AppendFromXPath(cBody, "match/source-protocol/eigrp", v)
+ }
}
- } else {
- data.Entries[i].SetLevel2 = types.BoolNull()
- }
- if value := r.Get("set.metric.metric-change"); value.Exists() && !data.Entries[i].SetMetricChange.IsNull() {
- data.Entries[i].SetMetricChange = types.StringValue(value.String())
- } else {
- data.Entries[i].SetMetricChange = types.StringNull()
- }
- if value := r.Get("set.metric.values.value"); value.Exists() && !data.Entries[i].SetMetricValue.IsNull() {
- data.Entries[i].SetMetricValue = types.Int64Value(value.Int())
- } else {
- data.Entries[i].SetMetricValue = types.Int64Null()
- }
- if value := r.Get("set.metric.values.delay"); value.Exists() && !data.Entries[i].SetMetricDelay.IsNull() {
- data.Entries[i].SetMetricDelay = types.StringValue(value.String())
- } else {
- data.Entries[i].SetMetricDelay = types.StringNull()
- }
- if value := r.Get("set.metric.values.reliability"); value.Exists() && !data.Entries[i].SetMetricReliability.IsNull() {
- data.Entries[i].SetMetricReliability = types.Int64Value(value.Int())
- } else {
- data.Entries[i].SetMetricReliability = types.Int64Null()
- }
- if value := r.Get("set.metric.values.loading"); value.Exists() && !data.Entries[i].SetMetricLoading.IsNull() {
- data.Entries[i].SetMetricLoading = types.Int64Value(value.Int())
- } else {
- data.Entries[i].SetMetricLoading = types.Int64Null()
- }
- if value := r.Get("set.metric.values.MTU"); value.Exists() && !data.Entries[i].SetMetricMtu.IsNull() {
- data.Entries[i].SetMetricMtu = types.Int64Value(value.Int())
- } else {
- data.Entries[i].SetMetricMtu = types.Int64Null()
- }
- if value := r.Get("set.metric-type"); value.Exists() && !data.Entries[i].SetMetricType.IsNull() {
- data.Entries[i].SetMetricType = types.StringValue(value.String())
- } else {
- data.Entries[i].SetMetricType = types.StringNull()
- }
- if value := r.Get("set.tag.tag-val"); value.Exists() && !data.Entries[i].SetTag.IsNull() {
- data.Entries[i].SetTag = types.Int64Value(value.Int())
- } else {
- data.Entries[i].SetTag = types.Int64Null()
- }
- if value := r.Get("set.vrf"); value.Exists() && !data.Entries[i].SetVrf.IsNull() {
- data.Entries[i].SetVrf = types.StringValue(value.String())
- } else {
- data.Entries[i].SetVrf = types.StringNull()
- }
- if value := r.Get("set.as-path.prepend.as-container.as-number"); value.Exists() && !data.Entries[i].SetAsPathPrependAsLegacy.IsNull() {
- data.Entries[i].SetAsPathPrependAsLegacy = types.StringValue(value.String())
- } else {
- data.Entries[i].SetAsPathPrependAsLegacy = types.StringNull()
- }
- if value := r.Get("set.as-path.prepend.last-as-cont.last-as"); value.Exists() && !data.Entries[i].SetAsPathPrependLastAsLegacy.IsNull() {
- data.Entries[i].SetAsPathPrependLastAsLegacy = types.Int64Value(value.Int())
- } else {
- data.Entries[i].SetAsPathPrependLastAsLegacy = types.Int64Null()
- }
- if value := r.Get("set.as-path.tag"); !data.Entries[i].SetAsPathTagLegacy.IsNull() {
- if value.Exists() {
- data.Entries[i].SetAsPathTagLegacy = types.BoolValue(true)
- } else {
- data.Entries[i].SetAsPathTagLegacy = types.BoolValue(false)
+ if !item.MatchSourceProtocolIsis.IsNull() && !item.MatchSourceProtocolIsis.IsUnknown() {
+ if item.MatchSourceProtocolIsis.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "match/source-protocol/isis", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "match/source-protocol/isis")
+ }
}
- } else {
- data.Entries[i].SetAsPathTagLegacy = types.BoolNull()
- }
- if value := r.Get("set.community.none"); !data.Entries[i].SetCommunityNoneLegacy.IsNull() {
- if value.Exists() {
- data.Entries[i].SetCommunityNoneLegacy = types.BoolValue(true)
- } else {
- data.Entries[i].SetCommunityNoneLegacy = types.BoolValue(false)
+ if !item.MatchSourceProtocolLisp.IsNull() && !item.MatchSourceProtocolLisp.IsUnknown() {
+ if item.MatchSourceProtocolLisp.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "match/source-protocol/lisp", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "match/source-protocol/lisp")
+ }
}
- } else {
- data.Entries[i].SetCommunityNoneLegacy = types.BoolNull()
- }
- if value := r.Get("set.community.community-well-known.community-list"); value.Exists() && !data.Entries[i].SetCommunitiesLegacy.IsNull() {
- data.Entries[i].SetCommunitiesLegacy = helpers.GetStringList(value.Array())
- } else {
- data.Entries[i].SetCommunitiesLegacy = types.ListNull(types.StringType)
- }
- if value := r.Get("set.community.community-well-known.additive"); !data.Entries[i].SetCommunitiesAdditiveLegacy.IsNull() {
- if value.Exists() {
- data.Entries[i].SetCommunitiesAdditiveLegacy = types.BoolValue(true)
- } else {
- data.Entries[i].SetCommunitiesAdditiveLegacy = types.BoolValue(false)
+ if !item.MatchSourceProtocolOspf.IsNull() && !item.MatchSourceProtocolOspf.IsUnknown() {
+ var values []string
+ item.MatchSourceProtocolOspf.ElementsAs(ctx, &values, false)
+ for _, v := range values {
+ cBody = helpers.AppendFromXPath(cBody, "match/source-protocol/ospf", v)
+ }
}
- } else {
- data.Entries[i].SetCommunitiesAdditiveLegacy = types.BoolNull()
- }
- if value := r.Get("set.comm-list.delete"); !data.Entries[i].SetCommunityListDeleteLegacy.IsNull() {
- if value.Exists() {
- data.Entries[i].SetCommunityListDeleteLegacy = types.BoolValue(true)
- } else {
- data.Entries[i].SetCommunityListDeleteLegacy = types.BoolValue(false)
+ if !item.MatchSourceProtocolOspfv3.IsNull() && !item.MatchSourceProtocolOspfv3.IsUnknown() {
+ var values []string
+ item.MatchSourceProtocolOspfv3.ElementsAs(ctx, &values, false)
+ for _, v := range values {
+ cBody = helpers.AppendFromXPath(cBody, "match/source-protocol/ospfv3", v)
+ }
}
- } else {
- data.Entries[i].SetCommunityListDeleteLegacy = types.BoolNull()
- }
- if value := r.Get("set.comm-list.comm-list-standard"); value.Exists() && !data.Entries[i].SetCommunityListStandardLegacy.IsNull() {
- data.Entries[i].SetCommunityListStandardLegacy = types.Int64Value(value.Int())
- } else {
- data.Entries[i].SetCommunityListStandardLegacy = types.Int64Null()
- }
- if value := r.Get("set.Cisco-IOS-XE-bgp:bgp-route-map-set.comm-list.comm-list-expanded"); value.Exists() && !data.Entries[i].SetCommunityListExpandedLegacy.IsNull() {
- data.Entries[i].SetCommunityListExpandedLegacy = types.Int64Value(value.Int())
- } else {
- data.Entries[i].SetCommunityListExpandedLegacy = types.Int64Null()
- }
- if value := r.Get("set.comm-list.comm-list-name"); value.Exists() && !data.Entries[i].SetCommunityListNameLegacy.IsNull() {
- data.Entries[i].SetCommunityListNameLegacy = types.StringValue(value.String())
- } else {
- data.Entries[i].SetCommunityListNameLegacy = types.StringNull()
- }
- if value := r.Get("set.extcommunity.rt.asn-nn"); value.Exists() && !data.Entries[i].SetExtcomunityRtLegacy.IsNull() {
- data.Entries[i].SetExtcomunityRtLegacy = helpers.GetStringList(value.Array())
- } else {
- data.Entries[i].SetExtcomunityRtLegacy = types.ListNull(types.StringType)
- }
- if value := r.Get("set.extcommunity.soo.asn-nn"); value.Exists() && !data.Entries[i].SetExtcomunitySooLegacy.IsNull() {
- data.Entries[i].SetExtcomunitySooLegacy = types.StringValue(value.String())
- } else {
- data.Entries[i].SetExtcomunitySooLegacy = types.StringNull()
- }
- if value := r.Get("set.extcommunity.vpn-distinguisher.asn-nn"); value.Exists() && !data.Entries[i].SetExtcomunityVpnDistinguisherLegacy.IsNull() {
- data.Entries[i].SetExtcomunityVpnDistinguisherLegacy = types.StringValue(value.String())
- } else {
- data.Entries[i].SetExtcomunityVpnDistinguisherLegacy = types.StringNull()
- }
- if value := r.Get("set.local-preference"); value.Exists() && !data.Entries[i].SetLocalPreferenceLegacy.IsNull() {
- data.Entries[i].SetLocalPreferenceLegacy = types.Int64Value(value.Int())
- } else {
- data.Entries[i].SetLocalPreferenceLegacy = types.Int64Null()
- }
- if value := r.Get("set.weight"); value.Exists() && !data.Entries[i].SetWeightLegacy.IsNull() {
- data.Entries[i].SetWeightLegacy = types.Int64Value(value.Int())
- } else {
- data.Entries[i].SetWeightLegacy = types.Int64Null()
- }
- if value := r.Get("set.Cisco-IOS-XE-bgp:bgp-route-map-set.as-path.prepend.as-container.as-number"); value.Exists() && !data.Entries[i].SetAsPathPrependAs.IsNull() {
- data.Entries[i].SetAsPathPrependAs = types.StringValue(value.String())
- } else {
- data.Entries[i].SetAsPathPrependAs = types.StringNull()
- }
- if value := r.Get("set.Cisco-IOS-XE-bgp:bgp-route-map-set.as-path.prepend.last-as-cont.last-as"); value.Exists() && !data.Entries[i].SetAsPathPrependLastAs.IsNull() {
- data.Entries[i].SetAsPathPrependLastAs = types.Int64Value(value.Int())
- } else {
- data.Entries[i].SetAsPathPrependLastAs = types.Int64Null()
- }
- if value := r.Get("set.Cisco-IOS-XE-bgp:bgp-route-map-set.as-path.tag"); !data.Entries[i].SetAsPathTag.IsNull() {
- if value.Exists() {
- data.Entries[i].SetAsPathTag = types.BoolValue(true)
- } else {
- data.Entries[i].SetAsPathTag = types.BoolValue(false)
+ if !item.MatchSourceProtocolRip.IsNull() && !item.MatchSourceProtocolRip.IsUnknown() {
+ if item.MatchSourceProtocolRip.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "match/source-protocol/rip", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "match/source-protocol/rip")
+ }
}
- } else {
- data.Entries[i].SetAsPathTag = types.BoolNull()
- }
- if value := r.Get("set.Cisco-IOS-XE-bgp:bgp-route-map-set.as-path.replace.any"); !data.Entries[i].SetAsPathReplaceAny.IsNull() {
- if value.Exists() {
- data.Entries[i].SetAsPathReplaceAny = types.BoolValue(true)
- } else {
- data.Entries[i].SetAsPathReplaceAny = types.BoolValue(false)
+ if !item.MatchSourceProtocolStatic.IsNull() && !item.MatchSourceProtocolStatic.IsUnknown() {
+ if item.MatchSourceProtocolStatic.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "match/source-protocol/static", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "match/source-protocol/static")
+ }
}
- } else {
- data.Entries[i].SetAsPathReplaceAny = types.BoolNull()
- }
- for ci := range data.Entries[i].SetAsPathReplaceAs {
- keys := [...]string{"as-number"}
- keyValues := [...]string{data.Entries[i].SetAsPathReplaceAs[ci].AsNumber.ValueString()}
-
- var cr gjson.Result
- r.Get("set.Cisco-IOS-XE-bgp:bgp-route-map-set.as-path.replace.as-container").ForEach(
- func(_, v gjson.Result) bool {
- found := false
- for ik := range keys {
- if v.Get(keys[ik]).String() == keyValues[ik] {
- found = true
- continue
- }
- found = false
- break
- }
- if found {
- cr = v
- return false
- }
- return true
- },
- )
- if value := cr.Get("as-number"); value.Exists() && !data.Entries[i].SetAsPathReplaceAs[ci].AsNumber.IsNull() {
- data.Entries[i].SetAsPathReplaceAs[ci].AsNumber = types.StringValue(value.String())
- } else {
- data.Entries[i].SetAsPathReplaceAs[ci].AsNumber = types.StringNull()
+ if !item.MatchTags.IsNull() && !item.MatchTags.IsUnknown() {
+ var values []int
+ item.MatchTags.ElementsAs(ctx, &values, false)
+ for _, v := range values {
+ cBody = helpers.AppendFromXPath(cBody, "match/tag/tag_value", v)
+ }
}
- }
- if value := r.Get("set.Cisco-IOS-XE-bgp:bgp-route-map-set.bgp-community.none"); !data.Entries[i].SetCommunityNone.IsNull() {
- if value.Exists() {
- data.Entries[i].SetCommunityNone = types.BoolValue(true)
- } else {
- data.Entries[i].SetCommunityNone = types.BoolValue(false)
+ if !item.MatchTrack.IsNull() && !item.MatchTrack.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "match/track", strconv.FormatInt(item.MatchTrack.ValueInt64(), 10))
}
- } else {
- data.Entries[i].SetCommunityNone = types.BoolNull()
- }
- if value := r.Get("set.Cisco-IOS-XE-bgp:bgp-route-map-set.bgp-community.community-well-known.community-list"); value.Exists() && !data.Entries[i].SetCommunities.IsNull() {
- data.Entries[i].SetCommunities = helpers.GetStringList(value.Array())
- } else {
- data.Entries[i].SetCommunities = types.ListNull(types.StringType)
- }
- if value := r.Get("set.Cisco-IOS-XE-bgp:bgp-route-map-set.bgp-community.community-well-known.additive"); !data.Entries[i].SetCommunitiesAdditive.IsNull() {
- if value.Exists() {
- data.Entries[i].SetCommunitiesAdditive = types.BoolValue(true)
- } else {
- data.Entries[i].SetCommunitiesAdditive = types.BoolValue(false)
+ if !item.MatchAsPathsLegacy.IsNull() && !item.MatchAsPathsLegacy.IsUnknown() {
+ var values []int
+ item.MatchAsPathsLegacy.ElementsAs(ctx, &values, false)
+ for _, v := range values {
+ cBody = helpers.AppendFromXPath(cBody, "match/as-path/access-list", v)
+ }
}
- } else {
- data.Entries[i].SetCommunitiesAdditive = types.BoolNull()
- }
- if value := r.Get("set.Cisco-IOS-XE-bgp:bgp-route-map-set.comm-list.delete"); !data.Entries[i].SetCommunityListDelete.IsNull() {
- if value.Exists() {
- data.Entries[i].SetCommunityListDelete = types.BoolValue(true)
- } else {
- data.Entries[i].SetCommunityListDelete = types.BoolValue(false)
+ if !item.MatchCommunityListsLegacy.IsNull() && !item.MatchCommunityListsLegacy.IsUnknown() {
+ var values []string
+ item.MatchCommunityListsLegacy.ElementsAs(ctx, &values, false)
+ for _, v := range values {
+ cBody = helpers.AppendFromXPath(cBody, "match/community/name", v)
+ }
}
- } else {
- data.Entries[i].SetCommunityListDelete = types.BoolNull()
- }
- if value := r.Get("set.Cisco-IOS-XE-bgp:bgp-route-map-set.comm-list.comm-list-standard"); value.Exists() && !data.Entries[i].SetCommunityListStandard.IsNull() {
- data.Entries[i].SetCommunityListStandard = types.Int64Value(value.Int())
- } else {
- data.Entries[i].SetCommunityListStandard = types.Int64Null()
- }
- if value := r.Get("set.Cisco-IOS-XE-bgp:bgp-route-map-set.comm-list.comm-list-expanded"); value.Exists() && !data.Entries[i].SetCommunityListExpanded.IsNull() {
- data.Entries[i].SetCommunityListExpanded = types.Int64Value(value.Int())
- } else {
- data.Entries[i].SetCommunityListExpanded = types.Int64Null()
- }
- if value := r.Get("set.Cisco-IOS-XE-bgp:bgp-route-map-set.comm-list.comm-list-name"); value.Exists() && !data.Entries[i].SetCommunityListName.IsNull() {
- data.Entries[i].SetCommunityListName = types.StringValue(value.String())
- } else {
- data.Entries[i].SetCommunityListName = types.StringNull()
- }
- if value := r.Get("set.Cisco-IOS-XE-bgp:bgp-route-map-set.extcommunity.rt.asn-nn"); value.Exists() && !data.Entries[i].SetExtcomunityRt.IsNull() {
- data.Entries[i].SetExtcomunityRt = helpers.GetStringList(value.Array())
- } else {
- data.Entries[i].SetExtcomunityRt = types.ListNull(types.StringType)
- }
- if value := r.Get("set.Cisco-IOS-XE-bgp:bgp-route-map-set.extcommunity.soo.asn-nn"); value.Exists() && !data.Entries[i].SetExtcomunitySoo.IsNull() {
- data.Entries[i].SetExtcomunitySoo = types.StringValue(value.String())
- } else {
- data.Entries[i].SetExtcomunitySoo = types.StringNull()
- }
- if value := r.Get("set.Cisco-IOS-XE-bgp:bgp-route-map-set.extcommunity.vpn-distinguisher.asn-nn"); value.Exists() && !data.Entries[i].SetExtcomunityVpnDistinguisher.IsNull() {
- data.Entries[i].SetExtcomunityVpnDistinguisher = types.StringValue(value.String())
- } else {
- data.Entries[i].SetExtcomunityVpnDistinguisher = types.StringNull()
- }
- if value := r.Get("set.Cisco-IOS-XE-bgp:bgp-route-map-set.extcommunity.vpn-distinguisher.asn-nn-additive"); !data.Entries[i].SetExtcomunityVpnDistinguisherAdditive.IsNull() {
- if value.Exists() {
- data.Entries[i].SetExtcomunityVpnDistinguisherAdditive = types.BoolValue(true)
- } else {
- data.Entries[i].SetExtcomunityVpnDistinguisherAdditive = types.BoolValue(false)
+ if !item.MatchExtcommunityListsLegacy.IsNull() && !item.MatchExtcommunityListsLegacy.IsUnknown() {
+ var values []string
+ item.MatchExtcommunityListsLegacy.ElementsAs(ctx, &values, false)
+ for _, v := range values {
+ cBody = helpers.AppendFromXPath(cBody, "match/extcommunity/name", v)
+ }
}
- } else {
- data.Entries[i].SetExtcomunityVpnDistinguisherAdditive = types.BoolNull()
- }
- if value := r.Get("set.Cisco-IOS-XE-bgp:bgp-route-map-set.local-preference"); value.Exists() && !data.Entries[i].SetLocalPreference.IsNull() {
- data.Entries[i].SetLocalPreference = types.Int64Value(value.Int())
- } else {
- data.Entries[i].SetLocalPreference = types.Int64Null()
- }
- if value := r.Get("set.Cisco-IOS-XE-bgp:bgp-route-map-set.weight"); value.Exists() && !data.Entries[i].SetWeight.IsNull() {
- data.Entries[i].SetWeight = types.Int64Value(value.Int())
- } else {
- data.Entries[i].SetWeight = types.Int64Null()
- }
- }
-}
-
-// End of section. //template:end updateFromBody
-
-// Section below is generated&owned by "gen/generator.go". //template:begin fromBody
-
-func (data *RouteMap) fromBody(ctx context.Context, res gjson.Result) {
- prefix := helpers.LastElement(data.getPath()) + "."
- if res.Get(helpers.LastElement(data.getPath())).IsArray() {
- prefix += "0."
- }
- if value := res.Get(prefix + "Cisco-IOS-XE-route-map:route-map-without-order-seq"); value.Exists() {
- data.Entries = make([]RouteMapEntries, 0)
- value.ForEach(func(k, v gjson.Result) bool {
- item := RouteMapEntries{}
- if cValue := v.Get("seq_no"); cValue.Exists() {
- item.Seq = types.Int64Value(cValue.Int())
+ if !item.MatchLocalPreferencesLegacy.IsNull() && !item.MatchLocalPreferencesLegacy.IsUnknown() {
+ var values []int
+ item.MatchLocalPreferencesLegacy.ElementsAs(ctx, &values, false)
+ for _, v := range values {
+ cBody = helpers.AppendFromXPath(cBody, "match/local-preference/values", v)
+ }
}
- if cValue := v.Get("operation"); cValue.Exists() {
- item.Operation = types.StringValue(cValue.String())
+ if !item.MatchAsPaths.IsNull() && !item.MatchAsPaths.IsUnknown() {
+ var values []int
+ item.MatchAsPaths.ElementsAs(ctx, &values, false)
+ for _, v := range values {
+ cBody = helpers.AppendFromXPath(cBody, "match/Cisco-IOS-XE-bgp:bgp-route-map-match/as-path/access-list", v)
+ }
}
- if cValue := v.Get("description"); cValue.Exists() {
- item.Description = types.StringValue(cValue.String())
+ if !item.MatchCommunityLists.IsNull() && !item.MatchCommunityLists.IsUnknown() {
+ var values []string
+ item.MatchCommunityLists.ElementsAs(ctx, &values, false)
+ for _, v := range values {
+ cBody = helpers.AppendFromXPath(cBody, "match/Cisco-IOS-XE-bgp:bgp-route-map-match/bgp-community/community-list", v)
+ }
}
- if cValue := v.Get("continue"); cValue.Exists() {
- item.Continue = types.BoolValue(true)
- } else {
- item.Continue = types.BoolValue(false)
+ if !item.MatchCommunityListExactMatch.IsNull() && !item.MatchCommunityListExactMatch.IsUnknown() {
+ if item.MatchCommunityListExactMatch.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "match/Cisco-IOS-XE-bgp:bgp-route-map-match/bgp-community/exact-match", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "match/Cisco-IOS-XE-bgp:bgp-route-map-match/bgp-community/exact-match")
+ }
}
- if cValue := v.Get("continue.sequence-number"); cValue.Exists() {
- item.ContinueSequenceNumber = types.Int64Value(cValue.Int())
+ if !item.MatchExtcommunityLists.IsNull() && !item.MatchExtcommunityLists.IsUnknown() {
+ var values []string
+ item.MatchExtcommunityLists.ElementsAs(ctx, &values, false)
+ for _, v := range values {
+ cBody = helpers.AppendFromXPath(cBody, "match/Cisco-IOS-XE-bgp:bgp-route-map-match/extcommunity/extcommunity-list", v)
+ }
}
- if cValue := v.Get("match.interface.interface"); cValue.Exists() {
- item.MatchInterfaces = helpers.GetStringList(cValue.Array())
- } else {
- item.MatchInterfaces = types.ListNull(types.StringType)
+ if !item.MatchLocalPreferences.IsNull() && !item.MatchLocalPreferences.IsUnknown() {
+ var values []int
+ item.MatchLocalPreferences.ElementsAs(ctx, &values, false)
+ for _, v := range values {
+ cBody = helpers.AppendFromXPath(cBody, "match/Cisco-IOS-XE-bgp:bgp-route-map-match/local-preference/values", v)
+ }
}
- if cValue := v.Get("match.ip.address.access-list"); cValue.Exists() {
- item.MatchIpAddressAccessLists = helpers.GetStringList(cValue.Array())
- } else {
- item.MatchIpAddressAccessLists = types.ListNull(types.StringType)
+ if !item.SetDefaultInterfaces.IsNull() && !item.SetDefaultInterfaces.IsUnknown() {
+ var values []string
+ item.SetDefaultInterfaces.ElementsAs(ctx, &values, false)
+ for _, v := range values {
+ cBody = helpers.AppendFromXPath(cBody, "set/default/interface-list", v)
+ }
}
- if cValue := v.Get("match.ip.address.prefix-list"); cValue.Exists() {
- item.MatchIpAddressPrefixLists = helpers.GetStringList(cValue.Array())
- } else {
- item.MatchIpAddressPrefixLists = types.ListNull(types.StringType)
+ if !item.SetGlobal.IsNull() && !item.SetGlobal.IsUnknown() {
+ if item.SetGlobal.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "set/global", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "set/global")
+ }
}
- if cValue := v.Get("match.ip.next-hop.access-list"); cValue.Exists() {
- item.MatchIpNextHopAccessLists = helpers.GetStringList(cValue.Array())
- } else {
- item.MatchIpNextHopAccessLists = types.ListNull(types.StringType)
+ if !item.SetInterfaces.IsNull() && !item.SetInterfaces.IsUnknown() {
+ var values []string
+ item.SetInterfaces.ElementsAs(ctx, &values, false)
+ for _, v := range values {
+ cBody = helpers.AppendFromXPath(cBody, "set/interface-list", v)
+ }
}
- if cValue := v.Get("match.ip.next-hop.prefix-list"); cValue.Exists() {
- item.MatchIpNextHopPrefixLists = helpers.GetStringList(cValue.Array())
- } else {
- item.MatchIpNextHopPrefixLists = types.ListNull(types.StringType)
+ if !item.SetIpAddress.IsNull() && !item.SetIpAddress.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "set/ip/address/prefix-list", item.SetIpAddress.ValueString())
}
- if cValue := v.Get("match.ipv6.address.access-list"); cValue.Exists() {
- item.MatchIpv6AddressAccessLists = types.StringValue(cValue.String())
+ if !item.SetIpDefaultGlobalNextHopAddress.IsNull() && !item.SetIpDefaultGlobalNextHopAddress.IsUnknown() {
+ var values []string
+ item.SetIpDefaultGlobalNextHopAddress.ElementsAs(ctx, &values, false)
+ for _, v := range values {
+ cBody = helpers.AppendFromXPath(cBody, "set/ip/default/global/next-hop/address", v)
+ }
}
- if cValue := v.Get("match.ipv6.address.prefix-list"); cValue.Exists() {
- item.MatchIpv6AddressPrefixLists = types.StringValue(cValue.String())
+ if !item.SetIpDefaultNextHopAddress.IsNull() && !item.SetIpDefaultNextHopAddress.IsUnknown() {
+ var values []string
+ item.SetIpDefaultNextHopAddress.ElementsAs(ctx, &values, false)
+ for _, v := range values {
+ cBody = helpers.AppendFromXPath(cBody, "set/ip/default/next-hop/address", v)
+ }
}
- if cValue := v.Get("match.ipv6.next-hop.access-list"); cValue.Exists() {
- item.MatchIpv6NextHopAccessLists = types.StringValue(cValue.String())
+ if !item.SetIpGlobalNextHopAddress.IsNull() && !item.SetIpGlobalNextHopAddress.IsUnknown() {
+ var values []string
+ item.SetIpGlobalNextHopAddress.ElementsAs(ctx, &values, false)
+ for _, v := range values {
+ cBody = helpers.AppendFromXPath(cBody, "set/ip/global/next-hop/address", v)
+ }
}
- if cValue := v.Get("match.ipv6.next-hop.prefix-list"); cValue.Exists() {
- item.MatchIpv6NextHopPrefixLists = types.StringValue(cValue.String())
+ if !item.SetIpNextHopAddress.IsNull() && !item.SetIpNextHopAddress.IsUnknown() {
+ var values []string
+ item.SetIpNextHopAddress.ElementsAs(ctx, &values, false)
+ for _, v := range values {
+ cBody = helpers.AppendFromXPath(cBody, "set/ip/next-hop/address", v)
+ }
}
- if cValue := v.Get("match.route-type.external"); cValue.Exists() {
- item.MatchRouteTypeExternal = types.BoolValue(true)
- } else {
- item.MatchRouteTypeExternal = types.BoolValue(false)
+ if !item.SetIpNextHopSelf.IsNull() && !item.SetIpNextHopSelf.IsUnknown() {
+ if item.SetIpNextHopSelf.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "set/ip/next-hop/self", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "set/ip/next-hop/self")
+ }
}
- if cValue := v.Get("match.route-type.external.type-1"); cValue.Exists() {
- item.MatchRouteTypeExternalType1 = types.BoolValue(true)
- } else {
- item.MatchRouteTypeExternalType1 = types.BoolValue(false)
+ if !item.SetIpQosGroup.IsNull() && !item.SetIpQosGroup.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "set/ip/qos-group/qos-id", strconv.FormatInt(item.SetIpQosGroup.ValueInt64(), 10))
}
- if cValue := v.Get("match.route-type.external.type-2"); cValue.Exists() {
- item.MatchRouteTypeExternalType2 = types.BoolValue(true)
- } else {
- item.MatchRouteTypeExternalType2 = types.BoolValue(false)
+ if !item.SetIpv6Address.IsNull() && !item.SetIpv6Address.IsUnknown() {
+ var values []string
+ item.SetIpv6Address.ElementsAs(ctx, &values, false)
+ for _, v := range values {
+ cBody = helpers.AppendFromXPath(cBody, "set/ipv6/address/prefix-list", v)
+ }
}
- if cValue := v.Get("match.route-type.internal"); cValue.Exists() {
- item.MatchRouteTypeInternal = types.BoolValue(true)
- } else {
- item.MatchRouteTypeInternal = types.BoolValue(false)
+ if !item.SetIpv6DefaultGlobalNextHop.IsNull() && !item.SetIpv6DefaultGlobalNextHop.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "set/ipv6/default/global/next-hop", item.SetIpv6DefaultGlobalNextHop.ValueString())
}
- if cValue := v.Get("match.route-type.level-1"); cValue.Exists() {
- item.MatchRouteTypeLevel1 = types.BoolValue(true)
- } else {
- item.MatchRouteTypeLevel1 = types.BoolValue(false)
+ if !item.SetIpv6DefaultNextHop.IsNull() && !item.SetIpv6DefaultNextHop.IsUnknown() {
+ var values []string
+ item.SetIpv6DefaultNextHop.ElementsAs(ctx, &values, false)
+ for _, v := range values {
+ cBody = helpers.AppendFromXPath(cBody, "set/ipv6/default/next-hop/ipv6", v)
+ }
}
- if cValue := v.Get("match.route-type.level-2"); cValue.Exists() {
- item.MatchRouteTypeLevel2 = types.BoolValue(true)
- } else {
- item.MatchRouteTypeLevel2 = types.BoolValue(false)
+ if !item.SetIpv6NextHop.IsNull() && !item.SetIpv6NextHop.IsUnknown() {
+ var values []string
+ item.SetIpv6NextHop.ElementsAs(ctx, &values, false)
+ for _, v := range values {
+ cBody = helpers.AppendFromXPath(cBody, "set/ipv6/next-hop/ipv6", v)
+ }
}
- if cValue := v.Get("match.route-type.local"); cValue.Exists() {
- item.MatchRouteTypeLocalLegacy = types.BoolValue(true)
- } else {
- item.MatchRouteTypeLocalLegacy = types.BoolValue(false)
+ if !item.SetLevel1.IsNull() && !item.SetLevel1.IsUnknown() {
+ if item.SetLevel1.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "set/level/level-1", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "set/level/level-1")
+ }
}
- if cValue := v.Get("match.Cisco-IOS-XE-bgp:bgp-route-map-match.route-type.local"); cValue.Exists() {
- item.MatchRouteTypeLocal = types.BoolValue(true)
- } else {
- item.MatchRouteTypeLocal = types.BoolValue(false)
+ if !item.SetLevel12.IsNull() && !item.SetLevel12.IsUnknown() {
+ if item.SetLevel12.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "set/level/level-1-2", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "set/level/level-1-2")
+ }
}
- if cValue := v.Get("match.source-protocol.bgp"); cValue.Exists() {
- item.MatchSourceProtocolBgp = helpers.GetStringList(cValue.Array())
- } else {
- item.MatchSourceProtocolBgp = types.ListNull(types.StringType)
+ if !item.SetLevel2.IsNull() && !item.SetLevel2.IsUnknown() {
+ if item.SetLevel2.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "set/level/level-2", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "set/level/level-2")
+ }
}
- if cValue := v.Get("match.source-protocol.connected"); cValue.Exists() {
- item.MatchSourceProtocolConnected = types.BoolValue(true)
- } else {
- item.MatchSourceProtocolConnected = types.BoolValue(false)
+ if !item.SetMetricChange.IsNull() && !item.SetMetricChange.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "set/metric/metric-change", item.SetMetricChange.ValueString())
}
- if cValue := v.Get("match.source-protocol.eigrp"); cValue.Exists() {
- item.MatchSourceProtocolEigrp = helpers.GetStringList(cValue.Array())
- } else {
- item.MatchSourceProtocolEigrp = types.ListNull(types.StringType)
+ if !item.SetMetricValue.IsNull() && !item.SetMetricValue.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "set/metric/values/value", strconv.FormatInt(item.SetMetricValue.ValueInt64(), 10))
}
- if cValue := v.Get("match.source-protocol.isis"); cValue.Exists() {
- item.MatchSourceProtocolIsis = types.BoolValue(true)
- } else {
- item.MatchSourceProtocolIsis = types.BoolValue(false)
+ if !item.SetMetricDelay.IsNull() && !item.SetMetricDelay.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "set/metric/values/delay", item.SetMetricDelay.ValueString())
}
- if cValue := v.Get("match.source-protocol.lisp"); cValue.Exists() {
- item.MatchSourceProtocolLisp = types.BoolValue(true)
- } else {
- item.MatchSourceProtocolLisp = types.BoolValue(false)
+ if !item.SetMetricReliability.IsNull() && !item.SetMetricReliability.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "set/metric/values/reliability", strconv.FormatInt(item.SetMetricReliability.ValueInt64(), 10))
}
- if cValue := v.Get("match.source-protocol.ospf"); cValue.Exists() {
- item.MatchSourceProtocolOspf = helpers.GetStringList(cValue.Array())
- } else {
- item.MatchSourceProtocolOspf = types.ListNull(types.StringType)
+ if !item.SetMetricLoading.IsNull() && !item.SetMetricLoading.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "set/metric/values/loading", strconv.FormatInt(item.SetMetricLoading.ValueInt64(), 10))
}
- if cValue := v.Get("match.source-protocol.ospfv3"); cValue.Exists() {
- item.MatchSourceProtocolOspfv3 = helpers.GetStringList(cValue.Array())
- } else {
- item.MatchSourceProtocolOspfv3 = types.ListNull(types.StringType)
+ if !item.SetMetricMtu.IsNull() && !item.SetMetricMtu.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "set/metric/values/MTU", strconv.FormatInt(item.SetMetricMtu.ValueInt64(), 10))
}
- if cValue := v.Get("match.source-protocol.rip"); cValue.Exists() {
- item.MatchSourceProtocolRip = types.BoolValue(true)
- } else {
- item.MatchSourceProtocolRip = types.BoolValue(false)
+ if !item.SetMetricType.IsNull() && !item.SetMetricType.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "set/metric-type", item.SetMetricType.ValueString())
}
- if cValue := v.Get("match.source-protocol.static"); cValue.Exists() {
- item.MatchSourceProtocolStatic = types.BoolValue(true)
- } else {
- item.MatchSourceProtocolStatic = types.BoolValue(false)
+ if !item.SetTag.IsNull() && !item.SetTag.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "set/tag/tag-val", strconv.FormatInt(item.SetTag.ValueInt64(), 10))
}
- if cValue := v.Get("match.tag.tag_value"); cValue.Exists() {
- item.MatchTags = helpers.GetInt64List(cValue.Array())
- } else {
- item.MatchTags = types.ListNull(types.Int64Type)
+ if !item.SetVrf.IsNull() && !item.SetVrf.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "set/vrf", item.SetVrf.ValueString())
}
- if cValue := v.Get("match.track"); cValue.Exists() {
- item.MatchTrack = types.Int64Value(cValue.Int())
+ if !item.SetAsPathPrependAsLegacy.IsNull() && !item.SetAsPathPrependAsLegacy.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "set/as-path/prepend/as-container/as-number", item.SetAsPathPrependAsLegacy.ValueString())
}
- if cValue := v.Get("match.as-path.access-list"); cValue.Exists() {
- item.MatchAsPathsLegacy = helpers.GetInt64List(cValue.Array())
- } else {
- item.MatchAsPathsLegacy = types.ListNull(types.Int64Type)
+ if !item.SetAsPathPrependLastAsLegacy.IsNull() && !item.SetAsPathPrependLastAsLegacy.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "set/as-path/prepend/last-as-cont/last-as", strconv.FormatInt(item.SetAsPathPrependLastAsLegacy.ValueInt64(), 10))
}
- if cValue := v.Get("match.community.name"); cValue.Exists() {
- item.MatchCommunityListsLegacy = helpers.GetStringList(cValue.Array())
- } else {
- item.MatchCommunityListsLegacy = types.ListNull(types.StringType)
+ if !item.SetAsPathTagLegacy.IsNull() && !item.SetAsPathTagLegacy.IsUnknown() {
+ if item.SetAsPathTagLegacy.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "set/as-path/tag", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "set/as-path/tag")
+ }
}
- if cValue := v.Get("match.extcommunity.name"); cValue.Exists() {
- item.MatchExtcommunityListsLegacy = helpers.GetStringList(cValue.Array())
- } else {
- item.MatchExtcommunityListsLegacy = types.ListNull(types.StringType)
+ if !item.SetCommunityNoneLegacy.IsNull() && !item.SetCommunityNoneLegacy.IsUnknown() {
+ if item.SetCommunityNoneLegacy.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "set/community/none", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "set/community/none")
+ }
}
- if cValue := v.Get("match.local-preference.values"); cValue.Exists() {
- item.MatchLocalPreferencesLegacy = helpers.GetInt64List(cValue.Array())
- } else {
- item.MatchLocalPreferencesLegacy = types.ListNull(types.Int64Type)
+ if !item.SetCommunitiesLegacy.IsNull() && !item.SetCommunitiesLegacy.IsUnknown() {
+ var values []string
+ item.SetCommunitiesLegacy.ElementsAs(ctx, &values, false)
+ for _, v := range values {
+ cBody = helpers.AppendFromXPath(cBody, "set/community/community-well-known/community-list", v)
+ }
}
- if cValue := v.Get("match.Cisco-IOS-XE-bgp:bgp-route-map-match.as-path.access-list"); cValue.Exists() {
- item.MatchAsPaths = helpers.GetInt64List(cValue.Array())
- } else {
- item.MatchAsPaths = types.ListNull(types.Int64Type)
+ if !item.SetCommunitiesAdditiveLegacy.IsNull() && !item.SetCommunitiesAdditiveLegacy.IsUnknown() {
+ if item.SetCommunitiesAdditiveLegacy.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "set/community/community-well-known/additive", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "set/community/community-well-known/additive")
+ }
}
- if cValue := v.Get("match.Cisco-IOS-XE-bgp:bgp-route-map-match.bgp-community.community-list"); cValue.Exists() {
- item.MatchCommunityLists = helpers.GetStringList(cValue.Array())
- } else {
- item.MatchCommunityLists = types.ListNull(types.StringType)
+ if !item.SetCommunityListDeleteLegacy.IsNull() && !item.SetCommunityListDeleteLegacy.IsUnknown() {
+ if item.SetCommunityListDeleteLegacy.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "set/comm-list/delete", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "set/comm-list/delete")
+ }
}
- if cValue := v.Get("match.Cisco-IOS-XE-bgp:bgp-route-map-match.bgp-community.exact-match"); cValue.Exists() {
- item.MatchCommunityListExactMatch = types.BoolValue(true)
- } else {
- item.MatchCommunityListExactMatch = types.BoolValue(false)
+ if !item.SetCommunityListStandardLegacy.IsNull() && !item.SetCommunityListStandardLegacy.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "set/comm-list/comm-list-standard", strconv.FormatInt(item.SetCommunityListStandardLegacy.ValueInt64(), 10))
}
- if cValue := v.Get("match.Cisco-IOS-XE-bgp:bgp-route-map-match.extcommunity.extcommunity-list"); cValue.Exists() {
- item.MatchExtcommunityLists = helpers.GetStringList(cValue.Array())
- } else {
- item.MatchExtcommunityLists = types.ListNull(types.StringType)
- }
- if cValue := v.Get("match.Cisco-IOS-XE-bgp:bgp-route-map-match.local-preference.values"); cValue.Exists() {
- item.MatchLocalPreferences = helpers.GetInt64List(cValue.Array())
- } else {
- item.MatchLocalPreferences = types.ListNull(types.Int64Type)
- }
- if cValue := v.Get("set.default.interface-list"); cValue.Exists() {
- item.SetDefaultInterfaces = helpers.GetStringList(cValue.Array())
- } else {
- item.SetDefaultInterfaces = types.ListNull(types.StringType)
- }
- if cValue := v.Get("set.global"); cValue.Exists() {
- item.SetGlobal = types.BoolValue(true)
- } else {
- item.SetGlobal = types.BoolValue(false)
- }
- if cValue := v.Get("set.interface-list"); cValue.Exists() {
- item.SetInterfaces = helpers.GetStringList(cValue.Array())
- } else {
- item.SetInterfaces = types.ListNull(types.StringType)
- }
- if cValue := v.Get("set.ip.address.prefix-list"); cValue.Exists() {
- item.SetIpAddress = types.StringValue(cValue.String())
- }
- if cValue := v.Get("set.ip.default.global.next-hop.address"); cValue.Exists() {
- item.SetIpDefaultGlobalNextHopAddress = helpers.GetStringList(cValue.Array())
- } else {
- item.SetIpDefaultGlobalNextHopAddress = types.ListNull(types.StringType)
- }
- if cValue := v.Get("set.ip.default.next-hop.address"); cValue.Exists() {
- item.SetIpDefaultNextHopAddress = helpers.GetStringList(cValue.Array())
- } else {
- item.SetIpDefaultNextHopAddress = types.ListNull(types.StringType)
- }
- if cValue := v.Get("set.ip.global.next-hop.address"); cValue.Exists() {
- item.SetIpGlobalNextHopAddress = helpers.GetStringList(cValue.Array())
- } else {
- item.SetIpGlobalNextHopAddress = types.ListNull(types.StringType)
- }
- if cValue := v.Get("set.ip.next-hop.address"); cValue.Exists() {
- item.SetIpNextHopAddress = helpers.GetStringList(cValue.Array())
- } else {
- item.SetIpNextHopAddress = types.ListNull(types.StringType)
- }
- if cValue := v.Get("set.ip.next-hop.self"); cValue.Exists() {
- item.SetIpNextHopSelf = types.BoolValue(true)
- } else {
- item.SetIpNextHopSelf = types.BoolValue(false)
- }
- if cValue := v.Get("set.ip.qos-group.qos-id"); cValue.Exists() {
- item.SetIpQosGroup = types.Int64Value(cValue.Int())
- }
- if cValue := v.Get("set.ipv6.address.prefix-list"); cValue.Exists() {
- item.SetIpv6Address = helpers.GetStringList(cValue.Array())
- } else {
- item.SetIpv6Address = types.ListNull(types.StringType)
- }
- if cValue := v.Get("set.ipv6.default.global.next-hop"); cValue.Exists() {
- item.SetIpv6DefaultGlobalNextHop = types.StringValue(cValue.String())
+ if !item.SetCommunityListExpandedLegacy.IsNull() && !item.SetCommunityListExpandedLegacy.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "set/Cisco-IOS-XE-bgp:bgp-route-map-set/comm-list/comm-list-expanded", strconv.FormatInt(item.SetCommunityListExpandedLegacy.ValueInt64(), 10))
}
- if cValue := v.Get("set.ipv6.default.next-hop.ipv6"); cValue.Exists() {
- item.SetIpv6DefaultNextHop = helpers.GetStringList(cValue.Array())
- } else {
- item.SetIpv6DefaultNextHop = types.ListNull(types.StringType)
+ if !item.SetCommunityListNameLegacy.IsNull() && !item.SetCommunityListNameLegacy.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "set/comm-list/comm-list-name", item.SetCommunityListNameLegacy.ValueString())
}
- if cValue := v.Get("set.ipv6.next-hop.ipv6"); cValue.Exists() {
- item.SetIpv6NextHop = helpers.GetStringList(cValue.Array())
- } else {
- item.SetIpv6NextHop = types.ListNull(types.StringType)
+ if !item.SetExtcomunityRtLegacy.IsNull() && !item.SetExtcomunityRtLegacy.IsUnknown() {
+ var values []string
+ item.SetExtcomunityRtLegacy.ElementsAs(ctx, &values, false)
+ for _, v := range values {
+ cBody = helpers.AppendFromXPath(cBody, "set/extcommunity/rt/asn-nn", v)
+ }
}
- if cValue := v.Get("set.level.level-1"); cValue.Exists() {
- item.SetLevel1 = types.BoolValue(true)
- } else {
- item.SetLevel1 = types.BoolValue(false)
+ if !item.SetExtcomunitySooLegacy.IsNull() && !item.SetExtcomunitySooLegacy.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "set/extcommunity/soo/asn-nn", item.SetExtcomunitySooLegacy.ValueString())
}
- if cValue := v.Get("set.level.level-1-2"); cValue.Exists() {
- item.SetLevel12 = types.BoolValue(true)
- } else {
- item.SetLevel12 = types.BoolValue(false)
+ if !item.SetExtcomunityVpnDistinguisherLegacy.IsNull() && !item.SetExtcomunityVpnDistinguisherLegacy.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "set/extcommunity/vpn-distinguisher/asn-nn", item.SetExtcomunityVpnDistinguisherLegacy.ValueString())
}
- if cValue := v.Get("set.level.level-2"); cValue.Exists() {
- item.SetLevel2 = types.BoolValue(true)
- } else {
- item.SetLevel2 = types.BoolValue(false)
+ if !item.SetLocalPreferenceLegacy.IsNull() && !item.SetLocalPreferenceLegacy.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "set/local-preference", strconv.FormatInt(item.SetLocalPreferenceLegacy.ValueInt64(), 10))
}
- if cValue := v.Get("set.metric.metric-change"); cValue.Exists() {
- item.SetMetricChange = types.StringValue(cValue.String())
+ if !item.SetWeightLegacy.IsNull() && !item.SetWeightLegacy.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "set/weight", strconv.FormatInt(item.SetWeightLegacy.ValueInt64(), 10))
}
- if cValue := v.Get("set.metric.values.value"); cValue.Exists() {
- item.SetMetricValue = types.Int64Value(cValue.Int())
+ if !item.SetAsPathPrependAs.IsNull() && !item.SetAsPathPrependAs.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "set/Cisco-IOS-XE-bgp:bgp-route-map-set/as-path/prepend/as-container/as-number", item.SetAsPathPrependAs.ValueString())
}
- if cValue := v.Get("set.metric.values.delay"); cValue.Exists() {
- item.SetMetricDelay = types.StringValue(cValue.String())
+ if !item.SetAsPathPrependLastAs.IsNull() && !item.SetAsPathPrependLastAs.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "set/Cisco-IOS-XE-bgp:bgp-route-map-set/as-path/prepend/last-as-cont/last-as", strconv.FormatInt(item.SetAsPathPrependLastAs.ValueInt64(), 10))
}
- if cValue := v.Get("set.metric.values.reliability"); cValue.Exists() {
- item.SetMetricReliability = types.Int64Value(cValue.Int())
+ if !item.SetAsPathTag.IsNull() && !item.SetAsPathTag.IsUnknown() {
+ if item.SetAsPathTag.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "set/Cisco-IOS-XE-bgp:bgp-route-map-set/as-path/tag", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "set/Cisco-IOS-XE-bgp:bgp-route-map-set/as-path/tag")
+ }
}
- if cValue := v.Get("set.metric.values.loading"); cValue.Exists() {
- item.SetMetricLoading = types.Int64Value(cValue.Int())
+ if !item.SetAsPathReplaceAny.IsNull() && !item.SetAsPathReplaceAny.IsUnknown() {
+ if item.SetAsPathReplaceAny.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "set/Cisco-IOS-XE-bgp:bgp-route-map-set/as-path/replace/any", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "set/Cisco-IOS-XE-bgp:bgp-route-map-set/as-path/replace/any")
+ }
}
- if cValue := v.Get("set.metric.values.MTU"); cValue.Exists() {
- item.SetMetricMtu = types.Int64Value(cValue.Int())
+ if len(item.SetAsPathReplaceAs) > 0 {
+ for _, citem := range item.SetAsPathReplaceAs {
+ ccBody := netconf.Body{}
+ if !citem.AsNumber.IsNull() && !citem.AsNumber.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "as-number", citem.AsNumber.ValueString())
+ }
+ cBody = helpers.SetRawFromXPath(cBody, "set/Cisco-IOS-XE-bgp:bgp-route-map-set/as-path/replace/as-container", ccBody.Res())
+ }
}
- if cValue := v.Get("set.metric-type"); cValue.Exists() {
- item.SetMetricType = types.StringValue(cValue.String())
+ if !item.SetCommunityNone.IsNull() && !item.SetCommunityNone.IsUnknown() {
+ if item.SetCommunityNone.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "set/Cisco-IOS-XE-bgp:bgp-route-map-set/bgp-community/none", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "set/Cisco-IOS-XE-bgp:bgp-route-map-set/bgp-community/none")
+ }
}
- if cValue := v.Get("set.tag.tag-val"); cValue.Exists() {
- item.SetTag = types.Int64Value(cValue.Int())
+ if !item.SetCommunities.IsNull() && !item.SetCommunities.IsUnknown() {
+ var values []string
+ item.SetCommunities.ElementsAs(ctx, &values, false)
+ for _, v := range values {
+ cBody = helpers.AppendFromXPath(cBody, "set/Cisco-IOS-XE-bgp:bgp-route-map-set/bgp-community/community-well-known/community-list", v)
+ }
}
- if cValue := v.Get("set.vrf"); cValue.Exists() {
- item.SetVrf = types.StringValue(cValue.String())
+ if !item.SetCommunitiesAdditive.IsNull() && !item.SetCommunitiesAdditive.IsUnknown() {
+ if item.SetCommunitiesAdditive.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "set/Cisco-IOS-XE-bgp:bgp-route-map-set/bgp-community/community-well-known/additive", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "set/Cisco-IOS-XE-bgp:bgp-route-map-set/bgp-community/community-well-known/additive")
+ }
}
- if cValue := v.Get("set.as-path.prepend.as-container.as-number"); cValue.Exists() {
- item.SetAsPathPrependAsLegacy = types.StringValue(cValue.String())
+ if !item.SetCommunityListDelete.IsNull() && !item.SetCommunityListDelete.IsUnknown() {
+ if item.SetCommunityListDelete.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "set/Cisco-IOS-XE-bgp:bgp-route-map-set/comm-list/delete", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "set/Cisco-IOS-XE-bgp:bgp-route-map-set/comm-list/delete")
+ }
}
- if cValue := v.Get("set.as-path.prepend.last-as-cont.last-as"); cValue.Exists() {
- item.SetAsPathPrependLastAsLegacy = types.Int64Value(cValue.Int())
+ if !item.SetCommunityListStandard.IsNull() && !item.SetCommunityListStandard.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "set/Cisco-IOS-XE-bgp:bgp-route-map-set/comm-list/comm-list-standard", strconv.FormatInt(item.SetCommunityListStandard.ValueInt64(), 10))
}
- if cValue := v.Get("set.as-path.tag"); cValue.Exists() {
- item.SetAsPathTagLegacy = types.BoolValue(true)
- } else {
- item.SetAsPathTagLegacy = types.BoolValue(false)
+ if !item.SetCommunityListExpanded.IsNull() && !item.SetCommunityListExpanded.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "set/Cisco-IOS-XE-bgp:bgp-route-map-set/comm-list/comm-list-expanded", strconv.FormatInt(item.SetCommunityListExpanded.ValueInt64(), 10))
}
- if cValue := v.Get("set.community.none"); cValue.Exists() {
- item.SetCommunityNoneLegacy = types.BoolValue(true)
- } else {
- item.SetCommunityNoneLegacy = types.BoolValue(false)
+ if !item.SetCommunityListName.IsNull() && !item.SetCommunityListName.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "set/Cisco-IOS-XE-bgp:bgp-route-map-set/comm-list/comm-list-name", item.SetCommunityListName.ValueString())
}
- if cValue := v.Get("set.community.community-well-known.community-list"); cValue.Exists() {
- item.SetCommunitiesLegacy = helpers.GetStringList(cValue.Array())
- } else {
- item.SetCommunitiesLegacy = types.ListNull(types.StringType)
+ if !item.SetExtcomunityRt.IsNull() && !item.SetExtcomunityRt.IsUnknown() {
+ var values []string
+ item.SetExtcomunityRt.ElementsAs(ctx, &values, false)
+ for _, v := range values {
+ cBody = helpers.AppendFromXPath(cBody, "set/Cisco-IOS-XE-bgp:bgp-route-map-set/extcommunity/rt/asn-nn", v)
+ }
}
- if cValue := v.Get("set.community.community-well-known.additive"); cValue.Exists() {
- item.SetCommunitiesAdditiveLegacy = types.BoolValue(true)
- } else {
- item.SetCommunitiesAdditiveLegacy = types.BoolValue(false)
+ if !item.SetExtcomunitySoo.IsNull() && !item.SetExtcomunitySoo.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "set/Cisco-IOS-XE-bgp:bgp-route-map-set/extcommunity/soo/asn-nn", item.SetExtcomunitySoo.ValueString())
}
- if cValue := v.Get("set.comm-list.delete"); cValue.Exists() {
- item.SetCommunityListDeleteLegacy = types.BoolValue(true)
- } else {
- item.SetCommunityListDeleteLegacy = types.BoolValue(false)
+ if !item.SetExtcomunityVpnDistinguisher.IsNull() && !item.SetExtcomunityVpnDistinguisher.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "set/Cisco-IOS-XE-bgp:bgp-route-map-set/extcommunity/vpn-distinguisher/asn-nn", item.SetExtcomunityVpnDistinguisher.ValueString())
}
- if cValue := v.Get("set.comm-list.comm-list-standard"); cValue.Exists() {
- item.SetCommunityListStandardLegacy = types.Int64Value(cValue.Int())
+ if !item.SetExtcomunityVpnDistinguisherAdditive.IsNull() && !item.SetExtcomunityVpnDistinguisherAdditive.IsUnknown() {
+ if item.SetExtcomunityVpnDistinguisherAdditive.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "set/Cisco-IOS-XE-bgp:bgp-route-map-set/extcommunity/vpn-distinguisher/asn-nn-additive", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "set/Cisco-IOS-XE-bgp:bgp-route-map-set/extcommunity/vpn-distinguisher/asn-nn-additive")
+ }
}
- if cValue := v.Get("set.Cisco-IOS-XE-bgp:bgp-route-map-set.comm-list.comm-list-expanded"); cValue.Exists() {
- item.SetCommunityListExpandedLegacy = types.Int64Value(cValue.Int())
+ if !item.SetLocalPreference.IsNull() && !item.SetLocalPreference.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "set/Cisco-IOS-XE-bgp:bgp-route-map-set/local-preference", strconv.FormatInt(item.SetLocalPreference.ValueInt64(), 10))
}
- if cValue := v.Get("set.comm-list.comm-list-name"); cValue.Exists() {
- item.SetCommunityListNameLegacy = types.StringValue(cValue.String())
+ if !item.SetWeight.IsNull() && !item.SetWeight.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "set/Cisco-IOS-XE-bgp:bgp-route-map-set/weight", strconv.FormatInt(item.SetWeight.ValueInt64(), 10))
}
- if cValue := v.Get("set.extcommunity.rt.asn-nn"); cValue.Exists() {
- item.SetExtcomunityRtLegacy = helpers.GetStringList(cValue.Array())
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-route-map:route-map-without-order-seq", cBody.Res())
+ }
+ }
+ bodyString, err := body.String()
+ if err != nil {
+ tflog.Error(ctx, fmt.Sprintf("Error converting body to string: %s", err))
+ }
+ return bodyString
+}
+
+// End of section. //template:end toBodyXML
+
+// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBody
+
+func (data *RouteMap) updateFromBody(ctx context.Context, res gjson.Result) {
+ prefix := helpers.LastElement(data.getPath()) + "."
+ if res.Get(helpers.LastElement(data.getPath())).IsArray() {
+ prefix += "0."
+ }
+ if value := res.Get(prefix + "name"); value.Exists() && !data.Name.IsNull() {
+ data.Name = types.StringValue(value.String())
+ } else {
+ data.Name = types.StringNull()
+ }
+ for i := range data.Entries {
+ keys := [...]string{"seq_no"}
+ keyValues := [...]string{strconv.FormatInt(data.Entries[i].Seq.ValueInt64(), 10)}
+
+ var r gjson.Result
+ res.Get(prefix + "Cisco-IOS-XE-route-map:route-map-without-order-seq").ForEach(
+ func(_, v gjson.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := r.Get("seq_no"); value.Exists() && !data.Entries[i].Seq.IsNull() {
+ data.Entries[i].Seq = types.Int64Value(value.Int())
+ } else {
+ data.Entries[i].Seq = types.Int64Null()
+ }
+ if value := r.Get("operation"); value.Exists() && !data.Entries[i].Operation.IsNull() {
+ data.Entries[i].Operation = types.StringValue(value.String())
+ } else {
+ data.Entries[i].Operation = types.StringNull()
+ }
+ if value := r.Get("description"); value.Exists() && !data.Entries[i].Description.IsNull() {
+ data.Entries[i].Description = types.StringValue(value.String())
+ } else {
+ data.Entries[i].Description = types.StringNull()
+ }
+ if value := r.Get("continue"); !data.Entries[i].Continue.IsNull() {
+ if value.Exists() {
+ data.Entries[i].Continue = types.BoolValue(true)
} else {
- item.SetExtcomunityRtLegacy = types.ListNull(types.StringType)
- }
- if cValue := v.Get("set.extcommunity.soo.asn-nn"); cValue.Exists() {
- item.SetExtcomunitySooLegacy = types.StringValue(cValue.String())
- }
- if cValue := v.Get("set.extcommunity.vpn-distinguisher.asn-nn"); cValue.Exists() {
- item.SetExtcomunityVpnDistinguisherLegacy = types.StringValue(cValue.String())
- }
- if cValue := v.Get("set.local-preference"); cValue.Exists() {
- item.SetLocalPreferenceLegacy = types.Int64Value(cValue.Int())
- }
- if cValue := v.Get("set.weight"); cValue.Exists() {
- item.SetWeightLegacy = types.Int64Value(cValue.Int())
+ data.Entries[i].Continue = types.BoolValue(false)
}
- if cValue := v.Get("set.Cisco-IOS-XE-bgp:bgp-route-map-set.as-path.prepend.as-container.as-number"); cValue.Exists() {
- item.SetAsPathPrependAs = types.StringValue(cValue.String())
- }
- if cValue := v.Get("set.Cisco-IOS-XE-bgp:bgp-route-map-set.as-path.prepend.last-as-cont.last-as"); cValue.Exists() {
- item.SetAsPathPrependLastAs = types.Int64Value(cValue.Int())
- }
- if cValue := v.Get("set.Cisco-IOS-XE-bgp:bgp-route-map-set.as-path.tag"); cValue.Exists() {
- item.SetAsPathTag = types.BoolValue(true)
+ } else {
+ data.Entries[i].Continue = types.BoolNull()
+ }
+ if value := r.Get("continue.sequence-number"); value.Exists() && !data.Entries[i].ContinueSequenceNumber.IsNull() {
+ data.Entries[i].ContinueSequenceNumber = types.Int64Value(value.Int())
+ } else {
+ data.Entries[i].ContinueSequenceNumber = types.Int64Null()
+ }
+ if value := r.Get("match.interface.interface"); value.Exists() && !data.Entries[i].MatchInterfaces.IsNull() {
+ data.Entries[i].MatchInterfaces = helpers.GetStringList(value.Array())
+ } else {
+ data.Entries[i].MatchInterfaces = types.ListNull(types.StringType)
+ }
+ if value := r.Get("match.ip.address.access-list"); value.Exists() && !data.Entries[i].MatchIpAddressAccessLists.IsNull() {
+ data.Entries[i].MatchIpAddressAccessLists = helpers.GetStringList(value.Array())
+ } else {
+ data.Entries[i].MatchIpAddressAccessLists = types.ListNull(types.StringType)
+ }
+ if value := r.Get("match.ip.address.prefix-list"); value.Exists() && !data.Entries[i].MatchIpAddressPrefixLists.IsNull() {
+ data.Entries[i].MatchIpAddressPrefixLists = helpers.GetStringList(value.Array())
+ } else {
+ data.Entries[i].MatchIpAddressPrefixLists = types.ListNull(types.StringType)
+ }
+ if value := r.Get("match.ip.next-hop.access-list"); value.Exists() && !data.Entries[i].MatchIpNextHopAccessLists.IsNull() {
+ data.Entries[i].MatchIpNextHopAccessLists = helpers.GetStringList(value.Array())
+ } else {
+ data.Entries[i].MatchIpNextHopAccessLists = types.ListNull(types.StringType)
+ }
+ if value := r.Get("match.ip.next-hop.prefix-list"); value.Exists() && !data.Entries[i].MatchIpNextHopPrefixLists.IsNull() {
+ data.Entries[i].MatchIpNextHopPrefixLists = helpers.GetStringList(value.Array())
+ } else {
+ data.Entries[i].MatchIpNextHopPrefixLists = types.ListNull(types.StringType)
+ }
+ if value := r.Get("match.ipv6.address.access-list"); value.Exists() && !data.Entries[i].MatchIpv6AddressAccessLists.IsNull() {
+ data.Entries[i].MatchIpv6AddressAccessLists = types.StringValue(value.String())
+ } else {
+ data.Entries[i].MatchIpv6AddressAccessLists = types.StringNull()
+ }
+ if value := r.Get("match.ipv6.address.prefix-list"); value.Exists() && !data.Entries[i].MatchIpv6AddressPrefixLists.IsNull() {
+ data.Entries[i].MatchIpv6AddressPrefixLists = types.StringValue(value.String())
+ } else {
+ data.Entries[i].MatchIpv6AddressPrefixLists = types.StringNull()
+ }
+ if value := r.Get("match.ipv6.next-hop.access-list"); value.Exists() && !data.Entries[i].MatchIpv6NextHopAccessLists.IsNull() {
+ data.Entries[i].MatchIpv6NextHopAccessLists = types.StringValue(value.String())
+ } else {
+ data.Entries[i].MatchIpv6NextHopAccessLists = types.StringNull()
+ }
+ if value := r.Get("match.ipv6.next-hop.prefix-list"); value.Exists() && !data.Entries[i].MatchIpv6NextHopPrefixLists.IsNull() {
+ data.Entries[i].MatchIpv6NextHopPrefixLists = types.StringValue(value.String())
+ } else {
+ data.Entries[i].MatchIpv6NextHopPrefixLists = types.StringNull()
+ }
+ if value := r.Get("match.route-type.external"); !data.Entries[i].MatchRouteTypeExternal.IsNull() {
+ if value.Exists() {
+ data.Entries[i].MatchRouteTypeExternal = types.BoolValue(true)
} else {
- item.SetAsPathTag = types.BoolValue(false)
+ data.Entries[i].MatchRouteTypeExternal = types.BoolValue(false)
}
- if cValue := v.Get("set.Cisco-IOS-XE-bgp:bgp-route-map-set.as-path.replace.any"); cValue.Exists() {
- item.SetAsPathReplaceAny = types.BoolValue(true)
+ } else {
+ data.Entries[i].MatchRouteTypeExternal = types.BoolNull()
+ }
+ if value := r.Get("match.route-type.external.type-1"); !data.Entries[i].MatchRouteTypeExternalType1.IsNull() {
+ if value.Exists() {
+ data.Entries[i].MatchRouteTypeExternalType1 = types.BoolValue(true)
} else {
- item.SetAsPathReplaceAny = types.BoolValue(false)
- }
- if cValue := v.Get("set.Cisco-IOS-XE-bgp:bgp-route-map-set.as-path.replace.as-container"); cValue.Exists() {
- item.SetAsPathReplaceAs = make([]RouteMapEntriesSetAsPathReplaceAs, 0)
- cValue.ForEach(func(ck, cv gjson.Result) bool {
- cItem := RouteMapEntriesSetAsPathReplaceAs{}
- if ccValue := cv.Get("as-number"); ccValue.Exists() {
- cItem.AsNumber = types.StringValue(ccValue.String())
- }
- item.SetAsPathReplaceAs = append(item.SetAsPathReplaceAs, cItem)
- return true
- })
+ data.Entries[i].MatchRouteTypeExternalType1 = types.BoolValue(false)
}
- if cValue := v.Get("set.Cisco-IOS-XE-bgp:bgp-route-map-set.bgp-community.none"); cValue.Exists() {
- item.SetCommunityNone = types.BoolValue(true)
+ } else {
+ data.Entries[i].MatchRouteTypeExternalType1 = types.BoolNull()
+ }
+ if value := r.Get("match.route-type.external.type-2"); !data.Entries[i].MatchRouteTypeExternalType2.IsNull() {
+ if value.Exists() {
+ data.Entries[i].MatchRouteTypeExternalType2 = types.BoolValue(true)
} else {
- item.SetCommunityNone = types.BoolValue(false)
+ data.Entries[i].MatchRouteTypeExternalType2 = types.BoolValue(false)
}
- if cValue := v.Get("set.Cisco-IOS-XE-bgp:bgp-route-map-set.bgp-community.community-well-known.community-list"); cValue.Exists() {
- item.SetCommunities = helpers.GetStringList(cValue.Array())
+ } else {
+ data.Entries[i].MatchRouteTypeExternalType2 = types.BoolNull()
+ }
+ if value := r.Get("match.route-type.internal"); !data.Entries[i].MatchRouteTypeInternal.IsNull() {
+ if value.Exists() {
+ data.Entries[i].MatchRouteTypeInternal = types.BoolValue(true)
} else {
- item.SetCommunities = types.ListNull(types.StringType)
+ data.Entries[i].MatchRouteTypeInternal = types.BoolValue(false)
}
- if cValue := v.Get("set.Cisco-IOS-XE-bgp:bgp-route-map-set.bgp-community.community-well-known.additive"); cValue.Exists() {
- item.SetCommunitiesAdditive = types.BoolValue(true)
+ } else {
+ data.Entries[i].MatchRouteTypeInternal = types.BoolNull()
+ }
+ if value := r.Get("match.route-type.level-1"); !data.Entries[i].MatchRouteTypeLevel1.IsNull() {
+ if value.Exists() {
+ data.Entries[i].MatchRouteTypeLevel1 = types.BoolValue(true)
} else {
- item.SetCommunitiesAdditive = types.BoolValue(false)
+ data.Entries[i].MatchRouteTypeLevel1 = types.BoolValue(false)
}
- if cValue := v.Get("set.Cisco-IOS-XE-bgp:bgp-route-map-set.comm-list.delete"); cValue.Exists() {
- item.SetCommunityListDelete = types.BoolValue(true)
+ } else {
+ data.Entries[i].MatchRouteTypeLevel1 = types.BoolNull()
+ }
+ if value := r.Get("match.route-type.level-2"); !data.Entries[i].MatchRouteTypeLevel2.IsNull() {
+ if value.Exists() {
+ data.Entries[i].MatchRouteTypeLevel2 = types.BoolValue(true)
} else {
- item.SetCommunityListDelete = types.BoolValue(false)
- }
- if cValue := v.Get("set.Cisco-IOS-XE-bgp:bgp-route-map-set.comm-list.comm-list-standard"); cValue.Exists() {
- item.SetCommunityListStandard = types.Int64Value(cValue.Int())
- }
- if cValue := v.Get("set.Cisco-IOS-XE-bgp:bgp-route-map-set.comm-list.comm-list-expanded"); cValue.Exists() {
- item.SetCommunityListExpanded = types.Int64Value(cValue.Int())
- }
- if cValue := v.Get("set.Cisco-IOS-XE-bgp:bgp-route-map-set.comm-list.comm-list-name"); cValue.Exists() {
- item.SetCommunityListName = types.StringValue(cValue.String())
+ data.Entries[i].MatchRouteTypeLevel2 = types.BoolValue(false)
}
- if cValue := v.Get("set.Cisco-IOS-XE-bgp:bgp-route-map-set.extcommunity.rt.asn-nn"); cValue.Exists() {
- item.SetExtcomunityRt = helpers.GetStringList(cValue.Array())
+ } else {
+ data.Entries[i].MatchRouteTypeLevel2 = types.BoolNull()
+ }
+ if value := r.Get("match.route-type.local"); !data.Entries[i].MatchRouteTypeLocalLegacy.IsNull() {
+ if value.Exists() {
+ data.Entries[i].MatchRouteTypeLocalLegacy = types.BoolValue(true)
} else {
- item.SetExtcomunityRt = types.ListNull(types.StringType)
- }
- if cValue := v.Get("set.Cisco-IOS-XE-bgp:bgp-route-map-set.extcommunity.soo.asn-nn"); cValue.Exists() {
- item.SetExtcomunitySoo = types.StringValue(cValue.String())
- }
- if cValue := v.Get("set.Cisco-IOS-XE-bgp:bgp-route-map-set.extcommunity.vpn-distinguisher.asn-nn"); cValue.Exists() {
- item.SetExtcomunityVpnDistinguisher = types.StringValue(cValue.String())
+ data.Entries[i].MatchRouteTypeLocalLegacy = types.BoolValue(false)
}
- if cValue := v.Get("set.Cisco-IOS-XE-bgp:bgp-route-map-set.extcommunity.vpn-distinguisher.asn-nn-additive"); cValue.Exists() {
- item.SetExtcomunityVpnDistinguisherAdditive = types.BoolValue(true)
+ } else {
+ data.Entries[i].MatchRouteTypeLocalLegacy = types.BoolNull()
+ }
+ if value := r.Get("match.Cisco-IOS-XE-bgp:bgp-route-map-match.route-type.local"); !data.Entries[i].MatchRouteTypeLocal.IsNull() {
+ if value.Exists() {
+ data.Entries[i].MatchRouteTypeLocal = types.BoolValue(true)
} else {
- item.SetExtcomunityVpnDistinguisherAdditive = types.BoolValue(false)
- }
- if cValue := v.Get("set.Cisco-IOS-XE-bgp:bgp-route-map-set.local-preference"); cValue.Exists() {
- item.SetLocalPreference = types.Int64Value(cValue.Int())
- }
- if cValue := v.Get("set.Cisco-IOS-XE-bgp:bgp-route-map-set.weight"); cValue.Exists() {
- item.SetWeight = types.Int64Value(cValue.Int())
- }
- data.Entries = append(data.Entries, item)
- return true
- })
- }
-}
-
-// End of section. //template:end fromBody
-
-// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyData
-
-func (data *RouteMapData) fromBody(ctx context.Context, res gjson.Result) {
- prefix := helpers.LastElement(data.getPath()) + "."
- if res.Get(helpers.LastElement(data.getPath())).IsArray() {
- prefix += "0."
- }
- if value := res.Get(prefix + "Cisco-IOS-XE-route-map:route-map-without-order-seq"); value.Exists() {
- data.Entries = make([]RouteMapEntries, 0)
- value.ForEach(func(k, v gjson.Result) bool {
- item := RouteMapEntries{}
- if cValue := v.Get("seq_no"); cValue.Exists() {
- item.Seq = types.Int64Value(cValue.Int())
- }
- if cValue := v.Get("operation"); cValue.Exists() {
- item.Operation = types.StringValue(cValue.String())
- }
- if cValue := v.Get("description"); cValue.Exists() {
- item.Description = types.StringValue(cValue.String())
+ data.Entries[i].MatchRouteTypeLocal = types.BoolValue(false)
}
- if cValue := v.Get("continue"); cValue.Exists() {
- item.Continue = types.BoolValue(true)
+ } else {
+ data.Entries[i].MatchRouteTypeLocal = types.BoolNull()
+ }
+ if value := r.Get("match.source-protocol.bgp"); value.Exists() && !data.Entries[i].MatchSourceProtocolBgp.IsNull() {
+ data.Entries[i].MatchSourceProtocolBgp = helpers.GetStringList(value.Array())
+ } else {
+ data.Entries[i].MatchSourceProtocolBgp = types.ListNull(types.StringType)
+ }
+ if value := r.Get("match.source-protocol.connected"); !data.Entries[i].MatchSourceProtocolConnected.IsNull() {
+ if value.Exists() {
+ data.Entries[i].MatchSourceProtocolConnected = types.BoolValue(true)
} else {
- item.Continue = types.BoolValue(false)
- }
- if cValue := v.Get("continue.sequence-number"); cValue.Exists() {
- item.ContinueSequenceNumber = types.Int64Value(cValue.Int())
+ data.Entries[i].MatchSourceProtocolConnected = types.BoolValue(false)
}
- if cValue := v.Get("match.interface.interface"); cValue.Exists() {
- item.MatchInterfaces = helpers.GetStringList(cValue.Array())
+ } else {
+ data.Entries[i].MatchSourceProtocolConnected = types.BoolNull()
+ }
+ if value := r.Get("match.source-protocol.eigrp"); value.Exists() && !data.Entries[i].MatchSourceProtocolEigrp.IsNull() {
+ data.Entries[i].MatchSourceProtocolEigrp = helpers.GetStringList(value.Array())
+ } else {
+ data.Entries[i].MatchSourceProtocolEigrp = types.ListNull(types.StringType)
+ }
+ if value := r.Get("match.source-protocol.isis"); !data.Entries[i].MatchSourceProtocolIsis.IsNull() {
+ if value.Exists() {
+ data.Entries[i].MatchSourceProtocolIsis = types.BoolValue(true)
} else {
- item.MatchInterfaces = types.ListNull(types.StringType)
+ data.Entries[i].MatchSourceProtocolIsis = types.BoolValue(false)
}
- if cValue := v.Get("match.ip.address.access-list"); cValue.Exists() {
- item.MatchIpAddressAccessLists = helpers.GetStringList(cValue.Array())
+ } else {
+ data.Entries[i].MatchSourceProtocolIsis = types.BoolNull()
+ }
+ if value := r.Get("match.source-protocol.lisp"); !data.Entries[i].MatchSourceProtocolLisp.IsNull() {
+ if value.Exists() {
+ data.Entries[i].MatchSourceProtocolLisp = types.BoolValue(true)
} else {
- item.MatchIpAddressAccessLists = types.ListNull(types.StringType)
+ data.Entries[i].MatchSourceProtocolLisp = types.BoolValue(false)
}
- if cValue := v.Get("match.ip.address.prefix-list"); cValue.Exists() {
- item.MatchIpAddressPrefixLists = helpers.GetStringList(cValue.Array())
+ } else {
+ data.Entries[i].MatchSourceProtocolLisp = types.BoolNull()
+ }
+ if value := r.Get("match.source-protocol.ospf"); value.Exists() && !data.Entries[i].MatchSourceProtocolOspf.IsNull() {
+ data.Entries[i].MatchSourceProtocolOspf = helpers.GetStringList(value.Array())
+ } else {
+ data.Entries[i].MatchSourceProtocolOspf = types.ListNull(types.StringType)
+ }
+ if value := r.Get("match.source-protocol.ospfv3"); value.Exists() && !data.Entries[i].MatchSourceProtocolOspfv3.IsNull() {
+ data.Entries[i].MatchSourceProtocolOspfv3 = helpers.GetStringList(value.Array())
+ } else {
+ data.Entries[i].MatchSourceProtocolOspfv3 = types.ListNull(types.StringType)
+ }
+ if value := r.Get("match.source-protocol.rip"); !data.Entries[i].MatchSourceProtocolRip.IsNull() {
+ if value.Exists() {
+ data.Entries[i].MatchSourceProtocolRip = types.BoolValue(true)
} else {
- item.MatchIpAddressPrefixLists = types.ListNull(types.StringType)
+ data.Entries[i].MatchSourceProtocolRip = types.BoolValue(false)
}
- if cValue := v.Get("match.ip.next-hop.access-list"); cValue.Exists() {
- item.MatchIpNextHopAccessLists = helpers.GetStringList(cValue.Array())
+ } else {
+ data.Entries[i].MatchSourceProtocolRip = types.BoolNull()
+ }
+ if value := r.Get("match.source-protocol.static"); !data.Entries[i].MatchSourceProtocolStatic.IsNull() {
+ if value.Exists() {
+ data.Entries[i].MatchSourceProtocolStatic = types.BoolValue(true)
} else {
- item.MatchIpNextHopAccessLists = types.ListNull(types.StringType)
+ data.Entries[i].MatchSourceProtocolStatic = types.BoolValue(false)
}
- if cValue := v.Get("match.ip.next-hop.prefix-list"); cValue.Exists() {
- item.MatchIpNextHopPrefixLists = helpers.GetStringList(cValue.Array())
+ } else {
+ data.Entries[i].MatchSourceProtocolStatic = types.BoolNull()
+ }
+ if value := r.Get("match.tag.tag_value"); value.Exists() && !data.Entries[i].MatchTags.IsNull() {
+ data.Entries[i].MatchTags = helpers.GetInt64List(value.Array())
+ } else {
+ data.Entries[i].MatchTags = types.ListNull(types.Int64Type)
+ }
+ if value := r.Get("match.track"); value.Exists() && !data.Entries[i].MatchTrack.IsNull() {
+ data.Entries[i].MatchTrack = types.Int64Value(value.Int())
+ } else {
+ data.Entries[i].MatchTrack = types.Int64Null()
+ }
+ if value := r.Get("match.as-path.access-list"); value.Exists() && !data.Entries[i].MatchAsPathsLegacy.IsNull() {
+ data.Entries[i].MatchAsPathsLegacy = helpers.GetInt64List(value.Array())
+ } else {
+ data.Entries[i].MatchAsPathsLegacy = types.ListNull(types.Int64Type)
+ }
+ if value := r.Get("match.community.name"); value.Exists() && !data.Entries[i].MatchCommunityListsLegacy.IsNull() {
+ data.Entries[i].MatchCommunityListsLegacy = helpers.GetStringList(value.Array())
+ } else {
+ data.Entries[i].MatchCommunityListsLegacy = types.ListNull(types.StringType)
+ }
+ if value := r.Get("match.extcommunity.name"); value.Exists() && !data.Entries[i].MatchExtcommunityListsLegacy.IsNull() {
+ data.Entries[i].MatchExtcommunityListsLegacy = helpers.GetStringList(value.Array())
+ } else {
+ data.Entries[i].MatchExtcommunityListsLegacy = types.ListNull(types.StringType)
+ }
+ if value := r.Get("match.local-preference.values"); value.Exists() && !data.Entries[i].MatchLocalPreferencesLegacy.IsNull() {
+ data.Entries[i].MatchLocalPreferencesLegacy = helpers.GetInt64List(value.Array())
+ } else {
+ data.Entries[i].MatchLocalPreferencesLegacy = types.ListNull(types.Int64Type)
+ }
+ if value := r.Get("match.Cisco-IOS-XE-bgp:bgp-route-map-match.as-path.access-list"); value.Exists() && !data.Entries[i].MatchAsPaths.IsNull() {
+ data.Entries[i].MatchAsPaths = helpers.GetInt64List(value.Array())
+ } else {
+ data.Entries[i].MatchAsPaths = types.ListNull(types.Int64Type)
+ }
+ if value := r.Get("match.Cisco-IOS-XE-bgp:bgp-route-map-match.bgp-community.community-list"); value.Exists() && !data.Entries[i].MatchCommunityLists.IsNull() {
+ data.Entries[i].MatchCommunityLists = helpers.GetStringList(value.Array())
+ } else {
+ data.Entries[i].MatchCommunityLists = types.ListNull(types.StringType)
+ }
+ if value := r.Get("match.Cisco-IOS-XE-bgp:bgp-route-map-match.bgp-community.exact-match"); !data.Entries[i].MatchCommunityListExactMatch.IsNull() {
+ if value.Exists() {
+ data.Entries[i].MatchCommunityListExactMatch = types.BoolValue(true)
} else {
- item.MatchIpNextHopPrefixLists = types.ListNull(types.StringType)
- }
- if cValue := v.Get("match.ipv6.address.access-list"); cValue.Exists() {
- item.MatchIpv6AddressAccessLists = types.StringValue(cValue.String())
- }
- if cValue := v.Get("match.ipv6.address.prefix-list"); cValue.Exists() {
- item.MatchIpv6AddressPrefixLists = types.StringValue(cValue.String())
- }
- if cValue := v.Get("match.ipv6.next-hop.access-list"); cValue.Exists() {
- item.MatchIpv6NextHopAccessLists = types.StringValue(cValue.String())
+ data.Entries[i].MatchCommunityListExactMatch = types.BoolValue(false)
}
- if cValue := v.Get("match.ipv6.next-hop.prefix-list"); cValue.Exists() {
- item.MatchIpv6NextHopPrefixLists = types.StringValue(cValue.String())
+ } else {
+ data.Entries[i].MatchCommunityListExactMatch = types.BoolNull()
+ }
+ if value := r.Get("match.Cisco-IOS-XE-bgp:bgp-route-map-match.extcommunity.extcommunity-list"); value.Exists() && !data.Entries[i].MatchExtcommunityLists.IsNull() {
+ data.Entries[i].MatchExtcommunityLists = helpers.GetStringList(value.Array())
+ } else {
+ data.Entries[i].MatchExtcommunityLists = types.ListNull(types.StringType)
+ }
+ if value := r.Get("match.Cisco-IOS-XE-bgp:bgp-route-map-match.local-preference.values"); value.Exists() && !data.Entries[i].MatchLocalPreferences.IsNull() {
+ data.Entries[i].MatchLocalPreferences = helpers.GetInt64List(value.Array())
+ } else {
+ data.Entries[i].MatchLocalPreferences = types.ListNull(types.Int64Type)
+ }
+ if value := r.Get("set.default.interface-list"); value.Exists() && !data.Entries[i].SetDefaultInterfaces.IsNull() {
+ data.Entries[i].SetDefaultInterfaces = helpers.GetStringList(value.Array())
+ } else {
+ data.Entries[i].SetDefaultInterfaces = types.ListNull(types.StringType)
+ }
+ if value := r.Get("set.global"); !data.Entries[i].SetGlobal.IsNull() {
+ if value.Exists() {
+ data.Entries[i].SetGlobal = types.BoolValue(true)
+ } else {
+ data.Entries[i].SetGlobal = types.BoolValue(false)
}
- if cValue := v.Get("match.route-type.external"); cValue.Exists() {
- item.MatchRouteTypeExternal = types.BoolValue(true)
+ } else {
+ data.Entries[i].SetGlobal = types.BoolNull()
+ }
+ if value := r.Get("set.interface-list"); value.Exists() && !data.Entries[i].SetInterfaces.IsNull() {
+ data.Entries[i].SetInterfaces = helpers.GetStringList(value.Array())
+ } else {
+ data.Entries[i].SetInterfaces = types.ListNull(types.StringType)
+ }
+ if value := r.Get("set.ip.address.prefix-list"); value.Exists() && !data.Entries[i].SetIpAddress.IsNull() {
+ data.Entries[i].SetIpAddress = types.StringValue(value.String())
+ } else {
+ data.Entries[i].SetIpAddress = types.StringNull()
+ }
+ if value := r.Get("set.ip.default.global.next-hop.address"); value.Exists() && !data.Entries[i].SetIpDefaultGlobalNextHopAddress.IsNull() {
+ data.Entries[i].SetIpDefaultGlobalNextHopAddress = helpers.GetStringList(value.Array())
+ } else {
+ data.Entries[i].SetIpDefaultGlobalNextHopAddress = types.ListNull(types.StringType)
+ }
+ if value := r.Get("set.ip.default.next-hop.address"); value.Exists() && !data.Entries[i].SetIpDefaultNextHopAddress.IsNull() {
+ data.Entries[i].SetIpDefaultNextHopAddress = helpers.GetStringList(value.Array())
+ } else {
+ data.Entries[i].SetIpDefaultNextHopAddress = types.ListNull(types.StringType)
+ }
+ if value := r.Get("set.ip.global.next-hop.address"); value.Exists() && !data.Entries[i].SetIpGlobalNextHopAddress.IsNull() {
+ data.Entries[i].SetIpGlobalNextHopAddress = helpers.GetStringList(value.Array())
+ } else {
+ data.Entries[i].SetIpGlobalNextHopAddress = types.ListNull(types.StringType)
+ }
+ if value := r.Get("set.ip.next-hop.address"); value.Exists() && !data.Entries[i].SetIpNextHopAddress.IsNull() {
+ data.Entries[i].SetIpNextHopAddress = helpers.GetStringList(value.Array())
+ } else {
+ data.Entries[i].SetIpNextHopAddress = types.ListNull(types.StringType)
+ }
+ if value := r.Get("set.ip.next-hop.self"); !data.Entries[i].SetIpNextHopSelf.IsNull() {
+ if value.Exists() {
+ data.Entries[i].SetIpNextHopSelf = types.BoolValue(true)
} else {
- item.MatchRouteTypeExternal = types.BoolValue(false)
+ data.Entries[i].SetIpNextHopSelf = types.BoolValue(false)
}
- if cValue := v.Get("match.route-type.external.type-1"); cValue.Exists() {
- item.MatchRouteTypeExternalType1 = types.BoolValue(true)
+ } else {
+ data.Entries[i].SetIpNextHopSelf = types.BoolNull()
+ }
+ if value := r.Get("set.ip.qos-group.qos-id"); value.Exists() && !data.Entries[i].SetIpQosGroup.IsNull() {
+ data.Entries[i].SetIpQosGroup = types.Int64Value(value.Int())
+ } else {
+ data.Entries[i].SetIpQosGroup = types.Int64Null()
+ }
+ if value := r.Get("set.ipv6.address.prefix-list"); value.Exists() && !data.Entries[i].SetIpv6Address.IsNull() {
+ data.Entries[i].SetIpv6Address = helpers.GetStringList(value.Array())
+ } else {
+ data.Entries[i].SetIpv6Address = types.ListNull(types.StringType)
+ }
+ if value := r.Get("set.ipv6.default.global.next-hop"); value.Exists() && !data.Entries[i].SetIpv6DefaultGlobalNextHop.IsNull() {
+ data.Entries[i].SetIpv6DefaultGlobalNextHop = types.StringValue(value.String())
+ } else {
+ data.Entries[i].SetIpv6DefaultGlobalNextHop = types.StringNull()
+ }
+ if value := r.Get("set.ipv6.default.next-hop.ipv6"); value.Exists() && !data.Entries[i].SetIpv6DefaultNextHop.IsNull() {
+ data.Entries[i].SetIpv6DefaultNextHop = helpers.GetStringList(value.Array())
+ } else {
+ data.Entries[i].SetIpv6DefaultNextHop = types.ListNull(types.StringType)
+ }
+ if value := r.Get("set.ipv6.next-hop.ipv6"); value.Exists() && !data.Entries[i].SetIpv6NextHop.IsNull() {
+ data.Entries[i].SetIpv6NextHop = helpers.GetStringList(value.Array())
+ } else {
+ data.Entries[i].SetIpv6NextHop = types.ListNull(types.StringType)
+ }
+ if value := r.Get("set.level.level-1"); !data.Entries[i].SetLevel1.IsNull() {
+ if value.Exists() {
+ data.Entries[i].SetLevel1 = types.BoolValue(true)
} else {
- item.MatchRouteTypeExternalType1 = types.BoolValue(false)
+ data.Entries[i].SetLevel1 = types.BoolValue(false)
}
- if cValue := v.Get("match.route-type.external.type-2"); cValue.Exists() {
- item.MatchRouteTypeExternalType2 = types.BoolValue(true)
+ } else {
+ data.Entries[i].SetLevel1 = types.BoolNull()
+ }
+ if value := r.Get("set.level.level-1-2"); !data.Entries[i].SetLevel12.IsNull() {
+ if value.Exists() {
+ data.Entries[i].SetLevel12 = types.BoolValue(true)
} else {
- item.MatchRouteTypeExternalType2 = types.BoolValue(false)
+ data.Entries[i].SetLevel12 = types.BoolValue(false)
}
- if cValue := v.Get("match.route-type.internal"); cValue.Exists() {
- item.MatchRouteTypeInternal = types.BoolValue(true)
+ } else {
+ data.Entries[i].SetLevel12 = types.BoolNull()
+ }
+ if value := r.Get("set.level.level-2"); !data.Entries[i].SetLevel2.IsNull() {
+ if value.Exists() {
+ data.Entries[i].SetLevel2 = types.BoolValue(true)
} else {
- item.MatchRouteTypeInternal = types.BoolValue(false)
+ data.Entries[i].SetLevel2 = types.BoolValue(false)
}
- if cValue := v.Get("match.route-type.level-1"); cValue.Exists() {
- item.MatchRouteTypeLevel1 = types.BoolValue(true)
+ } else {
+ data.Entries[i].SetLevel2 = types.BoolNull()
+ }
+ if value := r.Get("set.metric.metric-change"); value.Exists() && !data.Entries[i].SetMetricChange.IsNull() {
+ data.Entries[i].SetMetricChange = types.StringValue(value.String())
+ } else {
+ data.Entries[i].SetMetricChange = types.StringNull()
+ }
+ if value := r.Get("set.metric.values.value"); value.Exists() && !data.Entries[i].SetMetricValue.IsNull() {
+ data.Entries[i].SetMetricValue = types.Int64Value(value.Int())
+ } else {
+ data.Entries[i].SetMetricValue = types.Int64Null()
+ }
+ if value := r.Get("set.metric.values.delay"); value.Exists() && !data.Entries[i].SetMetricDelay.IsNull() {
+ data.Entries[i].SetMetricDelay = types.StringValue(value.String())
+ } else {
+ data.Entries[i].SetMetricDelay = types.StringNull()
+ }
+ if value := r.Get("set.metric.values.reliability"); value.Exists() && !data.Entries[i].SetMetricReliability.IsNull() {
+ data.Entries[i].SetMetricReliability = types.Int64Value(value.Int())
+ } else {
+ data.Entries[i].SetMetricReliability = types.Int64Null()
+ }
+ if value := r.Get("set.metric.values.loading"); value.Exists() && !data.Entries[i].SetMetricLoading.IsNull() {
+ data.Entries[i].SetMetricLoading = types.Int64Value(value.Int())
+ } else {
+ data.Entries[i].SetMetricLoading = types.Int64Null()
+ }
+ if value := r.Get("set.metric.values.MTU"); value.Exists() && !data.Entries[i].SetMetricMtu.IsNull() {
+ data.Entries[i].SetMetricMtu = types.Int64Value(value.Int())
+ } else {
+ data.Entries[i].SetMetricMtu = types.Int64Null()
+ }
+ if value := r.Get("set.metric-type"); value.Exists() && !data.Entries[i].SetMetricType.IsNull() {
+ data.Entries[i].SetMetricType = types.StringValue(value.String())
+ } else {
+ data.Entries[i].SetMetricType = types.StringNull()
+ }
+ if value := r.Get("set.tag.tag-val"); value.Exists() && !data.Entries[i].SetTag.IsNull() {
+ data.Entries[i].SetTag = types.Int64Value(value.Int())
+ } else {
+ data.Entries[i].SetTag = types.Int64Null()
+ }
+ if value := r.Get("set.vrf"); value.Exists() && !data.Entries[i].SetVrf.IsNull() {
+ data.Entries[i].SetVrf = types.StringValue(value.String())
+ } else {
+ data.Entries[i].SetVrf = types.StringNull()
+ }
+ if value := r.Get("set.as-path.prepend.as-container.as-number"); value.Exists() && !data.Entries[i].SetAsPathPrependAsLegacy.IsNull() {
+ data.Entries[i].SetAsPathPrependAsLegacy = types.StringValue(value.String())
+ } else {
+ data.Entries[i].SetAsPathPrependAsLegacy = types.StringNull()
+ }
+ if value := r.Get("set.as-path.prepend.last-as-cont.last-as"); value.Exists() && !data.Entries[i].SetAsPathPrependLastAsLegacy.IsNull() {
+ data.Entries[i].SetAsPathPrependLastAsLegacy = types.Int64Value(value.Int())
+ } else {
+ data.Entries[i].SetAsPathPrependLastAsLegacy = types.Int64Null()
+ }
+ if value := r.Get("set.as-path.tag"); !data.Entries[i].SetAsPathTagLegacy.IsNull() {
+ if value.Exists() {
+ data.Entries[i].SetAsPathTagLegacy = types.BoolValue(true)
} else {
- item.MatchRouteTypeLevel1 = types.BoolValue(false)
+ data.Entries[i].SetAsPathTagLegacy = types.BoolValue(false)
}
- if cValue := v.Get("match.route-type.level-2"); cValue.Exists() {
- item.MatchRouteTypeLevel2 = types.BoolValue(true)
- } else {
- item.MatchRouteTypeLevel2 = types.BoolValue(false)
- }
- if cValue := v.Get("match.route-type.local"); cValue.Exists() {
- item.MatchRouteTypeLocalLegacy = types.BoolValue(true)
- } else {
- item.MatchRouteTypeLocalLegacy = types.BoolValue(false)
- }
- if cValue := v.Get("match.Cisco-IOS-XE-bgp:bgp-route-map-match.route-type.local"); cValue.Exists() {
- item.MatchRouteTypeLocal = types.BoolValue(true)
- } else {
- item.MatchRouteTypeLocal = types.BoolValue(false)
- }
- if cValue := v.Get("match.source-protocol.bgp"); cValue.Exists() {
- item.MatchSourceProtocolBgp = helpers.GetStringList(cValue.Array())
- } else {
- item.MatchSourceProtocolBgp = types.ListNull(types.StringType)
- }
- if cValue := v.Get("match.source-protocol.connected"); cValue.Exists() {
- item.MatchSourceProtocolConnected = types.BoolValue(true)
- } else {
- item.MatchSourceProtocolConnected = types.BoolValue(false)
- }
- if cValue := v.Get("match.source-protocol.eigrp"); cValue.Exists() {
- item.MatchSourceProtocolEigrp = helpers.GetStringList(cValue.Array())
- } else {
- item.MatchSourceProtocolEigrp = types.ListNull(types.StringType)
- }
- if cValue := v.Get("match.source-protocol.isis"); cValue.Exists() {
- item.MatchSourceProtocolIsis = types.BoolValue(true)
- } else {
- item.MatchSourceProtocolIsis = types.BoolValue(false)
- }
- if cValue := v.Get("match.source-protocol.lisp"); cValue.Exists() {
- item.MatchSourceProtocolLisp = types.BoolValue(true)
- } else {
- item.MatchSourceProtocolLisp = types.BoolValue(false)
- }
- if cValue := v.Get("match.source-protocol.ospf"); cValue.Exists() {
- item.MatchSourceProtocolOspf = helpers.GetStringList(cValue.Array())
+ } else {
+ data.Entries[i].SetAsPathTagLegacy = types.BoolNull()
+ }
+ if value := r.Get("set.community.none"); !data.Entries[i].SetCommunityNoneLegacy.IsNull() {
+ if value.Exists() {
+ data.Entries[i].SetCommunityNoneLegacy = types.BoolValue(true)
} else {
- item.MatchSourceProtocolOspf = types.ListNull(types.StringType)
+ data.Entries[i].SetCommunityNoneLegacy = types.BoolValue(false)
}
- if cValue := v.Get("match.source-protocol.ospfv3"); cValue.Exists() {
- item.MatchSourceProtocolOspfv3 = helpers.GetStringList(cValue.Array())
+ } else {
+ data.Entries[i].SetCommunityNoneLegacy = types.BoolNull()
+ }
+ if value := r.Get("set.community.community-well-known.community-list"); value.Exists() && !data.Entries[i].SetCommunitiesLegacy.IsNull() {
+ data.Entries[i].SetCommunitiesLegacy = helpers.GetStringList(value.Array())
+ } else {
+ data.Entries[i].SetCommunitiesLegacy = types.ListNull(types.StringType)
+ }
+ if value := r.Get("set.community.community-well-known.additive"); !data.Entries[i].SetCommunitiesAdditiveLegacy.IsNull() {
+ if value.Exists() {
+ data.Entries[i].SetCommunitiesAdditiveLegacy = types.BoolValue(true)
} else {
- item.MatchSourceProtocolOspfv3 = types.ListNull(types.StringType)
+ data.Entries[i].SetCommunitiesAdditiveLegacy = types.BoolValue(false)
}
- if cValue := v.Get("match.source-protocol.rip"); cValue.Exists() {
- item.MatchSourceProtocolRip = types.BoolValue(true)
+ } else {
+ data.Entries[i].SetCommunitiesAdditiveLegacy = types.BoolNull()
+ }
+ if value := r.Get("set.comm-list.delete"); !data.Entries[i].SetCommunityListDeleteLegacy.IsNull() {
+ if value.Exists() {
+ data.Entries[i].SetCommunityListDeleteLegacy = types.BoolValue(true)
} else {
- item.MatchSourceProtocolRip = types.BoolValue(false)
+ data.Entries[i].SetCommunityListDeleteLegacy = types.BoolValue(false)
}
- if cValue := v.Get("match.source-protocol.static"); cValue.Exists() {
- item.MatchSourceProtocolStatic = types.BoolValue(true)
+ } else {
+ data.Entries[i].SetCommunityListDeleteLegacy = types.BoolNull()
+ }
+ if value := r.Get("set.comm-list.comm-list-standard"); value.Exists() && !data.Entries[i].SetCommunityListStandardLegacy.IsNull() {
+ data.Entries[i].SetCommunityListStandardLegacy = types.Int64Value(value.Int())
+ } else {
+ data.Entries[i].SetCommunityListStandardLegacy = types.Int64Null()
+ }
+ if value := r.Get("set.Cisco-IOS-XE-bgp:bgp-route-map-set.comm-list.comm-list-expanded"); value.Exists() && !data.Entries[i].SetCommunityListExpandedLegacy.IsNull() {
+ data.Entries[i].SetCommunityListExpandedLegacy = types.Int64Value(value.Int())
+ } else {
+ data.Entries[i].SetCommunityListExpandedLegacy = types.Int64Null()
+ }
+ if value := r.Get("set.comm-list.comm-list-name"); value.Exists() && !data.Entries[i].SetCommunityListNameLegacy.IsNull() {
+ data.Entries[i].SetCommunityListNameLegacy = types.StringValue(value.String())
+ } else {
+ data.Entries[i].SetCommunityListNameLegacy = types.StringNull()
+ }
+ if value := r.Get("set.extcommunity.rt.asn-nn"); value.Exists() && !data.Entries[i].SetExtcomunityRtLegacy.IsNull() {
+ data.Entries[i].SetExtcomunityRtLegacy = helpers.GetStringList(value.Array())
+ } else {
+ data.Entries[i].SetExtcomunityRtLegacy = types.ListNull(types.StringType)
+ }
+ if value := r.Get("set.extcommunity.soo.asn-nn"); value.Exists() && !data.Entries[i].SetExtcomunitySooLegacy.IsNull() {
+ data.Entries[i].SetExtcomunitySooLegacy = types.StringValue(value.String())
+ } else {
+ data.Entries[i].SetExtcomunitySooLegacy = types.StringNull()
+ }
+ if value := r.Get("set.extcommunity.vpn-distinguisher.asn-nn"); value.Exists() && !data.Entries[i].SetExtcomunityVpnDistinguisherLegacy.IsNull() {
+ data.Entries[i].SetExtcomunityVpnDistinguisherLegacy = types.StringValue(value.String())
+ } else {
+ data.Entries[i].SetExtcomunityVpnDistinguisherLegacy = types.StringNull()
+ }
+ if value := r.Get("set.local-preference"); value.Exists() && !data.Entries[i].SetLocalPreferenceLegacy.IsNull() {
+ data.Entries[i].SetLocalPreferenceLegacy = types.Int64Value(value.Int())
+ } else {
+ data.Entries[i].SetLocalPreferenceLegacy = types.Int64Null()
+ }
+ if value := r.Get("set.weight"); value.Exists() && !data.Entries[i].SetWeightLegacy.IsNull() {
+ data.Entries[i].SetWeightLegacy = types.Int64Value(value.Int())
+ } else {
+ data.Entries[i].SetWeightLegacy = types.Int64Null()
+ }
+ if value := r.Get("set.Cisco-IOS-XE-bgp:bgp-route-map-set.as-path.prepend.as-container.as-number"); value.Exists() && !data.Entries[i].SetAsPathPrependAs.IsNull() {
+ data.Entries[i].SetAsPathPrependAs = types.StringValue(value.String())
+ } else {
+ data.Entries[i].SetAsPathPrependAs = types.StringNull()
+ }
+ if value := r.Get("set.Cisco-IOS-XE-bgp:bgp-route-map-set.as-path.prepend.last-as-cont.last-as"); value.Exists() && !data.Entries[i].SetAsPathPrependLastAs.IsNull() {
+ data.Entries[i].SetAsPathPrependLastAs = types.Int64Value(value.Int())
+ } else {
+ data.Entries[i].SetAsPathPrependLastAs = types.Int64Null()
+ }
+ if value := r.Get("set.Cisco-IOS-XE-bgp:bgp-route-map-set.as-path.tag"); !data.Entries[i].SetAsPathTag.IsNull() {
+ if value.Exists() {
+ data.Entries[i].SetAsPathTag = types.BoolValue(true)
} else {
- item.MatchSourceProtocolStatic = types.BoolValue(false)
+ data.Entries[i].SetAsPathTag = types.BoolValue(false)
}
- if cValue := v.Get("match.tag.tag_value"); cValue.Exists() {
- item.MatchTags = helpers.GetInt64List(cValue.Array())
+ } else {
+ data.Entries[i].SetAsPathTag = types.BoolNull()
+ }
+ if value := r.Get("set.Cisco-IOS-XE-bgp:bgp-route-map-set.as-path.replace.any"); !data.Entries[i].SetAsPathReplaceAny.IsNull() {
+ if value.Exists() {
+ data.Entries[i].SetAsPathReplaceAny = types.BoolValue(true)
} else {
- item.MatchTags = types.ListNull(types.Int64Type)
- }
- if cValue := v.Get("match.track"); cValue.Exists() {
- item.MatchTrack = types.Int64Value(cValue.Int())
+ data.Entries[i].SetAsPathReplaceAny = types.BoolValue(false)
}
- if cValue := v.Get("match.as-path.access-list"); cValue.Exists() {
- item.MatchAsPathsLegacy = helpers.GetInt64List(cValue.Array())
+ } else {
+ data.Entries[i].SetAsPathReplaceAny = types.BoolNull()
+ }
+ for ci := range data.Entries[i].SetAsPathReplaceAs {
+ keys := [...]string{"as-number"}
+ keyValues := [...]string{data.Entries[i].SetAsPathReplaceAs[ci].AsNumber.ValueString()}
+
+ var cr gjson.Result
+ r.Get("set.Cisco-IOS-XE-bgp:bgp-route-map-set.as-path.replace.as-container").ForEach(
+ func(_, v gjson.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ cr = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := cr.Get("as-number"); value.Exists() && !data.Entries[i].SetAsPathReplaceAs[ci].AsNumber.IsNull() {
+ data.Entries[i].SetAsPathReplaceAs[ci].AsNumber = types.StringValue(value.String())
} else {
- item.MatchAsPathsLegacy = types.ListNull(types.Int64Type)
+ data.Entries[i].SetAsPathReplaceAs[ci].AsNumber = types.StringNull()
}
- if cValue := v.Get("match.community.name"); cValue.Exists() {
- item.MatchCommunityListsLegacy = helpers.GetStringList(cValue.Array())
+ }
+ if value := r.Get("set.Cisco-IOS-XE-bgp:bgp-route-map-set.bgp-community.none"); !data.Entries[i].SetCommunityNone.IsNull() {
+ if value.Exists() {
+ data.Entries[i].SetCommunityNone = types.BoolValue(true)
} else {
- item.MatchCommunityListsLegacy = types.ListNull(types.StringType)
+ data.Entries[i].SetCommunityNone = types.BoolValue(false)
}
- if cValue := v.Get("match.extcommunity.name"); cValue.Exists() {
- item.MatchExtcommunityListsLegacy = helpers.GetStringList(cValue.Array())
+ } else {
+ data.Entries[i].SetCommunityNone = types.BoolNull()
+ }
+ if value := r.Get("set.Cisco-IOS-XE-bgp:bgp-route-map-set.bgp-community.community-well-known.community-list"); value.Exists() && !data.Entries[i].SetCommunities.IsNull() {
+ data.Entries[i].SetCommunities = helpers.GetStringList(value.Array())
+ } else {
+ data.Entries[i].SetCommunities = types.ListNull(types.StringType)
+ }
+ if value := r.Get("set.Cisco-IOS-XE-bgp:bgp-route-map-set.bgp-community.community-well-known.additive"); !data.Entries[i].SetCommunitiesAdditive.IsNull() {
+ if value.Exists() {
+ data.Entries[i].SetCommunitiesAdditive = types.BoolValue(true)
} else {
- item.MatchExtcommunityListsLegacy = types.ListNull(types.StringType)
+ data.Entries[i].SetCommunitiesAdditive = types.BoolValue(false)
}
- if cValue := v.Get("match.local-preference.values"); cValue.Exists() {
- item.MatchLocalPreferencesLegacy = helpers.GetInt64List(cValue.Array())
+ } else {
+ data.Entries[i].SetCommunitiesAdditive = types.BoolNull()
+ }
+ if value := r.Get("set.Cisco-IOS-XE-bgp:bgp-route-map-set.comm-list.delete"); !data.Entries[i].SetCommunityListDelete.IsNull() {
+ if value.Exists() {
+ data.Entries[i].SetCommunityListDelete = types.BoolValue(true)
} else {
- item.MatchLocalPreferencesLegacy = types.ListNull(types.Int64Type)
+ data.Entries[i].SetCommunityListDelete = types.BoolValue(false)
}
- if cValue := v.Get("match.Cisco-IOS-XE-bgp:bgp-route-map-match.as-path.access-list"); cValue.Exists() {
- item.MatchAsPaths = helpers.GetInt64List(cValue.Array())
+ } else {
+ data.Entries[i].SetCommunityListDelete = types.BoolNull()
+ }
+ if value := r.Get("set.Cisco-IOS-XE-bgp:bgp-route-map-set.comm-list.comm-list-standard"); value.Exists() && !data.Entries[i].SetCommunityListStandard.IsNull() {
+ data.Entries[i].SetCommunityListStandard = types.Int64Value(value.Int())
+ } else {
+ data.Entries[i].SetCommunityListStandard = types.Int64Null()
+ }
+ if value := r.Get("set.Cisco-IOS-XE-bgp:bgp-route-map-set.comm-list.comm-list-expanded"); value.Exists() && !data.Entries[i].SetCommunityListExpanded.IsNull() {
+ data.Entries[i].SetCommunityListExpanded = types.Int64Value(value.Int())
+ } else {
+ data.Entries[i].SetCommunityListExpanded = types.Int64Null()
+ }
+ if value := r.Get("set.Cisco-IOS-XE-bgp:bgp-route-map-set.comm-list.comm-list-name"); value.Exists() && !data.Entries[i].SetCommunityListName.IsNull() {
+ data.Entries[i].SetCommunityListName = types.StringValue(value.String())
+ } else {
+ data.Entries[i].SetCommunityListName = types.StringNull()
+ }
+ if value := r.Get("set.Cisco-IOS-XE-bgp:bgp-route-map-set.extcommunity.rt.asn-nn"); value.Exists() && !data.Entries[i].SetExtcomunityRt.IsNull() {
+ data.Entries[i].SetExtcomunityRt = helpers.GetStringList(value.Array())
+ } else {
+ data.Entries[i].SetExtcomunityRt = types.ListNull(types.StringType)
+ }
+ if value := r.Get("set.Cisco-IOS-XE-bgp:bgp-route-map-set.extcommunity.soo.asn-nn"); value.Exists() && !data.Entries[i].SetExtcomunitySoo.IsNull() {
+ data.Entries[i].SetExtcomunitySoo = types.StringValue(value.String())
+ } else {
+ data.Entries[i].SetExtcomunitySoo = types.StringNull()
+ }
+ if value := r.Get("set.Cisco-IOS-XE-bgp:bgp-route-map-set.extcommunity.vpn-distinguisher.asn-nn"); value.Exists() && !data.Entries[i].SetExtcomunityVpnDistinguisher.IsNull() {
+ data.Entries[i].SetExtcomunityVpnDistinguisher = types.StringValue(value.String())
+ } else {
+ data.Entries[i].SetExtcomunityVpnDistinguisher = types.StringNull()
+ }
+ if value := r.Get("set.Cisco-IOS-XE-bgp:bgp-route-map-set.extcommunity.vpn-distinguisher.asn-nn-additive"); !data.Entries[i].SetExtcomunityVpnDistinguisherAdditive.IsNull() {
+ if value.Exists() {
+ data.Entries[i].SetExtcomunityVpnDistinguisherAdditive = types.BoolValue(true)
} else {
- item.MatchAsPaths = types.ListNull(types.Int64Type)
+ data.Entries[i].SetExtcomunityVpnDistinguisherAdditive = types.BoolValue(false)
}
- if cValue := v.Get("match.Cisco-IOS-XE-bgp:bgp-route-map-match.bgp-community.community-list"); cValue.Exists() {
- item.MatchCommunityLists = helpers.GetStringList(cValue.Array())
- } else {
- item.MatchCommunityLists = types.ListNull(types.StringType)
- }
- if cValue := v.Get("match.Cisco-IOS-XE-bgp:bgp-route-map-match.bgp-community.exact-match"); cValue.Exists() {
- item.MatchCommunityListExactMatch = types.BoolValue(true)
- } else {
- item.MatchCommunityListExactMatch = types.BoolValue(false)
- }
- if cValue := v.Get("match.Cisco-IOS-XE-bgp:bgp-route-map-match.extcommunity.extcommunity-list"); cValue.Exists() {
- item.MatchExtcommunityLists = helpers.GetStringList(cValue.Array())
- } else {
- item.MatchExtcommunityLists = types.ListNull(types.StringType)
- }
- if cValue := v.Get("match.Cisco-IOS-XE-bgp:bgp-route-map-match.local-preference.values"); cValue.Exists() {
- item.MatchLocalPreferences = helpers.GetInt64List(cValue.Array())
- } else {
- item.MatchLocalPreferences = types.ListNull(types.Int64Type)
- }
- if cValue := v.Get("set.default.interface-list"); cValue.Exists() {
- item.SetDefaultInterfaces = helpers.GetStringList(cValue.Array())
+ } else {
+ data.Entries[i].SetExtcomunityVpnDistinguisherAdditive = types.BoolNull()
+ }
+ if value := r.Get("set.Cisco-IOS-XE-bgp:bgp-route-map-set.local-preference"); value.Exists() && !data.Entries[i].SetLocalPreference.IsNull() {
+ data.Entries[i].SetLocalPreference = types.Int64Value(value.Int())
+ } else {
+ data.Entries[i].SetLocalPreference = types.Int64Null()
+ }
+ if value := r.Get("set.Cisco-IOS-XE-bgp:bgp-route-map-set.weight"); value.Exists() && !data.Entries[i].SetWeight.IsNull() {
+ data.Entries[i].SetWeight = types.Int64Value(value.Int())
+ } else {
+ data.Entries[i].SetWeight = types.Int64Null()
+ }
+ }
+}
+
+// End of section. //template:end updateFromBody
+
+// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBodyXML
+
+func (data *RouteMap) updateFromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/name"); value.Exists() && !data.Name.IsNull() {
+ data.Name = types.StringValue(value.String())
+ } else {
+ data.Name = types.StringNull()
+ }
+ for i := range data.Entries {
+ keys := [...]string{"seq_no"}
+ keyValues := [...]string{strconv.FormatInt(data.Entries[i].Seq.ValueInt64(), 10)}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-route-map:route-map-without-order-seq").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, "seq_no"); value.Exists() && !data.Entries[i].Seq.IsNull() {
+ data.Entries[i].Seq = types.Int64Value(value.Int())
+ } else {
+ data.Entries[i].Seq = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(r, "operation"); value.Exists() && !data.Entries[i].Operation.IsNull() {
+ data.Entries[i].Operation = types.StringValue(value.String())
+ } else {
+ data.Entries[i].Operation = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "description"); value.Exists() && !data.Entries[i].Description.IsNull() {
+ data.Entries[i].Description = types.StringValue(value.String())
+ } else {
+ data.Entries[i].Description = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "continue"); !data.Entries[i].Continue.IsNull() {
+ if value.Exists() {
+ data.Entries[i].Continue = types.BoolValue(true)
} else {
- item.SetDefaultInterfaces = types.ListNull(types.StringType)
+ data.Entries[i].Continue = types.BoolValue(false)
}
- if cValue := v.Get("set.global"); cValue.Exists() {
- item.SetGlobal = types.BoolValue(true)
+ } else {
+ data.Entries[i].Continue = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "continue/sequence-number"); value.Exists() && !data.Entries[i].ContinueSequenceNumber.IsNull() {
+ data.Entries[i].ContinueSequenceNumber = types.Int64Value(value.Int())
+ } else {
+ data.Entries[i].ContinueSequenceNumber = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(r, "match/interface/interface"); value.Exists() && !data.Entries[i].MatchInterfaces.IsNull() {
+ data.Entries[i].MatchInterfaces = helpers.GetStringListXML(value.Array())
+ } else {
+ data.Entries[i].MatchInterfaces = types.ListNull(types.StringType)
+ }
+ if value := helpers.GetFromXPath(r, "match/ip/address/access-list"); value.Exists() && !data.Entries[i].MatchIpAddressAccessLists.IsNull() {
+ data.Entries[i].MatchIpAddressAccessLists = helpers.GetStringListXML(value.Array())
+ } else {
+ data.Entries[i].MatchIpAddressAccessLists = types.ListNull(types.StringType)
+ }
+ if value := helpers.GetFromXPath(r, "match/ip/address/prefix-list"); value.Exists() && !data.Entries[i].MatchIpAddressPrefixLists.IsNull() {
+ data.Entries[i].MatchIpAddressPrefixLists = helpers.GetStringListXML(value.Array())
+ } else {
+ data.Entries[i].MatchIpAddressPrefixLists = types.ListNull(types.StringType)
+ }
+ if value := helpers.GetFromXPath(r, "match/ip/next-hop/access-list"); value.Exists() && !data.Entries[i].MatchIpNextHopAccessLists.IsNull() {
+ data.Entries[i].MatchIpNextHopAccessLists = helpers.GetStringListXML(value.Array())
+ } else {
+ data.Entries[i].MatchIpNextHopAccessLists = types.ListNull(types.StringType)
+ }
+ if value := helpers.GetFromXPath(r, "match/ip/next-hop/prefix-list"); value.Exists() && !data.Entries[i].MatchIpNextHopPrefixLists.IsNull() {
+ data.Entries[i].MatchIpNextHopPrefixLists = helpers.GetStringListXML(value.Array())
+ } else {
+ data.Entries[i].MatchIpNextHopPrefixLists = types.ListNull(types.StringType)
+ }
+ if value := helpers.GetFromXPath(r, "match/ipv6/address/access-list"); value.Exists() && !data.Entries[i].MatchIpv6AddressAccessLists.IsNull() {
+ data.Entries[i].MatchIpv6AddressAccessLists = types.StringValue(value.String())
+ } else {
+ data.Entries[i].MatchIpv6AddressAccessLists = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "match/ipv6/address/prefix-list"); value.Exists() && !data.Entries[i].MatchIpv6AddressPrefixLists.IsNull() {
+ data.Entries[i].MatchIpv6AddressPrefixLists = types.StringValue(value.String())
+ } else {
+ data.Entries[i].MatchIpv6AddressPrefixLists = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "match/ipv6/next-hop/access-list"); value.Exists() && !data.Entries[i].MatchIpv6NextHopAccessLists.IsNull() {
+ data.Entries[i].MatchIpv6NextHopAccessLists = types.StringValue(value.String())
+ } else {
+ data.Entries[i].MatchIpv6NextHopAccessLists = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "match/ipv6/next-hop/prefix-list"); value.Exists() && !data.Entries[i].MatchIpv6NextHopPrefixLists.IsNull() {
+ data.Entries[i].MatchIpv6NextHopPrefixLists = types.StringValue(value.String())
+ } else {
+ data.Entries[i].MatchIpv6NextHopPrefixLists = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "match/route-type/external"); !data.Entries[i].MatchRouteTypeExternal.IsNull() {
+ if value.Exists() {
+ data.Entries[i].MatchRouteTypeExternal = types.BoolValue(true)
} else {
- item.SetGlobal = types.BoolValue(false)
+ data.Entries[i].MatchRouteTypeExternal = types.BoolValue(false)
}
- if cValue := v.Get("set.interface-list"); cValue.Exists() {
- item.SetInterfaces = helpers.GetStringList(cValue.Array())
+ } else {
+ data.Entries[i].MatchRouteTypeExternal = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "match/route-type/external/type-1"); !data.Entries[i].MatchRouteTypeExternalType1.IsNull() {
+ if value.Exists() {
+ data.Entries[i].MatchRouteTypeExternalType1 = types.BoolValue(true)
} else {
- item.SetInterfaces = types.ListNull(types.StringType)
- }
- if cValue := v.Get("set.ip.address.prefix-list"); cValue.Exists() {
- item.SetIpAddress = types.StringValue(cValue.String())
+ data.Entries[i].MatchRouteTypeExternalType1 = types.BoolValue(false)
}
- if cValue := v.Get("set.ip.default.global.next-hop.address"); cValue.Exists() {
- item.SetIpDefaultGlobalNextHopAddress = helpers.GetStringList(cValue.Array())
+ } else {
+ data.Entries[i].MatchRouteTypeExternalType1 = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "match/route-type/external/type-2"); !data.Entries[i].MatchRouteTypeExternalType2.IsNull() {
+ if value.Exists() {
+ data.Entries[i].MatchRouteTypeExternalType2 = types.BoolValue(true)
} else {
- item.SetIpDefaultGlobalNextHopAddress = types.ListNull(types.StringType)
+ data.Entries[i].MatchRouteTypeExternalType2 = types.BoolValue(false)
}
- if cValue := v.Get("set.ip.default.next-hop.address"); cValue.Exists() {
- item.SetIpDefaultNextHopAddress = helpers.GetStringList(cValue.Array())
+ } else {
+ data.Entries[i].MatchRouteTypeExternalType2 = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "match/route-type/internal"); !data.Entries[i].MatchRouteTypeInternal.IsNull() {
+ if value.Exists() {
+ data.Entries[i].MatchRouteTypeInternal = types.BoolValue(true)
} else {
- item.SetIpDefaultNextHopAddress = types.ListNull(types.StringType)
+ data.Entries[i].MatchRouteTypeInternal = types.BoolValue(false)
}
- if cValue := v.Get("set.ip.global.next-hop.address"); cValue.Exists() {
- item.SetIpGlobalNextHopAddress = helpers.GetStringList(cValue.Array())
+ } else {
+ data.Entries[i].MatchRouteTypeInternal = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "match/route-type/level-1"); !data.Entries[i].MatchRouteTypeLevel1.IsNull() {
+ if value.Exists() {
+ data.Entries[i].MatchRouteTypeLevel1 = types.BoolValue(true)
} else {
- item.SetIpGlobalNextHopAddress = types.ListNull(types.StringType)
+ data.Entries[i].MatchRouteTypeLevel1 = types.BoolValue(false)
}
- if cValue := v.Get("set.ip.next-hop.address"); cValue.Exists() {
- item.SetIpNextHopAddress = helpers.GetStringList(cValue.Array())
+ } else {
+ data.Entries[i].MatchRouteTypeLevel1 = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "match/route-type/level-2"); !data.Entries[i].MatchRouteTypeLevel2.IsNull() {
+ if value.Exists() {
+ data.Entries[i].MatchRouteTypeLevel2 = types.BoolValue(true)
} else {
- item.SetIpNextHopAddress = types.ListNull(types.StringType)
+ data.Entries[i].MatchRouteTypeLevel2 = types.BoolValue(false)
}
- if cValue := v.Get("set.ip.next-hop.self"); cValue.Exists() {
- item.SetIpNextHopSelf = types.BoolValue(true)
+ } else {
+ data.Entries[i].MatchRouteTypeLevel2 = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "match/route-type/local"); !data.Entries[i].MatchRouteTypeLocalLegacy.IsNull() {
+ if value.Exists() {
+ data.Entries[i].MatchRouteTypeLocalLegacy = types.BoolValue(true)
} else {
- item.SetIpNextHopSelf = types.BoolValue(false)
- }
- if cValue := v.Get("set.ip.qos-group.qos-id"); cValue.Exists() {
- item.SetIpQosGroup = types.Int64Value(cValue.Int())
+ data.Entries[i].MatchRouteTypeLocalLegacy = types.BoolValue(false)
}
- if cValue := v.Get("set.ipv6.address.prefix-list"); cValue.Exists() {
- item.SetIpv6Address = helpers.GetStringList(cValue.Array())
+ } else {
+ data.Entries[i].MatchRouteTypeLocalLegacy = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "match/Cisco-IOS-XE-bgp:bgp-route-map-match/route-type/local"); !data.Entries[i].MatchRouteTypeLocal.IsNull() {
+ if value.Exists() {
+ data.Entries[i].MatchRouteTypeLocal = types.BoolValue(true)
} else {
- item.SetIpv6Address = types.ListNull(types.StringType)
- }
- if cValue := v.Get("set.ipv6.default.global.next-hop"); cValue.Exists() {
- item.SetIpv6DefaultGlobalNextHop = types.StringValue(cValue.String())
+ data.Entries[i].MatchRouteTypeLocal = types.BoolValue(false)
}
- if cValue := v.Get("set.ipv6.default.next-hop.ipv6"); cValue.Exists() {
- item.SetIpv6DefaultNextHop = helpers.GetStringList(cValue.Array())
+ } else {
+ data.Entries[i].MatchRouteTypeLocal = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "match/source-protocol/bgp"); value.Exists() && !data.Entries[i].MatchSourceProtocolBgp.IsNull() {
+ data.Entries[i].MatchSourceProtocolBgp = helpers.GetStringListXML(value.Array())
+ } else {
+ data.Entries[i].MatchSourceProtocolBgp = types.ListNull(types.StringType)
+ }
+ if value := helpers.GetFromXPath(r, "match/source-protocol/connected"); !data.Entries[i].MatchSourceProtocolConnected.IsNull() {
+ if value.Exists() {
+ data.Entries[i].MatchSourceProtocolConnected = types.BoolValue(true)
} else {
- item.SetIpv6DefaultNextHop = types.ListNull(types.StringType)
+ data.Entries[i].MatchSourceProtocolConnected = types.BoolValue(false)
}
- if cValue := v.Get("set.ipv6.next-hop.ipv6"); cValue.Exists() {
- item.SetIpv6NextHop = helpers.GetStringList(cValue.Array())
+ } else {
+ data.Entries[i].MatchSourceProtocolConnected = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "match/source-protocol/eigrp"); value.Exists() && !data.Entries[i].MatchSourceProtocolEigrp.IsNull() {
+ data.Entries[i].MatchSourceProtocolEigrp = helpers.GetStringListXML(value.Array())
+ } else {
+ data.Entries[i].MatchSourceProtocolEigrp = types.ListNull(types.StringType)
+ }
+ if value := helpers.GetFromXPath(r, "match/source-protocol/isis"); !data.Entries[i].MatchSourceProtocolIsis.IsNull() {
+ if value.Exists() {
+ data.Entries[i].MatchSourceProtocolIsis = types.BoolValue(true)
} else {
- item.SetIpv6NextHop = types.ListNull(types.StringType)
+ data.Entries[i].MatchSourceProtocolIsis = types.BoolValue(false)
}
- if cValue := v.Get("set.level.level-1"); cValue.Exists() {
- item.SetLevel1 = types.BoolValue(true)
+ } else {
+ data.Entries[i].MatchSourceProtocolIsis = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "match/source-protocol/lisp"); !data.Entries[i].MatchSourceProtocolLisp.IsNull() {
+ if value.Exists() {
+ data.Entries[i].MatchSourceProtocolLisp = types.BoolValue(true)
} else {
- item.SetLevel1 = types.BoolValue(false)
+ data.Entries[i].MatchSourceProtocolLisp = types.BoolValue(false)
}
- if cValue := v.Get("set.level.level-1-2"); cValue.Exists() {
- item.SetLevel12 = types.BoolValue(true)
+ } else {
+ data.Entries[i].MatchSourceProtocolLisp = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "match/source-protocol/ospf"); value.Exists() && !data.Entries[i].MatchSourceProtocolOspf.IsNull() {
+ data.Entries[i].MatchSourceProtocolOspf = helpers.GetStringListXML(value.Array())
+ } else {
+ data.Entries[i].MatchSourceProtocolOspf = types.ListNull(types.StringType)
+ }
+ if value := helpers.GetFromXPath(r, "match/source-protocol/ospfv3"); value.Exists() && !data.Entries[i].MatchSourceProtocolOspfv3.IsNull() {
+ data.Entries[i].MatchSourceProtocolOspfv3 = helpers.GetStringListXML(value.Array())
+ } else {
+ data.Entries[i].MatchSourceProtocolOspfv3 = types.ListNull(types.StringType)
+ }
+ if value := helpers.GetFromXPath(r, "match/source-protocol/rip"); !data.Entries[i].MatchSourceProtocolRip.IsNull() {
+ if value.Exists() {
+ data.Entries[i].MatchSourceProtocolRip = types.BoolValue(true)
} else {
- item.SetLevel12 = types.BoolValue(false)
+ data.Entries[i].MatchSourceProtocolRip = types.BoolValue(false)
}
- if cValue := v.Get("set.level.level-2"); cValue.Exists() {
- item.SetLevel2 = types.BoolValue(true)
+ } else {
+ data.Entries[i].MatchSourceProtocolRip = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "match/source-protocol/static"); !data.Entries[i].MatchSourceProtocolStatic.IsNull() {
+ if value.Exists() {
+ data.Entries[i].MatchSourceProtocolStatic = types.BoolValue(true)
} else {
- item.SetLevel2 = types.BoolValue(false)
- }
- if cValue := v.Get("set.metric.metric-change"); cValue.Exists() {
- item.SetMetricChange = types.StringValue(cValue.String())
+ data.Entries[i].MatchSourceProtocolStatic = types.BoolValue(false)
}
- if cValue := v.Get("set.metric.values.value"); cValue.Exists() {
- item.SetMetricValue = types.Int64Value(cValue.Int())
- }
- if cValue := v.Get("set.metric.values.delay"); cValue.Exists() {
- item.SetMetricDelay = types.StringValue(cValue.String())
- }
- if cValue := v.Get("set.metric.values.reliability"); cValue.Exists() {
- item.SetMetricReliability = types.Int64Value(cValue.Int())
- }
- if cValue := v.Get("set.metric.values.loading"); cValue.Exists() {
- item.SetMetricLoading = types.Int64Value(cValue.Int())
- }
- if cValue := v.Get("set.metric.values.MTU"); cValue.Exists() {
- item.SetMetricMtu = types.Int64Value(cValue.Int())
- }
- if cValue := v.Get("set.metric-type"); cValue.Exists() {
- item.SetMetricType = types.StringValue(cValue.String())
- }
- if cValue := v.Get("set.tag.tag-val"); cValue.Exists() {
- item.SetTag = types.Int64Value(cValue.Int())
- }
- if cValue := v.Get("set.vrf"); cValue.Exists() {
- item.SetVrf = types.StringValue(cValue.String())
- }
- if cValue := v.Get("set.as-path.prepend.as-container.as-number"); cValue.Exists() {
- item.SetAsPathPrependAsLegacy = types.StringValue(cValue.String())
- }
- if cValue := v.Get("set.as-path.prepend.last-as-cont.last-as"); cValue.Exists() {
- item.SetAsPathPrependLastAsLegacy = types.Int64Value(cValue.Int())
- }
- if cValue := v.Get("set.as-path.tag"); cValue.Exists() {
- item.SetAsPathTagLegacy = types.BoolValue(true)
+ } else {
+ data.Entries[i].MatchSourceProtocolStatic = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "match/tag/tag_value"); value.Exists() && !data.Entries[i].MatchTags.IsNull() {
+ data.Entries[i].MatchTags = helpers.GetInt64ListXML(value.Array())
+ } else {
+ data.Entries[i].MatchTags = types.ListNull(types.Int64Type)
+ }
+ if value := helpers.GetFromXPath(r, "match/track"); value.Exists() && !data.Entries[i].MatchTrack.IsNull() {
+ data.Entries[i].MatchTrack = types.Int64Value(value.Int())
+ } else {
+ data.Entries[i].MatchTrack = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(r, "match/as-path/access-list"); value.Exists() && !data.Entries[i].MatchAsPathsLegacy.IsNull() {
+ data.Entries[i].MatchAsPathsLegacy = helpers.GetInt64ListXML(value.Array())
+ } else {
+ data.Entries[i].MatchAsPathsLegacy = types.ListNull(types.Int64Type)
+ }
+ if value := helpers.GetFromXPath(r, "match/community/name"); value.Exists() && !data.Entries[i].MatchCommunityListsLegacy.IsNull() {
+ data.Entries[i].MatchCommunityListsLegacy = helpers.GetStringListXML(value.Array())
+ } else {
+ data.Entries[i].MatchCommunityListsLegacy = types.ListNull(types.StringType)
+ }
+ if value := helpers.GetFromXPath(r, "match/extcommunity/name"); value.Exists() && !data.Entries[i].MatchExtcommunityListsLegacy.IsNull() {
+ data.Entries[i].MatchExtcommunityListsLegacy = helpers.GetStringListXML(value.Array())
+ } else {
+ data.Entries[i].MatchExtcommunityListsLegacy = types.ListNull(types.StringType)
+ }
+ if value := helpers.GetFromXPath(r, "match/local-preference/values"); value.Exists() && !data.Entries[i].MatchLocalPreferencesLegacy.IsNull() {
+ data.Entries[i].MatchLocalPreferencesLegacy = helpers.GetInt64ListXML(value.Array())
+ } else {
+ data.Entries[i].MatchLocalPreferencesLegacy = types.ListNull(types.Int64Type)
+ }
+ if value := helpers.GetFromXPath(r, "match/Cisco-IOS-XE-bgp:bgp-route-map-match/as-path/access-list"); value.Exists() && !data.Entries[i].MatchAsPaths.IsNull() {
+ data.Entries[i].MatchAsPaths = helpers.GetInt64ListXML(value.Array())
+ } else {
+ data.Entries[i].MatchAsPaths = types.ListNull(types.Int64Type)
+ }
+ if value := helpers.GetFromXPath(r, "match/Cisco-IOS-XE-bgp:bgp-route-map-match/bgp-community/community-list"); value.Exists() && !data.Entries[i].MatchCommunityLists.IsNull() {
+ data.Entries[i].MatchCommunityLists = helpers.GetStringListXML(value.Array())
+ } else {
+ data.Entries[i].MatchCommunityLists = types.ListNull(types.StringType)
+ }
+ if value := helpers.GetFromXPath(r, "match/Cisco-IOS-XE-bgp:bgp-route-map-match/bgp-community/exact-match"); !data.Entries[i].MatchCommunityListExactMatch.IsNull() {
+ if value.Exists() {
+ data.Entries[i].MatchCommunityListExactMatch = types.BoolValue(true)
} else {
- item.SetAsPathTagLegacy = types.BoolValue(false)
+ data.Entries[i].MatchCommunityListExactMatch = types.BoolValue(false)
}
- if cValue := v.Get("set.community.none"); cValue.Exists() {
- item.SetCommunityNoneLegacy = types.BoolValue(true)
+ } else {
+ data.Entries[i].MatchCommunityListExactMatch = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "match/Cisco-IOS-XE-bgp:bgp-route-map-match/extcommunity/extcommunity-list"); value.Exists() && !data.Entries[i].MatchExtcommunityLists.IsNull() {
+ data.Entries[i].MatchExtcommunityLists = helpers.GetStringListXML(value.Array())
+ } else {
+ data.Entries[i].MatchExtcommunityLists = types.ListNull(types.StringType)
+ }
+ if value := helpers.GetFromXPath(r, "match/Cisco-IOS-XE-bgp:bgp-route-map-match/local-preference/values"); value.Exists() && !data.Entries[i].MatchLocalPreferences.IsNull() {
+ data.Entries[i].MatchLocalPreferences = helpers.GetInt64ListXML(value.Array())
+ } else {
+ data.Entries[i].MatchLocalPreferences = types.ListNull(types.Int64Type)
+ }
+ if value := helpers.GetFromXPath(r, "set/default/interface-list"); value.Exists() && !data.Entries[i].SetDefaultInterfaces.IsNull() {
+ data.Entries[i].SetDefaultInterfaces = helpers.GetStringListXML(value.Array())
+ } else {
+ data.Entries[i].SetDefaultInterfaces = types.ListNull(types.StringType)
+ }
+ if value := helpers.GetFromXPath(r, "set/global"); !data.Entries[i].SetGlobal.IsNull() {
+ if value.Exists() {
+ data.Entries[i].SetGlobal = types.BoolValue(true)
} else {
- item.SetCommunityNoneLegacy = types.BoolValue(false)
+ data.Entries[i].SetGlobal = types.BoolValue(false)
}
- if cValue := v.Get("set.community.community-well-known.community-list"); cValue.Exists() {
- item.SetCommunitiesLegacy = helpers.GetStringList(cValue.Array())
+ } else {
+ data.Entries[i].SetGlobal = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "set/interface-list"); value.Exists() && !data.Entries[i].SetInterfaces.IsNull() {
+ data.Entries[i].SetInterfaces = helpers.GetStringListXML(value.Array())
+ } else {
+ data.Entries[i].SetInterfaces = types.ListNull(types.StringType)
+ }
+ if value := helpers.GetFromXPath(r, "set/ip/address/prefix-list"); value.Exists() && !data.Entries[i].SetIpAddress.IsNull() {
+ data.Entries[i].SetIpAddress = types.StringValue(value.String())
+ } else {
+ data.Entries[i].SetIpAddress = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "set/ip/default/global/next-hop/address"); value.Exists() && !data.Entries[i].SetIpDefaultGlobalNextHopAddress.IsNull() {
+ data.Entries[i].SetIpDefaultGlobalNextHopAddress = helpers.GetStringListXML(value.Array())
+ } else {
+ data.Entries[i].SetIpDefaultGlobalNextHopAddress = types.ListNull(types.StringType)
+ }
+ if value := helpers.GetFromXPath(r, "set/ip/default/next-hop/address"); value.Exists() && !data.Entries[i].SetIpDefaultNextHopAddress.IsNull() {
+ data.Entries[i].SetIpDefaultNextHopAddress = helpers.GetStringListXML(value.Array())
+ } else {
+ data.Entries[i].SetIpDefaultNextHopAddress = types.ListNull(types.StringType)
+ }
+ if value := helpers.GetFromXPath(r, "set/ip/global/next-hop/address"); value.Exists() && !data.Entries[i].SetIpGlobalNextHopAddress.IsNull() {
+ data.Entries[i].SetIpGlobalNextHopAddress = helpers.GetStringListXML(value.Array())
+ } else {
+ data.Entries[i].SetIpGlobalNextHopAddress = types.ListNull(types.StringType)
+ }
+ if value := helpers.GetFromXPath(r, "set/ip/next-hop/address"); value.Exists() && !data.Entries[i].SetIpNextHopAddress.IsNull() {
+ data.Entries[i].SetIpNextHopAddress = helpers.GetStringListXML(value.Array())
+ } else {
+ data.Entries[i].SetIpNextHopAddress = types.ListNull(types.StringType)
+ }
+ if value := helpers.GetFromXPath(r, "set/ip/next-hop/self"); !data.Entries[i].SetIpNextHopSelf.IsNull() {
+ if value.Exists() {
+ data.Entries[i].SetIpNextHopSelf = types.BoolValue(true)
} else {
- item.SetCommunitiesLegacy = types.ListNull(types.StringType)
+ data.Entries[i].SetIpNextHopSelf = types.BoolValue(false)
}
- if cValue := v.Get("set.community.community-well-known.additive"); cValue.Exists() {
- item.SetCommunitiesAdditiveLegacy = types.BoolValue(true)
+ } else {
+ data.Entries[i].SetIpNextHopSelf = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "set/ip/qos-group/qos-id"); value.Exists() && !data.Entries[i].SetIpQosGroup.IsNull() {
+ data.Entries[i].SetIpQosGroup = types.Int64Value(value.Int())
+ } else {
+ data.Entries[i].SetIpQosGroup = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(r, "set/ipv6/address/prefix-list"); value.Exists() && !data.Entries[i].SetIpv6Address.IsNull() {
+ data.Entries[i].SetIpv6Address = helpers.GetStringListXML(value.Array())
+ } else {
+ data.Entries[i].SetIpv6Address = types.ListNull(types.StringType)
+ }
+ if value := helpers.GetFromXPath(r, "set/ipv6/default/global/next-hop"); value.Exists() && !data.Entries[i].SetIpv6DefaultGlobalNextHop.IsNull() {
+ data.Entries[i].SetIpv6DefaultGlobalNextHop = types.StringValue(value.String())
+ } else {
+ data.Entries[i].SetIpv6DefaultGlobalNextHop = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "set/ipv6/default/next-hop/ipv6"); value.Exists() && !data.Entries[i].SetIpv6DefaultNextHop.IsNull() {
+ data.Entries[i].SetIpv6DefaultNextHop = helpers.GetStringListXML(value.Array())
+ } else {
+ data.Entries[i].SetIpv6DefaultNextHop = types.ListNull(types.StringType)
+ }
+ if value := helpers.GetFromXPath(r, "set/ipv6/next-hop/ipv6"); value.Exists() && !data.Entries[i].SetIpv6NextHop.IsNull() {
+ data.Entries[i].SetIpv6NextHop = helpers.GetStringListXML(value.Array())
+ } else {
+ data.Entries[i].SetIpv6NextHop = types.ListNull(types.StringType)
+ }
+ if value := helpers.GetFromXPath(r, "set/level/level-1"); !data.Entries[i].SetLevel1.IsNull() {
+ if value.Exists() {
+ data.Entries[i].SetLevel1 = types.BoolValue(true)
} else {
- item.SetCommunitiesAdditiveLegacy = types.BoolValue(false)
+ data.Entries[i].SetLevel1 = types.BoolValue(false)
}
- if cValue := v.Get("set.comm-list.delete"); cValue.Exists() {
- item.SetCommunityListDeleteLegacy = types.BoolValue(true)
+ } else {
+ data.Entries[i].SetLevel1 = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "set/level/level-1-2"); !data.Entries[i].SetLevel12.IsNull() {
+ if value.Exists() {
+ data.Entries[i].SetLevel12 = types.BoolValue(true)
} else {
- item.SetCommunityListDeleteLegacy = types.BoolValue(false)
- }
- if cValue := v.Get("set.comm-list.comm-list-standard"); cValue.Exists() {
- item.SetCommunityListStandardLegacy = types.Int64Value(cValue.Int())
- }
- if cValue := v.Get("set.Cisco-IOS-XE-bgp:bgp-route-map-set.comm-list.comm-list-expanded"); cValue.Exists() {
- item.SetCommunityListExpandedLegacy = types.Int64Value(cValue.Int())
- }
- if cValue := v.Get("set.comm-list.comm-list-name"); cValue.Exists() {
- item.SetCommunityListNameLegacy = types.StringValue(cValue.String())
+ data.Entries[i].SetLevel12 = types.BoolValue(false)
}
- if cValue := v.Get("set.extcommunity.rt.asn-nn"); cValue.Exists() {
- item.SetExtcomunityRtLegacy = helpers.GetStringList(cValue.Array())
+ } else {
+ data.Entries[i].SetLevel12 = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "set/level/level-2"); !data.Entries[i].SetLevel2.IsNull() {
+ if value.Exists() {
+ data.Entries[i].SetLevel2 = types.BoolValue(true)
} else {
- item.SetExtcomunityRtLegacy = types.ListNull(types.StringType)
- }
- if cValue := v.Get("set.extcommunity.soo.asn-nn"); cValue.Exists() {
- item.SetExtcomunitySooLegacy = types.StringValue(cValue.String())
- }
- if cValue := v.Get("set.extcommunity.vpn-distinguisher.asn-nn"); cValue.Exists() {
- item.SetExtcomunityVpnDistinguisherLegacy = types.StringValue(cValue.String())
- }
- if cValue := v.Get("set.local-preference"); cValue.Exists() {
- item.SetLocalPreferenceLegacy = types.Int64Value(cValue.Int())
- }
- if cValue := v.Get("set.weight"); cValue.Exists() {
- item.SetWeightLegacy = types.Int64Value(cValue.Int())
+ data.Entries[i].SetLevel2 = types.BoolValue(false)
}
- if cValue := v.Get("set.Cisco-IOS-XE-bgp:bgp-route-map-set.as-path.prepend.as-container.as-number"); cValue.Exists() {
- item.SetAsPathPrependAs = types.StringValue(cValue.String())
+ } else {
+ data.Entries[i].SetLevel2 = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "set/metric/metric-change"); value.Exists() && !data.Entries[i].SetMetricChange.IsNull() {
+ data.Entries[i].SetMetricChange = types.StringValue(value.String())
+ } else {
+ data.Entries[i].SetMetricChange = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "set/metric/values/value"); value.Exists() && !data.Entries[i].SetMetricValue.IsNull() {
+ data.Entries[i].SetMetricValue = types.Int64Value(value.Int())
+ } else {
+ data.Entries[i].SetMetricValue = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(r, "set/metric/values/delay"); value.Exists() && !data.Entries[i].SetMetricDelay.IsNull() {
+ data.Entries[i].SetMetricDelay = types.StringValue(value.String())
+ } else {
+ data.Entries[i].SetMetricDelay = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "set/metric/values/reliability"); value.Exists() && !data.Entries[i].SetMetricReliability.IsNull() {
+ data.Entries[i].SetMetricReliability = types.Int64Value(value.Int())
+ } else {
+ data.Entries[i].SetMetricReliability = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(r, "set/metric/values/loading"); value.Exists() && !data.Entries[i].SetMetricLoading.IsNull() {
+ data.Entries[i].SetMetricLoading = types.Int64Value(value.Int())
+ } else {
+ data.Entries[i].SetMetricLoading = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(r, "set/metric/values/MTU"); value.Exists() && !data.Entries[i].SetMetricMtu.IsNull() {
+ data.Entries[i].SetMetricMtu = types.Int64Value(value.Int())
+ } else {
+ data.Entries[i].SetMetricMtu = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(r, "set/metric-type"); value.Exists() && !data.Entries[i].SetMetricType.IsNull() {
+ data.Entries[i].SetMetricType = types.StringValue(value.String())
+ } else {
+ data.Entries[i].SetMetricType = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "set/tag/tag-val"); value.Exists() && !data.Entries[i].SetTag.IsNull() {
+ data.Entries[i].SetTag = types.Int64Value(value.Int())
+ } else {
+ data.Entries[i].SetTag = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(r, "set/vrf"); value.Exists() && !data.Entries[i].SetVrf.IsNull() {
+ data.Entries[i].SetVrf = types.StringValue(value.String())
+ } else {
+ data.Entries[i].SetVrf = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "set/as-path/prepend/as-container/as-number"); value.Exists() && !data.Entries[i].SetAsPathPrependAsLegacy.IsNull() {
+ data.Entries[i].SetAsPathPrependAsLegacy = types.StringValue(value.String())
+ } else {
+ data.Entries[i].SetAsPathPrependAsLegacy = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "set/as-path/prepend/last-as-cont/last-as"); value.Exists() && !data.Entries[i].SetAsPathPrependLastAsLegacy.IsNull() {
+ data.Entries[i].SetAsPathPrependLastAsLegacy = types.Int64Value(value.Int())
+ } else {
+ data.Entries[i].SetAsPathPrependLastAsLegacy = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(r, "set/as-path/tag"); !data.Entries[i].SetAsPathTagLegacy.IsNull() {
+ if value.Exists() {
+ data.Entries[i].SetAsPathTagLegacy = types.BoolValue(true)
+ } else {
+ data.Entries[i].SetAsPathTagLegacy = types.BoolValue(false)
}
- if cValue := v.Get("set.Cisco-IOS-XE-bgp:bgp-route-map-set.as-path.prepend.last-as-cont.last-as"); cValue.Exists() {
- item.SetAsPathPrependLastAs = types.Int64Value(cValue.Int())
+ } else {
+ data.Entries[i].SetAsPathTagLegacy = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "set/community/none"); !data.Entries[i].SetCommunityNoneLegacy.IsNull() {
+ if value.Exists() {
+ data.Entries[i].SetCommunityNoneLegacy = types.BoolValue(true)
+ } else {
+ data.Entries[i].SetCommunityNoneLegacy = types.BoolValue(false)
}
- if cValue := v.Get("set.Cisco-IOS-XE-bgp:bgp-route-map-set.as-path.tag"); cValue.Exists() {
- item.SetAsPathTag = types.BoolValue(true)
+ } else {
+ data.Entries[i].SetCommunityNoneLegacy = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "set/community/community-well-known/community-list"); value.Exists() && !data.Entries[i].SetCommunitiesLegacy.IsNull() {
+ data.Entries[i].SetCommunitiesLegacy = helpers.GetStringListXML(value.Array())
+ } else {
+ data.Entries[i].SetCommunitiesLegacy = types.ListNull(types.StringType)
+ }
+ if value := helpers.GetFromXPath(r, "set/community/community-well-known/additive"); !data.Entries[i].SetCommunitiesAdditiveLegacy.IsNull() {
+ if value.Exists() {
+ data.Entries[i].SetCommunitiesAdditiveLegacy = types.BoolValue(true)
} else {
- item.SetAsPathTag = types.BoolValue(false)
+ data.Entries[i].SetCommunitiesAdditiveLegacy = types.BoolValue(false)
}
- if cValue := v.Get("set.Cisco-IOS-XE-bgp:bgp-route-map-set.as-path.replace.any"); cValue.Exists() {
- item.SetAsPathReplaceAny = types.BoolValue(true)
+ } else {
+ data.Entries[i].SetCommunitiesAdditiveLegacy = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "set/comm-list/delete"); !data.Entries[i].SetCommunityListDeleteLegacy.IsNull() {
+ if value.Exists() {
+ data.Entries[i].SetCommunityListDeleteLegacy = types.BoolValue(true)
} else {
- item.SetAsPathReplaceAny = types.BoolValue(false)
+ data.Entries[i].SetCommunityListDeleteLegacy = types.BoolValue(false)
+ }
+ } else {
+ data.Entries[i].SetCommunityListDeleteLegacy = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "set/comm-list/comm-list-standard"); value.Exists() && !data.Entries[i].SetCommunityListStandardLegacy.IsNull() {
+ data.Entries[i].SetCommunityListStandardLegacy = types.Int64Value(value.Int())
+ } else {
+ data.Entries[i].SetCommunityListStandardLegacy = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(r, "set/Cisco-IOS-XE-bgp:bgp-route-map-set/comm-list/comm-list-expanded"); value.Exists() && !data.Entries[i].SetCommunityListExpandedLegacy.IsNull() {
+ data.Entries[i].SetCommunityListExpandedLegacy = types.Int64Value(value.Int())
+ } else {
+ data.Entries[i].SetCommunityListExpandedLegacy = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(r, "set/comm-list/comm-list-name"); value.Exists() && !data.Entries[i].SetCommunityListNameLegacy.IsNull() {
+ data.Entries[i].SetCommunityListNameLegacy = types.StringValue(value.String())
+ } else {
+ data.Entries[i].SetCommunityListNameLegacy = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "set/extcommunity/rt/asn-nn"); value.Exists() && !data.Entries[i].SetExtcomunityRtLegacy.IsNull() {
+ data.Entries[i].SetExtcomunityRtLegacy = helpers.GetStringListXML(value.Array())
+ } else {
+ data.Entries[i].SetExtcomunityRtLegacy = types.ListNull(types.StringType)
+ }
+ if value := helpers.GetFromXPath(r, "set/extcommunity/soo/asn-nn"); value.Exists() && !data.Entries[i].SetExtcomunitySooLegacy.IsNull() {
+ data.Entries[i].SetExtcomunitySooLegacy = types.StringValue(value.String())
+ } else {
+ data.Entries[i].SetExtcomunitySooLegacy = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "set/extcommunity/vpn-distinguisher/asn-nn"); value.Exists() && !data.Entries[i].SetExtcomunityVpnDistinguisherLegacy.IsNull() {
+ data.Entries[i].SetExtcomunityVpnDistinguisherLegacy = types.StringValue(value.String())
+ } else {
+ data.Entries[i].SetExtcomunityVpnDistinguisherLegacy = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "set/local-preference"); value.Exists() && !data.Entries[i].SetLocalPreferenceLegacy.IsNull() {
+ data.Entries[i].SetLocalPreferenceLegacy = types.Int64Value(value.Int())
+ } else {
+ data.Entries[i].SetLocalPreferenceLegacy = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(r, "set/weight"); value.Exists() && !data.Entries[i].SetWeightLegacy.IsNull() {
+ data.Entries[i].SetWeightLegacy = types.Int64Value(value.Int())
+ } else {
+ data.Entries[i].SetWeightLegacy = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(r, "set/Cisco-IOS-XE-bgp:bgp-route-map-set/as-path/prepend/as-container/as-number"); value.Exists() && !data.Entries[i].SetAsPathPrependAs.IsNull() {
+ data.Entries[i].SetAsPathPrependAs = types.StringValue(value.String())
+ } else {
+ data.Entries[i].SetAsPathPrependAs = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "set/Cisco-IOS-XE-bgp:bgp-route-map-set/as-path/prepend/last-as-cont/last-as"); value.Exists() && !data.Entries[i].SetAsPathPrependLastAs.IsNull() {
+ data.Entries[i].SetAsPathPrependLastAs = types.Int64Value(value.Int())
+ } else {
+ data.Entries[i].SetAsPathPrependLastAs = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(r, "set/Cisco-IOS-XE-bgp:bgp-route-map-set/as-path/tag"); !data.Entries[i].SetAsPathTag.IsNull() {
+ if value.Exists() {
+ data.Entries[i].SetAsPathTag = types.BoolValue(true)
+ } else {
+ data.Entries[i].SetAsPathTag = types.BoolValue(false)
+ }
+ } else {
+ data.Entries[i].SetAsPathTag = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "set/Cisco-IOS-XE-bgp:bgp-route-map-set/as-path/replace/any"); !data.Entries[i].SetAsPathReplaceAny.IsNull() {
+ if value.Exists() {
+ data.Entries[i].SetAsPathReplaceAny = types.BoolValue(true)
+ } else {
+ data.Entries[i].SetAsPathReplaceAny = types.BoolValue(false)
+ }
+ } else {
+ data.Entries[i].SetAsPathReplaceAny = types.BoolNull()
+ }
+ for ci := range data.Entries[i].SetAsPathReplaceAs {
+ keys := [...]string{"as-number"}
+ keyValues := [...]string{data.Entries[i].SetAsPathReplaceAs[ci].AsNumber.ValueString()}
+
+ var cr xmldot.Result
+ helpers.GetFromXPath(r, "set/Cisco-IOS-XE-bgp:bgp-route-map-set/as-path/replace/as-container").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ cr = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(cr, "as-number"); value.Exists() && !data.Entries[i].SetAsPathReplaceAs[ci].AsNumber.IsNull() {
+ data.Entries[i].SetAsPathReplaceAs[ci].AsNumber = types.StringValue(value.String())
+ } else {
+ data.Entries[i].SetAsPathReplaceAs[ci].AsNumber = types.StringNull()
+ }
+ }
+ if value := helpers.GetFromXPath(r, "set/Cisco-IOS-XE-bgp:bgp-route-map-set/bgp-community/none"); !data.Entries[i].SetCommunityNone.IsNull() {
+ if value.Exists() {
+ data.Entries[i].SetCommunityNone = types.BoolValue(true)
+ } else {
+ data.Entries[i].SetCommunityNone = types.BoolValue(false)
+ }
+ } else {
+ data.Entries[i].SetCommunityNone = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "set/Cisco-IOS-XE-bgp:bgp-route-map-set/bgp-community/community-well-known/community-list"); value.Exists() && !data.Entries[i].SetCommunities.IsNull() {
+ data.Entries[i].SetCommunities = helpers.GetStringListXML(value.Array())
+ } else {
+ data.Entries[i].SetCommunities = types.ListNull(types.StringType)
+ }
+ if value := helpers.GetFromXPath(r, "set/Cisco-IOS-XE-bgp:bgp-route-map-set/bgp-community/community-well-known/additive"); !data.Entries[i].SetCommunitiesAdditive.IsNull() {
+ if value.Exists() {
+ data.Entries[i].SetCommunitiesAdditive = types.BoolValue(true)
+ } else {
+ data.Entries[i].SetCommunitiesAdditive = types.BoolValue(false)
+ }
+ } else {
+ data.Entries[i].SetCommunitiesAdditive = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "set/Cisco-IOS-XE-bgp:bgp-route-map-set/comm-list/delete"); !data.Entries[i].SetCommunityListDelete.IsNull() {
+ if value.Exists() {
+ data.Entries[i].SetCommunityListDelete = types.BoolValue(true)
+ } else {
+ data.Entries[i].SetCommunityListDelete = types.BoolValue(false)
+ }
+ } else {
+ data.Entries[i].SetCommunityListDelete = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "set/Cisco-IOS-XE-bgp:bgp-route-map-set/comm-list/comm-list-standard"); value.Exists() && !data.Entries[i].SetCommunityListStandard.IsNull() {
+ data.Entries[i].SetCommunityListStandard = types.Int64Value(value.Int())
+ } else {
+ data.Entries[i].SetCommunityListStandard = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(r, "set/Cisco-IOS-XE-bgp:bgp-route-map-set/comm-list/comm-list-expanded"); value.Exists() && !data.Entries[i].SetCommunityListExpanded.IsNull() {
+ data.Entries[i].SetCommunityListExpanded = types.Int64Value(value.Int())
+ } else {
+ data.Entries[i].SetCommunityListExpanded = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(r, "set/Cisco-IOS-XE-bgp:bgp-route-map-set/comm-list/comm-list-name"); value.Exists() && !data.Entries[i].SetCommunityListName.IsNull() {
+ data.Entries[i].SetCommunityListName = types.StringValue(value.String())
+ } else {
+ data.Entries[i].SetCommunityListName = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "set/Cisco-IOS-XE-bgp:bgp-route-map-set/extcommunity/rt/asn-nn"); value.Exists() && !data.Entries[i].SetExtcomunityRt.IsNull() {
+ data.Entries[i].SetExtcomunityRt = helpers.GetStringListXML(value.Array())
+ } else {
+ data.Entries[i].SetExtcomunityRt = types.ListNull(types.StringType)
+ }
+ if value := helpers.GetFromXPath(r, "set/Cisco-IOS-XE-bgp:bgp-route-map-set/extcommunity/soo/asn-nn"); value.Exists() && !data.Entries[i].SetExtcomunitySoo.IsNull() {
+ data.Entries[i].SetExtcomunitySoo = types.StringValue(value.String())
+ } else {
+ data.Entries[i].SetExtcomunitySoo = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "set/Cisco-IOS-XE-bgp:bgp-route-map-set/extcommunity/vpn-distinguisher/asn-nn"); value.Exists() && !data.Entries[i].SetExtcomunityVpnDistinguisher.IsNull() {
+ data.Entries[i].SetExtcomunityVpnDistinguisher = types.StringValue(value.String())
+ } else {
+ data.Entries[i].SetExtcomunityVpnDistinguisher = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "set/Cisco-IOS-XE-bgp:bgp-route-map-set/extcommunity/vpn-distinguisher/asn-nn-additive"); !data.Entries[i].SetExtcomunityVpnDistinguisherAdditive.IsNull() {
+ if value.Exists() {
+ data.Entries[i].SetExtcomunityVpnDistinguisherAdditive = types.BoolValue(true)
+ } else {
+ data.Entries[i].SetExtcomunityVpnDistinguisherAdditive = types.BoolValue(false)
+ }
+ } else {
+ data.Entries[i].SetExtcomunityVpnDistinguisherAdditive = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "set/Cisco-IOS-XE-bgp:bgp-route-map-set/local-preference"); value.Exists() && !data.Entries[i].SetLocalPreference.IsNull() {
+ data.Entries[i].SetLocalPreference = types.Int64Value(value.Int())
+ } else {
+ data.Entries[i].SetLocalPreference = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(r, "set/Cisco-IOS-XE-bgp:bgp-route-map-set/weight"); value.Exists() && !data.Entries[i].SetWeight.IsNull() {
+ data.Entries[i].SetWeight = types.Int64Value(value.Int())
+ } else {
+ data.Entries[i].SetWeight = types.Int64Null()
+ }
+ }
+}
+
+// End of section. //template:end updateFromBodyXML
+
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBody
+
+func (data *RouteMap) fromBody(ctx context.Context, res gjson.Result) {
+ prefix := helpers.LastElement(data.getPath()) + "."
+ if res.Get(helpers.LastElement(data.getPath())).IsArray() {
+ prefix += "0."
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-route-map:route-map-without-order-seq"); value.Exists() {
+ data.Entries = make([]RouteMapEntries, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := RouteMapEntries{}
+ if cValue := v.Get("seq_no"); cValue.Exists() {
+ item.Seq = types.Int64Value(cValue.Int())
+ }
+ if cValue := v.Get("operation"); cValue.Exists() {
+ item.Operation = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("description"); cValue.Exists() {
+ item.Description = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("continue"); cValue.Exists() {
+ item.Continue = types.BoolValue(true)
+ } else {
+ item.Continue = types.BoolValue(false)
+ }
+ if cValue := v.Get("continue.sequence-number"); cValue.Exists() {
+ item.ContinueSequenceNumber = types.Int64Value(cValue.Int())
+ }
+ if cValue := v.Get("match.interface.interface"); cValue.Exists() {
+ item.MatchInterfaces = helpers.GetStringList(cValue.Array())
+ } else {
+ item.MatchInterfaces = types.ListNull(types.StringType)
+ }
+ if cValue := v.Get("match.ip.address.access-list"); cValue.Exists() {
+ item.MatchIpAddressAccessLists = helpers.GetStringList(cValue.Array())
+ } else {
+ item.MatchIpAddressAccessLists = types.ListNull(types.StringType)
+ }
+ if cValue := v.Get("match.ip.address.prefix-list"); cValue.Exists() {
+ item.MatchIpAddressPrefixLists = helpers.GetStringList(cValue.Array())
+ } else {
+ item.MatchIpAddressPrefixLists = types.ListNull(types.StringType)
+ }
+ if cValue := v.Get("match.ip.next-hop.access-list"); cValue.Exists() {
+ item.MatchIpNextHopAccessLists = helpers.GetStringList(cValue.Array())
+ } else {
+ item.MatchIpNextHopAccessLists = types.ListNull(types.StringType)
+ }
+ if cValue := v.Get("match.ip.next-hop.prefix-list"); cValue.Exists() {
+ item.MatchIpNextHopPrefixLists = helpers.GetStringList(cValue.Array())
+ } else {
+ item.MatchIpNextHopPrefixLists = types.ListNull(types.StringType)
+ }
+ if cValue := v.Get("match.ipv6.address.access-list"); cValue.Exists() {
+ item.MatchIpv6AddressAccessLists = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("match.ipv6.address.prefix-list"); cValue.Exists() {
+ item.MatchIpv6AddressPrefixLists = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("match.ipv6.next-hop.access-list"); cValue.Exists() {
+ item.MatchIpv6NextHopAccessLists = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("match.ipv6.next-hop.prefix-list"); cValue.Exists() {
+ item.MatchIpv6NextHopPrefixLists = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("match.route-type.external"); cValue.Exists() {
+ item.MatchRouteTypeExternal = types.BoolValue(true)
+ } else {
+ item.MatchRouteTypeExternal = types.BoolValue(false)
+ }
+ if cValue := v.Get("match.route-type.external.type-1"); cValue.Exists() {
+ item.MatchRouteTypeExternalType1 = types.BoolValue(true)
+ } else {
+ item.MatchRouteTypeExternalType1 = types.BoolValue(false)
+ }
+ if cValue := v.Get("match.route-type.external.type-2"); cValue.Exists() {
+ item.MatchRouteTypeExternalType2 = types.BoolValue(true)
+ } else {
+ item.MatchRouteTypeExternalType2 = types.BoolValue(false)
+ }
+ if cValue := v.Get("match.route-type.internal"); cValue.Exists() {
+ item.MatchRouteTypeInternal = types.BoolValue(true)
+ } else {
+ item.MatchRouteTypeInternal = types.BoolValue(false)
+ }
+ if cValue := v.Get("match.route-type.level-1"); cValue.Exists() {
+ item.MatchRouteTypeLevel1 = types.BoolValue(true)
+ } else {
+ item.MatchRouteTypeLevel1 = types.BoolValue(false)
+ }
+ if cValue := v.Get("match.route-type.level-2"); cValue.Exists() {
+ item.MatchRouteTypeLevel2 = types.BoolValue(true)
+ } else {
+ item.MatchRouteTypeLevel2 = types.BoolValue(false)
+ }
+ if cValue := v.Get("match.route-type.local"); cValue.Exists() {
+ item.MatchRouteTypeLocalLegacy = types.BoolValue(true)
+ } else {
+ item.MatchRouteTypeLocalLegacy = types.BoolValue(false)
+ }
+ if cValue := v.Get("match.Cisco-IOS-XE-bgp:bgp-route-map-match.route-type.local"); cValue.Exists() {
+ item.MatchRouteTypeLocal = types.BoolValue(true)
+ } else {
+ item.MatchRouteTypeLocal = types.BoolValue(false)
+ }
+ if cValue := v.Get("match.source-protocol.bgp"); cValue.Exists() {
+ item.MatchSourceProtocolBgp = helpers.GetStringList(cValue.Array())
+ } else {
+ item.MatchSourceProtocolBgp = types.ListNull(types.StringType)
+ }
+ if cValue := v.Get("match.source-protocol.connected"); cValue.Exists() {
+ item.MatchSourceProtocolConnected = types.BoolValue(true)
+ } else {
+ item.MatchSourceProtocolConnected = types.BoolValue(false)
+ }
+ if cValue := v.Get("match.source-protocol.eigrp"); cValue.Exists() {
+ item.MatchSourceProtocolEigrp = helpers.GetStringList(cValue.Array())
+ } else {
+ item.MatchSourceProtocolEigrp = types.ListNull(types.StringType)
+ }
+ if cValue := v.Get("match.source-protocol.isis"); cValue.Exists() {
+ item.MatchSourceProtocolIsis = types.BoolValue(true)
+ } else {
+ item.MatchSourceProtocolIsis = types.BoolValue(false)
+ }
+ if cValue := v.Get("match.source-protocol.lisp"); cValue.Exists() {
+ item.MatchSourceProtocolLisp = types.BoolValue(true)
+ } else {
+ item.MatchSourceProtocolLisp = types.BoolValue(false)
+ }
+ if cValue := v.Get("match.source-protocol.ospf"); cValue.Exists() {
+ item.MatchSourceProtocolOspf = helpers.GetStringList(cValue.Array())
+ } else {
+ item.MatchSourceProtocolOspf = types.ListNull(types.StringType)
+ }
+ if cValue := v.Get("match.source-protocol.ospfv3"); cValue.Exists() {
+ item.MatchSourceProtocolOspfv3 = helpers.GetStringList(cValue.Array())
+ } else {
+ item.MatchSourceProtocolOspfv3 = types.ListNull(types.StringType)
+ }
+ if cValue := v.Get("match.source-protocol.rip"); cValue.Exists() {
+ item.MatchSourceProtocolRip = types.BoolValue(true)
+ } else {
+ item.MatchSourceProtocolRip = types.BoolValue(false)
+ }
+ if cValue := v.Get("match.source-protocol.static"); cValue.Exists() {
+ item.MatchSourceProtocolStatic = types.BoolValue(true)
+ } else {
+ item.MatchSourceProtocolStatic = types.BoolValue(false)
+ }
+ if cValue := v.Get("match.tag.tag_value"); cValue.Exists() {
+ item.MatchTags = helpers.GetInt64List(cValue.Array())
+ } else {
+ item.MatchTags = types.ListNull(types.Int64Type)
+ }
+ if cValue := v.Get("match.track"); cValue.Exists() {
+ item.MatchTrack = types.Int64Value(cValue.Int())
+ }
+ if cValue := v.Get("match.as-path.access-list"); cValue.Exists() {
+ item.MatchAsPathsLegacy = helpers.GetInt64List(cValue.Array())
+ } else {
+ item.MatchAsPathsLegacy = types.ListNull(types.Int64Type)
+ }
+ if cValue := v.Get("match.community.name"); cValue.Exists() {
+ item.MatchCommunityListsLegacy = helpers.GetStringList(cValue.Array())
+ } else {
+ item.MatchCommunityListsLegacy = types.ListNull(types.StringType)
+ }
+ if cValue := v.Get("match.extcommunity.name"); cValue.Exists() {
+ item.MatchExtcommunityListsLegacy = helpers.GetStringList(cValue.Array())
+ } else {
+ item.MatchExtcommunityListsLegacy = types.ListNull(types.StringType)
+ }
+ if cValue := v.Get("match.local-preference.values"); cValue.Exists() {
+ item.MatchLocalPreferencesLegacy = helpers.GetInt64List(cValue.Array())
+ } else {
+ item.MatchLocalPreferencesLegacy = types.ListNull(types.Int64Type)
+ }
+ if cValue := v.Get("match.Cisco-IOS-XE-bgp:bgp-route-map-match.as-path.access-list"); cValue.Exists() {
+ item.MatchAsPaths = helpers.GetInt64List(cValue.Array())
+ } else {
+ item.MatchAsPaths = types.ListNull(types.Int64Type)
+ }
+ if cValue := v.Get("match.Cisco-IOS-XE-bgp:bgp-route-map-match.bgp-community.community-list"); cValue.Exists() {
+ item.MatchCommunityLists = helpers.GetStringList(cValue.Array())
+ } else {
+ item.MatchCommunityLists = types.ListNull(types.StringType)
+ }
+ if cValue := v.Get("match.Cisco-IOS-XE-bgp:bgp-route-map-match.bgp-community.exact-match"); cValue.Exists() {
+ item.MatchCommunityListExactMatch = types.BoolValue(true)
+ } else {
+ item.MatchCommunityListExactMatch = types.BoolValue(false)
+ }
+ if cValue := v.Get("match.Cisco-IOS-XE-bgp:bgp-route-map-match.extcommunity.extcommunity-list"); cValue.Exists() {
+ item.MatchExtcommunityLists = helpers.GetStringList(cValue.Array())
+ } else {
+ item.MatchExtcommunityLists = types.ListNull(types.StringType)
+ }
+ if cValue := v.Get("match.Cisco-IOS-XE-bgp:bgp-route-map-match.local-preference.values"); cValue.Exists() {
+ item.MatchLocalPreferences = helpers.GetInt64List(cValue.Array())
+ } else {
+ item.MatchLocalPreferences = types.ListNull(types.Int64Type)
+ }
+ if cValue := v.Get("set.default.interface-list"); cValue.Exists() {
+ item.SetDefaultInterfaces = helpers.GetStringList(cValue.Array())
+ } else {
+ item.SetDefaultInterfaces = types.ListNull(types.StringType)
+ }
+ if cValue := v.Get("set.global"); cValue.Exists() {
+ item.SetGlobal = types.BoolValue(true)
+ } else {
+ item.SetGlobal = types.BoolValue(false)
+ }
+ if cValue := v.Get("set.interface-list"); cValue.Exists() {
+ item.SetInterfaces = helpers.GetStringList(cValue.Array())
+ } else {
+ item.SetInterfaces = types.ListNull(types.StringType)
+ }
+ if cValue := v.Get("set.ip.address.prefix-list"); cValue.Exists() {
+ item.SetIpAddress = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("set.ip.default.global.next-hop.address"); cValue.Exists() {
+ item.SetIpDefaultGlobalNextHopAddress = helpers.GetStringList(cValue.Array())
+ } else {
+ item.SetIpDefaultGlobalNextHopAddress = types.ListNull(types.StringType)
+ }
+ if cValue := v.Get("set.ip.default.next-hop.address"); cValue.Exists() {
+ item.SetIpDefaultNextHopAddress = helpers.GetStringList(cValue.Array())
+ } else {
+ item.SetIpDefaultNextHopAddress = types.ListNull(types.StringType)
+ }
+ if cValue := v.Get("set.ip.global.next-hop.address"); cValue.Exists() {
+ item.SetIpGlobalNextHopAddress = helpers.GetStringList(cValue.Array())
+ } else {
+ item.SetIpGlobalNextHopAddress = types.ListNull(types.StringType)
+ }
+ if cValue := v.Get("set.ip.next-hop.address"); cValue.Exists() {
+ item.SetIpNextHopAddress = helpers.GetStringList(cValue.Array())
+ } else {
+ item.SetIpNextHopAddress = types.ListNull(types.StringType)
+ }
+ if cValue := v.Get("set.ip.next-hop.self"); cValue.Exists() {
+ item.SetIpNextHopSelf = types.BoolValue(true)
+ } else {
+ item.SetIpNextHopSelf = types.BoolValue(false)
+ }
+ if cValue := v.Get("set.ip.qos-group.qos-id"); cValue.Exists() {
+ item.SetIpQosGroup = types.Int64Value(cValue.Int())
+ }
+ if cValue := v.Get("set.ipv6.address.prefix-list"); cValue.Exists() {
+ item.SetIpv6Address = helpers.GetStringList(cValue.Array())
+ } else {
+ item.SetIpv6Address = types.ListNull(types.StringType)
+ }
+ if cValue := v.Get("set.ipv6.default.global.next-hop"); cValue.Exists() {
+ item.SetIpv6DefaultGlobalNextHop = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("set.ipv6.default.next-hop.ipv6"); cValue.Exists() {
+ item.SetIpv6DefaultNextHop = helpers.GetStringList(cValue.Array())
+ } else {
+ item.SetIpv6DefaultNextHop = types.ListNull(types.StringType)
+ }
+ if cValue := v.Get("set.ipv6.next-hop.ipv6"); cValue.Exists() {
+ item.SetIpv6NextHop = helpers.GetStringList(cValue.Array())
+ } else {
+ item.SetIpv6NextHop = types.ListNull(types.StringType)
+ }
+ if cValue := v.Get("set.level.level-1"); cValue.Exists() {
+ item.SetLevel1 = types.BoolValue(true)
+ } else {
+ item.SetLevel1 = types.BoolValue(false)
+ }
+ if cValue := v.Get("set.level.level-1-2"); cValue.Exists() {
+ item.SetLevel12 = types.BoolValue(true)
+ } else {
+ item.SetLevel12 = types.BoolValue(false)
+ }
+ if cValue := v.Get("set.level.level-2"); cValue.Exists() {
+ item.SetLevel2 = types.BoolValue(true)
+ } else {
+ item.SetLevel2 = types.BoolValue(false)
+ }
+ if cValue := v.Get("set.metric.metric-change"); cValue.Exists() {
+ item.SetMetricChange = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("set.metric.values.value"); cValue.Exists() {
+ item.SetMetricValue = types.Int64Value(cValue.Int())
+ }
+ if cValue := v.Get("set.metric.values.delay"); cValue.Exists() {
+ item.SetMetricDelay = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("set.metric.values.reliability"); cValue.Exists() {
+ item.SetMetricReliability = types.Int64Value(cValue.Int())
+ }
+ if cValue := v.Get("set.metric.values.loading"); cValue.Exists() {
+ item.SetMetricLoading = types.Int64Value(cValue.Int())
+ }
+ if cValue := v.Get("set.metric.values.MTU"); cValue.Exists() {
+ item.SetMetricMtu = types.Int64Value(cValue.Int())
+ }
+ if cValue := v.Get("set.metric-type"); cValue.Exists() {
+ item.SetMetricType = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("set.tag.tag-val"); cValue.Exists() {
+ item.SetTag = types.Int64Value(cValue.Int())
+ }
+ if cValue := v.Get("set.vrf"); cValue.Exists() {
+ item.SetVrf = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("set.as-path.prepend.as-container.as-number"); cValue.Exists() {
+ item.SetAsPathPrependAsLegacy = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("set.as-path.prepend.last-as-cont.last-as"); cValue.Exists() {
+ item.SetAsPathPrependLastAsLegacy = types.Int64Value(cValue.Int())
+ }
+ if cValue := v.Get("set.as-path.tag"); cValue.Exists() {
+ item.SetAsPathTagLegacy = types.BoolValue(true)
+ } else {
+ item.SetAsPathTagLegacy = types.BoolValue(false)
+ }
+ if cValue := v.Get("set.community.none"); cValue.Exists() {
+ item.SetCommunityNoneLegacy = types.BoolValue(true)
+ } else {
+ item.SetCommunityNoneLegacy = types.BoolValue(false)
+ }
+ if cValue := v.Get("set.community.community-well-known.community-list"); cValue.Exists() {
+ item.SetCommunitiesLegacy = helpers.GetStringList(cValue.Array())
+ } else {
+ item.SetCommunitiesLegacy = types.ListNull(types.StringType)
+ }
+ if cValue := v.Get("set.community.community-well-known.additive"); cValue.Exists() {
+ item.SetCommunitiesAdditiveLegacy = types.BoolValue(true)
+ } else {
+ item.SetCommunitiesAdditiveLegacy = types.BoolValue(false)
+ }
+ if cValue := v.Get("set.comm-list.delete"); cValue.Exists() {
+ item.SetCommunityListDeleteLegacy = types.BoolValue(true)
+ } else {
+ item.SetCommunityListDeleteLegacy = types.BoolValue(false)
+ }
+ if cValue := v.Get("set.comm-list.comm-list-standard"); cValue.Exists() {
+ item.SetCommunityListStandardLegacy = types.Int64Value(cValue.Int())
+ }
+ if cValue := v.Get("set.Cisco-IOS-XE-bgp:bgp-route-map-set.comm-list.comm-list-expanded"); cValue.Exists() {
+ item.SetCommunityListExpandedLegacy = types.Int64Value(cValue.Int())
+ }
+ if cValue := v.Get("set.comm-list.comm-list-name"); cValue.Exists() {
+ item.SetCommunityListNameLegacy = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("set.extcommunity.rt.asn-nn"); cValue.Exists() {
+ item.SetExtcomunityRtLegacy = helpers.GetStringList(cValue.Array())
+ } else {
+ item.SetExtcomunityRtLegacy = types.ListNull(types.StringType)
+ }
+ if cValue := v.Get("set.extcommunity.soo.asn-nn"); cValue.Exists() {
+ item.SetExtcomunitySooLegacy = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("set.extcommunity.vpn-distinguisher.asn-nn"); cValue.Exists() {
+ item.SetExtcomunityVpnDistinguisherLegacy = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("set.local-preference"); cValue.Exists() {
+ item.SetLocalPreferenceLegacy = types.Int64Value(cValue.Int())
+ }
+ if cValue := v.Get("set.weight"); cValue.Exists() {
+ item.SetWeightLegacy = types.Int64Value(cValue.Int())
+ }
+ if cValue := v.Get("set.Cisco-IOS-XE-bgp:bgp-route-map-set.as-path.prepend.as-container.as-number"); cValue.Exists() {
+ item.SetAsPathPrependAs = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("set.Cisco-IOS-XE-bgp:bgp-route-map-set.as-path.prepend.last-as-cont.last-as"); cValue.Exists() {
+ item.SetAsPathPrependLastAs = types.Int64Value(cValue.Int())
+ }
+ if cValue := v.Get("set.Cisco-IOS-XE-bgp:bgp-route-map-set.as-path.tag"); cValue.Exists() {
+ item.SetAsPathTag = types.BoolValue(true)
+ } else {
+ item.SetAsPathTag = types.BoolValue(false)
+ }
+ if cValue := v.Get("set.Cisco-IOS-XE-bgp:bgp-route-map-set.as-path.replace.any"); cValue.Exists() {
+ item.SetAsPathReplaceAny = types.BoolValue(true)
+ } else {
+ item.SetAsPathReplaceAny = types.BoolValue(false)
+ }
+ if cValue := v.Get("set.Cisco-IOS-XE-bgp:bgp-route-map-set.as-path.replace.as-container"); cValue.Exists() {
+ item.SetAsPathReplaceAs = make([]RouteMapEntriesSetAsPathReplaceAs, 0)
+ cValue.ForEach(func(ck, cv gjson.Result) bool {
+ cItem := RouteMapEntriesSetAsPathReplaceAs{}
+ if ccValue := cv.Get("as-number"); ccValue.Exists() {
+ cItem.AsNumber = types.StringValue(ccValue.String())
+ }
+ item.SetAsPathReplaceAs = append(item.SetAsPathReplaceAs, cItem)
+ return true
+ })
+ }
+ if cValue := v.Get("set.Cisco-IOS-XE-bgp:bgp-route-map-set.bgp-community.none"); cValue.Exists() {
+ item.SetCommunityNone = types.BoolValue(true)
+ } else {
+ item.SetCommunityNone = types.BoolValue(false)
+ }
+ if cValue := v.Get("set.Cisco-IOS-XE-bgp:bgp-route-map-set.bgp-community.community-well-known.community-list"); cValue.Exists() {
+ item.SetCommunities = helpers.GetStringList(cValue.Array())
+ } else {
+ item.SetCommunities = types.ListNull(types.StringType)
+ }
+ if cValue := v.Get("set.Cisco-IOS-XE-bgp:bgp-route-map-set.bgp-community.community-well-known.additive"); cValue.Exists() {
+ item.SetCommunitiesAdditive = types.BoolValue(true)
+ } else {
+ item.SetCommunitiesAdditive = types.BoolValue(false)
+ }
+ if cValue := v.Get("set.Cisco-IOS-XE-bgp:bgp-route-map-set.comm-list.delete"); cValue.Exists() {
+ item.SetCommunityListDelete = types.BoolValue(true)
+ } else {
+ item.SetCommunityListDelete = types.BoolValue(false)
+ }
+ if cValue := v.Get("set.Cisco-IOS-XE-bgp:bgp-route-map-set.comm-list.comm-list-standard"); cValue.Exists() {
+ item.SetCommunityListStandard = types.Int64Value(cValue.Int())
+ }
+ if cValue := v.Get("set.Cisco-IOS-XE-bgp:bgp-route-map-set.comm-list.comm-list-expanded"); cValue.Exists() {
+ item.SetCommunityListExpanded = types.Int64Value(cValue.Int())
+ }
+ if cValue := v.Get("set.Cisco-IOS-XE-bgp:bgp-route-map-set.comm-list.comm-list-name"); cValue.Exists() {
+ item.SetCommunityListName = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("set.Cisco-IOS-XE-bgp:bgp-route-map-set.extcommunity.rt.asn-nn"); cValue.Exists() {
+ item.SetExtcomunityRt = helpers.GetStringList(cValue.Array())
+ } else {
+ item.SetExtcomunityRt = types.ListNull(types.StringType)
+ }
+ if cValue := v.Get("set.Cisco-IOS-XE-bgp:bgp-route-map-set.extcommunity.soo.asn-nn"); cValue.Exists() {
+ item.SetExtcomunitySoo = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("set.Cisco-IOS-XE-bgp:bgp-route-map-set.extcommunity.vpn-distinguisher.asn-nn"); cValue.Exists() {
+ item.SetExtcomunityVpnDistinguisher = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("set.Cisco-IOS-XE-bgp:bgp-route-map-set.extcommunity.vpn-distinguisher.asn-nn-additive"); cValue.Exists() {
+ item.SetExtcomunityVpnDistinguisherAdditive = types.BoolValue(true)
+ } else {
+ item.SetExtcomunityVpnDistinguisherAdditive = types.BoolValue(false)
+ }
+ if cValue := v.Get("set.Cisco-IOS-XE-bgp:bgp-route-map-set.local-preference"); cValue.Exists() {
+ item.SetLocalPreference = types.Int64Value(cValue.Int())
+ }
+ if cValue := v.Get("set.Cisco-IOS-XE-bgp:bgp-route-map-set.weight"); cValue.Exists() {
+ item.SetWeight = types.Int64Value(cValue.Int())
+ }
+ data.Entries = append(data.Entries, item)
+ return true
+ })
+ }
+}
+
+// End of section. //template:end fromBody
+
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyData
+
+func (data *RouteMapData) fromBody(ctx context.Context, res gjson.Result) {
+ prefix := helpers.LastElement(data.getPath()) + "."
+ if res.Get(helpers.LastElement(data.getPath())).IsArray() {
+ prefix += "0."
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-route-map:route-map-without-order-seq"); value.Exists() {
+ data.Entries = make([]RouteMapEntries, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := RouteMapEntries{}
+ if cValue := v.Get("seq_no"); cValue.Exists() {
+ item.Seq = types.Int64Value(cValue.Int())
+ }
+ if cValue := v.Get("operation"); cValue.Exists() {
+ item.Operation = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("description"); cValue.Exists() {
+ item.Description = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("continue"); cValue.Exists() {
+ item.Continue = types.BoolValue(true)
+ } else {
+ item.Continue = types.BoolValue(false)
+ }
+ if cValue := v.Get("continue.sequence-number"); cValue.Exists() {
+ item.ContinueSequenceNumber = types.Int64Value(cValue.Int())
+ }
+ if cValue := v.Get("match.interface.interface"); cValue.Exists() {
+ item.MatchInterfaces = helpers.GetStringList(cValue.Array())
+ } else {
+ item.MatchInterfaces = types.ListNull(types.StringType)
+ }
+ if cValue := v.Get("match.ip.address.access-list"); cValue.Exists() {
+ item.MatchIpAddressAccessLists = helpers.GetStringList(cValue.Array())
+ } else {
+ item.MatchIpAddressAccessLists = types.ListNull(types.StringType)
+ }
+ if cValue := v.Get("match.ip.address.prefix-list"); cValue.Exists() {
+ item.MatchIpAddressPrefixLists = helpers.GetStringList(cValue.Array())
+ } else {
+ item.MatchIpAddressPrefixLists = types.ListNull(types.StringType)
+ }
+ if cValue := v.Get("match.ip.next-hop.access-list"); cValue.Exists() {
+ item.MatchIpNextHopAccessLists = helpers.GetStringList(cValue.Array())
+ } else {
+ item.MatchIpNextHopAccessLists = types.ListNull(types.StringType)
+ }
+ if cValue := v.Get("match.ip.next-hop.prefix-list"); cValue.Exists() {
+ item.MatchIpNextHopPrefixLists = helpers.GetStringList(cValue.Array())
+ } else {
+ item.MatchIpNextHopPrefixLists = types.ListNull(types.StringType)
+ }
+ if cValue := v.Get("match.ipv6.address.access-list"); cValue.Exists() {
+ item.MatchIpv6AddressAccessLists = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("match.ipv6.address.prefix-list"); cValue.Exists() {
+ item.MatchIpv6AddressPrefixLists = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("match.ipv6.next-hop.access-list"); cValue.Exists() {
+ item.MatchIpv6NextHopAccessLists = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("match.ipv6.next-hop.prefix-list"); cValue.Exists() {
+ item.MatchIpv6NextHopPrefixLists = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("match.route-type.external"); cValue.Exists() {
+ item.MatchRouteTypeExternal = types.BoolValue(true)
+ } else {
+ item.MatchRouteTypeExternal = types.BoolValue(false)
+ }
+ if cValue := v.Get("match.route-type.external.type-1"); cValue.Exists() {
+ item.MatchRouteTypeExternalType1 = types.BoolValue(true)
+ } else {
+ item.MatchRouteTypeExternalType1 = types.BoolValue(false)
+ }
+ if cValue := v.Get("match.route-type.external.type-2"); cValue.Exists() {
+ item.MatchRouteTypeExternalType2 = types.BoolValue(true)
+ } else {
+ item.MatchRouteTypeExternalType2 = types.BoolValue(false)
+ }
+ if cValue := v.Get("match.route-type.internal"); cValue.Exists() {
+ item.MatchRouteTypeInternal = types.BoolValue(true)
+ } else {
+ item.MatchRouteTypeInternal = types.BoolValue(false)
+ }
+ if cValue := v.Get("match.route-type.level-1"); cValue.Exists() {
+ item.MatchRouteTypeLevel1 = types.BoolValue(true)
+ } else {
+ item.MatchRouteTypeLevel1 = types.BoolValue(false)
+ }
+ if cValue := v.Get("match.route-type.level-2"); cValue.Exists() {
+ item.MatchRouteTypeLevel2 = types.BoolValue(true)
+ } else {
+ item.MatchRouteTypeLevel2 = types.BoolValue(false)
+ }
+ if cValue := v.Get("match.route-type.local"); cValue.Exists() {
+ item.MatchRouteTypeLocalLegacy = types.BoolValue(true)
+ } else {
+ item.MatchRouteTypeLocalLegacy = types.BoolValue(false)
+ }
+ if cValue := v.Get("match.Cisco-IOS-XE-bgp:bgp-route-map-match.route-type.local"); cValue.Exists() {
+ item.MatchRouteTypeLocal = types.BoolValue(true)
+ } else {
+ item.MatchRouteTypeLocal = types.BoolValue(false)
+ }
+ if cValue := v.Get("match.source-protocol.bgp"); cValue.Exists() {
+ item.MatchSourceProtocolBgp = helpers.GetStringList(cValue.Array())
+ } else {
+ item.MatchSourceProtocolBgp = types.ListNull(types.StringType)
+ }
+ if cValue := v.Get("match.source-protocol.connected"); cValue.Exists() {
+ item.MatchSourceProtocolConnected = types.BoolValue(true)
+ } else {
+ item.MatchSourceProtocolConnected = types.BoolValue(false)
+ }
+ if cValue := v.Get("match.source-protocol.eigrp"); cValue.Exists() {
+ item.MatchSourceProtocolEigrp = helpers.GetStringList(cValue.Array())
+ } else {
+ item.MatchSourceProtocolEigrp = types.ListNull(types.StringType)
+ }
+ if cValue := v.Get("match.source-protocol.isis"); cValue.Exists() {
+ item.MatchSourceProtocolIsis = types.BoolValue(true)
+ } else {
+ item.MatchSourceProtocolIsis = types.BoolValue(false)
+ }
+ if cValue := v.Get("match.source-protocol.lisp"); cValue.Exists() {
+ item.MatchSourceProtocolLisp = types.BoolValue(true)
+ } else {
+ item.MatchSourceProtocolLisp = types.BoolValue(false)
+ }
+ if cValue := v.Get("match.source-protocol.ospf"); cValue.Exists() {
+ item.MatchSourceProtocolOspf = helpers.GetStringList(cValue.Array())
+ } else {
+ item.MatchSourceProtocolOspf = types.ListNull(types.StringType)
+ }
+ if cValue := v.Get("match.source-protocol.ospfv3"); cValue.Exists() {
+ item.MatchSourceProtocolOspfv3 = helpers.GetStringList(cValue.Array())
+ } else {
+ item.MatchSourceProtocolOspfv3 = types.ListNull(types.StringType)
+ }
+ if cValue := v.Get("match.source-protocol.rip"); cValue.Exists() {
+ item.MatchSourceProtocolRip = types.BoolValue(true)
+ } else {
+ item.MatchSourceProtocolRip = types.BoolValue(false)
+ }
+ if cValue := v.Get("match.source-protocol.static"); cValue.Exists() {
+ item.MatchSourceProtocolStatic = types.BoolValue(true)
+ } else {
+ item.MatchSourceProtocolStatic = types.BoolValue(false)
+ }
+ if cValue := v.Get("match.tag.tag_value"); cValue.Exists() {
+ item.MatchTags = helpers.GetInt64List(cValue.Array())
+ } else {
+ item.MatchTags = types.ListNull(types.Int64Type)
+ }
+ if cValue := v.Get("match.track"); cValue.Exists() {
+ item.MatchTrack = types.Int64Value(cValue.Int())
+ }
+ if cValue := v.Get("match.as-path.access-list"); cValue.Exists() {
+ item.MatchAsPathsLegacy = helpers.GetInt64List(cValue.Array())
+ } else {
+ item.MatchAsPathsLegacy = types.ListNull(types.Int64Type)
+ }
+ if cValue := v.Get("match.community.name"); cValue.Exists() {
+ item.MatchCommunityListsLegacy = helpers.GetStringList(cValue.Array())
+ } else {
+ item.MatchCommunityListsLegacy = types.ListNull(types.StringType)
+ }
+ if cValue := v.Get("match.extcommunity.name"); cValue.Exists() {
+ item.MatchExtcommunityListsLegacy = helpers.GetStringList(cValue.Array())
+ } else {
+ item.MatchExtcommunityListsLegacy = types.ListNull(types.StringType)
+ }
+ if cValue := v.Get("match.local-preference.values"); cValue.Exists() {
+ item.MatchLocalPreferencesLegacy = helpers.GetInt64List(cValue.Array())
+ } else {
+ item.MatchLocalPreferencesLegacy = types.ListNull(types.Int64Type)
+ }
+ if cValue := v.Get("match.Cisco-IOS-XE-bgp:bgp-route-map-match.as-path.access-list"); cValue.Exists() {
+ item.MatchAsPaths = helpers.GetInt64List(cValue.Array())
+ } else {
+ item.MatchAsPaths = types.ListNull(types.Int64Type)
+ }
+ if cValue := v.Get("match.Cisco-IOS-XE-bgp:bgp-route-map-match.bgp-community.community-list"); cValue.Exists() {
+ item.MatchCommunityLists = helpers.GetStringList(cValue.Array())
+ } else {
+ item.MatchCommunityLists = types.ListNull(types.StringType)
+ }
+ if cValue := v.Get("match.Cisco-IOS-XE-bgp:bgp-route-map-match.bgp-community.exact-match"); cValue.Exists() {
+ item.MatchCommunityListExactMatch = types.BoolValue(true)
+ } else {
+ item.MatchCommunityListExactMatch = types.BoolValue(false)
+ }
+ if cValue := v.Get("match.Cisco-IOS-XE-bgp:bgp-route-map-match.extcommunity.extcommunity-list"); cValue.Exists() {
+ item.MatchExtcommunityLists = helpers.GetStringList(cValue.Array())
+ } else {
+ item.MatchExtcommunityLists = types.ListNull(types.StringType)
+ }
+ if cValue := v.Get("match.Cisco-IOS-XE-bgp:bgp-route-map-match.local-preference.values"); cValue.Exists() {
+ item.MatchLocalPreferences = helpers.GetInt64List(cValue.Array())
+ } else {
+ item.MatchLocalPreferences = types.ListNull(types.Int64Type)
+ }
+ if cValue := v.Get("set.default.interface-list"); cValue.Exists() {
+ item.SetDefaultInterfaces = helpers.GetStringList(cValue.Array())
+ } else {
+ item.SetDefaultInterfaces = types.ListNull(types.StringType)
+ }
+ if cValue := v.Get("set.global"); cValue.Exists() {
+ item.SetGlobal = types.BoolValue(true)
+ } else {
+ item.SetGlobal = types.BoolValue(false)
+ }
+ if cValue := v.Get("set.interface-list"); cValue.Exists() {
+ item.SetInterfaces = helpers.GetStringList(cValue.Array())
+ } else {
+ item.SetInterfaces = types.ListNull(types.StringType)
+ }
+ if cValue := v.Get("set.ip.address.prefix-list"); cValue.Exists() {
+ item.SetIpAddress = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("set.ip.default.global.next-hop.address"); cValue.Exists() {
+ item.SetIpDefaultGlobalNextHopAddress = helpers.GetStringList(cValue.Array())
+ } else {
+ item.SetIpDefaultGlobalNextHopAddress = types.ListNull(types.StringType)
+ }
+ if cValue := v.Get("set.ip.default.next-hop.address"); cValue.Exists() {
+ item.SetIpDefaultNextHopAddress = helpers.GetStringList(cValue.Array())
+ } else {
+ item.SetIpDefaultNextHopAddress = types.ListNull(types.StringType)
+ }
+ if cValue := v.Get("set.ip.global.next-hop.address"); cValue.Exists() {
+ item.SetIpGlobalNextHopAddress = helpers.GetStringList(cValue.Array())
+ } else {
+ item.SetIpGlobalNextHopAddress = types.ListNull(types.StringType)
+ }
+ if cValue := v.Get("set.ip.next-hop.address"); cValue.Exists() {
+ item.SetIpNextHopAddress = helpers.GetStringList(cValue.Array())
+ } else {
+ item.SetIpNextHopAddress = types.ListNull(types.StringType)
+ }
+ if cValue := v.Get("set.ip.next-hop.self"); cValue.Exists() {
+ item.SetIpNextHopSelf = types.BoolValue(true)
+ } else {
+ item.SetIpNextHopSelf = types.BoolValue(false)
+ }
+ if cValue := v.Get("set.ip.qos-group.qos-id"); cValue.Exists() {
+ item.SetIpQosGroup = types.Int64Value(cValue.Int())
+ }
+ if cValue := v.Get("set.ipv6.address.prefix-list"); cValue.Exists() {
+ item.SetIpv6Address = helpers.GetStringList(cValue.Array())
+ } else {
+ item.SetIpv6Address = types.ListNull(types.StringType)
+ }
+ if cValue := v.Get("set.ipv6.default.global.next-hop"); cValue.Exists() {
+ item.SetIpv6DefaultGlobalNextHop = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("set.ipv6.default.next-hop.ipv6"); cValue.Exists() {
+ item.SetIpv6DefaultNextHop = helpers.GetStringList(cValue.Array())
+ } else {
+ item.SetIpv6DefaultNextHop = types.ListNull(types.StringType)
+ }
+ if cValue := v.Get("set.ipv6.next-hop.ipv6"); cValue.Exists() {
+ item.SetIpv6NextHop = helpers.GetStringList(cValue.Array())
+ } else {
+ item.SetIpv6NextHop = types.ListNull(types.StringType)
+ }
+ if cValue := v.Get("set.level.level-1"); cValue.Exists() {
+ item.SetLevel1 = types.BoolValue(true)
+ } else {
+ item.SetLevel1 = types.BoolValue(false)
+ }
+ if cValue := v.Get("set.level.level-1-2"); cValue.Exists() {
+ item.SetLevel12 = types.BoolValue(true)
+ } else {
+ item.SetLevel12 = types.BoolValue(false)
+ }
+ if cValue := v.Get("set.level.level-2"); cValue.Exists() {
+ item.SetLevel2 = types.BoolValue(true)
+ } else {
+ item.SetLevel2 = types.BoolValue(false)
+ }
+ if cValue := v.Get("set.metric.metric-change"); cValue.Exists() {
+ item.SetMetricChange = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("set.metric.values.value"); cValue.Exists() {
+ item.SetMetricValue = types.Int64Value(cValue.Int())
+ }
+ if cValue := v.Get("set.metric.values.delay"); cValue.Exists() {
+ item.SetMetricDelay = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("set.metric.values.reliability"); cValue.Exists() {
+ item.SetMetricReliability = types.Int64Value(cValue.Int())
+ }
+ if cValue := v.Get("set.metric.values.loading"); cValue.Exists() {
+ item.SetMetricLoading = types.Int64Value(cValue.Int())
+ }
+ if cValue := v.Get("set.metric.values.MTU"); cValue.Exists() {
+ item.SetMetricMtu = types.Int64Value(cValue.Int())
+ }
+ if cValue := v.Get("set.metric-type"); cValue.Exists() {
+ item.SetMetricType = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("set.tag.tag-val"); cValue.Exists() {
+ item.SetTag = types.Int64Value(cValue.Int())
+ }
+ if cValue := v.Get("set.vrf"); cValue.Exists() {
+ item.SetVrf = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("set.as-path.prepend.as-container.as-number"); cValue.Exists() {
+ item.SetAsPathPrependAsLegacy = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("set.as-path.prepend.last-as-cont.last-as"); cValue.Exists() {
+ item.SetAsPathPrependLastAsLegacy = types.Int64Value(cValue.Int())
+ }
+ if cValue := v.Get("set.as-path.tag"); cValue.Exists() {
+ item.SetAsPathTagLegacy = types.BoolValue(true)
+ } else {
+ item.SetAsPathTagLegacy = types.BoolValue(false)
+ }
+ if cValue := v.Get("set.community.none"); cValue.Exists() {
+ item.SetCommunityNoneLegacy = types.BoolValue(true)
+ } else {
+ item.SetCommunityNoneLegacy = types.BoolValue(false)
+ }
+ if cValue := v.Get("set.community.community-well-known.community-list"); cValue.Exists() {
+ item.SetCommunitiesLegacy = helpers.GetStringList(cValue.Array())
+ } else {
+ item.SetCommunitiesLegacy = types.ListNull(types.StringType)
+ }
+ if cValue := v.Get("set.community.community-well-known.additive"); cValue.Exists() {
+ item.SetCommunitiesAdditiveLegacy = types.BoolValue(true)
+ } else {
+ item.SetCommunitiesAdditiveLegacy = types.BoolValue(false)
+ }
+ if cValue := v.Get("set.comm-list.delete"); cValue.Exists() {
+ item.SetCommunityListDeleteLegacy = types.BoolValue(true)
+ } else {
+ item.SetCommunityListDeleteLegacy = types.BoolValue(false)
+ }
+ if cValue := v.Get("set.comm-list.comm-list-standard"); cValue.Exists() {
+ item.SetCommunityListStandardLegacy = types.Int64Value(cValue.Int())
+ }
+ if cValue := v.Get("set.Cisco-IOS-XE-bgp:bgp-route-map-set.comm-list.comm-list-expanded"); cValue.Exists() {
+ item.SetCommunityListExpandedLegacy = types.Int64Value(cValue.Int())
+ }
+ if cValue := v.Get("set.comm-list.comm-list-name"); cValue.Exists() {
+ item.SetCommunityListNameLegacy = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("set.extcommunity.rt.asn-nn"); cValue.Exists() {
+ item.SetExtcomunityRtLegacy = helpers.GetStringList(cValue.Array())
+ } else {
+ item.SetExtcomunityRtLegacy = types.ListNull(types.StringType)
+ }
+ if cValue := v.Get("set.extcommunity.soo.asn-nn"); cValue.Exists() {
+ item.SetExtcomunitySooLegacy = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("set.extcommunity.vpn-distinguisher.asn-nn"); cValue.Exists() {
+ item.SetExtcomunityVpnDistinguisherLegacy = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("set.local-preference"); cValue.Exists() {
+ item.SetLocalPreferenceLegacy = types.Int64Value(cValue.Int())
+ }
+ if cValue := v.Get("set.weight"); cValue.Exists() {
+ item.SetWeightLegacy = types.Int64Value(cValue.Int())
+ }
+ if cValue := v.Get("set.Cisco-IOS-XE-bgp:bgp-route-map-set.as-path.prepend.as-container.as-number"); cValue.Exists() {
+ item.SetAsPathPrependAs = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("set.Cisco-IOS-XE-bgp:bgp-route-map-set.as-path.prepend.last-as-cont.last-as"); cValue.Exists() {
+ item.SetAsPathPrependLastAs = types.Int64Value(cValue.Int())
+ }
+ if cValue := v.Get("set.Cisco-IOS-XE-bgp:bgp-route-map-set.as-path.tag"); cValue.Exists() {
+ item.SetAsPathTag = types.BoolValue(true)
+ } else {
+ item.SetAsPathTag = types.BoolValue(false)
+ }
+ if cValue := v.Get("set.Cisco-IOS-XE-bgp:bgp-route-map-set.as-path.replace.any"); cValue.Exists() {
+ item.SetAsPathReplaceAny = types.BoolValue(true)
+ } else {
+ item.SetAsPathReplaceAny = types.BoolValue(false)
}
if cValue := v.Get("set.Cisco-IOS-XE-bgp:bgp-route-map-set.as-path.replace.as-container"); cValue.Exists() {
item.SetAsPathReplaceAs = make([]RouteMapEntriesSetAsPathReplaceAs, 0)
- cValue.ForEach(func(ck, cv gjson.Result) bool {
+ cValue.ForEach(func(ck, cv gjson.Result) bool {
+ cItem := RouteMapEntriesSetAsPathReplaceAs{}
+ if ccValue := cv.Get("as-number"); ccValue.Exists() {
+ cItem.AsNumber = types.StringValue(ccValue.String())
+ }
+ item.SetAsPathReplaceAs = append(item.SetAsPathReplaceAs, cItem)
+ return true
+ })
+ }
+ if cValue := v.Get("set.Cisco-IOS-XE-bgp:bgp-route-map-set.bgp-community.none"); cValue.Exists() {
+ item.SetCommunityNone = types.BoolValue(true)
+ } else {
+ item.SetCommunityNone = types.BoolValue(false)
+ }
+ if cValue := v.Get("set.Cisco-IOS-XE-bgp:bgp-route-map-set.bgp-community.community-well-known.community-list"); cValue.Exists() {
+ item.SetCommunities = helpers.GetStringList(cValue.Array())
+ } else {
+ item.SetCommunities = types.ListNull(types.StringType)
+ }
+ if cValue := v.Get("set.Cisco-IOS-XE-bgp:bgp-route-map-set.bgp-community.community-well-known.additive"); cValue.Exists() {
+ item.SetCommunitiesAdditive = types.BoolValue(true)
+ } else {
+ item.SetCommunitiesAdditive = types.BoolValue(false)
+ }
+ if cValue := v.Get("set.Cisco-IOS-XE-bgp:bgp-route-map-set.comm-list.delete"); cValue.Exists() {
+ item.SetCommunityListDelete = types.BoolValue(true)
+ } else {
+ item.SetCommunityListDelete = types.BoolValue(false)
+ }
+ if cValue := v.Get("set.Cisco-IOS-XE-bgp:bgp-route-map-set.comm-list.comm-list-standard"); cValue.Exists() {
+ item.SetCommunityListStandard = types.Int64Value(cValue.Int())
+ }
+ if cValue := v.Get("set.Cisco-IOS-XE-bgp:bgp-route-map-set.comm-list.comm-list-expanded"); cValue.Exists() {
+ item.SetCommunityListExpanded = types.Int64Value(cValue.Int())
+ }
+ if cValue := v.Get("set.Cisco-IOS-XE-bgp:bgp-route-map-set.comm-list.comm-list-name"); cValue.Exists() {
+ item.SetCommunityListName = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("set.Cisco-IOS-XE-bgp:bgp-route-map-set.extcommunity.rt.asn-nn"); cValue.Exists() {
+ item.SetExtcomunityRt = helpers.GetStringList(cValue.Array())
+ } else {
+ item.SetExtcomunityRt = types.ListNull(types.StringType)
+ }
+ if cValue := v.Get("set.Cisco-IOS-XE-bgp:bgp-route-map-set.extcommunity.soo.asn-nn"); cValue.Exists() {
+ item.SetExtcomunitySoo = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("set.Cisco-IOS-XE-bgp:bgp-route-map-set.extcommunity.vpn-distinguisher.asn-nn"); cValue.Exists() {
+ item.SetExtcomunityVpnDistinguisher = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("set.Cisco-IOS-XE-bgp:bgp-route-map-set.extcommunity.vpn-distinguisher.asn-nn-additive"); cValue.Exists() {
+ item.SetExtcomunityVpnDistinguisherAdditive = types.BoolValue(true)
+ } else {
+ item.SetExtcomunityVpnDistinguisherAdditive = types.BoolValue(false)
+ }
+ if cValue := v.Get("set.Cisco-IOS-XE-bgp:bgp-route-map-set.local-preference"); cValue.Exists() {
+ item.SetLocalPreference = types.Int64Value(cValue.Int())
+ }
+ if cValue := v.Get("set.Cisco-IOS-XE-bgp:bgp-route-map-set.weight"); cValue.Exists() {
+ item.SetWeight = types.Int64Value(cValue.Int())
+ }
+ data.Entries = append(data.Entries, item)
+ return true
+ })
+ }
+}
+
+// End of section. //template:end fromBodyData
+
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyXML
+
+func (data *RouteMap) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-route-map:route-map-without-order-seq"); value.Exists() {
+ data.Entries = make([]RouteMapEntries, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := RouteMapEntries{}
+ if cValue := helpers.GetFromXPath(v, "seq_no"); cValue.Exists() {
+ item.Seq = types.Int64Value(cValue.Int())
+ }
+ if cValue := helpers.GetFromXPath(v, "operation"); cValue.Exists() {
+ item.Operation = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "description"); cValue.Exists() {
+ item.Description = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "continue"); cValue.Exists() {
+ item.Continue = types.BoolValue(true)
+ } else {
+ item.Continue = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "continue/sequence-number"); cValue.Exists() {
+ item.ContinueSequenceNumber = types.Int64Value(cValue.Int())
+ }
+ if cValue := helpers.GetFromXPath(v, "match/interface/interface"); cValue.Exists() {
+ item.MatchInterfaces = helpers.GetStringListXML(cValue.Array())
+ } else {
+ item.MatchInterfaces = types.ListNull(types.StringType)
+ }
+ if cValue := helpers.GetFromXPath(v, "match/ip/address/access-list"); cValue.Exists() {
+ item.MatchIpAddressAccessLists = helpers.GetStringListXML(cValue.Array())
+ } else {
+ item.MatchIpAddressAccessLists = types.ListNull(types.StringType)
+ }
+ if cValue := helpers.GetFromXPath(v, "match/ip/address/prefix-list"); cValue.Exists() {
+ item.MatchIpAddressPrefixLists = helpers.GetStringListXML(cValue.Array())
+ } else {
+ item.MatchIpAddressPrefixLists = types.ListNull(types.StringType)
+ }
+ if cValue := helpers.GetFromXPath(v, "match/ip/next-hop/access-list"); cValue.Exists() {
+ item.MatchIpNextHopAccessLists = helpers.GetStringListXML(cValue.Array())
+ } else {
+ item.MatchIpNextHopAccessLists = types.ListNull(types.StringType)
+ }
+ if cValue := helpers.GetFromXPath(v, "match/ip/next-hop/prefix-list"); cValue.Exists() {
+ item.MatchIpNextHopPrefixLists = helpers.GetStringListXML(cValue.Array())
+ } else {
+ item.MatchIpNextHopPrefixLists = types.ListNull(types.StringType)
+ }
+ if cValue := helpers.GetFromXPath(v, "match/ipv6/address/access-list"); cValue.Exists() {
+ item.MatchIpv6AddressAccessLists = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "match/ipv6/address/prefix-list"); cValue.Exists() {
+ item.MatchIpv6AddressPrefixLists = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "match/ipv6/next-hop/access-list"); cValue.Exists() {
+ item.MatchIpv6NextHopAccessLists = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "match/ipv6/next-hop/prefix-list"); cValue.Exists() {
+ item.MatchIpv6NextHopPrefixLists = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "match/route-type/external"); cValue.Exists() {
+ item.MatchRouteTypeExternal = types.BoolValue(true)
+ } else {
+ item.MatchRouteTypeExternal = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "match/route-type/external/type-1"); cValue.Exists() {
+ item.MatchRouteTypeExternalType1 = types.BoolValue(true)
+ } else {
+ item.MatchRouteTypeExternalType1 = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "match/route-type/external/type-2"); cValue.Exists() {
+ item.MatchRouteTypeExternalType2 = types.BoolValue(true)
+ } else {
+ item.MatchRouteTypeExternalType2 = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "match/route-type/internal"); cValue.Exists() {
+ item.MatchRouteTypeInternal = types.BoolValue(true)
+ } else {
+ item.MatchRouteTypeInternal = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "match/route-type/level-1"); cValue.Exists() {
+ item.MatchRouteTypeLevel1 = types.BoolValue(true)
+ } else {
+ item.MatchRouteTypeLevel1 = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "match/route-type/level-2"); cValue.Exists() {
+ item.MatchRouteTypeLevel2 = types.BoolValue(true)
+ } else {
+ item.MatchRouteTypeLevel2 = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "match/route-type/local"); cValue.Exists() {
+ item.MatchRouteTypeLocalLegacy = types.BoolValue(true)
+ } else {
+ item.MatchRouteTypeLocalLegacy = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "match/Cisco-IOS-XE-bgp:bgp-route-map-match/route-type/local"); cValue.Exists() {
+ item.MatchRouteTypeLocal = types.BoolValue(true)
+ } else {
+ item.MatchRouteTypeLocal = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "match/source-protocol/bgp"); cValue.Exists() {
+ item.MatchSourceProtocolBgp = helpers.GetStringListXML(cValue.Array())
+ } else {
+ item.MatchSourceProtocolBgp = types.ListNull(types.StringType)
+ }
+ if cValue := helpers.GetFromXPath(v, "match/source-protocol/connected"); cValue.Exists() {
+ item.MatchSourceProtocolConnected = types.BoolValue(true)
+ } else {
+ item.MatchSourceProtocolConnected = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "match/source-protocol/eigrp"); cValue.Exists() {
+ item.MatchSourceProtocolEigrp = helpers.GetStringListXML(cValue.Array())
+ } else {
+ item.MatchSourceProtocolEigrp = types.ListNull(types.StringType)
+ }
+ if cValue := helpers.GetFromXPath(v, "match/source-protocol/isis"); cValue.Exists() {
+ item.MatchSourceProtocolIsis = types.BoolValue(true)
+ } else {
+ item.MatchSourceProtocolIsis = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "match/source-protocol/lisp"); cValue.Exists() {
+ item.MatchSourceProtocolLisp = types.BoolValue(true)
+ } else {
+ item.MatchSourceProtocolLisp = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "match/source-protocol/ospf"); cValue.Exists() {
+ item.MatchSourceProtocolOspf = helpers.GetStringListXML(cValue.Array())
+ } else {
+ item.MatchSourceProtocolOspf = types.ListNull(types.StringType)
+ }
+ if cValue := helpers.GetFromXPath(v, "match/source-protocol/ospfv3"); cValue.Exists() {
+ item.MatchSourceProtocolOspfv3 = helpers.GetStringListXML(cValue.Array())
+ } else {
+ item.MatchSourceProtocolOspfv3 = types.ListNull(types.StringType)
+ }
+ if cValue := helpers.GetFromXPath(v, "match/source-protocol/rip"); cValue.Exists() {
+ item.MatchSourceProtocolRip = types.BoolValue(true)
+ } else {
+ item.MatchSourceProtocolRip = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "match/source-protocol/static"); cValue.Exists() {
+ item.MatchSourceProtocolStatic = types.BoolValue(true)
+ } else {
+ item.MatchSourceProtocolStatic = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "match/tag/tag_value"); cValue.Exists() {
+ item.MatchTags = helpers.GetInt64ListXML(cValue.Array())
+ } else {
+ item.MatchTags = types.ListNull(types.Int64Type)
+ }
+ if cValue := helpers.GetFromXPath(v, "match/track"); cValue.Exists() {
+ item.MatchTrack = types.Int64Value(cValue.Int())
+ }
+ if cValue := helpers.GetFromXPath(v, "match/as-path/access-list"); cValue.Exists() {
+ item.MatchAsPathsLegacy = helpers.GetInt64ListXML(cValue.Array())
+ } else {
+ item.MatchAsPathsLegacy = types.ListNull(types.Int64Type)
+ }
+ if cValue := helpers.GetFromXPath(v, "match/community/name"); cValue.Exists() {
+ item.MatchCommunityListsLegacy = helpers.GetStringListXML(cValue.Array())
+ } else {
+ item.MatchCommunityListsLegacy = types.ListNull(types.StringType)
+ }
+ if cValue := helpers.GetFromXPath(v, "match/extcommunity/name"); cValue.Exists() {
+ item.MatchExtcommunityListsLegacy = helpers.GetStringListXML(cValue.Array())
+ } else {
+ item.MatchExtcommunityListsLegacy = types.ListNull(types.StringType)
+ }
+ if cValue := helpers.GetFromXPath(v, "match/local-preference/values"); cValue.Exists() {
+ item.MatchLocalPreferencesLegacy = helpers.GetInt64ListXML(cValue.Array())
+ } else {
+ item.MatchLocalPreferencesLegacy = types.ListNull(types.Int64Type)
+ }
+ if cValue := helpers.GetFromXPath(v, "match/Cisco-IOS-XE-bgp:bgp-route-map-match/as-path/access-list"); cValue.Exists() {
+ item.MatchAsPaths = helpers.GetInt64ListXML(cValue.Array())
+ } else {
+ item.MatchAsPaths = types.ListNull(types.Int64Type)
+ }
+ if cValue := helpers.GetFromXPath(v, "match/Cisco-IOS-XE-bgp:bgp-route-map-match/bgp-community/community-list"); cValue.Exists() {
+ item.MatchCommunityLists = helpers.GetStringListXML(cValue.Array())
+ } else {
+ item.MatchCommunityLists = types.ListNull(types.StringType)
+ }
+ if cValue := helpers.GetFromXPath(v, "match/Cisco-IOS-XE-bgp:bgp-route-map-match/bgp-community/exact-match"); cValue.Exists() {
+ item.MatchCommunityListExactMatch = types.BoolValue(true)
+ } else {
+ item.MatchCommunityListExactMatch = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "match/Cisco-IOS-XE-bgp:bgp-route-map-match/extcommunity/extcommunity-list"); cValue.Exists() {
+ item.MatchExtcommunityLists = helpers.GetStringListXML(cValue.Array())
+ } else {
+ item.MatchExtcommunityLists = types.ListNull(types.StringType)
+ }
+ if cValue := helpers.GetFromXPath(v, "match/Cisco-IOS-XE-bgp:bgp-route-map-match/local-preference/values"); cValue.Exists() {
+ item.MatchLocalPreferences = helpers.GetInt64ListXML(cValue.Array())
+ } else {
+ item.MatchLocalPreferences = types.ListNull(types.Int64Type)
+ }
+ if cValue := helpers.GetFromXPath(v, "set/default/interface-list"); cValue.Exists() {
+ item.SetDefaultInterfaces = helpers.GetStringListXML(cValue.Array())
+ } else {
+ item.SetDefaultInterfaces = types.ListNull(types.StringType)
+ }
+ if cValue := helpers.GetFromXPath(v, "set/global"); cValue.Exists() {
+ item.SetGlobal = types.BoolValue(true)
+ } else {
+ item.SetGlobal = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "set/interface-list"); cValue.Exists() {
+ item.SetInterfaces = helpers.GetStringListXML(cValue.Array())
+ } else {
+ item.SetInterfaces = types.ListNull(types.StringType)
+ }
+ if cValue := helpers.GetFromXPath(v, "set/ip/address/prefix-list"); cValue.Exists() {
+ item.SetIpAddress = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "set/ip/default/global/next-hop/address"); cValue.Exists() {
+ item.SetIpDefaultGlobalNextHopAddress = helpers.GetStringListXML(cValue.Array())
+ } else {
+ item.SetIpDefaultGlobalNextHopAddress = types.ListNull(types.StringType)
+ }
+ if cValue := helpers.GetFromXPath(v, "set/ip/default/next-hop/address"); cValue.Exists() {
+ item.SetIpDefaultNextHopAddress = helpers.GetStringListXML(cValue.Array())
+ } else {
+ item.SetIpDefaultNextHopAddress = types.ListNull(types.StringType)
+ }
+ if cValue := helpers.GetFromXPath(v, "set/ip/global/next-hop/address"); cValue.Exists() {
+ item.SetIpGlobalNextHopAddress = helpers.GetStringListXML(cValue.Array())
+ } else {
+ item.SetIpGlobalNextHopAddress = types.ListNull(types.StringType)
+ }
+ if cValue := helpers.GetFromXPath(v, "set/ip/next-hop/address"); cValue.Exists() {
+ item.SetIpNextHopAddress = helpers.GetStringListXML(cValue.Array())
+ } else {
+ item.SetIpNextHopAddress = types.ListNull(types.StringType)
+ }
+ if cValue := helpers.GetFromXPath(v, "set/ip/next-hop/self"); cValue.Exists() {
+ item.SetIpNextHopSelf = types.BoolValue(true)
+ } else {
+ item.SetIpNextHopSelf = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "set/ip/qos-group/qos-id"); cValue.Exists() {
+ item.SetIpQosGroup = types.Int64Value(cValue.Int())
+ }
+ if cValue := helpers.GetFromXPath(v, "set/ipv6/address/prefix-list"); cValue.Exists() {
+ item.SetIpv6Address = helpers.GetStringListXML(cValue.Array())
+ } else {
+ item.SetIpv6Address = types.ListNull(types.StringType)
+ }
+ if cValue := helpers.GetFromXPath(v, "set/ipv6/default/global/next-hop"); cValue.Exists() {
+ item.SetIpv6DefaultGlobalNextHop = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "set/ipv6/default/next-hop/ipv6"); cValue.Exists() {
+ item.SetIpv6DefaultNextHop = helpers.GetStringListXML(cValue.Array())
+ } else {
+ item.SetIpv6DefaultNextHop = types.ListNull(types.StringType)
+ }
+ if cValue := helpers.GetFromXPath(v, "set/ipv6/next-hop/ipv6"); cValue.Exists() {
+ item.SetIpv6NextHop = helpers.GetStringListXML(cValue.Array())
+ } else {
+ item.SetIpv6NextHop = types.ListNull(types.StringType)
+ }
+ if cValue := helpers.GetFromXPath(v, "set/level/level-1"); cValue.Exists() {
+ item.SetLevel1 = types.BoolValue(true)
+ } else {
+ item.SetLevel1 = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "set/level/level-1-2"); cValue.Exists() {
+ item.SetLevel12 = types.BoolValue(true)
+ } else {
+ item.SetLevel12 = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "set/level/level-2"); cValue.Exists() {
+ item.SetLevel2 = types.BoolValue(true)
+ } else {
+ item.SetLevel2 = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "set/metric/metric-change"); cValue.Exists() {
+ item.SetMetricChange = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "set/metric/values/value"); cValue.Exists() {
+ item.SetMetricValue = types.Int64Value(cValue.Int())
+ }
+ if cValue := helpers.GetFromXPath(v, "set/metric/values/delay"); cValue.Exists() {
+ item.SetMetricDelay = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "set/metric/values/reliability"); cValue.Exists() {
+ item.SetMetricReliability = types.Int64Value(cValue.Int())
+ }
+ if cValue := helpers.GetFromXPath(v, "set/metric/values/loading"); cValue.Exists() {
+ item.SetMetricLoading = types.Int64Value(cValue.Int())
+ }
+ if cValue := helpers.GetFromXPath(v, "set/metric/values/MTU"); cValue.Exists() {
+ item.SetMetricMtu = types.Int64Value(cValue.Int())
+ }
+ if cValue := helpers.GetFromXPath(v, "set/metric-type"); cValue.Exists() {
+ item.SetMetricType = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "set/tag/tag-val"); cValue.Exists() {
+ item.SetTag = types.Int64Value(cValue.Int())
+ }
+ if cValue := helpers.GetFromXPath(v, "set/vrf"); cValue.Exists() {
+ item.SetVrf = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "set/as-path/prepend/as-container/as-number"); cValue.Exists() {
+ item.SetAsPathPrependAsLegacy = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "set/as-path/prepend/last-as-cont/last-as"); cValue.Exists() {
+ item.SetAsPathPrependLastAsLegacy = types.Int64Value(cValue.Int())
+ }
+ if cValue := helpers.GetFromXPath(v, "set/as-path/tag"); cValue.Exists() {
+ item.SetAsPathTagLegacy = types.BoolValue(true)
+ } else {
+ item.SetAsPathTagLegacy = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "set/community/none"); cValue.Exists() {
+ item.SetCommunityNoneLegacy = types.BoolValue(true)
+ } else {
+ item.SetCommunityNoneLegacy = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "set/community/community-well-known/community-list"); cValue.Exists() {
+ item.SetCommunitiesLegacy = helpers.GetStringListXML(cValue.Array())
+ } else {
+ item.SetCommunitiesLegacy = types.ListNull(types.StringType)
+ }
+ if cValue := helpers.GetFromXPath(v, "set/community/community-well-known/additive"); cValue.Exists() {
+ item.SetCommunitiesAdditiveLegacy = types.BoolValue(true)
+ } else {
+ item.SetCommunitiesAdditiveLegacy = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "set/comm-list/delete"); cValue.Exists() {
+ item.SetCommunityListDeleteLegacy = types.BoolValue(true)
+ } else {
+ item.SetCommunityListDeleteLegacy = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "set/comm-list/comm-list-standard"); cValue.Exists() {
+ item.SetCommunityListStandardLegacy = types.Int64Value(cValue.Int())
+ }
+ if cValue := helpers.GetFromXPath(v, "set/Cisco-IOS-XE-bgp:bgp-route-map-set/comm-list/comm-list-expanded"); cValue.Exists() {
+ item.SetCommunityListExpandedLegacy = types.Int64Value(cValue.Int())
+ }
+ if cValue := helpers.GetFromXPath(v, "set/comm-list/comm-list-name"); cValue.Exists() {
+ item.SetCommunityListNameLegacy = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "set/extcommunity/rt/asn-nn"); cValue.Exists() {
+ item.SetExtcomunityRtLegacy = helpers.GetStringListXML(cValue.Array())
+ } else {
+ item.SetExtcomunityRtLegacy = types.ListNull(types.StringType)
+ }
+ if cValue := helpers.GetFromXPath(v, "set/extcommunity/soo/asn-nn"); cValue.Exists() {
+ item.SetExtcomunitySooLegacy = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "set/extcommunity/vpn-distinguisher/asn-nn"); cValue.Exists() {
+ item.SetExtcomunityVpnDistinguisherLegacy = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "set/local-preference"); cValue.Exists() {
+ item.SetLocalPreferenceLegacy = types.Int64Value(cValue.Int())
+ }
+ if cValue := helpers.GetFromXPath(v, "set/weight"); cValue.Exists() {
+ item.SetWeightLegacy = types.Int64Value(cValue.Int())
+ }
+ if cValue := helpers.GetFromXPath(v, "set/Cisco-IOS-XE-bgp:bgp-route-map-set/as-path/prepend/as-container/as-number"); cValue.Exists() {
+ item.SetAsPathPrependAs = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "set/Cisco-IOS-XE-bgp:bgp-route-map-set/as-path/prepend/last-as-cont/last-as"); cValue.Exists() {
+ item.SetAsPathPrependLastAs = types.Int64Value(cValue.Int())
+ }
+ if cValue := helpers.GetFromXPath(v, "set/Cisco-IOS-XE-bgp:bgp-route-map-set/as-path/tag"); cValue.Exists() {
+ item.SetAsPathTag = types.BoolValue(true)
+ } else {
+ item.SetAsPathTag = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "set/Cisco-IOS-XE-bgp:bgp-route-map-set/as-path/replace/any"); cValue.Exists() {
+ item.SetAsPathReplaceAny = types.BoolValue(true)
+ } else {
+ item.SetAsPathReplaceAny = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "set/Cisco-IOS-XE-bgp:bgp-route-map-set/as-path/replace/as-container"); cValue.Exists() {
+ item.SetAsPathReplaceAs = make([]RouteMapEntriesSetAsPathReplaceAs, 0)
+ cValue.ForEach(func(_ int, cv xmldot.Result) bool {
+ cItem := RouteMapEntriesSetAsPathReplaceAs{}
+ if ccValue := helpers.GetFromXPath(cv, "as-number"); ccValue.Exists() {
+ cItem.AsNumber = types.StringValue(ccValue.String())
+ }
+ item.SetAsPathReplaceAs = append(item.SetAsPathReplaceAs, cItem)
+ return true
+ })
+ }
+ if cValue := helpers.GetFromXPath(v, "set/Cisco-IOS-XE-bgp:bgp-route-map-set/bgp-community/none"); cValue.Exists() {
+ item.SetCommunityNone = types.BoolValue(true)
+ } else {
+ item.SetCommunityNone = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "set/Cisco-IOS-XE-bgp:bgp-route-map-set/bgp-community/community-well-known/community-list"); cValue.Exists() {
+ item.SetCommunities = helpers.GetStringListXML(cValue.Array())
+ } else {
+ item.SetCommunities = types.ListNull(types.StringType)
+ }
+ if cValue := helpers.GetFromXPath(v, "set/Cisco-IOS-XE-bgp:bgp-route-map-set/bgp-community/community-well-known/additive"); cValue.Exists() {
+ item.SetCommunitiesAdditive = types.BoolValue(true)
+ } else {
+ item.SetCommunitiesAdditive = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "set/Cisco-IOS-XE-bgp:bgp-route-map-set/comm-list/delete"); cValue.Exists() {
+ item.SetCommunityListDelete = types.BoolValue(true)
+ } else {
+ item.SetCommunityListDelete = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "set/Cisco-IOS-XE-bgp:bgp-route-map-set/comm-list/comm-list-standard"); cValue.Exists() {
+ item.SetCommunityListStandard = types.Int64Value(cValue.Int())
+ }
+ if cValue := helpers.GetFromXPath(v, "set/Cisco-IOS-XE-bgp:bgp-route-map-set/comm-list/comm-list-expanded"); cValue.Exists() {
+ item.SetCommunityListExpanded = types.Int64Value(cValue.Int())
+ }
+ if cValue := helpers.GetFromXPath(v, "set/Cisco-IOS-XE-bgp:bgp-route-map-set/comm-list/comm-list-name"); cValue.Exists() {
+ item.SetCommunityListName = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "set/Cisco-IOS-XE-bgp:bgp-route-map-set/extcommunity/rt/asn-nn"); cValue.Exists() {
+ item.SetExtcomunityRt = helpers.GetStringListXML(cValue.Array())
+ } else {
+ item.SetExtcomunityRt = types.ListNull(types.StringType)
+ }
+ if cValue := helpers.GetFromXPath(v, "set/Cisco-IOS-XE-bgp:bgp-route-map-set/extcommunity/soo/asn-nn"); cValue.Exists() {
+ item.SetExtcomunitySoo = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "set/Cisco-IOS-XE-bgp:bgp-route-map-set/extcommunity/vpn-distinguisher/asn-nn"); cValue.Exists() {
+ item.SetExtcomunityVpnDistinguisher = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "set/Cisco-IOS-XE-bgp:bgp-route-map-set/extcommunity/vpn-distinguisher/asn-nn-additive"); cValue.Exists() {
+ item.SetExtcomunityVpnDistinguisherAdditive = types.BoolValue(true)
+ } else {
+ item.SetExtcomunityVpnDistinguisherAdditive = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "set/Cisco-IOS-XE-bgp:bgp-route-map-set/local-preference"); cValue.Exists() {
+ item.SetLocalPreference = types.Int64Value(cValue.Int())
+ }
+ if cValue := helpers.GetFromXPath(v, "set/Cisco-IOS-XE-bgp:bgp-route-map-set/weight"); cValue.Exists() {
+ item.SetWeight = types.Int64Value(cValue.Int())
+ }
+ data.Entries = append(data.Entries, item)
+ return true
+ })
+ }
+}
+
+// End of section. //template:end fromBodyXML
+
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyDataXML
+
+func (data *RouteMapData) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-route-map:route-map-without-order-seq"); value.Exists() {
+ data.Entries = make([]RouteMapEntries, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := RouteMapEntries{}
+ if cValue := helpers.GetFromXPath(v, "seq_no"); cValue.Exists() {
+ item.Seq = types.Int64Value(cValue.Int())
+ }
+ if cValue := helpers.GetFromXPath(v, "operation"); cValue.Exists() {
+ item.Operation = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "description"); cValue.Exists() {
+ item.Description = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "continue"); cValue.Exists() {
+ item.Continue = types.BoolValue(true)
+ } else {
+ item.Continue = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "continue/sequence-number"); cValue.Exists() {
+ item.ContinueSequenceNumber = types.Int64Value(cValue.Int())
+ }
+ if cValue := helpers.GetFromXPath(v, "match/interface/interface"); cValue.Exists() {
+ item.MatchInterfaces = helpers.GetStringListXML(cValue.Array())
+ } else {
+ item.MatchInterfaces = types.ListNull(types.StringType)
+ }
+ if cValue := helpers.GetFromXPath(v, "match/ip/address/access-list"); cValue.Exists() {
+ item.MatchIpAddressAccessLists = helpers.GetStringListXML(cValue.Array())
+ } else {
+ item.MatchIpAddressAccessLists = types.ListNull(types.StringType)
+ }
+ if cValue := helpers.GetFromXPath(v, "match/ip/address/prefix-list"); cValue.Exists() {
+ item.MatchIpAddressPrefixLists = helpers.GetStringListXML(cValue.Array())
+ } else {
+ item.MatchIpAddressPrefixLists = types.ListNull(types.StringType)
+ }
+ if cValue := helpers.GetFromXPath(v, "match/ip/next-hop/access-list"); cValue.Exists() {
+ item.MatchIpNextHopAccessLists = helpers.GetStringListXML(cValue.Array())
+ } else {
+ item.MatchIpNextHopAccessLists = types.ListNull(types.StringType)
+ }
+ if cValue := helpers.GetFromXPath(v, "match/ip/next-hop/prefix-list"); cValue.Exists() {
+ item.MatchIpNextHopPrefixLists = helpers.GetStringListXML(cValue.Array())
+ } else {
+ item.MatchIpNextHopPrefixLists = types.ListNull(types.StringType)
+ }
+ if cValue := helpers.GetFromXPath(v, "match/ipv6/address/access-list"); cValue.Exists() {
+ item.MatchIpv6AddressAccessLists = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "match/ipv6/address/prefix-list"); cValue.Exists() {
+ item.MatchIpv6AddressPrefixLists = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "match/ipv6/next-hop/access-list"); cValue.Exists() {
+ item.MatchIpv6NextHopAccessLists = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "match/ipv6/next-hop/prefix-list"); cValue.Exists() {
+ item.MatchIpv6NextHopPrefixLists = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "match/route-type/external"); cValue.Exists() {
+ item.MatchRouteTypeExternal = types.BoolValue(true)
+ } else {
+ item.MatchRouteTypeExternal = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "match/route-type/external/type-1"); cValue.Exists() {
+ item.MatchRouteTypeExternalType1 = types.BoolValue(true)
+ } else {
+ item.MatchRouteTypeExternalType1 = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "match/route-type/external/type-2"); cValue.Exists() {
+ item.MatchRouteTypeExternalType2 = types.BoolValue(true)
+ } else {
+ item.MatchRouteTypeExternalType2 = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "match/route-type/internal"); cValue.Exists() {
+ item.MatchRouteTypeInternal = types.BoolValue(true)
+ } else {
+ item.MatchRouteTypeInternal = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "match/route-type/level-1"); cValue.Exists() {
+ item.MatchRouteTypeLevel1 = types.BoolValue(true)
+ } else {
+ item.MatchRouteTypeLevel1 = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "match/route-type/level-2"); cValue.Exists() {
+ item.MatchRouteTypeLevel2 = types.BoolValue(true)
+ } else {
+ item.MatchRouteTypeLevel2 = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "match/route-type/local"); cValue.Exists() {
+ item.MatchRouteTypeLocalLegacy = types.BoolValue(true)
+ } else {
+ item.MatchRouteTypeLocalLegacy = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "match/Cisco-IOS-XE-bgp:bgp-route-map-match/route-type/local"); cValue.Exists() {
+ item.MatchRouteTypeLocal = types.BoolValue(true)
+ } else {
+ item.MatchRouteTypeLocal = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "match/source-protocol/bgp"); cValue.Exists() {
+ item.MatchSourceProtocolBgp = helpers.GetStringListXML(cValue.Array())
+ } else {
+ item.MatchSourceProtocolBgp = types.ListNull(types.StringType)
+ }
+ if cValue := helpers.GetFromXPath(v, "match/source-protocol/connected"); cValue.Exists() {
+ item.MatchSourceProtocolConnected = types.BoolValue(true)
+ } else {
+ item.MatchSourceProtocolConnected = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "match/source-protocol/eigrp"); cValue.Exists() {
+ item.MatchSourceProtocolEigrp = helpers.GetStringListXML(cValue.Array())
+ } else {
+ item.MatchSourceProtocolEigrp = types.ListNull(types.StringType)
+ }
+ if cValue := helpers.GetFromXPath(v, "match/source-protocol/isis"); cValue.Exists() {
+ item.MatchSourceProtocolIsis = types.BoolValue(true)
+ } else {
+ item.MatchSourceProtocolIsis = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "match/source-protocol/lisp"); cValue.Exists() {
+ item.MatchSourceProtocolLisp = types.BoolValue(true)
+ } else {
+ item.MatchSourceProtocolLisp = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "match/source-protocol/ospf"); cValue.Exists() {
+ item.MatchSourceProtocolOspf = helpers.GetStringListXML(cValue.Array())
+ } else {
+ item.MatchSourceProtocolOspf = types.ListNull(types.StringType)
+ }
+ if cValue := helpers.GetFromXPath(v, "match/source-protocol/ospfv3"); cValue.Exists() {
+ item.MatchSourceProtocolOspfv3 = helpers.GetStringListXML(cValue.Array())
+ } else {
+ item.MatchSourceProtocolOspfv3 = types.ListNull(types.StringType)
+ }
+ if cValue := helpers.GetFromXPath(v, "match/source-protocol/rip"); cValue.Exists() {
+ item.MatchSourceProtocolRip = types.BoolValue(true)
+ } else {
+ item.MatchSourceProtocolRip = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "match/source-protocol/static"); cValue.Exists() {
+ item.MatchSourceProtocolStatic = types.BoolValue(true)
+ } else {
+ item.MatchSourceProtocolStatic = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "match/tag/tag_value"); cValue.Exists() {
+ item.MatchTags = helpers.GetInt64ListXML(cValue.Array())
+ } else {
+ item.MatchTags = types.ListNull(types.Int64Type)
+ }
+ if cValue := helpers.GetFromXPath(v, "match/track"); cValue.Exists() {
+ item.MatchTrack = types.Int64Value(cValue.Int())
+ }
+ if cValue := helpers.GetFromXPath(v, "match/as-path/access-list"); cValue.Exists() {
+ item.MatchAsPathsLegacy = helpers.GetInt64ListXML(cValue.Array())
+ } else {
+ item.MatchAsPathsLegacy = types.ListNull(types.Int64Type)
+ }
+ if cValue := helpers.GetFromXPath(v, "match/community/name"); cValue.Exists() {
+ item.MatchCommunityListsLegacy = helpers.GetStringListXML(cValue.Array())
+ } else {
+ item.MatchCommunityListsLegacy = types.ListNull(types.StringType)
+ }
+ if cValue := helpers.GetFromXPath(v, "match/extcommunity/name"); cValue.Exists() {
+ item.MatchExtcommunityListsLegacy = helpers.GetStringListXML(cValue.Array())
+ } else {
+ item.MatchExtcommunityListsLegacy = types.ListNull(types.StringType)
+ }
+ if cValue := helpers.GetFromXPath(v, "match/local-preference/values"); cValue.Exists() {
+ item.MatchLocalPreferencesLegacy = helpers.GetInt64ListXML(cValue.Array())
+ } else {
+ item.MatchLocalPreferencesLegacy = types.ListNull(types.Int64Type)
+ }
+ if cValue := helpers.GetFromXPath(v, "match/Cisco-IOS-XE-bgp:bgp-route-map-match/as-path/access-list"); cValue.Exists() {
+ item.MatchAsPaths = helpers.GetInt64ListXML(cValue.Array())
+ } else {
+ item.MatchAsPaths = types.ListNull(types.Int64Type)
+ }
+ if cValue := helpers.GetFromXPath(v, "match/Cisco-IOS-XE-bgp:bgp-route-map-match/bgp-community/community-list"); cValue.Exists() {
+ item.MatchCommunityLists = helpers.GetStringListXML(cValue.Array())
+ } else {
+ item.MatchCommunityLists = types.ListNull(types.StringType)
+ }
+ if cValue := helpers.GetFromXPath(v, "match/Cisco-IOS-XE-bgp:bgp-route-map-match/bgp-community/exact-match"); cValue.Exists() {
+ item.MatchCommunityListExactMatch = types.BoolValue(true)
+ } else {
+ item.MatchCommunityListExactMatch = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "match/Cisco-IOS-XE-bgp:bgp-route-map-match/extcommunity/extcommunity-list"); cValue.Exists() {
+ item.MatchExtcommunityLists = helpers.GetStringListXML(cValue.Array())
+ } else {
+ item.MatchExtcommunityLists = types.ListNull(types.StringType)
+ }
+ if cValue := helpers.GetFromXPath(v, "match/Cisco-IOS-XE-bgp:bgp-route-map-match/local-preference/values"); cValue.Exists() {
+ item.MatchLocalPreferences = helpers.GetInt64ListXML(cValue.Array())
+ } else {
+ item.MatchLocalPreferences = types.ListNull(types.Int64Type)
+ }
+ if cValue := helpers.GetFromXPath(v, "set/default/interface-list"); cValue.Exists() {
+ item.SetDefaultInterfaces = helpers.GetStringListXML(cValue.Array())
+ } else {
+ item.SetDefaultInterfaces = types.ListNull(types.StringType)
+ }
+ if cValue := helpers.GetFromXPath(v, "set/global"); cValue.Exists() {
+ item.SetGlobal = types.BoolValue(true)
+ } else {
+ item.SetGlobal = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "set/interface-list"); cValue.Exists() {
+ item.SetInterfaces = helpers.GetStringListXML(cValue.Array())
+ } else {
+ item.SetInterfaces = types.ListNull(types.StringType)
+ }
+ if cValue := helpers.GetFromXPath(v, "set/ip/address/prefix-list"); cValue.Exists() {
+ item.SetIpAddress = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "set/ip/default/global/next-hop/address"); cValue.Exists() {
+ item.SetIpDefaultGlobalNextHopAddress = helpers.GetStringListXML(cValue.Array())
+ } else {
+ item.SetIpDefaultGlobalNextHopAddress = types.ListNull(types.StringType)
+ }
+ if cValue := helpers.GetFromXPath(v, "set/ip/default/next-hop/address"); cValue.Exists() {
+ item.SetIpDefaultNextHopAddress = helpers.GetStringListXML(cValue.Array())
+ } else {
+ item.SetIpDefaultNextHopAddress = types.ListNull(types.StringType)
+ }
+ if cValue := helpers.GetFromXPath(v, "set/ip/global/next-hop/address"); cValue.Exists() {
+ item.SetIpGlobalNextHopAddress = helpers.GetStringListXML(cValue.Array())
+ } else {
+ item.SetIpGlobalNextHopAddress = types.ListNull(types.StringType)
+ }
+ if cValue := helpers.GetFromXPath(v, "set/ip/next-hop/address"); cValue.Exists() {
+ item.SetIpNextHopAddress = helpers.GetStringListXML(cValue.Array())
+ } else {
+ item.SetIpNextHopAddress = types.ListNull(types.StringType)
+ }
+ if cValue := helpers.GetFromXPath(v, "set/ip/next-hop/self"); cValue.Exists() {
+ item.SetIpNextHopSelf = types.BoolValue(true)
+ } else {
+ item.SetIpNextHopSelf = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "set/ip/qos-group/qos-id"); cValue.Exists() {
+ item.SetIpQosGroup = types.Int64Value(cValue.Int())
+ }
+ if cValue := helpers.GetFromXPath(v, "set/ipv6/address/prefix-list"); cValue.Exists() {
+ item.SetIpv6Address = helpers.GetStringListXML(cValue.Array())
+ } else {
+ item.SetIpv6Address = types.ListNull(types.StringType)
+ }
+ if cValue := helpers.GetFromXPath(v, "set/ipv6/default/global/next-hop"); cValue.Exists() {
+ item.SetIpv6DefaultGlobalNextHop = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "set/ipv6/default/next-hop/ipv6"); cValue.Exists() {
+ item.SetIpv6DefaultNextHop = helpers.GetStringListXML(cValue.Array())
+ } else {
+ item.SetIpv6DefaultNextHop = types.ListNull(types.StringType)
+ }
+ if cValue := helpers.GetFromXPath(v, "set/ipv6/next-hop/ipv6"); cValue.Exists() {
+ item.SetIpv6NextHop = helpers.GetStringListXML(cValue.Array())
+ } else {
+ item.SetIpv6NextHop = types.ListNull(types.StringType)
+ }
+ if cValue := helpers.GetFromXPath(v, "set/level/level-1"); cValue.Exists() {
+ item.SetLevel1 = types.BoolValue(true)
+ } else {
+ item.SetLevel1 = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "set/level/level-1-2"); cValue.Exists() {
+ item.SetLevel12 = types.BoolValue(true)
+ } else {
+ item.SetLevel12 = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "set/level/level-2"); cValue.Exists() {
+ item.SetLevel2 = types.BoolValue(true)
+ } else {
+ item.SetLevel2 = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "set/metric/metric-change"); cValue.Exists() {
+ item.SetMetricChange = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "set/metric/values/value"); cValue.Exists() {
+ item.SetMetricValue = types.Int64Value(cValue.Int())
+ }
+ if cValue := helpers.GetFromXPath(v, "set/metric/values/delay"); cValue.Exists() {
+ item.SetMetricDelay = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "set/metric/values/reliability"); cValue.Exists() {
+ item.SetMetricReliability = types.Int64Value(cValue.Int())
+ }
+ if cValue := helpers.GetFromXPath(v, "set/metric/values/loading"); cValue.Exists() {
+ item.SetMetricLoading = types.Int64Value(cValue.Int())
+ }
+ if cValue := helpers.GetFromXPath(v, "set/metric/values/MTU"); cValue.Exists() {
+ item.SetMetricMtu = types.Int64Value(cValue.Int())
+ }
+ if cValue := helpers.GetFromXPath(v, "set/metric-type"); cValue.Exists() {
+ item.SetMetricType = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "set/tag/tag-val"); cValue.Exists() {
+ item.SetTag = types.Int64Value(cValue.Int())
+ }
+ if cValue := helpers.GetFromXPath(v, "set/vrf"); cValue.Exists() {
+ item.SetVrf = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "set/as-path/prepend/as-container/as-number"); cValue.Exists() {
+ item.SetAsPathPrependAsLegacy = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "set/as-path/prepend/last-as-cont/last-as"); cValue.Exists() {
+ item.SetAsPathPrependLastAsLegacy = types.Int64Value(cValue.Int())
+ }
+ if cValue := helpers.GetFromXPath(v, "set/as-path/tag"); cValue.Exists() {
+ item.SetAsPathTagLegacy = types.BoolValue(true)
+ } else {
+ item.SetAsPathTagLegacy = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "set/community/none"); cValue.Exists() {
+ item.SetCommunityNoneLegacy = types.BoolValue(true)
+ } else {
+ item.SetCommunityNoneLegacy = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "set/community/community-well-known/community-list"); cValue.Exists() {
+ item.SetCommunitiesLegacy = helpers.GetStringListXML(cValue.Array())
+ } else {
+ item.SetCommunitiesLegacy = types.ListNull(types.StringType)
+ }
+ if cValue := helpers.GetFromXPath(v, "set/community/community-well-known/additive"); cValue.Exists() {
+ item.SetCommunitiesAdditiveLegacy = types.BoolValue(true)
+ } else {
+ item.SetCommunitiesAdditiveLegacy = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "set/comm-list/delete"); cValue.Exists() {
+ item.SetCommunityListDeleteLegacy = types.BoolValue(true)
+ } else {
+ item.SetCommunityListDeleteLegacy = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "set/comm-list/comm-list-standard"); cValue.Exists() {
+ item.SetCommunityListStandardLegacy = types.Int64Value(cValue.Int())
+ }
+ if cValue := helpers.GetFromXPath(v, "set/Cisco-IOS-XE-bgp:bgp-route-map-set/comm-list/comm-list-expanded"); cValue.Exists() {
+ item.SetCommunityListExpandedLegacy = types.Int64Value(cValue.Int())
+ }
+ if cValue := helpers.GetFromXPath(v, "set/comm-list/comm-list-name"); cValue.Exists() {
+ item.SetCommunityListNameLegacy = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "set/extcommunity/rt/asn-nn"); cValue.Exists() {
+ item.SetExtcomunityRtLegacy = helpers.GetStringListXML(cValue.Array())
+ } else {
+ item.SetExtcomunityRtLegacy = types.ListNull(types.StringType)
+ }
+ if cValue := helpers.GetFromXPath(v, "set/extcommunity/soo/asn-nn"); cValue.Exists() {
+ item.SetExtcomunitySooLegacy = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "set/extcommunity/vpn-distinguisher/asn-nn"); cValue.Exists() {
+ item.SetExtcomunityVpnDistinguisherLegacy = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "set/local-preference"); cValue.Exists() {
+ item.SetLocalPreferenceLegacy = types.Int64Value(cValue.Int())
+ }
+ if cValue := helpers.GetFromXPath(v, "set/weight"); cValue.Exists() {
+ item.SetWeightLegacy = types.Int64Value(cValue.Int())
+ }
+ if cValue := helpers.GetFromXPath(v, "set/Cisco-IOS-XE-bgp:bgp-route-map-set/as-path/prepend/as-container/as-number"); cValue.Exists() {
+ item.SetAsPathPrependAs = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "set/Cisco-IOS-XE-bgp:bgp-route-map-set/as-path/prepend/last-as-cont/last-as"); cValue.Exists() {
+ item.SetAsPathPrependLastAs = types.Int64Value(cValue.Int())
+ }
+ if cValue := helpers.GetFromXPath(v, "set/Cisco-IOS-XE-bgp:bgp-route-map-set/as-path/tag"); cValue.Exists() {
+ item.SetAsPathTag = types.BoolValue(true)
+ } else {
+ item.SetAsPathTag = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "set/Cisco-IOS-XE-bgp:bgp-route-map-set/as-path/replace/any"); cValue.Exists() {
+ item.SetAsPathReplaceAny = types.BoolValue(true)
+ } else {
+ item.SetAsPathReplaceAny = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "set/Cisco-IOS-XE-bgp:bgp-route-map-set/as-path/replace/as-container"); cValue.Exists() {
+ item.SetAsPathReplaceAs = make([]RouteMapEntriesSetAsPathReplaceAs, 0)
+ cValue.ForEach(func(_ int, cv xmldot.Result) bool {
cItem := RouteMapEntriesSetAsPathReplaceAs{}
- if ccValue := cv.Get("as-number"); ccValue.Exists() {
+ if ccValue := helpers.GetFromXPath(cv, "as-number"); ccValue.Exists() {
cItem.AsNumber = types.StringValue(ccValue.String())
}
- item.SetAsPathReplaceAs = append(item.SetAsPathReplaceAs, cItem)
- return true
- })
- }
- if cValue := v.Get("set.Cisco-IOS-XE-bgp:bgp-route-map-set.bgp-community.none"); cValue.Exists() {
- item.SetCommunityNone = types.BoolValue(true)
- } else {
- item.SetCommunityNone = types.BoolValue(false)
- }
- if cValue := v.Get("set.Cisco-IOS-XE-bgp:bgp-route-map-set.bgp-community.community-well-known.community-list"); cValue.Exists() {
- item.SetCommunities = helpers.GetStringList(cValue.Array())
- } else {
- item.SetCommunities = types.ListNull(types.StringType)
- }
- if cValue := v.Get("set.Cisco-IOS-XE-bgp:bgp-route-map-set.bgp-community.community-well-known.additive"); cValue.Exists() {
- item.SetCommunitiesAdditive = types.BoolValue(true)
- } else {
- item.SetCommunitiesAdditive = types.BoolValue(false)
- }
- if cValue := v.Get("set.Cisco-IOS-XE-bgp:bgp-route-map-set.comm-list.delete"); cValue.Exists() {
- item.SetCommunityListDelete = types.BoolValue(true)
- } else {
- item.SetCommunityListDelete = types.BoolValue(false)
- }
- if cValue := v.Get("set.Cisco-IOS-XE-bgp:bgp-route-map-set.comm-list.comm-list-standard"); cValue.Exists() {
- item.SetCommunityListStandard = types.Int64Value(cValue.Int())
- }
- if cValue := v.Get("set.Cisco-IOS-XE-bgp:bgp-route-map-set.comm-list.comm-list-expanded"); cValue.Exists() {
- item.SetCommunityListExpanded = types.Int64Value(cValue.Int())
- }
- if cValue := v.Get("set.Cisco-IOS-XE-bgp:bgp-route-map-set.comm-list.comm-list-name"); cValue.Exists() {
- item.SetCommunityListName = types.StringValue(cValue.String())
- }
- if cValue := v.Get("set.Cisco-IOS-XE-bgp:bgp-route-map-set.extcommunity.rt.asn-nn"); cValue.Exists() {
- item.SetExtcomunityRt = helpers.GetStringList(cValue.Array())
- } else {
- item.SetExtcomunityRt = types.ListNull(types.StringType)
- }
- if cValue := v.Get("set.Cisco-IOS-XE-bgp:bgp-route-map-set.extcommunity.soo.asn-nn"); cValue.Exists() {
- item.SetExtcomunitySoo = types.StringValue(cValue.String())
- }
- if cValue := v.Get("set.Cisco-IOS-XE-bgp:bgp-route-map-set.extcommunity.vpn-distinguisher.asn-nn"); cValue.Exists() {
- item.SetExtcomunityVpnDistinguisher = types.StringValue(cValue.String())
- }
- if cValue := v.Get("set.Cisco-IOS-XE-bgp:bgp-route-map-set.extcommunity.vpn-distinguisher.asn-nn-additive"); cValue.Exists() {
- item.SetExtcomunityVpnDistinguisherAdditive = types.BoolValue(true)
- } else {
- item.SetExtcomunityVpnDistinguisherAdditive = types.BoolValue(false)
- }
- if cValue := v.Get("set.Cisco-IOS-XE-bgp:bgp-route-map-set.local-preference"); cValue.Exists() {
- item.SetLocalPreference = types.Int64Value(cValue.Int())
- }
- if cValue := v.Get("set.Cisco-IOS-XE-bgp:bgp-route-map-set.weight"); cValue.Exists() {
- item.SetWeight = types.Int64Value(cValue.Int())
+ item.SetAsPathReplaceAs = append(item.SetAsPathReplaceAs, cItem)
+ return true
+ })
+ }
+ if cValue := helpers.GetFromXPath(v, "set/Cisco-IOS-XE-bgp:bgp-route-map-set/bgp-community/none"); cValue.Exists() {
+ item.SetCommunityNone = types.BoolValue(true)
+ } else {
+ item.SetCommunityNone = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "set/Cisco-IOS-XE-bgp:bgp-route-map-set/bgp-community/community-well-known/community-list"); cValue.Exists() {
+ item.SetCommunities = helpers.GetStringListXML(cValue.Array())
+ } else {
+ item.SetCommunities = types.ListNull(types.StringType)
+ }
+ if cValue := helpers.GetFromXPath(v, "set/Cisco-IOS-XE-bgp:bgp-route-map-set/bgp-community/community-well-known/additive"); cValue.Exists() {
+ item.SetCommunitiesAdditive = types.BoolValue(true)
+ } else {
+ item.SetCommunitiesAdditive = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "set/Cisco-IOS-XE-bgp:bgp-route-map-set/comm-list/delete"); cValue.Exists() {
+ item.SetCommunityListDelete = types.BoolValue(true)
+ } else {
+ item.SetCommunityListDelete = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "set/Cisco-IOS-XE-bgp:bgp-route-map-set/comm-list/comm-list-standard"); cValue.Exists() {
+ item.SetCommunityListStandard = types.Int64Value(cValue.Int())
+ }
+ if cValue := helpers.GetFromXPath(v, "set/Cisco-IOS-XE-bgp:bgp-route-map-set/comm-list/comm-list-expanded"); cValue.Exists() {
+ item.SetCommunityListExpanded = types.Int64Value(cValue.Int())
+ }
+ if cValue := helpers.GetFromXPath(v, "set/Cisco-IOS-XE-bgp:bgp-route-map-set/comm-list/comm-list-name"); cValue.Exists() {
+ item.SetCommunityListName = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "set/Cisco-IOS-XE-bgp:bgp-route-map-set/extcommunity/rt/asn-nn"); cValue.Exists() {
+ item.SetExtcomunityRt = helpers.GetStringListXML(cValue.Array())
+ } else {
+ item.SetExtcomunityRt = types.ListNull(types.StringType)
+ }
+ if cValue := helpers.GetFromXPath(v, "set/Cisco-IOS-XE-bgp:bgp-route-map-set/extcommunity/soo/asn-nn"); cValue.Exists() {
+ item.SetExtcomunitySoo = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "set/Cisco-IOS-XE-bgp:bgp-route-map-set/extcommunity/vpn-distinguisher/asn-nn"); cValue.Exists() {
+ item.SetExtcomunityVpnDistinguisher = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "set/Cisco-IOS-XE-bgp:bgp-route-map-set/extcommunity/vpn-distinguisher/asn-nn-additive"); cValue.Exists() {
+ item.SetExtcomunityVpnDistinguisherAdditive = types.BoolValue(true)
+ } else {
+ item.SetExtcomunityVpnDistinguisherAdditive = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "set/Cisco-IOS-XE-bgp:bgp-route-map-set/local-preference"); cValue.Exists() {
+ item.SetLocalPreference = types.Int64Value(cValue.Int())
+ }
+ if cValue := helpers.GetFromXPath(v, "set/Cisco-IOS-XE-bgp:bgp-route-map-set/weight"); cValue.Exists() {
+ item.SetWeight = types.Int64Value(cValue.Int())
+ }
+ data.Entries = append(data.Entries, item)
+ return true
+ })
+ }
+}
+
+// End of section. //template:end fromBodyDataXML
+
+// Section below is generated&owned by "gen/generator.go". //template:begin getDeletedItems
+
+func (data *RouteMap) getDeletedItems(ctx context.Context, state RouteMap) []string {
+ deletedItems := make([]string, 0)
+ for i := range state.Entries {
+ stateKeyValues := [...]string{strconv.FormatInt(state.Entries[i].Seq.ValueInt64(), 10)}
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.Entries[i].Seq.ValueInt64()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.Entries {
+ found = true
+ if state.Entries[i].Seq.ValueInt64() != data.Entries[j].Seq.ValueInt64() {
+ found = false
+ }
+ if found {
+ if !state.Entries[i].SetWeight.IsNull() && data.Entries[j].SetWeight.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/set/Cisco-IOS-XE-bgp:bgp-route-map-set/weight", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ if !state.Entries[i].SetLocalPreference.IsNull() && data.Entries[j].SetLocalPreference.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/set/Cisco-IOS-XE-bgp:bgp-route-map-set/local-preference", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ if !state.Entries[i].SetExtcomunityVpnDistinguisherAdditive.IsNull() && data.Entries[j].SetExtcomunityVpnDistinguisherAdditive.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/set/Cisco-IOS-XE-bgp:bgp-route-map-set/extcommunity/vpn-distinguisher/asn-nn-additive", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ if !state.Entries[i].SetExtcomunityVpnDistinguisher.IsNull() && data.Entries[j].SetExtcomunityVpnDistinguisher.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/set/Cisco-IOS-XE-bgp:bgp-route-map-set/extcommunity/vpn-distinguisher/asn-nn", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ if !state.Entries[i].SetExtcomunitySoo.IsNull() && data.Entries[j].SetExtcomunitySoo.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/set/Cisco-IOS-XE-bgp:bgp-route-map-set/extcommunity/soo/asn-nn", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ if !state.Entries[i].SetExtcomunityRt.IsNull() {
+ if data.Entries[j].SetExtcomunityRt.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/set/Cisco-IOS-XE-bgp:bgp-route-map-set/extcommunity/rt/asn-nn", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ } else {
+ var dataValues, stateValues []string
+ data.Entries[i].SetExtcomunityRt.ElementsAs(ctx, &dataValues, false)
+ state.Entries[j].SetExtcomunityRt.ElementsAs(ctx, &stateValues, false)
+ for _, v := range stateValues {
+ found := false
+ for _, vv := range dataValues {
+ if v == vv {
+ found = true
+ break
+ }
+ }
+ if !found {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/set/Cisco-IOS-XE-bgp:bgp-route-map-set/extcommunity/rt/asn-nn=%v", state.getPath(), strings.Join(stateKeyValues[:], ","), v))
+ }
+ }
+ }
+ }
+ if !state.Entries[i].SetCommunityListName.IsNull() && data.Entries[j].SetCommunityListName.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/set/Cisco-IOS-XE-bgp:bgp-route-map-set/comm-list/comm-list-name", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ if !state.Entries[i].SetCommunityListExpanded.IsNull() && data.Entries[j].SetCommunityListExpanded.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/set/Cisco-IOS-XE-bgp:bgp-route-map-set/comm-list/comm-list-expanded", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ if !state.Entries[i].SetCommunityListStandard.IsNull() && data.Entries[j].SetCommunityListStandard.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/set/Cisco-IOS-XE-bgp:bgp-route-map-set/comm-list/comm-list-standard", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ if !state.Entries[i].SetCommunityListDelete.IsNull() && data.Entries[j].SetCommunityListDelete.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/set/Cisco-IOS-XE-bgp:bgp-route-map-set/comm-list/delete", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ if !state.Entries[i].SetCommunitiesAdditive.IsNull() && data.Entries[j].SetCommunitiesAdditive.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/set/Cisco-IOS-XE-bgp:bgp-route-map-set/bgp-community/community-well-known/additive", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ if !state.Entries[i].SetCommunities.IsNull() {
+ if data.Entries[j].SetCommunities.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/set/Cisco-IOS-XE-bgp:bgp-route-map-set/bgp-community/community-well-known/community-list", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ } else {
+ var dataValues, stateValues []string
+ data.Entries[i].SetCommunities.ElementsAs(ctx, &dataValues, false)
+ state.Entries[j].SetCommunities.ElementsAs(ctx, &stateValues, false)
+ for _, v := range stateValues {
+ found := false
+ for _, vv := range dataValues {
+ if v == vv {
+ found = true
+ break
+ }
+ }
+ if !found {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/set/Cisco-IOS-XE-bgp:bgp-route-map-set/bgp-community/community-well-known/community-list=%v", state.getPath(), strings.Join(stateKeyValues[:], ","), v))
+ }
+ }
+ }
+ }
+ if !state.Entries[i].SetCommunityNone.IsNull() && data.Entries[j].SetCommunityNone.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/set/Cisco-IOS-XE-bgp:bgp-route-map-set/bgp-community/none", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ for ci := range state.Entries[i].SetAsPathReplaceAs {
+ cstateKeyValues := [...]string{state.Entries[i].SetAsPathReplaceAs[ci].AsNumber.ValueString()}
+
+ cemptyKeys := true
+ if !reflect.ValueOf(state.Entries[i].SetAsPathReplaceAs[ci].AsNumber.ValueString()).IsZero() {
+ cemptyKeys = false
+ }
+ if cemptyKeys {
+ continue
+ }
+
+ found := false
+ for cj := range data.Entries[j].SetAsPathReplaceAs {
+ found = true
+ if state.Entries[i].SetAsPathReplaceAs[ci].AsNumber.ValueString() != data.Entries[j].SetAsPathReplaceAs[cj].AsNumber.ValueString() {
+ found = false
+ }
+ if found {
+ break
+ }
+ }
+ if !found {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/set/Cisco-IOS-XE-bgp:bgp-route-map-set/as-path/replace/as-container=%v", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ }
+ }
+ if !state.Entries[i].SetAsPathReplaceAny.IsNull() && data.Entries[j].SetAsPathReplaceAny.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/set/Cisco-IOS-XE-bgp:bgp-route-map-set/as-path/replace/any", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ if !state.Entries[i].SetAsPathTag.IsNull() && data.Entries[j].SetAsPathTag.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/set/Cisco-IOS-XE-bgp:bgp-route-map-set/as-path/tag", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ if !state.Entries[i].SetAsPathPrependLastAs.IsNull() && data.Entries[j].SetAsPathPrependLastAs.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/set/Cisco-IOS-XE-bgp:bgp-route-map-set/as-path/prepend/last-as-cont/last-as", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ if !state.Entries[i].SetAsPathPrependAs.IsNull() && data.Entries[j].SetAsPathPrependAs.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/set/Cisco-IOS-XE-bgp:bgp-route-map-set/as-path/prepend/as-container/as-number", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ if !state.Entries[i].SetWeightLegacy.IsNull() && data.Entries[j].SetWeightLegacy.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/set/weight", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ if !state.Entries[i].SetLocalPreferenceLegacy.IsNull() && data.Entries[j].SetLocalPreferenceLegacy.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/set/local-preference", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ if !state.Entries[i].SetExtcomunityVpnDistinguisherLegacy.IsNull() && data.Entries[j].SetExtcomunityVpnDistinguisherLegacy.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/set/extcommunity/vpn-distinguisher/asn-nn", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ if !state.Entries[i].SetExtcomunitySooLegacy.IsNull() && data.Entries[j].SetExtcomunitySooLegacy.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/set/extcommunity/soo/asn-nn", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ if !state.Entries[i].SetExtcomunityRtLegacy.IsNull() {
+ if data.Entries[j].SetExtcomunityRtLegacy.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/set/extcommunity/rt/asn-nn", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ } else {
+ var dataValues, stateValues []string
+ data.Entries[i].SetExtcomunityRtLegacy.ElementsAs(ctx, &dataValues, false)
+ state.Entries[j].SetExtcomunityRtLegacy.ElementsAs(ctx, &stateValues, false)
+ for _, v := range stateValues {
+ found := false
+ for _, vv := range dataValues {
+ if v == vv {
+ found = true
+ break
+ }
+ }
+ if !found {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/set/extcommunity/rt/asn-nn=%v", state.getPath(), strings.Join(stateKeyValues[:], ","), v))
+ }
+ }
+ }
+ }
+ if !state.Entries[i].SetCommunityListNameLegacy.IsNull() && data.Entries[j].SetCommunityListNameLegacy.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/set/comm-list/comm-list-name", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ if !state.Entries[i].SetCommunityListExpandedLegacy.IsNull() && data.Entries[j].SetCommunityListExpandedLegacy.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/set/Cisco-IOS-XE-bgp:bgp-route-map-set/comm-list/comm-list-expanded", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ if !state.Entries[i].SetCommunityListStandardLegacy.IsNull() && data.Entries[j].SetCommunityListStandardLegacy.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/set/comm-list/comm-list-standard", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ if !state.Entries[i].SetCommunityListDeleteLegacy.IsNull() && data.Entries[j].SetCommunityListDeleteLegacy.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/set/comm-list/delete", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ if !state.Entries[i].SetCommunitiesAdditiveLegacy.IsNull() && data.Entries[j].SetCommunitiesAdditiveLegacy.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/set/community/community-well-known/additive", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ if !state.Entries[i].SetCommunitiesLegacy.IsNull() {
+ if data.Entries[j].SetCommunitiesLegacy.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/set/community/community-well-known/community-list", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ } else {
+ var dataValues, stateValues []string
+ data.Entries[i].SetCommunitiesLegacy.ElementsAs(ctx, &dataValues, false)
+ state.Entries[j].SetCommunitiesLegacy.ElementsAs(ctx, &stateValues, false)
+ for _, v := range stateValues {
+ found := false
+ for _, vv := range dataValues {
+ if v == vv {
+ found = true
+ break
+ }
+ }
+ if !found {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/set/community/community-well-known/community-list=%v", state.getPath(), strings.Join(stateKeyValues[:], ","), v))
+ }
+ }
+ }
+ }
+ if !state.Entries[i].SetCommunityNoneLegacy.IsNull() && data.Entries[j].SetCommunityNoneLegacy.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/set/community/none", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ if !state.Entries[i].SetAsPathTagLegacy.IsNull() && data.Entries[j].SetAsPathTagLegacy.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/set/as-path/tag", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ if !state.Entries[i].SetAsPathPrependLastAsLegacy.IsNull() && data.Entries[j].SetAsPathPrependLastAsLegacy.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/set/as-path/prepend/last-as-cont/last-as", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ if !state.Entries[i].SetAsPathPrependAsLegacy.IsNull() && data.Entries[j].SetAsPathPrependAsLegacy.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/set/as-path/prepend/as-container/as-number", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ if !state.Entries[i].SetVrf.IsNull() && data.Entries[j].SetVrf.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/set/vrf", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ if !state.Entries[i].SetTag.IsNull() && data.Entries[j].SetTag.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/set/tag/tag-val", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ if !state.Entries[i].SetMetricType.IsNull() && data.Entries[j].SetMetricType.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/set/metric-type", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ if !state.Entries[i].SetMetricMtu.IsNull() && data.Entries[j].SetMetricMtu.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/set/metric/values/MTU", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ if !state.Entries[i].SetMetricLoading.IsNull() && data.Entries[j].SetMetricLoading.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/set/metric/values/loading", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ if !state.Entries[i].SetMetricReliability.IsNull() && data.Entries[j].SetMetricReliability.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/set/metric/values/reliability", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ if !state.Entries[i].SetMetricDelay.IsNull() && data.Entries[j].SetMetricDelay.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/set/metric/values/delay", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ if !state.Entries[i].SetMetricValue.IsNull() && data.Entries[j].SetMetricValue.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/set/metric/values/value", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ if !state.Entries[i].SetMetricChange.IsNull() && data.Entries[j].SetMetricChange.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/set/metric/metric-change", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ if !state.Entries[i].SetLevel2.IsNull() && data.Entries[j].SetLevel2.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/set/level/level-2", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ if !state.Entries[i].SetLevel12.IsNull() && data.Entries[j].SetLevel12.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/set/level/level-1-2", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ if !state.Entries[i].SetLevel1.IsNull() && data.Entries[j].SetLevel1.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/set/level/level-1", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ if !state.Entries[i].SetIpv6NextHop.IsNull() {
+ if data.Entries[j].SetIpv6NextHop.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/set/ipv6/next-hop/ipv6", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ } else {
+ var dataValues, stateValues []string
+ data.Entries[i].SetIpv6NextHop.ElementsAs(ctx, &dataValues, false)
+ state.Entries[j].SetIpv6NextHop.ElementsAs(ctx, &stateValues, false)
+ for _, v := range stateValues {
+ found := false
+ for _, vv := range dataValues {
+ if v == vv {
+ found = true
+ break
+ }
+ }
+ if !found {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/set/ipv6/next-hop/ipv6=%v", state.getPath(), strings.Join(stateKeyValues[:], ","), v))
+ }
+ }
+ }
+ }
+ if !state.Entries[i].SetIpv6DefaultNextHop.IsNull() {
+ if data.Entries[j].SetIpv6DefaultNextHop.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/set/ipv6/default/next-hop/ipv6", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ } else {
+ var dataValues, stateValues []string
+ data.Entries[i].SetIpv6DefaultNextHop.ElementsAs(ctx, &dataValues, false)
+ state.Entries[j].SetIpv6DefaultNextHop.ElementsAs(ctx, &stateValues, false)
+ for _, v := range stateValues {
+ found := false
+ for _, vv := range dataValues {
+ if v == vv {
+ found = true
+ break
+ }
+ }
+ if !found {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/set/ipv6/default/next-hop/ipv6=%v", state.getPath(), strings.Join(stateKeyValues[:], ","), v))
+ }
+ }
+ }
+ }
+ if !state.Entries[i].SetIpv6DefaultGlobalNextHop.IsNull() && data.Entries[j].SetIpv6DefaultGlobalNextHop.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/set/ipv6/default/global/next-hop", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ if !state.Entries[i].SetIpv6Address.IsNull() {
+ if data.Entries[j].SetIpv6Address.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/set/ipv6/address/prefix-list", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ } else {
+ var dataValues, stateValues []string
+ data.Entries[i].SetIpv6Address.ElementsAs(ctx, &dataValues, false)
+ state.Entries[j].SetIpv6Address.ElementsAs(ctx, &stateValues, false)
+ for _, v := range stateValues {
+ found := false
+ for _, vv := range dataValues {
+ if v == vv {
+ found = true
+ break
+ }
+ }
+ if !found {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/set/ipv6/address/prefix-list=%v", state.getPath(), strings.Join(stateKeyValues[:], ","), v))
+ }
+ }
+ }
+ }
+ if !state.Entries[i].SetIpQosGroup.IsNull() && data.Entries[j].SetIpQosGroup.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/set/ip/qos-group/qos-id", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ if !state.Entries[i].SetIpNextHopSelf.IsNull() && data.Entries[j].SetIpNextHopSelf.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/set/ip/next-hop/self", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ if !state.Entries[i].SetIpNextHopAddress.IsNull() {
+ if data.Entries[j].SetIpNextHopAddress.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/set/ip/next-hop/address", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ } else {
+ var dataValues, stateValues []string
+ data.Entries[i].SetIpNextHopAddress.ElementsAs(ctx, &dataValues, false)
+ state.Entries[j].SetIpNextHopAddress.ElementsAs(ctx, &stateValues, false)
+ for _, v := range stateValues {
+ found := false
+ for _, vv := range dataValues {
+ if v == vv {
+ found = true
+ break
+ }
+ }
+ if !found {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/set/ip/next-hop/address=%v", state.getPath(), strings.Join(stateKeyValues[:], ","), v))
+ }
+ }
+ }
+ }
+ if !state.Entries[i].SetIpGlobalNextHopAddress.IsNull() {
+ if data.Entries[j].SetIpGlobalNextHopAddress.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/set/ip/global/next-hop/address", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ } else {
+ var dataValues, stateValues []string
+ data.Entries[i].SetIpGlobalNextHopAddress.ElementsAs(ctx, &dataValues, false)
+ state.Entries[j].SetIpGlobalNextHopAddress.ElementsAs(ctx, &stateValues, false)
+ for _, v := range stateValues {
+ found := false
+ for _, vv := range dataValues {
+ if v == vv {
+ found = true
+ break
+ }
+ }
+ if !found {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/set/ip/global/next-hop/address=%v", state.getPath(), strings.Join(stateKeyValues[:], ","), v))
+ }
+ }
+ }
+ }
+ if !state.Entries[i].SetIpDefaultNextHopAddress.IsNull() {
+ if data.Entries[j].SetIpDefaultNextHopAddress.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/set/ip/default/next-hop/address", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ } else {
+ var dataValues, stateValues []string
+ data.Entries[i].SetIpDefaultNextHopAddress.ElementsAs(ctx, &dataValues, false)
+ state.Entries[j].SetIpDefaultNextHopAddress.ElementsAs(ctx, &stateValues, false)
+ for _, v := range stateValues {
+ found := false
+ for _, vv := range dataValues {
+ if v == vv {
+ found = true
+ break
+ }
+ }
+ if !found {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/set/ip/default/next-hop/address=%v", state.getPath(), strings.Join(stateKeyValues[:], ","), v))
+ }
+ }
+ }
+ }
+ if !state.Entries[i].SetIpDefaultGlobalNextHopAddress.IsNull() {
+ if data.Entries[j].SetIpDefaultGlobalNextHopAddress.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/set/ip/default/global/next-hop/address", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ } else {
+ var dataValues, stateValues []string
+ data.Entries[i].SetIpDefaultGlobalNextHopAddress.ElementsAs(ctx, &dataValues, false)
+ state.Entries[j].SetIpDefaultGlobalNextHopAddress.ElementsAs(ctx, &stateValues, false)
+ for _, v := range stateValues {
+ found := false
+ for _, vv := range dataValues {
+ if v == vv {
+ found = true
+ break
+ }
+ }
+ if !found {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/set/ip/default/global/next-hop/address=%v", state.getPath(), strings.Join(stateKeyValues[:], ","), v))
+ }
+ }
+ }
+ }
+ if !state.Entries[i].SetIpAddress.IsNull() && data.Entries[j].SetIpAddress.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/set/ip/address/prefix-list", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ if !state.Entries[i].SetInterfaces.IsNull() {
+ if data.Entries[j].SetInterfaces.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/set/interface-list", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ } else {
+ var dataValues, stateValues []string
+ data.Entries[i].SetInterfaces.ElementsAs(ctx, &dataValues, false)
+ state.Entries[j].SetInterfaces.ElementsAs(ctx, &stateValues, false)
+ for _, v := range stateValues {
+ found := false
+ for _, vv := range dataValues {
+ if v == vv {
+ found = true
+ break
+ }
+ }
+ if !found {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/set/interface-list=%v", state.getPath(), strings.Join(stateKeyValues[:], ","), v))
+ }
+ }
+ }
+ }
+ if !state.Entries[i].SetGlobal.IsNull() && data.Entries[j].SetGlobal.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/set/global", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ if !state.Entries[i].SetDefaultInterfaces.IsNull() {
+ if data.Entries[j].SetDefaultInterfaces.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/set/default/interface-list", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ } else {
+ var dataValues, stateValues []string
+ data.Entries[i].SetDefaultInterfaces.ElementsAs(ctx, &dataValues, false)
+ state.Entries[j].SetDefaultInterfaces.ElementsAs(ctx, &stateValues, false)
+ for _, v := range stateValues {
+ found := false
+ for _, vv := range dataValues {
+ if v == vv {
+ found = true
+ break
+ }
+ }
+ if !found {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/set/default/interface-list=%v", state.getPath(), strings.Join(stateKeyValues[:], ","), v))
+ }
+ }
+ }
+ }
+ if !state.Entries[i].MatchLocalPreferences.IsNull() {
+ if data.Entries[j].MatchLocalPreferences.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/match/Cisco-IOS-XE-bgp:bgp-route-map-match/local-preference/values", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ } else {
+ var dataValues, stateValues []int
+ data.Entries[i].MatchLocalPreferences.ElementsAs(ctx, &dataValues, false)
+ state.Entries[j].MatchLocalPreferences.ElementsAs(ctx, &stateValues, false)
+ for _, v := range stateValues {
+ found := false
+ for _, vv := range dataValues {
+ if v == vv {
+ found = true
+ break
+ }
+ }
+ if !found {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/match/Cisco-IOS-XE-bgp:bgp-route-map-match/local-preference/values=%v", state.getPath(), strings.Join(stateKeyValues[:], ","), v))
+ }
+ }
+ }
+ }
+ if !state.Entries[i].MatchExtcommunityLists.IsNull() {
+ if data.Entries[j].MatchExtcommunityLists.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/match/Cisco-IOS-XE-bgp:bgp-route-map-match/extcommunity/extcommunity-list", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ } else {
+ var dataValues, stateValues []string
+ data.Entries[i].MatchExtcommunityLists.ElementsAs(ctx, &dataValues, false)
+ state.Entries[j].MatchExtcommunityLists.ElementsAs(ctx, &stateValues, false)
+ for _, v := range stateValues {
+ found := false
+ for _, vv := range dataValues {
+ if v == vv {
+ found = true
+ break
+ }
+ }
+ if !found {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/match/Cisco-IOS-XE-bgp:bgp-route-map-match/extcommunity/extcommunity-list=%v", state.getPath(), strings.Join(stateKeyValues[:], ","), v))
+ }
+ }
+ }
+ }
+ if !state.Entries[i].MatchCommunityListExactMatch.IsNull() && data.Entries[j].MatchCommunityListExactMatch.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/match/Cisco-IOS-XE-bgp:bgp-route-map-match/bgp-community/exact-match", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ if !state.Entries[i].MatchCommunityLists.IsNull() {
+ if data.Entries[j].MatchCommunityLists.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/match/Cisco-IOS-XE-bgp:bgp-route-map-match/bgp-community/community-list", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ } else {
+ var dataValues, stateValues []string
+ data.Entries[i].MatchCommunityLists.ElementsAs(ctx, &dataValues, false)
+ state.Entries[j].MatchCommunityLists.ElementsAs(ctx, &stateValues, false)
+ for _, v := range stateValues {
+ found := false
+ for _, vv := range dataValues {
+ if v == vv {
+ found = true
+ break
+ }
+ }
+ if !found {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/match/Cisco-IOS-XE-bgp:bgp-route-map-match/bgp-community/community-list=%v", state.getPath(), strings.Join(stateKeyValues[:], ","), v))
+ }
+ }
+ }
+ }
+ if !state.Entries[i].MatchAsPaths.IsNull() {
+ if data.Entries[j].MatchAsPaths.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/match/Cisco-IOS-XE-bgp:bgp-route-map-match/as-path/access-list", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ } else {
+ var dataValues, stateValues []int
+ data.Entries[i].MatchAsPaths.ElementsAs(ctx, &dataValues, false)
+ state.Entries[j].MatchAsPaths.ElementsAs(ctx, &stateValues, false)
+ for _, v := range stateValues {
+ found := false
+ for _, vv := range dataValues {
+ if v == vv {
+ found = true
+ break
+ }
+ }
+ if !found {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/match/Cisco-IOS-XE-bgp:bgp-route-map-match/as-path/access-list=%v", state.getPath(), strings.Join(stateKeyValues[:], ","), v))
+ }
+ }
+ }
+ }
+ if !state.Entries[i].MatchLocalPreferencesLegacy.IsNull() {
+ if data.Entries[j].MatchLocalPreferencesLegacy.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/match/local-preference/values", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ } else {
+ var dataValues, stateValues []int
+ data.Entries[i].MatchLocalPreferencesLegacy.ElementsAs(ctx, &dataValues, false)
+ state.Entries[j].MatchLocalPreferencesLegacy.ElementsAs(ctx, &stateValues, false)
+ for _, v := range stateValues {
+ found := false
+ for _, vv := range dataValues {
+ if v == vv {
+ found = true
+ break
+ }
+ }
+ if !found {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/match/local-preference/values=%v", state.getPath(), strings.Join(stateKeyValues[:], ","), v))
+ }
+ }
+ }
+ }
+ if !state.Entries[i].MatchExtcommunityListsLegacy.IsNull() {
+ if data.Entries[j].MatchExtcommunityListsLegacy.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/match/extcommunity/name", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ } else {
+ var dataValues, stateValues []string
+ data.Entries[i].MatchExtcommunityListsLegacy.ElementsAs(ctx, &dataValues, false)
+ state.Entries[j].MatchExtcommunityListsLegacy.ElementsAs(ctx, &stateValues, false)
+ for _, v := range stateValues {
+ found := false
+ for _, vv := range dataValues {
+ if v == vv {
+ found = true
+ break
+ }
+ }
+ if !found {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/match/extcommunity/name=%v", state.getPath(), strings.Join(stateKeyValues[:], ","), v))
+ }
+ }
+ }
+ }
+ if !state.Entries[i].MatchCommunityListsLegacy.IsNull() {
+ if data.Entries[j].MatchCommunityListsLegacy.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/match/community/name", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ } else {
+ var dataValues, stateValues []string
+ data.Entries[i].MatchCommunityListsLegacy.ElementsAs(ctx, &dataValues, false)
+ state.Entries[j].MatchCommunityListsLegacy.ElementsAs(ctx, &stateValues, false)
+ for _, v := range stateValues {
+ found := false
+ for _, vv := range dataValues {
+ if v == vv {
+ found = true
+ break
+ }
+ }
+ if !found {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/match/community/name=%v", state.getPath(), strings.Join(stateKeyValues[:], ","), v))
+ }
+ }
+ }
+ }
+ if !state.Entries[i].MatchAsPathsLegacy.IsNull() {
+ if data.Entries[j].MatchAsPathsLegacy.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/match/as-path/access-list", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ } else {
+ var dataValues, stateValues []int
+ data.Entries[i].MatchAsPathsLegacy.ElementsAs(ctx, &dataValues, false)
+ state.Entries[j].MatchAsPathsLegacy.ElementsAs(ctx, &stateValues, false)
+ for _, v := range stateValues {
+ found := false
+ for _, vv := range dataValues {
+ if v == vv {
+ found = true
+ break
+ }
+ }
+ if !found {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/match/as-path/access-list=%v", state.getPath(), strings.Join(stateKeyValues[:], ","), v))
+ }
+ }
+ }
+ }
+ if !state.Entries[i].MatchTrack.IsNull() && data.Entries[j].MatchTrack.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/match/track", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ if !state.Entries[i].MatchTags.IsNull() {
+ if data.Entries[j].MatchTags.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/match/tag/tag_value", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ } else {
+ var dataValues, stateValues []int
+ data.Entries[i].MatchTags.ElementsAs(ctx, &dataValues, false)
+ state.Entries[j].MatchTags.ElementsAs(ctx, &stateValues, false)
+ for _, v := range stateValues {
+ found := false
+ for _, vv := range dataValues {
+ if v == vv {
+ found = true
+ break
+ }
+ }
+ if !found {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/match/tag/tag_value=%v", state.getPath(), strings.Join(stateKeyValues[:], ","), v))
+ }
+ }
+ }
+ }
+ if !state.Entries[i].MatchSourceProtocolStatic.IsNull() && data.Entries[j].MatchSourceProtocolStatic.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/match/source-protocol/static", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ if !state.Entries[i].MatchSourceProtocolRip.IsNull() && data.Entries[j].MatchSourceProtocolRip.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/match/source-protocol/rip", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ if !state.Entries[i].MatchSourceProtocolOspfv3.IsNull() {
+ if data.Entries[j].MatchSourceProtocolOspfv3.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/match/source-protocol/ospfv3", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ } else {
+ var dataValues, stateValues []string
+ data.Entries[i].MatchSourceProtocolOspfv3.ElementsAs(ctx, &dataValues, false)
+ state.Entries[j].MatchSourceProtocolOspfv3.ElementsAs(ctx, &stateValues, false)
+ for _, v := range stateValues {
+ found := false
+ for _, vv := range dataValues {
+ if v == vv {
+ found = true
+ break
+ }
+ }
+ if !found {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/match/source-protocol/ospfv3=%v", state.getPath(), strings.Join(stateKeyValues[:], ","), v))
+ }
+ }
+ }
+ }
+ if !state.Entries[i].MatchSourceProtocolOspf.IsNull() {
+ if data.Entries[j].MatchSourceProtocolOspf.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/match/source-protocol/ospf", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ } else {
+ var dataValues, stateValues []string
+ data.Entries[i].MatchSourceProtocolOspf.ElementsAs(ctx, &dataValues, false)
+ state.Entries[j].MatchSourceProtocolOspf.ElementsAs(ctx, &stateValues, false)
+ for _, v := range stateValues {
+ found := false
+ for _, vv := range dataValues {
+ if v == vv {
+ found = true
+ break
+ }
+ }
+ if !found {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/match/source-protocol/ospf=%v", state.getPath(), strings.Join(stateKeyValues[:], ","), v))
+ }
+ }
+ }
+ }
+ if !state.Entries[i].MatchSourceProtocolLisp.IsNull() && data.Entries[j].MatchSourceProtocolLisp.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/match/source-protocol/lisp", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ if !state.Entries[i].MatchSourceProtocolIsis.IsNull() && data.Entries[j].MatchSourceProtocolIsis.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/match/source-protocol/isis", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ if !state.Entries[i].MatchSourceProtocolEigrp.IsNull() {
+ if data.Entries[j].MatchSourceProtocolEigrp.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/match/source-protocol/eigrp", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ } else {
+ var dataValues, stateValues []string
+ data.Entries[i].MatchSourceProtocolEigrp.ElementsAs(ctx, &dataValues, false)
+ state.Entries[j].MatchSourceProtocolEigrp.ElementsAs(ctx, &stateValues, false)
+ for _, v := range stateValues {
+ found := false
+ for _, vv := range dataValues {
+ if v == vv {
+ found = true
+ break
+ }
+ }
+ if !found {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/match/source-protocol/eigrp=%v", state.getPath(), strings.Join(stateKeyValues[:], ","), v))
+ }
+ }
+ }
+ }
+ if !state.Entries[i].MatchSourceProtocolConnected.IsNull() && data.Entries[j].MatchSourceProtocolConnected.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/match/source-protocol/connected", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ if !state.Entries[i].MatchSourceProtocolBgp.IsNull() {
+ if data.Entries[j].MatchSourceProtocolBgp.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/match/source-protocol/bgp", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ } else {
+ var dataValues, stateValues []string
+ data.Entries[i].MatchSourceProtocolBgp.ElementsAs(ctx, &dataValues, false)
+ state.Entries[j].MatchSourceProtocolBgp.ElementsAs(ctx, &stateValues, false)
+ for _, v := range stateValues {
+ found := false
+ for _, vv := range dataValues {
+ if v == vv {
+ found = true
+ break
+ }
+ }
+ if !found {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/match/source-protocol/bgp=%v", state.getPath(), strings.Join(stateKeyValues[:], ","), v))
+ }
+ }
+ }
+ }
+ if !state.Entries[i].MatchRouteTypeLocal.IsNull() && data.Entries[j].MatchRouteTypeLocal.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/match/Cisco-IOS-XE-bgp:bgp-route-map-match/route-type/local", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ if !state.Entries[i].MatchRouteTypeLocalLegacy.IsNull() && data.Entries[j].MatchRouteTypeLocalLegacy.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/match/route-type/local", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ if !state.Entries[i].MatchRouteTypeLevel2.IsNull() && data.Entries[j].MatchRouteTypeLevel2.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/match/route-type/level-2", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ if !state.Entries[i].MatchRouteTypeLevel1.IsNull() && data.Entries[j].MatchRouteTypeLevel1.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/match/route-type/level-1", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ if !state.Entries[i].MatchRouteTypeInternal.IsNull() && data.Entries[j].MatchRouteTypeInternal.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/match/route-type/internal", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ if !state.Entries[i].MatchRouteTypeExternalType2.IsNull() && data.Entries[j].MatchRouteTypeExternalType2.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/match/route-type/external/type-2", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ if !state.Entries[i].MatchRouteTypeExternalType1.IsNull() && data.Entries[j].MatchRouteTypeExternalType1.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/match/route-type/external/type-1", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ if !state.Entries[i].MatchRouteTypeExternal.IsNull() && data.Entries[j].MatchRouteTypeExternal.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/match/route-type/external", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ if !state.Entries[i].MatchIpv6NextHopPrefixLists.IsNull() && data.Entries[j].MatchIpv6NextHopPrefixLists.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/match/ipv6/next-hop/prefix-list", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ if !state.Entries[i].MatchIpv6NextHopAccessLists.IsNull() && data.Entries[j].MatchIpv6NextHopAccessLists.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/match/ipv6/next-hop/access-list", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ if !state.Entries[i].MatchIpv6AddressPrefixLists.IsNull() && data.Entries[j].MatchIpv6AddressPrefixLists.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/match/ipv6/address/prefix-list", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ if !state.Entries[i].MatchIpv6AddressAccessLists.IsNull() && data.Entries[j].MatchIpv6AddressAccessLists.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/match/ipv6/address/access-list", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ if !state.Entries[i].MatchIpNextHopPrefixLists.IsNull() {
+ if data.Entries[j].MatchIpNextHopPrefixLists.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/match/ip/next-hop/prefix-list", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ } else {
+ var dataValues, stateValues []string
+ data.Entries[i].MatchIpNextHopPrefixLists.ElementsAs(ctx, &dataValues, false)
+ state.Entries[j].MatchIpNextHopPrefixLists.ElementsAs(ctx, &stateValues, false)
+ for _, v := range stateValues {
+ found := false
+ for _, vv := range dataValues {
+ if v == vv {
+ found = true
+ break
+ }
+ }
+ if !found {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/match/ip/next-hop/prefix-list=%v", state.getPath(), strings.Join(stateKeyValues[:], ","), v))
+ }
+ }
+ }
+ }
+ if !state.Entries[i].MatchIpNextHopAccessLists.IsNull() {
+ if data.Entries[j].MatchIpNextHopAccessLists.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/match/ip/next-hop/access-list", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ } else {
+ var dataValues, stateValues []string
+ data.Entries[i].MatchIpNextHopAccessLists.ElementsAs(ctx, &dataValues, false)
+ state.Entries[j].MatchIpNextHopAccessLists.ElementsAs(ctx, &stateValues, false)
+ for _, v := range stateValues {
+ found := false
+ for _, vv := range dataValues {
+ if v == vv {
+ found = true
+ break
+ }
+ }
+ if !found {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/match/ip/next-hop/access-list=%v", state.getPath(), strings.Join(stateKeyValues[:], ","), v))
+ }
+ }
+ }
+ }
+ if !state.Entries[i].MatchIpAddressPrefixLists.IsNull() {
+ if data.Entries[j].MatchIpAddressPrefixLists.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/match/ip/address/prefix-list", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ } else {
+ var dataValues, stateValues []string
+ data.Entries[i].MatchIpAddressPrefixLists.ElementsAs(ctx, &dataValues, false)
+ state.Entries[j].MatchIpAddressPrefixLists.ElementsAs(ctx, &stateValues, false)
+ for _, v := range stateValues {
+ found := false
+ for _, vv := range dataValues {
+ if v == vv {
+ found = true
+ break
+ }
+ }
+ if !found {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/match/ip/address/prefix-list=%v", state.getPath(), strings.Join(stateKeyValues[:], ","), v))
+ }
+ }
+ }
+ }
+ if !state.Entries[i].MatchIpAddressAccessLists.IsNull() {
+ if data.Entries[j].MatchIpAddressAccessLists.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/match/ip/address/access-list", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ } else {
+ var dataValues, stateValues []string
+ data.Entries[i].MatchIpAddressAccessLists.ElementsAs(ctx, &dataValues, false)
+ state.Entries[j].MatchIpAddressAccessLists.ElementsAs(ctx, &stateValues, false)
+ for _, v := range stateValues {
+ found := false
+ for _, vv := range dataValues {
+ if v == vv {
+ found = true
+ break
+ }
+ }
+ if !found {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/match/ip/address/access-list=%v", state.getPath(), strings.Join(stateKeyValues[:], ","), v))
+ }
+ }
+ }
+ }
+ if !state.Entries[i].MatchInterfaces.IsNull() {
+ if data.Entries[j].MatchInterfaces.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/match/interface/interface", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ } else {
+ var dataValues, stateValues []string
+ data.Entries[i].MatchInterfaces.ElementsAs(ctx, &dataValues, false)
+ state.Entries[j].MatchInterfaces.ElementsAs(ctx, &stateValues, false)
+ for _, v := range stateValues {
+ found := false
+ for _, vv := range dataValues {
+ if v == vv {
+ found = true
+ break
+ }
+ }
+ if !found {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/match/interface/interface=%v", state.getPath(), strings.Join(stateKeyValues[:], ","), v))
+ }
+ }
+ }
+ }
+ if !state.Entries[i].ContinueSequenceNumber.IsNull() && data.Entries[j].ContinueSequenceNumber.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/continue/sequence-number", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ if !state.Entries[i].Continue.IsNull() && data.Entries[j].Continue.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/continue", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ if !state.Entries[i].Description.IsNull() && data.Entries[j].Description.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/description", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ if !state.Entries[i].Operation.IsNull() && data.Entries[j].Operation.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/operation", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ break
}
- data.Entries = append(data.Entries, item)
- return true
- })
+ }
+ if !found {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
}
+
+ return deletedItems
}
-// End of section. //template:end fromBodyData
+// End of section. //template:end getDeletedItems
-// Section below is generated&owned by "gen/generator.go". //template:begin getDeletedItems
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletedItemsXML
-func (data *RouteMap) getDeletedItems(ctx context.Context, state RouteMap) []string {
- deletedItems := make([]string, 0)
+func (data *RouteMap) addDeletedItemsXML(ctx context.Context, state RouteMap, body string) string {
+ b := netconf.NewBody(body)
for i := range state.Entries {
+ stateKeys := [...]string{"seq_no"}
stateKeyValues := [...]string{strconv.FormatInt(state.Entries[i].Seq.ValueInt64(), 10)}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
emptyKeys := true
if !reflect.ValueOf(state.Entries[i].Seq.ValueInt64()).IsZero() {
@@ -2245,28 +5337,25 @@ func (data *RouteMap) getDeletedItems(ctx context.Context, state RouteMap) []str
found = false
}
if found {
- if !state.Entries[i].SetWeight.IsNull() && data.Entries[j].SetWeight.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/set/Cisco-IOS-XE-bgp:bgp-route-map-set/weight", state.getPath(), strings.Join(stateKeyValues[:], ",")))
- }
- if !state.Entries[i].SetLocalPreference.IsNull() && data.Entries[j].SetLocalPreference.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/set/Cisco-IOS-XE-bgp:bgp-route-map-set/local-preference", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ if !state.Entries[i].Operation.IsNull() && data.Entries[j].Operation.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-route-map:route-map-without-order-seq%v/operation", predicates))
}
- if !state.Entries[i].SetExtcomunityVpnDistinguisherAdditive.IsNull() && data.Entries[j].SetExtcomunityVpnDistinguisherAdditive.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/set/Cisco-IOS-XE-bgp:bgp-route-map-set/extcommunity/vpn-distinguisher/asn-nn-additive", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ if !state.Entries[i].Description.IsNull() && data.Entries[j].Description.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-route-map:route-map-without-order-seq%v/description", predicates))
}
- if !state.Entries[i].SetExtcomunityVpnDistinguisher.IsNull() && data.Entries[j].SetExtcomunityVpnDistinguisher.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/set/Cisco-IOS-XE-bgp:bgp-route-map-set/extcommunity/vpn-distinguisher/asn-nn", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ if !state.Entries[i].Continue.IsNull() && data.Entries[j].Continue.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-route-map:route-map-without-order-seq%v/continue", predicates))
}
- if !state.Entries[i].SetExtcomunitySoo.IsNull() && data.Entries[j].SetExtcomunitySoo.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/set/Cisco-IOS-XE-bgp:bgp-route-map-set/extcommunity/soo/asn-nn", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ if !state.Entries[i].ContinueSequenceNumber.IsNull() && data.Entries[j].ContinueSequenceNumber.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-route-map:route-map-without-order-seq%v/continue/sequence-number", predicates))
}
- if !state.Entries[i].SetExtcomunityRt.IsNull() {
- if data.Entries[j].SetExtcomunityRt.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/set/Cisco-IOS-XE-bgp:bgp-route-map-set/extcommunity/rt/asn-nn", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ if !state.Entries[i].MatchInterfaces.IsNull() {
+ if data.Entries[j].MatchInterfaces.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-route-map:route-map-without-order-seq%v/match/interface/interface", predicates))
} else {
var dataValues, stateValues []string
- data.Entries[i].SetExtcomunityRt.ElementsAs(ctx, &dataValues, false)
- state.Entries[j].SetExtcomunityRt.ElementsAs(ctx, &stateValues, false)
+ data.Entries[i].MatchInterfaces.ElementsAs(ctx, &dataValues, false)
+ state.Entries[j].MatchInterfaces.ElementsAs(ctx, &stateValues, false)
for _, v := range stateValues {
found := false
for _, vv := range dataValues {
@@ -2276,33 +5365,18 @@ func (data *RouteMap) getDeletedItems(ctx context.Context, state RouteMap) []str
}
}
if !found {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/set/Cisco-IOS-XE-bgp:bgp-route-map-set/extcommunity/rt/asn-nn=%v", state.getPath(), strings.Join(stateKeyValues[:], ","), v))
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-route-map:route-map-without-order-seq%v/match/interface/interface[.=%v]", predicates, v))
}
}
}
}
- if !state.Entries[i].SetCommunityListName.IsNull() && data.Entries[j].SetCommunityListName.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/set/Cisco-IOS-XE-bgp:bgp-route-map-set/comm-list/comm-list-name", state.getPath(), strings.Join(stateKeyValues[:], ",")))
- }
- if !state.Entries[i].SetCommunityListExpanded.IsNull() && data.Entries[j].SetCommunityListExpanded.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/set/Cisco-IOS-XE-bgp:bgp-route-map-set/comm-list/comm-list-expanded", state.getPath(), strings.Join(stateKeyValues[:], ",")))
- }
- if !state.Entries[i].SetCommunityListStandard.IsNull() && data.Entries[j].SetCommunityListStandard.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/set/Cisco-IOS-XE-bgp:bgp-route-map-set/comm-list/comm-list-standard", state.getPath(), strings.Join(stateKeyValues[:], ",")))
- }
- if !state.Entries[i].SetCommunityListDelete.IsNull() && data.Entries[j].SetCommunityListDelete.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/set/Cisco-IOS-XE-bgp:bgp-route-map-set/comm-list/delete", state.getPath(), strings.Join(stateKeyValues[:], ",")))
- }
- if !state.Entries[i].SetCommunitiesAdditive.IsNull() && data.Entries[j].SetCommunitiesAdditive.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/set/Cisco-IOS-XE-bgp:bgp-route-map-set/bgp-community/community-well-known/additive", state.getPath(), strings.Join(stateKeyValues[:], ",")))
- }
- if !state.Entries[i].SetCommunities.IsNull() {
- if data.Entries[j].SetCommunities.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/set/Cisco-IOS-XE-bgp:bgp-route-map-set/bgp-community/community-well-known/community-list", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ if !state.Entries[i].MatchIpAddressAccessLists.IsNull() {
+ if data.Entries[j].MatchIpAddressAccessLists.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-route-map:route-map-without-order-seq%v/match/ip/address/access-list", predicates))
} else {
var dataValues, stateValues []string
- data.Entries[i].SetCommunities.ElementsAs(ctx, &dataValues, false)
- state.Entries[j].SetCommunities.ElementsAs(ctx, &stateValues, false)
+ data.Entries[i].MatchIpAddressAccessLists.ElementsAs(ctx, &dataValues, false)
+ state.Entries[j].MatchIpAddressAccessLists.ElementsAs(ctx, &stateValues, false)
for _, v := range stateValues {
found := false
for _, vv := range dataValues {
@@ -2312,70 +5386,18 @@ func (data *RouteMap) getDeletedItems(ctx context.Context, state RouteMap) []str
}
}
if !found {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/set/Cisco-IOS-XE-bgp:bgp-route-map-set/bgp-community/community-well-known/community-list=%v", state.getPath(), strings.Join(stateKeyValues[:], ","), v))
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-route-map:route-map-without-order-seq%v/match/ip/address/access-list[.=%v]", predicates, v))
}
}
}
}
- if !state.Entries[i].SetCommunityNone.IsNull() && data.Entries[j].SetCommunityNone.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/set/Cisco-IOS-XE-bgp:bgp-route-map-set/bgp-community/none", state.getPath(), strings.Join(stateKeyValues[:], ",")))
- }
- for ci := range state.Entries[i].SetAsPathReplaceAs {
- cstateKeyValues := [...]string{state.Entries[i].SetAsPathReplaceAs[ci].AsNumber.ValueString()}
-
- cemptyKeys := true
- if !reflect.ValueOf(state.Entries[i].SetAsPathReplaceAs[ci].AsNumber.ValueString()).IsZero() {
- cemptyKeys = false
- }
- if cemptyKeys {
- continue
- }
-
- found := false
- for cj := range data.Entries[j].SetAsPathReplaceAs {
- found = true
- if state.Entries[i].SetAsPathReplaceAs[ci].AsNumber.ValueString() != data.Entries[j].SetAsPathReplaceAs[cj].AsNumber.ValueString() {
- found = false
- }
- if found {
- break
- }
- }
- if !found {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/set/Cisco-IOS-XE-bgp:bgp-route-map-set/as-path/replace/as-container=%v", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
- }
- }
- if !state.Entries[i].SetAsPathReplaceAny.IsNull() && data.Entries[j].SetAsPathReplaceAny.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/set/Cisco-IOS-XE-bgp:bgp-route-map-set/as-path/replace/any", state.getPath(), strings.Join(stateKeyValues[:], ",")))
- }
- if !state.Entries[i].SetAsPathTag.IsNull() && data.Entries[j].SetAsPathTag.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/set/Cisco-IOS-XE-bgp:bgp-route-map-set/as-path/tag", state.getPath(), strings.Join(stateKeyValues[:], ",")))
- }
- if !state.Entries[i].SetAsPathPrependLastAs.IsNull() && data.Entries[j].SetAsPathPrependLastAs.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/set/Cisco-IOS-XE-bgp:bgp-route-map-set/as-path/prepend/last-as-cont/last-as", state.getPath(), strings.Join(stateKeyValues[:], ",")))
- }
- if !state.Entries[i].SetAsPathPrependAs.IsNull() && data.Entries[j].SetAsPathPrependAs.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/set/Cisco-IOS-XE-bgp:bgp-route-map-set/as-path/prepend/as-container/as-number", state.getPath(), strings.Join(stateKeyValues[:], ",")))
- }
- if !state.Entries[i].SetWeightLegacy.IsNull() && data.Entries[j].SetWeightLegacy.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/set/weight", state.getPath(), strings.Join(stateKeyValues[:], ",")))
- }
- if !state.Entries[i].SetLocalPreferenceLegacy.IsNull() && data.Entries[j].SetLocalPreferenceLegacy.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/set/local-preference", state.getPath(), strings.Join(stateKeyValues[:], ",")))
- }
- if !state.Entries[i].SetExtcomunityVpnDistinguisherLegacy.IsNull() && data.Entries[j].SetExtcomunityVpnDistinguisherLegacy.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/set/extcommunity/vpn-distinguisher/asn-nn", state.getPath(), strings.Join(stateKeyValues[:], ",")))
- }
- if !state.Entries[i].SetExtcomunitySooLegacy.IsNull() && data.Entries[j].SetExtcomunitySooLegacy.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/set/extcommunity/soo/asn-nn", state.getPath(), strings.Join(stateKeyValues[:], ",")))
- }
- if !state.Entries[i].SetExtcomunityRtLegacy.IsNull() {
- if data.Entries[j].SetExtcomunityRtLegacy.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/set/extcommunity/rt/asn-nn", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ if !state.Entries[i].MatchIpAddressPrefixLists.IsNull() {
+ if data.Entries[j].MatchIpAddressPrefixLists.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-route-map:route-map-without-order-seq%v/match/ip/address/prefix-list", predicates))
} else {
var dataValues, stateValues []string
- data.Entries[i].SetExtcomunityRtLegacy.ElementsAs(ctx, &dataValues, false)
- state.Entries[j].SetExtcomunityRtLegacy.ElementsAs(ctx, &stateValues, false)
+ data.Entries[i].MatchIpAddressPrefixLists.ElementsAs(ctx, &dataValues, false)
+ state.Entries[j].MatchIpAddressPrefixLists.ElementsAs(ctx, &stateValues, false)
for _, v := range stateValues {
found := false
for _, vv := range dataValues {
@@ -2385,33 +5407,18 @@ func (data *RouteMap) getDeletedItems(ctx context.Context, state RouteMap) []str
}
}
if !found {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/set/extcommunity/rt/asn-nn=%v", state.getPath(), strings.Join(stateKeyValues[:], ","), v))
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-route-map:route-map-without-order-seq%v/match/ip/address/prefix-list[.=%v]", predicates, v))
}
}
}
}
- if !state.Entries[i].SetCommunityListNameLegacy.IsNull() && data.Entries[j].SetCommunityListNameLegacy.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/set/comm-list/comm-list-name", state.getPath(), strings.Join(stateKeyValues[:], ",")))
- }
- if !state.Entries[i].SetCommunityListExpandedLegacy.IsNull() && data.Entries[j].SetCommunityListExpandedLegacy.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/set/Cisco-IOS-XE-bgp:bgp-route-map-set/comm-list/comm-list-expanded", state.getPath(), strings.Join(stateKeyValues[:], ",")))
- }
- if !state.Entries[i].SetCommunityListStandardLegacy.IsNull() && data.Entries[j].SetCommunityListStandardLegacy.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/set/comm-list/comm-list-standard", state.getPath(), strings.Join(stateKeyValues[:], ",")))
- }
- if !state.Entries[i].SetCommunityListDeleteLegacy.IsNull() && data.Entries[j].SetCommunityListDeleteLegacy.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/set/comm-list/delete", state.getPath(), strings.Join(stateKeyValues[:], ",")))
- }
- if !state.Entries[i].SetCommunitiesAdditiveLegacy.IsNull() && data.Entries[j].SetCommunitiesAdditiveLegacy.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/set/community/community-well-known/additive", state.getPath(), strings.Join(stateKeyValues[:], ",")))
- }
- if !state.Entries[i].SetCommunitiesLegacy.IsNull() {
- if data.Entries[j].SetCommunitiesLegacy.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/set/community/community-well-known/community-list", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ if !state.Entries[i].MatchIpNextHopAccessLists.IsNull() {
+ if data.Entries[j].MatchIpNextHopAccessLists.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-route-map:route-map-without-order-seq%v/match/ip/next-hop/access-list", predicates))
} else {
var dataValues, stateValues []string
- data.Entries[i].SetCommunitiesLegacy.ElementsAs(ctx, &dataValues, false)
- state.Entries[j].SetCommunitiesLegacy.ElementsAs(ctx, &stateValues, false)
+ data.Entries[i].MatchIpNextHopAccessLists.ElementsAs(ctx, &dataValues, false)
+ state.Entries[j].MatchIpNextHopAccessLists.ElementsAs(ctx, &stateValues, false)
for _, v := range stateValues {
found := false
for _, vv := range dataValues {
@@ -2421,66 +5428,75 @@ func (data *RouteMap) getDeletedItems(ctx context.Context, state RouteMap) []str
}
}
if !found {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/set/community/community-well-known/community-list=%v", state.getPath(), strings.Join(stateKeyValues[:], ","), v))
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-route-map:route-map-without-order-seq%v/match/ip/next-hop/access-list[.=%v]", predicates, v))
}
}
}
}
- if !state.Entries[i].SetCommunityNoneLegacy.IsNull() && data.Entries[j].SetCommunityNoneLegacy.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/set/community/none", state.getPath(), strings.Join(stateKeyValues[:], ",")))
- }
- if !state.Entries[i].SetAsPathTagLegacy.IsNull() && data.Entries[j].SetAsPathTagLegacy.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/set/as-path/tag", state.getPath(), strings.Join(stateKeyValues[:], ",")))
- }
- if !state.Entries[i].SetAsPathPrependLastAsLegacy.IsNull() && data.Entries[j].SetAsPathPrependLastAsLegacy.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/set/as-path/prepend/last-as-cont/last-as", state.getPath(), strings.Join(stateKeyValues[:], ",")))
- }
- if !state.Entries[i].SetAsPathPrependAsLegacy.IsNull() && data.Entries[j].SetAsPathPrependAsLegacy.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/set/as-path/prepend/as-container/as-number", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ if !state.Entries[i].MatchIpNextHopPrefixLists.IsNull() {
+ if data.Entries[j].MatchIpNextHopPrefixLists.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-route-map:route-map-without-order-seq%v/match/ip/next-hop/prefix-list", predicates))
+ } else {
+ var dataValues, stateValues []string
+ data.Entries[i].MatchIpNextHopPrefixLists.ElementsAs(ctx, &dataValues, false)
+ state.Entries[j].MatchIpNextHopPrefixLists.ElementsAs(ctx, &stateValues, false)
+ for _, v := range stateValues {
+ found := false
+ for _, vv := range dataValues {
+ if v == vv {
+ found = true
+ break
+ }
+ }
+ if !found {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-route-map:route-map-without-order-seq%v/match/ip/next-hop/prefix-list[.=%v]", predicates, v))
+ }
+ }
+ }
}
- if !state.Entries[i].SetVrf.IsNull() && data.Entries[j].SetVrf.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/set/vrf", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ if !state.Entries[i].MatchIpv6AddressAccessLists.IsNull() && data.Entries[j].MatchIpv6AddressAccessLists.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-route-map:route-map-without-order-seq%v/match/ipv6/address/access-list", predicates))
}
- if !state.Entries[i].SetTag.IsNull() && data.Entries[j].SetTag.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/set/tag/tag-val", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ if !state.Entries[i].MatchIpv6AddressPrefixLists.IsNull() && data.Entries[j].MatchIpv6AddressPrefixLists.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-route-map:route-map-without-order-seq%v/match/ipv6/address/prefix-list", predicates))
}
- if !state.Entries[i].SetMetricType.IsNull() && data.Entries[j].SetMetricType.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/set/metric-type", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ if !state.Entries[i].MatchIpv6NextHopAccessLists.IsNull() && data.Entries[j].MatchIpv6NextHopAccessLists.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-route-map:route-map-without-order-seq%v/match/ipv6/next-hop/access-list", predicates))
}
- if !state.Entries[i].SetMetricMtu.IsNull() && data.Entries[j].SetMetricMtu.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/set/metric/values/MTU", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ if !state.Entries[i].MatchIpv6NextHopPrefixLists.IsNull() && data.Entries[j].MatchIpv6NextHopPrefixLists.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-route-map:route-map-without-order-seq%v/match/ipv6/next-hop/prefix-list", predicates))
}
- if !state.Entries[i].SetMetricLoading.IsNull() && data.Entries[j].SetMetricLoading.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/set/metric/values/loading", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ if !state.Entries[i].MatchRouteTypeExternal.IsNull() && data.Entries[j].MatchRouteTypeExternal.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-route-map:route-map-without-order-seq%v/match/route-type/external", predicates))
}
- if !state.Entries[i].SetMetricReliability.IsNull() && data.Entries[j].SetMetricReliability.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/set/metric/values/reliability", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ if !state.Entries[i].MatchRouteTypeExternalType1.IsNull() && data.Entries[j].MatchRouteTypeExternalType1.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-route-map:route-map-without-order-seq%v/match/route-type/external/type-1", predicates))
}
- if !state.Entries[i].SetMetricDelay.IsNull() && data.Entries[j].SetMetricDelay.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/set/metric/values/delay", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ if !state.Entries[i].MatchRouteTypeExternalType2.IsNull() && data.Entries[j].MatchRouteTypeExternalType2.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-route-map:route-map-without-order-seq%v/match/route-type/external/type-2", predicates))
}
- if !state.Entries[i].SetMetricValue.IsNull() && data.Entries[j].SetMetricValue.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/set/metric/values/value", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ if !state.Entries[i].MatchRouteTypeInternal.IsNull() && data.Entries[j].MatchRouteTypeInternal.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-route-map:route-map-without-order-seq%v/match/route-type/internal", predicates))
}
- if !state.Entries[i].SetMetricChange.IsNull() && data.Entries[j].SetMetricChange.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/set/metric/metric-change", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ if !state.Entries[i].MatchRouteTypeLevel1.IsNull() && data.Entries[j].MatchRouteTypeLevel1.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-route-map:route-map-without-order-seq%v/match/route-type/level-1", predicates))
}
- if !state.Entries[i].SetLevel2.IsNull() && data.Entries[j].SetLevel2.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/set/level/level-2", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ if !state.Entries[i].MatchRouteTypeLevel2.IsNull() && data.Entries[j].MatchRouteTypeLevel2.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-route-map:route-map-without-order-seq%v/match/route-type/level-2", predicates))
}
- if !state.Entries[i].SetLevel12.IsNull() && data.Entries[j].SetLevel12.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/set/level/level-1-2", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ if !state.Entries[i].MatchRouteTypeLocalLegacy.IsNull() && data.Entries[j].MatchRouteTypeLocalLegacy.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-route-map:route-map-without-order-seq%v/match/route-type/local", predicates))
}
- if !state.Entries[i].SetLevel1.IsNull() && data.Entries[j].SetLevel1.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/set/level/level-1", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ if !state.Entries[i].MatchRouteTypeLocal.IsNull() && data.Entries[j].MatchRouteTypeLocal.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-route-map:route-map-without-order-seq%v/match/Cisco-IOS-XE-bgp:bgp-route-map-match/route-type/local", predicates))
}
- if !state.Entries[i].SetIpv6NextHop.IsNull() {
- if data.Entries[j].SetIpv6NextHop.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/set/ipv6/next-hop/ipv6", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ if !state.Entries[i].MatchSourceProtocolBgp.IsNull() {
+ if data.Entries[j].MatchSourceProtocolBgp.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-route-map:route-map-without-order-seq%v/match/source-protocol/bgp", predicates))
} else {
var dataValues, stateValues []string
- data.Entries[i].SetIpv6NextHop.ElementsAs(ctx, &dataValues, false)
- state.Entries[j].SetIpv6NextHop.ElementsAs(ctx, &stateValues, false)
+ data.Entries[i].MatchSourceProtocolBgp.ElementsAs(ctx, &dataValues, false)
+ state.Entries[j].MatchSourceProtocolBgp.ElementsAs(ctx, &stateValues, false)
for _, v := range stateValues {
found := false
for _, vv := range dataValues {
@@ -2490,18 +5506,21 @@ func (data *RouteMap) getDeletedItems(ctx context.Context, state RouteMap) []str
}
}
if !found {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/set/ipv6/next-hop/ipv6=%v", state.getPath(), strings.Join(stateKeyValues[:], ","), v))
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-route-map:route-map-without-order-seq%v/match/source-protocol/bgp[.=%v]", predicates, v))
}
}
}
}
- if !state.Entries[i].SetIpv6DefaultNextHop.IsNull() {
- if data.Entries[j].SetIpv6DefaultNextHop.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/set/ipv6/default/next-hop/ipv6", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ if !state.Entries[i].MatchSourceProtocolConnected.IsNull() && data.Entries[j].MatchSourceProtocolConnected.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-route-map:route-map-without-order-seq%v/match/source-protocol/connected", predicates))
+ }
+ if !state.Entries[i].MatchSourceProtocolEigrp.IsNull() {
+ if data.Entries[j].MatchSourceProtocolEigrp.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-route-map:route-map-without-order-seq%v/match/source-protocol/eigrp", predicates))
} else {
var dataValues, stateValues []string
- data.Entries[i].SetIpv6DefaultNextHop.ElementsAs(ctx, &dataValues, false)
- state.Entries[j].SetIpv6DefaultNextHop.ElementsAs(ctx, &stateValues, false)
+ data.Entries[i].MatchSourceProtocolEigrp.ElementsAs(ctx, &dataValues, false)
+ state.Entries[j].MatchSourceProtocolEigrp.ElementsAs(ctx, &stateValues, false)
for _, v := range stateValues {
found := false
for _, vv := range dataValues {
@@ -2511,21 +5530,24 @@ func (data *RouteMap) getDeletedItems(ctx context.Context, state RouteMap) []str
}
}
if !found {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/set/ipv6/default/next-hop/ipv6=%v", state.getPath(), strings.Join(stateKeyValues[:], ","), v))
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-route-map:route-map-without-order-seq%v/match/source-protocol/eigrp[.=%v]", predicates, v))
}
}
}
}
- if !state.Entries[i].SetIpv6DefaultGlobalNextHop.IsNull() && data.Entries[j].SetIpv6DefaultGlobalNextHop.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/set/ipv6/default/global/next-hop", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ if !state.Entries[i].MatchSourceProtocolIsis.IsNull() && data.Entries[j].MatchSourceProtocolIsis.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-route-map:route-map-without-order-seq%v/match/source-protocol/isis", predicates))
}
- if !state.Entries[i].SetIpv6Address.IsNull() {
- if data.Entries[j].SetIpv6Address.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/set/ipv6/address/prefix-list", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ if !state.Entries[i].MatchSourceProtocolLisp.IsNull() && data.Entries[j].MatchSourceProtocolLisp.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-route-map:route-map-without-order-seq%v/match/source-protocol/lisp", predicates))
+ }
+ if !state.Entries[i].MatchSourceProtocolOspf.IsNull() {
+ if data.Entries[j].MatchSourceProtocolOspf.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-route-map:route-map-without-order-seq%v/match/source-protocol/ospf", predicates))
} else {
var dataValues, stateValues []string
- data.Entries[i].SetIpv6Address.ElementsAs(ctx, &dataValues, false)
- state.Entries[j].SetIpv6Address.ElementsAs(ctx, &stateValues, false)
+ data.Entries[i].MatchSourceProtocolOspf.ElementsAs(ctx, &dataValues, false)
+ state.Entries[j].MatchSourceProtocolOspf.ElementsAs(ctx, &stateValues, false)
for _, v := range stateValues {
found := false
for _, vv := range dataValues {
@@ -2535,24 +5557,18 @@ func (data *RouteMap) getDeletedItems(ctx context.Context, state RouteMap) []str
}
}
if !found {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/set/ipv6/address/prefix-list=%v", state.getPath(), strings.Join(stateKeyValues[:], ","), v))
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-route-map:route-map-without-order-seq%v/match/source-protocol/ospf[.=%v]", predicates, v))
}
}
}
}
- if !state.Entries[i].SetIpQosGroup.IsNull() && data.Entries[j].SetIpQosGroup.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/set/ip/qos-group/qos-id", state.getPath(), strings.Join(stateKeyValues[:], ",")))
- }
- if !state.Entries[i].SetIpNextHopSelf.IsNull() && data.Entries[j].SetIpNextHopSelf.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/set/ip/next-hop/self", state.getPath(), strings.Join(stateKeyValues[:], ",")))
- }
- if !state.Entries[i].SetIpNextHopAddress.IsNull() {
- if data.Entries[j].SetIpNextHopAddress.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/set/ip/next-hop/address", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ if !state.Entries[i].MatchSourceProtocolOspfv3.IsNull() {
+ if data.Entries[j].MatchSourceProtocolOspfv3.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-route-map:route-map-without-order-seq%v/match/source-protocol/ospfv3", predicates))
} else {
var dataValues, stateValues []string
- data.Entries[i].SetIpNextHopAddress.ElementsAs(ctx, &dataValues, false)
- state.Entries[j].SetIpNextHopAddress.ElementsAs(ctx, &stateValues, false)
+ data.Entries[i].MatchSourceProtocolOspfv3.ElementsAs(ctx, &dataValues, false)
+ state.Entries[j].MatchSourceProtocolOspfv3.ElementsAs(ctx, &stateValues, false)
for _, v := range stateValues {
found := false
for _, vv := range dataValues {
@@ -2562,18 +5578,24 @@ func (data *RouteMap) getDeletedItems(ctx context.Context, state RouteMap) []str
}
}
if !found {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/set/ip/next-hop/address=%v", state.getPath(), strings.Join(stateKeyValues[:], ","), v))
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-route-map:route-map-without-order-seq%v/match/source-protocol/ospfv3[.=%v]", predicates, v))
}
}
}
}
- if !state.Entries[i].SetIpGlobalNextHopAddress.IsNull() {
- if data.Entries[j].SetIpGlobalNextHopAddress.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/set/ip/global/next-hop/address", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ if !state.Entries[i].MatchSourceProtocolRip.IsNull() && data.Entries[j].MatchSourceProtocolRip.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-route-map:route-map-without-order-seq%v/match/source-protocol/rip", predicates))
+ }
+ if !state.Entries[i].MatchSourceProtocolStatic.IsNull() && data.Entries[j].MatchSourceProtocolStatic.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-route-map:route-map-without-order-seq%v/match/source-protocol/static", predicates))
+ }
+ if !state.Entries[i].MatchTags.IsNull() {
+ if data.Entries[j].MatchTags.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-route-map:route-map-without-order-seq%v/match/tag/tag_value", predicates))
} else {
- var dataValues, stateValues []string
- data.Entries[i].SetIpGlobalNextHopAddress.ElementsAs(ctx, &dataValues, false)
- state.Entries[j].SetIpGlobalNextHopAddress.ElementsAs(ctx, &stateValues, false)
+ var dataValues, stateValues []int
+ data.Entries[i].MatchTags.ElementsAs(ctx, &dataValues, false)
+ state.Entries[j].MatchTags.ElementsAs(ctx, &stateValues, false)
for _, v := range stateValues {
found := false
for _, vv := range dataValues {
@@ -2583,18 +5605,21 @@ func (data *RouteMap) getDeletedItems(ctx context.Context, state RouteMap) []str
}
}
if !found {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/set/ip/global/next-hop/address=%v", state.getPath(), strings.Join(stateKeyValues[:], ","), v))
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-route-map:route-map-without-order-seq%v/match/tag/tag_value[.=%v]", predicates, v))
}
}
}
}
- if !state.Entries[i].SetIpDefaultNextHopAddress.IsNull() {
- if data.Entries[j].SetIpDefaultNextHopAddress.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/set/ip/default/next-hop/address", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ if !state.Entries[i].MatchTrack.IsNull() && data.Entries[j].MatchTrack.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-route-map:route-map-without-order-seq%v/match/track", predicates))
+ }
+ if !state.Entries[i].MatchAsPathsLegacy.IsNull() {
+ if data.Entries[j].MatchAsPathsLegacy.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-route-map:route-map-without-order-seq%v/match/as-path/access-list", predicates))
} else {
- var dataValues, stateValues []string
- data.Entries[i].SetIpDefaultNextHopAddress.ElementsAs(ctx, &dataValues, false)
- state.Entries[j].SetIpDefaultNextHopAddress.ElementsAs(ctx, &stateValues, false)
+ var dataValues, stateValues []int
+ data.Entries[i].MatchAsPathsLegacy.ElementsAs(ctx, &dataValues, false)
+ state.Entries[j].MatchAsPathsLegacy.ElementsAs(ctx, &stateValues, false)
for _, v := range stateValues {
found := false
for _, vv := range dataValues {
@@ -2604,18 +5629,18 @@ func (data *RouteMap) getDeletedItems(ctx context.Context, state RouteMap) []str
}
}
if !found {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/set/ip/default/next-hop/address=%v", state.getPath(), strings.Join(stateKeyValues[:], ","), v))
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-route-map:route-map-without-order-seq%v/match/as-path/access-list[.=%v]", predicates, v))
}
}
}
}
- if !state.Entries[i].SetIpDefaultGlobalNextHopAddress.IsNull() {
- if data.Entries[j].SetIpDefaultGlobalNextHopAddress.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/set/ip/default/global/next-hop/address", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ if !state.Entries[i].MatchCommunityListsLegacy.IsNull() {
+ if data.Entries[j].MatchCommunityListsLegacy.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-route-map:route-map-without-order-seq%v/match/community/name", predicates))
} else {
var dataValues, stateValues []string
- data.Entries[i].SetIpDefaultGlobalNextHopAddress.ElementsAs(ctx, &dataValues, false)
- state.Entries[j].SetIpDefaultGlobalNextHopAddress.ElementsAs(ctx, &stateValues, false)
+ data.Entries[i].MatchCommunityListsLegacy.ElementsAs(ctx, &dataValues, false)
+ state.Entries[j].MatchCommunityListsLegacy.ElementsAs(ctx, &stateValues, false)
for _, v := range stateValues {
found := false
for _, vv := range dataValues {
@@ -2625,21 +5650,18 @@ func (data *RouteMap) getDeletedItems(ctx context.Context, state RouteMap) []str
}
}
if !found {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/set/ip/default/global/next-hop/address=%v", state.getPath(), strings.Join(stateKeyValues[:], ","), v))
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-route-map:route-map-without-order-seq%v/match/community/name[.=%v]", predicates, v))
}
}
}
}
- if !state.Entries[i].SetIpAddress.IsNull() && data.Entries[j].SetIpAddress.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/set/ip/address/prefix-list", state.getPath(), strings.Join(stateKeyValues[:], ",")))
- }
- if !state.Entries[i].SetInterfaces.IsNull() {
- if data.Entries[j].SetInterfaces.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/set/interface-list", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ if !state.Entries[i].MatchExtcommunityListsLegacy.IsNull() {
+ if data.Entries[j].MatchExtcommunityListsLegacy.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-route-map:route-map-without-order-seq%v/match/extcommunity/name", predicates))
} else {
var dataValues, stateValues []string
- data.Entries[i].SetInterfaces.ElementsAs(ctx, &dataValues, false)
- state.Entries[j].SetInterfaces.ElementsAs(ctx, &stateValues, false)
+ data.Entries[i].MatchExtcommunityListsLegacy.ElementsAs(ctx, &dataValues, false)
+ state.Entries[j].MatchExtcommunityListsLegacy.ElementsAs(ctx, &stateValues, false)
for _, v := range stateValues {
found := false
for _, vv := range dataValues {
@@ -2649,21 +5671,18 @@ func (data *RouteMap) getDeletedItems(ctx context.Context, state RouteMap) []str
}
}
if !found {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/set/interface-list=%v", state.getPath(), strings.Join(stateKeyValues[:], ","), v))
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-route-map:route-map-without-order-seq%v/match/extcommunity/name[.=%v]", predicates, v))
}
}
}
}
- if !state.Entries[i].SetGlobal.IsNull() && data.Entries[j].SetGlobal.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/set/global", state.getPath(), strings.Join(stateKeyValues[:], ",")))
- }
- if !state.Entries[i].SetDefaultInterfaces.IsNull() {
- if data.Entries[j].SetDefaultInterfaces.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/set/default/interface-list", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ if !state.Entries[i].MatchLocalPreferencesLegacy.IsNull() {
+ if data.Entries[j].MatchLocalPreferencesLegacy.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-route-map:route-map-without-order-seq%v/match/local-preference/values", predicates))
} else {
- var dataValues, stateValues []string
- data.Entries[i].SetDefaultInterfaces.ElementsAs(ctx, &dataValues, false)
- state.Entries[j].SetDefaultInterfaces.ElementsAs(ctx, &stateValues, false)
+ var dataValues, stateValues []int
+ data.Entries[i].MatchLocalPreferencesLegacy.ElementsAs(ctx, &dataValues, false)
+ state.Entries[j].MatchLocalPreferencesLegacy.ElementsAs(ctx, &stateValues, false)
for _, v := range stateValues {
found := false
for _, vv := range dataValues {
@@ -2673,18 +5692,18 @@ func (data *RouteMap) getDeletedItems(ctx context.Context, state RouteMap) []str
}
}
if !found {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/set/default/interface-list=%v", state.getPath(), strings.Join(stateKeyValues[:], ","), v))
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-route-map:route-map-without-order-seq%v/match/local-preference/values[.=%v]", predicates, v))
}
}
}
}
- if !state.Entries[i].MatchLocalPreferences.IsNull() {
- if data.Entries[j].MatchLocalPreferences.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/match/Cisco-IOS-XE-bgp:bgp-route-map-match/local-preference/values", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ if !state.Entries[i].MatchAsPaths.IsNull() {
+ if data.Entries[j].MatchAsPaths.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-route-map:route-map-without-order-seq%v/match/Cisco-IOS-XE-bgp:bgp-route-map-match/as-path/access-list", predicates))
} else {
var dataValues, stateValues []int
- data.Entries[i].MatchLocalPreferences.ElementsAs(ctx, &dataValues, false)
- state.Entries[j].MatchLocalPreferences.ElementsAs(ctx, &stateValues, false)
+ data.Entries[i].MatchAsPaths.ElementsAs(ctx, &dataValues, false)
+ state.Entries[j].MatchAsPaths.ElementsAs(ctx, &stateValues, false)
for _, v := range stateValues {
found := false
for _, vv := range dataValues {
@@ -2694,18 +5713,18 @@ func (data *RouteMap) getDeletedItems(ctx context.Context, state RouteMap) []str
}
}
if !found {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/match/Cisco-IOS-XE-bgp:bgp-route-map-match/local-preference/values=%v", state.getPath(), strings.Join(stateKeyValues[:], ","), v))
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-route-map:route-map-without-order-seq%v/match/Cisco-IOS-XE-bgp:bgp-route-map-match/as-path/access-list[.=%v]", predicates, v))
}
}
}
}
- if !state.Entries[i].MatchExtcommunityLists.IsNull() {
- if data.Entries[j].MatchExtcommunityLists.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/match/Cisco-IOS-XE-bgp:bgp-route-map-match/extcommunity/extcommunity-list", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ if !state.Entries[i].MatchCommunityLists.IsNull() {
+ if data.Entries[j].MatchCommunityLists.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-route-map:route-map-without-order-seq%v/match/Cisco-IOS-XE-bgp:bgp-route-map-match/bgp-community/community-list", predicates))
} else {
var dataValues, stateValues []string
- data.Entries[i].MatchExtcommunityLists.ElementsAs(ctx, &dataValues, false)
- state.Entries[j].MatchExtcommunityLists.ElementsAs(ctx, &stateValues, false)
+ data.Entries[i].MatchCommunityLists.ElementsAs(ctx, &dataValues, false)
+ state.Entries[j].MatchCommunityLists.ElementsAs(ctx, &stateValues, false)
for _, v := range stateValues {
found := false
for _, vv := range dataValues {
@@ -2715,21 +5734,21 @@ func (data *RouteMap) getDeletedItems(ctx context.Context, state RouteMap) []str
}
}
if !found {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/match/Cisco-IOS-XE-bgp:bgp-route-map-match/extcommunity/extcommunity-list=%v", state.getPath(), strings.Join(stateKeyValues[:], ","), v))
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-route-map:route-map-without-order-seq%v/match/Cisco-IOS-XE-bgp:bgp-route-map-match/bgp-community/community-list[.=%v]", predicates, v))
}
}
}
}
if !state.Entries[i].MatchCommunityListExactMatch.IsNull() && data.Entries[j].MatchCommunityListExactMatch.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/match/Cisco-IOS-XE-bgp:bgp-route-map-match/bgp-community/exact-match", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-route-map:route-map-without-order-seq%v/match/Cisco-IOS-XE-bgp:bgp-route-map-match/bgp-community/exact-match", predicates))
}
- if !state.Entries[i].MatchCommunityLists.IsNull() {
- if data.Entries[j].MatchCommunityLists.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/match/Cisco-IOS-XE-bgp:bgp-route-map-match/bgp-community/community-list", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ if !state.Entries[i].MatchExtcommunityLists.IsNull() {
+ if data.Entries[j].MatchExtcommunityLists.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-route-map:route-map-without-order-seq%v/match/Cisco-IOS-XE-bgp:bgp-route-map-match/extcommunity/extcommunity-list", predicates))
} else {
var dataValues, stateValues []string
- data.Entries[i].MatchCommunityLists.ElementsAs(ctx, &dataValues, false)
- state.Entries[j].MatchCommunityLists.ElementsAs(ctx, &stateValues, false)
+ data.Entries[i].MatchExtcommunityLists.ElementsAs(ctx, &dataValues, false)
+ state.Entries[j].MatchExtcommunityLists.ElementsAs(ctx, &stateValues, false)
for _, v := range stateValues {
found := false
for _, vv := range dataValues {
@@ -2739,18 +5758,18 @@ func (data *RouteMap) getDeletedItems(ctx context.Context, state RouteMap) []str
}
}
if !found {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/match/Cisco-IOS-XE-bgp:bgp-route-map-match/bgp-community/community-list=%v", state.getPath(), strings.Join(stateKeyValues[:], ","), v))
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-route-map:route-map-without-order-seq%v/match/Cisco-IOS-XE-bgp:bgp-route-map-match/extcommunity/extcommunity-list[.=%v]", predicates, v))
}
}
}
}
- if !state.Entries[i].MatchAsPaths.IsNull() {
- if data.Entries[j].MatchAsPaths.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/match/Cisco-IOS-XE-bgp:bgp-route-map-match/as-path/access-list", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ if !state.Entries[i].MatchLocalPreferences.IsNull() {
+ if data.Entries[j].MatchLocalPreferences.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-route-map:route-map-without-order-seq%v/match/Cisco-IOS-XE-bgp:bgp-route-map-match/local-preference/values", predicates))
} else {
var dataValues, stateValues []int
- data.Entries[i].MatchAsPaths.ElementsAs(ctx, &dataValues, false)
- state.Entries[j].MatchAsPaths.ElementsAs(ctx, &stateValues, false)
+ data.Entries[i].MatchLocalPreferences.ElementsAs(ctx, &dataValues, false)
+ state.Entries[j].MatchLocalPreferences.ElementsAs(ctx, &stateValues, false)
for _, v := range stateValues {
found := false
for _, vv := range dataValues {
@@ -2760,18 +5779,18 @@ func (data *RouteMap) getDeletedItems(ctx context.Context, state RouteMap) []str
}
}
if !found {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/match/Cisco-IOS-XE-bgp:bgp-route-map-match/as-path/access-list=%v", state.getPath(), strings.Join(stateKeyValues[:], ","), v))
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-route-map:route-map-without-order-seq%v/match/Cisco-IOS-XE-bgp:bgp-route-map-match/local-preference/values[.=%v]", predicates, v))
}
}
}
}
- if !state.Entries[i].MatchLocalPreferencesLegacy.IsNull() {
- if data.Entries[j].MatchLocalPreferencesLegacy.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/match/local-preference/values", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ if !state.Entries[i].SetDefaultInterfaces.IsNull() {
+ if data.Entries[j].SetDefaultInterfaces.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-route-map:route-map-without-order-seq%v/set/default/interface-list", predicates))
} else {
- var dataValues, stateValues []int
- data.Entries[i].MatchLocalPreferencesLegacy.ElementsAs(ctx, &dataValues, false)
- state.Entries[j].MatchLocalPreferencesLegacy.ElementsAs(ctx, &stateValues, false)
+ var dataValues, stateValues []string
+ data.Entries[i].SetDefaultInterfaces.ElementsAs(ctx, &dataValues, false)
+ state.Entries[j].SetDefaultInterfaces.ElementsAs(ctx, &stateValues, false)
for _, v := range stateValues {
found := false
for _, vv := range dataValues {
@@ -2781,18 +5800,21 @@ func (data *RouteMap) getDeletedItems(ctx context.Context, state RouteMap) []str
}
}
if !found {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/match/local-preference/values=%v", state.getPath(), strings.Join(stateKeyValues[:], ","), v))
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-route-map:route-map-without-order-seq%v/set/default/interface-list[.=%v]", predicates, v))
}
}
}
}
- if !state.Entries[i].MatchExtcommunityListsLegacy.IsNull() {
- if data.Entries[j].MatchExtcommunityListsLegacy.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/match/extcommunity/name", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ if !state.Entries[i].SetGlobal.IsNull() && data.Entries[j].SetGlobal.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-route-map:route-map-without-order-seq%v/set/global", predicates))
+ }
+ if !state.Entries[i].SetInterfaces.IsNull() {
+ if data.Entries[j].SetInterfaces.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-route-map:route-map-without-order-seq%v/set/interface-list", predicates))
} else {
var dataValues, stateValues []string
- data.Entries[i].MatchExtcommunityListsLegacy.ElementsAs(ctx, &dataValues, false)
- state.Entries[j].MatchExtcommunityListsLegacy.ElementsAs(ctx, &stateValues, false)
+ data.Entries[i].SetInterfaces.ElementsAs(ctx, &dataValues, false)
+ state.Entries[j].SetInterfaces.ElementsAs(ctx, &stateValues, false)
for _, v := range stateValues {
found := false
for _, vv := range dataValues {
@@ -2802,18 +5824,21 @@ func (data *RouteMap) getDeletedItems(ctx context.Context, state RouteMap) []str
}
}
if !found {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/match/extcommunity/name=%v", state.getPath(), strings.Join(stateKeyValues[:], ","), v))
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-route-map:route-map-without-order-seq%v/set/interface-list[.=%v]", predicates, v))
}
}
}
}
- if !state.Entries[i].MatchCommunityListsLegacy.IsNull() {
- if data.Entries[j].MatchCommunityListsLegacy.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/match/community/name", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ if !state.Entries[i].SetIpAddress.IsNull() && data.Entries[j].SetIpAddress.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-route-map:route-map-without-order-seq%v/set/ip/address/prefix-list", predicates))
+ }
+ if !state.Entries[i].SetIpDefaultGlobalNextHopAddress.IsNull() {
+ if data.Entries[j].SetIpDefaultGlobalNextHopAddress.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-route-map:route-map-without-order-seq%v/set/ip/default/global/next-hop/address", predicates))
} else {
var dataValues, stateValues []string
- data.Entries[i].MatchCommunityListsLegacy.ElementsAs(ctx, &dataValues, false)
- state.Entries[j].MatchCommunityListsLegacy.ElementsAs(ctx, &stateValues, false)
+ data.Entries[i].SetIpDefaultGlobalNextHopAddress.ElementsAs(ctx, &dataValues, false)
+ state.Entries[j].SetIpDefaultGlobalNextHopAddress.ElementsAs(ctx, &stateValues, false)
for _, v := range stateValues {
found := false
for _, vv := range dataValues {
@@ -2823,18 +5848,18 @@ func (data *RouteMap) getDeletedItems(ctx context.Context, state RouteMap) []str
}
}
if !found {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/match/community/name=%v", state.getPath(), strings.Join(stateKeyValues[:], ","), v))
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-route-map:route-map-without-order-seq%v/set/ip/default/global/next-hop/address[.=%v]", predicates, v))
}
}
}
}
- if !state.Entries[i].MatchAsPathsLegacy.IsNull() {
- if data.Entries[j].MatchAsPathsLegacy.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/match/as-path/access-list", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ if !state.Entries[i].SetIpDefaultNextHopAddress.IsNull() {
+ if data.Entries[j].SetIpDefaultNextHopAddress.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-route-map:route-map-without-order-seq%v/set/ip/default/next-hop/address", predicates))
} else {
- var dataValues, stateValues []int
- data.Entries[i].MatchAsPathsLegacy.ElementsAs(ctx, &dataValues, false)
- state.Entries[j].MatchAsPathsLegacy.ElementsAs(ctx, &stateValues, false)
+ var dataValues, stateValues []string
+ data.Entries[i].SetIpDefaultNextHopAddress.ElementsAs(ctx, &dataValues, false)
+ state.Entries[j].SetIpDefaultNextHopAddress.ElementsAs(ctx, &stateValues, false)
for _, v := range stateValues {
found := false
for _, vv := range dataValues {
@@ -2844,21 +5869,18 @@ func (data *RouteMap) getDeletedItems(ctx context.Context, state RouteMap) []str
}
}
if !found {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/match/as-path/access-list=%v", state.getPath(), strings.Join(stateKeyValues[:], ","), v))
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-route-map:route-map-without-order-seq%v/set/ip/default/next-hop/address[.=%v]", predicates, v))
}
}
}
}
- if !state.Entries[i].MatchTrack.IsNull() && data.Entries[j].MatchTrack.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/match/track", state.getPath(), strings.Join(stateKeyValues[:], ",")))
- }
- if !state.Entries[i].MatchTags.IsNull() {
- if data.Entries[j].MatchTags.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/match/tag/tag_value", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ if !state.Entries[i].SetIpGlobalNextHopAddress.IsNull() {
+ if data.Entries[j].SetIpGlobalNextHopAddress.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-route-map:route-map-without-order-seq%v/set/ip/global/next-hop/address", predicates))
} else {
- var dataValues, stateValues []int
- data.Entries[i].MatchTags.ElementsAs(ctx, &dataValues, false)
- state.Entries[j].MatchTags.ElementsAs(ctx, &stateValues, false)
+ var dataValues, stateValues []string
+ data.Entries[i].SetIpGlobalNextHopAddress.ElementsAs(ctx, &dataValues, false)
+ state.Entries[j].SetIpGlobalNextHopAddress.ElementsAs(ctx, &stateValues, false)
for _, v := range stateValues {
found := false
for _, vv := range dataValues {
@@ -2868,24 +5890,18 @@ func (data *RouteMap) getDeletedItems(ctx context.Context, state RouteMap) []str
}
}
if !found {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/match/tag/tag_value=%v", state.getPath(), strings.Join(stateKeyValues[:], ","), v))
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-route-map:route-map-without-order-seq%v/set/ip/global/next-hop/address[.=%v]", predicates, v))
}
}
}
}
- if !state.Entries[i].MatchSourceProtocolStatic.IsNull() && data.Entries[j].MatchSourceProtocolStatic.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/match/source-protocol/static", state.getPath(), strings.Join(stateKeyValues[:], ",")))
- }
- if !state.Entries[i].MatchSourceProtocolRip.IsNull() && data.Entries[j].MatchSourceProtocolRip.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/match/source-protocol/rip", state.getPath(), strings.Join(stateKeyValues[:], ",")))
- }
- if !state.Entries[i].MatchSourceProtocolOspfv3.IsNull() {
- if data.Entries[j].MatchSourceProtocolOspfv3.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/match/source-protocol/ospfv3", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ if !state.Entries[i].SetIpNextHopAddress.IsNull() {
+ if data.Entries[j].SetIpNextHopAddress.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-route-map:route-map-without-order-seq%v/set/ip/next-hop/address", predicates))
} else {
var dataValues, stateValues []string
- data.Entries[i].MatchSourceProtocolOspfv3.ElementsAs(ctx, &dataValues, false)
- state.Entries[j].MatchSourceProtocolOspfv3.ElementsAs(ctx, &stateValues, false)
+ data.Entries[i].SetIpNextHopAddress.ElementsAs(ctx, &dataValues, false)
+ state.Entries[j].SetIpNextHopAddress.ElementsAs(ctx, &stateValues, false)
for _, v := range stateValues {
found := false
for _, vv := range dataValues {
@@ -2895,18 +5911,24 @@ func (data *RouteMap) getDeletedItems(ctx context.Context, state RouteMap) []str
}
}
if !found {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/match/source-protocol/ospfv3=%v", state.getPath(), strings.Join(stateKeyValues[:], ","), v))
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-route-map:route-map-without-order-seq%v/set/ip/next-hop/address[.=%v]", predicates, v))
}
}
}
}
- if !state.Entries[i].MatchSourceProtocolOspf.IsNull() {
- if data.Entries[j].MatchSourceProtocolOspf.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/match/source-protocol/ospf", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ if !state.Entries[i].SetIpNextHopSelf.IsNull() && data.Entries[j].SetIpNextHopSelf.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-route-map:route-map-without-order-seq%v/set/ip/next-hop/self", predicates))
+ }
+ if !state.Entries[i].SetIpQosGroup.IsNull() && data.Entries[j].SetIpQosGroup.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-route-map:route-map-without-order-seq%v/set/ip/qos-group/qos-id", predicates))
+ }
+ if !state.Entries[i].SetIpv6Address.IsNull() {
+ if data.Entries[j].SetIpv6Address.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-route-map:route-map-without-order-seq%v/set/ipv6/address/prefix-list", predicates))
} else {
var dataValues, stateValues []string
- data.Entries[i].MatchSourceProtocolOspf.ElementsAs(ctx, &dataValues, false)
- state.Entries[j].MatchSourceProtocolOspf.ElementsAs(ctx, &stateValues, false)
+ data.Entries[i].SetIpv6Address.ElementsAs(ctx, &dataValues, false)
+ state.Entries[j].SetIpv6Address.ElementsAs(ctx, &stateValues, false)
for _, v := range stateValues {
found := false
for _, vv := range dataValues {
@@ -2916,24 +5938,21 @@ func (data *RouteMap) getDeletedItems(ctx context.Context, state RouteMap) []str
}
}
if !found {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/match/source-protocol/ospf=%v", state.getPath(), strings.Join(stateKeyValues[:], ","), v))
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-route-map:route-map-without-order-seq%v/set/ipv6/address/prefix-list[.=%v]", predicates, v))
}
}
}
}
- if !state.Entries[i].MatchSourceProtocolLisp.IsNull() && data.Entries[j].MatchSourceProtocolLisp.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/match/source-protocol/lisp", state.getPath(), strings.Join(stateKeyValues[:], ",")))
- }
- if !state.Entries[i].MatchSourceProtocolIsis.IsNull() && data.Entries[j].MatchSourceProtocolIsis.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/match/source-protocol/isis", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ if !state.Entries[i].SetIpv6DefaultGlobalNextHop.IsNull() && data.Entries[j].SetIpv6DefaultGlobalNextHop.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-route-map:route-map-without-order-seq%v/set/ipv6/default/global/next-hop", predicates))
}
- if !state.Entries[i].MatchSourceProtocolEigrp.IsNull() {
- if data.Entries[j].MatchSourceProtocolEigrp.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/match/source-protocol/eigrp", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ if !state.Entries[i].SetIpv6DefaultNextHop.IsNull() {
+ if data.Entries[j].SetIpv6DefaultNextHop.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-route-map:route-map-without-order-seq%v/set/ipv6/default/next-hop/ipv6", predicates))
} else {
var dataValues, stateValues []string
- data.Entries[i].MatchSourceProtocolEigrp.ElementsAs(ctx, &dataValues, false)
- state.Entries[j].MatchSourceProtocolEigrp.ElementsAs(ctx, &stateValues, false)
+ data.Entries[i].SetIpv6DefaultNextHop.ElementsAs(ctx, &dataValues, false)
+ state.Entries[j].SetIpv6DefaultNextHop.ElementsAs(ctx, &stateValues, false)
for _, v := range stateValues {
found := false
for _, vv := range dataValues {
@@ -2943,21 +5962,18 @@ func (data *RouteMap) getDeletedItems(ctx context.Context, state RouteMap) []str
}
}
if !found {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/match/source-protocol/eigrp=%v", state.getPath(), strings.Join(stateKeyValues[:], ","), v))
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-route-map:route-map-without-order-seq%v/set/ipv6/default/next-hop/ipv6[.=%v]", predicates, v))
}
}
}
}
- if !state.Entries[i].MatchSourceProtocolConnected.IsNull() && data.Entries[j].MatchSourceProtocolConnected.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/match/source-protocol/connected", state.getPath(), strings.Join(stateKeyValues[:], ",")))
- }
- if !state.Entries[i].MatchSourceProtocolBgp.IsNull() {
- if data.Entries[j].MatchSourceProtocolBgp.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/match/source-protocol/bgp", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ if !state.Entries[i].SetIpv6NextHop.IsNull() {
+ if data.Entries[j].SetIpv6NextHop.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-route-map:route-map-without-order-seq%v/set/ipv6/next-hop/ipv6", predicates))
} else {
var dataValues, stateValues []string
- data.Entries[i].MatchSourceProtocolBgp.ElementsAs(ctx, &dataValues, false)
- state.Entries[j].MatchSourceProtocolBgp.ElementsAs(ctx, &stateValues, false)
+ data.Entries[i].SetIpv6NextHop.ElementsAs(ctx, &dataValues, false)
+ state.Entries[j].SetIpv6NextHop.ElementsAs(ctx, &stateValues, false)
for _, v := range stateValues {
found := false
for _, vv := range dataValues {
@@ -2967,54 +5983,66 @@ func (data *RouteMap) getDeletedItems(ctx context.Context, state RouteMap) []str
}
}
if !found {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/match/source-protocol/bgp=%v", state.getPath(), strings.Join(stateKeyValues[:], ","), v))
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-route-map:route-map-without-order-seq%v/set/ipv6/next-hop/ipv6[.=%v]", predicates, v))
}
}
}
}
- if !state.Entries[i].MatchRouteTypeLocal.IsNull() && data.Entries[j].MatchRouteTypeLocal.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/match/Cisco-IOS-XE-bgp:bgp-route-map-match/route-type/local", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ if !state.Entries[i].SetLevel1.IsNull() && data.Entries[j].SetLevel1.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-route-map:route-map-without-order-seq%v/set/level/level-1", predicates))
}
- if !state.Entries[i].MatchRouteTypeLocalLegacy.IsNull() && data.Entries[j].MatchRouteTypeLocalLegacy.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/match/route-type/local", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ if !state.Entries[i].SetLevel12.IsNull() && data.Entries[j].SetLevel12.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-route-map:route-map-without-order-seq%v/set/level/level-1-2", predicates))
}
- if !state.Entries[i].MatchRouteTypeLevel2.IsNull() && data.Entries[j].MatchRouteTypeLevel2.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/match/route-type/level-2", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ if !state.Entries[i].SetLevel2.IsNull() && data.Entries[j].SetLevel2.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-route-map:route-map-without-order-seq%v/set/level/level-2", predicates))
}
- if !state.Entries[i].MatchRouteTypeLevel1.IsNull() && data.Entries[j].MatchRouteTypeLevel1.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/match/route-type/level-1", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ if !state.Entries[i].SetMetricChange.IsNull() && data.Entries[j].SetMetricChange.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-route-map:route-map-without-order-seq%v/set/metric/metric-change", predicates))
}
- if !state.Entries[i].MatchRouteTypeInternal.IsNull() && data.Entries[j].MatchRouteTypeInternal.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/match/route-type/internal", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ if !state.Entries[i].SetMetricValue.IsNull() && data.Entries[j].SetMetricValue.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-route-map:route-map-without-order-seq%v/set/metric/values/value", predicates))
}
- if !state.Entries[i].MatchRouteTypeExternalType2.IsNull() && data.Entries[j].MatchRouteTypeExternalType2.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/match/route-type/external/type-2", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ if !state.Entries[i].SetMetricDelay.IsNull() && data.Entries[j].SetMetricDelay.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-route-map:route-map-without-order-seq%v/set/metric/values/delay", predicates))
}
- if !state.Entries[i].MatchRouteTypeExternalType1.IsNull() && data.Entries[j].MatchRouteTypeExternalType1.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/match/route-type/external/type-1", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ if !state.Entries[i].SetMetricReliability.IsNull() && data.Entries[j].SetMetricReliability.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-route-map:route-map-without-order-seq%v/set/metric/values/reliability", predicates))
}
- if !state.Entries[i].MatchRouteTypeExternal.IsNull() && data.Entries[j].MatchRouteTypeExternal.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/match/route-type/external", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ if !state.Entries[i].SetMetricLoading.IsNull() && data.Entries[j].SetMetricLoading.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-route-map:route-map-without-order-seq%v/set/metric/values/loading", predicates))
}
- if !state.Entries[i].MatchIpv6NextHopPrefixLists.IsNull() && data.Entries[j].MatchIpv6NextHopPrefixLists.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/match/ipv6/next-hop/prefix-list", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ if !state.Entries[i].SetMetricMtu.IsNull() && data.Entries[j].SetMetricMtu.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-route-map:route-map-without-order-seq%v/set/metric/values/MTU", predicates))
}
- if !state.Entries[i].MatchIpv6NextHopAccessLists.IsNull() && data.Entries[j].MatchIpv6NextHopAccessLists.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/match/ipv6/next-hop/access-list", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ if !state.Entries[i].SetMetricType.IsNull() && data.Entries[j].SetMetricType.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-route-map:route-map-without-order-seq%v/set/metric-type", predicates))
}
- if !state.Entries[i].MatchIpv6AddressPrefixLists.IsNull() && data.Entries[j].MatchIpv6AddressPrefixLists.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/match/ipv6/address/prefix-list", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ if !state.Entries[i].SetTag.IsNull() && data.Entries[j].SetTag.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-route-map:route-map-without-order-seq%v/set/tag/tag-val", predicates))
}
- if !state.Entries[i].MatchIpv6AddressAccessLists.IsNull() && data.Entries[j].MatchIpv6AddressAccessLists.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/match/ipv6/address/access-list", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ if !state.Entries[i].SetVrf.IsNull() && data.Entries[j].SetVrf.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-route-map:route-map-without-order-seq%v/set/vrf", predicates))
}
- if !state.Entries[i].MatchIpNextHopPrefixLists.IsNull() {
- if data.Entries[j].MatchIpNextHopPrefixLists.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/match/ip/next-hop/prefix-list", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ if !state.Entries[i].SetAsPathPrependAsLegacy.IsNull() && data.Entries[j].SetAsPathPrependAsLegacy.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-route-map:route-map-without-order-seq%v/set/as-path/prepend/as-container/as-number", predicates))
+ }
+ if !state.Entries[i].SetAsPathPrependLastAsLegacy.IsNull() && data.Entries[j].SetAsPathPrependLastAsLegacy.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-route-map:route-map-without-order-seq%v/set/as-path/prepend/last-as-cont/last-as", predicates))
+ }
+ if !state.Entries[i].SetAsPathTagLegacy.IsNull() && data.Entries[j].SetAsPathTagLegacy.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-route-map:route-map-without-order-seq%v/set/as-path/tag", predicates))
+ }
+ if !state.Entries[i].SetCommunityNoneLegacy.IsNull() && data.Entries[j].SetCommunityNoneLegacy.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-route-map:route-map-without-order-seq%v/set/community/none", predicates))
+ }
+ if !state.Entries[i].SetCommunitiesLegacy.IsNull() {
+ if data.Entries[j].SetCommunitiesLegacy.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-route-map:route-map-without-order-seq%v/set/community/community-well-known/community-list", predicates))
} else {
var dataValues, stateValues []string
- data.Entries[i].MatchIpNextHopPrefixLists.ElementsAs(ctx, &dataValues, false)
- state.Entries[j].MatchIpNextHopPrefixLists.ElementsAs(ctx, &stateValues, false)
+ data.Entries[i].SetCommunitiesLegacy.ElementsAs(ctx, &dataValues, false)
+ state.Entries[j].SetCommunitiesLegacy.ElementsAs(ctx, &stateValues, false)
for _, v := range stateValues {
found := false
for _, vv := range dataValues {
@@ -3024,18 +6052,33 @@ func (data *RouteMap) getDeletedItems(ctx context.Context, state RouteMap) []str
}
}
if !found {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/match/ip/next-hop/prefix-list=%v", state.getPath(), strings.Join(stateKeyValues[:], ","), v))
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-route-map:route-map-without-order-seq%v/set/community/community-well-known/community-list[.=%v]", predicates, v))
}
}
}
}
- if !state.Entries[i].MatchIpNextHopAccessLists.IsNull() {
- if data.Entries[j].MatchIpNextHopAccessLists.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/match/ip/next-hop/access-list", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ if !state.Entries[i].SetCommunitiesAdditiveLegacy.IsNull() && data.Entries[j].SetCommunitiesAdditiveLegacy.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-route-map:route-map-without-order-seq%v/set/community/community-well-known/additive", predicates))
+ }
+ if !state.Entries[i].SetCommunityListDeleteLegacy.IsNull() && data.Entries[j].SetCommunityListDeleteLegacy.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-route-map:route-map-without-order-seq%v/set/comm-list/delete", predicates))
+ }
+ if !state.Entries[i].SetCommunityListStandardLegacy.IsNull() && data.Entries[j].SetCommunityListStandardLegacy.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-route-map:route-map-without-order-seq%v/set/comm-list/comm-list-standard", predicates))
+ }
+ if !state.Entries[i].SetCommunityListExpandedLegacy.IsNull() && data.Entries[j].SetCommunityListExpandedLegacy.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-route-map:route-map-without-order-seq%v/set/Cisco-IOS-XE-bgp:bgp-route-map-set/comm-list/comm-list-expanded", predicates))
+ }
+ if !state.Entries[i].SetCommunityListNameLegacy.IsNull() && data.Entries[j].SetCommunityListNameLegacy.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-route-map:route-map-without-order-seq%v/set/comm-list/comm-list-name", predicates))
+ }
+ if !state.Entries[i].SetExtcomunityRtLegacy.IsNull() {
+ if data.Entries[j].SetExtcomunityRtLegacy.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-route-map:route-map-without-order-seq%v/set/extcommunity/rt/asn-nn", predicates))
} else {
var dataValues, stateValues []string
- data.Entries[i].MatchIpNextHopAccessLists.ElementsAs(ctx, &dataValues, false)
- state.Entries[j].MatchIpNextHopAccessLists.ElementsAs(ctx, &stateValues, false)
+ data.Entries[i].SetExtcomunityRtLegacy.ElementsAs(ctx, &dataValues, false)
+ state.Entries[j].SetExtcomunityRtLegacy.ElementsAs(ctx, &stateValues, false)
for _, v := range stateValues {
found := false
for _, vv := range dataValues {
@@ -3045,39 +6088,75 @@ func (data *RouteMap) getDeletedItems(ctx context.Context, state RouteMap) []str
}
}
if !found {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/match/ip/next-hop/access-list=%v", state.getPath(), strings.Join(stateKeyValues[:], ","), v))
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-route-map:route-map-without-order-seq%v/set/extcommunity/rt/asn-nn[.=%v]", predicates, v))
}
}
}
}
- if !state.Entries[i].MatchIpAddressPrefixLists.IsNull() {
- if data.Entries[j].MatchIpAddressPrefixLists.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/match/ip/address/prefix-list", state.getPath(), strings.Join(stateKeyValues[:], ",")))
- } else {
- var dataValues, stateValues []string
- data.Entries[i].MatchIpAddressPrefixLists.ElementsAs(ctx, &dataValues, false)
- state.Entries[j].MatchIpAddressPrefixLists.ElementsAs(ctx, &stateValues, false)
- for _, v := range stateValues {
- found := false
- for _, vv := range dataValues {
- if v == vv {
- found = true
- break
- }
- }
- if !found {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/match/ip/address/prefix-list=%v", state.getPath(), strings.Join(stateKeyValues[:], ","), v))
- }
+ if !state.Entries[i].SetExtcomunitySooLegacy.IsNull() && data.Entries[j].SetExtcomunitySooLegacy.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-route-map:route-map-without-order-seq%v/set/extcommunity/soo/asn-nn", predicates))
+ }
+ if !state.Entries[i].SetExtcomunityVpnDistinguisherLegacy.IsNull() && data.Entries[j].SetExtcomunityVpnDistinguisherLegacy.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-route-map:route-map-without-order-seq%v/set/extcommunity/vpn-distinguisher/asn-nn", predicates))
+ }
+ if !state.Entries[i].SetLocalPreferenceLegacy.IsNull() && data.Entries[j].SetLocalPreferenceLegacy.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-route-map:route-map-without-order-seq%v/set/local-preference", predicates))
+ }
+ if !state.Entries[i].SetWeightLegacy.IsNull() && data.Entries[j].SetWeightLegacy.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-route-map:route-map-without-order-seq%v/set/weight", predicates))
+ }
+ if !state.Entries[i].SetAsPathPrependAs.IsNull() && data.Entries[j].SetAsPathPrependAs.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-route-map:route-map-without-order-seq%v/set/Cisco-IOS-XE-bgp:bgp-route-map-set/as-path/prepend/as-container/as-number", predicates))
+ }
+ if !state.Entries[i].SetAsPathPrependLastAs.IsNull() && data.Entries[j].SetAsPathPrependLastAs.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-route-map:route-map-without-order-seq%v/set/Cisco-IOS-XE-bgp:bgp-route-map-set/as-path/prepend/last-as-cont/last-as", predicates))
+ }
+ if !state.Entries[i].SetAsPathTag.IsNull() && data.Entries[j].SetAsPathTag.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-route-map:route-map-without-order-seq%v/set/Cisco-IOS-XE-bgp:bgp-route-map-set/as-path/tag", predicates))
+ }
+ if !state.Entries[i].SetAsPathReplaceAny.IsNull() && data.Entries[j].SetAsPathReplaceAny.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-route-map:route-map-without-order-seq%v/set/Cisco-IOS-XE-bgp:bgp-route-map-set/as-path/replace/any", predicates))
+ }
+ for ci := range state.Entries[i].SetAsPathReplaceAs {
+ cstateKeys := [...]string{"as-number"}
+ cstateKeyValues := [...]string{state.Entries[i].SetAsPathReplaceAs[ci].AsNumber.ValueString()}
+ cpredicates := ""
+ for i := range cstateKeys {
+ cpredicates += fmt.Sprintf("[%s='%s']", cstateKeys[i], cstateKeyValues[i])
+ }
+
+ cemptyKeys := true
+ if !reflect.ValueOf(state.Entries[i].SetAsPathReplaceAs[ci].AsNumber.ValueString()).IsZero() {
+ cemptyKeys = false
+ }
+ if cemptyKeys {
+ continue
+ }
+
+ found := false
+ for cj := range data.Entries[j].SetAsPathReplaceAs {
+ found = true
+ if state.Entries[i].SetAsPathReplaceAs[ci].AsNumber.ValueString() != data.Entries[j].SetAsPathReplaceAs[cj].AsNumber.ValueString() {
+ found = false
+ }
+ if found {
+ break
}
}
+ if !found {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-route-map:route-map-without-order-seq%v/set/Cisco-IOS-XE-bgp:bgp-route-map-set/as-path/replace/as-container%v", predicates, cpredicates))
+ }
}
- if !state.Entries[i].MatchIpAddressAccessLists.IsNull() {
- if data.Entries[j].MatchIpAddressAccessLists.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/match/ip/address/access-list", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ if !state.Entries[i].SetCommunityNone.IsNull() && data.Entries[j].SetCommunityNone.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-route-map:route-map-without-order-seq%v/set/Cisco-IOS-XE-bgp:bgp-route-map-set/bgp-community/none", predicates))
+ }
+ if !state.Entries[i].SetCommunities.IsNull() {
+ if data.Entries[j].SetCommunities.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-route-map:route-map-without-order-seq%v/set/Cisco-IOS-XE-bgp:bgp-route-map-set/bgp-community/community-well-known/community-list", predicates))
} else {
var dataValues, stateValues []string
- data.Entries[i].MatchIpAddressAccessLists.ElementsAs(ctx, &dataValues, false)
- state.Entries[j].MatchIpAddressAccessLists.ElementsAs(ctx, &stateValues, false)
+ data.Entries[i].SetCommunities.ElementsAs(ctx, &dataValues, false)
+ state.Entries[j].SetCommunities.ElementsAs(ctx, &stateValues, false)
for _, v := range stateValues {
found := false
for _, vv := range dataValues {
@@ -3087,18 +6166,33 @@ func (data *RouteMap) getDeletedItems(ctx context.Context, state RouteMap) []str
}
}
if !found {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/match/ip/address/access-list=%v", state.getPath(), strings.Join(stateKeyValues[:], ","), v))
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-route-map:route-map-without-order-seq%v/set/Cisco-IOS-XE-bgp:bgp-route-map-set/bgp-community/community-well-known/community-list[.=%v]", predicates, v))
}
}
}
}
- if !state.Entries[i].MatchInterfaces.IsNull() {
- if data.Entries[j].MatchInterfaces.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/match/interface/interface", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ if !state.Entries[i].SetCommunitiesAdditive.IsNull() && data.Entries[j].SetCommunitiesAdditive.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-route-map:route-map-without-order-seq%v/set/Cisco-IOS-XE-bgp:bgp-route-map-set/bgp-community/community-well-known/additive", predicates))
+ }
+ if !state.Entries[i].SetCommunityListDelete.IsNull() && data.Entries[j].SetCommunityListDelete.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-route-map:route-map-without-order-seq%v/set/Cisco-IOS-XE-bgp:bgp-route-map-set/comm-list/delete", predicates))
+ }
+ if !state.Entries[i].SetCommunityListStandard.IsNull() && data.Entries[j].SetCommunityListStandard.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-route-map:route-map-without-order-seq%v/set/Cisco-IOS-XE-bgp:bgp-route-map-set/comm-list/comm-list-standard", predicates))
+ }
+ if !state.Entries[i].SetCommunityListExpanded.IsNull() && data.Entries[j].SetCommunityListExpanded.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-route-map:route-map-without-order-seq%v/set/Cisco-IOS-XE-bgp:bgp-route-map-set/comm-list/comm-list-expanded", predicates))
+ }
+ if !state.Entries[i].SetCommunityListName.IsNull() && data.Entries[j].SetCommunityListName.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-route-map:route-map-without-order-seq%v/set/Cisco-IOS-XE-bgp:bgp-route-map-set/comm-list/comm-list-name", predicates))
+ }
+ if !state.Entries[i].SetExtcomunityRt.IsNull() {
+ if data.Entries[j].SetExtcomunityRt.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-route-map:route-map-without-order-seq%v/set/Cisco-IOS-XE-bgp:bgp-route-map-set/extcommunity/rt/asn-nn", predicates))
} else {
var dataValues, stateValues []string
- data.Entries[i].MatchInterfaces.ElementsAs(ctx, &dataValues, false)
- state.Entries[j].MatchInterfaces.ElementsAs(ctx, &stateValues, false)
+ data.Entries[i].SetExtcomunityRt.ElementsAs(ctx, &dataValues, false)
+ state.Entries[j].SetExtcomunityRt.ElementsAs(ctx, &stateValues, false)
for _, v := range stateValues {
found := false
for _, vv := range dataValues {
@@ -3108,35 +6202,38 @@ func (data *RouteMap) getDeletedItems(ctx context.Context, state RouteMap) []str
}
}
if !found {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/match/interface/interface=%v", state.getPath(), strings.Join(stateKeyValues[:], ","), v))
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-route-map:route-map-without-order-seq%v/set/Cisco-IOS-XE-bgp:bgp-route-map-set/extcommunity/rt/asn-nn[.=%v]", predicates, v))
}
}
}
}
- if !state.Entries[i].ContinueSequenceNumber.IsNull() && data.Entries[j].ContinueSequenceNumber.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/continue/sequence-number", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ if !state.Entries[i].SetExtcomunitySoo.IsNull() && data.Entries[j].SetExtcomunitySoo.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-route-map:route-map-without-order-seq%v/set/Cisco-IOS-XE-bgp:bgp-route-map-set/extcommunity/soo/asn-nn", predicates))
}
- if !state.Entries[i].Continue.IsNull() && data.Entries[j].Continue.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/continue", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ if !state.Entries[i].SetExtcomunityVpnDistinguisher.IsNull() && data.Entries[j].SetExtcomunityVpnDistinguisher.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-route-map:route-map-without-order-seq%v/set/Cisco-IOS-XE-bgp:bgp-route-map-set/extcommunity/vpn-distinguisher/asn-nn", predicates))
}
- if !state.Entries[i].Description.IsNull() && data.Entries[j].Description.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/description", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ if !state.Entries[i].SetExtcomunityVpnDistinguisherAdditive.IsNull() && data.Entries[j].SetExtcomunityVpnDistinguisherAdditive.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-route-map:route-map-without-order-seq%v/set/Cisco-IOS-XE-bgp:bgp-route-map-set/extcommunity/vpn-distinguisher/asn-nn-additive", predicates))
}
- if !state.Entries[i].Operation.IsNull() && data.Entries[j].Operation.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v/operation", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ if !state.Entries[i].SetLocalPreference.IsNull() && data.Entries[j].SetLocalPreference.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-route-map:route-map-without-order-seq%v/set/Cisco-IOS-XE-bgp:bgp-route-map-set/local-preference", predicates))
+ }
+ if !state.Entries[i].SetWeight.IsNull() && data.Entries[j].SetWeight.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-route-map:route-map-without-order-seq%v/set/Cisco-IOS-XE-bgp:bgp-route-map-set/weight", predicates))
}
break
}
}
if !found {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-route-map:route-map-without-order-seq=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-route-map:route-map-without-order-seq%v", predicates))
}
}
- return deletedItems
+ return b.Res()
}
-// End of section. //template:end getDeletedItems
+// End of section. //template:end addDeletedItemsXML
// Section below is generated&owned by "gen/generator.go". //template:begin getEmptyLeafsDelete
@@ -3257,3 +6354,23 @@ func (data *RouteMap) getDeletePaths(ctx context.Context) []string {
}
// End of section. //template:end getDeletePaths
+
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletePathsXML
+
+func (data *RouteMap) addDeletePathsXML(ctx context.Context, body string) string {
+ b := netconf.NewBody(body)
+ for i := range data.Entries {
+ keys := [...]string{"seq_no"}
+ keyValues := [...]string{strconv.FormatInt(data.Entries[i].Seq.ValueInt64(), 10)}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/Cisco-IOS-XE-route-map:route-map-without-order-seq%v", predicates))
+ }
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletePathsXML
diff --git a/internal/provider/model_iosxe_service.go b/internal/provider/model_iosxe_service.go
index b9a289be..fdee2722 100644
--- a/internal/provider/model_iosxe_service.go
+++ b/internal/provider/model_iosxe_service.go
@@ -27,6 +27,9 @@ import (
"github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/types"
+ "github.com/hashicorp/terraform-plugin-log/tflog"
+ "github.com/netascode/go-netconf"
+ "github.com/netascode/xmldot"
"github.com/tidwall/gjson"
"github.com/tidwall/sjson"
)
@@ -117,6 +120,17 @@ func (data Service) getPathShort() string {
return matches[1]
}
+// getXPath returns the XPath for NETCONF operations
+func (data Service) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/service"
+ return path
+}
+
+func (data ServiceData) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/service"
+ return path
+}
+
// End of section. //template:end getPath
// Section below is generated&owned by "gen/generator.go". //template:begin toBody
@@ -247,6 +261,182 @@ func (data Service) toBody(ctx context.Context) string {
// End of section. //template:end toBody
+// Section below is generated&owned by "gen/generator.go". //template:begin toBodyXML
+
+func (data Service) toBodyXML(ctx context.Context) string {
+ body := netconf.Body{}
+ if !data.Pad.IsNull() && !data.Pad.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/pad-conf/pad", data.Pad.ValueBool())
+ }
+ if !data.PasswordEncryption.IsNull() && !data.PasswordEncryption.IsUnknown() {
+ if data.PasswordEncryption.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/password-encryption", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/password-encryption")
+ }
+ }
+ if !data.PasswordRecovery.IsNull() && !data.PasswordRecovery.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/password-recovery", data.PasswordRecovery.ValueBool())
+ }
+ if !data.Timestamps.IsNull() && !data.Timestamps.IsUnknown() {
+ if data.Timestamps.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/timestamps", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/timestamps")
+ }
+ }
+ if !data.TimestampsDebug.IsNull() && !data.TimestampsDebug.IsUnknown() {
+ if data.TimestampsDebug.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/timestamps/debug-config", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/timestamps/debug-config")
+ }
+ }
+ if !data.TimestampsDebugDatetime.IsNull() && !data.TimestampsDebugDatetime.IsUnknown() {
+ if data.TimestampsDebugDatetime.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/timestamps/debug-config/datetime", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/timestamps/debug-config/datetime")
+ }
+ }
+ if !data.TimestampsDebugDatetimeMsec.IsNull() && !data.TimestampsDebugDatetimeMsec.IsUnknown() {
+ if data.TimestampsDebugDatetimeMsec.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/timestamps/debug-config/datetime/msec", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/timestamps/debug-config/datetime/msec")
+ }
+ }
+ if !data.TimestampsDebugDatetimeLocaltime.IsNull() && !data.TimestampsDebugDatetimeLocaltime.IsUnknown() {
+ if data.TimestampsDebugDatetimeLocaltime.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/timestamps/debug-config/datetime/localtime", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/timestamps/debug-config/datetime/localtime")
+ }
+ }
+ if !data.TimestampsDebugDatetimeShowTimezone.IsNull() && !data.TimestampsDebugDatetimeShowTimezone.IsUnknown() {
+ if data.TimestampsDebugDatetimeShowTimezone.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/timestamps/debug-config/datetime/show-timezone", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/timestamps/debug-config/datetime/show-timezone")
+ }
+ }
+ if !data.TimestampsDebugDatetimeYear.IsNull() && !data.TimestampsDebugDatetimeYear.IsUnknown() {
+ if data.TimestampsDebugDatetimeYear.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/timestamps/debug-config/datetime/year", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/timestamps/debug-config/datetime/year")
+ }
+ }
+ if !data.TimestampsDebugUptime.IsNull() && !data.TimestampsDebugUptime.IsUnknown() {
+ if data.TimestampsDebugUptime.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/timestamps/debug-config/uptime", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/timestamps/debug-config/uptime")
+ }
+ }
+ if !data.TimestampsLog.IsNull() && !data.TimestampsLog.IsUnknown() {
+ if data.TimestampsLog.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/timestamps/log-config", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/timestamps/log-config")
+ }
+ }
+ if !data.TimestampsLogDatetime.IsNull() && !data.TimestampsLogDatetime.IsUnknown() {
+ if data.TimestampsLogDatetime.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/timestamps/log-config/datetime", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/timestamps/log-config/datetime")
+ }
+ }
+ if !data.TimestampsLogDatetimeMsec.IsNull() && !data.TimestampsLogDatetimeMsec.IsUnknown() {
+ if data.TimestampsLogDatetimeMsec.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/timestamps/log-config/datetime/msec", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/timestamps/log-config/datetime/msec")
+ }
+ }
+ if !data.TimestampsLogDatetimeLocaltime.IsNull() && !data.TimestampsLogDatetimeLocaltime.IsUnknown() {
+ if data.TimestampsLogDatetimeLocaltime.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/timestamps/log-config/datetime/localtime", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/timestamps/log-config/datetime/localtime")
+ }
+ }
+ if !data.TimestampsLogDatetimeShowTimezone.IsNull() && !data.TimestampsLogDatetimeShowTimezone.IsUnknown() {
+ if data.TimestampsLogDatetimeShowTimezone.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/timestamps/log-config/datetime/show-timezone", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/timestamps/log-config/datetime/show-timezone")
+ }
+ }
+ if !data.TimestampsLogDatetimeYear.IsNull() && !data.TimestampsLogDatetimeYear.IsUnknown() {
+ if data.TimestampsLogDatetimeYear.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/timestamps/log-config/datetime/year", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/timestamps/log-config/datetime/year")
+ }
+ }
+ if !data.TimestampsLogUptime.IsNull() && !data.TimestampsLogUptime.IsUnknown() {
+ if data.TimestampsLogUptime.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/timestamps/log-config/uptime", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/timestamps/log-config/uptime")
+ }
+ }
+ if !data.Dhcp.IsNull() && !data.Dhcp.IsUnknown() {
+ if data.Dhcp.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/dhcp", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/dhcp")
+ }
+ }
+ if !data.TcpKeepalivesIn.IsNull() && !data.TcpKeepalivesIn.IsUnknown() {
+ if data.TcpKeepalivesIn.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/tcp-keepalives-in", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/tcp-keepalives-in")
+ }
+ }
+ if !data.TcpKeepalivesOut.IsNull() && !data.TcpKeepalivesOut.IsUnknown() {
+ if data.TcpKeepalivesOut.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/tcp-keepalives-out", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/tcp-keepalives-out")
+ }
+ }
+ if !data.CompressConfig.IsNull() && !data.CompressConfig.IsUnknown() {
+ if data.CompressConfig.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/compress-config", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/compress-config")
+ }
+ }
+ if !data.SequenceNumbers.IsNull() && !data.SequenceNumbers.IsUnknown() {
+ if data.SequenceNumbers.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/sequence-numbers", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/sequence-numbers")
+ }
+ }
+ if !data.CallHome.IsNull() && !data.CallHome.IsUnknown() {
+ if data.CallHome.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/call-home", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/call-home")
+ }
+ }
+ if !data.DhcpConfig.IsNull() && !data.DhcpConfig.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/dhcp-config", data.DhcpConfig.ValueBool())
+ }
+ bodyString, err := body.String()
+ if err != nil {
+ tflog.Error(ctx, fmt.Sprintf("Error converting body to string: %s", err))
+ }
+ return bodyString
+}
+
+// End of section. //template:end toBodyXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBody
func (data *Service) updateFromBody(ctx context.Context, res gjson.Result) {
@@ -464,22 +654,384 @@ func (data *Service) updateFromBody(ctx context.Context, res gjson.Result) {
data.CallHome = types.BoolValue(false)
}
} else {
- data.CallHome = types.BoolNull()
+ data.CallHome = types.BoolNull()
+ }
+ if value := res.Get(prefix + "dhcp-config"); !data.DhcpConfig.IsNull() {
+ if value.Exists() {
+ data.DhcpConfig = types.BoolValue(value.Bool())
+ }
+ } else {
+ data.DhcpConfig = types.BoolNull()
+ }
+}
+
+// End of section. //template:end updateFromBody
+
+// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBodyXML
+
+func (data *Service) updateFromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/pad-conf/pad"); !data.Pad.IsNull() {
+ if value.Exists() {
+ data.Pad = types.BoolValue(value.Bool())
+ }
+ } else {
+ data.Pad = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/password-encryption"); !data.PasswordEncryption.IsNull() {
+ if value.Exists() {
+ data.PasswordEncryption = types.BoolValue(true)
+ } else {
+ data.PasswordEncryption = types.BoolValue(false)
+ }
+ } else {
+ data.PasswordEncryption = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/password-recovery"); !data.PasswordRecovery.IsNull() {
+ if value.Exists() {
+ data.PasswordRecovery = types.BoolValue(value.Bool())
+ }
+ } else {
+ data.PasswordRecovery = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/timestamps"); !data.Timestamps.IsNull() {
+ if value.Exists() {
+ data.Timestamps = types.BoolValue(true)
+ } else {
+ data.Timestamps = types.BoolValue(false)
+ }
+ } else {
+ data.Timestamps = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/timestamps/debug-config"); !data.TimestampsDebug.IsNull() {
+ if value.Exists() {
+ data.TimestampsDebug = types.BoolValue(true)
+ } else {
+ data.TimestampsDebug = types.BoolValue(false)
+ }
+ } else {
+ data.TimestampsDebug = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/timestamps/debug-config/datetime"); !data.TimestampsDebugDatetime.IsNull() {
+ if value.Exists() {
+ data.TimestampsDebugDatetime = types.BoolValue(true)
+ } else {
+ data.TimestampsDebugDatetime = types.BoolValue(false)
+ }
+ } else {
+ data.TimestampsDebugDatetime = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/timestamps/debug-config/datetime/msec"); !data.TimestampsDebugDatetimeMsec.IsNull() {
+ if value.Exists() {
+ data.TimestampsDebugDatetimeMsec = types.BoolValue(true)
+ } else {
+ data.TimestampsDebugDatetimeMsec = types.BoolValue(false)
+ }
+ } else {
+ data.TimestampsDebugDatetimeMsec = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/timestamps/debug-config/datetime/localtime"); !data.TimestampsDebugDatetimeLocaltime.IsNull() {
+ if value.Exists() {
+ data.TimestampsDebugDatetimeLocaltime = types.BoolValue(true)
+ } else {
+ data.TimestampsDebugDatetimeLocaltime = types.BoolValue(false)
+ }
+ } else {
+ data.TimestampsDebugDatetimeLocaltime = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/timestamps/debug-config/datetime/show-timezone"); !data.TimestampsDebugDatetimeShowTimezone.IsNull() {
+ if value.Exists() {
+ data.TimestampsDebugDatetimeShowTimezone = types.BoolValue(true)
+ } else {
+ data.TimestampsDebugDatetimeShowTimezone = types.BoolValue(false)
+ }
+ } else {
+ data.TimestampsDebugDatetimeShowTimezone = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/timestamps/debug-config/datetime/year"); !data.TimestampsDebugDatetimeYear.IsNull() {
+ if value.Exists() {
+ data.TimestampsDebugDatetimeYear = types.BoolValue(true)
+ } else {
+ data.TimestampsDebugDatetimeYear = types.BoolValue(false)
+ }
+ } else {
+ data.TimestampsDebugDatetimeYear = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/timestamps/debug-config/uptime"); !data.TimestampsDebugUptime.IsNull() {
+ if value.Exists() {
+ data.TimestampsDebugUptime = types.BoolValue(true)
+ } else {
+ data.TimestampsDebugUptime = types.BoolValue(false)
+ }
+ } else {
+ data.TimestampsDebugUptime = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/timestamps/log-config"); !data.TimestampsLog.IsNull() {
+ if value.Exists() {
+ data.TimestampsLog = types.BoolValue(true)
+ } else {
+ data.TimestampsLog = types.BoolValue(false)
+ }
+ } else {
+ data.TimestampsLog = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/timestamps/log-config/datetime"); !data.TimestampsLogDatetime.IsNull() {
+ if value.Exists() {
+ data.TimestampsLogDatetime = types.BoolValue(true)
+ } else {
+ data.TimestampsLogDatetime = types.BoolValue(false)
+ }
+ } else {
+ data.TimestampsLogDatetime = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/timestamps/log-config/datetime/msec"); !data.TimestampsLogDatetimeMsec.IsNull() {
+ if value.Exists() {
+ data.TimestampsLogDatetimeMsec = types.BoolValue(true)
+ } else {
+ data.TimestampsLogDatetimeMsec = types.BoolValue(false)
+ }
+ } else {
+ data.TimestampsLogDatetimeMsec = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/timestamps/log-config/datetime/localtime"); !data.TimestampsLogDatetimeLocaltime.IsNull() {
+ if value.Exists() {
+ data.TimestampsLogDatetimeLocaltime = types.BoolValue(true)
+ } else {
+ data.TimestampsLogDatetimeLocaltime = types.BoolValue(false)
+ }
+ } else {
+ data.TimestampsLogDatetimeLocaltime = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/timestamps/log-config/datetime/show-timezone"); !data.TimestampsLogDatetimeShowTimezone.IsNull() {
+ if value.Exists() {
+ data.TimestampsLogDatetimeShowTimezone = types.BoolValue(true)
+ } else {
+ data.TimestampsLogDatetimeShowTimezone = types.BoolValue(false)
+ }
+ } else {
+ data.TimestampsLogDatetimeShowTimezone = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/timestamps/log-config/datetime/year"); !data.TimestampsLogDatetimeYear.IsNull() {
+ if value.Exists() {
+ data.TimestampsLogDatetimeYear = types.BoolValue(true)
+ } else {
+ data.TimestampsLogDatetimeYear = types.BoolValue(false)
+ }
+ } else {
+ data.TimestampsLogDatetimeYear = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/timestamps/log-config/uptime"); !data.TimestampsLogUptime.IsNull() {
+ if value.Exists() {
+ data.TimestampsLogUptime = types.BoolValue(true)
+ } else {
+ data.TimestampsLogUptime = types.BoolValue(false)
+ }
+ } else {
+ data.TimestampsLogUptime = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/dhcp"); !data.Dhcp.IsNull() {
+ if value.Exists() {
+ data.Dhcp = types.BoolValue(true)
+ } else {
+ data.Dhcp = types.BoolValue(false)
+ }
+ } else {
+ data.Dhcp = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/tcp-keepalives-in"); !data.TcpKeepalivesIn.IsNull() {
+ if value.Exists() {
+ data.TcpKeepalivesIn = types.BoolValue(true)
+ } else {
+ data.TcpKeepalivesIn = types.BoolValue(false)
+ }
+ } else {
+ data.TcpKeepalivesIn = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/tcp-keepalives-out"); !data.TcpKeepalivesOut.IsNull() {
+ if value.Exists() {
+ data.TcpKeepalivesOut = types.BoolValue(true)
+ } else {
+ data.TcpKeepalivesOut = types.BoolValue(false)
+ }
+ } else {
+ data.TcpKeepalivesOut = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/compress-config"); !data.CompressConfig.IsNull() {
+ if value.Exists() {
+ data.CompressConfig = types.BoolValue(true)
+ } else {
+ data.CompressConfig = types.BoolValue(false)
+ }
+ } else {
+ data.CompressConfig = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/sequence-numbers"); !data.SequenceNumbers.IsNull() {
+ if value.Exists() {
+ data.SequenceNumbers = types.BoolValue(true)
+ } else {
+ data.SequenceNumbers = types.BoolValue(false)
+ }
+ } else {
+ data.SequenceNumbers = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/call-home"); !data.CallHome.IsNull() {
+ if value.Exists() {
+ data.CallHome = types.BoolValue(true)
+ } else {
+ data.CallHome = types.BoolValue(false)
+ }
+ } else {
+ data.CallHome = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/dhcp-config"); !data.DhcpConfig.IsNull() {
+ if value.Exists() {
+ data.DhcpConfig = types.BoolValue(value.Bool())
+ }
+ } else {
+ data.DhcpConfig = types.BoolNull()
+ }
+}
+
+// End of section. //template:end updateFromBodyXML
+
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBody
+
+func (data *Service) fromBody(ctx context.Context, res gjson.Result) {
+ prefix := helpers.LastElement(data.getPath()) + "."
+ if res.Get(helpers.LastElement(data.getPath())).IsArray() {
+ prefix += "0."
+ }
+ if value := res.Get(prefix + "pad-conf.pad"); value.Exists() {
+ data.Pad = types.BoolValue(value.Bool())
+ } else {
+ data.Pad = types.BoolNull()
+ }
+ if value := res.Get(prefix + "password-encryption"); value.Exists() {
+ data.PasswordEncryption = types.BoolValue(true)
+ } else {
+ data.PasswordEncryption = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "password-recovery"); value.Exists() {
+ data.PasswordRecovery = types.BoolValue(value.Bool())
+ } else {
+ data.PasswordRecovery = types.BoolNull()
+ }
+ if value := res.Get(prefix + "timestamps"); value.Exists() {
+ data.Timestamps = types.BoolValue(true)
+ } else {
+ data.Timestamps = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "timestamps.debug-config"); value.Exists() {
+ data.TimestampsDebug = types.BoolValue(true)
+ } else {
+ data.TimestampsDebug = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "timestamps.debug-config.datetime"); value.Exists() {
+ data.TimestampsDebugDatetime = types.BoolValue(true)
+ } else {
+ data.TimestampsDebugDatetime = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "timestamps.debug-config.datetime.msec"); value.Exists() {
+ data.TimestampsDebugDatetimeMsec = types.BoolValue(true)
+ } else {
+ data.TimestampsDebugDatetimeMsec = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "timestamps.debug-config.datetime.localtime"); value.Exists() {
+ data.TimestampsDebugDatetimeLocaltime = types.BoolValue(true)
+ } else {
+ data.TimestampsDebugDatetimeLocaltime = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "timestamps.debug-config.datetime.show-timezone"); value.Exists() {
+ data.TimestampsDebugDatetimeShowTimezone = types.BoolValue(true)
+ } else {
+ data.TimestampsDebugDatetimeShowTimezone = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "timestamps.debug-config.datetime.year"); value.Exists() {
+ data.TimestampsDebugDatetimeYear = types.BoolValue(true)
+ } else {
+ data.TimestampsDebugDatetimeYear = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "timestamps.debug-config.uptime"); value.Exists() {
+ data.TimestampsDebugUptime = types.BoolValue(true)
+ } else {
+ data.TimestampsDebugUptime = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "timestamps.log-config"); value.Exists() {
+ data.TimestampsLog = types.BoolValue(true)
+ } else {
+ data.TimestampsLog = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "timestamps.log-config.datetime"); value.Exists() {
+ data.TimestampsLogDatetime = types.BoolValue(true)
+ } else {
+ data.TimestampsLogDatetime = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "timestamps.log-config.datetime.msec"); value.Exists() {
+ data.TimestampsLogDatetimeMsec = types.BoolValue(true)
+ } else {
+ data.TimestampsLogDatetimeMsec = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "timestamps.log-config.datetime.localtime"); value.Exists() {
+ data.TimestampsLogDatetimeLocaltime = types.BoolValue(true)
+ } else {
+ data.TimestampsLogDatetimeLocaltime = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "timestamps.log-config.datetime.show-timezone"); value.Exists() {
+ data.TimestampsLogDatetimeShowTimezone = types.BoolValue(true)
+ } else {
+ data.TimestampsLogDatetimeShowTimezone = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "timestamps.log-config.datetime.year"); value.Exists() {
+ data.TimestampsLogDatetimeYear = types.BoolValue(true)
+ } else {
+ data.TimestampsLogDatetimeYear = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "timestamps.log-config.uptime"); value.Exists() {
+ data.TimestampsLogUptime = types.BoolValue(true)
+ } else {
+ data.TimestampsLogUptime = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "dhcp"); value.Exists() {
+ data.Dhcp = types.BoolValue(true)
+ } else {
+ data.Dhcp = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "tcp-keepalives-in"); value.Exists() {
+ data.TcpKeepalivesIn = types.BoolValue(true)
+ } else {
+ data.TcpKeepalivesIn = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "tcp-keepalives-out"); value.Exists() {
+ data.TcpKeepalivesOut = types.BoolValue(true)
+ } else {
+ data.TcpKeepalivesOut = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "compress-config"); value.Exists() {
+ data.CompressConfig = types.BoolValue(true)
+ } else {
+ data.CompressConfig = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "sequence-numbers"); value.Exists() {
+ data.SequenceNumbers = types.BoolValue(true)
+ } else {
+ data.SequenceNumbers = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "call-home"); value.Exists() {
+ data.CallHome = types.BoolValue(true)
+ } else {
+ data.CallHome = types.BoolValue(false)
}
- if value := res.Get(prefix + "dhcp-config"); !data.DhcpConfig.IsNull() {
- if value.Exists() {
- data.DhcpConfig = types.BoolValue(value.Bool())
- }
+ if value := res.Get(prefix + "dhcp-config"); value.Exists() {
+ data.DhcpConfig = types.BoolValue(value.Bool())
} else {
data.DhcpConfig = types.BoolNull()
}
}
-// End of section. //template:end updateFromBody
+// End of section. //template:end fromBody
-// Section below is generated&owned by "gen/generator.go". //template:begin fromBody
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyData
-func (data *Service) fromBody(ctx context.Context, res gjson.Result) {
+func (data *ServiceData) fromBody(ctx context.Context, res gjson.Result) {
prefix := helpers.LastElement(data.getPath()) + "."
if res.Get(helpers.LastElement(data.getPath())).IsArray() {
prefix += "0."
@@ -611,143 +1163,271 @@ func (data *Service) fromBody(ctx context.Context, res gjson.Result) {
}
}
-// End of section. //template:end fromBody
+// End of section. //template:end fromBodyData
-// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyData
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyXML
-func (data *ServiceData) fromBody(ctx context.Context, res gjson.Result) {
- prefix := helpers.LastElement(data.getPath()) + "."
- if res.Get(helpers.LastElement(data.getPath())).IsArray() {
- prefix += "0."
+func (data *Service) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/pad-conf/pad"); value.Exists() {
+ data.Pad = types.BoolValue(value.Bool())
+ } else {
+ data.Pad = types.BoolNull()
}
- if value := res.Get(prefix + "pad-conf.pad"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/password-encryption"); value.Exists() {
+ data.PasswordEncryption = types.BoolValue(true)
+ } else {
+ data.PasswordEncryption = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/password-recovery"); value.Exists() {
+ data.PasswordRecovery = types.BoolValue(value.Bool())
+ } else {
+ data.PasswordRecovery = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/timestamps"); value.Exists() {
+ data.Timestamps = types.BoolValue(true)
+ } else {
+ data.Timestamps = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/timestamps/debug-config"); value.Exists() {
+ data.TimestampsDebug = types.BoolValue(true)
+ } else {
+ data.TimestampsDebug = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/timestamps/debug-config/datetime"); value.Exists() {
+ data.TimestampsDebugDatetime = types.BoolValue(true)
+ } else {
+ data.TimestampsDebugDatetime = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/timestamps/debug-config/datetime/msec"); value.Exists() {
+ data.TimestampsDebugDatetimeMsec = types.BoolValue(true)
+ } else {
+ data.TimestampsDebugDatetimeMsec = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/timestamps/debug-config/datetime/localtime"); value.Exists() {
+ data.TimestampsDebugDatetimeLocaltime = types.BoolValue(true)
+ } else {
+ data.TimestampsDebugDatetimeLocaltime = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/timestamps/debug-config/datetime/show-timezone"); value.Exists() {
+ data.TimestampsDebugDatetimeShowTimezone = types.BoolValue(true)
+ } else {
+ data.TimestampsDebugDatetimeShowTimezone = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/timestamps/debug-config/datetime/year"); value.Exists() {
+ data.TimestampsDebugDatetimeYear = types.BoolValue(true)
+ } else {
+ data.TimestampsDebugDatetimeYear = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/timestamps/debug-config/uptime"); value.Exists() {
+ data.TimestampsDebugUptime = types.BoolValue(true)
+ } else {
+ data.TimestampsDebugUptime = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/timestamps/log-config"); value.Exists() {
+ data.TimestampsLog = types.BoolValue(true)
+ } else {
+ data.TimestampsLog = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/timestamps/log-config/datetime"); value.Exists() {
+ data.TimestampsLogDatetime = types.BoolValue(true)
+ } else {
+ data.TimestampsLogDatetime = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/timestamps/log-config/datetime/msec"); value.Exists() {
+ data.TimestampsLogDatetimeMsec = types.BoolValue(true)
+ } else {
+ data.TimestampsLogDatetimeMsec = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/timestamps/log-config/datetime/localtime"); value.Exists() {
+ data.TimestampsLogDatetimeLocaltime = types.BoolValue(true)
+ } else {
+ data.TimestampsLogDatetimeLocaltime = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/timestamps/log-config/datetime/show-timezone"); value.Exists() {
+ data.TimestampsLogDatetimeShowTimezone = types.BoolValue(true)
+ } else {
+ data.TimestampsLogDatetimeShowTimezone = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/timestamps/log-config/datetime/year"); value.Exists() {
+ data.TimestampsLogDatetimeYear = types.BoolValue(true)
+ } else {
+ data.TimestampsLogDatetimeYear = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/timestamps/log-config/uptime"); value.Exists() {
+ data.TimestampsLogUptime = types.BoolValue(true)
+ } else {
+ data.TimestampsLogUptime = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/dhcp"); value.Exists() {
+ data.Dhcp = types.BoolValue(true)
+ } else {
+ data.Dhcp = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/tcp-keepalives-in"); value.Exists() {
+ data.TcpKeepalivesIn = types.BoolValue(true)
+ } else {
+ data.TcpKeepalivesIn = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/tcp-keepalives-out"); value.Exists() {
+ data.TcpKeepalivesOut = types.BoolValue(true)
+ } else {
+ data.TcpKeepalivesOut = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/compress-config"); value.Exists() {
+ data.CompressConfig = types.BoolValue(true)
+ } else {
+ data.CompressConfig = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/sequence-numbers"); value.Exists() {
+ data.SequenceNumbers = types.BoolValue(true)
+ } else {
+ data.SequenceNumbers = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/call-home"); value.Exists() {
+ data.CallHome = types.BoolValue(true)
+ } else {
+ data.CallHome = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/dhcp-config"); value.Exists() {
+ data.DhcpConfig = types.BoolValue(value.Bool())
+ } else {
+ data.DhcpConfig = types.BoolNull()
+ }
+}
+
+// End of section. //template:end fromBodyXML
+
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyDataXML
+
+func (data *ServiceData) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/pad-conf/pad"); value.Exists() {
data.Pad = types.BoolValue(value.Bool())
} else {
data.Pad = types.BoolNull()
}
- if value := res.Get(prefix + "password-encryption"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/password-encryption"); value.Exists() {
data.PasswordEncryption = types.BoolValue(true)
} else {
data.PasswordEncryption = types.BoolValue(false)
}
- if value := res.Get(prefix + "password-recovery"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/password-recovery"); value.Exists() {
data.PasswordRecovery = types.BoolValue(value.Bool())
} else {
data.PasswordRecovery = types.BoolNull()
}
- if value := res.Get(prefix + "timestamps"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/timestamps"); value.Exists() {
data.Timestamps = types.BoolValue(true)
} else {
data.Timestamps = types.BoolValue(false)
}
- if value := res.Get(prefix + "timestamps.debug-config"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/timestamps/debug-config"); value.Exists() {
data.TimestampsDebug = types.BoolValue(true)
} else {
data.TimestampsDebug = types.BoolValue(false)
}
- if value := res.Get(prefix + "timestamps.debug-config.datetime"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/timestamps/debug-config/datetime"); value.Exists() {
data.TimestampsDebugDatetime = types.BoolValue(true)
} else {
data.TimestampsDebugDatetime = types.BoolValue(false)
}
- if value := res.Get(prefix + "timestamps.debug-config.datetime.msec"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/timestamps/debug-config/datetime/msec"); value.Exists() {
data.TimestampsDebugDatetimeMsec = types.BoolValue(true)
} else {
data.TimestampsDebugDatetimeMsec = types.BoolValue(false)
}
- if value := res.Get(prefix + "timestamps.debug-config.datetime.localtime"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/timestamps/debug-config/datetime/localtime"); value.Exists() {
data.TimestampsDebugDatetimeLocaltime = types.BoolValue(true)
} else {
data.TimestampsDebugDatetimeLocaltime = types.BoolValue(false)
}
- if value := res.Get(prefix + "timestamps.debug-config.datetime.show-timezone"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/timestamps/debug-config/datetime/show-timezone"); value.Exists() {
data.TimestampsDebugDatetimeShowTimezone = types.BoolValue(true)
} else {
data.TimestampsDebugDatetimeShowTimezone = types.BoolValue(false)
}
- if value := res.Get(prefix + "timestamps.debug-config.datetime.year"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/timestamps/debug-config/datetime/year"); value.Exists() {
data.TimestampsDebugDatetimeYear = types.BoolValue(true)
} else {
data.TimestampsDebugDatetimeYear = types.BoolValue(false)
}
- if value := res.Get(prefix + "timestamps.debug-config.uptime"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/timestamps/debug-config/uptime"); value.Exists() {
data.TimestampsDebugUptime = types.BoolValue(true)
} else {
data.TimestampsDebugUptime = types.BoolValue(false)
}
- if value := res.Get(prefix + "timestamps.log-config"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/timestamps/log-config"); value.Exists() {
data.TimestampsLog = types.BoolValue(true)
} else {
data.TimestampsLog = types.BoolValue(false)
}
- if value := res.Get(prefix + "timestamps.log-config.datetime"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/timestamps/log-config/datetime"); value.Exists() {
data.TimestampsLogDatetime = types.BoolValue(true)
} else {
data.TimestampsLogDatetime = types.BoolValue(false)
}
- if value := res.Get(prefix + "timestamps.log-config.datetime.msec"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/timestamps/log-config/datetime/msec"); value.Exists() {
data.TimestampsLogDatetimeMsec = types.BoolValue(true)
} else {
data.TimestampsLogDatetimeMsec = types.BoolValue(false)
}
- if value := res.Get(prefix + "timestamps.log-config.datetime.localtime"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/timestamps/log-config/datetime/localtime"); value.Exists() {
data.TimestampsLogDatetimeLocaltime = types.BoolValue(true)
} else {
data.TimestampsLogDatetimeLocaltime = types.BoolValue(false)
}
- if value := res.Get(prefix + "timestamps.log-config.datetime.show-timezone"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/timestamps/log-config/datetime/show-timezone"); value.Exists() {
data.TimestampsLogDatetimeShowTimezone = types.BoolValue(true)
} else {
data.TimestampsLogDatetimeShowTimezone = types.BoolValue(false)
}
- if value := res.Get(prefix + "timestamps.log-config.datetime.year"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/timestamps/log-config/datetime/year"); value.Exists() {
data.TimestampsLogDatetimeYear = types.BoolValue(true)
} else {
data.TimestampsLogDatetimeYear = types.BoolValue(false)
}
- if value := res.Get(prefix + "timestamps.log-config.uptime"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/timestamps/log-config/uptime"); value.Exists() {
data.TimestampsLogUptime = types.BoolValue(true)
} else {
data.TimestampsLogUptime = types.BoolValue(false)
}
- if value := res.Get(prefix + "dhcp"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/dhcp"); value.Exists() {
data.Dhcp = types.BoolValue(true)
} else {
data.Dhcp = types.BoolValue(false)
}
- if value := res.Get(prefix + "tcp-keepalives-in"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/tcp-keepalives-in"); value.Exists() {
data.TcpKeepalivesIn = types.BoolValue(true)
} else {
data.TcpKeepalivesIn = types.BoolValue(false)
}
- if value := res.Get(prefix + "tcp-keepalives-out"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/tcp-keepalives-out"); value.Exists() {
data.TcpKeepalivesOut = types.BoolValue(true)
} else {
data.TcpKeepalivesOut = types.BoolValue(false)
}
- if value := res.Get(prefix + "compress-config"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/compress-config"); value.Exists() {
data.CompressConfig = types.BoolValue(true)
} else {
data.CompressConfig = types.BoolValue(false)
}
- if value := res.Get(prefix + "sequence-numbers"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/sequence-numbers"); value.Exists() {
data.SequenceNumbers = types.BoolValue(true)
} else {
data.SequenceNumbers = types.BoolValue(false)
}
- if value := res.Get(prefix + "call-home"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/call-home"); value.Exists() {
data.CallHome = types.BoolValue(true)
} else {
data.CallHome = types.BoolValue(false)
}
- if value := res.Get(prefix + "dhcp-config"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/dhcp-config"); value.Exists() {
data.DhcpConfig = types.BoolValue(value.Bool())
} else {
data.DhcpConfig = types.BoolNull()
}
}
-// End of section. //template:end fromBodyData
+// End of section. //template:end fromBodyDataXML
// Section below is generated&owned by "gen/generator.go". //template:begin getDeletedItems
@@ -831,6 +1511,88 @@ func (data *Service) getDeletedItems(ctx context.Context, state Service) []strin
// End of section. //template:end getDeletedItems
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletedItemsXML
+
+func (data *Service) addDeletedItemsXML(ctx context.Context, state Service, body string) string {
+ b := netconf.NewBody(body)
+ if !state.Pad.IsNull() && data.Pad.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/pad-conf/pad")
+ }
+ if !state.PasswordEncryption.IsNull() && data.PasswordEncryption.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/password-encryption")
+ }
+ if !state.Timestamps.IsNull() && data.Timestamps.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/timestamps")
+ }
+ if !state.TimestampsDebug.IsNull() && data.TimestampsDebug.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/timestamps/debug-config")
+ }
+ if !state.TimestampsDebugDatetime.IsNull() && data.TimestampsDebugDatetime.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/timestamps/debug-config/datetime")
+ }
+ if !state.TimestampsDebugDatetimeMsec.IsNull() && data.TimestampsDebugDatetimeMsec.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/timestamps/debug-config/datetime/msec")
+ }
+ if !state.TimestampsDebugDatetimeLocaltime.IsNull() && data.TimestampsDebugDatetimeLocaltime.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/timestamps/debug-config/datetime/localtime")
+ }
+ if !state.TimestampsDebugDatetimeShowTimezone.IsNull() && data.TimestampsDebugDatetimeShowTimezone.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/timestamps/debug-config/datetime/show-timezone")
+ }
+ if !state.TimestampsDebugDatetimeYear.IsNull() && data.TimestampsDebugDatetimeYear.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/timestamps/debug-config/datetime/year")
+ }
+ if !state.TimestampsDebugUptime.IsNull() && data.TimestampsDebugUptime.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/timestamps/debug-config/uptime")
+ }
+ if !state.TimestampsLog.IsNull() && data.TimestampsLog.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/timestamps/log-config")
+ }
+ if !state.TimestampsLogDatetime.IsNull() && data.TimestampsLogDatetime.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/timestamps/log-config/datetime")
+ }
+ if !state.TimestampsLogDatetimeMsec.IsNull() && data.TimestampsLogDatetimeMsec.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/timestamps/log-config/datetime/msec")
+ }
+ if !state.TimestampsLogDatetimeLocaltime.IsNull() && data.TimestampsLogDatetimeLocaltime.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/timestamps/log-config/datetime/localtime")
+ }
+ if !state.TimestampsLogDatetimeShowTimezone.IsNull() && data.TimestampsLogDatetimeShowTimezone.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/timestamps/log-config/datetime/show-timezone")
+ }
+ if !state.TimestampsLogDatetimeYear.IsNull() && data.TimestampsLogDatetimeYear.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/timestamps/log-config/datetime/year")
+ }
+ if !state.TimestampsLogUptime.IsNull() && data.TimestampsLogUptime.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/timestamps/log-config/uptime")
+ }
+ if !state.Dhcp.IsNull() && data.Dhcp.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/dhcp")
+ }
+ if !state.TcpKeepalivesIn.IsNull() && data.TcpKeepalivesIn.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/tcp-keepalives-in")
+ }
+ if !state.TcpKeepalivesOut.IsNull() && data.TcpKeepalivesOut.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/tcp-keepalives-out")
+ }
+ if !state.CompressConfig.IsNull() && data.CompressConfig.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/compress-config")
+ }
+ if !state.SequenceNumbers.IsNull() && data.SequenceNumbers.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/sequence-numbers")
+ }
+ if !state.CallHome.IsNull() && data.CallHome.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/call-home")
+ }
+ if !state.DhcpConfig.IsNull() && data.DhcpConfig.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/dhcp-config")
+ }
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletedItemsXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin getEmptyLeafsDelete
func (data *Service) getEmptyLeafsDelete(ctx context.Context) []string {
@@ -988,3 +1750,85 @@ func (data *Service) getDeletePaths(ctx context.Context) []string {
}
// End of section. //template:end getDeletePaths
+
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletePathsXML
+
+func (data *Service) addDeletePathsXML(ctx context.Context, body string) string {
+ b := netconf.NewBody(body)
+ if !data.Pad.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/pad-conf/pad")
+ }
+ if !data.PasswordEncryption.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/password-encryption")
+ }
+ if !data.Timestamps.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/timestamps")
+ }
+ if !data.TimestampsDebug.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/timestamps/debug-config")
+ }
+ if !data.TimestampsDebugDatetime.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/timestamps/debug-config/datetime")
+ }
+ if !data.TimestampsDebugDatetimeMsec.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/timestamps/debug-config/datetime/msec")
+ }
+ if !data.TimestampsDebugDatetimeLocaltime.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/timestamps/debug-config/datetime/localtime")
+ }
+ if !data.TimestampsDebugDatetimeShowTimezone.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/timestamps/debug-config/datetime/show-timezone")
+ }
+ if !data.TimestampsDebugDatetimeYear.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/timestamps/debug-config/datetime/year")
+ }
+ if !data.TimestampsDebugUptime.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/timestamps/debug-config/uptime")
+ }
+ if !data.TimestampsLog.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/timestamps/log-config")
+ }
+ if !data.TimestampsLogDatetime.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/timestamps/log-config/datetime")
+ }
+ if !data.TimestampsLogDatetimeMsec.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/timestamps/log-config/datetime/msec")
+ }
+ if !data.TimestampsLogDatetimeLocaltime.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/timestamps/log-config/datetime/localtime")
+ }
+ if !data.TimestampsLogDatetimeShowTimezone.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/timestamps/log-config/datetime/show-timezone")
+ }
+ if !data.TimestampsLogDatetimeYear.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/timestamps/log-config/datetime/year")
+ }
+ if !data.TimestampsLogUptime.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/timestamps/log-config/uptime")
+ }
+ if !data.Dhcp.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/dhcp")
+ }
+ if !data.TcpKeepalivesIn.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/tcp-keepalives-in")
+ }
+ if !data.TcpKeepalivesOut.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/tcp-keepalives-out")
+ }
+ if !data.CompressConfig.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/compress-config")
+ }
+ if !data.SequenceNumbers.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/sequence-numbers")
+ }
+ if !data.CallHome.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/call-home")
+ }
+ if !data.DhcpConfig.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/dhcp-config")
+ }
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletePathsXML
diff --git a/internal/provider/model_iosxe_service_template.go b/internal/provider/model_iosxe_service_template.go
index a674d91f..5bc20074 100644
--- a/internal/provider/model_iosxe_service_template.go
+++ b/internal/provider/model_iosxe_service_template.go
@@ -31,6 +31,9 @@ import (
"github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/types"
+ "github.com/hashicorp/terraform-plugin-log/tflog"
+ "github.com/netascode/go-netconf"
+ "github.com/netascode/xmldot"
"github.com/tidwall/gjson"
"github.com/tidwall/sjson"
)
@@ -126,6 +129,19 @@ func (data ServiceTemplate) getPathShort() string {
return matches[1]
}
+// getXPath returns the XPath for NETCONF operations
+func (data ServiceTemplate) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/Cisco-IOS-XE-switch:service-template[word=%v]"
+ path = fmt.Sprintf(path, fmt.Sprintf("%v", data.Name.ValueString()))
+ return path
+}
+
+func (data ServiceTemplateData) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/Cisco-IOS-XE-switch:service-template[word=%v]"
+ path = fmt.Sprintf(path, fmt.Sprintf("%v", data.Name.ValueString()))
+ return path
+}
+
// End of section. //template:end getPath
// Section below is generated&owned by "gen/generator.go". //template:begin toBody
@@ -225,6 +241,114 @@ func (data ServiceTemplate) toBody(ctx context.Context) string {
// End of section. //template:end toBody
+// Section below is generated&owned by "gen/generator.go". //template:begin toBodyXML
+
+func (data ServiceTemplate) toBodyXML(ctx context.Context) string {
+ body := netconf.Body{}
+ if !data.Name.IsNull() && !data.Name.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/word", data.Name.ValueString())
+ }
+ if len(data.AccessGroups) > 0 {
+ for _, item := range data.AccessGroups {
+ cBody := netconf.Body{}
+ if !item.Name.IsNull() && !item.Name.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "name", item.Name.ValueString())
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/access-group-config", cBody.Res())
+ }
+ }
+ if !data.InactivityTimer.IsNull() && !data.InactivityTimer.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/inactivity-timer/value", strconv.FormatInt(data.InactivityTimer.ValueInt64(), 10))
+ }
+ if !data.InactivityTimerProbe.IsNull() && !data.InactivityTimerProbe.IsUnknown() {
+ if data.InactivityTimerProbe.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/inactivity-timer/probe", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/inactivity-timer/probe")
+ }
+ }
+ if !data.Vlan.IsNull() && !data.Vlan.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/vlan", strconv.FormatInt(data.Vlan.ValueInt64(), 10))
+ }
+ if !data.VoiceVlan.IsNull() && !data.VoiceVlan.IsUnknown() {
+ if data.VoiceVlan.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/voice/vlan", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/voice/vlan")
+ }
+ }
+ if !data.LinksecPolicy.IsNull() && !data.LinksecPolicy.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/linksec/policy", data.LinksecPolicy.ValueString())
+ }
+ if !data.Sgt.IsNull() && !data.Sgt.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/sgt", strconv.FormatInt(data.Sgt.ValueInt64(), 10))
+ }
+ if !data.AbsoluteTimer.IsNull() && !data.AbsoluteTimer.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/absolute-timer", strconv.FormatInt(data.AbsoluteTimer.ValueInt64(), 10))
+ }
+ if !data.Description.IsNull() && !data.Description.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/description", data.Description.ValueString())
+ }
+ if len(data.InterfaceTemplates) > 0 {
+ for _, item := range data.InterfaceTemplates {
+ cBody := netconf.Body{}
+ if !item.Name.IsNull() && !item.Name.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "name", item.Name.ValueString())
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/interface-template", cBody.Res())
+ }
+ }
+ if !data.TunnelCapwapName.IsNull() && !data.TunnelCapwapName.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/tunnel/type/capwap/name", data.TunnelCapwapName.ValueString())
+ }
+ if !data.Vnid.IsNull() && !data.Vnid.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/vnid", data.Vnid.ValueString())
+ }
+ if !data.RedirectAppendClientMac.IsNull() && !data.RedirectAppendClientMac.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/redirect/append/client-mac", data.RedirectAppendClientMac.ValueString())
+ }
+ if !data.RedirectAppendSwitchMac.IsNull() && !data.RedirectAppendSwitchMac.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/redirect/append/switch-mac", data.RedirectAppendSwitchMac.ValueString())
+ }
+ if !data.RedirectUrl.IsNull() && !data.RedirectUrl.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/redirect/url/url_name", data.RedirectUrl.ValueString())
+ }
+ if !data.RedirectUrlMatchAcl.IsNull() && !data.RedirectUrlMatchAcl.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/redirect/url/match/acl_name", data.RedirectUrlMatchAcl.ValueString())
+ }
+ if !data.RedirectUrlMatchAction.IsNull() && !data.RedirectUrlMatchAction.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/redirect/url/match/action", data.RedirectUrlMatchAction.ValueString())
+ }
+ if !data.DnsAclPreauth.IsNull() && !data.DnsAclPreauth.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/dns-acl/preauth", data.DnsAclPreauth.ValueString())
+ }
+ if !data.ServicePolicyQosInput.IsNull() && !data.ServicePolicyQosInput.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/service-policy/qos/input", data.ServicePolicyQosInput.ValueString())
+ }
+ if !data.ServicePolicyQosOutput.IsNull() && !data.ServicePolicyQosOutput.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/service-policy/qos/output", data.ServicePolicyQosOutput.ValueString())
+ }
+ if len(data.Tags) > 0 {
+ for _, item := range data.Tags {
+ cBody := netconf.Body{}
+ if !item.Name.IsNull() && !item.Name.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "name", item.Name.ValueString())
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/tag-config", cBody.Res())
+ }
+ }
+ if !data.MdnsServicePolicy.IsNull() && !data.MdnsServicePolicy.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/mdns-service-policy", data.MdnsServicePolicy.ValueString())
+ }
+ bodyString, err := body.String()
+ if err != nil {
+ tflog.Error(ctx, fmt.Sprintf("Error converting body to string: %s", err))
+ }
+ return bodyString
+}
+
+// End of section. //template:end toBodyXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBody
func (data *ServiceTemplate) updateFromBody(ctx context.Context, res gjson.Result) {
@@ -431,6 +555,208 @@ func (data *ServiceTemplate) updateFromBody(ctx context.Context, res gjson.Resul
// End of section. //template:end updateFromBody
+// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBodyXML
+
+func (data *ServiceTemplate) updateFromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/word"); value.Exists() && !data.Name.IsNull() {
+ data.Name = types.StringValue(value.String())
+ } else {
+ data.Name = types.StringNull()
+ }
+ for i := range data.AccessGroups {
+ keys := [...]string{"name"}
+ keyValues := [...]string{data.AccessGroups[i].Name.ValueString()}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/access-group-config").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, "name"); value.Exists() && !data.AccessGroups[i].Name.IsNull() {
+ data.AccessGroups[i].Name = types.StringValue(value.String())
+ } else {
+ data.AccessGroups[i].Name = types.StringNull()
+ }
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/inactivity-timer/value"); value.Exists() && !data.InactivityTimer.IsNull() {
+ data.InactivityTimer = types.Int64Value(value.Int())
+ } else {
+ data.InactivityTimer = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/inactivity-timer/probe"); !data.InactivityTimerProbe.IsNull() {
+ if value.Exists() {
+ data.InactivityTimerProbe = types.BoolValue(true)
+ } else {
+ data.InactivityTimerProbe = types.BoolValue(false)
+ }
+ } else {
+ data.InactivityTimerProbe = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/vlan"); value.Exists() && !data.Vlan.IsNull() {
+ data.Vlan = types.Int64Value(value.Int())
+ } else {
+ data.Vlan = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/voice/vlan"); !data.VoiceVlan.IsNull() {
+ if value.Exists() {
+ data.VoiceVlan = types.BoolValue(true)
+ } else {
+ data.VoiceVlan = types.BoolValue(false)
+ }
+ } else {
+ data.VoiceVlan = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/linksec/policy"); value.Exists() && !data.LinksecPolicy.IsNull() {
+ data.LinksecPolicy = types.StringValue(value.String())
+ } else {
+ data.LinksecPolicy = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/sgt"); value.Exists() && !data.Sgt.IsNull() {
+ data.Sgt = types.Int64Value(value.Int())
+ } else {
+ data.Sgt = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/absolute-timer"); value.Exists() && !data.AbsoluteTimer.IsNull() {
+ data.AbsoluteTimer = types.Int64Value(value.Int())
+ } else {
+ data.AbsoluteTimer = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/description"); value.Exists() && !data.Description.IsNull() {
+ data.Description = types.StringValue(value.String())
+ } else {
+ data.Description = types.StringNull()
+ }
+ for i := range data.InterfaceTemplates {
+ keys := [...]string{"name"}
+ keyValues := [...]string{data.InterfaceTemplates[i].Name.ValueString()}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/interface-template").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, "name"); value.Exists() && !data.InterfaceTemplates[i].Name.IsNull() {
+ data.InterfaceTemplates[i].Name = types.StringValue(value.String())
+ } else {
+ data.InterfaceTemplates[i].Name = types.StringNull()
+ }
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/tunnel/type/capwap/name"); value.Exists() && !data.TunnelCapwapName.IsNull() {
+ data.TunnelCapwapName = types.StringValue(value.String())
+ } else {
+ data.TunnelCapwapName = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/vnid"); value.Exists() && !data.Vnid.IsNull() {
+ data.Vnid = types.StringValue(value.String())
+ } else {
+ data.Vnid = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/redirect/append/client-mac"); value.Exists() && !data.RedirectAppendClientMac.IsNull() {
+ data.RedirectAppendClientMac = types.StringValue(value.String())
+ } else {
+ data.RedirectAppendClientMac = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/redirect/append/switch-mac"); value.Exists() && !data.RedirectAppendSwitchMac.IsNull() {
+ data.RedirectAppendSwitchMac = types.StringValue(value.String())
+ } else {
+ data.RedirectAppendSwitchMac = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/redirect/url/url_name"); value.Exists() && !data.RedirectUrl.IsNull() {
+ data.RedirectUrl = types.StringValue(value.String())
+ } else {
+ data.RedirectUrl = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/redirect/url/match/acl_name"); value.Exists() && !data.RedirectUrlMatchAcl.IsNull() {
+ data.RedirectUrlMatchAcl = types.StringValue(value.String())
+ } else {
+ data.RedirectUrlMatchAcl = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/redirect/url/match/action"); value.Exists() && !data.RedirectUrlMatchAction.IsNull() {
+ data.RedirectUrlMatchAction = types.StringValue(value.String())
+ } else {
+ data.RedirectUrlMatchAction = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/dns-acl/preauth"); value.Exists() && !data.DnsAclPreauth.IsNull() {
+ data.DnsAclPreauth = types.StringValue(value.String())
+ } else {
+ data.DnsAclPreauth = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/service-policy/qos/input"); value.Exists() && !data.ServicePolicyQosInput.IsNull() {
+ data.ServicePolicyQosInput = types.StringValue(value.String())
+ } else {
+ data.ServicePolicyQosInput = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/service-policy/qos/output"); value.Exists() && !data.ServicePolicyQosOutput.IsNull() {
+ data.ServicePolicyQosOutput = types.StringValue(value.String())
+ } else {
+ data.ServicePolicyQosOutput = types.StringNull()
+ }
+ for i := range data.Tags {
+ keys := [...]string{"name"}
+ keyValues := [...]string{data.Tags[i].Name.ValueString()}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/tag-config").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, "name"); value.Exists() && !data.Tags[i].Name.IsNull() {
+ data.Tags[i].Name = types.StringValue(value.String())
+ } else {
+ data.Tags[i].Name = types.StringNull()
+ }
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/mdns-service-policy"); value.Exists() && !data.MdnsServicePolicy.IsNull() {
+ data.MdnsServicePolicy = types.StringValue(value.String())
+ } else {
+ data.MdnsServicePolicy = types.StringNull()
+ }
+}
+
+// End of section. //template:end updateFromBodyXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin fromBody
func (data *ServiceTemplate) fromBody(ctx context.Context, res gjson.Result) {
@@ -641,20 +967,222 @@ func (data *ServiceTemplateData) fromBody(ctx context.Context, res gjson.Result)
// End of section. //template:end fromBodyData
-// Section below is generated&owned by "gen/generator.go". //template:begin getDeletedItems
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyXML
-func (data *ServiceTemplate) getDeletedItems(ctx context.Context, state ServiceTemplate) []string {
- deletedItems := make([]string, 0)
- if !state.MdnsServicePolicy.IsNull() && data.MdnsServicePolicy.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/mdns-service-policy", state.getPath()))
+func (data *ServiceTemplate) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/access-group-config"); value.Exists() {
+ data.AccessGroups = make([]ServiceTemplateAccessGroups, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := ServiceTemplateAccessGroups{}
+ if cValue := helpers.GetFromXPath(v, "name"); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ data.AccessGroups = append(data.AccessGroups, item)
+ return true
+ })
}
- for i := range state.Tags {
- stateKeyValues := [...]string{state.Tags[i].Name.ValueString()}
-
- emptyKeys := true
- if !reflect.ValueOf(state.Tags[i].Name.ValueString()).IsZero() {
- emptyKeys = false
- }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/inactivity-timer/value"); value.Exists() {
+ data.InactivityTimer = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/inactivity-timer/probe"); value.Exists() {
+ data.InactivityTimerProbe = types.BoolValue(true)
+ } else {
+ data.InactivityTimerProbe = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/vlan"); value.Exists() {
+ data.Vlan = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/voice/vlan"); value.Exists() {
+ data.VoiceVlan = types.BoolValue(true)
+ } else {
+ data.VoiceVlan = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/linksec/policy"); value.Exists() {
+ data.LinksecPolicy = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/sgt"); value.Exists() {
+ data.Sgt = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/absolute-timer"); value.Exists() {
+ data.AbsoluteTimer = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/description"); value.Exists() {
+ data.Description = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/interface-template"); value.Exists() {
+ data.InterfaceTemplates = make([]ServiceTemplateInterfaceTemplates, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := ServiceTemplateInterfaceTemplates{}
+ if cValue := helpers.GetFromXPath(v, "name"); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ data.InterfaceTemplates = append(data.InterfaceTemplates, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/tunnel/type/capwap/name"); value.Exists() {
+ data.TunnelCapwapName = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/vnid"); value.Exists() {
+ data.Vnid = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/redirect/append/client-mac"); value.Exists() {
+ data.RedirectAppendClientMac = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/redirect/append/switch-mac"); value.Exists() {
+ data.RedirectAppendSwitchMac = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/redirect/url/url_name"); value.Exists() {
+ data.RedirectUrl = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/redirect/url/match/acl_name"); value.Exists() {
+ data.RedirectUrlMatchAcl = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/redirect/url/match/action"); value.Exists() {
+ data.RedirectUrlMatchAction = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/dns-acl/preauth"); value.Exists() {
+ data.DnsAclPreauth = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/service-policy/qos/input"); value.Exists() {
+ data.ServicePolicyQosInput = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/service-policy/qos/output"); value.Exists() {
+ data.ServicePolicyQosOutput = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/tag-config"); value.Exists() {
+ data.Tags = make([]ServiceTemplateTags, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := ServiceTemplateTags{}
+ if cValue := helpers.GetFromXPath(v, "name"); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ data.Tags = append(data.Tags, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/mdns-service-policy"); value.Exists() {
+ data.MdnsServicePolicy = types.StringValue(value.String())
+ }
+}
+
+// End of section. //template:end fromBodyXML
+
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyDataXML
+
+func (data *ServiceTemplateData) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/access-group-config"); value.Exists() {
+ data.AccessGroups = make([]ServiceTemplateAccessGroups, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := ServiceTemplateAccessGroups{}
+ if cValue := helpers.GetFromXPath(v, "name"); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ data.AccessGroups = append(data.AccessGroups, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/inactivity-timer/value"); value.Exists() {
+ data.InactivityTimer = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/inactivity-timer/probe"); value.Exists() {
+ data.InactivityTimerProbe = types.BoolValue(true)
+ } else {
+ data.InactivityTimerProbe = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/vlan"); value.Exists() {
+ data.Vlan = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/voice/vlan"); value.Exists() {
+ data.VoiceVlan = types.BoolValue(true)
+ } else {
+ data.VoiceVlan = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/linksec/policy"); value.Exists() {
+ data.LinksecPolicy = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/sgt"); value.Exists() {
+ data.Sgt = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/absolute-timer"); value.Exists() {
+ data.AbsoluteTimer = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/description"); value.Exists() {
+ data.Description = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/interface-template"); value.Exists() {
+ data.InterfaceTemplates = make([]ServiceTemplateInterfaceTemplates, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := ServiceTemplateInterfaceTemplates{}
+ if cValue := helpers.GetFromXPath(v, "name"); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ data.InterfaceTemplates = append(data.InterfaceTemplates, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/tunnel/type/capwap/name"); value.Exists() {
+ data.TunnelCapwapName = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/vnid"); value.Exists() {
+ data.Vnid = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/redirect/append/client-mac"); value.Exists() {
+ data.RedirectAppendClientMac = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/redirect/append/switch-mac"); value.Exists() {
+ data.RedirectAppendSwitchMac = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/redirect/url/url_name"); value.Exists() {
+ data.RedirectUrl = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/redirect/url/match/acl_name"); value.Exists() {
+ data.RedirectUrlMatchAcl = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/redirect/url/match/action"); value.Exists() {
+ data.RedirectUrlMatchAction = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/dns-acl/preauth"); value.Exists() {
+ data.DnsAclPreauth = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/service-policy/qos/input"); value.Exists() {
+ data.ServicePolicyQosInput = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/service-policy/qos/output"); value.Exists() {
+ data.ServicePolicyQosOutput = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/tag-config"); value.Exists() {
+ data.Tags = make([]ServiceTemplateTags, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := ServiceTemplateTags{}
+ if cValue := helpers.GetFromXPath(v, "name"); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ data.Tags = append(data.Tags, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/mdns-service-policy"); value.Exists() {
+ data.MdnsServicePolicy = types.StringValue(value.String())
+ }
+}
+
+// End of section. //template:end fromBodyDataXML
+
+// Section below is generated&owned by "gen/generator.go". //template:begin getDeletedItems
+
+func (data *ServiceTemplate) getDeletedItems(ctx context.Context, state ServiceTemplate) []string {
+ deletedItems := make([]string, 0)
+ if !state.MdnsServicePolicy.IsNull() && data.MdnsServicePolicy.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/mdns-service-policy", state.getPath()))
+ }
+ for i := range state.Tags {
+ stateKeyValues := [...]string{state.Tags[i].Name.ValueString()}
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.Tags[i].Name.ValueString()).IsZero() {
+ emptyKeys = false
+ }
if emptyKeys {
continue
}
@@ -783,6 +1311,163 @@ func (data *ServiceTemplate) getDeletedItems(ctx context.Context, state ServiceT
// End of section. //template:end getDeletedItems
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletedItemsXML
+
+func (data *ServiceTemplate) addDeletedItemsXML(ctx context.Context, state ServiceTemplate, body string) string {
+ b := netconf.NewBody(body)
+ for i := range state.AccessGroups {
+ stateKeys := [...]string{"name"}
+ stateKeyValues := [...]string{state.AccessGroups[i].Name.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.AccessGroups[i].Name.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.AccessGroups {
+ found = true
+ if state.AccessGroups[i].Name.ValueString() != data.AccessGroups[j].Name.ValueString() {
+ found = false
+ }
+ if found {
+ break
+ }
+ }
+ if !found {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/access-group-config%v", predicates))
+ }
+ }
+ if !state.InactivityTimer.IsNull() && data.InactivityTimer.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/inactivity-timer/value")
+ }
+ if !state.InactivityTimerProbe.IsNull() && data.InactivityTimerProbe.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/inactivity-timer/probe")
+ }
+ if !state.Vlan.IsNull() && data.Vlan.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/vlan")
+ }
+ if !state.VoiceVlan.IsNull() && data.VoiceVlan.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/voice/vlan")
+ }
+ if !state.LinksecPolicy.IsNull() && data.LinksecPolicy.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/linksec/policy")
+ }
+ if !state.Sgt.IsNull() && data.Sgt.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/sgt")
+ }
+ if !state.AbsoluteTimer.IsNull() && data.AbsoluteTimer.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/absolute-timer")
+ }
+ if !state.Description.IsNull() && data.Description.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/description")
+ }
+ for i := range state.InterfaceTemplates {
+ stateKeys := [...]string{"name"}
+ stateKeyValues := [...]string{state.InterfaceTemplates[i].Name.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.InterfaceTemplates[i].Name.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.InterfaceTemplates {
+ found = true
+ if state.InterfaceTemplates[i].Name.ValueString() != data.InterfaceTemplates[j].Name.ValueString() {
+ found = false
+ }
+ if found {
+ break
+ }
+ }
+ if !found {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/interface-template%v", predicates))
+ }
+ }
+ if !state.TunnelCapwapName.IsNull() && data.TunnelCapwapName.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/tunnel/type/capwap/name")
+ }
+ if !state.Vnid.IsNull() && data.Vnid.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/vnid")
+ }
+ if !state.RedirectAppendClientMac.IsNull() && data.RedirectAppendClientMac.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/redirect/append/client-mac")
+ }
+ if !state.RedirectAppendSwitchMac.IsNull() && data.RedirectAppendSwitchMac.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/redirect/append/switch-mac")
+ }
+ if !state.RedirectUrl.IsNull() && data.RedirectUrl.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/redirect/url/url_name")
+ }
+ if !state.RedirectUrlMatchAcl.IsNull() && data.RedirectUrlMatchAcl.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/redirect/url/match/acl_name")
+ }
+ if !state.RedirectUrlMatchAction.IsNull() && data.RedirectUrlMatchAction.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/redirect/url/match/action")
+ }
+ if !state.DnsAclPreauth.IsNull() && data.DnsAclPreauth.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/dns-acl/preauth")
+ }
+ if !state.ServicePolicyQosInput.IsNull() && data.ServicePolicyQosInput.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/service-policy/qos/input")
+ }
+ if !state.ServicePolicyQosOutput.IsNull() && data.ServicePolicyQosOutput.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/service-policy/qos/output")
+ }
+ for i := range state.Tags {
+ stateKeys := [...]string{"name"}
+ stateKeyValues := [...]string{state.Tags[i].Name.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.Tags[i].Name.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.Tags {
+ found = true
+ if state.Tags[i].Name.ValueString() != data.Tags[j].Name.ValueString() {
+ found = false
+ }
+ if found {
+ break
+ }
+ }
+ if !found {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/tag-config%v", predicates))
+ }
+ }
+ if !state.MdnsServicePolicy.IsNull() && data.MdnsServicePolicy.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/mdns-service-policy")
+ }
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletedItemsXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin getEmptyLeafsDelete
func (data *ServiceTemplate) getEmptyLeafsDelete(ctx context.Context) []string {
@@ -881,3 +1566,100 @@ func (data *ServiceTemplate) getDeletePaths(ctx context.Context) []string {
}
// End of section. //template:end getDeletePaths
+
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletePathsXML
+
+func (data *ServiceTemplate) addDeletePathsXML(ctx context.Context, body string) string {
+ b := netconf.NewBody(body)
+ for i := range data.AccessGroups {
+ keys := [...]string{"name"}
+ keyValues := [...]string{data.AccessGroups[i].Name.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/access-group-config%v", predicates))
+ }
+ if !data.InactivityTimer.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/inactivity-timer/value")
+ }
+ if !data.InactivityTimerProbe.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/inactivity-timer/probe")
+ }
+ if !data.Vlan.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/vlan")
+ }
+ if !data.VoiceVlan.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/voice/vlan")
+ }
+ if !data.LinksecPolicy.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/linksec/policy")
+ }
+ if !data.Sgt.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/sgt")
+ }
+ if !data.AbsoluteTimer.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/absolute-timer")
+ }
+ if !data.Description.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/description")
+ }
+ for i := range data.InterfaceTemplates {
+ keys := [...]string{"name"}
+ keyValues := [...]string{data.InterfaceTemplates[i].Name.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/interface-template%v", predicates))
+ }
+ if !data.TunnelCapwapName.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/tunnel/type/capwap/name")
+ }
+ if !data.Vnid.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/vnid")
+ }
+ if !data.RedirectAppendClientMac.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/redirect/append/client-mac")
+ }
+ if !data.RedirectAppendSwitchMac.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/redirect/append/switch-mac")
+ }
+ if !data.RedirectUrl.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/redirect/url/url_name")
+ }
+ if !data.RedirectUrlMatchAcl.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/redirect/url/match/acl_name")
+ }
+ if !data.RedirectUrlMatchAction.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/redirect/url/match/action")
+ }
+ if !data.DnsAclPreauth.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/dns-acl/preauth")
+ }
+ if !data.ServicePolicyQosInput.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/service-policy/qos/input")
+ }
+ if !data.ServicePolicyQosOutput.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/service-policy/qos/output")
+ }
+ for i := range data.Tags {
+ keys := [...]string{"name"}
+ keyValues := [...]string{data.Tags[i].Name.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/tag-config%v", predicates))
+ }
+ if !data.MdnsServicePolicy.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/mdns-service-policy")
+ }
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletePathsXML
diff --git a/internal/provider/model_iosxe_sla.go b/internal/provider/model_iosxe_sla.go
index 3d2af277..08365054 100644
--- a/internal/provider/model_iosxe_sla.go
+++ b/internal/provider/model_iosxe_sla.go
@@ -30,6 +30,9 @@ import (
"github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/types"
+ "github.com/hashicorp/terraform-plugin-log/tflog"
+ "github.com/netascode/go-netconf"
+ "github.com/netascode/xmldot"
"github.com/tidwall/gjson"
"github.com/tidwall/sjson"
)
@@ -84,6 +87,17 @@ func (data SLA) getPathShort() string {
return matches[1]
}
+// getXPath returns the XPath for NETCONF operations
+func (data SLA) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/ip/Cisco-IOS-XE-sla:sla"
+ return path
+}
+
+func (data SLAData) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/ip/Cisco-IOS-XE-sla:sla"
+ return path
+}
+
// End of section. //template:end getPath
// Section below is generated&owned by "gen/generator.go". //template:begin toBody
@@ -91,31 +105,31 @@ func (data SLA) getPathShort() string {
func (data SLA) toBody(ctx context.Context) string {
body := `{"` + helpers.LastElement(data.getPath()) + `":{}}`
if len(data.Entries) > 0 {
- body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"entry", []interface{}{})
+ body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"", []interface{}{})
for index, item := range data.Entries {
if !item.Number.IsNull() && !item.Number.IsUnknown() {
- body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"entry"+"."+strconv.Itoa(index)+"."+"number", strconv.FormatInt(item.Number.ValueInt64(), 10))
+ body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+""+"."+strconv.Itoa(index)+"."+"number", strconv.FormatInt(item.Number.ValueInt64(), 10))
}
if !item.IcmpEchoDestination.IsNull() && !item.IcmpEchoDestination.IsUnknown() {
- body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"entry"+"."+strconv.Itoa(index)+"."+"icmp-echo.destination", item.IcmpEchoDestination.ValueString())
+ body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+""+"."+strconv.Itoa(index)+"."+"icmp-echo.destination", item.IcmpEchoDestination.ValueString())
}
if !item.IcmpEchoSourceIp.IsNull() && !item.IcmpEchoSourceIp.IsUnknown() {
- body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"entry"+"."+strconv.Itoa(index)+"."+"icmp-echo.source-ip", item.IcmpEchoSourceIp.ValueString())
+ body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+""+"."+strconv.Itoa(index)+"."+"icmp-echo.source-ip", item.IcmpEchoSourceIp.ValueString())
}
}
}
if len(data.Schedules) > 0 {
- body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"schedule", []interface{}{})
+ body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"", []interface{}{})
for index, item := range data.Schedules {
if !item.EntryNumber.IsNull() && !item.EntryNumber.IsUnknown() {
- body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"schedule"+"."+strconv.Itoa(index)+"."+"entry-number", strconv.FormatInt(item.EntryNumber.ValueInt64(), 10))
+ body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+""+"."+strconv.Itoa(index)+"."+"", strconv.FormatInt(item.EntryNumber.ValueInt64(), 10))
}
if !item.Life.IsNull() && !item.Life.IsUnknown() {
- body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"schedule"+"."+strconv.Itoa(index)+"."+"life", strconv.FormatInt(item.Life.ValueInt64(), 10))
+ body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+""+"."+strconv.Itoa(index)+"."+"", strconv.FormatInt(item.Life.ValueInt64(), 10))
}
if !item.StartTimeNow.IsNull() && !item.StartTimeNow.IsUnknown() {
if item.StartTimeNow.ValueBool() {
- body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"schedule"+"."+strconv.Itoa(index)+"."+"start-time.now-config", map[string]string{})
+ body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+""+"."+strconv.Itoa(index)+"."+"start-time.now-config", map[string]string{})
}
}
}
@@ -125,6 +139,53 @@ func (data SLA) toBody(ctx context.Context) string {
// End of section. //template:end toBody
+// Section below is generated&owned by "gen/generator.go". //template:begin toBodyXML
+
+func (data SLA) toBodyXML(ctx context.Context) string {
+ body := netconf.Body{}
+ if len(data.Entries) > 0 {
+ for _, item := range data.Entries {
+ cBody := netconf.Body{}
+ if !item.Number.IsNull() && !item.Number.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "number", strconv.FormatInt(item.Number.ValueInt64(), 10))
+ }
+ if !item.IcmpEchoDestination.IsNull() && !item.IcmpEchoDestination.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "icmp-echo/destination", item.IcmpEchoDestination.ValueString())
+ }
+ if !item.IcmpEchoSourceIp.IsNull() && !item.IcmpEchoSourceIp.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "icmp-echo/source-ip", item.IcmpEchoSourceIp.ValueString())
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/", cBody.Res())
+ }
+ }
+ if len(data.Schedules) > 0 {
+ for _, item := range data.Schedules {
+ cBody := netconf.Body{}
+ if !item.EntryNumber.IsNull() && !item.EntryNumber.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "", strconv.FormatInt(item.EntryNumber.ValueInt64(), 10))
+ }
+ if !item.Life.IsNull() && !item.Life.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "", strconv.FormatInt(item.Life.ValueInt64(), 10))
+ }
+ if !item.StartTimeNow.IsNull() && !item.StartTimeNow.IsUnknown() {
+ if item.StartTimeNow.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "start-time/now-config", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "start-time/now-config")
+ }
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/", cBody.Res())
+ }
+ }
+ bodyString, err := body.String()
+ if err != nil {
+ tflog.Error(ctx, fmt.Sprintf("Error converting body to string: %s", err))
+ }
+ return bodyString
+}
+
+// End of section. //template:end toBodyXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBody
func (data *SLA) updateFromBody(ctx context.Context, res gjson.Result) {
@@ -137,7 +198,7 @@ func (data *SLA) updateFromBody(ctx context.Context, res gjson.Result) {
keyValues := [...]string{strconv.FormatInt(data.Entries[i].Number.ValueInt64(), 10)}
var r gjson.Result
- res.Get(prefix + "entry").ForEach(
+ res.Get(prefix + "").ForEach(
func(_, v gjson.Result) bool {
found := false
for ik := range keys {
@@ -172,11 +233,11 @@ func (data *SLA) updateFromBody(ctx context.Context, res gjson.Result) {
}
}
for i := range data.Schedules {
- keys := [...]string{"entry-number"}
+ keys := [...]string{""}
keyValues := [...]string{strconv.FormatInt(data.Schedules[i].EntryNumber.ValueInt64(), 10)}
var r gjson.Result
- res.Get(prefix + "schedule").ForEach(
+ res.Get(prefix + "").ForEach(
func(_, v gjson.Result) bool {
found := false
for ik := range keys {
@@ -194,12 +255,12 @@ func (data *SLA) updateFromBody(ctx context.Context, res gjson.Result) {
return true
},
)
- if value := r.Get("entry-number"); value.Exists() && !data.Schedules[i].EntryNumber.IsNull() {
+ if value := r.Get(""); value.Exists() && !data.Schedules[i].EntryNumber.IsNull() {
data.Schedules[i].EntryNumber = types.Int64Value(value.Int())
} else {
data.Schedules[i].EntryNumber = types.Int64Null()
}
- if value := r.Get("life"); value.Exists() && !data.Schedules[i].Life.IsNull() {
+ if value := r.Get(""); value.Exists() && !data.Schedules[i].Life.IsNull() {
data.Schedules[i].Life = types.Int64Value(value.Int())
} else {
data.Schedules[i].Life = types.Int64Null()
@@ -218,6 +279,95 @@ func (data *SLA) updateFromBody(ctx context.Context, res gjson.Result) {
// End of section. //template:end updateFromBody
+// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBodyXML
+
+func (data *SLA) updateFromBodyXML(ctx context.Context, res xmldot.Result) {
+ for i := range data.Entries {
+ keys := [...]string{"number"}
+ keyValues := [...]string{strconv.FormatInt(data.Entries[i].Number.ValueInt64(), 10)}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, "number"); value.Exists() && !data.Entries[i].Number.IsNull() {
+ data.Entries[i].Number = types.Int64Value(value.Int())
+ } else {
+ data.Entries[i].Number = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(r, "icmp-echo/destination"); value.Exists() && !data.Entries[i].IcmpEchoDestination.IsNull() {
+ data.Entries[i].IcmpEchoDestination = types.StringValue(value.String())
+ } else {
+ data.Entries[i].IcmpEchoDestination = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "icmp-echo/source-ip"); value.Exists() && !data.Entries[i].IcmpEchoSourceIp.IsNull() {
+ data.Entries[i].IcmpEchoSourceIp = types.StringValue(value.String())
+ } else {
+ data.Entries[i].IcmpEchoSourceIp = types.StringNull()
+ }
+ }
+ for i := range data.Schedules {
+ keys := [...]string{""}
+ keyValues := [...]string{strconv.FormatInt(data.Schedules[i].EntryNumber.ValueInt64(), 10)}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, ""); value.Exists() && !data.Schedules[i].EntryNumber.IsNull() {
+ data.Schedules[i].EntryNumber = types.Int64Value(value.Int())
+ } else {
+ data.Schedules[i].EntryNumber = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(r, ""); value.Exists() && !data.Schedules[i].Life.IsNull() {
+ data.Schedules[i].Life = types.Int64Value(value.Int())
+ } else {
+ data.Schedules[i].Life = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(r, "start-time/now-config"); !data.Schedules[i].StartTimeNow.IsNull() {
+ if value.Exists() {
+ data.Schedules[i].StartTimeNow = types.BoolValue(true)
+ } else {
+ data.Schedules[i].StartTimeNow = types.BoolValue(false)
+ }
+ } else {
+ data.Schedules[i].StartTimeNow = types.BoolNull()
+ }
+ }
+}
+
+// End of section. //template:end updateFromBodyXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin fromBody
func (data *SLA) fromBody(ctx context.Context, res gjson.Result) {
@@ -225,7 +375,7 @@ func (data *SLA) fromBody(ctx context.Context, res gjson.Result) {
if res.Get(helpers.LastElement(data.getPath())).IsArray() {
prefix += "0."
}
- if value := res.Get(prefix + "entry"); value.Exists() {
+ if value := res.Get(prefix + ""); value.Exists() {
data.Entries = make([]SLAEntries, 0)
value.ForEach(func(k, v gjson.Result) bool {
item := SLAEntries{}
@@ -242,14 +392,14 @@ func (data *SLA) fromBody(ctx context.Context, res gjson.Result) {
return true
})
}
- if value := res.Get(prefix + "schedule"); value.Exists() {
+ if value := res.Get(prefix + ""); value.Exists() {
data.Schedules = make([]SLASchedules, 0)
value.ForEach(func(k, v gjson.Result) bool {
item := SLASchedules{}
- if cValue := v.Get("entry-number"); cValue.Exists() {
+ if cValue := v.Get(""); cValue.Exists() {
item.EntryNumber = types.Int64Value(cValue.Int())
}
- if cValue := v.Get("life"); cValue.Exists() {
+ if cValue := v.Get(""); cValue.Exists() {
item.Life = types.Int64Value(cValue.Int())
}
if cValue := v.Get("start-time.now-config"); cValue.Exists() {
@@ -272,7 +422,7 @@ func (data *SLAData) fromBody(ctx context.Context, res gjson.Result) {
if res.Get(helpers.LastElement(data.getPath())).IsArray() {
prefix += "0."
}
- if value := res.Get(prefix + "entry"); value.Exists() {
+ if value := res.Get(prefix + ""); value.Exists() {
data.Entries = make([]SLAEntries, 0)
value.ForEach(func(k, v gjson.Result) bool {
item := SLAEntries{}
@@ -289,14 +439,14 @@ func (data *SLAData) fromBody(ctx context.Context, res gjson.Result) {
return true
})
}
- if value := res.Get(prefix + "schedule"); value.Exists() {
+ if value := res.Get(prefix + ""); value.Exists() {
data.Schedules = make([]SLASchedules, 0)
value.ForEach(func(k, v gjson.Result) bool {
item := SLASchedules{}
- if cValue := v.Get("entry-number"); cValue.Exists() {
+ if cValue := v.Get(""); cValue.Exists() {
item.EntryNumber = types.Int64Value(cValue.Int())
}
- if cValue := v.Get("life"); cValue.Exists() {
+ if cValue := v.Get(""); cValue.Exists() {
item.Life = types.Int64Value(cValue.Int())
}
if cValue := v.Get("start-time.now-config"); cValue.Exists() {
@@ -312,6 +462,92 @@ func (data *SLAData) fromBody(ctx context.Context, res gjson.Result) {
// End of section. //template:end fromBodyData
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyXML
+
+func (data *SLA) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/"); value.Exists() {
+ data.Entries = make([]SLAEntries, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := SLAEntries{}
+ if cValue := helpers.GetFromXPath(v, "number"); cValue.Exists() {
+ item.Number = types.Int64Value(cValue.Int())
+ }
+ if cValue := helpers.GetFromXPath(v, "icmp-echo/destination"); cValue.Exists() {
+ item.IcmpEchoDestination = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "icmp-echo/source-ip"); cValue.Exists() {
+ item.IcmpEchoSourceIp = types.StringValue(cValue.String())
+ }
+ data.Entries = append(data.Entries, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/"); value.Exists() {
+ data.Schedules = make([]SLASchedules, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := SLASchedules{}
+ if cValue := helpers.GetFromXPath(v, ""); cValue.Exists() {
+ item.EntryNumber = types.Int64Value(cValue.Int())
+ }
+ if cValue := helpers.GetFromXPath(v, ""); cValue.Exists() {
+ item.Life = types.Int64Value(cValue.Int())
+ }
+ if cValue := helpers.GetFromXPath(v, "start-time/now-config"); cValue.Exists() {
+ item.StartTimeNow = types.BoolValue(true)
+ } else {
+ item.StartTimeNow = types.BoolValue(false)
+ }
+ data.Schedules = append(data.Schedules, item)
+ return true
+ })
+ }
+}
+
+// End of section. //template:end fromBodyXML
+
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyDataXML
+
+func (data *SLAData) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/"); value.Exists() {
+ data.Entries = make([]SLAEntries, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := SLAEntries{}
+ if cValue := helpers.GetFromXPath(v, "number"); cValue.Exists() {
+ item.Number = types.Int64Value(cValue.Int())
+ }
+ if cValue := helpers.GetFromXPath(v, "icmp-echo/destination"); cValue.Exists() {
+ item.IcmpEchoDestination = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "icmp-echo/source-ip"); cValue.Exists() {
+ item.IcmpEchoSourceIp = types.StringValue(cValue.String())
+ }
+ data.Entries = append(data.Entries, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/"); value.Exists() {
+ data.Schedules = make([]SLASchedules, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := SLASchedules{}
+ if cValue := helpers.GetFromXPath(v, ""); cValue.Exists() {
+ item.EntryNumber = types.Int64Value(cValue.Int())
+ }
+ if cValue := helpers.GetFromXPath(v, ""); cValue.Exists() {
+ item.Life = types.Int64Value(cValue.Int())
+ }
+ if cValue := helpers.GetFromXPath(v, "start-time/now-config"); cValue.Exists() {
+ item.StartTimeNow = types.BoolValue(true)
+ } else {
+ item.StartTimeNow = types.BoolValue(false)
+ }
+ data.Schedules = append(data.Schedules, item)
+ return true
+ })
+ }
+}
+
+// End of section. //template:end fromBodyDataXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin getDeletedItems
func (data *SLA) getDeletedItems(ctx context.Context, state SLA) []string {
@@ -384,6 +620,88 @@ func (data *SLA) getDeletedItems(ctx context.Context, state SLA) []string {
// End of section. //template:end getDeletedItems
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletedItemsXML
+
+func (data *SLA) addDeletedItemsXML(ctx context.Context, state SLA, body string) string {
+ b := netconf.NewBody(body)
+ for i := range state.Entries {
+ stateKeys := [...]string{"number"}
+ stateKeyValues := [...]string{strconv.FormatInt(state.Entries[i].Number.ValueInt64(), 10)}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.Entries[i].Number.ValueInt64()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.Entries {
+ found = true
+ if state.Entries[i].Number.ValueInt64() != data.Entries[j].Number.ValueInt64() {
+ found = false
+ }
+ if found {
+ if !state.Entries[i].IcmpEchoDestination.IsNull() && data.Entries[j].IcmpEchoDestination.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/%v/icmp-echo/destination", predicates))
+ }
+ if !state.Entries[i].IcmpEchoSourceIp.IsNull() && data.Entries[j].IcmpEchoSourceIp.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/%v/icmp-echo/source-ip", predicates))
+ }
+ break
+ }
+ }
+ if !found {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/%v", predicates))
+ }
+ }
+ for i := range state.Schedules {
+ stateKeys := [...]string{""}
+ stateKeyValues := [...]string{strconv.FormatInt(state.Schedules[i].EntryNumber.ValueInt64(), 10)}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.Schedules[i].EntryNumber.ValueInt64()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.Schedules {
+ found = true
+ if state.Schedules[i].EntryNumber.ValueInt64() != data.Schedules[j].EntryNumber.ValueInt64() {
+ found = false
+ }
+ if found {
+ if !state.Schedules[i].Life.IsNull() && data.Schedules[j].Life.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/%v/", predicates))
+ }
+ if !state.Schedules[i].StartTimeNow.IsNull() && data.Schedules[j].StartTimeNow.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/%v/start-time/now-config", predicates))
+ }
+ break
+ }
+ }
+ if !found {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/%v", predicates))
+ }
+ }
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletedItemsXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin getEmptyLeafsDelete
func (data *SLA) getEmptyLeafsDelete(ctx context.Context) []string {
@@ -408,15 +726,45 @@ func (data *SLA) getDeletePaths(ctx context.Context) []string {
for i := range data.Schedules {
keyValues := [...]string{strconv.FormatInt(data.Schedules[i].EntryNumber.ValueInt64(), 10)}
- deletePaths = append(deletePaths, fmt.Sprintf("%v/schedule=%v", data.getPath(), strings.Join(keyValues[:], ",")))
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/=%v", data.getPath(), strings.Join(keyValues[:], ",")))
}
for i := range data.Entries {
keyValues := [...]string{strconv.FormatInt(data.Entries[i].Number.ValueInt64(), 10)}
- deletePaths = append(deletePaths, fmt.Sprintf("%v/entry=%v", data.getPath(), strings.Join(keyValues[:], ",")))
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/=%v", data.getPath(), strings.Join(keyValues[:], ",")))
}
return deletePaths
}
// End of section. //template:end getDeletePaths
+
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletePathsXML
+
+func (data *SLA) addDeletePathsXML(ctx context.Context, body string) string {
+ b := netconf.NewBody(body)
+ for i := range data.Entries {
+ keys := [...]string{"number"}
+ keyValues := [...]string{strconv.FormatInt(data.Entries[i].Number.ValueInt64(), 10)}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/%v", predicates))
+ }
+ for i := range data.Schedules {
+ keys := [...]string{""}
+ keyValues := [...]string{strconv.FormatInt(data.Schedules[i].EntryNumber.ValueInt64(), 10)}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/%v", predicates))
+ }
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletePathsXML
diff --git a/internal/provider/model_iosxe_snmp_server.go b/internal/provider/model_iosxe_snmp_server.go
index 1d1d8544..b63e7982 100644
--- a/internal/provider/model_iosxe_snmp_server.go
+++ b/internal/provider/model_iosxe_snmp_server.go
@@ -30,6 +30,9 @@ import (
"github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/types"
+ "github.com/hashicorp/terraform-plugin-log/tflog"
+ "github.com/netascode/go-netconf"
+ "github.com/netascode/xmldot"
"github.com/tidwall/gjson"
"github.com/tidwall/sjson"
)
@@ -570,6 +573,17 @@ func (data SNMPServer) getPathShort() string {
return matches[1]
}
+// getXPath returns the XPath for NETCONF operations
+func (data SNMPServer) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/snmp-server"
+ return path
+}
+
+func (data SNMPServerData) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/snmp-server"
+ return path
+}
+
// End of section. //template:end getPath
// Section below is generated&owned by "gen/generator.go". //template:begin toBody
@@ -1042,7 +1056,7 @@ func (data SNMPServer) toBody(ctx context.Context) string {
}
if !data.EnableTrapsBgpCbgp2.IsNull() && !data.EnableTrapsBgpCbgp2.IsUnknown() {
if data.EnableTrapsBgpCbgp2.ValueBool() {
- body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"Cisco-IOS-XE-snmp:enable.enable-choice.traps.Cisco-IOS-XE-bgp:bgp.cbgp2", map[string]string{})
+ body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"", map[string]string{})
}
}
if !data.EnableTrapsNhrpNhs.IsNull() && !data.EnableTrapsNhrpNhs.IsUnknown() {
@@ -1746,1857 +1760,1664 @@ func (data SNMPServer) toBody(ctx context.Context) string {
// End of section. //template:end toBody
-// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBody
+// Section below is generated&owned by "gen/generator.go". //template:begin toBodyXML
-func (data *SNMPServer) updateFromBody(ctx context.Context, res gjson.Result) {
- prefix := helpers.LastElement(data.getPath()) + "."
- if res.Get(helpers.LastElement(data.getPath())).IsArray() {
- prefix += "0."
- }
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:chassis-id"); value.Exists() && !data.ChassisId.IsNull() {
- data.ChassisId = types.StringValue(value.String())
- } else {
- data.ChassisId = types.StringNull()
+func (data SNMPServer) toBodyXML(ctx context.Context) string {
+ body := netconf.Body{}
+ if !data.ChassisId.IsNull() && !data.ChassisId.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:chassis-id", data.ChassisId.ValueString())
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:contact"); value.Exists() && !data.Contact.IsNull() {
- data.Contact = types.StringValue(value.String())
- } else {
- data.Contact = types.StringNull()
+ if !data.Contact.IsNull() && !data.Contact.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:contact", data.Contact.ValueString())
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:ifindex.persist"); !data.IfindexPersist.IsNull() {
- if value.Exists() {
- data.IfindexPersist = types.BoolValue(true)
+ if !data.IfindexPersist.IsNull() && !data.IfindexPersist.IsUnknown() {
+ if data.IfindexPersist.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:ifindex/persist", "")
} else {
- data.IfindexPersist = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:ifindex/persist")
}
- } else {
- data.IfindexPersist = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:location"); value.Exists() && !data.Location.IsNull() {
- data.Location = types.StringValue(value.String())
- } else {
- data.Location = types.StringNull()
+ if !data.Location.IsNull() && !data.Location.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:location", data.Location.ValueString())
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:packetsize"); value.Exists() && !data.Packetsize.IsNull() {
- data.Packetsize = types.Int64Value(value.Int())
- } else {
- data.Packetsize = types.Int64Null()
+ if !data.Packetsize.IsNull() && !data.Packetsize.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:packetsize", strconv.FormatInt(data.Packetsize.ValueInt64(), 10))
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:queue-length"); value.Exists() && !data.QueueLength.IsNull() {
- data.QueueLength = types.Int64Value(value.Int())
- } else {
- data.QueueLength = types.Int64Null()
+ if !data.QueueLength.IsNull() && !data.QueueLength.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:queue-length", strconv.FormatInt(data.QueueLength.ValueInt64(), 10))
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.logging.getop"); !data.EnableLoggingGetop.IsNull() {
- if value.Exists() {
- data.EnableLoggingGetop = types.BoolValue(value.Bool())
- }
- } else {
- data.EnableLoggingGetop = types.BoolNull()
+ if !data.EnableLoggingGetop.IsNull() && !data.EnableLoggingGetop.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/logging/getop", data.EnableLoggingGetop.ValueBool())
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.logging.setop"); !data.EnableLoggingSetop.IsNull() {
- if value.Exists() {
- data.EnableLoggingSetop = types.BoolValue(value.Bool())
- }
- } else {
- data.EnableLoggingSetop = types.BoolNull()
+ if !data.EnableLoggingSetop.IsNull() && !data.EnableLoggingSetop.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/logging/setop", data.EnableLoggingSetop.ValueBool())
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.informs"); !data.EnableInforms.IsNull() {
- if value.Exists() {
- data.EnableInforms = types.BoolValue(true)
+ if !data.EnableInforms.IsNull() && !data.EnableInforms.IsUnknown() {
+ if data.EnableInforms.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/informs", "")
} else {
- data.EnableInforms = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/informs")
}
- } else {
- data.EnableInforms = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps"); !data.EnableTraps.IsNull() {
- if value.Exists() {
- data.EnableTraps = types.BoolValue(true)
+ if !data.EnableTraps.IsNull() && !data.EnableTraps.IsUnknown() {
+ if data.EnableTraps.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps", "")
} else {
- data.EnableTraps = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps")
}
- } else {
- data.EnableTraps = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.snmp.authentication"); !data.EnableTrapsSnmpAuthentication.IsNull() {
- if value.Exists() {
- data.EnableTrapsSnmpAuthentication = types.BoolValue(true)
+ if !data.EnableTrapsSnmpAuthentication.IsNull() && !data.EnableTrapsSnmpAuthentication.IsUnknown() {
+ if data.EnableTrapsSnmpAuthentication.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/snmp/authentication", "")
} else {
- data.EnableTrapsSnmpAuthentication = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/snmp/authentication")
}
- } else {
- data.EnableTrapsSnmpAuthentication = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.snmp.coldstart"); !data.EnableTrapsSnmpColdstart.IsNull() {
- if value.Exists() {
- data.EnableTrapsSnmpColdstart = types.BoolValue(true)
+ if !data.EnableTrapsSnmpColdstart.IsNull() && !data.EnableTrapsSnmpColdstart.IsUnknown() {
+ if data.EnableTrapsSnmpColdstart.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/snmp/coldstart", "")
} else {
- data.EnableTrapsSnmpColdstart = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/snmp/coldstart")
}
- } else {
- data.EnableTrapsSnmpColdstart = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.snmp.linkdown"); !data.EnableTrapsSnmpLinkdown.IsNull() {
- if value.Exists() {
- data.EnableTrapsSnmpLinkdown = types.BoolValue(true)
+ if !data.EnableTrapsSnmpLinkdown.IsNull() && !data.EnableTrapsSnmpLinkdown.IsUnknown() {
+ if data.EnableTrapsSnmpLinkdown.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/snmp/linkdown", "")
} else {
- data.EnableTrapsSnmpLinkdown = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/snmp/linkdown")
}
- } else {
- data.EnableTrapsSnmpLinkdown = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.snmp.linkup"); !data.EnableTrapsSnmpLinkup.IsNull() {
- if value.Exists() {
- data.EnableTrapsSnmpLinkup = types.BoolValue(true)
+ if !data.EnableTrapsSnmpLinkup.IsNull() && !data.EnableTrapsSnmpLinkup.IsUnknown() {
+ if data.EnableTrapsSnmpLinkup.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/snmp/linkup", "")
} else {
- data.EnableTrapsSnmpLinkup = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/snmp/linkup")
}
- } else {
- data.EnableTrapsSnmpLinkup = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.snmp.warmstart"); !data.EnableTrapsSnmpWarmstart.IsNull() {
- if value.Exists() {
- data.EnableTrapsSnmpWarmstart = types.BoolValue(true)
+ if !data.EnableTrapsSnmpWarmstart.IsNull() && !data.EnableTrapsSnmpWarmstart.IsUnknown() {
+ if data.EnableTrapsSnmpWarmstart.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/snmp/warmstart", "")
} else {
- data.EnableTrapsSnmpWarmstart = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/snmp/warmstart")
}
- } else {
- data.EnableTrapsSnmpWarmstart = types.BoolNull()
}
- for i := range data.Hosts {
- keys := [...]string{"ip-address"}
- keyValues := [...]string{data.Hosts[i].IpAddress.ValueString()}
-
- var r gjson.Result
- res.Get(prefix + "Cisco-IOS-XE-snmp:host-config.ip-community").ForEach(
- func(_, v gjson.Result) bool {
- found := false
- for ik := range keys {
- if v.Get(keys[ik]).String() == keyValues[ik] {
- found = true
- continue
- }
- found = false
- break
- }
- if found {
- r = v
- return false
- }
- return true
- },
- )
- if value := r.Get("ip-address"); value.Exists() && !data.Hosts[i].IpAddress.IsNull() {
- data.Hosts[i].IpAddress = types.StringValue(value.String())
- } else {
- data.Hosts[i].IpAddress = types.StringNull()
+ if len(data.Hosts) > 0 {
+ for _, item := range data.Hosts {
+ cBody := netconf.Body{}
+ if !item.IpAddress.IsNull() && !item.IpAddress.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "ip-address", item.IpAddress.ValueString())
+ }
+ if !item.CommunityOrUser.IsNull() && !item.CommunityOrUser.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "community-or-user", item.CommunityOrUser.ValueString())
+ }
+ if !item.Version.IsNull() && !item.Version.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "version", item.Version.ValueString())
+ }
+ if !item.Encryption.IsNull() && !item.Encryption.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "encryption", item.Encryption.ValueString())
+ }
+ if !item.SecurityLevel.IsNull() && !item.SecurityLevel.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "security-level", item.SecurityLevel.ValueString())
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:host-config/ip-community", cBody.Res())
}
- if value := r.Get("version"); value.Exists() && !data.Hosts[i].Version.IsNull() {
- data.Hosts[i].Version = types.StringValue(value.String())
- } else {
- data.Hosts[i].Version = types.StringNull()
+ }
+ if len(data.VrfHosts) > 0 {
+ for _, item := range data.VrfHosts {
+ cBody := netconf.Body{}
+ if !item.IpAddress.IsNull() && !item.IpAddress.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "ip-address", item.IpAddress.ValueString())
+ }
+ if !item.Vrf.IsNull() && !item.Vrf.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "vrf", item.Vrf.ValueString())
+ }
+ if !item.CommunityOrUser.IsNull() && !item.CommunityOrUser.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "community-or-user", item.CommunityOrUser.ValueString())
+ }
+ if !item.Version.IsNull() && !item.Version.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "version", item.Version.ValueString())
+ }
+ if !item.Encryption.IsNull() && !item.Encryption.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "encryption", item.Encryption.ValueString())
+ }
+ if !item.SecurityLevel.IsNull() && !item.SecurityLevel.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "security-level", item.SecurityLevel.ValueString())
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:host-config/ip-vrf-community", cBody.Res())
}
- if value := r.Get("encryption"); value.Exists() && !data.Hosts[i].Encryption.IsNull() {
- data.Hosts[i].Encryption = types.StringValue(value.String())
+ }
+ if !data.SystemShutdown.IsNull() && !data.SystemShutdown.IsUnknown() {
+ if data.SystemShutdown.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:system-shutdown", "")
} else {
- data.Hosts[i].Encryption = types.StringNull()
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:system-shutdown")
}
- if value := r.Get("security-level"); value.Exists() && !data.Hosts[i].SecurityLevel.IsNull() {
- data.Hosts[i].SecurityLevel = types.StringValue(value.String())
+ }
+ if !data.EnableTrapsFlowmon.IsNull() && !data.EnableTrapsFlowmon.IsUnknown() {
+ if data.EnableTrapsFlowmon.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/flowmon", "")
} else {
- data.Hosts[i].SecurityLevel = types.StringNull()
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/flowmon")
}
}
- for i := range data.VrfHosts {
- keys := [...]string{"ip-address", "vrf"}
- keyValues := [...]string{data.VrfHosts[i].IpAddress.ValueString(), data.VrfHosts[i].Vrf.ValueString()}
-
- var r gjson.Result
- res.Get(prefix + "Cisco-IOS-XE-snmp:host-config.ip-vrf-community").ForEach(
- func(_, v gjson.Result) bool {
- found := false
- for ik := range keys {
- if v.Get(keys[ik]).String() == keyValues[ik] {
- found = true
- continue
- }
- found = false
- break
- }
- if found {
- r = v
- return false
- }
- return true
- },
- )
- if value := r.Get("ip-address"); value.Exists() && !data.VrfHosts[i].IpAddress.IsNull() {
- data.VrfHosts[i].IpAddress = types.StringValue(value.String())
+ if !data.EnableTrapsEntityPerfThroughputNotif.IsNull() && !data.EnableTrapsEntityPerfThroughputNotif.IsUnknown() {
+ if data.EnableTrapsEntityPerfThroughputNotif.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/entity-perf/throughput-notif", "")
} else {
- data.VrfHosts[i].IpAddress = types.StringNull()
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/entity-perf/throughput-notif")
}
- if value := r.Get("vrf"); value.Exists() && !data.VrfHosts[i].Vrf.IsNull() {
- data.VrfHosts[i].Vrf = types.StringValue(value.String())
+ }
+ if !data.EnableTrapsCallHomeMessageSendFail.IsNull() && !data.EnableTrapsCallHomeMessageSendFail.IsUnknown() {
+ if data.EnableTrapsCallHomeMessageSendFail.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/call-home/message-send-fail", "")
} else {
- data.VrfHosts[i].Vrf = types.StringNull()
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/call-home/message-send-fail")
}
- if value := r.Get("version"); value.Exists() && !data.VrfHosts[i].Version.IsNull() {
- data.VrfHosts[i].Version = types.StringValue(value.String())
+ }
+ if !data.EnableTrapsCallHomeServerFail.IsNull() && !data.EnableTrapsCallHomeServerFail.IsUnknown() {
+ if data.EnableTrapsCallHomeServerFail.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/call-home/server-fail", "")
} else {
- data.VrfHosts[i].Version = types.StringNull()
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/call-home/server-fail")
}
- if value := r.Get("encryption"); value.Exists() && !data.VrfHosts[i].Encryption.IsNull() {
- data.VrfHosts[i].Encryption = types.StringValue(value.String())
+ }
+ if !data.EnableTrapsTty.IsNull() && !data.EnableTrapsTty.IsUnknown() {
+ if data.EnableTrapsTty.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/tty", "")
} else {
- data.VrfHosts[i].Encryption = types.StringNull()
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/tty")
}
- if value := r.Get("security-level"); value.Exists() && !data.VrfHosts[i].SecurityLevel.IsNull() {
- data.VrfHosts[i].SecurityLevel = types.StringValue(value.String())
+ }
+ if !data.EnableTrapsOspfv3ConfigStateChange.IsNull() && !data.EnableTrapsOspfv3ConfigStateChange.IsUnknown() {
+ if data.EnableTrapsOspfv3ConfigStateChange.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/Cisco-IOS-XE-ospfv3:ospfv3-config/state-change/enable", "")
} else {
- data.VrfHosts[i].SecurityLevel = types.StringNull()
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/Cisco-IOS-XE-ospfv3:ospfv3-config/state-change/enable")
}
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:system-shutdown"); !data.SystemShutdown.IsNull() {
- if value.Exists() {
- data.SystemShutdown = types.BoolValue(true)
+ if !data.EnableTrapsOspfv3ConfigErrors.IsNull() && !data.EnableTrapsOspfv3ConfigErrors.IsUnknown() {
+ if data.EnableTrapsOspfv3ConfigErrors.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/Cisco-IOS-XE-ospfv3:ospfv3-config/errors/enable", "")
} else {
- data.SystemShutdown = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/Cisco-IOS-XE-ospfv3:ospfv3-config/errors/enable")
}
- } else {
- data.SystemShutdown = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.flowmon"); !data.EnableTrapsFlowmon.IsNull() {
- if value.Exists() {
- data.EnableTrapsFlowmon = types.BoolValue(true)
+ if !data.EnableTrapsOspfConfigRetransmit.IsNull() && !data.EnableTrapsOspfConfigRetransmit.IsUnknown() {
+ if data.EnableTrapsOspfConfigRetransmit.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/Cisco-IOS-XE-ospf:ospf-config/retransmit/enable", "")
} else {
- data.EnableTrapsFlowmon = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/Cisco-IOS-XE-ospf:ospf-config/retransmit/enable")
}
- } else {
- data.EnableTrapsFlowmon = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.entity-perf.throughput-notif"); !data.EnableTrapsEntityPerfThroughputNotif.IsNull() {
- if value.Exists() {
- data.EnableTrapsEntityPerfThroughputNotif = types.BoolValue(true)
+ if !data.EnableTrapsOspfConfigLsa.IsNull() && !data.EnableTrapsOspfConfigLsa.IsUnknown() {
+ if data.EnableTrapsOspfConfigLsa.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/Cisco-IOS-XE-ospf:ospf-config/lsa/enable", "")
} else {
- data.EnableTrapsEntityPerfThroughputNotif = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/Cisco-IOS-XE-ospf:ospf-config/lsa/enable")
}
- } else {
- data.EnableTrapsEntityPerfThroughputNotif = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.call-home.message-send-fail"); !data.EnableTrapsCallHomeMessageSendFail.IsNull() {
- if value.Exists() {
- data.EnableTrapsCallHomeMessageSendFail = types.BoolValue(true)
+ if !data.EnableTrapsOspfNssaTransChange.IsNull() && !data.EnableTrapsOspfNssaTransChange.IsUnknown() {
+ if data.EnableTrapsOspfNssaTransChange.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/Cisco-IOS-XE-ospf:ospf-config/cisco-specific/state-change/nssa-trans-change", "")
} else {
- data.EnableTrapsCallHomeMessageSendFail = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/Cisco-IOS-XE-ospf:ospf-config/cisco-specific/state-change/nssa-trans-change")
}
- } else {
- data.EnableTrapsCallHomeMessageSendFail = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.call-home.server-fail"); !data.EnableTrapsCallHomeServerFail.IsNull() {
- if value.Exists() {
- data.EnableTrapsCallHomeServerFail = types.BoolValue(true)
+ if !data.EnableTrapsOspfShamlinkInterface.IsNull() && !data.EnableTrapsOspfShamlinkInterface.IsUnknown() {
+ if data.EnableTrapsOspfShamlinkInterface.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/Cisco-IOS-XE-ospf:ospf-config/cisco-specific/state-change/shamlink/interface", "")
} else {
- data.EnableTrapsCallHomeServerFail = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/Cisco-IOS-XE-ospf:ospf-config/cisco-specific/state-change/shamlink/interface")
}
- } else {
- data.EnableTrapsCallHomeServerFail = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.tty"); !data.EnableTrapsTty.IsNull() {
- if value.Exists() {
- data.EnableTrapsTty = types.BoolValue(true)
+ if !data.EnableTrapsOspfShamlinkNeighbor.IsNull() && !data.EnableTrapsOspfShamlinkNeighbor.IsUnknown() {
+ if data.EnableTrapsOspfShamlinkNeighbor.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/Cisco-IOS-XE-ospf:ospf-config/cisco-specific/state-change/shamlink/neighbor", "")
} else {
- data.EnableTrapsTty = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/Cisco-IOS-XE-ospf:ospf-config/cisco-specific/state-change/shamlink/neighbor")
}
- } else {
- data.EnableTrapsTty = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.Cisco-IOS-XE-ospfv3:ospfv3-config.state-change.enable"); !data.EnableTrapsOspfv3ConfigStateChange.IsNull() {
- if value.Exists() {
- data.EnableTrapsOspfv3ConfigStateChange = types.BoolValue(true)
+ if !data.EnableTrapsOspfErrorsEnable.IsNull() && !data.EnableTrapsOspfErrorsEnable.IsUnknown() {
+ if data.EnableTrapsOspfErrorsEnable.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/Cisco-IOS-XE-ospf:ospf-config/cisco-specific/errors/enable", "")
} else {
- data.EnableTrapsOspfv3ConfigStateChange = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/Cisco-IOS-XE-ospf:ospf-config/cisco-specific/errors/enable")
}
- } else {
- data.EnableTrapsOspfv3ConfigStateChange = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.Cisco-IOS-XE-ospfv3:ospfv3-config.errors.enable"); !data.EnableTrapsOspfv3ConfigErrors.IsNull() {
- if value.Exists() {
- data.EnableTrapsOspfv3ConfigErrors = types.BoolValue(true)
+ if !data.EnableTrapsOspfRetransmitEnable.IsNull() && !data.EnableTrapsOspfRetransmitEnable.IsUnknown() {
+ if data.EnableTrapsOspfRetransmitEnable.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/Cisco-IOS-XE-ospf:ospf-config/cisco-specific/retransmit/enable", "")
} else {
- data.EnableTrapsOspfv3ConfigErrors = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/Cisco-IOS-XE-ospf:ospf-config/cisco-specific/retransmit/enable")
}
- } else {
- data.EnableTrapsOspfv3ConfigErrors = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.Cisco-IOS-XE-ospf:ospf-config.retransmit.enable"); !data.EnableTrapsOspfConfigRetransmit.IsNull() {
- if value.Exists() {
- data.EnableTrapsOspfConfigRetransmit = types.BoolValue(true)
+ if !data.EnableTrapsOspfLsaEnable.IsNull() && !data.EnableTrapsOspfLsaEnable.IsUnknown() {
+ if data.EnableTrapsOspfLsaEnable.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/Cisco-IOS-XE-ospf:ospf-config/cisco-specific/lsa/enable", "")
} else {
- data.EnableTrapsOspfConfigRetransmit = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/Cisco-IOS-XE-ospf:ospf-config/cisco-specific/lsa/enable")
}
- } else {
- data.EnableTrapsOspfConfigRetransmit = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.Cisco-IOS-XE-ospf:ospf-config.lsa.enable"); !data.EnableTrapsOspfConfigLsa.IsNull() {
- if value.Exists() {
- data.EnableTrapsOspfConfigLsa = types.BoolValue(true)
+ if !data.EnableTrapsEigrp.IsNull() && !data.EnableTrapsEigrp.IsUnknown() {
+ if data.EnableTrapsEigrp.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/eigrp", "")
} else {
- data.EnableTrapsOspfConfigLsa = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/eigrp")
}
- } else {
- data.EnableTrapsOspfConfigLsa = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.Cisco-IOS-XE-ospf:ospf-config.cisco-specific.state-change.nssa-trans-change"); !data.EnableTrapsOspfNssaTransChange.IsNull() {
- if value.Exists() {
- data.EnableTrapsOspfNssaTransChange = types.BoolValue(true)
+ if !data.EnableTrapsAuthFrameworkSecViolation.IsNull() && !data.EnableTrapsAuthFrameworkSecViolation.IsUnknown() {
+ if data.EnableTrapsAuthFrameworkSecViolation.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/auth-framework/sec-violation", "")
} else {
- data.EnableTrapsOspfNssaTransChange = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/auth-framework/sec-violation")
}
- } else {
- data.EnableTrapsOspfNssaTransChange = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.Cisco-IOS-XE-ospf:ospf-config.cisco-specific.state-change.shamlink.interface"); !data.EnableTrapsOspfShamlinkInterface.IsNull() {
- if value.Exists() {
- data.EnableTrapsOspfShamlinkInterface = types.BoolValue(true)
+ if !data.EnableTrapsRep.IsNull() && !data.EnableTrapsRep.IsUnknown() {
+ if data.EnableTrapsRep.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/rep", "")
} else {
- data.EnableTrapsOspfShamlinkInterface = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/rep")
}
- } else {
- data.EnableTrapsOspfShamlinkInterface = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.Cisco-IOS-XE-ospf:ospf-config.cisco-specific.state-change.shamlink.neighbor"); !data.EnableTrapsOspfShamlinkNeighbor.IsNull() {
- if value.Exists() {
- data.EnableTrapsOspfShamlinkNeighbor = types.BoolValue(true)
+ if !data.EnableTrapsVtp.IsNull() && !data.EnableTrapsVtp.IsUnknown() {
+ if data.EnableTrapsVtp.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/vtp", "")
} else {
- data.EnableTrapsOspfShamlinkNeighbor = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/vtp")
}
- } else {
- data.EnableTrapsOspfShamlinkNeighbor = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.Cisco-IOS-XE-ospf:ospf-config.cisco-specific.errors.enable"); !data.EnableTrapsOspfErrorsEnable.IsNull() {
- if value.Exists() {
- data.EnableTrapsOspfErrorsEnable = types.BoolValue(true)
+ if !data.EnableTrapsVlancreate.IsNull() && !data.EnableTrapsVlancreate.IsUnknown() {
+ if data.EnableTrapsVlancreate.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/vlancreate", "")
} else {
- data.EnableTrapsOspfErrorsEnable = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/vlancreate")
}
- } else {
- data.EnableTrapsOspfErrorsEnable = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.Cisco-IOS-XE-ospf:ospf-config.cisco-specific.retransmit.enable"); !data.EnableTrapsOspfRetransmitEnable.IsNull() {
- if value.Exists() {
- data.EnableTrapsOspfRetransmitEnable = types.BoolValue(true)
+ if !data.EnableTrapsVlandelete.IsNull() && !data.EnableTrapsVlandelete.IsUnknown() {
+ if data.EnableTrapsVlandelete.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/vlandelete", "")
} else {
- data.EnableTrapsOspfRetransmitEnable = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/vlandelete")
}
- } else {
- data.EnableTrapsOspfRetransmitEnable = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.Cisco-IOS-XE-ospf:ospf-config.cisco-specific.lsa.enable"); !data.EnableTrapsOspfLsaEnable.IsNull() {
- if value.Exists() {
- data.EnableTrapsOspfLsaEnable = types.BoolValue(true)
+ if !data.EnableTrapsPortSecurity.IsNull() && !data.EnableTrapsPortSecurity.IsUnknown() {
+ if data.EnableTrapsPortSecurity.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/port-security", "")
} else {
- data.EnableTrapsOspfLsaEnable = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/port-security")
}
- } else {
- data.EnableTrapsOspfLsaEnable = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.eigrp"); !data.EnableTrapsEigrp.IsNull() {
- if value.Exists() {
- data.EnableTrapsEigrp = types.BoolValue(true)
+ if !data.EnableTrapsLicense.IsNull() && !data.EnableTrapsLicense.IsUnknown() {
+ if data.EnableTrapsLicense.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/license", "")
} else {
- data.EnableTrapsEigrp = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/license")
}
- } else {
- data.EnableTrapsEigrp = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.auth-framework.sec-violation"); !data.EnableTrapsAuthFrameworkSecViolation.IsNull() {
- if value.Exists() {
- data.EnableTrapsAuthFrameworkSecViolation = types.BoolValue(true)
+ if !data.EnableTrapsSmartLicense.IsNull() && !data.EnableTrapsSmartLicense.IsUnknown() {
+ if data.EnableTrapsSmartLicense.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/smart-licenseing/smart-license", "")
} else {
- data.EnableTrapsAuthFrameworkSecViolation = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/smart-licenseing/smart-license")
}
- } else {
- data.EnableTrapsAuthFrameworkSecViolation = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.rep"); !data.EnableTrapsRep.IsNull() {
- if value.Exists() {
- data.EnableTrapsRep = types.BoolValue(true)
+ if !data.EnableTrapsCpuThreshold.IsNull() && !data.EnableTrapsCpuThreshold.IsUnknown() {
+ if data.EnableTrapsCpuThreshold.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/cpu/threshold", "")
} else {
- data.EnableTrapsRep = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/cpu/threshold")
}
- } else {
- data.EnableTrapsRep = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.vtp"); !data.EnableTrapsVtp.IsNull() {
- if value.Exists() {
- data.EnableTrapsVtp = types.BoolValue(true)
+ if !data.EnableTrapsMemoryBufferpeak.IsNull() && !data.EnableTrapsMemoryBufferpeak.IsUnknown() {
+ if data.EnableTrapsMemoryBufferpeak.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/memory/bufferpeak", "")
} else {
- data.EnableTrapsVtp = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/memory/bufferpeak")
}
- } else {
- data.EnableTrapsVtp = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.vlancreate"); !data.EnableTrapsVlancreate.IsNull() {
- if value.Exists() {
- data.EnableTrapsVlancreate = types.BoolValue(true)
+ if !data.EnableTrapsStackwise.IsNull() && !data.EnableTrapsStackwise.IsUnknown() {
+ if data.EnableTrapsStackwise.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/stackwise", "")
} else {
- data.EnableTrapsVlancreate = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/stackwise")
}
- } else {
- data.EnableTrapsVlancreate = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.vlandelete"); !data.EnableTrapsVlandelete.IsNull() {
- if value.Exists() {
- data.EnableTrapsVlandelete = types.BoolValue(true)
+ if !data.EnableTrapsUdldLinkFailRpt.IsNull() && !data.EnableTrapsUdldLinkFailRpt.IsUnknown() {
+ if data.EnableTrapsUdldLinkFailRpt.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/udld/link-fail-rpt", "")
} else {
- data.EnableTrapsVlandelete = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/udld/link-fail-rpt")
}
- } else {
- data.EnableTrapsVlandelete = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.port-security"); !data.EnableTrapsPortSecurity.IsNull() {
- if value.Exists() {
- data.EnableTrapsPortSecurity = types.BoolValue(true)
+ if !data.EnableTrapsUdldStatusChange.IsNull() && !data.EnableTrapsUdldStatusChange.IsUnknown() {
+ if data.EnableTrapsUdldStatusChange.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/udld/status-change", "")
} else {
- data.EnableTrapsPortSecurity = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/udld/status-change")
}
- } else {
- data.EnableTrapsPortSecurity = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.license"); !data.EnableTrapsLicense.IsNull() {
- if value.Exists() {
- data.EnableTrapsLicense = types.BoolValue(true)
+ if !data.EnableTrapsFruCtrl.IsNull() && !data.EnableTrapsFruCtrl.IsUnknown() {
+ if data.EnableTrapsFruCtrl.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/fru-ctrl", "")
} else {
- data.EnableTrapsLicense = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/fru-ctrl")
}
- } else {
- data.EnableTrapsLicense = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.smart-licenseing.smart-license"); !data.EnableTrapsSmartLicense.IsNull() {
- if value.Exists() {
- data.EnableTrapsSmartLicense = types.BoolValue(true)
+ if !data.EnableTrapsFlashInsertion.IsNull() && !data.EnableTrapsFlashInsertion.IsUnknown() {
+ if data.EnableTrapsFlashInsertion.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/flash/insertion", "")
} else {
- data.EnableTrapsSmartLicense = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/flash/insertion")
}
- } else {
- data.EnableTrapsSmartLicense = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.cpu.threshold"); !data.EnableTrapsCpuThreshold.IsNull() {
- if value.Exists() {
- data.EnableTrapsCpuThreshold = types.BoolValue(true)
+ if !data.EnableTrapsFlashRemoval.IsNull() && !data.EnableTrapsFlashRemoval.IsUnknown() {
+ if data.EnableTrapsFlashRemoval.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/flash/removal", "")
} else {
- data.EnableTrapsCpuThreshold = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/flash/removal")
}
- } else {
- data.EnableTrapsCpuThreshold = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.memory.bufferpeak"); !data.EnableTrapsMemoryBufferpeak.IsNull() {
- if value.Exists() {
- data.EnableTrapsMemoryBufferpeak = types.BoolValue(true)
+ if !data.EnableTrapsFlashLowspace.IsNull() && !data.EnableTrapsFlashLowspace.IsUnknown() {
+ if data.EnableTrapsFlashLowspace.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/flash/lowspace", "")
} else {
- data.EnableTrapsMemoryBufferpeak = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/flash/lowspace")
}
- } else {
- data.EnableTrapsMemoryBufferpeak = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.stackwise"); !data.EnableTrapsStackwise.IsNull() {
- if value.Exists() {
- data.EnableTrapsStackwise = types.BoolValue(true)
+ if !data.EnableTrapsEnergywise.IsNull() && !data.EnableTrapsEnergywise.IsUnknown() {
+ if data.EnableTrapsEnergywise.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/energywise", "")
} else {
- data.EnableTrapsStackwise = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/energywise")
}
- } else {
- data.EnableTrapsStackwise = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.udld.link-fail-rpt"); !data.EnableTrapsUdldLinkFailRpt.IsNull() {
- if value.Exists() {
- data.EnableTrapsUdldLinkFailRpt = types.BoolValue(true)
+ if !data.EnableTrapsPowerEthernetGroup.IsNull() && !data.EnableTrapsPowerEthernetGroup.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/power-ethernet/group", data.EnableTrapsPowerEthernetGroup.ValueString())
+ }
+ if !data.EnableTrapsPowerEthernetPolice.IsNull() && !data.EnableTrapsPowerEthernetPolice.IsUnknown() {
+ if data.EnableTrapsPowerEthernetPolice.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/power-ethernet/police", "")
} else {
- data.EnableTrapsUdldLinkFailRpt = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/power-ethernet/police")
}
- } else {
- data.EnableTrapsUdldLinkFailRpt = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.udld.status-change"); !data.EnableTrapsUdldStatusChange.IsNull() {
- if value.Exists() {
- data.EnableTrapsUdldStatusChange = types.BoolValue(true)
+ if !data.EnableTrapsEntity.IsNull() && !data.EnableTrapsEntity.IsUnknown() {
+ if data.EnableTrapsEntity.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/entity", "")
} else {
- data.EnableTrapsUdldStatusChange = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/entity")
}
- } else {
- data.EnableTrapsUdldStatusChange = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.fru-ctrl"); !data.EnableTrapsFruCtrl.IsNull() {
- if value.Exists() {
- data.EnableTrapsFruCtrl = types.BoolValue(true)
+ if !data.EnableTrapsPwVc.IsNull() && !data.EnableTrapsPwVc.IsUnknown() {
+ if data.EnableTrapsPwVc.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/pw/vc", "")
} else {
- data.EnableTrapsFruCtrl = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/pw/vc")
}
- } else {
- data.EnableTrapsFruCtrl = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.flash.insertion"); !data.EnableTrapsFlashInsertion.IsNull() {
- if value.Exists() {
- data.EnableTrapsFlashInsertion = types.BoolValue(true)
+ if !data.EnableTrapsEnvmon.IsNull() && !data.EnableTrapsEnvmon.IsUnknown() {
+ if data.EnableTrapsEnvmon.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/envmon", "")
} else {
- data.EnableTrapsFlashInsertion = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/envmon")
}
- } else {
- data.EnableTrapsFlashInsertion = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.flash.removal"); !data.EnableTrapsFlashRemoval.IsNull() {
- if value.Exists() {
- data.EnableTrapsFlashRemoval = types.BoolValue(true)
+ if !data.EnableTrapsCefResourceFailure.IsNull() && !data.EnableTrapsCefResourceFailure.IsUnknown() {
+ if data.EnableTrapsCefResourceFailure.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/cef/resource-failure", "")
} else {
- data.EnableTrapsFlashRemoval = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/cef/resource-failure")
}
- } else {
- data.EnableTrapsFlashRemoval = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.flash.lowspace"); !data.EnableTrapsFlashLowspace.IsNull() {
- if value.Exists() {
- data.EnableTrapsFlashLowspace = types.BoolValue(true)
+ if !data.EnableTrapsCefPeerStateChange.IsNull() && !data.EnableTrapsCefPeerStateChange.IsUnknown() {
+ if data.EnableTrapsCefPeerStateChange.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/cef/peer-state-change", "")
} else {
- data.EnableTrapsFlashLowspace = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/cef/peer-state-change")
}
- } else {
- data.EnableTrapsFlashLowspace = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.energywise"); !data.EnableTrapsEnergywise.IsNull() {
- if value.Exists() {
- data.EnableTrapsEnergywise = types.BoolValue(true)
+ if !data.EnableTrapsCefPeerFibStateChange.IsNull() && !data.EnableTrapsCefPeerFibStateChange.IsUnknown() {
+ if data.EnableTrapsCefPeerFibStateChange.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/cef/peer-fib-state-change", "")
} else {
- data.EnableTrapsEnergywise = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/cef/peer-fib-state-change")
}
- } else {
- data.EnableTrapsEnergywise = types.BoolNull()
- }
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.power-ethernet.group"); value.Exists() && !data.EnableTrapsPowerEthernetGroup.IsNull() {
- data.EnableTrapsPowerEthernetGroup = types.StringValue(value.String())
- } else {
- data.EnableTrapsPowerEthernetGroup = types.StringNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.power-ethernet.police"); !data.EnableTrapsPowerEthernetPolice.IsNull() {
- if value.Exists() {
- data.EnableTrapsPowerEthernetPolice = types.BoolValue(true)
+ if !data.EnableTrapsCefInconsistency.IsNull() && !data.EnableTrapsCefInconsistency.IsUnknown() {
+ if data.EnableTrapsCefInconsistency.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/cef/inconsistency", "")
} else {
- data.EnableTrapsPowerEthernetPolice = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/cef/inconsistency")
}
- } else {
- data.EnableTrapsPowerEthernetPolice = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.entity"); !data.EnableTrapsEntity.IsNull() {
- if value.Exists() {
- data.EnableTrapsEntity = types.BoolValue(true)
+ if !data.EnableTrapsIsis.IsNull() && !data.EnableTrapsIsis.IsUnknown() {
+ if data.EnableTrapsIsis.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/isis", "")
} else {
- data.EnableTrapsEntity = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/isis")
}
- } else {
- data.EnableTrapsEntity = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.pw.vc"); !data.EnableTrapsPwVc.IsNull() {
- if value.Exists() {
- data.EnableTrapsPwVc = types.BoolValue(true)
+ if !data.EnableTrapsIpsla.IsNull() && !data.EnableTrapsIpsla.IsUnknown() {
+ if data.EnableTrapsIpsla.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ipsla", "")
} else {
- data.EnableTrapsPwVc = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ipsla")
}
- } else {
- data.EnableTrapsPwVc = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.envmon"); !data.EnableTrapsEnvmon.IsNull() {
- if value.Exists() {
- data.EnableTrapsEnvmon = types.BoolValue(true)
+ if !data.EnableTrapsEntityDiagBootUpFail.IsNull() && !data.EnableTrapsEntityDiagBootUpFail.IsUnknown() {
+ if data.EnableTrapsEntityDiagBootUpFail.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/entity-diag/boot-up-fail", "")
} else {
- data.EnableTrapsEnvmon = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/entity-diag/boot-up-fail")
}
- } else {
- data.EnableTrapsEnvmon = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.cef.resource-failure"); !data.EnableTrapsCefResourceFailure.IsNull() {
- if value.Exists() {
- data.EnableTrapsCefResourceFailure = types.BoolValue(true)
+ if !data.EnableTrapsEntityDiagHmTestRecover.IsNull() && !data.EnableTrapsEntityDiagHmTestRecover.IsUnknown() {
+ if data.EnableTrapsEntityDiagHmTestRecover.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/entity-diag/hm-test-recover", "")
} else {
- data.EnableTrapsCefResourceFailure = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/entity-diag/hm-test-recover")
}
- } else {
- data.EnableTrapsCefResourceFailure = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.cef.peer-state-change"); !data.EnableTrapsCefPeerStateChange.IsNull() {
- if value.Exists() {
- data.EnableTrapsCefPeerStateChange = types.BoolValue(true)
+ if !data.EnableTrapsEntityDiagHmThreshReached.IsNull() && !data.EnableTrapsEntityDiagHmThreshReached.IsUnknown() {
+ if data.EnableTrapsEntityDiagHmThreshReached.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/entity-diag/hm-thresh-reached", "")
} else {
- data.EnableTrapsCefPeerStateChange = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/entity-diag/hm-thresh-reached")
}
- } else {
- data.EnableTrapsCefPeerStateChange = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.cef.peer-fib-state-change"); !data.EnableTrapsCefPeerFibStateChange.IsNull() {
- if value.Exists() {
- data.EnableTrapsCefPeerFibStateChange = types.BoolValue(true)
+ if !data.EnableTrapsEntityDiagScheduledTestFail.IsNull() && !data.EnableTrapsEntityDiagScheduledTestFail.IsUnknown() {
+ if data.EnableTrapsEntityDiagScheduledTestFail.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/entity-diag/scheduled-test-fail", "")
} else {
- data.EnableTrapsCefPeerFibStateChange = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/entity-diag/scheduled-test-fail")
}
- } else {
- data.EnableTrapsCefPeerFibStateChange = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.cef.inconsistency"); !data.EnableTrapsCefInconsistency.IsNull() {
- if value.Exists() {
- data.EnableTrapsCefInconsistency = types.BoolValue(true)
+ if !data.EnableTrapsBfd.IsNull() && !data.EnableTrapsBfd.IsUnknown() {
+ if data.EnableTrapsBfd.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/bfd", "")
} else {
- data.EnableTrapsCefInconsistency = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/bfd")
}
- } else {
- data.EnableTrapsCefInconsistency = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.isis"); !data.EnableTrapsIsis.IsNull() {
- if value.Exists() {
- data.EnableTrapsIsis = types.BoolValue(true)
+ if !data.EnableTrapsIkePolicyAdd.IsNull() && !data.EnableTrapsIkePolicyAdd.IsUnknown() {
+ if data.EnableTrapsIkePolicyAdd.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ike/policy/add", "")
} else {
- data.EnableTrapsIsis = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ike/policy/add")
}
- } else {
- data.EnableTrapsIsis = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ipsla"); !data.EnableTrapsIpsla.IsNull() {
- if value.Exists() {
- data.EnableTrapsIpsla = types.BoolValue(true)
+ if !data.EnableTrapsIkePolicyDelete.IsNull() && !data.EnableTrapsIkePolicyDelete.IsUnknown() {
+ if data.EnableTrapsIkePolicyDelete.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ike/policy/delete", "")
} else {
- data.EnableTrapsIpsla = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ike/policy/delete")
}
- } else {
- data.EnableTrapsIpsla = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.entity-diag.boot-up-fail"); !data.EnableTrapsEntityDiagBootUpFail.IsNull() {
- if value.Exists() {
- data.EnableTrapsEntityDiagBootUpFail = types.BoolValue(true)
+ if !data.EnableTrapsIkeTunnelStart.IsNull() && !data.EnableTrapsIkeTunnelStart.IsUnknown() {
+ if data.EnableTrapsIkeTunnelStart.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ike/tunnel/start", "")
} else {
- data.EnableTrapsEntityDiagBootUpFail = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ike/tunnel/start")
}
- } else {
- data.EnableTrapsEntityDiagBootUpFail = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.entity-diag.hm-test-recover"); !data.EnableTrapsEntityDiagHmTestRecover.IsNull() {
- if value.Exists() {
- data.EnableTrapsEntityDiagHmTestRecover = types.BoolValue(true)
+ if !data.EnableTrapsIkeTunnelStop.IsNull() && !data.EnableTrapsIkeTunnelStop.IsUnknown() {
+ if data.EnableTrapsIkeTunnelStop.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ike/tunnel/stop", "")
} else {
- data.EnableTrapsEntityDiagHmTestRecover = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ike/tunnel/stop")
}
- } else {
- data.EnableTrapsEntityDiagHmTestRecover = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.entity-diag.hm-thresh-reached"); !data.EnableTrapsEntityDiagHmThreshReached.IsNull() {
- if value.Exists() {
- data.EnableTrapsEntityDiagHmThreshReached = types.BoolValue(true)
+ if !data.EnableTrapsIpsecCryptomapAdd.IsNull() && !data.EnableTrapsIpsecCryptomapAdd.IsUnknown() {
+ if data.EnableTrapsIpsecCryptomapAdd.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ipsec/cryptomap/add", "")
} else {
- data.EnableTrapsEntityDiagHmThreshReached = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ipsec/cryptomap/add")
}
- } else {
- data.EnableTrapsEntityDiagHmThreshReached = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.entity-diag.scheduled-test-fail"); !data.EnableTrapsEntityDiagScheduledTestFail.IsNull() {
- if value.Exists() {
- data.EnableTrapsEntityDiagScheduledTestFail = types.BoolValue(true)
+ if !data.EnableTrapsIpsecCryptomapAttach.IsNull() && !data.EnableTrapsIpsecCryptomapAttach.IsUnknown() {
+ if data.EnableTrapsIpsecCryptomapAttach.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ipsec/cryptomap/attach", "")
} else {
- data.EnableTrapsEntityDiagScheduledTestFail = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ipsec/cryptomap/attach")
}
- } else {
- data.EnableTrapsEntityDiagScheduledTestFail = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.bfd"); !data.EnableTrapsBfd.IsNull() {
- if value.Exists() {
- data.EnableTrapsBfd = types.BoolValue(true)
+ if !data.EnableTrapsIpsecCryptomapDelete.IsNull() && !data.EnableTrapsIpsecCryptomapDelete.IsUnknown() {
+ if data.EnableTrapsIpsecCryptomapDelete.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ipsec/cryptomap/delete", "")
} else {
- data.EnableTrapsBfd = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ipsec/cryptomap/delete")
}
- } else {
- data.EnableTrapsBfd = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ike.policy.add"); !data.EnableTrapsIkePolicyAdd.IsNull() {
- if value.Exists() {
- data.EnableTrapsIkePolicyAdd = types.BoolValue(true)
+ if !data.EnableTrapsIpsecCryptomapDetach.IsNull() && !data.EnableTrapsIpsecCryptomapDetach.IsUnknown() {
+ if data.EnableTrapsIpsecCryptomapDetach.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ipsec/cryptomap/detach", "")
} else {
- data.EnableTrapsIkePolicyAdd = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ipsec/cryptomap/detach")
}
- } else {
- data.EnableTrapsIkePolicyAdd = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ike.policy.delete"); !data.EnableTrapsIkePolicyDelete.IsNull() {
- if value.Exists() {
- data.EnableTrapsIkePolicyDelete = types.BoolValue(true)
+ if !data.EnableTrapsIpsecTunnelStart.IsNull() && !data.EnableTrapsIpsecTunnelStart.IsUnknown() {
+ if data.EnableTrapsIpsecTunnelStart.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ipsec/tunnel/start", "")
} else {
- data.EnableTrapsIkePolicyDelete = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ipsec/tunnel/start")
}
- } else {
- data.EnableTrapsIkePolicyDelete = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ike.tunnel.start"); !data.EnableTrapsIkeTunnelStart.IsNull() {
- if value.Exists() {
- data.EnableTrapsIkeTunnelStart = types.BoolValue(true)
+ if !data.EnableTrapsIpsecTunnelStop.IsNull() && !data.EnableTrapsIpsecTunnelStop.IsUnknown() {
+ if data.EnableTrapsIpsecTunnelStop.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ipsec/tunnel/stop", "")
} else {
- data.EnableTrapsIkeTunnelStart = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ipsec/tunnel/stop")
}
- } else {
- data.EnableTrapsIkeTunnelStart = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ike.tunnel.stop"); !data.EnableTrapsIkeTunnelStop.IsNull() {
- if value.Exists() {
- data.EnableTrapsIkeTunnelStop = types.BoolValue(true)
+ if !data.EnableTrapsIpsecTooManySas.IsNull() && !data.EnableTrapsIpsecTooManySas.IsUnknown() {
+ if data.EnableTrapsIpsecTooManySas.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ipsec/too-many-sas", "")
} else {
- data.EnableTrapsIkeTunnelStop = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ipsec/too-many-sas")
}
- } else {
- data.EnableTrapsIkeTunnelStop = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ipsec.cryptomap.add"); !data.EnableTrapsIpsecCryptomapAdd.IsNull() {
- if value.Exists() {
- data.EnableTrapsIpsecCryptomapAdd = types.BoolValue(true)
+ if !data.EnableTrapsConfigCopy.IsNull() && !data.EnableTrapsConfigCopy.IsUnknown() {
+ if data.EnableTrapsConfigCopy.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/config-copy", "")
} else {
- data.EnableTrapsIpsecCryptomapAdd = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/config-copy")
}
- } else {
- data.EnableTrapsIpsecCryptomapAdd = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ipsec.cryptomap.attach"); !data.EnableTrapsIpsecCryptomapAttach.IsNull() {
- if value.Exists() {
- data.EnableTrapsIpsecCryptomapAttach = types.BoolValue(true)
+ if !data.EnableTrapsConfig.IsNull() && !data.EnableTrapsConfig.IsUnknown() {
+ if data.EnableTrapsConfig.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/config", "")
} else {
- data.EnableTrapsIpsecCryptomapAttach = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/config")
}
- } else {
- data.EnableTrapsIpsecCryptomapAttach = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ipsec.cryptomap.delete"); !data.EnableTrapsIpsecCryptomapDelete.IsNull() {
- if value.Exists() {
- data.EnableTrapsIpsecCryptomapDelete = types.BoolValue(true)
+ if !data.EnableTrapsConfigCtid.IsNull() && !data.EnableTrapsConfigCtid.IsUnknown() {
+ if data.EnableTrapsConfigCtid.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/config-ctid", "")
} else {
- data.EnableTrapsIpsecCryptomapDelete = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/config-ctid")
}
- } else {
- data.EnableTrapsIpsecCryptomapDelete = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ipsec.cryptomap.detach"); !data.EnableTrapsIpsecCryptomapDetach.IsNull() {
- if value.Exists() {
- data.EnableTrapsIpsecCryptomapDetach = types.BoolValue(true)
+ if !data.EnableTrapsDhcp.IsNull() && !data.EnableTrapsDhcp.IsUnknown() {
+ if data.EnableTrapsDhcp.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/dhcp", "")
} else {
- data.EnableTrapsIpsecCryptomapDetach = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/dhcp")
}
- } else {
- data.EnableTrapsIpsecCryptomapDetach = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ipsec.tunnel.start"); !data.EnableTrapsIpsecTunnelStart.IsNull() {
- if value.Exists() {
- data.EnableTrapsIpsecTunnelStart = types.BoolValue(true)
+ if !data.EnableTrapsEventManager.IsNull() && !data.EnableTrapsEventManager.IsUnknown() {
+ if data.EnableTrapsEventManager.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/event-manager", "")
} else {
- data.EnableTrapsIpsecTunnelStart = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/event-manager")
}
- } else {
- data.EnableTrapsIpsecTunnelStart = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ipsec.tunnel.stop"); !data.EnableTrapsIpsecTunnelStop.IsNull() {
- if value.Exists() {
- data.EnableTrapsIpsecTunnelStop = types.BoolValue(true)
+ if !data.EnableTrapsHsrp.IsNull() && !data.EnableTrapsHsrp.IsUnknown() {
+ if data.EnableTrapsHsrp.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/hsrp", "")
} else {
- data.EnableTrapsIpsecTunnelStop = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/hsrp")
}
- } else {
- data.EnableTrapsIpsecTunnelStop = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ipsec.too-many-sas"); !data.EnableTrapsIpsecTooManySas.IsNull() {
- if value.Exists() {
- data.EnableTrapsIpsecTooManySas = types.BoolValue(true)
+ if !data.EnableTrapsIpmulticast.IsNull() && !data.EnableTrapsIpmulticast.IsUnknown() {
+ if data.EnableTrapsIpmulticast.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ipmulticast", "")
} else {
- data.EnableTrapsIpsecTooManySas = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ipmulticast")
}
- } else {
- data.EnableTrapsIpsecTooManySas = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.config-copy"); !data.EnableTrapsConfigCopy.IsNull() {
- if value.Exists() {
- data.EnableTrapsConfigCopy = types.BoolValue(true)
+ if !data.EnableTrapsMsdp.IsNull() && !data.EnableTrapsMsdp.IsUnknown() {
+ if data.EnableTrapsMsdp.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/msdp", "")
} else {
- data.EnableTrapsConfigCopy = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/msdp")
}
- } else {
- data.EnableTrapsConfigCopy = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.config"); !data.EnableTrapsConfig.IsNull() {
- if value.Exists() {
- data.EnableTrapsConfig = types.BoolValue(true)
+ if !data.EnableTrapsOspfConfigStateChange.IsNull() && !data.EnableTrapsOspfConfigStateChange.IsUnknown() {
+ if data.EnableTrapsOspfConfigStateChange.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/Cisco-IOS-XE-ospf:ospf-config/state-change/enable", "")
} else {
- data.EnableTrapsConfig = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/Cisco-IOS-XE-ospf:ospf-config/state-change/enable")
}
- } else {
- data.EnableTrapsConfig = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.config-ctid"); !data.EnableTrapsConfigCtid.IsNull() {
- if value.Exists() {
- data.EnableTrapsConfigCtid = types.BoolValue(true)
+ if !data.EnableTrapsOspfConfigErrors.IsNull() && !data.EnableTrapsOspfConfigErrors.IsUnknown() {
+ if data.EnableTrapsOspfConfigErrors.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/Cisco-IOS-XE-ospf:ospf-config/errors/enable", "")
} else {
- data.EnableTrapsConfigCtid = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/Cisco-IOS-XE-ospf:ospf-config/errors/enable")
}
- } else {
- data.EnableTrapsConfigCtid = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.dhcp"); !data.EnableTrapsDhcp.IsNull() {
- if value.Exists() {
- data.EnableTrapsDhcp = types.BoolValue(true)
+ if !data.EnableTrapsPimInvalidPimMessage.IsNull() && !data.EnableTrapsPimInvalidPimMessage.IsUnknown() {
+ if data.EnableTrapsPimInvalidPimMessage.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/pim/invalid-pim-message", "")
} else {
- data.EnableTrapsDhcp = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/pim/invalid-pim-message")
}
- } else {
- data.EnableTrapsDhcp = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.event-manager"); !data.EnableTrapsEventManager.IsNull() {
- if value.Exists() {
- data.EnableTrapsEventManager = types.BoolValue(true)
+ if !data.EnableTrapsPimNeighborChange.IsNull() && !data.EnableTrapsPimNeighborChange.IsUnknown() {
+ if data.EnableTrapsPimNeighborChange.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/pim/neighbor-change", "")
} else {
- data.EnableTrapsEventManager = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/pim/neighbor-change")
}
- } else {
- data.EnableTrapsEventManager = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.hsrp"); !data.EnableTrapsHsrp.IsNull() {
- if value.Exists() {
- data.EnableTrapsHsrp = types.BoolValue(true)
+ if !data.EnableTrapsPimRpMappingChange.IsNull() && !data.EnableTrapsPimRpMappingChange.IsUnknown() {
+ if data.EnableTrapsPimRpMappingChange.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/pim/rp-mapping-change", "")
} else {
- data.EnableTrapsHsrp = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/pim/rp-mapping-change")
}
- } else {
- data.EnableTrapsHsrp = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ipmulticast"); !data.EnableTrapsIpmulticast.IsNull() {
- if value.Exists() {
- data.EnableTrapsIpmulticast = types.BoolValue(true)
+ if !data.EnableTrapsBridgeNewroot.IsNull() && !data.EnableTrapsBridgeNewroot.IsUnknown() {
+ if data.EnableTrapsBridgeNewroot.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/bridge/newroot", "")
} else {
- data.EnableTrapsIpmulticast = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/bridge/newroot")
}
- } else {
- data.EnableTrapsIpmulticast = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.msdp"); !data.EnableTrapsMsdp.IsNull() {
- if value.Exists() {
- data.EnableTrapsMsdp = types.BoolValue(true)
+ if !data.EnableTrapsBridgeTopologychange.IsNull() && !data.EnableTrapsBridgeTopologychange.IsUnknown() {
+ if data.EnableTrapsBridgeTopologychange.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/bridge/topologychange", "")
} else {
- data.EnableTrapsMsdp = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/bridge/topologychange")
}
- } else {
- data.EnableTrapsMsdp = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.Cisco-IOS-XE-ospf:ospf-config.state-change.enable"); !data.EnableTrapsOspfConfigStateChange.IsNull() {
- if value.Exists() {
- data.EnableTrapsOspfConfigStateChange = types.BoolValue(true)
+ if !data.EnableTrapsStpxInconsistency.IsNull() && !data.EnableTrapsStpxInconsistency.IsUnknown() {
+ if data.EnableTrapsStpxInconsistency.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/stpx/inconsistency", "")
} else {
- data.EnableTrapsOspfConfigStateChange = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/stpx/inconsistency")
}
- } else {
- data.EnableTrapsOspfConfigStateChange = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.Cisco-IOS-XE-ospf:ospf-config.errors.enable"); !data.EnableTrapsOspfConfigErrors.IsNull() {
- if value.Exists() {
- data.EnableTrapsOspfConfigErrors = types.BoolValue(true)
+ if !data.EnableTrapsStpxRootInconsistency.IsNull() && !data.EnableTrapsStpxRootInconsistency.IsUnknown() {
+ if data.EnableTrapsStpxRootInconsistency.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/stpx/root-inconsistency", "")
} else {
- data.EnableTrapsOspfConfigErrors = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/stpx/root-inconsistency")
}
- } else {
- data.EnableTrapsOspfConfigErrors = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.pim.invalid-pim-message"); !data.EnableTrapsPimInvalidPimMessage.IsNull() {
- if value.Exists() {
- data.EnableTrapsPimInvalidPimMessage = types.BoolValue(true)
+ if !data.EnableTrapsStpxLoopInconsistency.IsNull() && !data.EnableTrapsStpxLoopInconsistency.IsUnknown() {
+ if data.EnableTrapsStpxLoopInconsistency.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/stpx/loop-inconsistency", "")
} else {
- data.EnableTrapsPimInvalidPimMessage = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/stpx/loop-inconsistency")
}
- } else {
- data.EnableTrapsPimInvalidPimMessage = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.pim.neighbor-change"); !data.EnableTrapsPimNeighborChange.IsNull() {
- if value.Exists() {
- data.EnableTrapsPimNeighborChange = types.BoolValue(true)
+ if !data.EnableTrapsSyslog.IsNull() && !data.EnableTrapsSyslog.IsUnknown() {
+ if data.EnableTrapsSyslog.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/syslog", "")
} else {
- data.EnableTrapsPimNeighborChange = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/syslog")
}
- } else {
- data.EnableTrapsPimNeighborChange = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.pim.rp-mapping-change"); !data.EnableTrapsPimRpMappingChange.IsNull() {
- if value.Exists() {
- data.EnableTrapsPimRpMappingChange = types.BoolValue(true)
+ if !data.EnableTrapsBgpCbgp2.IsNull() && !data.EnableTrapsBgpCbgp2.IsUnknown() {
+ if data.EnableTrapsBgpCbgp2.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/", "")
} else {
- data.EnableTrapsPimRpMappingChange = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/")
}
- } else {
- data.EnableTrapsPimRpMappingChange = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.bridge.newroot"); !data.EnableTrapsBridgeNewroot.IsNull() {
- if value.Exists() {
- data.EnableTrapsBridgeNewroot = types.BoolValue(true)
+ if !data.EnableTrapsNhrpNhs.IsNull() && !data.EnableTrapsNhrpNhs.IsUnknown() {
+ if data.EnableTrapsNhrpNhs.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/nhrp/nhs", "")
} else {
- data.EnableTrapsBridgeNewroot = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/nhrp/nhs")
}
- } else {
- data.EnableTrapsBridgeNewroot = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.bridge.topologychange"); !data.EnableTrapsBridgeTopologychange.IsNull() {
- if value.Exists() {
- data.EnableTrapsBridgeTopologychange = types.BoolValue(true)
+ if !data.EnableTrapsNhrpNhc.IsNull() && !data.EnableTrapsNhrpNhc.IsUnknown() {
+ if data.EnableTrapsNhrpNhc.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/nhrp/nhc", "")
} else {
- data.EnableTrapsBridgeTopologychange = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/nhrp/nhc")
}
- } else {
- data.EnableTrapsBridgeTopologychange = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.stpx.inconsistency"); !data.EnableTrapsStpxInconsistency.IsNull() {
- if value.Exists() {
- data.EnableTrapsStpxInconsistency = types.BoolValue(true)
+ if !data.EnableTrapsNhrpNhp.IsNull() && !data.EnableTrapsNhrpNhp.IsUnknown() {
+ if data.EnableTrapsNhrpNhp.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/nhrp/nhp", "")
} else {
- data.EnableTrapsStpxInconsistency = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/nhrp/nhp")
}
- } else {
- data.EnableTrapsStpxInconsistency = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.stpx.root-inconsistency"); !data.EnableTrapsStpxRootInconsistency.IsNull() {
- if value.Exists() {
- data.EnableTrapsStpxRootInconsistency = types.BoolValue(true)
+ if !data.EnableTrapsNhrpQuotaExceeded.IsNull() && !data.EnableTrapsNhrpQuotaExceeded.IsUnknown() {
+ if data.EnableTrapsNhrpQuotaExceeded.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/nhrp/quota-exceeded", "")
} else {
- data.EnableTrapsStpxRootInconsistency = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/nhrp/quota-exceeded")
}
- } else {
- data.EnableTrapsStpxRootInconsistency = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.stpx.loop-inconsistency"); !data.EnableTrapsStpxLoopInconsistency.IsNull() {
- if value.Exists() {
- data.EnableTrapsStpxLoopInconsistency = types.BoolValue(true)
+ if !data.EnableTrapsMplsTrafficEng.IsNull() && !data.EnableTrapsMplsTrafficEng.IsUnknown() {
+ if data.EnableTrapsMplsTrafficEng.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/mpls/traffic-eng", "")
} else {
- data.EnableTrapsStpxLoopInconsistency = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/mpls/traffic-eng")
}
- } else {
- data.EnableTrapsStpxLoopInconsistency = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.syslog"); !data.EnableTrapsSyslog.IsNull() {
- if value.Exists() {
- data.EnableTrapsSyslog = types.BoolValue(true)
+ if !data.EnableTrapsMpls.IsNull() && !data.EnableTrapsMpls.IsUnknown() {
+ if data.EnableTrapsMpls.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/mpls", "")
} else {
- data.EnableTrapsSyslog = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/mpls")
}
- } else {
- data.EnableTrapsSyslog = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.Cisco-IOS-XE-bgp:bgp.cbgp2"); !data.EnableTrapsBgpCbgp2.IsNull() {
- if value.Exists() {
- data.EnableTrapsBgpCbgp2 = types.BoolValue(true)
+ if !data.EnableTrapsMplsVpn.IsNull() && !data.EnableTrapsMplsVpn.IsUnknown() {
+ if data.EnableTrapsMplsVpn.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/mpls/vpn", "")
} else {
- data.EnableTrapsBgpCbgp2 = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/mpls/vpn")
}
- } else {
- data.EnableTrapsBgpCbgp2 = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.nhrp.nhs"); !data.EnableTrapsNhrpNhs.IsNull() {
- if value.Exists() {
- data.EnableTrapsNhrpNhs = types.BoolValue(true)
+ if !data.EnableTrapsMplsRfc.IsNull() && !data.EnableTrapsMplsRfc.IsUnknown() {
+ if data.EnableTrapsMplsRfc.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/mpls/rfc", "")
} else {
- data.EnableTrapsNhrpNhs = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/mpls/rfc")
}
- } else {
- data.EnableTrapsNhrpNhs = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.nhrp.nhc"); !data.EnableTrapsNhrpNhc.IsNull() {
- if value.Exists() {
- data.EnableTrapsNhrpNhc = types.BoolValue(true)
+ if !data.EnableTrapsMplsRfcLdp.IsNull() && !data.EnableTrapsMplsRfcLdp.IsUnknown() {
+ if data.EnableTrapsMplsRfcLdp.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/mpls/rfc/ldp", "")
} else {
- data.EnableTrapsNhrpNhc = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/mpls/rfc/ldp")
}
- } else {
- data.EnableTrapsNhrpNhc = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.nhrp.nhp"); !data.EnableTrapsNhrpNhp.IsNull() {
- if value.Exists() {
- data.EnableTrapsNhrpNhp = types.BoolValue(true)
+ if !data.EnableTrapsMplsLdp.IsNull() && !data.EnableTrapsMplsLdp.IsUnknown() {
+ if data.EnableTrapsMplsLdp.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/mpls/ldp", "")
} else {
- data.EnableTrapsNhrpNhp = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/mpls/ldp")
}
- } else {
- data.EnableTrapsNhrpNhp = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.nhrp.quota-exceeded"); !data.EnableTrapsNhrpQuotaExceeded.IsNull() {
- if value.Exists() {
- data.EnableTrapsNhrpQuotaExceeded = types.BoolValue(true)
+ if !data.EnableTrapsFastRerouteProtected.IsNull() && !data.EnableTrapsFastRerouteProtected.IsUnknown() {
+ if data.EnableTrapsFastRerouteProtected.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/mpls/fast-reroute/protected", "")
} else {
- data.EnableTrapsNhrpQuotaExceeded = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/mpls/fast-reroute/protected")
}
- } else {
- data.EnableTrapsNhrpQuotaExceeded = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.mpls.traffic-eng"); !data.EnableTrapsMplsTrafficEng.IsNull() {
- if value.Exists() {
- data.EnableTrapsMplsTrafficEng = types.BoolValue(true)
+ if !data.EnableTrapsLocalAuth.IsNull() && !data.EnableTrapsLocalAuth.IsUnknown() {
+ if data.EnableTrapsLocalAuth.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/local-auth", "")
} else {
- data.EnableTrapsMplsTrafficEng = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/local-auth")
}
- } else {
- data.EnableTrapsMplsTrafficEng = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.mpls"); !data.EnableTrapsMpls.IsNull() {
- if value.Exists() {
- data.EnableTrapsMpls = types.BoolValue(true)
+ if !data.EnableTrapsVlanMembership.IsNull() && !data.EnableTrapsVlanMembership.IsUnknown() {
+ if data.EnableTrapsVlanMembership.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/vlan-membership", "")
} else {
- data.EnableTrapsMpls = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/vlan-membership")
}
- } else {
- data.EnableTrapsMpls = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.mpls.vpn"); !data.EnableTrapsMplsVpn.IsNull() {
- if value.Exists() {
- data.EnableTrapsMplsVpn = types.BoolValue(true)
+ if !data.EnableTrapsErrdisable.IsNull() && !data.EnableTrapsErrdisable.IsUnknown() {
+ if data.EnableTrapsErrdisable.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/errdisable", "")
} else {
- data.EnableTrapsMplsVpn = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/errdisable")
}
- } else {
- data.EnableTrapsMplsVpn = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.mpls.rfc"); !data.EnableTrapsMplsRfc.IsNull() {
- if value.Exists() {
- data.EnableTrapsMplsRfc = types.BoolValue(true)
+ if !data.EnableTrapsRf.IsNull() && !data.EnableTrapsRf.IsUnknown() {
+ if data.EnableTrapsRf.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/rf", "")
} else {
- data.EnableTrapsMplsRfc = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/rf")
}
- } else {
- data.EnableTrapsMplsRfc = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.mpls.rfc.ldp"); !data.EnableTrapsMplsRfcLdp.IsNull() {
- if value.Exists() {
- data.EnableTrapsMplsRfcLdp = types.BoolValue(true)
+ if !data.EnableTrapsTransceiverAll.IsNull() && !data.EnableTrapsTransceiverAll.IsUnknown() {
+ if data.EnableTrapsTransceiverAll.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/transceiver/all", "")
} else {
- data.EnableTrapsMplsRfcLdp = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/transceiver/all")
}
- } else {
- data.EnableTrapsMplsRfcLdp = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.mpls.ldp"); !data.EnableTrapsMplsLdp.IsNull() {
- if value.Exists() {
- data.EnableTrapsMplsLdp = types.BoolValue(true)
+ if !data.EnableTrapsBulkstatCollection.IsNull() && !data.EnableTrapsBulkstatCollection.IsUnknown() {
+ if data.EnableTrapsBulkstatCollection.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/bulkstat/collection", "")
} else {
- data.EnableTrapsMplsLdp = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/bulkstat/collection")
}
- } else {
- data.EnableTrapsMplsLdp = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.mpls.fast-reroute.protected"); !data.EnableTrapsFastRerouteProtected.IsNull() {
- if value.Exists() {
- data.EnableTrapsFastRerouteProtected = types.BoolValue(true)
+ if !data.EnableTrapsBulkstatTransfer.IsNull() && !data.EnableTrapsBulkstatTransfer.IsUnknown() {
+ if data.EnableTrapsBulkstatTransfer.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/bulkstat/transfer", "")
} else {
- data.EnableTrapsFastRerouteProtected = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/bulkstat/transfer")
}
- } else {
- data.EnableTrapsFastRerouteProtected = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.local-auth"); !data.EnableTrapsLocalAuth.IsNull() {
- if value.Exists() {
- data.EnableTrapsLocalAuth = types.BoolValue(true)
+ if !data.EnableTrapsMacNotificationChange.IsNull() && !data.EnableTrapsMacNotificationChange.IsUnknown() {
+ if data.EnableTrapsMacNotificationChange.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/mac-notification/change", "")
} else {
- data.EnableTrapsLocalAuth = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/mac-notification/change")
}
- } else {
- data.EnableTrapsLocalAuth = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.vlan-membership"); !data.EnableTrapsVlanMembership.IsNull() {
- if value.Exists() {
- data.EnableTrapsVlanMembership = types.BoolValue(true)
+ if !data.EnableTrapsMacNotificationMove.IsNull() && !data.EnableTrapsMacNotificationMove.IsUnknown() {
+ if data.EnableTrapsMacNotificationMove.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/mac-notification/move", "")
} else {
- data.EnableTrapsVlanMembership = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/mac-notification/move")
}
- } else {
- data.EnableTrapsVlanMembership = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.errdisable"); !data.EnableTrapsErrdisable.IsNull() {
- if value.Exists() {
- data.EnableTrapsErrdisable = types.BoolValue(true)
+ if !data.EnableTrapsMacNotificationThreshold.IsNull() && !data.EnableTrapsMacNotificationThreshold.IsUnknown() {
+ if data.EnableTrapsMacNotificationThreshold.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/mac-notification/threshold", "")
} else {
- data.EnableTrapsErrdisable = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/mac-notification/threshold")
}
- } else {
- data.EnableTrapsErrdisable = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.rf"); !data.EnableTrapsRf.IsNull() {
- if value.Exists() {
- data.EnableTrapsRf = types.BoolValue(true)
+ if !data.EnableTrapsVrfmibVrfUp.IsNull() && !data.EnableTrapsVrfmibVrfUp.IsUnknown() {
+ if data.EnableTrapsVrfmibVrfUp.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/vrfmib/vrf-up", "")
} else {
- data.EnableTrapsRf = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/vrfmib/vrf-up")
}
- } else {
- data.EnableTrapsRf = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.transceiver.all"); !data.EnableTrapsTransceiverAll.IsNull() {
- if value.Exists() {
- data.EnableTrapsTransceiverAll = types.BoolValue(true)
+ if !data.EnableTrapsVrfmibVrfDown.IsNull() && !data.EnableTrapsVrfmibVrfDown.IsUnknown() {
+ if data.EnableTrapsVrfmibVrfDown.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/vrfmib/vrf-down", "")
} else {
- data.EnableTrapsTransceiverAll = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/vrfmib/vrf-down")
}
- } else {
- data.EnableTrapsTransceiverAll = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.bulkstat.collection"); !data.EnableTrapsBulkstatCollection.IsNull() {
- if value.Exists() {
- data.EnableTrapsBulkstatCollection = types.BoolValue(true)
+ if !data.EnableTrapsVrfmibVnetTrunkUp.IsNull() && !data.EnableTrapsVrfmibVnetTrunkUp.IsUnknown() {
+ if data.EnableTrapsVrfmibVnetTrunkUp.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/vrfmib/vnet-trunk-up", "")
} else {
- data.EnableTrapsBulkstatCollection = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/vrfmib/vnet-trunk-up")
}
- } else {
- data.EnableTrapsBulkstatCollection = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.bulkstat.transfer"); !data.EnableTrapsBulkstatTransfer.IsNull() {
- if value.Exists() {
- data.EnableTrapsBulkstatTransfer = types.BoolValue(true)
+ if !data.EnableTrapsVrfmibVnetTrunkDown.IsNull() && !data.EnableTrapsVrfmibVnetTrunkDown.IsUnknown() {
+ if data.EnableTrapsVrfmibVnetTrunkDown.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/vrfmib/vnet-trunk-down", "")
} else {
- data.EnableTrapsBulkstatTransfer = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/vrfmib/vnet-trunk-down")
}
- } else {
- data.EnableTrapsBulkstatTransfer = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.mac-notification.change"); !data.EnableTrapsMacNotificationChange.IsNull() {
- if value.Exists() {
- data.EnableTrapsMacNotificationChange = types.BoolValue(true)
+ if !data.EnableTrapsMvpn.IsNull() && !data.EnableTrapsMvpn.IsUnknown() {
+ if data.EnableTrapsMvpn.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/mvpn", "")
} else {
- data.EnableTrapsMacNotificationChange = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/mvpn")
}
- } else {
- data.EnableTrapsMacNotificationChange = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.mac-notification.move"); !data.EnableTrapsMacNotificationMove.IsNull() {
- if value.Exists() {
- data.EnableTrapsMacNotificationMove = types.BoolValue(true)
+ if !data.EnableTrapsLisp.IsNull() && !data.EnableTrapsLisp.IsUnknown() {
+ if data.EnableTrapsLisp.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/lisp", "")
} else {
- data.EnableTrapsMacNotificationMove = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/lisp")
}
- } else {
- data.EnableTrapsMacNotificationMove = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.mac-notification.threshold"); !data.EnableTrapsMacNotificationThreshold.IsNull() {
- if value.Exists() {
- data.EnableTrapsMacNotificationThreshold = types.BoolValue(true)
+ if !data.EnableTrapsAaaServer.IsNull() && !data.EnableTrapsAaaServer.IsUnknown() {
+ if data.EnableTrapsAaaServer.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/aaa_server", "")
} else {
- data.EnableTrapsMacNotificationThreshold = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/aaa_server")
}
- } else {
- data.EnableTrapsMacNotificationThreshold = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.vrfmib.vrf-up"); !data.EnableTrapsVrfmibVrfUp.IsNull() {
- if value.Exists() {
- data.EnableTrapsVrfmibVrfUp = types.BoolValue(true)
+ if !data.EnableTrapsVdsl2line.IsNull() && !data.EnableTrapsVdsl2line.IsUnknown() {
+ if data.EnableTrapsVdsl2line.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/vdsl2line", "")
} else {
- data.EnableTrapsVrfmibVrfUp = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/vdsl2line")
}
- } else {
- data.EnableTrapsVrfmibVrfUp = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.vrfmib.vrf-down"); !data.EnableTrapsVrfmibVrfDown.IsNull() {
- if value.Exists() {
- data.EnableTrapsVrfmibVrfDown = types.BoolValue(true)
+ if !data.EnableTrapsAdslline.IsNull() && !data.EnableTrapsAdslline.IsUnknown() {
+ if data.EnableTrapsAdslline.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/adslline", "")
} else {
- data.EnableTrapsVrfmibVrfDown = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/adslline")
}
- } else {
- data.EnableTrapsVrfmibVrfDown = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.vrfmib.vnet-trunk-up"); !data.EnableTrapsVrfmibVnetTrunkUp.IsNull() {
- if value.Exists() {
- data.EnableTrapsVrfmibVnetTrunkUp = types.BoolValue(true)
+ if !data.EnableTrapsPki.IsNull() && !data.EnableTrapsPki.IsUnknown() {
+ if data.EnableTrapsPki.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/pki", "")
} else {
- data.EnableTrapsVrfmibVnetTrunkUp = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/pki")
}
- } else {
- data.EnableTrapsVrfmibVnetTrunkUp = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.vrfmib.vnet-trunk-down"); !data.EnableTrapsVrfmibVnetTrunkDown.IsNull() {
- if value.Exists() {
- data.EnableTrapsVrfmibVnetTrunkDown = types.BoolValue(true)
+ if !data.EnableTrapsAlarmType.IsNull() && !data.EnableTrapsAlarmType.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/alarms/alarm-type", data.EnableTrapsAlarmType.ValueString())
+ }
+ if !data.EnableTrapsCasa.IsNull() && !data.EnableTrapsCasa.IsUnknown() {
+ if data.EnableTrapsCasa.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/casa", "")
} else {
- data.EnableTrapsVrfmibVnetTrunkDown = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/casa")
}
- } else {
- data.EnableTrapsVrfmibVnetTrunkDown = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.mvpn"); !data.EnableTrapsMvpn.IsNull() {
- if value.Exists() {
- data.EnableTrapsMvpn = types.BoolValue(true)
+ if !data.EnableTrapsCnpd.IsNull() && !data.EnableTrapsCnpd.IsUnknown() {
+ if data.EnableTrapsCnpd.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/cnpd", "")
} else {
- data.EnableTrapsMvpn = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/cnpd")
}
- } else {
- data.EnableTrapsMvpn = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.lisp"); !data.EnableTrapsLisp.IsNull() {
- if value.Exists() {
- data.EnableTrapsLisp = types.BoolValue(true)
+ if !data.EnableTrapsDial.IsNull() && !data.EnableTrapsDial.IsUnknown() {
+ if data.EnableTrapsDial.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/dial", "")
} else {
- data.EnableTrapsLisp = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/dial")
}
- } else {
- data.EnableTrapsLisp = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.aaa_server"); !data.EnableTrapsAaaServer.IsNull() {
- if value.Exists() {
- data.EnableTrapsAaaServer = types.BoolValue(true)
+ if !data.EnableTrapsDlsw.IsNull() && !data.EnableTrapsDlsw.IsUnknown() {
+ if data.EnableTrapsDlsw.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/dlsw", "")
} else {
- data.EnableTrapsAaaServer = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/dlsw")
}
- } else {
- data.EnableTrapsAaaServer = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.vdsl2line"); !data.EnableTrapsVdsl2line.IsNull() {
- if value.Exists() {
- data.EnableTrapsVdsl2line = types.BoolValue(true)
+ if !data.EnableTrapsDs1.IsNull() && !data.EnableTrapsDs1.IsUnknown() {
+ if data.EnableTrapsDs1.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ds1", "")
} else {
- data.EnableTrapsVdsl2line = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ds1")
}
- } else {
- data.EnableTrapsVdsl2line = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.adslline"); !data.EnableTrapsAdslline.IsNull() {
- if value.Exists() {
- data.EnableTrapsAdslline = types.BoolValue(true)
+ if !data.EnableTrapsDspCardStatus.IsNull() && !data.EnableTrapsDspCardStatus.IsUnknown() {
+ if data.EnableTrapsDspCardStatus.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/dsp/card-status", "")
} else {
- data.EnableTrapsAdslline = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/dsp/card-status")
}
- } else {
- data.EnableTrapsAdslline = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.pki"); !data.EnableTrapsPki.IsNull() {
- if value.Exists() {
- data.EnableTrapsPki = types.BoolValue(true)
+ if !data.EnableTrapsDspOperState.IsNull() && !data.EnableTrapsDspOperState.IsUnknown() {
+ if data.EnableTrapsDspOperState.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/dsp/oper-state", "")
} else {
- data.EnableTrapsPki = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/dsp/oper-state")
}
- } else {
- data.EnableTrapsPki = types.BoolNull()
- }
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.alarms.alarm-type"); value.Exists() && !data.EnableTrapsAlarmType.IsNull() {
- data.EnableTrapsAlarmType = types.StringValue(value.String())
- } else {
- data.EnableTrapsAlarmType = types.StringNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.casa"); !data.EnableTrapsCasa.IsNull() {
- if value.Exists() {
- data.EnableTrapsCasa = types.BoolValue(true)
+ if !data.EnableTrapsEntitySensor.IsNull() && !data.EnableTrapsEntitySensor.IsUnknown() {
+ if data.EnableTrapsEntitySensor.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/entity-sensor", "")
} else {
- data.EnableTrapsCasa = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/entity-sensor")
}
- } else {
- data.EnableTrapsCasa = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.cnpd"); !data.EnableTrapsCnpd.IsNull() {
- if value.Exists() {
- data.EnableTrapsCnpd = types.BoolValue(true)
+ if !data.EnableTrapsEntityState.IsNull() && !data.EnableTrapsEntityState.IsUnknown() {
+ if data.EnableTrapsEntityState.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/entity-state", "")
} else {
- data.EnableTrapsCnpd = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/entity-state")
}
- } else {
- data.EnableTrapsCnpd = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.dial"); !data.EnableTrapsDial.IsNull() {
- if value.Exists() {
- data.EnableTrapsDial = types.BoolValue(true)
+ if !data.EnableTrapsEntityQfpMemResThresh.IsNull() && !data.EnableTrapsEntityQfpMemResThresh.IsUnknown() {
+ if data.EnableTrapsEntityQfpMemResThresh.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/entity-qfp/mem-res-thresh", "")
} else {
- data.EnableTrapsDial = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/entity-qfp/mem-res-thresh")
}
- } else {
- data.EnableTrapsDial = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.dlsw"); !data.EnableTrapsDlsw.IsNull() {
- if value.Exists() {
- data.EnableTrapsDlsw = types.BoolValue(true)
+ if !data.EnableTrapsEntityQfpThroughputNotif.IsNull() && !data.EnableTrapsEntityQfpThroughputNotif.IsUnknown() {
+ if data.EnableTrapsEntityQfpThroughputNotif.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/entity-qfp/throughput-notif", "")
} else {
- data.EnableTrapsDlsw = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/entity-qfp/throughput-notif")
}
- } else {
- data.EnableTrapsDlsw = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ds1"); !data.EnableTrapsDs1.IsNull() {
- if value.Exists() {
- data.EnableTrapsDs1 = types.BoolValue(true)
+ if !data.EnableTrapsEtherOam.IsNull() && !data.EnableTrapsEtherOam.IsUnknown() {
+ if data.EnableTrapsEtherOam.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ether-oam", "")
} else {
- data.EnableTrapsDs1 = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ether-oam")
}
- } else {
- data.EnableTrapsDs1 = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.dsp.card-status"); !data.EnableTrapsDspCardStatus.IsNull() {
- if value.Exists() {
- data.EnableTrapsDspCardStatus = types.BoolValue(true)
+ if !data.EnableTrapsEthernetCfmAlarm.IsNull() && !data.EnableTrapsEthernetCfmAlarm.IsUnknown() {
+ if data.EnableTrapsEthernetCfmAlarm.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ethernet/cfm/alarm", "")
} else {
- data.EnableTrapsDspCardStatus = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ethernet/cfm/alarm")
}
- } else {
- data.EnableTrapsDspCardStatus = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.dsp.oper-state"); !data.EnableTrapsDspOperState.IsNull() {
- if value.Exists() {
- data.EnableTrapsDspOperState = types.BoolValue(true)
+ if !data.EnableTrapsEthernetCfmCcConfig.IsNull() && !data.EnableTrapsEthernetCfmCcConfig.IsUnknown() {
+ if data.EnableTrapsEthernetCfmCcConfig.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ethernet/cfm/cc/config", "")
} else {
- data.EnableTrapsDspOperState = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ethernet/cfm/cc/config")
}
- } else {
- data.EnableTrapsDspOperState = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.entity-sensor"); !data.EnableTrapsEntitySensor.IsNull() {
- if value.Exists() {
- data.EnableTrapsEntitySensor = types.BoolValue(true)
+ if !data.EnableTrapsEthernetCfmCcCrossConnect.IsNull() && !data.EnableTrapsEthernetCfmCcCrossConnect.IsUnknown() {
+ if data.EnableTrapsEthernetCfmCcCrossConnect.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ethernet/cfm/cc/cross-connect", "")
} else {
- data.EnableTrapsEntitySensor = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ethernet/cfm/cc/cross-connect")
}
- } else {
- data.EnableTrapsEntitySensor = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.entity-state"); !data.EnableTrapsEntityState.IsNull() {
- if value.Exists() {
- data.EnableTrapsEntityState = types.BoolValue(true)
+ if !data.EnableTrapsEthernetCfmCcLoop.IsNull() && !data.EnableTrapsEthernetCfmCcLoop.IsUnknown() {
+ if data.EnableTrapsEthernetCfmCcLoop.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ethernet/cfm/cc/loop", "")
} else {
- data.EnableTrapsEntityState = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ethernet/cfm/cc/loop")
}
- } else {
- data.EnableTrapsEntityState = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.entity-qfp.mem-res-thresh"); !data.EnableTrapsEntityQfpMemResThresh.IsNull() {
- if value.Exists() {
- data.EnableTrapsEntityQfpMemResThresh = types.BoolValue(true)
+ if !data.EnableTrapsEthernetCfmCcMepDown.IsNull() && !data.EnableTrapsEthernetCfmCcMepDown.IsUnknown() {
+ if data.EnableTrapsEthernetCfmCcMepDown.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ethernet/cfm/cc/mep-down", "")
} else {
- data.EnableTrapsEntityQfpMemResThresh = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ethernet/cfm/cc/mep-down")
}
- } else {
- data.EnableTrapsEntityQfpMemResThresh = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.entity-qfp.throughput-notif"); !data.EnableTrapsEntityQfpThroughputNotif.IsNull() {
- if value.Exists() {
- data.EnableTrapsEntityQfpThroughputNotif = types.BoolValue(true)
+ if !data.EnableTrapsEthernetCfmCcMepUp.IsNull() && !data.EnableTrapsEthernetCfmCcMepUp.IsUnknown() {
+ if data.EnableTrapsEthernetCfmCcMepUp.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ethernet/cfm/cc/mep-up", "")
} else {
- data.EnableTrapsEntityQfpThroughputNotif = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ethernet/cfm/cc/mep-up")
}
- } else {
- data.EnableTrapsEntityQfpThroughputNotif = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ether-oam"); !data.EnableTrapsEtherOam.IsNull() {
- if value.Exists() {
- data.EnableTrapsEtherOam = types.BoolValue(true)
+ if !data.EnableTrapsEthernetCfmCrosscheckMepMissing.IsNull() && !data.EnableTrapsEthernetCfmCrosscheckMepMissing.IsUnknown() {
+ if data.EnableTrapsEthernetCfmCrosscheckMepMissing.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ethernet/cfm/crosscheck/mep-missing", "")
} else {
- data.EnableTrapsEtherOam = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ethernet/cfm/crosscheck/mep-missing")
}
- } else {
- data.EnableTrapsEtherOam = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ethernet.cfm.alarm"); !data.EnableTrapsEthernetCfmAlarm.IsNull() {
- if value.Exists() {
- data.EnableTrapsEthernetCfmAlarm = types.BoolValue(true)
+ if !data.EnableTrapsEthernetCfmCrosscheckMepUnknown.IsNull() && !data.EnableTrapsEthernetCfmCrosscheckMepUnknown.IsUnknown() {
+ if data.EnableTrapsEthernetCfmCrosscheckMepUnknown.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ethernet/cfm/crosscheck/mep-unknown", "")
} else {
- data.EnableTrapsEthernetCfmAlarm = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ethernet/cfm/crosscheck/mep-unknown")
}
- } else {
- data.EnableTrapsEthernetCfmAlarm = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ethernet.cfm.cc.config"); !data.EnableTrapsEthernetCfmCcConfig.IsNull() {
- if value.Exists() {
- data.EnableTrapsEthernetCfmCcConfig = types.BoolValue(true)
+ if !data.EnableTrapsEthernetCfmCrosscheckServiceUp.IsNull() && !data.EnableTrapsEthernetCfmCrosscheckServiceUp.IsUnknown() {
+ if data.EnableTrapsEthernetCfmCrosscheckServiceUp.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ethernet/cfm/crosscheck/service-up", "")
} else {
- data.EnableTrapsEthernetCfmCcConfig = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ethernet/cfm/crosscheck/service-up")
}
- } else {
- data.EnableTrapsEthernetCfmCcConfig = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ethernet.cfm.cc.cross-connect"); !data.EnableTrapsEthernetCfmCcCrossConnect.IsNull() {
- if value.Exists() {
- data.EnableTrapsEthernetCfmCcCrossConnect = types.BoolValue(true)
+ if !data.EnableTrapsEthernetEvcCreate.IsNull() && !data.EnableTrapsEthernetEvcCreate.IsUnknown() {
+ if data.EnableTrapsEthernetEvcCreate.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ethernet/evc/create", "")
} else {
- data.EnableTrapsEthernetCfmCcCrossConnect = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ethernet/evc/create")
}
- } else {
- data.EnableTrapsEthernetCfmCcCrossConnect = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ethernet.cfm.cc.loop"); !data.EnableTrapsEthernetCfmCcLoop.IsNull() {
- if value.Exists() {
- data.EnableTrapsEthernetCfmCcLoop = types.BoolValue(true)
+ if !data.EnableTrapsEthernetEvcDelete.IsNull() && !data.EnableTrapsEthernetEvcDelete.IsUnknown() {
+ if data.EnableTrapsEthernetEvcDelete.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ethernet/evc/delete", "")
} else {
- data.EnableTrapsEthernetCfmCcLoop = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ethernet/evc/delete")
}
- } else {
- data.EnableTrapsEthernetCfmCcLoop = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ethernet.cfm.cc.mep-down"); !data.EnableTrapsEthernetCfmCcMepDown.IsNull() {
- if value.Exists() {
- data.EnableTrapsEthernetCfmCcMepDown = types.BoolValue(true)
+ if !data.EnableTrapsEthernetEvcStatus.IsNull() && !data.EnableTrapsEthernetEvcStatus.IsUnknown() {
+ if data.EnableTrapsEthernetEvcStatus.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ethernet/evc/status", "")
} else {
- data.EnableTrapsEthernetCfmCcMepDown = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ethernet/evc/status")
}
- } else {
- data.EnableTrapsEthernetCfmCcMepDown = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ethernet.cfm.cc.mep-up"); !data.EnableTrapsEthernetCfmCcMepUp.IsNull() {
- if value.Exists() {
- data.EnableTrapsEthernetCfmCcMepUp = types.BoolValue(true)
+ if !data.EnableTrapsFirewallServerstatus.IsNull() && !data.EnableTrapsFirewallServerstatus.IsUnknown() {
+ if data.EnableTrapsFirewallServerstatus.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/firewall/serverstatus", "")
} else {
- data.EnableTrapsEthernetCfmCcMepUp = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/firewall/serverstatus")
}
- } else {
- data.EnableTrapsEthernetCfmCcMepUp = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ethernet.cfm.crosscheck.mep-missing"); !data.EnableTrapsEthernetCfmCrosscheckMepMissing.IsNull() {
- if value.Exists() {
- data.EnableTrapsEthernetCfmCrosscheckMepMissing = types.BoolValue(true)
+ if !data.EnableTrapsFrameRelayConfigOnly.IsNull() && !data.EnableTrapsFrameRelayConfigOnly.IsUnknown() {
+ if data.EnableTrapsFrameRelayConfigOnly.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/frame-relay-config/only-frame-relay/frame-relay", "")
} else {
- data.EnableTrapsEthernetCfmCrosscheckMepMissing = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/frame-relay-config/only-frame-relay/frame-relay")
}
- } else {
- data.EnableTrapsEthernetCfmCrosscheckMepMissing = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ethernet.cfm.crosscheck.mep-unknown"); !data.EnableTrapsEthernetCfmCrosscheckMepUnknown.IsNull() {
- if value.Exists() {
- data.EnableTrapsEthernetCfmCrosscheckMepUnknown = types.BoolValue(true)
+ if !data.EnableTrapsFrameRelayConfigSubifConfigs.IsNull() && !data.EnableTrapsFrameRelayConfigSubifConfigs.IsUnknown() {
+ if data.EnableTrapsFrameRelayConfigSubifConfigs.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/frame-relay-config/frame-relay-options/frame-relay/subif-configs/subif", "")
} else {
- data.EnableTrapsEthernetCfmCrosscheckMepUnknown = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/frame-relay-config/frame-relay-options/frame-relay/subif-configs/subif")
}
- } else {
- data.EnableTrapsEthernetCfmCrosscheckMepUnknown = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ethernet.cfm.crosscheck.service-up"); !data.EnableTrapsEthernetCfmCrosscheckServiceUp.IsNull() {
- if value.Exists() {
- data.EnableTrapsEthernetCfmCrosscheckServiceUp = types.BoolValue(true)
+ if !data.EnableTrapsFrameRelaySubifCount.IsNull() && !data.EnableTrapsFrameRelaySubifCount.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/frame-relay/subif/count", strconv.FormatInt(data.EnableTrapsFrameRelaySubifCount.ValueInt64(), 10))
+ }
+ if !data.EnableTrapsFrameRelaySubifInterval.IsNull() && !data.EnableTrapsFrameRelaySubifInterval.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/frame-relay/subif/interval", strconv.FormatInt(data.EnableTrapsFrameRelaySubifInterval.ValueInt64(), 10))
+ }
+ if !data.EnableTrapsFrameRelayConfigBundleMismatch.IsNull() && !data.EnableTrapsFrameRelayConfigBundleMismatch.IsUnknown() {
+ if data.EnableTrapsFrameRelayConfigBundleMismatch.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/frame-relay-config/frame-relay-options/frame-relay/multilink/bundle-mismatch", "")
} else {
- data.EnableTrapsEthernetCfmCrosscheckServiceUp = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/frame-relay-config/frame-relay-options/frame-relay/multilink/bundle-mismatch")
}
- } else {
- data.EnableTrapsEthernetCfmCrosscheckServiceUp = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ethernet.evc.create"); !data.EnableTrapsEthernetEvcCreate.IsNull() {
- if value.Exists() {
- data.EnableTrapsEthernetEvcCreate = types.BoolValue(true)
+ if !data.EnableTrapsFrameRelayMultilinkBundleMismatch.IsNull() && !data.EnableTrapsFrameRelayMultilinkBundleMismatch.IsUnknown() {
+ if data.EnableTrapsFrameRelayMultilinkBundleMismatch.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/frame-relay/multilink/bundle-mismatch", "")
} else {
- data.EnableTrapsEthernetEvcCreate = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/frame-relay/multilink/bundle-mismatch")
}
- } else {
- data.EnableTrapsEthernetEvcCreate = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ethernet.evc.delete"); !data.EnableTrapsEthernetEvcDelete.IsNull() {
- if value.Exists() {
- data.EnableTrapsEthernetEvcDelete = types.BoolValue(true)
+ if !data.EnableTrapsIpLocalPool.IsNull() && !data.EnableTrapsIpLocalPool.IsUnknown() {
+ if data.EnableTrapsIpLocalPool.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ip/local/pool", "")
} else {
- data.EnableTrapsEthernetEvcDelete = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ip/local/pool")
}
- } else {
- data.EnableTrapsEthernetEvcDelete = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ethernet.evc.status"); !data.EnableTrapsEthernetEvcStatus.IsNull() {
- if value.Exists() {
- data.EnableTrapsEthernetEvcStatus = types.BoolValue(true)
+ if !data.EnableTrapsIsdnCallInformation.IsNull() && !data.EnableTrapsIsdnCallInformation.IsUnknown() {
+ if data.EnableTrapsIsdnCallInformation.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/isdn/call-information", "")
} else {
- data.EnableTrapsEthernetEvcStatus = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/isdn/call-information")
}
- } else {
- data.EnableTrapsEthernetEvcStatus = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.firewall.serverstatus"); !data.EnableTrapsFirewallServerstatus.IsNull() {
- if value.Exists() {
- data.EnableTrapsFirewallServerstatus = types.BoolValue(true)
+ if !data.EnableTrapsIsdnChanNotAvail.IsNull() && !data.EnableTrapsIsdnChanNotAvail.IsUnknown() {
+ if data.EnableTrapsIsdnChanNotAvail.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/isdn/chan-not-avail", "")
} else {
- data.EnableTrapsFirewallServerstatus = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/isdn/chan-not-avail")
}
- } else {
- data.EnableTrapsFirewallServerstatus = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.frame-relay-config.only-frame-relay.frame-relay"); !data.EnableTrapsFrameRelayConfigOnly.IsNull() {
- if value.Exists() {
- data.EnableTrapsFrameRelayConfigOnly = types.BoolValue(true)
+ if !data.EnableTrapsIsdnIetf.IsNull() && !data.EnableTrapsIsdnIetf.IsUnknown() {
+ if data.EnableTrapsIsdnIetf.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/isdn/ietf", "")
} else {
- data.EnableTrapsFrameRelayConfigOnly = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/isdn/ietf")
}
- } else {
- data.EnableTrapsFrameRelayConfigOnly = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.frame-relay-config.frame-relay-options.frame-relay.subif-configs.subif"); !data.EnableTrapsFrameRelayConfigSubifConfigs.IsNull() {
- if value.Exists() {
- data.EnableTrapsFrameRelayConfigSubifConfigs = types.BoolValue(true)
+ if !data.EnableTrapsIsdnLayer2.IsNull() && !data.EnableTrapsIsdnLayer2.IsUnknown() {
+ if data.EnableTrapsIsdnLayer2.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/isdn/layer2", "")
} else {
- data.EnableTrapsFrameRelayConfigSubifConfigs = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/isdn/layer2")
}
- } else {
- data.EnableTrapsFrameRelayConfigSubifConfigs = types.BoolNull()
- }
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.frame-relay.subif.count"); value.Exists() && !data.EnableTrapsFrameRelaySubifCount.IsNull() {
- data.EnableTrapsFrameRelaySubifCount = types.Int64Value(value.Int())
- } else {
- data.EnableTrapsFrameRelaySubifCount = types.Int64Null()
- }
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.frame-relay.subif.interval"); value.Exists() && !data.EnableTrapsFrameRelaySubifInterval.IsNull() {
- data.EnableTrapsFrameRelaySubifInterval = types.Int64Value(value.Int())
- } else {
- data.EnableTrapsFrameRelaySubifInterval = types.Int64Null()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.frame-relay-config.frame-relay-options.frame-relay.multilink.bundle-mismatch"); !data.EnableTrapsFrameRelayConfigBundleMismatch.IsNull() {
- if value.Exists() {
- data.EnableTrapsFrameRelayConfigBundleMismatch = types.BoolValue(true)
+ if !data.EnableTrapsL2tunSession.IsNull() && !data.EnableTrapsL2tunSession.IsUnknown() {
+ if data.EnableTrapsL2tunSession.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/l2tun/session", "")
} else {
- data.EnableTrapsFrameRelayConfigBundleMismatch = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/l2tun/session")
}
- } else {
- data.EnableTrapsFrameRelayConfigBundleMismatch = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.frame-relay.multilink.bundle-mismatch"); !data.EnableTrapsFrameRelayMultilinkBundleMismatch.IsNull() {
- if value.Exists() {
- data.EnableTrapsFrameRelayMultilinkBundleMismatch = types.BoolValue(true)
+ if !data.EnableTrapsL2tunTunnel.IsNull() && !data.EnableTrapsL2tunTunnel.IsUnknown() {
+ if data.EnableTrapsL2tunTunnel.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/l2tun/tunnel", "")
} else {
- data.EnableTrapsFrameRelayMultilinkBundleMismatch = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/l2tun/tunnel")
}
- } else {
- data.EnableTrapsFrameRelayMultilinkBundleMismatch = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ip.local.pool"); !data.EnableTrapsIpLocalPool.IsNull() {
- if value.Exists() {
- data.EnableTrapsIpLocalPool = types.BoolValue(true)
+ if !data.EnableTrapsL2tunPseudowireStatus.IsNull() && !data.EnableTrapsL2tunPseudowireStatus.IsUnknown() {
+ if data.EnableTrapsL2tunPseudowireStatus.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/l2tun/pseudowire/status", "")
} else {
- data.EnableTrapsIpLocalPool = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/l2tun/pseudowire/status")
}
- } else {
- data.EnableTrapsIpLocalPool = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.isdn.call-information"); !data.EnableTrapsIsdnCallInformation.IsNull() {
- if value.Exists() {
- data.EnableTrapsIsdnCallInformation = types.BoolValue(true)
+ if !data.EnableTrapsPimstdmibNeighborLoss.IsNull() && !data.EnableTrapsPimstdmibNeighborLoss.IsUnknown() {
+ if data.EnableTrapsPimstdmibNeighborLoss.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/pimstdmib/neighbor-loss", "")
} else {
- data.EnableTrapsIsdnCallInformation = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/pimstdmib/neighbor-loss")
}
- } else {
- data.EnableTrapsIsdnCallInformation = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.isdn.chan-not-avail"); !data.EnableTrapsIsdnChanNotAvail.IsNull() {
- if value.Exists() {
- data.EnableTrapsIsdnChanNotAvail = types.BoolValue(true)
+ if !data.EnableTrapsPimstdmibInvalidRegister.IsNull() && !data.EnableTrapsPimstdmibInvalidRegister.IsUnknown() {
+ if data.EnableTrapsPimstdmibInvalidRegister.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/pimstdmib/invalid-register", "")
} else {
- data.EnableTrapsIsdnChanNotAvail = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/pimstdmib/invalid-register")
}
- } else {
- data.EnableTrapsIsdnChanNotAvail = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.isdn.ietf"); !data.EnableTrapsIsdnIetf.IsNull() {
- if value.Exists() {
- data.EnableTrapsIsdnIetf = types.BoolValue(true)
+ if !data.EnableTrapsPimstdmibInvalidJoinPrune.IsNull() && !data.EnableTrapsPimstdmibInvalidJoinPrune.IsUnknown() {
+ if data.EnableTrapsPimstdmibInvalidJoinPrune.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/pimstdmib/invalid-join-prune", "")
} else {
- data.EnableTrapsIsdnIetf = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/pimstdmib/invalid-join-prune")
}
- } else {
- data.EnableTrapsIsdnIetf = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.isdn.layer2"); !data.EnableTrapsIsdnLayer2.IsNull() {
- if value.Exists() {
- data.EnableTrapsIsdnLayer2 = types.BoolValue(true)
+ if !data.EnableTrapsPimstdmibRpMappingChange.IsNull() && !data.EnableTrapsPimstdmibRpMappingChange.IsUnknown() {
+ if data.EnableTrapsPimstdmibRpMappingChange.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/pimstdmib/rp-mapping-change", "")
} else {
- data.EnableTrapsIsdnLayer2 = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/pimstdmib/rp-mapping-change")
}
- } else {
- data.EnableTrapsIsdnLayer2 = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.l2tun.session"); !data.EnableTrapsL2tunSession.IsNull() {
- if value.Exists() {
- data.EnableTrapsL2tunSession = types.BoolValue(true)
+ if !data.EnableTrapsPimstdmibInterfaceElection.IsNull() && !data.EnableTrapsPimstdmibInterfaceElection.IsUnknown() {
+ if data.EnableTrapsPimstdmibInterfaceElection.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/pimstdmib/interface-election", "")
} else {
- data.EnableTrapsL2tunSession = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/pimstdmib/interface-election")
}
- } else {
- data.EnableTrapsL2tunSession = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.l2tun.tunnel"); !data.EnableTrapsL2tunTunnel.IsNull() {
- if value.Exists() {
- data.EnableTrapsL2tunTunnel = types.BoolValue(true)
+ if !data.EnableTrapsPfr.IsNull() && !data.EnableTrapsPfr.IsUnknown() {
+ if data.EnableTrapsPfr.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/pfr", "")
} else {
- data.EnableTrapsL2tunTunnel = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/pfr")
}
- } else {
- data.EnableTrapsL2tunTunnel = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.l2tun.pseudowire.status"); !data.EnableTrapsL2tunPseudowireStatus.IsNull() {
- if value.Exists() {
- data.EnableTrapsL2tunPseudowireStatus = types.BoolValue(true)
+ if !data.EnableTrapsPppoe.IsNull() && !data.EnableTrapsPppoe.IsUnknown() {
+ if data.EnableTrapsPppoe.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/pppoe", "")
} else {
- data.EnableTrapsL2tunPseudowireStatus = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/pppoe")
}
- } else {
- data.EnableTrapsL2tunPseudowireStatus = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.pimstdmib.neighbor-loss"); !data.EnableTrapsPimstdmibNeighborLoss.IsNull() {
- if value.Exists() {
- data.EnableTrapsPimstdmibNeighborLoss = types.BoolValue(true)
+ if !data.EnableTrapsResourcePolicy.IsNull() && !data.EnableTrapsResourcePolicy.IsUnknown() {
+ if data.EnableTrapsResourcePolicy.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/resource-policy", "")
} else {
- data.EnableTrapsPimstdmibNeighborLoss = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/resource-policy")
}
- } else {
- data.EnableTrapsPimstdmibNeighborLoss = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.pimstdmib.invalid-register"); !data.EnableTrapsPimstdmibInvalidRegister.IsNull() {
- if value.Exists() {
- data.EnableTrapsPimstdmibInvalidRegister = types.BoolValue(true)
+ if !data.EnableTrapsRsvp.IsNull() && !data.EnableTrapsRsvp.IsUnknown() {
+ if data.EnableTrapsRsvp.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/rsvp", "")
} else {
- data.EnableTrapsPimstdmibInvalidRegister = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/rsvp")
}
- } else {
- data.EnableTrapsPimstdmibInvalidRegister = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.pimstdmib.invalid-join-prune"); !data.EnableTrapsPimstdmibInvalidJoinPrune.IsNull() {
- if value.Exists() {
- data.EnableTrapsPimstdmibInvalidJoinPrune = types.BoolValue(true)
+ if !data.EnableTrapsVrrp.IsNull() && !data.EnableTrapsVrrp.IsUnknown() {
+ if data.EnableTrapsVrrp.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/vrrp", "")
} else {
- data.EnableTrapsPimstdmibInvalidJoinPrune = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/vrrp")
}
- } else {
- data.EnableTrapsPimstdmibInvalidJoinPrune = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.pimstdmib.rp-mapping-change"); !data.EnableTrapsPimstdmibRpMappingChange.IsNull() {
- if value.Exists() {
- data.EnableTrapsPimstdmibRpMappingChange = types.BoolValue(true)
+ if !data.EnableTrapsSonet.IsNull() && !data.EnableTrapsSonet.IsUnknown() {
+ if data.EnableTrapsSonet.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/sonet", "")
} else {
- data.EnableTrapsPimstdmibRpMappingChange = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/sonet")
}
- } else {
- data.EnableTrapsPimstdmibRpMappingChange = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.pimstdmib.interface-election"); !data.EnableTrapsPimstdmibInterfaceElection.IsNull() {
- if value.Exists() {
- data.EnableTrapsPimstdmibInterfaceElection = types.BoolValue(true)
+ if !data.EnableTrapsSrp.IsNull() && !data.EnableTrapsSrp.IsUnknown() {
+ if data.EnableTrapsSrp.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/srp", "")
} else {
- data.EnableTrapsPimstdmibInterfaceElection = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/srp")
}
- } else {
- data.EnableTrapsPimstdmibInterfaceElection = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.pfr"); !data.EnableTrapsPfr.IsNull() {
- if value.Exists() {
- data.EnableTrapsPfr = types.BoolValue(true)
+ if !data.EnableTrapsVoice.IsNull() && !data.EnableTrapsVoice.IsUnknown() {
+ if data.EnableTrapsVoice.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/voice", "")
} else {
- data.EnableTrapsPfr = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/voice")
}
- } else {
- data.EnableTrapsPfr = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.pppoe"); !data.EnableTrapsPppoe.IsNull() {
- if value.Exists() {
- data.EnableTrapsPppoe = types.BoolValue(true)
+ if !data.EnableTrapsBgp.IsNull() && !data.EnableTrapsBgp.IsUnknown() {
+ if data.EnableTrapsBgp.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/bgp", "")
} else {
- data.EnableTrapsPppoe = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/bgp")
}
- } else {
- data.EnableTrapsPppoe = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.resource-policy"); !data.EnableTrapsResourcePolicy.IsNull() {
- if value.Exists() {
- data.EnableTrapsResourcePolicy = types.BoolValue(true)
+ if !data.EnableTrapsCbgp2.IsNull() && !data.EnableTrapsCbgp2.IsUnknown() {
+ if data.EnableTrapsCbgp2.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/bgp-traps/cbgp2", "")
} else {
- data.EnableTrapsResourcePolicy = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/bgp-traps/cbgp2")
}
- } else {
- data.EnableTrapsResourcePolicy = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.rsvp"); !data.EnableTrapsRsvp.IsNull() {
- if value.Exists() {
- data.EnableTrapsRsvp = types.BoolValue(true)
+ if !data.EnableTrapsOspfv3Errors.IsNull() && !data.EnableTrapsOspfv3Errors.IsUnknown() {
+ if data.EnableTrapsOspfv3Errors.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ospfv3/errors", "")
} else {
- data.EnableTrapsRsvp = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ospfv3/errors")
}
- } else {
- data.EnableTrapsRsvp = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.vrrp"); !data.EnableTrapsVrrp.IsNull() {
- if value.Exists() {
- data.EnableTrapsVrrp = types.BoolValue(true)
+ if !data.EnableTrapsOspfv3StateChange.IsNull() && !data.EnableTrapsOspfv3StateChange.IsUnknown() {
+ if data.EnableTrapsOspfv3StateChange.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ospfv3/state-change", "")
} else {
- data.EnableTrapsVrrp = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ospfv3/state-change")
}
- } else {
- data.EnableTrapsVrrp = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.sonet"); !data.EnableTrapsSonet.IsNull() {
- if value.Exists() {
- data.EnableTrapsSonet = types.BoolValue(true)
- } else {
- data.EnableTrapsSonet = types.BoolValue(false)
+ if !data.SourceInterfaceInformsGigabitEthernet.IsNull() && !data.SourceInterfaceInformsGigabitEthernet.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:source-interface/informs/GigabitEthernet", data.SourceInterfaceInformsGigabitEthernet.ValueString())
+ }
+ if !data.SourceInterfaceInformsTenGigabitEthernet.IsNull() && !data.SourceInterfaceInformsTenGigabitEthernet.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:source-interface/informs/TenGigabitEthernet", data.SourceInterfaceInformsTenGigabitEthernet.ValueString())
+ }
+ if !data.SourceInterfaceInformsFortyGigabitEthernet.IsNull() && !data.SourceInterfaceInformsFortyGigabitEthernet.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:source-interface/informs/FortyGigabitEthernet", data.SourceInterfaceInformsFortyGigabitEthernet.ValueString())
+ }
+ if !data.SourceInterfaceInformsHundredGigE.IsNull() && !data.SourceInterfaceInformsHundredGigE.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:source-interface/informs/HundredGigE", data.SourceInterfaceInformsHundredGigE.ValueString())
+ }
+ if !data.SourceInterfaceInformsLoopback.IsNull() && !data.SourceInterfaceInformsLoopback.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:source-interface/informs/Loopback", strconv.FormatInt(data.SourceInterfaceInformsLoopback.ValueInt64(), 10))
+ }
+ if !data.SourceInterfaceInformsPortChannel.IsNull() && !data.SourceInterfaceInformsPortChannel.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:source-interface/informs/Port-channel", strconv.FormatInt(data.SourceInterfaceInformsPortChannel.ValueInt64(), 10))
+ }
+ if !data.SourceInterfaceInformsPortChannelSubinterface.IsNull() && !data.SourceInterfaceInformsPortChannelSubinterface.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:source-interface/informs/Port-channel-subinterface/Port-channel", data.SourceInterfaceInformsPortChannelSubinterface.ValueString())
+ }
+ if !data.SourceInterfaceInformsVlan.IsNull() && !data.SourceInterfaceInformsVlan.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:source-interface/informs/Vlan", strconv.FormatInt(data.SourceInterfaceInformsVlan.ValueInt64(), 10))
+ }
+ if !data.SourceInterfaceTrapsGigabitEthernet.IsNull() && !data.SourceInterfaceTrapsGigabitEthernet.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:source-interface/traps/GigabitEthernet", data.SourceInterfaceTrapsGigabitEthernet.ValueString())
+ }
+ if !data.SourceInterfaceTrapsTenGigabitEthernet.IsNull() && !data.SourceInterfaceTrapsTenGigabitEthernet.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:source-interface/traps/TenGigabitEthernet", data.SourceInterfaceTrapsTenGigabitEthernet.ValueString())
+ }
+ if !data.SourceInterfaceTrapsFortyGigabitEthernet.IsNull() && !data.SourceInterfaceTrapsFortyGigabitEthernet.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:source-interface/traps/FortyGigabitEthernet", data.SourceInterfaceTrapsFortyGigabitEthernet.ValueString())
+ }
+ if !data.SourceInterfaceTrapsHundredGigE.IsNull() && !data.SourceInterfaceTrapsHundredGigE.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:source-interface/traps/HundredGigE", data.SourceInterfaceTrapsHundredGigE.ValueString())
+ }
+ if !data.SourceInterfaceTrapsLoopback.IsNull() && !data.SourceInterfaceTrapsLoopback.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:source-interface/traps/Loopback", strconv.FormatInt(data.SourceInterfaceTrapsLoopback.ValueInt64(), 10))
+ }
+ if !data.SourceInterfaceTrapsPortChannel.IsNull() && !data.SourceInterfaceTrapsPortChannel.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:source-interface/traps/Port-channel", strconv.FormatInt(data.SourceInterfaceTrapsPortChannel.ValueInt64(), 10))
+ }
+ if !data.SourceInterfaceTrapsPortChannelSubinterface.IsNull() && !data.SourceInterfaceTrapsPortChannelSubinterface.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:source-interface/traps/Port-channel-subinterface/Port-channel", data.SourceInterfaceTrapsPortChannelSubinterface.ValueString())
+ }
+ if !data.SourceInterfaceTrapsVlan.IsNull() && !data.SourceInterfaceTrapsVlan.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:source-interface/traps/Vlan", strconv.FormatInt(data.SourceInterfaceTrapsVlan.ValueInt64(), 10))
+ }
+ if !data.TrapSourceGigabitEthernet.IsNull() && !data.TrapSourceGigabitEthernet.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:trap-source/GigabitEthernet", data.TrapSourceGigabitEthernet.ValueString())
+ }
+ if !data.TrapSourceTenGigabitEthernet.IsNull() && !data.TrapSourceTenGigabitEthernet.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:trap-source/TenGigabitEthernet", data.TrapSourceTenGigabitEthernet.ValueString())
+ }
+ if !data.TrapSourceFortyGigabitEthernet.IsNull() && !data.TrapSourceFortyGigabitEthernet.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:trap-source/FortyGigabitEthernet", data.TrapSourceFortyGigabitEthernet.ValueString())
+ }
+ if !data.TrapSourceHundredGigE.IsNull() && !data.TrapSourceHundredGigE.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:trap-source/HundredGigE", data.TrapSourceHundredGigE.ValueString())
+ }
+ if !data.TrapSourceLoopback.IsNull() && !data.TrapSourceLoopback.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:trap-source/Loopback", strconv.FormatInt(data.TrapSourceLoopback.ValueInt64(), 10))
+ }
+ if !data.TrapSourcePortChannel.IsNull() && !data.TrapSourcePortChannel.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:trap-source/Port-channel", strconv.FormatInt(data.TrapSourcePortChannel.ValueInt64(), 10))
+ }
+ if !data.TrapSourcePortChannelSubinterface.IsNull() && !data.TrapSourcePortChannelSubinterface.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:trap-source/Port-channel-subinterface/Port-channel", data.TrapSourcePortChannelSubinterface.ValueString())
+ }
+ if !data.TrapSourceVlan.IsNull() && !data.TrapSourceVlan.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:trap-source/Vlan", strconv.FormatInt(data.TrapSourceVlan.ValueInt64(), 10))
+ }
+ if len(data.SnmpCommunities) > 0 {
+ for _, item := range data.SnmpCommunities {
+ cBody := netconf.Body{}
+ if !item.Name.IsNull() && !item.Name.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "name", item.Name.ValueString())
+ }
+ if !item.View.IsNull() && !item.View.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "view", item.View.ValueString())
+ }
+ if !item.Permission.IsNull() && !item.Permission.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "permission", item.Permission.ValueString())
+ }
+ if !item.Ipv6.IsNull() && !item.Ipv6.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "ipv6", item.Ipv6.ValueString())
+ }
+ if !item.AccessListName.IsNull() && !item.AccessListName.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "access-list-name", item.AccessListName.ValueString())
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:community-config", cBody.Res())
+ }
+ }
+ if len(data.Contexts) > 0 {
+ for _, item := range data.Contexts {
+ cBody := netconf.Body{}
+ if !item.Name.IsNull() && !item.Name.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "name", item.Name.ValueString())
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:context", cBody.Res())
+ }
+ }
+ if len(data.Views) > 0 {
+ for _, item := range data.Views {
+ cBody := netconf.Body{}
+ if !item.Name.IsNull() && !item.Name.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "name", item.Name.ValueString())
+ }
+ if !item.Mib.IsNull() && !item.Mib.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "mib", item.Mib.ValueString())
+ }
+ if !item.IncExl.IsNull() && !item.IncExl.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "inc-exl", item.IncExl.ValueString())
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:view", cBody.Res())
+ }
+ }
+ if len(data.Groups) > 0 {
+ for _, item := range data.Groups {
+ cBody := netconf.Body{}
+ if !item.Name.IsNull() && !item.Name.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "id", item.Name.ValueString())
+ }
+ if len(item.V3Security) > 0 {
+ for _, citem := range item.V3Security {
+ ccBody := netconf.Body{}
+ if !citem.SecurityLevel.IsNull() && !citem.SecurityLevel.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "security-level", citem.SecurityLevel.ValueString())
+ }
+ if !citem.ContextNode.IsNull() && !citem.ContextNode.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "context-node", citem.ContextNode.ValueString())
+ }
+ if !citem.MatchNode.IsNull() && !citem.MatchNode.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "match-node", citem.MatchNode.ValueString())
+ }
+ if !citem.ReadNode.IsNull() && !citem.ReadNode.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "read-node", citem.ReadNode.ValueString())
+ }
+ if !citem.WriteNode.IsNull() && !citem.WriteNode.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "write-node", citem.WriteNode.ValueString())
+ }
+ if !citem.NotifyNode.IsNull() && !citem.NotifyNode.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "notify-node", citem.NotifyNode.ValueString())
+ }
+ if !citem.AccessIpv6Acl.IsNull() && !citem.AccessIpv6Acl.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "access-config/ipv6-acl", citem.AccessIpv6Acl.ValueString())
+ }
+ if !citem.AccessStandardAcl.IsNull() && !citem.AccessStandardAcl.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "access-config/standard-acl", strconv.FormatInt(citem.AccessStandardAcl.ValueInt64(), 10))
+ }
+ if !citem.AccessAclName.IsNull() && !citem.AccessAclName.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "access-config/acl-name", citem.AccessAclName.ValueString())
+ }
+ cBody = helpers.SetRawFromXPath(cBody, "v3/security-level-list", ccBody.Res())
+ }
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:group", cBody.Res())
+ }
+ }
+ if len(data.Users) > 0 {
+ for _, item := range data.Users {
+ cBody := netconf.Body{}
+ if !item.Username.IsNull() && !item.Username.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "username", item.Username.ValueString())
+ }
+ if !item.Grpname.IsNull() && !item.Grpname.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "grpname", item.Grpname.ValueString())
+ }
+ if !item.V3AuthAlgorithm.IsNull() && !item.V3AuthAlgorithm.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "v3/auth-config/algorithm", item.V3AuthAlgorithm.ValueString())
+ }
+ if !item.V3AuthPassword.IsNull() && !item.V3AuthPassword.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "v3/auth-config/password", item.V3AuthPassword.ValueString())
+ }
+ if !item.V3AuthPrivAesAlgorithm.IsNull() && !item.V3AuthPrivAesAlgorithm.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "v3/auth-config/priv-config/aes/algorithm", item.V3AuthPrivAesAlgorithm.ValueString())
+ }
+ if !item.V3AuthPrivAesPassword.IsNull() && !item.V3AuthPrivAesPassword.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "v3/auth-config/priv-config/aes/password", item.V3AuthPrivAesPassword.ValueString())
+ }
+ if !item.V3AuthPrivAesAccessIpv6Acl.IsNull() && !item.V3AuthPrivAesAccessIpv6Acl.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "v3/auth-config/priv-config/aes/access-config/ipv6-acl", item.V3AuthPrivAesAccessIpv6Acl.ValueString())
+ }
+ if !item.V3AuthPrivAesAccessStandardAcl.IsNull() && !item.V3AuthPrivAesAccessStandardAcl.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "v3/auth-config/priv-config/aes/access-config/standard-acl", strconv.FormatInt(item.V3AuthPrivAesAccessStandardAcl.ValueInt64(), 10))
+ }
+ if !item.V3AuthPrivAesAccessAclName.IsNull() && !item.V3AuthPrivAesAccessAclName.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "v3/auth-config/priv-config/aes/access-config/acl-name", item.V3AuthPrivAesAccessAclName.ValueString())
+ }
+ if !item.V3AuthPrivDesPassword.IsNull() && !item.V3AuthPrivDesPassword.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "v3/auth-config/priv-config/des/password", item.V3AuthPrivDesPassword.ValueString())
+ }
+ if !item.V3AuthPrivDesAccessIpv6Acl.IsNull() && !item.V3AuthPrivDesAccessIpv6Acl.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "v3/auth-config/priv-config/des/access-config/ipv6-acl", item.V3AuthPrivDesAccessIpv6Acl.ValueString())
+ }
+ if !item.V3AuthPrivDesAccessStandardAcl.IsNull() && !item.V3AuthPrivDesAccessStandardAcl.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "v3/auth-config/priv-config/des/access-config/standard-acl", strconv.FormatInt(item.V3AuthPrivDesAccessStandardAcl.ValueInt64(), 10))
+ }
+ if !item.V3AuthPrivDesAccessAclName.IsNull() && !item.V3AuthPrivDesAccessAclName.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "v3/auth-config/priv-config/des/access-config/acl-name", item.V3AuthPrivDesAccessAclName.ValueString())
+ }
+ if !item.V3AuthPrivDes3Password.IsNull() && !item.V3AuthPrivDes3Password.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "v3/auth-config/priv-config/des3/password", item.V3AuthPrivDes3Password.ValueString())
+ }
+ if !item.V3AuthPrivDes3AccessIpv6Acl.IsNull() && !item.V3AuthPrivDes3AccessIpv6Acl.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "v3/auth-config/priv-config/des3/access-config/ipv6-acl", item.V3AuthPrivDes3AccessIpv6Acl.ValueString())
+ }
+ if !item.V3AuthPrivDes3AccessStandardAcl.IsNull() && !item.V3AuthPrivDes3AccessStandardAcl.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "v3/auth-config/priv-config/des3/access-config/standard-acl", strconv.FormatInt(item.V3AuthPrivDes3AccessStandardAcl.ValueInt64(), 10))
+ }
+ if !item.V3AuthPrivDes3AccessAclName.IsNull() && !item.V3AuthPrivDes3AccessAclName.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "v3/auth-config/priv-config/des3/access-config/acl-name", item.V3AuthPrivDes3AccessAclName.ValueString())
+ }
+ if !item.V3AuthAccessIpv6Acl.IsNull() && !item.V3AuthAccessIpv6Acl.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "v3/auth-config/access-config/ipv6-acl", item.V3AuthAccessIpv6Acl.ValueString())
+ }
+ if !item.V3AuthAccessStandardAcl.IsNull() && !item.V3AuthAccessStandardAcl.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "v3/auth-config/access-config/standard-acl", strconv.FormatInt(item.V3AuthAccessStandardAcl.ValueInt64(), 10))
+ }
+ if !item.V3AuthAccessAclName.IsNull() && !item.V3AuthAccessAclName.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "v3/auth-config/access-config/acl-name", item.V3AuthAccessAclName.ValueString())
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-snmp:user/names", cBody.Res())
}
+ }
+ bodyString, err := body.String()
+ if err != nil {
+ tflog.Error(ctx, fmt.Sprintf("Error converting body to string: %s", err))
+ }
+ return bodyString
+}
+
+// End of section. //template:end toBodyXML
+
+// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBody
+
+func (data *SNMPServer) updateFromBody(ctx context.Context, res gjson.Result) {
+ prefix := helpers.LastElement(data.getPath()) + "."
+ if res.Get(helpers.LastElement(data.getPath())).IsArray() {
+ prefix += "0."
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:chassis-id"); value.Exists() && !data.ChassisId.IsNull() {
+ data.ChassisId = types.StringValue(value.String())
} else {
- data.EnableTrapsSonet = types.BoolNull()
+ data.ChassisId = types.StringNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.srp"); !data.EnableTrapsSrp.IsNull() {
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:contact"); value.Exists() && !data.Contact.IsNull() {
+ data.Contact = types.StringValue(value.String())
+ } else {
+ data.Contact = types.StringNull()
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:ifindex.persist"); !data.IfindexPersist.IsNull() {
if value.Exists() {
- data.EnableTrapsSrp = types.BoolValue(true)
+ data.IfindexPersist = types.BoolValue(true)
} else {
- data.EnableTrapsSrp = types.BoolValue(false)
+ data.IfindexPersist = types.BoolValue(false)
}
} else {
- data.EnableTrapsSrp = types.BoolNull()
+ data.IfindexPersist = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.voice"); !data.EnableTrapsVoice.IsNull() {
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:location"); value.Exists() && !data.Location.IsNull() {
+ data.Location = types.StringValue(value.String())
+ } else {
+ data.Location = types.StringNull()
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:packetsize"); value.Exists() && !data.Packetsize.IsNull() {
+ data.Packetsize = types.Int64Value(value.Int())
+ } else {
+ data.Packetsize = types.Int64Null()
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:queue-length"); value.Exists() && !data.QueueLength.IsNull() {
+ data.QueueLength = types.Int64Value(value.Int())
+ } else {
+ data.QueueLength = types.Int64Null()
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.logging.getop"); !data.EnableLoggingGetop.IsNull() {
if value.Exists() {
- data.EnableTrapsVoice = types.BoolValue(true)
- } else {
- data.EnableTrapsVoice = types.BoolValue(false)
+ data.EnableLoggingGetop = types.BoolValue(value.Bool())
}
} else {
- data.EnableTrapsVoice = types.BoolNull()
+ data.EnableLoggingGetop = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.bgp"); !data.EnableTrapsBgp.IsNull() {
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.logging.setop"); !data.EnableLoggingSetop.IsNull() {
if value.Exists() {
- data.EnableTrapsBgp = types.BoolValue(true)
- } else {
- data.EnableTrapsBgp = types.BoolValue(false)
+ data.EnableLoggingSetop = types.BoolValue(value.Bool())
}
} else {
- data.EnableTrapsBgp = types.BoolNull()
+ data.EnableLoggingSetop = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.bgp-traps.cbgp2"); !data.EnableTrapsCbgp2.IsNull() {
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.informs"); !data.EnableInforms.IsNull() {
if value.Exists() {
- data.EnableTrapsCbgp2 = types.BoolValue(true)
+ data.EnableInforms = types.BoolValue(true)
} else {
- data.EnableTrapsCbgp2 = types.BoolValue(false)
+ data.EnableInforms = types.BoolValue(false)
}
} else {
- data.EnableTrapsCbgp2 = types.BoolNull()
+ data.EnableInforms = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ospfv3.errors"); !data.EnableTrapsOspfv3Errors.IsNull() {
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps"); !data.EnableTraps.IsNull() {
if value.Exists() {
- data.EnableTrapsOspfv3Errors = types.BoolValue(true)
+ data.EnableTraps = types.BoolValue(true)
} else {
- data.EnableTrapsOspfv3Errors = types.BoolValue(false)
+ data.EnableTraps = types.BoolValue(false)
}
} else {
- data.EnableTrapsOspfv3Errors = types.BoolNull()
+ data.EnableTraps = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ospfv3.state-change"); !data.EnableTrapsOspfv3StateChange.IsNull() {
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.snmp.authentication"); !data.EnableTrapsSnmpAuthentication.IsNull() {
if value.Exists() {
- data.EnableTrapsOspfv3StateChange = types.BoolValue(true)
+ data.EnableTrapsSnmpAuthentication = types.BoolValue(true)
} else {
- data.EnableTrapsOspfv3StateChange = types.BoolValue(false)
+ data.EnableTrapsSnmpAuthentication = types.BoolValue(false)
}
} else {
- data.EnableTrapsOspfv3StateChange = types.BoolNull()
+ data.EnableTrapsSnmpAuthentication = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:source-interface.informs.GigabitEthernet"); value.Exists() && !data.SourceInterfaceInformsGigabitEthernet.IsNull() {
- data.SourceInterfaceInformsGigabitEthernet = types.StringValue(value.String())
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.snmp.coldstart"); !data.EnableTrapsSnmpColdstart.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsSnmpColdstart = types.BoolValue(true)
+ } else {
+ data.EnableTrapsSnmpColdstart = types.BoolValue(false)
+ }
} else {
- data.SourceInterfaceInformsGigabitEthernet = types.StringNull()
+ data.EnableTrapsSnmpColdstart = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:source-interface.informs.TenGigabitEthernet"); value.Exists() && !data.SourceInterfaceInformsTenGigabitEthernet.IsNull() {
- data.SourceInterfaceInformsTenGigabitEthernet = types.StringValue(value.String())
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.snmp.linkdown"); !data.EnableTrapsSnmpLinkdown.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsSnmpLinkdown = types.BoolValue(true)
+ } else {
+ data.EnableTrapsSnmpLinkdown = types.BoolValue(false)
+ }
} else {
- data.SourceInterfaceInformsTenGigabitEthernet = types.StringNull()
+ data.EnableTrapsSnmpLinkdown = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:source-interface.informs.FortyGigabitEthernet"); value.Exists() && !data.SourceInterfaceInformsFortyGigabitEthernet.IsNull() {
- data.SourceInterfaceInformsFortyGigabitEthernet = types.StringValue(value.String())
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.snmp.linkup"); !data.EnableTrapsSnmpLinkup.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsSnmpLinkup = types.BoolValue(true)
+ } else {
+ data.EnableTrapsSnmpLinkup = types.BoolValue(false)
+ }
} else {
- data.SourceInterfaceInformsFortyGigabitEthernet = types.StringNull()
- }
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:source-interface.informs.HundredGigE"); value.Exists() && !data.SourceInterfaceInformsHundredGigE.IsNull() {
- data.SourceInterfaceInformsHundredGigE = types.StringValue(value.String())
- } else {
- data.SourceInterfaceInformsHundredGigE = types.StringNull()
- }
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:source-interface.informs.Loopback"); value.Exists() && !data.SourceInterfaceInformsLoopback.IsNull() {
- data.SourceInterfaceInformsLoopback = types.Int64Value(value.Int())
- } else {
- data.SourceInterfaceInformsLoopback = types.Int64Null()
- }
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:source-interface.informs.Port-channel"); value.Exists() && !data.SourceInterfaceInformsPortChannel.IsNull() {
- data.SourceInterfaceInformsPortChannel = types.Int64Value(value.Int())
- } else {
- data.SourceInterfaceInformsPortChannel = types.Int64Null()
- }
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:source-interface.informs.Port-channel-subinterface.Port-channel"); value.Exists() && !data.SourceInterfaceInformsPortChannelSubinterface.IsNull() {
- data.SourceInterfaceInformsPortChannelSubinterface = types.StringValue(value.String())
- } else {
- data.SourceInterfaceInformsPortChannelSubinterface = types.StringNull()
- }
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:source-interface.informs.Vlan"); value.Exists() && !data.SourceInterfaceInformsVlan.IsNull() {
- data.SourceInterfaceInformsVlan = types.Int64Value(value.Int())
- } else {
- data.SourceInterfaceInformsVlan = types.Int64Null()
- }
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:source-interface.traps.GigabitEthernet"); value.Exists() && !data.SourceInterfaceTrapsGigabitEthernet.IsNull() {
- data.SourceInterfaceTrapsGigabitEthernet = types.StringValue(value.String())
- } else {
- data.SourceInterfaceTrapsGigabitEthernet = types.StringNull()
- }
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:source-interface.traps.TenGigabitEthernet"); value.Exists() && !data.SourceInterfaceTrapsTenGigabitEthernet.IsNull() {
- data.SourceInterfaceTrapsTenGigabitEthernet = types.StringValue(value.String())
- } else {
- data.SourceInterfaceTrapsTenGigabitEthernet = types.StringNull()
- }
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:source-interface.traps.FortyGigabitEthernet"); value.Exists() && !data.SourceInterfaceTrapsFortyGigabitEthernet.IsNull() {
- data.SourceInterfaceTrapsFortyGigabitEthernet = types.StringValue(value.String())
- } else {
- data.SourceInterfaceTrapsFortyGigabitEthernet = types.StringNull()
- }
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:source-interface.traps.HundredGigE"); value.Exists() && !data.SourceInterfaceTrapsHundredGigE.IsNull() {
- data.SourceInterfaceTrapsHundredGigE = types.StringValue(value.String())
- } else {
- data.SourceInterfaceTrapsHundredGigE = types.StringNull()
- }
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:source-interface.traps.Loopback"); value.Exists() && !data.SourceInterfaceTrapsLoopback.IsNull() {
- data.SourceInterfaceTrapsLoopback = types.Int64Value(value.Int())
- } else {
- data.SourceInterfaceTrapsLoopback = types.Int64Null()
- }
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:source-interface.traps.Port-channel"); value.Exists() && !data.SourceInterfaceTrapsPortChannel.IsNull() {
- data.SourceInterfaceTrapsPortChannel = types.Int64Value(value.Int())
- } else {
- data.SourceInterfaceTrapsPortChannel = types.Int64Null()
- }
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:source-interface.traps.Port-channel-subinterface.Port-channel"); value.Exists() && !data.SourceInterfaceTrapsPortChannelSubinterface.IsNull() {
- data.SourceInterfaceTrapsPortChannelSubinterface = types.StringValue(value.String())
- } else {
- data.SourceInterfaceTrapsPortChannelSubinterface = types.StringNull()
- }
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:source-interface.traps.Vlan"); value.Exists() && !data.SourceInterfaceTrapsVlan.IsNull() {
- data.SourceInterfaceTrapsVlan = types.Int64Value(value.Int())
- } else {
- data.SourceInterfaceTrapsVlan = types.Int64Null()
- }
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:trap-source.GigabitEthernet"); value.Exists() && !data.TrapSourceGigabitEthernet.IsNull() {
- data.TrapSourceGigabitEthernet = types.StringValue(value.String())
- } else {
- data.TrapSourceGigabitEthernet = types.StringNull()
- }
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:trap-source.TenGigabitEthernet"); value.Exists() && !data.TrapSourceTenGigabitEthernet.IsNull() {
- data.TrapSourceTenGigabitEthernet = types.StringValue(value.String())
- } else {
- data.TrapSourceTenGigabitEthernet = types.StringNull()
- }
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:trap-source.FortyGigabitEthernet"); value.Exists() && !data.TrapSourceFortyGigabitEthernet.IsNull() {
- data.TrapSourceFortyGigabitEthernet = types.StringValue(value.String())
- } else {
- data.TrapSourceFortyGigabitEthernet = types.StringNull()
- }
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:trap-source.HundredGigE"); value.Exists() && !data.TrapSourceHundredGigE.IsNull() {
- data.TrapSourceHundredGigE = types.StringValue(value.String())
- } else {
- data.TrapSourceHundredGigE = types.StringNull()
- }
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:trap-source.Loopback"); value.Exists() && !data.TrapSourceLoopback.IsNull() {
- data.TrapSourceLoopback = types.Int64Value(value.Int())
- } else {
- data.TrapSourceLoopback = types.Int64Null()
- }
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:trap-source.Port-channel"); value.Exists() && !data.TrapSourcePortChannel.IsNull() {
- data.TrapSourcePortChannel = types.Int64Value(value.Int())
- } else {
- data.TrapSourcePortChannel = types.Int64Null()
- }
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:trap-source.Port-channel-subinterface.Port-channel"); value.Exists() && !data.TrapSourcePortChannelSubinterface.IsNull() {
- data.TrapSourcePortChannelSubinterface = types.StringValue(value.String())
- } else {
- data.TrapSourcePortChannelSubinterface = types.StringNull()
+ data.EnableTrapsSnmpLinkup = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:trap-source.Vlan"); value.Exists() && !data.TrapSourceVlan.IsNull() {
- data.TrapSourceVlan = types.Int64Value(value.Int())
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.snmp.warmstart"); !data.EnableTrapsSnmpWarmstart.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsSnmpWarmstart = types.BoolValue(true)
+ } else {
+ data.EnableTrapsSnmpWarmstart = types.BoolValue(false)
+ }
} else {
- data.TrapSourceVlan = types.Int64Null()
+ data.EnableTrapsSnmpWarmstart = types.BoolNull()
}
- for i := range data.SnmpCommunities {
- keys := [...]string{"name"}
- keyValues := [...]string{data.SnmpCommunities[i].Name.ValueString()}
+ for i := range data.Hosts {
+ keys := [...]string{"ip-address"}
+ keyValues := [...]string{data.Hosts[i].IpAddress.ValueString()}
var r gjson.Result
- res.Get(prefix + "Cisco-IOS-XE-snmp:community-config").ForEach(
+ res.Get(prefix + "Cisco-IOS-XE-snmp:host-config.ip-community").ForEach(
func(_, v gjson.Result) bool {
found := false
for ik := range keys {
@@ -3614,33 +3435,33 @@ func (data *SNMPServer) updateFromBody(ctx context.Context, res gjson.Result) {
return true
},
)
- if value := r.Get("view"); value.Exists() && !data.SnmpCommunities[i].View.IsNull() {
- data.SnmpCommunities[i].View = types.StringValue(value.String())
+ if value := r.Get("ip-address"); value.Exists() && !data.Hosts[i].IpAddress.IsNull() {
+ data.Hosts[i].IpAddress = types.StringValue(value.String())
} else {
- data.SnmpCommunities[i].View = types.StringNull()
+ data.Hosts[i].IpAddress = types.StringNull()
}
- if value := r.Get("permission"); value.Exists() && !data.SnmpCommunities[i].Permission.IsNull() {
- data.SnmpCommunities[i].Permission = types.StringValue(value.String())
+ if value := r.Get("version"); value.Exists() && !data.Hosts[i].Version.IsNull() {
+ data.Hosts[i].Version = types.StringValue(value.String())
} else {
- data.SnmpCommunities[i].Permission = types.StringNull()
+ data.Hosts[i].Version = types.StringNull()
}
- if value := r.Get("ipv6"); value.Exists() && !data.SnmpCommunities[i].Ipv6.IsNull() {
- data.SnmpCommunities[i].Ipv6 = types.StringValue(value.String())
+ if value := r.Get("encryption"); value.Exists() && !data.Hosts[i].Encryption.IsNull() {
+ data.Hosts[i].Encryption = types.StringValue(value.String())
} else {
- data.SnmpCommunities[i].Ipv6 = types.StringNull()
+ data.Hosts[i].Encryption = types.StringNull()
}
- if value := r.Get("access-list-name"); value.Exists() && !data.SnmpCommunities[i].AccessListName.IsNull() {
- data.SnmpCommunities[i].AccessListName = types.StringValue(value.String())
+ if value := r.Get("security-level"); value.Exists() && !data.Hosts[i].SecurityLevel.IsNull() {
+ data.Hosts[i].SecurityLevel = types.StringValue(value.String())
} else {
- data.SnmpCommunities[i].AccessListName = types.StringNull()
+ data.Hosts[i].SecurityLevel = types.StringNull()
}
}
- for i := range data.Contexts {
- keys := [...]string{"name"}
- keyValues := [...]string{data.Contexts[i].Name.ValueString()}
+ for i := range data.VrfHosts {
+ keys := [...]string{"ip-address", "vrf"}
+ keyValues := [...]string{data.VrfHosts[i].IpAddress.ValueString(), data.VrfHosts[i].Vrf.ValueString()}
var r gjson.Result
- res.Get(prefix + "Cisco-IOS-XE-snmp:context").ForEach(
+ res.Get(prefix + "Cisco-IOS-XE-snmp:host-config.ip-vrf-community").ForEach(
func(_, v gjson.Result) bool {
found := false
for ik := range keys {
@@ -3658,2677 +3479,10654 @@ func (data *SNMPServer) updateFromBody(ctx context.Context, res gjson.Result) {
return true
},
)
- if value := r.Get("name"); value.Exists() && !data.Contexts[i].Name.IsNull() {
- data.Contexts[i].Name = types.StringValue(value.String())
+ if value := r.Get("ip-address"); value.Exists() && !data.VrfHosts[i].IpAddress.IsNull() {
+ data.VrfHosts[i].IpAddress = types.StringValue(value.String())
} else {
- data.Contexts[i].Name = types.StringNull()
+ data.VrfHosts[i].IpAddress = types.StringNull()
}
- }
- for i := range data.Views {
- keys := [...]string{"name", "mib"}
- keyValues := [...]string{data.Views[i].Name.ValueString(), data.Views[i].Mib.ValueString()}
-
- var r gjson.Result
- res.Get(prefix + "Cisco-IOS-XE-snmp:view").ForEach(
- func(_, v gjson.Result) bool {
- found := false
- for ik := range keys {
- if v.Get(keys[ik]).String() == keyValues[ik] {
- found = true
- continue
- }
- found = false
- break
- }
- if found {
- r = v
- return false
- }
- return true
- },
- )
- if value := r.Get("name"); value.Exists() && !data.Views[i].Name.IsNull() {
- data.Views[i].Name = types.StringValue(value.String())
+ if value := r.Get("vrf"); value.Exists() && !data.VrfHosts[i].Vrf.IsNull() {
+ data.VrfHosts[i].Vrf = types.StringValue(value.String())
} else {
- data.Views[i].Name = types.StringNull()
+ data.VrfHosts[i].Vrf = types.StringNull()
}
- if value := r.Get("mib"); value.Exists() && !data.Views[i].Mib.IsNull() {
- data.Views[i].Mib = types.StringValue(value.String())
+ if value := r.Get("version"); value.Exists() && !data.VrfHosts[i].Version.IsNull() {
+ data.VrfHosts[i].Version = types.StringValue(value.String())
} else {
- data.Views[i].Mib = types.StringNull()
+ data.VrfHosts[i].Version = types.StringNull()
}
- if value := r.Get("inc-exl"); value.Exists() && !data.Views[i].IncExl.IsNull() {
- data.Views[i].IncExl = types.StringValue(value.String())
+ if value := r.Get("encryption"); value.Exists() && !data.VrfHosts[i].Encryption.IsNull() {
+ data.VrfHosts[i].Encryption = types.StringValue(value.String())
} else {
- data.Views[i].IncExl = types.StringNull()
+ data.VrfHosts[i].Encryption = types.StringNull()
+ }
+ if value := r.Get("security-level"); value.Exists() && !data.VrfHosts[i].SecurityLevel.IsNull() {
+ data.VrfHosts[i].SecurityLevel = types.StringValue(value.String())
+ } else {
+ data.VrfHosts[i].SecurityLevel = types.StringNull()
}
}
- for i := range data.Groups {
- keys := [...]string{"id"}
- keyValues := [...]string{data.Groups[i].Name.ValueString()}
-
- var r gjson.Result
- res.Get(prefix + "Cisco-IOS-XE-snmp:group").ForEach(
- func(_, v gjson.Result) bool {
- found := false
- for ik := range keys {
- if v.Get(keys[ik]).String() == keyValues[ik] {
- found = true
- continue
- }
- found = false
- break
- }
- if found {
- r = v
- return false
- }
- return true
- },
- )
- if value := r.Get("id"); value.Exists() && !data.Groups[i].Name.IsNull() {
- data.Groups[i].Name = types.StringValue(value.String())
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:system-shutdown"); !data.SystemShutdown.IsNull() {
+ if value.Exists() {
+ data.SystemShutdown = types.BoolValue(true)
} else {
- data.Groups[i].Name = types.StringNull()
+ data.SystemShutdown = types.BoolValue(false)
}
- for ci := range data.Groups[i].V3Security {
- keys := [...]string{"security-level"}
- keyValues := [...]string{data.Groups[i].V3Security[ci].SecurityLevel.ValueString()}
-
- var cr gjson.Result
- r.Get("v3.security-level-list").ForEach(
- func(_, v gjson.Result) bool {
- found := false
- for ik := range keys {
- if v.Get(keys[ik]).String() == keyValues[ik] {
- found = true
- continue
- }
- found = false
- break
- }
- if found {
- cr = v
- return false
- }
- return true
- },
- )
- if value := cr.Get("security-level"); value.Exists() && !data.Groups[i].V3Security[ci].SecurityLevel.IsNull() {
- data.Groups[i].V3Security[ci].SecurityLevel = types.StringValue(value.String())
- } else {
- data.Groups[i].V3Security[ci].SecurityLevel = types.StringNull()
- }
- if value := cr.Get("context-node"); value.Exists() && !data.Groups[i].V3Security[ci].ContextNode.IsNull() {
- data.Groups[i].V3Security[ci].ContextNode = types.StringValue(value.String())
- } else {
- data.Groups[i].V3Security[ci].ContextNode = types.StringNull()
- }
- if value := cr.Get("match-node"); value.Exists() && !data.Groups[i].V3Security[ci].MatchNode.IsNull() {
- data.Groups[i].V3Security[ci].MatchNode = types.StringValue(value.String())
- } else {
- data.Groups[i].V3Security[ci].MatchNode = types.StringNull()
- }
- if value := cr.Get("read-node"); value.Exists() && !data.Groups[i].V3Security[ci].ReadNode.IsNull() {
- data.Groups[i].V3Security[ci].ReadNode = types.StringValue(value.String())
- } else {
- data.Groups[i].V3Security[ci].ReadNode = types.StringNull()
- }
- if value := cr.Get("write-node"); value.Exists() && !data.Groups[i].V3Security[ci].WriteNode.IsNull() {
- data.Groups[i].V3Security[ci].WriteNode = types.StringValue(value.String())
- } else {
- data.Groups[i].V3Security[ci].WriteNode = types.StringNull()
- }
- if value := cr.Get("notify-node"); value.Exists() && !data.Groups[i].V3Security[ci].NotifyNode.IsNull() {
- data.Groups[i].V3Security[ci].NotifyNode = types.StringValue(value.String())
- } else {
- data.Groups[i].V3Security[ci].NotifyNode = types.StringNull()
- }
- if value := cr.Get("access-config.ipv6-acl"); value.Exists() && !data.Groups[i].V3Security[ci].AccessIpv6Acl.IsNull() {
- data.Groups[i].V3Security[ci].AccessIpv6Acl = types.StringValue(value.String())
- } else {
- data.Groups[i].V3Security[ci].AccessIpv6Acl = types.StringNull()
- }
- if value := cr.Get("access-config.standard-acl"); value.Exists() && !data.Groups[i].V3Security[ci].AccessStandardAcl.IsNull() {
- data.Groups[i].V3Security[ci].AccessStandardAcl = types.Int64Value(value.Int())
- } else {
- data.Groups[i].V3Security[ci].AccessStandardAcl = types.Int64Null()
- }
- if value := cr.Get("access-config.acl-name"); value.Exists() && !data.Groups[i].V3Security[ci].AccessAclName.IsNull() {
- data.Groups[i].V3Security[ci].AccessAclName = types.StringValue(value.String())
- } else {
- data.Groups[i].V3Security[ci].AccessAclName = types.StringNull()
- }
+ } else {
+ data.SystemShutdown = types.BoolNull()
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.flowmon"); !data.EnableTrapsFlowmon.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsFlowmon = types.BoolValue(true)
+ } else {
+ data.EnableTrapsFlowmon = types.BoolValue(false)
}
+ } else {
+ data.EnableTrapsFlowmon = types.BoolNull()
}
- for i := range data.Users {
- keys := [...]string{"username", "grpname"}
- keyValues := [...]string{data.Users[i].Username.ValueString(), data.Users[i].Grpname.ValueString()}
-
- var r gjson.Result
- res.Get(prefix + "Cisco-IOS-XE-snmp:user.names").ForEach(
- func(_, v gjson.Result) bool {
- found := false
- for ik := range keys {
- if v.Get(keys[ik]).String() == keyValues[ik] {
- found = true
- continue
- }
- found = false
- break
- }
- if found {
- r = v
- return false
- }
- return true
- },
- )
- if value := r.Get("username"); value.Exists() && !data.Users[i].Username.IsNull() {
- data.Users[i].Username = types.StringValue(value.String())
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.entity-perf.throughput-notif"); !data.EnableTrapsEntityPerfThroughputNotif.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsEntityPerfThroughputNotif = types.BoolValue(true)
} else {
- data.Users[i].Username = types.StringNull()
+ data.EnableTrapsEntityPerfThroughputNotif = types.BoolValue(false)
}
- if value := r.Get("grpname"); value.Exists() && !data.Users[i].Grpname.IsNull() {
- data.Users[i].Grpname = types.StringValue(value.String())
+ } else {
+ data.EnableTrapsEntityPerfThroughputNotif = types.BoolNull()
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.call-home.message-send-fail"); !data.EnableTrapsCallHomeMessageSendFail.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsCallHomeMessageSendFail = types.BoolValue(true)
} else {
- data.Users[i].Grpname = types.StringNull()
+ data.EnableTrapsCallHomeMessageSendFail = types.BoolValue(false)
}
- if value := r.Get("v3.auth-config.algorithm"); value.Exists() && !data.Users[i].V3AuthAlgorithm.IsNull() {
- data.Users[i].V3AuthAlgorithm = types.StringValue(value.String())
+ } else {
+ data.EnableTrapsCallHomeMessageSendFail = types.BoolNull()
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.call-home.server-fail"); !data.EnableTrapsCallHomeServerFail.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsCallHomeServerFail = types.BoolValue(true)
} else {
- data.Users[i].V3AuthAlgorithm = types.StringNull()
+ data.EnableTrapsCallHomeServerFail = types.BoolValue(false)
}
- if value := r.Get("v3.auth-config.priv-config.aes.algorithm"); value.Exists() && !data.Users[i].V3AuthPrivAesAlgorithm.IsNull() {
- data.Users[i].V3AuthPrivAesAlgorithm = types.StringValue(value.String())
+ } else {
+ data.EnableTrapsCallHomeServerFail = types.BoolNull()
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.tty"); !data.EnableTrapsTty.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsTty = types.BoolValue(true)
} else {
- data.Users[i].V3AuthPrivAesAlgorithm = types.StringNull()
+ data.EnableTrapsTty = types.BoolValue(false)
}
- if value := r.Get("v3.auth-config.priv-config.aes.access-config.ipv6-acl"); value.Exists() && !data.Users[i].V3AuthPrivAesAccessIpv6Acl.IsNull() {
- data.Users[i].V3AuthPrivAesAccessIpv6Acl = types.StringValue(value.String())
+ } else {
+ data.EnableTrapsTty = types.BoolNull()
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.Cisco-IOS-XE-ospfv3:ospfv3-config.state-change.enable"); !data.EnableTrapsOspfv3ConfigStateChange.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsOspfv3ConfigStateChange = types.BoolValue(true)
} else {
- data.Users[i].V3AuthPrivAesAccessIpv6Acl = types.StringNull()
+ data.EnableTrapsOspfv3ConfigStateChange = types.BoolValue(false)
}
- if value := r.Get("v3.auth-config.priv-config.aes.access-config.standard-acl"); value.Exists() && !data.Users[i].V3AuthPrivAesAccessStandardAcl.IsNull() {
- data.Users[i].V3AuthPrivAesAccessStandardAcl = types.Int64Value(value.Int())
+ } else {
+ data.EnableTrapsOspfv3ConfigStateChange = types.BoolNull()
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.Cisco-IOS-XE-ospfv3:ospfv3-config.errors.enable"); !data.EnableTrapsOspfv3ConfigErrors.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsOspfv3ConfigErrors = types.BoolValue(true)
} else {
- data.Users[i].V3AuthPrivAesAccessStandardAcl = types.Int64Null()
+ data.EnableTrapsOspfv3ConfigErrors = types.BoolValue(false)
}
- if value := r.Get("v3.auth-config.priv-config.aes.access-config.acl-name"); value.Exists() && !data.Users[i].V3AuthPrivAesAccessAclName.IsNull() {
- data.Users[i].V3AuthPrivAesAccessAclName = types.StringValue(value.String())
+ } else {
+ data.EnableTrapsOspfv3ConfigErrors = types.BoolNull()
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.Cisco-IOS-XE-ospf:ospf-config.retransmit.enable"); !data.EnableTrapsOspfConfigRetransmit.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsOspfConfigRetransmit = types.BoolValue(true)
} else {
- data.Users[i].V3AuthPrivAesAccessAclName = types.StringNull()
+ data.EnableTrapsOspfConfigRetransmit = types.BoolValue(false)
}
- if value := r.Get("v3.auth-config.priv-config.des.access-config.ipv6-acl"); value.Exists() && !data.Users[i].V3AuthPrivDesAccessIpv6Acl.IsNull() {
- data.Users[i].V3AuthPrivDesAccessIpv6Acl = types.StringValue(value.String())
+ } else {
+ data.EnableTrapsOspfConfigRetransmit = types.BoolNull()
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.Cisco-IOS-XE-ospf:ospf-config.lsa.enable"); !data.EnableTrapsOspfConfigLsa.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsOspfConfigLsa = types.BoolValue(true)
} else {
- data.Users[i].V3AuthPrivDesAccessIpv6Acl = types.StringNull()
+ data.EnableTrapsOspfConfigLsa = types.BoolValue(false)
}
- if value := r.Get("v3.auth-config.priv-config.des.access-config.standard-acl"); value.Exists() && !data.Users[i].V3AuthPrivDesAccessStandardAcl.IsNull() {
- data.Users[i].V3AuthPrivDesAccessStandardAcl = types.Int64Value(value.Int())
+ } else {
+ data.EnableTrapsOspfConfigLsa = types.BoolNull()
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.Cisco-IOS-XE-ospf:ospf-config.cisco-specific.state-change.nssa-trans-change"); !data.EnableTrapsOspfNssaTransChange.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsOspfNssaTransChange = types.BoolValue(true)
} else {
- data.Users[i].V3AuthPrivDesAccessStandardAcl = types.Int64Null()
+ data.EnableTrapsOspfNssaTransChange = types.BoolValue(false)
}
- if value := r.Get("v3.auth-config.priv-config.des.access-config.acl-name"); value.Exists() && !data.Users[i].V3AuthPrivDesAccessAclName.IsNull() {
- data.Users[i].V3AuthPrivDesAccessAclName = types.StringValue(value.String())
+ } else {
+ data.EnableTrapsOspfNssaTransChange = types.BoolNull()
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.Cisco-IOS-XE-ospf:ospf-config.cisco-specific.state-change.shamlink.interface"); !data.EnableTrapsOspfShamlinkInterface.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsOspfShamlinkInterface = types.BoolValue(true)
} else {
- data.Users[i].V3AuthPrivDesAccessAclName = types.StringNull()
+ data.EnableTrapsOspfShamlinkInterface = types.BoolValue(false)
}
- if value := r.Get("v3.auth-config.priv-config.des3.access-config.ipv6-acl"); value.Exists() && !data.Users[i].V3AuthPrivDes3AccessIpv6Acl.IsNull() {
- data.Users[i].V3AuthPrivDes3AccessIpv6Acl = types.StringValue(value.String())
+ } else {
+ data.EnableTrapsOspfShamlinkInterface = types.BoolNull()
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.Cisco-IOS-XE-ospf:ospf-config.cisco-specific.state-change.shamlink.neighbor"); !data.EnableTrapsOspfShamlinkNeighbor.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsOspfShamlinkNeighbor = types.BoolValue(true)
} else {
- data.Users[i].V3AuthPrivDes3AccessIpv6Acl = types.StringNull()
+ data.EnableTrapsOspfShamlinkNeighbor = types.BoolValue(false)
}
- if value := r.Get("v3.auth-config.priv-config.des3.access-config.standard-acl"); value.Exists() && !data.Users[i].V3AuthPrivDes3AccessStandardAcl.IsNull() {
- data.Users[i].V3AuthPrivDes3AccessStandardAcl = types.Int64Value(value.Int())
+ } else {
+ data.EnableTrapsOspfShamlinkNeighbor = types.BoolNull()
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.Cisco-IOS-XE-ospf:ospf-config.cisco-specific.errors.enable"); !data.EnableTrapsOspfErrorsEnable.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsOspfErrorsEnable = types.BoolValue(true)
} else {
- data.Users[i].V3AuthPrivDes3AccessStandardAcl = types.Int64Null()
+ data.EnableTrapsOspfErrorsEnable = types.BoolValue(false)
}
- if value := r.Get("v3.auth-config.priv-config.des3.access-config.acl-name"); value.Exists() && !data.Users[i].V3AuthPrivDes3AccessAclName.IsNull() {
- data.Users[i].V3AuthPrivDes3AccessAclName = types.StringValue(value.String())
+ } else {
+ data.EnableTrapsOspfErrorsEnable = types.BoolNull()
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.Cisco-IOS-XE-ospf:ospf-config.cisco-specific.retransmit.enable"); !data.EnableTrapsOspfRetransmitEnable.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsOspfRetransmitEnable = types.BoolValue(true)
} else {
- data.Users[i].V3AuthPrivDes3AccessAclName = types.StringNull()
+ data.EnableTrapsOspfRetransmitEnable = types.BoolValue(false)
}
- if value := r.Get("v3.auth-config.access-config.ipv6-acl"); value.Exists() && !data.Users[i].V3AuthAccessIpv6Acl.IsNull() {
- data.Users[i].V3AuthAccessIpv6Acl = types.StringValue(value.String())
+ } else {
+ data.EnableTrapsOspfRetransmitEnable = types.BoolNull()
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.Cisco-IOS-XE-ospf:ospf-config.cisco-specific.lsa.enable"); !data.EnableTrapsOspfLsaEnable.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsOspfLsaEnable = types.BoolValue(true)
} else {
- data.Users[i].V3AuthAccessIpv6Acl = types.StringNull()
+ data.EnableTrapsOspfLsaEnable = types.BoolValue(false)
}
- if value := r.Get("v3.auth-config.access-config.standard-acl"); value.Exists() && !data.Users[i].V3AuthAccessStandardAcl.IsNull() {
- data.Users[i].V3AuthAccessStandardAcl = types.Int64Value(value.Int())
+ } else {
+ data.EnableTrapsOspfLsaEnable = types.BoolNull()
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.eigrp"); !data.EnableTrapsEigrp.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsEigrp = types.BoolValue(true)
} else {
- data.Users[i].V3AuthAccessStandardAcl = types.Int64Null()
+ data.EnableTrapsEigrp = types.BoolValue(false)
}
- if value := r.Get("v3.auth-config.access-config.acl-name"); value.Exists() && !data.Users[i].V3AuthAccessAclName.IsNull() {
- data.Users[i].V3AuthAccessAclName = types.StringValue(value.String())
+ } else {
+ data.EnableTrapsEigrp = types.BoolNull()
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.auth-framework.sec-violation"); !data.EnableTrapsAuthFrameworkSecViolation.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsAuthFrameworkSecViolation = types.BoolValue(true)
} else {
- data.Users[i].V3AuthAccessAclName = types.StringNull()
+ data.EnableTrapsAuthFrameworkSecViolation = types.BoolValue(false)
}
+ } else {
+ data.EnableTrapsAuthFrameworkSecViolation = types.BoolNull()
}
-}
-
-// End of section. //template:end updateFromBody
-
-// Section below is generated&owned by "gen/generator.go". //template:begin fromBody
-
-func (data *SNMPServer) fromBody(ctx context.Context, res gjson.Result) {
- prefix := helpers.LastElement(data.getPath()) + "."
- if res.Get(helpers.LastElement(data.getPath())).IsArray() {
- prefix += "0."
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.rep"); !data.EnableTrapsRep.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsRep = types.BoolValue(true)
+ } else {
+ data.EnableTrapsRep = types.BoolValue(false)
+ }
+ } else {
+ data.EnableTrapsRep = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:chassis-id"); value.Exists() {
- data.ChassisId = types.StringValue(value.String())
- }
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:contact"); value.Exists() {
- data.Contact = types.StringValue(value.String())
- }
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:ifindex.persist"); value.Exists() {
- data.IfindexPersist = types.BoolValue(true)
- } else {
- data.IfindexPersist = types.BoolValue(false)
- }
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:location"); value.Exists() {
- data.Location = types.StringValue(value.String())
- }
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:packetsize"); value.Exists() {
- data.Packetsize = types.Int64Value(value.Int())
- }
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:queue-length"); value.Exists() {
- data.QueueLength = types.Int64Value(value.Int())
- }
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.logging.getop"); value.Exists() {
- data.EnableLoggingGetop = types.BoolValue(value.Bool())
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.vtp"); !data.EnableTrapsVtp.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsVtp = types.BoolValue(true)
+ } else {
+ data.EnableTrapsVtp = types.BoolValue(false)
+ }
} else {
- data.EnableLoggingGetop = types.BoolNull()
+ data.EnableTrapsVtp = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.logging.setop"); value.Exists() {
- data.EnableLoggingSetop = types.BoolValue(value.Bool())
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.vlancreate"); !data.EnableTrapsVlancreate.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsVlancreate = types.BoolValue(true)
+ } else {
+ data.EnableTrapsVlancreate = types.BoolValue(false)
+ }
} else {
- data.EnableLoggingSetop = types.BoolNull()
+ data.EnableTrapsVlancreate = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.informs"); value.Exists() {
- data.EnableInforms = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.vlandelete"); !data.EnableTrapsVlandelete.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsVlandelete = types.BoolValue(true)
+ } else {
+ data.EnableTrapsVlandelete = types.BoolValue(false)
+ }
} else {
- data.EnableInforms = types.BoolValue(false)
+ data.EnableTrapsVlandelete = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps"); value.Exists() {
- data.EnableTraps = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.port-security"); !data.EnableTrapsPortSecurity.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsPortSecurity = types.BoolValue(true)
+ } else {
+ data.EnableTrapsPortSecurity = types.BoolValue(false)
+ }
} else {
- data.EnableTraps = types.BoolValue(false)
+ data.EnableTrapsPortSecurity = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.snmp.authentication"); value.Exists() {
- data.EnableTrapsSnmpAuthentication = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.license"); !data.EnableTrapsLicense.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsLicense = types.BoolValue(true)
+ } else {
+ data.EnableTrapsLicense = types.BoolValue(false)
+ }
} else {
- data.EnableTrapsSnmpAuthentication = types.BoolValue(false)
+ data.EnableTrapsLicense = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.snmp.coldstart"); value.Exists() {
- data.EnableTrapsSnmpColdstart = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.smart-licenseing.smart-license"); !data.EnableTrapsSmartLicense.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsSmartLicense = types.BoolValue(true)
+ } else {
+ data.EnableTrapsSmartLicense = types.BoolValue(false)
+ }
} else {
- data.EnableTrapsSnmpColdstart = types.BoolValue(false)
+ data.EnableTrapsSmartLicense = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.snmp.linkdown"); value.Exists() {
- data.EnableTrapsSnmpLinkdown = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.cpu.threshold"); !data.EnableTrapsCpuThreshold.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsCpuThreshold = types.BoolValue(true)
+ } else {
+ data.EnableTrapsCpuThreshold = types.BoolValue(false)
+ }
} else {
- data.EnableTrapsSnmpLinkdown = types.BoolValue(false)
+ data.EnableTrapsCpuThreshold = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.snmp.linkup"); value.Exists() {
- data.EnableTrapsSnmpLinkup = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.memory.bufferpeak"); !data.EnableTrapsMemoryBufferpeak.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsMemoryBufferpeak = types.BoolValue(true)
+ } else {
+ data.EnableTrapsMemoryBufferpeak = types.BoolValue(false)
+ }
} else {
- data.EnableTrapsSnmpLinkup = types.BoolValue(false)
+ data.EnableTrapsMemoryBufferpeak = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.snmp.warmstart"); value.Exists() {
- data.EnableTrapsSnmpWarmstart = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.stackwise"); !data.EnableTrapsStackwise.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsStackwise = types.BoolValue(true)
+ } else {
+ data.EnableTrapsStackwise = types.BoolValue(false)
+ }
} else {
- data.EnableTrapsSnmpWarmstart = types.BoolValue(false)
- }
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:host-config.ip-community"); value.Exists() {
- data.Hosts = make([]SNMPServerHosts, 0)
- value.ForEach(func(k, v gjson.Result) bool {
- item := SNMPServerHosts{}
- if cValue := v.Get("ip-address"); cValue.Exists() {
- item.IpAddress = types.StringValue(cValue.String())
- }
- if cValue := v.Get("community-or-user"); cValue.Exists() {
- item.CommunityOrUser = types.StringValue(cValue.String())
- }
- if cValue := v.Get("version"); cValue.Exists() {
- item.Version = types.StringValue(cValue.String())
- }
- if cValue := v.Get("encryption"); cValue.Exists() {
- item.Encryption = types.StringValue(cValue.String())
- }
- if cValue := v.Get("security-level"); cValue.Exists() {
- item.SecurityLevel = types.StringValue(cValue.String())
- }
- data.Hosts = append(data.Hosts, item)
- return true
- })
- }
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:host-config.ip-vrf-community"); value.Exists() {
- data.VrfHosts = make([]SNMPServerVrfHosts, 0)
- value.ForEach(func(k, v gjson.Result) bool {
- item := SNMPServerVrfHosts{}
- if cValue := v.Get("ip-address"); cValue.Exists() {
- item.IpAddress = types.StringValue(cValue.String())
- }
- if cValue := v.Get("vrf"); cValue.Exists() {
- item.Vrf = types.StringValue(cValue.String())
- }
- if cValue := v.Get("community-or-user"); cValue.Exists() {
- item.CommunityOrUser = types.StringValue(cValue.String())
- }
- if cValue := v.Get("version"); cValue.Exists() {
- item.Version = types.StringValue(cValue.String())
- }
- if cValue := v.Get("encryption"); cValue.Exists() {
- item.Encryption = types.StringValue(cValue.String())
- }
- if cValue := v.Get("security-level"); cValue.Exists() {
- item.SecurityLevel = types.StringValue(cValue.String())
- }
- data.VrfHosts = append(data.VrfHosts, item)
- return true
- })
+ data.EnableTrapsStackwise = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:system-shutdown"); value.Exists() {
- data.SystemShutdown = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.udld.link-fail-rpt"); !data.EnableTrapsUdldLinkFailRpt.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsUdldLinkFailRpt = types.BoolValue(true)
+ } else {
+ data.EnableTrapsUdldLinkFailRpt = types.BoolValue(false)
+ }
} else {
- data.SystemShutdown = types.BoolValue(false)
+ data.EnableTrapsUdldLinkFailRpt = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.flowmon"); value.Exists() {
- data.EnableTrapsFlowmon = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.udld.status-change"); !data.EnableTrapsUdldStatusChange.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsUdldStatusChange = types.BoolValue(true)
+ } else {
+ data.EnableTrapsUdldStatusChange = types.BoolValue(false)
+ }
} else {
- data.EnableTrapsFlowmon = types.BoolValue(false)
+ data.EnableTrapsUdldStatusChange = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.entity-perf.throughput-notif"); value.Exists() {
- data.EnableTrapsEntityPerfThroughputNotif = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.fru-ctrl"); !data.EnableTrapsFruCtrl.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsFruCtrl = types.BoolValue(true)
+ } else {
+ data.EnableTrapsFruCtrl = types.BoolValue(false)
+ }
} else {
- data.EnableTrapsEntityPerfThroughputNotif = types.BoolValue(false)
+ data.EnableTrapsFruCtrl = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.call-home.message-send-fail"); value.Exists() {
- data.EnableTrapsCallHomeMessageSendFail = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.flash.insertion"); !data.EnableTrapsFlashInsertion.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsFlashInsertion = types.BoolValue(true)
+ } else {
+ data.EnableTrapsFlashInsertion = types.BoolValue(false)
+ }
} else {
- data.EnableTrapsCallHomeMessageSendFail = types.BoolValue(false)
+ data.EnableTrapsFlashInsertion = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.call-home.server-fail"); value.Exists() {
- data.EnableTrapsCallHomeServerFail = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.flash.removal"); !data.EnableTrapsFlashRemoval.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsFlashRemoval = types.BoolValue(true)
+ } else {
+ data.EnableTrapsFlashRemoval = types.BoolValue(false)
+ }
} else {
- data.EnableTrapsCallHomeServerFail = types.BoolValue(false)
+ data.EnableTrapsFlashRemoval = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.tty"); value.Exists() {
- data.EnableTrapsTty = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.flash.lowspace"); !data.EnableTrapsFlashLowspace.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsFlashLowspace = types.BoolValue(true)
+ } else {
+ data.EnableTrapsFlashLowspace = types.BoolValue(false)
+ }
} else {
- data.EnableTrapsTty = types.BoolValue(false)
+ data.EnableTrapsFlashLowspace = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.Cisco-IOS-XE-ospfv3:ospfv3-config.state-change.enable"); value.Exists() {
- data.EnableTrapsOspfv3ConfigStateChange = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.energywise"); !data.EnableTrapsEnergywise.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsEnergywise = types.BoolValue(true)
+ } else {
+ data.EnableTrapsEnergywise = types.BoolValue(false)
+ }
} else {
- data.EnableTrapsOspfv3ConfigStateChange = types.BoolValue(false)
+ data.EnableTrapsEnergywise = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.Cisco-IOS-XE-ospfv3:ospfv3-config.errors.enable"); value.Exists() {
- data.EnableTrapsOspfv3ConfigErrors = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.power-ethernet.group"); value.Exists() && !data.EnableTrapsPowerEthernetGroup.IsNull() {
+ data.EnableTrapsPowerEthernetGroup = types.StringValue(value.String())
} else {
- data.EnableTrapsOspfv3ConfigErrors = types.BoolValue(false)
+ data.EnableTrapsPowerEthernetGroup = types.StringNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.Cisco-IOS-XE-ospf:ospf-config.retransmit.enable"); value.Exists() {
- data.EnableTrapsOspfConfigRetransmit = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.power-ethernet.police"); !data.EnableTrapsPowerEthernetPolice.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsPowerEthernetPolice = types.BoolValue(true)
+ } else {
+ data.EnableTrapsPowerEthernetPolice = types.BoolValue(false)
+ }
} else {
- data.EnableTrapsOspfConfigRetransmit = types.BoolValue(false)
+ data.EnableTrapsPowerEthernetPolice = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.Cisco-IOS-XE-ospf:ospf-config.lsa.enable"); value.Exists() {
- data.EnableTrapsOspfConfigLsa = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.entity"); !data.EnableTrapsEntity.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsEntity = types.BoolValue(true)
+ } else {
+ data.EnableTrapsEntity = types.BoolValue(false)
+ }
} else {
- data.EnableTrapsOspfConfigLsa = types.BoolValue(false)
+ data.EnableTrapsEntity = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.Cisco-IOS-XE-ospf:ospf-config.cisco-specific.state-change.nssa-trans-change"); value.Exists() {
- data.EnableTrapsOspfNssaTransChange = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.pw.vc"); !data.EnableTrapsPwVc.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsPwVc = types.BoolValue(true)
+ } else {
+ data.EnableTrapsPwVc = types.BoolValue(false)
+ }
} else {
- data.EnableTrapsOspfNssaTransChange = types.BoolValue(false)
+ data.EnableTrapsPwVc = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.Cisco-IOS-XE-ospf:ospf-config.cisco-specific.state-change.shamlink.interface"); value.Exists() {
- data.EnableTrapsOspfShamlinkInterface = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.envmon"); !data.EnableTrapsEnvmon.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsEnvmon = types.BoolValue(true)
+ } else {
+ data.EnableTrapsEnvmon = types.BoolValue(false)
+ }
} else {
- data.EnableTrapsOspfShamlinkInterface = types.BoolValue(false)
+ data.EnableTrapsEnvmon = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.Cisco-IOS-XE-ospf:ospf-config.cisco-specific.state-change.shamlink.neighbor"); value.Exists() {
- data.EnableTrapsOspfShamlinkNeighbor = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.cef.resource-failure"); !data.EnableTrapsCefResourceFailure.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsCefResourceFailure = types.BoolValue(true)
+ } else {
+ data.EnableTrapsCefResourceFailure = types.BoolValue(false)
+ }
} else {
- data.EnableTrapsOspfShamlinkNeighbor = types.BoolValue(false)
+ data.EnableTrapsCefResourceFailure = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.Cisco-IOS-XE-ospf:ospf-config.cisco-specific.errors.enable"); value.Exists() {
- data.EnableTrapsOspfErrorsEnable = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.cef.peer-state-change"); !data.EnableTrapsCefPeerStateChange.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsCefPeerStateChange = types.BoolValue(true)
+ } else {
+ data.EnableTrapsCefPeerStateChange = types.BoolValue(false)
+ }
} else {
- data.EnableTrapsOspfErrorsEnable = types.BoolValue(false)
+ data.EnableTrapsCefPeerStateChange = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.Cisco-IOS-XE-ospf:ospf-config.cisco-specific.retransmit.enable"); value.Exists() {
- data.EnableTrapsOspfRetransmitEnable = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.cef.peer-fib-state-change"); !data.EnableTrapsCefPeerFibStateChange.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsCefPeerFibStateChange = types.BoolValue(true)
+ } else {
+ data.EnableTrapsCefPeerFibStateChange = types.BoolValue(false)
+ }
} else {
- data.EnableTrapsOspfRetransmitEnable = types.BoolValue(false)
+ data.EnableTrapsCefPeerFibStateChange = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.Cisco-IOS-XE-ospf:ospf-config.cisco-specific.lsa.enable"); value.Exists() {
- data.EnableTrapsOspfLsaEnable = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.cef.inconsistency"); !data.EnableTrapsCefInconsistency.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsCefInconsistency = types.BoolValue(true)
+ } else {
+ data.EnableTrapsCefInconsistency = types.BoolValue(false)
+ }
} else {
- data.EnableTrapsOspfLsaEnable = types.BoolValue(false)
+ data.EnableTrapsCefInconsistency = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.eigrp"); value.Exists() {
- data.EnableTrapsEigrp = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.isis"); !data.EnableTrapsIsis.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsIsis = types.BoolValue(true)
+ } else {
+ data.EnableTrapsIsis = types.BoolValue(false)
+ }
} else {
- data.EnableTrapsEigrp = types.BoolValue(false)
+ data.EnableTrapsIsis = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.auth-framework.sec-violation"); value.Exists() {
- data.EnableTrapsAuthFrameworkSecViolation = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ipsla"); !data.EnableTrapsIpsla.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsIpsla = types.BoolValue(true)
+ } else {
+ data.EnableTrapsIpsla = types.BoolValue(false)
+ }
} else {
- data.EnableTrapsAuthFrameworkSecViolation = types.BoolValue(false)
+ data.EnableTrapsIpsla = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.rep"); value.Exists() {
- data.EnableTrapsRep = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.entity-diag.boot-up-fail"); !data.EnableTrapsEntityDiagBootUpFail.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsEntityDiagBootUpFail = types.BoolValue(true)
+ } else {
+ data.EnableTrapsEntityDiagBootUpFail = types.BoolValue(false)
+ }
} else {
- data.EnableTrapsRep = types.BoolValue(false)
+ data.EnableTrapsEntityDiagBootUpFail = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.vtp"); value.Exists() {
- data.EnableTrapsVtp = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.entity-diag.hm-test-recover"); !data.EnableTrapsEntityDiagHmTestRecover.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsEntityDiagHmTestRecover = types.BoolValue(true)
+ } else {
+ data.EnableTrapsEntityDiagHmTestRecover = types.BoolValue(false)
+ }
} else {
- data.EnableTrapsVtp = types.BoolValue(false)
+ data.EnableTrapsEntityDiagHmTestRecover = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.vlancreate"); value.Exists() {
- data.EnableTrapsVlancreate = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.entity-diag.hm-thresh-reached"); !data.EnableTrapsEntityDiagHmThreshReached.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsEntityDiagHmThreshReached = types.BoolValue(true)
+ } else {
+ data.EnableTrapsEntityDiagHmThreshReached = types.BoolValue(false)
+ }
} else {
- data.EnableTrapsVlancreate = types.BoolValue(false)
+ data.EnableTrapsEntityDiagHmThreshReached = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.vlandelete"); value.Exists() {
- data.EnableTrapsVlandelete = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.entity-diag.scheduled-test-fail"); !data.EnableTrapsEntityDiagScheduledTestFail.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsEntityDiagScheduledTestFail = types.BoolValue(true)
+ } else {
+ data.EnableTrapsEntityDiagScheduledTestFail = types.BoolValue(false)
+ }
} else {
- data.EnableTrapsVlandelete = types.BoolValue(false)
+ data.EnableTrapsEntityDiagScheduledTestFail = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.port-security"); value.Exists() {
- data.EnableTrapsPortSecurity = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.bfd"); !data.EnableTrapsBfd.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsBfd = types.BoolValue(true)
+ } else {
+ data.EnableTrapsBfd = types.BoolValue(false)
+ }
} else {
- data.EnableTrapsPortSecurity = types.BoolValue(false)
+ data.EnableTrapsBfd = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.license"); value.Exists() {
- data.EnableTrapsLicense = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ike.policy.add"); !data.EnableTrapsIkePolicyAdd.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsIkePolicyAdd = types.BoolValue(true)
+ } else {
+ data.EnableTrapsIkePolicyAdd = types.BoolValue(false)
+ }
} else {
- data.EnableTrapsLicense = types.BoolValue(false)
+ data.EnableTrapsIkePolicyAdd = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.smart-licenseing.smart-license"); value.Exists() {
- data.EnableTrapsSmartLicense = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ike.policy.delete"); !data.EnableTrapsIkePolicyDelete.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsIkePolicyDelete = types.BoolValue(true)
+ } else {
+ data.EnableTrapsIkePolicyDelete = types.BoolValue(false)
+ }
} else {
- data.EnableTrapsSmartLicense = types.BoolValue(false)
+ data.EnableTrapsIkePolicyDelete = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.cpu.threshold"); value.Exists() {
- data.EnableTrapsCpuThreshold = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ike.tunnel.start"); !data.EnableTrapsIkeTunnelStart.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsIkeTunnelStart = types.BoolValue(true)
+ } else {
+ data.EnableTrapsIkeTunnelStart = types.BoolValue(false)
+ }
} else {
- data.EnableTrapsCpuThreshold = types.BoolValue(false)
+ data.EnableTrapsIkeTunnelStart = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.memory.bufferpeak"); value.Exists() {
- data.EnableTrapsMemoryBufferpeak = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ike.tunnel.stop"); !data.EnableTrapsIkeTunnelStop.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsIkeTunnelStop = types.BoolValue(true)
+ } else {
+ data.EnableTrapsIkeTunnelStop = types.BoolValue(false)
+ }
} else {
- data.EnableTrapsMemoryBufferpeak = types.BoolValue(false)
+ data.EnableTrapsIkeTunnelStop = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.stackwise"); value.Exists() {
- data.EnableTrapsStackwise = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ipsec.cryptomap.add"); !data.EnableTrapsIpsecCryptomapAdd.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsIpsecCryptomapAdd = types.BoolValue(true)
+ } else {
+ data.EnableTrapsIpsecCryptomapAdd = types.BoolValue(false)
+ }
} else {
- data.EnableTrapsStackwise = types.BoolValue(false)
+ data.EnableTrapsIpsecCryptomapAdd = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.udld.link-fail-rpt"); value.Exists() {
- data.EnableTrapsUdldLinkFailRpt = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ipsec.cryptomap.attach"); !data.EnableTrapsIpsecCryptomapAttach.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsIpsecCryptomapAttach = types.BoolValue(true)
+ } else {
+ data.EnableTrapsIpsecCryptomapAttach = types.BoolValue(false)
+ }
} else {
- data.EnableTrapsUdldLinkFailRpt = types.BoolValue(false)
+ data.EnableTrapsIpsecCryptomapAttach = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.udld.status-change"); value.Exists() {
- data.EnableTrapsUdldStatusChange = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ipsec.cryptomap.delete"); !data.EnableTrapsIpsecCryptomapDelete.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsIpsecCryptomapDelete = types.BoolValue(true)
+ } else {
+ data.EnableTrapsIpsecCryptomapDelete = types.BoolValue(false)
+ }
} else {
- data.EnableTrapsUdldStatusChange = types.BoolValue(false)
+ data.EnableTrapsIpsecCryptomapDelete = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.fru-ctrl"); value.Exists() {
- data.EnableTrapsFruCtrl = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ipsec.cryptomap.detach"); !data.EnableTrapsIpsecCryptomapDetach.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsIpsecCryptomapDetach = types.BoolValue(true)
+ } else {
+ data.EnableTrapsIpsecCryptomapDetach = types.BoolValue(false)
+ }
} else {
- data.EnableTrapsFruCtrl = types.BoolValue(false)
+ data.EnableTrapsIpsecCryptomapDetach = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.flash.insertion"); value.Exists() {
- data.EnableTrapsFlashInsertion = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ipsec.tunnel.start"); !data.EnableTrapsIpsecTunnelStart.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsIpsecTunnelStart = types.BoolValue(true)
+ } else {
+ data.EnableTrapsIpsecTunnelStart = types.BoolValue(false)
+ }
} else {
- data.EnableTrapsFlashInsertion = types.BoolValue(false)
+ data.EnableTrapsIpsecTunnelStart = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.flash.removal"); value.Exists() {
- data.EnableTrapsFlashRemoval = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ipsec.tunnel.stop"); !data.EnableTrapsIpsecTunnelStop.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsIpsecTunnelStop = types.BoolValue(true)
+ } else {
+ data.EnableTrapsIpsecTunnelStop = types.BoolValue(false)
+ }
} else {
- data.EnableTrapsFlashRemoval = types.BoolValue(false)
+ data.EnableTrapsIpsecTunnelStop = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.flash.lowspace"); value.Exists() {
- data.EnableTrapsFlashLowspace = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ipsec.too-many-sas"); !data.EnableTrapsIpsecTooManySas.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsIpsecTooManySas = types.BoolValue(true)
+ } else {
+ data.EnableTrapsIpsecTooManySas = types.BoolValue(false)
+ }
} else {
- data.EnableTrapsFlashLowspace = types.BoolValue(false)
+ data.EnableTrapsIpsecTooManySas = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.energywise"); value.Exists() {
- data.EnableTrapsEnergywise = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.config-copy"); !data.EnableTrapsConfigCopy.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsConfigCopy = types.BoolValue(true)
+ } else {
+ data.EnableTrapsConfigCopy = types.BoolValue(false)
+ }
} else {
- data.EnableTrapsEnergywise = types.BoolValue(false)
- }
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.power-ethernet.group"); value.Exists() {
- data.EnableTrapsPowerEthernetGroup = types.StringValue(value.String())
+ data.EnableTrapsConfigCopy = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.power-ethernet.police"); value.Exists() {
- data.EnableTrapsPowerEthernetPolice = types.BoolValue(true)
- } else {
- data.EnableTrapsPowerEthernetPolice = types.BoolValue(false)
- }
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.entity"); value.Exists() {
- data.EnableTrapsEntity = types.BoolValue(true)
- } else {
- data.EnableTrapsEntity = types.BoolValue(false)
- }
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.pw.vc"); value.Exists() {
- data.EnableTrapsPwVc = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.config"); !data.EnableTrapsConfig.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsConfig = types.BoolValue(true)
+ } else {
+ data.EnableTrapsConfig = types.BoolValue(false)
+ }
} else {
- data.EnableTrapsPwVc = types.BoolValue(false)
+ data.EnableTrapsConfig = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.envmon"); value.Exists() {
- data.EnableTrapsEnvmon = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.config-ctid"); !data.EnableTrapsConfigCtid.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsConfigCtid = types.BoolValue(true)
+ } else {
+ data.EnableTrapsConfigCtid = types.BoolValue(false)
+ }
} else {
- data.EnableTrapsEnvmon = types.BoolValue(false)
+ data.EnableTrapsConfigCtid = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.cef.resource-failure"); value.Exists() {
- data.EnableTrapsCefResourceFailure = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.dhcp"); !data.EnableTrapsDhcp.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsDhcp = types.BoolValue(true)
+ } else {
+ data.EnableTrapsDhcp = types.BoolValue(false)
+ }
} else {
- data.EnableTrapsCefResourceFailure = types.BoolValue(false)
+ data.EnableTrapsDhcp = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.cef.peer-state-change"); value.Exists() {
- data.EnableTrapsCefPeerStateChange = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.event-manager"); !data.EnableTrapsEventManager.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsEventManager = types.BoolValue(true)
+ } else {
+ data.EnableTrapsEventManager = types.BoolValue(false)
+ }
} else {
- data.EnableTrapsCefPeerStateChange = types.BoolValue(false)
+ data.EnableTrapsEventManager = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.cef.peer-fib-state-change"); value.Exists() {
- data.EnableTrapsCefPeerFibStateChange = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.hsrp"); !data.EnableTrapsHsrp.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsHsrp = types.BoolValue(true)
+ } else {
+ data.EnableTrapsHsrp = types.BoolValue(false)
+ }
} else {
- data.EnableTrapsCefPeerFibStateChange = types.BoolValue(false)
+ data.EnableTrapsHsrp = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.cef.inconsistency"); value.Exists() {
- data.EnableTrapsCefInconsistency = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ipmulticast"); !data.EnableTrapsIpmulticast.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsIpmulticast = types.BoolValue(true)
+ } else {
+ data.EnableTrapsIpmulticast = types.BoolValue(false)
+ }
} else {
- data.EnableTrapsCefInconsistency = types.BoolValue(false)
+ data.EnableTrapsIpmulticast = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.isis"); value.Exists() {
- data.EnableTrapsIsis = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.msdp"); !data.EnableTrapsMsdp.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsMsdp = types.BoolValue(true)
+ } else {
+ data.EnableTrapsMsdp = types.BoolValue(false)
+ }
} else {
- data.EnableTrapsIsis = types.BoolValue(false)
+ data.EnableTrapsMsdp = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ipsla"); value.Exists() {
- data.EnableTrapsIpsla = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.Cisco-IOS-XE-ospf:ospf-config.state-change.enable"); !data.EnableTrapsOspfConfigStateChange.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsOspfConfigStateChange = types.BoolValue(true)
+ } else {
+ data.EnableTrapsOspfConfigStateChange = types.BoolValue(false)
+ }
} else {
- data.EnableTrapsIpsla = types.BoolValue(false)
+ data.EnableTrapsOspfConfigStateChange = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.entity-diag.boot-up-fail"); value.Exists() {
- data.EnableTrapsEntityDiagBootUpFail = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.Cisco-IOS-XE-ospf:ospf-config.errors.enable"); !data.EnableTrapsOspfConfigErrors.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsOspfConfigErrors = types.BoolValue(true)
+ } else {
+ data.EnableTrapsOspfConfigErrors = types.BoolValue(false)
+ }
} else {
- data.EnableTrapsEntityDiagBootUpFail = types.BoolValue(false)
+ data.EnableTrapsOspfConfigErrors = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.entity-diag.hm-test-recover"); value.Exists() {
- data.EnableTrapsEntityDiagHmTestRecover = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.pim.invalid-pim-message"); !data.EnableTrapsPimInvalidPimMessage.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsPimInvalidPimMessage = types.BoolValue(true)
+ } else {
+ data.EnableTrapsPimInvalidPimMessage = types.BoolValue(false)
+ }
} else {
- data.EnableTrapsEntityDiagHmTestRecover = types.BoolValue(false)
+ data.EnableTrapsPimInvalidPimMessage = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.entity-diag.hm-thresh-reached"); value.Exists() {
- data.EnableTrapsEntityDiagHmThreshReached = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.pim.neighbor-change"); !data.EnableTrapsPimNeighborChange.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsPimNeighborChange = types.BoolValue(true)
+ } else {
+ data.EnableTrapsPimNeighborChange = types.BoolValue(false)
+ }
} else {
- data.EnableTrapsEntityDiagHmThreshReached = types.BoolValue(false)
+ data.EnableTrapsPimNeighborChange = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.entity-diag.scheduled-test-fail"); value.Exists() {
- data.EnableTrapsEntityDiagScheduledTestFail = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.pim.rp-mapping-change"); !data.EnableTrapsPimRpMappingChange.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsPimRpMappingChange = types.BoolValue(true)
+ } else {
+ data.EnableTrapsPimRpMappingChange = types.BoolValue(false)
+ }
} else {
- data.EnableTrapsEntityDiagScheduledTestFail = types.BoolValue(false)
+ data.EnableTrapsPimRpMappingChange = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.bfd"); value.Exists() {
- data.EnableTrapsBfd = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.bridge.newroot"); !data.EnableTrapsBridgeNewroot.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsBridgeNewroot = types.BoolValue(true)
+ } else {
+ data.EnableTrapsBridgeNewroot = types.BoolValue(false)
+ }
} else {
- data.EnableTrapsBfd = types.BoolValue(false)
+ data.EnableTrapsBridgeNewroot = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ike.policy.add"); value.Exists() {
- data.EnableTrapsIkePolicyAdd = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.bridge.topologychange"); !data.EnableTrapsBridgeTopologychange.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsBridgeTopologychange = types.BoolValue(true)
+ } else {
+ data.EnableTrapsBridgeTopologychange = types.BoolValue(false)
+ }
} else {
- data.EnableTrapsIkePolicyAdd = types.BoolValue(false)
+ data.EnableTrapsBridgeTopologychange = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ike.policy.delete"); value.Exists() {
- data.EnableTrapsIkePolicyDelete = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.stpx.inconsistency"); !data.EnableTrapsStpxInconsistency.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsStpxInconsistency = types.BoolValue(true)
+ } else {
+ data.EnableTrapsStpxInconsistency = types.BoolValue(false)
+ }
} else {
- data.EnableTrapsIkePolicyDelete = types.BoolValue(false)
+ data.EnableTrapsStpxInconsistency = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ike.tunnel.start"); value.Exists() {
- data.EnableTrapsIkeTunnelStart = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.stpx.root-inconsistency"); !data.EnableTrapsStpxRootInconsistency.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsStpxRootInconsistency = types.BoolValue(true)
+ } else {
+ data.EnableTrapsStpxRootInconsistency = types.BoolValue(false)
+ }
} else {
- data.EnableTrapsIkeTunnelStart = types.BoolValue(false)
+ data.EnableTrapsStpxRootInconsistency = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ike.tunnel.stop"); value.Exists() {
- data.EnableTrapsIkeTunnelStop = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.stpx.loop-inconsistency"); !data.EnableTrapsStpxLoopInconsistency.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsStpxLoopInconsistency = types.BoolValue(true)
+ } else {
+ data.EnableTrapsStpxLoopInconsistency = types.BoolValue(false)
+ }
} else {
- data.EnableTrapsIkeTunnelStop = types.BoolValue(false)
+ data.EnableTrapsStpxLoopInconsistency = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ipsec.cryptomap.add"); value.Exists() {
- data.EnableTrapsIpsecCryptomapAdd = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.syslog"); !data.EnableTrapsSyslog.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsSyslog = types.BoolValue(true)
+ } else {
+ data.EnableTrapsSyslog = types.BoolValue(false)
+ }
} else {
- data.EnableTrapsIpsecCryptomapAdd = types.BoolValue(false)
+ data.EnableTrapsSyslog = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ipsec.cryptomap.attach"); value.Exists() {
- data.EnableTrapsIpsecCryptomapAttach = types.BoolValue(true)
+ if value := res.Get(prefix + ""); !data.EnableTrapsBgpCbgp2.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsBgpCbgp2 = types.BoolValue(true)
+ } else {
+ data.EnableTrapsBgpCbgp2 = types.BoolValue(false)
+ }
} else {
- data.EnableTrapsIpsecCryptomapAttach = types.BoolValue(false)
+ data.EnableTrapsBgpCbgp2 = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ipsec.cryptomap.delete"); value.Exists() {
- data.EnableTrapsIpsecCryptomapDelete = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.nhrp.nhs"); !data.EnableTrapsNhrpNhs.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsNhrpNhs = types.BoolValue(true)
+ } else {
+ data.EnableTrapsNhrpNhs = types.BoolValue(false)
+ }
} else {
- data.EnableTrapsIpsecCryptomapDelete = types.BoolValue(false)
+ data.EnableTrapsNhrpNhs = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ipsec.cryptomap.detach"); value.Exists() {
- data.EnableTrapsIpsecCryptomapDetach = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.nhrp.nhc"); !data.EnableTrapsNhrpNhc.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsNhrpNhc = types.BoolValue(true)
+ } else {
+ data.EnableTrapsNhrpNhc = types.BoolValue(false)
+ }
} else {
- data.EnableTrapsIpsecCryptomapDetach = types.BoolValue(false)
+ data.EnableTrapsNhrpNhc = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ipsec.tunnel.start"); value.Exists() {
- data.EnableTrapsIpsecTunnelStart = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.nhrp.nhp"); !data.EnableTrapsNhrpNhp.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsNhrpNhp = types.BoolValue(true)
+ } else {
+ data.EnableTrapsNhrpNhp = types.BoolValue(false)
+ }
} else {
- data.EnableTrapsIpsecTunnelStart = types.BoolValue(false)
+ data.EnableTrapsNhrpNhp = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ipsec.tunnel.stop"); value.Exists() {
- data.EnableTrapsIpsecTunnelStop = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.nhrp.quota-exceeded"); !data.EnableTrapsNhrpQuotaExceeded.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsNhrpQuotaExceeded = types.BoolValue(true)
+ } else {
+ data.EnableTrapsNhrpQuotaExceeded = types.BoolValue(false)
+ }
} else {
- data.EnableTrapsIpsecTunnelStop = types.BoolValue(false)
+ data.EnableTrapsNhrpQuotaExceeded = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ipsec.too-many-sas"); value.Exists() {
- data.EnableTrapsIpsecTooManySas = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.mpls.traffic-eng"); !data.EnableTrapsMplsTrafficEng.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsMplsTrafficEng = types.BoolValue(true)
+ } else {
+ data.EnableTrapsMplsTrafficEng = types.BoolValue(false)
+ }
} else {
- data.EnableTrapsIpsecTooManySas = types.BoolValue(false)
+ data.EnableTrapsMplsTrafficEng = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.config-copy"); value.Exists() {
- data.EnableTrapsConfigCopy = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.mpls"); !data.EnableTrapsMpls.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsMpls = types.BoolValue(true)
+ } else {
+ data.EnableTrapsMpls = types.BoolValue(false)
+ }
} else {
- data.EnableTrapsConfigCopy = types.BoolValue(false)
+ data.EnableTrapsMpls = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.config"); value.Exists() {
- data.EnableTrapsConfig = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.mpls.vpn"); !data.EnableTrapsMplsVpn.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsMplsVpn = types.BoolValue(true)
+ } else {
+ data.EnableTrapsMplsVpn = types.BoolValue(false)
+ }
} else {
- data.EnableTrapsConfig = types.BoolValue(false)
+ data.EnableTrapsMplsVpn = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.config-ctid"); value.Exists() {
- data.EnableTrapsConfigCtid = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.mpls.rfc"); !data.EnableTrapsMplsRfc.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsMplsRfc = types.BoolValue(true)
+ } else {
+ data.EnableTrapsMplsRfc = types.BoolValue(false)
+ }
} else {
- data.EnableTrapsConfigCtid = types.BoolValue(false)
+ data.EnableTrapsMplsRfc = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.dhcp"); value.Exists() {
- data.EnableTrapsDhcp = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.mpls.rfc.ldp"); !data.EnableTrapsMplsRfcLdp.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsMplsRfcLdp = types.BoolValue(true)
+ } else {
+ data.EnableTrapsMplsRfcLdp = types.BoolValue(false)
+ }
} else {
- data.EnableTrapsDhcp = types.BoolValue(false)
+ data.EnableTrapsMplsRfcLdp = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.event-manager"); value.Exists() {
- data.EnableTrapsEventManager = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.mpls.ldp"); !data.EnableTrapsMplsLdp.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsMplsLdp = types.BoolValue(true)
+ } else {
+ data.EnableTrapsMplsLdp = types.BoolValue(false)
+ }
} else {
- data.EnableTrapsEventManager = types.BoolValue(false)
+ data.EnableTrapsMplsLdp = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.hsrp"); value.Exists() {
- data.EnableTrapsHsrp = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.mpls.fast-reroute.protected"); !data.EnableTrapsFastRerouteProtected.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsFastRerouteProtected = types.BoolValue(true)
+ } else {
+ data.EnableTrapsFastRerouteProtected = types.BoolValue(false)
+ }
} else {
- data.EnableTrapsHsrp = types.BoolValue(false)
+ data.EnableTrapsFastRerouteProtected = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ipmulticast"); value.Exists() {
- data.EnableTrapsIpmulticast = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.local-auth"); !data.EnableTrapsLocalAuth.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsLocalAuth = types.BoolValue(true)
+ } else {
+ data.EnableTrapsLocalAuth = types.BoolValue(false)
+ }
} else {
- data.EnableTrapsIpmulticast = types.BoolValue(false)
+ data.EnableTrapsLocalAuth = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.msdp"); value.Exists() {
- data.EnableTrapsMsdp = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.vlan-membership"); !data.EnableTrapsVlanMembership.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsVlanMembership = types.BoolValue(true)
+ } else {
+ data.EnableTrapsVlanMembership = types.BoolValue(false)
+ }
} else {
- data.EnableTrapsMsdp = types.BoolValue(false)
+ data.EnableTrapsVlanMembership = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.Cisco-IOS-XE-ospf:ospf-config.state-change.enable"); value.Exists() {
- data.EnableTrapsOspfConfigStateChange = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.errdisable"); !data.EnableTrapsErrdisable.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsErrdisable = types.BoolValue(true)
+ } else {
+ data.EnableTrapsErrdisable = types.BoolValue(false)
+ }
} else {
- data.EnableTrapsOspfConfigStateChange = types.BoolValue(false)
+ data.EnableTrapsErrdisable = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.Cisco-IOS-XE-ospf:ospf-config.errors.enable"); value.Exists() {
- data.EnableTrapsOspfConfigErrors = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.rf"); !data.EnableTrapsRf.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsRf = types.BoolValue(true)
+ } else {
+ data.EnableTrapsRf = types.BoolValue(false)
+ }
} else {
- data.EnableTrapsOspfConfigErrors = types.BoolValue(false)
+ data.EnableTrapsRf = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.pim.invalid-pim-message"); value.Exists() {
- data.EnableTrapsPimInvalidPimMessage = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.transceiver.all"); !data.EnableTrapsTransceiverAll.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsTransceiverAll = types.BoolValue(true)
+ } else {
+ data.EnableTrapsTransceiverAll = types.BoolValue(false)
+ }
} else {
- data.EnableTrapsPimInvalidPimMessage = types.BoolValue(false)
+ data.EnableTrapsTransceiverAll = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.pim.neighbor-change"); value.Exists() {
- data.EnableTrapsPimNeighborChange = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.bulkstat.collection"); !data.EnableTrapsBulkstatCollection.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsBulkstatCollection = types.BoolValue(true)
+ } else {
+ data.EnableTrapsBulkstatCollection = types.BoolValue(false)
+ }
} else {
- data.EnableTrapsPimNeighborChange = types.BoolValue(false)
+ data.EnableTrapsBulkstatCollection = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.pim.rp-mapping-change"); value.Exists() {
- data.EnableTrapsPimRpMappingChange = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.bulkstat.transfer"); !data.EnableTrapsBulkstatTransfer.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsBulkstatTransfer = types.BoolValue(true)
+ } else {
+ data.EnableTrapsBulkstatTransfer = types.BoolValue(false)
+ }
} else {
- data.EnableTrapsPimRpMappingChange = types.BoolValue(false)
+ data.EnableTrapsBulkstatTransfer = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.bridge.newroot"); value.Exists() {
- data.EnableTrapsBridgeNewroot = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.mac-notification.change"); !data.EnableTrapsMacNotificationChange.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsMacNotificationChange = types.BoolValue(true)
+ } else {
+ data.EnableTrapsMacNotificationChange = types.BoolValue(false)
+ }
} else {
- data.EnableTrapsBridgeNewroot = types.BoolValue(false)
+ data.EnableTrapsMacNotificationChange = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.bridge.topologychange"); value.Exists() {
- data.EnableTrapsBridgeTopologychange = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.mac-notification.move"); !data.EnableTrapsMacNotificationMove.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsMacNotificationMove = types.BoolValue(true)
+ } else {
+ data.EnableTrapsMacNotificationMove = types.BoolValue(false)
+ }
} else {
- data.EnableTrapsBridgeTopologychange = types.BoolValue(false)
+ data.EnableTrapsMacNotificationMove = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.stpx.inconsistency"); value.Exists() {
- data.EnableTrapsStpxInconsistency = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.mac-notification.threshold"); !data.EnableTrapsMacNotificationThreshold.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsMacNotificationThreshold = types.BoolValue(true)
+ } else {
+ data.EnableTrapsMacNotificationThreshold = types.BoolValue(false)
+ }
} else {
- data.EnableTrapsStpxInconsistency = types.BoolValue(false)
+ data.EnableTrapsMacNotificationThreshold = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.stpx.root-inconsistency"); value.Exists() {
- data.EnableTrapsStpxRootInconsistency = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.vrfmib.vrf-up"); !data.EnableTrapsVrfmibVrfUp.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsVrfmibVrfUp = types.BoolValue(true)
+ } else {
+ data.EnableTrapsVrfmibVrfUp = types.BoolValue(false)
+ }
} else {
- data.EnableTrapsStpxRootInconsistency = types.BoolValue(false)
+ data.EnableTrapsVrfmibVrfUp = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.stpx.loop-inconsistency"); value.Exists() {
- data.EnableTrapsStpxLoopInconsistency = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.vrfmib.vrf-down"); !data.EnableTrapsVrfmibVrfDown.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsVrfmibVrfDown = types.BoolValue(true)
+ } else {
+ data.EnableTrapsVrfmibVrfDown = types.BoolValue(false)
+ }
} else {
- data.EnableTrapsStpxLoopInconsistency = types.BoolValue(false)
+ data.EnableTrapsVrfmibVrfDown = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.syslog"); value.Exists() {
- data.EnableTrapsSyslog = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.vrfmib.vnet-trunk-up"); !data.EnableTrapsVrfmibVnetTrunkUp.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsVrfmibVnetTrunkUp = types.BoolValue(true)
+ } else {
+ data.EnableTrapsVrfmibVnetTrunkUp = types.BoolValue(false)
+ }
} else {
- data.EnableTrapsSyslog = types.BoolValue(false)
+ data.EnableTrapsVrfmibVnetTrunkUp = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.Cisco-IOS-XE-bgp:bgp.cbgp2"); value.Exists() {
- data.EnableTrapsBgpCbgp2 = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.vrfmib.vnet-trunk-down"); !data.EnableTrapsVrfmibVnetTrunkDown.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsVrfmibVnetTrunkDown = types.BoolValue(true)
+ } else {
+ data.EnableTrapsVrfmibVnetTrunkDown = types.BoolValue(false)
+ }
} else {
- data.EnableTrapsBgpCbgp2 = types.BoolValue(false)
+ data.EnableTrapsVrfmibVnetTrunkDown = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.nhrp.nhs"); value.Exists() {
- data.EnableTrapsNhrpNhs = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.mvpn"); !data.EnableTrapsMvpn.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsMvpn = types.BoolValue(true)
+ } else {
+ data.EnableTrapsMvpn = types.BoolValue(false)
+ }
} else {
- data.EnableTrapsNhrpNhs = types.BoolValue(false)
+ data.EnableTrapsMvpn = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.nhrp.nhc"); value.Exists() {
- data.EnableTrapsNhrpNhc = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.lisp"); !data.EnableTrapsLisp.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsLisp = types.BoolValue(true)
+ } else {
+ data.EnableTrapsLisp = types.BoolValue(false)
+ }
} else {
- data.EnableTrapsNhrpNhc = types.BoolValue(false)
+ data.EnableTrapsLisp = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.nhrp.nhp"); value.Exists() {
- data.EnableTrapsNhrpNhp = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.aaa_server"); !data.EnableTrapsAaaServer.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsAaaServer = types.BoolValue(true)
+ } else {
+ data.EnableTrapsAaaServer = types.BoolValue(false)
+ }
} else {
- data.EnableTrapsNhrpNhp = types.BoolValue(false)
+ data.EnableTrapsAaaServer = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.nhrp.quota-exceeded"); value.Exists() {
- data.EnableTrapsNhrpQuotaExceeded = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.vdsl2line"); !data.EnableTrapsVdsl2line.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsVdsl2line = types.BoolValue(true)
+ } else {
+ data.EnableTrapsVdsl2line = types.BoolValue(false)
+ }
} else {
- data.EnableTrapsNhrpQuotaExceeded = types.BoolValue(false)
+ data.EnableTrapsVdsl2line = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.mpls.traffic-eng"); value.Exists() {
- data.EnableTrapsMplsTrafficEng = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.adslline"); !data.EnableTrapsAdslline.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsAdslline = types.BoolValue(true)
+ } else {
+ data.EnableTrapsAdslline = types.BoolValue(false)
+ }
} else {
- data.EnableTrapsMplsTrafficEng = types.BoolValue(false)
+ data.EnableTrapsAdslline = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.mpls"); value.Exists() {
- data.EnableTrapsMpls = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.pki"); !data.EnableTrapsPki.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsPki = types.BoolValue(true)
+ } else {
+ data.EnableTrapsPki = types.BoolValue(false)
+ }
} else {
- data.EnableTrapsMpls = types.BoolValue(false)
+ data.EnableTrapsPki = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.mpls.vpn"); value.Exists() {
- data.EnableTrapsMplsVpn = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.alarms.alarm-type"); value.Exists() && !data.EnableTrapsAlarmType.IsNull() {
+ data.EnableTrapsAlarmType = types.StringValue(value.String())
} else {
- data.EnableTrapsMplsVpn = types.BoolValue(false)
+ data.EnableTrapsAlarmType = types.StringNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.mpls.rfc"); value.Exists() {
- data.EnableTrapsMplsRfc = types.BoolValue(true)
- } else {
- data.EnableTrapsMplsRfc = types.BoolValue(false)
- }
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.mpls.rfc.ldp"); value.Exists() {
- data.EnableTrapsMplsRfcLdp = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.casa"); !data.EnableTrapsCasa.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsCasa = types.BoolValue(true)
+ } else {
+ data.EnableTrapsCasa = types.BoolValue(false)
+ }
} else {
- data.EnableTrapsMplsRfcLdp = types.BoolValue(false)
+ data.EnableTrapsCasa = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.mpls.ldp"); value.Exists() {
- data.EnableTrapsMplsLdp = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.cnpd"); !data.EnableTrapsCnpd.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsCnpd = types.BoolValue(true)
+ } else {
+ data.EnableTrapsCnpd = types.BoolValue(false)
+ }
} else {
- data.EnableTrapsMplsLdp = types.BoolValue(false)
+ data.EnableTrapsCnpd = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.mpls.fast-reroute.protected"); value.Exists() {
- data.EnableTrapsFastRerouteProtected = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.dial"); !data.EnableTrapsDial.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsDial = types.BoolValue(true)
+ } else {
+ data.EnableTrapsDial = types.BoolValue(false)
+ }
} else {
- data.EnableTrapsFastRerouteProtected = types.BoolValue(false)
+ data.EnableTrapsDial = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.local-auth"); value.Exists() {
- data.EnableTrapsLocalAuth = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.dlsw"); !data.EnableTrapsDlsw.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsDlsw = types.BoolValue(true)
+ } else {
+ data.EnableTrapsDlsw = types.BoolValue(false)
+ }
} else {
- data.EnableTrapsLocalAuth = types.BoolValue(false)
+ data.EnableTrapsDlsw = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.vlan-membership"); value.Exists() {
- data.EnableTrapsVlanMembership = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ds1"); !data.EnableTrapsDs1.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsDs1 = types.BoolValue(true)
+ } else {
+ data.EnableTrapsDs1 = types.BoolValue(false)
+ }
} else {
- data.EnableTrapsVlanMembership = types.BoolValue(false)
+ data.EnableTrapsDs1 = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.errdisable"); value.Exists() {
- data.EnableTrapsErrdisable = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.dsp.card-status"); !data.EnableTrapsDspCardStatus.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsDspCardStatus = types.BoolValue(true)
+ } else {
+ data.EnableTrapsDspCardStatus = types.BoolValue(false)
+ }
} else {
- data.EnableTrapsErrdisable = types.BoolValue(false)
+ data.EnableTrapsDspCardStatus = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.rf"); value.Exists() {
- data.EnableTrapsRf = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.dsp.oper-state"); !data.EnableTrapsDspOperState.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsDspOperState = types.BoolValue(true)
+ } else {
+ data.EnableTrapsDspOperState = types.BoolValue(false)
+ }
} else {
- data.EnableTrapsRf = types.BoolValue(false)
+ data.EnableTrapsDspOperState = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.transceiver.all"); value.Exists() {
- data.EnableTrapsTransceiverAll = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.entity-sensor"); !data.EnableTrapsEntitySensor.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsEntitySensor = types.BoolValue(true)
+ } else {
+ data.EnableTrapsEntitySensor = types.BoolValue(false)
+ }
} else {
- data.EnableTrapsTransceiverAll = types.BoolValue(false)
+ data.EnableTrapsEntitySensor = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.bulkstat.collection"); value.Exists() {
- data.EnableTrapsBulkstatCollection = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.entity-state"); !data.EnableTrapsEntityState.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsEntityState = types.BoolValue(true)
+ } else {
+ data.EnableTrapsEntityState = types.BoolValue(false)
+ }
} else {
- data.EnableTrapsBulkstatCollection = types.BoolValue(false)
+ data.EnableTrapsEntityState = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.bulkstat.transfer"); value.Exists() {
- data.EnableTrapsBulkstatTransfer = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.entity-qfp.mem-res-thresh"); !data.EnableTrapsEntityQfpMemResThresh.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsEntityQfpMemResThresh = types.BoolValue(true)
+ } else {
+ data.EnableTrapsEntityQfpMemResThresh = types.BoolValue(false)
+ }
} else {
- data.EnableTrapsBulkstatTransfer = types.BoolValue(false)
+ data.EnableTrapsEntityQfpMemResThresh = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.mac-notification.change"); value.Exists() {
- data.EnableTrapsMacNotificationChange = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.entity-qfp.throughput-notif"); !data.EnableTrapsEntityQfpThroughputNotif.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsEntityQfpThroughputNotif = types.BoolValue(true)
+ } else {
+ data.EnableTrapsEntityQfpThroughputNotif = types.BoolValue(false)
+ }
} else {
- data.EnableTrapsMacNotificationChange = types.BoolValue(false)
+ data.EnableTrapsEntityQfpThroughputNotif = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.mac-notification.move"); value.Exists() {
- data.EnableTrapsMacNotificationMove = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ether-oam"); !data.EnableTrapsEtherOam.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsEtherOam = types.BoolValue(true)
+ } else {
+ data.EnableTrapsEtherOam = types.BoolValue(false)
+ }
} else {
- data.EnableTrapsMacNotificationMove = types.BoolValue(false)
+ data.EnableTrapsEtherOam = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.mac-notification.threshold"); value.Exists() {
- data.EnableTrapsMacNotificationThreshold = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ethernet.cfm.alarm"); !data.EnableTrapsEthernetCfmAlarm.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsEthernetCfmAlarm = types.BoolValue(true)
+ } else {
+ data.EnableTrapsEthernetCfmAlarm = types.BoolValue(false)
+ }
} else {
- data.EnableTrapsMacNotificationThreshold = types.BoolValue(false)
+ data.EnableTrapsEthernetCfmAlarm = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.vrfmib.vrf-up"); value.Exists() {
- data.EnableTrapsVrfmibVrfUp = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ethernet.cfm.cc.config"); !data.EnableTrapsEthernetCfmCcConfig.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsEthernetCfmCcConfig = types.BoolValue(true)
+ } else {
+ data.EnableTrapsEthernetCfmCcConfig = types.BoolValue(false)
+ }
} else {
- data.EnableTrapsVrfmibVrfUp = types.BoolValue(false)
+ data.EnableTrapsEthernetCfmCcConfig = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.vrfmib.vrf-down"); value.Exists() {
- data.EnableTrapsVrfmibVrfDown = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ethernet.cfm.cc.cross-connect"); !data.EnableTrapsEthernetCfmCcCrossConnect.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsEthernetCfmCcCrossConnect = types.BoolValue(true)
+ } else {
+ data.EnableTrapsEthernetCfmCcCrossConnect = types.BoolValue(false)
+ }
} else {
- data.EnableTrapsVrfmibVrfDown = types.BoolValue(false)
+ data.EnableTrapsEthernetCfmCcCrossConnect = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.vrfmib.vnet-trunk-up"); value.Exists() {
- data.EnableTrapsVrfmibVnetTrunkUp = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ethernet.cfm.cc.loop"); !data.EnableTrapsEthernetCfmCcLoop.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsEthernetCfmCcLoop = types.BoolValue(true)
+ } else {
+ data.EnableTrapsEthernetCfmCcLoop = types.BoolValue(false)
+ }
} else {
- data.EnableTrapsVrfmibVnetTrunkUp = types.BoolValue(false)
+ data.EnableTrapsEthernetCfmCcLoop = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.vrfmib.vnet-trunk-down"); value.Exists() {
- data.EnableTrapsVrfmibVnetTrunkDown = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ethernet.cfm.cc.mep-down"); !data.EnableTrapsEthernetCfmCcMepDown.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsEthernetCfmCcMepDown = types.BoolValue(true)
+ } else {
+ data.EnableTrapsEthernetCfmCcMepDown = types.BoolValue(false)
+ }
} else {
- data.EnableTrapsVrfmibVnetTrunkDown = types.BoolValue(false)
+ data.EnableTrapsEthernetCfmCcMepDown = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.mvpn"); value.Exists() {
- data.EnableTrapsMvpn = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ethernet.cfm.cc.mep-up"); !data.EnableTrapsEthernetCfmCcMepUp.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsEthernetCfmCcMepUp = types.BoolValue(true)
+ } else {
+ data.EnableTrapsEthernetCfmCcMepUp = types.BoolValue(false)
+ }
} else {
- data.EnableTrapsMvpn = types.BoolValue(false)
+ data.EnableTrapsEthernetCfmCcMepUp = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.lisp"); value.Exists() {
- data.EnableTrapsLisp = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ethernet.cfm.crosscheck.mep-missing"); !data.EnableTrapsEthernetCfmCrosscheckMepMissing.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsEthernetCfmCrosscheckMepMissing = types.BoolValue(true)
+ } else {
+ data.EnableTrapsEthernetCfmCrosscheckMepMissing = types.BoolValue(false)
+ }
} else {
- data.EnableTrapsLisp = types.BoolValue(false)
+ data.EnableTrapsEthernetCfmCrosscheckMepMissing = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.aaa_server"); value.Exists() {
- data.EnableTrapsAaaServer = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ethernet.cfm.crosscheck.mep-unknown"); !data.EnableTrapsEthernetCfmCrosscheckMepUnknown.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsEthernetCfmCrosscheckMepUnknown = types.BoolValue(true)
+ } else {
+ data.EnableTrapsEthernetCfmCrosscheckMepUnknown = types.BoolValue(false)
+ }
} else {
- data.EnableTrapsAaaServer = types.BoolValue(false)
+ data.EnableTrapsEthernetCfmCrosscheckMepUnknown = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.vdsl2line"); value.Exists() {
- data.EnableTrapsVdsl2line = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ethernet.cfm.crosscheck.service-up"); !data.EnableTrapsEthernetCfmCrosscheckServiceUp.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsEthernetCfmCrosscheckServiceUp = types.BoolValue(true)
+ } else {
+ data.EnableTrapsEthernetCfmCrosscheckServiceUp = types.BoolValue(false)
+ }
} else {
- data.EnableTrapsVdsl2line = types.BoolValue(false)
+ data.EnableTrapsEthernetCfmCrosscheckServiceUp = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.adslline"); value.Exists() {
- data.EnableTrapsAdslline = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ethernet.evc.create"); !data.EnableTrapsEthernetEvcCreate.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsEthernetEvcCreate = types.BoolValue(true)
+ } else {
+ data.EnableTrapsEthernetEvcCreate = types.BoolValue(false)
+ }
} else {
- data.EnableTrapsAdslline = types.BoolValue(false)
+ data.EnableTrapsEthernetEvcCreate = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.pki"); value.Exists() {
- data.EnableTrapsPki = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ethernet.evc.delete"); !data.EnableTrapsEthernetEvcDelete.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsEthernetEvcDelete = types.BoolValue(true)
+ } else {
+ data.EnableTrapsEthernetEvcDelete = types.BoolValue(false)
+ }
} else {
- data.EnableTrapsPki = types.BoolValue(false)
- }
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.alarms.alarm-type"); value.Exists() {
- data.EnableTrapsAlarmType = types.StringValue(value.String())
+ data.EnableTrapsEthernetEvcDelete = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.casa"); value.Exists() {
- data.EnableTrapsCasa = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ethernet.evc.status"); !data.EnableTrapsEthernetEvcStatus.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsEthernetEvcStatus = types.BoolValue(true)
+ } else {
+ data.EnableTrapsEthernetEvcStatus = types.BoolValue(false)
+ }
} else {
- data.EnableTrapsCasa = types.BoolValue(false)
+ data.EnableTrapsEthernetEvcStatus = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.cnpd"); value.Exists() {
- data.EnableTrapsCnpd = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.firewall.serverstatus"); !data.EnableTrapsFirewallServerstatus.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsFirewallServerstatus = types.BoolValue(true)
+ } else {
+ data.EnableTrapsFirewallServerstatus = types.BoolValue(false)
+ }
} else {
- data.EnableTrapsCnpd = types.BoolValue(false)
+ data.EnableTrapsFirewallServerstatus = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.dial"); value.Exists() {
- data.EnableTrapsDial = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.frame-relay-config.only-frame-relay.frame-relay"); !data.EnableTrapsFrameRelayConfigOnly.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsFrameRelayConfigOnly = types.BoolValue(true)
+ } else {
+ data.EnableTrapsFrameRelayConfigOnly = types.BoolValue(false)
+ }
} else {
- data.EnableTrapsDial = types.BoolValue(false)
+ data.EnableTrapsFrameRelayConfigOnly = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.dlsw"); value.Exists() {
- data.EnableTrapsDlsw = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.frame-relay-config.frame-relay-options.frame-relay.subif-configs.subif"); !data.EnableTrapsFrameRelayConfigSubifConfigs.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsFrameRelayConfigSubifConfigs = types.BoolValue(true)
+ } else {
+ data.EnableTrapsFrameRelayConfigSubifConfigs = types.BoolValue(false)
+ }
} else {
- data.EnableTrapsDlsw = types.BoolValue(false)
+ data.EnableTrapsFrameRelayConfigSubifConfigs = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ds1"); value.Exists() {
- data.EnableTrapsDs1 = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.frame-relay.subif.count"); value.Exists() && !data.EnableTrapsFrameRelaySubifCount.IsNull() {
+ data.EnableTrapsFrameRelaySubifCount = types.Int64Value(value.Int())
} else {
- data.EnableTrapsDs1 = types.BoolValue(false)
+ data.EnableTrapsFrameRelaySubifCount = types.Int64Null()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.dsp.card-status"); value.Exists() {
- data.EnableTrapsDspCardStatus = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.frame-relay.subif.interval"); value.Exists() && !data.EnableTrapsFrameRelaySubifInterval.IsNull() {
+ data.EnableTrapsFrameRelaySubifInterval = types.Int64Value(value.Int())
} else {
- data.EnableTrapsDspCardStatus = types.BoolValue(false)
+ data.EnableTrapsFrameRelaySubifInterval = types.Int64Null()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.dsp.oper-state"); value.Exists() {
- data.EnableTrapsDspOperState = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.frame-relay-config.frame-relay-options.frame-relay.multilink.bundle-mismatch"); !data.EnableTrapsFrameRelayConfigBundleMismatch.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsFrameRelayConfigBundleMismatch = types.BoolValue(true)
+ } else {
+ data.EnableTrapsFrameRelayConfigBundleMismatch = types.BoolValue(false)
+ }
} else {
- data.EnableTrapsDspOperState = types.BoolValue(false)
+ data.EnableTrapsFrameRelayConfigBundleMismatch = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.entity-sensor"); value.Exists() {
- data.EnableTrapsEntitySensor = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.frame-relay.multilink.bundle-mismatch"); !data.EnableTrapsFrameRelayMultilinkBundleMismatch.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsFrameRelayMultilinkBundleMismatch = types.BoolValue(true)
+ } else {
+ data.EnableTrapsFrameRelayMultilinkBundleMismatch = types.BoolValue(false)
+ }
} else {
- data.EnableTrapsEntitySensor = types.BoolValue(false)
+ data.EnableTrapsFrameRelayMultilinkBundleMismatch = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.entity-state"); value.Exists() {
- data.EnableTrapsEntityState = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ip.local.pool"); !data.EnableTrapsIpLocalPool.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsIpLocalPool = types.BoolValue(true)
+ } else {
+ data.EnableTrapsIpLocalPool = types.BoolValue(false)
+ }
} else {
- data.EnableTrapsEntityState = types.BoolValue(false)
+ data.EnableTrapsIpLocalPool = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.entity-qfp.mem-res-thresh"); value.Exists() {
- data.EnableTrapsEntityQfpMemResThresh = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.isdn.call-information"); !data.EnableTrapsIsdnCallInformation.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsIsdnCallInformation = types.BoolValue(true)
+ } else {
+ data.EnableTrapsIsdnCallInformation = types.BoolValue(false)
+ }
} else {
- data.EnableTrapsEntityQfpMemResThresh = types.BoolValue(false)
+ data.EnableTrapsIsdnCallInformation = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.entity-qfp.throughput-notif"); value.Exists() {
- data.EnableTrapsEntityQfpThroughputNotif = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.isdn.chan-not-avail"); !data.EnableTrapsIsdnChanNotAvail.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsIsdnChanNotAvail = types.BoolValue(true)
+ } else {
+ data.EnableTrapsIsdnChanNotAvail = types.BoolValue(false)
+ }
} else {
- data.EnableTrapsEntityQfpThroughputNotif = types.BoolValue(false)
+ data.EnableTrapsIsdnChanNotAvail = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ether-oam"); value.Exists() {
- data.EnableTrapsEtherOam = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.isdn.ietf"); !data.EnableTrapsIsdnIetf.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsIsdnIetf = types.BoolValue(true)
+ } else {
+ data.EnableTrapsIsdnIetf = types.BoolValue(false)
+ }
} else {
- data.EnableTrapsEtherOam = types.BoolValue(false)
+ data.EnableTrapsIsdnIetf = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ethernet.cfm.alarm"); value.Exists() {
- data.EnableTrapsEthernetCfmAlarm = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.isdn.layer2"); !data.EnableTrapsIsdnLayer2.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsIsdnLayer2 = types.BoolValue(true)
+ } else {
+ data.EnableTrapsIsdnLayer2 = types.BoolValue(false)
+ }
} else {
- data.EnableTrapsEthernetCfmAlarm = types.BoolValue(false)
+ data.EnableTrapsIsdnLayer2 = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ethernet.cfm.cc.config"); value.Exists() {
- data.EnableTrapsEthernetCfmCcConfig = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.l2tun.session"); !data.EnableTrapsL2tunSession.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsL2tunSession = types.BoolValue(true)
+ } else {
+ data.EnableTrapsL2tunSession = types.BoolValue(false)
+ }
} else {
- data.EnableTrapsEthernetCfmCcConfig = types.BoolValue(false)
+ data.EnableTrapsL2tunSession = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ethernet.cfm.cc.cross-connect"); value.Exists() {
- data.EnableTrapsEthernetCfmCcCrossConnect = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.l2tun.tunnel"); !data.EnableTrapsL2tunTunnel.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsL2tunTunnel = types.BoolValue(true)
+ } else {
+ data.EnableTrapsL2tunTunnel = types.BoolValue(false)
+ }
} else {
- data.EnableTrapsEthernetCfmCcCrossConnect = types.BoolValue(false)
+ data.EnableTrapsL2tunTunnel = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ethernet.cfm.cc.loop"); value.Exists() {
- data.EnableTrapsEthernetCfmCcLoop = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.l2tun.pseudowire.status"); !data.EnableTrapsL2tunPseudowireStatus.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsL2tunPseudowireStatus = types.BoolValue(true)
+ } else {
+ data.EnableTrapsL2tunPseudowireStatus = types.BoolValue(false)
+ }
} else {
- data.EnableTrapsEthernetCfmCcLoop = types.BoolValue(false)
+ data.EnableTrapsL2tunPseudowireStatus = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ethernet.cfm.cc.mep-down"); value.Exists() {
- data.EnableTrapsEthernetCfmCcMepDown = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.pimstdmib.neighbor-loss"); !data.EnableTrapsPimstdmibNeighborLoss.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsPimstdmibNeighborLoss = types.BoolValue(true)
+ } else {
+ data.EnableTrapsPimstdmibNeighborLoss = types.BoolValue(false)
+ }
} else {
- data.EnableTrapsEthernetCfmCcMepDown = types.BoolValue(false)
+ data.EnableTrapsPimstdmibNeighborLoss = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ethernet.cfm.cc.mep-up"); value.Exists() {
- data.EnableTrapsEthernetCfmCcMepUp = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.pimstdmib.invalid-register"); !data.EnableTrapsPimstdmibInvalidRegister.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsPimstdmibInvalidRegister = types.BoolValue(true)
+ } else {
+ data.EnableTrapsPimstdmibInvalidRegister = types.BoolValue(false)
+ }
} else {
- data.EnableTrapsEthernetCfmCcMepUp = types.BoolValue(false)
+ data.EnableTrapsPimstdmibInvalidRegister = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ethernet.cfm.crosscheck.mep-missing"); value.Exists() {
- data.EnableTrapsEthernetCfmCrosscheckMepMissing = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.pimstdmib.invalid-join-prune"); !data.EnableTrapsPimstdmibInvalidJoinPrune.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsPimstdmibInvalidJoinPrune = types.BoolValue(true)
+ } else {
+ data.EnableTrapsPimstdmibInvalidJoinPrune = types.BoolValue(false)
+ }
} else {
- data.EnableTrapsEthernetCfmCrosscheckMepMissing = types.BoolValue(false)
+ data.EnableTrapsPimstdmibInvalidJoinPrune = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ethernet.cfm.crosscheck.mep-unknown"); value.Exists() {
- data.EnableTrapsEthernetCfmCrosscheckMepUnknown = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.pimstdmib.rp-mapping-change"); !data.EnableTrapsPimstdmibRpMappingChange.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsPimstdmibRpMappingChange = types.BoolValue(true)
+ } else {
+ data.EnableTrapsPimstdmibRpMappingChange = types.BoolValue(false)
+ }
} else {
- data.EnableTrapsEthernetCfmCrosscheckMepUnknown = types.BoolValue(false)
+ data.EnableTrapsPimstdmibRpMappingChange = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ethernet.cfm.crosscheck.service-up"); value.Exists() {
- data.EnableTrapsEthernetCfmCrosscheckServiceUp = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.pimstdmib.interface-election"); !data.EnableTrapsPimstdmibInterfaceElection.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsPimstdmibInterfaceElection = types.BoolValue(true)
+ } else {
+ data.EnableTrapsPimstdmibInterfaceElection = types.BoolValue(false)
+ }
} else {
- data.EnableTrapsEthernetCfmCrosscheckServiceUp = types.BoolValue(false)
+ data.EnableTrapsPimstdmibInterfaceElection = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ethernet.evc.create"); value.Exists() {
- data.EnableTrapsEthernetEvcCreate = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.pfr"); !data.EnableTrapsPfr.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsPfr = types.BoolValue(true)
+ } else {
+ data.EnableTrapsPfr = types.BoolValue(false)
+ }
} else {
- data.EnableTrapsEthernetEvcCreate = types.BoolValue(false)
+ data.EnableTrapsPfr = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ethernet.evc.delete"); value.Exists() {
- data.EnableTrapsEthernetEvcDelete = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.pppoe"); !data.EnableTrapsPppoe.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsPppoe = types.BoolValue(true)
+ } else {
+ data.EnableTrapsPppoe = types.BoolValue(false)
+ }
} else {
- data.EnableTrapsEthernetEvcDelete = types.BoolValue(false)
+ data.EnableTrapsPppoe = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ethernet.evc.status"); value.Exists() {
- data.EnableTrapsEthernetEvcStatus = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.resource-policy"); !data.EnableTrapsResourcePolicy.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsResourcePolicy = types.BoolValue(true)
+ } else {
+ data.EnableTrapsResourcePolicy = types.BoolValue(false)
+ }
} else {
- data.EnableTrapsEthernetEvcStatus = types.BoolValue(false)
+ data.EnableTrapsResourcePolicy = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.firewall.serverstatus"); value.Exists() {
- data.EnableTrapsFirewallServerstatus = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.rsvp"); !data.EnableTrapsRsvp.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsRsvp = types.BoolValue(true)
+ } else {
+ data.EnableTrapsRsvp = types.BoolValue(false)
+ }
} else {
- data.EnableTrapsFirewallServerstatus = types.BoolValue(false)
+ data.EnableTrapsRsvp = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.frame-relay-config.only-frame-relay.frame-relay"); value.Exists() {
- data.EnableTrapsFrameRelayConfigOnly = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.vrrp"); !data.EnableTrapsVrrp.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsVrrp = types.BoolValue(true)
+ } else {
+ data.EnableTrapsVrrp = types.BoolValue(false)
+ }
} else {
- data.EnableTrapsFrameRelayConfigOnly = types.BoolValue(false)
+ data.EnableTrapsVrrp = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.frame-relay-config.frame-relay-options.frame-relay.subif-configs.subif"); value.Exists() {
- data.EnableTrapsFrameRelayConfigSubifConfigs = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.sonet"); !data.EnableTrapsSonet.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsSonet = types.BoolValue(true)
+ } else {
+ data.EnableTrapsSonet = types.BoolValue(false)
+ }
} else {
- data.EnableTrapsFrameRelayConfigSubifConfigs = types.BoolValue(false)
- }
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.frame-relay.subif.count"); value.Exists() {
- data.EnableTrapsFrameRelaySubifCount = types.Int64Value(value.Int())
- }
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.frame-relay.subif.interval"); value.Exists() {
- data.EnableTrapsFrameRelaySubifInterval = types.Int64Value(value.Int())
+ data.EnableTrapsSonet = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.frame-relay-config.frame-relay-options.frame-relay.multilink.bundle-mismatch"); value.Exists() {
- data.EnableTrapsFrameRelayConfigBundleMismatch = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.srp"); !data.EnableTrapsSrp.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsSrp = types.BoolValue(true)
+ } else {
+ data.EnableTrapsSrp = types.BoolValue(false)
+ }
} else {
- data.EnableTrapsFrameRelayConfigBundleMismatch = types.BoolValue(false)
- }
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.frame-relay.multilink.bundle-mismatch"); value.Exists() {
- data.EnableTrapsFrameRelayMultilinkBundleMismatch = types.BoolValue(true)
- } else {
- data.EnableTrapsFrameRelayMultilinkBundleMismatch = types.BoolValue(false)
- }
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ip.local.pool"); value.Exists() {
- data.EnableTrapsIpLocalPool = types.BoolValue(true)
- } else {
- data.EnableTrapsIpLocalPool = types.BoolValue(false)
- }
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.isdn.call-information"); value.Exists() {
- data.EnableTrapsIsdnCallInformation = types.BoolValue(true)
- } else {
- data.EnableTrapsIsdnCallInformation = types.BoolValue(false)
- }
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.isdn.chan-not-avail"); value.Exists() {
- data.EnableTrapsIsdnChanNotAvail = types.BoolValue(true)
- } else {
- data.EnableTrapsIsdnChanNotAvail = types.BoolValue(false)
- }
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.isdn.ietf"); value.Exists() {
- data.EnableTrapsIsdnIetf = types.BoolValue(true)
- } else {
- data.EnableTrapsIsdnIetf = types.BoolValue(false)
- }
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.isdn.layer2"); value.Exists() {
- data.EnableTrapsIsdnLayer2 = types.BoolValue(true)
- } else {
- data.EnableTrapsIsdnLayer2 = types.BoolValue(false)
- }
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.l2tun.session"); value.Exists() {
- data.EnableTrapsL2tunSession = types.BoolValue(true)
- } else {
- data.EnableTrapsL2tunSession = types.BoolValue(false)
- }
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.l2tun.tunnel"); value.Exists() {
- data.EnableTrapsL2tunTunnel = types.BoolValue(true)
- } else {
- data.EnableTrapsL2tunTunnel = types.BoolValue(false)
- }
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.l2tun.pseudowire.status"); value.Exists() {
- data.EnableTrapsL2tunPseudowireStatus = types.BoolValue(true)
- } else {
- data.EnableTrapsL2tunPseudowireStatus = types.BoolValue(false)
- }
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.pimstdmib.neighbor-loss"); value.Exists() {
- data.EnableTrapsPimstdmibNeighborLoss = types.BoolValue(true)
- } else {
- data.EnableTrapsPimstdmibNeighborLoss = types.BoolValue(false)
- }
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.pimstdmib.invalid-register"); value.Exists() {
- data.EnableTrapsPimstdmibInvalidRegister = types.BoolValue(true)
- } else {
- data.EnableTrapsPimstdmibInvalidRegister = types.BoolValue(false)
- }
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.pimstdmib.invalid-join-prune"); value.Exists() {
- data.EnableTrapsPimstdmibInvalidJoinPrune = types.BoolValue(true)
- } else {
- data.EnableTrapsPimstdmibInvalidJoinPrune = types.BoolValue(false)
- }
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.pimstdmib.rp-mapping-change"); value.Exists() {
- data.EnableTrapsPimstdmibRpMappingChange = types.BoolValue(true)
- } else {
- data.EnableTrapsPimstdmibRpMappingChange = types.BoolValue(false)
- }
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.pimstdmib.interface-election"); value.Exists() {
- data.EnableTrapsPimstdmibInterfaceElection = types.BoolValue(true)
- } else {
- data.EnableTrapsPimstdmibInterfaceElection = types.BoolValue(false)
- }
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.pfr"); value.Exists() {
- data.EnableTrapsPfr = types.BoolValue(true)
- } else {
- data.EnableTrapsPfr = types.BoolValue(false)
- }
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.pppoe"); value.Exists() {
- data.EnableTrapsPppoe = types.BoolValue(true)
- } else {
- data.EnableTrapsPppoe = types.BoolValue(false)
- }
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.resource-policy"); value.Exists() {
- data.EnableTrapsResourcePolicy = types.BoolValue(true)
- } else {
- data.EnableTrapsResourcePolicy = types.BoolValue(false)
- }
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.rsvp"); value.Exists() {
- data.EnableTrapsRsvp = types.BoolValue(true)
- } else {
- data.EnableTrapsRsvp = types.BoolValue(false)
- }
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.vrrp"); value.Exists() {
- data.EnableTrapsVrrp = types.BoolValue(true)
- } else {
- data.EnableTrapsVrrp = types.BoolValue(false)
- }
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.sonet"); value.Exists() {
- data.EnableTrapsSonet = types.BoolValue(true)
- } else {
- data.EnableTrapsSonet = types.BoolValue(false)
- }
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.srp"); value.Exists() {
- data.EnableTrapsSrp = types.BoolValue(true)
- } else {
- data.EnableTrapsSrp = types.BoolValue(false)
+ data.EnableTrapsSrp = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.voice"); value.Exists() {
- data.EnableTrapsVoice = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.voice"); !data.EnableTrapsVoice.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsVoice = types.BoolValue(true)
+ } else {
+ data.EnableTrapsVoice = types.BoolValue(false)
+ }
} else {
- data.EnableTrapsVoice = types.BoolValue(false)
+ data.EnableTrapsVoice = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.bgp"); value.Exists() {
- data.EnableTrapsBgp = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.bgp"); !data.EnableTrapsBgp.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsBgp = types.BoolValue(true)
+ } else {
+ data.EnableTrapsBgp = types.BoolValue(false)
+ }
} else {
- data.EnableTrapsBgp = types.BoolValue(false)
+ data.EnableTrapsBgp = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.bgp-traps.cbgp2"); value.Exists() {
- data.EnableTrapsCbgp2 = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.bgp-traps.cbgp2"); !data.EnableTrapsCbgp2.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsCbgp2 = types.BoolValue(true)
+ } else {
+ data.EnableTrapsCbgp2 = types.BoolValue(false)
+ }
} else {
- data.EnableTrapsCbgp2 = types.BoolValue(false)
+ data.EnableTrapsCbgp2 = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ospfv3.errors"); value.Exists() {
- data.EnableTrapsOspfv3Errors = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ospfv3.errors"); !data.EnableTrapsOspfv3Errors.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsOspfv3Errors = types.BoolValue(true)
+ } else {
+ data.EnableTrapsOspfv3Errors = types.BoolValue(false)
+ }
} else {
- data.EnableTrapsOspfv3Errors = types.BoolValue(false)
+ data.EnableTrapsOspfv3Errors = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ospfv3.state-change"); value.Exists() {
- data.EnableTrapsOspfv3StateChange = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ospfv3.state-change"); !data.EnableTrapsOspfv3StateChange.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsOspfv3StateChange = types.BoolValue(true)
+ } else {
+ data.EnableTrapsOspfv3StateChange = types.BoolValue(false)
+ }
} else {
- data.EnableTrapsOspfv3StateChange = types.BoolValue(false)
+ data.EnableTrapsOspfv3StateChange = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:source-interface.informs.GigabitEthernet"); value.Exists() {
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:source-interface.informs.GigabitEthernet"); value.Exists() && !data.SourceInterfaceInformsGigabitEthernet.IsNull() {
data.SourceInterfaceInformsGigabitEthernet = types.StringValue(value.String())
+ } else {
+ data.SourceInterfaceInformsGigabitEthernet = types.StringNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:source-interface.informs.TenGigabitEthernet"); value.Exists() {
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:source-interface.informs.TenGigabitEthernet"); value.Exists() && !data.SourceInterfaceInformsTenGigabitEthernet.IsNull() {
data.SourceInterfaceInformsTenGigabitEthernet = types.StringValue(value.String())
+ } else {
+ data.SourceInterfaceInformsTenGigabitEthernet = types.StringNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:source-interface.informs.FortyGigabitEthernet"); value.Exists() {
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:source-interface.informs.FortyGigabitEthernet"); value.Exists() && !data.SourceInterfaceInformsFortyGigabitEthernet.IsNull() {
data.SourceInterfaceInformsFortyGigabitEthernet = types.StringValue(value.String())
+ } else {
+ data.SourceInterfaceInformsFortyGigabitEthernet = types.StringNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:source-interface.informs.HundredGigE"); value.Exists() {
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:source-interface.informs.HundredGigE"); value.Exists() && !data.SourceInterfaceInformsHundredGigE.IsNull() {
data.SourceInterfaceInformsHundredGigE = types.StringValue(value.String())
+ } else {
+ data.SourceInterfaceInformsHundredGigE = types.StringNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:source-interface.informs.Loopback"); value.Exists() {
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:source-interface.informs.Loopback"); value.Exists() && !data.SourceInterfaceInformsLoopback.IsNull() {
data.SourceInterfaceInformsLoopback = types.Int64Value(value.Int())
+ } else {
+ data.SourceInterfaceInformsLoopback = types.Int64Null()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:source-interface.informs.Port-channel"); value.Exists() {
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:source-interface.informs.Port-channel"); value.Exists() && !data.SourceInterfaceInformsPortChannel.IsNull() {
data.SourceInterfaceInformsPortChannel = types.Int64Value(value.Int())
+ } else {
+ data.SourceInterfaceInformsPortChannel = types.Int64Null()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:source-interface.informs.Port-channel-subinterface.Port-channel"); value.Exists() {
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:source-interface.informs.Port-channel-subinterface.Port-channel"); value.Exists() && !data.SourceInterfaceInformsPortChannelSubinterface.IsNull() {
data.SourceInterfaceInformsPortChannelSubinterface = types.StringValue(value.String())
+ } else {
+ data.SourceInterfaceInformsPortChannelSubinterface = types.StringNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:source-interface.informs.Vlan"); value.Exists() {
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:source-interface.informs.Vlan"); value.Exists() && !data.SourceInterfaceInformsVlan.IsNull() {
data.SourceInterfaceInformsVlan = types.Int64Value(value.Int())
+ } else {
+ data.SourceInterfaceInformsVlan = types.Int64Null()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:source-interface.traps.GigabitEthernet"); value.Exists() {
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:source-interface.traps.GigabitEthernet"); value.Exists() && !data.SourceInterfaceTrapsGigabitEthernet.IsNull() {
data.SourceInterfaceTrapsGigabitEthernet = types.StringValue(value.String())
+ } else {
+ data.SourceInterfaceTrapsGigabitEthernet = types.StringNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:source-interface.traps.TenGigabitEthernet"); value.Exists() {
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:source-interface.traps.TenGigabitEthernet"); value.Exists() && !data.SourceInterfaceTrapsTenGigabitEthernet.IsNull() {
data.SourceInterfaceTrapsTenGigabitEthernet = types.StringValue(value.String())
+ } else {
+ data.SourceInterfaceTrapsTenGigabitEthernet = types.StringNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:source-interface.traps.FortyGigabitEthernet"); value.Exists() {
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:source-interface.traps.FortyGigabitEthernet"); value.Exists() && !data.SourceInterfaceTrapsFortyGigabitEthernet.IsNull() {
data.SourceInterfaceTrapsFortyGigabitEthernet = types.StringValue(value.String())
+ } else {
+ data.SourceInterfaceTrapsFortyGigabitEthernet = types.StringNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:source-interface.traps.HundredGigE"); value.Exists() {
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:source-interface.traps.HundredGigE"); value.Exists() && !data.SourceInterfaceTrapsHundredGigE.IsNull() {
data.SourceInterfaceTrapsHundredGigE = types.StringValue(value.String())
+ } else {
+ data.SourceInterfaceTrapsHundredGigE = types.StringNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:source-interface.traps.Loopback"); value.Exists() {
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:source-interface.traps.Loopback"); value.Exists() && !data.SourceInterfaceTrapsLoopback.IsNull() {
data.SourceInterfaceTrapsLoopback = types.Int64Value(value.Int())
+ } else {
+ data.SourceInterfaceTrapsLoopback = types.Int64Null()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:source-interface.traps.Port-channel"); value.Exists() {
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:source-interface.traps.Port-channel"); value.Exists() && !data.SourceInterfaceTrapsPortChannel.IsNull() {
data.SourceInterfaceTrapsPortChannel = types.Int64Value(value.Int())
+ } else {
+ data.SourceInterfaceTrapsPortChannel = types.Int64Null()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:source-interface.traps.Port-channel-subinterface.Port-channel"); value.Exists() {
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:source-interface.traps.Port-channel-subinterface.Port-channel"); value.Exists() && !data.SourceInterfaceTrapsPortChannelSubinterface.IsNull() {
data.SourceInterfaceTrapsPortChannelSubinterface = types.StringValue(value.String())
+ } else {
+ data.SourceInterfaceTrapsPortChannelSubinterface = types.StringNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:source-interface.traps.Vlan"); value.Exists() {
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:source-interface.traps.Vlan"); value.Exists() && !data.SourceInterfaceTrapsVlan.IsNull() {
data.SourceInterfaceTrapsVlan = types.Int64Value(value.Int())
+ } else {
+ data.SourceInterfaceTrapsVlan = types.Int64Null()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:trap-source.GigabitEthernet"); value.Exists() {
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:trap-source.GigabitEthernet"); value.Exists() && !data.TrapSourceGigabitEthernet.IsNull() {
data.TrapSourceGigabitEthernet = types.StringValue(value.String())
+ } else {
+ data.TrapSourceGigabitEthernet = types.StringNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:trap-source.TenGigabitEthernet"); value.Exists() {
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:trap-source.TenGigabitEthernet"); value.Exists() && !data.TrapSourceTenGigabitEthernet.IsNull() {
data.TrapSourceTenGigabitEthernet = types.StringValue(value.String())
+ } else {
+ data.TrapSourceTenGigabitEthernet = types.StringNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:trap-source.FortyGigabitEthernet"); value.Exists() {
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:trap-source.FortyGigabitEthernet"); value.Exists() && !data.TrapSourceFortyGigabitEthernet.IsNull() {
data.TrapSourceFortyGigabitEthernet = types.StringValue(value.String())
+ } else {
+ data.TrapSourceFortyGigabitEthernet = types.StringNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:trap-source.HundredGigE"); value.Exists() {
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:trap-source.HundredGigE"); value.Exists() && !data.TrapSourceHundredGigE.IsNull() {
data.TrapSourceHundredGigE = types.StringValue(value.String())
+ } else {
+ data.TrapSourceHundredGigE = types.StringNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:trap-source.Loopback"); value.Exists() {
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:trap-source.Loopback"); value.Exists() && !data.TrapSourceLoopback.IsNull() {
data.TrapSourceLoopback = types.Int64Value(value.Int())
+ } else {
+ data.TrapSourceLoopback = types.Int64Null()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:trap-source.Port-channel"); value.Exists() {
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:trap-source.Port-channel"); value.Exists() && !data.TrapSourcePortChannel.IsNull() {
data.TrapSourcePortChannel = types.Int64Value(value.Int())
+ } else {
+ data.TrapSourcePortChannel = types.Int64Null()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:trap-source.Port-channel-subinterface.Port-channel"); value.Exists() {
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:trap-source.Port-channel-subinterface.Port-channel"); value.Exists() && !data.TrapSourcePortChannelSubinterface.IsNull() {
data.TrapSourcePortChannelSubinterface = types.StringValue(value.String())
+ } else {
+ data.TrapSourcePortChannelSubinterface = types.StringNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:trap-source.Vlan"); value.Exists() {
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:trap-source.Vlan"); value.Exists() && !data.TrapSourceVlan.IsNull() {
data.TrapSourceVlan = types.Int64Value(value.Int())
+ } else {
+ data.TrapSourceVlan = types.Int64Null()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:community-config"); value.Exists() {
- data.SnmpCommunities = make([]SNMPServerSnmpCommunities, 0)
- value.ForEach(func(k, v gjson.Result) bool {
- item := SNMPServerSnmpCommunities{}
- if cValue := v.Get("name"); cValue.Exists() {
- item.Name = types.StringValue(cValue.String())
+ for i := range data.SnmpCommunities {
+ keys := [...]string{"name"}
+ keyValues := [...]string{data.SnmpCommunities[i].Name.ValueString()}
+
+ var r gjson.Result
+ res.Get(prefix + "Cisco-IOS-XE-snmp:community-config").ForEach(
+ func(_, v gjson.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := r.Get("view"); value.Exists() && !data.SnmpCommunities[i].View.IsNull() {
+ data.SnmpCommunities[i].View = types.StringValue(value.String())
+ } else {
+ data.SnmpCommunities[i].View = types.StringNull()
+ }
+ if value := r.Get("permission"); value.Exists() && !data.SnmpCommunities[i].Permission.IsNull() {
+ data.SnmpCommunities[i].Permission = types.StringValue(value.String())
+ } else {
+ data.SnmpCommunities[i].Permission = types.StringNull()
+ }
+ if value := r.Get("ipv6"); value.Exists() && !data.SnmpCommunities[i].Ipv6.IsNull() {
+ data.SnmpCommunities[i].Ipv6 = types.StringValue(value.String())
+ } else {
+ data.SnmpCommunities[i].Ipv6 = types.StringNull()
+ }
+ if value := r.Get("access-list-name"); value.Exists() && !data.SnmpCommunities[i].AccessListName.IsNull() {
+ data.SnmpCommunities[i].AccessListName = types.StringValue(value.String())
+ } else {
+ data.SnmpCommunities[i].AccessListName = types.StringNull()
+ }
+ }
+ for i := range data.Contexts {
+ keys := [...]string{"name"}
+ keyValues := [...]string{data.Contexts[i].Name.ValueString()}
+
+ var r gjson.Result
+ res.Get(prefix + "Cisco-IOS-XE-snmp:context").ForEach(
+ func(_, v gjson.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := r.Get("name"); value.Exists() && !data.Contexts[i].Name.IsNull() {
+ data.Contexts[i].Name = types.StringValue(value.String())
+ } else {
+ data.Contexts[i].Name = types.StringNull()
+ }
+ }
+ for i := range data.Views {
+ keys := [...]string{"name", "mib"}
+ keyValues := [...]string{data.Views[i].Name.ValueString(), data.Views[i].Mib.ValueString()}
+
+ var r gjson.Result
+ res.Get(prefix + "Cisco-IOS-XE-snmp:view").ForEach(
+ func(_, v gjson.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := r.Get("name"); value.Exists() && !data.Views[i].Name.IsNull() {
+ data.Views[i].Name = types.StringValue(value.String())
+ } else {
+ data.Views[i].Name = types.StringNull()
+ }
+ if value := r.Get("mib"); value.Exists() && !data.Views[i].Mib.IsNull() {
+ data.Views[i].Mib = types.StringValue(value.String())
+ } else {
+ data.Views[i].Mib = types.StringNull()
+ }
+ if value := r.Get("inc-exl"); value.Exists() && !data.Views[i].IncExl.IsNull() {
+ data.Views[i].IncExl = types.StringValue(value.String())
+ } else {
+ data.Views[i].IncExl = types.StringNull()
+ }
+ }
+ for i := range data.Groups {
+ keys := [...]string{"id"}
+ keyValues := [...]string{data.Groups[i].Name.ValueString()}
+
+ var r gjson.Result
+ res.Get(prefix + "Cisco-IOS-XE-snmp:group").ForEach(
+ func(_, v gjson.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := r.Get("id"); value.Exists() && !data.Groups[i].Name.IsNull() {
+ data.Groups[i].Name = types.StringValue(value.String())
+ } else {
+ data.Groups[i].Name = types.StringNull()
+ }
+ for ci := range data.Groups[i].V3Security {
+ keys := [...]string{"security-level"}
+ keyValues := [...]string{data.Groups[i].V3Security[ci].SecurityLevel.ValueString()}
+
+ var cr gjson.Result
+ r.Get("v3.security-level-list").ForEach(
+ func(_, v gjson.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ cr = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := cr.Get("security-level"); value.Exists() && !data.Groups[i].V3Security[ci].SecurityLevel.IsNull() {
+ data.Groups[i].V3Security[ci].SecurityLevel = types.StringValue(value.String())
+ } else {
+ data.Groups[i].V3Security[ci].SecurityLevel = types.StringNull()
}
- if cValue := v.Get("view"); cValue.Exists() {
- item.View = types.StringValue(cValue.String())
+ if value := cr.Get("context-node"); value.Exists() && !data.Groups[i].V3Security[ci].ContextNode.IsNull() {
+ data.Groups[i].V3Security[ci].ContextNode = types.StringValue(value.String())
+ } else {
+ data.Groups[i].V3Security[ci].ContextNode = types.StringNull()
}
- if cValue := v.Get("permission"); cValue.Exists() {
- item.Permission = types.StringValue(cValue.String())
+ if value := cr.Get("match-node"); value.Exists() && !data.Groups[i].V3Security[ci].MatchNode.IsNull() {
+ data.Groups[i].V3Security[ci].MatchNode = types.StringValue(value.String())
+ } else {
+ data.Groups[i].V3Security[ci].MatchNode = types.StringNull()
}
- if cValue := v.Get("ipv6"); cValue.Exists() {
- item.Ipv6 = types.StringValue(cValue.String())
+ if value := cr.Get("read-node"); value.Exists() && !data.Groups[i].V3Security[ci].ReadNode.IsNull() {
+ data.Groups[i].V3Security[ci].ReadNode = types.StringValue(value.String())
+ } else {
+ data.Groups[i].V3Security[ci].ReadNode = types.StringNull()
}
- if cValue := v.Get("access-list-name"); cValue.Exists() {
- item.AccessListName = types.StringValue(cValue.String())
+ if value := cr.Get("write-node"); value.Exists() && !data.Groups[i].V3Security[ci].WriteNode.IsNull() {
+ data.Groups[i].V3Security[ci].WriteNode = types.StringValue(value.String())
+ } else {
+ data.Groups[i].V3Security[ci].WriteNode = types.StringNull()
}
- data.SnmpCommunities = append(data.SnmpCommunities, item)
- return true
- })
- }
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:context"); value.Exists() {
- data.Contexts = make([]SNMPServerContexts, 0)
- value.ForEach(func(k, v gjson.Result) bool {
- item := SNMPServerContexts{}
- if cValue := v.Get("name"); cValue.Exists() {
- item.Name = types.StringValue(cValue.String())
+ if value := cr.Get("notify-node"); value.Exists() && !data.Groups[i].V3Security[ci].NotifyNode.IsNull() {
+ data.Groups[i].V3Security[ci].NotifyNode = types.StringValue(value.String())
+ } else {
+ data.Groups[i].V3Security[ci].NotifyNode = types.StringNull()
}
- data.Contexts = append(data.Contexts, item)
- return true
- })
- }
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:view"); value.Exists() {
- data.Views = make([]SNMPServerViews, 0)
- value.ForEach(func(k, v gjson.Result) bool {
- item := SNMPServerViews{}
- if cValue := v.Get("name"); cValue.Exists() {
- item.Name = types.StringValue(cValue.String())
+ if value := cr.Get("access-config.ipv6-acl"); value.Exists() && !data.Groups[i].V3Security[ci].AccessIpv6Acl.IsNull() {
+ data.Groups[i].V3Security[ci].AccessIpv6Acl = types.StringValue(value.String())
+ } else {
+ data.Groups[i].V3Security[ci].AccessIpv6Acl = types.StringNull()
}
- if cValue := v.Get("mib"); cValue.Exists() {
- item.Mib = types.StringValue(cValue.String())
+ if value := cr.Get("access-config.standard-acl"); value.Exists() && !data.Groups[i].V3Security[ci].AccessStandardAcl.IsNull() {
+ data.Groups[i].V3Security[ci].AccessStandardAcl = types.Int64Value(value.Int())
+ } else {
+ data.Groups[i].V3Security[ci].AccessStandardAcl = types.Int64Null()
}
- if cValue := v.Get("inc-exl"); cValue.Exists() {
- item.IncExl = types.StringValue(cValue.String())
+ if value := cr.Get("access-config.acl-name"); value.Exists() && !data.Groups[i].V3Security[ci].AccessAclName.IsNull() {
+ data.Groups[i].V3Security[ci].AccessAclName = types.StringValue(value.String())
+ } else {
+ data.Groups[i].V3Security[ci].AccessAclName = types.StringNull()
}
- data.Views = append(data.Views, item)
- return true
- })
+ }
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:group"); value.Exists() {
- data.Groups = make([]SNMPServerGroups, 0)
- value.ForEach(func(k, v gjson.Result) bool {
- item := SNMPServerGroups{}
- if cValue := v.Get("id"); cValue.Exists() {
- item.Name = types.StringValue(cValue.String())
- }
- if cValue := v.Get("v3.security-level-list"); cValue.Exists() {
- item.V3Security = make([]SNMPServerGroupsV3Security, 0)
- cValue.ForEach(func(ck, cv gjson.Result) bool {
- cItem := SNMPServerGroupsV3Security{}
- if ccValue := cv.Get("security-level"); ccValue.Exists() {
- cItem.SecurityLevel = types.StringValue(ccValue.String())
- }
- if ccValue := cv.Get("context-node"); ccValue.Exists() {
- cItem.ContextNode = types.StringValue(ccValue.String())
- }
- if ccValue := cv.Get("match-node"); ccValue.Exists() {
- cItem.MatchNode = types.StringValue(ccValue.String())
+ for i := range data.Users {
+ keys := [...]string{"username", "grpname"}
+ keyValues := [...]string{data.Users[i].Username.ValueString(), data.Users[i].Grpname.ValueString()}
+
+ var r gjson.Result
+ res.Get(prefix + "Cisco-IOS-XE-snmp:user.names").ForEach(
+ func(_, v gjson.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
}
- if ccValue := cv.Get("read-node"); ccValue.Exists() {
- cItem.ReadNode = types.StringValue(ccValue.String())
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := r.Get("username"); value.Exists() && !data.Users[i].Username.IsNull() {
+ data.Users[i].Username = types.StringValue(value.String())
+ } else {
+ data.Users[i].Username = types.StringNull()
+ }
+ if value := r.Get("grpname"); value.Exists() && !data.Users[i].Grpname.IsNull() {
+ data.Users[i].Grpname = types.StringValue(value.String())
+ } else {
+ data.Users[i].Grpname = types.StringNull()
+ }
+ if value := r.Get("v3.auth-config.algorithm"); value.Exists() && !data.Users[i].V3AuthAlgorithm.IsNull() {
+ data.Users[i].V3AuthAlgorithm = types.StringValue(value.String())
+ } else {
+ data.Users[i].V3AuthAlgorithm = types.StringNull()
+ }
+ if value := r.Get("v3.auth-config.priv-config.aes.algorithm"); value.Exists() && !data.Users[i].V3AuthPrivAesAlgorithm.IsNull() {
+ data.Users[i].V3AuthPrivAesAlgorithm = types.StringValue(value.String())
+ } else {
+ data.Users[i].V3AuthPrivAesAlgorithm = types.StringNull()
+ }
+ if value := r.Get("v3.auth-config.priv-config.aes.access-config.ipv6-acl"); value.Exists() && !data.Users[i].V3AuthPrivAesAccessIpv6Acl.IsNull() {
+ data.Users[i].V3AuthPrivAesAccessIpv6Acl = types.StringValue(value.String())
+ } else {
+ data.Users[i].V3AuthPrivAesAccessIpv6Acl = types.StringNull()
+ }
+ if value := r.Get("v3.auth-config.priv-config.aes.access-config.standard-acl"); value.Exists() && !data.Users[i].V3AuthPrivAesAccessStandardAcl.IsNull() {
+ data.Users[i].V3AuthPrivAesAccessStandardAcl = types.Int64Value(value.Int())
+ } else {
+ data.Users[i].V3AuthPrivAesAccessStandardAcl = types.Int64Null()
+ }
+ if value := r.Get("v3.auth-config.priv-config.aes.access-config.acl-name"); value.Exists() && !data.Users[i].V3AuthPrivAesAccessAclName.IsNull() {
+ data.Users[i].V3AuthPrivAesAccessAclName = types.StringValue(value.String())
+ } else {
+ data.Users[i].V3AuthPrivAesAccessAclName = types.StringNull()
+ }
+ if value := r.Get("v3.auth-config.priv-config.des.access-config.ipv6-acl"); value.Exists() && !data.Users[i].V3AuthPrivDesAccessIpv6Acl.IsNull() {
+ data.Users[i].V3AuthPrivDesAccessIpv6Acl = types.StringValue(value.String())
+ } else {
+ data.Users[i].V3AuthPrivDesAccessIpv6Acl = types.StringNull()
+ }
+ if value := r.Get("v3.auth-config.priv-config.des.access-config.standard-acl"); value.Exists() && !data.Users[i].V3AuthPrivDesAccessStandardAcl.IsNull() {
+ data.Users[i].V3AuthPrivDesAccessStandardAcl = types.Int64Value(value.Int())
+ } else {
+ data.Users[i].V3AuthPrivDesAccessStandardAcl = types.Int64Null()
+ }
+ if value := r.Get("v3.auth-config.priv-config.des.access-config.acl-name"); value.Exists() && !data.Users[i].V3AuthPrivDesAccessAclName.IsNull() {
+ data.Users[i].V3AuthPrivDesAccessAclName = types.StringValue(value.String())
+ } else {
+ data.Users[i].V3AuthPrivDesAccessAclName = types.StringNull()
+ }
+ if value := r.Get("v3.auth-config.priv-config.des3.access-config.ipv6-acl"); value.Exists() && !data.Users[i].V3AuthPrivDes3AccessIpv6Acl.IsNull() {
+ data.Users[i].V3AuthPrivDes3AccessIpv6Acl = types.StringValue(value.String())
+ } else {
+ data.Users[i].V3AuthPrivDes3AccessIpv6Acl = types.StringNull()
+ }
+ if value := r.Get("v3.auth-config.priv-config.des3.access-config.standard-acl"); value.Exists() && !data.Users[i].V3AuthPrivDes3AccessStandardAcl.IsNull() {
+ data.Users[i].V3AuthPrivDes3AccessStandardAcl = types.Int64Value(value.Int())
+ } else {
+ data.Users[i].V3AuthPrivDes3AccessStandardAcl = types.Int64Null()
+ }
+ if value := r.Get("v3.auth-config.priv-config.des3.access-config.acl-name"); value.Exists() && !data.Users[i].V3AuthPrivDes3AccessAclName.IsNull() {
+ data.Users[i].V3AuthPrivDes3AccessAclName = types.StringValue(value.String())
+ } else {
+ data.Users[i].V3AuthPrivDes3AccessAclName = types.StringNull()
+ }
+ if value := r.Get("v3.auth-config.access-config.ipv6-acl"); value.Exists() && !data.Users[i].V3AuthAccessIpv6Acl.IsNull() {
+ data.Users[i].V3AuthAccessIpv6Acl = types.StringValue(value.String())
+ } else {
+ data.Users[i].V3AuthAccessIpv6Acl = types.StringNull()
+ }
+ if value := r.Get("v3.auth-config.access-config.standard-acl"); value.Exists() && !data.Users[i].V3AuthAccessStandardAcl.IsNull() {
+ data.Users[i].V3AuthAccessStandardAcl = types.Int64Value(value.Int())
+ } else {
+ data.Users[i].V3AuthAccessStandardAcl = types.Int64Null()
+ }
+ if value := r.Get("v3.auth-config.access-config.acl-name"); value.Exists() && !data.Users[i].V3AuthAccessAclName.IsNull() {
+ data.Users[i].V3AuthAccessAclName = types.StringValue(value.String())
+ } else {
+ data.Users[i].V3AuthAccessAclName = types.StringNull()
+ }
+ }
+}
+
+// End of section. //template:end updateFromBody
+
+// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBodyXML
+
+func (data *SNMPServer) updateFromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:chassis-id"); value.Exists() && !data.ChassisId.IsNull() {
+ data.ChassisId = types.StringValue(value.String())
+ } else {
+ data.ChassisId = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:contact"); value.Exists() && !data.Contact.IsNull() {
+ data.Contact = types.StringValue(value.String())
+ } else {
+ data.Contact = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:ifindex/persist"); !data.IfindexPersist.IsNull() {
+ if value.Exists() {
+ data.IfindexPersist = types.BoolValue(true)
+ } else {
+ data.IfindexPersist = types.BoolValue(false)
+ }
+ } else {
+ data.IfindexPersist = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:location"); value.Exists() && !data.Location.IsNull() {
+ data.Location = types.StringValue(value.String())
+ } else {
+ data.Location = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:packetsize"); value.Exists() && !data.Packetsize.IsNull() {
+ data.Packetsize = types.Int64Value(value.Int())
+ } else {
+ data.Packetsize = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:queue-length"); value.Exists() && !data.QueueLength.IsNull() {
+ data.QueueLength = types.Int64Value(value.Int())
+ } else {
+ data.QueueLength = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/logging/getop"); !data.EnableLoggingGetop.IsNull() {
+ if value.Exists() {
+ data.EnableLoggingGetop = types.BoolValue(value.Bool())
+ }
+ } else {
+ data.EnableLoggingGetop = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/logging/setop"); !data.EnableLoggingSetop.IsNull() {
+ if value.Exists() {
+ data.EnableLoggingSetop = types.BoolValue(value.Bool())
+ }
+ } else {
+ data.EnableLoggingSetop = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/informs"); !data.EnableInforms.IsNull() {
+ if value.Exists() {
+ data.EnableInforms = types.BoolValue(true)
+ } else {
+ data.EnableInforms = types.BoolValue(false)
+ }
+ } else {
+ data.EnableInforms = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps"); !data.EnableTraps.IsNull() {
+ if value.Exists() {
+ data.EnableTraps = types.BoolValue(true)
+ } else {
+ data.EnableTraps = types.BoolValue(false)
+ }
+ } else {
+ data.EnableTraps = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/snmp/authentication"); !data.EnableTrapsSnmpAuthentication.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsSnmpAuthentication = types.BoolValue(true)
+ } else {
+ data.EnableTrapsSnmpAuthentication = types.BoolValue(false)
+ }
+ } else {
+ data.EnableTrapsSnmpAuthentication = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/snmp/coldstart"); !data.EnableTrapsSnmpColdstart.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsSnmpColdstart = types.BoolValue(true)
+ } else {
+ data.EnableTrapsSnmpColdstart = types.BoolValue(false)
+ }
+ } else {
+ data.EnableTrapsSnmpColdstart = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/snmp/linkdown"); !data.EnableTrapsSnmpLinkdown.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsSnmpLinkdown = types.BoolValue(true)
+ } else {
+ data.EnableTrapsSnmpLinkdown = types.BoolValue(false)
+ }
+ } else {
+ data.EnableTrapsSnmpLinkdown = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/snmp/linkup"); !data.EnableTrapsSnmpLinkup.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsSnmpLinkup = types.BoolValue(true)
+ } else {
+ data.EnableTrapsSnmpLinkup = types.BoolValue(false)
+ }
+ } else {
+ data.EnableTrapsSnmpLinkup = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/snmp/warmstart"); !data.EnableTrapsSnmpWarmstart.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsSnmpWarmstart = types.BoolValue(true)
+ } else {
+ data.EnableTrapsSnmpWarmstart = types.BoolValue(false)
+ }
+ } else {
+ data.EnableTrapsSnmpWarmstart = types.BoolNull()
+ }
+ for i := range data.Hosts {
+ keys := [...]string{"ip-address"}
+ keyValues := [...]string{data.Hosts[i].IpAddress.ValueString()}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:host-config/ip-community").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
}
- if ccValue := cv.Get("write-node"); ccValue.Exists() {
- cItem.WriteNode = types.StringValue(ccValue.String())
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, "ip-address"); value.Exists() && !data.Hosts[i].IpAddress.IsNull() {
+ data.Hosts[i].IpAddress = types.StringValue(value.String())
+ } else {
+ data.Hosts[i].IpAddress = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "version"); value.Exists() && !data.Hosts[i].Version.IsNull() {
+ data.Hosts[i].Version = types.StringValue(value.String())
+ } else {
+ data.Hosts[i].Version = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "encryption"); value.Exists() && !data.Hosts[i].Encryption.IsNull() {
+ data.Hosts[i].Encryption = types.StringValue(value.String())
+ } else {
+ data.Hosts[i].Encryption = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "security-level"); value.Exists() && !data.Hosts[i].SecurityLevel.IsNull() {
+ data.Hosts[i].SecurityLevel = types.StringValue(value.String())
+ } else {
+ data.Hosts[i].SecurityLevel = types.StringNull()
+ }
+ }
+ for i := range data.VrfHosts {
+ keys := [...]string{"ip-address", "vrf"}
+ keyValues := [...]string{data.VrfHosts[i].IpAddress.ValueString(), data.VrfHosts[i].Vrf.ValueString()}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:host-config/ip-vrf-community").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
}
- if ccValue := cv.Get("notify-node"); ccValue.Exists() {
- cItem.NotifyNode = types.StringValue(ccValue.String())
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, "ip-address"); value.Exists() && !data.VrfHosts[i].IpAddress.IsNull() {
+ data.VrfHosts[i].IpAddress = types.StringValue(value.String())
+ } else {
+ data.VrfHosts[i].IpAddress = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "vrf"); value.Exists() && !data.VrfHosts[i].Vrf.IsNull() {
+ data.VrfHosts[i].Vrf = types.StringValue(value.String())
+ } else {
+ data.VrfHosts[i].Vrf = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "version"); value.Exists() && !data.VrfHosts[i].Version.IsNull() {
+ data.VrfHosts[i].Version = types.StringValue(value.String())
+ } else {
+ data.VrfHosts[i].Version = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "encryption"); value.Exists() && !data.VrfHosts[i].Encryption.IsNull() {
+ data.VrfHosts[i].Encryption = types.StringValue(value.String())
+ } else {
+ data.VrfHosts[i].Encryption = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "security-level"); value.Exists() && !data.VrfHosts[i].SecurityLevel.IsNull() {
+ data.VrfHosts[i].SecurityLevel = types.StringValue(value.String())
+ } else {
+ data.VrfHosts[i].SecurityLevel = types.StringNull()
+ }
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:system-shutdown"); !data.SystemShutdown.IsNull() {
+ if value.Exists() {
+ data.SystemShutdown = types.BoolValue(true)
+ } else {
+ data.SystemShutdown = types.BoolValue(false)
+ }
+ } else {
+ data.SystemShutdown = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/flowmon"); !data.EnableTrapsFlowmon.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsFlowmon = types.BoolValue(true)
+ } else {
+ data.EnableTrapsFlowmon = types.BoolValue(false)
+ }
+ } else {
+ data.EnableTrapsFlowmon = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/entity-perf/throughput-notif"); !data.EnableTrapsEntityPerfThroughputNotif.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsEntityPerfThroughputNotif = types.BoolValue(true)
+ } else {
+ data.EnableTrapsEntityPerfThroughputNotif = types.BoolValue(false)
+ }
+ } else {
+ data.EnableTrapsEntityPerfThroughputNotif = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/call-home/message-send-fail"); !data.EnableTrapsCallHomeMessageSendFail.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsCallHomeMessageSendFail = types.BoolValue(true)
+ } else {
+ data.EnableTrapsCallHomeMessageSendFail = types.BoolValue(false)
+ }
+ } else {
+ data.EnableTrapsCallHomeMessageSendFail = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/call-home/server-fail"); !data.EnableTrapsCallHomeServerFail.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsCallHomeServerFail = types.BoolValue(true)
+ } else {
+ data.EnableTrapsCallHomeServerFail = types.BoolValue(false)
+ }
+ } else {
+ data.EnableTrapsCallHomeServerFail = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/tty"); !data.EnableTrapsTty.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsTty = types.BoolValue(true)
+ } else {
+ data.EnableTrapsTty = types.BoolValue(false)
+ }
+ } else {
+ data.EnableTrapsTty = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/Cisco-IOS-XE-ospfv3:ospfv3-config/state-change/enable"); !data.EnableTrapsOspfv3ConfigStateChange.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsOspfv3ConfigStateChange = types.BoolValue(true)
+ } else {
+ data.EnableTrapsOspfv3ConfigStateChange = types.BoolValue(false)
+ }
+ } else {
+ data.EnableTrapsOspfv3ConfigStateChange = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/Cisco-IOS-XE-ospfv3:ospfv3-config/errors/enable"); !data.EnableTrapsOspfv3ConfigErrors.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsOspfv3ConfigErrors = types.BoolValue(true)
+ } else {
+ data.EnableTrapsOspfv3ConfigErrors = types.BoolValue(false)
+ }
+ } else {
+ data.EnableTrapsOspfv3ConfigErrors = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/Cisco-IOS-XE-ospf:ospf-config/retransmit/enable"); !data.EnableTrapsOspfConfigRetransmit.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsOspfConfigRetransmit = types.BoolValue(true)
+ } else {
+ data.EnableTrapsOspfConfigRetransmit = types.BoolValue(false)
+ }
+ } else {
+ data.EnableTrapsOspfConfigRetransmit = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/Cisco-IOS-XE-ospf:ospf-config/lsa/enable"); !data.EnableTrapsOspfConfigLsa.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsOspfConfigLsa = types.BoolValue(true)
+ } else {
+ data.EnableTrapsOspfConfigLsa = types.BoolValue(false)
+ }
+ } else {
+ data.EnableTrapsOspfConfigLsa = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/Cisco-IOS-XE-ospf:ospf-config/cisco-specific/state-change/nssa-trans-change"); !data.EnableTrapsOspfNssaTransChange.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsOspfNssaTransChange = types.BoolValue(true)
+ } else {
+ data.EnableTrapsOspfNssaTransChange = types.BoolValue(false)
+ }
+ } else {
+ data.EnableTrapsOspfNssaTransChange = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/Cisco-IOS-XE-ospf:ospf-config/cisco-specific/state-change/shamlink/interface"); !data.EnableTrapsOspfShamlinkInterface.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsOspfShamlinkInterface = types.BoolValue(true)
+ } else {
+ data.EnableTrapsOspfShamlinkInterface = types.BoolValue(false)
+ }
+ } else {
+ data.EnableTrapsOspfShamlinkInterface = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/Cisco-IOS-XE-ospf:ospf-config/cisco-specific/state-change/shamlink/neighbor"); !data.EnableTrapsOspfShamlinkNeighbor.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsOspfShamlinkNeighbor = types.BoolValue(true)
+ } else {
+ data.EnableTrapsOspfShamlinkNeighbor = types.BoolValue(false)
+ }
+ } else {
+ data.EnableTrapsOspfShamlinkNeighbor = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/Cisco-IOS-XE-ospf:ospf-config/cisco-specific/errors/enable"); !data.EnableTrapsOspfErrorsEnable.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsOspfErrorsEnable = types.BoolValue(true)
+ } else {
+ data.EnableTrapsOspfErrorsEnable = types.BoolValue(false)
+ }
+ } else {
+ data.EnableTrapsOspfErrorsEnable = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/Cisco-IOS-XE-ospf:ospf-config/cisco-specific/retransmit/enable"); !data.EnableTrapsOspfRetransmitEnable.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsOspfRetransmitEnable = types.BoolValue(true)
+ } else {
+ data.EnableTrapsOspfRetransmitEnable = types.BoolValue(false)
+ }
+ } else {
+ data.EnableTrapsOspfRetransmitEnable = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/Cisco-IOS-XE-ospf:ospf-config/cisco-specific/lsa/enable"); !data.EnableTrapsOspfLsaEnable.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsOspfLsaEnable = types.BoolValue(true)
+ } else {
+ data.EnableTrapsOspfLsaEnable = types.BoolValue(false)
+ }
+ } else {
+ data.EnableTrapsOspfLsaEnable = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/eigrp"); !data.EnableTrapsEigrp.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsEigrp = types.BoolValue(true)
+ } else {
+ data.EnableTrapsEigrp = types.BoolValue(false)
+ }
+ } else {
+ data.EnableTrapsEigrp = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/auth-framework/sec-violation"); !data.EnableTrapsAuthFrameworkSecViolation.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsAuthFrameworkSecViolation = types.BoolValue(true)
+ } else {
+ data.EnableTrapsAuthFrameworkSecViolation = types.BoolValue(false)
+ }
+ } else {
+ data.EnableTrapsAuthFrameworkSecViolation = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/rep"); !data.EnableTrapsRep.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsRep = types.BoolValue(true)
+ } else {
+ data.EnableTrapsRep = types.BoolValue(false)
+ }
+ } else {
+ data.EnableTrapsRep = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/vtp"); !data.EnableTrapsVtp.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsVtp = types.BoolValue(true)
+ } else {
+ data.EnableTrapsVtp = types.BoolValue(false)
+ }
+ } else {
+ data.EnableTrapsVtp = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/vlancreate"); !data.EnableTrapsVlancreate.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsVlancreate = types.BoolValue(true)
+ } else {
+ data.EnableTrapsVlancreate = types.BoolValue(false)
+ }
+ } else {
+ data.EnableTrapsVlancreate = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/vlandelete"); !data.EnableTrapsVlandelete.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsVlandelete = types.BoolValue(true)
+ } else {
+ data.EnableTrapsVlandelete = types.BoolValue(false)
+ }
+ } else {
+ data.EnableTrapsVlandelete = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/port-security"); !data.EnableTrapsPortSecurity.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsPortSecurity = types.BoolValue(true)
+ } else {
+ data.EnableTrapsPortSecurity = types.BoolValue(false)
+ }
+ } else {
+ data.EnableTrapsPortSecurity = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/license"); !data.EnableTrapsLicense.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsLicense = types.BoolValue(true)
+ } else {
+ data.EnableTrapsLicense = types.BoolValue(false)
+ }
+ } else {
+ data.EnableTrapsLicense = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/smart-licenseing/smart-license"); !data.EnableTrapsSmartLicense.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsSmartLicense = types.BoolValue(true)
+ } else {
+ data.EnableTrapsSmartLicense = types.BoolValue(false)
+ }
+ } else {
+ data.EnableTrapsSmartLicense = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/cpu/threshold"); !data.EnableTrapsCpuThreshold.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsCpuThreshold = types.BoolValue(true)
+ } else {
+ data.EnableTrapsCpuThreshold = types.BoolValue(false)
+ }
+ } else {
+ data.EnableTrapsCpuThreshold = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/memory/bufferpeak"); !data.EnableTrapsMemoryBufferpeak.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsMemoryBufferpeak = types.BoolValue(true)
+ } else {
+ data.EnableTrapsMemoryBufferpeak = types.BoolValue(false)
+ }
+ } else {
+ data.EnableTrapsMemoryBufferpeak = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/stackwise"); !data.EnableTrapsStackwise.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsStackwise = types.BoolValue(true)
+ } else {
+ data.EnableTrapsStackwise = types.BoolValue(false)
+ }
+ } else {
+ data.EnableTrapsStackwise = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/udld/link-fail-rpt"); !data.EnableTrapsUdldLinkFailRpt.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsUdldLinkFailRpt = types.BoolValue(true)
+ } else {
+ data.EnableTrapsUdldLinkFailRpt = types.BoolValue(false)
+ }
+ } else {
+ data.EnableTrapsUdldLinkFailRpt = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/udld/status-change"); !data.EnableTrapsUdldStatusChange.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsUdldStatusChange = types.BoolValue(true)
+ } else {
+ data.EnableTrapsUdldStatusChange = types.BoolValue(false)
+ }
+ } else {
+ data.EnableTrapsUdldStatusChange = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/fru-ctrl"); !data.EnableTrapsFruCtrl.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsFruCtrl = types.BoolValue(true)
+ } else {
+ data.EnableTrapsFruCtrl = types.BoolValue(false)
+ }
+ } else {
+ data.EnableTrapsFruCtrl = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/flash/insertion"); !data.EnableTrapsFlashInsertion.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsFlashInsertion = types.BoolValue(true)
+ } else {
+ data.EnableTrapsFlashInsertion = types.BoolValue(false)
+ }
+ } else {
+ data.EnableTrapsFlashInsertion = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/flash/removal"); !data.EnableTrapsFlashRemoval.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsFlashRemoval = types.BoolValue(true)
+ } else {
+ data.EnableTrapsFlashRemoval = types.BoolValue(false)
+ }
+ } else {
+ data.EnableTrapsFlashRemoval = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/flash/lowspace"); !data.EnableTrapsFlashLowspace.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsFlashLowspace = types.BoolValue(true)
+ } else {
+ data.EnableTrapsFlashLowspace = types.BoolValue(false)
+ }
+ } else {
+ data.EnableTrapsFlashLowspace = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/energywise"); !data.EnableTrapsEnergywise.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsEnergywise = types.BoolValue(true)
+ } else {
+ data.EnableTrapsEnergywise = types.BoolValue(false)
+ }
+ } else {
+ data.EnableTrapsEnergywise = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/power-ethernet/group"); value.Exists() && !data.EnableTrapsPowerEthernetGroup.IsNull() {
+ data.EnableTrapsPowerEthernetGroup = types.StringValue(value.String())
+ } else {
+ data.EnableTrapsPowerEthernetGroup = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/power-ethernet/police"); !data.EnableTrapsPowerEthernetPolice.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsPowerEthernetPolice = types.BoolValue(true)
+ } else {
+ data.EnableTrapsPowerEthernetPolice = types.BoolValue(false)
+ }
+ } else {
+ data.EnableTrapsPowerEthernetPolice = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/entity"); !data.EnableTrapsEntity.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsEntity = types.BoolValue(true)
+ } else {
+ data.EnableTrapsEntity = types.BoolValue(false)
+ }
+ } else {
+ data.EnableTrapsEntity = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/pw/vc"); !data.EnableTrapsPwVc.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsPwVc = types.BoolValue(true)
+ } else {
+ data.EnableTrapsPwVc = types.BoolValue(false)
+ }
+ } else {
+ data.EnableTrapsPwVc = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/envmon"); !data.EnableTrapsEnvmon.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsEnvmon = types.BoolValue(true)
+ } else {
+ data.EnableTrapsEnvmon = types.BoolValue(false)
+ }
+ } else {
+ data.EnableTrapsEnvmon = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/cef/resource-failure"); !data.EnableTrapsCefResourceFailure.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsCefResourceFailure = types.BoolValue(true)
+ } else {
+ data.EnableTrapsCefResourceFailure = types.BoolValue(false)
+ }
+ } else {
+ data.EnableTrapsCefResourceFailure = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/cef/peer-state-change"); !data.EnableTrapsCefPeerStateChange.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsCefPeerStateChange = types.BoolValue(true)
+ } else {
+ data.EnableTrapsCefPeerStateChange = types.BoolValue(false)
+ }
+ } else {
+ data.EnableTrapsCefPeerStateChange = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/cef/peer-fib-state-change"); !data.EnableTrapsCefPeerFibStateChange.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsCefPeerFibStateChange = types.BoolValue(true)
+ } else {
+ data.EnableTrapsCefPeerFibStateChange = types.BoolValue(false)
+ }
+ } else {
+ data.EnableTrapsCefPeerFibStateChange = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/cef/inconsistency"); !data.EnableTrapsCefInconsistency.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsCefInconsistency = types.BoolValue(true)
+ } else {
+ data.EnableTrapsCefInconsistency = types.BoolValue(false)
+ }
+ } else {
+ data.EnableTrapsCefInconsistency = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/isis"); !data.EnableTrapsIsis.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsIsis = types.BoolValue(true)
+ } else {
+ data.EnableTrapsIsis = types.BoolValue(false)
+ }
+ } else {
+ data.EnableTrapsIsis = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ipsla"); !data.EnableTrapsIpsla.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsIpsla = types.BoolValue(true)
+ } else {
+ data.EnableTrapsIpsla = types.BoolValue(false)
+ }
+ } else {
+ data.EnableTrapsIpsla = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/entity-diag/boot-up-fail"); !data.EnableTrapsEntityDiagBootUpFail.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsEntityDiagBootUpFail = types.BoolValue(true)
+ } else {
+ data.EnableTrapsEntityDiagBootUpFail = types.BoolValue(false)
+ }
+ } else {
+ data.EnableTrapsEntityDiagBootUpFail = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/entity-diag/hm-test-recover"); !data.EnableTrapsEntityDiagHmTestRecover.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsEntityDiagHmTestRecover = types.BoolValue(true)
+ } else {
+ data.EnableTrapsEntityDiagHmTestRecover = types.BoolValue(false)
+ }
+ } else {
+ data.EnableTrapsEntityDiagHmTestRecover = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/entity-diag/hm-thresh-reached"); !data.EnableTrapsEntityDiagHmThreshReached.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsEntityDiagHmThreshReached = types.BoolValue(true)
+ } else {
+ data.EnableTrapsEntityDiagHmThreshReached = types.BoolValue(false)
+ }
+ } else {
+ data.EnableTrapsEntityDiagHmThreshReached = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/entity-diag/scheduled-test-fail"); !data.EnableTrapsEntityDiagScheduledTestFail.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsEntityDiagScheduledTestFail = types.BoolValue(true)
+ } else {
+ data.EnableTrapsEntityDiagScheduledTestFail = types.BoolValue(false)
+ }
+ } else {
+ data.EnableTrapsEntityDiagScheduledTestFail = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/bfd"); !data.EnableTrapsBfd.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsBfd = types.BoolValue(true)
+ } else {
+ data.EnableTrapsBfd = types.BoolValue(false)
+ }
+ } else {
+ data.EnableTrapsBfd = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ike/policy/add"); !data.EnableTrapsIkePolicyAdd.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsIkePolicyAdd = types.BoolValue(true)
+ } else {
+ data.EnableTrapsIkePolicyAdd = types.BoolValue(false)
+ }
+ } else {
+ data.EnableTrapsIkePolicyAdd = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ike/policy/delete"); !data.EnableTrapsIkePolicyDelete.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsIkePolicyDelete = types.BoolValue(true)
+ } else {
+ data.EnableTrapsIkePolicyDelete = types.BoolValue(false)
+ }
+ } else {
+ data.EnableTrapsIkePolicyDelete = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ike/tunnel/start"); !data.EnableTrapsIkeTunnelStart.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsIkeTunnelStart = types.BoolValue(true)
+ } else {
+ data.EnableTrapsIkeTunnelStart = types.BoolValue(false)
+ }
+ } else {
+ data.EnableTrapsIkeTunnelStart = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ike/tunnel/stop"); !data.EnableTrapsIkeTunnelStop.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsIkeTunnelStop = types.BoolValue(true)
+ } else {
+ data.EnableTrapsIkeTunnelStop = types.BoolValue(false)
+ }
+ } else {
+ data.EnableTrapsIkeTunnelStop = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ipsec/cryptomap/add"); !data.EnableTrapsIpsecCryptomapAdd.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsIpsecCryptomapAdd = types.BoolValue(true)
+ } else {
+ data.EnableTrapsIpsecCryptomapAdd = types.BoolValue(false)
+ }
+ } else {
+ data.EnableTrapsIpsecCryptomapAdd = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ipsec/cryptomap/attach"); !data.EnableTrapsIpsecCryptomapAttach.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsIpsecCryptomapAttach = types.BoolValue(true)
+ } else {
+ data.EnableTrapsIpsecCryptomapAttach = types.BoolValue(false)
+ }
+ } else {
+ data.EnableTrapsIpsecCryptomapAttach = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ipsec/cryptomap/delete"); !data.EnableTrapsIpsecCryptomapDelete.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsIpsecCryptomapDelete = types.BoolValue(true)
+ } else {
+ data.EnableTrapsIpsecCryptomapDelete = types.BoolValue(false)
+ }
+ } else {
+ data.EnableTrapsIpsecCryptomapDelete = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ipsec/cryptomap/detach"); !data.EnableTrapsIpsecCryptomapDetach.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsIpsecCryptomapDetach = types.BoolValue(true)
+ } else {
+ data.EnableTrapsIpsecCryptomapDetach = types.BoolValue(false)
+ }
+ } else {
+ data.EnableTrapsIpsecCryptomapDetach = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ipsec/tunnel/start"); !data.EnableTrapsIpsecTunnelStart.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsIpsecTunnelStart = types.BoolValue(true)
+ } else {
+ data.EnableTrapsIpsecTunnelStart = types.BoolValue(false)
+ }
+ } else {
+ data.EnableTrapsIpsecTunnelStart = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ipsec/tunnel/stop"); !data.EnableTrapsIpsecTunnelStop.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsIpsecTunnelStop = types.BoolValue(true)
+ } else {
+ data.EnableTrapsIpsecTunnelStop = types.BoolValue(false)
+ }
+ } else {
+ data.EnableTrapsIpsecTunnelStop = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ipsec/too-many-sas"); !data.EnableTrapsIpsecTooManySas.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsIpsecTooManySas = types.BoolValue(true)
+ } else {
+ data.EnableTrapsIpsecTooManySas = types.BoolValue(false)
+ }
+ } else {
+ data.EnableTrapsIpsecTooManySas = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/config-copy"); !data.EnableTrapsConfigCopy.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsConfigCopy = types.BoolValue(true)
+ } else {
+ data.EnableTrapsConfigCopy = types.BoolValue(false)
+ }
+ } else {
+ data.EnableTrapsConfigCopy = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/config"); !data.EnableTrapsConfig.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsConfig = types.BoolValue(true)
+ } else {
+ data.EnableTrapsConfig = types.BoolValue(false)
+ }
+ } else {
+ data.EnableTrapsConfig = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/config-ctid"); !data.EnableTrapsConfigCtid.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsConfigCtid = types.BoolValue(true)
+ } else {
+ data.EnableTrapsConfigCtid = types.BoolValue(false)
+ }
+ } else {
+ data.EnableTrapsConfigCtid = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/dhcp"); !data.EnableTrapsDhcp.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsDhcp = types.BoolValue(true)
+ } else {
+ data.EnableTrapsDhcp = types.BoolValue(false)
+ }
+ } else {
+ data.EnableTrapsDhcp = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/event-manager"); !data.EnableTrapsEventManager.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsEventManager = types.BoolValue(true)
+ } else {
+ data.EnableTrapsEventManager = types.BoolValue(false)
+ }
+ } else {
+ data.EnableTrapsEventManager = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/hsrp"); !data.EnableTrapsHsrp.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsHsrp = types.BoolValue(true)
+ } else {
+ data.EnableTrapsHsrp = types.BoolValue(false)
+ }
+ } else {
+ data.EnableTrapsHsrp = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ipmulticast"); !data.EnableTrapsIpmulticast.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsIpmulticast = types.BoolValue(true)
+ } else {
+ data.EnableTrapsIpmulticast = types.BoolValue(false)
+ }
+ } else {
+ data.EnableTrapsIpmulticast = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/msdp"); !data.EnableTrapsMsdp.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsMsdp = types.BoolValue(true)
+ } else {
+ data.EnableTrapsMsdp = types.BoolValue(false)
+ }
+ } else {
+ data.EnableTrapsMsdp = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/Cisco-IOS-XE-ospf:ospf-config/state-change/enable"); !data.EnableTrapsOspfConfigStateChange.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsOspfConfigStateChange = types.BoolValue(true)
+ } else {
+ data.EnableTrapsOspfConfigStateChange = types.BoolValue(false)
+ }
+ } else {
+ data.EnableTrapsOspfConfigStateChange = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/Cisco-IOS-XE-ospf:ospf-config/errors/enable"); !data.EnableTrapsOspfConfigErrors.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsOspfConfigErrors = types.BoolValue(true)
+ } else {
+ data.EnableTrapsOspfConfigErrors = types.BoolValue(false)
+ }
+ } else {
+ data.EnableTrapsOspfConfigErrors = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/pim/invalid-pim-message"); !data.EnableTrapsPimInvalidPimMessage.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsPimInvalidPimMessage = types.BoolValue(true)
+ } else {
+ data.EnableTrapsPimInvalidPimMessage = types.BoolValue(false)
+ }
+ } else {
+ data.EnableTrapsPimInvalidPimMessage = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/pim/neighbor-change"); !data.EnableTrapsPimNeighborChange.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsPimNeighborChange = types.BoolValue(true)
+ } else {
+ data.EnableTrapsPimNeighborChange = types.BoolValue(false)
+ }
+ } else {
+ data.EnableTrapsPimNeighborChange = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/pim/rp-mapping-change"); !data.EnableTrapsPimRpMappingChange.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsPimRpMappingChange = types.BoolValue(true)
+ } else {
+ data.EnableTrapsPimRpMappingChange = types.BoolValue(false)
+ }
+ } else {
+ data.EnableTrapsPimRpMappingChange = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/bridge/newroot"); !data.EnableTrapsBridgeNewroot.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsBridgeNewroot = types.BoolValue(true)
+ } else {
+ data.EnableTrapsBridgeNewroot = types.BoolValue(false)
+ }
+ } else {
+ data.EnableTrapsBridgeNewroot = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/bridge/topologychange"); !data.EnableTrapsBridgeTopologychange.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsBridgeTopologychange = types.BoolValue(true)
+ } else {
+ data.EnableTrapsBridgeTopologychange = types.BoolValue(false)
+ }
+ } else {
+ data.EnableTrapsBridgeTopologychange = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/stpx/inconsistency"); !data.EnableTrapsStpxInconsistency.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsStpxInconsistency = types.BoolValue(true)
+ } else {
+ data.EnableTrapsStpxInconsistency = types.BoolValue(false)
+ }
+ } else {
+ data.EnableTrapsStpxInconsistency = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/stpx/root-inconsistency"); !data.EnableTrapsStpxRootInconsistency.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsStpxRootInconsistency = types.BoolValue(true)
+ } else {
+ data.EnableTrapsStpxRootInconsistency = types.BoolValue(false)
+ }
+ } else {
+ data.EnableTrapsStpxRootInconsistency = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/stpx/loop-inconsistency"); !data.EnableTrapsStpxLoopInconsistency.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsStpxLoopInconsistency = types.BoolValue(true)
+ } else {
+ data.EnableTrapsStpxLoopInconsistency = types.BoolValue(false)
+ }
+ } else {
+ data.EnableTrapsStpxLoopInconsistency = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/syslog"); !data.EnableTrapsSyslog.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsSyslog = types.BoolValue(true)
+ } else {
+ data.EnableTrapsSyslog = types.BoolValue(false)
+ }
+ } else {
+ data.EnableTrapsSyslog = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/"); !data.EnableTrapsBgpCbgp2.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsBgpCbgp2 = types.BoolValue(true)
+ } else {
+ data.EnableTrapsBgpCbgp2 = types.BoolValue(false)
+ }
+ } else {
+ data.EnableTrapsBgpCbgp2 = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/nhrp/nhs"); !data.EnableTrapsNhrpNhs.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsNhrpNhs = types.BoolValue(true)
+ } else {
+ data.EnableTrapsNhrpNhs = types.BoolValue(false)
+ }
+ } else {
+ data.EnableTrapsNhrpNhs = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/nhrp/nhc"); !data.EnableTrapsNhrpNhc.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsNhrpNhc = types.BoolValue(true)
+ } else {
+ data.EnableTrapsNhrpNhc = types.BoolValue(false)
+ }
+ } else {
+ data.EnableTrapsNhrpNhc = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/nhrp/nhp"); !data.EnableTrapsNhrpNhp.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsNhrpNhp = types.BoolValue(true)
+ } else {
+ data.EnableTrapsNhrpNhp = types.BoolValue(false)
+ }
+ } else {
+ data.EnableTrapsNhrpNhp = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/nhrp/quota-exceeded"); !data.EnableTrapsNhrpQuotaExceeded.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsNhrpQuotaExceeded = types.BoolValue(true)
+ } else {
+ data.EnableTrapsNhrpQuotaExceeded = types.BoolValue(false)
+ }
+ } else {
+ data.EnableTrapsNhrpQuotaExceeded = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/mpls/traffic-eng"); !data.EnableTrapsMplsTrafficEng.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsMplsTrafficEng = types.BoolValue(true)
+ } else {
+ data.EnableTrapsMplsTrafficEng = types.BoolValue(false)
+ }
+ } else {
+ data.EnableTrapsMplsTrafficEng = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/mpls"); !data.EnableTrapsMpls.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsMpls = types.BoolValue(true)
+ } else {
+ data.EnableTrapsMpls = types.BoolValue(false)
+ }
+ } else {
+ data.EnableTrapsMpls = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/mpls/vpn"); !data.EnableTrapsMplsVpn.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsMplsVpn = types.BoolValue(true)
+ } else {
+ data.EnableTrapsMplsVpn = types.BoolValue(false)
+ }
+ } else {
+ data.EnableTrapsMplsVpn = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/mpls/rfc"); !data.EnableTrapsMplsRfc.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsMplsRfc = types.BoolValue(true)
+ } else {
+ data.EnableTrapsMplsRfc = types.BoolValue(false)
+ }
+ } else {
+ data.EnableTrapsMplsRfc = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/mpls/rfc/ldp"); !data.EnableTrapsMplsRfcLdp.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsMplsRfcLdp = types.BoolValue(true)
+ } else {
+ data.EnableTrapsMplsRfcLdp = types.BoolValue(false)
+ }
+ } else {
+ data.EnableTrapsMplsRfcLdp = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/mpls/ldp"); !data.EnableTrapsMplsLdp.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsMplsLdp = types.BoolValue(true)
+ } else {
+ data.EnableTrapsMplsLdp = types.BoolValue(false)
+ }
+ } else {
+ data.EnableTrapsMplsLdp = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/mpls/fast-reroute/protected"); !data.EnableTrapsFastRerouteProtected.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsFastRerouteProtected = types.BoolValue(true)
+ } else {
+ data.EnableTrapsFastRerouteProtected = types.BoolValue(false)
+ }
+ } else {
+ data.EnableTrapsFastRerouteProtected = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/local-auth"); !data.EnableTrapsLocalAuth.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsLocalAuth = types.BoolValue(true)
+ } else {
+ data.EnableTrapsLocalAuth = types.BoolValue(false)
+ }
+ } else {
+ data.EnableTrapsLocalAuth = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/vlan-membership"); !data.EnableTrapsVlanMembership.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsVlanMembership = types.BoolValue(true)
+ } else {
+ data.EnableTrapsVlanMembership = types.BoolValue(false)
+ }
+ } else {
+ data.EnableTrapsVlanMembership = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/errdisable"); !data.EnableTrapsErrdisable.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsErrdisable = types.BoolValue(true)
+ } else {
+ data.EnableTrapsErrdisable = types.BoolValue(false)
+ }
+ } else {
+ data.EnableTrapsErrdisable = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/rf"); !data.EnableTrapsRf.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsRf = types.BoolValue(true)
+ } else {
+ data.EnableTrapsRf = types.BoolValue(false)
+ }
+ } else {
+ data.EnableTrapsRf = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/transceiver/all"); !data.EnableTrapsTransceiverAll.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsTransceiverAll = types.BoolValue(true)
+ } else {
+ data.EnableTrapsTransceiverAll = types.BoolValue(false)
+ }
+ } else {
+ data.EnableTrapsTransceiverAll = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/bulkstat/collection"); !data.EnableTrapsBulkstatCollection.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsBulkstatCollection = types.BoolValue(true)
+ } else {
+ data.EnableTrapsBulkstatCollection = types.BoolValue(false)
+ }
+ } else {
+ data.EnableTrapsBulkstatCollection = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/bulkstat/transfer"); !data.EnableTrapsBulkstatTransfer.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsBulkstatTransfer = types.BoolValue(true)
+ } else {
+ data.EnableTrapsBulkstatTransfer = types.BoolValue(false)
+ }
+ } else {
+ data.EnableTrapsBulkstatTransfer = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/mac-notification/change"); !data.EnableTrapsMacNotificationChange.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsMacNotificationChange = types.BoolValue(true)
+ } else {
+ data.EnableTrapsMacNotificationChange = types.BoolValue(false)
+ }
+ } else {
+ data.EnableTrapsMacNotificationChange = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/mac-notification/move"); !data.EnableTrapsMacNotificationMove.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsMacNotificationMove = types.BoolValue(true)
+ } else {
+ data.EnableTrapsMacNotificationMove = types.BoolValue(false)
+ }
+ } else {
+ data.EnableTrapsMacNotificationMove = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/mac-notification/threshold"); !data.EnableTrapsMacNotificationThreshold.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsMacNotificationThreshold = types.BoolValue(true)
+ } else {
+ data.EnableTrapsMacNotificationThreshold = types.BoolValue(false)
+ }
+ } else {
+ data.EnableTrapsMacNotificationThreshold = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/vrfmib/vrf-up"); !data.EnableTrapsVrfmibVrfUp.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsVrfmibVrfUp = types.BoolValue(true)
+ } else {
+ data.EnableTrapsVrfmibVrfUp = types.BoolValue(false)
+ }
+ } else {
+ data.EnableTrapsVrfmibVrfUp = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/vrfmib/vrf-down"); !data.EnableTrapsVrfmibVrfDown.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsVrfmibVrfDown = types.BoolValue(true)
+ } else {
+ data.EnableTrapsVrfmibVrfDown = types.BoolValue(false)
+ }
+ } else {
+ data.EnableTrapsVrfmibVrfDown = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/vrfmib/vnet-trunk-up"); !data.EnableTrapsVrfmibVnetTrunkUp.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsVrfmibVnetTrunkUp = types.BoolValue(true)
+ } else {
+ data.EnableTrapsVrfmibVnetTrunkUp = types.BoolValue(false)
+ }
+ } else {
+ data.EnableTrapsVrfmibVnetTrunkUp = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/vrfmib/vnet-trunk-down"); !data.EnableTrapsVrfmibVnetTrunkDown.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsVrfmibVnetTrunkDown = types.BoolValue(true)
+ } else {
+ data.EnableTrapsVrfmibVnetTrunkDown = types.BoolValue(false)
+ }
+ } else {
+ data.EnableTrapsVrfmibVnetTrunkDown = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/mvpn"); !data.EnableTrapsMvpn.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsMvpn = types.BoolValue(true)
+ } else {
+ data.EnableTrapsMvpn = types.BoolValue(false)
+ }
+ } else {
+ data.EnableTrapsMvpn = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/lisp"); !data.EnableTrapsLisp.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsLisp = types.BoolValue(true)
+ } else {
+ data.EnableTrapsLisp = types.BoolValue(false)
+ }
+ } else {
+ data.EnableTrapsLisp = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/aaa_server"); !data.EnableTrapsAaaServer.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsAaaServer = types.BoolValue(true)
+ } else {
+ data.EnableTrapsAaaServer = types.BoolValue(false)
+ }
+ } else {
+ data.EnableTrapsAaaServer = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/vdsl2line"); !data.EnableTrapsVdsl2line.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsVdsl2line = types.BoolValue(true)
+ } else {
+ data.EnableTrapsVdsl2line = types.BoolValue(false)
+ }
+ } else {
+ data.EnableTrapsVdsl2line = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/adslline"); !data.EnableTrapsAdslline.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsAdslline = types.BoolValue(true)
+ } else {
+ data.EnableTrapsAdslline = types.BoolValue(false)
+ }
+ } else {
+ data.EnableTrapsAdslline = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/pki"); !data.EnableTrapsPki.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsPki = types.BoolValue(true)
+ } else {
+ data.EnableTrapsPki = types.BoolValue(false)
+ }
+ } else {
+ data.EnableTrapsPki = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/alarms/alarm-type"); value.Exists() && !data.EnableTrapsAlarmType.IsNull() {
+ data.EnableTrapsAlarmType = types.StringValue(value.String())
+ } else {
+ data.EnableTrapsAlarmType = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/casa"); !data.EnableTrapsCasa.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsCasa = types.BoolValue(true)
+ } else {
+ data.EnableTrapsCasa = types.BoolValue(false)
+ }
+ } else {
+ data.EnableTrapsCasa = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/cnpd"); !data.EnableTrapsCnpd.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsCnpd = types.BoolValue(true)
+ } else {
+ data.EnableTrapsCnpd = types.BoolValue(false)
+ }
+ } else {
+ data.EnableTrapsCnpd = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/dial"); !data.EnableTrapsDial.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsDial = types.BoolValue(true)
+ } else {
+ data.EnableTrapsDial = types.BoolValue(false)
+ }
+ } else {
+ data.EnableTrapsDial = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/dlsw"); !data.EnableTrapsDlsw.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsDlsw = types.BoolValue(true)
+ } else {
+ data.EnableTrapsDlsw = types.BoolValue(false)
+ }
+ } else {
+ data.EnableTrapsDlsw = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ds1"); !data.EnableTrapsDs1.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsDs1 = types.BoolValue(true)
+ } else {
+ data.EnableTrapsDs1 = types.BoolValue(false)
+ }
+ } else {
+ data.EnableTrapsDs1 = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/dsp/card-status"); !data.EnableTrapsDspCardStatus.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsDspCardStatus = types.BoolValue(true)
+ } else {
+ data.EnableTrapsDspCardStatus = types.BoolValue(false)
+ }
+ } else {
+ data.EnableTrapsDspCardStatus = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/dsp/oper-state"); !data.EnableTrapsDspOperState.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsDspOperState = types.BoolValue(true)
+ } else {
+ data.EnableTrapsDspOperState = types.BoolValue(false)
+ }
+ } else {
+ data.EnableTrapsDspOperState = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/entity-sensor"); !data.EnableTrapsEntitySensor.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsEntitySensor = types.BoolValue(true)
+ } else {
+ data.EnableTrapsEntitySensor = types.BoolValue(false)
+ }
+ } else {
+ data.EnableTrapsEntitySensor = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/entity-state"); !data.EnableTrapsEntityState.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsEntityState = types.BoolValue(true)
+ } else {
+ data.EnableTrapsEntityState = types.BoolValue(false)
+ }
+ } else {
+ data.EnableTrapsEntityState = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/entity-qfp/mem-res-thresh"); !data.EnableTrapsEntityQfpMemResThresh.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsEntityQfpMemResThresh = types.BoolValue(true)
+ } else {
+ data.EnableTrapsEntityQfpMemResThresh = types.BoolValue(false)
+ }
+ } else {
+ data.EnableTrapsEntityQfpMemResThresh = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/entity-qfp/throughput-notif"); !data.EnableTrapsEntityQfpThroughputNotif.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsEntityQfpThroughputNotif = types.BoolValue(true)
+ } else {
+ data.EnableTrapsEntityQfpThroughputNotif = types.BoolValue(false)
+ }
+ } else {
+ data.EnableTrapsEntityQfpThroughputNotif = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ether-oam"); !data.EnableTrapsEtherOam.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsEtherOam = types.BoolValue(true)
+ } else {
+ data.EnableTrapsEtherOam = types.BoolValue(false)
+ }
+ } else {
+ data.EnableTrapsEtherOam = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ethernet/cfm/alarm"); !data.EnableTrapsEthernetCfmAlarm.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsEthernetCfmAlarm = types.BoolValue(true)
+ } else {
+ data.EnableTrapsEthernetCfmAlarm = types.BoolValue(false)
+ }
+ } else {
+ data.EnableTrapsEthernetCfmAlarm = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ethernet/cfm/cc/config"); !data.EnableTrapsEthernetCfmCcConfig.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsEthernetCfmCcConfig = types.BoolValue(true)
+ } else {
+ data.EnableTrapsEthernetCfmCcConfig = types.BoolValue(false)
+ }
+ } else {
+ data.EnableTrapsEthernetCfmCcConfig = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ethernet/cfm/cc/cross-connect"); !data.EnableTrapsEthernetCfmCcCrossConnect.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsEthernetCfmCcCrossConnect = types.BoolValue(true)
+ } else {
+ data.EnableTrapsEthernetCfmCcCrossConnect = types.BoolValue(false)
+ }
+ } else {
+ data.EnableTrapsEthernetCfmCcCrossConnect = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ethernet/cfm/cc/loop"); !data.EnableTrapsEthernetCfmCcLoop.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsEthernetCfmCcLoop = types.BoolValue(true)
+ } else {
+ data.EnableTrapsEthernetCfmCcLoop = types.BoolValue(false)
+ }
+ } else {
+ data.EnableTrapsEthernetCfmCcLoop = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ethernet/cfm/cc/mep-down"); !data.EnableTrapsEthernetCfmCcMepDown.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsEthernetCfmCcMepDown = types.BoolValue(true)
+ } else {
+ data.EnableTrapsEthernetCfmCcMepDown = types.BoolValue(false)
+ }
+ } else {
+ data.EnableTrapsEthernetCfmCcMepDown = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ethernet/cfm/cc/mep-up"); !data.EnableTrapsEthernetCfmCcMepUp.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsEthernetCfmCcMepUp = types.BoolValue(true)
+ } else {
+ data.EnableTrapsEthernetCfmCcMepUp = types.BoolValue(false)
+ }
+ } else {
+ data.EnableTrapsEthernetCfmCcMepUp = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ethernet/cfm/crosscheck/mep-missing"); !data.EnableTrapsEthernetCfmCrosscheckMepMissing.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsEthernetCfmCrosscheckMepMissing = types.BoolValue(true)
+ } else {
+ data.EnableTrapsEthernetCfmCrosscheckMepMissing = types.BoolValue(false)
+ }
+ } else {
+ data.EnableTrapsEthernetCfmCrosscheckMepMissing = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ethernet/cfm/crosscheck/mep-unknown"); !data.EnableTrapsEthernetCfmCrosscheckMepUnknown.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsEthernetCfmCrosscheckMepUnknown = types.BoolValue(true)
+ } else {
+ data.EnableTrapsEthernetCfmCrosscheckMepUnknown = types.BoolValue(false)
+ }
+ } else {
+ data.EnableTrapsEthernetCfmCrosscheckMepUnknown = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ethernet/cfm/crosscheck/service-up"); !data.EnableTrapsEthernetCfmCrosscheckServiceUp.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsEthernetCfmCrosscheckServiceUp = types.BoolValue(true)
+ } else {
+ data.EnableTrapsEthernetCfmCrosscheckServiceUp = types.BoolValue(false)
+ }
+ } else {
+ data.EnableTrapsEthernetCfmCrosscheckServiceUp = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ethernet/evc/create"); !data.EnableTrapsEthernetEvcCreate.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsEthernetEvcCreate = types.BoolValue(true)
+ } else {
+ data.EnableTrapsEthernetEvcCreate = types.BoolValue(false)
+ }
+ } else {
+ data.EnableTrapsEthernetEvcCreate = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ethernet/evc/delete"); !data.EnableTrapsEthernetEvcDelete.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsEthernetEvcDelete = types.BoolValue(true)
+ } else {
+ data.EnableTrapsEthernetEvcDelete = types.BoolValue(false)
+ }
+ } else {
+ data.EnableTrapsEthernetEvcDelete = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ethernet/evc/status"); !data.EnableTrapsEthernetEvcStatus.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsEthernetEvcStatus = types.BoolValue(true)
+ } else {
+ data.EnableTrapsEthernetEvcStatus = types.BoolValue(false)
+ }
+ } else {
+ data.EnableTrapsEthernetEvcStatus = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/firewall/serverstatus"); !data.EnableTrapsFirewallServerstatus.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsFirewallServerstatus = types.BoolValue(true)
+ } else {
+ data.EnableTrapsFirewallServerstatus = types.BoolValue(false)
+ }
+ } else {
+ data.EnableTrapsFirewallServerstatus = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/frame-relay-config/only-frame-relay/frame-relay"); !data.EnableTrapsFrameRelayConfigOnly.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsFrameRelayConfigOnly = types.BoolValue(true)
+ } else {
+ data.EnableTrapsFrameRelayConfigOnly = types.BoolValue(false)
+ }
+ } else {
+ data.EnableTrapsFrameRelayConfigOnly = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/frame-relay-config/frame-relay-options/frame-relay/subif-configs/subif"); !data.EnableTrapsFrameRelayConfigSubifConfigs.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsFrameRelayConfigSubifConfigs = types.BoolValue(true)
+ } else {
+ data.EnableTrapsFrameRelayConfigSubifConfigs = types.BoolValue(false)
+ }
+ } else {
+ data.EnableTrapsFrameRelayConfigSubifConfigs = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/frame-relay/subif/count"); value.Exists() && !data.EnableTrapsFrameRelaySubifCount.IsNull() {
+ data.EnableTrapsFrameRelaySubifCount = types.Int64Value(value.Int())
+ } else {
+ data.EnableTrapsFrameRelaySubifCount = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/frame-relay/subif/interval"); value.Exists() && !data.EnableTrapsFrameRelaySubifInterval.IsNull() {
+ data.EnableTrapsFrameRelaySubifInterval = types.Int64Value(value.Int())
+ } else {
+ data.EnableTrapsFrameRelaySubifInterval = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/frame-relay-config/frame-relay-options/frame-relay/multilink/bundle-mismatch"); !data.EnableTrapsFrameRelayConfigBundleMismatch.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsFrameRelayConfigBundleMismatch = types.BoolValue(true)
+ } else {
+ data.EnableTrapsFrameRelayConfigBundleMismatch = types.BoolValue(false)
+ }
+ } else {
+ data.EnableTrapsFrameRelayConfigBundleMismatch = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/frame-relay/multilink/bundle-mismatch"); !data.EnableTrapsFrameRelayMultilinkBundleMismatch.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsFrameRelayMultilinkBundleMismatch = types.BoolValue(true)
+ } else {
+ data.EnableTrapsFrameRelayMultilinkBundleMismatch = types.BoolValue(false)
+ }
+ } else {
+ data.EnableTrapsFrameRelayMultilinkBundleMismatch = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ip/local/pool"); !data.EnableTrapsIpLocalPool.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsIpLocalPool = types.BoolValue(true)
+ } else {
+ data.EnableTrapsIpLocalPool = types.BoolValue(false)
+ }
+ } else {
+ data.EnableTrapsIpLocalPool = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/isdn/call-information"); !data.EnableTrapsIsdnCallInformation.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsIsdnCallInformation = types.BoolValue(true)
+ } else {
+ data.EnableTrapsIsdnCallInformation = types.BoolValue(false)
+ }
+ } else {
+ data.EnableTrapsIsdnCallInformation = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/isdn/chan-not-avail"); !data.EnableTrapsIsdnChanNotAvail.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsIsdnChanNotAvail = types.BoolValue(true)
+ } else {
+ data.EnableTrapsIsdnChanNotAvail = types.BoolValue(false)
+ }
+ } else {
+ data.EnableTrapsIsdnChanNotAvail = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/isdn/ietf"); !data.EnableTrapsIsdnIetf.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsIsdnIetf = types.BoolValue(true)
+ } else {
+ data.EnableTrapsIsdnIetf = types.BoolValue(false)
+ }
+ } else {
+ data.EnableTrapsIsdnIetf = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/isdn/layer2"); !data.EnableTrapsIsdnLayer2.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsIsdnLayer2 = types.BoolValue(true)
+ } else {
+ data.EnableTrapsIsdnLayer2 = types.BoolValue(false)
+ }
+ } else {
+ data.EnableTrapsIsdnLayer2 = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/l2tun/session"); !data.EnableTrapsL2tunSession.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsL2tunSession = types.BoolValue(true)
+ } else {
+ data.EnableTrapsL2tunSession = types.BoolValue(false)
+ }
+ } else {
+ data.EnableTrapsL2tunSession = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/l2tun/tunnel"); !data.EnableTrapsL2tunTunnel.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsL2tunTunnel = types.BoolValue(true)
+ } else {
+ data.EnableTrapsL2tunTunnel = types.BoolValue(false)
+ }
+ } else {
+ data.EnableTrapsL2tunTunnel = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/l2tun/pseudowire/status"); !data.EnableTrapsL2tunPseudowireStatus.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsL2tunPseudowireStatus = types.BoolValue(true)
+ } else {
+ data.EnableTrapsL2tunPseudowireStatus = types.BoolValue(false)
+ }
+ } else {
+ data.EnableTrapsL2tunPseudowireStatus = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/pimstdmib/neighbor-loss"); !data.EnableTrapsPimstdmibNeighborLoss.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsPimstdmibNeighborLoss = types.BoolValue(true)
+ } else {
+ data.EnableTrapsPimstdmibNeighborLoss = types.BoolValue(false)
+ }
+ } else {
+ data.EnableTrapsPimstdmibNeighborLoss = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/pimstdmib/invalid-register"); !data.EnableTrapsPimstdmibInvalidRegister.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsPimstdmibInvalidRegister = types.BoolValue(true)
+ } else {
+ data.EnableTrapsPimstdmibInvalidRegister = types.BoolValue(false)
+ }
+ } else {
+ data.EnableTrapsPimstdmibInvalidRegister = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/pimstdmib/invalid-join-prune"); !data.EnableTrapsPimstdmibInvalidJoinPrune.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsPimstdmibInvalidJoinPrune = types.BoolValue(true)
+ } else {
+ data.EnableTrapsPimstdmibInvalidJoinPrune = types.BoolValue(false)
+ }
+ } else {
+ data.EnableTrapsPimstdmibInvalidJoinPrune = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/pimstdmib/rp-mapping-change"); !data.EnableTrapsPimstdmibRpMappingChange.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsPimstdmibRpMappingChange = types.BoolValue(true)
+ } else {
+ data.EnableTrapsPimstdmibRpMappingChange = types.BoolValue(false)
+ }
+ } else {
+ data.EnableTrapsPimstdmibRpMappingChange = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/pimstdmib/interface-election"); !data.EnableTrapsPimstdmibInterfaceElection.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsPimstdmibInterfaceElection = types.BoolValue(true)
+ } else {
+ data.EnableTrapsPimstdmibInterfaceElection = types.BoolValue(false)
+ }
+ } else {
+ data.EnableTrapsPimstdmibInterfaceElection = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/pfr"); !data.EnableTrapsPfr.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsPfr = types.BoolValue(true)
+ } else {
+ data.EnableTrapsPfr = types.BoolValue(false)
+ }
+ } else {
+ data.EnableTrapsPfr = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/pppoe"); !data.EnableTrapsPppoe.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsPppoe = types.BoolValue(true)
+ } else {
+ data.EnableTrapsPppoe = types.BoolValue(false)
+ }
+ } else {
+ data.EnableTrapsPppoe = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/resource-policy"); !data.EnableTrapsResourcePolicy.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsResourcePolicy = types.BoolValue(true)
+ } else {
+ data.EnableTrapsResourcePolicy = types.BoolValue(false)
+ }
+ } else {
+ data.EnableTrapsResourcePolicy = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/rsvp"); !data.EnableTrapsRsvp.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsRsvp = types.BoolValue(true)
+ } else {
+ data.EnableTrapsRsvp = types.BoolValue(false)
+ }
+ } else {
+ data.EnableTrapsRsvp = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/vrrp"); !data.EnableTrapsVrrp.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsVrrp = types.BoolValue(true)
+ } else {
+ data.EnableTrapsVrrp = types.BoolValue(false)
+ }
+ } else {
+ data.EnableTrapsVrrp = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/sonet"); !data.EnableTrapsSonet.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsSonet = types.BoolValue(true)
+ } else {
+ data.EnableTrapsSonet = types.BoolValue(false)
+ }
+ } else {
+ data.EnableTrapsSonet = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/srp"); !data.EnableTrapsSrp.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsSrp = types.BoolValue(true)
+ } else {
+ data.EnableTrapsSrp = types.BoolValue(false)
+ }
+ } else {
+ data.EnableTrapsSrp = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/voice"); !data.EnableTrapsVoice.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsVoice = types.BoolValue(true)
+ } else {
+ data.EnableTrapsVoice = types.BoolValue(false)
+ }
+ } else {
+ data.EnableTrapsVoice = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/bgp"); !data.EnableTrapsBgp.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsBgp = types.BoolValue(true)
+ } else {
+ data.EnableTrapsBgp = types.BoolValue(false)
+ }
+ } else {
+ data.EnableTrapsBgp = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/bgp-traps/cbgp2"); !data.EnableTrapsCbgp2.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsCbgp2 = types.BoolValue(true)
+ } else {
+ data.EnableTrapsCbgp2 = types.BoolValue(false)
+ }
+ } else {
+ data.EnableTrapsCbgp2 = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ospfv3/errors"); !data.EnableTrapsOspfv3Errors.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsOspfv3Errors = types.BoolValue(true)
+ } else {
+ data.EnableTrapsOspfv3Errors = types.BoolValue(false)
+ }
+ } else {
+ data.EnableTrapsOspfv3Errors = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ospfv3/state-change"); !data.EnableTrapsOspfv3StateChange.IsNull() {
+ if value.Exists() {
+ data.EnableTrapsOspfv3StateChange = types.BoolValue(true)
+ } else {
+ data.EnableTrapsOspfv3StateChange = types.BoolValue(false)
+ }
+ } else {
+ data.EnableTrapsOspfv3StateChange = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:source-interface/informs/GigabitEthernet"); value.Exists() && !data.SourceInterfaceInformsGigabitEthernet.IsNull() {
+ data.SourceInterfaceInformsGigabitEthernet = types.StringValue(value.String())
+ } else {
+ data.SourceInterfaceInformsGigabitEthernet = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:source-interface/informs/TenGigabitEthernet"); value.Exists() && !data.SourceInterfaceInformsTenGigabitEthernet.IsNull() {
+ data.SourceInterfaceInformsTenGigabitEthernet = types.StringValue(value.String())
+ } else {
+ data.SourceInterfaceInformsTenGigabitEthernet = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:source-interface/informs/FortyGigabitEthernet"); value.Exists() && !data.SourceInterfaceInformsFortyGigabitEthernet.IsNull() {
+ data.SourceInterfaceInformsFortyGigabitEthernet = types.StringValue(value.String())
+ } else {
+ data.SourceInterfaceInformsFortyGigabitEthernet = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:source-interface/informs/HundredGigE"); value.Exists() && !data.SourceInterfaceInformsHundredGigE.IsNull() {
+ data.SourceInterfaceInformsHundredGigE = types.StringValue(value.String())
+ } else {
+ data.SourceInterfaceInformsHundredGigE = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:source-interface/informs/Loopback"); value.Exists() && !data.SourceInterfaceInformsLoopback.IsNull() {
+ data.SourceInterfaceInformsLoopback = types.Int64Value(value.Int())
+ } else {
+ data.SourceInterfaceInformsLoopback = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:source-interface/informs/Port-channel"); value.Exists() && !data.SourceInterfaceInformsPortChannel.IsNull() {
+ data.SourceInterfaceInformsPortChannel = types.Int64Value(value.Int())
+ } else {
+ data.SourceInterfaceInformsPortChannel = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:source-interface/informs/Port-channel-subinterface/Port-channel"); value.Exists() && !data.SourceInterfaceInformsPortChannelSubinterface.IsNull() {
+ data.SourceInterfaceInformsPortChannelSubinterface = types.StringValue(value.String())
+ } else {
+ data.SourceInterfaceInformsPortChannelSubinterface = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:source-interface/informs/Vlan"); value.Exists() && !data.SourceInterfaceInformsVlan.IsNull() {
+ data.SourceInterfaceInformsVlan = types.Int64Value(value.Int())
+ } else {
+ data.SourceInterfaceInformsVlan = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:source-interface/traps/GigabitEthernet"); value.Exists() && !data.SourceInterfaceTrapsGigabitEthernet.IsNull() {
+ data.SourceInterfaceTrapsGigabitEthernet = types.StringValue(value.String())
+ } else {
+ data.SourceInterfaceTrapsGigabitEthernet = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:source-interface/traps/TenGigabitEthernet"); value.Exists() && !data.SourceInterfaceTrapsTenGigabitEthernet.IsNull() {
+ data.SourceInterfaceTrapsTenGigabitEthernet = types.StringValue(value.String())
+ } else {
+ data.SourceInterfaceTrapsTenGigabitEthernet = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:source-interface/traps/FortyGigabitEthernet"); value.Exists() && !data.SourceInterfaceTrapsFortyGigabitEthernet.IsNull() {
+ data.SourceInterfaceTrapsFortyGigabitEthernet = types.StringValue(value.String())
+ } else {
+ data.SourceInterfaceTrapsFortyGigabitEthernet = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:source-interface/traps/HundredGigE"); value.Exists() && !data.SourceInterfaceTrapsHundredGigE.IsNull() {
+ data.SourceInterfaceTrapsHundredGigE = types.StringValue(value.String())
+ } else {
+ data.SourceInterfaceTrapsHundredGigE = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:source-interface/traps/Loopback"); value.Exists() && !data.SourceInterfaceTrapsLoopback.IsNull() {
+ data.SourceInterfaceTrapsLoopback = types.Int64Value(value.Int())
+ } else {
+ data.SourceInterfaceTrapsLoopback = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:source-interface/traps/Port-channel"); value.Exists() && !data.SourceInterfaceTrapsPortChannel.IsNull() {
+ data.SourceInterfaceTrapsPortChannel = types.Int64Value(value.Int())
+ } else {
+ data.SourceInterfaceTrapsPortChannel = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:source-interface/traps/Port-channel-subinterface/Port-channel"); value.Exists() && !data.SourceInterfaceTrapsPortChannelSubinterface.IsNull() {
+ data.SourceInterfaceTrapsPortChannelSubinterface = types.StringValue(value.String())
+ } else {
+ data.SourceInterfaceTrapsPortChannelSubinterface = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:source-interface/traps/Vlan"); value.Exists() && !data.SourceInterfaceTrapsVlan.IsNull() {
+ data.SourceInterfaceTrapsVlan = types.Int64Value(value.Int())
+ } else {
+ data.SourceInterfaceTrapsVlan = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:trap-source/GigabitEthernet"); value.Exists() && !data.TrapSourceGigabitEthernet.IsNull() {
+ data.TrapSourceGigabitEthernet = types.StringValue(value.String())
+ } else {
+ data.TrapSourceGigabitEthernet = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:trap-source/TenGigabitEthernet"); value.Exists() && !data.TrapSourceTenGigabitEthernet.IsNull() {
+ data.TrapSourceTenGigabitEthernet = types.StringValue(value.String())
+ } else {
+ data.TrapSourceTenGigabitEthernet = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:trap-source/FortyGigabitEthernet"); value.Exists() && !data.TrapSourceFortyGigabitEthernet.IsNull() {
+ data.TrapSourceFortyGigabitEthernet = types.StringValue(value.String())
+ } else {
+ data.TrapSourceFortyGigabitEthernet = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:trap-source/HundredGigE"); value.Exists() && !data.TrapSourceHundredGigE.IsNull() {
+ data.TrapSourceHundredGigE = types.StringValue(value.String())
+ } else {
+ data.TrapSourceHundredGigE = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:trap-source/Loopback"); value.Exists() && !data.TrapSourceLoopback.IsNull() {
+ data.TrapSourceLoopback = types.Int64Value(value.Int())
+ } else {
+ data.TrapSourceLoopback = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:trap-source/Port-channel"); value.Exists() && !data.TrapSourcePortChannel.IsNull() {
+ data.TrapSourcePortChannel = types.Int64Value(value.Int())
+ } else {
+ data.TrapSourcePortChannel = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:trap-source/Port-channel-subinterface/Port-channel"); value.Exists() && !data.TrapSourcePortChannelSubinterface.IsNull() {
+ data.TrapSourcePortChannelSubinterface = types.StringValue(value.String())
+ } else {
+ data.TrapSourcePortChannelSubinterface = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:trap-source/Vlan"); value.Exists() && !data.TrapSourceVlan.IsNull() {
+ data.TrapSourceVlan = types.Int64Value(value.Int())
+ } else {
+ data.TrapSourceVlan = types.Int64Null()
+ }
+ for i := range data.SnmpCommunities {
+ keys := [...]string{"name"}
+ keyValues := [...]string{data.SnmpCommunities[i].Name.ValueString()}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:community-config").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, "view"); value.Exists() && !data.SnmpCommunities[i].View.IsNull() {
+ data.SnmpCommunities[i].View = types.StringValue(value.String())
+ } else {
+ data.SnmpCommunities[i].View = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "permission"); value.Exists() && !data.SnmpCommunities[i].Permission.IsNull() {
+ data.SnmpCommunities[i].Permission = types.StringValue(value.String())
+ } else {
+ data.SnmpCommunities[i].Permission = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "ipv6"); value.Exists() && !data.SnmpCommunities[i].Ipv6.IsNull() {
+ data.SnmpCommunities[i].Ipv6 = types.StringValue(value.String())
+ } else {
+ data.SnmpCommunities[i].Ipv6 = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "access-list-name"); value.Exists() && !data.SnmpCommunities[i].AccessListName.IsNull() {
+ data.SnmpCommunities[i].AccessListName = types.StringValue(value.String())
+ } else {
+ data.SnmpCommunities[i].AccessListName = types.StringNull()
+ }
+ }
+ for i := range data.Contexts {
+ keys := [...]string{"name"}
+ keyValues := [...]string{data.Contexts[i].Name.ValueString()}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:context").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, "name"); value.Exists() && !data.Contexts[i].Name.IsNull() {
+ data.Contexts[i].Name = types.StringValue(value.String())
+ } else {
+ data.Contexts[i].Name = types.StringNull()
+ }
+ }
+ for i := range data.Views {
+ keys := [...]string{"name", "mib"}
+ keyValues := [...]string{data.Views[i].Name.ValueString(), data.Views[i].Mib.ValueString()}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:view").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, "name"); value.Exists() && !data.Views[i].Name.IsNull() {
+ data.Views[i].Name = types.StringValue(value.String())
+ } else {
+ data.Views[i].Name = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "mib"); value.Exists() && !data.Views[i].Mib.IsNull() {
+ data.Views[i].Mib = types.StringValue(value.String())
+ } else {
+ data.Views[i].Mib = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "inc-exl"); value.Exists() && !data.Views[i].IncExl.IsNull() {
+ data.Views[i].IncExl = types.StringValue(value.String())
+ } else {
+ data.Views[i].IncExl = types.StringNull()
+ }
+ }
+ for i := range data.Groups {
+ keys := [...]string{"id"}
+ keyValues := [...]string{data.Groups[i].Name.ValueString()}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:group").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, "id"); value.Exists() && !data.Groups[i].Name.IsNull() {
+ data.Groups[i].Name = types.StringValue(value.String())
+ } else {
+ data.Groups[i].Name = types.StringNull()
+ }
+ for ci := range data.Groups[i].V3Security {
+ keys := [...]string{"security-level"}
+ keyValues := [...]string{data.Groups[i].V3Security[ci].SecurityLevel.ValueString()}
+
+ var cr xmldot.Result
+ helpers.GetFromXPath(r, "v3/security-level-list").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ cr = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(cr, "security-level"); value.Exists() && !data.Groups[i].V3Security[ci].SecurityLevel.IsNull() {
+ data.Groups[i].V3Security[ci].SecurityLevel = types.StringValue(value.String())
+ } else {
+ data.Groups[i].V3Security[ci].SecurityLevel = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(cr, "context-node"); value.Exists() && !data.Groups[i].V3Security[ci].ContextNode.IsNull() {
+ data.Groups[i].V3Security[ci].ContextNode = types.StringValue(value.String())
+ } else {
+ data.Groups[i].V3Security[ci].ContextNode = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(cr, "match-node"); value.Exists() && !data.Groups[i].V3Security[ci].MatchNode.IsNull() {
+ data.Groups[i].V3Security[ci].MatchNode = types.StringValue(value.String())
+ } else {
+ data.Groups[i].V3Security[ci].MatchNode = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(cr, "read-node"); value.Exists() && !data.Groups[i].V3Security[ci].ReadNode.IsNull() {
+ data.Groups[i].V3Security[ci].ReadNode = types.StringValue(value.String())
+ } else {
+ data.Groups[i].V3Security[ci].ReadNode = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(cr, "write-node"); value.Exists() && !data.Groups[i].V3Security[ci].WriteNode.IsNull() {
+ data.Groups[i].V3Security[ci].WriteNode = types.StringValue(value.String())
+ } else {
+ data.Groups[i].V3Security[ci].WriteNode = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(cr, "notify-node"); value.Exists() && !data.Groups[i].V3Security[ci].NotifyNode.IsNull() {
+ data.Groups[i].V3Security[ci].NotifyNode = types.StringValue(value.String())
+ } else {
+ data.Groups[i].V3Security[ci].NotifyNode = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(cr, "access-config/ipv6-acl"); value.Exists() && !data.Groups[i].V3Security[ci].AccessIpv6Acl.IsNull() {
+ data.Groups[i].V3Security[ci].AccessIpv6Acl = types.StringValue(value.String())
+ } else {
+ data.Groups[i].V3Security[ci].AccessIpv6Acl = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(cr, "access-config/standard-acl"); value.Exists() && !data.Groups[i].V3Security[ci].AccessStandardAcl.IsNull() {
+ data.Groups[i].V3Security[ci].AccessStandardAcl = types.Int64Value(value.Int())
+ } else {
+ data.Groups[i].V3Security[ci].AccessStandardAcl = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(cr, "access-config/acl-name"); value.Exists() && !data.Groups[i].V3Security[ci].AccessAclName.IsNull() {
+ data.Groups[i].V3Security[ci].AccessAclName = types.StringValue(value.String())
+ } else {
+ data.Groups[i].V3Security[ci].AccessAclName = types.StringNull()
+ }
+ }
+ }
+ for i := range data.Users {
+ keys := [...]string{"username", "grpname"}
+ keyValues := [...]string{data.Users[i].Username.ValueString(), data.Users[i].Grpname.ValueString()}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:user/names").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, "username"); value.Exists() && !data.Users[i].Username.IsNull() {
+ data.Users[i].Username = types.StringValue(value.String())
+ } else {
+ data.Users[i].Username = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "grpname"); value.Exists() && !data.Users[i].Grpname.IsNull() {
+ data.Users[i].Grpname = types.StringValue(value.String())
+ } else {
+ data.Users[i].Grpname = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "v3/auth-config/algorithm"); value.Exists() && !data.Users[i].V3AuthAlgorithm.IsNull() {
+ data.Users[i].V3AuthAlgorithm = types.StringValue(value.String())
+ } else {
+ data.Users[i].V3AuthAlgorithm = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "v3/auth-config/priv-config/aes/algorithm"); value.Exists() && !data.Users[i].V3AuthPrivAesAlgorithm.IsNull() {
+ data.Users[i].V3AuthPrivAesAlgorithm = types.StringValue(value.String())
+ } else {
+ data.Users[i].V3AuthPrivAesAlgorithm = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "v3/auth-config/priv-config/aes/access-config/ipv6-acl"); value.Exists() && !data.Users[i].V3AuthPrivAesAccessIpv6Acl.IsNull() {
+ data.Users[i].V3AuthPrivAesAccessIpv6Acl = types.StringValue(value.String())
+ } else {
+ data.Users[i].V3AuthPrivAesAccessIpv6Acl = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "v3/auth-config/priv-config/aes/access-config/standard-acl"); value.Exists() && !data.Users[i].V3AuthPrivAesAccessStandardAcl.IsNull() {
+ data.Users[i].V3AuthPrivAesAccessStandardAcl = types.Int64Value(value.Int())
+ } else {
+ data.Users[i].V3AuthPrivAesAccessStandardAcl = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(r, "v3/auth-config/priv-config/aes/access-config/acl-name"); value.Exists() && !data.Users[i].V3AuthPrivAesAccessAclName.IsNull() {
+ data.Users[i].V3AuthPrivAesAccessAclName = types.StringValue(value.String())
+ } else {
+ data.Users[i].V3AuthPrivAesAccessAclName = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "v3/auth-config/priv-config/des/access-config/ipv6-acl"); value.Exists() && !data.Users[i].V3AuthPrivDesAccessIpv6Acl.IsNull() {
+ data.Users[i].V3AuthPrivDesAccessIpv6Acl = types.StringValue(value.String())
+ } else {
+ data.Users[i].V3AuthPrivDesAccessIpv6Acl = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "v3/auth-config/priv-config/des/access-config/standard-acl"); value.Exists() && !data.Users[i].V3AuthPrivDesAccessStandardAcl.IsNull() {
+ data.Users[i].V3AuthPrivDesAccessStandardAcl = types.Int64Value(value.Int())
+ } else {
+ data.Users[i].V3AuthPrivDesAccessStandardAcl = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(r, "v3/auth-config/priv-config/des/access-config/acl-name"); value.Exists() && !data.Users[i].V3AuthPrivDesAccessAclName.IsNull() {
+ data.Users[i].V3AuthPrivDesAccessAclName = types.StringValue(value.String())
+ } else {
+ data.Users[i].V3AuthPrivDesAccessAclName = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "v3/auth-config/priv-config/des3/access-config/ipv6-acl"); value.Exists() && !data.Users[i].V3AuthPrivDes3AccessIpv6Acl.IsNull() {
+ data.Users[i].V3AuthPrivDes3AccessIpv6Acl = types.StringValue(value.String())
+ } else {
+ data.Users[i].V3AuthPrivDes3AccessIpv6Acl = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "v3/auth-config/priv-config/des3/access-config/standard-acl"); value.Exists() && !data.Users[i].V3AuthPrivDes3AccessStandardAcl.IsNull() {
+ data.Users[i].V3AuthPrivDes3AccessStandardAcl = types.Int64Value(value.Int())
+ } else {
+ data.Users[i].V3AuthPrivDes3AccessStandardAcl = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(r, "v3/auth-config/priv-config/des3/access-config/acl-name"); value.Exists() && !data.Users[i].V3AuthPrivDes3AccessAclName.IsNull() {
+ data.Users[i].V3AuthPrivDes3AccessAclName = types.StringValue(value.String())
+ } else {
+ data.Users[i].V3AuthPrivDes3AccessAclName = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "v3/auth-config/access-config/ipv6-acl"); value.Exists() && !data.Users[i].V3AuthAccessIpv6Acl.IsNull() {
+ data.Users[i].V3AuthAccessIpv6Acl = types.StringValue(value.String())
+ } else {
+ data.Users[i].V3AuthAccessIpv6Acl = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "v3/auth-config/access-config/standard-acl"); value.Exists() && !data.Users[i].V3AuthAccessStandardAcl.IsNull() {
+ data.Users[i].V3AuthAccessStandardAcl = types.Int64Value(value.Int())
+ } else {
+ data.Users[i].V3AuthAccessStandardAcl = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(r, "v3/auth-config/access-config/acl-name"); value.Exists() && !data.Users[i].V3AuthAccessAclName.IsNull() {
+ data.Users[i].V3AuthAccessAclName = types.StringValue(value.String())
+ } else {
+ data.Users[i].V3AuthAccessAclName = types.StringNull()
+ }
+ }
+}
+
+// End of section. //template:end updateFromBodyXML
+
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBody
+
+func (data *SNMPServer) fromBody(ctx context.Context, res gjson.Result) {
+ prefix := helpers.LastElement(data.getPath()) + "."
+ if res.Get(helpers.LastElement(data.getPath())).IsArray() {
+ prefix += "0."
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:chassis-id"); value.Exists() {
+ data.ChassisId = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:contact"); value.Exists() {
+ data.Contact = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:ifindex.persist"); value.Exists() {
+ data.IfindexPersist = types.BoolValue(true)
+ } else {
+ data.IfindexPersist = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:location"); value.Exists() {
+ data.Location = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:packetsize"); value.Exists() {
+ data.Packetsize = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:queue-length"); value.Exists() {
+ data.QueueLength = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.logging.getop"); value.Exists() {
+ data.EnableLoggingGetop = types.BoolValue(value.Bool())
+ } else {
+ data.EnableLoggingGetop = types.BoolNull()
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.logging.setop"); value.Exists() {
+ data.EnableLoggingSetop = types.BoolValue(value.Bool())
+ } else {
+ data.EnableLoggingSetop = types.BoolNull()
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.informs"); value.Exists() {
+ data.EnableInforms = types.BoolValue(true)
+ } else {
+ data.EnableInforms = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps"); value.Exists() {
+ data.EnableTraps = types.BoolValue(true)
+ } else {
+ data.EnableTraps = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.snmp.authentication"); value.Exists() {
+ data.EnableTrapsSnmpAuthentication = types.BoolValue(true)
+ } else {
+ data.EnableTrapsSnmpAuthentication = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.snmp.coldstart"); value.Exists() {
+ data.EnableTrapsSnmpColdstart = types.BoolValue(true)
+ } else {
+ data.EnableTrapsSnmpColdstart = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.snmp.linkdown"); value.Exists() {
+ data.EnableTrapsSnmpLinkdown = types.BoolValue(true)
+ } else {
+ data.EnableTrapsSnmpLinkdown = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.snmp.linkup"); value.Exists() {
+ data.EnableTrapsSnmpLinkup = types.BoolValue(true)
+ } else {
+ data.EnableTrapsSnmpLinkup = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.snmp.warmstart"); value.Exists() {
+ data.EnableTrapsSnmpWarmstart = types.BoolValue(true)
+ } else {
+ data.EnableTrapsSnmpWarmstart = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:host-config.ip-community"); value.Exists() {
+ data.Hosts = make([]SNMPServerHosts, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := SNMPServerHosts{}
+ if cValue := v.Get("ip-address"); cValue.Exists() {
+ item.IpAddress = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("community-or-user"); cValue.Exists() {
+ item.CommunityOrUser = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("version"); cValue.Exists() {
+ item.Version = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("encryption"); cValue.Exists() {
+ item.Encryption = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("security-level"); cValue.Exists() {
+ item.SecurityLevel = types.StringValue(cValue.String())
+ }
+ data.Hosts = append(data.Hosts, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:host-config.ip-vrf-community"); value.Exists() {
+ data.VrfHosts = make([]SNMPServerVrfHosts, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := SNMPServerVrfHosts{}
+ if cValue := v.Get("ip-address"); cValue.Exists() {
+ item.IpAddress = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("vrf"); cValue.Exists() {
+ item.Vrf = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("community-or-user"); cValue.Exists() {
+ item.CommunityOrUser = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("version"); cValue.Exists() {
+ item.Version = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("encryption"); cValue.Exists() {
+ item.Encryption = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("security-level"); cValue.Exists() {
+ item.SecurityLevel = types.StringValue(cValue.String())
+ }
+ data.VrfHosts = append(data.VrfHosts, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:system-shutdown"); value.Exists() {
+ data.SystemShutdown = types.BoolValue(true)
+ } else {
+ data.SystemShutdown = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.flowmon"); value.Exists() {
+ data.EnableTrapsFlowmon = types.BoolValue(true)
+ } else {
+ data.EnableTrapsFlowmon = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.entity-perf.throughput-notif"); value.Exists() {
+ data.EnableTrapsEntityPerfThroughputNotif = types.BoolValue(true)
+ } else {
+ data.EnableTrapsEntityPerfThroughputNotif = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.call-home.message-send-fail"); value.Exists() {
+ data.EnableTrapsCallHomeMessageSendFail = types.BoolValue(true)
+ } else {
+ data.EnableTrapsCallHomeMessageSendFail = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.call-home.server-fail"); value.Exists() {
+ data.EnableTrapsCallHomeServerFail = types.BoolValue(true)
+ } else {
+ data.EnableTrapsCallHomeServerFail = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.tty"); value.Exists() {
+ data.EnableTrapsTty = types.BoolValue(true)
+ } else {
+ data.EnableTrapsTty = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.Cisco-IOS-XE-ospfv3:ospfv3-config.state-change.enable"); value.Exists() {
+ data.EnableTrapsOspfv3ConfigStateChange = types.BoolValue(true)
+ } else {
+ data.EnableTrapsOspfv3ConfigStateChange = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.Cisco-IOS-XE-ospfv3:ospfv3-config.errors.enable"); value.Exists() {
+ data.EnableTrapsOspfv3ConfigErrors = types.BoolValue(true)
+ } else {
+ data.EnableTrapsOspfv3ConfigErrors = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.Cisco-IOS-XE-ospf:ospf-config.retransmit.enable"); value.Exists() {
+ data.EnableTrapsOspfConfigRetransmit = types.BoolValue(true)
+ } else {
+ data.EnableTrapsOspfConfigRetransmit = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.Cisco-IOS-XE-ospf:ospf-config.lsa.enable"); value.Exists() {
+ data.EnableTrapsOspfConfigLsa = types.BoolValue(true)
+ } else {
+ data.EnableTrapsOspfConfigLsa = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.Cisco-IOS-XE-ospf:ospf-config.cisco-specific.state-change.nssa-trans-change"); value.Exists() {
+ data.EnableTrapsOspfNssaTransChange = types.BoolValue(true)
+ } else {
+ data.EnableTrapsOspfNssaTransChange = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.Cisco-IOS-XE-ospf:ospf-config.cisco-specific.state-change.shamlink.interface"); value.Exists() {
+ data.EnableTrapsOspfShamlinkInterface = types.BoolValue(true)
+ } else {
+ data.EnableTrapsOspfShamlinkInterface = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.Cisco-IOS-XE-ospf:ospf-config.cisco-specific.state-change.shamlink.neighbor"); value.Exists() {
+ data.EnableTrapsOspfShamlinkNeighbor = types.BoolValue(true)
+ } else {
+ data.EnableTrapsOspfShamlinkNeighbor = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.Cisco-IOS-XE-ospf:ospf-config.cisco-specific.errors.enable"); value.Exists() {
+ data.EnableTrapsOspfErrorsEnable = types.BoolValue(true)
+ } else {
+ data.EnableTrapsOspfErrorsEnable = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.Cisco-IOS-XE-ospf:ospf-config.cisco-specific.retransmit.enable"); value.Exists() {
+ data.EnableTrapsOspfRetransmitEnable = types.BoolValue(true)
+ } else {
+ data.EnableTrapsOspfRetransmitEnable = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.Cisco-IOS-XE-ospf:ospf-config.cisco-specific.lsa.enable"); value.Exists() {
+ data.EnableTrapsOspfLsaEnable = types.BoolValue(true)
+ } else {
+ data.EnableTrapsOspfLsaEnable = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.eigrp"); value.Exists() {
+ data.EnableTrapsEigrp = types.BoolValue(true)
+ } else {
+ data.EnableTrapsEigrp = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.auth-framework.sec-violation"); value.Exists() {
+ data.EnableTrapsAuthFrameworkSecViolation = types.BoolValue(true)
+ } else {
+ data.EnableTrapsAuthFrameworkSecViolation = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.rep"); value.Exists() {
+ data.EnableTrapsRep = types.BoolValue(true)
+ } else {
+ data.EnableTrapsRep = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.vtp"); value.Exists() {
+ data.EnableTrapsVtp = types.BoolValue(true)
+ } else {
+ data.EnableTrapsVtp = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.vlancreate"); value.Exists() {
+ data.EnableTrapsVlancreate = types.BoolValue(true)
+ } else {
+ data.EnableTrapsVlancreate = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.vlandelete"); value.Exists() {
+ data.EnableTrapsVlandelete = types.BoolValue(true)
+ } else {
+ data.EnableTrapsVlandelete = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.port-security"); value.Exists() {
+ data.EnableTrapsPortSecurity = types.BoolValue(true)
+ } else {
+ data.EnableTrapsPortSecurity = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.license"); value.Exists() {
+ data.EnableTrapsLicense = types.BoolValue(true)
+ } else {
+ data.EnableTrapsLicense = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.smart-licenseing.smart-license"); value.Exists() {
+ data.EnableTrapsSmartLicense = types.BoolValue(true)
+ } else {
+ data.EnableTrapsSmartLicense = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.cpu.threshold"); value.Exists() {
+ data.EnableTrapsCpuThreshold = types.BoolValue(true)
+ } else {
+ data.EnableTrapsCpuThreshold = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.memory.bufferpeak"); value.Exists() {
+ data.EnableTrapsMemoryBufferpeak = types.BoolValue(true)
+ } else {
+ data.EnableTrapsMemoryBufferpeak = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.stackwise"); value.Exists() {
+ data.EnableTrapsStackwise = types.BoolValue(true)
+ } else {
+ data.EnableTrapsStackwise = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.udld.link-fail-rpt"); value.Exists() {
+ data.EnableTrapsUdldLinkFailRpt = types.BoolValue(true)
+ } else {
+ data.EnableTrapsUdldLinkFailRpt = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.udld.status-change"); value.Exists() {
+ data.EnableTrapsUdldStatusChange = types.BoolValue(true)
+ } else {
+ data.EnableTrapsUdldStatusChange = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.fru-ctrl"); value.Exists() {
+ data.EnableTrapsFruCtrl = types.BoolValue(true)
+ } else {
+ data.EnableTrapsFruCtrl = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.flash.insertion"); value.Exists() {
+ data.EnableTrapsFlashInsertion = types.BoolValue(true)
+ } else {
+ data.EnableTrapsFlashInsertion = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.flash.removal"); value.Exists() {
+ data.EnableTrapsFlashRemoval = types.BoolValue(true)
+ } else {
+ data.EnableTrapsFlashRemoval = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.flash.lowspace"); value.Exists() {
+ data.EnableTrapsFlashLowspace = types.BoolValue(true)
+ } else {
+ data.EnableTrapsFlashLowspace = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.energywise"); value.Exists() {
+ data.EnableTrapsEnergywise = types.BoolValue(true)
+ } else {
+ data.EnableTrapsEnergywise = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.power-ethernet.group"); value.Exists() {
+ data.EnableTrapsPowerEthernetGroup = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.power-ethernet.police"); value.Exists() {
+ data.EnableTrapsPowerEthernetPolice = types.BoolValue(true)
+ } else {
+ data.EnableTrapsPowerEthernetPolice = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.entity"); value.Exists() {
+ data.EnableTrapsEntity = types.BoolValue(true)
+ } else {
+ data.EnableTrapsEntity = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.pw.vc"); value.Exists() {
+ data.EnableTrapsPwVc = types.BoolValue(true)
+ } else {
+ data.EnableTrapsPwVc = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.envmon"); value.Exists() {
+ data.EnableTrapsEnvmon = types.BoolValue(true)
+ } else {
+ data.EnableTrapsEnvmon = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.cef.resource-failure"); value.Exists() {
+ data.EnableTrapsCefResourceFailure = types.BoolValue(true)
+ } else {
+ data.EnableTrapsCefResourceFailure = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.cef.peer-state-change"); value.Exists() {
+ data.EnableTrapsCefPeerStateChange = types.BoolValue(true)
+ } else {
+ data.EnableTrapsCefPeerStateChange = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.cef.peer-fib-state-change"); value.Exists() {
+ data.EnableTrapsCefPeerFibStateChange = types.BoolValue(true)
+ } else {
+ data.EnableTrapsCefPeerFibStateChange = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.cef.inconsistency"); value.Exists() {
+ data.EnableTrapsCefInconsistency = types.BoolValue(true)
+ } else {
+ data.EnableTrapsCefInconsistency = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.isis"); value.Exists() {
+ data.EnableTrapsIsis = types.BoolValue(true)
+ } else {
+ data.EnableTrapsIsis = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ipsla"); value.Exists() {
+ data.EnableTrapsIpsla = types.BoolValue(true)
+ } else {
+ data.EnableTrapsIpsla = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.entity-diag.boot-up-fail"); value.Exists() {
+ data.EnableTrapsEntityDiagBootUpFail = types.BoolValue(true)
+ } else {
+ data.EnableTrapsEntityDiagBootUpFail = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.entity-diag.hm-test-recover"); value.Exists() {
+ data.EnableTrapsEntityDiagHmTestRecover = types.BoolValue(true)
+ } else {
+ data.EnableTrapsEntityDiagHmTestRecover = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.entity-diag.hm-thresh-reached"); value.Exists() {
+ data.EnableTrapsEntityDiagHmThreshReached = types.BoolValue(true)
+ } else {
+ data.EnableTrapsEntityDiagHmThreshReached = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.entity-diag.scheduled-test-fail"); value.Exists() {
+ data.EnableTrapsEntityDiagScheduledTestFail = types.BoolValue(true)
+ } else {
+ data.EnableTrapsEntityDiagScheduledTestFail = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.bfd"); value.Exists() {
+ data.EnableTrapsBfd = types.BoolValue(true)
+ } else {
+ data.EnableTrapsBfd = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ike.policy.add"); value.Exists() {
+ data.EnableTrapsIkePolicyAdd = types.BoolValue(true)
+ } else {
+ data.EnableTrapsIkePolicyAdd = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ike.policy.delete"); value.Exists() {
+ data.EnableTrapsIkePolicyDelete = types.BoolValue(true)
+ } else {
+ data.EnableTrapsIkePolicyDelete = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ike.tunnel.start"); value.Exists() {
+ data.EnableTrapsIkeTunnelStart = types.BoolValue(true)
+ } else {
+ data.EnableTrapsIkeTunnelStart = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ike.tunnel.stop"); value.Exists() {
+ data.EnableTrapsIkeTunnelStop = types.BoolValue(true)
+ } else {
+ data.EnableTrapsIkeTunnelStop = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ipsec.cryptomap.add"); value.Exists() {
+ data.EnableTrapsIpsecCryptomapAdd = types.BoolValue(true)
+ } else {
+ data.EnableTrapsIpsecCryptomapAdd = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ipsec.cryptomap.attach"); value.Exists() {
+ data.EnableTrapsIpsecCryptomapAttach = types.BoolValue(true)
+ } else {
+ data.EnableTrapsIpsecCryptomapAttach = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ipsec.cryptomap.delete"); value.Exists() {
+ data.EnableTrapsIpsecCryptomapDelete = types.BoolValue(true)
+ } else {
+ data.EnableTrapsIpsecCryptomapDelete = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ipsec.cryptomap.detach"); value.Exists() {
+ data.EnableTrapsIpsecCryptomapDetach = types.BoolValue(true)
+ } else {
+ data.EnableTrapsIpsecCryptomapDetach = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ipsec.tunnel.start"); value.Exists() {
+ data.EnableTrapsIpsecTunnelStart = types.BoolValue(true)
+ } else {
+ data.EnableTrapsIpsecTunnelStart = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ipsec.tunnel.stop"); value.Exists() {
+ data.EnableTrapsIpsecTunnelStop = types.BoolValue(true)
+ } else {
+ data.EnableTrapsIpsecTunnelStop = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ipsec.too-many-sas"); value.Exists() {
+ data.EnableTrapsIpsecTooManySas = types.BoolValue(true)
+ } else {
+ data.EnableTrapsIpsecTooManySas = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.config-copy"); value.Exists() {
+ data.EnableTrapsConfigCopy = types.BoolValue(true)
+ } else {
+ data.EnableTrapsConfigCopy = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.config"); value.Exists() {
+ data.EnableTrapsConfig = types.BoolValue(true)
+ } else {
+ data.EnableTrapsConfig = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.config-ctid"); value.Exists() {
+ data.EnableTrapsConfigCtid = types.BoolValue(true)
+ } else {
+ data.EnableTrapsConfigCtid = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.dhcp"); value.Exists() {
+ data.EnableTrapsDhcp = types.BoolValue(true)
+ } else {
+ data.EnableTrapsDhcp = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.event-manager"); value.Exists() {
+ data.EnableTrapsEventManager = types.BoolValue(true)
+ } else {
+ data.EnableTrapsEventManager = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.hsrp"); value.Exists() {
+ data.EnableTrapsHsrp = types.BoolValue(true)
+ } else {
+ data.EnableTrapsHsrp = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ipmulticast"); value.Exists() {
+ data.EnableTrapsIpmulticast = types.BoolValue(true)
+ } else {
+ data.EnableTrapsIpmulticast = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.msdp"); value.Exists() {
+ data.EnableTrapsMsdp = types.BoolValue(true)
+ } else {
+ data.EnableTrapsMsdp = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.Cisco-IOS-XE-ospf:ospf-config.state-change.enable"); value.Exists() {
+ data.EnableTrapsOspfConfigStateChange = types.BoolValue(true)
+ } else {
+ data.EnableTrapsOspfConfigStateChange = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.Cisco-IOS-XE-ospf:ospf-config.errors.enable"); value.Exists() {
+ data.EnableTrapsOspfConfigErrors = types.BoolValue(true)
+ } else {
+ data.EnableTrapsOspfConfigErrors = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.pim.invalid-pim-message"); value.Exists() {
+ data.EnableTrapsPimInvalidPimMessage = types.BoolValue(true)
+ } else {
+ data.EnableTrapsPimInvalidPimMessage = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.pim.neighbor-change"); value.Exists() {
+ data.EnableTrapsPimNeighborChange = types.BoolValue(true)
+ } else {
+ data.EnableTrapsPimNeighborChange = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.pim.rp-mapping-change"); value.Exists() {
+ data.EnableTrapsPimRpMappingChange = types.BoolValue(true)
+ } else {
+ data.EnableTrapsPimRpMappingChange = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.bridge.newroot"); value.Exists() {
+ data.EnableTrapsBridgeNewroot = types.BoolValue(true)
+ } else {
+ data.EnableTrapsBridgeNewroot = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.bridge.topologychange"); value.Exists() {
+ data.EnableTrapsBridgeTopologychange = types.BoolValue(true)
+ } else {
+ data.EnableTrapsBridgeTopologychange = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.stpx.inconsistency"); value.Exists() {
+ data.EnableTrapsStpxInconsistency = types.BoolValue(true)
+ } else {
+ data.EnableTrapsStpxInconsistency = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.stpx.root-inconsistency"); value.Exists() {
+ data.EnableTrapsStpxRootInconsistency = types.BoolValue(true)
+ } else {
+ data.EnableTrapsStpxRootInconsistency = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.stpx.loop-inconsistency"); value.Exists() {
+ data.EnableTrapsStpxLoopInconsistency = types.BoolValue(true)
+ } else {
+ data.EnableTrapsStpxLoopInconsistency = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.syslog"); value.Exists() {
+ data.EnableTrapsSyslog = types.BoolValue(true)
+ } else {
+ data.EnableTrapsSyslog = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + ""); value.Exists() {
+ data.EnableTrapsBgpCbgp2 = types.BoolValue(true)
+ } else {
+ data.EnableTrapsBgpCbgp2 = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.nhrp.nhs"); value.Exists() {
+ data.EnableTrapsNhrpNhs = types.BoolValue(true)
+ } else {
+ data.EnableTrapsNhrpNhs = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.nhrp.nhc"); value.Exists() {
+ data.EnableTrapsNhrpNhc = types.BoolValue(true)
+ } else {
+ data.EnableTrapsNhrpNhc = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.nhrp.nhp"); value.Exists() {
+ data.EnableTrapsNhrpNhp = types.BoolValue(true)
+ } else {
+ data.EnableTrapsNhrpNhp = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.nhrp.quota-exceeded"); value.Exists() {
+ data.EnableTrapsNhrpQuotaExceeded = types.BoolValue(true)
+ } else {
+ data.EnableTrapsNhrpQuotaExceeded = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.mpls.traffic-eng"); value.Exists() {
+ data.EnableTrapsMplsTrafficEng = types.BoolValue(true)
+ } else {
+ data.EnableTrapsMplsTrafficEng = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.mpls"); value.Exists() {
+ data.EnableTrapsMpls = types.BoolValue(true)
+ } else {
+ data.EnableTrapsMpls = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.mpls.vpn"); value.Exists() {
+ data.EnableTrapsMplsVpn = types.BoolValue(true)
+ } else {
+ data.EnableTrapsMplsVpn = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.mpls.rfc"); value.Exists() {
+ data.EnableTrapsMplsRfc = types.BoolValue(true)
+ } else {
+ data.EnableTrapsMplsRfc = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.mpls.rfc.ldp"); value.Exists() {
+ data.EnableTrapsMplsRfcLdp = types.BoolValue(true)
+ } else {
+ data.EnableTrapsMplsRfcLdp = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.mpls.ldp"); value.Exists() {
+ data.EnableTrapsMplsLdp = types.BoolValue(true)
+ } else {
+ data.EnableTrapsMplsLdp = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.mpls.fast-reroute.protected"); value.Exists() {
+ data.EnableTrapsFastRerouteProtected = types.BoolValue(true)
+ } else {
+ data.EnableTrapsFastRerouteProtected = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.local-auth"); value.Exists() {
+ data.EnableTrapsLocalAuth = types.BoolValue(true)
+ } else {
+ data.EnableTrapsLocalAuth = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.vlan-membership"); value.Exists() {
+ data.EnableTrapsVlanMembership = types.BoolValue(true)
+ } else {
+ data.EnableTrapsVlanMembership = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.errdisable"); value.Exists() {
+ data.EnableTrapsErrdisable = types.BoolValue(true)
+ } else {
+ data.EnableTrapsErrdisable = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.rf"); value.Exists() {
+ data.EnableTrapsRf = types.BoolValue(true)
+ } else {
+ data.EnableTrapsRf = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.transceiver.all"); value.Exists() {
+ data.EnableTrapsTransceiverAll = types.BoolValue(true)
+ } else {
+ data.EnableTrapsTransceiverAll = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.bulkstat.collection"); value.Exists() {
+ data.EnableTrapsBulkstatCollection = types.BoolValue(true)
+ } else {
+ data.EnableTrapsBulkstatCollection = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.bulkstat.transfer"); value.Exists() {
+ data.EnableTrapsBulkstatTransfer = types.BoolValue(true)
+ } else {
+ data.EnableTrapsBulkstatTransfer = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.mac-notification.change"); value.Exists() {
+ data.EnableTrapsMacNotificationChange = types.BoolValue(true)
+ } else {
+ data.EnableTrapsMacNotificationChange = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.mac-notification.move"); value.Exists() {
+ data.EnableTrapsMacNotificationMove = types.BoolValue(true)
+ } else {
+ data.EnableTrapsMacNotificationMove = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.mac-notification.threshold"); value.Exists() {
+ data.EnableTrapsMacNotificationThreshold = types.BoolValue(true)
+ } else {
+ data.EnableTrapsMacNotificationThreshold = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.vrfmib.vrf-up"); value.Exists() {
+ data.EnableTrapsVrfmibVrfUp = types.BoolValue(true)
+ } else {
+ data.EnableTrapsVrfmibVrfUp = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.vrfmib.vrf-down"); value.Exists() {
+ data.EnableTrapsVrfmibVrfDown = types.BoolValue(true)
+ } else {
+ data.EnableTrapsVrfmibVrfDown = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.vrfmib.vnet-trunk-up"); value.Exists() {
+ data.EnableTrapsVrfmibVnetTrunkUp = types.BoolValue(true)
+ } else {
+ data.EnableTrapsVrfmibVnetTrunkUp = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.vrfmib.vnet-trunk-down"); value.Exists() {
+ data.EnableTrapsVrfmibVnetTrunkDown = types.BoolValue(true)
+ } else {
+ data.EnableTrapsVrfmibVnetTrunkDown = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.mvpn"); value.Exists() {
+ data.EnableTrapsMvpn = types.BoolValue(true)
+ } else {
+ data.EnableTrapsMvpn = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.lisp"); value.Exists() {
+ data.EnableTrapsLisp = types.BoolValue(true)
+ } else {
+ data.EnableTrapsLisp = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.aaa_server"); value.Exists() {
+ data.EnableTrapsAaaServer = types.BoolValue(true)
+ } else {
+ data.EnableTrapsAaaServer = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.vdsl2line"); value.Exists() {
+ data.EnableTrapsVdsl2line = types.BoolValue(true)
+ } else {
+ data.EnableTrapsVdsl2line = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.adslline"); value.Exists() {
+ data.EnableTrapsAdslline = types.BoolValue(true)
+ } else {
+ data.EnableTrapsAdslline = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.pki"); value.Exists() {
+ data.EnableTrapsPki = types.BoolValue(true)
+ } else {
+ data.EnableTrapsPki = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.alarms.alarm-type"); value.Exists() {
+ data.EnableTrapsAlarmType = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.casa"); value.Exists() {
+ data.EnableTrapsCasa = types.BoolValue(true)
+ } else {
+ data.EnableTrapsCasa = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.cnpd"); value.Exists() {
+ data.EnableTrapsCnpd = types.BoolValue(true)
+ } else {
+ data.EnableTrapsCnpd = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.dial"); value.Exists() {
+ data.EnableTrapsDial = types.BoolValue(true)
+ } else {
+ data.EnableTrapsDial = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.dlsw"); value.Exists() {
+ data.EnableTrapsDlsw = types.BoolValue(true)
+ } else {
+ data.EnableTrapsDlsw = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ds1"); value.Exists() {
+ data.EnableTrapsDs1 = types.BoolValue(true)
+ } else {
+ data.EnableTrapsDs1 = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.dsp.card-status"); value.Exists() {
+ data.EnableTrapsDspCardStatus = types.BoolValue(true)
+ } else {
+ data.EnableTrapsDspCardStatus = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.dsp.oper-state"); value.Exists() {
+ data.EnableTrapsDspOperState = types.BoolValue(true)
+ } else {
+ data.EnableTrapsDspOperState = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.entity-sensor"); value.Exists() {
+ data.EnableTrapsEntitySensor = types.BoolValue(true)
+ } else {
+ data.EnableTrapsEntitySensor = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.entity-state"); value.Exists() {
+ data.EnableTrapsEntityState = types.BoolValue(true)
+ } else {
+ data.EnableTrapsEntityState = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.entity-qfp.mem-res-thresh"); value.Exists() {
+ data.EnableTrapsEntityQfpMemResThresh = types.BoolValue(true)
+ } else {
+ data.EnableTrapsEntityQfpMemResThresh = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.entity-qfp.throughput-notif"); value.Exists() {
+ data.EnableTrapsEntityQfpThroughputNotif = types.BoolValue(true)
+ } else {
+ data.EnableTrapsEntityQfpThroughputNotif = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ether-oam"); value.Exists() {
+ data.EnableTrapsEtherOam = types.BoolValue(true)
+ } else {
+ data.EnableTrapsEtherOam = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ethernet.cfm.alarm"); value.Exists() {
+ data.EnableTrapsEthernetCfmAlarm = types.BoolValue(true)
+ } else {
+ data.EnableTrapsEthernetCfmAlarm = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ethernet.cfm.cc.config"); value.Exists() {
+ data.EnableTrapsEthernetCfmCcConfig = types.BoolValue(true)
+ } else {
+ data.EnableTrapsEthernetCfmCcConfig = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ethernet.cfm.cc.cross-connect"); value.Exists() {
+ data.EnableTrapsEthernetCfmCcCrossConnect = types.BoolValue(true)
+ } else {
+ data.EnableTrapsEthernetCfmCcCrossConnect = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ethernet.cfm.cc.loop"); value.Exists() {
+ data.EnableTrapsEthernetCfmCcLoop = types.BoolValue(true)
+ } else {
+ data.EnableTrapsEthernetCfmCcLoop = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ethernet.cfm.cc.mep-down"); value.Exists() {
+ data.EnableTrapsEthernetCfmCcMepDown = types.BoolValue(true)
+ } else {
+ data.EnableTrapsEthernetCfmCcMepDown = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ethernet.cfm.cc.mep-up"); value.Exists() {
+ data.EnableTrapsEthernetCfmCcMepUp = types.BoolValue(true)
+ } else {
+ data.EnableTrapsEthernetCfmCcMepUp = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ethernet.cfm.crosscheck.mep-missing"); value.Exists() {
+ data.EnableTrapsEthernetCfmCrosscheckMepMissing = types.BoolValue(true)
+ } else {
+ data.EnableTrapsEthernetCfmCrosscheckMepMissing = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ethernet.cfm.crosscheck.mep-unknown"); value.Exists() {
+ data.EnableTrapsEthernetCfmCrosscheckMepUnknown = types.BoolValue(true)
+ } else {
+ data.EnableTrapsEthernetCfmCrosscheckMepUnknown = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ethernet.cfm.crosscheck.service-up"); value.Exists() {
+ data.EnableTrapsEthernetCfmCrosscheckServiceUp = types.BoolValue(true)
+ } else {
+ data.EnableTrapsEthernetCfmCrosscheckServiceUp = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ethernet.evc.create"); value.Exists() {
+ data.EnableTrapsEthernetEvcCreate = types.BoolValue(true)
+ } else {
+ data.EnableTrapsEthernetEvcCreate = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ethernet.evc.delete"); value.Exists() {
+ data.EnableTrapsEthernetEvcDelete = types.BoolValue(true)
+ } else {
+ data.EnableTrapsEthernetEvcDelete = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ethernet.evc.status"); value.Exists() {
+ data.EnableTrapsEthernetEvcStatus = types.BoolValue(true)
+ } else {
+ data.EnableTrapsEthernetEvcStatus = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.firewall.serverstatus"); value.Exists() {
+ data.EnableTrapsFirewallServerstatus = types.BoolValue(true)
+ } else {
+ data.EnableTrapsFirewallServerstatus = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.frame-relay-config.only-frame-relay.frame-relay"); value.Exists() {
+ data.EnableTrapsFrameRelayConfigOnly = types.BoolValue(true)
+ } else {
+ data.EnableTrapsFrameRelayConfigOnly = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.frame-relay-config.frame-relay-options.frame-relay.subif-configs.subif"); value.Exists() {
+ data.EnableTrapsFrameRelayConfigSubifConfigs = types.BoolValue(true)
+ } else {
+ data.EnableTrapsFrameRelayConfigSubifConfigs = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.frame-relay.subif.count"); value.Exists() {
+ data.EnableTrapsFrameRelaySubifCount = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.frame-relay.subif.interval"); value.Exists() {
+ data.EnableTrapsFrameRelaySubifInterval = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.frame-relay-config.frame-relay-options.frame-relay.multilink.bundle-mismatch"); value.Exists() {
+ data.EnableTrapsFrameRelayConfigBundleMismatch = types.BoolValue(true)
+ } else {
+ data.EnableTrapsFrameRelayConfigBundleMismatch = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.frame-relay.multilink.bundle-mismatch"); value.Exists() {
+ data.EnableTrapsFrameRelayMultilinkBundleMismatch = types.BoolValue(true)
+ } else {
+ data.EnableTrapsFrameRelayMultilinkBundleMismatch = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ip.local.pool"); value.Exists() {
+ data.EnableTrapsIpLocalPool = types.BoolValue(true)
+ } else {
+ data.EnableTrapsIpLocalPool = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.isdn.call-information"); value.Exists() {
+ data.EnableTrapsIsdnCallInformation = types.BoolValue(true)
+ } else {
+ data.EnableTrapsIsdnCallInformation = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.isdn.chan-not-avail"); value.Exists() {
+ data.EnableTrapsIsdnChanNotAvail = types.BoolValue(true)
+ } else {
+ data.EnableTrapsIsdnChanNotAvail = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.isdn.ietf"); value.Exists() {
+ data.EnableTrapsIsdnIetf = types.BoolValue(true)
+ } else {
+ data.EnableTrapsIsdnIetf = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.isdn.layer2"); value.Exists() {
+ data.EnableTrapsIsdnLayer2 = types.BoolValue(true)
+ } else {
+ data.EnableTrapsIsdnLayer2 = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.l2tun.session"); value.Exists() {
+ data.EnableTrapsL2tunSession = types.BoolValue(true)
+ } else {
+ data.EnableTrapsL2tunSession = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.l2tun.tunnel"); value.Exists() {
+ data.EnableTrapsL2tunTunnel = types.BoolValue(true)
+ } else {
+ data.EnableTrapsL2tunTunnel = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.l2tun.pseudowire.status"); value.Exists() {
+ data.EnableTrapsL2tunPseudowireStatus = types.BoolValue(true)
+ } else {
+ data.EnableTrapsL2tunPseudowireStatus = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.pimstdmib.neighbor-loss"); value.Exists() {
+ data.EnableTrapsPimstdmibNeighborLoss = types.BoolValue(true)
+ } else {
+ data.EnableTrapsPimstdmibNeighborLoss = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.pimstdmib.invalid-register"); value.Exists() {
+ data.EnableTrapsPimstdmibInvalidRegister = types.BoolValue(true)
+ } else {
+ data.EnableTrapsPimstdmibInvalidRegister = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.pimstdmib.invalid-join-prune"); value.Exists() {
+ data.EnableTrapsPimstdmibInvalidJoinPrune = types.BoolValue(true)
+ } else {
+ data.EnableTrapsPimstdmibInvalidJoinPrune = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.pimstdmib.rp-mapping-change"); value.Exists() {
+ data.EnableTrapsPimstdmibRpMappingChange = types.BoolValue(true)
+ } else {
+ data.EnableTrapsPimstdmibRpMappingChange = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.pimstdmib.interface-election"); value.Exists() {
+ data.EnableTrapsPimstdmibInterfaceElection = types.BoolValue(true)
+ } else {
+ data.EnableTrapsPimstdmibInterfaceElection = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.pfr"); value.Exists() {
+ data.EnableTrapsPfr = types.BoolValue(true)
+ } else {
+ data.EnableTrapsPfr = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.pppoe"); value.Exists() {
+ data.EnableTrapsPppoe = types.BoolValue(true)
+ } else {
+ data.EnableTrapsPppoe = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.resource-policy"); value.Exists() {
+ data.EnableTrapsResourcePolicy = types.BoolValue(true)
+ } else {
+ data.EnableTrapsResourcePolicy = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.rsvp"); value.Exists() {
+ data.EnableTrapsRsvp = types.BoolValue(true)
+ } else {
+ data.EnableTrapsRsvp = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.vrrp"); value.Exists() {
+ data.EnableTrapsVrrp = types.BoolValue(true)
+ } else {
+ data.EnableTrapsVrrp = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.sonet"); value.Exists() {
+ data.EnableTrapsSonet = types.BoolValue(true)
+ } else {
+ data.EnableTrapsSonet = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.srp"); value.Exists() {
+ data.EnableTrapsSrp = types.BoolValue(true)
+ } else {
+ data.EnableTrapsSrp = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.voice"); value.Exists() {
+ data.EnableTrapsVoice = types.BoolValue(true)
+ } else {
+ data.EnableTrapsVoice = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.bgp"); value.Exists() {
+ data.EnableTrapsBgp = types.BoolValue(true)
+ } else {
+ data.EnableTrapsBgp = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.bgp-traps.cbgp2"); value.Exists() {
+ data.EnableTrapsCbgp2 = types.BoolValue(true)
+ } else {
+ data.EnableTrapsCbgp2 = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ospfv3.errors"); value.Exists() {
+ data.EnableTrapsOspfv3Errors = types.BoolValue(true)
+ } else {
+ data.EnableTrapsOspfv3Errors = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ospfv3.state-change"); value.Exists() {
+ data.EnableTrapsOspfv3StateChange = types.BoolValue(true)
+ } else {
+ data.EnableTrapsOspfv3StateChange = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:source-interface.informs.GigabitEthernet"); value.Exists() {
+ data.SourceInterfaceInformsGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:source-interface.informs.TenGigabitEthernet"); value.Exists() {
+ data.SourceInterfaceInformsTenGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:source-interface.informs.FortyGigabitEthernet"); value.Exists() {
+ data.SourceInterfaceInformsFortyGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:source-interface.informs.HundredGigE"); value.Exists() {
+ data.SourceInterfaceInformsHundredGigE = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:source-interface.informs.Loopback"); value.Exists() {
+ data.SourceInterfaceInformsLoopback = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:source-interface.informs.Port-channel"); value.Exists() {
+ data.SourceInterfaceInformsPortChannel = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:source-interface.informs.Port-channel-subinterface.Port-channel"); value.Exists() {
+ data.SourceInterfaceInformsPortChannelSubinterface = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:source-interface.informs.Vlan"); value.Exists() {
+ data.SourceInterfaceInformsVlan = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:source-interface.traps.GigabitEthernet"); value.Exists() {
+ data.SourceInterfaceTrapsGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:source-interface.traps.TenGigabitEthernet"); value.Exists() {
+ data.SourceInterfaceTrapsTenGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:source-interface.traps.FortyGigabitEthernet"); value.Exists() {
+ data.SourceInterfaceTrapsFortyGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:source-interface.traps.HundredGigE"); value.Exists() {
+ data.SourceInterfaceTrapsHundredGigE = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:source-interface.traps.Loopback"); value.Exists() {
+ data.SourceInterfaceTrapsLoopback = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:source-interface.traps.Port-channel"); value.Exists() {
+ data.SourceInterfaceTrapsPortChannel = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:source-interface.traps.Port-channel-subinterface.Port-channel"); value.Exists() {
+ data.SourceInterfaceTrapsPortChannelSubinterface = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:source-interface.traps.Vlan"); value.Exists() {
+ data.SourceInterfaceTrapsVlan = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:trap-source.GigabitEthernet"); value.Exists() {
+ data.TrapSourceGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:trap-source.TenGigabitEthernet"); value.Exists() {
+ data.TrapSourceTenGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:trap-source.FortyGigabitEthernet"); value.Exists() {
+ data.TrapSourceFortyGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:trap-source.HundredGigE"); value.Exists() {
+ data.TrapSourceHundredGigE = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:trap-source.Loopback"); value.Exists() {
+ data.TrapSourceLoopback = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:trap-source.Port-channel"); value.Exists() {
+ data.TrapSourcePortChannel = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:trap-source.Port-channel-subinterface.Port-channel"); value.Exists() {
+ data.TrapSourcePortChannelSubinterface = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:trap-source.Vlan"); value.Exists() {
+ data.TrapSourceVlan = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:community-config"); value.Exists() {
+ data.SnmpCommunities = make([]SNMPServerSnmpCommunities, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := SNMPServerSnmpCommunities{}
+ if cValue := v.Get("name"); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("view"); cValue.Exists() {
+ item.View = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("permission"); cValue.Exists() {
+ item.Permission = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("ipv6"); cValue.Exists() {
+ item.Ipv6 = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("access-list-name"); cValue.Exists() {
+ item.AccessListName = types.StringValue(cValue.String())
+ }
+ data.SnmpCommunities = append(data.SnmpCommunities, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:context"); value.Exists() {
+ data.Contexts = make([]SNMPServerContexts, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := SNMPServerContexts{}
+ if cValue := v.Get("name"); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ data.Contexts = append(data.Contexts, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:view"); value.Exists() {
+ data.Views = make([]SNMPServerViews, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := SNMPServerViews{}
+ if cValue := v.Get("name"); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("mib"); cValue.Exists() {
+ item.Mib = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("inc-exl"); cValue.Exists() {
+ item.IncExl = types.StringValue(cValue.String())
+ }
+ data.Views = append(data.Views, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:group"); value.Exists() {
+ data.Groups = make([]SNMPServerGroups, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := SNMPServerGroups{}
+ if cValue := v.Get("id"); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("v3.security-level-list"); cValue.Exists() {
+ item.V3Security = make([]SNMPServerGroupsV3Security, 0)
+ cValue.ForEach(func(ck, cv gjson.Result) bool {
+ cItem := SNMPServerGroupsV3Security{}
+ if ccValue := cv.Get("security-level"); ccValue.Exists() {
+ cItem.SecurityLevel = types.StringValue(ccValue.String())
+ }
+ if ccValue := cv.Get("context-node"); ccValue.Exists() {
+ cItem.ContextNode = types.StringValue(ccValue.String())
+ }
+ if ccValue := cv.Get("match-node"); ccValue.Exists() {
+ cItem.MatchNode = types.StringValue(ccValue.String())
+ }
+ if ccValue := cv.Get("read-node"); ccValue.Exists() {
+ cItem.ReadNode = types.StringValue(ccValue.String())
+ }
+ if ccValue := cv.Get("write-node"); ccValue.Exists() {
+ cItem.WriteNode = types.StringValue(ccValue.String())
+ }
+ if ccValue := cv.Get("notify-node"); ccValue.Exists() {
+ cItem.NotifyNode = types.StringValue(ccValue.String())
+ }
+ if ccValue := cv.Get("access-config.ipv6-acl"); ccValue.Exists() {
+ cItem.AccessIpv6Acl = types.StringValue(ccValue.String())
+ }
+ if ccValue := cv.Get("access-config.standard-acl"); ccValue.Exists() {
+ cItem.AccessStandardAcl = types.Int64Value(ccValue.Int())
+ }
+ if ccValue := cv.Get("access-config.acl-name"); ccValue.Exists() {
+ cItem.AccessAclName = types.StringValue(ccValue.String())
+ }
+ item.V3Security = append(item.V3Security, cItem)
+ return true
+ })
+ }
+ data.Groups = append(data.Groups, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:user.names"); value.Exists() {
+ data.Users = make([]SNMPServerUsers, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := SNMPServerUsers{}
+ if cValue := v.Get("username"); cValue.Exists() {
+ item.Username = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("grpname"); cValue.Exists() {
+ item.Grpname = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("v3.auth-config.algorithm"); cValue.Exists() {
+ item.V3AuthAlgorithm = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("v3.auth-config.password"); cValue.Exists() {
+ item.V3AuthPassword = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("v3.auth-config.priv-config.aes.algorithm"); cValue.Exists() {
+ item.V3AuthPrivAesAlgorithm = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("v3.auth-config.priv-config.aes.password"); cValue.Exists() {
+ item.V3AuthPrivAesPassword = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("v3.auth-config.priv-config.aes.access-config.ipv6-acl"); cValue.Exists() {
+ item.V3AuthPrivAesAccessIpv6Acl = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("v3.auth-config.priv-config.aes.access-config.standard-acl"); cValue.Exists() {
+ item.V3AuthPrivAesAccessStandardAcl = types.Int64Value(cValue.Int())
+ }
+ if cValue := v.Get("v3.auth-config.priv-config.aes.access-config.acl-name"); cValue.Exists() {
+ item.V3AuthPrivAesAccessAclName = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("v3.auth-config.priv-config.des.password"); cValue.Exists() {
+ item.V3AuthPrivDesPassword = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("v3.auth-config.priv-config.des.access-config.ipv6-acl"); cValue.Exists() {
+ item.V3AuthPrivDesAccessIpv6Acl = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("v3.auth-config.priv-config.des.access-config.standard-acl"); cValue.Exists() {
+ item.V3AuthPrivDesAccessStandardAcl = types.Int64Value(cValue.Int())
+ }
+ if cValue := v.Get("v3.auth-config.priv-config.des.access-config.acl-name"); cValue.Exists() {
+ item.V3AuthPrivDesAccessAclName = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("v3.auth-config.priv-config.des3.password"); cValue.Exists() {
+ item.V3AuthPrivDes3Password = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("v3.auth-config.priv-config.des3.access-config.ipv6-acl"); cValue.Exists() {
+ item.V3AuthPrivDes3AccessIpv6Acl = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("v3.auth-config.priv-config.des3.access-config.standard-acl"); cValue.Exists() {
+ item.V3AuthPrivDes3AccessStandardAcl = types.Int64Value(cValue.Int())
+ }
+ if cValue := v.Get("v3.auth-config.priv-config.des3.access-config.acl-name"); cValue.Exists() {
+ item.V3AuthPrivDes3AccessAclName = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("v3.auth-config.access-config.ipv6-acl"); cValue.Exists() {
+ item.V3AuthAccessIpv6Acl = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("v3.auth-config.access-config.standard-acl"); cValue.Exists() {
+ item.V3AuthAccessStandardAcl = types.Int64Value(cValue.Int())
+ }
+ if cValue := v.Get("v3.auth-config.access-config.acl-name"); cValue.Exists() {
+ item.V3AuthAccessAclName = types.StringValue(cValue.String())
+ }
+ data.Users = append(data.Users, item)
+ return true
+ })
+ }
+}
+
+// End of section. //template:end fromBody
+
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyData
+
+func (data *SNMPServerData) fromBody(ctx context.Context, res gjson.Result) {
+ prefix := helpers.LastElement(data.getPath()) + "."
+ if res.Get(helpers.LastElement(data.getPath())).IsArray() {
+ prefix += "0."
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:chassis-id"); value.Exists() {
+ data.ChassisId = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:contact"); value.Exists() {
+ data.Contact = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:ifindex.persist"); value.Exists() {
+ data.IfindexPersist = types.BoolValue(true)
+ } else {
+ data.IfindexPersist = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:location"); value.Exists() {
+ data.Location = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:packetsize"); value.Exists() {
+ data.Packetsize = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:queue-length"); value.Exists() {
+ data.QueueLength = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.logging.getop"); value.Exists() {
+ data.EnableLoggingGetop = types.BoolValue(value.Bool())
+ } else {
+ data.EnableLoggingGetop = types.BoolNull()
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.logging.setop"); value.Exists() {
+ data.EnableLoggingSetop = types.BoolValue(value.Bool())
+ } else {
+ data.EnableLoggingSetop = types.BoolNull()
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.informs"); value.Exists() {
+ data.EnableInforms = types.BoolValue(true)
+ } else {
+ data.EnableInforms = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps"); value.Exists() {
+ data.EnableTraps = types.BoolValue(true)
+ } else {
+ data.EnableTraps = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.snmp.authentication"); value.Exists() {
+ data.EnableTrapsSnmpAuthentication = types.BoolValue(true)
+ } else {
+ data.EnableTrapsSnmpAuthentication = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.snmp.coldstart"); value.Exists() {
+ data.EnableTrapsSnmpColdstart = types.BoolValue(true)
+ } else {
+ data.EnableTrapsSnmpColdstart = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.snmp.linkdown"); value.Exists() {
+ data.EnableTrapsSnmpLinkdown = types.BoolValue(true)
+ } else {
+ data.EnableTrapsSnmpLinkdown = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.snmp.linkup"); value.Exists() {
+ data.EnableTrapsSnmpLinkup = types.BoolValue(true)
+ } else {
+ data.EnableTrapsSnmpLinkup = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.snmp.warmstart"); value.Exists() {
+ data.EnableTrapsSnmpWarmstart = types.BoolValue(true)
+ } else {
+ data.EnableTrapsSnmpWarmstart = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:host-config.ip-community"); value.Exists() {
+ data.Hosts = make([]SNMPServerHosts, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := SNMPServerHosts{}
+ if cValue := v.Get("ip-address"); cValue.Exists() {
+ item.IpAddress = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("community-or-user"); cValue.Exists() {
+ item.CommunityOrUser = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("version"); cValue.Exists() {
+ item.Version = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("encryption"); cValue.Exists() {
+ item.Encryption = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("security-level"); cValue.Exists() {
+ item.SecurityLevel = types.StringValue(cValue.String())
+ }
+ data.Hosts = append(data.Hosts, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:host-config.ip-vrf-community"); value.Exists() {
+ data.VrfHosts = make([]SNMPServerVrfHosts, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := SNMPServerVrfHosts{}
+ if cValue := v.Get("ip-address"); cValue.Exists() {
+ item.IpAddress = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("vrf"); cValue.Exists() {
+ item.Vrf = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("community-or-user"); cValue.Exists() {
+ item.CommunityOrUser = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("version"); cValue.Exists() {
+ item.Version = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("encryption"); cValue.Exists() {
+ item.Encryption = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("security-level"); cValue.Exists() {
+ item.SecurityLevel = types.StringValue(cValue.String())
+ }
+ data.VrfHosts = append(data.VrfHosts, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:system-shutdown"); value.Exists() {
+ data.SystemShutdown = types.BoolValue(true)
+ } else {
+ data.SystemShutdown = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.flowmon"); value.Exists() {
+ data.EnableTrapsFlowmon = types.BoolValue(true)
+ } else {
+ data.EnableTrapsFlowmon = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.entity-perf.throughput-notif"); value.Exists() {
+ data.EnableTrapsEntityPerfThroughputNotif = types.BoolValue(true)
+ } else {
+ data.EnableTrapsEntityPerfThroughputNotif = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.call-home.message-send-fail"); value.Exists() {
+ data.EnableTrapsCallHomeMessageSendFail = types.BoolValue(true)
+ } else {
+ data.EnableTrapsCallHomeMessageSendFail = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.call-home.server-fail"); value.Exists() {
+ data.EnableTrapsCallHomeServerFail = types.BoolValue(true)
+ } else {
+ data.EnableTrapsCallHomeServerFail = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.tty"); value.Exists() {
+ data.EnableTrapsTty = types.BoolValue(true)
+ } else {
+ data.EnableTrapsTty = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.Cisco-IOS-XE-ospfv3:ospfv3-config.state-change.enable"); value.Exists() {
+ data.EnableTrapsOspfv3ConfigStateChange = types.BoolValue(true)
+ } else {
+ data.EnableTrapsOspfv3ConfigStateChange = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.Cisco-IOS-XE-ospfv3:ospfv3-config.errors.enable"); value.Exists() {
+ data.EnableTrapsOspfv3ConfigErrors = types.BoolValue(true)
+ } else {
+ data.EnableTrapsOspfv3ConfigErrors = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.Cisco-IOS-XE-ospf:ospf-config.retransmit.enable"); value.Exists() {
+ data.EnableTrapsOspfConfigRetransmit = types.BoolValue(true)
+ } else {
+ data.EnableTrapsOspfConfigRetransmit = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.Cisco-IOS-XE-ospf:ospf-config.lsa.enable"); value.Exists() {
+ data.EnableTrapsOspfConfigLsa = types.BoolValue(true)
+ } else {
+ data.EnableTrapsOspfConfigLsa = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.Cisco-IOS-XE-ospf:ospf-config.cisco-specific.state-change.nssa-trans-change"); value.Exists() {
+ data.EnableTrapsOspfNssaTransChange = types.BoolValue(true)
+ } else {
+ data.EnableTrapsOspfNssaTransChange = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.Cisco-IOS-XE-ospf:ospf-config.cisco-specific.state-change.shamlink.interface"); value.Exists() {
+ data.EnableTrapsOspfShamlinkInterface = types.BoolValue(true)
+ } else {
+ data.EnableTrapsOspfShamlinkInterface = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.Cisco-IOS-XE-ospf:ospf-config.cisco-specific.state-change.shamlink.neighbor"); value.Exists() {
+ data.EnableTrapsOspfShamlinkNeighbor = types.BoolValue(true)
+ } else {
+ data.EnableTrapsOspfShamlinkNeighbor = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.Cisco-IOS-XE-ospf:ospf-config.cisco-specific.errors.enable"); value.Exists() {
+ data.EnableTrapsOspfErrorsEnable = types.BoolValue(true)
+ } else {
+ data.EnableTrapsOspfErrorsEnable = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.Cisco-IOS-XE-ospf:ospf-config.cisco-specific.retransmit.enable"); value.Exists() {
+ data.EnableTrapsOspfRetransmitEnable = types.BoolValue(true)
+ } else {
+ data.EnableTrapsOspfRetransmitEnable = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.Cisco-IOS-XE-ospf:ospf-config.cisco-specific.lsa.enable"); value.Exists() {
+ data.EnableTrapsOspfLsaEnable = types.BoolValue(true)
+ } else {
+ data.EnableTrapsOspfLsaEnable = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.eigrp"); value.Exists() {
+ data.EnableTrapsEigrp = types.BoolValue(true)
+ } else {
+ data.EnableTrapsEigrp = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.auth-framework.sec-violation"); value.Exists() {
+ data.EnableTrapsAuthFrameworkSecViolation = types.BoolValue(true)
+ } else {
+ data.EnableTrapsAuthFrameworkSecViolation = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.rep"); value.Exists() {
+ data.EnableTrapsRep = types.BoolValue(true)
+ } else {
+ data.EnableTrapsRep = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.vtp"); value.Exists() {
+ data.EnableTrapsVtp = types.BoolValue(true)
+ } else {
+ data.EnableTrapsVtp = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.vlancreate"); value.Exists() {
+ data.EnableTrapsVlancreate = types.BoolValue(true)
+ } else {
+ data.EnableTrapsVlancreate = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.vlandelete"); value.Exists() {
+ data.EnableTrapsVlandelete = types.BoolValue(true)
+ } else {
+ data.EnableTrapsVlandelete = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.port-security"); value.Exists() {
+ data.EnableTrapsPortSecurity = types.BoolValue(true)
+ } else {
+ data.EnableTrapsPortSecurity = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.license"); value.Exists() {
+ data.EnableTrapsLicense = types.BoolValue(true)
+ } else {
+ data.EnableTrapsLicense = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.smart-licenseing.smart-license"); value.Exists() {
+ data.EnableTrapsSmartLicense = types.BoolValue(true)
+ } else {
+ data.EnableTrapsSmartLicense = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.cpu.threshold"); value.Exists() {
+ data.EnableTrapsCpuThreshold = types.BoolValue(true)
+ } else {
+ data.EnableTrapsCpuThreshold = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.memory.bufferpeak"); value.Exists() {
+ data.EnableTrapsMemoryBufferpeak = types.BoolValue(true)
+ } else {
+ data.EnableTrapsMemoryBufferpeak = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.stackwise"); value.Exists() {
+ data.EnableTrapsStackwise = types.BoolValue(true)
+ } else {
+ data.EnableTrapsStackwise = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.udld.link-fail-rpt"); value.Exists() {
+ data.EnableTrapsUdldLinkFailRpt = types.BoolValue(true)
+ } else {
+ data.EnableTrapsUdldLinkFailRpt = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.udld.status-change"); value.Exists() {
+ data.EnableTrapsUdldStatusChange = types.BoolValue(true)
+ } else {
+ data.EnableTrapsUdldStatusChange = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.fru-ctrl"); value.Exists() {
+ data.EnableTrapsFruCtrl = types.BoolValue(true)
+ } else {
+ data.EnableTrapsFruCtrl = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.flash.insertion"); value.Exists() {
+ data.EnableTrapsFlashInsertion = types.BoolValue(true)
+ } else {
+ data.EnableTrapsFlashInsertion = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.flash.removal"); value.Exists() {
+ data.EnableTrapsFlashRemoval = types.BoolValue(true)
+ } else {
+ data.EnableTrapsFlashRemoval = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.flash.lowspace"); value.Exists() {
+ data.EnableTrapsFlashLowspace = types.BoolValue(true)
+ } else {
+ data.EnableTrapsFlashLowspace = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.energywise"); value.Exists() {
+ data.EnableTrapsEnergywise = types.BoolValue(true)
+ } else {
+ data.EnableTrapsEnergywise = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.power-ethernet.group"); value.Exists() {
+ data.EnableTrapsPowerEthernetGroup = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.power-ethernet.police"); value.Exists() {
+ data.EnableTrapsPowerEthernetPolice = types.BoolValue(true)
+ } else {
+ data.EnableTrapsPowerEthernetPolice = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.entity"); value.Exists() {
+ data.EnableTrapsEntity = types.BoolValue(true)
+ } else {
+ data.EnableTrapsEntity = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.pw.vc"); value.Exists() {
+ data.EnableTrapsPwVc = types.BoolValue(true)
+ } else {
+ data.EnableTrapsPwVc = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.envmon"); value.Exists() {
+ data.EnableTrapsEnvmon = types.BoolValue(true)
+ } else {
+ data.EnableTrapsEnvmon = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.cef.resource-failure"); value.Exists() {
+ data.EnableTrapsCefResourceFailure = types.BoolValue(true)
+ } else {
+ data.EnableTrapsCefResourceFailure = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.cef.peer-state-change"); value.Exists() {
+ data.EnableTrapsCefPeerStateChange = types.BoolValue(true)
+ } else {
+ data.EnableTrapsCefPeerStateChange = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.cef.peer-fib-state-change"); value.Exists() {
+ data.EnableTrapsCefPeerFibStateChange = types.BoolValue(true)
+ } else {
+ data.EnableTrapsCefPeerFibStateChange = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.cef.inconsistency"); value.Exists() {
+ data.EnableTrapsCefInconsistency = types.BoolValue(true)
+ } else {
+ data.EnableTrapsCefInconsistency = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.isis"); value.Exists() {
+ data.EnableTrapsIsis = types.BoolValue(true)
+ } else {
+ data.EnableTrapsIsis = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ipsla"); value.Exists() {
+ data.EnableTrapsIpsla = types.BoolValue(true)
+ } else {
+ data.EnableTrapsIpsla = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.entity-diag.boot-up-fail"); value.Exists() {
+ data.EnableTrapsEntityDiagBootUpFail = types.BoolValue(true)
+ } else {
+ data.EnableTrapsEntityDiagBootUpFail = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.entity-diag.hm-test-recover"); value.Exists() {
+ data.EnableTrapsEntityDiagHmTestRecover = types.BoolValue(true)
+ } else {
+ data.EnableTrapsEntityDiagHmTestRecover = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.entity-diag.hm-thresh-reached"); value.Exists() {
+ data.EnableTrapsEntityDiagHmThreshReached = types.BoolValue(true)
+ } else {
+ data.EnableTrapsEntityDiagHmThreshReached = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.entity-diag.scheduled-test-fail"); value.Exists() {
+ data.EnableTrapsEntityDiagScheduledTestFail = types.BoolValue(true)
+ } else {
+ data.EnableTrapsEntityDiagScheduledTestFail = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.bfd"); value.Exists() {
+ data.EnableTrapsBfd = types.BoolValue(true)
+ } else {
+ data.EnableTrapsBfd = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ike.policy.add"); value.Exists() {
+ data.EnableTrapsIkePolicyAdd = types.BoolValue(true)
+ } else {
+ data.EnableTrapsIkePolicyAdd = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ike.policy.delete"); value.Exists() {
+ data.EnableTrapsIkePolicyDelete = types.BoolValue(true)
+ } else {
+ data.EnableTrapsIkePolicyDelete = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ike.tunnel.start"); value.Exists() {
+ data.EnableTrapsIkeTunnelStart = types.BoolValue(true)
+ } else {
+ data.EnableTrapsIkeTunnelStart = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ike.tunnel.stop"); value.Exists() {
+ data.EnableTrapsIkeTunnelStop = types.BoolValue(true)
+ } else {
+ data.EnableTrapsIkeTunnelStop = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ipsec.cryptomap.add"); value.Exists() {
+ data.EnableTrapsIpsecCryptomapAdd = types.BoolValue(true)
+ } else {
+ data.EnableTrapsIpsecCryptomapAdd = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ipsec.cryptomap.attach"); value.Exists() {
+ data.EnableTrapsIpsecCryptomapAttach = types.BoolValue(true)
+ } else {
+ data.EnableTrapsIpsecCryptomapAttach = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ipsec.cryptomap.delete"); value.Exists() {
+ data.EnableTrapsIpsecCryptomapDelete = types.BoolValue(true)
+ } else {
+ data.EnableTrapsIpsecCryptomapDelete = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ipsec.cryptomap.detach"); value.Exists() {
+ data.EnableTrapsIpsecCryptomapDetach = types.BoolValue(true)
+ } else {
+ data.EnableTrapsIpsecCryptomapDetach = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ipsec.tunnel.start"); value.Exists() {
+ data.EnableTrapsIpsecTunnelStart = types.BoolValue(true)
+ } else {
+ data.EnableTrapsIpsecTunnelStart = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ipsec.tunnel.stop"); value.Exists() {
+ data.EnableTrapsIpsecTunnelStop = types.BoolValue(true)
+ } else {
+ data.EnableTrapsIpsecTunnelStop = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ipsec.too-many-sas"); value.Exists() {
+ data.EnableTrapsIpsecTooManySas = types.BoolValue(true)
+ } else {
+ data.EnableTrapsIpsecTooManySas = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.config-copy"); value.Exists() {
+ data.EnableTrapsConfigCopy = types.BoolValue(true)
+ } else {
+ data.EnableTrapsConfigCopy = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.config"); value.Exists() {
+ data.EnableTrapsConfig = types.BoolValue(true)
+ } else {
+ data.EnableTrapsConfig = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.config-ctid"); value.Exists() {
+ data.EnableTrapsConfigCtid = types.BoolValue(true)
+ } else {
+ data.EnableTrapsConfigCtid = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.dhcp"); value.Exists() {
+ data.EnableTrapsDhcp = types.BoolValue(true)
+ } else {
+ data.EnableTrapsDhcp = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.event-manager"); value.Exists() {
+ data.EnableTrapsEventManager = types.BoolValue(true)
+ } else {
+ data.EnableTrapsEventManager = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.hsrp"); value.Exists() {
+ data.EnableTrapsHsrp = types.BoolValue(true)
+ } else {
+ data.EnableTrapsHsrp = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ipmulticast"); value.Exists() {
+ data.EnableTrapsIpmulticast = types.BoolValue(true)
+ } else {
+ data.EnableTrapsIpmulticast = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.msdp"); value.Exists() {
+ data.EnableTrapsMsdp = types.BoolValue(true)
+ } else {
+ data.EnableTrapsMsdp = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.Cisco-IOS-XE-ospf:ospf-config.state-change.enable"); value.Exists() {
+ data.EnableTrapsOspfConfigStateChange = types.BoolValue(true)
+ } else {
+ data.EnableTrapsOspfConfigStateChange = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.Cisco-IOS-XE-ospf:ospf-config.errors.enable"); value.Exists() {
+ data.EnableTrapsOspfConfigErrors = types.BoolValue(true)
+ } else {
+ data.EnableTrapsOspfConfigErrors = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.pim.invalid-pim-message"); value.Exists() {
+ data.EnableTrapsPimInvalidPimMessage = types.BoolValue(true)
+ } else {
+ data.EnableTrapsPimInvalidPimMessage = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.pim.neighbor-change"); value.Exists() {
+ data.EnableTrapsPimNeighborChange = types.BoolValue(true)
+ } else {
+ data.EnableTrapsPimNeighborChange = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.pim.rp-mapping-change"); value.Exists() {
+ data.EnableTrapsPimRpMappingChange = types.BoolValue(true)
+ } else {
+ data.EnableTrapsPimRpMappingChange = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.bridge.newroot"); value.Exists() {
+ data.EnableTrapsBridgeNewroot = types.BoolValue(true)
+ } else {
+ data.EnableTrapsBridgeNewroot = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.bridge.topologychange"); value.Exists() {
+ data.EnableTrapsBridgeTopologychange = types.BoolValue(true)
+ } else {
+ data.EnableTrapsBridgeTopologychange = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.stpx.inconsistency"); value.Exists() {
+ data.EnableTrapsStpxInconsistency = types.BoolValue(true)
+ } else {
+ data.EnableTrapsStpxInconsistency = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.stpx.root-inconsistency"); value.Exists() {
+ data.EnableTrapsStpxRootInconsistency = types.BoolValue(true)
+ } else {
+ data.EnableTrapsStpxRootInconsistency = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.stpx.loop-inconsistency"); value.Exists() {
+ data.EnableTrapsStpxLoopInconsistency = types.BoolValue(true)
+ } else {
+ data.EnableTrapsStpxLoopInconsistency = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.syslog"); value.Exists() {
+ data.EnableTrapsSyslog = types.BoolValue(true)
+ } else {
+ data.EnableTrapsSyslog = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + ""); value.Exists() {
+ data.EnableTrapsBgpCbgp2 = types.BoolValue(true)
+ } else {
+ data.EnableTrapsBgpCbgp2 = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.nhrp.nhs"); value.Exists() {
+ data.EnableTrapsNhrpNhs = types.BoolValue(true)
+ } else {
+ data.EnableTrapsNhrpNhs = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.nhrp.nhc"); value.Exists() {
+ data.EnableTrapsNhrpNhc = types.BoolValue(true)
+ } else {
+ data.EnableTrapsNhrpNhc = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.nhrp.nhp"); value.Exists() {
+ data.EnableTrapsNhrpNhp = types.BoolValue(true)
+ } else {
+ data.EnableTrapsNhrpNhp = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.nhrp.quota-exceeded"); value.Exists() {
+ data.EnableTrapsNhrpQuotaExceeded = types.BoolValue(true)
+ } else {
+ data.EnableTrapsNhrpQuotaExceeded = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.mpls.traffic-eng"); value.Exists() {
+ data.EnableTrapsMplsTrafficEng = types.BoolValue(true)
+ } else {
+ data.EnableTrapsMplsTrafficEng = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.mpls"); value.Exists() {
+ data.EnableTrapsMpls = types.BoolValue(true)
+ } else {
+ data.EnableTrapsMpls = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.mpls.vpn"); value.Exists() {
+ data.EnableTrapsMplsVpn = types.BoolValue(true)
+ } else {
+ data.EnableTrapsMplsVpn = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.mpls.rfc"); value.Exists() {
+ data.EnableTrapsMplsRfc = types.BoolValue(true)
+ } else {
+ data.EnableTrapsMplsRfc = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.mpls.rfc.ldp"); value.Exists() {
+ data.EnableTrapsMplsRfcLdp = types.BoolValue(true)
+ } else {
+ data.EnableTrapsMplsRfcLdp = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.mpls.ldp"); value.Exists() {
+ data.EnableTrapsMplsLdp = types.BoolValue(true)
+ } else {
+ data.EnableTrapsMplsLdp = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.mpls.fast-reroute.protected"); value.Exists() {
+ data.EnableTrapsFastRerouteProtected = types.BoolValue(true)
+ } else {
+ data.EnableTrapsFastRerouteProtected = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.local-auth"); value.Exists() {
+ data.EnableTrapsLocalAuth = types.BoolValue(true)
+ } else {
+ data.EnableTrapsLocalAuth = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.vlan-membership"); value.Exists() {
+ data.EnableTrapsVlanMembership = types.BoolValue(true)
+ } else {
+ data.EnableTrapsVlanMembership = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.errdisable"); value.Exists() {
+ data.EnableTrapsErrdisable = types.BoolValue(true)
+ } else {
+ data.EnableTrapsErrdisable = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.rf"); value.Exists() {
+ data.EnableTrapsRf = types.BoolValue(true)
+ } else {
+ data.EnableTrapsRf = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.transceiver.all"); value.Exists() {
+ data.EnableTrapsTransceiverAll = types.BoolValue(true)
+ } else {
+ data.EnableTrapsTransceiverAll = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.bulkstat.collection"); value.Exists() {
+ data.EnableTrapsBulkstatCollection = types.BoolValue(true)
+ } else {
+ data.EnableTrapsBulkstatCollection = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.bulkstat.transfer"); value.Exists() {
+ data.EnableTrapsBulkstatTransfer = types.BoolValue(true)
+ } else {
+ data.EnableTrapsBulkstatTransfer = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.mac-notification.change"); value.Exists() {
+ data.EnableTrapsMacNotificationChange = types.BoolValue(true)
+ } else {
+ data.EnableTrapsMacNotificationChange = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.mac-notification.move"); value.Exists() {
+ data.EnableTrapsMacNotificationMove = types.BoolValue(true)
+ } else {
+ data.EnableTrapsMacNotificationMove = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.mac-notification.threshold"); value.Exists() {
+ data.EnableTrapsMacNotificationThreshold = types.BoolValue(true)
+ } else {
+ data.EnableTrapsMacNotificationThreshold = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.vrfmib.vrf-up"); value.Exists() {
+ data.EnableTrapsVrfmibVrfUp = types.BoolValue(true)
+ } else {
+ data.EnableTrapsVrfmibVrfUp = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.vrfmib.vrf-down"); value.Exists() {
+ data.EnableTrapsVrfmibVrfDown = types.BoolValue(true)
+ } else {
+ data.EnableTrapsVrfmibVrfDown = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.vrfmib.vnet-trunk-up"); value.Exists() {
+ data.EnableTrapsVrfmibVnetTrunkUp = types.BoolValue(true)
+ } else {
+ data.EnableTrapsVrfmibVnetTrunkUp = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.vrfmib.vnet-trunk-down"); value.Exists() {
+ data.EnableTrapsVrfmibVnetTrunkDown = types.BoolValue(true)
+ } else {
+ data.EnableTrapsVrfmibVnetTrunkDown = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.mvpn"); value.Exists() {
+ data.EnableTrapsMvpn = types.BoolValue(true)
+ } else {
+ data.EnableTrapsMvpn = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.lisp"); value.Exists() {
+ data.EnableTrapsLisp = types.BoolValue(true)
+ } else {
+ data.EnableTrapsLisp = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.aaa_server"); value.Exists() {
+ data.EnableTrapsAaaServer = types.BoolValue(true)
+ } else {
+ data.EnableTrapsAaaServer = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.vdsl2line"); value.Exists() {
+ data.EnableTrapsVdsl2line = types.BoolValue(true)
+ } else {
+ data.EnableTrapsVdsl2line = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.adslline"); value.Exists() {
+ data.EnableTrapsAdslline = types.BoolValue(true)
+ } else {
+ data.EnableTrapsAdslline = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.pki"); value.Exists() {
+ data.EnableTrapsPki = types.BoolValue(true)
+ } else {
+ data.EnableTrapsPki = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.alarms.alarm-type"); value.Exists() {
+ data.EnableTrapsAlarmType = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.casa"); value.Exists() {
+ data.EnableTrapsCasa = types.BoolValue(true)
+ } else {
+ data.EnableTrapsCasa = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.cnpd"); value.Exists() {
+ data.EnableTrapsCnpd = types.BoolValue(true)
+ } else {
+ data.EnableTrapsCnpd = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.dial"); value.Exists() {
+ data.EnableTrapsDial = types.BoolValue(true)
+ } else {
+ data.EnableTrapsDial = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.dlsw"); value.Exists() {
+ data.EnableTrapsDlsw = types.BoolValue(true)
+ } else {
+ data.EnableTrapsDlsw = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ds1"); value.Exists() {
+ data.EnableTrapsDs1 = types.BoolValue(true)
+ } else {
+ data.EnableTrapsDs1 = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.dsp.card-status"); value.Exists() {
+ data.EnableTrapsDspCardStatus = types.BoolValue(true)
+ } else {
+ data.EnableTrapsDspCardStatus = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.dsp.oper-state"); value.Exists() {
+ data.EnableTrapsDspOperState = types.BoolValue(true)
+ } else {
+ data.EnableTrapsDspOperState = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.entity-sensor"); value.Exists() {
+ data.EnableTrapsEntitySensor = types.BoolValue(true)
+ } else {
+ data.EnableTrapsEntitySensor = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.entity-state"); value.Exists() {
+ data.EnableTrapsEntityState = types.BoolValue(true)
+ } else {
+ data.EnableTrapsEntityState = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.entity-qfp.mem-res-thresh"); value.Exists() {
+ data.EnableTrapsEntityQfpMemResThresh = types.BoolValue(true)
+ } else {
+ data.EnableTrapsEntityQfpMemResThresh = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.entity-qfp.throughput-notif"); value.Exists() {
+ data.EnableTrapsEntityQfpThroughputNotif = types.BoolValue(true)
+ } else {
+ data.EnableTrapsEntityQfpThroughputNotif = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ether-oam"); value.Exists() {
+ data.EnableTrapsEtherOam = types.BoolValue(true)
+ } else {
+ data.EnableTrapsEtherOam = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ethernet.cfm.alarm"); value.Exists() {
+ data.EnableTrapsEthernetCfmAlarm = types.BoolValue(true)
+ } else {
+ data.EnableTrapsEthernetCfmAlarm = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ethernet.cfm.cc.config"); value.Exists() {
+ data.EnableTrapsEthernetCfmCcConfig = types.BoolValue(true)
+ } else {
+ data.EnableTrapsEthernetCfmCcConfig = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ethernet.cfm.cc.cross-connect"); value.Exists() {
+ data.EnableTrapsEthernetCfmCcCrossConnect = types.BoolValue(true)
+ } else {
+ data.EnableTrapsEthernetCfmCcCrossConnect = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ethernet.cfm.cc.loop"); value.Exists() {
+ data.EnableTrapsEthernetCfmCcLoop = types.BoolValue(true)
+ } else {
+ data.EnableTrapsEthernetCfmCcLoop = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ethernet.cfm.cc.mep-down"); value.Exists() {
+ data.EnableTrapsEthernetCfmCcMepDown = types.BoolValue(true)
+ } else {
+ data.EnableTrapsEthernetCfmCcMepDown = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ethernet.cfm.cc.mep-up"); value.Exists() {
+ data.EnableTrapsEthernetCfmCcMepUp = types.BoolValue(true)
+ } else {
+ data.EnableTrapsEthernetCfmCcMepUp = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ethernet.cfm.crosscheck.mep-missing"); value.Exists() {
+ data.EnableTrapsEthernetCfmCrosscheckMepMissing = types.BoolValue(true)
+ } else {
+ data.EnableTrapsEthernetCfmCrosscheckMepMissing = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ethernet.cfm.crosscheck.mep-unknown"); value.Exists() {
+ data.EnableTrapsEthernetCfmCrosscheckMepUnknown = types.BoolValue(true)
+ } else {
+ data.EnableTrapsEthernetCfmCrosscheckMepUnknown = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ethernet.cfm.crosscheck.service-up"); value.Exists() {
+ data.EnableTrapsEthernetCfmCrosscheckServiceUp = types.BoolValue(true)
+ } else {
+ data.EnableTrapsEthernetCfmCrosscheckServiceUp = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ethernet.evc.create"); value.Exists() {
+ data.EnableTrapsEthernetEvcCreate = types.BoolValue(true)
+ } else {
+ data.EnableTrapsEthernetEvcCreate = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ethernet.evc.delete"); value.Exists() {
+ data.EnableTrapsEthernetEvcDelete = types.BoolValue(true)
+ } else {
+ data.EnableTrapsEthernetEvcDelete = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ethernet.evc.status"); value.Exists() {
+ data.EnableTrapsEthernetEvcStatus = types.BoolValue(true)
+ } else {
+ data.EnableTrapsEthernetEvcStatus = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.firewall.serverstatus"); value.Exists() {
+ data.EnableTrapsFirewallServerstatus = types.BoolValue(true)
+ } else {
+ data.EnableTrapsFirewallServerstatus = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.frame-relay-config.only-frame-relay.frame-relay"); value.Exists() {
+ data.EnableTrapsFrameRelayConfigOnly = types.BoolValue(true)
+ } else {
+ data.EnableTrapsFrameRelayConfigOnly = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.frame-relay-config.frame-relay-options.frame-relay.subif-configs.subif"); value.Exists() {
+ data.EnableTrapsFrameRelayConfigSubifConfigs = types.BoolValue(true)
+ } else {
+ data.EnableTrapsFrameRelayConfigSubifConfigs = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.frame-relay.subif.count"); value.Exists() {
+ data.EnableTrapsFrameRelaySubifCount = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.frame-relay.subif.interval"); value.Exists() {
+ data.EnableTrapsFrameRelaySubifInterval = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.frame-relay-config.frame-relay-options.frame-relay.multilink.bundle-mismatch"); value.Exists() {
+ data.EnableTrapsFrameRelayConfigBundleMismatch = types.BoolValue(true)
+ } else {
+ data.EnableTrapsFrameRelayConfigBundleMismatch = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.frame-relay.multilink.bundle-mismatch"); value.Exists() {
+ data.EnableTrapsFrameRelayMultilinkBundleMismatch = types.BoolValue(true)
+ } else {
+ data.EnableTrapsFrameRelayMultilinkBundleMismatch = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ip.local.pool"); value.Exists() {
+ data.EnableTrapsIpLocalPool = types.BoolValue(true)
+ } else {
+ data.EnableTrapsIpLocalPool = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.isdn.call-information"); value.Exists() {
+ data.EnableTrapsIsdnCallInformation = types.BoolValue(true)
+ } else {
+ data.EnableTrapsIsdnCallInformation = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.isdn.chan-not-avail"); value.Exists() {
+ data.EnableTrapsIsdnChanNotAvail = types.BoolValue(true)
+ } else {
+ data.EnableTrapsIsdnChanNotAvail = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.isdn.ietf"); value.Exists() {
+ data.EnableTrapsIsdnIetf = types.BoolValue(true)
+ } else {
+ data.EnableTrapsIsdnIetf = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.isdn.layer2"); value.Exists() {
+ data.EnableTrapsIsdnLayer2 = types.BoolValue(true)
+ } else {
+ data.EnableTrapsIsdnLayer2 = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.l2tun.session"); value.Exists() {
+ data.EnableTrapsL2tunSession = types.BoolValue(true)
+ } else {
+ data.EnableTrapsL2tunSession = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.l2tun.tunnel"); value.Exists() {
+ data.EnableTrapsL2tunTunnel = types.BoolValue(true)
+ } else {
+ data.EnableTrapsL2tunTunnel = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.l2tun.pseudowire.status"); value.Exists() {
+ data.EnableTrapsL2tunPseudowireStatus = types.BoolValue(true)
+ } else {
+ data.EnableTrapsL2tunPseudowireStatus = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.pimstdmib.neighbor-loss"); value.Exists() {
+ data.EnableTrapsPimstdmibNeighborLoss = types.BoolValue(true)
+ } else {
+ data.EnableTrapsPimstdmibNeighborLoss = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.pimstdmib.invalid-register"); value.Exists() {
+ data.EnableTrapsPimstdmibInvalidRegister = types.BoolValue(true)
+ } else {
+ data.EnableTrapsPimstdmibInvalidRegister = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.pimstdmib.invalid-join-prune"); value.Exists() {
+ data.EnableTrapsPimstdmibInvalidJoinPrune = types.BoolValue(true)
+ } else {
+ data.EnableTrapsPimstdmibInvalidJoinPrune = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.pimstdmib.rp-mapping-change"); value.Exists() {
+ data.EnableTrapsPimstdmibRpMappingChange = types.BoolValue(true)
+ } else {
+ data.EnableTrapsPimstdmibRpMappingChange = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.pimstdmib.interface-election"); value.Exists() {
+ data.EnableTrapsPimstdmibInterfaceElection = types.BoolValue(true)
+ } else {
+ data.EnableTrapsPimstdmibInterfaceElection = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.pfr"); value.Exists() {
+ data.EnableTrapsPfr = types.BoolValue(true)
+ } else {
+ data.EnableTrapsPfr = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.pppoe"); value.Exists() {
+ data.EnableTrapsPppoe = types.BoolValue(true)
+ } else {
+ data.EnableTrapsPppoe = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.resource-policy"); value.Exists() {
+ data.EnableTrapsResourcePolicy = types.BoolValue(true)
+ } else {
+ data.EnableTrapsResourcePolicy = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.rsvp"); value.Exists() {
+ data.EnableTrapsRsvp = types.BoolValue(true)
+ } else {
+ data.EnableTrapsRsvp = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.vrrp"); value.Exists() {
+ data.EnableTrapsVrrp = types.BoolValue(true)
+ } else {
+ data.EnableTrapsVrrp = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.sonet"); value.Exists() {
+ data.EnableTrapsSonet = types.BoolValue(true)
+ } else {
+ data.EnableTrapsSonet = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.srp"); value.Exists() {
+ data.EnableTrapsSrp = types.BoolValue(true)
+ } else {
+ data.EnableTrapsSrp = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.voice"); value.Exists() {
+ data.EnableTrapsVoice = types.BoolValue(true)
+ } else {
+ data.EnableTrapsVoice = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.bgp"); value.Exists() {
+ data.EnableTrapsBgp = types.BoolValue(true)
+ } else {
+ data.EnableTrapsBgp = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.bgp-traps.cbgp2"); value.Exists() {
+ data.EnableTrapsCbgp2 = types.BoolValue(true)
+ } else {
+ data.EnableTrapsCbgp2 = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ospfv3.errors"); value.Exists() {
+ data.EnableTrapsOspfv3Errors = types.BoolValue(true)
+ } else {
+ data.EnableTrapsOspfv3Errors = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ospfv3.state-change"); value.Exists() {
+ data.EnableTrapsOspfv3StateChange = types.BoolValue(true)
+ } else {
+ data.EnableTrapsOspfv3StateChange = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:source-interface.informs.GigabitEthernet"); value.Exists() {
+ data.SourceInterfaceInformsGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:source-interface.informs.TenGigabitEthernet"); value.Exists() {
+ data.SourceInterfaceInformsTenGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:source-interface.informs.FortyGigabitEthernet"); value.Exists() {
+ data.SourceInterfaceInformsFortyGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:source-interface.informs.HundredGigE"); value.Exists() {
+ data.SourceInterfaceInformsHundredGigE = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:source-interface.informs.Loopback"); value.Exists() {
+ data.SourceInterfaceInformsLoopback = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:source-interface.informs.Port-channel"); value.Exists() {
+ data.SourceInterfaceInformsPortChannel = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:source-interface.informs.Port-channel-subinterface.Port-channel"); value.Exists() {
+ data.SourceInterfaceInformsPortChannelSubinterface = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:source-interface.informs.Vlan"); value.Exists() {
+ data.SourceInterfaceInformsVlan = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:source-interface.traps.GigabitEthernet"); value.Exists() {
+ data.SourceInterfaceTrapsGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:source-interface.traps.TenGigabitEthernet"); value.Exists() {
+ data.SourceInterfaceTrapsTenGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:source-interface.traps.FortyGigabitEthernet"); value.Exists() {
+ data.SourceInterfaceTrapsFortyGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:source-interface.traps.HundredGigE"); value.Exists() {
+ data.SourceInterfaceTrapsHundredGigE = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:source-interface.traps.Loopback"); value.Exists() {
+ data.SourceInterfaceTrapsLoopback = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:source-interface.traps.Port-channel"); value.Exists() {
+ data.SourceInterfaceTrapsPortChannel = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:source-interface.traps.Port-channel-subinterface.Port-channel"); value.Exists() {
+ data.SourceInterfaceTrapsPortChannelSubinterface = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:source-interface.traps.Vlan"); value.Exists() {
+ data.SourceInterfaceTrapsVlan = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:trap-source.GigabitEthernet"); value.Exists() {
+ data.TrapSourceGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:trap-source.TenGigabitEthernet"); value.Exists() {
+ data.TrapSourceTenGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:trap-source.FortyGigabitEthernet"); value.Exists() {
+ data.TrapSourceFortyGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:trap-source.HundredGigE"); value.Exists() {
+ data.TrapSourceHundredGigE = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:trap-source.Loopback"); value.Exists() {
+ data.TrapSourceLoopback = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:trap-source.Port-channel"); value.Exists() {
+ data.TrapSourcePortChannel = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:trap-source.Port-channel-subinterface.Port-channel"); value.Exists() {
+ data.TrapSourcePortChannelSubinterface = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:trap-source.Vlan"); value.Exists() {
+ data.TrapSourceVlan = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:community-config"); value.Exists() {
+ data.SnmpCommunities = make([]SNMPServerSnmpCommunities, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := SNMPServerSnmpCommunities{}
+ if cValue := v.Get("name"); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("view"); cValue.Exists() {
+ item.View = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("permission"); cValue.Exists() {
+ item.Permission = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("ipv6"); cValue.Exists() {
+ item.Ipv6 = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("access-list-name"); cValue.Exists() {
+ item.AccessListName = types.StringValue(cValue.String())
+ }
+ data.SnmpCommunities = append(data.SnmpCommunities, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:context"); value.Exists() {
+ data.Contexts = make([]SNMPServerContexts, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := SNMPServerContexts{}
+ if cValue := v.Get("name"); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ data.Contexts = append(data.Contexts, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:view"); value.Exists() {
+ data.Views = make([]SNMPServerViews, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := SNMPServerViews{}
+ if cValue := v.Get("name"); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("mib"); cValue.Exists() {
+ item.Mib = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("inc-exl"); cValue.Exists() {
+ item.IncExl = types.StringValue(cValue.String())
+ }
+ data.Views = append(data.Views, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:group"); value.Exists() {
+ data.Groups = make([]SNMPServerGroups, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := SNMPServerGroups{}
+ if cValue := v.Get("id"); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("v3.security-level-list"); cValue.Exists() {
+ item.V3Security = make([]SNMPServerGroupsV3Security, 0)
+ cValue.ForEach(func(ck, cv gjson.Result) bool {
+ cItem := SNMPServerGroupsV3Security{}
+ if ccValue := cv.Get("security-level"); ccValue.Exists() {
+ cItem.SecurityLevel = types.StringValue(ccValue.String())
+ }
+ if ccValue := cv.Get("context-node"); ccValue.Exists() {
+ cItem.ContextNode = types.StringValue(ccValue.String())
+ }
+ if ccValue := cv.Get("match-node"); ccValue.Exists() {
+ cItem.MatchNode = types.StringValue(ccValue.String())
+ }
+ if ccValue := cv.Get("read-node"); ccValue.Exists() {
+ cItem.ReadNode = types.StringValue(ccValue.String())
+ }
+ if ccValue := cv.Get("write-node"); ccValue.Exists() {
+ cItem.WriteNode = types.StringValue(ccValue.String())
+ }
+ if ccValue := cv.Get("notify-node"); ccValue.Exists() {
+ cItem.NotifyNode = types.StringValue(ccValue.String())
+ }
+ if ccValue := cv.Get("access-config.ipv6-acl"); ccValue.Exists() {
+ cItem.AccessIpv6Acl = types.StringValue(ccValue.String())
+ }
+ if ccValue := cv.Get("access-config.standard-acl"); ccValue.Exists() {
+ cItem.AccessStandardAcl = types.Int64Value(ccValue.Int())
+ }
+ if ccValue := cv.Get("access-config.acl-name"); ccValue.Exists() {
+ cItem.AccessAclName = types.StringValue(ccValue.String())
+ }
+ item.V3Security = append(item.V3Security, cItem)
+ return true
+ })
+ }
+ data.Groups = append(data.Groups, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-snmp:user.names"); value.Exists() {
+ data.Users = make([]SNMPServerUsers, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := SNMPServerUsers{}
+ if cValue := v.Get("username"); cValue.Exists() {
+ item.Username = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("grpname"); cValue.Exists() {
+ item.Grpname = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("v3.auth-config.algorithm"); cValue.Exists() {
+ item.V3AuthAlgorithm = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("v3.auth-config.password"); cValue.Exists() {
+ item.V3AuthPassword = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("v3.auth-config.priv-config.aes.algorithm"); cValue.Exists() {
+ item.V3AuthPrivAesAlgorithm = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("v3.auth-config.priv-config.aes.password"); cValue.Exists() {
+ item.V3AuthPrivAesPassword = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("v3.auth-config.priv-config.aes.access-config.ipv6-acl"); cValue.Exists() {
+ item.V3AuthPrivAesAccessIpv6Acl = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("v3.auth-config.priv-config.aes.access-config.standard-acl"); cValue.Exists() {
+ item.V3AuthPrivAesAccessStandardAcl = types.Int64Value(cValue.Int())
+ }
+ if cValue := v.Get("v3.auth-config.priv-config.aes.access-config.acl-name"); cValue.Exists() {
+ item.V3AuthPrivAesAccessAclName = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("v3.auth-config.priv-config.des.password"); cValue.Exists() {
+ item.V3AuthPrivDesPassword = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("v3.auth-config.priv-config.des.access-config.ipv6-acl"); cValue.Exists() {
+ item.V3AuthPrivDesAccessIpv6Acl = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("v3.auth-config.priv-config.des.access-config.standard-acl"); cValue.Exists() {
+ item.V3AuthPrivDesAccessStandardAcl = types.Int64Value(cValue.Int())
+ }
+ if cValue := v.Get("v3.auth-config.priv-config.des.access-config.acl-name"); cValue.Exists() {
+ item.V3AuthPrivDesAccessAclName = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("v3.auth-config.priv-config.des3.password"); cValue.Exists() {
+ item.V3AuthPrivDes3Password = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("v3.auth-config.priv-config.des3.access-config.ipv6-acl"); cValue.Exists() {
+ item.V3AuthPrivDes3AccessIpv6Acl = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("v3.auth-config.priv-config.des3.access-config.standard-acl"); cValue.Exists() {
+ item.V3AuthPrivDes3AccessStandardAcl = types.Int64Value(cValue.Int())
+ }
+ if cValue := v.Get("v3.auth-config.priv-config.des3.access-config.acl-name"); cValue.Exists() {
+ item.V3AuthPrivDes3AccessAclName = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("v3.auth-config.access-config.ipv6-acl"); cValue.Exists() {
+ item.V3AuthAccessIpv6Acl = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("v3.auth-config.access-config.standard-acl"); cValue.Exists() {
+ item.V3AuthAccessStandardAcl = types.Int64Value(cValue.Int())
+ }
+ if cValue := v.Get("v3.auth-config.access-config.acl-name"); cValue.Exists() {
+ item.V3AuthAccessAclName = types.StringValue(cValue.String())
+ }
+ data.Users = append(data.Users, item)
+ return true
+ })
+ }
+}
+
+// End of section. //template:end fromBodyData
+
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyXML
+
+func (data *SNMPServer) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:chassis-id"); value.Exists() {
+ data.ChassisId = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:contact"); value.Exists() {
+ data.Contact = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:ifindex/persist"); value.Exists() {
+ data.IfindexPersist = types.BoolValue(true)
+ } else {
+ data.IfindexPersist = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:location"); value.Exists() {
+ data.Location = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:packetsize"); value.Exists() {
+ data.Packetsize = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:queue-length"); value.Exists() {
+ data.QueueLength = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/logging/getop"); value.Exists() {
+ data.EnableLoggingGetop = types.BoolValue(value.Bool())
+ } else {
+ data.EnableLoggingGetop = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/logging/setop"); value.Exists() {
+ data.EnableLoggingSetop = types.BoolValue(value.Bool())
+ } else {
+ data.EnableLoggingSetop = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/informs"); value.Exists() {
+ data.EnableInforms = types.BoolValue(true)
+ } else {
+ data.EnableInforms = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps"); value.Exists() {
+ data.EnableTraps = types.BoolValue(true)
+ } else {
+ data.EnableTraps = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/snmp/authentication"); value.Exists() {
+ data.EnableTrapsSnmpAuthentication = types.BoolValue(true)
+ } else {
+ data.EnableTrapsSnmpAuthentication = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/snmp/coldstart"); value.Exists() {
+ data.EnableTrapsSnmpColdstart = types.BoolValue(true)
+ } else {
+ data.EnableTrapsSnmpColdstart = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/snmp/linkdown"); value.Exists() {
+ data.EnableTrapsSnmpLinkdown = types.BoolValue(true)
+ } else {
+ data.EnableTrapsSnmpLinkdown = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/snmp/linkup"); value.Exists() {
+ data.EnableTrapsSnmpLinkup = types.BoolValue(true)
+ } else {
+ data.EnableTrapsSnmpLinkup = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/snmp/warmstart"); value.Exists() {
+ data.EnableTrapsSnmpWarmstart = types.BoolValue(true)
+ } else {
+ data.EnableTrapsSnmpWarmstart = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:host-config/ip-community"); value.Exists() {
+ data.Hosts = make([]SNMPServerHosts, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := SNMPServerHosts{}
+ if cValue := helpers.GetFromXPath(v, "ip-address"); cValue.Exists() {
+ item.IpAddress = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "community-or-user"); cValue.Exists() {
+ item.CommunityOrUser = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "version"); cValue.Exists() {
+ item.Version = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "encryption"); cValue.Exists() {
+ item.Encryption = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "security-level"); cValue.Exists() {
+ item.SecurityLevel = types.StringValue(cValue.String())
+ }
+ data.Hosts = append(data.Hosts, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:host-config/ip-vrf-community"); value.Exists() {
+ data.VrfHosts = make([]SNMPServerVrfHosts, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := SNMPServerVrfHosts{}
+ if cValue := helpers.GetFromXPath(v, "ip-address"); cValue.Exists() {
+ item.IpAddress = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "vrf"); cValue.Exists() {
+ item.Vrf = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "community-or-user"); cValue.Exists() {
+ item.CommunityOrUser = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "version"); cValue.Exists() {
+ item.Version = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "encryption"); cValue.Exists() {
+ item.Encryption = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "security-level"); cValue.Exists() {
+ item.SecurityLevel = types.StringValue(cValue.String())
+ }
+ data.VrfHosts = append(data.VrfHosts, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:system-shutdown"); value.Exists() {
+ data.SystemShutdown = types.BoolValue(true)
+ } else {
+ data.SystemShutdown = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/flowmon"); value.Exists() {
+ data.EnableTrapsFlowmon = types.BoolValue(true)
+ } else {
+ data.EnableTrapsFlowmon = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/entity-perf/throughput-notif"); value.Exists() {
+ data.EnableTrapsEntityPerfThroughputNotif = types.BoolValue(true)
+ } else {
+ data.EnableTrapsEntityPerfThroughputNotif = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/call-home/message-send-fail"); value.Exists() {
+ data.EnableTrapsCallHomeMessageSendFail = types.BoolValue(true)
+ } else {
+ data.EnableTrapsCallHomeMessageSendFail = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/call-home/server-fail"); value.Exists() {
+ data.EnableTrapsCallHomeServerFail = types.BoolValue(true)
+ } else {
+ data.EnableTrapsCallHomeServerFail = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/tty"); value.Exists() {
+ data.EnableTrapsTty = types.BoolValue(true)
+ } else {
+ data.EnableTrapsTty = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/Cisco-IOS-XE-ospfv3:ospfv3-config/state-change/enable"); value.Exists() {
+ data.EnableTrapsOspfv3ConfigStateChange = types.BoolValue(true)
+ } else {
+ data.EnableTrapsOspfv3ConfigStateChange = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/Cisco-IOS-XE-ospfv3:ospfv3-config/errors/enable"); value.Exists() {
+ data.EnableTrapsOspfv3ConfigErrors = types.BoolValue(true)
+ } else {
+ data.EnableTrapsOspfv3ConfigErrors = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/Cisco-IOS-XE-ospf:ospf-config/retransmit/enable"); value.Exists() {
+ data.EnableTrapsOspfConfigRetransmit = types.BoolValue(true)
+ } else {
+ data.EnableTrapsOspfConfigRetransmit = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/Cisco-IOS-XE-ospf:ospf-config/lsa/enable"); value.Exists() {
+ data.EnableTrapsOspfConfigLsa = types.BoolValue(true)
+ } else {
+ data.EnableTrapsOspfConfigLsa = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/Cisco-IOS-XE-ospf:ospf-config/cisco-specific/state-change/nssa-trans-change"); value.Exists() {
+ data.EnableTrapsOspfNssaTransChange = types.BoolValue(true)
+ } else {
+ data.EnableTrapsOspfNssaTransChange = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/Cisco-IOS-XE-ospf:ospf-config/cisco-specific/state-change/shamlink/interface"); value.Exists() {
+ data.EnableTrapsOspfShamlinkInterface = types.BoolValue(true)
+ } else {
+ data.EnableTrapsOspfShamlinkInterface = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/Cisco-IOS-XE-ospf:ospf-config/cisco-specific/state-change/shamlink/neighbor"); value.Exists() {
+ data.EnableTrapsOspfShamlinkNeighbor = types.BoolValue(true)
+ } else {
+ data.EnableTrapsOspfShamlinkNeighbor = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/Cisco-IOS-XE-ospf:ospf-config/cisco-specific/errors/enable"); value.Exists() {
+ data.EnableTrapsOspfErrorsEnable = types.BoolValue(true)
+ } else {
+ data.EnableTrapsOspfErrorsEnable = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/Cisco-IOS-XE-ospf:ospf-config/cisco-specific/retransmit/enable"); value.Exists() {
+ data.EnableTrapsOspfRetransmitEnable = types.BoolValue(true)
+ } else {
+ data.EnableTrapsOspfRetransmitEnable = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/Cisco-IOS-XE-ospf:ospf-config/cisco-specific/lsa/enable"); value.Exists() {
+ data.EnableTrapsOspfLsaEnable = types.BoolValue(true)
+ } else {
+ data.EnableTrapsOspfLsaEnable = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/eigrp"); value.Exists() {
+ data.EnableTrapsEigrp = types.BoolValue(true)
+ } else {
+ data.EnableTrapsEigrp = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/auth-framework/sec-violation"); value.Exists() {
+ data.EnableTrapsAuthFrameworkSecViolation = types.BoolValue(true)
+ } else {
+ data.EnableTrapsAuthFrameworkSecViolation = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/rep"); value.Exists() {
+ data.EnableTrapsRep = types.BoolValue(true)
+ } else {
+ data.EnableTrapsRep = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/vtp"); value.Exists() {
+ data.EnableTrapsVtp = types.BoolValue(true)
+ } else {
+ data.EnableTrapsVtp = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/vlancreate"); value.Exists() {
+ data.EnableTrapsVlancreate = types.BoolValue(true)
+ } else {
+ data.EnableTrapsVlancreate = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/vlandelete"); value.Exists() {
+ data.EnableTrapsVlandelete = types.BoolValue(true)
+ } else {
+ data.EnableTrapsVlandelete = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/port-security"); value.Exists() {
+ data.EnableTrapsPortSecurity = types.BoolValue(true)
+ } else {
+ data.EnableTrapsPortSecurity = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/license"); value.Exists() {
+ data.EnableTrapsLicense = types.BoolValue(true)
+ } else {
+ data.EnableTrapsLicense = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/smart-licenseing/smart-license"); value.Exists() {
+ data.EnableTrapsSmartLicense = types.BoolValue(true)
+ } else {
+ data.EnableTrapsSmartLicense = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/cpu/threshold"); value.Exists() {
+ data.EnableTrapsCpuThreshold = types.BoolValue(true)
+ } else {
+ data.EnableTrapsCpuThreshold = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/memory/bufferpeak"); value.Exists() {
+ data.EnableTrapsMemoryBufferpeak = types.BoolValue(true)
+ } else {
+ data.EnableTrapsMemoryBufferpeak = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/stackwise"); value.Exists() {
+ data.EnableTrapsStackwise = types.BoolValue(true)
+ } else {
+ data.EnableTrapsStackwise = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/udld/link-fail-rpt"); value.Exists() {
+ data.EnableTrapsUdldLinkFailRpt = types.BoolValue(true)
+ } else {
+ data.EnableTrapsUdldLinkFailRpt = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/udld/status-change"); value.Exists() {
+ data.EnableTrapsUdldStatusChange = types.BoolValue(true)
+ } else {
+ data.EnableTrapsUdldStatusChange = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/fru-ctrl"); value.Exists() {
+ data.EnableTrapsFruCtrl = types.BoolValue(true)
+ } else {
+ data.EnableTrapsFruCtrl = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/flash/insertion"); value.Exists() {
+ data.EnableTrapsFlashInsertion = types.BoolValue(true)
+ } else {
+ data.EnableTrapsFlashInsertion = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/flash/removal"); value.Exists() {
+ data.EnableTrapsFlashRemoval = types.BoolValue(true)
+ } else {
+ data.EnableTrapsFlashRemoval = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/flash/lowspace"); value.Exists() {
+ data.EnableTrapsFlashLowspace = types.BoolValue(true)
+ } else {
+ data.EnableTrapsFlashLowspace = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/energywise"); value.Exists() {
+ data.EnableTrapsEnergywise = types.BoolValue(true)
+ } else {
+ data.EnableTrapsEnergywise = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/power-ethernet/group"); value.Exists() {
+ data.EnableTrapsPowerEthernetGroup = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/power-ethernet/police"); value.Exists() {
+ data.EnableTrapsPowerEthernetPolice = types.BoolValue(true)
+ } else {
+ data.EnableTrapsPowerEthernetPolice = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/entity"); value.Exists() {
+ data.EnableTrapsEntity = types.BoolValue(true)
+ } else {
+ data.EnableTrapsEntity = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/pw/vc"); value.Exists() {
+ data.EnableTrapsPwVc = types.BoolValue(true)
+ } else {
+ data.EnableTrapsPwVc = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/envmon"); value.Exists() {
+ data.EnableTrapsEnvmon = types.BoolValue(true)
+ } else {
+ data.EnableTrapsEnvmon = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/cef/resource-failure"); value.Exists() {
+ data.EnableTrapsCefResourceFailure = types.BoolValue(true)
+ } else {
+ data.EnableTrapsCefResourceFailure = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/cef/peer-state-change"); value.Exists() {
+ data.EnableTrapsCefPeerStateChange = types.BoolValue(true)
+ } else {
+ data.EnableTrapsCefPeerStateChange = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/cef/peer-fib-state-change"); value.Exists() {
+ data.EnableTrapsCefPeerFibStateChange = types.BoolValue(true)
+ } else {
+ data.EnableTrapsCefPeerFibStateChange = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/cef/inconsistency"); value.Exists() {
+ data.EnableTrapsCefInconsistency = types.BoolValue(true)
+ } else {
+ data.EnableTrapsCefInconsistency = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/isis"); value.Exists() {
+ data.EnableTrapsIsis = types.BoolValue(true)
+ } else {
+ data.EnableTrapsIsis = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ipsla"); value.Exists() {
+ data.EnableTrapsIpsla = types.BoolValue(true)
+ } else {
+ data.EnableTrapsIpsla = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/entity-diag/boot-up-fail"); value.Exists() {
+ data.EnableTrapsEntityDiagBootUpFail = types.BoolValue(true)
+ } else {
+ data.EnableTrapsEntityDiagBootUpFail = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/entity-diag/hm-test-recover"); value.Exists() {
+ data.EnableTrapsEntityDiagHmTestRecover = types.BoolValue(true)
+ } else {
+ data.EnableTrapsEntityDiagHmTestRecover = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/entity-diag/hm-thresh-reached"); value.Exists() {
+ data.EnableTrapsEntityDiagHmThreshReached = types.BoolValue(true)
+ } else {
+ data.EnableTrapsEntityDiagHmThreshReached = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/entity-diag/scheduled-test-fail"); value.Exists() {
+ data.EnableTrapsEntityDiagScheduledTestFail = types.BoolValue(true)
+ } else {
+ data.EnableTrapsEntityDiagScheduledTestFail = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/bfd"); value.Exists() {
+ data.EnableTrapsBfd = types.BoolValue(true)
+ } else {
+ data.EnableTrapsBfd = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ike/policy/add"); value.Exists() {
+ data.EnableTrapsIkePolicyAdd = types.BoolValue(true)
+ } else {
+ data.EnableTrapsIkePolicyAdd = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ike/policy/delete"); value.Exists() {
+ data.EnableTrapsIkePolicyDelete = types.BoolValue(true)
+ } else {
+ data.EnableTrapsIkePolicyDelete = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ike/tunnel/start"); value.Exists() {
+ data.EnableTrapsIkeTunnelStart = types.BoolValue(true)
+ } else {
+ data.EnableTrapsIkeTunnelStart = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ike/tunnel/stop"); value.Exists() {
+ data.EnableTrapsIkeTunnelStop = types.BoolValue(true)
+ } else {
+ data.EnableTrapsIkeTunnelStop = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ipsec/cryptomap/add"); value.Exists() {
+ data.EnableTrapsIpsecCryptomapAdd = types.BoolValue(true)
+ } else {
+ data.EnableTrapsIpsecCryptomapAdd = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ipsec/cryptomap/attach"); value.Exists() {
+ data.EnableTrapsIpsecCryptomapAttach = types.BoolValue(true)
+ } else {
+ data.EnableTrapsIpsecCryptomapAttach = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ipsec/cryptomap/delete"); value.Exists() {
+ data.EnableTrapsIpsecCryptomapDelete = types.BoolValue(true)
+ } else {
+ data.EnableTrapsIpsecCryptomapDelete = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ipsec/cryptomap/detach"); value.Exists() {
+ data.EnableTrapsIpsecCryptomapDetach = types.BoolValue(true)
+ } else {
+ data.EnableTrapsIpsecCryptomapDetach = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ipsec/tunnel/start"); value.Exists() {
+ data.EnableTrapsIpsecTunnelStart = types.BoolValue(true)
+ } else {
+ data.EnableTrapsIpsecTunnelStart = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ipsec/tunnel/stop"); value.Exists() {
+ data.EnableTrapsIpsecTunnelStop = types.BoolValue(true)
+ } else {
+ data.EnableTrapsIpsecTunnelStop = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ipsec/too-many-sas"); value.Exists() {
+ data.EnableTrapsIpsecTooManySas = types.BoolValue(true)
+ } else {
+ data.EnableTrapsIpsecTooManySas = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/config-copy"); value.Exists() {
+ data.EnableTrapsConfigCopy = types.BoolValue(true)
+ } else {
+ data.EnableTrapsConfigCopy = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/config"); value.Exists() {
+ data.EnableTrapsConfig = types.BoolValue(true)
+ } else {
+ data.EnableTrapsConfig = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/config-ctid"); value.Exists() {
+ data.EnableTrapsConfigCtid = types.BoolValue(true)
+ } else {
+ data.EnableTrapsConfigCtid = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/dhcp"); value.Exists() {
+ data.EnableTrapsDhcp = types.BoolValue(true)
+ } else {
+ data.EnableTrapsDhcp = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/event-manager"); value.Exists() {
+ data.EnableTrapsEventManager = types.BoolValue(true)
+ } else {
+ data.EnableTrapsEventManager = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/hsrp"); value.Exists() {
+ data.EnableTrapsHsrp = types.BoolValue(true)
+ } else {
+ data.EnableTrapsHsrp = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ipmulticast"); value.Exists() {
+ data.EnableTrapsIpmulticast = types.BoolValue(true)
+ } else {
+ data.EnableTrapsIpmulticast = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/msdp"); value.Exists() {
+ data.EnableTrapsMsdp = types.BoolValue(true)
+ } else {
+ data.EnableTrapsMsdp = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/Cisco-IOS-XE-ospf:ospf-config/state-change/enable"); value.Exists() {
+ data.EnableTrapsOspfConfigStateChange = types.BoolValue(true)
+ } else {
+ data.EnableTrapsOspfConfigStateChange = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/Cisco-IOS-XE-ospf:ospf-config/errors/enable"); value.Exists() {
+ data.EnableTrapsOspfConfigErrors = types.BoolValue(true)
+ } else {
+ data.EnableTrapsOspfConfigErrors = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/pim/invalid-pim-message"); value.Exists() {
+ data.EnableTrapsPimInvalidPimMessage = types.BoolValue(true)
+ } else {
+ data.EnableTrapsPimInvalidPimMessage = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/pim/neighbor-change"); value.Exists() {
+ data.EnableTrapsPimNeighborChange = types.BoolValue(true)
+ } else {
+ data.EnableTrapsPimNeighborChange = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/pim/rp-mapping-change"); value.Exists() {
+ data.EnableTrapsPimRpMappingChange = types.BoolValue(true)
+ } else {
+ data.EnableTrapsPimRpMappingChange = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/bridge/newroot"); value.Exists() {
+ data.EnableTrapsBridgeNewroot = types.BoolValue(true)
+ } else {
+ data.EnableTrapsBridgeNewroot = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/bridge/topologychange"); value.Exists() {
+ data.EnableTrapsBridgeTopologychange = types.BoolValue(true)
+ } else {
+ data.EnableTrapsBridgeTopologychange = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/stpx/inconsistency"); value.Exists() {
+ data.EnableTrapsStpxInconsistency = types.BoolValue(true)
+ } else {
+ data.EnableTrapsStpxInconsistency = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/stpx/root-inconsistency"); value.Exists() {
+ data.EnableTrapsStpxRootInconsistency = types.BoolValue(true)
+ } else {
+ data.EnableTrapsStpxRootInconsistency = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/stpx/loop-inconsistency"); value.Exists() {
+ data.EnableTrapsStpxLoopInconsistency = types.BoolValue(true)
+ } else {
+ data.EnableTrapsStpxLoopInconsistency = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/syslog"); value.Exists() {
+ data.EnableTrapsSyslog = types.BoolValue(true)
+ } else {
+ data.EnableTrapsSyslog = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/"); value.Exists() {
+ data.EnableTrapsBgpCbgp2 = types.BoolValue(true)
+ } else {
+ data.EnableTrapsBgpCbgp2 = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/nhrp/nhs"); value.Exists() {
+ data.EnableTrapsNhrpNhs = types.BoolValue(true)
+ } else {
+ data.EnableTrapsNhrpNhs = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/nhrp/nhc"); value.Exists() {
+ data.EnableTrapsNhrpNhc = types.BoolValue(true)
+ } else {
+ data.EnableTrapsNhrpNhc = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/nhrp/nhp"); value.Exists() {
+ data.EnableTrapsNhrpNhp = types.BoolValue(true)
+ } else {
+ data.EnableTrapsNhrpNhp = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/nhrp/quota-exceeded"); value.Exists() {
+ data.EnableTrapsNhrpQuotaExceeded = types.BoolValue(true)
+ } else {
+ data.EnableTrapsNhrpQuotaExceeded = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/mpls/traffic-eng"); value.Exists() {
+ data.EnableTrapsMplsTrafficEng = types.BoolValue(true)
+ } else {
+ data.EnableTrapsMplsTrafficEng = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/mpls"); value.Exists() {
+ data.EnableTrapsMpls = types.BoolValue(true)
+ } else {
+ data.EnableTrapsMpls = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/mpls/vpn"); value.Exists() {
+ data.EnableTrapsMplsVpn = types.BoolValue(true)
+ } else {
+ data.EnableTrapsMplsVpn = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/mpls/rfc"); value.Exists() {
+ data.EnableTrapsMplsRfc = types.BoolValue(true)
+ } else {
+ data.EnableTrapsMplsRfc = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/mpls/rfc/ldp"); value.Exists() {
+ data.EnableTrapsMplsRfcLdp = types.BoolValue(true)
+ } else {
+ data.EnableTrapsMplsRfcLdp = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/mpls/ldp"); value.Exists() {
+ data.EnableTrapsMplsLdp = types.BoolValue(true)
+ } else {
+ data.EnableTrapsMplsLdp = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/mpls/fast-reroute/protected"); value.Exists() {
+ data.EnableTrapsFastRerouteProtected = types.BoolValue(true)
+ } else {
+ data.EnableTrapsFastRerouteProtected = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/local-auth"); value.Exists() {
+ data.EnableTrapsLocalAuth = types.BoolValue(true)
+ } else {
+ data.EnableTrapsLocalAuth = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/vlan-membership"); value.Exists() {
+ data.EnableTrapsVlanMembership = types.BoolValue(true)
+ } else {
+ data.EnableTrapsVlanMembership = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/errdisable"); value.Exists() {
+ data.EnableTrapsErrdisable = types.BoolValue(true)
+ } else {
+ data.EnableTrapsErrdisable = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/rf"); value.Exists() {
+ data.EnableTrapsRf = types.BoolValue(true)
+ } else {
+ data.EnableTrapsRf = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/transceiver/all"); value.Exists() {
+ data.EnableTrapsTransceiverAll = types.BoolValue(true)
+ } else {
+ data.EnableTrapsTransceiverAll = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/bulkstat/collection"); value.Exists() {
+ data.EnableTrapsBulkstatCollection = types.BoolValue(true)
+ } else {
+ data.EnableTrapsBulkstatCollection = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/bulkstat/transfer"); value.Exists() {
+ data.EnableTrapsBulkstatTransfer = types.BoolValue(true)
+ } else {
+ data.EnableTrapsBulkstatTransfer = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/mac-notification/change"); value.Exists() {
+ data.EnableTrapsMacNotificationChange = types.BoolValue(true)
+ } else {
+ data.EnableTrapsMacNotificationChange = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/mac-notification/move"); value.Exists() {
+ data.EnableTrapsMacNotificationMove = types.BoolValue(true)
+ } else {
+ data.EnableTrapsMacNotificationMove = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/mac-notification/threshold"); value.Exists() {
+ data.EnableTrapsMacNotificationThreshold = types.BoolValue(true)
+ } else {
+ data.EnableTrapsMacNotificationThreshold = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/vrfmib/vrf-up"); value.Exists() {
+ data.EnableTrapsVrfmibVrfUp = types.BoolValue(true)
+ } else {
+ data.EnableTrapsVrfmibVrfUp = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/vrfmib/vrf-down"); value.Exists() {
+ data.EnableTrapsVrfmibVrfDown = types.BoolValue(true)
+ } else {
+ data.EnableTrapsVrfmibVrfDown = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/vrfmib/vnet-trunk-up"); value.Exists() {
+ data.EnableTrapsVrfmibVnetTrunkUp = types.BoolValue(true)
+ } else {
+ data.EnableTrapsVrfmibVnetTrunkUp = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/vrfmib/vnet-trunk-down"); value.Exists() {
+ data.EnableTrapsVrfmibVnetTrunkDown = types.BoolValue(true)
+ } else {
+ data.EnableTrapsVrfmibVnetTrunkDown = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/mvpn"); value.Exists() {
+ data.EnableTrapsMvpn = types.BoolValue(true)
+ } else {
+ data.EnableTrapsMvpn = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/lisp"); value.Exists() {
+ data.EnableTrapsLisp = types.BoolValue(true)
+ } else {
+ data.EnableTrapsLisp = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/aaa_server"); value.Exists() {
+ data.EnableTrapsAaaServer = types.BoolValue(true)
+ } else {
+ data.EnableTrapsAaaServer = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/vdsl2line"); value.Exists() {
+ data.EnableTrapsVdsl2line = types.BoolValue(true)
+ } else {
+ data.EnableTrapsVdsl2line = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/adslline"); value.Exists() {
+ data.EnableTrapsAdslline = types.BoolValue(true)
+ } else {
+ data.EnableTrapsAdslline = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/pki"); value.Exists() {
+ data.EnableTrapsPki = types.BoolValue(true)
+ } else {
+ data.EnableTrapsPki = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/alarms/alarm-type"); value.Exists() {
+ data.EnableTrapsAlarmType = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/casa"); value.Exists() {
+ data.EnableTrapsCasa = types.BoolValue(true)
+ } else {
+ data.EnableTrapsCasa = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/cnpd"); value.Exists() {
+ data.EnableTrapsCnpd = types.BoolValue(true)
+ } else {
+ data.EnableTrapsCnpd = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/dial"); value.Exists() {
+ data.EnableTrapsDial = types.BoolValue(true)
+ } else {
+ data.EnableTrapsDial = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/dlsw"); value.Exists() {
+ data.EnableTrapsDlsw = types.BoolValue(true)
+ } else {
+ data.EnableTrapsDlsw = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ds1"); value.Exists() {
+ data.EnableTrapsDs1 = types.BoolValue(true)
+ } else {
+ data.EnableTrapsDs1 = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/dsp/card-status"); value.Exists() {
+ data.EnableTrapsDspCardStatus = types.BoolValue(true)
+ } else {
+ data.EnableTrapsDspCardStatus = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/dsp/oper-state"); value.Exists() {
+ data.EnableTrapsDspOperState = types.BoolValue(true)
+ } else {
+ data.EnableTrapsDspOperState = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/entity-sensor"); value.Exists() {
+ data.EnableTrapsEntitySensor = types.BoolValue(true)
+ } else {
+ data.EnableTrapsEntitySensor = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/entity-state"); value.Exists() {
+ data.EnableTrapsEntityState = types.BoolValue(true)
+ } else {
+ data.EnableTrapsEntityState = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/entity-qfp/mem-res-thresh"); value.Exists() {
+ data.EnableTrapsEntityQfpMemResThresh = types.BoolValue(true)
+ } else {
+ data.EnableTrapsEntityQfpMemResThresh = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/entity-qfp/throughput-notif"); value.Exists() {
+ data.EnableTrapsEntityQfpThroughputNotif = types.BoolValue(true)
+ } else {
+ data.EnableTrapsEntityQfpThroughputNotif = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ether-oam"); value.Exists() {
+ data.EnableTrapsEtherOam = types.BoolValue(true)
+ } else {
+ data.EnableTrapsEtherOam = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ethernet/cfm/alarm"); value.Exists() {
+ data.EnableTrapsEthernetCfmAlarm = types.BoolValue(true)
+ } else {
+ data.EnableTrapsEthernetCfmAlarm = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ethernet/cfm/cc/config"); value.Exists() {
+ data.EnableTrapsEthernetCfmCcConfig = types.BoolValue(true)
+ } else {
+ data.EnableTrapsEthernetCfmCcConfig = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ethernet/cfm/cc/cross-connect"); value.Exists() {
+ data.EnableTrapsEthernetCfmCcCrossConnect = types.BoolValue(true)
+ } else {
+ data.EnableTrapsEthernetCfmCcCrossConnect = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ethernet/cfm/cc/loop"); value.Exists() {
+ data.EnableTrapsEthernetCfmCcLoop = types.BoolValue(true)
+ } else {
+ data.EnableTrapsEthernetCfmCcLoop = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ethernet/cfm/cc/mep-down"); value.Exists() {
+ data.EnableTrapsEthernetCfmCcMepDown = types.BoolValue(true)
+ } else {
+ data.EnableTrapsEthernetCfmCcMepDown = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ethernet/cfm/cc/mep-up"); value.Exists() {
+ data.EnableTrapsEthernetCfmCcMepUp = types.BoolValue(true)
+ } else {
+ data.EnableTrapsEthernetCfmCcMepUp = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ethernet/cfm/crosscheck/mep-missing"); value.Exists() {
+ data.EnableTrapsEthernetCfmCrosscheckMepMissing = types.BoolValue(true)
+ } else {
+ data.EnableTrapsEthernetCfmCrosscheckMepMissing = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ethernet/cfm/crosscheck/mep-unknown"); value.Exists() {
+ data.EnableTrapsEthernetCfmCrosscheckMepUnknown = types.BoolValue(true)
+ } else {
+ data.EnableTrapsEthernetCfmCrosscheckMepUnknown = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ethernet/cfm/crosscheck/service-up"); value.Exists() {
+ data.EnableTrapsEthernetCfmCrosscheckServiceUp = types.BoolValue(true)
+ } else {
+ data.EnableTrapsEthernetCfmCrosscheckServiceUp = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ethernet/evc/create"); value.Exists() {
+ data.EnableTrapsEthernetEvcCreate = types.BoolValue(true)
+ } else {
+ data.EnableTrapsEthernetEvcCreate = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ethernet/evc/delete"); value.Exists() {
+ data.EnableTrapsEthernetEvcDelete = types.BoolValue(true)
+ } else {
+ data.EnableTrapsEthernetEvcDelete = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ethernet/evc/status"); value.Exists() {
+ data.EnableTrapsEthernetEvcStatus = types.BoolValue(true)
+ } else {
+ data.EnableTrapsEthernetEvcStatus = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/firewall/serverstatus"); value.Exists() {
+ data.EnableTrapsFirewallServerstatus = types.BoolValue(true)
+ } else {
+ data.EnableTrapsFirewallServerstatus = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/frame-relay-config/only-frame-relay/frame-relay"); value.Exists() {
+ data.EnableTrapsFrameRelayConfigOnly = types.BoolValue(true)
+ } else {
+ data.EnableTrapsFrameRelayConfigOnly = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/frame-relay-config/frame-relay-options/frame-relay/subif-configs/subif"); value.Exists() {
+ data.EnableTrapsFrameRelayConfigSubifConfigs = types.BoolValue(true)
+ } else {
+ data.EnableTrapsFrameRelayConfigSubifConfigs = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/frame-relay/subif/count"); value.Exists() {
+ data.EnableTrapsFrameRelaySubifCount = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/frame-relay/subif/interval"); value.Exists() {
+ data.EnableTrapsFrameRelaySubifInterval = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/frame-relay-config/frame-relay-options/frame-relay/multilink/bundle-mismatch"); value.Exists() {
+ data.EnableTrapsFrameRelayConfigBundleMismatch = types.BoolValue(true)
+ } else {
+ data.EnableTrapsFrameRelayConfigBundleMismatch = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/frame-relay/multilink/bundle-mismatch"); value.Exists() {
+ data.EnableTrapsFrameRelayMultilinkBundleMismatch = types.BoolValue(true)
+ } else {
+ data.EnableTrapsFrameRelayMultilinkBundleMismatch = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ip/local/pool"); value.Exists() {
+ data.EnableTrapsIpLocalPool = types.BoolValue(true)
+ } else {
+ data.EnableTrapsIpLocalPool = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/isdn/call-information"); value.Exists() {
+ data.EnableTrapsIsdnCallInformation = types.BoolValue(true)
+ } else {
+ data.EnableTrapsIsdnCallInformation = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/isdn/chan-not-avail"); value.Exists() {
+ data.EnableTrapsIsdnChanNotAvail = types.BoolValue(true)
+ } else {
+ data.EnableTrapsIsdnChanNotAvail = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/isdn/ietf"); value.Exists() {
+ data.EnableTrapsIsdnIetf = types.BoolValue(true)
+ } else {
+ data.EnableTrapsIsdnIetf = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/isdn/layer2"); value.Exists() {
+ data.EnableTrapsIsdnLayer2 = types.BoolValue(true)
+ } else {
+ data.EnableTrapsIsdnLayer2 = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/l2tun/session"); value.Exists() {
+ data.EnableTrapsL2tunSession = types.BoolValue(true)
+ } else {
+ data.EnableTrapsL2tunSession = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/l2tun/tunnel"); value.Exists() {
+ data.EnableTrapsL2tunTunnel = types.BoolValue(true)
+ } else {
+ data.EnableTrapsL2tunTunnel = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/l2tun/pseudowire/status"); value.Exists() {
+ data.EnableTrapsL2tunPseudowireStatus = types.BoolValue(true)
+ } else {
+ data.EnableTrapsL2tunPseudowireStatus = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/pimstdmib/neighbor-loss"); value.Exists() {
+ data.EnableTrapsPimstdmibNeighborLoss = types.BoolValue(true)
+ } else {
+ data.EnableTrapsPimstdmibNeighborLoss = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/pimstdmib/invalid-register"); value.Exists() {
+ data.EnableTrapsPimstdmibInvalidRegister = types.BoolValue(true)
+ } else {
+ data.EnableTrapsPimstdmibInvalidRegister = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/pimstdmib/invalid-join-prune"); value.Exists() {
+ data.EnableTrapsPimstdmibInvalidJoinPrune = types.BoolValue(true)
+ } else {
+ data.EnableTrapsPimstdmibInvalidJoinPrune = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/pimstdmib/rp-mapping-change"); value.Exists() {
+ data.EnableTrapsPimstdmibRpMappingChange = types.BoolValue(true)
+ } else {
+ data.EnableTrapsPimstdmibRpMappingChange = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/pimstdmib/interface-election"); value.Exists() {
+ data.EnableTrapsPimstdmibInterfaceElection = types.BoolValue(true)
+ } else {
+ data.EnableTrapsPimstdmibInterfaceElection = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/pfr"); value.Exists() {
+ data.EnableTrapsPfr = types.BoolValue(true)
+ } else {
+ data.EnableTrapsPfr = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/pppoe"); value.Exists() {
+ data.EnableTrapsPppoe = types.BoolValue(true)
+ } else {
+ data.EnableTrapsPppoe = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/resource-policy"); value.Exists() {
+ data.EnableTrapsResourcePolicy = types.BoolValue(true)
+ } else {
+ data.EnableTrapsResourcePolicy = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/rsvp"); value.Exists() {
+ data.EnableTrapsRsvp = types.BoolValue(true)
+ } else {
+ data.EnableTrapsRsvp = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/vrrp"); value.Exists() {
+ data.EnableTrapsVrrp = types.BoolValue(true)
+ } else {
+ data.EnableTrapsVrrp = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/sonet"); value.Exists() {
+ data.EnableTrapsSonet = types.BoolValue(true)
+ } else {
+ data.EnableTrapsSonet = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/srp"); value.Exists() {
+ data.EnableTrapsSrp = types.BoolValue(true)
+ } else {
+ data.EnableTrapsSrp = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/voice"); value.Exists() {
+ data.EnableTrapsVoice = types.BoolValue(true)
+ } else {
+ data.EnableTrapsVoice = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/bgp"); value.Exists() {
+ data.EnableTrapsBgp = types.BoolValue(true)
+ } else {
+ data.EnableTrapsBgp = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/bgp-traps/cbgp2"); value.Exists() {
+ data.EnableTrapsCbgp2 = types.BoolValue(true)
+ } else {
+ data.EnableTrapsCbgp2 = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ospfv3/errors"); value.Exists() {
+ data.EnableTrapsOspfv3Errors = types.BoolValue(true)
+ } else {
+ data.EnableTrapsOspfv3Errors = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ospfv3/state-change"); value.Exists() {
+ data.EnableTrapsOspfv3StateChange = types.BoolValue(true)
+ } else {
+ data.EnableTrapsOspfv3StateChange = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:source-interface/informs/GigabitEthernet"); value.Exists() {
+ data.SourceInterfaceInformsGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:source-interface/informs/TenGigabitEthernet"); value.Exists() {
+ data.SourceInterfaceInformsTenGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:source-interface/informs/FortyGigabitEthernet"); value.Exists() {
+ data.SourceInterfaceInformsFortyGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:source-interface/informs/HundredGigE"); value.Exists() {
+ data.SourceInterfaceInformsHundredGigE = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:source-interface/informs/Loopback"); value.Exists() {
+ data.SourceInterfaceInformsLoopback = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:source-interface/informs/Port-channel"); value.Exists() {
+ data.SourceInterfaceInformsPortChannel = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:source-interface/informs/Port-channel-subinterface/Port-channel"); value.Exists() {
+ data.SourceInterfaceInformsPortChannelSubinterface = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:source-interface/informs/Vlan"); value.Exists() {
+ data.SourceInterfaceInformsVlan = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:source-interface/traps/GigabitEthernet"); value.Exists() {
+ data.SourceInterfaceTrapsGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:source-interface/traps/TenGigabitEthernet"); value.Exists() {
+ data.SourceInterfaceTrapsTenGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:source-interface/traps/FortyGigabitEthernet"); value.Exists() {
+ data.SourceInterfaceTrapsFortyGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:source-interface/traps/HundredGigE"); value.Exists() {
+ data.SourceInterfaceTrapsHundredGigE = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:source-interface/traps/Loopback"); value.Exists() {
+ data.SourceInterfaceTrapsLoopback = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:source-interface/traps/Port-channel"); value.Exists() {
+ data.SourceInterfaceTrapsPortChannel = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:source-interface/traps/Port-channel-subinterface/Port-channel"); value.Exists() {
+ data.SourceInterfaceTrapsPortChannelSubinterface = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:source-interface/traps/Vlan"); value.Exists() {
+ data.SourceInterfaceTrapsVlan = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:trap-source/GigabitEthernet"); value.Exists() {
+ data.TrapSourceGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:trap-source/TenGigabitEthernet"); value.Exists() {
+ data.TrapSourceTenGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:trap-source/FortyGigabitEthernet"); value.Exists() {
+ data.TrapSourceFortyGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:trap-source/HundredGigE"); value.Exists() {
+ data.TrapSourceHundredGigE = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:trap-source/Loopback"); value.Exists() {
+ data.TrapSourceLoopback = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:trap-source/Port-channel"); value.Exists() {
+ data.TrapSourcePortChannel = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:trap-source/Port-channel-subinterface/Port-channel"); value.Exists() {
+ data.TrapSourcePortChannelSubinterface = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:trap-source/Vlan"); value.Exists() {
+ data.TrapSourceVlan = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:community-config"); value.Exists() {
+ data.SnmpCommunities = make([]SNMPServerSnmpCommunities, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := SNMPServerSnmpCommunities{}
+ if cValue := helpers.GetFromXPath(v, "name"); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "view"); cValue.Exists() {
+ item.View = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "permission"); cValue.Exists() {
+ item.Permission = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "ipv6"); cValue.Exists() {
+ item.Ipv6 = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "access-list-name"); cValue.Exists() {
+ item.AccessListName = types.StringValue(cValue.String())
+ }
+ data.SnmpCommunities = append(data.SnmpCommunities, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:context"); value.Exists() {
+ data.Contexts = make([]SNMPServerContexts, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := SNMPServerContexts{}
+ if cValue := helpers.GetFromXPath(v, "name"); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ data.Contexts = append(data.Contexts, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:view"); value.Exists() {
+ data.Views = make([]SNMPServerViews, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := SNMPServerViews{}
+ if cValue := helpers.GetFromXPath(v, "name"); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "mib"); cValue.Exists() {
+ item.Mib = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "inc-exl"); cValue.Exists() {
+ item.IncExl = types.StringValue(cValue.String())
+ }
+ data.Views = append(data.Views, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:group"); value.Exists() {
+ data.Groups = make([]SNMPServerGroups, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := SNMPServerGroups{}
+ if cValue := helpers.GetFromXPath(v, "id"); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "v3/security-level-list"); cValue.Exists() {
+ item.V3Security = make([]SNMPServerGroupsV3Security, 0)
+ cValue.ForEach(func(_ int, cv xmldot.Result) bool {
+ cItem := SNMPServerGroupsV3Security{}
+ if ccValue := helpers.GetFromXPath(cv, "security-level"); ccValue.Exists() {
+ cItem.SecurityLevel = types.StringValue(ccValue.String())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "context-node"); ccValue.Exists() {
+ cItem.ContextNode = types.StringValue(ccValue.String())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "match-node"); ccValue.Exists() {
+ cItem.MatchNode = types.StringValue(ccValue.String())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "read-node"); ccValue.Exists() {
+ cItem.ReadNode = types.StringValue(ccValue.String())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "write-node"); ccValue.Exists() {
+ cItem.WriteNode = types.StringValue(ccValue.String())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "notify-node"); ccValue.Exists() {
+ cItem.NotifyNode = types.StringValue(ccValue.String())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "access-config/ipv6-acl"); ccValue.Exists() {
+ cItem.AccessIpv6Acl = types.StringValue(ccValue.String())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "access-config/standard-acl"); ccValue.Exists() {
+ cItem.AccessStandardAcl = types.Int64Value(ccValue.Int())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "access-config/acl-name"); ccValue.Exists() {
+ cItem.AccessAclName = types.StringValue(ccValue.String())
+ }
+ item.V3Security = append(item.V3Security, cItem)
+ return true
+ })
+ }
+ data.Groups = append(data.Groups, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:user/names"); value.Exists() {
+ data.Users = make([]SNMPServerUsers, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := SNMPServerUsers{}
+ if cValue := helpers.GetFromXPath(v, "username"); cValue.Exists() {
+ item.Username = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "grpname"); cValue.Exists() {
+ item.Grpname = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "v3/auth-config/algorithm"); cValue.Exists() {
+ item.V3AuthAlgorithm = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "v3/auth-config/password"); cValue.Exists() {
+ item.V3AuthPassword = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "v3/auth-config/priv-config/aes/algorithm"); cValue.Exists() {
+ item.V3AuthPrivAesAlgorithm = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "v3/auth-config/priv-config/aes/password"); cValue.Exists() {
+ item.V3AuthPrivAesPassword = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "v3/auth-config/priv-config/aes/access-config/ipv6-acl"); cValue.Exists() {
+ item.V3AuthPrivAesAccessIpv6Acl = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "v3/auth-config/priv-config/aes/access-config/standard-acl"); cValue.Exists() {
+ item.V3AuthPrivAesAccessStandardAcl = types.Int64Value(cValue.Int())
+ }
+ if cValue := helpers.GetFromXPath(v, "v3/auth-config/priv-config/aes/access-config/acl-name"); cValue.Exists() {
+ item.V3AuthPrivAesAccessAclName = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "v3/auth-config/priv-config/des/password"); cValue.Exists() {
+ item.V3AuthPrivDesPassword = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "v3/auth-config/priv-config/des/access-config/ipv6-acl"); cValue.Exists() {
+ item.V3AuthPrivDesAccessIpv6Acl = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "v3/auth-config/priv-config/des/access-config/standard-acl"); cValue.Exists() {
+ item.V3AuthPrivDesAccessStandardAcl = types.Int64Value(cValue.Int())
+ }
+ if cValue := helpers.GetFromXPath(v, "v3/auth-config/priv-config/des/access-config/acl-name"); cValue.Exists() {
+ item.V3AuthPrivDesAccessAclName = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "v3/auth-config/priv-config/des3/password"); cValue.Exists() {
+ item.V3AuthPrivDes3Password = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "v3/auth-config/priv-config/des3/access-config/ipv6-acl"); cValue.Exists() {
+ item.V3AuthPrivDes3AccessIpv6Acl = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "v3/auth-config/priv-config/des3/access-config/standard-acl"); cValue.Exists() {
+ item.V3AuthPrivDes3AccessStandardAcl = types.Int64Value(cValue.Int())
+ }
+ if cValue := helpers.GetFromXPath(v, "v3/auth-config/priv-config/des3/access-config/acl-name"); cValue.Exists() {
+ item.V3AuthPrivDes3AccessAclName = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "v3/auth-config/access-config/ipv6-acl"); cValue.Exists() {
+ item.V3AuthAccessIpv6Acl = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "v3/auth-config/access-config/standard-acl"); cValue.Exists() {
+ item.V3AuthAccessStandardAcl = types.Int64Value(cValue.Int())
+ }
+ if cValue := helpers.GetFromXPath(v, "v3/auth-config/access-config/acl-name"); cValue.Exists() {
+ item.V3AuthAccessAclName = types.StringValue(cValue.String())
+ }
+ data.Users = append(data.Users, item)
+ return true
+ })
+ }
+}
+
+// End of section. //template:end fromBodyXML
+
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyDataXML
+
+func (data *SNMPServerData) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:chassis-id"); value.Exists() {
+ data.ChassisId = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:contact"); value.Exists() {
+ data.Contact = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:ifindex/persist"); value.Exists() {
+ data.IfindexPersist = types.BoolValue(true)
+ } else {
+ data.IfindexPersist = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:location"); value.Exists() {
+ data.Location = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:packetsize"); value.Exists() {
+ data.Packetsize = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:queue-length"); value.Exists() {
+ data.QueueLength = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/logging/getop"); value.Exists() {
+ data.EnableLoggingGetop = types.BoolValue(value.Bool())
+ } else {
+ data.EnableLoggingGetop = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/logging/setop"); value.Exists() {
+ data.EnableLoggingSetop = types.BoolValue(value.Bool())
+ } else {
+ data.EnableLoggingSetop = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/informs"); value.Exists() {
+ data.EnableInforms = types.BoolValue(true)
+ } else {
+ data.EnableInforms = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps"); value.Exists() {
+ data.EnableTraps = types.BoolValue(true)
+ } else {
+ data.EnableTraps = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/snmp/authentication"); value.Exists() {
+ data.EnableTrapsSnmpAuthentication = types.BoolValue(true)
+ } else {
+ data.EnableTrapsSnmpAuthentication = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/snmp/coldstart"); value.Exists() {
+ data.EnableTrapsSnmpColdstart = types.BoolValue(true)
+ } else {
+ data.EnableTrapsSnmpColdstart = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/snmp/linkdown"); value.Exists() {
+ data.EnableTrapsSnmpLinkdown = types.BoolValue(true)
+ } else {
+ data.EnableTrapsSnmpLinkdown = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/snmp/linkup"); value.Exists() {
+ data.EnableTrapsSnmpLinkup = types.BoolValue(true)
+ } else {
+ data.EnableTrapsSnmpLinkup = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/snmp/warmstart"); value.Exists() {
+ data.EnableTrapsSnmpWarmstart = types.BoolValue(true)
+ } else {
+ data.EnableTrapsSnmpWarmstart = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:host-config/ip-community"); value.Exists() {
+ data.Hosts = make([]SNMPServerHosts, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := SNMPServerHosts{}
+ if cValue := helpers.GetFromXPath(v, "ip-address"); cValue.Exists() {
+ item.IpAddress = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "community-or-user"); cValue.Exists() {
+ item.CommunityOrUser = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "version"); cValue.Exists() {
+ item.Version = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "encryption"); cValue.Exists() {
+ item.Encryption = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "security-level"); cValue.Exists() {
+ item.SecurityLevel = types.StringValue(cValue.String())
+ }
+ data.Hosts = append(data.Hosts, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:host-config/ip-vrf-community"); value.Exists() {
+ data.VrfHosts = make([]SNMPServerVrfHosts, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := SNMPServerVrfHosts{}
+ if cValue := helpers.GetFromXPath(v, "ip-address"); cValue.Exists() {
+ item.IpAddress = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "vrf"); cValue.Exists() {
+ item.Vrf = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "community-or-user"); cValue.Exists() {
+ item.CommunityOrUser = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "version"); cValue.Exists() {
+ item.Version = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "encryption"); cValue.Exists() {
+ item.Encryption = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "security-level"); cValue.Exists() {
+ item.SecurityLevel = types.StringValue(cValue.String())
+ }
+ data.VrfHosts = append(data.VrfHosts, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:system-shutdown"); value.Exists() {
+ data.SystemShutdown = types.BoolValue(true)
+ } else {
+ data.SystemShutdown = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/flowmon"); value.Exists() {
+ data.EnableTrapsFlowmon = types.BoolValue(true)
+ } else {
+ data.EnableTrapsFlowmon = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/entity-perf/throughput-notif"); value.Exists() {
+ data.EnableTrapsEntityPerfThroughputNotif = types.BoolValue(true)
+ } else {
+ data.EnableTrapsEntityPerfThroughputNotif = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/call-home/message-send-fail"); value.Exists() {
+ data.EnableTrapsCallHomeMessageSendFail = types.BoolValue(true)
+ } else {
+ data.EnableTrapsCallHomeMessageSendFail = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/call-home/server-fail"); value.Exists() {
+ data.EnableTrapsCallHomeServerFail = types.BoolValue(true)
+ } else {
+ data.EnableTrapsCallHomeServerFail = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/tty"); value.Exists() {
+ data.EnableTrapsTty = types.BoolValue(true)
+ } else {
+ data.EnableTrapsTty = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/Cisco-IOS-XE-ospfv3:ospfv3-config/state-change/enable"); value.Exists() {
+ data.EnableTrapsOspfv3ConfigStateChange = types.BoolValue(true)
+ } else {
+ data.EnableTrapsOspfv3ConfigStateChange = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/Cisco-IOS-XE-ospfv3:ospfv3-config/errors/enable"); value.Exists() {
+ data.EnableTrapsOspfv3ConfigErrors = types.BoolValue(true)
+ } else {
+ data.EnableTrapsOspfv3ConfigErrors = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/Cisco-IOS-XE-ospf:ospf-config/retransmit/enable"); value.Exists() {
+ data.EnableTrapsOspfConfigRetransmit = types.BoolValue(true)
+ } else {
+ data.EnableTrapsOspfConfigRetransmit = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/Cisco-IOS-XE-ospf:ospf-config/lsa/enable"); value.Exists() {
+ data.EnableTrapsOspfConfigLsa = types.BoolValue(true)
+ } else {
+ data.EnableTrapsOspfConfigLsa = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/Cisco-IOS-XE-ospf:ospf-config/cisco-specific/state-change/nssa-trans-change"); value.Exists() {
+ data.EnableTrapsOspfNssaTransChange = types.BoolValue(true)
+ } else {
+ data.EnableTrapsOspfNssaTransChange = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/Cisco-IOS-XE-ospf:ospf-config/cisco-specific/state-change/shamlink/interface"); value.Exists() {
+ data.EnableTrapsOspfShamlinkInterface = types.BoolValue(true)
+ } else {
+ data.EnableTrapsOspfShamlinkInterface = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/Cisco-IOS-XE-ospf:ospf-config/cisco-specific/state-change/shamlink/neighbor"); value.Exists() {
+ data.EnableTrapsOspfShamlinkNeighbor = types.BoolValue(true)
+ } else {
+ data.EnableTrapsOspfShamlinkNeighbor = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/Cisco-IOS-XE-ospf:ospf-config/cisco-specific/errors/enable"); value.Exists() {
+ data.EnableTrapsOspfErrorsEnable = types.BoolValue(true)
+ } else {
+ data.EnableTrapsOspfErrorsEnable = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/Cisco-IOS-XE-ospf:ospf-config/cisco-specific/retransmit/enable"); value.Exists() {
+ data.EnableTrapsOspfRetransmitEnable = types.BoolValue(true)
+ } else {
+ data.EnableTrapsOspfRetransmitEnable = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/Cisco-IOS-XE-ospf:ospf-config/cisco-specific/lsa/enable"); value.Exists() {
+ data.EnableTrapsOspfLsaEnable = types.BoolValue(true)
+ } else {
+ data.EnableTrapsOspfLsaEnable = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/eigrp"); value.Exists() {
+ data.EnableTrapsEigrp = types.BoolValue(true)
+ } else {
+ data.EnableTrapsEigrp = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/auth-framework/sec-violation"); value.Exists() {
+ data.EnableTrapsAuthFrameworkSecViolation = types.BoolValue(true)
+ } else {
+ data.EnableTrapsAuthFrameworkSecViolation = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/rep"); value.Exists() {
+ data.EnableTrapsRep = types.BoolValue(true)
+ } else {
+ data.EnableTrapsRep = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/vtp"); value.Exists() {
+ data.EnableTrapsVtp = types.BoolValue(true)
+ } else {
+ data.EnableTrapsVtp = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/vlancreate"); value.Exists() {
+ data.EnableTrapsVlancreate = types.BoolValue(true)
+ } else {
+ data.EnableTrapsVlancreate = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/vlandelete"); value.Exists() {
+ data.EnableTrapsVlandelete = types.BoolValue(true)
+ } else {
+ data.EnableTrapsVlandelete = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/port-security"); value.Exists() {
+ data.EnableTrapsPortSecurity = types.BoolValue(true)
+ } else {
+ data.EnableTrapsPortSecurity = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/license"); value.Exists() {
+ data.EnableTrapsLicense = types.BoolValue(true)
+ } else {
+ data.EnableTrapsLicense = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/smart-licenseing/smart-license"); value.Exists() {
+ data.EnableTrapsSmartLicense = types.BoolValue(true)
+ } else {
+ data.EnableTrapsSmartLicense = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/cpu/threshold"); value.Exists() {
+ data.EnableTrapsCpuThreshold = types.BoolValue(true)
+ } else {
+ data.EnableTrapsCpuThreshold = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/memory/bufferpeak"); value.Exists() {
+ data.EnableTrapsMemoryBufferpeak = types.BoolValue(true)
+ } else {
+ data.EnableTrapsMemoryBufferpeak = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/stackwise"); value.Exists() {
+ data.EnableTrapsStackwise = types.BoolValue(true)
+ } else {
+ data.EnableTrapsStackwise = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/udld/link-fail-rpt"); value.Exists() {
+ data.EnableTrapsUdldLinkFailRpt = types.BoolValue(true)
+ } else {
+ data.EnableTrapsUdldLinkFailRpt = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/udld/status-change"); value.Exists() {
+ data.EnableTrapsUdldStatusChange = types.BoolValue(true)
+ } else {
+ data.EnableTrapsUdldStatusChange = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/fru-ctrl"); value.Exists() {
+ data.EnableTrapsFruCtrl = types.BoolValue(true)
+ } else {
+ data.EnableTrapsFruCtrl = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/flash/insertion"); value.Exists() {
+ data.EnableTrapsFlashInsertion = types.BoolValue(true)
+ } else {
+ data.EnableTrapsFlashInsertion = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/flash/removal"); value.Exists() {
+ data.EnableTrapsFlashRemoval = types.BoolValue(true)
+ } else {
+ data.EnableTrapsFlashRemoval = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/flash/lowspace"); value.Exists() {
+ data.EnableTrapsFlashLowspace = types.BoolValue(true)
+ } else {
+ data.EnableTrapsFlashLowspace = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/energywise"); value.Exists() {
+ data.EnableTrapsEnergywise = types.BoolValue(true)
+ } else {
+ data.EnableTrapsEnergywise = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/power-ethernet/group"); value.Exists() {
+ data.EnableTrapsPowerEthernetGroup = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/power-ethernet/police"); value.Exists() {
+ data.EnableTrapsPowerEthernetPolice = types.BoolValue(true)
+ } else {
+ data.EnableTrapsPowerEthernetPolice = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/entity"); value.Exists() {
+ data.EnableTrapsEntity = types.BoolValue(true)
+ } else {
+ data.EnableTrapsEntity = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/pw/vc"); value.Exists() {
+ data.EnableTrapsPwVc = types.BoolValue(true)
+ } else {
+ data.EnableTrapsPwVc = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/envmon"); value.Exists() {
+ data.EnableTrapsEnvmon = types.BoolValue(true)
+ } else {
+ data.EnableTrapsEnvmon = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/cef/resource-failure"); value.Exists() {
+ data.EnableTrapsCefResourceFailure = types.BoolValue(true)
+ } else {
+ data.EnableTrapsCefResourceFailure = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/cef/peer-state-change"); value.Exists() {
+ data.EnableTrapsCefPeerStateChange = types.BoolValue(true)
+ } else {
+ data.EnableTrapsCefPeerStateChange = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/cef/peer-fib-state-change"); value.Exists() {
+ data.EnableTrapsCefPeerFibStateChange = types.BoolValue(true)
+ } else {
+ data.EnableTrapsCefPeerFibStateChange = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/cef/inconsistency"); value.Exists() {
+ data.EnableTrapsCefInconsistency = types.BoolValue(true)
+ } else {
+ data.EnableTrapsCefInconsistency = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/isis"); value.Exists() {
+ data.EnableTrapsIsis = types.BoolValue(true)
+ } else {
+ data.EnableTrapsIsis = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ipsla"); value.Exists() {
+ data.EnableTrapsIpsla = types.BoolValue(true)
+ } else {
+ data.EnableTrapsIpsla = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/entity-diag/boot-up-fail"); value.Exists() {
+ data.EnableTrapsEntityDiagBootUpFail = types.BoolValue(true)
+ } else {
+ data.EnableTrapsEntityDiagBootUpFail = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/entity-diag/hm-test-recover"); value.Exists() {
+ data.EnableTrapsEntityDiagHmTestRecover = types.BoolValue(true)
+ } else {
+ data.EnableTrapsEntityDiagHmTestRecover = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/entity-diag/hm-thresh-reached"); value.Exists() {
+ data.EnableTrapsEntityDiagHmThreshReached = types.BoolValue(true)
+ } else {
+ data.EnableTrapsEntityDiagHmThreshReached = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/entity-diag/scheduled-test-fail"); value.Exists() {
+ data.EnableTrapsEntityDiagScheduledTestFail = types.BoolValue(true)
+ } else {
+ data.EnableTrapsEntityDiagScheduledTestFail = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/bfd"); value.Exists() {
+ data.EnableTrapsBfd = types.BoolValue(true)
+ } else {
+ data.EnableTrapsBfd = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ike/policy/add"); value.Exists() {
+ data.EnableTrapsIkePolicyAdd = types.BoolValue(true)
+ } else {
+ data.EnableTrapsIkePolicyAdd = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ike/policy/delete"); value.Exists() {
+ data.EnableTrapsIkePolicyDelete = types.BoolValue(true)
+ } else {
+ data.EnableTrapsIkePolicyDelete = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ike/tunnel/start"); value.Exists() {
+ data.EnableTrapsIkeTunnelStart = types.BoolValue(true)
+ } else {
+ data.EnableTrapsIkeTunnelStart = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ike/tunnel/stop"); value.Exists() {
+ data.EnableTrapsIkeTunnelStop = types.BoolValue(true)
+ } else {
+ data.EnableTrapsIkeTunnelStop = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ipsec/cryptomap/add"); value.Exists() {
+ data.EnableTrapsIpsecCryptomapAdd = types.BoolValue(true)
+ } else {
+ data.EnableTrapsIpsecCryptomapAdd = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ipsec/cryptomap/attach"); value.Exists() {
+ data.EnableTrapsIpsecCryptomapAttach = types.BoolValue(true)
+ } else {
+ data.EnableTrapsIpsecCryptomapAttach = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ipsec/cryptomap/delete"); value.Exists() {
+ data.EnableTrapsIpsecCryptomapDelete = types.BoolValue(true)
+ } else {
+ data.EnableTrapsIpsecCryptomapDelete = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ipsec/cryptomap/detach"); value.Exists() {
+ data.EnableTrapsIpsecCryptomapDetach = types.BoolValue(true)
+ } else {
+ data.EnableTrapsIpsecCryptomapDetach = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ipsec/tunnel/start"); value.Exists() {
+ data.EnableTrapsIpsecTunnelStart = types.BoolValue(true)
+ } else {
+ data.EnableTrapsIpsecTunnelStart = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ipsec/tunnel/stop"); value.Exists() {
+ data.EnableTrapsIpsecTunnelStop = types.BoolValue(true)
+ } else {
+ data.EnableTrapsIpsecTunnelStop = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ipsec/too-many-sas"); value.Exists() {
+ data.EnableTrapsIpsecTooManySas = types.BoolValue(true)
+ } else {
+ data.EnableTrapsIpsecTooManySas = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/config-copy"); value.Exists() {
+ data.EnableTrapsConfigCopy = types.BoolValue(true)
+ } else {
+ data.EnableTrapsConfigCopy = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/config"); value.Exists() {
+ data.EnableTrapsConfig = types.BoolValue(true)
+ } else {
+ data.EnableTrapsConfig = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/config-ctid"); value.Exists() {
+ data.EnableTrapsConfigCtid = types.BoolValue(true)
+ } else {
+ data.EnableTrapsConfigCtid = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/dhcp"); value.Exists() {
+ data.EnableTrapsDhcp = types.BoolValue(true)
+ } else {
+ data.EnableTrapsDhcp = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/event-manager"); value.Exists() {
+ data.EnableTrapsEventManager = types.BoolValue(true)
+ } else {
+ data.EnableTrapsEventManager = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/hsrp"); value.Exists() {
+ data.EnableTrapsHsrp = types.BoolValue(true)
+ } else {
+ data.EnableTrapsHsrp = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ipmulticast"); value.Exists() {
+ data.EnableTrapsIpmulticast = types.BoolValue(true)
+ } else {
+ data.EnableTrapsIpmulticast = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/msdp"); value.Exists() {
+ data.EnableTrapsMsdp = types.BoolValue(true)
+ } else {
+ data.EnableTrapsMsdp = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/Cisco-IOS-XE-ospf:ospf-config/state-change/enable"); value.Exists() {
+ data.EnableTrapsOspfConfigStateChange = types.BoolValue(true)
+ } else {
+ data.EnableTrapsOspfConfigStateChange = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/Cisco-IOS-XE-ospf:ospf-config/errors/enable"); value.Exists() {
+ data.EnableTrapsOspfConfigErrors = types.BoolValue(true)
+ } else {
+ data.EnableTrapsOspfConfigErrors = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/pim/invalid-pim-message"); value.Exists() {
+ data.EnableTrapsPimInvalidPimMessage = types.BoolValue(true)
+ } else {
+ data.EnableTrapsPimInvalidPimMessage = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/pim/neighbor-change"); value.Exists() {
+ data.EnableTrapsPimNeighborChange = types.BoolValue(true)
+ } else {
+ data.EnableTrapsPimNeighborChange = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/pim/rp-mapping-change"); value.Exists() {
+ data.EnableTrapsPimRpMappingChange = types.BoolValue(true)
+ } else {
+ data.EnableTrapsPimRpMappingChange = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/bridge/newroot"); value.Exists() {
+ data.EnableTrapsBridgeNewroot = types.BoolValue(true)
+ } else {
+ data.EnableTrapsBridgeNewroot = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/bridge/topologychange"); value.Exists() {
+ data.EnableTrapsBridgeTopologychange = types.BoolValue(true)
+ } else {
+ data.EnableTrapsBridgeTopologychange = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/stpx/inconsistency"); value.Exists() {
+ data.EnableTrapsStpxInconsistency = types.BoolValue(true)
+ } else {
+ data.EnableTrapsStpxInconsistency = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/stpx/root-inconsistency"); value.Exists() {
+ data.EnableTrapsStpxRootInconsistency = types.BoolValue(true)
+ } else {
+ data.EnableTrapsStpxRootInconsistency = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/stpx/loop-inconsistency"); value.Exists() {
+ data.EnableTrapsStpxLoopInconsistency = types.BoolValue(true)
+ } else {
+ data.EnableTrapsStpxLoopInconsistency = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/syslog"); value.Exists() {
+ data.EnableTrapsSyslog = types.BoolValue(true)
+ } else {
+ data.EnableTrapsSyslog = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/"); value.Exists() {
+ data.EnableTrapsBgpCbgp2 = types.BoolValue(true)
+ } else {
+ data.EnableTrapsBgpCbgp2 = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/nhrp/nhs"); value.Exists() {
+ data.EnableTrapsNhrpNhs = types.BoolValue(true)
+ } else {
+ data.EnableTrapsNhrpNhs = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/nhrp/nhc"); value.Exists() {
+ data.EnableTrapsNhrpNhc = types.BoolValue(true)
+ } else {
+ data.EnableTrapsNhrpNhc = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/nhrp/nhp"); value.Exists() {
+ data.EnableTrapsNhrpNhp = types.BoolValue(true)
+ } else {
+ data.EnableTrapsNhrpNhp = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/nhrp/quota-exceeded"); value.Exists() {
+ data.EnableTrapsNhrpQuotaExceeded = types.BoolValue(true)
+ } else {
+ data.EnableTrapsNhrpQuotaExceeded = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/mpls/traffic-eng"); value.Exists() {
+ data.EnableTrapsMplsTrafficEng = types.BoolValue(true)
+ } else {
+ data.EnableTrapsMplsTrafficEng = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/mpls"); value.Exists() {
+ data.EnableTrapsMpls = types.BoolValue(true)
+ } else {
+ data.EnableTrapsMpls = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/mpls/vpn"); value.Exists() {
+ data.EnableTrapsMplsVpn = types.BoolValue(true)
+ } else {
+ data.EnableTrapsMplsVpn = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/mpls/rfc"); value.Exists() {
+ data.EnableTrapsMplsRfc = types.BoolValue(true)
+ } else {
+ data.EnableTrapsMplsRfc = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/mpls/rfc/ldp"); value.Exists() {
+ data.EnableTrapsMplsRfcLdp = types.BoolValue(true)
+ } else {
+ data.EnableTrapsMplsRfcLdp = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/mpls/ldp"); value.Exists() {
+ data.EnableTrapsMplsLdp = types.BoolValue(true)
+ } else {
+ data.EnableTrapsMplsLdp = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/mpls/fast-reroute/protected"); value.Exists() {
+ data.EnableTrapsFastRerouteProtected = types.BoolValue(true)
+ } else {
+ data.EnableTrapsFastRerouteProtected = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/local-auth"); value.Exists() {
+ data.EnableTrapsLocalAuth = types.BoolValue(true)
+ } else {
+ data.EnableTrapsLocalAuth = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/vlan-membership"); value.Exists() {
+ data.EnableTrapsVlanMembership = types.BoolValue(true)
+ } else {
+ data.EnableTrapsVlanMembership = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/errdisable"); value.Exists() {
+ data.EnableTrapsErrdisable = types.BoolValue(true)
+ } else {
+ data.EnableTrapsErrdisable = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/rf"); value.Exists() {
+ data.EnableTrapsRf = types.BoolValue(true)
+ } else {
+ data.EnableTrapsRf = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/transceiver/all"); value.Exists() {
+ data.EnableTrapsTransceiverAll = types.BoolValue(true)
+ } else {
+ data.EnableTrapsTransceiverAll = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/bulkstat/collection"); value.Exists() {
+ data.EnableTrapsBulkstatCollection = types.BoolValue(true)
+ } else {
+ data.EnableTrapsBulkstatCollection = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/bulkstat/transfer"); value.Exists() {
+ data.EnableTrapsBulkstatTransfer = types.BoolValue(true)
+ } else {
+ data.EnableTrapsBulkstatTransfer = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/mac-notification/change"); value.Exists() {
+ data.EnableTrapsMacNotificationChange = types.BoolValue(true)
+ } else {
+ data.EnableTrapsMacNotificationChange = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/mac-notification/move"); value.Exists() {
+ data.EnableTrapsMacNotificationMove = types.BoolValue(true)
+ } else {
+ data.EnableTrapsMacNotificationMove = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/mac-notification/threshold"); value.Exists() {
+ data.EnableTrapsMacNotificationThreshold = types.BoolValue(true)
+ } else {
+ data.EnableTrapsMacNotificationThreshold = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/vrfmib/vrf-up"); value.Exists() {
+ data.EnableTrapsVrfmibVrfUp = types.BoolValue(true)
+ } else {
+ data.EnableTrapsVrfmibVrfUp = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/vrfmib/vrf-down"); value.Exists() {
+ data.EnableTrapsVrfmibVrfDown = types.BoolValue(true)
+ } else {
+ data.EnableTrapsVrfmibVrfDown = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/vrfmib/vnet-trunk-up"); value.Exists() {
+ data.EnableTrapsVrfmibVnetTrunkUp = types.BoolValue(true)
+ } else {
+ data.EnableTrapsVrfmibVnetTrunkUp = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/vrfmib/vnet-trunk-down"); value.Exists() {
+ data.EnableTrapsVrfmibVnetTrunkDown = types.BoolValue(true)
+ } else {
+ data.EnableTrapsVrfmibVnetTrunkDown = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/mvpn"); value.Exists() {
+ data.EnableTrapsMvpn = types.BoolValue(true)
+ } else {
+ data.EnableTrapsMvpn = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/lisp"); value.Exists() {
+ data.EnableTrapsLisp = types.BoolValue(true)
+ } else {
+ data.EnableTrapsLisp = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/aaa_server"); value.Exists() {
+ data.EnableTrapsAaaServer = types.BoolValue(true)
+ } else {
+ data.EnableTrapsAaaServer = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/vdsl2line"); value.Exists() {
+ data.EnableTrapsVdsl2line = types.BoolValue(true)
+ } else {
+ data.EnableTrapsVdsl2line = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/adslline"); value.Exists() {
+ data.EnableTrapsAdslline = types.BoolValue(true)
+ } else {
+ data.EnableTrapsAdslline = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/pki"); value.Exists() {
+ data.EnableTrapsPki = types.BoolValue(true)
+ } else {
+ data.EnableTrapsPki = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/alarms/alarm-type"); value.Exists() {
+ data.EnableTrapsAlarmType = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/casa"); value.Exists() {
+ data.EnableTrapsCasa = types.BoolValue(true)
+ } else {
+ data.EnableTrapsCasa = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/cnpd"); value.Exists() {
+ data.EnableTrapsCnpd = types.BoolValue(true)
+ } else {
+ data.EnableTrapsCnpd = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/dial"); value.Exists() {
+ data.EnableTrapsDial = types.BoolValue(true)
+ } else {
+ data.EnableTrapsDial = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/dlsw"); value.Exists() {
+ data.EnableTrapsDlsw = types.BoolValue(true)
+ } else {
+ data.EnableTrapsDlsw = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ds1"); value.Exists() {
+ data.EnableTrapsDs1 = types.BoolValue(true)
+ } else {
+ data.EnableTrapsDs1 = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/dsp/card-status"); value.Exists() {
+ data.EnableTrapsDspCardStatus = types.BoolValue(true)
+ } else {
+ data.EnableTrapsDspCardStatus = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/dsp/oper-state"); value.Exists() {
+ data.EnableTrapsDspOperState = types.BoolValue(true)
+ } else {
+ data.EnableTrapsDspOperState = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/entity-sensor"); value.Exists() {
+ data.EnableTrapsEntitySensor = types.BoolValue(true)
+ } else {
+ data.EnableTrapsEntitySensor = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/entity-state"); value.Exists() {
+ data.EnableTrapsEntityState = types.BoolValue(true)
+ } else {
+ data.EnableTrapsEntityState = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/entity-qfp/mem-res-thresh"); value.Exists() {
+ data.EnableTrapsEntityQfpMemResThresh = types.BoolValue(true)
+ } else {
+ data.EnableTrapsEntityQfpMemResThresh = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/entity-qfp/throughput-notif"); value.Exists() {
+ data.EnableTrapsEntityQfpThroughputNotif = types.BoolValue(true)
+ } else {
+ data.EnableTrapsEntityQfpThroughputNotif = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ether-oam"); value.Exists() {
+ data.EnableTrapsEtherOam = types.BoolValue(true)
+ } else {
+ data.EnableTrapsEtherOam = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ethernet/cfm/alarm"); value.Exists() {
+ data.EnableTrapsEthernetCfmAlarm = types.BoolValue(true)
+ } else {
+ data.EnableTrapsEthernetCfmAlarm = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ethernet/cfm/cc/config"); value.Exists() {
+ data.EnableTrapsEthernetCfmCcConfig = types.BoolValue(true)
+ } else {
+ data.EnableTrapsEthernetCfmCcConfig = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ethernet/cfm/cc/cross-connect"); value.Exists() {
+ data.EnableTrapsEthernetCfmCcCrossConnect = types.BoolValue(true)
+ } else {
+ data.EnableTrapsEthernetCfmCcCrossConnect = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ethernet/cfm/cc/loop"); value.Exists() {
+ data.EnableTrapsEthernetCfmCcLoop = types.BoolValue(true)
+ } else {
+ data.EnableTrapsEthernetCfmCcLoop = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ethernet/cfm/cc/mep-down"); value.Exists() {
+ data.EnableTrapsEthernetCfmCcMepDown = types.BoolValue(true)
+ } else {
+ data.EnableTrapsEthernetCfmCcMepDown = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ethernet/cfm/cc/mep-up"); value.Exists() {
+ data.EnableTrapsEthernetCfmCcMepUp = types.BoolValue(true)
+ } else {
+ data.EnableTrapsEthernetCfmCcMepUp = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ethernet/cfm/crosscheck/mep-missing"); value.Exists() {
+ data.EnableTrapsEthernetCfmCrosscheckMepMissing = types.BoolValue(true)
+ } else {
+ data.EnableTrapsEthernetCfmCrosscheckMepMissing = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ethernet/cfm/crosscheck/mep-unknown"); value.Exists() {
+ data.EnableTrapsEthernetCfmCrosscheckMepUnknown = types.BoolValue(true)
+ } else {
+ data.EnableTrapsEthernetCfmCrosscheckMepUnknown = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ethernet/cfm/crosscheck/service-up"); value.Exists() {
+ data.EnableTrapsEthernetCfmCrosscheckServiceUp = types.BoolValue(true)
+ } else {
+ data.EnableTrapsEthernetCfmCrosscheckServiceUp = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ethernet/evc/create"); value.Exists() {
+ data.EnableTrapsEthernetEvcCreate = types.BoolValue(true)
+ } else {
+ data.EnableTrapsEthernetEvcCreate = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ethernet/evc/delete"); value.Exists() {
+ data.EnableTrapsEthernetEvcDelete = types.BoolValue(true)
+ } else {
+ data.EnableTrapsEthernetEvcDelete = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ethernet/evc/status"); value.Exists() {
+ data.EnableTrapsEthernetEvcStatus = types.BoolValue(true)
+ } else {
+ data.EnableTrapsEthernetEvcStatus = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/firewall/serverstatus"); value.Exists() {
+ data.EnableTrapsFirewallServerstatus = types.BoolValue(true)
+ } else {
+ data.EnableTrapsFirewallServerstatus = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/frame-relay-config/only-frame-relay/frame-relay"); value.Exists() {
+ data.EnableTrapsFrameRelayConfigOnly = types.BoolValue(true)
+ } else {
+ data.EnableTrapsFrameRelayConfigOnly = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/frame-relay-config/frame-relay-options/frame-relay/subif-configs/subif"); value.Exists() {
+ data.EnableTrapsFrameRelayConfigSubifConfigs = types.BoolValue(true)
+ } else {
+ data.EnableTrapsFrameRelayConfigSubifConfigs = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/frame-relay/subif/count"); value.Exists() {
+ data.EnableTrapsFrameRelaySubifCount = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/frame-relay/subif/interval"); value.Exists() {
+ data.EnableTrapsFrameRelaySubifInterval = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/frame-relay-config/frame-relay-options/frame-relay/multilink/bundle-mismatch"); value.Exists() {
+ data.EnableTrapsFrameRelayConfigBundleMismatch = types.BoolValue(true)
+ } else {
+ data.EnableTrapsFrameRelayConfigBundleMismatch = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/frame-relay/multilink/bundle-mismatch"); value.Exists() {
+ data.EnableTrapsFrameRelayMultilinkBundleMismatch = types.BoolValue(true)
+ } else {
+ data.EnableTrapsFrameRelayMultilinkBundleMismatch = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ip/local/pool"); value.Exists() {
+ data.EnableTrapsIpLocalPool = types.BoolValue(true)
+ } else {
+ data.EnableTrapsIpLocalPool = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/isdn/call-information"); value.Exists() {
+ data.EnableTrapsIsdnCallInformation = types.BoolValue(true)
+ } else {
+ data.EnableTrapsIsdnCallInformation = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/isdn/chan-not-avail"); value.Exists() {
+ data.EnableTrapsIsdnChanNotAvail = types.BoolValue(true)
+ } else {
+ data.EnableTrapsIsdnChanNotAvail = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/isdn/ietf"); value.Exists() {
+ data.EnableTrapsIsdnIetf = types.BoolValue(true)
+ } else {
+ data.EnableTrapsIsdnIetf = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/isdn/layer2"); value.Exists() {
+ data.EnableTrapsIsdnLayer2 = types.BoolValue(true)
+ } else {
+ data.EnableTrapsIsdnLayer2 = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/l2tun/session"); value.Exists() {
+ data.EnableTrapsL2tunSession = types.BoolValue(true)
+ } else {
+ data.EnableTrapsL2tunSession = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/l2tun/tunnel"); value.Exists() {
+ data.EnableTrapsL2tunTunnel = types.BoolValue(true)
+ } else {
+ data.EnableTrapsL2tunTunnel = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/l2tun/pseudowire/status"); value.Exists() {
+ data.EnableTrapsL2tunPseudowireStatus = types.BoolValue(true)
+ } else {
+ data.EnableTrapsL2tunPseudowireStatus = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/pimstdmib/neighbor-loss"); value.Exists() {
+ data.EnableTrapsPimstdmibNeighborLoss = types.BoolValue(true)
+ } else {
+ data.EnableTrapsPimstdmibNeighborLoss = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/pimstdmib/invalid-register"); value.Exists() {
+ data.EnableTrapsPimstdmibInvalidRegister = types.BoolValue(true)
+ } else {
+ data.EnableTrapsPimstdmibInvalidRegister = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/pimstdmib/invalid-join-prune"); value.Exists() {
+ data.EnableTrapsPimstdmibInvalidJoinPrune = types.BoolValue(true)
+ } else {
+ data.EnableTrapsPimstdmibInvalidJoinPrune = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/pimstdmib/rp-mapping-change"); value.Exists() {
+ data.EnableTrapsPimstdmibRpMappingChange = types.BoolValue(true)
+ } else {
+ data.EnableTrapsPimstdmibRpMappingChange = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/pimstdmib/interface-election"); value.Exists() {
+ data.EnableTrapsPimstdmibInterfaceElection = types.BoolValue(true)
+ } else {
+ data.EnableTrapsPimstdmibInterfaceElection = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/pfr"); value.Exists() {
+ data.EnableTrapsPfr = types.BoolValue(true)
+ } else {
+ data.EnableTrapsPfr = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/pppoe"); value.Exists() {
+ data.EnableTrapsPppoe = types.BoolValue(true)
+ } else {
+ data.EnableTrapsPppoe = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/resource-policy"); value.Exists() {
+ data.EnableTrapsResourcePolicy = types.BoolValue(true)
+ } else {
+ data.EnableTrapsResourcePolicy = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/rsvp"); value.Exists() {
+ data.EnableTrapsRsvp = types.BoolValue(true)
+ } else {
+ data.EnableTrapsRsvp = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/vrrp"); value.Exists() {
+ data.EnableTrapsVrrp = types.BoolValue(true)
+ } else {
+ data.EnableTrapsVrrp = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/sonet"); value.Exists() {
+ data.EnableTrapsSonet = types.BoolValue(true)
+ } else {
+ data.EnableTrapsSonet = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/srp"); value.Exists() {
+ data.EnableTrapsSrp = types.BoolValue(true)
+ } else {
+ data.EnableTrapsSrp = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/voice"); value.Exists() {
+ data.EnableTrapsVoice = types.BoolValue(true)
+ } else {
+ data.EnableTrapsVoice = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/bgp"); value.Exists() {
+ data.EnableTrapsBgp = types.BoolValue(true)
+ } else {
+ data.EnableTrapsBgp = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/bgp-traps/cbgp2"); value.Exists() {
+ data.EnableTrapsCbgp2 = types.BoolValue(true)
+ } else {
+ data.EnableTrapsCbgp2 = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ospfv3/errors"); value.Exists() {
+ data.EnableTrapsOspfv3Errors = types.BoolValue(true)
+ } else {
+ data.EnableTrapsOspfv3Errors = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ospfv3/state-change"); value.Exists() {
+ data.EnableTrapsOspfv3StateChange = types.BoolValue(true)
+ } else {
+ data.EnableTrapsOspfv3StateChange = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:source-interface/informs/GigabitEthernet"); value.Exists() {
+ data.SourceInterfaceInformsGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:source-interface/informs/TenGigabitEthernet"); value.Exists() {
+ data.SourceInterfaceInformsTenGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:source-interface/informs/FortyGigabitEthernet"); value.Exists() {
+ data.SourceInterfaceInformsFortyGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:source-interface/informs/HundredGigE"); value.Exists() {
+ data.SourceInterfaceInformsHundredGigE = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:source-interface/informs/Loopback"); value.Exists() {
+ data.SourceInterfaceInformsLoopback = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:source-interface/informs/Port-channel"); value.Exists() {
+ data.SourceInterfaceInformsPortChannel = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:source-interface/informs/Port-channel-subinterface/Port-channel"); value.Exists() {
+ data.SourceInterfaceInformsPortChannelSubinterface = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:source-interface/informs/Vlan"); value.Exists() {
+ data.SourceInterfaceInformsVlan = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:source-interface/traps/GigabitEthernet"); value.Exists() {
+ data.SourceInterfaceTrapsGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:source-interface/traps/TenGigabitEthernet"); value.Exists() {
+ data.SourceInterfaceTrapsTenGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:source-interface/traps/FortyGigabitEthernet"); value.Exists() {
+ data.SourceInterfaceTrapsFortyGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:source-interface/traps/HundredGigE"); value.Exists() {
+ data.SourceInterfaceTrapsHundredGigE = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:source-interface/traps/Loopback"); value.Exists() {
+ data.SourceInterfaceTrapsLoopback = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:source-interface/traps/Port-channel"); value.Exists() {
+ data.SourceInterfaceTrapsPortChannel = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:source-interface/traps/Port-channel-subinterface/Port-channel"); value.Exists() {
+ data.SourceInterfaceTrapsPortChannelSubinterface = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:source-interface/traps/Vlan"); value.Exists() {
+ data.SourceInterfaceTrapsVlan = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:trap-source/GigabitEthernet"); value.Exists() {
+ data.TrapSourceGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:trap-source/TenGigabitEthernet"); value.Exists() {
+ data.TrapSourceTenGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:trap-source/FortyGigabitEthernet"); value.Exists() {
+ data.TrapSourceFortyGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:trap-source/HundredGigE"); value.Exists() {
+ data.TrapSourceHundredGigE = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:trap-source/Loopback"); value.Exists() {
+ data.TrapSourceLoopback = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:trap-source/Port-channel"); value.Exists() {
+ data.TrapSourcePortChannel = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:trap-source/Port-channel-subinterface/Port-channel"); value.Exists() {
+ data.TrapSourcePortChannelSubinterface = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:trap-source/Vlan"); value.Exists() {
+ data.TrapSourceVlan = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:community-config"); value.Exists() {
+ data.SnmpCommunities = make([]SNMPServerSnmpCommunities, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := SNMPServerSnmpCommunities{}
+ if cValue := helpers.GetFromXPath(v, "name"); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "view"); cValue.Exists() {
+ item.View = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "permission"); cValue.Exists() {
+ item.Permission = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "ipv6"); cValue.Exists() {
+ item.Ipv6 = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "access-list-name"); cValue.Exists() {
+ item.AccessListName = types.StringValue(cValue.String())
+ }
+ data.SnmpCommunities = append(data.SnmpCommunities, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:context"); value.Exists() {
+ data.Contexts = make([]SNMPServerContexts, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := SNMPServerContexts{}
+ if cValue := helpers.GetFromXPath(v, "name"); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ data.Contexts = append(data.Contexts, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:view"); value.Exists() {
+ data.Views = make([]SNMPServerViews, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := SNMPServerViews{}
+ if cValue := helpers.GetFromXPath(v, "name"); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "mib"); cValue.Exists() {
+ item.Mib = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "inc-exl"); cValue.Exists() {
+ item.IncExl = types.StringValue(cValue.String())
+ }
+ data.Views = append(data.Views, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:group"); value.Exists() {
+ data.Groups = make([]SNMPServerGroups, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := SNMPServerGroups{}
+ if cValue := helpers.GetFromXPath(v, "id"); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "v3/security-level-list"); cValue.Exists() {
+ item.V3Security = make([]SNMPServerGroupsV3Security, 0)
+ cValue.ForEach(func(_ int, cv xmldot.Result) bool {
+ cItem := SNMPServerGroupsV3Security{}
+ if ccValue := helpers.GetFromXPath(cv, "security-level"); ccValue.Exists() {
+ cItem.SecurityLevel = types.StringValue(ccValue.String())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "context-node"); ccValue.Exists() {
+ cItem.ContextNode = types.StringValue(ccValue.String())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "match-node"); ccValue.Exists() {
+ cItem.MatchNode = types.StringValue(ccValue.String())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "read-node"); ccValue.Exists() {
+ cItem.ReadNode = types.StringValue(ccValue.String())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "write-node"); ccValue.Exists() {
+ cItem.WriteNode = types.StringValue(ccValue.String())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "notify-node"); ccValue.Exists() {
+ cItem.NotifyNode = types.StringValue(ccValue.String())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "access-config/ipv6-acl"); ccValue.Exists() {
+ cItem.AccessIpv6Acl = types.StringValue(ccValue.String())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "access-config/standard-acl"); ccValue.Exists() {
+ cItem.AccessStandardAcl = types.Int64Value(ccValue.Int())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "access-config/acl-name"); ccValue.Exists() {
+ cItem.AccessAclName = types.StringValue(ccValue.String())
+ }
+ item.V3Security = append(item.V3Security, cItem)
+ return true
+ })
+ }
+ data.Groups = append(data.Groups, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-snmp:user/names"); value.Exists() {
+ data.Users = make([]SNMPServerUsers, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := SNMPServerUsers{}
+ if cValue := helpers.GetFromXPath(v, "username"); cValue.Exists() {
+ item.Username = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "grpname"); cValue.Exists() {
+ item.Grpname = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "v3/auth-config/algorithm"); cValue.Exists() {
+ item.V3AuthAlgorithm = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "v3/auth-config/password"); cValue.Exists() {
+ item.V3AuthPassword = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "v3/auth-config/priv-config/aes/algorithm"); cValue.Exists() {
+ item.V3AuthPrivAesAlgorithm = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "v3/auth-config/priv-config/aes/password"); cValue.Exists() {
+ item.V3AuthPrivAesPassword = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "v3/auth-config/priv-config/aes/access-config/ipv6-acl"); cValue.Exists() {
+ item.V3AuthPrivAesAccessIpv6Acl = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "v3/auth-config/priv-config/aes/access-config/standard-acl"); cValue.Exists() {
+ item.V3AuthPrivAesAccessStandardAcl = types.Int64Value(cValue.Int())
+ }
+ if cValue := helpers.GetFromXPath(v, "v3/auth-config/priv-config/aes/access-config/acl-name"); cValue.Exists() {
+ item.V3AuthPrivAesAccessAclName = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "v3/auth-config/priv-config/des/password"); cValue.Exists() {
+ item.V3AuthPrivDesPassword = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "v3/auth-config/priv-config/des/access-config/ipv6-acl"); cValue.Exists() {
+ item.V3AuthPrivDesAccessIpv6Acl = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "v3/auth-config/priv-config/des/access-config/standard-acl"); cValue.Exists() {
+ item.V3AuthPrivDesAccessStandardAcl = types.Int64Value(cValue.Int())
+ }
+ if cValue := helpers.GetFromXPath(v, "v3/auth-config/priv-config/des/access-config/acl-name"); cValue.Exists() {
+ item.V3AuthPrivDesAccessAclName = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "v3/auth-config/priv-config/des3/password"); cValue.Exists() {
+ item.V3AuthPrivDes3Password = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "v3/auth-config/priv-config/des3/access-config/ipv6-acl"); cValue.Exists() {
+ item.V3AuthPrivDes3AccessIpv6Acl = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "v3/auth-config/priv-config/des3/access-config/standard-acl"); cValue.Exists() {
+ item.V3AuthPrivDes3AccessStandardAcl = types.Int64Value(cValue.Int())
+ }
+ if cValue := helpers.GetFromXPath(v, "v3/auth-config/priv-config/des3/access-config/acl-name"); cValue.Exists() {
+ item.V3AuthPrivDes3AccessAclName = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "v3/auth-config/access-config/ipv6-acl"); cValue.Exists() {
+ item.V3AuthAccessIpv6Acl = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "v3/auth-config/access-config/standard-acl"); cValue.Exists() {
+ item.V3AuthAccessStandardAcl = types.Int64Value(cValue.Int())
+ }
+ if cValue := helpers.GetFromXPath(v, "v3/auth-config/access-config/acl-name"); cValue.Exists() {
+ item.V3AuthAccessAclName = types.StringValue(cValue.String())
+ }
+ data.Users = append(data.Users, item)
+ return true
+ })
+ }
+}
+
+// End of section. //template:end fromBodyDataXML
+
+// Section below is generated&owned by "gen/generator.go". //template:begin getDeletedItems
+
+func (data *SNMPServer) getDeletedItems(ctx context.Context, state SNMPServer) []string {
+ deletedItems := make([]string, 0)
+ for i := range state.Users {
+ stateKeyValues := [...]string{state.Users[i].Username.ValueString(), state.Users[i].Grpname.ValueString()}
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.Users[i].Username.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if !reflect.ValueOf(state.Users[i].Grpname.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.Users {
+ found = true
+ if state.Users[i].Username.ValueString() != data.Users[j].Username.ValueString() {
+ found = false
+ }
+ if state.Users[i].Grpname.ValueString() != data.Users[j].Grpname.ValueString() {
+ found = false
+ }
+ if found {
+ if !state.Users[i].V3AuthAccessAclName.IsNull() && data.Users[j].V3AuthAccessAclName.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:user/names=%v/v3/auth-config/access-config/acl-name", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ if !state.Users[i].V3AuthAccessStandardAcl.IsNull() && data.Users[j].V3AuthAccessStandardAcl.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:user/names=%v/v3/auth-config/access-config/standard-acl", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ if !state.Users[i].V3AuthAccessIpv6Acl.IsNull() && data.Users[j].V3AuthAccessIpv6Acl.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:user/names=%v/v3/auth-config/access-config/ipv6-acl", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ if !state.Users[i].V3AuthPrivDes3AccessAclName.IsNull() && data.Users[j].V3AuthPrivDes3AccessAclName.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:user/names=%v/v3/auth-config/priv-config/des3/access-config/acl-name", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ if !state.Users[i].V3AuthPrivDes3AccessStandardAcl.IsNull() && data.Users[j].V3AuthPrivDes3AccessStandardAcl.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:user/names=%v/v3/auth-config/priv-config/des3/access-config/standard-acl", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ if !state.Users[i].V3AuthPrivDes3AccessIpv6Acl.IsNull() && data.Users[j].V3AuthPrivDes3AccessIpv6Acl.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:user/names=%v/v3/auth-config/priv-config/des3/access-config/ipv6-acl", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ if !state.Users[i].V3AuthPrivDes3Password.IsNull() && data.Users[j].V3AuthPrivDes3Password.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:user/names=%v/v3/auth-config/priv-config/des3/password", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ if !state.Users[i].V3AuthPrivDesAccessAclName.IsNull() && data.Users[j].V3AuthPrivDesAccessAclName.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:user/names=%v/v3/auth-config/priv-config/des/access-config/acl-name", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ if !state.Users[i].V3AuthPrivDesAccessStandardAcl.IsNull() && data.Users[j].V3AuthPrivDesAccessStandardAcl.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:user/names=%v/v3/auth-config/priv-config/des/access-config/standard-acl", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ if !state.Users[i].V3AuthPrivDesAccessIpv6Acl.IsNull() && data.Users[j].V3AuthPrivDesAccessIpv6Acl.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:user/names=%v/v3/auth-config/priv-config/des/access-config/ipv6-acl", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ if !state.Users[i].V3AuthPrivDesPassword.IsNull() && data.Users[j].V3AuthPrivDesPassword.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:user/names=%v/v3/auth-config/priv-config/des/password", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ if !state.Users[i].V3AuthPrivAesAccessAclName.IsNull() && data.Users[j].V3AuthPrivAesAccessAclName.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:user/names=%v/v3/auth-config/priv-config/aes/access-config/acl-name", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ if !state.Users[i].V3AuthPrivAesAccessStandardAcl.IsNull() && data.Users[j].V3AuthPrivAesAccessStandardAcl.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:user/names=%v/v3/auth-config/priv-config/aes/access-config/standard-acl", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ if !state.Users[i].V3AuthPrivAesAccessIpv6Acl.IsNull() && data.Users[j].V3AuthPrivAesAccessIpv6Acl.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:user/names=%v/v3/auth-config/priv-config/aes/access-config/ipv6-acl", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ if !state.Users[i].V3AuthPrivAesPassword.IsNull() && data.Users[j].V3AuthPrivAesPassword.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:user/names=%v/v3/auth-config/priv-config/aes/password", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ if !state.Users[i].V3AuthPrivAesAlgorithm.IsNull() && data.Users[j].V3AuthPrivAesAlgorithm.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:user/names=%v/v3/auth-config/priv-config/aes/algorithm", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ if !state.Users[i].V3AuthPassword.IsNull() && data.Users[j].V3AuthPassword.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:user/names=%v/v3/auth-config/password", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ if !state.Users[i].V3AuthAlgorithm.IsNull() && data.Users[j].V3AuthAlgorithm.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:user/names=%v/v3/auth-config/algorithm", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ break
+ }
+ }
+ if !found {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:user/names=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ }
+ for i := range state.Groups {
+ stateKeyValues := [...]string{state.Groups[i].Name.ValueString()}
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.Groups[i].Name.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.Groups {
+ found = true
+ if state.Groups[i].Name.ValueString() != data.Groups[j].Name.ValueString() {
+ found = false
+ }
+ if found {
+ for ci := range state.Groups[i].V3Security {
+ cstateKeyValues := [...]string{state.Groups[i].V3Security[ci].SecurityLevel.ValueString()}
+
+ cemptyKeys := true
+ if !reflect.ValueOf(state.Groups[i].V3Security[ci].SecurityLevel.ValueString()).IsZero() {
+ cemptyKeys = false
}
- if ccValue := cv.Get("access-config.ipv6-acl"); ccValue.Exists() {
- cItem.AccessIpv6Acl = types.StringValue(ccValue.String())
+ if cemptyKeys {
+ continue
}
- if ccValue := cv.Get("access-config.standard-acl"); ccValue.Exists() {
- cItem.AccessStandardAcl = types.Int64Value(ccValue.Int())
+
+ found := false
+ for cj := range data.Groups[j].V3Security {
+ found = true
+ if state.Groups[i].V3Security[ci].SecurityLevel.ValueString() != data.Groups[j].V3Security[cj].SecurityLevel.ValueString() {
+ found = false
+ }
+ if found {
+ if !state.Groups[i].V3Security[ci].AccessAclName.IsNull() && data.Groups[j].V3Security[cj].AccessAclName.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:group=%v/v3/security-level-list=%v/access-config/acl-name", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ }
+ if !state.Groups[i].V3Security[ci].AccessStandardAcl.IsNull() && data.Groups[j].V3Security[cj].AccessStandardAcl.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:group=%v/v3/security-level-list=%v/access-config/standard-acl", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ }
+ if !state.Groups[i].V3Security[ci].AccessIpv6Acl.IsNull() && data.Groups[j].V3Security[cj].AccessIpv6Acl.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:group=%v/v3/security-level-list=%v/access-config/ipv6-acl", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ }
+ if !state.Groups[i].V3Security[ci].NotifyNode.IsNull() && data.Groups[j].V3Security[cj].NotifyNode.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:group=%v/v3/security-level-list=%v/notify-node", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ }
+ if !state.Groups[i].V3Security[ci].WriteNode.IsNull() && data.Groups[j].V3Security[cj].WriteNode.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:group=%v/v3/security-level-list=%v/write-node", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ }
+ if !state.Groups[i].V3Security[ci].ReadNode.IsNull() && data.Groups[j].V3Security[cj].ReadNode.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:group=%v/v3/security-level-list=%v/read-node", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ }
+ if !state.Groups[i].V3Security[ci].MatchNode.IsNull() && data.Groups[j].V3Security[cj].MatchNode.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:group=%v/v3/security-level-list=%v/match-node", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ }
+ if !state.Groups[i].V3Security[ci].ContextNode.IsNull() && data.Groups[j].V3Security[cj].ContextNode.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:group=%v/v3/security-level-list=%v/context-node", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ }
+ break
+ }
}
- if ccValue := cv.Get("access-config.acl-name"); ccValue.Exists() {
- cItem.AccessAclName = types.StringValue(ccValue.String())
+ if !found {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:group=%v/v3/security-level-list=%v", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
}
- item.V3Security = append(item.V3Security, cItem)
- return true
- })
+ }
+ break
}
- data.Groups = append(data.Groups, item)
- return true
- })
+ }
+ if !found {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:group=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ }
+ for i := range state.Views {
+ stateKeyValues := [...]string{state.Views[i].Name.ValueString(), state.Views[i].Mib.ValueString()}
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.Views[i].Name.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if !reflect.ValueOf(state.Views[i].Mib.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.Views {
+ found = true
+ if state.Views[i].Name.ValueString() != data.Views[j].Name.ValueString() {
+ found = false
+ }
+ if state.Views[i].Mib.ValueString() != data.Views[j].Mib.ValueString() {
+ found = false
+ }
+ if found {
+ if !state.Views[i].IncExl.IsNull() && data.Views[j].IncExl.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:view=%v/inc-exl", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ break
+ }
+ }
+ if !found {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:view=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ }
+ for i := range state.Contexts {
+ stateKeyValues := [...]string{state.Contexts[i].Name.ValueString()}
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.Contexts[i].Name.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.Contexts {
+ found = true
+ if state.Contexts[i].Name.ValueString() != data.Contexts[j].Name.ValueString() {
+ found = false
+ }
+ if found {
+ break
+ }
+ }
+ if !found {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:context=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ }
+ for i := range state.SnmpCommunities {
+ stateKeyValues := [...]string{state.SnmpCommunities[i].Name.ValueString()}
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.SnmpCommunities[i].Name.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.SnmpCommunities {
+ found = true
+ if state.SnmpCommunities[i].Name.ValueString() != data.SnmpCommunities[j].Name.ValueString() {
+ found = false
+ }
+ if found {
+ if !state.SnmpCommunities[i].AccessListName.IsNull() && data.SnmpCommunities[j].AccessListName.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:community-config=%v/access-list-name", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ if !state.SnmpCommunities[i].Ipv6.IsNull() && data.SnmpCommunities[j].Ipv6.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:community-config=%v/ipv6", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ if !state.SnmpCommunities[i].Permission.IsNull() && data.SnmpCommunities[j].Permission.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:community-config=%v/permission", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ if !state.SnmpCommunities[i].View.IsNull() && data.SnmpCommunities[j].View.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:community-config=%v/view", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ break
+ }
+ }
+ if !found {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:community-config=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ }
+ if !state.TrapSourceVlan.IsNull() && data.TrapSourceVlan.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:trap-source/Vlan", state.getPath()))
+ }
+ if !state.TrapSourcePortChannelSubinterface.IsNull() && data.TrapSourcePortChannelSubinterface.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:trap-source/Port-channel-subinterface/Port-channel", state.getPath()))
+ }
+ if !state.TrapSourcePortChannel.IsNull() && data.TrapSourcePortChannel.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:trap-source/Port-channel", state.getPath()))
+ }
+ if !state.TrapSourceLoopback.IsNull() && data.TrapSourceLoopback.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:trap-source/Loopback", state.getPath()))
+ }
+ if !state.TrapSourceHundredGigE.IsNull() && data.TrapSourceHundredGigE.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:trap-source/HundredGigE", state.getPath()))
+ }
+ if !state.TrapSourceFortyGigabitEthernet.IsNull() && data.TrapSourceFortyGigabitEthernet.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:trap-source/FortyGigabitEthernet", state.getPath()))
+ }
+ if !state.TrapSourceTenGigabitEthernet.IsNull() && data.TrapSourceTenGigabitEthernet.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:trap-source/TenGigabitEthernet", state.getPath()))
+ }
+ if !state.TrapSourceGigabitEthernet.IsNull() && data.TrapSourceGigabitEthernet.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:trap-source/GigabitEthernet", state.getPath()))
+ }
+ if !state.SourceInterfaceTrapsVlan.IsNull() && data.SourceInterfaceTrapsVlan.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:source-interface/traps/Vlan", state.getPath()))
+ }
+ if !state.SourceInterfaceTrapsPortChannelSubinterface.IsNull() && data.SourceInterfaceTrapsPortChannelSubinterface.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:source-interface/traps/Port-channel-subinterface/Port-channel", state.getPath()))
+ }
+ if !state.SourceInterfaceTrapsPortChannel.IsNull() && data.SourceInterfaceTrapsPortChannel.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:source-interface/traps/Port-channel", state.getPath()))
+ }
+ if !state.SourceInterfaceTrapsLoopback.IsNull() && data.SourceInterfaceTrapsLoopback.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:source-interface/traps/Loopback", state.getPath()))
+ }
+ if !state.SourceInterfaceTrapsHundredGigE.IsNull() && data.SourceInterfaceTrapsHundredGigE.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:source-interface/traps/HundredGigE", state.getPath()))
+ }
+ if !state.SourceInterfaceTrapsFortyGigabitEthernet.IsNull() && data.SourceInterfaceTrapsFortyGigabitEthernet.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:source-interface/traps/FortyGigabitEthernet", state.getPath()))
+ }
+ if !state.SourceInterfaceTrapsTenGigabitEthernet.IsNull() && data.SourceInterfaceTrapsTenGigabitEthernet.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:source-interface/traps/TenGigabitEthernet", state.getPath()))
+ }
+ if !state.SourceInterfaceTrapsGigabitEthernet.IsNull() && data.SourceInterfaceTrapsGigabitEthernet.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:source-interface/traps/GigabitEthernet", state.getPath()))
+ }
+ if !state.SourceInterfaceInformsVlan.IsNull() && data.SourceInterfaceInformsVlan.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:source-interface/informs/Vlan", state.getPath()))
+ }
+ if !state.SourceInterfaceInformsPortChannelSubinterface.IsNull() && data.SourceInterfaceInformsPortChannelSubinterface.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:source-interface/informs/Port-channel-subinterface/Port-channel", state.getPath()))
+ }
+ if !state.SourceInterfaceInformsPortChannel.IsNull() && data.SourceInterfaceInformsPortChannel.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:source-interface/informs/Port-channel", state.getPath()))
+ }
+ if !state.SourceInterfaceInformsLoopback.IsNull() && data.SourceInterfaceInformsLoopback.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:source-interface/informs/Loopback", state.getPath()))
+ }
+ if !state.SourceInterfaceInformsHundredGigE.IsNull() && data.SourceInterfaceInformsHundredGigE.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:source-interface/informs/HundredGigE", state.getPath()))
+ }
+ if !state.SourceInterfaceInformsFortyGigabitEthernet.IsNull() && data.SourceInterfaceInformsFortyGigabitEthernet.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:source-interface/informs/FortyGigabitEthernet", state.getPath()))
+ }
+ if !state.SourceInterfaceInformsTenGigabitEthernet.IsNull() && data.SourceInterfaceInformsTenGigabitEthernet.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:source-interface/informs/TenGigabitEthernet", state.getPath()))
+ }
+ if !state.SourceInterfaceInformsGigabitEthernet.IsNull() && data.SourceInterfaceInformsGigabitEthernet.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:source-interface/informs/GigabitEthernet", state.getPath()))
+ }
+ if !state.EnableTrapsOspfv3StateChange.IsNull() && data.EnableTrapsOspfv3StateChange.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ospfv3/state-change", state.getPath()))
+ }
+ if !state.EnableTrapsOspfv3Errors.IsNull() && data.EnableTrapsOspfv3Errors.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ospfv3/errors", state.getPath()))
+ }
+ if !state.EnableTrapsCbgp2.IsNull() && data.EnableTrapsCbgp2.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/bgp-traps/cbgp2", state.getPath()))
+ }
+ if !state.EnableTrapsBgp.IsNull() && data.EnableTrapsBgp.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/bgp", state.getPath()))
+ }
+ if !state.EnableTrapsVoice.IsNull() && data.EnableTrapsVoice.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/voice", state.getPath()))
+ }
+ if !state.EnableTrapsSrp.IsNull() && data.EnableTrapsSrp.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/srp", state.getPath()))
+ }
+ if !state.EnableTrapsSonet.IsNull() && data.EnableTrapsSonet.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/sonet", state.getPath()))
+ }
+ if !state.EnableTrapsVrrp.IsNull() && data.EnableTrapsVrrp.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/vrrp", state.getPath()))
+ }
+ if !state.EnableTrapsRsvp.IsNull() && data.EnableTrapsRsvp.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/rsvp", state.getPath()))
+ }
+ if !state.EnableTrapsResourcePolicy.IsNull() && data.EnableTrapsResourcePolicy.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/resource-policy", state.getPath()))
+ }
+ if !state.EnableTrapsPppoe.IsNull() && data.EnableTrapsPppoe.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/pppoe", state.getPath()))
+ }
+ if !state.EnableTrapsPfr.IsNull() && data.EnableTrapsPfr.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/pfr", state.getPath()))
+ }
+ if !state.EnableTrapsPimstdmibInterfaceElection.IsNull() && data.EnableTrapsPimstdmibInterfaceElection.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/pimstdmib/interface-election", state.getPath()))
+ }
+ if !state.EnableTrapsPimstdmibRpMappingChange.IsNull() && data.EnableTrapsPimstdmibRpMappingChange.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/pimstdmib/rp-mapping-change", state.getPath()))
+ }
+ if !state.EnableTrapsPimstdmibInvalidJoinPrune.IsNull() && data.EnableTrapsPimstdmibInvalidJoinPrune.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/pimstdmib/invalid-join-prune", state.getPath()))
+ }
+ if !state.EnableTrapsPimstdmibInvalidRegister.IsNull() && data.EnableTrapsPimstdmibInvalidRegister.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/pimstdmib/invalid-register", state.getPath()))
+ }
+ if !state.EnableTrapsPimstdmibNeighborLoss.IsNull() && data.EnableTrapsPimstdmibNeighborLoss.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/pimstdmib/neighbor-loss", state.getPath()))
+ }
+ if !state.EnableTrapsL2tunPseudowireStatus.IsNull() && data.EnableTrapsL2tunPseudowireStatus.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/l2tun/pseudowire/status", state.getPath()))
+ }
+ if !state.EnableTrapsL2tunTunnel.IsNull() && data.EnableTrapsL2tunTunnel.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/l2tun/tunnel", state.getPath()))
+ }
+ if !state.EnableTrapsL2tunSession.IsNull() && data.EnableTrapsL2tunSession.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/l2tun/session", state.getPath()))
+ }
+ if !state.EnableTrapsIsdnLayer2.IsNull() && data.EnableTrapsIsdnLayer2.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/isdn/layer2", state.getPath()))
+ }
+ if !state.EnableTrapsIsdnIetf.IsNull() && data.EnableTrapsIsdnIetf.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/isdn/ietf", state.getPath()))
+ }
+ if !state.EnableTrapsIsdnChanNotAvail.IsNull() && data.EnableTrapsIsdnChanNotAvail.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/isdn/chan-not-avail", state.getPath()))
+ }
+ if !state.EnableTrapsIsdnCallInformation.IsNull() && data.EnableTrapsIsdnCallInformation.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/isdn/call-information", state.getPath()))
+ }
+ if !state.EnableTrapsIpLocalPool.IsNull() && data.EnableTrapsIpLocalPool.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ip/local/pool", state.getPath()))
+ }
+ if !state.EnableTrapsFrameRelayMultilinkBundleMismatch.IsNull() && data.EnableTrapsFrameRelayMultilinkBundleMismatch.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/frame-relay/multilink/bundle-mismatch", state.getPath()))
+ }
+ if !state.EnableTrapsFrameRelayConfigBundleMismatch.IsNull() && data.EnableTrapsFrameRelayConfigBundleMismatch.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/frame-relay-config/frame-relay-options/frame-relay/multilink/bundle-mismatch", state.getPath()))
+ }
+ if !state.EnableTrapsFrameRelaySubifInterval.IsNull() && data.EnableTrapsFrameRelaySubifInterval.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/frame-relay/subif/interval", state.getPath()))
+ }
+ if !state.EnableTrapsFrameRelaySubifCount.IsNull() && data.EnableTrapsFrameRelaySubifCount.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/frame-relay/subif/count", state.getPath()))
+ }
+ if !state.EnableTrapsFrameRelayConfigSubifConfigs.IsNull() && data.EnableTrapsFrameRelayConfigSubifConfigs.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/frame-relay-config/frame-relay-options/frame-relay/subif-configs/subif", state.getPath()))
+ }
+ if !state.EnableTrapsFrameRelayConfigOnly.IsNull() && data.EnableTrapsFrameRelayConfigOnly.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/frame-relay-config/only-frame-relay/frame-relay", state.getPath()))
+ }
+ if !state.EnableTrapsFirewallServerstatus.IsNull() && data.EnableTrapsFirewallServerstatus.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/firewall/serverstatus", state.getPath()))
+ }
+ if !state.EnableTrapsEthernetEvcStatus.IsNull() && data.EnableTrapsEthernetEvcStatus.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ethernet/evc/status", state.getPath()))
+ }
+ if !state.EnableTrapsEthernetEvcDelete.IsNull() && data.EnableTrapsEthernetEvcDelete.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ethernet/evc/delete", state.getPath()))
+ }
+ if !state.EnableTrapsEthernetEvcCreate.IsNull() && data.EnableTrapsEthernetEvcCreate.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ethernet/evc/create", state.getPath()))
+ }
+ if !state.EnableTrapsEthernetCfmCrosscheckServiceUp.IsNull() && data.EnableTrapsEthernetCfmCrosscheckServiceUp.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ethernet/cfm/crosscheck/service-up", state.getPath()))
+ }
+ if !state.EnableTrapsEthernetCfmCrosscheckMepUnknown.IsNull() && data.EnableTrapsEthernetCfmCrosscheckMepUnknown.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ethernet/cfm/crosscheck/mep-unknown", state.getPath()))
+ }
+ if !state.EnableTrapsEthernetCfmCrosscheckMepMissing.IsNull() && data.EnableTrapsEthernetCfmCrosscheckMepMissing.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ethernet/cfm/crosscheck/mep-missing", state.getPath()))
+ }
+ if !state.EnableTrapsEthernetCfmCcMepUp.IsNull() && data.EnableTrapsEthernetCfmCcMepUp.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ethernet/cfm/cc/mep-up", state.getPath()))
+ }
+ if !state.EnableTrapsEthernetCfmCcMepDown.IsNull() && data.EnableTrapsEthernetCfmCcMepDown.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ethernet/cfm/cc/mep-down", state.getPath()))
+ }
+ if !state.EnableTrapsEthernetCfmCcLoop.IsNull() && data.EnableTrapsEthernetCfmCcLoop.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ethernet/cfm/cc/loop", state.getPath()))
+ }
+ if !state.EnableTrapsEthernetCfmCcCrossConnect.IsNull() && data.EnableTrapsEthernetCfmCcCrossConnect.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ethernet/cfm/cc/cross-connect", state.getPath()))
+ }
+ if !state.EnableTrapsEthernetCfmCcConfig.IsNull() && data.EnableTrapsEthernetCfmCcConfig.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ethernet/cfm/cc/config", state.getPath()))
+ }
+ if !state.EnableTrapsEthernetCfmAlarm.IsNull() && data.EnableTrapsEthernetCfmAlarm.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ethernet/cfm/alarm", state.getPath()))
+ }
+ if !state.EnableTrapsEtherOam.IsNull() && data.EnableTrapsEtherOam.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ether-oam", state.getPath()))
+ }
+ if !state.EnableTrapsEntityQfpThroughputNotif.IsNull() && data.EnableTrapsEntityQfpThroughputNotif.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/entity-qfp/throughput-notif", state.getPath()))
+ }
+ if !state.EnableTrapsEntityQfpMemResThresh.IsNull() && data.EnableTrapsEntityQfpMemResThresh.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/entity-qfp/mem-res-thresh", state.getPath()))
+ }
+ if !state.EnableTrapsEntityState.IsNull() && data.EnableTrapsEntityState.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/entity-state", state.getPath()))
+ }
+ if !state.EnableTrapsEntitySensor.IsNull() && data.EnableTrapsEntitySensor.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/entity-sensor", state.getPath()))
+ }
+ if !state.EnableTrapsDspOperState.IsNull() && data.EnableTrapsDspOperState.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/dsp/oper-state", state.getPath()))
+ }
+ if !state.EnableTrapsDspCardStatus.IsNull() && data.EnableTrapsDspCardStatus.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/dsp/card-status", state.getPath()))
+ }
+ if !state.EnableTrapsDs1.IsNull() && data.EnableTrapsDs1.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ds1", state.getPath()))
+ }
+ if !state.EnableTrapsDlsw.IsNull() && data.EnableTrapsDlsw.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/dlsw", state.getPath()))
+ }
+ if !state.EnableTrapsDial.IsNull() && data.EnableTrapsDial.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/dial", state.getPath()))
+ }
+ if !state.EnableTrapsCnpd.IsNull() && data.EnableTrapsCnpd.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/cnpd", state.getPath()))
+ }
+ if !state.EnableTrapsCasa.IsNull() && data.EnableTrapsCasa.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/casa", state.getPath()))
+ }
+ if !state.EnableTrapsAlarmType.IsNull() && data.EnableTrapsAlarmType.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/alarms/alarm-type", state.getPath()))
+ }
+ if !state.EnableTrapsPki.IsNull() && data.EnableTrapsPki.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/pki", state.getPath()))
+ }
+ if !state.EnableTrapsAdslline.IsNull() && data.EnableTrapsAdslline.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/adslline", state.getPath()))
+ }
+ if !state.EnableTrapsVdsl2line.IsNull() && data.EnableTrapsVdsl2line.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/vdsl2line", state.getPath()))
+ }
+ if !state.EnableTrapsAaaServer.IsNull() && data.EnableTrapsAaaServer.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/aaa_server", state.getPath()))
+ }
+ if !state.EnableTrapsLisp.IsNull() && data.EnableTrapsLisp.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/lisp", state.getPath()))
+ }
+ if !state.EnableTrapsMvpn.IsNull() && data.EnableTrapsMvpn.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/mvpn", state.getPath()))
+ }
+ if !state.EnableTrapsVrfmibVnetTrunkDown.IsNull() && data.EnableTrapsVrfmibVnetTrunkDown.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/vrfmib/vnet-trunk-down", state.getPath()))
+ }
+ if !state.EnableTrapsVrfmibVnetTrunkUp.IsNull() && data.EnableTrapsVrfmibVnetTrunkUp.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/vrfmib/vnet-trunk-up", state.getPath()))
+ }
+ if !state.EnableTrapsVrfmibVrfDown.IsNull() && data.EnableTrapsVrfmibVrfDown.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/vrfmib/vrf-down", state.getPath()))
+ }
+ if !state.EnableTrapsVrfmibVrfUp.IsNull() && data.EnableTrapsVrfmibVrfUp.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/vrfmib/vrf-up", state.getPath()))
+ }
+ if !state.EnableTrapsMacNotificationThreshold.IsNull() && data.EnableTrapsMacNotificationThreshold.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/mac-notification/threshold", state.getPath()))
+ }
+ if !state.EnableTrapsMacNotificationMove.IsNull() && data.EnableTrapsMacNotificationMove.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/mac-notification/move", state.getPath()))
+ }
+ if !state.EnableTrapsMacNotificationChange.IsNull() && data.EnableTrapsMacNotificationChange.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/mac-notification/change", state.getPath()))
+ }
+ if !state.EnableTrapsBulkstatTransfer.IsNull() && data.EnableTrapsBulkstatTransfer.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/bulkstat/transfer", state.getPath()))
+ }
+ if !state.EnableTrapsBulkstatCollection.IsNull() && data.EnableTrapsBulkstatCollection.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/bulkstat/collection", state.getPath()))
+ }
+ if !state.EnableTrapsTransceiverAll.IsNull() && data.EnableTrapsTransceiverAll.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/transceiver/all", state.getPath()))
+ }
+ if !state.EnableTrapsRf.IsNull() && data.EnableTrapsRf.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/rf", state.getPath()))
+ }
+ if !state.EnableTrapsErrdisable.IsNull() && data.EnableTrapsErrdisable.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/errdisable", state.getPath()))
+ }
+ if !state.EnableTrapsVlanMembership.IsNull() && data.EnableTrapsVlanMembership.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/vlan-membership", state.getPath()))
+ }
+ if !state.EnableTrapsLocalAuth.IsNull() && data.EnableTrapsLocalAuth.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/local-auth", state.getPath()))
+ }
+ if !state.EnableTrapsFastRerouteProtected.IsNull() && data.EnableTrapsFastRerouteProtected.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/mpls/fast-reroute/protected", state.getPath()))
+ }
+ if !state.EnableTrapsMplsLdp.IsNull() && data.EnableTrapsMplsLdp.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/mpls/ldp", state.getPath()))
+ }
+ if !state.EnableTrapsMplsRfcLdp.IsNull() && data.EnableTrapsMplsRfcLdp.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/mpls/rfc/ldp", state.getPath()))
+ }
+ if !state.EnableTrapsMplsRfc.IsNull() && data.EnableTrapsMplsRfc.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/mpls/rfc", state.getPath()))
+ }
+ if !state.EnableTrapsMplsVpn.IsNull() && data.EnableTrapsMplsVpn.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/mpls/vpn", state.getPath()))
+ }
+ if !state.EnableTrapsMpls.IsNull() && data.EnableTrapsMpls.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/mpls", state.getPath()))
+ }
+ if !state.EnableTrapsMplsTrafficEng.IsNull() && data.EnableTrapsMplsTrafficEng.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/mpls/traffic-eng", state.getPath()))
+ }
+ if !state.EnableTrapsNhrpQuotaExceeded.IsNull() && data.EnableTrapsNhrpQuotaExceeded.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/nhrp/quota-exceeded", state.getPath()))
+ }
+ if !state.EnableTrapsNhrpNhp.IsNull() && data.EnableTrapsNhrpNhp.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/nhrp/nhp", state.getPath()))
+ }
+ if !state.EnableTrapsNhrpNhc.IsNull() && data.EnableTrapsNhrpNhc.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/nhrp/nhc", state.getPath()))
+ }
+ if !state.EnableTrapsNhrpNhs.IsNull() && data.EnableTrapsNhrpNhs.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/nhrp/nhs", state.getPath()))
+ }
+ if !state.EnableTrapsBgpCbgp2.IsNull() && data.EnableTrapsBgpCbgp2.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/Cisco-IOS-XE-bgp:bgp/cbgp2", state.getPath()))
+ }
+ if !state.EnableTrapsSyslog.IsNull() && data.EnableTrapsSyslog.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/syslog", state.getPath()))
+ }
+ if !state.EnableTrapsStpxLoopInconsistency.IsNull() && data.EnableTrapsStpxLoopInconsistency.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/stpx", state.getPath()))
+ }
+ if !state.EnableTrapsStpxRootInconsistency.IsNull() && data.EnableTrapsStpxRootInconsistency.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/stpx", state.getPath()))
+ }
+ if !state.EnableTrapsStpxInconsistency.IsNull() && data.EnableTrapsStpxInconsistency.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/stpx/inconsistency", state.getPath()))
+ }
+ if !state.EnableTrapsBridgeTopologychange.IsNull() && data.EnableTrapsBridgeTopologychange.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/bridge/topologychange", state.getPath()))
+ }
+ if !state.EnableTrapsBridgeNewroot.IsNull() && data.EnableTrapsBridgeNewroot.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/bridge/newroot", state.getPath()))
+ }
+ if !state.EnableTrapsPimRpMappingChange.IsNull() && data.EnableTrapsPimRpMappingChange.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/pim/rp-mapping-change", state.getPath()))
+ }
+ if !state.EnableTrapsPimNeighborChange.IsNull() && data.EnableTrapsPimNeighborChange.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/pim/neighbor-change", state.getPath()))
+ }
+ if !state.EnableTrapsPimInvalidPimMessage.IsNull() && data.EnableTrapsPimInvalidPimMessage.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/pim/invalid-pim-message", state.getPath()))
+ }
+ if !state.EnableTrapsOspfConfigErrors.IsNull() && data.EnableTrapsOspfConfigErrors.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/Cisco-IOS-XE-ospf:ospf-config/errors/enable", state.getPath()))
+ }
+ if !state.EnableTrapsOspfConfigStateChange.IsNull() && data.EnableTrapsOspfConfigStateChange.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/Cisco-IOS-XE-ospf:ospf-config/state-change/enable", state.getPath()))
+ }
+ if !state.EnableTrapsMsdp.IsNull() && data.EnableTrapsMsdp.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/msdp", state.getPath()))
+ }
+ if !state.EnableTrapsIpmulticast.IsNull() && data.EnableTrapsIpmulticast.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ipmulticast", state.getPath()))
+ }
+ if !state.EnableTrapsHsrp.IsNull() && data.EnableTrapsHsrp.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/hsrp", state.getPath()))
+ }
+ if !state.EnableTrapsEventManager.IsNull() && data.EnableTrapsEventManager.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/event-manager", state.getPath()))
+ }
+ if !state.EnableTrapsDhcp.IsNull() && data.EnableTrapsDhcp.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/dhcp", state.getPath()))
+ }
+ if !state.EnableTrapsConfigCtid.IsNull() && data.EnableTrapsConfigCtid.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/config-ctid", state.getPath()))
+ }
+ if !state.EnableTrapsConfig.IsNull() && data.EnableTrapsConfig.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/config", state.getPath()))
+ }
+ if !state.EnableTrapsConfigCopy.IsNull() && data.EnableTrapsConfigCopy.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/config-copy", state.getPath()))
+ }
+ if !state.EnableTrapsIpsecTooManySas.IsNull() && data.EnableTrapsIpsecTooManySas.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ipsec/too-many-sas", state.getPath()))
+ }
+ if !state.EnableTrapsIpsecTunnelStop.IsNull() && data.EnableTrapsIpsecTunnelStop.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ipsec/tunnel/stop", state.getPath()))
+ }
+ if !state.EnableTrapsIpsecTunnelStart.IsNull() && data.EnableTrapsIpsecTunnelStart.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ipsec/tunnel/start", state.getPath()))
+ }
+ if !state.EnableTrapsIpsecCryptomapDetach.IsNull() && data.EnableTrapsIpsecCryptomapDetach.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ipsec/cryptomap/detach", state.getPath()))
+ }
+ if !state.EnableTrapsIpsecCryptomapDelete.IsNull() && data.EnableTrapsIpsecCryptomapDelete.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ipsec/cryptomap/delete", state.getPath()))
+ }
+ if !state.EnableTrapsIpsecCryptomapAttach.IsNull() && data.EnableTrapsIpsecCryptomapAttach.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ipsec/cryptomap/attach", state.getPath()))
+ }
+ if !state.EnableTrapsIpsecCryptomapAdd.IsNull() && data.EnableTrapsIpsecCryptomapAdd.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ipsec/cryptomap/add", state.getPath()))
+ }
+ if !state.EnableTrapsIkeTunnelStop.IsNull() && data.EnableTrapsIkeTunnelStop.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ike/tunnel/stop", state.getPath()))
+ }
+ if !state.EnableTrapsIkeTunnelStart.IsNull() && data.EnableTrapsIkeTunnelStart.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ike/tunnel/start", state.getPath()))
+ }
+ if !state.EnableTrapsIkePolicyDelete.IsNull() && data.EnableTrapsIkePolicyDelete.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ike/policy/delete", state.getPath()))
+ }
+ if !state.EnableTrapsIkePolicyAdd.IsNull() && data.EnableTrapsIkePolicyAdd.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ike/policy/add", state.getPath()))
+ }
+ if !state.EnableTrapsBfd.IsNull() && data.EnableTrapsBfd.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/bfd", state.getPath()))
+ }
+ if !state.EnableTrapsEntityDiagScheduledTestFail.IsNull() && data.EnableTrapsEntityDiagScheduledTestFail.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/entity-diag/scheduled-test-fail", state.getPath()))
+ }
+ if !state.EnableTrapsEntityDiagHmThreshReached.IsNull() && data.EnableTrapsEntityDiagHmThreshReached.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/entity-diag/hm-thresh-reached", state.getPath()))
+ }
+ if !state.EnableTrapsEntityDiagHmTestRecover.IsNull() && data.EnableTrapsEntityDiagHmTestRecover.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/entity-diag/hm-test-recover", state.getPath()))
+ }
+ if !state.EnableTrapsEntityDiagBootUpFail.IsNull() && data.EnableTrapsEntityDiagBootUpFail.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/entity-diag/boot-up-fail", state.getPath()))
+ }
+ if !state.EnableTrapsIpsla.IsNull() && data.EnableTrapsIpsla.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ipsla", state.getPath()))
+ }
+ if !state.EnableTrapsIsis.IsNull() && data.EnableTrapsIsis.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/isis", state.getPath()))
+ }
+ if !state.EnableTrapsCefInconsistency.IsNull() && data.EnableTrapsCefInconsistency.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/cef/inconsistency", state.getPath()))
+ }
+ if !state.EnableTrapsCefPeerFibStateChange.IsNull() && data.EnableTrapsCefPeerFibStateChange.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/cef/peer-fib-state-change", state.getPath()))
+ }
+ if !state.EnableTrapsCefPeerStateChange.IsNull() && data.EnableTrapsCefPeerStateChange.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/cef/peer-state-change", state.getPath()))
+ }
+ if !state.EnableTrapsCefResourceFailure.IsNull() && data.EnableTrapsCefResourceFailure.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/cef/resource-failure", state.getPath()))
+ }
+ if !state.EnableTrapsEnvmon.IsNull() && data.EnableTrapsEnvmon.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/envmon", state.getPath()))
+ }
+ if !state.EnableTrapsPwVc.IsNull() && data.EnableTrapsPwVc.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/pw", state.getPath()))
+ }
+ if !state.EnableTrapsEntity.IsNull() && data.EnableTrapsEntity.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/entity", state.getPath()))
+ }
+ if !state.EnableTrapsPowerEthernetPolice.IsNull() && data.EnableTrapsPowerEthernetPolice.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/power-ethernet/police", state.getPath()))
+ }
+ if !state.EnableTrapsPowerEthernetGroup.IsNull() && data.EnableTrapsPowerEthernetGroup.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/power-ethernet/group", state.getPath()))
+ }
+ if !state.EnableTrapsEnergywise.IsNull() && data.EnableTrapsEnergywise.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/energywise", state.getPath()))
+ }
+ if !state.EnableTrapsFlashLowspace.IsNull() && data.EnableTrapsFlashLowspace.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/flash/lowspace", state.getPath()))
+ }
+ if !state.EnableTrapsFlashRemoval.IsNull() && data.EnableTrapsFlashRemoval.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/flash/removal", state.getPath()))
+ }
+ if !state.EnableTrapsFlashInsertion.IsNull() && data.EnableTrapsFlashInsertion.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/flash/insertion", state.getPath()))
+ }
+ if !state.EnableTrapsFruCtrl.IsNull() && data.EnableTrapsFruCtrl.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/fru-ctrl", state.getPath()))
+ }
+ if !state.EnableTrapsUdldStatusChange.IsNull() && data.EnableTrapsUdldStatusChange.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/udld/status-change", state.getPath()))
+ }
+ if !state.EnableTrapsUdldLinkFailRpt.IsNull() && data.EnableTrapsUdldLinkFailRpt.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/udld/link-fail-rpt", state.getPath()))
+ }
+ if !state.EnableTrapsStackwise.IsNull() && data.EnableTrapsStackwise.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/stackwise", state.getPath()))
+ }
+ if !state.EnableTrapsMemoryBufferpeak.IsNull() && data.EnableTrapsMemoryBufferpeak.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/memory/bufferpeak", state.getPath()))
+ }
+ if !state.EnableTrapsCpuThreshold.IsNull() && data.EnableTrapsCpuThreshold.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/cpu/threshold", state.getPath()))
+ }
+ if !state.EnableTrapsSmartLicense.IsNull() && data.EnableTrapsSmartLicense.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/smart-licenseing/smart-license", state.getPath()))
+ }
+ if !state.EnableTrapsLicense.IsNull() && data.EnableTrapsLicense.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/license", state.getPath()))
+ }
+ if !state.EnableTrapsPortSecurity.IsNull() && data.EnableTrapsPortSecurity.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/port-security", state.getPath()))
+ }
+ if !state.EnableTrapsVlandelete.IsNull() && data.EnableTrapsVlandelete.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/vlandelete", state.getPath()))
+ }
+ if !state.EnableTrapsVlancreate.IsNull() && data.EnableTrapsVlancreate.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/vlancreate", state.getPath()))
+ }
+ if !state.EnableTrapsVtp.IsNull() && data.EnableTrapsVtp.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/vtp", state.getPath()))
+ }
+ if !state.EnableTrapsRep.IsNull() && data.EnableTrapsRep.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/rep", state.getPath()))
+ }
+ if !state.EnableTrapsAuthFrameworkSecViolation.IsNull() && data.EnableTrapsAuthFrameworkSecViolation.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/auth-framework/sec-violation", state.getPath()))
+ }
+ if !state.EnableTrapsEigrp.IsNull() && data.EnableTrapsEigrp.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/eigrp", state.getPath()))
+ }
+ if !state.EnableTrapsOspfLsaEnable.IsNull() && data.EnableTrapsOspfLsaEnable.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/Cisco-IOS-XE-ospf:ospf-config/cisco-specific/lsa/enable", state.getPath()))
+ }
+ if !state.EnableTrapsOspfRetransmitEnable.IsNull() && data.EnableTrapsOspfRetransmitEnable.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/Cisco-IOS-XE-ospf:ospf-config/cisco-specific/retransmit/enable", state.getPath()))
+ }
+ if !state.EnableTrapsOspfErrorsEnable.IsNull() && data.EnableTrapsOspfErrorsEnable.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/Cisco-IOS-XE-ospf:ospf-config/cisco-specific/errors/enable", state.getPath()))
+ }
+ if !state.EnableTrapsOspfShamlinkNeighbor.IsNull() && data.EnableTrapsOspfShamlinkNeighbor.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/Cisco-IOS-XE-ospf:ospf-config/cisco-specific/state-change/shamlink/neighbor", state.getPath()))
+ }
+ if !state.EnableTrapsOspfShamlinkInterface.IsNull() && data.EnableTrapsOspfShamlinkInterface.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/Cisco-IOS-XE-ospf:ospf-config/cisco-specific/state-change/shamlink/interface", state.getPath()))
+ }
+ if !state.EnableTrapsOspfNssaTransChange.IsNull() && data.EnableTrapsOspfNssaTransChange.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/Cisco-IOS-XE-ospf:ospf-config/cisco-specific/state-change/nssa-trans-change", state.getPath()))
+ }
+ if !state.EnableTrapsOspfConfigLsa.IsNull() && data.EnableTrapsOspfConfigLsa.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/Cisco-IOS-XE-ospf:ospf-config/lsa/enable", state.getPath()))
+ }
+ if !state.EnableTrapsOspfConfigRetransmit.IsNull() && data.EnableTrapsOspfConfigRetransmit.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/Cisco-IOS-XE-ospf:ospf-config/retransmit/enable", state.getPath()))
+ }
+ if !state.EnableTrapsOspfv3ConfigErrors.IsNull() && data.EnableTrapsOspfv3ConfigErrors.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/Cisco-IOS-XE-ospfv3:ospfv3-config/errors/enable", state.getPath()))
+ }
+ if !state.EnableTrapsOspfv3ConfigStateChange.IsNull() && data.EnableTrapsOspfv3ConfigStateChange.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/Cisco-IOS-XE-ospfv3:ospfv3-config/state-change/enable", state.getPath()))
+ }
+ if !state.EnableTrapsTty.IsNull() && data.EnableTrapsTty.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/tty", state.getPath()))
+ }
+ if !state.EnableTrapsCallHomeServerFail.IsNull() && data.EnableTrapsCallHomeServerFail.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/call-home/server-fail", state.getPath()))
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:user.names"); value.Exists() {
- data.Users = make([]SNMPServerUsers, 0)
- value.ForEach(func(k, v gjson.Result) bool {
- item := SNMPServerUsers{}
- if cValue := v.Get("username"); cValue.Exists() {
- item.Username = types.StringValue(cValue.String())
- }
- if cValue := v.Get("grpname"); cValue.Exists() {
- item.Grpname = types.StringValue(cValue.String())
- }
- if cValue := v.Get("v3.auth-config.algorithm"); cValue.Exists() {
- item.V3AuthAlgorithm = types.StringValue(cValue.String())
- }
- if cValue := v.Get("v3.auth-config.password"); cValue.Exists() {
- item.V3AuthPassword = types.StringValue(cValue.String())
- }
- if cValue := v.Get("v3.auth-config.priv-config.aes.algorithm"); cValue.Exists() {
- item.V3AuthPrivAesAlgorithm = types.StringValue(cValue.String())
- }
- if cValue := v.Get("v3.auth-config.priv-config.aes.password"); cValue.Exists() {
- item.V3AuthPrivAesPassword = types.StringValue(cValue.String())
- }
- if cValue := v.Get("v3.auth-config.priv-config.aes.access-config.ipv6-acl"); cValue.Exists() {
- item.V3AuthPrivAesAccessIpv6Acl = types.StringValue(cValue.String())
- }
- if cValue := v.Get("v3.auth-config.priv-config.aes.access-config.standard-acl"); cValue.Exists() {
- item.V3AuthPrivAesAccessStandardAcl = types.Int64Value(cValue.Int())
- }
- if cValue := v.Get("v3.auth-config.priv-config.aes.access-config.acl-name"); cValue.Exists() {
- item.V3AuthPrivAesAccessAclName = types.StringValue(cValue.String())
- }
- if cValue := v.Get("v3.auth-config.priv-config.des.password"); cValue.Exists() {
- item.V3AuthPrivDesPassword = types.StringValue(cValue.String())
- }
- if cValue := v.Get("v3.auth-config.priv-config.des.access-config.ipv6-acl"); cValue.Exists() {
- item.V3AuthPrivDesAccessIpv6Acl = types.StringValue(cValue.String())
- }
- if cValue := v.Get("v3.auth-config.priv-config.des.access-config.standard-acl"); cValue.Exists() {
- item.V3AuthPrivDesAccessStandardAcl = types.Int64Value(cValue.Int())
- }
- if cValue := v.Get("v3.auth-config.priv-config.des.access-config.acl-name"); cValue.Exists() {
- item.V3AuthPrivDesAccessAclName = types.StringValue(cValue.String())
- }
- if cValue := v.Get("v3.auth-config.priv-config.des3.password"); cValue.Exists() {
- item.V3AuthPrivDes3Password = types.StringValue(cValue.String())
- }
- if cValue := v.Get("v3.auth-config.priv-config.des3.access-config.ipv6-acl"); cValue.Exists() {
- item.V3AuthPrivDes3AccessIpv6Acl = types.StringValue(cValue.String())
- }
- if cValue := v.Get("v3.auth-config.priv-config.des3.access-config.standard-acl"); cValue.Exists() {
- item.V3AuthPrivDes3AccessStandardAcl = types.Int64Value(cValue.Int())
- }
- if cValue := v.Get("v3.auth-config.priv-config.des3.access-config.acl-name"); cValue.Exists() {
- item.V3AuthPrivDes3AccessAclName = types.StringValue(cValue.String())
- }
- if cValue := v.Get("v3.auth-config.access-config.ipv6-acl"); cValue.Exists() {
- item.V3AuthAccessIpv6Acl = types.StringValue(cValue.String())
+ if !state.EnableTrapsCallHomeMessageSendFail.IsNull() && data.EnableTrapsCallHomeMessageSendFail.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/call-home/message-send-fail", state.getPath()))
+ }
+ if !state.EnableTrapsEntityPerfThroughputNotif.IsNull() && data.EnableTrapsEntityPerfThroughputNotif.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/entity-perf/throughput-notif", state.getPath()))
+ }
+ if !state.EnableTrapsFlowmon.IsNull() && data.EnableTrapsFlowmon.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/flowmon", state.getPath()))
+ }
+ if !state.SystemShutdown.IsNull() && data.SystemShutdown.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:system-shutdown", state.getPath()))
+ }
+ for i := range state.VrfHosts {
+ stateKeyValues := [...]string{state.VrfHosts[i].IpAddress.ValueString(), state.VrfHosts[i].Vrf.ValueString()}
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.VrfHosts[i].IpAddress.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if !reflect.ValueOf(state.VrfHosts[i].Vrf.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.VrfHosts {
+ found = true
+ if state.VrfHosts[i].IpAddress.ValueString() != data.VrfHosts[j].IpAddress.ValueString() {
+ found = false
}
- if cValue := v.Get("v3.auth-config.access-config.standard-acl"); cValue.Exists() {
- item.V3AuthAccessStandardAcl = types.Int64Value(cValue.Int())
+ if state.VrfHosts[i].Vrf.ValueString() != data.VrfHosts[j].Vrf.ValueString() {
+ found = false
}
- if cValue := v.Get("v3.auth-config.access-config.acl-name"); cValue.Exists() {
- item.V3AuthAccessAclName = types.StringValue(cValue.String())
+ if found {
+ if !state.VrfHosts[i].SecurityLevel.IsNull() && data.VrfHosts[j].SecurityLevel.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:host-config/ip-vrf-community=%v/security-level", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ if !state.VrfHosts[i].Encryption.IsNull() && data.VrfHosts[j].Encryption.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:host-config/ip-vrf-community=%v/encryption", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ if !state.VrfHosts[i].Version.IsNull() && data.VrfHosts[j].Version.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:host-config/ip-vrf-community=%v/version", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ if !state.VrfHosts[i].CommunityOrUser.IsNull() && data.VrfHosts[j].CommunityOrUser.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:host-config/ip-vrf-community=%v/community-or-user", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ break
}
- data.Users = append(data.Users, item)
- return true
- })
+ }
+ if !found {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:host-config/ip-vrf-community=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
}
-}
-
-// End of section. //template:end fromBody
+ for i := range state.Hosts {
+ stateKeyValues := [...]string{state.Hosts[i].IpAddress.ValueString()}
-// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyData
+ emptyKeys := true
+ if !reflect.ValueOf(state.Hosts[i].IpAddress.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
-func (data *SNMPServerData) fromBody(ctx context.Context, res gjson.Result) {
- prefix := helpers.LastElement(data.getPath()) + "."
- if res.Get(helpers.LastElement(data.getPath())).IsArray() {
- prefix += "0."
+ found := false
+ for j := range data.Hosts {
+ found = true
+ if state.Hosts[i].IpAddress.ValueString() != data.Hosts[j].IpAddress.ValueString() {
+ found = false
+ }
+ if found {
+ if !state.Hosts[i].SecurityLevel.IsNull() && data.Hosts[j].SecurityLevel.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:host-config/ip-community=%v/security-level", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ if !state.Hosts[i].Encryption.IsNull() && data.Hosts[j].Encryption.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:host-config/ip-community=%v/encryption", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ if !state.Hosts[i].Version.IsNull() && data.Hosts[j].Version.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:host-config/ip-community=%v/version", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ if !state.Hosts[i].CommunityOrUser.IsNull() && data.Hosts[j].CommunityOrUser.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:host-config/ip-community=%v/community-or-user", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ break
+ }
+ }
+ if !found {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:host-config/ip-community=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:chassis-id"); value.Exists() {
- data.ChassisId = types.StringValue(value.String())
+ if !state.EnableTrapsSnmpWarmstart.IsNull() && data.EnableTrapsSnmpWarmstart.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/snmp/warmstart", state.getPath()))
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:contact"); value.Exists() {
- data.Contact = types.StringValue(value.String())
+ if !state.EnableTrapsSnmpLinkup.IsNull() && data.EnableTrapsSnmpLinkup.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/snmp/linkup", state.getPath()))
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:ifindex.persist"); value.Exists() {
- data.IfindexPersist = types.BoolValue(true)
- } else {
- data.IfindexPersist = types.BoolValue(false)
+ if !state.EnableTrapsSnmpLinkdown.IsNull() && data.EnableTrapsSnmpLinkdown.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/snmp/linkdown", state.getPath()))
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:location"); value.Exists() {
- data.Location = types.StringValue(value.String())
+ if !state.EnableTrapsSnmpColdstart.IsNull() && data.EnableTrapsSnmpColdstart.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/snmp/coldstart", state.getPath()))
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:packetsize"); value.Exists() {
- data.Packetsize = types.Int64Value(value.Int())
+ if !state.EnableTrapsSnmpAuthentication.IsNull() && data.EnableTrapsSnmpAuthentication.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/snmp/authentication", state.getPath()))
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:queue-length"); value.Exists() {
- data.QueueLength = types.Int64Value(value.Int())
+ if !state.EnableTraps.IsNull() && data.EnableTraps.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps", state.getPath()))
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.logging.getop"); value.Exists() {
- data.EnableLoggingGetop = types.BoolValue(value.Bool())
- } else {
- data.EnableLoggingGetop = types.BoolNull()
+ if !state.EnableInforms.IsNull() && data.EnableInforms.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/informs", state.getPath()))
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.logging.setop"); value.Exists() {
- data.EnableLoggingSetop = types.BoolValue(value.Bool())
- } else {
- data.EnableLoggingSetop = types.BoolNull()
+ if !state.EnableLoggingSetop.IsNull() && data.EnableLoggingSetop.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/logging/setop", state.getPath()))
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.informs"); value.Exists() {
- data.EnableInforms = types.BoolValue(true)
- } else {
- data.EnableInforms = types.BoolValue(false)
+ if !state.EnableLoggingGetop.IsNull() && data.EnableLoggingGetop.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/logging/getop", state.getPath()))
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps"); value.Exists() {
- data.EnableTraps = types.BoolValue(true)
- } else {
- data.EnableTraps = types.BoolValue(false)
+ if !state.QueueLength.IsNull() && data.QueueLength.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:queue-length", state.getPath()))
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.snmp.authentication"); value.Exists() {
- data.EnableTrapsSnmpAuthentication = types.BoolValue(true)
- } else {
- data.EnableTrapsSnmpAuthentication = types.BoolValue(false)
+ if !state.Packetsize.IsNull() && data.Packetsize.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:packetsize", state.getPath()))
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.snmp.coldstart"); value.Exists() {
- data.EnableTrapsSnmpColdstart = types.BoolValue(true)
- } else {
- data.EnableTrapsSnmpColdstart = types.BoolValue(false)
+ if !state.Location.IsNull() && data.Location.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:location", state.getPath()))
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.snmp.linkdown"); value.Exists() {
- data.EnableTrapsSnmpLinkdown = types.BoolValue(true)
- } else {
- data.EnableTrapsSnmpLinkdown = types.BoolValue(false)
+ if !state.IfindexPersist.IsNull() && data.IfindexPersist.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:ifindex/persist", state.getPath()))
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.snmp.linkup"); value.Exists() {
- data.EnableTrapsSnmpLinkup = types.BoolValue(true)
- } else {
- data.EnableTrapsSnmpLinkup = types.BoolValue(false)
+ if !state.Contact.IsNull() && data.Contact.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:contact", state.getPath()))
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.snmp.warmstart"); value.Exists() {
- data.EnableTrapsSnmpWarmstart = types.BoolValue(true)
- } else {
- data.EnableTrapsSnmpWarmstart = types.BoolValue(false)
+ if !state.ChassisId.IsNull() && data.ChassisId.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:chassis-id", state.getPath()))
+ }
+
+ return deletedItems
+}
+
+// End of section. //template:end getDeletedItems
+
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletedItemsXML
+
+func (data *SNMPServer) addDeletedItemsXML(ctx context.Context, state SNMPServer, body string) string {
+ b := netconf.NewBody(body)
+ if !state.ChassisId.IsNull() && data.ChassisId.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:chassis-id")
+ }
+ if !state.Contact.IsNull() && data.Contact.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:contact")
+ }
+ if !state.IfindexPersist.IsNull() && data.IfindexPersist.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:ifindex/persist")
+ }
+ if !state.Location.IsNull() && data.Location.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:location")
+ }
+ if !state.Packetsize.IsNull() && data.Packetsize.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:packetsize")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:host-config.ip-community"); value.Exists() {
- data.Hosts = make([]SNMPServerHosts, 0)
- value.ForEach(func(k, v gjson.Result) bool {
- item := SNMPServerHosts{}
- if cValue := v.Get("ip-address"); cValue.Exists() {
- item.IpAddress = types.StringValue(cValue.String())
- }
- if cValue := v.Get("community-or-user"); cValue.Exists() {
- item.CommunityOrUser = types.StringValue(cValue.String())
- }
- if cValue := v.Get("version"); cValue.Exists() {
- item.Version = types.StringValue(cValue.String())
- }
- if cValue := v.Get("encryption"); cValue.Exists() {
- item.Encryption = types.StringValue(cValue.String())
- }
- if cValue := v.Get("security-level"); cValue.Exists() {
- item.SecurityLevel = types.StringValue(cValue.String())
- }
- data.Hosts = append(data.Hosts, item)
- return true
- })
+ if !state.QueueLength.IsNull() && data.QueueLength.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:queue-length")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:host-config.ip-vrf-community"); value.Exists() {
- data.VrfHosts = make([]SNMPServerVrfHosts, 0)
- value.ForEach(func(k, v gjson.Result) bool {
- item := SNMPServerVrfHosts{}
- if cValue := v.Get("ip-address"); cValue.Exists() {
- item.IpAddress = types.StringValue(cValue.String())
- }
- if cValue := v.Get("vrf"); cValue.Exists() {
- item.Vrf = types.StringValue(cValue.String())
- }
- if cValue := v.Get("community-or-user"); cValue.Exists() {
- item.CommunityOrUser = types.StringValue(cValue.String())
- }
- if cValue := v.Get("version"); cValue.Exists() {
- item.Version = types.StringValue(cValue.String())
- }
- if cValue := v.Get("encryption"); cValue.Exists() {
- item.Encryption = types.StringValue(cValue.String())
- }
- if cValue := v.Get("security-level"); cValue.Exists() {
- item.SecurityLevel = types.StringValue(cValue.String())
- }
- data.VrfHosts = append(data.VrfHosts, item)
- return true
- })
+ if !state.EnableLoggingGetop.IsNull() && data.EnableLoggingGetop.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/logging/getop")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:system-shutdown"); value.Exists() {
- data.SystemShutdown = types.BoolValue(true)
- } else {
- data.SystemShutdown = types.BoolValue(false)
+ if !state.EnableLoggingSetop.IsNull() && data.EnableLoggingSetop.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/logging/setop")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.flowmon"); value.Exists() {
- data.EnableTrapsFlowmon = types.BoolValue(true)
- } else {
- data.EnableTrapsFlowmon = types.BoolValue(false)
+ if !state.EnableInforms.IsNull() && data.EnableInforms.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/informs")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.entity-perf.throughput-notif"); value.Exists() {
- data.EnableTrapsEntityPerfThroughputNotif = types.BoolValue(true)
- } else {
- data.EnableTrapsEntityPerfThroughputNotif = types.BoolValue(false)
+ if !state.EnableTraps.IsNull() && data.EnableTraps.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.call-home.message-send-fail"); value.Exists() {
- data.EnableTrapsCallHomeMessageSendFail = types.BoolValue(true)
- } else {
- data.EnableTrapsCallHomeMessageSendFail = types.BoolValue(false)
+ if !state.EnableTrapsSnmpAuthentication.IsNull() && data.EnableTrapsSnmpAuthentication.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/snmp/authentication")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.call-home.server-fail"); value.Exists() {
- data.EnableTrapsCallHomeServerFail = types.BoolValue(true)
- } else {
- data.EnableTrapsCallHomeServerFail = types.BoolValue(false)
+ if !state.EnableTrapsSnmpColdstart.IsNull() && data.EnableTrapsSnmpColdstart.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/snmp/coldstart")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.tty"); value.Exists() {
- data.EnableTrapsTty = types.BoolValue(true)
- } else {
- data.EnableTrapsTty = types.BoolValue(false)
+ if !state.EnableTrapsSnmpLinkdown.IsNull() && data.EnableTrapsSnmpLinkdown.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/snmp/linkdown")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.Cisco-IOS-XE-ospfv3:ospfv3-config.state-change.enable"); value.Exists() {
- data.EnableTrapsOspfv3ConfigStateChange = types.BoolValue(true)
- } else {
- data.EnableTrapsOspfv3ConfigStateChange = types.BoolValue(false)
+ if !state.EnableTrapsSnmpLinkup.IsNull() && data.EnableTrapsSnmpLinkup.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/snmp/linkup")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.Cisco-IOS-XE-ospfv3:ospfv3-config.errors.enable"); value.Exists() {
- data.EnableTrapsOspfv3ConfigErrors = types.BoolValue(true)
- } else {
- data.EnableTrapsOspfv3ConfigErrors = types.BoolValue(false)
+ if !state.EnableTrapsSnmpWarmstart.IsNull() && data.EnableTrapsSnmpWarmstart.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/snmp/warmstart")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.Cisco-IOS-XE-ospf:ospf-config.retransmit.enable"); value.Exists() {
- data.EnableTrapsOspfConfigRetransmit = types.BoolValue(true)
- } else {
- data.EnableTrapsOspfConfigRetransmit = types.BoolValue(false)
+ for i := range state.Hosts {
+ stateKeys := [...]string{"ip-address"}
+ stateKeyValues := [...]string{state.Hosts[i].IpAddress.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.Hosts[i].IpAddress.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.Hosts {
+ found = true
+ if state.Hosts[i].IpAddress.ValueString() != data.Hosts[j].IpAddress.ValueString() {
+ found = false
+ }
+ if found {
+ if !state.Hosts[i].CommunityOrUser.IsNull() && data.Hosts[j].CommunityOrUser.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-snmp:host-config/ip-community%v/community-or-user", predicates))
+ }
+ if !state.Hosts[i].Version.IsNull() && data.Hosts[j].Version.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-snmp:host-config/ip-community%v/version", predicates))
+ }
+ if !state.Hosts[i].Encryption.IsNull() && data.Hosts[j].Encryption.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-snmp:host-config/ip-community%v/encryption", predicates))
+ }
+ if !state.Hosts[i].SecurityLevel.IsNull() && data.Hosts[j].SecurityLevel.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-snmp:host-config/ip-community%v/security-level", predicates))
+ }
+ break
+ }
+ }
+ if !found {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-snmp:host-config/ip-community%v", predicates))
+ }
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.Cisco-IOS-XE-ospf:ospf-config.lsa.enable"); value.Exists() {
- data.EnableTrapsOspfConfigLsa = types.BoolValue(true)
- } else {
- data.EnableTrapsOspfConfigLsa = types.BoolValue(false)
+ for i := range state.VrfHosts {
+ stateKeys := [...]string{"ip-address", "vrf"}
+ stateKeyValues := [...]string{state.VrfHosts[i].IpAddress.ValueString(), state.VrfHosts[i].Vrf.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.VrfHosts[i].IpAddress.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if !reflect.ValueOf(state.VrfHosts[i].Vrf.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.VrfHosts {
+ found = true
+ if state.VrfHosts[i].IpAddress.ValueString() != data.VrfHosts[j].IpAddress.ValueString() {
+ found = false
+ }
+ if state.VrfHosts[i].Vrf.ValueString() != data.VrfHosts[j].Vrf.ValueString() {
+ found = false
+ }
+ if found {
+ if !state.VrfHosts[i].CommunityOrUser.IsNull() && data.VrfHosts[j].CommunityOrUser.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-snmp:host-config/ip-vrf-community%v/community-or-user", predicates))
+ }
+ if !state.VrfHosts[i].Version.IsNull() && data.VrfHosts[j].Version.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-snmp:host-config/ip-vrf-community%v/version", predicates))
+ }
+ if !state.VrfHosts[i].Encryption.IsNull() && data.VrfHosts[j].Encryption.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-snmp:host-config/ip-vrf-community%v/encryption", predicates))
+ }
+ if !state.VrfHosts[i].SecurityLevel.IsNull() && data.VrfHosts[j].SecurityLevel.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-snmp:host-config/ip-vrf-community%v/security-level", predicates))
+ }
+ break
+ }
+ }
+ if !found {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-snmp:host-config/ip-vrf-community%v", predicates))
+ }
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.Cisco-IOS-XE-ospf:ospf-config.cisco-specific.state-change.nssa-trans-change"); value.Exists() {
- data.EnableTrapsOspfNssaTransChange = types.BoolValue(true)
- } else {
- data.EnableTrapsOspfNssaTransChange = types.BoolValue(false)
+ if !state.SystemShutdown.IsNull() && data.SystemShutdown.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:system-shutdown")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.Cisco-IOS-XE-ospf:ospf-config.cisco-specific.state-change.shamlink.interface"); value.Exists() {
- data.EnableTrapsOspfShamlinkInterface = types.BoolValue(true)
- } else {
- data.EnableTrapsOspfShamlinkInterface = types.BoolValue(false)
+ if !state.EnableTrapsFlowmon.IsNull() && data.EnableTrapsFlowmon.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/flowmon")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.Cisco-IOS-XE-ospf:ospf-config.cisco-specific.state-change.shamlink.neighbor"); value.Exists() {
- data.EnableTrapsOspfShamlinkNeighbor = types.BoolValue(true)
- } else {
- data.EnableTrapsOspfShamlinkNeighbor = types.BoolValue(false)
+ if !state.EnableTrapsEntityPerfThroughputNotif.IsNull() && data.EnableTrapsEntityPerfThroughputNotif.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/entity-perf/throughput-notif")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.Cisco-IOS-XE-ospf:ospf-config.cisco-specific.errors.enable"); value.Exists() {
- data.EnableTrapsOspfErrorsEnable = types.BoolValue(true)
- } else {
- data.EnableTrapsOspfErrorsEnable = types.BoolValue(false)
+ if !state.EnableTrapsCallHomeMessageSendFail.IsNull() && data.EnableTrapsCallHomeMessageSendFail.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/call-home/message-send-fail")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.Cisco-IOS-XE-ospf:ospf-config.cisco-specific.retransmit.enable"); value.Exists() {
- data.EnableTrapsOspfRetransmitEnable = types.BoolValue(true)
- } else {
- data.EnableTrapsOspfRetransmitEnable = types.BoolValue(false)
+ if !state.EnableTrapsCallHomeServerFail.IsNull() && data.EnableTrapsCallHomeServerFail.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/call-home/server-fail")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.Cisco-IOS-XE-ospf:ospf-config.cisco-specific.lsa.enable"); value.Exists() {
- data.EnableTrapsOspfLsaEnable = types.BoolValue(true)
- } else {
- data.EnableTrapsOspfLsaEnable = types.BoolValue(false)
+ if !state.EnableTrapsTty.IsNull() && data.EnableTrapsTty.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/tty")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.eigrp"); value.Exists() {
- data.EnableTrapsEigrp = types.BoolValue(true)
- } else {
- data.EnableTrapsEigrp = types.BoolValue(false)
+ if !state.EnableTrapsOspfv3ConfigStateChange.IsNull() && data.EnableTrapsOspfv3ConfigStateChange.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/Cisco-IOS-XE-ospfv3:ospfv3-config/state-change/enable")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.auth-framework.sec-violation"); value.Exists() {
- data.EnableTrapsAuthFrameworkSecViolation = types.BoolValue(true)
- } else {
- data.EnableTrapsAuthFrameworkSecViolation = types.BoolValue(false)
+ if !state.EnableTrapsOspfv3ConfigErrors.IsNull() && data.EnableTrapsOspfv3ConfigErrors.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/Cisco-IOS-XE-ospfv3:ospfv3-config/errors/enable")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.rep"); value.Exists() {
- data.EnableTrapsRep = types.BoolValue(true)
- } else {
- data.EnableTrapsRep = types.BoolValue(false)
+ if !state.EnableTrapsOspfConfigRetransmit.IsNull() && data.EnableTrapsOspfConfigRetransmit.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/Cisco-IOS-XE-ospf:ospf-config/retransmit/enable")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.vtp"); value.Exists() {
- data.EnableTrapsVtp = types.BoolValue(true)
- } else {
- data.EnableTrapsVtp = types.BoolValue(false)
+ if !state.EnableTrapsOspfConfigLsa.IsNull() && data.EnableTrapsOspfConfigLsa.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/Cisco-IOS-XE-ospf:ospf-config/lsa/enable")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.vlancreate"); value.Exists() {
- data.EnableTrapsVlancreate = types.BoolValue(true)
- } else {
- data.EnableTrapsVlancreate = types.BoolValue(false)
+ if !state.EnableTrapsOspfNssaTransChange.IsNull() && data.EnableTrapsOspfNssaTransChange.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/Cisco-IOS-XE-ospf:ospf-config/cisco-specific/state-change/nssa-trans-change")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.vlandelete"); value.Exists() {
- data.EnableTrapsVlandelete = types.BoolValue(true)
- } else {
- data.EnableTrapsVlandelete = types.BoolValue(false)
+ if !state.EnableTrapsOspfShamlinkInterface.IsNull() && data.EnableTrapsOspfShamlinkInterface.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/Cisco-IOS-XE-ospf:ospf-config/cisco-specific/state-change/shamlink/interface")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.port-security"); value.Exists() {
- data.EnableTrapsPortSecurity = types.BoolValue(true)
- } else {
- data.EnableTrapsPortSecurity = types.BoolValue(false)
+ if !state.EnableTrapsOspfShamlinkNeighbor.IsNull() && data.EnableTrapsOspfShamlinkNeighbor.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/Cisco-IOS-XE-ospf:ospf-config/cisco-specific/state-change/shamlink/neighbor")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.license"); value.Exists() {
- data.EnableTrapsLicense = types.BoolValue(true)
- } else {
- data.EnableTrapsLicense = types.BoolValue(false)
+ if !state.EnableTrapsOspfErrorsEnable.IsNull() && data.EnableTrapsOspfErrorsEnable.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/Cisco-IOS-XE-ospf:ospf-config/cisco-specific/errors/enable")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.smart-licenseing.smart-license"); value.Exists() {
- data.EnableTrapsSmartLicense = types.BoolValue(true)
- } else {
- data.EnableTrapsSmartLicense = types.BoolValue(false)
+ if !state.EnableTrapsOspfRetransmitEnable.IsNull() && data.EnableTrapsOspfRetransmitEnable.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/Cisco-IOS-XE-ospf:ospf-config/cisco-specific/retransmit/enable")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.cpu.threshold"); value.Exists() {
- data.EnableTrapsCpuThreshold = types.BoolValue(true)
- } else {
- data.EnableTrapsCpuThreshold = types.BoolValue(false)
+ if !state.EnableTrapsOspfLsaEnable.IsNull() && data.EnableTrapsOspfLsaEnable.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/Cisco-IOS-XE-ospf:ospf-config/cisco-specific/lsa/enable")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.memory.bufferpeak"); value.Exists() {
- data.EnableTrapsMemoryBufferpeak = types.BoolValue(true)
- } else {
- data.EnableTrapsMemoryBufferpeak = types.BoolValue(false)
+ if !state.EnableTrapsEigrp.IsNull() && data.EnableTrapsEigrp.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/eigrp")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.stackwise"); value.Exists() {
- data.EnableTrapsStackwise = types.BoolValue(true)
- } else {
- data.EnableTrapsStackwise = types.BoolValue(false)
+ if !state.EnableTrapsAuthFrameworkSecViolation.IsNull() && data.EnableTrapsAuthFrameworkSecViolation.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/auth-framework/sec-violation")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.udld.link-fail-rpt"); value.Exists() {
- data.EnableTrapsUdldLinkFailRpt = types.BoolValue(true)
- } else {
- data.EnableTrapsUdldLinkFailRpt = types.BoolValue(false)
+ if !state.EnableTrapsRep.IsNull() && data.EnableTrapsRep.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/rep")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.udld.status-change"); value.Exists() {
- data.EnableTrapsUdldStatusChange = types.BoolValue(true)
- } else {
- data.EnableTrapsUdldStatusChange = types.BoolValue(false)
+ if !state.EnableTrapsVtp.IsNull() && data.EnableTrapsVtp.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/vtp")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.fru-ctrl"); value.Exists() {
- data.EnableTrapsFruCtrl = types.BoolValue(true)
- } else {
- data.EnableTrapsFruCtrl = types.BoolValue(false)
+ if !state.EnableTrapsVlancreate.IsNull() && data.EnableTrapsVlancreate.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/vlancreate")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.flash.insertion"); value.Exists() {
- data.EnableTrapsFlashInsertion = types.BoolValue(true)
- } else {
- data.EnableTrapsFlashInsertion = types.BoolValue(false)
+ if !state.EnableTrapsVlandelete.IsNull() && data.EnableTrapsVlandelete.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/vlandelete")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.flash.removal"); value.Exists() {
- data.EnableTrapsFlashRemoval = types.BoolValue(true)
- } else {
- data.EnableTrapsFlashRemoval = types.BoolValue(false)
+ if !state.EnableTrapsPortSecurity.IsNull() && data.EnableTrapsPortSecurity.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/port-security")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.flash.lowspace"); value.Exists() {
- data.EnableTrapsFlashLowspace = types.BoolValue(true)
- } else {
- data.EnableTrapsFlashLowspace = types.BoolValue(false)
+ if !state.EnableTrapsLicense.IsNull() && data.EnableTrapsLicense.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/license")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.energywise"); value.Exists() {
- data.EnableTrapsEnergywise = types.BoolValue(true)
- } else {
- data.EnableTrapsEnergywise = types.BoolValue(false)
+ if !state.EnableTrapsSmartLicense.IsNull() && data.EnableTrapsSmartLicense.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/smart-licenseing/smart-license")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.power-ethernet.group"); value.Exists() {
- data.EnableTrapsPowerEthernetGroup = types.StringValue(value.String())
+ if !state.EnableTrapsCpuThreshold.IsNull() && data.EnableTrapsCpuThreshold.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/cpu/threshold")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.power-ethernet.police"); value.Exists() {
- data.EnableTrapsPowerEthernetPolice = types.BoolValue(true)
- } else {
- data.EnableTrapsPowerEthernetPolice = types.BoolValue(false)
+ if !state.EnableTrapsMemoryBufferpeak.IsNull() && data.EnableTrapsMemoryBufferpeak.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/memory/bufferpeak")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.entity"); value.Exists() {
- data.EnableTrapsEntity = types.BoolValue(true)
- } else {
- data.EnableTrapsEntity = types.BoolValue(false)
+ if !state.EnableTrapsStackwise.IsNull() && data.EnableTrapsStackwise.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/stackwise")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.pw.vc"); value.Exists() {
- data.EnableTrapsPwVc = types.BoolValue(true)
- } else {
- data.EnableTrapsPwVc = types.BoolValue(false)
+ if !state.EnableTrapsUdldLinkFailRpt.IsNull() && data.EnableTrapsUdldLinkFailRpt.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/udld/link-fail-rpt")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.envmon"); value.Exists() {
- data.EnableTrapsEnvmon = types.BoolValue(true)
- } else {
- data.EnableTrapsEnvmon = types.BoolValue(false)
+ if !state.EnableTrapsUdldStatusChange.IsNull() && data.EnableTrapsUdldStatusChange.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/udld/status-change")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.cef.resource-failure"); value.Exists() {
- data.EnableTrapsCefResourceFailure = types.BoolValue(true)
- } else {
- data.EnableTrapsCefResourceFailure = types.BoolValue(false)
+ if !state.EnableTrapsFruCtrl.IsNull() && data.EnableTrapsFruCtrl.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/fru-ctrl")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.cef.peer-state-change"); value.Exists() {
- data.EnableTrapsCefPeerStateChange = types.BoolValue(true)
- } else {
- data.EnableTrapsCefPeerStateChange = types.BoolValue(false)
+ if !state.EnableTrapsFlashInsertion.IsNull() && data.EnableTrapsFlashInsertion.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/flash/insertion")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.cef.peer-fib-state-change"); value.Exists() {
- data.EnableTrapsCefPeerFibStateChange = types.BoolValue(true)
- } else {
- data.EnableTrapsCefPeerFibStateChange = types.BoolValue(false)
+ if !state.EnableTrapsFlashRemoval.IsNull() && data.EnableTrapsFlashRemoval.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/flash/removal")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.cef.inconsistency"); value.Exists() {
- data.EnableTrapsCefInconsistency = types.BoolValue(true)
- } else {
- data.EnableTrapsCefInconsistency = types.BoolValue(false)
+ if !state.EnableTrapsFlashLowspace.IsNull() && data.EnableTrapsFlashLowspace.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/flash/lowspace")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.isis"); value.Exists() {
- data.EnableTrapsIsis = types.BoolValue(true)
- } else {
- data.EnableTrapsIsis = types.BoolValue(false)
+ if !state.EnableTrapsEnergywise.IsNull() && data.EnableTrapsEnergywise.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/energywise")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ipsla"); value.Exists() {
- data.EnableTrapsIpsla = types.BoolValue(true)
- } else {
- data.EnableTrapsIpsla = types.BoolValue(false)
+ if !state.EnableTrapsPowerEthernetGroup.IsNull() && data.EnableTrapsPowerEthernetGroup.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/power-ethernet/group")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.entity-diag.boot-up-fail"); value.Exists() {
- data.EnableTrapsEntityDiagBootUpFail = types.BoolValue(true)
- } else {
- data.EnableTrapsEntityDiagBootUpFail = types.BoolValue(false)
+ if !state.EnableTrapsPowerEthernetPolice.IsNull() && data.EnableTrapsPowerEthernetPolice.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/power-ethernet/police")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.entity-diag.hm-test-recover"); value.Exists() {
- data.EnableTrapsEntityDiagHmTestRecover = types.BoolValue(true)
- } else {
- data.EnableTrapsEntityDiagHmTestRecover = types.BoolValue(false)
+ if !state.EnableTrapsEntity.IsNull() && data.EnableTrapsEntity.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/entity")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.entity-diag.hm-thresh-reached"); value.Exists() {
- data.EnableTrapsEntityDiagHmThreshReached = types.BoolValue(true)
- } else {
- data.EnableTrapsEntityDiagHmThreshReached = types.BoolValue(false)
+ if !state.EnableTrapsPwVc.IsNull() && data.EnableTrapsPwVc.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/pw/vc")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.entity-diag.scheduled-test-fail"); value.Exists() {
- data.EnableTrapsEntityDiagScheduledTestFail = types.BoolValue(true)
- } else {
- data.EnableTrapsEntityDiagScheduledTestFail = types.BoolValue(false)
+ if !state.EnableTrapsEnvmon.IsNull() && data.EnableTrapsEnvmon.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/envmon")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.bfd"); value.Exists() {
- data.EnableTrapsBfd = types.BoolValue(true)
- } else {
- data.EnableTrapsBfd = types.BoolValue(false)
+ if !state.EnableTrapsCefResourceFailure.IsNull() && data.EnableTrapsCefResourceFailure.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/cef/resource-failure")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ike.policy.add"); value.Exists() {
- data.EnableTrapsIkePolicyAdd = types.BoolValue(true)
- } else {
- data.EnableTrapsIkePolicyAdd = types.BoolValue(false)
+ if !state.EnableTrapsCefPeerStateChange.IsNull() && data.EnableTrapsCefPeerStateChange.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/cef/peer-state-change")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ike.policy.delete"); value.Exists() {
- data.EnableTrapsIkePolicyDelete = types.BoolValue(true)
- } else {
- data.EnableTrapsIkePolicyDelete = types.BoolValue(false)
+ if !state.EnableTrapsCefPeerFibStateChange.IsNull() && data.EnableTrapsCefPeerFibStateChange.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/cef/peer-fib-state-change")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ike.tunnel.start"); value.Exists() {
- data.EnableTrapsIkeTunnelStart = types.BoolValue(true)
- } else {
- data.EnableTrapsIkeTunnelStart = types.BoolValue(false)
+ if !state.EnableTrapsCefInconsistency.IsNull() && data.EnableTrapsCefInconsistency.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/cef/inconsistency")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ike.tunnel.stop"); value.Exists() {
- data.EnableTrapsIkeTunnelStop = types.BoolValue(true)
- } else {
- data.EnableTrapsIkeTunnelStop = types.BoolValue(false)
+ if !state.EnableTrapsIsis.IsNull() && data.EnableTrapsIsis.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/isis")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ipsec.cryptomap.add"); value.Exists() {
- data.EnableTrapsIpsecCryptomapAdd = types.BoolValue(true)
- } else {
- data.EnableTrapsIpsecCryptomapAdd = types.BoolValue(false)
+ if !state.EnableTrapsIpsla.IsNull() && data.EnableTrapsIpsla.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ipsla")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ipsec.cryptomap.attach"); value.Exists() {
- data.EnableTrapsIpsecCryptomapAttach = types.BoolValue(true)
- } else {
- data.EnableTrapsIpsecCryptomapAttach = types.BoolValue(false)
+ if !state.EnableTrapsEntityDiagBootUpFail.IsNull() && data.EnableTrapsEntityDiagBootUpFail.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/entity-diag/boot-up-fail")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ipsec.cryptomap.delete"); value.Exists() {
- data.EnableTrapsIpsecCryptomapDelete = types.BoolValue(true)
- } else {
- data.EnableTrapsIpsecCryptomapDelete = types.BoolValue(false)
+ if !state.EnableTrapsEntityDiagHmTestRecover.IsNull() && data.EnableTrapsEntityDiagHmTestRecover.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/entity-diag/hm-test-recover")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ipsec.cryptomap.detach"); value.Exists() {
- data.EnableTrapsIpsecCryptomapDetach = types.BoolValue(true)
- } else {
- data.EnableTrapsIpsecCryptomapDetach = types.BoolValue(false)
+ if !state.EnableTrapsEntityDiagHmThreshReached.IsNull() && data.EnableTrapsEntityDiagHmThreshReached.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/entity-diag/hm-thresh-reached")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ipsec.tunnel.start"); value.Exists() {
- data.EnableTrapsIpsecTunnelStart = types.BoolValue(true)
- } else {
- data.EnableTrapsIpsecTunnelStart = types.BoolValue(false)
+ if !state.EnableTrapsEntityDiagScheduledTestFail.IsNull() && data.EnableTrapsEntityDiagScheduledTestFail.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/entity-diag/scheduled-test-fail")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ipsec.tunnel.stop"); value.Exists() {
- data.EnableTrapsIpsecTunnelStop = types.BoolValue(true)
- } else {
- data.EnableTrapsIpsecTunnelStop = types.BoolValue(false)
+ if !state.EnableTrapsBfd.IsNull() && data.EnableTrapsBfd.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/bfd")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ipsec.too-many-sas"); value.Exists() {
- data.EnableTrapsIpsecTooManySas = types.BoolValue(true)
- } else {
- data.EnableTrapsIpsecTooManySas = types.BoolValue(false)
+ if !state.EnableTrapsIkePolicyAdd.IsNull() && data.EnableTrapsIkePolicyAdd.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ike/policy/add")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.config-copy"); value.Exists() {
- data.EnableTrapsConfigCopy = types.BoolValue(true)
- } else {
- data.EnableTrapsConfigCopy = types.BoolValue(false)
+ if !state.EnableTrapsIkePolicyDelete.IsNull() && data.EnableTrapsIkePolicyDelete.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ike/policy/delete")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.config"); value.Exists() {
- data.EnableTrapsConfig = types.BoolValue(true)
- } else {
- data.EnableTrapsConfig = types.BoolValue(false)
+ if !state.EnableTrapsIkeTunnelStart.IsNull() && data.EnableTrapsIkeTunnelStart.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ike/tunnel/start")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.config-ctid"); value.Exists() {
- data.EnableTrapsConfigCtid = types.BoolValue(true)
- } else {
- data.EnableTrapsConfigCtid = types.BoolValue(false)
+ if !state.EnableTrapsIkeTunnelStop.IsNull() && data.EnableTrapsIkeTunnelStop.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ike/tunnel/stop")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.dhcp"); value.Exists() {
- data.EnableTrapsDhcp = types.BoolValue(true)
- } else {
- data.EnableTrapsDhcp = types.BoolValue(false)
+ if !state.EnableTrapsIpsecCryptomapAdd.IsNull() && data.EnableTrapsIpsecCryptomapAdd.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ipsec/cryptomap/add")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.event-manager"); value.Exists() {
- data.EnableTrapsEventManager = types.BoolValue(true)
- } else {
- data.EnableTrapsEventManager = types.BoolValue(false)
+ if !state.EnableTrapsIpsecCryptomapAttach.IsNull() && data.EnableTrapsIpsecCryptomapAttach.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ipsec/cryptomap/attach")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.hsrp"); value.Exists() {
- data.EnableTrapsHsrp = types.BoolValue(true)
- } else {
- data.EnableTrapsHsrp = types.BoolValue(false)
+ if !state.EnableTrapsIpsecCryptomapDelete.IsNull() && data.EnableTrapsIpsecCryptomapDelete.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ipsec/cryptomap/delete")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ipmulticast"); value.Exists() {
- data.EnableTrapsIpmulticast = types.BoolValue(true)
- } else {
- data.EnableTrapsIpmulticast = types.BoolValue(false)
+ if !state.EnableTrapsIpsecCryptomapDetach.IsNull() && data.EnableTrapsIpsecCryptomapDetach.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ipsec/cryptomap/detach")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.msdp"); value.Exists() {
- data.EnableTrapsMsdp = types.BoolValue(true)
- } else {
- data.EnableTrapsMsdp = types.BoolValue(false)
+ if !state.EnableTrapsIpsecTunnelStart.IsNull() && data.EnableTrapsIpsecTunnelStart.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ipsec/tunnel/start")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.Cisco-IOS-XE-ospf:ospf-config.state-change.enable"); value.Exists() {
- data.EnableTrapsOspfConfigStateChange = types.BoolValue(true)
- } else {
- data.EnableTrapsOspfConfigStateChange = types.BoolValue(false)
+ if !state.EnableTrapsIpsecTunnelStop.IsNull() && data.EnableTrapsIpsecTunnelStop.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ipsec/tunnel/stop")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.Cisco-IOS-XE-ospf:ospf-config.errors.enable"); value.Exists() {
- data.EnableTrapsOspfConfigErrors = types.BoolValue(true)
- } else {
- data.EnableTrapsOspfConfigErrors = types.BoolValue(false)
+ if !state.EnableTrapsIpsecTooManySas.IsNull() && data.EnableTrapsIpsecTooManySas.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ipsec/too-many-sas")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.pim.invalid-pim-message"); value.Exists() {
- data.EnableTrapsPimInvalidPimMessage = types.BoolValue(true)
- } else {
- data.EnableTrapsPimInvalidPimMessage = types.BoolValue(false)
+ if !state.EnableTrapsConfigCopy.IsNull() && data.EnableTrapsConfigCopy.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/config-copy")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.pim.neighbor-change"); value.Exists() {
- data.EnableTrapsPimNeighborChange = types.BoolValue(true)
- } else {
- data.EnableTrapsPimNeighborChange = types.BoolValue(false)
+ if !state.EnableTrapsConfig.IsNull() && data.EnableTrapsConfig.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/config")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.pim.rp-mapping-change"); value.Exists() {
- data.EnableTrapsPimRpMappingChange = types.BoolValue(true)
- } else {
- data.EnableTrapsPimRpMappingChange = types.BoolValue(false)
+ if !state.EnableTrapsConfigCtid.IsNull() && data.EnableTrapsConfigCtid.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/config-ctid")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.bridge.newroot"); value.Exists() {
- data.EnableTrapsBridgeNewroot = types.BoolValue(true)
- } else {
- data.EnableTrapsBridgeNewroot = types.BoolValue(false)
+ if !state.EnableTrapsDhcp.IsNull() && data.EnableTrapsDhcp.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/dhcp")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.bridge.topologychange"); value.Exists() {
- data.EnableTrapsBridgeTopologychange = types.BoolValue(true)
- } else {
- data.EnableTrapsBridgeTopologychange = types.BoolValue(false)
+ if !state.EnableTrapsEventManager.IsNull() && data.EnableTrapsEventManager.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/event-manager")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.stpx.inconsistency"); value.Exists() {
- data.EnableTrapsStpxInconsistency = types.BoolValue(true)
- } else {
- data.EnableTrapsStpxInconsistency = types.BoolValue(false)
+ if !state.EnableTrapsHsrp.IsNull() && data.EnableTrapsHsrp.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/hsrp")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.stpx.root-inconsistency"); value.Exists() {
- data.EnableTrapsStpxRootInconsistency = types.BoolValue(true)
- } else {
- data.EnableTrapsStpxRootInconsistency = types.BoolValue(false)
+ if !state.EnableTrapsIpmulticast.IsNull() && data.EnableTrapsIpmulticast.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ipmulticast")
+ }
+ if !state.EnableTrapsMsdp.IsNull() && data.EnableTrapsMsdp.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/msdp")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.stpx.loop-inconsistency"); value.Exists() {
- data.EnableTrapsStpxLoopInconsistency = types.BoolValue(true)
- } else {
- data.EnableTrapsStpxLoopInconsistency = types.BoolValue(false)
+ if !state.EnableTrapsOspfConfigStateChange.IsNull() && data.EnableTrapsOspfConfigStateChange.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/Cisco-IOS-XE-ospf:ospf-config/state-change/enable")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.syslog"); value.Exists() {
- data.EnableTrapsSyslog = types.BoolValue(true)
- } else {
- data.EnableTrapsSyslog = types.BoolValue(false)
+ if !state.EnableTrapsOspfConfigErrors.IsNull() && data.EnableTrapsOspfConfigErrors.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/Cisco-IOS-XE-ospf:ospf-config/errors/enable")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.Cisco-IOS-XE-bgp:bgp.cbgp2"); value.Exists() {
- data.EnableTrapsBgpCbgp2 = types.BoolValue(true)
- } else {
- data.EnableTrapsBgpCbgp2 = types.BoolValue(false)
+ if !state.EnableTrapsPimInvalidPimMessage.IsNull() && data.EnableTrapsPimInvalidPimMessage.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/pim/invalid-pim-message")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.nhrp.nhs"); value.Exists() {
- data.EnableTrapsNhrpNhs = types.BoolValue(true)
- } else {
- data.EnableTrapsNhrpNhs = types.BoolValue(false)
+ if !state.EnableTrapsPimNeighborChange.IsNull() && data.EnableTrapsPimNeighborChange.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/pim/neighbor-change")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.nhrp.nhc"); value.Exists() {
- data.EnableTrapsNhrpNhc = types.BoolValue(true)
- } else {
- data.EnableTrapsNhrpNhc = types.BoolValue(false)
+ if !state.EnableTrapsPimRpMappingChange.IsNull() && data.EnableTrapsPimRpMappingChange.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/pim/rp-mapping-change")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.nhrp.nhp"); value.Exists() {
- data.EnableTrapsNhrpNhp = types.BoolValue(true)
- } else {
- data.EnableTrapsNhrpNhp = types.BoolValue(false)
+ if !state.EnableTrapsBridgeNewroot.IsNull() && data.EnableTrapsBridgeNewroot.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/bridge/newroot")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.nhrp.quota-exceeded"); value.Exists() {
- data.EnableTrapsNhrpQuotaExceeded = types.BoolValue(true)
- } else {
- data.EnableTrapsNhrpQuotaExceeded = types.BoolValue(false)
+ if !state.EnableTrapsBridgeTopologychange.IsNull() && data.EnableTrapsBridgeTopologychange.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/bridge/topologychange")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.mpls.traffic-eng"); value.Exists() {
- data.EnableTrapsMplsTrafficEng = types.BoolValue(true)
- } else {
- data.EnableTrapsMplsTrafficEng = types.BoolValue(false)
+ if !state.EnableTrapsStpxInconsistency.IsNull() && data.EnableTrapsStpxInconsistency.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/stpx/inconsistency")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.mpls"); value.Exists() {
- data.EnableTrapsMpls = types.BoolValue(true)
- } else {
- data.EnableTrapsMpls = types.BoolValue(false)
+ if !state.EnableTrapsStpxRootInconsistency.IsNull() && data.EnableTrapsStpxRootInconsistency.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/stpx/root-inconsistency")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.mpls.vpn"); value.Exists() {
- data.EnableTrapsMplsVpn = types.BoolValue(true)
- } else {
- data.EnableTrapsMplsVpn = types.BoolValue(false)
+ if !state.EnableTrapsStpxLoopInconsistency.IsNull() && data.EnableTrapsStpxLoopInconsistency.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/stpx/loop-inconsistency")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.mpls.rfc"); value.Exists() {
- data.EnableTrapsMplsRfc = types.BoolValue(true)
- } else {
- data.EnableTrapsMplsRfc = types.BoolValue(false)
+ if !state.EnableTrapsSyslog.IsNull() && data.EnableTrapsSyslog.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/syslog")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.mpls.rfc.ldp"); value.Exists() {
- data.EnableTrapsMplsRfcLdp = types.BoolValue(true)
- } else {
- data.EnableTrapsMplsRfcLdp = types.BoolValue(false)
+ if !state.EnableTrapsBgpCbgp2.IsNull() && data.EnableTrapsBgpCbgp2.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.mpls.ldp"); value.Exists() {
- data.EnableTrapsMplsLdp = types.BoolValue(true)
- } else {
- data.EnableTrapsMplsLdp = types.BoolValue(false)
+ if !state.EnableTrapsNhrpNhs.IsNull() && data.EnableTrapsNhrpNhs.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/nhrp/nhs")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.mpls.fast-reroute.protected"); value.Exists() {
- data.EnableTrapsFastRerouteProtected = types.BoolValue(true)
- } else {
- data.EnableTrapsFastRerouteProtected = types.BoolValue(false)
+ if !state.EnableTrapsNhrpNhc.IsNull() && data.EnableTrapsNhrpNhc.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/nhrp/nhc")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.local-auth"); value.Exists() {
- data.EnableTrapsLocalAuth = types.BoolValue(true)
- } else {
- data.EnableTrapsLocalAuth = types.BoolValue(false)
+ if !state.EnableTrapsNhrpNhp.IsNull() && data.EnableTrapsNhrpNhp.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/nhrp/nhp")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.vlan-membership"); value.Exists() {
- data.EnableTrapsVlanMembership = types.BoolValue(true)
- } else {
- data.EnableTrapsVlanMembership = types.BoolValue(false)
+ if !state.EnableTrapsNhrpQuotaExceeded.IsNull() && data.EnableTrapsNhrpQuotaExceeded.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/nhrp/quota-exceeded")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.errdisable"); value.Exists() {
- data.EnableTrapsErrdisable = types.BoolValue(true)
- } else {
- data.EnableTrapsErrdisable = types.BoolValue(false)
+ if !state.EnableTrapsMplsTrafficEng.IsNull() && data.EnableTrapsMplsTrafficEng.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/mpls/traffic-eng")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.rf"); value.Exists() {
- data.EnableTrapsRf = types.BoolValue(true)
- } else {
- data.EnableTrapsRf = types.BoolValue(false)
+ if !state.EnableTrapsMpls.IsNull() && data.EnableTrapsMpls.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/mpls")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.transceiver.all"); value.Exists() {
- data.EnableTrapsTransceiverAll = types.BoolValue(true)
- } else {
- data.EnableTrapsTransceiverAll = types.BoolValue(false)
+ if !state.EnableTrapsMplsVpn.IsNull() && data.EnableTrapsMplsVpn.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/mpls/vpn")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.bulkstat.collection"); value.Exists() {
- data.EnableTrapsBulkstatCollection = types.BoolValue(true)
- } else {
- data.EnableTrapsBulkstatCollection = types.BoolValue(false)
+ if !state.EnableTrapsMplsRfc.IsNull() && data.EnableTrapsMplsRfc.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/mpls/rfc")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.bulkstat.transfer"); value.Exists() {
- data.EnableTrapsBulkstatTransfer = types.BoolValue(true)
- } else {
- data.EnableTrapsBulkstatTransfer = types.BoolValue(false)
+ if !state.EnableTrapsMplsRfcLdp.IsNull() && data.EnableTrapsMplsRfcLdp.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/mpls/rfc/ldp")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.mac-notification.change"); value.Exists() {
- data.EnableTrapsMacNotificationChange = types.BoolValue(true)
- } else {
- data.EnableTrapsMacNotificationChange = types.BoolValue(false)
+ if !state.EnableTrapsMplsLdp.IsNull() && data.EnableTrapsMplsLdp.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/mpls/ldp")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.mac-notification.move"); value.Exists() {
- data.EnableTrapsMacNotificationMove = types.BoolValue(true)
- } else {
- data.EnableTrapsMacNotificationMove = types.BoolValue(false)
+ if !state.EnableTrapsFastRerouteProtected.IsNull() && data.EnableTrapsFastRerouteProtected.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/mpls/fast-reroute/protected")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.mac-notification.threshold"); value.Exists() {
- data.EnableTrapsMacNotificationThreshold = types.BoolValue(true)
- } else {
- data.EnableTrapsMacNotificationThreshold = types.BoolValue(false)
+ if !state.EnableTrapsLocalAuth.IsNull() && data.EnableTrapsLocalAuth.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/local-auth")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.vrfmib.vrf-up"); value.Exists() {
- data.EnableTrapsVrfmibVrfUp = types.BoolValue(true)
- } else {
- data.EnableTrapsVrfmibVrfUp = types.BoolValue(false)
+ if !state.EnableTrapsVlanMembership.IsNull() && data.EnableTrapsVlanMembership.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/vlan-membership")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.vrfmib.vrf-down"); value.Exists() {
- data.EnableTrapsVrfmibVrfDown = types.BoolValue(true)
- } else {
- data.EnableTrapsVrfmibVrfDown = types.BoolValue(false)
+ if !state.EnableTrapsErrdisable.IsNull() && data.EnableTrapsErrdisable.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/errdisable")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.vrfmib.vnet-trunk-up"); value.Exists() {
- data.EnableTrapsVrfmibVnetTrunkUp = types.BoolValue(true)
- } else {
- data.EnableTrapsVrfmibVnetTrunkUp = types.BoolValue(false)
+ if !state.EnableTrapsRf.IsNull() && data.EnableTrapsRf.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/rf")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.vrfmib.vnet-trunk-down"); value.Exists() {
- data.EnableTrapsVrfmibVnetTrunkDown = types.BoolValue(true)
- } else {
- data.EnableTrapsVrfmibVnetTrunkDown = types.BoolValue(false)
+ if !state.EnableTrapsTransceiverAll.IsNull() && data.EnableTrapsTransceiverAll.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/transceiver/all")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.mvpn"); value.Exists() {
- data.EnableTrapsMvpn = types.BoolValue(true)
- } else {
- data.EnableTrapsMvpn = types.BoolValue(false)
+ if !state.EnableTrapsBulkstatCollection.IsNull() && data.EnableTrapsBulkstatCollection.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/bulkstat/collection")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.lisp"); value.Exists() {
- data.EnableTrapsLisp = types.BoolValue(true)
- } else {
- data.EnableTrapsLisp = types.BoolValue(false)
+ if !state.EnableTrapsBulkstatTransfer.IsNull() && data.EnableTrapsBulkstatTransfer.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/bulkstat/transfer")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.aaa_server"); value.Exists() {
- data.EnableTrapsAaaServer = types.BoolValue(true)
- } else {
- data.EnableTrapsAaaServer = types.BoolValue(false)
+ if !state.EnableTrapsMacNotificationChange.IsNull() && data.EnableTrapsMacNotificationChange.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/mac-notification/change")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.vdsl2line"); value.Exists() {
- data.EnableTrapsVdsl2line = types.BoolValue(true)
- } else {
- data.EnableTrapsVdsl2line = types.BoolValue(false)
+ if !state.EnableTrapsMacNotificationMove.IsNull() && data.EnableTrapsMacNotificationMove.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/mac-notification/move")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.adslline"); value.Exists() {
- data.EnableTrapsAdslline = types.BoolValue(true)
- } else {
- data.EnableTrapsAdslline = types.BoolValue(false)
+ if !state.EnableTrapsMacNotificationThreshold.IsNull() && data.EnableTrapsMacNotificationThreshold.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/mac-notification/threshold")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.pki"); value.Exists() {
- data.EnableTrapsPki = types.BoolValue(true)
- } else {
- data.EnableTrapsPki = types.BoolValue(false)
+ if !state.EnableTrapsVrfmibVrfUp.IsNull() && data.EnableTrapsVrfmibVrfUp.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/vrfmib/vrf-up")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.alarms.alarm-type"); value.Exists() {
- data.EnableTrapsAlarmType = types.StringValue(value.String())
+ if !state.EnableTrapsVrfmibVrfDown.IsNull() && data.EnableTrapsVrfmibVrfDown.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/vrfmib/vrf-down")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.casa"); value.Exists() {
- data.EnableTrapsCasa = types.BoolValue(true)
- } else {
- data.EnableTrapsCasa = types.BoolValue(false)
+ if !state.EnableTrapsVrfmibVnetTrunkUp.IsNull() && data.EnableTrapsVrfmibVnetTrunkUp.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/vrfmib/vnet-trunk-up")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.cnpd"); value.Exists() {
- data.EnableTrapsCnpd = types.BoolValue(true)
- } else {
- data.EnableTrapsCnpd = types.BoolValue(false)
+ if !state.EnableTrapsVrfmibVnetTrunkDown.IsNull() && data.EnableTrapsVrfmibVnetTrunkDown.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/vrfmib/vnet-trunk-down")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.dial"); value.Exists() {
- data.EnableTrapsDial = types.BoolValue(true)
- } else {
- data.EnableTrapsDial = types.BoolValue(false)
+ if !state.EnableTrapsMvpn.IsNull() && data.EnableTrapsMvpn.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/mvpn")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.dlsw"); value.Exists() {
- data.EnableTrapsDlsw = types.BoolValue(true)
- } else {
- data.EnableTrapsDlsw = types.BoolValue(false)
+ if !state.EnableTrapsLisp.IsNull() && data.EnableTrapsLisp.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/lisp")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ds1"); value.Exists() {
- data.EnableTrapsDs1 = types.BoolValue(true)
- } else {
- data.EnableTrapsDs1 = types.BoolValue(false)
+ if !state.EnableTrapsAaaServer.IsNull() && data.EnableTrapsAaaServer.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/aaa_server")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.dsp.card-status"); value.Exists() {
- data.EnableTrapsDspCardStatus = types.BoolValue(true)
- } else {
- data.EnableTrapsDspCardStatus = types.BoolValue(false)
+ if !state.EnableTrapsVdsl2line.IsNull() && data.EnableTrapsVdsl2line.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/vdsl2line")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.dsp.oper-state"); value.Exists() {
- data.EnableTrapsDspOperState = types.BoolValue(true)
- } else {
- data.EnableTrapsDspOperState = types.BoolValue(false)
+ if !state.EnableTrapsAdslline.IsNull() && data.EnableTrapsAdslline.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/adslline")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.entity-sensor"); value.Exists() {
- data.EnableTrapsEntitySensor = types.BoolValue(true)
- } else {
- data.EnableTrapsEntitySensor = types.BoolValue(false)
+ if !state.EnableTrapsPki.IsNull() && data.EnableTrapsPki.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/pki")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.entity-state"); value.Exists() {
- data.EnableTrapsEntityState = types.BoolValue(true)
- } else {
- data.EnableTrapsEntityState = types.BoolValue(false)
+ if !state.EnableTrapsAlarmType.IsNull() && data.EnableTrapsAlarmType.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/alarms/alarm-type")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.entity-qfp.mem-res-thresh"); value.Exists() {
- data.EnableTrapsEntityQfpMemResThresh = types.BoolValue(true)
- } else {
- data.EnableTrapsEntityQfpMemResThresh = types.BoolValue(false)
+ if !state.EnableTrapsCasa.IsNull() && data.EnableTrapsCasa.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/casa")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.entity-qfp.throughput-notif"); value.Exists() {
- data.EnableTrapsEntityQfpThroughputNotif = types.BoolValue(true)
- } else {
- data.EnableTrapsEntityQfpThroughputNotif = types.BoolValue(false)
+ if !state.EnableTrapsCnpd.IsNull() && data.EnableTrapsCnpd.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/cnpd")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ether-oam"); value.Exists() {
- data.EnableTrapsEtherOam = types.BoolValue(true)
- } else {
- data.EnableTrapsEtherOam = types.BoolValue(false)
+ if !state.EnableTrapsDial.IsNull() && data.EnableTrapsDial.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/dial")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ethernet.cfm.alarm"); value.Exists() {
- data.EnableTrapsEthernetCfmAlarm = types.BoolValue(true)
- } else {
- data.EnableTrapsEthernetCfmAlarm = types.BoolValue(false)
+ if !state.EnableTrapsDlsw.IsNull() && data.EnableTrapsDlsw.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/dlsw")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ethernet.cfm.cc.config"); value.Exists() {
- data.EnableTrapsEthernetCfmCcConfig = types.BoolValue(true)
- } else {
- data.EnableTrapsEthernetCfmCcConfig = types.BoolValue(false)
+ if !state.EnableTrapsDs1.IsNull() && data.EnableTrapsDs1.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ds1")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ethernet.cfm.cc.cross-connect"); value.Exists() {
- data.EnableTrapsEthernetCfmCcCrossConnect = types.BoolValue(true)
- } else {
- data.EnableTrapsEthernetCfmCcCrossConnect = types.BoolValue(false)
+ if !state.EnableTrapsDspCardStatus.IsNull() && data.EnableTrapsDspCardStatus.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/dsp/card-status")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ethernet.cfm.cc.loop"); value.Exists() {
- data.EnableTrapsEthernetCfmCcLoop = types.BoolValue(true)
- } else {
- data.EnableTrapsEthernetCfmCcLoop = types.BoolValue(false)
+ if !state.EnableTrapsDspOperState.IsNull() && data.EnableTrapsDspOperState.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/dsp/oper-state")
+ }
+ if !state.EnableTrapsEntitySensor.IsNull() && data.EnableTrapsEntitySensor.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/entity-sensor")
+ }
+ if !state.EnableTrapsEntityState.IsNull() && data.EnableTrapsEntityState.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/entity-state")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ethernet.cfm.cc.mep-down"); value.Exists() {
- data.EnableTrapsEthernetCfmCcMepDown = types.BoolValue(true)
- } else {
- data.EnableTrapsEthernetCfmCcMepDown = types.BoolValue(false)
+ if !state.EnableTrapsEntityQfpMemResThresh.IsNull() && data.EnableTrapsEntityQfpMemResThresh.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/entity-qfp/mem-res-thresh")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ethernet.cfm.cc.mep-up"); value.Exists() {
- data.EnableTrapsEthernetCfmCcMepUp = types.BoolValue(true)
- } else {
- data.EnableTrapsEthernetCfmCcMepUp = types.BoolValue(false)
+ if !state.EnableTrapsEntityQfpThroughputNotif.IsNull() && data.EnableTrapsEntityQfpThroughputNotif.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/entity-qfp/throughput-notif")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ethernet.cfm.crosscheck.mep-missing"); value.Exists() {
- data.EnableTrapsEthernetCfmCrosscheckMepMissing = types.BoolValue(true)
- } else {
- data.EnableTrapsEthernetCfmCrosscheckMepMissing = types.BoolValue(false)
+ if !state.EnableTrapsEtherOam.IsNull() && data.EnableTrapsEtherOam.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ether-oam")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ethernet.cfm.crosscheck.mep-unknown"); value.Exists() {
- data.EnableTrapsEthernetCfmCrosscheckMepUnknown = types.BoolValue(true)
- } else {
- data.EnableTrapsEthernetCfmCrosscheckMepUnknown = types.BoolValue(false)
+ if !state.EnableTrapsEthernetCfmAlarm.IsNull() && data.EnableTrapsEthernetCfmAlarm.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ethernet/cfm/alarm")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ethernet.cfm.crosscheck.service-up"); value.Exists() {
- data.EnableTrapsEthernetCfmCrosscheckServiceUp = types.BoolValue(true)
- } else {
- data.EnableTrapsEthernetCfmCrosscheckServiceUp = types.BoolValue(false)
+ if !state.EnableTrapsEthernetCfmCcConfig.IsNull() && data.EnableTrapsEthernetCfmCcConfig.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ethernet/cfm/cc/config")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ethernet.evc.create"); value.Exists() {
- data.EnableTrapsEthernetEvcCreate = types.BoolValue(true)
- } else {
- data.EnableTrapsEthernetEvcCreate = types.BoolValue(false)
+ if !state.EnableTrapsEthernetCfmCcCrossConnect.IsNull() && data.EnableTrapsEthernetCfmCcCrossConnect.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ethernet/cfm/cc/cross-connect")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ethernet.evc.delete"); value.Exists() {
- data.EnableTrapsEthernetEvcDelete = types.BoolValue(true)
- } else {
- data.EnableTrapsEthernetEvcDelete = types.BoolValue(false)
+ if !state.EnableTrapsEthernetCfmCcLoop.IsNull() && data.EnableTrapsEthernetCfmCcLoop.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ethernet/cfm/cc/loop")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ethernet.evc.status"); value.Exists() {
- data.EnableTrapsEthernetEvcStatus = types.BoolValue(true)
- } else {
- data.EnableTrapsEthernetEvcStatus = types.BoolValue(false)
+ if !state.EnableTrapsEthernetCfmCcMepDown.IsNull() && data.EnableTrapsEthernetCfmCcMepDown.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ethernet/cfm/cc/mep-down")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.firewall.serverstatus"); value.Exists() {
- data.EnableTrapsFirewallServerstatus = types.BoolValue(true)
- } else {
- data.EnableTrapsFirewallServerstatus = types.BoolValue(false)
+ if !state.EnableTrapsEthernetCfmCcMepUp.IsNull() && data.EnableTrapsEthernetCfmCcMepUp.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ethernet/cfm/cc/mep-up")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.frame-relay-config.only-frame-relay.frame-relay"); value.Exists() {
- data.EnableTrapsFrameRelayConfigOnly = types.BoolValue(true)
- } else {
- data.EnableTrapsFrameRelayConfigOnly = types.BoolValue(false)
+ if !state.EnableTrapsEthernetCfmCrosscheckMepMissing.IsNull() && data.EnableTrapsEthernetCfmCrosscheckMepMissing.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ethernet/cfm/crosscheck/mep-missing")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.frame-relay-config.frame-relay-options.frame-relay.subif-configs.subif"); value.Exists() {
- data.EnableTrapsFrameRelayConfigSubifConfigs = types.BoolValue(true)
- } else {
- data.EnableTrapsFrameRelayConfigSubifConfigs = types.BoolValue(false)
+ if !state.EnableTrapsEthernetCfmCrosscheckMepUnknown.IsNull() && data.EnableTrapsEthernetCfmCrosscheckMepUnknown.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ethernet/cfm/crosscheck/mep-unknown")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.frame-relay.subif.count"); value.Exists() {
- data.EnableTrapsFrameRelaySubifCount = types.Int64Value(value.Int())
+ if !state.EnableTrapsEthernetCfmCrosscheckServiceUp.IsNull() && data.EnableTrapsEthernetCfmCrosscheckServiceUp.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ethernet/cfm/crosscheck/service-up")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.frame-relay.subif.interval"); value.Exists() {
- data.EnableTrapsFrameRelaySubifInterval = types.Int64Value(value.Int())
+ if !state.EnableTrapsEthernetEvcCreate.IsNull() && data.EnableTrapsEthernetEvcCreate.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ethernet/evc/create")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.frame-relay-config.frame-relay-options.frame-relay.multilink.bundle-mismatch"); value.Exists() {
- data.EnableTrapsFrameRelayConfigBundleMismatch = types.BoolValue(true)
- } else {
- data.EnableTrapsFrameRelayConfigBundleMismatch = types.BoolValue(false)
+ if !state.EnableTrapsEthernetEvcDelete.IsNull() && data.EnableTrapsEthernetEvcDelete.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ethernet/evc/delete")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.frame-relay.multilink.bundle-mismatch"); value.Exists() {
- data.EnableTrapsFrameRelayMultilinkBundleMismatch = types.BoolValue(true)
- } else {
- data.EnableTrapsFrameRelayMultilinkBundleMismatch = types.BoolValue(false)
+ if !state.EnableTrapsEthernetEvcStatus.IsNull() && data.EnableTrapsEthernetEvcStatus.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ethernet/evc/status")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ip.local.pool"); value.Exists() {
- data.EnableTrapsIpLocalPool = types.BoolValue(true)
- } else {
- data.EnableTrapsIpLocalPool = types.BoolValue(false)
+ if !state.EnableTrapsFirewallServerstatus.IsNull() && data.EnableTrapsFirewallServerstatus.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/firewall/serverstatus")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.isdn.call-information"); value.Exists() {
- data.EnableTrapsIsdnCallInformation = types.BoolValue(true)
- } else {
- data.EnableTrapsIsdnCallInformation = types.BoolValue(false)
+ if !state.EnableTrapsFrameRelayConfigOnly.IsNull() && data.EnableTrapsFrameRelayConfigOnly.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/frame-relay-config/only-frame-relay/frame-relay")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.isdn.chan-not-avail"); value.Exists() {
- data.EnableTrapsIsdnChanNotAvail = types.BoolValue(true)
- } else {
- data.EnableTrapsIsdnChanNotAvail = types.BoolValue(false)
+ if !state.EnableTrapsFrameRelayConfigSubifConfigs.IsNull() && data.EnableTrapsFrameRelayConfigSubifConfigs.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/frame-relay-config/frame-relay-options/frame-relay/subif-configs/subif")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.isdn.ietf"); value.Exists() {
- data.EnableTrapsIsdnIetf = types.BoolValue(true)
- } else {
- data.EnableTrapsIsdnIetf = types.BoolValue(false)
+ if !state.EnableTrapsFrameRelaySubifCount.IsNull() && data.EnableTrapsFrameRelaySubifCount.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/frame-relay/subif/count")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.isdn.layer2"); value.Exists() {
- data.EnableTrapsIsdnLayer2 = types.BoolValue(true)
- } else {
- data.EnableTrapsIsdnLayer2 = types.BoolValue(false)
+ if !state.EnableTrapsFrameRelaySubifInterval.IsNull() && data.EnableTrapsFrameRelaySubifInterval.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/frame-relay/subif/interval")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.l2tun.session"); value.Exists() {
- data.EnableTrapsL2tunSession = types.BoolValue(true)
- } else {
- data.EnableTrapsL2tunSession = types.BoolValue(false)
+ if !state.EnableTrapsFrameRelayConfigBundleMismatch.IsNull() && data.EnableTrapsFrameRelayConfigBundleMismatch.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/frame-relay-config/frame-relay-options/frame-relay/multilink/bundle-mismatch")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.l2tun.tunnel"); value.Exists() {
- data.EnableTrapsL2tunTunnel = types.BoolValue(true)
- } else {
- data.EnableTrapsL2tunTunnel = types.BoolValue(false)
+ if !state.EnableTrapsFrameRelayMultilinkBundleMismatch.IsNull() && data.EnableTrapsFrameRelayMultilinkBundleMismatch.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/frame-relay/multilink/bundle-mismatch")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.l2tun.pseudowire.status"); value.Exists() {
- data.EnableTrapsL2tunPseudowireStatus = types.BoolValue(true)
- } else {
- data.EnableTrapsL2tunPseudowireStatus = types.BoolValue(false)
+ if !state.EnableTrapsIpLocalPool.IsNull() && data.EnableTrapsIpLocalPool.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ip/local/pool")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.pimstdmib.neighbor-loss"); value.Exists() {
- data.EnableTrapsPimstdmibNeighborLoss = types.BoolValue(true)
- } else {
- data.EnableTrapsPimstdmibNeighborLoss = types.BoolValue(false)
+ if !state.EnableTrapsIsdnCallInformation.IsNull() && data.EnableTrapsIsdnCallInformation.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/isdn/call-information")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.pimstdmib.invalid-register"); value.Exists() {
- data.EnableTrapsPimstdmibInvalidRegister = types.BoolValue(true)
- } else {
- data.EnableTrapsPimstdmibInvalidRegister = types.BoolValue(false)
+ if !state.EnableTrapsIsdnChanNotAvail.IsNull() && data.EnableTrapsIsdnChanNotAvail.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/isdn/chan-not-avail")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.pimstdmib.invalid-join-prune"); value.Exists() {
- data.EnableTrapsPimstdmibInvalidJoinPrune = types.BoolValue(true)
- } else {
- data.EnableTrapsPimstdmibInvalidJoinPrune = types.BoolValue(false)
+ if !state.EnableTrapsIsdnIetf.IsNull() && data.EnableTrapsIsdnIetf.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/isdn/ietf")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.pimstdmib.rp-mapping-change"); value.Exists() {
- data.EnableTrapsPimstdmibRpMappingChange = types.BoolValue(true)
- } else {
- data.EnableTrapsPimstdmibRpMappingChange = types.BoolValue(false)
+ if !state.EnableTrapsIsdnLayer2.IsNull() && data.EnableTrapsIsdnLayer2.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/isdn/layer2")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.pimstdmib.interface-election"); value.Exists() {
- data.EnableTrapsPimstdmibInterfaceElection = types.BoolValue(true)
- } else {
- data.EnableTrapsPimstdmibInterfaceElection = types.BoolValue(false)
+ if !state.EnableTrapsL2tunSession.IsNull() && data.EnableTrapsL2tunSession.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/l2tun/session")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.pfr"); value.Exists() {
- data.EnableTrapsPfr = types.BoolValue(true)
- } else {
- data.EnableTrapsPfr = types.BoolValue(false)
+ if !state.EnableTrapsL2tunTunnel.IsNull() && data.EnableTrapsL2tunTunnel.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/l2tun/tunnel")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.pppoe"); value.Exists() {
- data.EnableTrapsPppoe = types.BoolValue(true)
- } else {
- data.EnableTrapsPppoe = types.BoolValue(false)
+ if !state.EnableTrapsL2tunPseudowireStatus.IsNull() && data.EnableTrapsL2tunPseudowireStatus.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/l2tun/pseudowire/status")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.resource-policy"); value.Exists() {
- data.EnableTrapsResourcePolicy = types.BoolValue(true)
- } else {
- data.EnableTrapsResourcePolicy = types.BoolValue(false)
+ if !state.EnableTrapsPimstdmibNeighborLoss.IsNull() && data.EnableTrapsPimstdmibNeighborLoss.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/pimstdmib/neighbor-loss")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.rsvp"); value.Exists() {
- data.EnableTrapsRsvp = types.BoolValue(true)
- } else {
- data.EnableTrapsRsvp = types.BoolValue(false)
+ if !state.EnableTrapsPimstdmibInvalidRegister.IsNull() && data.EnableTrapsPimstdmibInvalidRegister.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/pimstdmib/invalid-register")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.vrrp"); value.Exists() {
- data.EnableTrapsVrrp = types.BoolValue(true)
- } else {
- data.EnableTrapsVrrp = types.BoolValue(false)
+ if !state.EnableTrapsPimstdmibInvalidJoinPrune.IsNull() && data.EnableTrapsPimstdmibInvalidJoinPrune.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/pimstdmib/invalid-join-prune")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.sonet"); value.Exists() {
- data.EnableTrapsSonet = types.BoolValue(true)
- } else {
- data.EnableTrapsSonet = types.BoolValue(false)
+ if !state.EnableTrapsPimstdmibRpMappingChange.IsNull() && data.EnableTrapsPimstdmibRpMappingChange.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/pimstdmib/rp-mapping-change")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.srp"); value.Exists() {
- data.EnableTrapsSrp = types.BoolValue(true)
- } else {
- data.EnableTrapsSrp = types.BoolValue(false)
+ if !state.EnableTrapsPimstdmibInterfaceElection.IsNull() && data.EnableTrapsPimstdmibInterfaceElection.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/pimstdmib/interface-election")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.voice"); value.Exists() {
- data.EnableTrapsVoice = types.BoolValue(true)
- } else {
- data.EnableTrapsVoice = types.BoolValue(false)
+ if !state.EnableTrapsPfr.IsNull() && data.EnableTrapsPfr.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/pfr")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.bgp"); value.Exists() {
- data.EnableTrapsBgp = types.BoolValue(true)
- } else {
- data.EnableTrapsBgp = types.BoolValue(false)
+ if !state.EnableTrapsPppoe.IsNull() && data.EnableTrapsPppoe.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/pppoe")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.bgp-traps.cbgp2"); value.Exists() {
- data.EnableTrapsCbgp2 = types.BoolValue(true)
- } else {
- data.EnableTrapsCbgp2 = types.BoolValue(false)
+ if !state.EnableTrapsResourcePolicy.IsNull() && data.EnableTrapsResourcePolicy.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/resource-policy")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ospfv3.errors"); value.Exists() {
- data.EnableTrapsOspfv3Errors = types.BoolValue(true)
- } else {
- data.EnableTrapsOspfv3Errors = types.BoolValue(false)
+ if !state.EnableTrapsRsvp.IsNull() && data.EnableTrapsRsvp.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/rsvp")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:enable.enable-choice.traps.ospfv3.state-change"); value.Exists() {
- data.EnableTrapsOspfv3StateChange = types.BoolValue(true)
- } else {
- data.EnableTrapsOspfv3StateChange = types.BoolValue(false)
+ if !state.EnableTrapsVrrp.IsNull() && data.EnableTrapsVrrp.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/vrrp")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:source-interface.informs.GigabitEthernet"); value.Exists() {
- data.SourceInterfaceInformsGigabitEthernet = types.StringValue(value.String())
+ if !state.EnableTrapsSonet.IsNull() && data.EnableTrapsSonet.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/sonet")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:source-interface.informs.TenGigabitEthernet"); value.Exists() {
- data.SourceInterfaceInformsTenGigabitEthernet = types.StringValue(value.String())
+ if !state.EnableTrapsSrp.IsNull() && data.EnableTrapsSrp.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/srp")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:source-interface.informs.FortyGigabitEthernet"); value.Exists() {
- data.SourceInterfaceInformsFortyGigabitEthernet = types.StringValue(value.String())
+ if !state.EnableTrapsVoice.IsNull() && data.EnableTrapsVoice.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/voice")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:source-interface.informs.HundredGigE"); value.Exists() {
- data.SourceInterfaceInformsHundredGigE = types.StringValue(value.String())
+ if !state.EnableTrapsBgp.IsNull() && data.EnableTrapsBgp.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/bgp")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:source-interface.informs.Loopback"); value.Exists() {
- data.SourceInterfaceInformsLoopback = types.Int64Value(value.Int())
+ if !state.EnableTrapsCbgp2.IsNull() && data.EnableTrapsCbgp2.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/bgp-traps/cbgp2")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:source-interface.informs.Port-channel"); value.Exists() {
- data.SourceInterfaceInformsPortChannel = types.Int64Value(value.Int())
+ if !state.EnableTrapsOspfv3Errors.IsNull() && data.EnableTrapsOspfv3Errors.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ospfv3/errors")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:source-interface.informs.Port-channel-subinterface.Port-channel"); value.Exists() {
- data.SourceInterfaceInformsPortChannelSubinterface = types.StringValue(value.String())
+ if !state.EnableTrapsOspfv3StateChange.IsNull() && data.EnableTrapsOspfv3StateChange.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ospfv3/state-change")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:source-interface.informs.Vlan"); value.Exists() {
- data.SourceInterfaceInformsVlan = types.Int64Value(value.Int())
+ if !state.SourceInterfaceInformsGigabitEthernet.IsNull() && data.SourceInterfaceInformsGigabitEthernet.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:source-interface/informs/GigabitEthernet")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:source-interface.traps.GigabitEthernet"); value.Exists() {
- data.SourceInterfaceTrapsGigabitEthernet = types.StringValue(value.String())
+ if !state.SourceInterfaceInformsTenGigabitEthernet.IsNull() && data.SourceInterfaceInformsTenGigabitEthernet.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:source-interface/informs/TenGigabitEthernet")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:source-interface.traps.TenGigabitEthernet"); value.Exists() {
- data.SourceInterfaceTrapsTenGigabitEthernet = types.StringValue(value.String())
+ if !state.SourceInterfaceInformsFortyGigabitEthernet.IsNull() && data.SourceInterfaceInformsFortyGigabitEthernet.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:source-interface/informs/FortyGigabitEthernet")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:source-interface.traps.FortyGigabitEthernet"); value.Exists() {
- data.SourceInterfaceTrapsFortyGigabitEthernet = types.StringValue(value.String())
+ if !state.SourceInterfaceInformsHundredGigE.IsNull() && data.SourceInterfaceInformsHundredGigE.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:source-interface/informs/HundredGigE")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:source-interface.traps.HundredGigE"); value.Exists() {
- data.SourceInterfaceTrapsHundredGigE = types.StringValue(value.String())
+ if !state.SourceInterfaceInformsLoopback.IsNull() && data.SourceInterfaceInformsLoopback.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:source-interface/informs/Loopback")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:source-interface.traps.Loopback"); value.Exists() {
- data.SourceInterfaceTrapsLoopback = types.Int64Value(value.Int())
+ if !state.SourceInterfaceInformsPortChannel.IsNull() && data.SourceInterfaceInformsPortChannel.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:source-interface/informs/Port-channel")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:source-interface.traps.Port-channel"); value.Exists() {
- data.SourceInterfaceTrapsPortChannel = types.Int64Value(value.Int())
+ if !state.SourceInterfaceInformsPortChannelSubinterface.IsNull() && data.SourceInterfaceInformsPortChannelSubinterface.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:source-interface/informs/Port-channel-subinterface/Port-channel")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:source-interface.traps.Port-channel-subinterface.Port-channel"); value.Exists() {
- data.SourceInterfaceTrapsPortChannelSubinterface = types.StringValue(value.String())
+ if !state.SourceInterfaceInformsVlan.IsNull() && data.SourceInterfaceInformsVlan.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:source-interface/informs/Vlan")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:source-interface.traps.Vlan"); value.Exists() {
- data.SourceInterfaceTrapsVlan = types.Int64Value(value.Int())
+ if !state.SourceInterfaceTrapsGigabitEthernet.IsNull() && data.SourceInterfaceTrapsGigabitEthernet.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:source-interface/traps/GigabitEthernet")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:trap-source.GigabitEthernet"); value.Exists() {
- data.TrapSourceGigabitEthernet = types.StringValue(value.String())
+ if !state.SourceInterfaceTrapsTenGigabitEthernet.IsNull() && data.SourceInterfaceTrapsTenGigabitEthernet.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:source-interface/traps/TenGigabitEthernet")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:trap-source.TenGigabitEthernet"); value.Exists() {
- data.TrapSourceTenGigabitEthernet = types.StringValue(value.String())
+ if !state.SourceInterfaceTrapsFortyGigabitEthernet.IsNull() && data.SourceInterfaceTrapsFortyGigabitEthernet.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:source-interface/traps/FortyGigabitEthernet")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:trap-source.FortyGigabitEthernet"); value.Exists() {
- data.TrapSourceFortyGigabitEthernet = types.StringValue(value.String())
+ if !state.SourceInterfaceTrapsHundredGigE.IsNull() && data.SourceInterfaceTrapsHundredGigE.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:source-interface/traps/HundredGigE")
+ }
+ if !state.SourceInterfaceTrapsLoopback.IsNull() && data.SourceInterfaceTrapsLoopback.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:source-interface/traps/Loopback")
+ }
+ if !state.SourceInterfaceTrapsPortChannel.IsNull() && data.SourceInterfaceTrapsPortChannel.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:source-interface/traps/Port-channel")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:trap-source.HundredGigE"); value.Exists() {
- data.TrapSourceHundredGigE = types.StringValue(value.String())
+ if !state.SourceInterfaceTrapsPortChannelSubinterface.IsNull() && data.SourceInterfaceTrapsPortChannelSubinterface.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:source-interface/traps/Port-channel-subinterface/Port-channel")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:trap-source.Loopback"); value.Exists() {
- data.TrapSourceLoopback = types.Int64Value(value.Int())
+ if !state.SourceInterfaceTrapsVlan.IsNull() && data.SourceInterfaceTrapsVlan.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:source-interface/traps/Vlan")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:trap-source.Port-channel"); value.Exists() {
- data.TrapSourcePortChannel = types.Int64Value(value.Int())
+ if !state.TrapSourceGigabitEthernet.IsNull() && data.TrapSourceGigabitEthernet.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:trap-source/GigabitEthernet")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:trap-source.Port-channel-subinterface.Port-channel"); value.Exists() {
- data.TrapSourcePortChannelSubinterface = types.StringValue(value.String())
+ if !state.TrapSourceTenGigabitEthernet.IsNull() && data.TrapSourceTenGigabitEthernet.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:trap-source/TenGigabitEthernet")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:trap-source.Vlan"); value.Exists() {
- data.TrapSourceVlan = types.Int64Value(value.Int())
+ if !state.TrapSourceFortyGigabitEthernet.IsNull() && data.TrapSourceFortyGigabitEthernet.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:trap-source/FortyGigabitEthernet")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:community-config"); value.Exists() {
- data.SnmpCommunities = make([]SNMPServerSnmpCommunities, 0)
- value.ForEach(func(k, v gjson.Result) bool {
- item := SNMPServerSnmpCommunities{}
- if cValue := v.Get("name"); cValue.Exists() {
- item.Name = types.StringValue(cValue.String())
- }
- if cValue := v.Get("view"); cValue.Exists() {
- item.View = types.StringValue(cValue.String())
- }
- if cValue := v.Get("permission"); cValue.Exists() {
- item.Permission = types.StringValue(cValue.String())
- }
- if cValue := v.Get("ipv6"); cValue.Exists() {
- item.Ipv6 = types.StringValue(cValue.String())
- }
- if cValue := v.Get("access-list-name"); cValue.Exists() {
- item.AccessListName = types.StringValue(cValue.String())
- }
- data.SnmpCommunities = append(data.SnmpCommunities, item)
- return true
- })
+ if !state.TrapSourceHundredGigE.IsNull() && data.TrapSourceHundredGigE.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:trap-source/HundredGigE")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:context"); value.Exists() {
- data.Contexts = make([]SNMPServerContexts, 0)
- value.ForEach(func(k, v gjson.Result) bool {
- item := SNMPServerContexts{}
- if cValue := v.Get("name"); cValue.Exists() {
- item.Name = types.StringValue(cValue.String())
- }
- data.Contexts = append(data.Contexts, item)
- return true
- })
+ if !state.TrapSourceLoopback.IsNull() && data.TrapSourceLoopback.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:trap-source/Loopback")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:view"); value.Exists() {
- data.Views = make([]SNMPServerViews, 0)
- value.ForEach(func(k, v gjson.Result) bool {
- item := SNMPServerViews{}
- if cValue := v.Get("name"); cValue.Exists() {
- item.Name = types.StringValue(cValue.String())
- }
- if cValue := v.Get("mib"); cValue.Exists() {
- item.Mib = types.StringValue(cValue.String())
- }
- if cValue := v.Get("inc-exl"); cValue.Exists() {
- item.IncExl = types.StringValue(cValue.String())
- }
- data.Views = append(data.Views, item)
- return true
- })
+ if !state.TrapSourcePortChannel.IsNull() && data.TrapSourcePortChannel.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:trap-source/Port-channel")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:group"); value.Exists() {
- data.Groups = make([]SNMPServerGroups, 0)
- value.ForEach(func(k, v gjson.Result) bool {
- item := SNMPServerGroups{}
- if cValue := v.Get("id"); cValue.Exists() {
- item.Name = types.StringValue(cValue.String())
- }
- if cValue := v.Get("v3.security-level-list"); cValue.Exists() {
- item.V3Security = make([]SNMPServerGroupsV3Security, 0)
- cValue.ForEach(func(ck, cv gjson.Result) bool {
- cItem := SNMPServerGroupsV3Security{}
- if ccValue := cv.Get("security-level"); ccValue.Exists() {
- cItem.SecurityLevel = types.StringValue(ccValue.String())
- }
- if ccValue := cv.Get("context-node"); ccValue.Exists() {
- cItem.ContextNode = types.StringValue(ccValue.String())
- }
- if ccValue := cv.Get("match-node"); ccValue.Exists() {
- cItem.MatchNode = types.StringValue(ccValue.String())
- }
- if ccValue := cv.Get("read-node"); ccValue.Exists() {
- cItem.ReadNode = types.StringValue(ccValue.String())
- }
- if ccValue := cv.Get("write-node"); ccValue.Exists() {
- cItem.WriteNode = types.StringValue(ccValue.String())
- }
- if ccValue := cv.Get("notify-node"); ccValue.Exists() {
- cItem.NotifyNode = types.StringValue(ccValue.String())
- }
- if ccValue := cv.Get("access-config.ipv6-acl"); ccValue.Exists() {
- cItem.AccessIpv6Acl = types.StringValue(ccValue.String())
- }
- if ccValue := cv.Get("access-config.standard-acl"); ccValue.Exists() {
- cItem.AccessStandardAcl = types.Int64Value(ccValue.Int())
- }
- if ccValue := cv.Get("access-config.acl-name"); ccValue.Exists() {
- cItem.AccessAclName = types.StringValue(ccValue.String())
- }
- item.V3Security = append(item.V3Security, cItem)
- return true
- })
- }
- data.Groups = append(data.Groups, item)
- return true
- })
+ if !state.TrapSourcePortChannelSubinterface.IsNull() && data.TrapSourcePortChannelSubinterface.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:trap-source/Port-channel-subinterface/Port-channel")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-snmp:user.names"); value.Exists() {
- data.Users = make([]SNMPServerUsers, 0)
- value.ForEach(func(k, v gjson.Result) bool {
- item := SNMPServerUsers{}
- if cValue := v.Get("username"); cValue.Exists() {
- item.Username = types.StringValue(cValue.String())
- }
- if cValue := v.Get("grpname"); cValue.Exists() {
- item.Grpname = types.StringValue(cValue.String())
- }
- if cValue := v.Get("v3.auth-config.algorithm"); cValue.Exists() {
- item.V3AuthAlgorithm = types.StringValue(cValue.String())
- }
- if cValue := v.Get("v3.auth-config.password"); cValue.Exists() {
- item.V3AuthPassword = types.StringValue(cValue.String())
- }
- if cValue := v.Get("v3.auth-config.priv-config.aes.algorithm"); cValue.Exists() {
- item.V3AuthPrivAesAlgorithm = types.StringValue(cValue.String())
- }
- if cValue := v.Get("v3.auth-config.priv-config.aes.password"); cValue.Exists() {
- item.V3AuthPrivAesPassword = types.StringValue(cValue.String())
- }
- if cValue := v.Get("v3.auth-config.priv-config.aes.access-config.ipv6-acl"); cValue.Exists() {
- item.V3AuthPrivAesAccessIpv6Acl = types.StringValue(cValue.String())
- }
- if cValue := v.Get("v3.auth-config.priv-config.aes.access-config.standard-acl"); cValue.Exists() {
- item.V3AuthPrivAesAccessStandardAcl = types.Int64Value(cValue.Int())
- }
- if cValue := v.Get("v3.auth-config.priv-config.aes.access-config.acl-name"); cValue.Exists() {
- item.V3AuthPrivAesAccessAclName = types.StringValue(cValue.String())
- }
- if cValue := v.Get("v3.auth-config.priv-config.des.password"); cValue.Exists() {
- item.V3AuthPrivDesPassword = types.StringValue(cValue.String())
- }
- if cValue := v.Get("v3.auth-config.priv-config.des.access-config.ipv6-acl"); cValue.Exists() {
- item.V3AuthPrivDesAccessIpv6Acl = types.StringValue(cValue.String())
- }
- if cValue := v.Get("v3.auth-config.priv-config.des.access-config.standard-acl"); cValue.Exists() {
- item.V3AuthPrivDesAccessStandardAcl = types.Int64Value(cValue.Int())
- }
- if cValue := v.Get("v3.auth-config.priv-config.des.access-config.acl-name"); cValue.Exists() {
- item.V3AuthPrivDesAccessAclName = types.StringValue(cValue.String())
- }
- if cValue := v.Get("v3.auth-config.priv-config.des3.password"); cValue.Exists() {
- item.V3AuthPrivDes3Password = types.StringValue(cValue.String())
- }
- if cValue := v.Get("v3.auth-config.priv-config.des3.access-config.ipv6-acl"); cValue.Exists() {
- item.V3AuthPrivDes3AccessIpv6Acl = types.StringValue(cValue.String())
- }
- if cValue := v.Get("v3.auth-config.priv-config.des3.access-config.standard-acl"); cValue.Exists() {
- item.V3AuthPrivDes3AccessStandardAcl = types.Int64Value(cValue.Int())
- }
- if cValue := v.Get("v3.auth-config.priv-config.des3.access-config.acl-name"); cValue.Exists() {
- item.V3AuthPrivDes3AccessAclName = types.StringValue(cValue.String())
- }
- if cValue := v.Get("v3.auth-config.access-config.ipv6-acl"); cValue.Exists() {
- item.V3AuthAccessIpv6Acl = types.StringValue(cValue.String())
- }
- if cValue := v.Get("v3.auth-config.access-config.standard-acl"); cValue.Exists() {
- item.V3AuthAccessStandardAcl = types.Int64Value(cValue.Int())
- }
- if cValue := v.Get("v3.auth-config.access-config.acl-name"); cValue.Exists() {
- item.V3AuthAccessAclName = types.StringValue(cValue.String())
- }
- data.Users = append(data.Users, item)
- return true
- })
+ if !state.TrapSourceVlan.IsNull() && data.TrapSourceVlan.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-snmp:trap-source/Vlan")
}
-}
-
-// End of section. //template:end fromBodyData
-
-// Section below is generated&owned by "gen/generator.go". //template:begin getDeletedItems
-
-func (data *SNMPServer) getDeletedItems(ctx context.Context, state SNMPServer) []string {
- deletedItems := make([]string, 0)
- for i := range state.Users {
- stateKeyValues := [...]string{state.Users[i].Username.ValueString(), state.Users[i].Grpname.ValueString()}
+ for i := range state.SnmpCommunities {
+ stateKeys := [...]string{"name"}
+ stateKeyValues := [...]string{state.SnmpCommunities[i].Name.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
emptyKeys := true
- if !reflect.ValueOf(state.Users[i].Username.ValueString()).IsZero() {
- emptyKeys = false
- }
- if !reflect.ValueOf(state.Users[i].Grpname.ValueString()).IsZero() {
+ if !reflect.ValueOf(state.SnmpCommunities[i].Name.ValueString()).IsZero() {
emptyKeys = false
}
if emptyKeys {
@@ -6336,81 +14134,41 @@ func (data *SNMPServer) getDeletedItems(ctx context.Context, state SNMPServer) [
}
found := false
- for j := range data.Users {
+ for j := range data.SnmpCommunities {
found = true
- if state.Users[i].Username.ValueString() != data.Users[j].Username.ValueString() {
- found = false
- }
- if state.Users[i].Grpname.ValueString() != data.Users[j].Grpname.ValueString() {
+ if state.SnmpCommunities[i].Name.ValueString() != data.SnmpCommunities[j].Name.ValueString() {
found = false
}
if found {
- if !state.Users[i].V3AuthAccessAclName.IsNull() && data.Users[j].V3AuthAccessAclName.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:user/names=%v/v3/auth-config/access-config/acl-name", state.getPath(), strings.Join(stateKeyValues[:], ",")))
- }
- if !state.Users[i].V3AuthAccessStandardAcl.IsNull() && data.Users[j].V3AuthAccessStandardAcl.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:user/names=%v/v3/auth-config/access-config/standard-acl", state.getPath(), strings.Join(stateKeyValues[:], ",")))
- }
- if !state.Users[i].V3AuthAccessIpv6Acl.IsNull() && data.Users[j].V3AuthAccessIpv6Acl.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:user/names=%v/v3/auth-config/access-config/ipv6-acl", state.getPath(), strings.Join(stateKeyValues[:], ",")))
- }
- if !state.Users[i].V3AuthPrivDes3AccessAclName.IsNull() && data.Users[j].V3AuthPrivDes3AccessAclName.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:user/names=%v/v3/auth-config/priv-config/des3/access-config/acl-name", state.getPath(), strings.Join(stateKeyValues[:], ",")))
- }
- if !state.Users[i].V3AuthPrivDes3AccessStandardAcl.IsNull() && data.Users[j].V3AuthPrivDes3AccessStandardAcl.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:user/names=%v/v3/auth-config/priv-config/des3/access-config/standard-acl", state.getPath(), strings.Join(stateKeyValues[:], ",")))
- }
- if !state.Users[i].V3AuthPrivDes3AccessIpv6Acl.IsNull() && data.Users[j].V3AuthPrivDes3AccessIpv6Acl.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:user/names=%v/v3/auth-config/priv-config/des3/access-config/ipv6-acl", state.getPath(), strings.Join(stateKeyValues[:], ",")))
- }
- if !state.Users[i].V3AuthPrivDes3Password.IsNull() && data.Users[j].V3AuthPrivDes3Password.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:user/names=%v/v3/auth-config/priv-config/des3/password", state.getPath(), strings.Join(stateKeyValues[:], ",")))
- }
- if !state.Users[i].V3AuthPrivDesAccessAclName.IsNull() && data.Users[j].V3AuthPrivDesAccessAclName.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:user/names=%v/v3/auth-config/priv-config/des/access-config/acl-name", state.getPath(), strings.Join(stateKeyValues[:], ",")))
- }
- if !state.Users[i].V3AuthPrivDesAccessStandardAcl.IsNull() && data.Users[j].V3AuthPrivDesAccessStandardAcl.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:user/names=%v/v3/auth-config/priv-config/des/access-config/standard-acl", state.getPath(), strings.Join(stateKeyValues[:], ",")))
- }
- if !state.Users[i].V3AuthPrivDesAccessIpv6Acl.IsNull() && data.Users[j].V3AuthPrivDesAccessIpv6Acl.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:user/names=%v/v3/auth-config/priv-config/des/access-config/ipv6-acl", state.getPath(), strings.Join(stateKeyValues[:], ",")))
- }
- if !state.Users[i].V3AuthPrivDesPassword.IsNull() && data.Users[j].V3AuthPrivDesPassword.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:user/names=%v/v3/auth-config/priv-config/des/password", state.getPath(), strings.Join(stateKeyValues[:], ",")))
- }
- if !state.Users[i].V3AuthPrivAesAccessAclName.IsNull() && data.Users[j].V3AuthPrivAesAccessAclName.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:user/names=%v/v3/auth-config/priv-config/aes/access-config/acl-name", state.getPath(), strings.Join(stateKeyValues[:], ",")))
- }
- if !state.Users[i].V3AuthPrivAesAccessStandardAcl.IsNull() && data.Users[j].V3AuthPrivAesAccessStandardAcl.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:user/names=%v/v3/auth-config/priv-config/aes/access-config/standard-acl", state.getPath(), strings.Join(stateKeyValues[:], ",")))
- }
- if !state.Users[i].V3AuthPrivAesAccessIpv6Acl.IsNull() && data.Users[j].V3AuthPrivAesAccessIpv6Acl.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:user/names=%v/v3/auth-config/priv-config/aes/access-config/ipv6-acl", state.getPath(), strings.Join(stateKeyValues[:], ",")))
- }
- if !state.Users[i].V3AuthPrivAesPassword.IsNull() && data.Users[j].V3AuthPrivAesPassword.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:user/names=%v/v3/auth-config/priv-config/aes/password", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ if !state.SnmpCommunities[i].View.IsNull() && data.SnmpCommunities[j].View.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-snmp:community-config%v/view", predicates))
}
- if !state.Users[i].V3AuthPrivAesAlgorithm.IsNull() && data.Users[j].V3AuthPrivAesAlgorithm.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:user/names=%v/v3/auth-config/priv-config/aes/algorithm", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ if !state.SnmpCommunities[i].Permission.IsNull() && data.SnmpCommunities[j].Permission.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-snmp:community-config%v/permission", predicates))
}
- if !state.Users[i].V3AuthPassword.IsNull() && data.Users[j].V3AuthPassword.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:user/names=%v/v3/auth-config/password", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ if !state.SnmpCommunities[i].Ipv6.IsNull() && data.SnmpCommunities[j].Ipv6.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-snmp:community-config%v/ipv6", predicates))
}
- if !state.Users[i].V3AuthAlgorithm.IsNull() && data.Users[j].V3AuthAlgorithm.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:user/names=%v/v3/auth-config/algorithm", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ if !state.SnmpCommunities[i].AccessListName.IsNull() && data.SnmpCommunities[j].AccessListName.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-snmp:community-config%v/access-list-name", predicates))
}
break
}
}
if !found {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:user/names=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-snmp:community-config%v", predicates))
}
}
- for i := range state.Groups {
- stateKeyValues := [...]string{state.Groups[i].Name.ValueString()}
+ for i := range state.Contexts {
+ stateKeys := [...]string{"name"}
+ stateKeyValues := [...]string{state.Contexts[i].Name.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
emptyKeys := true
- if !reflect.ValueOf(state.Groups[i].Name.ValueString()).IsZero() {
+ if !reflect.ValueOf(state.Contexts[i].Name.ValueString()).IsZero() {
emptyKeys = false
}
if emptyKeys {
@@ -6418,70 +14176,26 @@ func (data *SNMPServer) getDeletedItems(ctx context.Context, state SNMPServer) [
}
found := false
- for j := range data.Groups {
+ for j := range data.Contexts {
found = true
- if state.Groups[i].Name.ValueString() != data.Groups[j].Name.ValueString() {
+ if state.Contexts[i].Name.ValueString() != data.Contexts[j].Name.ValueString() {
found = false
}
if found {
- for ci := range state.Groups[i].V3Security {
- cstateKeyValues := [...]string{state.Groups[i].V3Security[ci].SecurityLevel.ValueString()}
-
- cemptyKeys := true
- if !reflect.ValueOf(state.Groups[i].V3Security[ci].SecurityLevel.ValueString()).IsZero() {
- cemptyKeys = false
- }
- if cemptyKeys {
- continue
- }
-
- found := false
- for cj := range data.Groups[j].V3Security {
- found = true
- if state.Groups[i].V3Security[ci].SecurityLevel.ValueString() != data.Groups[j].V3Security[cj].SecurityLevel.ValueString() {
- found = false
- }
- if found {
- if !state.Groups[i].V3Security[ci].AccessAclName.IsNull() && data.Groups[j].V3Security[cj].AccessAclName.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:group=%v/v3/security-level-list=%v/access-config/acl-name", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
- }
- if !state.Groups[i].V3Security[ci].AccessStandardAcl.IsNull() && data.Groups[j].V3Security[cj].AccessStandardAcl.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:group=%v/v3/security-level-list=%v/access-config/standard-acl", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
- }
- if !state.Groups[i].V3Security[ci].AccessIpv6Acl.IsNull() && data.Groups[j].V3Security[cj].AccessIpv6Acl.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:group=%v/v3/security-level-list=%v/access-config/ipv6-acl", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
- }
- if !state.Groups[i].V3Security[ci].NotifyNode.IsNull() && data.Groups[j].V3Security[cj].NotifyNode.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:group=%v/v3/security-level-list=%v/notify-node", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
- }
- if !state.Groups[i].V3Security[ci].WriteNode.IsNull() && data.Groups[j].V3Security[cj].WriteNode.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:group=%v/v3/security-level-list=%v/write-node", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
- }
- if !state.Groups[i].V3Security[ci].ReadNode.IsNull() && data.Groups[j].V3Security[cj].ReadNode.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:group=%v/v3/security-level-list=%v/read-node", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
- }
- if !state.Groups[i].V3Security[ci].MatchNode.IsNull() && data.Groups[j].V3Security[cj].MatchNode.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:group=%v/v3/security-level-list=%v/match-node", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
- }
- if !state.Groups[i].V3Security[ci].ContextNode.IsNull() && data.Groups[j].V3Security[cj].ContextNode.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:group=%v/v3/security-level-list=%v/context-node", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
- }
- break
- }
- }
- if !found {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:group=%v/v3/security-level-list=%v", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
- }
- }
break
}
}
if !found {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:group=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-snmp:context%v", predicates))
}
}
for i := range state.Views {
+ stateKeys := [...]string{"name", "mib"}
stateKeyValues := [...]string{state.Views[i].Name.ValueString(), state.Views[i].Mib.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
emptyKeys := true
if !reflect.ValueOf(state.Views[i].Name.ValueString()).IsZero() {
@@ -6505,20 +14219,25 @@ func (data *SNMPServer) getDeletedItems(ctx context.Context, state SNMPServer) [
}
if found {
if !state.Views[i].IncExl.IsNull() && data.Views[j].IncExl.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:view=%v/inc-exl", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-snmp:view%v/inc-exl", predicates))
}
break
}
}
if !found {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:view=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-snmp:view%v", predicates))
}
}
- for i := range state.Contexts {
- stateKeyValues := [...]string{state.Contexts[i].Name.ValueString()}
+ for i := range state.Groups {
+ stateKeys := [...]string{"id"}
+ stateKeyValues := [...]string{state.Groups[i].Name.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
emptyKeys := true
- if !reflect.ValueOf(state.Contexts[i].Name.ValueString()).IsZero() {
+ if !reflect.ValueOf(state.Groups[i].Name.ValueString()).IsZero() {
emptyKeys = false
}
if emptyKeys {
@@ -6526,24 +14245,86 @@ func (data *SNMPServer) getDeletedItems(ctx context.Context, state SNMPServer) [
}
found := false
- for j := range data.Contexts {
+ for j := range data.Groups {
found = true
- if state.Contexts[i].Name.ValueString() != data.Contexts[j].Name.ValueString() {
+ if state.Groups[i].Name.ValueString() != data.Groups[j].Name.ValueString() {
found = false
}
if found {
+ for ci := range state.Groups[i].V3Security {
+ cstateKeys := [...]string{"security-level"}
+ cstateKeyValues := [...]string{state.Groups[i].V3Security[ci].SecurityLevel.ValueString()}
+ cpredicates := ""
+ for i := range cstateKeys {
+ cpredicates += fmt.Sprintf("[%s='%s']", cstateKeys[i], cstateKeyValues[i])
+ }
+
+ cemptyKeys := true
+ if !reflect.ValueOf(state.Groups[i].V3Security[ci].SecurityLevel.ValueString()).IsZero() {
+ cemptyKeys = false
+ }
+ if cemptyKeys {
+ continue
+ }
+
+ found := false
+ for cj := range data.Groups[j].V3Security {
+ found = true
+ if state.Groups[i].V3Security[ci].SecurityLevel.ValueString() != data.Groups[j].V3Security[cj].SecurityLevel.ValueString() {
+ found = false
+ }
+ if found {
+ if !state.Groups[i].V3Security[ci].ContextNode.IsNull() && data.Groups[j].V3Security[cj].ContextNode.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-snmp:group%v/v3/security-level-list%v/context-node", predicates, cpredicates))
+ }
+ if !state.Groups[i].V3Security[ci].MatchNode.IsNull() && data.Groups[j].V3Security[cj].MatchNode.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-snmp:group%v/v3/security-level-list%v/match-node", predicates, cpredicates))
+ }
+ if !state.Groups[i].V3Security[ci].ReadNode.IsNull() && data.Groups[j].V3Security[cj].ReadNode.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-snmp:group%v/v3/security-level-list%v/read-node", predicates, cpredicates))
+ }
+ if !state.Groups[i].V3Security[ci].WriteNode.IsNull() && data.Groups[j].V3Security[cj].WriteNode.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-snmp:group%v/v3/security-level-list%v/write-node", predicates, cpredicates))
+ }
+ if !state.Groups[i].V3Security[ci].NotifyNode.IsNull() && data.Groups[j].V3Security[cj].NotifyNode.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-snmp:group%v/v3/security-level-list%v/notify-node", predicates, cpredicates))
+ }
+ if !state.Groups[i].V3Security[ci].AccessIpv6Acl.IsNull() && data.Groups[j].V3Security[cj].AccessIpv6Acl.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-snmp:group%v/v3/security-level-list%v/access-config/ipv6-acl", predicates, cpredicates))
+ }
+ if !state.Groups[i].V3Security[ci].AccessStandardAcl.IsNull() && data.Groups[j].V3Security[cj].AccessStandardAcl.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-snmp:group%v/v3/security-level-list%v/access-config/standard-acl", predicates, cpredicates))
+ }
+ if !state.Groups[i].V3Security[ci].AccessAclName.IsNull() && data.Groups[j].V3Security[cj].AccessAclName.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-snmp:group%v/v3/security-level-list%v/access-config/acl-name", predicates, cpredicates))
+ }
+ break
+ }
+ }
+ if !found {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-snmp:group%v/v3/security-level-list%v", predicates, cpredicates))
+ }
+ }
break
}
}
if !found {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:context=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-snmp:group%v", predicates))
}
}
- for i := range state.SnmpCommunities {
- stateKeyValues := [...]string{state.SnmpCommunities[i].Name.ValueString()}
+ for i := range state.Users {
+ stateKeys := [...]string{"username", "grpname"}
+ stateKeyValues := [...]string{state.Users[i].Username.ValueString(), state.Users[i].Grpname.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
emptyKeys := true
- if !reflect.ValueOf(state.SnmpCommunities[i].Name.ValueString()).IsZero() {
+ if !reflect.ValueOf(state.Users[i].Username.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if !reflect.ValueOf(state.Users[i].Grpname.ValueString()).IsZero() {
emptyKeys = false
}
if emptyKeys {
@@ -6551,1946 +14332,1991 @@ func (data *SNMPServer) getDeletedItems(ctx context.Context, state SNMPServer) [
}
found := false
- for j := range data.SnmpCommunities {
+ for j := range data.Users {
found = true
- if state.SnmpCommunities[i].Name.ValueString() != data.SnmpCommunities[j].Name.ValueString() {
+ if state.Users[i].Username.ValueString() != data.Users[j].Username.ValueString() {
+ found = false
+ }
+ if state.Users[i].Grpname.ValueString() != data.Users[j].Grpname.ValueString() {
found = false
}
if found {
- if !state.SnmpCommunities[i].AccessListName.IsNull() && data.SnmpCommunities[j].AccessListName.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:community-config=%v/access-list-name", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ if !state.Users[i].V3AuthAlgorithm.IsNull() && data.Users[j].V3AuthAlgorithm.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-snmp:user/names%v/v3/auth-config/algorithm", predicates))
}
- if !state.SnmpCommunities[i].Ipv6.IsNull() && data.SnmpCommunities[j].Ipv6.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:community-config=%v/ipv6", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ if !state.Users[i].V3AuthPassword.IsNull() && data.Users[j].V3AuthPassword.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-snmp:user/names%v/v3/auth-config/password", predicates))
}
- if !state.SnmpCommunities[i].Permission.IsNull() && data.SnmpCommunities[j].Permission.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:community-config=%v/permission", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ if !state.Users[i].V3AuthPrivAesAlgorithm.IsNull() && data.Users[j].V3AuthPrivAesAlgorithm.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-snmp:user/names%v/v3/auth-config/priv-config/aes/algorithm", predicates))
}
- if !state.SnmpCommunities[i].View.IsNull() && data.SnmpCommunities[j].View.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:community-config=%v/view", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ if !state.Users[i].V3AuthPrivAesPassword.IsNull() && data.Users[j].V3AuthPrivAesPassword.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-snmp:user/names%v/v3/auth-config/priv-config/aes/password", predicates))
+ }
+ if !state.Users[i].V3AuthPrivAesAccessIpv6Acl.IsNull() && data.Users[j].V3AuthPrivAesAccessIpv6Acl.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-snmp:user/names%v/v3/auth-config/priv-config/aes/access-config/ipv6-acl", predicates))
+ }
+ if !state.Users[i].V3AuthPrivAesAccessStandardAcl.IsNull() && data.Users[j].V3AuthPrivAesAccessStandardAcl.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-snmp:user/names%v/v3/auth-config/priv-config/aes/access-config/standard-acl", predicates))
+ }
+ if !state.Users[i].V3AuthPrivAesAccessAclName.IsNull() && data.Users[j].V3AuthPrivAesAccessAclName.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-snmp:user/names%v/v3/auth-config/priv-config/aes/access-config/acl-name", predicates))
+ }
+ if !state.Users[i].V3AuthPrivDesPassword.IsNull() && data.Users[j].V3AuthPrivDesPassword.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-snmp:user/names%v/v3/auth-config/priv-config/des/password", predicates))
+ }
+ if !state.Users[i].V3AuthPrivDesAccessIpv6Acl.IsNull() && data.Users[j].V3AuthPrivDesAccessIpv6Acl.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-snmp:user/names%v/v3/auth-config/priv-config/des/access-config/ipv6-acl", predicates))
+ }
+ if !state.Users[i].V3AuthPrivDesAccessStandardAcl.IsNull() && data.Users[j].V3AuthPrivDesAccessStandardAcl.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-snmp:user/names%v/v3/auth-config/priv-config/des/access-config/standard-acl", predicates))
+ }
+ if !state.Users[i].V3AuthPrivDesAccessAclName.IsNull() && data.Users[j].V3AuthPrivDesAccessAclName.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-snmp:user/names%v/v3/auth-config/priv-config/des/access-config/acl-name", predicates))
+ }
+ if !state.Users[i].V3AuthPrivDes3Password.IsNull() && data.Users[j].V3AuthPrivDes3Password.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-snmp:user/names%v/v3/auth-config/priv-config/des3/password", predicates))
+ }
+ if !state.Users[i].V3AuthPrivDes3AccessIpv6Acl.IsNull() && data.Users[j].V3AuthPrivDes3AccessIpv6Acl.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-snmp:user/names%v/v3/auth-config/priv-config/des3/access-config/ipv6-acl", predicates))
+ }
+ if !state.Users[i].V3AuthPrivDes3AccessStandardAcl.IsNull() && data.Users[j].V3AuthPrivDes3AccessStandardAcl.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-snmp:user/names%v/v3/auth-config/priv-config/des3/access-config/standard-acl", predicates))
+ }
+ if !state.Users[i].V3AuthPrivDes3AccessAclName.IsNull() && data.Users[j].V3AuthPrivDes3AccessAclName.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-snmp:user/names%v/v3/auth-config/priv-config/des3/access-config/acl-name", predicates))
+ }
+ if !state.Users[i].V3AuthAccessIpv6Acl.IsNull() && data.Users[j].V3AuthAccessIpv6Acl.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-snmp:user/names%v/v3/auth-config/access-config/ipv6-acl", predicates))
+ }
+ if !state.Users[i].V3AuthAccessStandardAcl.IsNull() && data.Users[j].V3AuthAccessStandardAcl.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-snmp:user/names%v/v3/auth-config/access-config/standard-acl", predicates))
+ }
+ if !state.Users[i].V3AuthAccessAclName.IsNull() && data.Users[j].V3AuthAccessAclName.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-snmp:user/names%v/v3/auth-config/access-config/acl-name", predicates))
}
break
}
}
if !found {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:community-config=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-snmp:user/names%v", predicates))
}
}
- if !state.TrapSourceVlan.IsNull() && data.TrapSourceVlan.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:trap-source/Vlan", state.getPath()))
- }
- if !state.TrapSourcePortChannelSubinterface.IsNull() && data.TrapSourcePortChannelSubinterface.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:trap-source/Port-channel-subinterface/Port-channel", state.getPath()))
- }
- if !state.TrapSourcePortChannel.IsNull() && data.TrapSourcePortChannel.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:trap-source/Port-channel", state.getPath()))
- }
- if !state.TrapSourceLoopback.IsNull() && data.TrapSourceLoopback.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:trap-source/Loopback", state.getPath()))
- }
- if !state.TrapSourceHundredGigE.IsNull() && data.TrapSourceHundredGigE.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:trap-source/HundredGigE", state.getPath()))
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletedItemsXML
+
+// Section below is generated&owned by "gen/generator.go". //template:begin getEmptyLeafsDelete
+
+func (data *SNMPServer) getEmptyLeafsDelete(ctx context.Context) []string {
+ emptyLeafsDelete := make([]string, 0)
+
+ if !data.EnableTrapsOspfv3StateChange.IsNull() && !data.EnableTrapsOspfv3StateChange.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ospfv3/state-change", data.getPath()))
}
- if !state.TrapSourceFortyGigabitEthernet.IsNull() && data.TrapSourceFortyGigabitEthernet.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:trap-source/FortyGigabitEthernet", state.getPath()))
+ if !data.EnableTrapsOspfv3Errors.IsNull() && !data.EnableTrapsOspfv3Errors.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ospfv3/errors", data.getPath()))
}
- if !state.TrapSourceTenGigabitEthernet.IsNull() && data.TrapSourceTenGigabitEthernet.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:trap-source/TenGigabitEthernet", state.getPath()))
+ if !data.EnableTrapsCbgp2.IsNull() && !data.EnableTrapsCbgp2.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/bgp-traps/cbgp2", data.getPath()))
}
- if !state.TrapSourceGigabitEthernet.IsNull() && data.TrapSourceGigabitEthernet.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:trap-source/GigabitEthernet", state.getPath()))
+ if !data.EnableTrapsBgp.IsNull() && !data.EnableTrapsBgp.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/bgp", data.getPath()))
}
- if !state.SourceInterfaceTrapsVlan.IsNull() && data.SourceInterfaceTrapsVlan.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:source-interface/traps/Vlan", state.getPath()))
+ if !data.EnableTrapsVoice.IsNull() && !data.EnableTrapsVoice.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/voice", data.getPath()))
}
- if !state.SourceInterfaceTrapsPortChannelSubinterface.IsNull() && data.SourceInterfaceTrapsPortChannelSubinterface.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:source-interface/traps/Port-channel-subinterface/Port-channel", state.getPath()))
+ if !data.EnableTrapsSrp.IsNull() && !data.EnableTrapsSrp.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/srp", data.getPath()))
}
- if !state.SourceInterfaceTrapsPortChannel.IsNull() && data.SourceInterfaceTrapsPortChannel.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:source-interface/traps/Port-channel", state.getPath()))
+ if !data.EnableTrapsSonet.IsNull() && !data.EnableTrapsSonet.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/sonet", data.getPath()))
}
- if !state.SourceInterfaceTrapsLoopback.IsNull() && data.SourceInterfaceTrapsLoopback.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:source-interface/traps/Loopback", state.getPath()))
+ if !data.EnableTrapsVrrp.IsNull() && !data.EnableTrapsVrrp.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/vrrp", data.getPath()))
}
- if !state.SourceInterfaceTrapsHundredGigE.IsNull() && data.SourceInterfaceTrapsHundredGigE.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:source-interface/traps/HundredGigE", state.getPath()))
+ if !data.EnableTrapsRsvp.IsNull() && !data.EnableTrapsRsvp.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/rsvp", data.getPath()))
}
- if !state.SourceInterfaceTrapsFortyGigabitEthernet.IsNull() && data.SourceInterfaceTrapsFortyGigabitEthernet.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:source-interface/traps/FortyGigabitEthernet", state.getPath()))
+ if !data.EnableTrapsResourcePolicy.IsNull() && !data.EnableTrapsResourcePolicy.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/resource-policy", data.getPath()))
}
- if !state.SourceInterfaceTrapsTenGigabitEthernet.IsNull() && data.SourceInterfaceTrapsTenGigabitEthernet.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:source-interface/traps/TenGigabitEthernet", state.getPath()))
+ if !data.EnableTrapsPppoe.IsNull() && !data.EnableTrapsPppoe.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/pppoe", data.getPath()))
}
- if !state.SourceInterfaceTrapsGigabitEthernet.IsNull() && data.SourceInterfaceTrapsGigabitEthernet.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:source-interface/traps/GigabitEthernet", state.getPath()))
+ if !data.EnableTrapsPfr.IsNull() && !data.EnableTrapsPfr.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/pfr", data.getPath()))
}
- if !state.SourceInterfaceInformsVlan.IsNull() && data.SourceInterfaceInformsVlan.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:source-interface/informs/Vlan", state.getPath()))
+ if !data.EnableTrapsPimstdmibInterfaceElection.IsNull() && !data.EnableTrapsPimstdmibInterfaceElection.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/pimstdmib/interface-election", data.getPath()))
}
- if !state.SourceInterfaceInformsPortChannelSubinterface.IsNull() && data.SourceInterfaceInformsPortChannelSubinterface.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:source-interface/informs/Port-channel-subinterface/Port-channel", state.getPath()))
+ if !data.EnableTrapsPimstdmibRpMappingChange.IsNull() && !data.EnableTrapsPimstdmibRpMappingChange.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/pimstdmib/rp-mapping-change", data.getPath()))
}
- if !state.SourceInterfaceInformsPortChannel.IsNull() && data.SourceInterfaceInformsPortChannel.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:source-interface/informs/Port-channel", state.getPath()))
+ if !data.EnableTrapsPimstdmibInvalidJoinPrune.IsNull() && !data.EnableTrapsPimstdmibInvalidJoinPrune.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/pimstdmib/invalid-join-prune", data.getPath()))
}
- if !state.SourceInterfaceInformsLoopback.IsNull() && data.SourceInterfaceInformsLoopback.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:source-interface/informs/Loopback", state.getPath()))
+ if !data.EnableTrapsPimstdmibInvalidRegister.IsNull() && !data.EnableTrapsPimstdmibInvalidRegister.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/pimstdmib/invalid-register", data.getPath()))
}
- if !state.SourceInterfaceInformsHundredGigE.IsNull() && data.SourceInterfaceInformsHundredGigE.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:source-interface/informs/HundredGigE", state.getPath()))
+ if !data.EnableTrapsPimstdmibNeighborLoss.IsNull() && !data.EnableTrapsPimstdmibNeighborLoss.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/pimstdmib/neighbor-loss", data.getPath()))
}
- if !state.SourceInterfaceInformsFortyGigabitEthernet.IsNull() && data.SourceInterfaceInformsFortyGigabitEthernet.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:source-interface/informs/FortyGigabitEthernet", state.getPath()))
+ if !data.EnableTrapsL2tunPseudowireStatus.IsNull() && !data.EnableTrapsL2tunPseudowireStatus.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/l2tun/pseudowire/status", data.getPath()))
}
- if !state.SourceInterfaceInformsTenGigabitEthernet.IsNull() && data.SourceInterfaceInformsTenGigabitEthernet.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:source-interface/informs/TenGigabitEthernet", state.getPath()))
+ if !data.EnableTrapsL2tunTunnel.IsNull() && !data.EnableTrapsL2tunTunnel.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/l2tun/tunnel", data.getPath()))
}
- if !state.SourceInterfaceInformsGigabitEthernet.IsNull() && data.SourceInterfaceInformsGigabitEthernet.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:source-interface/informs/GigabitEthernet", state.getPath()))
+ if !data.EnableTrapsL2tunSession.IsNull() && !data.EnableTrapsL2tunSession.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/l2tun/session", data.getPath()))
}
- if !state.EnableTrapsOspfv3StateChange.IsNull() && data.EnableTrapsOspfv3StateChange.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ospfv3/state-change", state.getPath()))
+ if !data.EnableTrapsIsdnLayer2.IsNull() && !data.EnableTrapsIsdnLayer2.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/isdn/layer2", data.getPath()))
}
- if !state.EnableTrapsOspfv3Errors.IsNull() && data.EnableTrapsOspfv3Errors.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ospfv3/errors", state.getPath()))
+ if !data.EnableTrapsIsdnIetf.IsNull() && !data.EnableTrapsIsdnIetf.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/isdn/ietf", data.getPath()))
}
- if !state.EnableTrapsCbgp2.IsNull() && data.EnableTrapsCbgp2.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/bgp-traps/cbgp2", state.getPath()))
+ if !data.EnableTrapsIsdnChanNotAvail.IsNull() && !data.EnableTrapsIsdnChanNotAvail.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/isdn/chan-not-avail", data.getPath()))
}
- if !state.EnableTrapsBgp.IsNull() && data.EnableTrapsBgp.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/bgp", state.getPath()))
+ if !data.EnableTrapsIsdnCallInformation.IsNull() && !data.EnableTrapsIsdnCallInformation.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/isdn/call-information", data.getPath()))
}
- if !state.EnableTrapsVoice.IsNull() && data.EnableTrapsVoice.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/voice", state.getPath()))
+ if !data.EnableTrapsIpLocalPool.IsNull() && !data.EnableTrapsIpLocalPool.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ip/local/pool", data.getPath()))
}
- if !state.EnableTrapsSrp.IsNull() && data.EnableTrapsSrp.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/srp", state.getPath()))
+ if !data.EnableTrapsFrameRelayMultilinkBundleMismatch.IsNull() && !data.EnableTrapsFrameRelayMultilinkBundleMismatch.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/frame-relay/multilink/bundle-mismatch", data.getPath()))
}
- if !state.EnableTrapsSonet.IsNull() && data.EnableTrapsSonet.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/sonet", state.getPath()))
+ if !data.EnableTrapsFrameRelayConfigBundleMismatch.IsNull() && !data.EnableTrapsFrameRelayConfigBundleMismatch.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/frame-relay-config/frame-relay-options/frame-relay/multilink/bundle-mismatch", data.getPath()))
}
- if !state.EnableTrapsVrrp.IsNull() && data.EnableTrapsVrrp.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/vrrp", state.getPath()))
+ if !data.EnableTrapsFrameRelayConfigSubifConfigs.IsNull() && !data.EnableTrapsFrameRelayConfigSubifConfigs.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/frame-relay-config/frame-relay-options/frame-relay/subif-configs/subif", data.getPath()))
}
- if !state.EnableTrapsRsvp.IsNull() && data.EnableTrapsRsvp.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/rsvp", state.getPath()))
+ if !data.EnableTrapsFrameRelayConfigOnly.IsNull() && !data.EnableTrapsFrameRelayConfigOnly.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/frame-relay-config/only-frame-relay/frame-relay", data.getPath()))
}
- if !state.EnableTrapsResourcePolicy.IsNull() && data.EnableTrapsResourcePolicy.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/resource-policy", state.getPath()))
+ if !data.EnableTrapsFirewallServerstatus.IsNull() && !data.EnableTrapsFirewallServerstatus.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/firewall/serverstatus", data.getPath()))
}
- if !state.EnableTrapsPppoe.IsNull() && data.EnableTrapsPppoe.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/pppoe", state.getPath()))
+ if !data.EnableTrapsEthernetEvcStatus.IsNull() && !data.EnableTrapsEthernetEvcStatus.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ethernet/evc/status", data.getPath()))
}
- if !state.EnableTrapsPfr.IsNull() && data.EnableTrapsPfr.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/pfr", state.getPath()))
+ if !data.EnableTrapsEthernetEvcDelete.IsNull() && !data.EnableTrapsEthernetEvcDelete.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ethernet/evc/delete", data.getPath()))
}
- if !state.EnableTrapsPimstdmibInterfaceElection.IsNull() && data.EnableTrapsPimstdmibInterfaceElection.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/pimstdmib/interface-election", state.getPath()))
+ if !data.EnableTrapsEthernetEvcCreate.IsNull() && !data.EnableTrapsEthernetEvcCreate.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ethernet/evc/create", data.getPath()))
}
- if !state.EnableTrapsPimstdmibRpMappingChange.IsNull() && data.EnableTrapsPimstdmibRpMappingChange.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/pimstdmib/rp-mapping-change", state.getPath()))
+ if !data.EnableTrapsEthernetCfmCrosscheckServiceUp.IsNull() && !data.EnableTrapsEthernetCfmCrosscheckServiceUp.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ethernet/cfm/crosscheck/service-up", data.getPath()))
}
- if !state.EnableTrapsPimstdmibInvalidJoinPrune.IsNull() && data.EnableTrapsPimstdmibInvalidJoinPrune.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/pimstdmib/invalid-join-prune", state.getPath()))
+ if !data.EnableTrapsEthernetCfmCrosscheckMepUnknown.IsNull() && !data.EnableTrapsEthernetCfmCrosscheckMepUnknown.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ethernet/cfm/crosscheck/mep-unknown", data.getPath()))
}
- if !state.EnableTrapsPimstdmibInvalidRegister.IsNull() && data.EnableTrapsPimstdmibInvalidRegister.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/pimstdmib/invalid-register", state.getPath()))
+ if !data.EnableTrapsEthernetCfmCrosscheckMepMissing.IsNull() && !data.EnableTrapsEthernetCfmCrosscheckMepMissing.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ethernet/cfm/crosscheck/mep-missing", data.getPath()))
}
- if !state.EnableTrapsPimstdmibNeighborLoss.IsNull() && data.EnableTrapsPimstdmibNeighborLoss.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/pimstdmib/neighbor-loss", state.getPath()))
+ if !data.EnableTrapsEthernetCfmCcMepUp.IsNull() && !data.EnableTrapsEthernetCfmCcMepUp.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ethernet/cfm/cc/mep-up", data.getPath()))
}
- if !state.EnableTrapsL2tunPseudowireStatus.IsNull() && data.EnableTrapsL2tunPseudowireStatus.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/l2tun/pseudowire/status", state.getPath()))
+ if !data.EnableTrapsEthernetCfmCcMepDown.IsNull() && !data.EnableTrapsEthernetCfmCcMepDown.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ethernet/cfm/cc/mep-down", data.getPath()))
}
- if !state.EnableTrapsL2tunTunnel.IsNull() && data.EnableTrapsL2tunTunnel.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/l2tun/tunnel", state.getPath()))
+ if !data.EnableTrapsEthernetCfmCcLoop.IsNull() && !data.EnableTrapsEthernetCfmCcLoop.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ethernet/cfm/cc/loop", data.getPath()))
}
- if !state.EnableTrapsL2tunSession.IsNull() && data.EnableTrapsL2tunSession.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/l2tun/session", state.getPath()))
+ if !data.EnableTrapsEthernetCfmCcCrossConnect.IsNull() && !data.EnableTrapsEthernetCfmCcCrossConnect.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ethernet/cfm/cc/cross-connect", data.getPath()))
}
- if !state.EnableTrapsIsdnLayer2.IsNull() && data.EnableTrapsIsdnLayer2.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/isdn/layer2", state.getPath()))
+ if !data.EnableTrapsEthernetCfmCcConfig.IsNull() && !data.EnableTrapsEthernetCfmCcConfig.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ethernet/cfm/cc/config", data.getPath()))
}
- if !state.EnableTrapsIsdnIetf.IsNull() && data.EnableTrapsIsdnIetf.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/isdn/ietf", state.getPath()))
+ if !data.EnableTrapsEthernetCfmAlarm.IsNull() && !data.EnableTrapsEthernetCfmAlarm.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ethernet/cfm/alarm", data.getPath()))
}
- if !state.EnableTrapsIsdnChanNotAvail.IsNull() && data.EnableTrapsIsdnChanNotAvail.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/isdn/chan-not-avail", state.getPath()))
+ if !data.EnableTrapsEtherOam.IsNull() && !data.EnableTrapsEtherOam.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ether-oam", data.getPath()))
}
- if !state.EnableTrapsIsdnCallInformation.IsNull() && data.EnableTrapsIsdnCallInformation.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/isdn/call-information", state.getPath()))
+ if !data.EnableTrapsEntityQfpThroughputNotif.IsNull() && !data.EnableTrapsEntityQfpThroughputNotif.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/entity-qfp/throughput-notif", data.getPath()))
}
- if !state.EnableTrapsIpLocalPool.IsNull() && data.EnableTrapsIpLocalPool.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ip/local/pool", state.getPath()))
+ if !data.EnableTrapsEntityQfpMemResThresh.IsNull() && !data.EnableTrapsEntityQfpMemResThresh.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/entity-qfp/mem-res-thresh", data.getPath()))
}
- if !state.EnableTrapsFrameRelayMultilinkBundleMismatch.IsNull() && data.EnableTrapsFrameRelayMultilinkBundleMismatch.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/frame-relay/multilink/bundle-mismatch", state.getPath()))
+ if !data.EnableTrapsEntityState.IsNull() && !data.EnableTrapsEntityState.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/entity-state", data.getPath()))
}
- if !state.EnableTrapsFrameRelayConfigBundleMismatch.IsNull() && data.EnableTrapsFrameRelayConfigBundleMismatch.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/frame-relay-config/frame-relay-options/frame-relay/multilink/bundle-mismatch", state.getPath()))
+ if !data.EnableTrapsEntitySensor.IsNull() && !data.EnableTrapsEntitySensor.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/entity-sensor", data.getPath()))
}
- if !state.EnableTrapsFrameRelaySubifInterval.IsNull() && data.EnableTrapsFrameRelaySubifInterval.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/frame-relay/subif/interval", state.getPath()))
+ if !data.EnableTrapsDspOperState.IsNull() && !data.EnableTrapsDspOperState.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/dsp/oper-state", data.getPath()))
}
- if !state.EnableTrapsFrameRelaySubifCount.IsNull() && data.EnableTrapsFrameRelaySubifCount.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/frame-relay/subif/count", state.getPath()))
+ if !data.EnableTrapsDspCardStatus.IsNull() && !data.EnableTrapsDspCardStatus.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/dsp/card-status", data.getPath()))
}
- if !state.EnableTrapsFrameRelayConfigSubifConfigs.IsNull() && data.EnableTrapsFrameRelayConfigSubifConfigs.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/frame-relay-config/frame-relay-options/frame-relay/subif-configs/subif", state.getPath()))
+ if !data.EnableTrapsDs1.IsNull() && !data.EnableTrapsDs1.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ds1", data.getPath()))
}
- if !state.EnableTrapsFrameRelayConfigOnly.IsNull() && data.EnableTrapsFrameRelayConfigOnly.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/frame-relay-config/only-frame-relay/frame-relay", state.getPath()))
+ if !data.EnableTrapsDlsw.IsNull() && !data.EnableTrapsDlsw.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/dlsw", data.getPath()))
}
- if !state.EnableTrapsFirewallServerstatus.IsNull() && data.EnableTrapsFirewallServerstatus.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/firewall/serverstatus", state.getPath()))
+ if !data.EnableTrapsDial.IsNull() && !data.EnableTrapsDial.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/dial", data.getPath()))
}
- if !state.EnableTrapsEthernetEvcStatus.IsNull() && data.EnableTrapsEthernetEvcStatus.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ethernet/evc/status", state.getPath()))
+ if !data.EnableTrapsCnpd.IsNull() && !data.EnableTrapsCnpd.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/cnpd", data.getPath()))
}
- if !state.EnableTrapsEthernetEvcDelete.IsNull() && data.EnableTrapsEthernetEvcDelete.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ethernet/evc/delete", state.getPath()))
+ if !data.EnableTrapsCasa.IsNull() && !data.EnableTrapsCasa.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/casa", data.getPath()))
}
- if !state.EnableTrapsEthernetEvcCreate.IsNull() && data.EnableTrapsEthernetEvcCreate.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ethernet/evc/create", state.getPath()))
+ if !data.EnableTrapsPki.IsNull() && !data.EnableTrapsPki.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/pki", data.getPath()))
}
- if !state.EnableTrapsEthernetCfmCrosscheckServiceUp.IsNull() && data.EnableTrapsEthernetCfmCrosscheckServiceUp.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ethernet/cfm/crosscheck/service-up", state.getPath()))
+ if !data.EnableTrapsAdslline.IsNull() && !data.EnableTrapsAdslline.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/adslline", data.getPath()))
}
- if !state.EnableTrapsEthernetCfmCrosscheckMepUnknown.IsNull() && data.EnableTrapsEthernetCfmCrosscheckMepUnknown.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ethernet/cfm/crosscheck/mep-unknown", state.getPath()))
+ if !data.EnableTrapsVdsl2line.IsNull() && !data.EnableTrapsVdsl2line.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/vdsl2line", data.getPath()))
}
- if !state.EnableTrapsEthernetCfmCrosscheckMepMissing.IsNull() && data.EnableTrapsEthernetCfmCrosscheckMepMissing.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ethernet/cfm/crosscheck/mep-missing", state.getPath()))
+ if !data.EnableTrapsAaaServer.IsNull() && !data.EnableTrapsAaaServer.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/aaa_server", data.getPath()))
}
- if !state.EnableTrapsEthernetCfmCcMepUp.IsNull() && data.EnableTrapsEthernetCfmCcMepUp.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ethernet/cfm/cc/mep-up", state.getPath()))
+ if !data.EnableTrapsLisp.IsNull() && !data.EnableTrapsLisp.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/lisp", data.getPath()))
}
- if !state.EnableTrapsEthernetCfmCcMepDown.IsNull() && data.EnableTrapsEthernetCfmCcMepDown.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ethernet/cfm/cc/mep-down", state.getPath()))
+ if !data.EnableTrapsMvpn.IsNull() && !data.EnableTrapsMvpn.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/mvpn", data.getPath()))
}
- if !state.EnableTrapsEthernetCfmCcLoop.IsNull() && data.EnableTrapsEthernetCfmCcLoop.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ethernet/cfm/cc/loop", state.getPath()))
+ if !data.EnableTrapsVrfmibVnetTrunkDown.IsNull() && !data.EnableTrapsVrfmibVnetTrunkDown.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/vrfmib/vnet-trunk-down", data.getPath()))
}
- if !state.EnableTrapsEthernetCfmCcCrossConnect.IsNull() && data.EnableTrapsEthernetCfmCcCrossConnect.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ethernet/cfm/cc/cross-connect", state.getPath()))
+ if !data.EnableTrapsVrfmibVnetTrunkUp.IsNull() && !data.EnableTrapsVrfmibVnetTrunkUp.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/vrfmib/vnet-trunk-up", data.getPath()))
}
- if !state.EnableTrapsEthernetCfmCcConfig.IsNull() && data.EnableTrapsEthernetCfmCcConfig.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ethernet/cfm/cc/config", state.getPath()))
+ if !data.EnableTrapsVrfmibVrfDown.IsNull() && !data.EnableTrapsVrfmibVrfDown.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/vrfmib/vrf-down", data.getPath()))
}
- if !state.EnableTrapsEthernetCfmAlarm.IsNull() && data.EnableTrapsEthernetCfmAlarm.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ethernet/cfm/alarm", state.getPath()))
+ if !data.EnableTrapsVrfmibVrfUp.IsNull() && !data.EnableTrapsVrfmibVrfUp.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/vrfmib/vrf-up", data.getPath()))
}
- if !state.EnableTrapsEtherOam.IsNull() && data.EnableTrapsEtherOam.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ether-oam", state.getPath()))
+ if !data.EnableTrapsMacNotificationThreshold.IsNull() && !data.EnableTrapsMacNotificationThreshold.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/mac-notification/threshold", data.getPath()))
}
- if !state.EnableTrapsEntityQfpThroughputNotif.IsNull() && data.EnableTrapsEntityQfpThroughputNotif.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/entity-qfp/throughput-notif", state.getPath()))
+ if !data.EnableTrapsMacNotificationMove.IsNull() && !data.EnableTrapsMacNotificationMove.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/mac-notification/move", data.getPath()))
}
- if !state.EnableTrapsEntityQfpMemResThresh.IsNull() && data.EnableTrapsEntityQfpMemResThresh.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/entity-qfp/mem-res-thresh", state.getPath()))
+ if !data.EnableTrapsMacNotificationChange.IsNull() && !data.EnableTrapsMacNotificationChange.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/mac-notification/change", data.getPath()))
}
- if !state.EnableTrapsEntityState.IsNull() && data.EnableTrapsEntityState.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/entity-state", state.getPath()))
+ if !data.EnableTrapsBulkstatTransfer.IsNull() && !data.EnableTrapsBulkstatTransfer.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/bulkstat/transfer", data.getPath()))
}
- if !state.EnableTrapsEntitySensor.IsNull() && data.EnableTrapsEntitySensor.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/entity-sensor", state.getPath()))
+ if !data.EnableTrapsBulkstatCollection.IsNull() && !data.EnableTrapsBulkstatCollection.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/bulkstat/collection", data.getPath()))
}
- if !state.EnableTrapsDspOperState.IsNull() && data.EnableTrapsDspOperState.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/dsp/oper-state", state.getPath()))
+ if !data.EnableTrapsTransceiverAll.IsNull() && !data.EnableTrapsTransceiverAll.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/transceiver/all", data.getPath()))
}
- if !state.EnableTrapsDspCardStatus.IsNull() && data.EnableTrapsDspCardStatus.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/dsp/card-status", state.getPath()))
+ if !data.EnableTrapsRf.IsNull() && !data.EnableTrapsRf.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/rf", data.getPath()))
}
- if !state.EnableTrapsDs1.IsNull() && data.EnableTrapsDs1.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ds1", state.getPath()))
+ if !data.EnableTrapsErrdisable.IsNull() && !data.EnableTrapsErrdisable.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/errdisable", data.getPath()))
}
- if !state.EnableTrapsDlsw.IsNull() && data.EnableTrapsDlsw.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/dlsw", state.getPath()))
+ if !data.EnableTrapsVlanMembership.IsNull() && !data.EnableTrapsVlanMembership.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/vlan-membership", data.getPath()))
}
- if !state.EnableTrapsDial.IsNull() && data.EnableTrapsDial.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/dial", state.getPath()))
+ if !data.EnableTrapsLocalAuth.IsNull() && !data.EnableTrapsLocalAuth.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/local-auth", data.getPath()))
}
- if !state.EnableTrapsCnpd.IsNull() && data.EnableTrapsCnpd.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/cnpd", state.getPath()))
+ if !data.EnableTrapsFastRerouteProtected.IsNull() && !data.EnableTrapsFastRerouteProtected.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/mpls/fast-reroute/protected", data.getPath()))
}
- if !state.EnableTrapsCasa.IsNull() && data.EnableTrapsCasa.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/casa", state.getPath()))
+ if !data.EnableTrapsMplsLdp.IsNull() && !data.EnableTrapsMplsLdp.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/mpls/ldp", data.getPath()))
}
- if !state.EnableTrapsAlarmType.IsNull() && data.EnableTrapsAlarmType.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/alarms/alarm-type", state.getPath()))
+ if !data.EnableTrapsMplsRfcLdp.IsNull() && !data.EnableTrapsMplsRfcLdp.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/mpls/rfc/ldp", data.getPath()))
}
- if !state.EnableTrapsPki.IsNull() && data.EnableTrapsPki.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/pki", state.getPath()))
+ if !data.EnableTrapsMplsRfc.IsNull() && !data.EnableTrapsMplsRfc.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/mpls/rfc", data.getPath()))
}
- if !state.EnableTrapsAdslline.IsNull() && data.EnableTrapsAdslline.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/adslline", state.getPath()))
+ if !data.EnableTrapsMplsVpn.IsNull() && !data.EnableTrapsMplsVpn.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/mpls/vpn", data.getPath()))
}
- if !state.EnableTrapsVdsl2line.IsNull() && data.EnableTrapsVdsl2line.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/vdsl2line", state.getPath()))
+ if !data.EnableTrapsMpls.IsNull() && !data.EnableTrapsMpls.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/mpls", data.getPath()))
}
- if !state.EnableTrapsAaaServer.IsNull() && data.EnableTrapsAaaServer.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/aaa_server", state.getPath()))
+ if !data.EnableTrapsMplsTrafficEng.IsNull() && !data.EnableTrapsMplsTrafficEng.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/mpls/traffic-eng", data.getPath()))
}
- if !state.EnableTrapsLisp.IsNull() && data.EnableTrapsLisp.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/lisp", state.getPath()))
+ if !data.EnableTrapsNhrpQuotaExceeded.IsNull() && !data.EnableTrapsNhrpQuotaExceeded.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/nhrp/quota-exceeded", data.getPath()))
}
- if !state.EnableTrapsMvpn.IsNull() && data.EnableTrapsMvpn.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/mvpn", state.getPath()))
+ if !data.EnableTrapsNhrpNhp.IsNull() && !data.EnableTrapsNhrpNhp.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/nhrp/nhp", data.getPath()))
}
- if !state.EnableTrapsVrfmibVnetTrunkDown.IsNull() && data.EnableTrapsVrfmibVnetTrunkDown.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/vrfmib/vnet-trunk-down", state.getPath()))
+ if !data.EnableTrapsNhrpNhc.IsNull() && !data.EnableTrapsNhrpNhc.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/nhrp/nhc", data.getPath()))
}
- if !state.EnableTrapsVrfmibVnetTrunkUp.IsNull() && data.EnableTrapsVrfmibVnetTrunkUp.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/vrfmib/vnet-trunk-up", state.getPath()))
+ if !data.EnableTrapsNhrpNhs.IsNull() && !data.EnableTrapsNhrpNhs.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/nhrp/nhs", data.getPath()))
}
- if !state.EnableTrapsVrfmibVrfDown.IsNull() && data.EnableTrapsVrfmibVrfDown.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/vrfmib/vrf-down", state.getPath()))
+ if !data.EnableTrapsBgpCbgp2.IsNull() && !data.EnableTrapsBgpCbgp2.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/", data.getPath()))
}
- if !state.EnableTrapsVrfmibVrfUp.IsNull() && data.EnableTrapsVrfmibVrfUp.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/vrfmib/vrf-up", state.getPath()))
+ if !data.EnableTrapsSyslog.IsNull() && !data.EnableTrapsSyslog.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/syslog", data.getPath()))
}
- if !state.EnableTrapsMacNotificationThreshold.IsNull() && data.EnableTrapsMacNotificationThreshold.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/mac-notification/threshold", state.getPath()))
+ if !data.EnableTrapsStpxLoopInconsistency.IsNull() && !data.EnableTrapsStpxLoopInconsistency.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/stpx/loop-inconsistency", data.getPath()))
}
- if !state.EnableTrapsMacNotificationMove.IsNull() && data.EnableTrapsMacNotificationMove.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/mac-notification/move", state.getPath()))
+ if !data.EnableTrapsStpxRootInconsistency.IsNull() && !data.EnableTrapsStpxRootInconsistency.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/stpx/root-inconsistency", data.getPath()))
}
- if !state.EnableTrapsMacNotificationChange.IsNull() && data.EnableTrapsMacNotificationChange.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/mac-notification/change", state.getPath()))
+ if !data.EnableTrapsStpxInconsistency.IsNull() && !data.EnableTrapsStpxInconsistency.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/stpx/inconsistency", data.getPath()))
}
- if !state.EnableTrapsBulkstatTransfer.IsNull() && data.EnableTrapsBulkstatTransfer.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/bulkstat/transfer", state.getPath()))
+ if !data.EnableTrapsBridgeTopologychange.IsNull() && !data.EnableTrapsBridgeTopologychange.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/bridge/topologychange", data.getPath()))
}
- if !state.EnableTrapsBulkstatCollection.IsNull() && data.EnableTrapsBulkstatCollection.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/bulkstat/collection", state.getPath()))
+ if !data.EnableTrapsBridgeNewroot.IsNull() && !data.EnableTrapsBridgeNewroot.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/bridge/newroot", data.getPath()))
}
- if !state.EnableTrapsTransceiverAll.IsNull() && data.EnableTrapsTransceiverAll.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/transceiver/all", state.getPath()))
+ if !data.EnableTrapsPimRpMappingChange.IsNull() && !data.EnableTrapsPimRpMappingChange.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/pim/rp-mapping-change", data.getPath()))
}
- if !state.EnableTrapsRf.IsNull() && data.EnableTrapsRf.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/rf", state.getPath()))
+ if !data.EnableTrapsPimNeighborChange.IsNull() && !data.EnableTrapsPimNeighborChange.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/pim/neighbor-change", data.getPath()))
}
- if !state.EnableTrapsErrdisable.IsNull() && data.EnableTrapsErrdisable.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/errdisable", state.getPath()))
+ if !data.EnableTrapsPimInvalidPimMessage.IsNull() && !data.EnableTrapsPimInvalidPimMessage.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/pim/invalid-pim-message", data.getPath()))
}
- if !state.EnableTrapsVlanMembership.IsNull() && data.EnableTrapsVlanMembership.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/vlan-membership", state.getPath()))
+ if !data.EnableTrapsOspfConfigErrors.IsNull() && !data.EnableTrapsOspfConfigErrors.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/Cisco-IOS-XE-ospf:ospf-config/errors/enable", data.getPath()))
}
- if !state.EnableTrapsLocalAuth.IsNull() && data.EnableTrapsLocalAuth.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/local-auth", state.getPath()))
+ if !data.EnableTrapsOspfConfigStateChange.IsNull() && !data.EnableTrapsOspfConfigStateChange.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/Cisco-IOS-XE-ospf:ospf-config/state-change/enable", data.getPath()))
}
- if !state.EnableTrapsFastRerouteProtected.IsNull() && data.EnableTrapsFastRerouteProtected.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/mpls/fast-reroute/protected", state.getPath()))
+ if !data.EnableTrapsMsdp.IsNull() && !data.EnableTrapsMsdp.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/msdp", data.getPath()))
}
- if !state.EnableTrapsMplsLdp.IsNull() && data.EnableTrapsMplsLdp.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/mpls/ldp", state.getPath()))
+ if !data.EnableTrapsIpmulticast.IsNull() && !data.EnableTrapsIpmulticast.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ipmulticast", data.getPath()))
}
- if !state.EnableTrapsMplsRfcLdp.IsNull() && data.EnableTrapsMplsRfcLdp.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/mpls/rfc/ldp", state.getPath()))
+ if !data.EnableTrapsHsrp.IsNull() && !data.EnableTrapsHsrp.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/hsrp", data.getPath()))
}
- if !state.EnableTrapsMplsRfc.IsNull() && data.EnableTrapsMplsRfc.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/mpls/rfc", state.getPath()))
+ if !data.EnableTrapsEventManager.IsNull() && !data.EnableTrapsEventManager.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/event-manager", data.getPath()))
}
- if !state.EnableTrapsMplsVpn.IsNull() && data.EnableTrapsMplsVpn.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/mpls/vpn", state.getPath()))
+ if !data.EnableTrapsDhcp.IsNull() && !data.EnableTrapsDhcp.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/dhcp", data.getPath()))
}
- if !state.EnableTrapsMpls.IsNull() && data.EnableTrapsMpls.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/mpls", state.getPath()))
+ if !data.EnableTrapsConfigCtid.IsNull() && !data.EnableTrapsConfigCtid.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/config-ctid", data.getPath()))
}
- if !state.EnableTrapsMplsTrafficEng.IsNull() && data.EnableTrapsMplsTrafficEng.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/mpls/traffic-eng", state.getPath()))
+ if !data.EnableTrapsConfig.IsNull() && !data.EnableTrapsConfig.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/config", data.getPath()))
}
- if !state.EnableTrapsNhrpQuotaExceeded.IsNull() && data.EnableTrapsNhrpQuotaExceeded.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/nhrp/quota-exceeded", state.getPath()))
+ if !data.EnableTrapsConfigCopy.IsNull() && !data.EnableTrapsConfigCopy.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/config-copy", data.getPath()))
}
- if !state.EnableTrapsNhrpNhp.IsNull() && data.EnableTrapsNhrpNhp.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/nhrp/nhp", state.getPath()))
+ if !data.EnableTrapsIpsecTooManySas.IsNull() && !data.EnableTrapsIpsecTooManySas.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ipsec/too-many-sas", data.getPath()))
}
- if !state.EnableTrapsNhrpNhc.IsNull() && data.EnableTrapsNhrpNhc.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/nhrp/nhc", state.getPath()))
+ if !data.EnableTrapsIpsecTunnelStop.IsNull() && !data.EnableTrapsIpsecTunnelStop.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ipsec/tunnel/stop", data.getPath()))
}
- if !state.EnableTrapsNhrpNhs.IsNull() && data.EnableTrapsNhrpNhs.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/nhrp/nhs", state.getPath()))
+ if !data.EnableTrapsIpsecTunnelStart.IsNull() && !data.EnableTrapsIpsecTunnelStart.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ipsec/tunnel/start", data.getPath()))
}
- if !state.EnableTrapsBgpCbgp2.IsNull() && data.EnableTrapsBgpCbgp2.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/Cisco-IOS-XE-bgp:bgp/cbgp2", state.getPath()))
+ if !data.EnableTrapsIpsecCryptomapDetach.IsNull() && !data.EnableTrapsIpsecCryptomapDetach.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ipsec/cryptomap/detach", data.getPath()))
}
- if !state.EnableTrapsSyslog.IsNull() && data.EnableTrapsSyslog.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/syslog", state.getPath()))
+ if !data.EnableTrapsIpsecCryptomapDelete.IsNull() && !data.EnableTrapsIpsecCryptomapDelete.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ipsec/cryptomap/delete", data.getPath()))
}
- if !state.EnableTrapsStpxLoopInconsistency.IsNull() && data.EnableTrapsStpxLoopInconsistency.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/stpx", state.getPath()))
+ if !data.EnableTrapsIpsecCryptomapAttach.IsNull() && !data.EnableTrapsIpsecCryptomapAttach.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ipsec/cryptomap/attach", data.getPath()))
}
- if !state.EnableTrapsStpxRootInconsistency.IsNull() && data.EnableTrapsStpxRootInconsistency.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/stpx", state.getPath()))
+ if !data.EnableTrapsIpsecCryptomapAdd.IsNull() && !data.EnableTrapsIpsecCryptomapAdd.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ipsec/cryptomap/add", data.getPath()))
}
- if !state.EnableTrapsStpxInconsistency.IsNull() && data.EnableTrapsStpxInconsistency.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/stpx/inconsistency", state.getPath()))
+ if !data.EnableTrapsIkeTunnelStop.IsNull() && !data.EnableTrapsIkeTunnelStop.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ike/tunnel/stop", data.getPath()))
}
- if !state.EnableTrapsBridgeTopologychange.IsNull() && data.EnableTrapsBridgeTopologychange.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/bridge/topologychange", state.getPath()))
+ if !data.EnableTrapsIkeTunnelStart.IsNull() && !data.EnableTrapsIkeTunnelStart.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ike/tunnel/start", data.getPath()))
}
- if !state.EnableTrapsBridgeNewroot.IsNull() && data.EnableTrapsBridgeNewroot.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/bridge/newroot", state.getPath()))
+ if !data.EnableTrapsIkePolicyDelete.IsNull() && !data.EnableTrapsIkePolicyDelete.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ike/policy/delete", data.getPath()))
}
- if !state.EnableTrapsPimRpMappingChange.IsNull() && data.EnableTrapsPimRpMappingChange.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/pim/rp-mapping-change", state.getPath()))
+ if !data.EnableTrapsIkePolicyAdd.IsNull() && !data.EnableTrapsIkePolicyAdd.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ike/policy/add", data.getPath()))
}
- if !state.EnableTrapsPimNeighborChange.IsNull() && data.EnableTrapsPimNeighborChange.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/pim/neighbor-change", state.getPath()))
+ if !data.EnableTrapsBfd.IsNull() && !data.EnableTrapsBfd.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/bfd", data.getPath()))
}
- if !state.EnableTrapsPimInvalidPimMessage.IsNull() && data.EnableTrapsPimInvalidPimMessage.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/pim/invalid-pim-message", state.getPath()))
+ if !data.EnableTrapsEntityDiagScheduledTestFail.IsNull() && !data.EnableTrapsEntityDiagScheduledTestFail.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/entity-diag/scheduled-test-fail", data.getPath()))
}
- if !state.EnableTrapsOspfConfigErrors.IsNull() && data.EnableTrapsOspfConfigErrors.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/Cisco-IOS-XE-ospf:ospf-config/errors/enable", state.getPath()))
+ if !data.EnableTrapsEntityDiagHmThreshReached.IsNull() && !data.EnableTrapsEntityDiagHmThreshReached.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/entity-diag/hm-thresh-reached", data.getPath()))
}
- if !state.EnableTrapsOspfConfigStateChange.IsNull() && data.EnableTrapsOspfConfigStateChange.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/Cisco-IOS-XE-ospf:ospf-config/state-change/enable", state.getPath()))
+ if !data.EnableTrapsEntityDiagHmTestRecover.IsNull() && !data.EnableTrapsEntityDiagHmTestRecover.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/entity-diag/hm-test-recover", data.getPath()))
}
- if !state.EnableTrapsMsdp.IsNull() && data.EnableTrapsMsdp.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/msdp", state.getPath()))
+ if !data.EnableTrapsEntityDiagBootUpFail.IsNull() && !data.EnableTrapsEntityDiagBootUpFail.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/entity-diag/boot-up-fail", data.getPath()))
}
- if !state.EnableTrapsIpmulticast.IsNull() && data.EnableTrapsIpmulticast.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ipmulticast", state.getPath()))
+ if !data.EnableTrapsIpsla.IsNull() && !data.EnableTrapsIpsla.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ipsla", data.getPath()))
}
- if !state.EnableTrapsHsrp.IsNull() && data.EnableTrapsHsrp.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/hsrp", state.getPath()))
+ if !data.EnableTrapsIsis.IsNull() && !data.EnableTrapsIsis.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/isis", data.getPath()))
}
- if !state.EnableTrapsEventManager.IsNull() && data.EnableTrapsEventManager.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/event-manager", state.getPath()))
+ if !data.EnableTrapsCefInconsistency.IsNull() && !data.EnableTrapsCefInconsistency.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/cef/inconsistency", data.getPath()))
}
- if !state.EnableTrapsDhcp.IsNull() && data.EnableTrapsDhcp.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/dhcp", state.getPath()))
+ if !data.EnableTrapsCefPeerFibStateChange.IsNull() && !data.EnableTrapsCefPeerFibStateChange.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/cef/peer-fib-state-change", data.getPath()))
}
- if !state.EnableTrapsConfigCtid.IsNull() && data.EnableTrapsConfigCtid.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/config-ctid", state.getPath()))
+ if !data.EnableTrapsCefPeerStateChange.IsNull() && !data.EnableTrapsCefPeerStateChange.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/cef/peer-state-change", data.getPath()))
}
- if !state.EnableTrapsConfig.IsNull() && data.EnableTrapsConfig.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/config", state.getPath()))
+ if !data.EnableTrapsCefResourceFailure.IsNull() && !data.EnableTrapsCefResourceFailure.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/cef/resource-failure", data.getPath()))
}
- if !state.EnableTrapsConfigCopy.IsNull() && data.EnableTrapsConfigCopy.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/config-copy", state.getPath()))
+ if !data.EnableTrapsEnvmon.IsNull() && !data.EnableTrapsEnvmon.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/envmon", data.getPath()))
}
- if !state.EnableTrapsIpsecTooManySas.IsNull() && data.EnableTrapsIpsecTooManySas.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ipsec/too-many-sas", state.getPath()))
+ if !data.EnableTrapsPwVc.IsNull() && !data.EnableTrapsPwVc.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/pw/vc", data.getPath()))
}
- if !state.EnableTrapsIpsecTunnelStop.IsNull() && data.EnableTrapsIpsecTunnelStop.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ipsec/tunnel/stop", state.getPath()))
+ if !data.EnableTrapsEntity.IsNull() && !data.EnableTrapsEntity.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/entity", data.getPath()))
}
- if !state.EnableTrapsIpsecTunnelStart.IsNull() && data.EnableTrapsIpsecTunnelStart.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ipsec/tunnel/start", state.getPath()))
+ if !data.EnableTrapsPowerEthernetPolice.IsNull() && !data.EnableTrapsPowerEthernetPolice.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/power-ethernet/police", data.getPath()))
}
- if !state.EnableTrapsIpsecCryptomapDetach.IsNull() && data.EnableTrapsIpsecCryptomapDetach.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ipsec/cryptomap/detach", state.getPath()))
+ if !data.EnableTrapsEnergywise.IsNull() && !data.EnableTrapsEnergywise.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/energywise", data.getPath()))
}
- if !state.EnableTrapsIpsecCryptomapDelete.IsNull() && data.EnableTrapsIpsecCryptomapDelete.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ipsec/cryptomap/delete", state.getPath()))
+ if !data.EnableTrapsFlashLowspace.IsNull() && !data.EnableTrapsFlashLowspace.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/flash/lowspace", data.getPath()))
}
- if !state.EnableTrapsIpsecCryptomapAttach.IsNull() && data.EnableTrapsIpsecCryptomapAttach.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ipsec/cryptomap/attach", state.getPath()))
+ if !data.EnableTrapsFlashRemoval.IsNull() && !data.EnableTrapsFlashRemoval.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/flash/removal", data.getPath()))
}
- if !state.EnableTrapsIpsecCryptomapAdd.IsNull() && data.EnableTrapsIpsecCryptomapAdd.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ipsec/cryptomap/add", state.getPath()))
+ if !data.EnableTrapsFlashInsertion.IsNull() && !data.EnableTrapsFlashInsertion.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/flash/insertion", data.getPath()))
}
- if !state.EnableTrapsIkeTunnelStop.IsNull() && data.EnableTrapsIkeTunnelStop.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ike/tunnel/stop", state.getPath()))
+ if !data.EnableTrapsFruCtrl.IsNull() && !data.EnableTrapsFruCtrl.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/fru-ctrl", data.getPath()))
}
- if !state.EnableTrapsIkeTunnelStart.IsNull() && data.EnableTrapsIkeTunnelStart.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ike/tunnel/start", state.getPath()))
+ if !data.EnableTrapsUdldStatusChange.IsNull() && !data.EnableTrapsUdldStatusChange.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/udld/status-change", data.getPath()))
}
- if !state.EnableTrapsIkePolicyDelete.IsNull() && data.EnableTrapsIkePolicyDelete.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ike/policy/delete", state.getPath()))
+ if !data.EnableTrapsUdldLinkFailRpt.IsNull() && !data.EnableTrapsUdldLinkFailRpt.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/udld/link-fail-rpt", data.getPath()))
}
- if !state.EnableTrapsIkePolicyAdd.IsNull() && data.EnableTrapsIkePolicyAdd.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ike/policy/add", state.getPath()))
+ if !data.EnableTrapsStackwise.IsNull() && !data.EnableTrapsStackwise.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/stackwise", data.getPath()))
}
- if !state.EnableTrapsBfd.IsNull() && data.EnableTrapsBfd.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/bfd", state.getPath()))
+ if !data.EnableTrapsMemoryBufferpeak.IsNull() && !data.EnableTrapsMemoryBufferpeak.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/memory/bufferpeak", data.getPath()))
}
- if !state.EnableTrapsEntityDiagScheduledTestFail.IsNull() && data.EnableTrapsEntityDiagScheduledTestFail.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/entity-diag/scheduled-test-fail", state.getPath()))
+ if !data.EnableTrapsCpuThreshold.IsNull() && !data.EnableTrapsCpuThreshold.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/cpu/threshold", data.getPath()))
}
- if !state.EnableTrapsEntityDiagHmThreshReached.IsNull() && data.EnableTrapsEntityDiagHmThreshReached.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/entity-diag/hm-thresh-reached", state.getPath()))
+ if !data.EnableTrapsSmartLicense.IsNull() && !data.EnableTrapsSmartLicense.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/smart-licenseing/smart-license", data.getPath()))
}
- if !state.EnableTrapsEntityDiagHmTestRecover.IsNull() && data.EnableTrapsEntityDiagHmTestRecover.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/entity-diag/hm-test-recover", state.getPath()))
+ if !data.EnableTrapsLicense.IsNull() && !data.EnableTrapsLicense.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/license", data.getPath()))
}
- if !state.EnableTrapsEntityDiagBootUpFail.IsNull() && data.EnableTrapsEntityDiagBootUpFail.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/entity-diag/boot-up-fail", state.getPath()))
+ if !data.EnableTrapsPortSecurity.IsNull() && !data.EnableTrapsPortSecurity.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/port-security", data.getPath()))
}
- if !state.EnableTrapsIpsla.IsNull() && data.EnableTrapsIpsla.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ipsla", state.getPath()))
+ if !data.EnableTrapsVlandelete.IsNull() && !data.EnableTrapsVlandelete.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/vlandelete", data.getPath()))
}
- if !state.EnableTrapsIsis.IsNull() && data.EnableTrapsIsis.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/isis", state.getPath()))
+ if !data.EnableTrapsVlancreate.IsNull() && !data.EnableTrapsVlancreate.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/vlancreate", data.getPath()))
}
- if !state.EnableTrapsCefInconsistency.IsNull() && data.EnableTrapsCefInconsistency.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/cef/inconsistency", state.getPath()))
+ if !data.EnableTrapsVtp.IsNull() && !data.EnableTrapsVtp.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/vtp", data.getPath()))
}
- if !state.EnableTrapsCefPeerFibStateChange.IsNull() && data.EnableTrapsCefPeerFibStateChange.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/cef/peer-fib-state-change", state.getPath()))
+ if !data.EnableTrapsRep.IsNull() && !data.EnableTrapsRep.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/rep", data.getPath()))
}
- if !state.EnableTrapsCefPeerStateChange.IsNull() && data.EnableTrapsCefPeerStateChange.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/cef/peer-state-change", state.getPath()))
+ if !data.EnableTrapsAuthFrameworkSecViolation.IsNull() && !data.EnableTrapsAuthFrameworkSecViolation.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/auth-framework/sec-violation", data.getPath()))
}
- if !state.EnableTrapsCefResourceFailure.IsNull() && data.EnableTrapsCefResourceFailure.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/cef/resource-failure", state.getPath()))
+ if !data.EnableTrapsEigrp.IsNull() && !data.EnableTrapsEigrp.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/eigrp", data.getPath()))
}
- if !state.EnableTrapsEnvmon.IsNull() && data.EnableTrapsEnvmon.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/envmon", state.getPath()))
+ if !data.EnableTrapsOspfLsaEnable.IsNull() && !data.EnableTrapsOspfLsaEnable.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/Cisco-IOS-XE-ospf:ospf-config/cisco-specific/lsa/enable", data.getPath()))
}
- if !state.EnableTrapsPwVc.IsNull() && data.EnableTrapsPwVc.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/pw", state.getPath()))
+ if !data.EnableTrapsOspfRetransmitEnable.IsNull() && !data.EnableTrapsOspfRetransmitEnable.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/Cisco-IOS-XE-ospf:ospf-config/cisco-specific/retransmit/enable", data.getPath()))
}
- if !state.EnableTrapsEntity.IsNull() && data.EnableTrapsEntity.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/entity", state.getPath()))
+ if !data.EnableTrapsOspfErrorsEnable.IsNull() && !data.EnableTrapsOspfErrorsEnable.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/Cisco-IOS-XE-ospf:ospf-config/cisco-specific/errors/enable", data.getPath()))
}
- if !state.EnableTrapsPowerEthernetPolice.IsNull() && data.EnableTrapsPowerEthernetPolice.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/power-ethernet/police", state.getPath()))
+ if !data.EnableTrapsOspfShamlinkNeighbor.IsNull() && !data.EnableTrapsOspfShamlinkNeighbor.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/Cisco-IOS-XE-ospf:ospf-config/cisco-specific/state-change/shamlink/neighbor", data.getPath()))
}
- if !state.EnableTrapsPowerEthernetGroup.IsNull() && data.EnableTrapsPowerEthernetGroup.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/power-ethernet/group", state.getPath()))
+ if !data.EnableTrapsOspfShamlinkInterface.IsNull() && !data.EnableTrapsOspfShamlinkInterface.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/Cisco-IOS-XE-ospf:ospf-config/cisco-specific/state-change/shamlink/interface", data.getPath()))
}
- if !state.EnableTrapsEnergywise.IsNull() && data.EnableTrapsEnergywise.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/energywise", state.getPath()))
+ if !data.EnableTrapsOspfNssaTransChange.IsNull() && !data.EnableTrapsOspfNssaTransChange.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/Cisco-IOS-XE-ospf:ospf-config/cisco-specific/state-change/nssa-trans-change", data.getPath()))
}
- if !state.EnableTrapsFlashLowspace.IsNull() && data.EnableTrapsFlashLowspace.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/flash/lowspace", state.getPath()))
+ if !data.EnableTrapsOspfConfigLsa.IsNull() && !data.EnableTrapsOspfConfigLsa.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/Cisco-IOS-XE-ospf:ospf-config/lsa/enable", data.getPath()))
}
- if !state.EnableTrapsFlashRemoval.IsNull() && data.EnableTrapsFlashRemoval.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/flash/removal", state.getPath()))
+ if !data.EnableTrapsOspfConfigRetransmit.IsNull() && !data.EnableTrapsOspfConfigRetransmit.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/Cisco-IOS-XE-ospf:ospf-config/retransmit/enable", data.getPath()))
}
- if !state.EnableTrapsFlashInsertion.IsNull() && data.EnableTrapsFlashInsertion.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/flash/insertion", state.getPath()))
+ if !data.EnableTrapsOspfv3ConfigErrors.IsNull() && !data.EnableTrapsOspfv3ConfigErrors.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/Cisco-IOS-XE-ospfv3:ospfv3-config/errors/enable", data.getPath()))
}
- if !state.EnableTrapsFruCtrl.IsNull() && data.EnableTrapsFruCtrl.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/fru-ctrl", state.getPath()))
+ if !data.EnableTrapsOspfv3ConfigStateChange.IsNull() && !data.EnableTrapsOspfv3ConfigStateChange.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/Cisco-IOS-XE-ospfv3:ospfv3-config/state-change/enable", data.getPath()))
}
- if !state.EnableTrapsUdldStatusChange.IsNull() && data.EnableTrapsUdldStatusChange.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/udld/status-change", state.getPath()))
+ if !data.EnableTrapsTty.IsNull() && !data.EnableTrapsTty.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/tty", data.getPath()))
}
- if !state.EnableTrapsUdldLinkFailRpt.IsNull() && data.EnableTrapsUdldLinkFailRpt.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/udld/link-fail-rpt", state.getPath()))
+ if !data.EnableTrapsCallHomeServerFail.IsNull() && !data.EnableTrapsCallHomeServerFail.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/call-home/server-fail", data.getPath()))
}
- if !state.EnableTrapsStackwise.IsNull() && data.EnableTrapsStackwise.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/stackwise", state.getPath()))
+ if !data.EnableTrapsCallHomeMessageSendFail.IsNull() && !data.EnableTrapsCallHomeMessageSendFail.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/call-home/message-send-fail", data.getPath()))
}
- if !state.EnableTrapsMemoryBufferpeak.IsNull() && data.EnableTrapsMemoryBufferpeak.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/memory/bufferpeak", state.getPath()))
+ if !data.EnableTrapsEntityPerfThroughputNotif.IsNull() && !data.EnableTrapsEntityPerfThroughputNotif.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/entity-perf/throughput-notif", data.getPath()))
}
- if !state.EnableTrapsCpuThreshold.IsNull() && data.EnableTrapsCpuThreshold.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/cpu/threshold", state.getPath()))
+ if !data.EnableTrapsFlowmon.IsNull() && !data.EnableTrapsFlowmon.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/flowmon", data.getPath()))
}
- if !state.EnableTrapsSmartLicense.IsNull() && data.EnableTrapsSmartLicense.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/smart-licenseing/smart-license", state.getPath()))
+ if !data.SystemShutdown.IsNull() && !data.SystemShutdown.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:system-shutdown", data.getPath()))
}
- if !state.EnableTrapsLicense.IsNull() && data.EnableTrapsLicense.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/license", state.getPath()))
+
+ if !data.EnableTrapsSnmpWarmstart.IsNull() && !data.EnableTrapsSnmpWarmstart.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/snmp/warmstart", data.getPath()))
}
- if !state.EnableTrapsPortSecurity.IsNull() && data.EnableTrapsPortSecurity.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/port-security", state.getPath()))
+ if !data.EnableTrapsSnmpLinkup.IsNull() && !data.EnableTrapsSnmpLinkup.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/snmp/linkup", data.getPath()))
}
- if !state.EnableTrapsVlandelete.IsNull() && data.EnableTrapsVlandelete.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/vlandelete", state.getPath()))
+ if !data.EnableTrapsSnmpLinkdown.IsNull() && !data.EnableTrapsSnmpLinkdown.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/snmp/linkdown", data.getPath()))
}
- if !state.EnableTrapsVlancreate.IsNull() && data.EnableTrapsVlancreate.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/vlancreate", state.getPath()))
+ if !data.EnableTrapsSnmpColdstart.IsNull() && !data.EnableTrapsSnmpColdstart.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/snmp/coldstart", data.getPath()))
}
- if !state.EnableTrapsVtp.IsNull() && data.EnableTrapsVtp.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/vtp", state.getPath()))
+ if !data.EnableTrapsSnmpAuthentication.IsNull() && !data.EnableTrapsSnmpAuthentication.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/snmp/authentication", data.getPath()))
}
- if !state.EnableTrapsRep.IsNull() && data.EnableTrapsRep.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/rep", state.getPath()))
+ if !data.EnableTraps.IsNull() && !data.EnableTraps.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps", data.getPath()))
}
- if !state.EnableTrapsAuthFrameworkSecViolation.IsNull() && data.EnableTrapsAuthFrameworkSecViolation.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/auth-framework/sec-violation", state.getPath()))
+ if !data.EnableInforms.IsNull() && !data.EnableInforms.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/informs", data.getPath()))
}
- if !state.EnableTrapsEigrp.IsNull() && data.EnableTrapsEigrp.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/eigrp", state.getPath()))
+ if !data.IfindexPersist.IsNull() && !data.IfindexPersist.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:ifindex/persist", data.getPath()))
}
- if !state.EnableTrapsOspfLsaEnable.IsNull() && data.EnableTrapsOspfLsaEnable.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/Cisco-IOS-XE-ospf:ospf-config/cisco-specific/lsa/enable", state.getPath()))
+
+ return emptyLeafsDelete
+}
+
+// End of section. //template:end getEmptyLeafsDelete
+
+// Section below is generated&owned by "gen/generator.go". //template:begin getDeletePaths
+
+func (data *SNMPServer) getDeletePaths(ctx context.Context) []string {
+ var deletePaths []string
+ for i := range data.Users {
+ keyValues := [...]string{data.Users[i].Username.ValueString(), data.Users[i].Grpname.ValueString()}
+
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:user/names=%v", data.getPath(), strings.Join(keyValues[:], ",")))
}
- if !state.EnableTrapsOspfRetransmitEnable.IsNull() && data.EnableTrapsOspfRetransmitEnable.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/Cisco-IOS-XE-ospf:ospf-config/cisco-specific/retransmit/enable", state.getPath()))
+ for i := range data.Groups {
+ keyValues := [...]string{data.Groups[i].Name.ValueString()}
+
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:group=%v", data.getPath(), strings.Join(keyValues[:], ",")))
}
- if !state.EnableTrapsOspfErrorsEnable.IsNull() && data.EnableTrapsOspfErrorsEnable.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/Cisco-IOS-XE-ospf:ospf-config/cisco-specific/errors/enable", state.getPath()))
+ for i := range data.Views {
+ keyValues := [...]string{data.Views[i].Name.ValueString(), data.Views[i].Mib.ValueString()}
+
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:view=%v", data.getPath(), strings.Join(keyValues[:], ",")))
}
- if !state.EnableTrapsOspfShamlinkNeighbor.IsNull() && data.EnableTrapsOspfShamlinkNeighbor.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/Cisco-IOS-XE-ospf:ospf-config/cisco-specific/state-change/shamlink/neighbor", state.getPath()))
+ for i := range data.Contexts {
+ keyValues := [...]string{data.Contexts[i].Name.ValueString()}
+
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:context=%v", data.getPath(), strings.Join(keyValues[:], ",")))
}
- if !state.EnableTrapsOspfShamlinkInterface.IsNull() && data.EnableTrapsOspfShamlinkInterface.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/Cisco-IOS-XE-ospf:ospf-config/cisco-specific/state-change/shamlink/interface", state.getPath()))
+ for i := range data.SnmpCommunities {
+ keyValues := [...]string{data.SnmpCommunities[i].Name.ValueString()}
+
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:community-config=%v", data.getPath(), strings.Join(keyValues[:], ",")))
}
- if !state.EnableTrapsOspfNssaTransChange.IsNull() && data.EnableTrapsOspfNssaTransChange.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/Cisco-IOS-XE-ospf:ospf-config/cisco-specific/state-change/nssa-trans-change", state.getPath()))
+ if !data.TrapSourceVlan.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:trap-source/Vlan", data.getPath()))
}
- if !state.EnableTrapsOspfConfigLsa.IsNull() && data.EnableTrapsOspfConfigLsa.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/Cisco-IOS-XE-ospf:ospf-config/lsa/enable", state.getPath()))
+ if !data.TrapSourcePortChannelSubinterface.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:trap-source/Port-channel-subinterface/Port-channel", data.getPath()))
}
- if !state.EnableTrapsOspfConfigRetransmit.IsNull() && data.EnableTrapsOspfConfigRetransmit.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/Cisco-IOS-XE-ospf:ospf-config/retransmit/enable", state.getPath()))
+ if !data.TrapSourcePortChannel.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:trap-source/Port-channel", data.getPath()))
}
- if !state.EnableTrapsOspfv3ConfigErrors.IsNull() && data.EnableTrapsOspfv3ConfigErrors.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/Cisco-IOS-XE-ospfv3:ospfv3-config/errors/enable", state.getPath()))
+ if !data.TrapSourceLoopback.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:trap-source/Loopback", data.getPath()))
}
- if !state.EnableTrapsOspfv3ConfigStateChange.IsNull() && data.EnableTrapsOspfv3ConfigStateChange.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/Cisco-IOS-XE-ospfv3:ospfv3-config/state-change/enable", state.getPath()))
+ if !data.TrapSourceHundredGigE.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:trap-source/HundredGigE", data.getPath()))
}
- if !state.EnableTrapsTty.IsNull() && data.EnableTrapsTty.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/tty", state.getPath()))
+ if !data.TrapSourceFortyGigabitEthernet.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:trap-source/FortyGigabitEthernet", data.getPath()))
}
- if !state.EnableTrapsCallHomeServerFail.IsNull() && data.EnableTrapsCallHomeServerFail.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/call-home/server-fail", state.getPath()))
+ if !data.TrapSourceTenGigabitEthernet.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:trap-source/TenGigabitEthernet", data.getPath()))
}
- if !state.EnableTrapsCallHomeMessageSendFail.IsNull() && data.EnableTrapsCallHomeMessageSendFail.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/call-home/message-send-fail", state.getPath()))
+ if !data.TrapSourceGigabitEthernet.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:trap-source/GigabitEthernet", data.getPath()))
}
- if !state.EnableTrapsEntityPerfThroughputNotif.IsNull() && data.EnableTrapsEntityPerfThroughputNotif.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/entity-perf/throughput-notif", state.getPath()))
+ if !data.SourceInterfaceTrapsVlan.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:source-interface/traps/Vlan", data.getPath()))
}
- if !state.EnableTrapsFlowmon.IsNull() && data.EnableTrapsFlowmon.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/flowmon", state.getPath()))
+ if !data.SourceInterfaceTrapsPortChannelSubinterface.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:source-interface/traps/Port-channel-subinterface/Port-channel", data.getPath()))
}
- if !state.SystemShutdown.IsNull() && data.SystemShutdown.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:system-shutdown", state.getPath()))
+ if !data.SourceInterfaceTrapsPortChannel.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:source-interface/traps/Port-channel", data.getPath()))
}
- for i := range state.VrfHosts {
- stateKeyValues := [...]string{state.VrfHosts[i].IpAddress.ValueString(), state.VrfHosts[i].Vrf.ValueString()}
-
- emptyKeys := true
- if !reflect.ValueOf(state.VrfHosts[i].IpAddress.ValueString()).IsZero() {
- emptyKeys = false
- }
- if !reflect.ValueOf(state.VrfHosts[i].Vrf.ValueString()).IsZero() {
- emptyKeys = false
- }
- if emptyKeys {
- continue
- }
-
- found := false
- for j := range data.VrfHosts {
- found = true
- if state.VrfHosts[i].IpAddress.ValueString() != data.VrfHosts[j].IpAddress.ValueString() {
- found = false
- }
- if state.VrfHosts[i].Vrf.ValueString() != data.VrfHosts[j].Vrf.ValueString() {
- found = false
- }
- if found {
- if !state.VrfHosts[i].SecurityLevel.IsNull() && data.VrfHosts[j].SecurityLevel.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:host-config/ip-vrf-community=%v/security-level", state.getPath(), strings.Join(stateKeyValues[:], ",")))
- }
- if !state.VrfHosts[i].Encryption.IsNull() && data.VrfHosts[j].Encryption.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:host-config/ip-vrf-community=%v/encryption", state.getPath(), strings.Join(stateKeyValues[:], ",")))
- }
- if !state.VrfHosts[i].Version.IsNull() && data.VrfHosts[j].Version.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:host-config/ip-vrf-community=%v/version", state.getPath(), strings.Join(stateKeyValues[:], ",")))
- }
- if !state.VrfHosts[i].CommunityOrUser.IsNull() && data.VrfHosts[j].CommunityOrUser.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:host-config/ip-vrf-community=%v/community-or-user", state.getPath(), strings.Join(stateKeyValues[:], ",")))
- }
- break
- }
- }
- if !found {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:host-config/ip-vrf-community=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
- }
+ if !data.SourceInterfaceTrapsLoopback.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:source-interface/traps/Loopback", data.getPath()))
}
- for i := range state.Hosts {
- stateKeyValues := [...]string{state.Hosts[i].IpAddress.ValueString()}
-
- emptyKeys := true
- if !reflect.ValueOf(state.Hosts[i].IpAddress.ValueString()).IsZero() {
- emptyKeys = false
- }
- if emptyKeys {
- continue
- }
-
- found := false
- for j := range data.Hosts {
- found = true
- if state.Hosts[i].IpAddress.ValueString() != data.Hosts[j].IpAddress.ValueString() {
- found = false
- }
- if found {
- if !state.Hosts[i].SecurityLevel.IsNull() && data.Hosts[j].SecurityLevel.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:host-config/ip-community=%v/security-level", state.getPath(), strings.Join(stateKeyValues[:], ",")))
- }
- if !state.Hosts[i].Encryption.IsNull() && data.Hosts[j].Encryption.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:host-config/ip-community=%v/encryption", state.getPath(), strings.Join(stateKeyValues[:], ",")))
- }
- if !state.Hosts[i].Version.IsNull() && data.Hosts[j].Version.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:host-config/ip-community=%v/version", state.getPath(), strings.Join(stateKeyValues[:], ",")))
- }
- if !state.Hosts[i].CommunityOrUser.IsNull() && data.Hosts[j].CommunityOrUser.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:host-config/ip-community=%v/community-or-user", state.getPath(), strings.Join(stateKeyValues[:], ",")))
- }
- break
- }
- }
- if !found {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:host-config/ip-community=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
- }
+ if !data.SourceInterfaceTrapsHundredGigE.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:source-interface/traps/HundredGigE", data.getPath()))
}
- if !state.EnableTrapsSnmpWarmstart.IsNull() && data.EnableTrapsSnmpWarmstart.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/snmp/warmstart", state.getPath()))
+ if !data.SourceInterfaceTrapsFortyGigabitEthernet.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:source-interface/traps/FortyGigabitEthernet", data.getPath()))
}
- if !state.EnableTrapsSnmpLinkup.IsNull() && data.EnableTrapsSnmpLinkup.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/snmp/linkup", state.getPath()))
+ if !data.SourceInterfaceTrapsTenGigabitEthernet.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:source-interface/traps/TenGigabitEthernet", data.getPath()))
}
- if !state.EnableTrapsSnmpLinkdown.IsNull() && data.EnableTrapsSnmpLinkdown.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/snmp/linkdown", state.getPath()))
+ if !data.SourceInterfaceTrapsGigabitEthernet.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:source-interface/traps/GigabitEthernet", data.getPath()))
}
- if !state.EnableTrapsSnmpColdstart.IsNull() && data.EnableTrapsSnmpColdstart.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/snmp/coldstart", state.getPath()))
+ if !data.SourceInterfaceInformsVlan.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:source-interface/informs/Vlan", data.getPath()))
}
- if !state.EnableTrapsSnmpAuthentication.IsNull() && data.EnableTrapsSnmpAuthentication.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/snmp/authentication", state.getPath()))
+ if !data.SourceInterfaceInformsPortChannelSubinterface.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:source-interface/informs/Port-channel-subinterface/Port-channel", data.getPath()))
}
- if !state.EnableTraps.IsNull() && data.EnableTraps.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps", state.getPath()))
+ if !data.SourceInterfaceInformsPortChannel.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:source-interface/informs/Port-channel", data.getPath()))
}
- if !state.EnableInforms.IsNull() && data.EnableInforms.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/informs", state.getPath()))
+ if !data.SourceInterfaceInformsLoopback.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:source-interface/informs/Loopback", data.getPath()))
}
- if !state.EnableLoggingSetop.IsNull() && data.EnableLoggingSetop.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/logging/setop", state.getPath()))
+ if !data.SourceInterfaceInformsHundredGigE.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:source-interface/informs/HundredGigE", data.getPath()))
}
- if !state.EnableLoggingGetop.IsNull() && data.EnableLoggingGetop.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/logging/getop", state.getPath()))
+ if !data.SourceInterfaceInformsFortyGigabitEthernet.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:source-interface/informs/FortyGigabitEthernet", data.getPath()))
}
- if !state.QueueLength.IsNull() && data.QueueLength.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:queue-length", state.getPath()))
+ if !data.SourceInterfaceInformsTenGigabitEthernet.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:source-interface/informs/TenGigabitEthernet", data.getPath()))
}
- if !state.Packetsize.IsNull() && data.Packetsize.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:packetsize", state.getPath()))
+ if !data.SourceInterfaceInformsGigabitEthernet.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:source-interface/informs/GigabitEthernet", data.getPath()))
}
- if !state.Location.IsNull() && data.Location.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:location", state.getPath()))
+ if !data.EnableTrapsOspfv3StateChange.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ospfv3/state-change", data.getPath()))
}
- if !state.IfindexPersist.IsNull() && data.IfindexPersist.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:ifindex/persist", state.getPath()))
+ if !data.EnableTrapsOspfv3Errors.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ospfv3/errors", data.getPath()))
}
- if !state.Contact.IsNull() && data.Contact.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:contact", state.getPath()))
+ if !data.EnableTrapsCbgp2.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/bgp-traps/cbgp2", data.getPath()))
}
- if !state.ChassisId.IsNull() && data.ChassisId.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:chassis-id", state.getPath()))
+ if !data.EnableTrapsBgp.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/bgp", data.getPath()))
}
-
- return deletedItems
-}
-
-// End of section. //template:end getDeletedItems
-
-// Section below is generated&owned by "gen/generator.go". //template:begin getEmptyLeafsDelete
-
-func (data *SNMPServer) getEmptyLeafsDelete(ctx context.Context) []string {
- emptyLeafsDelete := make([]string, 0)
-
- if !data.EnableTrapsOspfv3StateChange.IsNull() && !data.EnableTrapsOspfv3StateChange.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ospfv3/state-change", data.getPath()))
+ if !data.EnableTrapsVoice.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/voice", data.getPath()))
}
- if !data.EnableTrapsOspfv3Errors.IsNull() && !data.EnableTrapsOspfv3Errors.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ospfv3/errors", data.getPath()))
+ if !data.EnableTrapsSrp.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/srp", data.getPath()))
}
- if !data.EnableTrapsCbgp2.IsNull() && !data.EnableTrapsCbgp2.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/bgp-traps/cbgp2", data.getPath()))
+ if !data.EnableTrapsSonet.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/sonet", data.getPath()))
}
- if !data.EnableTrapsBgp.IsNull() && !data.EnableTrapsBgp.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/bgp", data.getPath()))
+ if !data.EnableTrapsVrrp.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/vrrp", data.getPath()))
}
- if !data.EnableTrapsVoice.IsNull() && !data.EnableTrapsVoice.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/voice", data.getPath()))
+ if !data.EnableTrapsRsvp.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/rsvp", data.getPath()))
}
- if !data.EnableTrapsSrp.IsNull() && !data.EnableTrapsSrp.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/srp", data.getPath()))
+ if !data.EnableTrapsResourcePolicy.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/resource-policy", data.getPath()))
}
- if !data.EnableTrapsSonet.IsNull() && !data.EnableTrapsSonet.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/sonet", data.getPath()))
+ if !data.EnableTrapsPppoe.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/pppoe", data.getPath()))
}
- if !data.EnableTrapsVrrp.IsNull() && !data.EnableTrapsVrrp.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/vrrp", data.getPath()))
+ if !data.EnableTrapsPfr.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/pfr", data.getPath()))
}
- if !data.EnableTrapsRsvp.IsNull() && !data.EnableTrapsRsvp.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/rsvp", data.getPath()))
+ if !data.EnableTrapsPimstdmibInterfaceElection.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/pimstdmib/interface-election", data.getPath()))
}
- if !data.EnableTrapsResourcePolicy.IsNull() && !data.EnableTrapsResourcePolicy.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/resource-policy", data.getPath()))
+ if !data.EnableTrapsPimstdmibRpMappingChange.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/pimstdmib/rp-mapping-change", data.getPath()))
}
- if !data.EnableTrapsPppoe.IsNull() && !data.EnableTrapsPppoe.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/pppoe", data.getPath()))
+ if !data.EnableTrapsPimstdmibInvalidJoinPrune.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/pimstdmib/invalid-join-prune", data.getPath()))
}
- if !data.EnableTrapsPfr.IsNull() && !data.EnableTrapsPfr.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/pfr", data.getPath()))
+ if !data.EnableTrapsPimstdmibInvalidRegister.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/pimstdmib/invalid-register", data.getPath()))
}
- if !data.EnableTrapsPimstdmibInterfaceElection.IsNull() && !data.EnableTrapsPimstdmibInterfaceElection.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/pimstdmib/interface-election", data.getPath()))
+ if !data.EnableTrapsPimstdmibNeighborLoss.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/pimstdmib/neighbor-loss", data.getPath()))
}
- if !data.EnableTrapsPimstdmibRpMappingChange.IsNull() && !data.EnableTrapsPimstdmibRpMappingChange.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/pimstdmib/rp-mapping-change", data.getPath()))
+ if !data.EnableTrapsL2tunPseudowireStatus.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/l2tun/pseudowire/status", data.getPath()))
}
- if !data.EnableTrapsPimstdmibInvalidJoinPrune.IsNull() && !data.EnableTrapsPimstdmibInvalidJoinPrune.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/pimstdmib/invalid-join-prune", data.getPath()))
+ if !data.EnableTrapsL2tunTunnel.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/l2tun/tunnel", data.getPath()))
}
- if !data.EnableTrapsPimstdmibInvalidRegister.IsNull() && !data.EnableTrapsPimstdmibInvalidRegister.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/pimstdmib/invalid-register", data.getPath()))
+ if !data.EnableTrapsL2tunSession.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/l2tun/session", data.getPath()))
}
- if !data.EnableTrapsPimstdmibNeighborLoss.IsNull() && !data.EnableTrapsPimstdmibNeighborLoss.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/pimstdmib/neighbor-loss", data.getPath()))
+ if !data.EnableTrapsIsdnLayer2.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/isdn/layer2", data.getPath()))
}
- if !data.EnableTrapsL2tunPseudowireStatus.IsNull() && !data.EnableTrapsL2tunPseudowireStatus.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/l2tun/pseudowire/status", data.getPath()))
+ if !data.EnableTrapsIsdnIetf.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/isdn/ietf", data.getPath()))
}
- if !data.EnableTrapsL2tunTunnel.IsNull() && !data.EnableTrapsL2tunTunnel.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/l2tun/tunnel", data.getPath()))
+ if !data.EnableTrapsIsdnChanNotAvail.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/isdn/chan-not-avail", data.getPath()))
}
- if !data.EnableTrapsL2tunSession.IsNull() && !data.EnableTrapsL2tunSession.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/l2tun/session", data.getPath()))
+ if !data.EnableTrapsIsdnCallInformation.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/isdn/call-information", data.getPath()))
}
- if !data.EnableTrapsIsdnLayer2.IsNull() && !data.EnableTrapsIsdnLayer2.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/isdn/layer2", data.getPath()))
+ if !data.EnableTrapsIpLocalPool.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ip/local/pool", data.getPath()))
}
- if !data.EnableTrapsIsdnIetf.IsNull() && !data.EnableTrapsIsdnIetf.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/isdn/ietf", data.getPath()))
+ if !data.EnableTrapsFrameRelayMultilinkBundleMismatch.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/frame-relay/multilink/bundle-mismatch", data.getPath()))
}
- if !data.EnableTrapsIsdnChanNotAvail.IsNull() && !data.EnableTrapsIsdnChanNotAvail.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/isdn/chan-not-avail", data.getPath()))
+ if !data.EnableTrapsFrameRelayConfigBundleMismatch.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/frame-relay-config/frame-relay-options/frame-relay/multilink/bundle-mismatch", data.getPath()))
}
- if !data.EnableTrapsIsdnCallInformation.IsNull() && !data.EnableTrapsIsdnCallInformation.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/isdn/call-information", data.getPath()))
+ if !data.EnableTrapsFrameRelaySubifInterval.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/frame-relay/subif/interval", data.getPath()))
}
- if !data.EnableTrapsIpLocalPool.IsNull() && !data.EnableTrapsIpLocalPool.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ip/local/pool", data.getPath()))
+ if !data.EnableTrapsFrameRelaySubifCount.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/frame-relay/subif/count", data.getPath()))
}
- if !data.EnableTrapsFrameRelayMultilinkBundleMismatch.IsNull() && !data.EnableTrapsFrameRelayMultilinkBundleMismatch.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/frame-relay/multilink/bundle-mismatch", data.getPath()))
+ if !data.EnableTrapsFrameRelayConfigSubifConfigs.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/frame-relay-config/frame-relay-options/frame-relay/subif-configs/subif", data.getPath()))
}
- if !data.EnableTrapsFrameRelayConfigBundleMismatch.IsNull() && !data.EnableTrapsFrameRelayConfigBundleMismatch.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/frame-relay-config/frame-relay-options/frame-relay/multilink/bundle-mismatch", data.getPath()))
+ if !data.EnableTrapsFrameRelayConfigOnly.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/frame-relay-config/only-frame-relay/frame-relay", data.getPath()))
}
- if !data.EnableTrapsFrameRelayConfigSubifConfigs.IsNull() && !data.EnableTrapsFrameRelayConfigSubifConfigs.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/frame-relay-config/frame-relay-options/frame-relay/subif-configs/subif", data.getPath()))
+ if !data.EnableTrapsFirewallServerstatus.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/firewall/serverstatus", data.getPath()))
}
- if !data.EnableTrapsFrameRelayConfigOnly.IsNull() && !data.EnableTrapsFrameRelayConfigOnly.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/frame-relay-config/only-frame-relay/frame-relay", data.getPath()))
+ if !data.EnableTrapsEthernetEvcStatus.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ethernet/evc/status", data.getPath()))
}
- if !data.EnableTrapsFirewallServerstatus.IsNull() && !data.EnableTrapsFirewallServerstatus.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/firewall/serverstatus", data.getPath()))
+ if !data.EnableTrapsEthernetEvcDelete.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ethernet/evc/delete", data.getPath()))
+ }
+ if !data.EnableTrapsEthernetEvcCreate.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ethernet/evc/create", data.getPath()))
+ }
+ if !data.EnableTrapsEthernetCfmCrosscheckServiceUp.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ethernet/cfm/crosscheck/service-up", data.getPath()))
+ }
+ if !data.EnableTrapsEthernetCfmCrosscheckMepUnknown.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ethernet/cfm/crosscheck/mep-unknown", data.getPath()))
+ }
+ if !data.EnableTrapsEthernetCfmCrosscheckMepMissing.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ethernet/cfm/crosscheck/mep-missing", data.getPath()))
+ }
+ if !data.EnableTrapsEthernetCfmCcMepUp.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ethernet/cfm/cc/mep-up", data.getPath()))
+ }
+ if !data.EnableTrapsEthernetCfmCcMepDown.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ethernet/cfm/cc/mep-down", data.getPath()))
+ }
+ if !data.EnableTrapsEthernetCfmCcLoop.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ethernet/cfm/cc/loop", data.getPath()))
+ }
+ if !data.EnableTrapsEthernetCfmCcCrossConnect.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ethernet/cfm/cc/cross-connect", data.getPath()))
+ }
+ if !data.EnableTrapsEthernetCfmCcConfig.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ethernet/cfm/cc/config", data.getPath()))
}
- if !data.EnableTrapsEthernetEvcStatus.IsNull() && !data.EnableTrapsEthernetEvcStatus.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ethernet/evc/status", data.getPath()))
+ if !data.EnableTrapsEthernetCfmAlarm.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ethernet/cfm/alarm", data.getPath()))
}
- if !data.EnableTrapsEthernetEvcDelete.IsNull() && !data.EnableTrapsEthernetEvcDelete.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ethernet/evc/delete", data.getPath()))
+ if !data.EnableTrapsEtherOam.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ether-oam", data.getPath()))
}
- if !data.EnableTrapsEthernetEvcCreate.IsNull() && !data.EnableTrapsEthernetEvcCreate.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ethernet/evc/create", data.getPath()))
+ if !data.EnableTrapsEntityQfpThroughputNotif.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/entity-qfp/throughput-notif", data.getPath()))
}
- if !data.EnableTrapsEthernetCfmCrosscheckServiceUp.IsNull() && !data.EnableTrapsEthernetCfmCrosscheckServiceUp.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ethernet/cfm/crosscheck/service-up", data.getPath()))
+ if !data.EnableTrapsEntityQfpMemResThresh.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/entity-qfp/mem-res-thresh", data.getPath()))
}
- if !data.EnableTrapsEthernetCfmCrosscheckMepUnknown.IsNull() && !data.EnableTrapsEthernetCfmCrosscheckMepUnknown.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ethernet/cfm/crosscheck/mep-unknown", data.getPath()))
+ if !data.EnableTrapsEntityState.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/entity-state", data.getPath()))
}
- if !data.EnableTrapsEthernetCfmCrosscheckMepMissing.IsNull() && !data.EnableTrapsEthernetCfmCrosscheckMepMissing.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ethernet/cfm/crosscheck/mep-missing", data.getPath()))
+ if !data.EnableTrapsEntitySensor.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/entity-sensor", data.getPath()))
}
- if !data.EnableTrapsEthernetCfmCcMepUp.IsNull() && !data.EnableTrapsEthernetCfmCcMepUp.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ethernet/cfm/cc/mep-up", data.getPath()))
+ if !data.EnableTrapsDspOperState.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/dsp/oper-state", data.getPath()))
}
- if !data.EnableTrapsEthernetCfmCcMepDown.IsNull() && !data.EnableTrapsEthernetCfmCcMepDown.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ethernet/cfm/cc/mep-down", data.getPath()))
+ if !data.EnableTrapsDspCardStatus.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/dsp/card-status", data.getPath()))
}
- if !data.EnableTrapsEthernetCfmCcLoop.IsNull() && !data.EnableTrapsEthernetCfmCcLoop.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ethernet/cfm/cc/loop", data.getPath()))
+ if !data.EnableTrapsDs1.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ds1", data.getPath()))
}
- if !data.EnableTrapsEthernetCfmCcCrossConnect.IsNull() && !data.EnableTrapsEthernetCfmCcCrossConnect.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ethernet/cfm/cc/cross-connect", data.getPath()))
+ if !data.EnableTrapsDlsw.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/dlsw", data.getPath()))
}
- if !data.EnableTrapsEthernetCfmCcConfig.IsNull() && !data.EnableTrapsEthernetCfmCcConfig.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ethernet/cfm/cc/config", data.getPath()))
+ if !data.EnableTrapsDial.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/dial", data.getPath()))
}
- if !data.EnableTrapsEthernetCfmAlarm.IsNull() && !data.EnableTrapsEthernetCfmAlarm.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ethernet/cfm/alarm", data.getPath()))
+ if !data.EnableTrapsCnpd.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/cnpd", data.getPath()))
}
- if !data.EnableTrapsEtherOam.IsNull() && !data.EnableTrapsEtherOam.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ether-oam", data.getPath()))
+ if !data.EnableTrapsCasa.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/casa", data.getPath()))
}
- if !data.EnableTrapsEntityQfpThroughputNotif.IsNull() && !data.EnableTrapsEntityQfpThroughputNotif.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/entity-qfp/throughput-notif", data.getPath()))
+ if !data.EnableTrapsAlarmType.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/alarms/alarm-type", data.getPath()))
}
- if !data.EnableTrapsEntityQfpMemResThresh.IsNull() && !data.EnableTrapsEntityQfpMemResThresh.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/entity-qfp/mem-res-thresh", data.getPath()))
+ if !data.EnableTrapsPki.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/pki", data.getPath()))
}
- if !data.EnableTrapsEntityState.IsNull() && !data.EnableTrapsEntityState.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/entity-state", data.getPath()))
+ if !data.EnableTrapsAdslline.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/adslline", data.getPath()))
}
- if !data.EnableTrapsEntitySensor.IsNull() && !data.EnableTrapsEntitySensor.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/entity-sensor", data.getPath()))
+ if !data.EnableTrapsVdsl2line.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/vdsl2line", data.getPath()))
}
- if !data.EnableTrapsDspOperState.IsNull() && !data.EnableTrapsDspOperState.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/dsp/oper-state", data.getPath()))
+ if !data.EnableTrapsAaaServer.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/aaa_server", data.getPath()))
}
- if !data.EnableTrapsDspCardStatus.IsNull() && !data.EnableTrapsDspCardStatus.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/dsp/card-status", data.getPath()))
+ if !data.EnableTrapsLisp.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/lisp", data.getPath()))
}
- if !data.EnableTrapsDs1.IsNull() && !data.EnableTrapsDs1.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ds1", data.getPath()))
+ if !data.EnableTrapsMvpn.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/mvpn", data.getPath()))
}
- if !data.EnableTrapsDlsw.IsNull() && !data.EnableTrapsDlsw.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/dlsw", data.getPath()))
+ if !data.EnableTrapsVrfmibVnetTrunkDown.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/vrfmib/vnet-trunk-down", data.getPath()))
}
- if !data.EnableTrapsDial.IsNull() && !data.EnableTrapsDial.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/dial", data.getPath()))
+ if !data.EnableTrapsVrfmibVnetTrunkUp.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/vrfmib/vnet-trunk-up", data.getPath()))
}
- if !data.EnableTrapsCnpd.IsNull() && !data.EnableTrapsCnpd.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/cnpd", data.getPath()))
+ if !data.EnableTrapsVrfmibVrfDown.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/vrfmib/vrf-down", data.getPath()))
}
- if !data.EnableTrapsCasa.IsNull() && !data.EnableTrapsCasa.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/casa", data.getPath()))
+ if !data.EnableTrapsVrfmibVrfUp.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/vrfmib/vrf-up", data.getPath()))
}
- if !data.EnableTrapsPki.IsNull() && !data.EnableTrapsPki.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/pki", data.getPath()))
+ if !data.EnableTrapsMacNotificationThreshold.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/mac-notification/threshold", data.getPath()))
}
- if !data.EnableTrapsAdslline.IsNull() && !data.EnableTrapsAdslline.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/adslline", data.getPath()))
+ if !data.EnableTrapsMacNotificationMove.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/mac-notification/move", data.getPath()))
}
- if !data.EnableTrapsVdsl2line.IsNull() && !data.EnableTrapsVdsl2line.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/vdsl2line", data.getPath()))
+ if !data.EnableTrapsMacNotificationChange.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/mac-notification/change", data.getPath()))
}
- if !data.EnableTrapsAaaServer.IsNull() && !data.EnableTrapsAaaServer.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/aaa_server", data.getPath()))
+ if !data.EnableTrapsBulkstatTransfer.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/bulkstat/transfer", data.getPath()))
}
- if !data.EnableTrapsLisp.IsNull() && !data.EnableTrapsLisp.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/lisp", data.getPath()))
+ if !data.EnableTrapsBulkstatCollection.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/bulkstat/collection", data.getPath()))
}
- if !data.EnableTrapsMvpn.IsNull() && !data.EnableTrapsMvpn.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/mvpn", data.getPath()))
+ if !data.EnableTrapsTransceiverAll.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/transceiver/all", data.getPath()))
}
- if !data.EnableTrapsVrfmibVnetTrunkDown.IsNull() && !data.EnableTrapsVrfmibVnetTrunkDown.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/vrfmib/vnet-trunk-down", data.getPath()))
+ if !data.EnableTrapsRf.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/rf", data.getPath()))
}
- if !data.EnableTrapsVrfmibVnetTrunkUp.IsNull() && !data.EnableTrapsVrfmibVnetTrunkUp.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/vrfmib/vnet-trunk-up", data.getPath()))
+ if !data.EnableTrapsErrdisable.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/errdisable", data.getPath()))
}
- if !data.EnableTrapsVrfmibVrfDown.IsNull() && !data.EnableTrapsVrfmibVrfDown.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/vrfmib/vrf-down", data.getPath()))
+ if !data.EnableTrapsVlanMembership.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/vlan-membership", data.getPath()))
}
- if !data.EnableTrapsVrfmibVrfUp.IsNull() && !data.EnableTrapsVrfmibVrfUp.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/vrfmib/vrf-up", data.getPath()))
+ if !data.EnableTrapsLocalAuth.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/local-auth", data.getPath()))
}
- if !data.EnableTrapsMacNotificationThreshold.IsNull() && !data.EnableTrapsMacNotificationThreshold.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/mac-notification/threshold", data.getPath()))
+ if !data.EnableTrapsFastRerouteProtected.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/mpls/fast-reroute/protected", data.getPath()))
}
- if !data.EnableTrapsMacNotificationMove.IsNull() && !data.EnableTrapsMacNotificationMove.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/mac-notification/move", data.getPath()))
+ if !data.EnableTrapsMplsLdp.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/mpls/ldp", data.getPath()))
}
- if !data.EnableTrapsMacNotificationChange.IsNull() && !data.EnableTrapsMacNotificationChange.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/mac-notification/change", data.getPath()))
+ if !data.EnableTrapsMplsRfcLdp.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/mpls/rfc/ldp", data.getPath()))
}
- if !data.EnableTrapsBulkstatTransfer.IsNull() && !data.EnableTrapsBulkstatTransfer.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/bulkstat/transfer", data.getPath()))
+ if !data.EnableTrapsMplsRfc.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/mpls/rfc", data.getPath()))
}
- if !data.EnableTrapsBulkstatCollection.IsNull() && !data.EnableTrapsBulkstatCollection.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/bulkstat/collection", data.getPath()))
+ if !data.EnableTrapsMplsVpn.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/mpls/vpn", data.getPath()))
}
- if !data.EnableTrapsTransceiverAll.IsNull() && !data.EnableTrapsTransceiverAll.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/transceiver/all", data.getPath()))
+ if !data.EnableTrapsMpls.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/mpls", data.getPath()))
}
- if !data.EnableTrapsRf.IsNull() && !data.EnableTrapsRf.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/rf", data.getPath()))
+ if !data.EnableTrapsMplsTrafficEng.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/mpls/traffic-eng", data.getPath()))
}
- if !data.EnableTrapsErrdisable.IsNull() && !data.EnableTrapsErrdisable.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/errdisable", data.getPath()))
+ if !data.EnableTrapsNhrpQuotaExceeded.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/nhrp/quota-exceeded", data.getPath()))
}
- if !data.EnableTrapsVlanMembership.IsNull() && !data.EnableTrapsVlanMembership.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/vlan-membership", data.getPath()))
+ if !data.EnableTrapsNhrpNhp.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/nhrp/nhp", data.getPath()))
}
- if !data.EnableTrapsLocalAuth.IsNull() && !data.EnableTrapsLocalAuth.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/local-auth", data.getPath()))
+ if !data.EnableTrapsNhrpNhc.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/nhrp/nhc", data.getPath()))
}
- if !data.EnableTrapsFastRerouteProtected.IsNull() && !data.EnableTrapsFastRerouteProtected.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/mpls/fast-reroute/protected", data.getPath()))
+ if !data.EnableTrapsNhrpNhs.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/nhrp/nhs", data.getPath()))
}
- if !data.EnableTrapsMplsLdp.IsNull() && !data.EnableTrapsMplsLdp.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/mpls/ldp", data.getPath()))
+ if !data.EnableTrapsBgpCbgp2.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/Cisco-IOS-XE-bgp:bgp/cbgp2", data.getPath()))
}
- if !data.EnableTrapsMplsRfcLdp.IsNull() && !data.EnableTrapsMplsRfcLdp.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/mpls/rfc/ldp", data.getPath()))
+ if !data.EnableTrapsSyslog.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/syslog", data.getPath()))
}
- if !data.EnableTrapsMplsRfc.IsNull() && !data.EnableTrapsMplsRfc.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/mpls/rfc", data.getPath()))
+ if !data.EnableTrapsStpxLoopInconsistency.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/stpx", data.getPath()))
}
- if !data.EnableTrapsMplsVpn.IsNull() && !data.EnableTrapsMplsVpn.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/mpls/vpn", data.getPath()))
+ if !data.EnableTrapsStpxRootInconsistency.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/stpx", data.getPath()))
}
- if !data.EnableTrapsMpls.IsNull() && !data.EnableTrapsMpls.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/mpls", data.getPath()))
+ if !data.EnableTrapsStpxInconsistency.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/stpx/inconsistency", data.getPath()))
}
- if !data.EnableTrapsMplsTrafficEng.IsNull() && !data.EnableTrapsMplsTrafficEng.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/mpls/traffic-eng", data.getPath()))
+ if !data.EnableTrapsBridgeTopologychange.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/bridge/topologychange", data.getPath()))
}
- if !data.EnableTrapsNhrpQuotaExceeded.IsNull() && !data.EnableTrapsNhrpQuotaExceeded.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/nhrp/quota-exceeded", data.getPath()))
+ if !data.EnableTrapsBridgeNewroot.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/bridge/newroot", data.getPath()))
}
- if !data.EnableTrapsNhrpNhp.IsNull() && !data.EnableTrapsNhrpNhp.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/nhrp/nhp", data.getPath()))
+ if !data.EnableTrapsPimRpMappingChange.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/pim/rp-mapping-change", data.getPath()))
}
- if !data.EnableTrapsNhrpNhc.IsNull() && !data.EnableTrapsNhrpNhc.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/nhrp/nhc", data.getPath()))
+ if !data.EnableTrapsPimNeighborChange.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/pim/neighbor-change", data.getPath()))
}
- if !data.EnableTrapsNhrpNhs.IsNull() && !data.EnableTrapsNhrpNhs.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/nhrp/nhs", data.getPath()))
+ if !data.EnableTrapsPimInvalidPimMessage.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/pim/invalid-pim-message", data.getPath()))
}
- if !data.EnableTrapsBgpCbgp2.IsNull() && !data.EnableTrapsBgpCbgp2.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/Cisco-IOS-XE-bgp:bgp/cbgp2", data.getPath()))
+ if !data.EnableTrapsOspfConfigErrors.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/Cisco-IOS-XE-ospf:ospf-config/errors/enable", data.getPath()))
}
- if !data.EnableTrapsSyslog.IsNull() && !data.EnableTrapsSyslog.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/syslog", data.getPath()))
+ if !data.EnableTrapsOspfConfigStateChange.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/Cisco-IOS-XE-ospf:ospf-config/state-change/enable", data.getPath()))
}
- if !data.EnableTrapsStpxLoopInconsistency.IsNull() && !data.EnableTrapsStpxLoopInconsistency.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/stpx/loop-inconsistency", data.getPath()))
+ if !data.EnableTrapsMsdp.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/msdp", data.getPath()))
}
- if !data.EnableTrapsStpxRootInconsistency.IsNull() && !data.EnableTrapsStpxRootInconsistency.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/stpx/root-inconsistency", data.getPath()))
+ if !data.EnableTrapsIpmulticast.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ipmulticast", data.getPath()))
}
- if !data.EnableTrapsStpxInconsistency.IsNull() && !data.EnableTrapsStpxInconsistency.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/stpx/inconsistency", data.getPath()))
+ if !data.EnableTrapsHsrp.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/hsrp", data.getPath()))
}
- if !data.EnableTrapsBridgeTopologychange.IsNull() && !data.EnableTrapsBridgeTopologychange.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/bridge/topologychange", data.getPath()))
+ if !data.EnableTrapsEventManager.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/event-manager", data.getPath()))
}
- if !data.EnableTrapsBridgeNewroot.IsNull() && !data.EnableTrapsBridgeNewroot.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/bridge/newroot", data.getPath()))
+ if !data.EnableTrapsDhcp.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/dhcp", data.getPath()))
}
- if !data.EnableTrapsPimRpMappingChange.IsNull() && !data.EnableTrapsPimRpMappingChange.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/pim/rp-mapping-change", data.getPath()))
+ if !data.EnableTrapsConfigCtid.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/config-ctid", data.getPath()))
}
- if !data.EnableTrapsPimNeighborChange.IsNull() && !data.EnableTrapsPimNeighborChange.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/pim/neighbor-change", data.getPath()))
+ if !data.EnableTrapsConfig.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/config", data.getPath()))
}
- if !data.EnableTrapsPimInvalidPimMessage.IsNull() && !data.EnableTrapsPimInvalidPimMessage.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/pim/invalid-pim-message", data.getPath()))
+ if !data.EnableTrapsConfigCopy.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/config-copy", data.getPath()))
}
- if !data.EnableTrapsOspfConfigErrors.IsNull() && !data.EnableTrapsOspfConfigErrors.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/Cisco-IOS-XE-ospf:ospf-config/errors/enable", data.getPath()))
+ if !data.EnableTrapsIpsecTooManySas.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ipsec/too-many-sas", data.getPath()))
}
- if !data.EnableTrapsOspfConfigStateChange.IsNull() && !data.EnableTrapsOspfConfigStateChange.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/Cisco-IOS-XE-ospf:ospf-config/state-change/enable", data.getPath()))
+ if !data.EnableTrapsIpsecTunnelStop.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ipsec/tunnel/stop", data.getPath()))
}
- if !data.EnableTrapsMsdp.IsNull() && !data.EnableTrapsMsdp.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/msdp", data.getPath()))
+ if !data.EnableTrapsIpsecTunnelStart.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ipsec/tunnel/start", data.getPath()))
}
- if !data.EnableTrapsIpmulticast.IsNull() && !data.EnableTrapsIpmulticast.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ipmulticast", data.getPath()))
+ if !data.EnableTrapsIpsecCryptomapDetach.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ipsec/cryptomap/detach", data.getPath()))
}
- if !data.EnableTrapsHsrp.IsNull() && !data.EnableTrapsHsrp.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/hsrp", data.getPath()))
+ if !data.EnableTrapsIpsecCryptomapDelete.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ipsec/cryptomap/delete", data.getPath()))
}
- if !data.EnableTrapsEventManager.IsNull() && !data.EnableTrapsEventManager.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/event-manager", data.getPath()))
+ if !data.EnableTrapsIpsecCryptomapAttach.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ipsec/cryptomap/attach", data.getPath()))
}
- if !data.EnableTrapsDhcp.IsNull() && !data.EnableTrapsDhcp.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/dhcp", data.getPath()))
+ if !data.EnableTrapsIpsecCryptomapAdd.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ipsec/cryptomap/add", data.getPath()))
}
- if !data.EnableTrapsConfigCtid.IsNull() && !data.EnableTrapsConfigCtid.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/config-ctid", data.getPath()))
+ if !data.EnableTrapsIkeTunnelStop.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ike/tunnel/stop", data.getPath()))
}
- if !data.EnableTrapsConfig.IsNull() && !data.EnableTrapsConfig.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/config", data.getPath()))
+ if !data.EnableTrapsIkeTunnelStart.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ike/tunnel/start", data.getPath()))
}
- if !data.EnableTrapsConfigCopy.IsNull() && !data.EnableTrapsConfigCopy.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/config-copy", data.getPath()))
+ if !data.EnableTrapsIkePolicyDelete.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ike/policy/delete", data.getPath()))
}
- if !data.EnableTrapsIpsecTooManySas.IsNull() && !data.EnableTrapsIpsecTooManySas.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ipsec/too-many-sas", data.getPath()))
+ if !data.EnableTrapsIkePolicyAdd.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ike/policy/add", data.getPath()))
}
- if !data.EnableTrapsIpsecTunnelStop.IsNull() && !data.EnableTrapsIpsecTunnelStop.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ipsec/tunnel/stop", data.getPath()))
+ if !data.EnableTrapsBfd.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/bfd", data.getPath()))
}
- if !data.EnableTrapsIpsecTunnelStart.IsNull() && !data.EnableTrapsIpsecTunnelStart.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ipsec/tunnel/start", data.getPath()))
+ if !data.EnableTrapsEntityDiagScheduledTestFail.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/entity-diag/scheduled-test-fail", data.getPath()))
}
- if !data.EnableTrapsIpsecCryptomapDetach.IsNull() && !data.EnableTrapsIpsecCryptomapDetach.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ipsec/cryptomap/detach", data.getPath()))
+ if !data.EnableTrapsEntityDiagHmThreshReached.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/entity-diag/hm-thresh-reached", data.getPath()))
}
- if !data.EnableTrapsIpsecCryptomapDelete.IsNull() && !data.EnableTrapsIpsecCryptomapDelete.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ipsec/cryptomap/delete", data.getPath()))
+ if !data.EnableTrapsEntityDiagHmTestRecover.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/entity-diag/hm-test-recover", data.getPath()))
}
- if !data.EnableTrapsIpsecCryptomapAttach.IsNull() && !data.EnableTrapsIpsecCryptomapAttach.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ipsec/cryptomap/attach", data.getPath()))
+ if !data.EnableTrapsEntityDiagBootUpFail.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/entity-diag/boot-up-fail", data.getPath()))
}
- if !data.EnableTrapsIpsecCryptomapAdd.IsNull() && !data.EnableTrapsIpsecCryptomapAdd.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ipsec/cryptomap/add", data.getPath()))
+ if !data.EnableTrapsIpsla.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ipsla", data.getPath()))
}
- if !data.EnableTrapsIkeTunnelStop.IsNull() && !data.EnableTrapsIkeTunnelStop.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ike/tunnel/stop", data.getPath()))
+ if !data.EnableTrapsIsis.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/isis", data.getPath()))
}
- if !data.EnableTrapsIkeTunnelStart.IsNull() && !data.EnableTrapsIkeTunnelStart.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ike/tunnel/start", data.getPath()))
+ if !data.EnableTrapsCefInconsistency.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/cef/inconsistency", data.getPath()))
}
- if !data.EnableTrapsIkePolicyDelete.IsNull() && !data.EnableTrapsIkePolicyDelete.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ike/policy/delete", data.getPath()))
+ if !data.EnableTrapsCefPeerFibStateChange.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/cef/peer-fib-state-change", data.getPath()))
}
- if !data.EnableTrapsIkePolicyAdd.IsNull() && !data.EnableTrapsIkePolicyAdd.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ike/policy/add", data.getPath()))
+ if !data.EnableTrapsCefPeerStateChange.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/cef/peer-state-change", data.getPath()))
}
- if !data.EnableTrapsBfd.IsNull() && !data.EnableTrapsBfd.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/bfd", data.getPath()))
+ if !data.EnableTrapsCefResourceFailure.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/cef/resource-failure", data.getPath()))
}
- if !data.EnableTrapsEntityDiagScheduledTestFail.IsNull() && !data.EnableTrapsEntityDiagScheduledTestFail.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/entity-diag/scheduled-test-fail", data.getPath()))
+ if !data.EnableTrapsEnvmon.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/envmon", data.getPath()))
}
- if !data.EnableTrapsEntityDiagHmThreshReached.IsNull() && !data.EnableTrapsEntityDiagHmThreshReached.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/entity-diag/hm-thresh-reached", data.getPath()))
+ if !data.EnableTrapsPwVc.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/pw", data.getPath()))
}
- if !data.EnableTrapsEntityDiagHmTestRecover.IsNull() && !data.EnableTrapsEntityDiagHmTestRecover.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/entity-diag/hm-test-recover", data.getPath()))
+ if !data.EnableTrapsEntity.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/entity", data.getPath()))
}
- if !data.EnableTrapsEntityDiagBootUpFail.IsNull() && !data.EnableTrapsEntityDiagBootUpFail.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/entity-diag/boot-up-fail", data.getPath()))
+ if !data.EnableTrapsPowerEthernetPolice.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/power-ethernet/police", data.getPath()))
}
- if !data.EnableTrapsIpsla.IsNull() && !data.EnableTrapsIpsla.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ipsla", data.getPath()))
+ if !data.EnableTrapsPowerEthernetGroup.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/power-ethernet/group", data.getPath()))
}
- if !data.EnableTrapsIsis.IsNull() && !data.EnableTrapsIsis.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/isis", data.getPath()))
+ if !data.EnableTrapsEnergywise.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/energywise", data.getPath()))
}
- if !data.EnableTrapsCefInconsistency.IsNull() && !data.EnableTrapsCefInconsistency.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/cef/inconsistency", data.getPath()))
+ if !data.EnableTrapsFlashLowspace.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/flash/lowspace", data.getPath()))
}
- if !data.EnableTrapsCefPeerFibStateChange.IsNull() && !data.EnableTrapsCefPeerFibStateChange.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/cef/peer-fib-state-change", data.getPath()))
+ if !data.EnableTrapsFlashRemoval.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/flash/removal", data.getPath()))
}
- if !data.EnableTrapsCefPeerStateChange.IsNull() && !data.EnableTrapsCefPeerStateChange.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/cef/peer-state-change", data.getPath()))
+ if !data.EnableTrapsFlashInsertion.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/flash/insertion", data.getPath()))
}
- if !data.EnableTrapsCefResourceFailure.IsNull() && !data.EnableTrapsCefResourceFailure.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/cef/resource-failure", data.getPath()))
+ if !data.EnableTrapsFruCtrl.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/fru-ctrl", data.getPath()))
}
- if !data.EnableTrapsEnvmon.IsNull() && !data.EnableTrapsEnvmon.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/envmon", data.getPath()))
+ if !data.EnableTrapsUdldStatusChange.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/udld/status-change", data.getPath()))
}
- if !data.EnableTrapsPwVc.IsNull() && !data.EnableTrapsPwVc.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/pw/vc", data.getPath()))
+ if !data.EnableTrapsUdldLinkFailRpt.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/udld/link-fail-rpt", data.getPath()))
}
- if !data.EnableTrapsEntity.IsNull() && !data.EnableTrapsEntity.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/entity", data.getPath()))
+ if !data.EnableTrapsStackwise.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/stackwise", data.getPath()))
}
- if !data.EnableTrapsPowerEthernetPolice.IsNull() && !data.EnableTrapsPowerEthernetPolice.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/power-ethernet/police", data.getPath()))
+ if !data.EnableTrapsMemoryBufferpeak.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/memory/bufferpeak", data.getPath()))
}
- if !data.EnableTrapsEnergywise.IsNull() && !data.EnableTrapsEnergywise.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/energywise", data.getPath()))
+ if !data.EnableTrapsCpuThreshold.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/cpu/threshold", data.getPath()))
}
- if !data.EnableTrapsFlashLowspace.IsNull() && !data.EnableTrapsFlashLowspace.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/flash/lowspace", data.getPath()))
+ if !data.EnableTrapsSmartLicense.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/smart-licenseing/smart-license", data.getPath()))
}
- if !data.EnableTrapsFlashRemoval.IsNull() && !data.EnableTrapsFlashRemoval.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/flash/removal", data.getPath()))
+ if !data.EnableTrapsLicense.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/license", data.getPath()))
}
- if !data.EnableTrapsFlashInsertion.IsNull() && !data.EnableTrapsFlashInsertion.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/flash/insertion", data.getPath()))
+ if !data.EnableTrapsPortSecurity.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/port-security", data.getPath()))
}
- if !data.EnableTrapsFruCtrl.IsNull() && !data.EnableTrapsFruCtrl.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/fru-ctrl", data.getPath()))
+ if !data.EnableTrapsVlandelete.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/vlandelete", data.getPath()))
}
- if !data.EnableTrapsUdldStatusChange.IsNull() && !data.EnableTrapsUdldStatusChange.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/udld/status-change", data.getPath()))
+ if !data.EnableTrapsVlancreate.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/vlancreate", data.getPath()))
}
- if !data.EnableTrapsUdldLinkFailRpt.IsNull() && !data.EnableTrapsUdldLinkFailRpt.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/udld/link-fail-rpt", data.getPath()))
+ if !data.EnableTrapsVtp.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/vtp", data.getPath()))
}
- if !data.EnableTrapsStackwise.IsNull() && !data.EnableTrapsStackwise.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/stackwise", data.getPath()))
+ if !data.EnableTrapsRep.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/rep", data.getPath()))
}
- if !data.EnableTrapsMemoryBufferpeak.IsNull() && !data.EnableTrapsMemoryBufferpeak.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/memory/bufferpeak", data.getPath()))
+ if !data.EnableTrapsAuthFrameworkSecViolation.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/auth-framework/sec-violation", data.getPath()))
}
- if !data.EnableTrapsCpuThreshold.IsNull() && !data.EnableTrapsCpuThreshold.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/cpu/threshold", data.getPath()))
+ if !data.EnableTrapsEigrp.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/eigrp", data.getPath()))
}
- if !data.EnableTrapsSmartLicense.IsNull() && !data.EnableTrapsSmartLicense.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/smart-licenseing/smart-license", data.getPath()))
+ if !data.EnableTrapsOspfLsaEnable.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/Cisco-IOS-XE-ospf:ospf-config/cisco-specific/lsa/enable", data.getPath()))
}
- if !data.EnableTrapsLicense.IsNull() && !data.EnableTrapsLicense.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/license", data.getPath()))
+ if !data.EnableTrapsOspfRetransmitEnable.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/Cisco-IOS-XE-ospf:ospf-config/cisco-specific/retransmit/enable", data.getPath()))
}
- if !data.EnableTrapsPortSecurity.IsNull() && !data.EnableTrapsPortSecurity.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/port-security", data.getPath()))
+ if !data.EnableTrapsOspfErrorsEnable.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/Cisco-IOS-XE-ospf:ospf-config/cisco-specific/errors/enable", data.getPath()))
}
- if !data.EnableTrapsVlandelete.IsNull() && !data.EnableTrapsVlandelete.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/vlandelete", data.getPath()))
+ if !data.EnableTrapsOspfShamlinkNeighbor.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/Cisco-IOS-XE-ospf:ospf-config/cisco-specific/state-change/shamlink/neighbor", data.getPath()))
}
- if !data.EnableTrapsVlancreate.IsNull() && !data.EnableTrapsVlancreate.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/vlancreate", data.getPath()))
+ if !data.EnableTrapsOspfShamlinkInterface.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/Cisco-IOS-XE-ospf:ospf-config/cisco-specific/state-change/shamlink/interface", data.getPath()))
}
- if !data.EnableTrapsVtp.IsNull() && !data.EnableTrapsVtp.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/vtp", data.getPath()))
+ if !data.EnableTrapsOspfNssaTransChange.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/Cisco-IOS-XE-ospf:ospf-config/cisco-specific/state-change/nssa-trans-change", data.getPath()))
}
- if !data.EnableTrapsRep.IsNull() && !data.EnableTrapsRep.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/rep", data.getPath()))
+ if !data.EnableTrapsOspfConfigLsa.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/Cisco-IOS-XE-ospf:ospf-config/lsa/enable", data.getPath()))
}
- if !data.EnableTrapsAuthFrameworkSecViolation.IsNull() && !data.EnableTrapsAuthFrameworkSecViolation.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/auth-framework/sec-violation", data.getPath()))
+ if !data.EnableTrapsOspfConfigRetransmit.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/Cisco-IOS-XE-ospf:ospf-config/retransmit/enable", data.getPath()))
}
- if !data.EnableTrapsEigrp.IsNull() && !data.EnableTrapsEigrp.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/eigrp", data.getPath()))
+ if !data.EnableTrapsOspfv3ConfigErrors.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/Cisco-IOS-XE-ospfv3:ospfv3-config/errors/enable", data.getPath()))
}
- if !data.EnableTrapsOspfLsaEnable.IsNull() && !data.EnableTrapsOspfLsaEnable.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/Cisco-IOS-XE-ospf:ospf-config/cisco-specific/lsa/enable", data.getPath()))
+ if !data.EnableTrapsOspfv3ConfigStateChange.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/Cisco-IOS-XE-ospfv3:ospfv3-config/state-change/enable", data.getPath()))
}
- if !data.EnableTrapsOspfRetransmitEnable.IsNull() && !data.EnableTrapsOspfRetransmitEnable.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/Cisco-IOS-XE-ospf:ospf-config/cisco-specific/retransmit/enable", data.getPath()))
+ if !data.EnableTrapsTty.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/tty", data.getPath()))
}
- if !data.EnableTrapsOspfErrorsEnable.IsNull() && !data.EnableTrapsOspfErrorsEnable.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/Cisco-IOS-XE-ospf:ospf-config/cisco-specific/errors/enable", data.getPath()))
+ if !data.EnableTrapsCallHomeServerFail.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/call-home/server-fail", data.getPath()))
}
- if !data.EnableTrapsOspfShamlinkNeighbor.IsNull() && !data.EnableTrapsOspfShamlinkNeighbor.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/Cisco-IOS-XE-ospf:ospf-config/cisco-specific/state-change/shamlink/neighbor", data.getPath()))
+ if !data.EnableTrapsCallHomeMessageSendFail.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/call-home/message-send-fail", data.getPath()))
}
- if !data.EnableTrapsOspfShamlinkInterface.IsNull() && !data.EnableTrapsOspfShamlinkInterface.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/Cisco-IOS-XE-ospf:ospf-config/cisco-specific/state-change/shamlink/interface", data.getPath()))
+ if !data.EnableTrapsEntityPerfThroughputNotif.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/entity-perf/throughput-notif", data.getPath()))
}
- if !data.EnableTrapsOspfNssaTransChange.IsNull() && !data.EnableTrapsOspfNssaTransChange.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/Cisco-IOS-XE-ospf:ospf-config/cisco-specific/state-change/nssa-trans-change", data.getPath()))
+ if !data.EnableTrapsFlowmon.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/flowmon", data.getPath()))
}
- if !data.EnableTrapsOspfConfigLsa.IsNull() && !data.EnableTrapsOspfConfigLsa.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/Cisco-IOS-XE-ospf:ospf-config/lsa/enable", data.getPath()))
+ if !data.SystemShutdown.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:system-shutdown", data.getPath()))
}
- if !data.EnableTrapsOspfConfigRetransmit.IsNull() && !data.EnableTrapsOspfConfigRetransmit.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/Cisco-IOS-XE-ospf:ospf-config/retransmit/enable", data.getPath()))
+ for i := range data.VrfHosts {
+ keyValues := [...]string{data.VrfHosts[i].IpAddress.ValueString(), data.VrfHosts[i].Vrf.ValueString()}
+
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:host-config/ip-vrf-community=%v", data.getPath(), strings.Join(keyValues[:], ",")))
}
- if !data.EnableTrapsOspfv3ConfigErrors.IsNull() && !data.EnableTrapsOspfv3ConfigErrors.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/Cisco-IOS-XE-ospfv3:ospfv3-config/errors/enable", data.getPath()))
+ for i := range data.Hosts {
+ keyValues := [...]string{data.Hosts[i].IpAddress.ValueString()}
+
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:host-config/ip-community=%v", data.getPath(), strings.Join(keyValues[:], ",")))
}
- if !data.EnableTrapsOspfv3ConfigStateChange.IsNull() && !data.EnableTrapsOspfv3ConfigStateChange.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/Cisco-IOS-XE-ospfv3:ospfv3-config/state-change/enable", data.getPath()))
+ if !data.EnableTrapsSnmpWarmstart.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/snmp/warmstart", data.getPath()))
}
- if !data.EnableTrapsTty.IsNull() && !data.EnableTrapsTty.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/tty", data.getPath()))
+ if !data.EnableTrapsSnmpLinkup.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/snmp/linkup", data.getPath()))
}
- if !data.EnableTrapsCallHomeServerFail.IsNull() && !data.EnableTrapsCallHomeServerFail.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/call-home/server-fail", data.getPath()))
+ if !data.EnableTrapsSnmpLinkdown.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/snmp/linkdown", data.getPath()))
}
- if !data.EnableTrapsCallHomeMessageSendFail.IsNull() && !data.EnableTrapsCallHomeMessageSendFail.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/call-home/message-send-fail", data.getPath()))
+ if !data.EnableTrapsSnmpColdstart.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/snmp/coldstart", data.getPath()))
}
- if !data.EnableTrapsEntityPerfThroughputNotif.IsNull() && !data.EnableTrapsEntityPerfThroughputNotif.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/entity-perf/throughput-notif", data.getPath()))
+ if !data.EnableTrapsSnmpAuthentication.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/snmp/authentication", data.getPath()))
}
- if !data.EnableTrapsFlowmon.IsNull() && !data.EnableTrapsFlowmon.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/flowmon", data.getPath()))
+ if !data.EnableTraps.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps", data.getPath()))
}
- if !data.SystemShutdown.IsNull() && !data.SystemShutdown.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:system-shutdown", data.getPath()))
+ if !data.EnableInforms.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/informs", data.getPath()))
}
-
- if !data.EnableTrapsSnmpWarmstart.IsNull() && !data.EnableTrapsSnmpWarmstart.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/snmp/warmstart", data.getPath()))
+ if !data.EnableLoggingSetop.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/logging/setop", data.getPath()))
}
- if !data.EnableTrapsSnmpLinkup.IsNull() && !data.EnableTrapsSnmpLinkup.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/snmp/linkup", data.getPath()))
+ if !data.EnableLoggingGetop.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/logging/getop", data.getPath()))
}
- if !data.EnableTrapsSnmpLinkdown.IsNull() && !data.EnableTrapsSnmpLinkdown.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/snmp/linkdown", data.getPath()))
+ if !data.QueueLength.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:queue-length", data.getPath()))
}
- if !data.EnableTrapsSnmpColdstart.IsNull() && !data.EnableTrapsSnmpColdstart.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/snmp/coldstart", data.getPath()))
+ if !data.Packetsize.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:packetsize", data.getPath()))
}
- if !data.EnableTrapsSnmpAuthentication.IsNull() && !data.EnableTrapsSnmpAuthentication.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/snmp/authentication", data.getPath()))
+ if !data.Location.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:location", data.getPath()))
}
- if !data.EnableTraps.IsNull() && !data.EnableTraps.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps", data.getPath()))
+ if !data.IfindexPersist.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:ifindex/persist", data.getPath()))
}
- if !data.EnableInforms.IsNull() && !data.EnableInforms.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/informs", data.getPath()))
+ if !data.Contact.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:contact", data.getPath()))
}
- if !data.IfindexPersist.IsNull() && !data.IfindexPersist.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:ifindex/persist", data.getPath()))
+ if !data.ChassisId.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:chassis-id", data.getPath()))
}
- return emptyLeafsDelete
+ return deletePaths
}
-// End of section. //template:end getEmptyLeafsDelete
-
-// Section below is generated&owned by "gen/generator.go". //template:begin getDeletePaths
-
-func (data *SNMPServer) getDeletePaths(ctx context.Context) []string {
- var deletePaths []string
- for i := range data.Users {
- keyValues := [...]string{data.Users[i].Username.ValueString(), data.Users[i].Grpname.ValueString()}
+// End of section. //template:end getDeletePaths
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:user/names=%v", data.getPath(), strings.Join(keyValues[:], ",")))
- }
- for i := range data.Groups {
- keyValues := [...]string{data.Groups[i].Name.ValueString()}
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletePathsXML
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:group=%v", data.getPath(), strings.Join(keyValues[:], ",")))
+func (data *SNMPServer) addDeletePathsXML(ctx context.Context, body string) string {
+ b := netconf.NewBody(body)
+ if !data.ChassisId.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:chassis-id")
}
- for i := range data.Views {
- keyValues := [...]string{data.Views[i].Name.ValueString(), data.Views[i].Mib.ValueString()}
-
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:view=%v", data.getPath(), strings.Join(keyValues[:], ",")))
+ if !data.Contact.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:contact")
}
- for i := range data.Contexts {
- keyValues := [...]string{data.Contexts[i].Name.ValueString()}
-
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:context=%v", data.getPath(), strings.Join(keyValues[:], ",")))
+ if !data.IfindexPersist.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:ifindex/persist")
}
- for i := range data.SnmpCommunities {
- keyValues := [...]string{data.SnmpCommunities[i].Name.ValueString()}
-
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:community-config=%v", data.getPath(), strings.Join(keyValues[:], ",")))
+ if !data.Location.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:location")
}
- if !data.TrapSourceVlan.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:trap-source/Vlan", data.getPath()))
+ if !data.Packetsize.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:packetsize")
}
- if !data.TrapSourcePortChannelSubinterface.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:trap-source/Port-channel-subinterface/Port-channel", data.getPath()))
+ if !data.QueueLength.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:queue-length")
}
- if !data.TrapSourcePortChannel.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:trap-source/Port-channel", data.getPath()))
+ if !data.EnableLoggingGetop.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/logging/getop")
}
- if !data.TrapSourceLoopback.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:trap-source/Loopback", data.getPath()))
+ if !data.EnableLoggingSetop.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/logging/setop")
}
- if !data.TrapSourceHundredGigE.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:trap-source/HundredGigE", data.getPath()))
+ if !data.EnableInforms.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/informs")
}
- if !data.TrapSourceFortyGigabitEthernet.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:trap-source/FortyGigabitEthernet", data.getPath()))
+ if !data.EnableTraps.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps")
}
- if !data.TrapSourceTenGigabitEthernet.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:trap-source/TenGigabitEthernet", data.getPath()))
+ if !data.EnableTrapsSnmpAuthentication.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/snmp/authentication")
}
- if !data.TrapSourceGigabitEthernet.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:trap-source/GigabitEthernet", data.getPath()))
+ if !data.EnableTrapsSnmpColdstart.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/snmp/coldstart")
}
- if !data.SourceInterfaceTrapsVlan.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:source-interface/traps/Vlan", data.getPath()))
+ if !data.EnableTrapsSnmpLinkdown.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/snmp/linkdown")
}
- if !data.SourceInterfaceTrapsPortChannelSubinterface.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:source-interface/traps/Port-channel-subinterface/Port-channel", data.getPath()))
+ if !data.EnableTrapsSnmpLinkup.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/snmp/linkup")
}
- if !data.SourceInterfaceTrapsPortChannel.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:source-interface/traps/Port-channel", data.getPath()))
+ if !data.EnableTrapsSnmpWarmstart.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/snmp/warmstart")
}
- if !data.SourceInterfaceTrapsLoopback.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:source-interface/traps/Loopback", data.getPath()))
+ for i := range data.Hosts {
+ keys := [...]string{"ip-address"}
+ keyValues := [...]string{data.Hosts[i].IpAddress.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/Cisco-IOS-XE-snmp:host-config/ip-community%v", predicates))
}
- if !data.SourceInterfaceTrapsHundredGigE.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:source-interface/traps/HundredGigE", data.getPath()))
+ for i := range data.VrfHosts {
+ keys := [...]string{"ip-address", "vrf"}
+ keyValues := [...]string{data.VrfHosts[i].IpAddress.ValueString(), data.VrfHosts[i].Vrf.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/Cisco-IOS-XE-snmp:host-config/ip-vrf-community%v", predicates))
}
- if !data.SourceInterfaceTrapsFortyGigabitEthernet.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:source-interface/traps/FortyGigabitEthernet", data.getPath()))
+ if !data.SystemShutdown.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:system-shutdown")
}
- if !data.SourceInterfaceTrapsTenGigabitEthernet.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:source-interface/traps/TenGigabitEthernet", data.getPath()))
+ if !data.EnableTrapsFlowmon.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/flowmon")
}
- if !data.SourceInterfaceTrapsGigabitEthernet.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:source-interface/traps/GigabitEthernet", data.getPath()))
+ if !data.EnableTrapsEntityPerfThroughputNotif.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/entity-perf/throughput-notif")
}
- if !data.SourceInterfaceInformsVlan.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:source-interface/informs/Vlan", data.getPath()))
+ if !data.EnableTrapsCallHomeMessageSendFail.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/call-home/message-send-fail")
}
- if !data.SourceInterfaceInformsPortChannelSubinterface.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:source-interface/informs/Port-channel-subinterface/Port-channel", data.getPath()))
+ if !data.EnableTrapsCallHomeServerFail.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/call-home/server-fail")
}
- if !data.SourceInterfaceInformsPortChannel.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:source-interface/informs/Port-channel", data.getPath()))
+ if !data.EnableTrapsTty.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/tty")
}
- if !data.SourceInterfaceInformsLoopback.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:source-interface/informs/Loopback", data.getPath()))
+ if !data.EnableTrapsOspfv3ConfigStateChange.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/Cisco-IOS-XE-ospfv3:ospfv3-config/state-change/enable")
}
- if !data.SourceInterfaceInformsHundredGigE.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:source-interface/informs/HundredGigE", data.getPath()))
+ if !data.EnableTrapsOspfv3ConfigErrors.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/Cisco-IOS-XE-ospfv3:ospfv3-config/errors/enable")
}
- if !data.SourceInterfaceInformsFortyGigabitEthernet.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:source-interface/informs/FortyGigabitEthernet", data.getPath()))
+ if !data.EnableTrapsOspfConfigRetransmit.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/Cisco-IOS-XE-ospf:ospf-config/retransmit/enable")
}
- if !data.SourceInterfaceInformsTenGigabitEthernet.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:source-interface/informs/TenGigabitEthernet", data.getPath()))
+ if !data.EnableTrapsOspfConfigLsa.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/Cisco-IOS-XE-ospf:ospf-config/lsa/enable")
}
- if !data.SourceInterfaceInformsGigabitEthernet.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:source-interface/informs/GigabitEthernet", data.getPath()))
+ if !data.EnableTrapsOspfNssaTransChange.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/Cisco-IOS-XE-ospf:ospf-config/cisco-specific/state-change/nssa-trans-change")
}
- if !data.EnableTrapsOspfv3StateChange.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ospfv3/state-change", data.getPath()))
+ if !data.EnableTrapsOspfShamlinkInterface.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/Cisco-IOS-XE-ospf:ospf-config/cisco-specific/state-change/shamlink/interface")
}
- if !data.EnableTrapsOspfv3Errors.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ospfv3/errors", data.getPath()))
+ if !data.EnableTrapsOspfShamlinkNeighbor.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/Cisco-IOS-XE-ospf:ospf-config/cisco-specific/state-change/shamlink/neighbor")
}
- if !data.EnableTrapsCbgp2.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/bgp-traps/cbgp2", data.getPath()))
+ if !data.EnableTrapsOspfErrorsEnable.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/Cisco-IOS-XE-ospf:ospf-config/cisco-specific/errors/enable")
}
- if !data.EnableTrapsBgp.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/bgp", data.getPath()))
+ if !data.EnableTrapsOspfRetransmitEnable.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/Cisco-IOS-XE-ospf:ospf-config/cisco-specific/retransmit/enable")
}
- if !data.EnableTrapsVoice.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/voice", data.getPath()))
+ if !data.EnableTrapsOspfLsaEnable.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/Cisco-IOS-XE-ospf:ospf-config/cisco-specific/lsa/enable")
}
- if !data.EnableTrapsSrp.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/srp", data.getPath()))
+ if !data.EnableTrapsEigrp.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/eigrp")
}
- if !data.EnableTrapsSonet.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/sonet", data.getPath()))
+ if !data.EnableTrapsAuthFrameworkSecViolation.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/auth-framework/sec-violation")
}
- if !data.EnableTrapsVrrp.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/vrrp", data.getPath()))
+ if !data.EnableTrapsRep.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/rep")
}
- if !data.EnableTrapsRsvp.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/rsvp", data.getPath()))
+ if !data.EnableTrapsVtp.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/vtp")
}
- if !data.EnableTrapsResourcePolicy.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/resource-policy", data.getPath()))
+ if !data.EnableTrapsVlancreate.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/vlancreate")
}
- if !data.EnableTrapsPppoe.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/pppoe", data.getPath()))
+ if !data.EnableTrapsVlandelete.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/vlandelete")
}
- if !data.EnableTrapsPfr.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/pfr", data.getPath()))
+ if !data.EnableTrapsPortSecurity.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/port-security")
}
- if !data.EnableTrapsPimstdmibInterfaceElection.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/pimstdmib/interface-election", data.getPath()))
+ if !data.EnableTrapsLicense.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/license")
}
- if !data.EnableTrapsPimstdmibRpMappingChange.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/pimstdmib/rp-mapping-change", data.getPath()))
+ if !data.EnableTrapsSmartLicense.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/smart-licenseing/smart-license")
}
- if !data.EnableTrapsPimstdmibInvalidJoinPrune.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/pimstdmib/invalid-join-prune", data.getPath()))
+ if !data.EnableTrapsCpuThreshold.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/cpu/threshold")
}
- if !data.EnableTrapsPimstdmibInvalidRegister.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/pimstdmib/invalid-register", data.getPath()))
+ if !data.EnableTrapsMemoryBufferpeak.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/memory/bufferpeak")
}
- if !data.EnableTrapsPimstdmibNeighborLoss.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/pimstdmib/neighbor-loss", data.getPath()))
+ if !data.EnableTrapsStackwise.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/stackwise")
}
- if !data.EnableTrapsL2tunPseudowireStatus.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/l2tun/pseudowire/status", data.getPath()))
+ if !data.EnableTrapsUdldLinkFailRpt.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/udld/link-fail-rpt")
}
- if !data.EnableTrapsL2tunTunnel.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/l2tun/tunnel", data.getPath()))
+ if !data.EnableTrapsUdldStatusChange.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/udld/status-change")
}
- if !data.EnableTrapsL2tunSession.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/l2tun/session", data.getPath()))
+ if !data.EnableTrapsFruCtrl.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/fru-ctrl")
}
- if !data.EnableTrapsIsdnLayer2.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/isdn/layer2", data.getPath()))
+ if !data.EnableTrapsFlashInsertion.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/flash/insertion")
}
- if !data.EnableTrapsIsdnIetf.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/isdn/ietf", data.getPath()))
+ if !data.EnableTrapsFlashRemoval.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/flash/removal")
}
- if !data.EnableTrapsIsdnChanNotAvail.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/isdn/chan-not-avail", data.getPath()))
+ if !data.EnableTrapsFlashLowspace.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/flash/lowspace")
}
- if !data.EnableTrapsIsdnCallInformation.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/isdn/call-information", data.getPath()))
+ if !data.EnableTrapsEnergywise.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/energywise")
}
- if !data.EnableTrapsIpLocalPool.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ip/local/pool", data.getPath()))
+ if !data.EnableTrapsPowerEthernetGroup.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/power-ethernet/group")
}
- if !data.EnableTrapsFrameRelayMultilinkBundleMismatch.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/frame-relay/multilink/bundle-mismatch", data.getPath()))
+ if !data.EnableTrapsPowerEthernetPolice.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/power-ethernet/police")
}
- if !data.EnableTrapsFrameRelayConfigBundleMismatch.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/frame-relay-config/frame-relay-options/frame-relay/multilink/bundle-mismatch", data.getPath()))
+ if !data.EnableTrapsEntity.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/entity")
}
- if !data.EnableTrapsFrameRelaySubifInterval.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/frame-relay/subif/interval", data.getPath()))
+ if !data.EnableTrapsPwVc.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/pw/vc")
}
- if !data.EnableTrapsFrameRelaySubifCount.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/frame-relay/subif/count", data.getPath()))
+ if !data.EnableTrapsEnvmon.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/envmon")
}
- if !data.EnableTrapsFrameRelayConfigSubifConfigs.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/frame-relay-config/frame-relay-options/frame-relay/subif-configs/subif", data.getPath()))
+ if !data.EnableTrapsCefResourceFailure.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/cef/resource-failure")
}
- if !data.EnableTrapsFrameRelayConfigOnly.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/frame-relay-config/only-frame-relay/frame-relay", data.getPath()))
+ if !data.EnableTrapsCefPeerStateChange.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/cef/peer-state-change")
}
- if !data.EnableTrapsFirewallServerstatus.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/firewall/serverstatus", data.getPath()))
+ if !data.EnableTrapsCefPeerFibStateChange.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/cef/peer-fib-state-change")
}
- if !data.EnableTrapsEthernetEvcStatus.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ethernet/evc/status", data.getPath()))
+ if !data.EnableTrapsCefInconsistency.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/cef/inconsistency")
}
- if !data.EnableTrapsEthernetEvcDelete.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ethernet/evc/delete", data.getPath()))
+ if !data.EnableTrapsIsis.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/isis")
}
- if !data.EnableTrapsEthernetEvcCreate.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ethernet/evc/create", data.getPath()))
+ if !data.EnableTrapsIpsla.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ipsla")
}
- if !data.EnableTrapsEthernetCfmCrosscheckServiceUp.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ethernet/cfm/crosscheck/service-up", data.getPath()))
+ if !data.EnableTrapsEntityDiagBootUpFail.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/entity-diag/boot-up-fail")
}
- if !data.EnableTrapsEthernetCfmCrosscheckMepUnknown.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ethernet/cfm/crosscheck/mep-unknown", data.getPath()))
+ if !data.EnableTrapsEntityDiagHmTestRecover.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/entity-diag/hm-test-recover")
}
- if !data.EnableTrapsEthernetCfmCrosscheckMepMissing.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ethernet/cfm/crosscheck/mep-missing", data.getPath()))
+ if !data.EnableTrapsEntityDiagHmThreshReached.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/entity-diag/hm-thresh-reached")
}
- if !data.EnableTrapsEthernetCfmCcMepUp.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ethernet/cfm/cc/mep-up", data.getPath()))
+ if !data.EnableTrapsEntityDiagScheduledTestFail.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/entity-diag/scheduled-test-fail")
}
- if !data.EnableTrapsEthernetCfmCcMepDown.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ethernet/cfm/cc/mep-down", data.getPath()))
+ if !data.EnableTrapsBfd.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/bfd")
}
- if !data.EnableTrapsEthernetCfmCcLoop.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ethernet/cfm/cc/loop", data.getPath()))
+ if !data.EnableTrapsIkePolicyAdd.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ike/policy/add")
}
- if !data.EnableTrapsEthernetCfmCcCrossConnect.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ethernet/cfm/cc/cross-connect", data.getPath()))
+ if !data.EnableTrapsIkePolicyDelete.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ike/policy/delete")
}
- if !data.EnableTrapsEthernetCfmCcConfig.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ethernet/cfm/cc/config", data.getPath()))
+ if !data.EnableTrapsIkeTunnelStart.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ike/tunnel/start")
}
- if !data.EnableTrapsEthernetCfmAlarm.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ethernet/cfm/alarm", data.getPath()))
+ if !data.EnableTrapsIkeTunnelStop.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ike/tunnel/stop")
}
- if !data.EnableTrapsEtherOam.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ether-oam", data.getPath()))
+ if !data.EnableTrapsIpsecCryptomapAdd.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ipsec/cryptomap/add")
}
- if !data.EnableTrapsEntityQfpThroughputNotif.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/entity-qfp/throughput-notif", data.getPath()))
+ if !data.EnableTrapsIpsecCryptomapAttach.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ipsec/cryptomap/attach")
}
- if !data.EnableTrapsEntityQfpMemResThresh.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/entity-qfp/mem-res-thresh", data.getPath()))
+ if !data.EnableTrapsIpsecCryptomapDelete.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ipsec/cryptomap/delete")
}
- if !data.EnableTrapsEntityState.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/entity-state", data.getPath()))
+ if !data.EnableTrapsIpsecCryptomapDetach.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ipsec/cryptomap/detach")
}
- if !data.EnableTrapsEntitySensor.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/entity-sensor", data.getPath()))
+ if !data.EnableTrapsIpsecTunnelStart.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ipsec/tunnel/start")
}
- if !data.EnableTrapsDspOperState.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/dsp/oper-state", data.getPath()))
+ if !data.EnableTrapsIpsecTunnelStop.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ipsec/tunnel/stop")
}
- if !data.EnableTrapsDspCardStatus.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/dsp/card-status", data.getPath()))
+ if !data.EnableTrapsIpsecTooManySas.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ipsec/too-many-sas")
}
- if !data.EnableTrapsDs1.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ds1", data.getPath()))
+ if !data.EnableTrapsConfigCopy.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/config-copy")
}
- if !data.EnableTrapsDlsw.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/dlsw", data.getPath()))
+ if !data.EnableTrapsConfig.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/config")
}
- if !data.EnableTrapsDial.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/dial", data.getPath()))
+ if !data.EnableTrapsConfigCtid.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/config-ctid")
}
- if !data.EnableTrapsCnpd.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/cnpd", data.getPath()))
+ if !data.EnableTrapsDhcp.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/dhcp")
}
- if !data.EnableTrapsCasa.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/casa", data.getPath()))
+ if !data.EnableTrapsEventManager.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/event-manager")
}
- if !data.EnableTrapsAlarmType.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/alarms/alarm-type", data.getPath()))
+ if !data.EnableTrapsHsrp.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/hsrp")
}
- if !data.EnableTrapsPki.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/pki", data.getPath()))
+ if !data.EnableTrapsIpmulticast.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ipmulticast")
}
- if !data.EnableTrapsAdslline.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/adslline", data.getPath()))
+ if !data.EnableTrapsMsdp.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/msdp")
}
- if !data.EnableTrapsVdsl2line.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/vdsl2line", data.getPath()))
+ if !data.EnableTrapsOspfConfigStateChange.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/Cisco-IOS-XE-ospf:ospf-config/state-change/enable")
}
- if !data.EnableTrapsAaaServer.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/aaa_server", data.getPath()))
+ if !data.EnableTrapsOspfConfigErrors.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/Cisco-IOS-XE-ospf:ospf-config/errors/enable")
}
- if !data.EnableTrapsLisp.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/lisp", data.getPath()))
+ if !data.EnableTrapsPimInvalidPimMessage.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/pim/invalid-pim-message")
}
- if !data.EnableTrapsMvpn.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/mvpn", data.getPath()))
+ if !data.EnableTrapsPimNeighborChange.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/pim/neighbor-change")
}
- if !data.EnableTrapsVrfmibVnetTrunkDown.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/vrfmib/vnet-trunk-down", data.getPath()))
+ if !data.EnableTrapsPimRpMappingChange.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/pim/rp-mapping-change")
}
- if !data.EnableTrapsVrfmibVnetTrunkUp.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/vrfmib/vnet-trunk-up", data.getPath()))
+ if !data.EnableTrapsBridgeNewroot.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/bridge/newroot")
}
- if !data.EnableTrapsVrfmibVrfDown.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/vrfmib/vrf-down", data.getPath()))
+ if !data.EnableTrapsBridgeTopologychange.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/bridge/topologychange")
}
- if !data.EnableTrapsVrfmibVrfUp.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/vrfmib/vrf-up", data.getPath()))
+ if !data.EnableTrapsStpxInconsistency.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/stpx/inconsistency")
}
- if !data.EnableTrapsMacNotificationThreshold.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/mac-notification/threshold", data.getPath()))
+ if !data.EnableTrapsStpxRootInconsistency.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/stpx/root-inconsistency")
}
- if !data.EnableTrapsMacNotificationMove.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/mac-notification/move", data.getPath()))
+ if !data.EnableTrapsStpxLoopInconsistency.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/stpx/loop-inconsistency")
}
- if !data.EnableTrapsMacNotificationChange.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/mac-notification/change", data.getPath()))
+ if !data.EnableTrapsSyslog.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/syslog")
}
- if !data.EnableTrapsBulkstatTransfer.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/bulkstat/transfer", data.getPath()))
+ if !data.EnableTrapsBgpCbgp2.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/")
}
- if !data.EnableTrapsBulkstatCollection.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/bulkstat/collection", data.getPath()))
+ if !data.EnableTrapsNhrpNhs.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/nhrp/nhs")
}
- if !data.EnableTrapsTransceiverAll.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/transceiver/all", data.getPath()))
+ if !data.EnableTrapsNhrpNhc.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/nhrp/nhc")
}
- if !data.EnableTrapsRf.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/rf", data.getPath()))
+ if !data.EnableTrapsNhrpNhp.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/nhrp/nhp")
}
- if !data.EnableTrapsErrdisable.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/errdisable", data.getPath()))
+ if !data.EnableTrapsNhrpQuotaExceeded.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/nhrp/quota-exceeded")
}
- if !data.EnableTrapsVlanMembership.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/vlan-membership", data.getPath()))
+ if !data.EnableTrapsMplsTrafficEng.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/mpls/traffic-eng")
}
- if !data.EnableTrapsLocalAuth.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/local-auth", data.getPath()))
+ if !data.EnableTrapsMpls.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/mpls")
}
- if !data.EnableTrapsFastRerouteProtected.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/mpls/fast-reroute/protected", data.getPath()))
+ if !data.EnableTrapsMplsVpn.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/mpls/vpn")
}
- if !data.EnableTrapsMplsLdp.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/mpls/ldp", data.getPath()))
+ if !data.EnableTrapsMplsRfc.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/mpls/rfc")
}
if !data.EnableTrapsMplsRfcLdp.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/mpls/rfc/ldp", data.getPath()))
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/mpls/rfc/ldp")
}
- if !data.EnableTrapsMplsRfc.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/mpls/rfc", data.getPath()))
+ if !data.EnableTrapsMplsLdp.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/mpls/ldp")
}
- if !data.EnableTrapsMplsVpn.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/mpls/vpn", data.getPath()))
+ if !data.EnableTrapsFastRerouteProtected.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/mpls/fast-reroute/protected")
}
- if !data.EnableTrapsMpls.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/mpls", data.getPath()))
+ if !data.EnableTrapsLocalAuth.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/local-auth")
}
- if !data.EnableTrapsMplsTrafficEng.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/mpls/traffic-eng", data.getPath()))
+ if !data.EnableTrapsVlanMembership.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/vlan-membership")
}
- if !data.EnableTrapsNhrpQuotaExceeded.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/nhrp/quota-exceeded", data.getPath()))
+ if !data.EnableTrapsErrdisable.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/errdisable")
}
- if !data.EnableTrapsNhrpNhp.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/nhrp/nhp", data.getPath()))
+ if !data.EnableTrapsRf.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/rf")
}
- if !data.EnableTrapsNhrpNhc.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/nhrp/nhc", data.getPath()))
+ if !data.EnableTrapsTransceiverAll.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/transceiver/all")
}
- if !data.EnableTrapsNhrpNhs.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/nhrp/nhs", data.getPath()))
+ if !data.EnableTrapsBulkstatCollection.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/bulkstat/collection")
}
- if !data.EnableTrapsBgpCbgp2.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/Cisco-IOS-XE-bgp:bgp/cbgp2", data.getPath()))
+ if !data.EnableTrapsBulkstatTransfer.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/bulkstat/transfer")
}
- if !data.EnableTrapsSyslog.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/syslog", data.getPath()))
+ if !data.EnableTrapsMacNotificationChange.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/mac-notification/change")
}
- if !data.EnableTrapsStpxLoopInconsistency.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/stpx", data.getPath()))
+ if !data.EnableTrapsMacNotificationMove.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/mac-notification/move")
}
- if !data.EnableTrapsStpxRootInconsistency.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/stpx", data.getPath()))
+ if !data.EnableTrapsMacNotificationThreshold.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/mac-notification/threshold")
}
- if !data.EnableTrapsStpxInconsistency.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/stpx/inconsistency", data.getPath()))
+ if !data.EnableTrapsVrfmibVrfUp.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/vrfmib/vrf-up")
}
- if !data.EnableTrapsBridgeTopologychange.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/bridge/topologychange", data.getPath()))
+ if !data.EnableTrapsVrfmibVrfDown.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/vrfmib/vrf-down")
}
- if !data.EnableTrapsBridgeNewroot.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/bridge/newroot", data.getPath()))
+ if !data.EnableTrapsVrfmibVnetTrunkUp.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/vrfmib/vnet-trunk-up")
}
- if !data.EnableTrapsPimRpMappingChange.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/pim/rp-mapping-change", data.getPath()))
+ if !data.EnableTrapsVrfmibVnetTrunkDown.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/vrfmib/vnet-trunk-down")
}
- if !data.EnableTrapsPimNeighborChange.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/pim/neighbor-change", data.getPath()))
+ if !data.EnableTrapsMvpn.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/mvpn")
}
- if !data.EnableTrapsPimInvalidPimMessage.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/pim/invalid-pim-message", data.getPath()))
+ if !data.EnableTrapsLisp.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/lisp")
}
- if !data.EnableTrapsOspfConfigErrors.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/Cisco-IOS-XE-ospf:ospf-config/errors/enable", data.getPath()))
+ if !data.EnableTrapsAaaServer.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/aaa_server")
}
- if !data.EnableTrapsOspfConfigStateChange.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/Cisco-IOS-XE-ospf:ospf-config/state-change/enable", data.getPath()))
+ if !data.EnableTrapsVdsl2line.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/vdsl2line")
}
- if !data.EnableTrapsMsdp.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/msdp", data.getPath()))
+ if !data.EnableTrapsAdslline.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/adslline")
}
- if !data.EnableTrapsIpmulticast.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ipmulticast", data.getPath()))
+ if !data.EnableTrapsPki.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/pki")
}
- if !data.EnableTrapsHsrp.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/hsrp", data.getPath()))
+ if !data.EnableTrapsAlarmType.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/alarms/alarm-type")
}
- if !data.EnableTrapsEventManager.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/event-manager", data.getPath()))
+ if !data.EnableTrapsCasa.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/casa")
}
- if !data.EnableTrapsDhcp.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/dhcp", data.getPath()))
+ if !data.EnableTrapsCnpd.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/cnpd")
}
- if !data.EnableTrapsConfigCtid.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/config-ctid", data.getPath()))
+ if !data.EnableTrapsDial.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/dial")
}
- if !data.EnableTrapsConfig.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/config", data.getPath()))
+ if !data.EnableTrapsDlsw.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/dlsw")
}
- if !data.EnableTrapsConfigCopy.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/config-copy", data.getPath()))
+ if !data.EnableTrapsDs1.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ds1")
}
- if !data.EnableTrapsIpsecTooManySas.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ipsec/too-many-sas", data.getPath()))
+ if !data.EnableTrapsDspCardStatus.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/dsp/card-status")
}
- if !data.EnableTrapsIpsecTunnelStop.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ipsec/tunnel/stop", data.getPath()))
+ if !data.EnableTrapsDspOperState.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/dsp/oper-state")
}
- if !data.EnableTrapsIpsecTunnelStart.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ipsec/tunnel/start", data.getPath()))
+ if !data.EnableTrapsEntitySensor.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/entity-sensor")
}
- if !data.EnableTrapsIpsecCryptomapDetach.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ipsec/cryptomap/detach", data.getPath()))
+ if !data.EnableTrapsEntityState.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/entity-state")
}
- if !data.EnableTrapsIpsecCryptomapDelete.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ipsec/cryptomap/delete", data.getPath()))
+ if !data.EnableTrapsEntityQfpMemResThresh.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/entity-qfp/mem-res-thresh")
}
- if !data.EnableTrapsIpsecCryptomapAttach.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ipsec/cryptomap/attach", data.getPath()))
+ if !data.EnableTrapsEntityQfpThroughputNotif.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/entity-qfp/throughput-notif")
}
- if !data.EnableTrapsIpsecCryptomapAdd.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ipsec/cryptomap/add", data.getPath()))
+ if !data.EnableTrapsEtherOam.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ether-oam")
}
- if !data.EnableTrapsIkeTunnelStop.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ike/tunnel/stop", data.getPath()))
+ if !data.EnableTrapsEthernetCfmAlarm.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ethernet/cfm/alarm")
}
- if !data.EnableTrapsIkeTunnelStart.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ike/tunnel/start", data.getPath()))
+ if !data.EnableTrapsEthernetCfmCcConfig.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ethernet/cfm/cc/config")
}
- if !data.EnableTrapsIkePolicyDelete.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ike/policy/delete", data.getPath()))
+ if !data.EnableTrapsEthernetCfmCcCrossConnect.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ethernet/cfm/cc/cross-connect")
}
- if !data.EnableTrapsIkePolicyAdd.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ike/policy/add", data.getPath()))
+ if !data.EnableTrapsEthernetCfmCcLoop.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ethernet/cfm/cc/loop")
}
- if !data.EnableTrapsBfd.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/bfd", data.getPath()))
+ if !data.EnableTrapsEthernetCfmCcMepDown.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ethernet/cfm/cc/mep-down")
}
- if !data.EnableTrapsEntityDiagScheduledTestFail.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/entity-diag/scheduled-test-fail", data.getPath()))
+ if !data.EnableTrapsEthernetCfmCcMepUp.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ethernet/cfm/cc/mep-up")
}
- if !data.EnableTrapsEntityDiagHmThreshReached.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/entity-diag/hm-thresh-reached", data.getPath()))
+ if !data.EnableTrapsEthernetCfmCrosscheckMepMissing.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ethernet/cfm/crosscheck/mep-missing")
}
- if !data.EnableTrapsEntityDiagHmTestRecover.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/entity-diag/hm-test-recover", data.getPath()))
+ if !data.EnableTrapsEthernetCfmCrosscheckMepUnknown.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ethernet/cfm/crosscheck/mep-unknown")
}
- if !data.EnableTrapsEntityDiagBootUpFail.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/entity-diag/boot-up-fail", data.getPath()))
+ if !data.EnableTrapsEthernetCfmCrosscheckServiceUp.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ethernet/cfm/crosscheck/service-up")
}
- if !data.EnableTrapsIpsla.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ipsla", data.getPath()))
+ if !data.EnableTrapsEthernetEvcCreate.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ethernet/evc/create")
}
- if !data.EnableTrapsIsis.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/isis", data.getPath()))
+ if !data.EnableTrapsEthernetEvcDelete.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ethernet/evc/delete")
}
- if !data.EnableTrapsCefInconsistency.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/cef/inconsistency", data.getPath()))
+ if !data.EnableTrapsEthernetEvcStatus.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ethernet/evc/status")
}
- if !data.EnableTrapsCefPeerFibStateChange.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/cef/peer-fib-state-change", data.getPath()))
+ if !data.EnableTrapsFirewallServerstatus.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/firewall/serverstatus")
}
- if !data.EnableTrapsCefPeerStateChange.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/cef/peer-state-change", data.getPath()))
+ if !data.EnableTrapsFrameRelayConfigOnly.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/frame-relay-config/only-frame-relay/frame-relay")
}
- if !data.EnableTrapsCefResourceFailure.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/cef/resource-failure", data.getPath()))
+ if !data.EnableTrapsFrameRelayConfigSubifConfigs.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/frame-relay-config/frame-relay-options/frame-relay/subif-configs/subif")
}
- if !data.EnableTrapsEnvmon.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/envmon", data.getPath()))
+ if !data.EnableTrapsFrameRelaySubifCount.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/frame-relay/subif/count")
}
- if !data.EnableTrapsPwVc.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/pw", data.getPath()))
+ if !data.EnableTrapsFrameRelaySubifInterval.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/frame-relay/subif/interval")
}
- if !data.EnableTrapsEntity.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/entity", data.getPath()))
+ if !data.EnableTrapsFrameRelayConfigBundleMismatch.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/frame-relay-config/frame-relay-options/frame-relay/multilink/bundle-mismatch")
}
- if !data.EnableTrapsPowerEthernetPolice.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/power-ethernet/police", data.getPath()))
+ if !data.EnableTrapsFrameRelayMultilinkBundleMismatch.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/frame-relay/multilink/bundle-mismatch")
}
- if !data.EnableTrapsPowerEthernetGroup.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/power-ethernet/group", data.getPath()))
+ if !data.EnableTrapsIpLocalPool.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ip/local/pool")
}
- if !data.EnableTrapsEnergywise.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/energywise", data.getPath()))
+ if !data.EnableTrapsIsdnCallInformation.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/isdn/call-information")
}
- if !data.EnableTrapsFlashLowspace.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/flash/lowspace", data.getPath()))
+ if !data.EnableTrapsIsdnChanNotAvail.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/isdn/chan-not-avail")
}
- if !data.EnableTrapsFlashRemoval.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/flash/removal", data.getPath()))
+ if !data.EnableTrapsIsdnIetf.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/isdn/ietf")
}
- if !data.EnableTrapsFlashInsertion.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/flash/insertion", data.getPath()))
+ if !data.EnableTrapsIsdnLayer2.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/isdn/layer2")
}
- if !data.EnableTrapsFruCtrl.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/fru-ctrl", data.getPath()))
+ if !data.EnableTrapsL2tunSession.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/l2tun/session")
}
- if !data.EnableTrapsUdldStatusChange.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/udld/status-change", data.getPath()))
+ if !data.EnableTrapsL2tunTunnel.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/l2tun/tunnel")
}
- if !data.EnableTrapsUdldLinkFailRpt.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/udld/link-fail-rpt", data.getPath()))
+ if !data.EnableTrapsL2tunPseudowireStatus.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/l2tun/pseudowire/status")
}
- if !data.EnableTrapsStackwise.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/stackwise", data.getPath()))
+ if !data.EnableTrapsPimstdmibNeighborLoss.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/pimstdmib/neighbor-loss")
}
- if !data.EnableTrapsMemoryBufferpeak.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/memory/bufferpeak", data.getPath()))
+ if !data.EnableTrapsPimstdmibInvalidRegister.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/pimstdmib/invalid-register")
}
- if !data.EnableTrapsCpuThreshold.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/cpu/threshold", data.getPath()))
+ if !data.EnableTrapsPimstdmibInvalidJoinPrune.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/pimstdmib/invalid-join-prune")
}
- if !data.EnableTrapsSmartLicense.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/smart-licenseing/smart-license", data.getPath()))
+ if !data.EnableTrapsPimstdmibRpMappingChange.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/pimstdmib/rp-mapping-change")
}
- if !data.EnableTrapsLicense.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/license", data.getPath()))
+ if !data.EnableTrapsPimstdmibInterfaceElection.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/pimstdmib/interface-election")
}
- if !data.EnableTrapsPortSecurity.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/port-security", data.getPath()))
+ if !data.EnableTrapsPfr.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/pfr")
}
- if !data.EnableTrapsVlandelete.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/vlandelete", data.getPath()))
+ if !data.EnableTrapsPppoe.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/pppoe")
}
- if !data.EnableTrapsVlancreate.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/vlancreate", data.getPath()))
+ if !data.EnableTrapsResourcePolicy.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/resource-policy")
}
- if !data.EnableTrapsVtp.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/vtp", data.getPath()))
+ if !data.EnableTrapsRsvp.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/rsvp")
}
- if !data.EnableTrapsRep.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/rep", data.getPath()))
+ if !data.EnableTrapsVrrp.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/vrrp")
}
- if !data.EnableTrapsAuthFrameworkSecViolation.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/auth-framework/sec-violation", data.getPath()))
+ if !data.EnableTrapsSonet.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/sonet")
}
- if !data.EnableTrapsEigrp.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/eigrp", data.getPath()))
+ if !data.EnableTrapsSrp.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/srp")
}
- if !data.EnableTrapsOspfLsaEnable.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/Cisco-IOS-XE-ospf:ospf-config/cisco-specific/lsa/enable", data.getPath()))
+ if !data.EnableTrapsVoice.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/voice")
}
- if !data.EnableTrapsOspfRetransmitEnable.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/Cisco-IOS-XE-ospf:ospf-config/cisco-specific/retransmit/enable", data.getPath()))
+ if !data.EnableTrapsBgp.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/bgp")
}
- if !data.EnableTrapsOspfErrorsEnable.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/Cisco-IOS-XE-ospf:ospf-config/cisco-specific/errors/enable", data.getPath()))
+ if !data.EnableTrapsCbgp2.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/bgp-traps/cbgp2")
}
- if !data.EnableTrapsOspfShamlinkNeighbor.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/Cisco-IOS-XE-ospf:ospf-config/cisco-specific/state-change/shamlink/neighbor", data.getPath()))
+ if !data.EnableTrapsOspfv3Errors.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ospfv3/errors")
}
- if !data.EnableTrapsOspfShamlinkInterface.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/Cisco-IOS-XE-ospf:ospf-config/cisco-specific/state-change/shamlink/interface", data.getPath()))
+ if !data.EnableTrapsOspfv3StateChange.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:enable/enable-choice/traps/ospfv3/state-change")
}
- if !data.EnableTrapsOspfNssaTransChange.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/Cisco-IOS-XE-ospf:ospf-config/cisco-specific/state-change/nssa-trans-change", data.getPath()))
+ if !data.SourceInterfaceInformsGigabitEthernet.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:source-interface/informs/GigabitEthernet")
}
- if !data.EnableTrapsOspfConfigLsa.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/Cisco-IOS-XE-ospf:ospf-config/lsa/enable", data.getPath()))
+ if !data.SourceInterfaceInformsTenGigabitEthernet.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:source-interface/informs/TenGigabitEthernet")
}
- if !data.EnableTrapsOspfConfigRetransmit.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/Cisco-IOS-XE-ospf:ospf-config/retransmit/enable", data.getPath()))
+ if !data.SourceInterfaceInformsFortyGigabitEthernet.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:source-interface/informs/FortyGigabitEthernet")
}
- if !data.EnableTrapsOspfv3ConfigErrors.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/Cisco-IOS-XE-ospfv3:ospfv3-config/errors/enable", data.getPath()))
+ if !data.SourceInterfaceInformsHundredGigE.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:source-interface/informs/HundredGigE")
}
- if !data.EnableTrapsOspfv3ConfigStateChange.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/Cisco-IOS-XE-ospfv3:ospfv3-config/state-change/enable", data.getPath()))
+ if !data.SourceInterfaceInformsLoopback.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:source-interface/informs/Loopback")
}
- if !data.EnableTrapsTty.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/tty", data.getPath()))
+ if !data.SourceInterfaceInformsPortChannel.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:source-interface/informs/Port-channel")
}
- if !data.EnableTrapsCallHomeServerFail.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/call-home/server-fail", data.getPath()))
+ if !data.SourceInterfaceInformsPortChannelSubinterface.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:source-interface/informs/Port-channel-subinterface/Port-channel")
}
- if !data.EnableTrapsCallHomeMessageSendFail.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/call-home/message-send-fail", data.getPath()))
+ if !data.SourceInterfaceInformsVlan.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:source-interface/informs/Vlan")
}
- if !data.EnableTrapsEntityPerfThroughputNotif.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/entity-perf/throughput-notif", data.getPath()))
+ if !data.SourceInterfaceTrapsGigabitEthernet.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:source-interface/traps/GigabitEthernet")
}
- if !data.EnableTrapsFlowmon.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/flowmon", data.getPath()))
+ if !data.SourceInterfaceTrapsTenGigabitEthernet.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:source-interface/traps/TenGigabitEthernet")
}
- if !data.SystemShutdown.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:system-shutdown", data.getPath()))
+ if !data.SourceInterfaceTrapsFortyGigabitEthernet.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:source-interface/traps/FortyGigabitEthernet")
}
- for i := range data.VrfHosts {
- keyValues := [...]string{data.VrfHosts[i].IpAddress.ValueString(), data.VrfHosts[i].Vrf.ValueString()}
-
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:host-config/ip-vrf-community=%v", data.getPath(), strings.Join(keyValues[:], ",")))
+ if !data.SourceInterfaceTrapsHundredGigE.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:source-interface/traps/HundredGigE")
}
- for i := range data.Hosts {
- keyValues := [...]string{data.Hosts[i].IpAddress.ValueString()}
-
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:host-config/ip-community=%v", data.getPath(), strings.Join(keyValues[:], ",")))
+ if !data.SourceInterfaceTrapsLoopback.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:source-interface/traps/Loopback")
}
- if !data.EnableTrapsSnmpWarmstart.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/snmp/warmstart", data.getPath()))
+ if !data.SourceInterfaceTrapsPortChannel.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:source-interface/traps/Port-channel")
}
- if !data.EnableTrapsSnmpLinkup.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/snmp/linkup", data.getPath()))
+ if !data.SourceInterfaceTrapsPortChannelSubinterface.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:source-interface/traps/Port-channel-subinterface/Port-channel")
}
- if !data.EnableTrapsSnmpLinkdown.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/snmp/linkdown", data.getPath()))
+ if !data.SourceInterfaceTrapsVlan.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:source-interface/traps/Vlan")
}
- if !data.EnableTrapsSnmpColdstart.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/snmp/coldstart", data.getPath()))
+ if !data.TrapSourceGigabitEthernet.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:trap-source/GigabitEthernet")
}
- if !data.EnableTrapsSnmpAuthentication.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps/snmp/authentication", data.getPath()))
+ if !data.TrapSourceTenGigabitEthernet.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:trap-source/TenGigabitEthernet")
}
- if !data.EnableTraps.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/traps", data.getPath()))
+ if !data.TrapSourceFortyGigabitEthernet.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:trap-source/FortyGigabitEthernet")
}
- if !data.EnableInforms.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/informs", data.getPath()))
+ if !data.TrapSourceHundredGigE.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:trap-source/HundredGigE")
}
- if !data.EnableLoggingSetop.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/logging/setop", data.getPath()))
+ if !data.TrapSourceLoopback.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:trap-source/Loopback")
}
- if !data.EnableLoggingGetop.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:enable/enable-choice/logging/getop", data.getPath()))
+ if !data.TrapSourcePortChannel.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:trap-source/Port-channel")
}
- if !data.QueueLength.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:queue-length", data.getPath()))
+ if !data.TrapSourcePortChannelSubinterface.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:trap-source/Port-channel-subinterface/Port-channel")
}
- if !data.Packetsize.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:packetsize", data.getPath()))
+ if !data.TrapSourceVlan.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-snmp:trap-source/Vlan")
}
- if !data.Location.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:location", data.getPath()))
+ for i := range data.SnmpCommunities {
+ keys := [...]string{"name"}
+ keyValues := [...]string{data.SnmpCommunities[i].Name.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/Cisco-IOS-XE-snmp:community-config%v", predicates))
}
- if !data.IfindexPersist.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:ifindex/persist", data.getPath()))
+ for i := range data.Contexts {
+ keys := [...]string{"name"}
+ keyValues := [...]string{data.Contexts[i].Name.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/Cisco-IOS-XE-snmp:context%v", predicates))
}
- if !data.Contact.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:contact", data.getPath()))
+ for i := range data.Views {
+ keys := [...]string{"name", "mib"}
+ keyValues := [...]string{data.Views[i].Name.ValueString(), data.Views[i].Mib.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/Cisco-IOS-XE-snmp:view%v", predicates))
}
- if !data.ChassisId.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-snmp:chassis-id", data.getPath()))
+ for i := range data.Groups {
+ keys := [...]string{"id"}
+ keyValues := [...]string{data.Groups[i].Name.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/Cisco-IOS-XE-snmp:group%v", predicates))
}
+ for i := range data.Users {
+ keys := [...]string{"username", "grpname"}
+ keyValues := [...]string{data.Users[i].Username.ValueString(), data.Users[i].Grpname.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
- return deletePaths
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/Cisco-IOS-XE-snmp:user/names%v", predicates))
+ }
+
+ return b.Res()
}
-// End of section. //template:end getDeletePaths
+// End of section. //template:end addDeletePathsXML
diff --git a/internal/provider/model_iosxe_spanning_tree.go b/internal/provider/model_iosxe_spanning_tree.go
index 913b0cee..95e54146 100644
--- a/internal/provider/model_iosxe_spanning_tree.go
+++ b/internal/provider/model_iosxe_spanning_tree.go
@@ -30,6 +30,9 @@ import (
"github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/types"
+ "github.com/hashicorp/terraform-plugin-log/tflog"
+ "github.com/netascode/go-netconf"
+ "github.com/netascode/xmldot"
"github.com/tidwall/gjson"
"github.com/tidwall/sjson"
)
@@ -94,6 +97,17 @@ func (data SpanningTree) getPathShort() string {
return matches[1]
}
+// getXPath returns the XPath for NETCONF operations
+func (data SpanningTree) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/spanning-tree"
+ return path
+}
+
+func (data SpanningTreeData) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/spanning-tree"
+ return path
+}
+
// End of section. //template:end getPath
// Section below is generated&owned by "gen/generator.go". //template:begin toBody
@@ -157,6 +171,85 @@ func (data SpanningTree) toBody(ctx context.Context) string {
// End of section. //template:end toBody
+// Section below is generated&owned by "gen/generator.go". //template:begin toBodyXML
+
+func (data SpanningTree) toBodyXML(ctx context.Context) string {
+ body := netconf.Body{}
+ if !data.Mode.IsNull() && !data.Mode.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-spanning-tree:mode", data.Mode.ValueString())
+ }
+ if !data.Logging.IsNull() && !data.Logging.IsUnknown() {
+ if data.Logging.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-spanning-tree:logging", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-spanning-tree:logging")
+ }
+ }
+ if !data.LoopguardDefault.IsNull() && !data.LoopguardDefault.IsUnknown() {
+ if data.LoopguardDefault.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-spanning-tree:loopguard/default", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-spanning-tree:loopguard/default")
+ }
+ }
+ if !data.PortfastDefault.IsNull() && !data.PortfastDefault.IsUnknown() {
+ if data.PortfastDefault.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-spanning-tree:portfast/default", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-spanning-tree:portfast/default")
+ }
+ }
+ if !data.PortfastBpduguardDefault.IsNull() && !data.PortfastBpduguardDefault.IsUnknown() {
+ if data.PortfastBpduguardDefault.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-spanning-tree:portfast/bpduguard/default", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-spanning-tree:portfast/bpduguard/default")
+ }
+ }
+ if !data.ExtendSystemId.IsNull() && !data.ExtendSystemId.IsUnknown() {
+ if data.ExtendSystemId.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-spanning-tree:extend/system-id", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-spanning-tree:extend/system-id")
+ }
+ }
+ if len(data.MstInstances) > 0 {
+ for _, item := range data.MstInstances {
+ cBody := netconf.Body{}
+ if !item.Id.IsNull() && !item.Id.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "id", strconv.FormatInt(item.Id.ValueInt64(), 10))
+ }
+ if !item.VlanIds.IsNull() && !item.VlanIds.IsUnknown() {
+ var values []int
+ item.VlanIds.ElementsAs(ctx, &values, false)
+ for _, v := range values {
+ cBody = helpers.AppendFromXPath(cBody, "vlan-ids", v)
+ }
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-spanning-tree:mst/configuration/instance", cBody.Res())
+ }
+ }
+ if len(data.Vlans) > 0 {
+ for _, item := range data.Vlans {
+ cBody := netconf.Body{}
+ if !item.Id.IsNull() && !item.Id.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "id", item.Id.ValueString())
+ }
+ if !item.Priority.IsNull() && !item.Priority.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "priority", strconv.FormatInt(item.Priority.ValueInt64(), 10))
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-spanning-tree:vlan", cBody.Res())
+ }
+ }
+ bodyString, err := body.String()
+ if err != nil {
+ tflog.Error(ctx, fmt.Sprintf("Error converting body to string: %s", err))
+ }
+ return bodyString
+}
+
+// End of section. //template:end toBodyXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBody
func (data *SpanningTree) updateFromBody(ctx context.Context, res gjson.Result) {
@@ -286,6 +379,131 @@ func (data *SpanningTree) updateFromBody(ctx context.Context, res gjson.Result)
// End of section. //template:end updateFromBody
+// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBodyXML
+
+func (data *SpanningTree) updateFromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-spanning-tree:mode"); value.Exists() && !data.Mode.IsNull() {
+ data.Mode = types.StringValue(value.String())
+ } else {
+ data.Mode = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-spanning-tree:logging"); !data.Logging.IsNull() {
+ if value.Exists() {
+ data.Logging = types.BoolValue(true)
+ } else {
+ data.Logging = types.BoolValue(false)
+ }
+ } else {
+ data.Logging = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-spanning-tree:loopguard/default"); !data.LoopguardDefault.IsNull() {
+ if value.Exists() {
+ data.LoopguardDefault = types.BoolValue(true)
+ } else {
+ data.LoopguardDefault = types.BoolValue(false)
+ }
+ } else {
+ data.LoopguardDefault = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-spanning-tree:portfast/default"); !data.PortfastDefault.IsNull() {
+ if value.Exists() {
+ data.PortfastDefault = types.BoolValue(true)
+ } else {
+ data.PortfastDefault = types.BoolValue(false)
+ }
+ } else {
+ data.PortfastDefault = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-spanning-tree:portfast/bpduguard/default"); !data.PortfastBpduguardDefault.IsNull() {
+ if value.Exists() {
+ data.PortfastBpduguardDefault = types.BoolValue(true)
+ } else {
+ data.PortfastBpduguardDefault = types.BoolValue(false)
+ }
+ } else {
+ data.PortfastBpduguardDefault = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-spanning-tree:extend/system-id"); !data.ExtendSystemId.IsNull() {
+ if value.Exists() {
+ data.ExtendSystemId = types.BoolValue(true)
+ } else {
+ data.ExtendSystemId = types.BoolValue(false)
+ }
+ } else {
+ data.ExtendSystemId = types.BoolNull()
+ }
+ for i := range data.MstInstances {
+ keys := [...]string{"id"}
+ keyValues := [...]string{strconv.FormatInt(data.MstInstances[i].Id.ValueInt64(), 10)}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-spanning-tree:mst/configuration/instance").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, "id"); value.Exists() && !data.MstInstances[i].Id.IsNull() {
+ data.MstInstances[i].Id = types.Int64Value(value.Int())
+ } else {
+ data.MstInstances[i].Id = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(r, "vlan-ids"); value.Exists() && !data.MstInstances[i].VlanIds.IsNull() {
+ data.MstInstances[i].VlanIds = helpers.GetInt64ListXML(value.Array())
+ } else {
+ data.MstInstances[i].VlanIds = types.ListNull(types.Int64Type)
+ }
+ }
+ for i := range data.Vlans {
+ keys := [...]string{"id"}
+ keyValues := [...]string{data.Vlans[i].Id.ValueString()}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-spanning-tree:vlan").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, "id"); value.Exists() && !data.Vlans[i].Id.IsNull() {
+ data.Vlans[i].Id = types.StringValue(value.String())
+ } else {
+ data.Vlans[i].Id = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "priority"); value.Exists() && !data.Vlans[i].Priority.IsNull() {
+ data.Vlans[i].Priority = types.Int64Value(value.Int())
+ } else {
+ data.Vlans[i].Priority = types.Int64Null()
+ }
+ }
+}
+
+// End of section. //template:end updateFromBodyXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin fromBody
func (data *SpanningTree) fromBody(ctx context.Context, res gjson.Result) {
@@ -424,6 +642,136 @@ func (data *SpanningTreeData) fromBody(ctx context.Context, res gjson.Result) {
// End of section. //template:end fromBodyData
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyXML
+
+func (data *SpanningTree) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-spanning-tree:mode"); value.Exists() {
+ data.Mode = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-spanning-tree:logging"); value.Exists() {
+ data.Logging = types.BoolValue(true)
+ } else {
+ data.Logging = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-spanning-tree:loopguard/default"); value.Exists() {
+ data.LoopguardDefault = types.BoolValue(true)
+ } else {
+ data.LoopguardDefault = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-spanning-tree:portfast/default"); value.Exists() {
+ data.PortfastDefault = types.BoolValue(true)
+ } else {
+ data.PortfastDefault = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-spanning-tree:portfast/bpduguard/default"); value.Exists() {
+ data.PortfastBpduguardDefault = types.BoolValue(true)
+ } else {
+ data.PortfastBpduguardDefault = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-spanning-tree:extend/system-id"); value.Exists() {
+ data.ExtendSystemId = types.BoolValue(true)
+ } else {
+ data.ExtendSystemId = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-spanning-tree:mst/configuration/instance"); value.Exists() {
+ data.MstInstances = make([]SpanningTreeMstInstances, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := SpanningTreeMstInstances{}
+ if cValue := helpers.GetFromXPath(v, "id"); cValue.Exists() {
+ item.Id = types.Int64Value(cValue.Int())
+ }
+ if cValue := helpers.GetFromXPath(v, "vlan-ids"); cValue.Exists() {
+ item.VlanIds = helpers.GetInt64ListXML(cValue.Array())
+ } else {
+ item.VlanIds = types.ListNull(types.Int64Type)
+ }
+ data.MstInstances = append(data.MstInstances, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-spanning-tree:vlan"); value.Exists() {
+ data.Vlans = make([]SpanningTreeVlans, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := SpanningTreeVlans{}
+ if cValue := helpers.GetFromXPath(v, "id"); cValue.Exists() {
+ item.Id = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "priority"); cValue.Exists() {
+ item.Priority = types.Int64Value(cValue.Int())
+ }
+ data.Vlans = append(data.Vlans, item)
+ return true
+ })
+ }
+}
+
+// End of section. //template:end fromBodyXML
+
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyDataXML
+
+func (data *SpanningTreeData) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-spanning-tree:mode"); value.Exists() {
+ data.Mode = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-spanning-tree:logging"); value.Exists() {
+ data.Logging = types.BoolValue(true)
+ } else {
+ data.Logging = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-spanning-tree:loopguard/default"); value.Exists() {
+ data.LoopguardDefault = types.BoolValue(true)
+ } else {
+ data.LoopguardDefault = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-spanning-tree:portfast/default"); value.Exists() {
+ data.PortfastDefault = types.BoolValue(true)
+ } else {
+ data.PortfastDefault = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-spanning-tree:portfast/bpduguard/default"); value.Exists() {
+ data.PortfastBpduguardDefault = types.BoolValue(true)
+ } else {
+ data.PortfastBpduguardDefault = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-spanning-tree:extend/system-id"); value.Exists() {
+ data.ExtendSystemId = types.BoolValue(true)
+ } else {
+ data.ExtendSystemId = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-spanning-tree:mst/configuration/instance"); value.Exists() {
+ data.MstInstances = make([]SpanningTreeMstInstances, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := SpanningTreeMstInstances{}
+ if cValue := helpers.GetFromXPath(v, "id"); cValue.Exists() {
+ item.Id = types.Int64Value(cValue.Int())
+ }
+ if cValue := helpers.GetFromXPath(v, "vlan-ids"); cValue.Exists() {
+ item.VlanIds = helpers.GetInt64ListXML(cValue.Array())
+ } else {
+ item.VlanIds = types.ListNull(types.Int64Type)
+ }
+ data.MstInstances = append(data.MstInstances, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-spanning-tree:vlan"); value.Exists() {
+ data.Vlans = make([]SpanningTreeVlans, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := SpanningTreeVlans{}
+ if cValue := helpers.GetFromXPath(v, "id"); cValue.Exists() {
+ item.Id = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "priority"); cValue.Exists() {
+ item.Priority = types.Int64Value(cValue.Int())
+ }
+ data.Vlans = append(data.Vlans, item)
+ return true
+ })
+ }
+}
+
+// End of section. //template:end fromBodyDataXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin getDeletedItems
func (data *SpanningTree) getDeletedItems(ctx context.Context, state SpanningTree) []string {
@@ -523,6 +871,115 @@ func (data *SpanningTree) getDeletedItems(ctx context.Context, state SpanningTre
// End of section. //template:end getDeletedItems
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletedItemsXML
+
+func (data *SpanningTree) addDeletedItemsXML(ctx context.Context, state SpanningTree, body string) string {
+ b := netconf.NewBody(body)
+ if !state.Mode.IsNull() && data.Mode.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-spanning-tree:mode")
+ }
+ if !state.Logging.IsNull() && data.Logging.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-spanning-tree:logging")
+ }
+ if !state.LoopguardDefault.IsNull() && data.LoopguardDefault.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-spanning-tree:loopguard/default")
+ }
+ if !state.PortfastDefault.IsNull() && data.PortfastDefault.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-spanning-tree:portfast/default")
+ }
+ if !state.PortfastBpduguardDefault.IsNull() && data.PortfastBpduguardDefault.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-spanning-tree:portfast/bpduguard/default")
+ }
+ for i := range state.MstInstances {
+ stateKeys := [...]string{"id"}
+ stateKeyValues := [...]string{strconv.FormatInt(state.MstInstances[i].Id.ValueInt64(), 10)}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.MstInstances[i].Id.ValueInt64()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.MstInstances {
+ found = true
+ if state.MstInstances[i].Id.ValueInt64() != data.MstInstances[j].Id.ValueInt64() {
+ found = false
+ }
+ if found {
+ if !state.MstInstances[i].VlanIds.IsNull() {
+ if data.MstInstances[j].VlanIds.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-spanning-tree:mst/configuration/instance%v/vlan-ids", predicates))
+ } else {
+ var dataValues, stateValues []int
+ data.MstInstances[i].VlanIds.ElementsAs(ctx, &dataValues, false)
+ state.MstInstances[j].VlanIds.ElementsAs(ctx, &stateValues, false)
+ for _, v := range stateValues {
+ found := false
+ for _, vv := range dataValues {
+ if v == vv {
+ found = true
+ break
+ }
+ }
+ if !found {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-spanning-tree:mst/configuration/instance%v/vlan-ids[.=%v]", predicates, v))
+ }
+ }
+ }
+ }
+ break
+ }
+ }
+ if !found {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-spanning-tree:mst/configuration/instance%v", predicates))
+ }
+ }
+ for i := range state.Vlans {
+ stateKeys := [...]string{"id"}
+ stateKeyValues := [...]string{state.Vlans[i].Id.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.Vlans[i].Id.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.Vlans {
+ found = true
+ if state.Vlans[i].Id.ValueString() != data.Vlans[j].Id.ValueString() {
+ found = false
+ }
+ if found {
+ if !state.Vlans[i].Priority.IsNull() && data.Vlans[j].Priority.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-spanning-tree:vlan%v/priority", predicates))
+ }
+ break
+ }
+ }
+ if !found {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-spanning-tree:vlan%v", predicates))
+ }
+ }
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletedItemsXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin getEmptyLeafsDelete
func (data *SpanningTree) getEmptyLeafsDelete(ctx context.Context) []string {
@@ -583,3 +1040,48 @@ func (data *SpanningTree) getDeletePaths(ctx context.Context) []string {
}
// End of section. //template:end getDeletePaths
+
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletePathsXML
+
+func (data *SpanningTree) addDeletePathsXML(ctx context.Context, body string) string {
+ b := netconf.NewBody(body)
+ if !data.Mode.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-spanning-tree:mode")
+ }
+ if !data.Logging.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-spanning-tree:logging")
+ }
+ if !data.LoopguardDefault.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-spanning-tree:loopguard/default")
+ }
+ if !data.PortfastDefault.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-spanning-tree:portfast/default")
+ }
+ if !data.PortfastBpduguardDefault.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-spanning-tree:portfast/bpduguard/default")
+ }
+ for i := range data.MstInstances {
+ keys := [...]string{"id"}
+ keyValues := [...]string{strconv.FormatInt(data.MstInstances[i].Id.ValueInt64(), 10)}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/Cisco-IOS-XE-spanning-tree:mst/configuration/instance%v", predicates))
+ }
+ for i := range data.Vlans {
+ keys := [...]string{"id"}
+ keyValues := [...]string{data.Vlans[i].Id.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/Cisco-IOS-XE-spanning-tree:vlan%v", predicates))
+ }
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletePathsXML
diff --git a/internal/provider/model_iosxe_static_route.go b/internal/provider/model_iosxe_static_route.go
index 001c494e..1ae4ec39 100644
--- a/internal/provider/model_iosxe_static_route.go
+++ b/internal/provider/model_iosxe_static_route.go
@@ -31,6 +31,9 @@ import (
"github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/types"
+ "github.com/hashicorp/terraform-plugin-log/tflog"
+ "github.com/netascode/go-netconf"
+ "github.com/netascode/xmldot"
"github.com/tidwall/gjson"
"github.com/tidwall/sjson"
)
@@ -95,6 +98,19 @@ func (data StaticRoute) getPathShort() string {
return matches[1]
}
+// getXPath returns the XPath for NETCONF operations
+func (data StaticRoute) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/ip/route/ip-route-interface-forwarding-list[prefix=%s][mask=%s]"
+ path = fmt.Sprintf(path, fmt.Sprintf("%v", data.Prefix.ValueString()), fmt.Sprintf("%v", data.Mask.ValueString()))
+ return path
+}
+
+func (data StaticRouteData) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/ip/route/ip-route-interface-forwarding-list[prefix=%s][mask=%s]"
+ path = fmt.Sprintf(path, fmt.Sprintf("%v", data.Prefix.ValueString()), fmt.Sprintf("%v", data.Mask.ValueString()))
+ return path
+}
+
// End of section. //template:end getPath
// Section below is generated&owned by "gen/generator.go". //template:begin toBody
@@ -164,6 +180,85 @@ func (data StaticRoute) toBody(ctx context.Context) string {
// End of section. //template:end toBody
+// Section below is generated&owned by "gen/generator.go". //template:begin toBodyXML
+
+func (data StaticRoute) toBodyXML(ctx context.Context) string {
+ body := netconf.Body{}
+ if !data.Prefix.IsNull() && !data.Prefix.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/prefix", data.Prefix.ValueString())
+ }
+ if !data.Mask.IsNull() && !data.Mask.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/mask", data.Mask.ValueString())
+ }
+ if len(data.NextHops) > 0 {
+ for _, item := range data.NextHops {
+ cBody := netconf.Body{}
+ if !item.NextHop.IsNull() && !item.NextHop.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "fwd", item.NextHop.ValueString())
+ }
+ if !item.Distance.IsNull() && !item.Distance.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "metric", strconv.FormatInt(item.Distance.ValueInt64(), 10))
+ }
+ if !item.Global.IsNull() && !item.Global.IsUnknown() {
+ if item.Global.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "global", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "global")
+ }
+ }
+ if !item.Name.IsNull() && !item.Name.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "name", item.Name.ValueString())
+ }
+ if !item.Permanent.IsNull() && !item.Permanent.IsUnknown() {
+ if item.Permanent.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "permanent", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "permanent")
+ }
+ }
+ if !item.Tag.IsNull() && !item.Tag.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "tag", strconv.FormatInt(item.Tag.ValueInt64(), 10))
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/fwd-list", cBody.Res())
+ }
+ }
+ if len(data.NextHopsWithTrack) > 0 {
+ for _, item := range data.NextHopsWithTrack {
+ cBody := netconf.Body{}
+ if !item.NextHop.IsNull() && !item.NextHop.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "fwd", item.NextHop.ValueString())
+ }
+ if !item.Name.IsNull() && !item.Name.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "name", item.Name.ValueString())
+ }
+ if !item.TrackIdName.IsNull() && !item.TrackIdName.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "track-id-name/id", strconv.FormatInt(item.TrackIdName.ValueInt64(), 10))
+ }
+ if !item.Distance.IsNull() && !item.Distance.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "metric", strconv.FormatInt(item.Distance.ValueInt64(), 10))
+ }
+ if !item.Tag.IsNull() && !item.Tag.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "tag", strconv.FormatInt(item.Tag.ValueInt64(), 10))
+ }
+ if !item.Permanent.IsNull() && !item.Permanent.IsUnknown() {
+ if item.Permanent.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "permanent", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "permanent")
+ }
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/fwd-list-with-track", cBody.Res())
+ }
+ }
+ bodyString, err := body.String()
+ if err != nil {
+ tflog.Error(ctx, fmt.Sprintf("Error converting body to string: %s", err))
+ }
+ return bodyString
+}
+
+// End of section. //template:end toBodyXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBody
func (data *StaticRoute) updateFromBody(ctx context.Context, res gjson.Result) {
@@ -305,6 +400,143 @@ func (data *StaticRoute) updateFromBody(ctx context.Context, res gjson.Result) {
// End of section. //template:end updateFromBody
+// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBodyXML
+
+func (data *StaticRoute) updateFromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/prefix"); value.Exists() && !data.Prefix.IsNull() {
+ data.Prefix = types.StringValue(value.String())
+ } else {
+ data.Prefix = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/mask"); value.Exists() && !data.Mask.IsNull() {
+ data.Mask = types.StringValue(value.String())
+ } else {
+ data.Mask = types.StringNull()
+ }
+ for i := range data.NextHops {
+ keys := [...]string{"fwd"}
+ keyValues := [...]string{data.NextHops[i].NextHop.ValueString()}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/fwd-list").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, "fwd"); value.Exists() && !data.NextHops[i].NextHop.IsNull() {
+ data.NextHops[i].NextHop = types.StringValue(value.String())
+ } else {
+ data.NextHops[i].NextHop = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "metric"); value.Exists() && !data.NextHops[i].Distance.IsNull() {
+ data.NextHops[i].Distance = types.Int64Value(value.Int())
+ } else {
+ data.NextHops[i].Distance = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(r, "global"); !data.NextHops[i].Global.IsNull() {
+ if value.Exists() {
+ data.NextHops[i].Global = types.BoolValue(true)
+ } else {
+ data.NextHops[i].Global = types.BoolValue(false)
+ }
+ } else {
+ data.NextHops[i].Global = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "name"); value.Exists() && !data.NextHops[i].Name.IsNull() {
+ data.NextHops[i].Name = types.StringValue(value.String())
+ } else {
+ data.NextHops[i].Name = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "permanent"); !data.NextHops[i].Permanent.IsNull() {
+ if value.Exists() {
+ data.NextHops[i].Permanent = types.BoolValue(true)
+ } else {
+ data.NextHops[i].Permanent = types.BoolValue(false)
+ }
+ } else {
+ data.NextHops[i].Permanent = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "tag"); value.Exists() && !data.NextHops[i].Tag.IsNull() {
+ data.NextHops[i].Tag = types.Int64Value(value.Int())
+ } else {
+ data.NextHops[i].Tag = types.Int64Null()
+ }
+ }
+ for i := range data.NextHopsWithTrack {
+ keys := [...]string{"fwd"}
+ keyValues := [...]string{data.NextHopsWithTrack[i].NextHop.ValueString()}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/fwd-list-with-track").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, "fwd"); value.Exists() && !data.NextHopsWithTrack[i].NextHop.IsNull() {
+ data.NextHopsWithTrack[i].NextHop = types.StringValue(value.String())
+ } else {
+ data.NextHopsWithTrack[i].NextHop = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "name"); value.Exists() && !data.NextHopsWithTrack[i].Name.IsNull() {
+ data.NextHopsWithTrack[i].Name = types.StringValue(value.String())
+ } else {
+ data.NextHopsWithTrack[i].Name = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "track-id-name/id"); value.Exists() && !data.NextHopsWithTrack[i].TrackIdName.IsNull() {
+ data.NextHopsWithTrack[i].TrackIdName = types.Int64Value(value.Int())
+ } else {
+ data.NextHopsWithTrack[i].TrackIdName = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(r, "metric"); value.Exists() && !data.NextHopsWithTrack[i].Distance.IsNull() {
+ data.NextHopsWithTrack[i].Distance = types.Int64Value(value.Int())
+ } else {
+ data.NextHopsWithTrack[i].Distance = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(r, "tag"); value.Exists() && !data.NextHopsWithTrack[i].Tag.IsNull() {
+ data.NextHopsWithTrack[i].Tag = types.Int64Value(value.Int())
+ } else {
+ data.NextHopsWithTrack[i].Tag = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(r, "permanent"); !data.NextHopsWithTrack[i].Permanent.IsNull() {
+ if value.Exists() {
+ data.NextHopsWithTrack[i].Permanent = types.BoolValue(true)
+ } else {
+ data.NextHopsWithTrack[i].Permanent = types.BoolValue(false)
+ }
+ } else {
+ data.NextHopsWithTrack[i].Permanent = types.BoolNull()
+ }
+ }
+}
+
+// End of section. //template:end updateFromBodyXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin fromBody
func (data *StaticRoute) fromBody(ctx context.Context, res gjson.Result) {
@@ -443,6 +675,136 @@ func (data *StaticRouteData) fromBody(ctx context.Context, res gjson.Result) {
// End of section. //template:end fromBodyData
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyXML
+
+func (data *StaticRoute) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/fwd-list"); value.Exists() {
+ data.NextHops = make([]StaticRouteNextHops, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := StaticRouteNextHops{}
+ if cValue := helpers.GetFromXPath(v, "fwd"); cValue.Exists() {
+ item.NextHop = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "metric"); cValue.Exists() {
+ item.Distance = types.Int64Value(cValue.Int())
+ }
+ if cValue := helpers.GetFromXPath(v, "global"); cValue.Exists() {
+ item.Global = types.BoolValue(true)
+ } else {
+ item.Global = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "name"); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "permanent"); cValue.Exists() {
+ item.Permanent = types.BoolValue(true)
+ } else {
+ item.Permanent = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "tag"); cValue.Exists() {
+ item.Tag = types.Int64Value(cValue.Int())
+ }
+ data.NextHops = append(data.NextHops, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/fwd-list-with-track"); value.Exists() {
+ data.NextHopsWithTrack = make([]StaticRouteNextHopsWithTrack, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := StaticRouteNextHopsWithTrack{}
+ if cValue := helpers.GetFromXPath(v, "fwd"); cValue.Exists() {
+ item.NextHop = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "name"); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "track-id-name/id"); cValue.Exists() {
+ item.TrackIdName = types.Int64Value(cValue.Int())
+ }
+ if cValue := helpers.GetFromXPath(v, "metric"); cValue.Exists() {
+ item.Distance = types.Int64Value(cValue.Int())
+ }
+ if cValue := helpers.GetFromXPath(v, "tag"); cValue.Exists() {
+ item.Tag = types.Int64Value(cValue.Int())
+ }
+ if cValue := helpers.GetFromXPath(v, "permanent"); cValue.Exists() {
+ item.Permanent = types.BoolValue(true)
+ } else {
+ item.Permanent = types.BoolValue(false)
+ }
+ data.NextHopsWithTrack = append(data.NextHopsWithTrack, item)
+ return true
+ })
+ }
+}
+
+// End of section. //template:end fromBodyXML
+
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyDataXML
+
+func (data *StaticRouteData) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/fwd-list"); value.Exists() {
+ data.NextHops = make([]StaticRouteNextHops, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := StaticRouteNextHops{}
+ if cValue := helpers.GetFromXPath(v, "fwd"); cValue.Exists() {
+ item.NextHop = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "metric"); cValue.Exists() {
+ item.Distance = types.Int64Value(cValue.Int())
+ }
+ if cValue := helpers.GetFromXPath(v, "global"); cValue.Exists() {
+ item.Global = types.BoolValue(true)
+ } else {
+ item.Global = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "name"); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "permanent"); cValue.Exists() {
+ item.Permanent = types.BoolValue(true)
+ } else {
+ item.Permanent = types.BoolValue(false)
+ }
+ if cValue := helpers.GetFromXPath(v, "tag"); cValue.Exists() {
+ item.Tag = types.Int64Value(cValue.Int())
+ }
+ data.NextHops = append(data.NextHops, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/fwd-list-with-track"); value.Exists() {
+ data.NextHopsWithTrack = make([]StaticRouteNextHopsWithTrack, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := StaticRouteNextHopsWithTrack{}
+ if cValue := helpers.GetFromXPath(v, "fwd"); cValue.Exists() {
+ item.NextHop = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "name"); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "track-id-name/id"); cValue.Exists() {
+ item.TrackIdName = types.Int64Value(cValue.Int())
+ }
+ if cValue := helpers.GetFromXPath(v, "metric"); cValue.Exists() {
+ item.Distance = types.Int64Value(cValue.Int())
+ }
+ if cValue := helpers.GetFromXPath(v, "tag"); cValue.Exists() {
+ item.Tag = types.Int64Value(cValue.Int())
+ }
+ if cValue := helpers.GetFromXPath(v, "permanent"); cValue.Exists() {
+ item.Permanent = types.BoolValue(true)
+ } else {
+ item.Permanent = types.BoolValue(false)
+ }
+ data.NextHopsWithTrack = append(data.NextHopsWithTrack, item)
+ return true
+ })
+ }
+}
+
+// End of section. //template:end fromBodyDataXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin getDeletedItems
func (data *StaticRoute) getDeletedItems(ctx context.Context, state StaticRoute) []string {
@@ -533,6 +895,106 @@ func (data *StaticRoute) getDeletedItems(ctx context.Context, state StaticRoute)
// End of section. //template:end getDeletedItems
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletedItemsXML
+
+func (data *StaticRoute) addDeletedItemsXML(ctx context.Context, state StaticRoute, body string) string {
+ b := netconf.NewBody(body)
+ for i := range state.NextHops {
+ stateKeys := [...]string{"fwd"}
+ stateKeyValues := [...]string{state.NextHops[i].NextHop.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.NextHops[i].NextHop.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.NextHops {
+ found = true
+ if state.NextHops[i].NextHop.ValueString() != data.NextHops[j].NextHop.ValueString() {
+ found = false
+ }
+ if found {
+ if !state.NextHops[i].Distance.IsNull() && data.NextHops[j].Distance.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/fwd-list%v/metric", predicates))
+ }
+ if !state.NextHops[i].Global.IsNull() && data.NextHops[j].Global.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/fwd-list%v/global", predicates))
+ }
+ if !state.NextHops[i].Name.IsNull() && data.NextHops[j].Name.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/fwd-list%v/name", predicates))
+ }
+ if !state.NextHops[i].Permanent.IsNull() && data.NextHops[j].Permanent.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/fwd-list%v/permanent", predicates))
+ }
+ if !state.NextHops[i].Tag.IsNull() && data.NextHops[j].Tag.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/fwd-list%v/tag", predicates))
+ }
+ break
+ }
+ }
+ if !found {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/fwd-list%v", predicates))
+ }
+ }
+ for i := range state.NextHopsWithTrack {
+ stateKeys := [...]string{"fwd"}
+ stateKeyValues := [...]string{state.NextHopsWithTrack[i].NextHop.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.NextHopsWithTrack[i].NextHop.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.NextHopsWithTrack {
+ found = true
+ if state.NextHopsWithTrack[i].NextHop.ValueString() != data.NextHopsWithTrack[j].NextHop.ValueString() {
+ found = false
+ }
+ if found {
+ if !state.NextHopsWithTrack[i].Name.IsNull() && data.NextHopsWithTrack[j].Name.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/fwd-list-with-track%v/name", predicates))
+ }
+ if !state.NextHopsWithTrack[i].TrackIdName.IsNull() && data.NextHopsWithTrack[j].TrackIdName.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/fwd-list-with-track%v/track-id-name/id", predicates))
+ }
+ if !state.NextHopsWithTrack[i].Distance.IsNull() && data.NextHopsWithTrack[j].Distance.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/fwd-list-with-track%v/metric", predicates))
+ }
+ if !state.NextHopsWithTrack[i].Tag.IsNull() && data.NextHopsWithTrack[j].Tag.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/fwd-list-with-track%v/tag", predicates))
+ }
+ if !state.NextHopsWithTrack[i].Permanent.IsNull() && data.NextHopsWithTrack[j].Permanent.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/fwd-list-with-track%v/permanent", predicates))
+ }
+ break
+ }
+ }
+ if !found {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/fwd-list-with-track%v", predicates))
+ }
+ }
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletedItemsXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin getEmptyLeafsDelete
func (data *StaticRoute) getEmptyLeafsDelete(ctx context.Context) []string {
@@ -579,3 +1041,33 @@ func (data *StaticRoute) getDeletePaths(ctx context.Context) []string {
}
// End of section. //template:end getDeletePaths
+
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletePathsXML
+
+func (data *StaticRoute) addDeletePathsXML(ctx context.Context, body string) string {
+ b := netconf.NewBody(body)
+ for i := range data.NextHops {
+ keys := [...]string{"fwd"}
+ keyValues := [...]string{data.NextHops[i].NextHop.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/fwd-list%v", predicates))
+ }
+ for i := range data.NextHopsWithTrack {
+ keys := [...]string{"fwd"}
+ keyValues := [...]string{data.NextHopsWithTrack[i].NextHop.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/fwd-list-with-track%v", predicates))
+ }
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletePathsXML
diff --git a/internal/provider/model_iosxe_static_routes_vrf.go b/internal/provider/model_iosxe_static_routes_vrf.go
index 1546af9d..e9a5ea46 100644
--- a/internal/provider/model_iosxe_static_routes_vrf.go
+++ b/internal/provider/model_iosxe_static_routes_vrf.go
@@ -31,6 +31,9 @@ import (
"github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/types"
+ "github.com/hashicorp/terraform-plugin-log/tflog"
+ "github.com/netascode/go-netconf"
+ "github.com/netascode/xmldot"
"github.com/tidwall/gjson"
"github.com/tidwall/sjson"
)
@@ -97,6 +100,19 @@ func (data StaticRoutesVRF) getPathShort() string {
return matches[1]
}
+// getXPath returns the XPath for NETCONF operations
+func (data StaticRoutesVRF) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/ip/route/vrf[name=%s]"
+ path = fmt.Sprintf(path, fmt.Sprintf("%v", data.Vrf.ValueString()))
+ return path
+}
+
+func (data StaticRoutesVRFData) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/ip/route/vrf[name=%s]"
+ path = fmt.Sprintf(path, fmt.Sprintf("%v", data.Vrf.ValueString()))
+ return path
+}
+
// End of section. //template:end getPath
// Section below is generated&owned by "gen/generator.go". //template:begin toBody
@@ -174,6 +190,94 @@ func (data StaticRoutesVRF) toBody(ctx context.Context) string {
// End of section. //template:end toBody
+// Section below is generated&owned by "gen/generator.go". //template:begin toBodyXML
+
+func (data StaticRoutesVRF) toBodyXML(ctx context.Context) string {
+ body := netconf.Body{}
+ if !data.Vrf.IsNull() && !data.Vrf.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/name", data.Vrf.ValueString())
+ }
+ if len(data.Routes) > 0 {
+ for _, item := range data.Routes {
+ cBody := netconf.Body{}
+ if !item.Prefix.IsNull() && !item.Prefix.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "prefix", item.Prefix.ValueString())
+ }
+ if !item.Mask.IsNull() && !item.Mask.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "mask", item.Mask.ValueString())
+ }
+ if len(item.NextHops) > 0 {
+ for _, citem := range item.NextHops {
+ ccBody := netconf.Body{}
+ if !citem.NextHop.IsNull() && !citem.NextHop.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "fwd", citem.NextHop.ValueString())
+ }
+ if !citem.Distance.IsNull() && !citem.Distance.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "metric", strconv.FormatInt(citem.Distance.ValueInt64(), 10))
+ }
+ if !citem.Global.IsNull() && !citem.Global.IsUnknown() {
+ if citem.Global.ValueBool() {
+ ccBody = helpers.SetFromXPath(ccBody, "global", "")
+ } else {
+ ccBody = helpers.RemoveFromXPath(ccBody, "global")
+ }
+ }
+ if !citem.Name.IsNull() && !citem.Name.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "name", citem.Name.ValueString())
+ }
+ if !citem.Permanent.IsNull() && !citem.Permanent.IsUnknown() {
+ if citem.Permanent.ValueBool() {
+ ccBody = helpers.SetFromXPath(ccBody, "permanent", "")
+ } else {
+ ccBody = helpers.RemoveFromXPath(ccBody, "permanent")
+ }
+ }
+ if !citem.Tag.IsNull() && !citem.Tag.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "tag", strconv.FormatInt(citem.Tag.ValueInt64(), 10))
+ }
+ cBody = helpers.SetRawFromXPath(cBody, "fwd-list", ccBody.Res())
+ }
+ }
+ if len(item.NextHopsWithTrack) > 0 {
+ for _, citem := range item.NextHopsWithTrack {
+ ccBody := netconf.Body{}
+ if !citem.NextHop.IsNull() && !citem.NextHop.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "fwd", citem.NextHop.ValueString())
+ }
+ if !citem.Name.IsNull() && !citem.Name.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "name", citem.Name.ValueString())
+ }
+ if !citem.TrackIdName.IsNull() && !citem.TrackIdName.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "track-id-name/id", strconv.FormatInt(citem.TrackIdName.ValueInt64(), 10))
+ }
+ if !citem.Distance.IsNull() && !citem.Distance.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "metric", strconv.FormatInt(citem.Distance.ValueInt64(), 10))
+ }
+ if !citem.Tag.IsNull() && !citem.Tag.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "tag", strconv.FormatInt(citem.Tag.ValueInt64(), 10))
+ }
+ if !citem.Permanent.IsNull() && !citem.Permanent.IsUnknown() {
+ if citem.Permanent.ValueBool() {
+ ccBody = helpers.SetFromXPath(ccBody, "permanent", "")
+ } else {
+ ccBody = helpers.RemoveFromXPath(ccBody, "permanent")
+ }
+ }
+ cBody = helpers.SetRawFromXPath(cBody, "fwd-list-with-track", ccBody.Res())
+ }
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/ip-route-interface-forwarding-list", cBody.Res())
+ }
+ }
+ bodyString, err := body.String()
+ if err != nil {
+ tflog.Error(ctx, fmt.Sprintf("Error converting body to string: %s", err))
+ }
+ return bodyString
+}
+
+// End of section. //template:end toBodyXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBody
func (data *StaticRoutesVRF) updateFromBody(ctx context.Context, res gjson.Result) {
@@ -344,6 +448,172 @@ func (data *StaticRoutesVRF) updateFromBody(ctx context.Context, res gjson.Resul
// End of section. //template:end updateFromBody
+// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBodyXML
+
+func (data *StaticRoutesVRF) updateFromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/name"); value.Exists() && !data.Vrf.IsNull() {
+ data.Vrf = types.StringValue(value.String())
+ } else {
+ data.Vrf = types.StringNull()
+ }
+ for i := range data.Routes {
+ keys := [...]string{"prefix", "mask"}
+ keyValues := [...]string{data.Routes[i].Prefix.ValueString(), data.Routes[i].Mask.ValueString()}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip-route-interface-forwarding-list").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, "prefix"); value.Exists() && !data.Routes[i].Prefix.IsNull() {
+ data.Routes[i].Prefix = types.StringValue(value.String())
+ } else {
+ data.Routes[i].Prefix = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "mask"); value.Exists() && !data.Routes[i].Mask.IsNull() {
+ data.Routes[i].Mask = types.StringValue(value.String())
+ } else {
+ data.Routes[i].Mask = types.StringNull()
+ }
+ for ci := range data.Routes[i].NextHops {
+ keys := [...]string{"fwd"}
+ keyValues := [...]string{data.Routes[i].NextHops[ci].NextHop.ValueString()}
+
+ var cr xmldot.Result
+ helpers.GetFromXPath(r, "fwd-list").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ cr = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(cr, "fwd"); value.Exists() && !data.Routes[i].NextHops[ci].NextHop.IsNull() {
+ data.Routes[i].NextHops[ci].NextHop = types.StringValue(value.String())
+ } else {
+ data.Routes[i].NextHops[ci].NextHop = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(cr, "metric"); value.Exists() && !data.Routes[i].NextHops[ci].Distance.IsNull() {
+ data.Routes[i].NextHops[ci].Distance = types.Int64Value(value.Int())
+ } else {
+ data.Routes[i].NextHops[ci].Distance = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(cr, "global"); !data.Routes[i].NextHops[ci].Global.IsNull() {
+ if value.Exists() {
+ data.Routes[i].NextHops[ci].Global = types.BoolValue(true)
+ } else {
+ data.Routes[i].NextHops[ci].Global = types.BoolValue(false)
+ }
+ } else {
+ data.Routes[i].NextHops[ci].Global = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(cr, "name"); value.Exists() && !data.Routes[i].NextHops[ci].Name.IsNull() {
+ data.Routes[i].NextHops[ci].Name = types.StringValue(value.String())
+ } else {
+ data.Routes[i].NextHops[ci].Name = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(cr, "permanent"); !data.Routes[i].NextHops[ci].Permanent.IsNull() {
+ if value.Exists() {
+ data.Routes[i].NextHops[ci].Permanent = types.BoolValue(true)
+ } else {
+ data.Routes[i].NextHops[ci].Permanent = types.BoolValue(false)
+ }
+ } else {
+ data.Routes[i].NextHops[ci].Permanent = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(cr, "tag"); value.Exists() && !data.Routes[i].NextHops[ci].Tag.IsNull() {
+ data.Routes[i].NextHops[ci].Tag = types.Int64Value(value.Int())
+ } else {
+ data.Routes[i].NextHops[ci].Tag = types.Int64Null()
+ }
+ }
+ for ci := range data.Routes[i].NextHopsWithTrack {
+ keys := [...]string{"fwd"}
+ keyValues := [...]string{data.Routes[i].NextHopsWithTrack[ci].NextHop.ValueString()}
+
+ var cr xmldot.Result
+ helpers.GetFromXPath(r, "fwd-list-with-track").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ cr = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(cr, "fwd"); value.Exists() && !data.Routes[i].NextHopsWithTrack[ci].NextHop.IsNull() {
+ data.Routes[i].NextHopsWithTrack[ci].NextHop = types.StringValue(value.String())
+ } else {
+ data.Routes[i].NextHopsWithTrack[ci].NextHop = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(cr, "name"); value.Exists() && !data.Routes[i].NextHopsWithTrack[ci].Name.IsNull() {
+ data.Routes[i].NextHopsWithTrack[ci].Name = types.StringValue(value.String())
+ } else {
+ data.Routes[i].NextHopsWithTrack[ci].Name = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(cr, "track-id-name/id"); value.Exists() && !data.Routes[i].NextHopsWithTrack[ci].TrackIdName.IsNull() {
+ data.Routes[i].NextHopsWithTrack[ci].TrackIdName = types.Int64Value(value.Int())
+ } else {
+ data.Routes[i].NextHopsWithTrack[ci].TrackIdName = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(cr, "metric"); value.Exists() && !data.Routes[i].NextHopsWithTrack[ci].Distance.IsNull() {
+ data.Routes[i].NextHopsWithTrack[ci].Distance = types.Int64Value(value.Int())
+ } else {
+ data.Routes[i].NextHopsWithTrack[ci].Distance = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(cr, "tag"); value.Exists() && !data.Routes[i].NextHopsWithTrack[ci].Tag.IsNull() {
+ data.Routes[i].NextHopsWithTrack[ci].Tag = types.Int64Value(value.Int())
+ } else {
+ data.Routes[i].NextHopsWithTrack[ci].Tag = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(cr, "permanent"); !data.Routes[i].NextHopsWithTrack[ci].Permanent.IsNull() {
+ if value.Exists() {
+ data.Routes[i].NextHopsWithTrack[ci].Permanent = types.BoolValue(true)
+ } else {
+ data.Routes[i].NextHopsWithTrack[ci].Permanent = types.BoolValue(false)
+ }
+ } else {
+ data.Routes[i].NextHopsWithTrack[ci].Permanent = types.BoolNull()
+ }
+ }
+ }
+}
+
+// End of section. //template:end updateFromBodyXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin fromBody
func (data *StaticRoutesVRF) fromBody(ctx context.Context, res gjson.Result) {
@@ -510,6 +780,164 @@ func (data *StaticRoutesVRFData) fromBody(ctx context.Context, res gjson.Result)
// End of section. //template:end fromBodyData
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyXML
+
+func (data *StaticRoutesVRF) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip-route-interface-forwarding-list"); value.Exists() {
+ data.Routes = make([]StaticRoutesVRFRoutes, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := StaticRoutesVRFRoutes{}
+ if cValue := helpers.GetFromXPath(v, "prefix"); cValue.Exists() {
+ item.Prefix = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "mask"); cValue.Exists() {
+ item.Mask = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "fwd-list"); cValue.Exists() {
+ item.NextHops = make([]StaticRoutesVRFRoutesNextHops, 0)
+ cValue.ForEach(func(_ int, cv xmldot.Result) bool {
+ cItem := StaticRoutesVRFRoutesNextHops{}
+ if ccValue := helpers.GetFromXPath(cv, "fwd"); ccValue.Exists() {
+ cItem.NextHop = types.StringValue(ccValue.String())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "metric"); ccValue.Exists() {
+ cItem.Distance = types.Int64Value(ccValue.Int())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "global"); ccValue.Exists() {
+ cItem.Global = types.BoolValue(true)
+ } else {
+ cItem.Global = types.BoolValue(false)
+ }
+ if ccValue := helpers.GetFromXPath(cv, "name"); ccValue.Exists() {
+ cItem.Name = types.StringValue(ccValue.String())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "permanent"); ccValue.Exists() {
+ cItem.Permanent = types.BoolValue(true)
+ } else {
+ cItem.Permanent = types.BoolValue(false)
+ }
+ if ccValue := helpers.GetFromXPath(cv, "tag"); ccValue.Exists() {
+ cItem.Tag = types.Int64Value(ccValue.Int())
+ }
+ item.NextHops = append(item.NextHops, cItem)
+ return true
+ })
+ }
+ if cValue := helpers.GetFromXPath(v, "fwd-list-with-track"); cValue.Exists() {
+ item.NextHopsWithTrack = make([]StaticRoutesVRFRoutesNextHopsWithTrack, 0)
+ cValue.ForEach(func(_ int, cv xmldot.Result) bool {
+ cItem := StaticRoutesVRFRoutesNextHopsWithTrack{}
+ if ccValue := helpers.GetFromXPath(cv, "fwd"); ccValue.Exists() {
+ cItem.NextHop = types.StringValue(ccValue.String())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "name"); ccValue.Exists() {
+ cItem.Name = types.StringValue(ccValue.String())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "track-id-name/id"); ccValue.Exists() {
+ cItem.TrackIdName = types.Int64Value(ccValue.Int())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "metric"); ccValue.Exists() {
+ cItem.Distance = types.Int64Value(ccValue.Int())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "tag"); ccValue.Exists() {
+ cItem.Tag = types.Int64Value(ccValue.Int())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "permanent"); ccValue.Exists() {
+ cItem.Permanent = types.BoolValue(true)
+ } else {
+ cItem.Permanent = types.BoolValue(false)
+ }
+ item.NextHopsWithTrack = append(item.NextHopsWithTrack, cItem)
+ return true
+ })
+ }
+ data.Routes = append(data.Routes, item)
+ return true
+ })
+ }
+}
+
+// End of section. //template:end fromBodyXML
+
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyDataXML
+
+func (data *StaticRoutesVRFData) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip-route-interface-forwarding-list"); value.Exists() {
+ data.Routes = make([]StaticRoutesVRFRoutes, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := StaticRoutesVRFRoutes{}
+ if cValue := helpers.GetFromXPath(v, "prefix"); cValue.Exists() {
+ item.Prefix = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "mask"); cValue.Exists() {
+ item.Mask = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "fwd-list"); cValue.Exists() {
+ item.NextHops = make([]StaticRoutesVRFRoutesNextHops, 0)
+ cValue.ForEach(func(_ int, cv xmldot.Result) bool {
+ cItem := StaticRoutesVRFRoutesNextHops{}
+ if ccValue := helpers.GetFromXPath(cv, "fwd"); ccValue.Exists() {
+ cItem.NextHop = types.StringValue(ccValue.String())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "metric"); ccValue.Exists() {
+ cItem.Distance = types.Int64Value(ccValue.Int())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "global"); ccValue.Exists() {
+ cItem.Global = types.BoolValue(true)
+ } else {
+ cItem.Global = types.BoolValue(false)
+ }
+ if ccValue := helpers.GetFromXPath(cv, "name"); ccValue.Exists() {
+ cItem.Name = types.StringValue(ccValue.String())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "permanent"); ccValue.Exists() {
+ cItem.Permanent = types.BoolValue(true)
+ } else {
+ cItem.Permanent = types.BoolValue(false)
+ }
+ if ccValue := helpers.GetFromXPath(cv, "tag"); ccValue.Exists() {
+ cItem.Tag = types.Int64Value(ccValue.Int())
+ }
+ item.NextHops = append(item.NextHops, cItem)
+ return true
+ })
+ }
+ if cValue := helpers.GetFromXPath(v, "fwd-list-with-track"); cValue.Exists() {
+ item.NextHopsWithTrack = make([]StaticRoutesVRFRoutesNextHopsWithTrack, 0)
+ cValue.ForEach(func(_ int, cv xmldot.Result) bool {
+ cItem := StaticRoutesVRFRoutesNextHopsWithTrack{}
+ if ccValue := helpers.GetFromXPath(cv, "fwd"); ccValue.Exists() {
+ cItem.NextHop = types.StringValue(ccValue.String())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "name"); ccValue.Exists() {
+ cItem.Name = types.StringValue(ccValue.String())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "track-id-name/id"); ccValue.Exists() {
+ cItem.TrackIdName = types.Int64Value(ccValue.Int())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "metric"); ccValue.Exists() {
+ cItem.Distance = types.Int64Value(ccValue.Int())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "tag"); ccValue.Exists() {
+ cItem.Tag = types.Int64Value(ccValue.Int())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "permanent"); ccValue.Exists() {
+ cItem.Permanent = types.BoolValue(true)
+ } else {
+ cItem.Permanent = types.BoolValue(false)
+ }
+ item.NextHopsWithTrack = append(item.NextHopsWithTrack, cItem)
+ return true
+ })
+ }
+ data.Routes = append(data.Routes, item)
+ return true
+ })
+ }
+}
+
+// End of section. //template:end fromBodyDataXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin getDeletedItems
func (data *StaticRoutesVRF) getDeletedItems(ctx context.Context, state StaticRoutesVRF) []string {
@@ -631,6 +1059,142 @@ func (data *StaticRoutesVRF) getDeletedItems(ctx context.Context, state StaticRo
// End of section. //template:end getDeletedItems
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletedItemsXML
+
+func (data *StaticRoutesVRF) addDeletedItemsXML(ctx context.Context, state StaticRoutesVRF, body string) string {
+ b := netconf.NewBody(body)
+ for i := range state.Routes {
+ stateKeys := [...]string{"prefix", "mask"}
+ stateKeyValues := [...]string{state.Routes[i].Prefix.ValueString(), state.Routes[i].Mask.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.Routes[i].Prefix.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if !reflect.ValueOf(state.Routes[i].Mask.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.Routes {
+ found = true
+ if state.Routes[i].Prefix.ValueString() != data.Routes[j].Prefix.ValueString() {
+ found = false
+ }
+ if state.Routes[i].Mask.ValueString() != data.Routes[j].Mask.ValueString() {
+ found = false
+ }
+ if found {
+ for ci := range state.Routes[i].NextHops {
+ cstateKeys := [...]string{"fwd"}
+ cstateKeyValues := [...]string{state.Routes[i].NextHops[ci].NextHop.ValueString()}
+ cpredicates := ""
+ for i := range cstateKeys {
+ cpredicates += fmt.Sprintf("[%s='%s']", cstateKeys[i], cstateKeyValues[i])
+ }
+
+ cemptyKeys := true
+ if !reflect.ValueOf(state.Routes[i].NextHops[ci].NextHop.ValueString()).IsZero() {
+ cemptyKeys = false
+ }
+ if cemptyKeys {
+ continue
+ }
+
+ found := false
+ for cj := range data.Routes[j].NextHops {
+ found = true
+ if state.Routes[i].NextHops[ci].NextHop.ValueString() != data.Routes[j].NextHops[cj].NextHop.ValueString() {
+ found = false
+ }
+ if found {
+ if !state.Routes[i].NextHops[ci].Distance.IsNull() && data.Routes[j].NextHops[cj].Distance.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/ip-route-interface-forwarding-list%v/fwd-list%v/metric", predicates, cpredicates))
+ }
+ if !state.Routes[i].NextHops[ci].Global.IsNull() && data.Routes[j].NextHops[cj].Global.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/ip-route-interface-forwarding-list%v/fwd-list%v/global", predicates, cpredicates))
+ }
+ if !state.Routes[i].NextHops[ci].Name.IsNull() && data.Routes[j].NextHops[cj].Name.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/ip-route-interface-forwarding-list%v/fwd-list%v/name", predicates, cpredicates))
+ }
+ if !state.Routes[i].NextHops[ci].Permanent.IsNull() && data.Routes[j].NextHops[cj].Permanent.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/ip-route-interface-forwarding-list%v/fwd-list%v/permanent", predicates, cpredicates))
+ }
+ if !state.Routes[i].NextHops[ci].Tag.IsNull() && data.Routes[j].NextHops[cj].Tag.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/ip-route-interface-forwarding-list%v/fwd-list%v/tag", predicates, cpredicates))
+ }
+ break
+ }
+ }
+ if !found {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/ip-route-interface-forwarding-list%v/fwd-list%v", predicates, cpredicates))
+ }
+ }
+ for ci := range state.Routes[i].NextHopsWithTrack {
+ cstateKeys := [...]string{"fwd"}
+ cstateKeyValues := [...]string{state.Routes[i].NextHopsWithTrack[ci].NextHop.ValueString()}
+ cpredicates := ""
+ for i := range cstateKeys {
+ cpredicates += fmt.Sprintf("[%s='%s']", cstateKeys[i], cstateKeyValues[i])
+ }
+
+ cemptyKeys := true
+ if !reflect.ValueOf(state.Routes[i].NextHopsWithTrack[ci].NextHop.ValueString()).IsZero() {
+ cemptyKeys = false
+ }
+ if cemptyKeys {
+ continue
+ }
+
+ found := false
+ for cj := range data.Routes[j].NextHopsWithTrack {
+ found = true
+ if state.Routes[i].NextHopsWithTrack[ci].NextHop.ValueString() != data.Routes[j].NextHopsWithTrack[cj].NextHop.ValueString() {
+ found = false
+ }
+ if found {
+ if !state.Routes[i].NextHopsWithTrack[ci].Name.IsNull() && data.Routes[j].NextHopsWithTrack[cj].Name.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/ip-route-interface-forwarding-list%v/fwd-list-with-track%v/name", predicates, cpredicates))
+ }
+ if !state.Routes[i].NextHopsWithTrack[ci].TrackIdName.IsNull() && data.Routes[j].NextHopsWithTrack[cj].TrackIdName.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/ip-route-interface-forwarding-list%v/fwd-list-with-track%v/track-id-name/id", predicates, cpredicates))
+ }
+ if !state.Routes[i].NextHopsWithTrack[ci].Distance.IsNull() && data.Routes[j].NextHopsWithTrack[cj].Distance.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/ip-route-interface-forwarding-list%v/fwd-list-with-track%v/metric", predicates, cpredicates))
+ }
+ if !state.Routes[i].NextHopsWithTrack[ci].Tag.IsNull() && data.Routes[j].NextHopsWithTrack[cj].Tag.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/ip-route-interface-forwarding-list%v/fwd-list-with-track%v/tag", predicates, cpredicates))
+ }
+ if !state.Routes[i].NextHopsWithTrack[ci].Permanent.IsNull() && data.Routes[j].NextHopsWithTrack[cj].Permanent.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/ip-route-interface-forwarding-list%v/fwd-list-with-track%v/permanent", predicates, cpredicates))
+ }
+ break
+ }
+ }
+ if !found {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/ip-route-interface-forwarding-list%v/fwd-list-with-track%v", predicates, cpredicates))
+ }
+ }
+ break
+ }
+ }
+ if !found {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/ip-route-interface-forwarding-list%v", predicates))
+ }
+ }
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletedItemsXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin getEmptyLeafsDelete
func (data *StaticRoutesVRF) getEmptyLeafsDelete(ctx context.Context) []string {
@@ -676,3 +1240,23 @@ func (data *StaticRoutesVRF) getDeletePaths(ctx context.Context) []string {
}
// End of section. //template:end getDeletePaths
+
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletePathsXML
+
+func (data *StaticRoutesVRF) addDeletePathsXML(ctx context.Context, body string) string {
+ b := netconf.NewBody(body)
+ for i := range data.Routes {
+ keys := [...]string{"prefix", "mask"}
+ keyValues := [...]string{data.Routes[i].Prefix.ValueString(), data.Routes[i].Mask.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/ip-route-interface-forwarding-list%v", predicates))
+ }
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletePathsXML
diff --git a/internal/provider/model_iosxe_system.go b/internal/provider/model_iosxe_system.go
index 4984fa02..e175d137 100644
--- a/internal/provider/model_iosxe_system.go
+++ b/internal/provider/model_iosxe_system.go
@@ -30,6 +30,9 @@ import (
"github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/types"
+ "github.com/hashicorp/terraform-plugin-log/tflog"
+ "github.com/netascode/go-netconf"
+ "github.com/netascode/xmldot"
"github.com/tidwall/gjson"
"github.com/tidwall/sjson"
)
@@ -368,6 +371,17 @@ func (data System) getPathShort() string {
return matches[1]
}
+// getXPath returns the XPath for NETCONF operations
+func (data System) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native"
+ return path
+}
+
+func (data SystemData) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native"
+ return path
+}
+
// End of section. //template:end getPath
// Section below is generated&owned by "gen/generator.go". //template:begin toBody
@@ -900,955 +914,739 @@ func (data System) toBody(ctx context.Context) string {
// End of section. //template:end toBody
-// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBody
+// Section below is generated&owned by "gen/generator.go". //template:begin toBodyXML
-func (data *System) updateFromBody(ctx context.Context, res gjson.Result) {
- prefix := helpers.LastElement(data.getPath()) + "."
- if res.Get(helpers.LastElement(data.getPath())).IsArray() {
- prefix += "0."
- }
- if value := res.Get(prefix + "hostname"); value.Exists() && !data.Hostname.IsNull() {
- data.Hostname = types.StringValue(value.String())
- } else {
- data.Hostname = types.StringNull()
+func (data System) toBodyXML(ctx context.Context) string {
+ body := netconf.Body{}
+ if !data.Hostname.IsNull() && !data.Hostname.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/hostname", data.Hostname.ValueString())
}
- if value := res.Get(prefix + "ip.bgp-community.new-format"); !data.IpBgpCommunityNewFormat.IsNull() {
- if value.Exists() {
- data.IpBgpCommunityNewFormat = types.BoolValue(true)
+ if !data.IpBgpCommunityNewFormat.IsNull() && !data.IpBgpCommunityNewFormat.IsUnknown() {
+ if data.IpBgpCommunityNewFormat.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ip/bgp-community/new-format", "")
} else {
- data.IpBgpCommunityNewFormat = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/ip/bgp-community/new-format")
}
- } else {
- data.IpBgpCommunityNewFormat = types.BoolNull()
}
- if value := res.Get(prefix + "ip.routing-conf.routing"); !data.IpRouting.IsNull() {
- if value.Exists() {
- data.IpRouting = types.BoolValue(value.Bool())
- }
- } else {
- data.IpRouting = types.BoolNull()
+ if !data.IpRouting.IsNull() && !data.IpRouting.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ip/routing-conf/routing", data.IpRouting.ValueBool())
}
- if value := res.Get(prefix + "ipv6.unicast-routing"); !data.Ipv6UnicastRouting.IsNull() {
- if value.Exists() {
- data.Ipv6UnicastRouting = types.BoolValue(true)
+ if !data.Ipv6UnicastRouting.IsNull() && !data.Ipv6UnicastRouting.IsUnknown() {
+ if data.Ipv6UnicastRouting.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ipv6/unicast-routing", "")
} else {
- data.Ipv6UnicastRouting = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/ipv6/unicast-routing")
}
- } else {
- data.Ipv6UnicastRouting = types.BoolNull()
}
- if value := res.Get(prefix + "system.Cisco-IOS-XE-switch:mtu.size"); value.Exists() && !data.Mtu.IsNull() {
- data.Mtu = types.Int64Value(value.Int())
- } else {
- data.Mtu = types.Int64Null()
+ if !data.Mtu.IsNull() && !data.Mtu.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/system/Cisco-IOS-XE-switch:mtu/size", strconv.FormatInt(data.Mtu.ValueInt64(), 10))
}
- if value := res.Get(prefix + "ip.source-route"); !data.IpSourceRoute.IsNull() {
- if value.Exists() {
- data.IpSourceRoute = types.BoolValue(value.Bool())
- }
- } else {
- data.IpSourceRoute = types.BoolNull()
+ if !data.IpSourceRoute.IsNull() && !data.IpSourceRoute.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ip/source-route", data.IpSourceRoute.ValueBool())
}
- if value := res.Get(prefix + "ip.domain.lookup"); !data.IpDomainLookup.IsNull() {
- if value.Exists() {
- data.IpDomainLookup = types.BoolValue(value.Bool())
- }
- } else {
- data.IpDomainLookup = types.BoolNull()
+ if !data.IpDomainLookup.IsNull() && !data.IpDomainLookup.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ip/domain/lookup", data.IpDomainLookup.ValueBool())
}
- if value := res.Get(prefix + "ip.domain.name"); value.Exists() && !data.IpDomainName.IsNull() {
- data.IpDomainName = types.StringValue(value.String())
- } else {
- data.IpDomainName = types.StringNull()
+ if !data.IpDomainName.IsNull() && !data.IpDomainName.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ip/domain/name", data.IpDomainName.ValueString())
}
- if value := res.Get(prefix + "login.delay"); value.Exists() && !data.LoginDelay.IsNull() {
- data.LoginDelay = types.Int64Value(value.Int())
- } else {
- data.LoginDelay = types.Int64Null()
+ if !data.LoginDelay.IsNull() && !data.LoginDelay.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/login/delay", strconv.FormatInt(data.LoginDelay.ValueInt64(), 10))
}
- if value := res.Get(prefix + "login.on-failure"); !data.LoginOnFailure.IsNull() {
- if value.Exists() {
- data.LoginOnFailure = types.BoolValue(true)
+ if !data.LoginOnFailure.IsNull() && !data.LoginOnFailure.IsUnknown() {
+ if data.LoginOnFailure.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/login/on-failure", "")
} else {
- data.LoginOnFailure = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/login/on-failure")
}
- } else {
- data.LoginOnFailure = types.BoolNull()
}
- if value := res.Get(prefix + "login.on-failure.log"); !data.LoginOnFailureLog.IsNull() {
- if value.Exists() {
- data.LoginOnFailureLog = types.BoolValue(true)
+ if !data.LoginOnFailureLog.IsNull() && !data.LoginOnFailureLog.IsUnknown() {
+ if data.LoginOnFailureLog.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/login/on-failure/log", "")
} else {
- data.LoginOnFailureLog = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/login/on-failure/log")
}
- } else {
- data.LoginOnFailureLog = types.BoolNull()
}
- if value := res.Get(prefix + "login.on-success"); !data.LoginOnSuccess.IsNull() {
- if value.Exists() {
- data.LoginOnSuccess = types.BoolValue(true)
+ if !data.LoginOnSuccess.IsNull() && !data.LoginOnSuccess.IsUnknown() {
+ if data.LoginOnSuccess.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/login/on-success", "")
} else {
- data.LoginOnSuccess = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/login/on-success")
}
- } else {
- data.LoginOnSuccess = types.BoolNull()
}
- if value := res.Get(prefix + "login.on-success.log"); !data.LoginOnSuccessLog.IsNull() {
- if value.Exists() {
- data.LoginOnSuccessLog = types.BoolValue(true)
+ if !data.LoginOnSuccessLog.IsNull() && !data.LoginOnSuccessLog.IsUnknown() {
+ if data.LoginOnSuccessLog.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/login/on-success/log", "")
} else {
- data.LoginOnSuccessLog = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/login/on-success/log")
}
- } else {
- data.LoginOnSuccessLog = types.BoolNull()
}
- if value := res.Get(prefix + "ip.Cisco-IOS-XE-multicast:multicast-routing"); !data.IpMulticastRouting.IsNull() {
- if value.Exists() {
- data.IpMulticastRouting = types.BoolValue(true)
+ if !data.IpMulticastRouting.IsNull() && !data.IpMulticastRouting.IsUnknown() {
+ if data.IpMulticastRouting.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ip/Cisco-IOS-XE-multicast:multicast-routing", "")
} else {
- data.IpMulticastRouting = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/ip/Cisco-IOS-XE-multicast:multicast-routing")
}
- } else {
- data.IpMulticastRouting = types.BoolNull()
}
- if value := res.Get(prefix + "ip.Cisco-IOS-XE-multicast:mcr-conf.multicast-routing"); !data.MulticastRoutingSwitch.IsNull() {
- if value.Exists() {
- data.MulticastRoutingSwitch = types.BoolValue(true)
+ if !data.MulticastRoutingSwitch.IsNull() && !data.MulticastRoutingSwitch.IsUnknown() {
+ if data.MulticastRoutingSwitch.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ip/Cisco-IOS-XE-multicast:mcr-conf/multicast-routing", "")
} else {
- data.MulticastRoutingSwitch = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/ip/Cisco-IOS-XE-multicast:mcr-conf/multicast-routing")
}
- } else {
- data.MulticastRoutingSwitch = types.BoolNull()
}
- if value := res.Get(prefix + "ip.Cisco-IOS-XE-multicast:multicast-routing.distributed"); !data.IpMulticastRoutingDistributed.IsNull() {
- if value.Exists() {
- data.IpMulticastRoutingDistributed = types.BoolValue(true)
+ if !data.IpMulticastRoutingDistributed.IsNull() && !data.IpMulticastRoutingDistributed.IsUnknown() {
+ if data.IpMulticastRoutingDistributed.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ip/Cisco-IOS-XE-multicast:multicast-routing/distributed", "")
} else {
- data.IpMulticastRoutingDistributed = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/ip/Cisco-IOS-XE-multicast:multicast-routing/distributed")
}
- } else {
- data.IpMulticastRoutingDistributed = types.BoolNull()
}
- for i := range data.MulticastRoutingVrfs {
- keys := [...]string{"name"}
- keyValues := [...]string{data.MulticastRoutingVrfs[i].Vrf.ValueString()}
-
- var r gjson.Result
- res.Get(prefix + "ip.Cisco-IOS-XE-multicast:multicast-routing.vrf").ForEach(
- func(_, v gjson.Result) bool {
- found := false
- for ik := range keys {
- if v.Get(keys[ik]).String() == keyValues[ik] {
- found = true
- continue
- }
- found = false
- break
- }
- if found {
- r = v
- return false
+ if len(data.MulticastRoutingVrfs) > 0 {
+ for _, item := range data.MulticastRoutingVrfs {
+ cBody := netconf.Body{}
+ if !item.Vrf.IsNull() && !item.Vrf.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "name", item.Vrf.ValueString())
+ }
+ if !item.Distributed.IsNull() && !item.Distributed.IsUnknown() {
+ if item.Distributed.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "distributed", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "distributed")
}
- return true
- },
- )
- if value := r.Get("name"); value.Exists() && !data.MulticastRoutingVrfs[i].Vrf.IsNull() {
- data.MulticastRoutingVrfs[i].Vrf = types.StringValue(value.String())
- } else {
- data.MulticastRoutingVrfs[i].Vrf = types.StringNull()
- }
- if value := r.Get("distributed"); !data.MulticastRoutingVrfs[i].Distributed.IsNull() {
- if value.Exists() {
- data.MulticastRoutingVrfs[i].Distributed = types.BoolValue(true)
- } else {
- data.MulticastRoutingVrfs[i].Distributed = types.BoolValue(false)
}
- } else {
- data.MulticastRoutingVrfs[i].Distributed = types.BoolNull()
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/ip/Cisco-IOS-XE-multicast:multicast-routing/vrf", cBody.Res())
}
}
- if value := res.Get(prefix + "ip.Cisco-IOS-XE-http:http.access-class"); value.Exists() && !data.IpHttpAccessClass.IsNull() {
- data.IpHttpAccessClass = types.Int64Value(value.Int())
- } else {
- data.IpHttpAccessClass = types.Int64Null()
+ if !data.IpHttpAccessClass.IsNull() && !data.IpHttpAccessClass.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ip/Cisco-IOS-XE-http:http/access-class", strconv.FormatInt(data.IpHttpAccessClass.ValueInt64(), 10))
}
- if value := res.Get(prefix + "ip.Cisco-IOS-XE-http:http.authentication.aaa"); !data.IpHttpAuthenticationAaa.IsNull() {
- if value.Exists() {
- data.IpHttpAuthenticationAaa = types.BoolValue(true)
+ if !data.IpHttpAuthenticationAaa.IsNull() && !data.IpHttpAuthenticationAaa.IsUnknown() {
+ if data.IpHttpAuthenticationAaa.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ip/Cisco-IOS-XE-http:http/authentication/aaa", "")
} else {
- data.IpHttpAuthenticationAaa = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/ip/Cisco-IOS-XE-http:http/authentication/aaa")
}
- } else {
- data.IpHttpAuthenticationAaa = types.BoolNull()
}
- if value := res.Get(prefix + "ip.Cisco-IOS-XE-http:http.authentication.aaa.exec-authorization"); value.Exists() && !data.IpHttpAuthenticationAaaExecAuthorization.IsNull() {
- data.IpHttpAuthenticationAaaExecAuthorization = types.StringValue(value.String())
- } else {
- data.IpHttpAuthenticationAaaExecAuthorization = types.StringNull()
+ if !data.IpHttpAuthenticationAaaExecAuthorization.IsNull() && !data.IpHttpAuthenticationAaaExecAuthorization.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ip/Cisco-IOS-XE-http:http/authentication/aaa/exec-authorization", data.IpHttpAuthenticationAaaExecAuthorization.ValueString())
}
- if value := res.Get(prefix + "ip.Cisco-IOS-XE-http:http.authentication.aaa.login-authentication"); value.Exists() && !data.IpHttpAuthenticationAaaLoginAuthentication.IsNull() {
- data.IpHttpAuthenticationAaaLoginAuthentication = types.StringValue(value.String())
- } else {
- data.IpHttpAuthenticationAaaLoginAuthentication = types.StringNull()
+ if !data.IpHttpAuthenticationAaaLoginAuthentication.IsNull() && !data.IpHttpAuthenticationAaaLoginAuthentication.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ip/Cisco-IOS-XE-http:http/authentication/aaa/login-authentication", data.IpHttpAuthenticationAaaLoginAuthentication.ValueString())
}
- for i := range data.IpHttpAuthenticationAaaCommandAuthorization {
- keys := [...]string{"level"}
- keyValues := [...]string{strconv.FormatInt(data.IpHttpAuthenticationAaaCommandAuthorization[i].Level.ValueInt64(), 10)}
-
- var r gjson.Result
- res.Get(prefix + "ip.Cisco-IOS-XE-http:http.authentication.aaa.command-authorization").ForEach(
- func(_, v gjson.Result) bool {
- found := false
- for ik := range keys {
- if v.Get(keys[ik]).String() == keyValues[ik] {
- found = true
- continue
- }
- found = false
- break
- }
- if found {
- r = v
- return false
- }
- return true
- },
- )
- if value := r.Get("level"); value.Exists() && !data.IpHttpAuthenticationAaaCommandAuthorization[i].Level.IsNull() {
- data.IpHttpAuthenticationAaaCommandAuthorization[i].Level = types.Int64Value(value.Int())
- } else {
- data.IpHttpAuthenticationAaaCommandAuthorization[i].Level = types.Int64Null()
- }
- if value := r.Get("name"); value.Exists() && !data.IpHttpAuthenticationAaaCommandAuthorization[i].Name.IsNull() {
- data.IpHttpAuthenticationAaaCommandAuthorization[i].Name = types.StringValue(value.String())
- } else {
- data.IpHttpAuthenticationAaaCommandAuthorization[i].Name = types.StringNull()
+ if len(data.IpHttpAuthenticationAaaCommandAuthorization) > 0 {
+ for _, item := range data.IpHttpAuthenticationAaaCommandAuthorization {
+ cBody := netconf.Body{}
+ if !item.Level.IsNull() && !item.Level.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "level", strconv.FormatInt(item.Level.ValueInt64(), 10))
+ }
+ if !item.Name.IsNull() && !item.Name.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "name", item.Name.ValueString())
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/ip/Cisco-IOS-XE-http:http/authentication/aaa/command-authorization", cBody.Res())
}
}
- if value := res.Get(prefix + "ip.Cisco-IOS-XE-http:http.authentication.local"); !data.IpHttpAuthenticationLocal.IsNull() {
- if value.Exists() {
- data.IpHttpAuthenticationLocal = types.BoolValue(true)
+ if !data.IpHttpAuthenticationLocal.IsNull() && !data.IpHttpAuthenticationLocal.IsUnknown() {
+ if data.IpHttpAuthenticationLocal.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ip/Cisco-IOS-XE-http:http/authentication/local", "")
} else {
- data.IpHttpAuthenticationLocal = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/ip/Cisco-IOS-XE-http:http/authentication/local")
}
- } else {
- data.IpHttpAuthenticationLocal = types.BoolNull()
}
- if value := res.Get(prefix + "ip.Cisco-IOS-XE-http:http.server"); !data.IpHttpServer.IsNull() {
- if value.Exists() {
- data.IpHttpServer = types.BoolValue(value.Bool())
- }
- } else {
- data.IpHttpServer = types.BoolNull()
+ if !data.IpHttpServer.IsNull() && !data.IpHttpServer.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ip/Cisco-IOS-XE-http:http/server", data.IpHttpServer.ValueBool())
}
- if value := res.Get(prefix + "ip.Cisco-IOS-XE-http:http.secure-server"); !data.IpHttpSecureServer.IsNull() {
- if value.Exists() {
- data.IpHttpSecureServer = types.BoolValue(value.Bool())
- }
- } else {
- data.IpHttpSecureServer = types.BoolNull()
+ if !data.IpHttpSecureServer.IsNull() && !data.IpHttpSecureServer.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ip/Cisco-IOS-XE-http:http/secure-server", data.IpHttpSecureServer.ValueBool())
}
- if value := res.Get(prefix + "ip.Cisco-IOS-XE-http:http.secure-trustpoint"); value.Exists() && !data.IpHttpSecureTrustpoint.IsNull() {
- data.IpHttpSecureTrustpoint = types.StringValue(value.String())
- } else {
- data.IpHttpSecureTrustpoint = types.StringNull()
+ if !data.IpHttpSecureTrustpoint.IsNull() && !data.IpHttpSecureTrustpoint.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ip/Cisco-IOS-XE-http:http/secure-trustpoint", data.IpHttpSecureTrustpoint.ValueString())
}
- if value := res.Get(prefix + "ip.Cisco-IOS-XE-http:http.tls-version"); value.Exists() && !data.IpHttpTlsVersion.IsNull() {
- data.IpHttpTlsVersion = types.StringValue(value.String())
- } else {
- data.IpHttpTlsVersion = types.StringNull()
+ if !data.IpHttpTlsVersion.IsNull() && !data.IpHttpTlsVersion.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ip/Cisco-IOS-XE-http:http/tls-version", data.IpHttpTlsVersion.ValueString())
}
- if value := res.Get(prefix + "ip.Cisco-IOS-XE-http:http.client.secure-trustpoint"); value.Exists() && !data.IpHttpClientSecureTrustpoint.IsNull() {
- data.IpHttpClientSecureTrustpoint = types.StringValue(value.String())
- } else {
- data.IpHttpClientSecureTrustpoint = types.StringNull()
+ if !data.IpHttpClientSecureTrustpoint.IsNull() && !data.IpHttpClientSecureTrustpoint.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ip/Cisco-IOS-XE-http:http/client/secure-trustpoint", data.IpHttpClientSecureTrustpoint.ValueString())
}
- if value := res.Get(prefix + "ip.Cisco-IOS-XE-http:http.client.source-interface"); value.Exists() && !data.IpHttpClientSourceInterface.IsNull() {
- data.IpHttpClientSourceInterface = types.StringValue(value.String())
- } else {
- data.IpHttpClientSourceInterface = types.StringNull()
+ if !data.IpHttpClientSourceInterface.IsNull() && !data.IpHttpClientSourceInterface.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ip/Cisco-IOS-XE-http:http/client/source-interface", data.IpHttpClientSourceInterface.ValueString())
}
- if value := res.Get(prefix + "ip.Cisco-IOS-XE-http:http.secure-active-session-modules"); value.Exists() && !data.IpHttpSecureActiveSessionModules.IsNull() {
- data.IpHttpSecureActiveSessionModules = types.StringValue(value.String())
- } else {
- data.IpHttpSecureActiveSessionModules = types.StringNull()
+ if !data.IpHttpSecureActiveSessionModules.IsNull() && !data.IpHttpSecureActiveSessionModules.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ip/Cisco-IOS-XE-http:http/secure-active-session-modules", data.IpHttpSecureActiveSessionModules.ValueString())
}
- if value := res.Get(prefix + "ip.Cisco-IOS-XE-http:http.max-connections"); value.Exists() && !data.IpHttpMaxConnections.IsNull() {
- data.IpHttpMaxConnections = types.Int64Value(value.Int())
- } else {
- data.IpHttpMaxConnections = types.Int64Null()
+ if !data.IpHttpMaxConnections.IsNull() && !data.IpHttpMaxConnections.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ip/Cisco-IOS-XE-http:http/max-connections", strconv.FormatInt(data.IpHttpMaxConnections.ValueInt64(), 10))
}
- if value := res.Get(prefix + "ip.Cisco-IOS-XE-http:http.active-session-modules"); value.Exists() && !data.IpHttpActiveSessionModules.IsNull() {
- data.IpHttpActiveSessionModules = types.StringValue(value.String())
- } else {
- data.IpHttpActiveSessionModules = types.StringNull()
+ if !data.IpHttpActiveSessionModules.IsNull() && !data.IpHttpActiveSessionModules.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ip/Cisco-IOS-XE-http:http/active-session-modules", data.IpHttpActiveSessionModules.ValueString())
}
- if value := res.Get(prefix + "ip.name-server.no-vrf-ordered"); value.Exists() && !data.IpNameServers.IsNull() {
- data.IpNameServers = helpers.GetStringList(value.Array())
- } else {
- data.IpNameServers = types.ListNull(types.StringType)
+ if !data.IpNameServers.IsNull() && !data.IpNameServers.IsUnknown() {
+ var values []string
+ data.IpNameServers.ElementsAs(ctx, &values, false)
+ for _, v := range values {
+ body = helpers.AppendFromXPath(body, data.getXPath()+"/ip/name-server/no-vrf-ordered", v)
+ }
}
- for i := range data.IpNameServersVrf {
- keys := [...]string{"word"}
- keyValues := [...]string{data.IpNameServersVrf[i].Vrf.ValueString()}
-
- var r gjson.Result
- res.Get(prefix + "ip.name-server.vrf").ForEach(
- func(_, v gjson.Result) bool {
- found := false
- for ik := range keys {
- if v.Get(keys[ik]).String() == keyValues[ik] {
- found = true
- continue
- }
- found = false
- break
- }
- if found {
- r = v
- return false
+ if len(data.IpNameServersVrf) > 0 {
+ for _, item := range data.IpNameServersVrf {
+ cBody := netconf.Body{}
+ if !item.Vrf.IsNull() && !item.Vrf.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "word", item.Vrf.ValueString())
+ }
+ if !item.Servers.IsNull() && !item.Servers.IsUnknown() {
+ var values []string
+ item.Servers.ElementsAs(ctx, &values, false)
+ for _, v := range values {
+ cBody = helpers.AppendFromXPath(cBody, "server-ip-list-ordered", v)
}
- return true
- },
- )
- if value := r.Get("word"); value.Exists() && !data.IpNameServersVrf[i].Vrf.IsNull() {
- data.IpNameServersVrf[i].Vrf = types.StringValue(value.String())
- } else {
- data.IpNameServersVrf[i].Vrf = types.StringNull()
- }
- if value := r.Get("server-ip-list-ordered"); value.Exists() && !data.IpNameServersVrf[i].Servers.IsNull() {
- data.IpNameServersVrf[i].Servers = helpers.GetStringList(value.Array())
- } else {
- data.IpNameServersVrf[i].Servers = types.ListNull(types.StringType)
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/ip/name-server/vrf", cBody.Res())
}
}
- if value := res.Get(prefix + "ip.domain.lookup-settings.lookup.source-interface.Loopback"); value.Exists() && !data.IpDomainLookupSourceInterfaceLoopback.IsNull() {
- data.IpDomainLookupSourceInterfaceLoopback = types.Int64Value(value.Int())
- } else {
- data.IpDomainLookupSourceInterfaceLoopback = types.Int64Null()
+ if !data.IpDomainLookupSourceInterfaceLoopback.IsNull() && !data.IpDomainLookupSourceInterfaceLoopback.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ip/domain/lookup-settings/lookup/source-interface/Loopback", strconv.FormatInt(data.IpDomainLookupSourceInterfaceLoopback.ValueInt64(), 10))
}
- if value := res.Get(prefix + "ip.domain.lookup-settings.lookup.source-interface.Vlan"); value.Exists() && !data.IpDomainLookupSourceInterfaceVlan.IsNull() {
- data.IpDomainLookupSourceInterfaceVlan = types.Int64Value(value.Int())
- } else {
- data.IpDomainLookupSourceInterfaceVlan = types.Int64Null()
+ if !data.IpDomainLookupSourceInterfaceVlan.IsNull() && !data.IpDomainLookupSourceInterfaceVlan.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ip/domain/lookup-settings/lookup/source-interface/Vlan", strconv.FormatInt(data.IpDomainLookupSourceInterfaceVlan.ValueInt64(), 10))
}
- if value := res.Get(prefix + "ip.domain.lookup-settings.lookup.source-interface.GigabitEthernet"); value.Exists() && !data.IpDomainLookupSourceInterfaceGigabitEthernet.IsNull() {
- data.IpDomainLookupSourceInterfaceGigabitEthernet = types.StringValue(value.String())
- } else {
- data.IpDomainLookupSourceInterfaceGigabitEthernet = types.StringNull()
+ if !data.IpDomainLookupSourceInterfaceGigabitEthernet.IsNull() && !data.IpDomainLookupSourceInterfaceGigabitEthernet.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ip/domain/lookup-settings/lookup/source-interface/GigabitEthernet", data.IpDomainLookupSourceInterfaceGigabitEthernet.ValueString())
}
- if value := res.Get(prefix + "ip.domain.lookup-settings.lookup.source-interface.TwoGigabitEthernet"); value.Exists() && !data.IpDomainLookupSourceInterfaceTwoGigabitEthernet.IsNull() {
- data.IpDomainLookupSourceInterfaceTwoGigabitEthernet = types.StringValue(value.String())
- } else {
- data.IpDomainLookupSourceInterfaceTwoGigabitEthernet = types.StringNull()
+ if !data.IpDomainLookupSourceInterfaceTwoGigabitEthernet.IsNull() && !data.IpDomainLookupSourceInterfaceTwoGigabitEthernet.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ip/domain/lookup-settings/lookup/source-interface/TwoGigabitEthernet", data.IpDomainLookupSourceInterfaceTwoGigabitEthernet.ValueString())
}
- if value := res.Get(prefix + "ip.domain.lookup-settings.lookup.source-interface.FiveGigabitEthernet"); value.Exists() && !data.IpDomainLookupSourceInterfaceFiveGigabitEthernet.IsNull() {
- data.IpDomainLookupSourceInterfaceFiveGigabitEthernet = types.StringValue(value.String())
- } else {
- data.IpDomainLookupSourceInterfaceFiveGigabitEthernet = types.StringNull()
+ if !data.IpDomainLookupSourceInterfaceFiveGigabitEthernet.IsNull() && !data.IpDomainLookupSourceInterfaceFiveGigabitEthernet.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ip/domain/lookup-settings/lookup/source-interface/FiveGigabitEthernet", data.IpDomainLookupSourceInterfaceFiveGigabitEthernet.ValueString())
}
- if value := res.Get(prefix + "ip.domain.lookup-settings.lookup.source-interface.TenGigabitEthernet"); value.Exists() && !data.IpDomainLookupSourceInterfaceTenGigabitEthernet.IsNull() {
- data.IpDomainLookupSourceInterfaceTenGigabitEthernet = types.StringValue(value.String())
- } else {
- data.IpDomainLookupSourceInterfaceTenGigabitEthernet = types.StringNull()
+ if !data.IpDomainLookupSourceInterfaceTenGigabitEthernet.IsNull() && !data.IpDomainLookupSourceInterfaceTenGigabitEthernet.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ip/domain/lookup-settings/lookup/source-interface/TenGigabitEthernet", data.IpDomainLookupSourceInterfaceTenGigabitEthernet.ValueString())
}
- if value := res.Get(prefix + "ip.domain.lookup-settings.lookup.source-interface.TwentyFiveGigE"); value.Exists() && !data.IpDomainLookupSourceInterfaceTwentyFiveGigabitEthernet.IsNull() {
- data.IpDomainLookupSourceInterfaceTwentyFiveGigabitEthernet = types.StringValue(value.String())
- } else {
- data.IpDomainLookupSourceInterfaceTwentyFiveGigabitEthernet = types.StringNull()
+ if !data.IpDomainLookupSourceInterfaceTwentyFiveGigabitEthernet.IsNull() && !data.IpDomainLookupSourceInterfaceTwentyFiveGigabitEthernet.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ip/domain/lookup-settings/lookup/source-interface/TwentyFiveGigE", data.IpDomainLookupSourceInterfaceTwentyFiveGigabitEthernet.ValueString())
}
- if value := res.Get(prefix + "ip.domain.lookup-settings.lookup.source-interface.FortyGigabitEthernet"); value.Exists() && !data.IpDomainLookupSourceInterfaceFortyGigabitEthernet.IsNull() {
- data.IpDomainLookupSourceInterfaceFortyGigabitEthernet = types.StringValue(value.String())
- } else {
- data.IpDomainLookupSourceInterfaceFortyGigabitEthernet = types.StringNull()
+ if !data.IpDomainLookupSourceInterfaceFortyGigabitEthernet.IsNull() && !data.IpDomainLookupSourceInterfaceFortyGigabitEthernet.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ip/domain/lookup-settings/lookup/source-interface/FortyGigabitEthernet", data.IpDomainLookupSourceInterfaceFortyGigabitEthernet.ValueString())
}
- if value := res.Get(prefix + "ip.domain.lookup-settings.lookup.source-interface.HundredGigE"); value.Exists() && !data.IpDomainLookupSourceInterfaceHundredGigabitEthernet.IsNull() {
- data.IpDomainLookupSourceInterfaceHundredGigabitEthernet = types.StringValue(value.String())
- } else {
- data.IpDomainLookupSourceInterfaceHundredGigabitEthernet = types.StringNull()
+ if !data.IpDomainLookupSourceInterfaceHundredGigabitEthernet.IsNull() && !data.IpDomainLookupSourceInterfaceHundredGigabitEthernet.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ip/domain/lookup-settings/lookup/source-interface/HundredGigE", data.IpDomainLookupSourceInterfaceHundredGigabitEthernet.ValueString())
}
- if value := res.Get(prefix + "cisp.enable"); !data.CispEnable.IsNull() {
- if value.Exists() {
- data.CispEnable = types.BoolValue(true)
+ if !data.CispEnable.IsNull() && !data.CispEnable.IsUnknown() {
+ if data.CispEnable.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/cisp/enable", "")
} else {
- data.CispEnable = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/cisp/enable")
}
- } else {
- data.CispEnable = types.BoolNull()
}
- if value := res.Get(prefix + "epm.logging"); !data.EpmLogging.IsNull() {
- if value.Exists() {
- data.EpmLogging = types.BoolValue(true)
+ if !data.EpmLogging.IsNull() && !data.EpmLogging.IsUnknown() {
+ if data.EpmLogging.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/epm/logging", "")
} else {
- data.EpmLogging = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/epm/logging")
}
- } else {
- data.EpmLogging = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-sanet:access-session.mac-move.deny"); !data.AccessSessionMacMoveDeny.IsNull() {
- if value.Exists() {
- data.AccessSessionMacMoveDeny = types.BoolValue(true)
+ if !data.AccessSessionMacMoveDeny.IsNull() && !data.AccessSessionMacMoveDeny.IsUnknown() {
+ if data.AccessSessionMacMoveDeny.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-sanet:access-session/mac-move/deny", "")
} else {
- data.AccessSessionMacMoveDeny = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-sanet:access-session/mac-move/deny")
}
- } else {
- data.AccessSessionMacMoveDeny = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-diagnostics:diagnostic.bootup.level"); value.Exists() && !data.DiagnosticBootupLevel.IsNull() {
- data.DiagnosticBootupLevel = types.StringValue(value.String())
- } else {
- data.DiagnosticBootupLevel = types.StringNull()
+ if !data.DiagnosticBootupLevel.IsNull() && !data.DiagnosticBootupLevel.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-diagnostics:diagnostic/bootup/level", data.DiagnosticBootupLevel.ValueString())
}
- if value := res.Get(prefix + "memory.free.low-watermark.processor"); value.Exists() && !data.MemoryFreeLowWatermarkProcessor.IsNull() {
- data.MemoryFreeLowWatermarkProcessor = types.Int64Value(value.Int())
- } else {
- data.MemoryFreeLowWatermarkProcessor = types.Int64Null()
+ if !data.MemoryFreeLowWatermarkProcessor.IsNull() && !data.MemoryFreeLowWatermarkProcessor.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/memory/free/low-watermark/processor", strconv.FormatInt(data.MemoryFreeLowWatermarkProcessor.ValueInt64(), 10))
}
- if value := res.Get(prefix + "archive.path"); value.Exists() && !data.ArchivePath.IsNull() {
- data.ArchivePath = types.StringValue(value.String())
- } else {
- data.ArchivePath = types.StringNull()
+ if !data.ArchivePath.IsNull() && !data.ArchivePath.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/archive/path", data.ArchivePath.ValueString())
}
- if value := res.Get(prefix + "archive.maximum"); value.Exists() && !data.ArchiveMaximum.IsNull() {
- data.ArchiveMaximum = types.Int64Value(value.Int())
- } else {
- data.ArchiveMaximum = types.Int64Null()
+ if !data.ArchiveMaximum.IsNull() && !data.ArchiveMaximum.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/archive/maximum", strconv.FormatInt(data.ArchiveMaximum.ValueInt64(), 10))
}
- if value := res.Get(prefix + "archive.write-memory"); !data.ArchiveWriteMemory.IsNull() {
- if value.Exists() {
- data.ArchiveWriteMemory = types.BoolValue(true)
+ if !data.ArchiveWriteMemory.IsNull() && !data.ArchiveWriteMemory.IsUnknown() {
+ if data.ArchiveWriteMemory.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/archive/write-memory", "")
} else {
- data.ArchiveWriteMemory = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/archive/write-memory")
}
- } else {
- data.ArchiveWriteMemory = types.BoolNull()
}
- if value := res.Get(prefix + "archive.time-period"); value.Exists() && !data.ArchiveTimePeriod.IsNull() {
- data.ArchiveTimePeriod = types.Int64Value(value.Int())
- } else {
- data.ArchiveTimePeriod = types.Int64Null()
+ if !data.ArchiveTimePeriod.IsNull() && !data.ArchiveTimePeriod.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/archive/time-period", strconv.FormatInt(data.ArchiveTimePeriod.ValueInt64(), 10))
}
- if value := res.Get(prefix + "archive.log.config.logging.enable"); !data.ArchiveLogConfigLoggingEnable.IsNull() {
- if value.Exists() {
- data.ArchiveLogConfigLoggingEnable = types.BoolValue(true)
+ if !data.ArchiveLogConfigLoggingEnable.IsNull() && !data.ArchiveLogConfigLoggingEnable.IsUnknown() {
+ if data.ArchiveLogConfigLoggingEnable.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/archive/log/config/logging/enable", "")
} else {
- data.ArchiveLogConfigLoggingEnable = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/archive/log/config/logging/enable")
}
- } else {
- data.ArchiveLogConfigLoggingEnable = types.BoolNull()
}
- if value := res.Get(prefix + "archive.log.config.logging.size"); value.Exists() && !data.ArchiveLogConfigLoggingSize.IsNull() {
- data.ArchiveLogConfigLoggingSize = types.Int64Value(value.Int())
- } else {
- data.ArchiveLogConfigLoggingSize = types.Int64Null()
+ if !data.ArchiveLogConfigLoggingSize.IsNull() && !data.ArchiveLogConfigLoggingSize.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/archive/log/config/logging/size", strconv.FormatInt(data.ArchiveLogConfigLoggingSize.ValueInt64(), 10))
}
- if value := res.Get(prefix + "redundancy"); !data.Redundancy.IsNull() {
- if value.Exists() {
- data.Redundancy = types.BoolValue(true)
+ if !data.Redundancy.IsNull() && !data.Redundancy.IsUnknown() {
+ if data.Redundancy.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/redundancy", "")
} else {
- data.Redundancy = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/redundancy")
}
- } else {
- data.Redundancy = types.BoolNull()
}
- if value := res.Get(prefix + "redundancy.mode"); value.Exists() && !data.RedundancyMode.IsNull() {
- data.RedundancyMode = types.StringValue(value.String())
- } else {
- data.RedundancyMode = types.StringNull()
+ if !data.RedundancyMode.IsNull() && !data.RedundancyMode.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/redundancy/mode", data.RedundancyMode.ValueString())
}
- if value := res.Get(prefix + "transceivers.type.all.monitoring-enable.monitoring"); !data.TransceiverTypeAllMonitoring.IsNull() {
- if value.Exists() {
- data.TransceiverTypeAllMonitoring = types.BoolValue(true)
+ if !data.TransceiverTypeAllMonitoring.IsNull() && !data.TransceiverTypeAllMonitoring.IsUnknown() {
+ if data.TransceiverTypeAllMonitoring.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/transceivers/type/all/monitoring-enable/monitoring", "")
} else {
- data.TransceiverTypeAllMonitoring = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/transceivers/type/all/monitoring-enable/monitoring")
}
- } else {
- data.TransceiverTypeAllMonitoring = types.BoolNull()
}
- if value := res.Get(prefix + "ip.forward-protocol-v2.nd"); !data.IpForwardProtocolNd.IsNull() {
- if value.Exists() {
- data.IpForwardProtocolNd = types.BoolValue(value.Bool())
- }
- } else {
- data.IpForwardProtocolNd = types.BoolNull()
+ if !data.IpForwardProtocolNd.IsNull() && !data.IpForwardProtocolNd.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ip/forward-protocol-v2/nd", data.IpForwardProtocolNd.ValueBool())
}
- if value := res.Get(prefix + "ip.scp.server.enable"); !data.IpScpServerEnable.IsNull() {
- if value.Exists() {
- data.IpScpServerEnable = types.BoolValue(true)
+ if !data.IpScpServerEnable.IsNull() && !data.IpScpServerEnable.IsUnknown() {
+ if data.IpScpServerEnable.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ip/scp/server/enable", "")
} else {
- data.IpScpServerEnable = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/ip/scp/server/enable")
}
- } else {
- data.IpScpServerEnable = types.BoolNull()
}
- if value := res.Get(prefix + "ip.ssh.ssh-version"); value.Exists() && !data.IpSshVersion.IsNull() {
- data.IpSshVersion = types.StringValue(value.String())
- } else {
- data.IpSshVersion = types.StringNull()
+ if !data.IpSshVersion.IsNull() && !data.IpSshVersion.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ip/ssh/ssh-version", data.IpSshVersion.ValueString())
}
- if value := res.Get(prefix + "ip.ssh.version"); value.Exists() && !data.IpSshVersionLegacy.IsNull() {
- data.IpSshVersionLegacy = types.Int64Value(value.Int())
- } else {
- data.IpSshVersionLegacy = types.Int64Null()
+ if !data.IpSshVersionLegacy.IsNull() && !data.IpSshVersionLegacy.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ip/ssh/version", strconv.FormatInt(data.IpSshVersionLegacy.ValueInt64(), 10))
}
- if value := res.Get(prefix + "ip.ssh.time-out"); value.Exists() && !data.IpSshTimeOut.IsNull() {
- data.IpSshTimeOut = types.Int64Value(value.Int())
- } else {
- data.IpSshTimeOut = types.Int64Null()
+ if !data.IpSshTimeOut.IsNull() && !data.IpSshTimeOut.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ip/ssh/time-out", strconv.FormatInt(data.IpSshTimeOut.ValueInt64(), 10))
}
- if value := res.Get(prefix + "ip.ssh.authentication-retries"); value.Exists() && !data.IpSshAuthenticationRetries.IsNull() {
- data.IpSshAuthenticationRetries = types.Int64Value(value.Int())
- } else {
- data.IpSshAuthenticationRetries = types.Int64Null()
+ if !data.IpSshAuthenticationRetries.IsNull() && !data.IpSshAuthenticationRetries.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ip/ssh/authentication-retries", strconv.FormatInt(data.IpSshAuthenticationRetries.ValueInt64(), 10))
}
- if value := res.Get(prefix + "ip.ssh.source-interface-config.Loopback"); value.Exists() && !data.IpSshSourceInterfaceLoopback.IsNull() {
- data.IpSshSourceInterfaceLoopback = types.Int64Value(value.Int())
- } else {
- data.IpSshSourceInterfaceLoopback = types.Int64Null()
+ if !data.IpSshSourceInterfaceLoopback.IsNull() && !data.IpSshSourceInterfaceLoopback.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ip/ssh/source-interface-config/Loopback", strconv.FormatInt(data.IpSshSourceInterfaceLoopback.ValueInt64(), 10))
}
- if value := res.Get(prefix + "ip.ssh.source-interface-config.Vlan"); value.Exists() && !data.IpSshSourceInterfaceVlan.IsNull() {
- data.IpSshSourceInterfaceVlan = types.Int64Value(value.Int())
- } else {
- data.IpSshSourceInterfaceVlan = types.Int64Null()
+ if !data.IpSshSourceInterfaceVlan.IsNull() && !data.IpSshSourceInterfaceVlan.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ip/ssh/source-interface-config/Vlan", strconv.FormatInt(data.IpSshSourceInterfaceVlan.ValueInt64(), 10))
}
- if value := res.Get(prefix + "ip.ssh.source-interface-config.GigabitEthernet"); value.Exists() && !data.IpSshSourceInterfaceGigabitEthernet.IsNull() {
- data.IpSshSourceInterfaceGigabitEthernet = types.StringValue(value.String())
- } else {
- data.IpSshSourceInterfaceGigabitEthernet = types.StringNull()
+ if !data.IpSshSourceInterfaceGigabitEthernet.IsNull() && !data.IpSshSourceInterfaceGigabitEthernet.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ip/ssh/source-interface-config/GigabitEthernet", data.IpSshSourceInterfaceGigabitEthernet.ValueString())
}
- if value := res.Get(prefix + "ip.ssh.source-interface-config.TwoGigabitEthernet"); value.Exists() && !data.IpSshSourceInterfaceTwoGigabitEthernet.IsNull() {
- data.IpSshSourceInterfaceTwoGigabitEthernet = types.StringValue(value.String())
- } else {
- data.IpSshSourceInterfaceTwoGigabitEthernet = types.StringNull()
+ if !data.IpSshSourceInterfaceTwoGigabitEthernet.IsNull() && !data.IpSshSourceInterfaceTwoGigabitEthernet.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ip/ssh/source-interface-config/TwoGigabitEthernet", data.IpSshSourceInterfaceTwoGigabitEthernet.ValueString())
}
- if value := res.Get(prefix + "ip.ssh.source-interface-config.FiveGigabitEthernet"); value.Exists() && !data.IpSshSourceInterfaceFiveGigabitEthernet.IsNull() {
- data.IpSshSourceInterfaceFiveGigabitEthernet = types.StringValue(value.String())
- } else {
- data.IpSshSourceInterfaceFiveGigabitEthernet = types.StringNull()
+ if !data.IpSshSourceInterfaceFiveGigabitEthernet.IsNull() && !data.IpSshSourceInterfaceFiveGigabitEthernet.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ip/ssh/source-interface-config/FiveGigabitEthernet", data.IpSshSourceInterfaceFiveGigabitEthernet.ValueString())
}
- if value := res.Get(prefix + "ip.ssh.source-interface-config.TenGigabitEthernet"); value.Exists() && !data.IpSshSourceInterfaceTenGigabitEthernet.IsNull() {
- data.IpSshSourceInterfaceTenGigabitEthernet = types.StringValue(value.String())
- } else {
- data.IpSshSourceInterfaceTenGigabitEthernet = types.StringNull()
+ if !data.IpSshSourceInterfaceTenGigabitEthernet.IsNull() && !data.IpSshSourceInterfaceTenGigabitEthernet.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ip/ssh/source-interface-config/TenGigabitEthernet", data.IpSshSourceInterfaceTenGigabitEthernet.ValueString())
}
- if value := res.Get(prefix + "ip.ssh.source-interface-config.TwentyFiveGigE"); value.Exists() && !data.IpSshSourceInterfaceTwentyFiveGigabitEthernet.IsNull() {
- data.IpSshSourceInterfaceTwentyFiveGigabitEthernet = types.StringValue(value.String())
- } else {
- data.IpSshSourceInterfaceTwentyFiveGigabitEthernet = types.StringNull()
+ if !data.IpSshSourceInterfaceTwentyFiveGigabitEthernet.IsNull() && !data.IpSshSourceInterfaceTwentyFiveGigabitEthernet.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ip/ssh/source-interface-config/TwentyFiveGigE", data.IpSshSourceInterfaceTwentyFiveGigabitEthernet.ValueString())
}
- if value := res.Get(prefix + "ip.ssh.source-interface-config.FortyGigabitEthernet"); value.Exists() && !data.IpSshSourceInterfaceFortyGigabitEthernet.IsNull() {
- data.IpSshSourceInterfaceFortyGigabitEthernet = types.StringValue(value.String())
- } else {
- data.IpSshSourceInterfaceFortyGigabitEthernet = types.StringNull()
+ if !data.IpSshSourceInterfaceFortyGigabitEthernet.IsNull() && !data.IpSshSourceInterfaceFortyGigabitEthernet.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ip/ssh/source-interface-config/FortyGigabitEthernet", data.IpSshSourceInterfaceFortyGigabitEthernet.ValueString())
}
- if value := res.Get(prefix + "ip.ssh.source-interface-config.HundredGigE"); value.Exists() && !data.IpSshSourceInterfaceHundredGigabitEthernet.IsNull() {
- data.IpSshSourceInterfaceHundredGigabitEthernet = types.StringValue(value.String())
- } else {
- data.IpSshSourceInterfaceHundredGigabitEthernet = types.StringNull()
+ if !data.IpSshSourceInterfaceHundredGigabitEthernet.IsNull() && !data.IpSshSourceInterfaceHundredGigabitEthernet.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ip/ssh/source-interface-config/HundredGigE", data.IpSshSourceInterfaceHundredGigabitEthernet.ValueString())
}
- if value := res.Get(prefix + "control-plane.Cisco-IOS-XE-policy:service-policy.input"); value.Exists() && !data.ControlPlaneServicePolicyInput.IsNull() {
- data.ControlPlaneServicePolicyInput = types.StringValue(value.String())
- } else {
- data.ControlPlaneServicePolicyInput = types.StringNull()
+ if !data.ControlPlaneServicePolicyInput.IsNull() && !data.ControlPlaneServicePolicyInput.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/control-plane/Cisco-IOS-XE-policy:service-policy/input", data.ControlPlaneServicePolicyInput.ValueString())
}
- for i := range data.PnpProfiles {
- keys := [...]string{"name"}
- keyValues := [...]string{data.PnpProfiles[i].Name.ValueString()}
-
- var r gjson.Result
- res.Get(prefix + "Cisco-IOS-XE-pnp:pnp.profile").ForEach(
- func(_, v gjson.Result) bool {
- found := false
- for ik := range keys {
- if v.Get(keys[ik]).String() == keyValues[ik] {
- found = true
- continue
- }
- found = false
- break
- }
- if found {
- r = v
- return false
- }
- return true
- },
- )
- if value := r.Get("name"); value.Exists() && !data.PnpProfiles[i].Name.IsNull() {
- data.PnpProfiles[i].Name = types.StringValue(value.String())
- } else {
- data.PnpProfiles[i].Name = types.StringNull()
- }
- if value := r.Get("transport.https.ipv4.ipv4-address"); value.Exists() && !data.PnpProfiles[i].TransportHttpsIpv4Ipv4Address.IsNull() {
- data.PnpProfiles[i].TransportHttpsIpv4Ipv4Address = types.StringValue(value.String())
- } else {
- data.PnpProfiles[i].TransportHttpsIpv4Ipv4Address = types.StringNull()
- }
- if value := r.Get("transport.https.ipv4.port"); value.Exists() && !data.PnpProfiles[i].TransportHttpsIpv4Port.IsNull() {
- data.PnpProfiles[i].TransportHttpsIpv4Port = types.Int64Value(value.Int())
- } else {
- data.PnpProfiles[i].TransportHttpsIpv4Port = types.Int64Null()
+ if len(data.PnpProfiles) > 0 {
+ for _, item := range data.PnpProfiles {
+ cBody := netconf.Body{}
+ if !item.Name.IsNull() && !item.Name.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "name", item.Name.ValueString())
+ }
+ if !item.TransportHttpsIpv4Ipv4Address.IsNull() && !item.TransportHttpsIpv4Ipv4Address.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "transport/https/ipv4/ipv4-address", item.TransportHttpsIpv4Ipv4Address.ValueString())
+ }
+ if !item.TransportHttpsIpv4Port.IsNull() && !item.TransportHttpsIpv4Port.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "transport/https/ipv4/port", strconv.FormatInt(item.TransportHttpsIpv4Port.ValueInt64(), 10))
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-pnp:pnp/profile", cBody.Res())
}
}
- if value := res.Get(prefix + "ip.Cisco-IOS-XE-aaa:tacacs.source-interface.Loopback"); value.Exists() && !data.IpTacacsSourceInterfaceLoopback.IsNull() {
- data.IpTacacsSourceInterfaceLoopback = types.Int64Value(value.Int())
- } else {
- data.IpTacacsSourceInterfaceLoopback = types.Int64Null()
+ if !data.IpTacacsSourceInterfaceLoopback.IsNull() && !data.IpTacacsSourceInterfaceLoopback.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ip/Cisco-IOS-XE-aaa:tacacs/source-interface/Loopback", strconv.FormatInt(data.IpTacacsSourceInterfaceLoopback.ValueInt64(), 10))
}
- if value := res.Get(prefix + "ip.Cisco-IOS-XE-aaa:tacacs.source-interface.Vlan"); value.Exists() && !data.IpTacacsSourceInterfaceVlan.IsNull() {
- data.IpTacacsSourceInterfaceVlan = types.Int64Value(value.Int())
- } else {
- data.IpTacacsSourceInterfaceVlan = types.Int64Null()
+ if !data.IpTacacsSourceInterfaceVlan.IsNull() && !data.IpTacacsSourceInterfaceVlan.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ip/Cisco-IOS-XE-aaa:tacacs/source-interface/Vlan", strconv.FormatInt(data.IpTacacsSourceInterfaceVlan.ValueInt64(), 10))
}
- if value := res.Get(prefix + "ip.Cisco-IOS-XE-aaa:tacacs.source-interface.GigabitEthernet"); value.Exists() && !data.IpTacacsSourceInterfaceGigabitEthernet.IsNull() {
- data.IpTacacsSourceInterfaceGigabitEthernet = types.StringValue(value.String())
- } else {
- data.IpTacacsSourceInterfaceGigabitEthernet = types.StringNull()
+ if !data.IpTacacsSourceInterfaceGigabitEthernet.IsNull() && !data.IpTacacsSourceInterfaceGigabitEthernet.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ip/Cisco-IOS-XE-aaa:tacacs/source-interface/GigabitEthernet", data.IpTacacsSourceInterfaceGigabitEthernet.ValueString())
}
- if value := res.Get(prefix + "ip.Cisco-IOS-XE-aaa:tacacs.source-interface.TwoGigabitEthernet"); value.Exists() && !data.IpTacacsSourceInterfaceTwoGigabitEthernet.IsNull() {
- data.IpTacacsSourceInterfaceTwoGigabitEthernet = types.StringValue(value.String())
- } else {
- data.IpTacacsSourceInterfaceTwoGigabitEthernet = types.StringNull()
+ if !data.IpTacacsSourceInterfaceTwoGigabitEthernet.IsNull() && !data.IpTacacsSourceInterfaceTwoGigabitEthernet.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ip/Cisco-IOS-XE-aaa:tacacs/source-interface/TwoGigabitEthernet", data.IpTacacsSourceInterfaceTwoGigabitEthernet.ValueString())
}
- if value := res.Get(prefix + "ip.Cisco-IOS-XE-aaa:tacacs.source-interface.FiveGigabitEthernet"); value.Exists() && !data.IpTacacsSourceInterfaceFiveGigabitEthernet.IsNull() {
- data.IpTacacsSourceInterfaceFiveGigabitEthernet = types.StringValue(value.String())
- } else {
- data.IpTacacsSourceInterfaceFiveGigabitEthernet = types.StringNull()
+ if !data.IpTacacsSourceInterfaceFiveGigabitEthernet.IsNull() && !data.IpTacacsSourceInterfaceFiveGigabitEthernet.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ip/Cisco-IOS-XE-aaa:tacacs/source-interface/FiveGigabitEthernet", data.IpTacacsSourceInterfaceFiveGigabitEthernet.ValueString())
}
- if value := res.Get(prefix + "ip.Cisco-IOS-XE-aaa:tacacs.source-interface.TenGigabitEthernet"); value.Exists() && !data.IpTacacsSourceInterfaceTenGigabitEthernet.IsNull() {
- data.IpTacacsSourceInterfaceTenGigabitEthernet = types.StringValue(value.String())
- } else {
- data.IpTacacsSourceInterfaceTenGigabitEthernet = types.StringNull()
+ if !data.IpTacacsSourceInterfaceTenGigabitEthernet.IsNull() && !data.IpTacacsSourceInterfaceTenGigabitEthernet.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ip/Cisco-IOS-XE-aaa:tacacs/source-interface/TenGigabitEthernet", data.IpTacacsSourceInterfaceTenGigabitEthernet.ValueString())
}
- if value := res.Get(prefix + "ip.Cisco-IOS-XE-aaa:tacacs.source-interface.TwentyFiveGigE"); value.Exists() && !data.IpTacacsSourceInterfaceTwentyFiveGigabitEthernet.IsNull() {
- data.IpTacacsSourceInterfaceTwentyFiveGigabitEthernet = types.StringValue(value.String())
- } else {
- data.IpTacacsSourceInterfaceTwentyFiveGigabitEthernet = types.StringNull()
+ if !data.IpTacacsSourceInterfaceTwentyFiveGigabitEthernet.IsNull() && !data.IpTacacsSourceInterfaceTwentyFiveGigabitEthernet.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ip/Cisco-IOS-XE-aaa:tacacs/source-interface/TwentyFiveGigE", data.IpTacacsSourceInterfaceTwentyFiveGigabitEthernet.ValueString())
}
- if value := res.Get(prefix + "ip.Cisco-IOS-XE-aaa:tacacs.source-interface.FortyGigabitEthernet"); value.Exists() && !data.IpTacacsSourceInterfaceFortyGigabitEthernet.IsNull() {
- data.IpTacacsSourceInterfaceFortyGigabitEthernet = types.StringValue(value.String())
- } else {
- data.IpTacacsSourceInterfaceFortyGigabitEthernet = types.StringNull()
+ if !data.IpTacacsSourceInterfaceFortyGigabitEthernet.IsNull() && !data.IpTacacsSourceInterfaceFortyGigabitEthernet.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ip/Cisco-IOS-XE-aaa:tacacs/source-interface/FortyGigabitEthernet", data.IpTacacsSourceInterfaceFortyGigabitEthernet.ValueString())
}
- if value := res.Get(prefix + "ip.Cisco-IOS-XE-aaa:tacacs.source-interface.HundredGigE"); value.Exists() && !data.IpTacacsSourceInterfaceHundredGigabitEthernet.IsNull() {
- data.IpTacacsSourceInterfaceHundredGigabitEthernet = types.StringValue(value.String())
- } else {
- data.IpTacacsSourceInterfaceHundredGigabitEthernet = types.StringNull()
+ if !data.IpTacacsSourceInterfaceHundredGigabitEthernet.IsNull() && !data.IpTacacsSourceInterfaceHundredGigabitEthernet.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ip/Cisco-IOS-XE-aaa:tacacs/source-interface/HundredGigE", data.IpTacacsSourceInterfaceHundredGigabitEthernet.ValueString())
}
- if value := res.Get(prefix + "ip.Cisco-IOS-XE-aaa:tacacs.source-interface.vrf"); value.Exists() && !data.IpTacacsSourceInterfaceVrf.IsNull() {
- data.IpTacacsSourceInterfaceVrf = types.StringValue(value.String())
- } else {
- data.IpTacacsSourceInterfaceVrf = types.StringNull()
+ if !data.IpTacacsSourceInterfaceVrf.IsNull() && !data.IpTacacsSourceInterfaceVrf.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ip/Cisco-IOS-XE-aaa:tacacs/source-interface/vrf", data.IpTacacsSourceInterfaceVrf.ValueString())
}
- if value := res.Get(prefix + "ip.Cisco-IOS-XE-aaa:radius.source-interface.Loopback"); value.Exists() && !data.IpRadiusSourceInterfaceLoopback.IsNull() {
- data.IpRadiusSourceInterfaceLoopback = types.Int64Value(value.Int())
- } else {
- data.IpRadiusSourceInterfaceLoopback = types.Int64Null()
+ if !data.IpRadiusSourceInterfaceLoopback.IsNull() && !data.IpRadiusSourceInterfaceLoopback.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ip/Cisco-IOS-XE-aaa:radius/source-interface/Loopback", strconv.FormatInt(data.IpRadiusSourceInterfaceLoopback.ValueInt64(), 10))
}
- if value := res.Get(prefix + "ip.Cisco-IOS-XE-aaa:radius.source-interface.Vlan"); value.Exists() && !data.IpRadiusSourceInterfaceVlan.IsNull() {
- data.IpRadiusSourceInterfaceVlan = types.Int64Value(value.Int())
- } else {
- data.IpRadiusSourceInterfaceVlan = types.Int64Null()
+ if !data.IpRadiusSourceInterfaceVlan.IsNull() && !data.IpRadiusSourceInterfaceVlan.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ip/Cisco-IOS-XE-aaa:radius/source-interface/Vlan", strconv.FormatInt(data.IpRadiusSourceInterfaceVlan.ValueInt64(), 10))
}
- if value := res.Get(prefix + "ip.Cisco-IOS-XE-aaa:radius.source-interface.GigabitEthernet"); value.Exists() && !data.IpRadiusSourceInterfaceGigabitEthernet.IsNull() {
- data.IpRadiusSourceInterfaceGigabitEthernet = types.StringValue(value.String())
- } else {
- data.IpRadiusSourceInterfaceGigabitEthernet = types.StringNull()
+ if !data.IpRadiusSourceInterfaceGigabitEthernet.IsNull() && !data.IpRadiusSourceInterfaceGigabitEthernet.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ip/Cisco-IOS-XE-aaa:radius/source-interface/GigabitEthernet", data.IpRadiusSourceInterfaceGigabitEthernet.ValueString())
}
- if value := res.Get(prefix + "ip.Cisco-IOS-XE-aaa:radius.source-interface.TwoGigabitEthernet"); value.Exists() && !data.IpRadiusSourceInterfaceTwoGigabitEthernet.IsNull() {
- data.IpRadiusSourceInterfaceTwoGigabitEthernet = types.StringValue(value.String())
- } else {
- data.IpRadiusSourceInterfaceTwoGigabitEthernet = types.StringNull()
+ if !data.IpRadiusSourceInterfaceTwoGigabitEthernet.IsNull() && !data.IpRadiusSourceInterfaceTwoGigabitEthernet.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ip/Cisco-IOS-XE-aaa:radius/source-interface/TwoGigabitEthernet", data.IpRadiusSourceInterfaceTwoGigabitEthernet.ValueString())
}
- if value := res.Get(prefix + "ip.Cisco-IOS-XE-aaa:radius.source-interface.FiveGigabitEthernet"); value.Exists() && !data.IpRadiusSourceInterfaceFiveGigabitEthernet.IsNull() {
- data.IpRadiusSourceInterfaceFiveGigabitEthernet = types.StringValue(value.String())
- } else {
- data.IpRadiusSourceInterfaceFiveGigabitEthernet = types.StringNull()
+ if !data.IpRadiusSourceInterfaceFiveGigabitEthernet.IsNull() && !data.IpRadiusSourceInterfaceFiveGigabitEthernet.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ip/Cisco-IOS-XE-aaa:radius/source-interface/FiveGigabitEthernet", data.IpRadiusSourceInterfaceFiveGigabitEthernet.ValueString())
}
- if value := res.Get(prefix + "ip.Cisco-IOS-XE-aaa:radius.source-interface.TenGigabitEthernet"); value.Exists() && !data.IpRadiusSourceInterfaceTenGigabitEthernet.IsNull() {
- data.IpRadiusSourceInterfaceTenGigabitEthernet = types.StringValue(value.String())
- } else {
- data.IpRadiusSourceInterfaceTenGigabitEthernet = types.StringNull()
+ if !data.IpRadiusSourceInterfaceTenGigabitEthernet.IsNull() && !data.IpRadiusSourceInterfaceTenGigabitEthernet.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ip/Cisco-IOS-XE-aaa:radius/source-interface/TenGigabitEthernet", data.IpRadiusSourceInterfaceTenGigabitEthernet.ValueString())
}
- if value := res.Get(prefix + "ip.Cisco-IOS-XE-aaa:radius.source-interface.TwentyFiveGigE"); value.Exists() && !data.IpRadiusSourceInterfaceTwentyFiveGigabitEthernet.IsNull() {
- data.IpRadiusSourceInterfaceTwentyFiveGigabitEthernet = types.StringValue(value.String())
- } else {
- data.IpRadiusSourceInterfaceTwentyFiveGigabitEthernet = types.StringNull()
+ if !data.IpRadiusSourceInterfaceTwentyFiveGigabitEthernet.IsNull() && !data.IpRadiusSourceInterfaceTwentyFiveGigabitEthernet.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ip/Cisco-IOS-XE-aaa:radius/source-interface/TwentyFiveGigE", data.IpRadiusSourceInterfaceTwentyFiveGigabitEthernet.ValueString())
}
- if value := res.Get(prefix + "ip.Cisco-IOS-XE-aaa:radius.source-interface.FortyGigabitEthernet"); value.Exists() && !data.IpRadiusSourceInterfaceFortyGigabitEthernet.IsNull() {
- data.IpRadiusSourceInterfaceFortyGigabitEthernet = types.StringValue(value.String())
- } else {
- data.IpRadiusSourceInterfaceFortyGigabitEthernet = types.StringNull()
+ if !data.IpRadiusSourceInterfaceFortyGigabitEthernet.IsNull() && !data.IpRadiusSourceInterfaceFortyGigabitEthernet.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ip/Cisco-IOS-XE-aaa:radius/source-interface/FortyGigabitEthernet", data.IpRadiusSourceInterfaceFortyGigabitEthernet.ValueString())
}
- if value := res.Get(prefix + "ip.Cisco-IOS-XE-aaa:radius.source-interface.HundredGigE"); value.Exists() && !data.IpRadiusSourceInterfaceHundredGigabitEthernet.IsNull() {
- data.IpRadiusSourceInterfaceHundredGigabitEthernet = types.StringValue(value.String())
- } else {
- data.IpRadiusSourceInterfaceHundredGigabitEthernet = types.StringNull()
+ if !data.IpRadiusSourceInterfaceHundredGigabitEthernet.IsNull() && !data.IpRadiusSourceInterfaceHundredGigabitEthernet.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ip/Cisco-IOS-XE-aaa:radius/source-interface/HundredGigE", data.IpRadiusSourceInterfaceHundredGigabitEthernet.ValueString())
}
- if value := res.Get(prefix + "ip.Cisco-IOS-XE-aaa:radius.source-interface.vrf"); value.Exists() && !data.IpRadiusSourceInterfaceVrf.IsNull() {
- data.IpRadiusSourceInterfaceVrf = types.StringValue(value.String())
- } else {
- data.IpRadiusSourceInterfaceVrf = types.StringNull()
+ if !data.IpRadiusSourceInterfaceVrf.IsNull() && !data.IpRadiusSourceInterfaceVrf.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ip/Cisco-IOS-XE-aaa:radius/source-interface/vrf", data.IpRadiusSourceInterfaceVrf.ValueString())
}
- for i := range data.BootSystemFlashFiles {
- keys := [...]string{"flash-leaf"}
- keyValues := [...]string{data.BootSystemFlashFiles[i].Path.ValueString()}
-
- var r gjson.Result
- res.Get(prefix + "boot.system.flash.flash-list-ordered-by-user").ForEach(
- func(_, v gjson.Result) bool {
- found := false
- for ik := range keys {
- if v.Get(keys[ik]).String() == keyValues[ik] {
- found = true
- continue
- }
- found = false
- break
- }
- if found {
- r = v
- return false
- }
- return true
- },
- )
- if value := r.Get("flash-leaf"); value.Exists() && !data.BootSystemFlashFiles[i].Path.IsNull() {
- data.BootSystemFlashFiles[i].Path = types.StringValue(value.String())
- } else {
- data.BootSystemFlashFiles[i].Path = types.StringNull()
+ if len(data.BootSystemFlashFiles) > 0 {
+ for _, item := range data.BootSystemFlashFiles {
+ cBody := netconf.Body{}
+ if !item.Path.IsNull() && !item.Path.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "flash-leaf", item.Path.ValueString())
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/boot/system/flash/flash-list-ordered-by-user", cBody.Res())
}
}
- for i := range data.BootSystemBootfiles {
- keys := [...]string{"filename"}
- keyValues := [...]string{data.BootSystemBootfiles[i].Path.ValueString()}
-
- var r gjson.Result
- res.Get(prefix + "boot.system.bootfile.filename-list-ordered-by-user").ForEach(
- func(_, v gjson.Result) bool {
- found := false
- for ik := range keys {
- if v.Get(keys[ik]).String() == keyValues[ik] {
- found = true
- continue
- }
- found = false
- break
- }
- if found {
- r = v
- return false
- }
- return true
- },
- )
- if value := r.Get("filename"); value.Exists() && !data.BootSystemBootfiles[i].Path.IsNull() {
- data.BootSystemBootfiles[i].Path = types.StringValue(value.String())
- } else {
- data.BootSystemBootfiles[i].Path = types.StringNull()
+ if len(data.BootSystemBootfiles) > 0 {
+ for _, item := range data.BootSystemBootfiles {
+ cBody := netconf.Body{}
+ if !item.Path.IsNull() && !item.Path.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "filename", item.Path.ValueString())
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/boot/system/bootfile/filename-list-ordered-by-user", cBody.Res())
}
}
- if value := res.Get(prefix + "enable.secret.level"); value.Exists() && !data.EnableSecretLevel.IsNull() {
- data.EnableSecretLevel = types.Int64Value(value.Int())
- } else {
- data.EnableSecretLevel = types.Int64Null()
+ if !data.EnableSecret.IsNull() && !data.EnableSecret.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/enable/secret/secret", data.EnableSecret.ValueString())
}
- for i := range data.IpHosts {
- keys := [...]string{"name"}
- keyValues := [...]string{data.IpHosts[i].Name.ValueString()}
-
- var r gjson.Result
- res.Get(prefix + "ip.host.host-list").ForEach(
- func(_, v gjson.Result) bool {
- found := false
- for ik := range keys {
- if v.Get(keys[ik]).String() == keyValues[ik] {
- found = true
- continue
- }
- found = false
- break
- }
- if found {
- r = v
- return false
+ if !data.EnableSecretType.IsNull() && !data.EnableSecretType.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/enable/secret/type", data.EnableSecretType.ValueString())
+ }
+ if !data.EnableSecretLevel.IsNull() && !data.EnableSecretLevel.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/enable/secret/level", strconv.FormatInt(data.EnableSecretLevel.ValueInt64(), 10))
+ }
+ if len(data.IpHosts) > 0 {
+ for _, item := range data.IpHosts {
+ cBody := netconf.Body{}
+ if !item.Name.IsNull() && !item.Name.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "name", item.Name.ValueString())
+ }
+ if !item.Ips.IsNull() && !item.Ips.IsUnknown() {
+ var values []string
+ item.Ips.ElementsAs(ctx, &values, false)
+ for _, v := range values {
+ cBody = helpers.AppendFromXPath(cBody, "ip-list-ordered", v)
}
- return true
- },
- )
- if value := r.Get("name"); value.Exists() && !data.IpHosts[i].Name.IsNull() {
- data.IpHosts[i].Name = types.StringValue(value.String())
- } else {
- data.IpHosts[i].Name = types.StringNull()
- }
- if value := r.Get("ip-list-ordered"); value.Exists() && !data.IpHosts[i].Ips.IsNull() {
- data.IpHosts[i].Ips = helpers.GetStringList(value.Array())
- } else {
- data.IpHosts[i].Ips = types.ListNull(types.StringType)
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/ip/host/host-list", cBody.Res())
}
}
- for i := range data.IpHostsVrf {
- keys := [...]string{"vrf-name"}
- keyValues := [...]string{data.IpHostsVrf[i].Vrf.ValueString()}
-
- var r gjson.Result
- res.Get(prefix + "ip.host.vrf").ForEach(
- func(_, v gjson.Result) bool {
- found := false
- for ik := range keys {
- if v.Get(keys[ik]).String() == keyValues[ik] {
- found = true
- continue
+ if len(data.IpHostsVrf) > 0 {
+ for _, item := range data.IpHostsVrf {
+ cBody := netconf.Body{}
+ if !item.Vrf.IsNull() && !item.Vrf.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "vrf-name", item.Vrf.ValueString())
+ }
+ if len(item.Hosts) > 0 {
+ for _, citem := range item.Hosts {
+ ccBody := netconf.Body{}
+ if !citem.Name.IsNull() && !citem.Name.IsUnknown() {
+ ccBody = helpers.SetFromXPath(ccBody, "host-name", citem.Name.ValueString())
}
- found = false
- break
- }
- if found {
- r = v
- return false
+ if !citem.Ips.IsNull() && !citem.Ips.IsUnknown() {
+ var values []string
+ citem.Ips.ElementsAs(ctx, &values, false)
+ for _, v := range values {
+ ccBody = helpers.AppendFromXPath(ccBody, "ip-list", v)
+ }
+ }
+ cBody = helpers.SetRawFromXPath(cBody, "host-name", ccBody.Res())
}
- return true
- },
- )
- if value := r.Get("vrf-name"); value.Exists() && !data.IpHostsVrf[i].Vrf.IsNull() {
- data.IpHostsVrf[i].Vrf = types.StringValue(value.String())
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/ip/host/vrf", cBody.Res())
+ }
+ }
+ if !data.DiagnosticEventLogSize.IsNull() && !data.DiagnosticEventLogSize.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-diagnostics:diagnostic/event-log/size", strconv.FormatInt(data.DiagnosticEventLogSize.ValueInt64(), 10))
+ }
+ if !data.SubscriberTemplating.IsNull() && !data.SubscriberTemplating.IsUnknown() {
+ if data.SubscriberTemplating.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/subscriber/templating", "")
} else {
- data.IpHostsVrf[i].Vrf = types.StringNull()
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/subscriber/templating")
}
- for ci := range data.IpHostsVrf[i].Hosts {
- keys := [...]string{"host-name"}
- keyValues := [...]string{data.IpHostsVrf[i].Hosts[ci].Name.ValueString()}
-
- var cr gjson.Result
- r.Get("host-name").ForEach(
- func(_, v gjson.Result) bool {
- found := false
- for ik := range keys {
- if v.Get(keys[ik]).String() == keyValues[ik] {
- found = true
- continue
- }
- found = false
- break
- }
- if found {
- cr = v
- return false
- }
- return true
- },
- )
- if value := cr.Get("host-name"); value.Exists() && !data.IpHostsVrf[i].Hosts[ci].Name.IsNull() {
- data.IpHostsVrf[i].Hosts[ci].Name = types.StringValue(value.String())
- } else {
- data.IpHostsVrf[i].Hosts[ci].Name = types.StringNull()
+ }
+ if !data.CallHomeContactEmail.IsNull() && !data.CallHomeContactEmail.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/call-home/Cisco-IOS-XE-call-home:contact-email-addr", data.CallHomeContactEmail.ValueString())
+ }
+ if !data.CallHomeCiscoTac1ProfileActive.IsNull() && !data.CallHomeCiscoTac1ProfileActive.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/call-home/Cisco-IOS-XE-call-home:tac-profile/profile/CiscoTAC-1/active", data.CallHomeCiscoTac1ProfileActive.ValueBool())
+ }
+ if !data.CallHomeCiscoTac1DestinationTransportMethod.IsNull() && !data.CallHomeCiscoTac1DestinationTransportMethod.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/call-home/Cisco-IOS-XE-call-home:tac-profile/profile/CiscoTAC-1/destination/transport-method", data.CallHomeCiscoTac1DestinationTransportMethod.ValueString())
+ }
+ if !data.IpFtpPassive.IsNull() && !data.IpFtpPassive.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ip/ftp/passive-enable", data.IpFtpPassive.ValueBool())
+ }
+ if !data.TftpSourceInterfaceGigabitEthernet.IsNull() && !data.TftpSourceInterfaceGigabitEthernet.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ip/tftp/source-interface/GigabitEthernet", data.TftpSourceInterfaceGigabitEthernet.ValueString())
+ }
+ if !data.TftpSourceInterfaceLoopback.IsNull() && !data.TftpSourceInterfaceLoopback.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ip/tftp/source-interface/Loopback", strconv.FormatInt(data.TftpSourceInterfaceLoopback.ValueInt64(), 10))
+ }
+ if !data.TftpSourceInterfaceVlan.IsNull() && !data.TftpSourceInterfaceVlan.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ip/tftp/source-interface/Vlan", strconv.FormatInt(data.TftpSourceInterfaceVlan.ValueInt64(), 10))
+ }
+ if !data.TftpSourceInterfaceTwoGigabitEthernet.IsNull() && !data.TftpSourceInterfaceTwoGigabitEthernet.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ip/tftp/source-interface/TwoGigabitEthernet", data.TftpSourceInterfaceTwoGigabitEthernet.ValueString())
+ }
+ if !data.TftpSourceInterfaceFiveGigabitEthernet.IsNull() && !data.TftpSourceInterfaceFiveGigabitEthernet.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ip/tftp/source-interface/FiveGigabitEthernet", data.TftpSourceInterfaceFiveGigabitEthernet.ValueString())
+ }
+ if !data.TftpSourceInterfaceTenGigabitEthernet.IsNull() && !data.TftpSourceInterfaceTenGigabitEthernet.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ip/tftp/source-interface/TenGigabitEthernet", data.TftpSourceInterfaceTenGigabitEthernet.ValueString())
+ }
+ if !data.TftpSourceInterfaceTwentyFiveGigabitEthernet.IsNull() && !data.TftpSourceInterfaceTwentyFiveGigabitEthernet.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ip/tftp/source-interface/TwentyFiveGigabitEthernet", data.TftpSourceInterfaceTwentyFiveGigabitEthernet.ValueString())
+ }
+ if !data.TftpSourceInterfaceFortyGigabitEthernet.IsNull() && !data.TftpSourceInterfaceFortyGigabitEthernet.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ip/tftp/source-interface/FortyGigabitEthernet", data.TftpSourceInterfaceFortyGigabitEthernet.ValueString())
+ }
+ if !data.TftpSourceInterfaceHundredGigabitEthernet.IsNull() && !data.TftpSourceInterfaceHundredGigabitEthernet.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ip/tftp/source-interface/HundredGigE", data.TftpSourceInterfaceHundredGigabitEthernet.ValueString())
+ }
+ if !data.MultilinkPppBundleName.IsNull() && !data.MultilinkPppBundleName.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/multilink/Cisco-IOS-XE-ppp:bundle-name", data.MultilinkPppBundleName.ValueString())
+ }
+ if !data.Version.IsNull() && !data.Version.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/version", data.Version.ValueString())
+ }
+ if len(data.TrackObjects) > 0 {
+ for _, item := range data.TrackObjects {
+ cBody := netconf.Body{}
+ if !item.Number.IsNull() && !item.Number.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "object-number", item.Number.ValueString())
}
- if value := cr.Get("ip-list"); value.Exists() && !data.IpHostsVrf[i].Hosts[ci].Ips.IsNull() {
- data.IpHostsVrf[i].Hosts[ci].Ips = helpers.GetStringList(value.Array())
- } else {
- data.IpHostsVrf[i].Hosts[ci].Ips = types.ListNull(types.StringType)
+ if !item.IpSlaNumber.IsNull() && !item.IpSlaNumber.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "ip/sla/number", strconv.FormatInt(item.IpSlaNumber.ValueInt64(), 10))
+ }
+ if !item.IpSlaReachability.IsNull() && !item.IpSlaReachability.IsUnknown() {
+ if item.IpSlaReachability.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "ip/sla/reachability", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "ip/sla/reachability")
+ }
}
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/track/Cisco-IOS-XE-track:tracked-object-v2", cBody.Res())
}
}
- if value := res.Get(prefix + "Cisco-IOS-XE-diagnostics:diagnostic.event-log.size"); value.Exists() && !data.DiagnosticEventLogSize.IsNull() {
- data.DiagnosticEventLogSize = types.Int64Value(value.Int())
+ if !data.IpNbarClassificationDnsClassifyByDomain.IsNull() && !data.IpNbarClassificationDnsClassifyByDomain.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ip/Cisco-IOS-XE-nbar:nbar/classification/dns/classify-by-domain-with-default", data.IpNbarClassificationDnsClassifyByDomain.ValueBool())
+ }
+ if !data.IpMulticastRouteLimit.IsNull() && !data.IpMulticastRouteLimit.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ip/multicast/Cisco-IOS-XE-multicast:route-limit-container/routelimit", strconv.FormatInt(data.IpMulticastRouteLimit.ValueInt64(), 10))
+ }
+ if !data.SecurityPasswordsMinLength.IsNull() && !data.SecurityPasswordsMinLength.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-aaa:security/passwords/min-length", strconv.FormatInt(data.SecurityPasswordsMinLength.ValueInt64(), 10))
+ }
+ if !data.IpDomainListNames.IsNull() && !data.IpDomainListNames.IsUnknown() {
+ var values []string
+ data.IpDomainListNames.ElementsAs(ctx, &values, false)
+ for _, v := range values {
+ body = helpers.AppendFromXPath(body, data.getXPath()+"/ip/domain/list/domain-name", v)
+ }
+ }
+ if !data.IpDomainListVrfDomain.IsNull() && !data.IpDomainListVrfDomain.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ip/domain/list/vrf/domain-name", data.IpDomainListVrfDomain.ValueString())
+ }
+ if !data.IpDomainListVrf.IsNull() && !data.IpDomainListVrf.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ip/domain/list/vrf/vrf-name", data.IpDomainListVrf.ValueString())
+ }
+ if !data.EthernetCfmAlarmConfigDelay.IsNull() && !data.EthernetCfmAlarmConfigDelay.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ethernet/Cisco-IOS-XE-ethernet:cfm/alarm-config/delay", strconv.FormatInt(data.EthernetCfmAlarmConfigDelay.ValueInt64(), 10))
+ }
+ if !data.EthernetCfmAlarmConfigReset.IsNull() && !data.EthernetCfmAlarmConfigReset.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ethernet/Cisco-IOS-XE-ethernet:cfm/alarm-config/reset", strconv.FormatInt(data.EthernetCfmAlarmConfigReset.ValueInt64(), 10))
+ }
+ if !data.StandbyRedirects.IsNull() && !data.StandbyRedirects.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/standby/redirects-config/redirects", data.StandbyRedirects.ValueBool())
+ }
+ if !data.StandbyRedirectsEnableDisable.IsNull() && !data.StandbyRedirectsEnableDisable.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/standby/redirects-config/redirect-enable-disable/redirects", data.StandbyRedirectsEnableDisable.ValueString())
+ }
+ bodyString, err := body.String()
+ if err != nil {
+ tflog.Error(ctx, fmt.Sprintf("Error converting body to string: %s", err))
+ }
+ return bodyString
+}
+
+// End of section. //template:end toBodyXML
+
+// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBody
+
+func (data *System) updateFromBody(ctx context.Context, res gjson.Result) {
+ prefix := helpers.LastElement(data.getPath()) + "."
+ if res.Get(helpers.LastElement(data.getPath())).IsArray() {
+ prefix += "0."
+ }
+ if value := res.Get(prefix + "hostname"); value.Exists() && !data.Hostname.IsNull() {
+ data.Hostname = types.StringValue(value.String())
} else {
- data.DiagnosticEventLogSize = types.Int64Null()
+ data.Hostname = types.StringNull()
}
- if value := res.Get(prefix + "subscriber.templating"); !data.SubscriberTemplating.IsNull() {
+ if value := res.Get(prefix + "ip.bgp-community.new-format"); !data.IpBgpCommunityNewFormat.IsNull() {
if value.Exists() {
- data.SubscriberTemplating = types.BoolValue(true)
+ data.IpBgpCommunityNewFormat = types.BoolValue(true)
} else {
- data.SubscriberTemplating = types.BoolValue(false)
+ data.IpBgpCommunityNewFormat = types.BoolValue(false)
}
} else {
- data.SubscriberTemplating = types.BoolNull()
+ data.IpBgpCommunityNewFormat = types.BoolNull()
}
- if value := res.Get(prefix + "call-home.Cisco-IOS-XE-call-home:contact-email-addr"); value.Exists() && !data.CallHomeContactEmail.IsNull() {
- data.CallHomeContactEmail = types.StringValue(value.String())
+ if value := res.Get(prefix + "ip.routing-conf.routing"); !data.IpRouting.IsNull() {
+ if value.Exists() {
+ data.IpRouting = types.BoolValue(value.Bool())
+ }
} else {
- data.CallHomeContactEmail = types.StringNull()
+ data.IpRouting = types.BoolNull()
}
- if value := res.Get(prefix + "call-home.Cisco-IOS-XE-call-home:tac-profile.profile.CiscoTAC-1.active"); !data.CallHomeCiscoTac1ProfileActive.IsNull() {
+ if value := res.Get(prefix + "ipv6.unicast-routing"); !data.Ipv6UnicastRouting.IsNull() {
if value.Exists() {
- data.CallHomeCiscoTac1ProfileActive = types.BoolValue(value.Bool())
+ data.Ipv6UnicastRouting = types.BoolValue(true)
+ } else {
+ data.Ipv6UnicastRouting = types.BoolValue(false)
}
} else {
- data.CallHomeCiscoTac1ProfileActive = types.BoolNull()
+ data.Ipv6UnicastRouting = types.BoolNull()
}
- if value := res.Get(prefix + "call-home.Cisco-IOS-XE-call-home:tac-profile.profile.CiscoTAC-1.destination.transport-method"); value.Exists() && !data.CallHomeCiscoTac1DestinationTransportMethod.IsNull() {
- data.CallHomeCiscoTac1DestinationTransportMethod = types.StringValue(value.String())
+ if value := res.Get(prefix + "system.Cisco-IOS-XE-switch:mtu.size"); value.Exists() && !data.Mtu.IsNull() {
+ data.Mtu = types.Int64Value(value.Int())
} else {
- data.CallHomeCiscoTac1DestinationTransportMethod = types.StringNull()
+ data.Mtu = types.Int64Null()
}
- if value := res.Get(prefix + "ip.ftp.passive-enable"); !data.IpFtpPassive.IsNull() {
+ if value := res.Get(prefix + "ip.source-route"); !data.IpSourceRoute.IsNull() {
if value.Exists() {
- data.IpFtpPassive = types.BoolValue(value.Bool())
+ data.IpSourceRoute = types.BoolValue(value.Bool())
}
} else {
- data.IpFtpPassive = types.BoolNull()
+ data.IpSourceRoute = types.BoolNull()
}
- if value := res.Get(prefix + "ip.tftp.source-interface.GigabitEthernet"); value.Exists() && !data.TftpSourceInterfaceGigabitEthernet.IsNull() {
- data.TftpSourceInterfaceGigabitEthernet = types.StringValue(value.String())
+ if value := res.Get(prefix + "ip.domain.lookup"); !data.IpDomainLookup.IsNull() {
+ if value.Exists() {
+ data.IpDomainLookup = types.BoolValue(value.Bool())
+ }
} else {
- data.TftpSourceInterfaceGigabitEthernet = types.StringNull()
+ data.IpDomainLookup = types.BoolNull()
}
- if value := res.Get(prefix + "ip.tftp.source-interface.Loopback"); value.Exists() && !data.TftpSourceInterfaceLoopback.IsNull() {
- data.TftpSourceInterfaceLoopback = types.Int64Value(value.Int())
+ if value := res.Get(prefix + "ip.domain.name"); value.Exists() && !data.IpDomainName.IsNull() {
+ data.IpDomainName = types.StringValue(value.String())
} else {
- data.TftpSourceInterfaceLoopback = types.Int64Null()
+ data.IpDomainName = types.StringNull()
}
- if value := res.Get(prefix + "ip.tftp.source-interface.Vlan"); value.Exists() && !data.TftpSourceInterfaceVlan.IsNull() {
- data.TftpSourceInterfaceVlan = types.Int64Value(value.Int())
+ if value := res.Get(prefix + "login.delay"); value.Exists() && !data.LoginDelay.IsNull() {
+ data.LoginDelay = types.Int64Value(value.Int())
} else {
- data.TftpSourceInterfaceVlan = types.Int64Null()
+ data.LoginDelay = types.Int64Null()
}
- if value := res.Get(prefix + "ip.tftp.source-interface.TwoGigabitEthernet"); value.Exists() && !data.TftpSourceInterfaceTwoGigabitEthernet.IsNull() {
- data.TftpSourceInterfaceTwoGigabitEthernet = types.StringValue(value.String())
+ if value := res.Get(prefix + "login.on-failure"); !data.LoginOnFailure.IsNull() {
+ if value.Exists() {
+ data.LoginOnFailure = types.BoolValue(true)
+ } else {
+ data.LoginOnFailure = types.BoolValue(false)
+ }
} else {
- data.TftpSourceInterfaceTwoGigabitEthernet = types.StringNull()
+ data.LoginOnFailure = types.BoolNull()
}
- if value := res.Get(prefix + "ip.tftp.source-interface.FiveGigabitEthernet"); value.Exists() && !data.TftpSourceInterfaceFiveGigabitEthernet.IsNull() {
- data.TftpSourceInterfaceFiveGigabitEthernet = types.StringValue(value.String())
+ if value := res.Get(prefix + "login.on-failure.log"); !data.LoginOnFailureLog.IsNull() {
+ if value.Exists() {
+ data.LoginOnFailureLog = types.BoolValue(true)
+ } else {
+ data.LoginOnFailureLog = types.BoolValue(false)
+ }
} else {
- data.TftpSourceInterfaceFiveGigabitEthernet = types.StringNull()
+ data.LoginOnFailureLog = types.BoolNull()
}
- if value := res.Get(prefix + "ip.tftp.source-interface.TenGigabitEthernet"); value.Exists() && !data.TftpSourceInterfaceTenGigabitEthernet.IsNull() {
- data.TftpSourceInterfaceTenGigabitEthernet = types.StringValue(value.String())
- } else {
- data.TftpSourceInterfaceTenGigabitEthernet = types.StringNull()
- }
- if value := res.Get(prefix + "ip.tftp.source-interface.TwentyFiveGigabitEthernet"); value.Exists() && !data.TftpSourceInterfaceTwentyFiveGigabitEthernet.IsNull() {
- data.TftpSourceInterfaceTwentyFiveGigabitEthernet = types.StringValue(value.String())
+ if value := res.Get(prefix + "login.on-success"); !data.LoginOnSuccess.IsNull() {
+ if value.Exists() {
+ data.LoginOnSuccess = types.BoolValue(true)
+ } else {
+ data.LoginOnSuccess = types.BoolValue(false)
+ }
} else {
- data.TftpSourceInterfaceTwentyFiveGigabitEthernet = types.StringNull()
+ data.LoginOnSuccess = types.BoolNull()
}
- if value := res.Get(prefix + "ip.tftp.source-interface.FortyGigabitEthernet"); value.Exists() && !data.TftpSourceInterfaceFortyGigabitEthernet.IsNull() {
- data.TftpSourceInterfaceFortyGigabitEthernet = types.StringValue(value.String())
+ if value := res.Get(prefix + "login.on-success.log"); !data.LoginOnSuccessLog.IsNull() {
+ if value.Exists() {
+ data.LoginOnSuccessLog = types.BoolValue(true)
+ } else {
+ data.LoginOnSuccessLog = types.BoolValue(false)
+ }
} else {
- data.TftpSourceInterfaceFortyGigabitEthernet = types.StringNull()
+ data.LoginOnSuccessLog = types.BoolNull()
}
- if value := res.Get(prefix + "ip.tftp.source-interface.HundredGigE"); value.Exists() && !data.TftpSourceInterfaceHundredGigabitEthernet.IsNull() {
- data.TftpSourceInterfaceHundredGigabitEthernet = types.StringValue(value.String())
+ if value := res.Get(prefix + "ip.Cisco-IOS-XE-multicast:multicast-routing"); !data.IpMulticastRouting.IsNull() {
+ if value.Exists() {
+ data.IpMulticastRouting = types.BoolValue(true)
+ } else {
+ data.IpMulticastRouting = types.BoolValue(false)
+ }
} else {
- data.TftpSourceInterfaceHundredGigabitEthernet = types.StringNull()
+ data.IpMulticastRouting = types.BoolNull()
}
- if value := res.Get(prefix + "multilink.Cisco-IOS-XE-ppp:bundle-name"); value.Exists() && !data.MultilinkPppBundleName.IsNull() {
- data.MultilinkPppBundleName = types.StringValue(value.String())
+ if value := res.Get(prefix + "ip.Cisco-IOS-XE-multicast:mcr-conf.multicast-routing"); !data.MulticastRoutingSwitch.IsNull() {
+ if value.Exists() {
+ data.MulticastRoutingSwitch = types.BoolValue(true)
+ } else {
+ data.MulticastRoutingSwitch = types.BoolValue(false)
+ }
} else {
- data.MultilinkPppBundleName = types.StringNull()
+ data.MulticastRoutingSwitch = types.BoolNull()
}
- if value := res.Get(prefix + "version"); value.Exists() && !data.Version.IsNull() {
- data.Version = types.StringValue(value.String())
+ if value := res.Get(prefix + "ip.Cisco-IOS-XE-multicast:multicast-routing.distributed"); !data.IpMulticastRoutingDistributed.IsNull() {
+ if value.Exists() {
+ data.IpMulticastRoutingDistributed = types.BoolValue(true)
+ } else {
+ data.IpMulticastRoutingDistributed = types.BoolValue(false)
+ }
} else {
- data.Version = types.StringNull()
+ data.IpMulticastRoutingDistributed = types.BoolNull()
}
- for i := range data.TrackObjects {
- keys := [...]string{"object-number"}
- keyValues := [...]string{data.TrackObjects[i].Number.ValueString()}
+ for i := range data.MulticastRoutingVrfs {
+ keys := [...]string{"name"}
+ keyValues := [...]string{data.MulticastRoutingVrfs[i].Vrf.ValueString()}
var r gjson.Result
- res.Get(prefix + "track.Cisco-IOS-XE-track:tracked-object-v2").ForEach(
+ res.Get(prefix + "ip.Cisco-IOS-XE-multicast:multicast-routing.vrf").ForEach(
func(_, v gjson.Result) bool {
found := false
for ik := range keys {
@@ -1866,1305 +1664,5450 @@ func (data *System) updateFromBody(ctx context.Context, res gjson.Result) {
return true
},
)
- if value := r.Get("object-number"); value.Exists() && !data.TrackObjects[i].Number.IsNull() {
- data.TrackObjects[i].Number = types.StringValue(value.String())
- } else {
- data.TrackObjects[i].Number = types.StringNull()
- }
- if value := r.Get("ip.sla.number"); value.Exists() && !data.TrackObjects[i].IpSlaNumber.IsNull() {
- data.TrackObjects[i].IpSlaNumber = types.Int64Value(value.Int())
+ if value := r.Get("name"); value.Exists() && !data.MulticastRoutingVrfs[i].Vrf.IsNull() {
+ data.MulticastRoutingVrfs[i].Vrf = types.StringValue(value.String())
} else {
- data.TrackObjects[i].IpSlaNumber = types.Int64Null()
+ data.MulticastRoutingVrfs[i].Vrf = types.StringNull()
}
- if value := r.Get("ip.sla.reachability"); !data.TrackObjects[i].IpSlaReachability.IsNull() {
+ if value := r.Get("distributed"); !data.MulticastRoutingVrfs[i].Distributed.IsNull() {
if value.Exists() {
- data.TrackObjects[i].IpSlaReachability = types.BoolValue(true)
+ data.MulticastRoutingVrfs[i].Distributed = types.BoolValue(true)
} else {
- data.TrackObjects[i].IpSlaReachability = types.BoolValue(false)
+ data.MulticastRoutingVrfs[i].Distributed = types.BoolValue(false)
}
} else {
- data.TrackObjects[i].IpSlaReachability = types.BoolNull()
- }
- }
- if value := res.Get(prefix + "ip.Cisco-IOS-XE-nbar:nbar.classification.dns.classify-by-domain-with-default"); !data.IpNbarClassificationDnsClassifyByDomain.IsNull() {
- if value.Exists() {
- data.IpNbarClassificationDnsClassifyByDomain = types.BoolValue(value.Bool())
+ data.MulticastRoutingVrfs[i].Distributed = types.BoolNull()
}
- } else {
- data.IpNbarClassificationDnsClassifyByDomain = types.BoolNull()
}
- if value := res.Get(prefix + "ip.multicast.Cisco-IOS-XE-multicast:route-limit-container.routelimit"); value.Exists() && !data.IpMulticastRouteLimit.IsNull() {
- data.IpMulticastRouteLimit = types.Int64Value(value.Int())
- } else {
- data.IpMulticastRouteLimit = types.Int64Null()
- }
- if value := res.Get(prefix + "Cisco-IOS-XE-aaa:security.passwords.min-length"); value.Exists() && !data.SecurityPasswordsMinLength.IsNull() {
- data.SecurityPasswordsMinLength = types.Int64Value(value.Int())
+ if value := res.Get(prefix + "ip.Cisco-IOS-XE-http:http.access-class"); value.Exists() && !data.IpHttpAccessClass.IsNull() {
+ data.IpHttpAccessClass = types.Int64Value(value.Int())
} else {
- data.SecurityPasswordsMinLength = types.Int64Null()
+ data.IpHttpAccessClass = types.Int64Null()
}
- if value := res.Get(prefix + "ip.domain.list.domain-name"); value.Exists() && !data.IpDomainListNames.IsNull() {
- data.IpDomainListNames = helpers.GetStringList(value.Array())
+ if value := res.Get(prefix + "ip.Cisco-IOS-XE-http:http.authentication.aaa"); !data.IpHttpAuthenticationAaa.IsNull() {
+ if value.Exists() {
+ data.IpHttpAuthenticationAaa = types.BoolValue(true)
+ } else {
+ data.IpHttpAuthenticationAaa = types.BoolValue(false)
+ }
} else {
- data.IpDomainListNames = types.ListNull(types.StringType)
+ data.IpHttpAuthenticationAaa = types.BoolNull()
}
- if value := res.Get(prefix + "ip.domain.list.vrf.domain-name"); value.Exists() && !data.IpDomainListVrfDomain.IsNull() {
- data.IpDomainListVrfDomain = types.StringValue(value.String())
+ if value := res.Get(prefix + "ip.Cisco-IOS-XE-http:http.authentication.aaa.exec-authorization"); value.Exists() && !data.IpHttpAuthenticationAaaExecAuthorization.IsNull() {
+ data.IpHttpAuthenticationAaaExecAuthorization = types.StringValue(value.String())
} else {
- data.IpDomainListVrfDomain = types.StringNull()
+ data.IpHttpAuthenticationAaaExecAuthorization = types.StringNull()
}
- if value := res.Get(prefix + "ip.domain.list.vrf.vrf-name"); value.Exists() && !data.IpDomainListVrf.IsNull() {
- data.IpDomainListVrf = types.StringValue(value.String())
+ if value := res.Get(prefix + "ip.Cisco-IOS-XE-http:http.authentication.aaa.login-authentication"); value.Exists() && !data.IpHttpAuthenticationAaaLoginAuthentication.IsNull() {
+ data.IpHttpAuthenticationAaaLoginAuthentication = types.StringValue(value.String())
} else {
- data.IpDomainListVrf = types.StringNull()
+ data.IpHttpAuthenticationAaaLoginAuthentication = types.StringNull()
}
- if value := res.Get(prefix + "ethernet.Cisco-IOS-XE-ethernet:cfm.alarm-config.delay"); value.Exists() && !data.EthernetCfmAlarmConfigDelay.IsNull() {
- data.EthernetCfmAlarmConfigDelay = types.Int64Value(value.Int())
- } else {
- data.EthernetCfmAlarmConfigDelay = types.Int64Null()
+ for i := range data.IpHttpAuthenticationAaaCommandAuthorization {
+ keys := [...]string{"level"}
+ keyValues := [...]string{strconv.FormatInt(data.IpHttpAuthenticationAaaCommandAuthorization[i].Level.ValueInt64(), 10)}
+
+ var r gjson.Result
+ res.Get(prefix + "ip.Cisco-IOS-XE-http:http.authentication.aaa.command-authorization").ForEach(
+ func(_, v gjson.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := r.Get("level"); value.Exists() && !data.IpHttpAuthenticationAaaCommandAuthorization[i].Level.IsNull() {
+ data.IpHttpAuthenticationAaaCommandAuthorization[i].Level = types.Int64Value(value.Int())
+ } else {
+ data.IpHttpAuthenticationAaaCommandAuthorization[i].Level = types.Int64Null()
+ }
+ if value := r.Get("name"); value.Exists() && !data.IpHttpAuthenticationAaaCommandAuthorization[i].Name.IsNull() {
+ data.IpHttpAuthenticationAaaCommandAuthorization[i].Name = types.StringValue(value.String())
+ } else {
+ data.IpHttpAuthenticationAaaCommandAuthorization[i].Name = types.StringNull()
+ }
}
- if value := res.Get(prefix + "ethernet.Cisco-IOS-XE-ethernet:cfm.alarm-config.reset"); value.Exists() && !data.EthernetCfmAlarmConfigReset.IsNull() {
- data.EthernetCfmAlarmConfigReset = types.Int64Value(value.Int())
+ if value := res.Get(prefix + "ip.Cisco-IOS-XE-http:http.authentication.local"); !data.IpHttpAuthenticationLocal.IsNull() {
+ if value.Exists() {
+ data.IpHttpAuthenticationLocal = types.BoolValue(true)
+ } else {
+ data.IpHttpAuthenticationLocal = types.BoolValue(false)
+ }
} else {
- data.EthernetCfmAlarmConfigReset = types.Int64Null()
+ data.IpHttpAuthenticationLocal = types.BoolNull()
}
- if value := res.Get(prefix + "standby.redirects-config.redirects"); !data.StandbyRedirects.IsNull() {
+ if value := res.Get(prefix + "ip.Cisco-IOS-XE-http:http.server"); !data.IpHttpServer.IsNull() {
if value.Exists() {
- data.StandbyRedirects = types.BoolValue(value.Bool())
+ data.IpHttpServer = types.BoolValue(value.Bool())
}
} else {
- data.StandbyRedirects = types.BoolNull()
+ data.IpHttpServer = types.BoolNull()
}
- if value := res.Get(prefix + "standby.redirects-config.redirect-enable-disable.redirects"); value.Exists() && !data.StandbyRedirectsEnableDisable.IsNull() {
- data.StandbyRedirectsEnableDisable = types.StringValue(value.String())
+ if value := res.Get(prefix + "ip.Cisco-IOS-XE-http:http.secure-server"); !data.IpHttpSecureServer.IsNull() {
+ if value.Exists() {
+ data.IpHttpSecureServer = types.BoolValue(value.Bool())
+ }
} else {
- data.StandbyRedirectsEnableDisable = types.StringNull()
- }
-}
-
-// End of section. //template:end updateFromBody
-
-// Section below is generated&owned by "gen/generator.go". //template:begin fromBody
-
-func (data *System) fromBody(ctx context.Context, res gjson.Result) {
- prefix := helpers.LastElement(data.getPath()) + "."
- if res.Get(helpers.LastElement(data.getPath())).IsArray() {
- prefix += "0."
- }
- if value := res.Get(prefix + "hostname"); value.Exists() {
- data.Hostname = types.StringValue(value.String())
+ data.IpHttpSecureServer = types.BoolNull()
}
- if value := res.Get(prefix + "ip.bgp-community.new-format"); value.Exists() {
- data.IpBgpCommunityNewFormat = types.BoolValue(true)
+ if value := res.Get(prefix + "ip.Cisco-IOS-XE-http:http.secure-trustpoint"); value.Exists() && !data.IpHttpSecureTrustpoint.IsNull() {
+ data.IpHttpSecureTrustpoint = types.StringValue(value.String())
} else {
- data.IpBgpCommunityNewFormat = types.BoolValue(false)
+ data.IpHttpSecureTrustpoint = types.StringNull()
}
- if value := res.Get(prefix + "ip.routing-conf.routing"); value.Exists() {
- data.IpRouting = types.BoolValue(value.Bool())
+ if value := res.Get(prefix + "ip.Cisco-IOS-XE-http:http.tls-version"); value.Exists() && !data.IpHttpTlsVersion.IsNull() {
+ data.IpHttpTlsVersion = types.StringValue(value.String())
} else {
- data.IpRouting = types.BoolNull()
+ data.IpHttpTlsVersion = types.StringNull()
}
- if value := res.Get(prefix + "ipv6.unicast-routing"); value.Exists() {
- data.Ipv6UnicastRouting = types.BoolValue(true)
+ if value := res.Get(prefix + "ip.Cisco-IOS-XE-http:http.client.secure-trustpoint"); value.Exists() && !data.IpHttpClientSecureTrustpoint.IsNull() {
+ data.IpHttpClientSecureTrustpoint = types.StringValue(value.String())
} else {
- data.Ipv6UnicastRouting = types.BoolValue(false)
- }
- if value := res.Get(prefix + "system.Cisco-IOS-XE-switch:mtu.size"); value.Exists() {
- data.Mtu = types.Int64Value(value.Int())
+ data.IpHttpClientSecureTrustpoint = types.StringNull()
}
- if value := res.Get(prefix + "ip.source-route"); value.Exists() {
- data.IpSourceRoute = types.BoolValue(value.Bool())
+ if value := res.Get(prefix + "ip.Cisco-IOS-XE-http:http.client.source-interface"); value.Exists() && !data.IpHttpClientSourceInterface.IsNull() {
+ data.IpHttpClientSourceInterface = types.StringValue(value.String())
} else {
- data.IpSourceRoute = types.BoolNull()
+ data.IpHttpClientSourceInterface = types.StringNull()
}
- if value := res.Get(prefix + "ip.domain.lookup"); value.Exists() {
- data.IpDomainLookup = types.BoolValue(value.Bool())
+ if value := res.Get(prefix + "ip.Cisco-IOS-XE-http:http.secure-active-session-modules"); value.Exists() && !data.IpHttpSecureActiveSessionModules.IsNull() {
+ data.IpHttpSecureActiveSessionModules = types.StringValue(value.String())
} else {
- data.IpDomainLookup = types.BoolNull()
- }
- if value := res.Get(prefix + "ip.domain.name"); value.Exists() {
- data.IpDomainName = types.StringValue(value.String())
- }
- if value := res.Get(prefix + "login.delay"); value.Exists() {
- data.LoginDelay = types.Int64Value(value.Int())
+ data.IpHttpSecureActiveSessionModules = types.StringNull()
}
- if value := res.Get(prefix + "login.on-failure"); value.Exists() {
- data.LoginOnFailure = types.BoolValue(true)
+ if value := res.Get(prefix + "ip.Cisco-IOS-XE-http:http.max-connections"); value.Exists() && !data.IpHttpMaxConnections.IsNull() {
+ data.IpHttpMaxConnections = types.Int64Value(value.Int())
} else {
- data.LoginOnFailure = types.BoolValue(false)
+ data.IpHttpMaxConnections = types.Int64Null()
}
- if value := res.Get(prefix + "login.on-failure.log"); value.Exists() {
- data.LoginOnFailureLog = types.BoolValue(true)
+ if value := res.Get(prefix + "ip.Cisco-IOS-XE-http:http.active-session-modules"); value.Exists() && !data.IpHttpActiveSessionModules.IsNull() {
+ data.IpHttpActiveSessionModules = types.StringValue(value.String())
} else {
- data.LoginOnFailureLog = types.BoolValue(false)
+ data.IpHttpActiveSessionModules = types.StringNull()
}
- if value := res.Get(prefix + "login.on-success"); value.Exists() {
- data.LoginOnSuccess = types.BoolValue(true)
+ if value := res.Get(prefix + "ip.name-server.no-vrf-ordered"); value.Exists() && !data.IpNameServers.IsNull() {
+ data.IpNameServers = helpers.GetStringList(value.Array())
} else {
- data.LoginOnSuccess = types.BoolValue(false)
+ data.IpNameServers = types.ListNull(types.StringType)
}
- if value := res.Get(prefix + "login.on-success.log"); value.Exists() {
- data.LoginOnSuccessLog = types.BoolValue(true)
- } else {
- data.LoginOnSuccessLog = types.BoolValue(false)
- }
- if value := res.Get(prefix + "ip.Cisco-IOS-XE-multicast:multicast-routing"); value.Exists() {
- data.IpMulticastRouting = types.BoolValue(true)
- } else {
- data.IpMulticastRouting = types.BoolValue(false)
- }
- if value := res.Get(prefix + "ip.Cisco-IOS-XE-multicast:mcr-conf.multicast-routing"); value.Exists() {
- data.MulticastRoutingSwitch = types.BoolValue(true)
- } else {
- data.MulticastRoutingSwitch = types.BoolValue(false)
- }
- if value := res.Get(prefix + "ip.Cisco-IOS-XE-multicast:multicast-routing.distributed"); value.Exists() {
- data.IpMulticastRoutingDistributed = types.BoolValue(true)
- } else {
- data.IpMulticastRoutingDistributed = types.BoolValue(false)
- }
- if value := res.Get(prefix + "ip.Cisco-IOS-XE-multicast:multicast-routing.vrf"); value.Exists() {
- data.MulticastRoutingVrfs = make([]SystemMulticastRoutingVrfs, 0)
- value.ForEach(func(k, v gjson.Result) bool {
- item := SystemMulticastRoutingVrfs{}
- if cValue := v.Get("name"); cValue.Exists() {
- item.Vrf = types.StringValue(cValue.String())
- }
- if cValue := v.Get("distributed"); cValue.Exists() {
- item.Distributed = types.BoolValue(true)
- } else {
- item.Distributed = types.BoolValue(false)
- }
- data.MulticastRoutingVrfs = append(data.MulticastRoutingVrfs, item)
- return true
- })
- }
- if value := res.Get(prefix + "ip.Cisco-IOS-XE-http:http.access-class"); value.Exists() {
- data.IpHttpAccessClass = types.Int64Value(value.Int())
- }
- if value := res.Get(prefix + "ip.Cisco-IOS-XE-http:http.authentication.aaa"); value.Exists() {
- data.IpHttpAuthenticationAaa = types.BoolValue(true)
- } else {
- data.IpHttpAuthenticationAaa = types.BoolValue(false)
- }
- if value := res.Get(prefix + "ip.Cisco-IOS-XE-http:http.authentication.aaa.exec-authorization"); value.Exists() {
- data.IpHttpAuthenticationAaaExecAuthorization = types.StringValue(value.String())
- }
- if value := res.Get(prefix + "ip.Cisco-IOS-XE-http:http.authentication.aaa.login-authentication"); value.Exists() {
- data.IpHttpAuthenticationAaaLoginAuthentication = types.StringValue(value.String())
- }
- if value := res.Get(prefix + "ip.Cisco-IOS-XE-http:http.authentication.aaa.command-authorization"); value.Exists() {
- data.IpHttpAuthenticationAaaCommandAuthorization = make([]SystemIpHttpAuthenticationAaaCommandAuthorization, 0)
- value.ForEach(func(k, v gjson.Result) bool {
- item := SystemIpHttpAuthenticationAaaCommandAuthorization{}
- if cValue := v.Get("level"); cValue.Exists() {
- item.Level = types.Int64Value(cValue.Int())
- }
- if cValue := v.Get("name"); cValue.Exists() {
- item.Name = types.StringValue(cValue.String())
- }
- data.IpHttpAuthenticationAaaCommandAuthorization = append(data.IpHttpAuthenticationAaaCommandAuthorization, item)
- return true
- })
- }
- if value := res.Get(prefix + "ip.Cisco-IOS-XE-http:http.authentication.local"); value.Exists() {
- data.IpHttpAuthenticationLocal = types.BoolValue(true)
- } else {
- data.IpHttpAuthenticationLocal = types.BoolValue(false)
- }
- if value := res.Get(prefix + "ip.Cisco-IOS-XE-http:http.server"); value.Exists() {
- data.IpHttpServer = types.BoolValue(value.Bool())
- } else {
- data.IpHttpServer = types.BoolNull()
- }
- if value := res.Get(prefix + "ip.Cisco-IOS-XE-http:http.secure-server"); value.Exists() {
- data.IpHttpSecureServer = types.BoolValue(value.Bool())
- } else {
- data.IpHttpSecureServer = types.BoolNull()
- }
- if value := res.Get(prefix + "ip.Cisco-IOS-XE-http:http.secure-trustpoint"); value.Exists() {
- data.IpHttpSecureTrustpoint = types.StringValue(value.String())
- }
- if value := res.Get(prefix + "ip.Cisco-IOS-XE-http:http.tls-version"); value.Exists() {
- data.IpHttpTlsVersion = types.StringValue(value.String())
- }
- if value := res.Get(prefix + "ip.Cisco-IOS-XE-http:http.client.secure-trustpoint"); value.Exists() {
- data.IpHttpClientSecureTrustpoint = types.StringValue(value.String())
- }
- if value := res.Get(prefix + "ip.Cisco-IOS-XE-http:http.client.source-interface"); value.Exists() {
- data.IpHttpClientSourceInterface = types.StringValue(value.String())
- }
- if value := res.Get(prefix + "ip.Cisco-IOS-XE-http:http.secure-active-session-modules"); value.Exists() {
- data.IpHttpSecureActiveSessionModules = types.StringValue(value.String())
- }
- if value := res.Get(prefix + "ip.Cisco-IOS-XE-http:http.max-connections"); value.Exists() {
- data.IpHttpMaxConnections = types.Int64Value(value.Int())
- }
- if value := res.Get(prefix + "ip.Cisco-IOS-XE-http:http.active-session-modules"); value.Exists() {
- data.IpHttpActiveSessionModules = types.StringValue(value.String())
- }
- if value := res.Get(prefix + "ip.name-server.no-vrf-ordered"); value.Exists() {
- data.IpNameServers = helpers.GetStringList(value.Array())
- } else {
- data.IpNameServers = types.ListNull(types.StringType)
- }
- if value := res.Get(prefix + "ip.name-server.vrf"); value.Exists() {
- data.IpNameServersVrf = make([]SystemIpNameServersVrf, 0)
- value.ForEach(func(k, v gjson.Result) bool {
- item := SystemIpNameServersVrf{}
- if cValue := v.Get("word"); cValue.Exists() {
- item.Vrf = types.StringValue(cValue.String())
- }
- if cValue := v.Get("server-ip-list-ordered"); cValue.Exists() {
- item.Servers = helpers.GetStringList(cValue.Array())
- } else {
- item.Servers = types.ListNull(types.StringType)
- }
- data.IpNameServersVrf = append(data.IpNameServersVrf, item)
- return true
- })
+ for i := range data.IpNameServersVrf {
+ keys := [...]string{"word"}
+ keyValues := [...]string{data.IpNameServersVrf[i].Vrf.ValueString()}
+
+ var r gjson.Result
+ res.Get(prefix + "ip.name-server.vrf").ForEach(
+ func(_, v gjson.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := r.Get("word"); value.Exists() && !data.IpNameServersVrf[i].Vrf.IsNull() {
+ data.IpNameServersVrf[i].Vrf = types.StringValue(value.String())
+ } else {
+ data.IpNameServersVrf[i].Vrf = types.StringNull()
+ }
+ if value := r.Get("server-ip-list-ordered"); value.Exists() && !data.IpNameServersVrf[i].Servers.IsNull() {
+ data.IpNameServersVrf[i].Servers = helpers.GetStringList(value.Array())
+ } else {
+ data.IpNameServersVrf[i].Servers = types.ListNull(types.StringType)
+ }
}
- if value := res.Get(prefix + "ip.domain.lookup-settings.lookup.source-interface.Loopback"); value.Exists() {
+ if value := res.Get(prefix + "ip.domain.lookup-settings.lookup.source-interface.Loopback"); value.Exists() && !data.IpDomainLookupSourceInterfaceLoopback.IsNull() {
data.IpDomainLookupSourceInterfaceLoopback = types.Int64Value(value.Int())
+ } else {
+ data.IpDomainLookupSourceInterfaceLoopback = types.Int64Null()
}
- if value := res.Get(prefix + "ip.domain.lookup-settings.lookup.source-interface.Vlan"); value.Exists() {
+ if value := res.Get(prefix + "ip.domain.lookup-settings.lookup.source-interface.Vlan"); value.Exists() && !data.IpDomainLookupSourceInterfaceVlan.IsNull() {
data.IpDomainLookupSourceInterfaceVlan = types.Int64Value(value.Int())
+ } else {
+ data.IpDomainLookupSourceInterfaceVlan = types.Int64Null()
}
- if value := res.Get(prefix + "ip.domain.lookup-settings.lookup.source-interface.GigabitEthernet"); value.Exists() {
+ if value := res.Get(prefix + "ip.domain.lookup-settings.lookup.source-interface.GigabitEthernet"); value.Exists() && !data.IpDomainLookupSourceInterfaceGigabitEthernet.IsNull() {
data.IpDomainLookupSourceInterfaceGigabitEthernet = types.StringValue(value.String())
+ } else {
+ data.IpDomainLookupSourceInterfaceGigabitEthernet = types.StringNull()
}
- if value := res.Get(prefix + "ip.domain.lookup-settings.lookup.source-interface.TwoGigabitEthernet"); value.Exists() {
+ if value := res.Get(prefix + "ip.domain.lookup-settings.lookup.source-interface.TwoGigabitEthernet"); value.Exists() && !data.IpDomainLookupSourceInterfaceTwoGigabitEthernet.IsNull() {
data.IpDomainLookupSourceInterfaceTwoGigabitEthernet = types.StringValue(value.String())
+ } else {
+ data.IpDomainLookupSourceInterfaceTwoGigabitEthernet = types.StringNull()
}
- if value := res.Get(prefix + "ip.domain.lookup-settings.lookup.source-interface.FiveGigabitEthernet"); value.Exists() {
+ if value := res.Get(prefix + "ip.domain.lookup-settings.lookup.source-interface.FiveGigabitEthernet"); value.Exists() && !data.IpDomainLookupSourceInterfaceFiveGigabitEthernet.IsNull() {
data.IpDomainLookupSourceInterfaceFiveGigabitEthernet = types.StringValue(value.String())
+ } else {
+ data.IpDomainLookupSourceInterfaceFiveGigabitEthernet = types.StringNull()
}
- if value := res.Get(prefix + "ip.domain.lookup-settings.lookup.source-interface.TenGigabitEthernet"); value.Exists() {
+ if value := res.Get(prefix + "ip.domain.lookup-settings.lookup.source-interface.TenGigabitEthernet"); value.Exists() && !data.IpDomainLookupSourceInterfaceTenGigabitEthernet.IsNull() {
data.IpDomainLookupSourceInterfaceTenGigabitEthernet = types.StringValue(value.String())
+ } else {
+ data.IpDomainLookupSourceInterfaceTenGigabitEthernet = types.StringNull()
}
- if value := res.Get(prefix + "ip.domain.lookup-settings.lookup.source-interface.TwentyFiveGigE"); value.Exists() {
+ if value := res.Get(prefix + "ip.domain.lookup-settings.lookup.source-interface.TwentyFiveGigE"); value.Exists() && !data.IpDomainLookupSourceInterfaceTwentyFiveGigabitEthernet.IsNull() {
data.IpDomainLookupSourceInterfaceTwentyFiveGigabitEthernet = types.StringValue(value.String())
+ } else {
+ data.IpDomainLookupSourceInterfaceTwentyFiveGigabitEthernet = types.StringNull()
}
- if value := res.Get(prefix + "ip.domain.lookup-settings.lookup.source-interface.FortyGigabitEthernet"); value.Exists() {
+ if value := res.Get(prefix + "ip.domain.lookup-settings.lookup.source-interface.FortyGigabitEthernet"); value.Exists() && !data.IpDomainLookupSourceInterfaceFortyGigabitEthernet.IsNull() {
data.IpDomainLookupSourceInterfaceFortyGigabitEthernet = types.StringValue(value.String())
+ } else {
+ data.IpDomainLookupSourceInterfaceFortyGigabitEthernet = types.StringNull()
}
- if value := res.Get(prefix + "ip.domain.lookup-settings.lookup.source-interface.HundredGigE"); value.Exists() {
+ if value := res.Get(prefix + "ip.domain.lookup-settings.lookup.source-interface.HundredGigE"); value.Exists() && !data.IpDomainLookupSourceInterfaceHundredGigabitEthernet.IsNull() {
data.IpDomainLookupSourceInterfaceHundredGigabitEthernet = types.StringValue(value.String())
+ } else {
+ data.IpDomainLookupSourceInterfaceHundredGigabitEthernet = types.StringNull()
}
- if value := res.Get(prefix + "cisp.enable"); value.Exists() {
- data.CispEnable = types.BoolValue(true)
+ if value := res.Get(prefix + "cisp.enable"); !data.CispEnable.IsNull() {
+ if value.Exists() {
+ data.CispEnable = types.BoolValue(true)
+ } else {
+ data.CispEnable = types.BoolValue(false)
+ }
} else {
- data.CispEnable = types.BoolValue(false)
+ data.CispEnable = types.BoolNull()
}
- if value := res.Get(prefix + "epm.logging"); value.Exists() {
- data.EpmLogging = types.BoolValue(true)
+ if value := res.Get(prefix + "epm.logging"); !data.EpmLogging.IsNull() {
+ if value.Exists() {
+ data.EpmLogging = types.BoolValue(true)
+ } else {
+ data.EpmLogging = types.BoolValue(false)
+ }
} else {
- data.EpmLogging = types.BoolValue(false)
+ data.EpmLogging = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-sanet:access-session.mac-move.deny"); value.Exists() {
- data.AccessSessionMacMoveDeny = types.BoolValue(true)
+ if value := res.Get(prefix + "Cisco-IOS-XE-sanet:access-session.mac-move.deny"); !data.AccessSessionMacMoveDeny.IsNull() {
+ if value.Exists() {
+ data.AccessSessionMacMoveDeny = types.BoolValue(true)
+ } else {
+ data.AccessSessionMacMoveDeny = types.BoolValue(false)
+ }
} else {
- data.AccessSessionMacMoveDeny = types.BoolValue(false)
+ data.AccessSessionMacMoveDeny = types.BoolNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-diagnostics:diagnostic.bootup.level"); value.Exists() {
+ if value := res.Get(prefix + "Cisco-IOS-XE-diagnostics:diagnostic.bootup.level"); value.Exists() && !data.DiagnosticBootupLevel.IsNull() {
data.DiagnosticBootupLevel = types.StringValue(value.String())
+ } else {
+ data.DiagnosticBootupLevel = types.StringNull()
}
- if value := res.Get(prefix + "memory.free.low-watermark.processor"); value.Exists() {
+ if value := res.Get(prefix + "memory.free.low-watermark.processor"); value.Exists() && !data.MemoryFreeLowWatermarkProcessor.IsNull() {
data.MemoryFreeLowWatermarkProcessor = types.Int64Value(value.Int())
+ } else {
+ data.MemoryFreeLowWatermarkProcessor = types.Int64Null()
}
- if value := res.Get(prefix + "archive.path"); value.Exists() {
+ if value := res.Get(prefix + "archive.path"); value.Exists() && !data.ArchivePath.IsNull() {
data.ArchivePath = types.StringValue(value.String())
+ } else {
+ data.ArchivePath = types.StringNull()
}
- if value := res.Get(prefix + "archive.maximum"); value.Exists() {
+ if value := res.Get(prefix + "archive.maximum"); value.Exists() && !data.ArchiveMaximum.IsNull() {
data.ArchiveMaximum = types.Int64Value(value.Int())
+ } else {
+ data.ArchiveMaximum = types.Int64Null()
}
- if value := res.Get(prefix + "archive.write-memory"); value.Exists() {
- data.ArchiveWriteMemory = types.BoolValue(true)
+ if value := res.Get(prefix + "archive.write-memory"); !data.ArchiveWriteMemory.IsNull() {
+ if value.Exists() {
+ data.ArchiveWriteMemory = types.BoolValue(true)
+ } else {
+ data.ArchiveWriteMemory = types.BoolValue(false)
+ }
} else {
- data.ArchiveWriteMemory = types.BoolValue(false)
+ data.ArchiveWriteMemory = types.BoolNull()
}
- if value := res.Get(prefix + "archive.time-period"); value.Exists() {
+ if value := res.Get(prefix + "archive.time-period"); value.Exists() && !data.ArchiveTimePeriod.IsNull() {
data.ArchiveTimePeriod = types.Int64Value(value.Int())
+ } else {
+ data.ArchiveTimePeriod = types.Int64Null()
}
- if value := res.Get(prefix + "archive.log.config.logging.enable"); value.Exists() {
- data.ArchiveLogConfigLoggingEnable = types.BoolValue(true)
+ if value := res.Get(prefix + "archive.log.config.logging.enable"); !data.ArchiveLogConfigLoggingEnable.IsNull() {
+ if value.Exists() {
+ data.ArchiveLogConfigLoggingEnable = types.BoolValue(true)
+ } else {
+ data.ArchiveLogConfigLoggingEnable = types.BoolValue(false)
+ }
} else {
- data.ArchiveLogConfigLoggingEnable = types.BoolValue(false)
+ data.ArchiveLogConfigLoggingEnable = types.BoolNull()
}
- if value := res.Get(prefix + "archive.log.config.logging.size"); value.Exists() {
+ if value := res.Get(prefix + "archive.log.config.logging.size"); value.Exists() && !data.ArchiveLogConfigLoggingSize.IsNull() {
data.ArchiveLogConfigLoggingSize = types.Int64Value(value.Int())
+ } else {
+ data.ArchiveLogConfigLoggingSize = types.Int64Null()
}
- if value := res.Get(prefix + "redundancy"); value.Exists() {
- data.Redundancy = types.BoolValue(true)
+ if value := res.Get(prefix + "redundancy"); !data.Redundancy.IsNull() {
+ if value.Exists() {
+ data.Redundancy = types.BoolValue(true)
+ } else {
+ data.Redundancy = types.BoolValue(false)
+ }
} else {
- data.Redundancy = types.BoolValue(false)
+ data.Redundancy = types.BoolNull()
}
- if value := res.Get(prefix + "redundancy.mode"); value.Exists() {
+ if value := res.Get(prefix + "redundancy.mode"); value.Exists() && !data.RedundancyMode.IsNull() {
data.RedundancyMode = types.StringValue(value.String())
+ } else {
+ data.RedundancyMode = types.StringNull()
}
- if value := res.Get(prefix + "transceivers.type.all.monitoring-enable.monitoring"); value.Exists() {
- data.TransceiverTypeAllMonitoring = types.BoolValue(true)
+ if value := res.Get(prefix + "transceivers.type.all.monitoring-enable.monitoring"); !data.TransceiverTypeAllMonitoring.IsNull() {
+ if value.Exists() {
+ data.TransceiverTypeAllMonitoring = types.BoolValue(true)
+ } else {
+ data.TransceiverTypeAllMonitoring = types.BoolValue(false)
+ }
} else {
- data.TransceiverTypeAllMonitoring = types.BoolValue(false)
+ data.TransceiverTypeAllMonitoring = types.BoolNull()
}
- if value := res.Get(prefix + "ip.forward-protocol-v2.nd"); value.Exists() {
- data.IpForwardProtocolNd = types.BoolValue(value.Bool())
+ if value := res.Get(prefix + "ip.forward-protocol-v2.nd"); !data.IpForwardProtocolNd.IsNull() {
+ if value.Exists() {
+ data.IpForwardProtocolNd = types.BoolValue(value.Bool())
+ }
} else {
data.IpForwardProtocolNd = types.BoolNull()
}
- if value := res.Get(prefix + "ip.scp.server.enable"); value.Exists() {
- data.IpScpServerEnable = types.BoolValue(true)
+ if value := res.Get(prefix + "ip.scp.server.enable"); !data.IpScpServerEnable.IsNull() {
+ if value.Exists() {
+ data.IpScpServerEnable = types.BoolValue(true)
+ } else {
+ data.IpScpServerEnable = types.BoolValue(false)
+ }
} else {
- data.IpScpServerEnable = types.BoolValue(false)
+ data.IpScpServerEnable = types.BoolNull()
}
- if value := res.Get(prefix + "ip.ssh.ssh-version"); value.Exists() {
+ if value := res.Get(prefix + "ip.ssh.ssh-version"); value.Exists() && !data.IpSshVersion.IsNull() {
data.IpSshVersion = types.StringValue(value.String())
+ } else {
+ data.IpSshVersion = types.StringNull()
}
- if value := res.Get(prefix + "ip.ssh.version"); value.Exists() {
+ if value := res.Get(prefix + "ip.ssh.version"); value.Exists() && !data.IpSshVersionLegacy.IsNull() {
data.IpSshVersionLegacy = types.Int64Value(value.Int())
+ } else {
+ data.IpSshVersionLegacy = types.Int64Null()
}
- if value := res.Get(prefix + "ip.ssh.time-out"); value.Exists() {
+ if value := res.Get(prefix + "ip.ssh.time-out"); value.Exists() && !data.IpSshTimeOut.IsNull() {
data.IpSshTimeOut = types.Int64Value(value.Int())
+ } else {
+ data.IpSshTimeOut = types.Int64Null()
}
- if value := res.Get(prefix + "ip.ssh.authentication-retries"); value.Exists() {
+ if value := res.Get(prefix + "ip.ssh.authentication-retries"); value.Exists() && !data.IpSshAuthenticationRetries.IsNull() {
data.IpSshAuthenticationRetries = types.Int64Value(value.Int())
+ } else {
+ data.IpSshAuthenticationRetries = types.Int64Null()
}
- if value := res.Get(prefix + "ip.ssh.source-interface-config.Loopback"); value.Exists() {
+ if value := res.Get(prefix + "ip.ssh.source-interface-config.Loopback"); value.Exists() && !data.IpSshSourceInterfaceLoopback.IsNull() {
data.IpSshSourceInterfaceLoopback = types.Int64Value(value.Int())
+ } else {
+ data.IpSshSourceInterfaceLoopback = types.Int64Null()
}
- if value := res.Get(prefix + "ip.ssh.source-interface-config.Vlan"); value.Exists() {
+ if value := res.Get(prefix + "ip.ssh.source-interface-config.Vlan"); value.Exists() && !data.IpSshSourceInterfaceVlan.IsNull() {
data.IpSshSourceInterfaceVlan = types.Int64Value(value.Int())
+ } else {
+ data.IpSshSourceInterfaceVlan = types.Int64Null()
}
- if value := res.Get(prefix + "ip.ssh.source-interface-config.GigabitEthernet"); value.Exists() {
+ if value := res.Get(prefix + "ip.ssh.source-interface-config.GigabitEthernet"); value.Exists() && !data.IpSshSourceInterfaceGigabitEthernet.IsNull() {
data.IpSshSourceInterfaceGigabitEthernet = types.StringValue(value.String())
+ } else {
+ data.IpSshSourceInterfaceGigabitEthernet = types.StringNull()
}
- if value := res.Get(prefix + "ip.ssh.source-interface-config.TwoGigabitEthernet"); value.Exists() {
+ if value := res.Get(prefix + "ip.ssh.source-interface-config.TwoGigabitEthernet"); value.Exists() && !data.IpSshSourceInterfaceTwoGigabitEthernet.IsNull() {
data.IpSshSourceInterfaceTwoGigabitEthernet = types.StringValue(value.String())
+ } else {
+ data.IpSshSourceInterfaceTwoGigabitEthernet = types.StringNull()
}
- if value := res.Get(prefix + "ip.ssh.source-interface-config.FiveGigabitEthernet"); value.Exists() {
+ if value := res.Get(prefix + "ip.ssh.source-interface-config.FiveGigabitEthernet"); value.Exists() && !data.IpSshSourceInterfaceFiveGigabitEthernet.IsNull() {
data.IpSshSourceInterfaceFiveGigabitEthernet = types.StringValue(value.String())
+ } else {
+ data.IpSshSourceInterfaceFiveGigabitEthernet = types.StringNull()
}
- if value := res.Get(prefix + "ip.ssh.source-interface-config.TenGigabitEthernet"); value.Exists() {
+ if value := res.Get(prefix + "ip.ssh.source-interface-config.TenGigabitEthernet"); value.Exists() && !data.IpSshSourceInterfaceTenGigabitEthernet.IsNull() {
data.IpSshSourceInterfaceTenGigabitEthernet = types.StringValue(value.String())
+ } else {
+ data.IpSshSourceInterfaceTenGigabitEthernet = types.StringNull()
}
- if value := res.Get(prefix + "ip.ssh.source-interface-config.TwentyFiveGigE"); value.Exists() {
+ if value := res.Get(prefix + "ip.ssh.source-interface-config.TwentyFiveGigE"); value.Exists() && !data.IpSshSourceInterfaceTwentyFiveGigabitEthernet.IsNull() {
data.IpSshSourceInterfaceTwentyFiveGigabitEthernet = types.StringValue(value.String())
+ } else {
+ data.IpSshSourceInterfaceTwentyFiveGigabitEthernet = types.StringNull()
}
- if value := res.Get(prefix + "ip.ssh.source-interface-config.FortyGigabitEthernet"); value.Exists() {
+ if value := res.Get(prefix + "ip.ssh.source-interface-config.FortyGigabitEthernet"); value.Exists() && !data.IpSshSourceInterfaceFortyGigabitEthernet.IsNull() {
data.IpSshSourceInterfaceFortyGigabitEthernet = types.StringValue(value.String())
+ } else {
+ data.IpSshSourceInterfaceFortyGigabitEthernet = types.StringNull()
}
- if value := res.Get(prefix + "ip.ssh.source-interface-config.HundredGigE"); value.Exists() {
+ if value := res.Get(prefix + "ip.ssh.source-interface-config.HundredGigE"); value.Exists() && !data.IpSshSourceInterfaceHundredGigabitEthernet.IsNull() {
data.IpSshSourceInterfaceHundredGigabitEthernet = types.StringValue(value.String())
+ } else {
+ data.IpSshSourceInterfaceHundredGigabitEthernet = types.StringNull()
}
- if value := res.Get(prefix + "control-plane.Cisco-IOS-XE-policy:service-policy.input"); value.Exists() {
+ if value := res.Get(prefix + "control-plane.Cisco-IOS-XE-policy:service-policy.input"); value.Exists() && !data.ControlPlaneServicePolicyInput.IsNull() {
data.ControlPlaneServicePolicyInput = types.StringValue(value.String())
+ } else {
+ data.ControlPlaneServicePolicyInput = types.StringNull()
}
- if value := res.Get(prefix + "Cisco-IOS-XE-pnp:pnp.profile"); value.Exists() {
- data.PnpProfiles = make([]SystemPnpProfiles, 0)
- value.ForEach(func(k, v gjson.Result) bool {
- item := SystemPnpProfiles{}
- if cValue := v.Get("name"); cValue.Exists() {
- item.Name = types.StringValue(cValue.String())
- }
- if cValue := v.Get("transport.https.ipv4.ipv4-address"); cValue.Exists() {
- item.TransportHttpsIpv4Ipv4Address = types.StringValue(cValue.String())
- }
- if cValue := v.Get("transport.https.ipv4.port"); cValue.Exists() {
- item.TransportHttpsIpv4Port = types.Int64Value(cValue.Int())
- }
- data.PnpProfiles = append(data.PnpProfiles, item)
- return true
- })
+ for i := range data.PnpProfiles {
+ keys := [...]string{"name"}
+ keyValues := [...]string{data.PnpProfiles[i].Name.ValueString()}
+
+ var r gjson.Result
+ res.Get(prefix + "Cisco-IOS-XE-pnp:pnp.profile").ForEach(
+ func(_, v gjson.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := r.Get("name"); value.Exists() && !data.PnpProfiles[i].Name.IsNull() {
+ data.PnpProfiles[i].Name = types.StringValue(value.String())
+ } else {
+ data.PnpProfiles[i].Name = types.StringNull()
+ }
+ if value := r.Get("transport.https.ipv4.ipv4-address"); value.Exists() && !data.PnpProfiles[i].TransportHttpsIpv4Ipv4Address.IsNull() {
+ data.PnpProfiles[i].TransportHttpsIpv4Ipv4Address = types.StringValue(value.String())
+ } else {
+ data.PnpProfiles[i].TransportHttpsIpv4Ipv4Address = types.StringNull()
+ }
+ if value := r.Get("transport.https.ipv4.port"); value.Exists() && !data.PnpProfiles[i].TransportHttpsIpv4Port.IsNull() {
+ data.PnpProfiles[i].TransportHttpsIpv4Port = types.Int64Value(value.Int())
+ } else {
+ data.PnpProfiles[i].TransportHttpsIpv4Port = types.Int64Null()
+ }
}
- if value := res.Get(prefix + "ip.Cisco-IOS-XE-aaa:tacacs.source-interface.Loopback"); value.Exists() {
+ if value := res.Get(prefix + "ip.Cisco-IOS-XE-aaa:tacacs.source-interface.Loopback"); value.Exists() && !data.IpTacacsSourceInterfaceLoopback.IsNull() {
data.IpTacacsSourceInterfaceLoopback = types.Int64Value(value.Int())
+ } else {
+ data.IpTacacsSourceInterfaceLoopback = types.Int64Null()
}
- if value := res.Get(prefix + "ip.Cisco-IOS-XE-aaa:tacacs.source-interface.Vlan"); value.Exists() {
+ if value := res.Get(prefix + "ip.Cisco-IOS-XE-aaa:tacacs.source-interface.Vlan"); value.Exists() && !data.IpTacacsSourceInterfaceVlan.IsNull() {
data.IpTacacsSourceInterfaceVlan = types.Int64Value(value.Int())
+ } else {
+ data.IpTacacsSourceInterfaceVlan = types.Int64Null()
}
- if value := res.Get(prefix + "ip.Cisco-IOS-XE-aaa:tacacs.source-interface.GigabitEthernet"); value.Exists() {
+ if value := res.Get(prefix + "ip.Cisco-IOS-XE-aaa:tacacs.source-interface.GigabitEthernet"); value.Exists() && !data.IpTacacsSourceInterfaceGigabitEthernet.IsNull() {
data.IpTacacsSourceInterfaceGigabitEthernet = types.StringValue(value.String())
+ } else {
+ data.IpTacacsSourceInterfaceGigabitEthernet = types.StringNull()
}
- if value := res.Get(prefix + "ip.Cisco-IOS-XE-aaa:tacacs.source-interface.TwoGigabitEthernet"); value.Exists() {
+ if value := res.Get(prefix + "ip.Cisco-IOS-XE-aaa:tacacs.source-interface.TwoGigabitEthernet"); value.Exists() && !data.IpTacacsSourceInterfaceTwoGigabitEthernet.IsNull() {
data.IpTacacsSourceInterfaceTwoGigabitEthernet = types.StringValue(value.String())
+ } else {
+ data.IpTacacsSourceInterfaceTwoGigabitEthernet = types.StringNull()
}
- if value := res.Get(prefix + "ip.Cisco-IOS-XE-aaa:tacacs.source-interface.FiveGigabitEthernet"); value.Exists() {
+ if value := res.Get(prefix + "ip.Cisco-IOS-XE-aaa:tacacs.source-interface.FiveGigabitEthernet"); value.Exists() && !data.IpTacacsSourceInterfaceFiveGigabitEthernet.IsNull() {
data.IpTacacsSourceInterfaceFiveGigabitEthernet = types.StringValue(value.String())
+ } else {
+ data.IpTacacsSourceInterfaceFiveGigabitEthernet = types.StringNull()
}
- if value := res.Get(prefix + "ip.Cisco-IOS-XE-aaa:tacacs.source-interface.TenGigabitEthernet"); value.Exists() {
+ if value := res.Get(prefix + "ip.Cisco-IOS-XE-aaa:tacacs.source-interface.TenGigabitEthernet"); value.Exists() && !data.IpTacacsSourceInterfaceTenGigabitEthernet.IsNull() {
data.IpTacacsSourceInterfaceTenGigabitEthernet = types.StringValue(value.String())
+ } else {
+ data.IpTacacsSourceInterfaceTenGigabitEthernet = types.StringNull()
}
- if value := res.Get(prefix + "ip.Cisco-IOS-XE-aaa:tacacs.source-interface.TwentyFiveGigE"); value.Exists() {
+ if value := res.Get(prefix + "ip.Cisco-IOS-XE-aaa:tacacs.source-interface.TwentyFiveGigE"); value.Exists() && !data.IpTacacsSourceInterfaceTwentyFiveGigabitEthernet.IsNull() {
data.IpTacacsSourceInterfaceTwentyFiveGigabitEthernet = types.StringValue(value.String())
+ } else {
+ data.IpTacacsSourceInterfaceTwentyFiveGigabitEthernet = types.StringNull()
}
- if value := res.Get(prefix + "ip.Cisco-IOS-XE-aaa:tacacs.source-interface.FortyGigabitEthernet"); value.Exists() {
+ if value := res.Get(prefix + "ip.Cisco-IOS-XE-aaa:tacacs.source-interface.FortyGigabitEthernet"); value.Exists() && !data.IpTacacsSourceInterfaceFortyGigabitEthernet.IsNull() {
data.IpTacacsSourceInterfaceFortyGigabitEthernet = types.StringValue(value.String())
+ } else {
+ data.IpTacacsSourceInterfaceFortyGigabitEthernet = types.StringNull()
}
- if value := res.Get(prefix + "ip.Cisco-IOS-XE-aaa:tacacs.source-interface.HundredGigE"); value.Exists() {
+ if value := res.Get(prefix + "ip.Cisco-IOS-XE-aaa:tacacs.source-interface.HundredGigE"); value.Exists() && !data.IpTacacsSourceInterfaceHundredGigabitEthernet.IsNull() {
data.IpTacacsSourceInterfaceHundredGigabitEthernet = types.StringValue(value.String())
+ } else {
+ data.IpTacacsSourceInterfaceHundredGigabitEthernet = types.StringNull()
}
- if value := res.Get(prefix + "ip.Cisco-IOS-XE-aaa:tacacs.source-interface.vrf"); value.Exists() {
+ if value := res.Get(prefix + "ip.Cisco-IOS-XE-aaa:tacacs.source-interface.vrf"); value.Exists() && !data.IpTacacsSourceInterfaceVrf.IsNull() {
data.IpTacacsSourceInterfaceVrf = types.StringValue(value.String())
+ } else {
+ data.IpTacacsSourceInterfaceVrf = types.StringNull()
}
- if value := res.Get(prefix + "ip.Cisco-IOS-XE-aaa:radius.source-interface.Loopback"); value.Exists() {
+ if value := res.Get(prefix + "ip.Cisco-IOS-XE-aaa:radius.source-interface.Loopback"); value.Exists() && !data.IpRadiusSourceInterfaceLoopback.IsNull() {
data.IpRadiusSourceInterfaceLoopback = types.Int64Value(value.Int())
+ } else {
+ data.IpRadiusSourceInterfaceLoopback = types.Int64Null()
}
- if value := res.Get(prefix + "ip.Cisco-IOS-XE-aaa:radius.source-interface.Vlan"); value.Exists() {
+ if value := res.Get(prefix + "ip.Cisco-IOS-XE-aaa:radius.source-interface.Vlan"); value.Exists() && !data.IpRadiusSourceInterfaceVlan.IsNull() {
data.IpRadiusSourceInterfaceVlan = types.Int64Value(value.Int())
+ } else {
+ data.IpRadiusSourceInterfaceVlan = types.Int64Null()
}
- if value := res.Get(prefix + "ip.Cisco-IOS-XE-aaa:radius.source-interface.GigabitEthernet"); value.Exists() {
+ if value := res.Get(prefix + "ip.Cisco-IOS-XE-aaa:radius.source-interface.GigabitEthernet"); value.Exists() && !data.IpRadiusSourceInterfaceGigabitEthernet.IsNull() {
data.IpRadiusSourceInterfaceGigabitEthernet = types.StringValue(value.String())
+ } else {
+ data.IpRadiusSourceInterfaceGigabitEthernet = types.StringNull()
}
- if value := res.Get(prefix + "ip.Cisco-IOS-XE-aaa:radius.source-interface.TwoGigabitEthernet"); value.Exists() {
+ if value := res.Get(prefix + "ip.Cisco-IOS-XE-aaa:radius.source-interface.TwoGigabitEthernet"); value.Exists() && !data.IpRadiusSourceInterfaceTwoGigabitEthernet.IsNull() {
data.IpRadiusSourceInterfaceTwoGigabitEthernet = types.StringValue(value.String())
+ } else {
+ data.IpRadiusSourceInterfaceTwoGigabitEthernet = types.StringNull()
}
- if value := res.Get(prefix + "ip.Cisco-IOS-XE-aaa:radius.source-interface.FiveGigabitEthernet"); value.Exists() {
+ if value := res.Get(prefix + "ip.Cisco-IOS-XE-aaa:radius.source-interface.FiveGigabitEthernet"); value.Exists() && !data.IpRadiusSourceInterfaceFiveGigabitEthernet.IsNull() {
data.IpRadiusSourceInterfaceFiveGigabitEthernet = types.StringValue(value.String())
+ } else {
+ data.IpRadiusSourceInterfaceFiveGigabitEthernet = types.StringNull()
}
- if value := res.Get(prefix + "ip.Cisco-IOS-XE-aaa:radius.source-interface.TenGigabitEthernet"); value.Exists() {
+ if value := res.Get(prefix + "ip.Cisco-IOS-XE-aaa:radius.source-interface.TenGigabitEthernet"); value.Exists() && !data.IpRadiusSourceInterfaceTenGigabitEthernet.IsNull() {
data.IpRadiusSourceInterfaceTenGigabitEthernet = types.StringValue(value.String())
+ } else {
+ data.IpRadiusSourceInterfaceTenGigabitEthernet = types.StringNull()
}
- if value := res.Get(prefix + "ip.Cisco-IOS-XE-aaa:radius.source-interface.TwentyFiveGigE"); value.Exists() {
+ if value := res.Get(prefix + "ip.Cisco-IOS-XE-aaa:radius.source-interface.TwentyFiveGigE"); value.Exists() && !data.IpRadiusSourceInterfaceTwentyFiveGigabitEthernet.IsNull() {
data.IpRadiusSourceInterfaceTwentyFiveGigabitEthernet = types.StringValue(value.String())
+ } else {
+ data.IpRadiusSourceInterfaceTwentyFiveGigabitEthernet = types.StringNull()
}
- if value := res.Get(prefix + "ip.Cisco-IOS-XE-aaa:radius.source-interface.FortyGigabitEthernet"); value.Exists() {
+ if value := res.Get(prefix + "ip.Cisco-IOS-XE-aaa:radius.source-interface.FortyGigabitEthernet"); value.Exists() && !data.IpRadiusSourceInterfaceFortyGigabitEthernet.IsNull() {
data.IpRadiusSourceInterfaceFortyGigabitEthernet = types.StringValue(value.String())
+ } else {
+ data.IpRadiusSourceInterfaceFortyGigabitEthernet = types.StringNull()
}
- if value := res.Get(prefix + "ip.Cisco-IOS-XE-aaa:radius.source-interface.HundredGigE"); value.Exists() {
+ if value := res.Get(prefix + "ip.Cisco-IOS-XE-aaa:radius.source-interface.HundredGigE"); value.Exists() && !data.IpRadiusSourceInterfaceHundredGigabitEthernet.IsNull() {
data.IpRadiusSourceInterfaceHundredGigabitEthernet = types.StringValue(value.String())
+ } else {
+ data.IpRadiusSourceInterfaceHundredGigabitEthernet = types.StringNull()
}
- if value := res.Get(prefix + "ip.Cisco-IOS-XE-aaa:radius.source-interface.vrf"); value.Exists() {
+ if value := res.Get(prefix + "ip.Cisco-IOS-XE-aaa:radius.source-interface.vrf"); value.Exists() && !data.IpRadiusSourceInterfaceVrf.IsNull() {
data.IpRadiusSourceInterfaceVrf = types.StringValue(value.String())
+ } else {
+ data.IpRadiusSourceInterfaceVrf = types.StringNull()
}
- if value := res.Get(prefix + "boot.system.flash.flash-list-ordered-by-user"); value.Exists() {
- data.BootSystemFlashFiles = make([]SystemBootSystemFlashFiles, 0)
- value.ForEach(func(k, v gjson.Result) bool {
- item := SystemBootSystemFlashFiles{}
- if cValue := v.Get("flash-leaf"); cValue.Exists() {
- item.Path = types.StringValue(cValue.String())
- }
- data.BootSystemFlashFiles = append(data.BootSystemFlashFiles, item)
- return true
- })
- }
- if value := res.Get(prefix + "boot.system.bootfile.filename-list-ordered-by-user"); value.Exists() {
- data.BootSystemBootfiles = make([]SystemBootSystemBootfiles, 0)
- value.ForEach(func(k, v gjson.Result) bool {
- item := SystemBootSystemBootfiles{}
- if cValue := v.Get("filename"); cValue.Exists() {
- item.Path = types.StringValue(cValue.String())
- }
- data.BootSystemBootfiles = append(data.BootSystemBootfiles, item)
- return true
- })
- }
- if value := res.Get(prefix + "enable.secret.secret"); value.Exists() {
- data.EnableSecret = types.StringValue(value.String())
+ for i := range data.BootSystemFlashFiles {
+ keys := [...]string{"flash-leaf"}
+ keyValues := [...]string{data.BootSystemFlashFiles[i].Path.ValueString()}
+
+ var r gjson.Result
+ res.Get(prefix + "boot.system.flash.flash-list-ordered-by-user").ForEach(
+ func(_, v gjson.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := r.Get("flash-leaf"); value.Exists() && !data.BootSystemFlashFiles[i].Path.IsNull() {
+ data.BootSystemFlashFiles[i].Path = types.StringValue(value.String())
+ } else {
+ data.BootSystemFlashFiles[i].Path = types.StringNull()
+ }
}
- if value := res.Get(prefix + "enable.secret.type"); value.Exists() {
- data.EnableSecretType = types.StringValue(value.String())
+ for i := range data.BootSystemBootfiles {
+ keys := [...]string{"filename"}
+ keyValues := [...]string{data.BootSystemBootfiles[i].Path.ValueString()}
+
+ var r gjson.Result
+ res.Get(prefix + "boot.system.bootfile.filename-list-ordered-by-user").ForEach(
+ func(_, v gjson.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := r.Get("filename"); value.Exists() && !data.BootSystemBootfiles[i].Path.IsNull() {
+ data.BootSystemBootfiles[i].Path = types.StringValue(value.String())
+ } else {
+ data.BootSystemBootfiles[i].Path = types.StringNull()
+ }
}
- if value := res.Get(prefix + "enable.secret.level"); value.Exists() {
+ if value := res.Get(prefix + "enable.secret.level"); value.Exists() && !data.EnableSecretLevel.IsNull() {
data.EnableSecretLevel = types.Int64Value(value.Int())
+ } else {
+ data.EnableSecretLevel = types.Int64Null()
}
- if value := res.Get(prefix + "ip.host.host-list"); value.Exists() {
- data.IpHosts = make([]SystemIpHosts, 0)
- value.ForEach(func(k, v gjson.Result) bool {
- item := SystemIpHosts{}
- if cValue := v.Get("name"); cValue.Exists() {
- item.Name = types.StringValue(cValue.String())
- }
- if cValue := v.Get("ip-list-ordered"); cValue.Exists() {
- item.Ips = helpers.GetStringList(cValue.Array())
- } else {
- item.Ips = types.ListNull(types.StringType)
- }
- data.IpHosts = append(data.IpHosts, item)
- return true
- })
+ for i := range data.IpHosts {
+ keys := [...]string{"name"}
+ keyValues := [...]string{data.IpHosts[i].Name.ValueString()}
+
+ var r gjson.Result
+ res.Get(prefix + "ip.host.host-list").ForEach(
+ func(_, v gjson.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := r.Get("name"); value.Exists() && !data.IpHosts[i].Name.IsNull() {
+ data.IpHosts[i].Name = types.StringValue(value.String())
+ } else {
+ data.IpHosts[i].Name = types.StringNull()
+ }
+ if value := r.Get("ip-list-ordered"); value.Exists() && !data.IpHosts[i].Ips.IsNull() {
+ data.IpHosts[i].Ips = helpers.GetStringList(value.Array())
+ } else {
+ data.IpHosts[i].Ips = types.ListNull(types.StringType)
+ }
}
- if value := res.Get(prefix + "ip.host.vrf"); value.Exists() {
- data.IpHostsVrf = make([]SystemIpHostsVrf, 0)
- value.ForEach(func(k, v gjson.Result) bool {
- item := SystemIpHostsVrf{}
- if cValue := v.Get("vrf-name"); cValue.Exists() {
- item.Vrf = types.StringValue(cValue.String())
- }
- if cValue := v.Get("host-name"); cValue.Exists() {
- item.Hosts = make([]SystemIpHostsVrfHosts, 0)
- cValue.ForEach(func(ck, cv gjson.Result) bool {
- cItem := SystemIpHostsVrfHosts{}
- if ccValue := cv.Get("host-name"); ccValue.Exists() {
- cItem.Name = types.StringValue(ccValue.String())
+ for i := range data.IpHostsVrf {
+ keys := [...]string{"vrf-name"}
+ keyValues := [...]string{data.IpHostsVrf[i].Vrf.ValueString()}
+
+ var r gjson.Result
+ res.Get(prefix + "ip.host.vrf").ForEach(
+ func(_, v gjson.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
}
- if ccValue := cv.Get("ip-list"); ccValue.Exists() {
- cItem.Ips = helpers.GetStringList(ccValue.Array())
- } else {
- cItem.Ips = types.ListNull(types.StringType)
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := r.Get("vrf-name"); value.Exists() && !data.IpHostsVrf[i].Vrf.IsNull() {
+ data.IpHostsVrf[i].Vrf = types.StringValue(value.String())
+ } else {
+ data.IpHostsVrf[i].Vrf = types.StringNull()
+ }
+ for ci := range data.IpHostsVrf[i].Hosts {
+ keys := [...]string{"host-name"}
+ keyValues := [...]string{data.IpHostsVrf[i].Hosts[ci].Name.ValueString()}
+
+ var cr gjson.Result
+ r.Get("host-name").ForEach(
+ func(_, v gjson.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ cr = v
+ return false
}
- item.Hosts = append(item.Hosts, cItem)
return true
- })
+ },
+ )
+ if value := cr.Get("host-name"); value.Exists() && !data.IpHostsVrf[i].Hosts[ci].Name.IsNull() {
+ data.IpHostsVrf[i].Hosts[ci].Name = types.StringValue(value.String())
+ } else {
+ data.IpHostsVrf[i].Hosts[ci].Name = types.StringNull()
}
- data.IpHostsVrf = append(data.IpHostsVrf, item)
- return true
- })
+ if value := cr.Get("ip-list"); value.Exists() && !data.IpHostsVrf[i].Hosts[ci].Ips.IsNull() {
+ data.IpHostsVrf[i].Hosts[ci].Ips = helpers.GetStringList(value.Array())
+ } else {
+ data.IpHostsVrf[i].Hosts[ci].Ips = types.ListNull(types.StringType)
+ }
+ }
}
- if value := res.Get(prefix + "Cisco-IOS-XE-diagnostics:diagnostic.event-log.size"); value.Exists() {
+ if value := res.Get(prefix + "Cisco-IOS-XE-diagnostics:diagnostic.event-log.size"); value.Exists() && !data.DiagnosticEventLogSize.IsNull() {
data.DiagnosticEventLogSize = types.Int64Value(value.Int())
+ } else {
+ data.DiagnosticEventLogSize = types.Int64Null()
}
- if value := res.Get(prefix + "subscriber.templating"); value.Exists() {
- data.SubscriberTemplating = types.BoolValue(true)
+ if value := res.Get(prefix + "subscriber.templating"); !data.SubscriberTemplating.IsNull() {
+ if value.Exists() {
+ data.SubscriberTemplating = types.BoolValue(true)
+ } else {
+ data.SubscriberTemplating = types.BoolValue(false)
+ }
} else {
- data.SubscriberTemplating = types.BoolValue(false)
+ data.SubscriberTemplating = types.BoolNull()
}
- if value := res.Get(prefix + "call-home.Cisco-IOS-XE-call-home:contact-email-addr"); value.Exists() {
+ if value := res.Get(prefix + "call-home.Cisco-IOS-XE-call-home:contact-email-addr"); value.Exists() && !data.CallHomeContactEmail.IsNull() {
data.CallHomeContactEmail = types.StringValue(value.String())
+ } else {
+ data.CallHomeContactEmail = types.StringNull()
+ }
+ if value := res.Get(prefix + "call-home.Cisco-IOS-XE-call-home:tac-profile.profile.CiscoTAC-1.active"); !data.CallHomeCiscoTac1ProfileActive.IsNull() {
+ if value.Exists() {
+ data.CallHomeCiscoTac1ProfileActive = types.BoolValue(value.Bool())
+ }
+ } else {
+ data.CallHomeCiscoTac1ProfileActive = types.BoolNull()
+ }
+ if value := res.Get(prefix + "call-home.Cisco-IOS-XE-call-home:tac-profile.profile.CiscoTAC-1.destination.transport-method"); value.Exists() && !data.CallHomeCiscoTac1DestinationTransportMethod.IsNull() {
+ data.CallHomeCiscoTac1DestinationTransportMethod = types.StringValue(value.String())
+ } else {
+ data.CallHomeCiscoTac1DestinationTransportMethod = types.StringNull()
+ }
+ if value := res.Get(prefix + "ip.ftp.passive-enable"); !data.IpFtpPassive.IsNull() {
+ if value.Exists() {
+ data.IpFtpPassive = types.BoolValue(value.Bool())
+ }
+ } else {
+ data.IpFtpPassive = types.BoolNull()
+ }
+ if value := res.Get(prefix + "ip.tftp.source-interface.GigabitEthernet"); value.Exists() && !data.TftpSourceInterfaceGigabitEthernet.IsNull() {
+ data.TftpSourceInterfaceGigabitEthernet = types.StringValue(value.String())
+ } else {
+ data.TftpSourceInterfaceGigabitEthernet = types.StringNull()
+ }
+ if value := res.Get(prefix + "ip.tftp.source-interface.Loopback"); value.Exists() && !data.TftpSourceInterfaceLoopback.IsNull() {
+ data.TftpSourceInterfaceLoopback = types.Int64Value(value.Int())
+ } else {
+ data.TftpSourceInterfaceLoopback = types.Int64Null()
+ }
+ if value := res.Get(prefix + "ip.tftp.source-interface.Vlan"); value.Exists() && !data.TftpSourceInterfaceVlan.IsNull() {
+ data.TftpSourceInterfaceVlan = types.Int64Value(value.Int())
+ } else {
+ data.TftpSourceInterfaceVlan = types.Int64Null()
+ }
+ if value := res.Get(prefix + "ip.tftp.source-interface.TwoGigabitEthernet"); value.Exists() && !data.TftpSourceInterfaceTwoGigabitEthernet.IsNull() {
+ data.TftpSourceInterfaceTwoGigabitEthernet = types.StringValue(value.String())
+ } else {
+ data.TftpSourceInterfaceTwoGigabitEthernet = types.StringNull()
+ }
+ if value := res.Get(prefix + "ip.tftp.source-interface.FiveGigabitEthernet"); value.Exists() && !data.TftpSourceInterfaceFiveGigabitEthernet.IsNull() {
+ data.TftpSourceInterfaceFiveGigabitEthernet = types.StringValue(value.String())
+ } else {
+ data.TftpSourceInterfaceFiveGigabitEthernet = types.StringNull()
+ }
+ if value := res.Get(prefix + "ip.tftp.source-interface.TenGigabitEthernet"); value.Exists() && !data.TftpSourceInterfaceTenGigabitEthernet.IsNull() {
+ data.TftpSourceInterfaceTenGigabitEthernet = types.StringValue(value.String())
+ } else {
+ data.TftpSourceInterfaceTenGigabitEthernet = types.StringNull()
+ }
+ if value := res.Get(prefix + "ip.tftp.source-interface.TwentyFiveGigabitEthernet"); value.Exists() && !data.TftpSourceInterfaceTwentyFiveGigabitEthernet.IsNull() {
+ data.TftpSourceInterfaceTwentyFiveGigabitEthernet = types.StringValue(value.String())
+ } else {
+ data.TftpSourceInterfaceTwentyFiveGigabitEthernet = types.StringNull()
+ }
+ if value := res.Get(prefix + "ip.tftp.source-interface.FortyGigabitEthernet"); value.Exists() && !data.TftpSourceInterfaceFortyGigabitEthernet.IsNull() {
+ data.TftpSourceInterfaceFortyGigabitEthernet = types.StringValue(value.String())
+ } else {
+ data.TftpSourceInterfaceFortyGigabitEthernet = types.StringNull()
+ }
+ if value := res.Get(prefix + "ip.tftp.source-interface.HundredGigE"); value.Exists() && !data.TftpSourceInterfaceHundredGigabitEthernet.IsNull() {
+ data.TftpSourceInterfaceHundredGigabitEthernet = types.StringValue(value.String())
+ } else {
+ data.TftpSourceInterfaceHundredGigabitEthernet = types.StringNull()
+ }
+ if value := res.Get(prefix + "multilink.Cisco-IOS-XE-ppp:bundle-name"); value.Exists() && !data.MultilinkPppBundleName.IsNull() {
+ data.MultilinkPppBundleName = types.StringValue(value.String())
+ } else {
+ data.MultilinkPppBundleName = types.StringNull()
+ }
+ if value := res.Get(prefix + "version"); value.Exists() && !data.Version.IsNull() {
+ data.Version = types.StringValue(value.String())
+ } else {
+ data.Version = types.StringNull()
+ }
+ for i := range data.TrackObjects {
+ keys := [...]string{"object-number"}
+ keyValues := [...]string{data.TrackObjects[i].Number.ValueString()}
+
+ var r gjson.Result
+ res.Get(prefix + "track.Cisco-IOS-XE-track:tracked-object-v2").ForEach(
+ func(_, v gjson.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := r.Get("object-number"); value.Exists() && !data.TrackObjects[i].Number.IsNull() {
+ data.TrackObjects[i].Number = types.StringValue(value.String())
+ } else {
+ data.TrackObjects[i].Number = types.StringNull()
+ }
+ if value := r.Get("ip.sla.number"); value.Exists() && !data.TrackObjects[i].IpSlaNumber.IsNull() {
+ data.TrackObjects[i].IpSlaNumber = types.Int64Value(value.Int())
+ } else {
+ data.TrackObjects[i].IpSlaNumber = types.Int64Null()
+ }
+ if value := r.Get("ip.sla.reachability"); !data.TrackObjects[i].IpSlaReachability.IsNull() {
+ if value.Exists() {
+ data.TrackObjects[i].IpSlaReachability = types.BoolValue(true)
+ } else {
+ data.TrackObjects[i].IpSlaReachability = types.BoolValue(false)
+ }
+ } else {
+ data.TrackObjects[i].IpSlaReachability = types.BoolNull()
+ }
+ }
+ if value := res.Get(prefix + "ip.Cisco-IOS-XE-nbar:nbar.classification.dns.classify-by-domain-with-default"); !data.IpNbarClassificationDnsClassifyByDomain.IsNull() {
+ if value.Exists() {
+ data.IpNbarClassificationDnsClassifyByDomain = types.BoolValue(value.Bool())
+ }
+ } else {
+ data.IpNbarClassificationDnsClassifyByDomain = types.BoolNull()
+ }
+ if value := res.Get(prefix + "ip.multicast.Cisco-IOS-XE-multicast:route-limit-container.routelimit"); value.Exists() && !data.IpMulticastRouteLimit.IsNull() {
+ data.IpMulticastRouteLimit = types.Int64Value(value.Int())
+ } else {
+ data.IpMulticastRouteLimit = types.Int64Null()
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-aaa:security.passwords.min-length"); value.Exists() && !data.SecurityPasswordsMinLength.IsNull() {
+ data.SecurityPasswordsMinLength = types.Int64Value(value.Int())
+ } else {
+ data.SecurityPasswordsMinLength = types.Int64Null()
+ }
+ if value := res.Get(prefix + "ip.domain.list.domain-name"); value.Exists() && !data.IpDomainListNames.IsNull() {
+ data.IpDomainListNames = helpers.GetStringList(value.Array())
+ } else {
+ data.IpDomainListNames = types.ListNull(types.StringType)
+ }
+ if value := res.Get(prefix + "ip.domain.list.vrf.domain-name"); value.Exists() && !data.IpDomainListVrfDomain.IsNull() {
+ data.IpDomainListVrfDomain = types.StringValue(value.String())
+ } else {
+ data.IpDomainListVrfDomain = types.StringNull()
+ }
+ if value := res.Get(prefix + "ip.domain.list.vrf.vrf-name"); value.Exists() && !data.IpDomainListVrf.IsNull() {
+ data.IpDomainListVrf = types.StringValue(value.String())
+ } else {
+ data.IpDomainListVrf = types.StringNull()
+ }
+ if value := res.Get(prefix + "ethernet.Cisco-IOS-XE-ethernet:cfm.alarm-config.delay"); value.Exists() && !data.EthernetCfmAlarmConfigDelay.IsNull() {
+ data.EthernetCfmAlarmConfigDelay = types.Int64Value(value.Int())
+ } else {
+ data.EthernetCfmAlarmConfigDelay = types.Int64Null()
+ }
+ if value := res.Get(prefix + "ethernet.Cisco-IOS-XE-ethernet:cfm.alarm-config.reset"); value.Exists() && !data.EthernetCfmAlarmConfigReset.IsNull() {
+ data.EthernetCfmAlarmConfigReset = types.Int64Value(value.Int())
+ } else {
+ data.EthernetCfmAlarmConfigReset = types.Int64Null()
+ }
+ if value := res.Get(prefix + "standby.redirects-config.redirects"); !data.StandbyRedirects.IsNull() {
+ if value.Exists() {
+ data.StandbyRedirects = types.BoolValue(value.Bool())
+ }
+ } else {
+ data.StandbyRedirects = types.BoolNull()
+ }
+ if value := res.Get(prefix + "standby.redirects-config.redirect-enable-disable.redirects"); value.Exists() && !data.StandbyRedirectsEnableDisable.IsNull() {
+ data.StandbyRedirectsEnableDisable = types.StringValue(value.String())
+ } else {
+ data.StandbyRedirectsEnableDisable = types.StringNull()
+ }
+}
+
+// End of section. //template:end updateFromBody
+
+// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBodyXML
+
+func (data *System) updateFromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/hostname"); value.Exists() && !data.Hostname.IsNull() {
+ data.Hostname = types.StringValue(value.String())
+ } else {
+ data.Hostname = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/bgp-community/new-format"); !data.IpBgpCommunityNewFormat.IsNull() {
+ if value.Exists() {
+ data.IpBgpCommunityNewFormat = types.BoolValue(true)
+ } else {
+ data.IpBgpCommunityNewFormat = types.BoolValue(false)
+ }
+ } else {
+ data.IpBgpCommunityNewFormat = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/routing-conf/routing"); !data.IpRouting.IsNull() {
+ if value.Exists() {
+ data.IpRouting = types.BoolValue(value.Bool())
+ }
+ } else {
+ data.IpRouting = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ipv6/unicast-routing"); !data.Ipv6UnicastRouting.IsNull() {
+ if value.Exists() {
+ data.Ipv6UnicastRouting = types.BoolValue(true)
+ } else {
+ data.Ipv6UnicastRouting = types.BoolValue(false)
+ }
+ } else {
+ data.Ipv6UnicastRouting = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/system/Cisco-IOS-XE-switch:mtu/size"); value.Exists() && !data.Mtu.IsNull() {
+ data.Mtu = types.Int64Value(value.Int())
+ } else {
+ data.Mtu = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/source-route"); !data.IpSourceRoute.IsNull() {
+ if value.Exists() {
+ data.IpSourceRoute = types.BoolValue(value.Bool())
+ }
+ } else {
+ data.IpSourceRoute = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/domain/lookup"); !data.IpDomainLookup.IsNull() {
+ if value.Exists() {
+ data.IpDomainLookup = types.BoolValue(value.Bool())
+ }
+ } else {
+ data.IpDomainLookup = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/domain/name"); value.Exists() && !data.IpDomainName.IsNull() {
+ data.IpDomainName = types.StringValue(value.String())
+ } else {
+ data.IpDomainName = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/login/delay"); value.Exists() && !data.LoginDelay.IsNull() {
+ data.LoginDelay = types.Int64Value(value.Int())
+ } else {
+ data.LoginDelay = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/login/on-failure"); !data.LoginOnFailure.IsNull() {
+ if value.Exists() {
+ data.LoginOnFailure = types.BoolValue(true)
+ } else {
+ data.LoginOnFailure = types.BoolValue(false)
+ }
+ } else {
+ data.LoginOnFailure = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/login/on-failure/log"); !data.LoginOnFailureLog.IsNull() {
+ if value.Exists() {
+ data.LoginOnFailureLog = types.BoolValue(true)
+ } else {
+ data.LoginOnFailureLog = types.BoolValue(false)
+ }
+ } else {
+ data.LoginOnFailureLog = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/login/on-success"); !data.LoginOnSuccess.IsNull() {
+ if value.Exists() {
+ data.LoginOnSuccess = types.BoolValue(true)
+ } else {
+ data.LoginOnSuccess = types.BoolValue(false)
+ }
+ } else {
+ data.LoginOnSuccess = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/login/on-success/log"); !data.LoginOnSuccessLog.IsNull() {
+ if value.Exists() {
+ data.LoginOnSuccessLog = types.BoolValue(true)
+ } else {
+ data.LoginOnSuccessLog = types.BoolValue(false)
+ }
+ } else {
+ data.LoginOnSuccessLog = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/Cisco-IOS-XE-multicast:multicast-routing"); !data.IpMulticastRouting.IsNull() {
+ if value.Exists() {
+ data.IpMulticastRouting = types.BoolValue(true)
+ } else {
+ data.IpMulticastRouting = types.BoolValue(false)
+ }
+ } else {
+ data.IpMulticastRouting = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/Cisco-IOS-XE-multicast:mcr-conf/multicast-routing"); !data.MulticastRoutingSwitch.IsNull() {
+ if value.Exists() {
+ data.MulticastRoutingSwitch = types.BoolValue(true)
+ } else {
+ data.MulticastRoutingSwitch = types.BoolValue(false)
+ }
+ } else {
+ data.MulticastRoutingSwitch = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/Cisco-IOS-XE-multicast:multicast-routing/distributed"); !data.IpMulticastRoutingDistributed.IsNull() {
+ if value.Exists() {
+ data.IpMulticastRoutingDistributed = types.BoolValue(true)
+ } else {
+ data.IpMulticastRoutingDistributed = types.BoolValue(false)
+ }
+ } else {
+ data.IpMulticastRoutingDistributed = types.BoolNull()
+ }
+ for i := range data.MulticastRoutingVrfs {
+ keys := [...]string{"name"}
+ keyValues := [...]string{data.MulticastRoutingVrfs[i].Vrf.ValueString()}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/Cisco-IOS-XE-multicast:multicast-routing/vrf").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, "name"); value.Exists() && !data.MulticastRoutingVrfs[i].Vrf.IsNull() {
+ data.MulticastRoutingVrfs[i].Vrf = types.StringValue(value.String())
+ } else {
+ data.MulticastRoutingVrfs[i].Vrf = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "distributed"); !data.MulticastRoutingVrfs[i].Distributed.IsNull() {
+ if value.Exists() {
+ data.MulticastRoutingVrfs[i].Distributed = types.BoolValue(true)
+ } else {
+ data.MulticastRoutingVrfs[i].Distributed = types.BoolValue(false)
+ }
+ } else {
+ data.MulticastRoutingVrfs[i].Distributed = types.BoolNull()
+ }
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/Cisco-IOS-XE-http:http/access-class"); value.Exists() && !data.IpHttpAccessClass.IsNull() {
+ data.IpHttpAccessClass = types.Int64Value(value.Int())
+ } else {
+ data.IpHttpAccessClass = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/Cisco-IOS-XE-http:http/authentication/aaa"); !data.IpHttpAuthenticationAaa.IsNull() {
+ if value.Exists() {
+ data.IpHttpAuthenticationAaa = types.BoolValue(true)
+ } else {
+ data.IpHttpAuthenticationAaa = types.BoolValue(false)
+ }
+ } else {
+ data.IpHttpAuthenticationAaa = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/Cisco-IOS-XE-http:http/authentication/aaa/exec-authorization"); value.Exists() && !data.IpHttpAuthenticationAaaExecAuthorization.IsNull() {
+ data.IpHttpAuthenticationAaaExecAuthorization = types.StringValue(value.String())
+ } else {
+ data.IpHttpAuthenticationAaaExecAuthorization = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/Cisco-IOS-XE-http:http/authentication/aaa/login-authentication"); value.Exists() && !data.IpHttpAuthenticationAaaLoginAuthentication.IsNull() {
+ data.IpHttpAuthenticationAaaLoginAuthentication = types.StringValue(value.String())
+ } else {
+ data.IpHttpAuthenticationAaaLoginAuthentication = types.StringNull()
+ }
+ for i := range data.IpHttpAuthenticationAaaCommandAuthorization {
+ keys := [...]string{"level"}
+ keyValues := [...]string{strconv.FormatInt(data.IpHttpAuthenticationAaaCommandAuthorization[i].Level.ValueInt64(), 10)}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/Cisco-IOS-XE-http:http/authentication/aaa/command-authorization").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, "level"); value.Exists() && !data.IpHttpAuthenticationAaaCommandAuthorization[i].Level.IsNull() {
+ data.IpHttpAuthenticationAaaCommandAuthorization[i].Level = types.Int64Value(value.Int())
+ } else {
+ data.IpHttpAuthenticationAaaCommandAuthorization[i].Level = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(r, "name"); value.Exists() && !data.IpHttpAuthenticationAaaCommandAuthorization[i].Name.IsNull() {
+ data.IpHttpAuthenticationAaaCommandAuthorization[i].Name = types.StringValue(value.String())
+ } else {
+ data.IpHttpAuthenticationAaaCommandAuthorization[i].Name = types.StringNull()
+ }
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/Cisco-IOS-XE-http:http/authentication/local"); !data.IpHttpAuthenticationLocal.IsNull() {
+ if value.Exists() {
+ data.IpHttpAuthenticationLocal = types.BoolValue(true)
+ } else {
+ data.IpHttpAuthenticationLocal = types.BoolValue(false)
+ }
+ } else {
+ data.IpHttpAuthenticationLocal = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/Cisco-IOS-XE-http:http/server"); !data.IpHttpServer.IsNull() {
+ if value.Exists() {
+ data.IpHttpServer = types.BoolValue(value.Bool())
+ }
+ } else {
+ data.IpHttpServer = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/Cisco-IOS-XE-http:http/secure-server"); !data.IpHttpSecureServer.IsNull() {
+ if value.Exists() {
+ data.IpHttpSecureServer = types.BoolValue(value.Bool())
+ }
+ } else {
+ data.IpHttpSecureServer = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/Cisco-IOS-XE-http:http/secure-trustpoint"); value.Exists() && !data.IpHttpSecureTrustpoint.IsNull() {
+ data.IpHttpSecureTrustpoint = types.StringValue(value.String())
+ } else {
+ data.IpHttpSecureTrustpoint = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/Cisco-IOS-XE-http:http/tls-version"); value.Exists() && !data.IpHttpTlsVersion.IsNull() {
+ data.IpHttpTlsVersion = types.StringValue(value.String())
+ } else {
+ data.IpHttpTlsVersion = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/Cisco-IOS-XE-http:http/client/secure-trustpoint"); value.Exists() && !data.IpHttpClientSecureTrustpoint.IsNull() {
+ data.IpHttpClientSecureTrustpoint = types.StringValue(value.String())
+ } else {
+ data.IpHttpClientSecureTrustpoint = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/Cisco-IOS-XE-http:http/client/source-interface"); value.Exists() && !data.IpHttpClientSourceInterface.IsNull() {
+ data.IpHttpClientSourceInterface = types.StringValue(value.String())
+ } else {
+ data.IpHttpClientSourceInterface = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/Cisco-IOS-XE-http:http/secure-active-session-modules"); value.Exists() && !data.IpHttpSecureActiveSessionModules.IsNull() {
+ data.IpHttpSecureActiveSessionModules = types.StringValue(value.String())
+ } else {
+ data.IpHttpSecureActiveSessionModules = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/Cisco-IOS-XE-http:http/max-connections"); value.Exists() && !data.IpHttpMaxConnections.IsNull() {
+ data.IpHttpMaxConnections = types.Int64Value(value.Int())
+ } else {
+ data.IpHttpMaxConnections = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/Cisco-IOS-XE-http:http/active-session-modules"); value.Exists() && !data.IpHttpActiveSessionModules.IsNull() {
+ data.IpHttpActiveSessionModules = types.StringValue(value.String())
+ } else {
+ data.IpHttpActiveSessionModules = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/name-server/no-vrf-ordered"); value.Exists() && !data.IpNameServers.IsNull() {
+ data.IpNameServers = helpers.GetStringListXML(value.Array())
+ } else {
+ data.IpNameServers = types.ListNull(types.StringType)
+ }
+ for i := range data.IpNameServersVrf {
+ keys := [...]string{"word"}
+ keyValues := [...]string{data.IpNameServersVrf[i].Vrf.ValueString()}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/name-server/vrf").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, "word"); value.Exists() && !data.IpNameServersVrf[i].Vrf.IsNull() {
+ data.IpNameServersVrf[i].Vrf = types.StringValue(value.String())
+ } else {
+ data.IpNameServersVrf[i].Vrf = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "server-ip-list-ordered"); value.Exists() && !data.IpNameServersVrf[i].Servers.IsNull() {
+ data.IpNameServersVrf[i].Servers = helpers.GetStringListXML(value.Array())
+ } else {
+ data.IpNameServersVrf[i].Servers = types.ListNull(types.StringType)
+ }
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/domain/lookup-settings/lookup/source-interface/Loopback"); value.Exists() && !data.IpDomainLookupSourceInterfaceLoopback.IsNull() {
+ data.IpDomainLookupSourceInterfaceLoopback = types.Int64Value(value.Int())
+ } else {
+ data.IpDomainLookupSourceInterfaceLoopback = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/domain/lookup-settings/lookup/source-interface/Vlan"); value.Exists() && !data.IpDomainLookupSourceInterfaceVlan.IsNull() {
+ data.IpDomainLookupSourceInterfaceVlan = types.Int64Value(value.Int())
+ } else {
+ data.IpDomainLookupSourceInterfaceVlan = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/domain/lookup-settings/lookup/source-interface/GigabitEthernet"); value.Exists() && !data.IpDomainLookupSourceInterfaceGigabitEthernet.IsNull() {
+ data.IpDomainLookupSourceInterfaceGigabitEthernet = types.StringValue(value.String())
+ } else {
+ data.IpDomainLookupSourceInterfaceGigabitEthernet = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/domain/lookup-settings/lookup/source-interface/TwoGigabitEthernet"); value.Exists() && !data.IpDomainLookupSourceInterfaceTwoGigabitEthernet.IsNull() {
+ data.IpDomainLookupSourceInterfaceTwoGigabitEthernet = types.StringValue(value.String())
+ } else {
+ data.IpDomainLookupSourceInterfaceTwoGigabitEthernet = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/domain/lookup-settings/lookup/source-interface/FiveGigabitEthernet"); value.Exists() && !data.IpDomainLookupSourceInterfaceFiveGigabitEthernet.IsNull() {
+ data.IpDomainLookupSourceInterfaceFiveGigabitEthernet = types.StringValue(value.String())
+ } else {
+ data.IpDomainLookupSourceInterfaceFiveGigabitEthernet = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/domain/lookup-settings/lookup/source-interface/TenGigabitEthernet"); value.Exists() && !data.IpDomainLookupSourceInterfaceTenGigabitEthernet.IsNull() {
+ data.IpDomainLookupSourceInterfaceTenGigabitEthernet = types.StringValue(value.String())
+ } else {
+ data.IpDomainLookupSourceInterfaceTenGigabitEthernet = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/domain/lookup-settings/lookup/source-interface/TwentyFiveGigE"); value.Exists() && !data.IpDomainLookupSourceInterfaceTwentyFiveGigabitEthernet.IsNull() {
+ data.IpDomainLookupSourceInterfaceTwentyFiveGigabitEthernet = types.StringValue(value.String())
+ } else {
+ data.IpDomainLookupSourceInterfaceTwentyFiveGigabitEthernet = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/domain/lookup-settings/lookup/source-interface/FortyGigabitEthernet"); value.Exists() && !data.IpDomainLookupSourceInterfaceFortyGigabitEthernet.IsNull() {
+ data.IpDomainLookupSourceInterfaceFortyGigabitEthernet = types.StringValue(value.String())
+ } else {
+ data.IpDomainLookupSourceInterfaceFortyGigabitEthernet = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/domain/lookup-settings/lookup/source-interface/HundredGigE"); value.Exists() && !data.IpDomainLookupSourceInterfaceHundredGigabitEthernet.IsNull() {
+ data.IpDomainLookupSourceInterfaceHundredGigabitEthernet = types.StringValue(value.String())
+ } else {
+ data.IpDomainLookupSourceInterfaceHundredGigabitEthernet = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/cisp/enable"); !data.CispEnable.IsNull() {
+ if value.Exists() {
+ data.CispEnable = types.BoolValue(true)
+ } else {
+ data.CispEnable = types.BoolValue(false)
+ }
+ } else {
+ data.CispEnable = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/epm/logging"); !data.EpmLogging.IsNull() {
+ if value.Exists() {
+ data.EpmLogging = types.BoolValue(true)
+ } else {
+ data.EpmLogging = types.BoolValue(false)
+ }
+ } else {
+ data.EpmLogging = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-sanet:access-session/mac-move/deny"); !data.AccessSessionMacMoveDeny.IsNull() {
+ if value.Exists() {
+ data.AccessSessionMacMoveDeny = types.BoolValue(true)
+ } else {
+ data.AccessSessionMacMoveDeny = types.BoolValue(false)
+ }
+ } else {
+ data.AccessSessionMacMoveDeny = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-diagnostics:diagnostic/bootup/level"); value.Exists() && !data.DiagnosticBootupLevel.IsNull() {
+ data.DiagnosticBootupLevel = types.StringValue(value.String())
+ } else {
+ data.DiagnosticBootupLevel = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/memory/free/low-watermark/processor"); value.Exists() && !data.MemoryFreeLowWatermarkProcessor.IsNull() {
+ data.MemoryFreeLowWatermarkProcessor = types.Int64Value(value.Int())
+ } else {
+ data.MemoryFreeLowWatermarkProcessor = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/archive/path"); value.Exists() && !data.ArchivePath.IsNull() {
+ data.ArchivePath = types.StringValue(value.String())
+ } else {
+ data.ArchivePath = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/archive/maximum"); value.Exists() && !data.ArchiveMaximum.IsNull() {
+ data.ArchiveMaximum = types.Int64Value(value.Int())
+ } else {
+ data.ArchiveMaximum = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/archive/write-memory"); !data.ArchiveWriteMemory.IsNull() {
+ if value.Exists() {
+ data.ArchiveWriteMemory = types.BoolValue(true)
+ } else {
+ data.ArchiveWriteMemory = types.BoolValue(false)
+ }
+ } else {
+ data.ArchiveWriteMemory = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/archive/time-period"); value.Exists() && !data.ArchiveTimePeriod.IsNull() {
+ data.ArchiveTimePeriod = types.Int64Value(value.Int())
+ } else {
+ data.ArchiveTimePeriod = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/archive/log/config/logging/enable"); !data.ArchiveLogConfigLoggingEnable.IsNull() {
+ if value.Exists() {
+ data.ArchiveLogConfigLoggingEnable = types.BoolValue(true)
+ } else {
+ data.ArchiveLogConfigLoggingEnable = types.BoolValue(false)
+ }
+ } else {
+ data.ArchiveLogConfigLoggingEnable = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/archive/log/config/logging/size"); value.Exists() && !data.ArchiveLogConfigLoggingSize.IsNull() {
+ data.ArchiveLogConfigLoggingSize = types.Int64Value(value.Int())
+ } else {
+ data.ArchiveLogConfigLoggingSize = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/redundancy"); !data.Redundancy.IsNull() {
+ if value.Exists() {
+ data.Redundancy = types.BoolValue(true)
+ } else {
+ data.Redundancy = types.BoolValue(false)
+ }
+ } else {
+ data.Redundancy = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/redundancy/mode"); value.Exists() && !data.RedundancyMode.IsNull() {
+ data.RedundancyMode = types.StringValue(value.String())
+ } else {
+ data.RedundancyMode = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/transceivers/type/all/monitoring-enable/monitoring"); !data.TransceiverTypeAllMonitoring.IsNull() {
+ if value.Exists() {
+ data.TransceiverTypeAllMonitoring = types.BoolValue(true)
+ } else {
+ data.TransceiverTypeAllMonitoring = types.BoolValue(false)
+ }
+ } else {
+ data.TransceiverTypeAllMonitoring = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/forward-protocol-v2/nd"); !data.IpForwardProtocolNd.IsNull() {
+ if value.Exists() {
+ data.IpForwardProtocolNd = types.BoolValue(value.Bool())
+ }
+ } else {
+ data.IpForwardProtocolNd = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/scp/server/enable"); !data.IpScpServerEnable.IsNull() {
+ if value.Exists() {
+ data.IpScpServerEnable = types.BoolValue(true)
+ } else {
+ data.IpScpServerEnable = types.BoolValue(false)
+ }
+ } else {
+ data.IpScpServerEnable = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/ssh/ssh-version"); value.Exists() && !data.IpSshVersion.IsNull() {
+ data.IpSshVersion = types.StringValue(value.String())
+ } else {
+ data.IpSshVersion = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/ssh/version"); value.Exists() && !data.IpSshVersionLegacy.IsNull() {
+ data.IpSshVersionLegacy = types.Int64Value(value.Int())
+ } else {
+ data.IpSshVersionLegacy = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/ssh/time-out"); value.Exists() && !data.IpSshTimeOut.IsNull() {
+ data.IpSshTimeOut = types.Int64Value(value.Int())
+ } else {
+ data.IpSshTimeOut = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/ssh/authentication-retries"); value.Exists() && !data.IpSshAuthenticationRetries.IsNull() {
+ data.IpSshAuthenticationRetries = types.Int64Value(value.Int())
+ } else {
+ data.IpSshAuthenticationRetries = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/ssh/source-interface-config/Loopback"); value.Exists() && !data.IpSshSourceInterfaceLoopback.IsNull() {
+ data.IpSshSourceInterfaceLoopback = types.Int64Value(value.Int())
+ } else {
+ data.IpSshSourceInterfaceLoopback = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/ssh/source-interface-config/Vlan"); value.Exists() && !data.IpSshSourceInterfaceVlan.IsNull() {
+ data.IpSshSourceInterfaceVlan = types.Int64Value(value.Int())
+ } else {
+ data.IpSshSourceInterfaceVlan = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/ssh/source-interface-config/GigabitEthernet"); value.Exists() && !data.IpSshSourceInterfaceGigabitEthernet.IsNull() {
+ data.IpSshSourceInterfaceGigabitEthernet = types.StringValue(value.String())
+ } else {
+ data.IpSshSourceInterfaceGigabitEthernet = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/ssh/source-interface-config/TwoGigabitEthernet"); value.Exists() && !data.IpSshSourceInterfaceTwoGigabitEthernet.IsNull() {
+ data.IpSshSourceInterfaceTwoGigabitEthernet = types.StringValue(value.String())
+ } else {
+ data.IpSshSourceInterfaceTwoGigabitEthernet = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/ssh/source-interface-config/FiveGigabitEthernet"); value.Exists() && !data.IpSshSourceInterfaceFiveGigabitEthernet.IsNull() {
+ data.IpSshSourceInterfaceFiveGigabitEthernet = types.StringValue(value.String())
+ } else {
+ data.IpSshSourceInterfaceFiveGigabitEthernet = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/ssh/source-interface-config/TenGigabitEthernet"); value.Exists() && !data.IpSshSourceInterfaceTenGigabitEthernet.IsNull() {
+ data.IpSshSourceInterfaceTenGigabitEthernet = types.StringValue(value.String())
+ } else {
+ data.IpSshSourceInterfaceTenGigabitEthernet = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/ssh/source-interface-config/TwentyFiveGigE"); value.Exists() && !data.IpSshSourceInterfaceTwentyFiveGigabitEthernet.IsNull() {
+ data.IpSshSourceInterfaceTwentyFiveGigabitEthernet = types.StringValue(value.String())
+ } else {
+ data.IpSshSourceInterfaceTwentyFiveGigabitEthernet = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/ssh/source-interface-config/FortyGigabitEthernet"); value.Exists() && !data.IpSshSourceInterfaceFortyGigabitEthernet.IsNull() {
+ data.IpSshSourceInterfaceFortyGigabitEthernet = types.StringValue(value.String())
+ } else {
+ data.IpSshSourceInterfaceFortyGigabitEthernet = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/ssh/source-interface-config/HundredGigE"); value.Exists() && !data.IpSshSourceInterfaceHundredGigabitEthernet.IsNull() {
+ data.IpSshSourceInterfaceHundredGigabitEthernet = types.StringValue(value.String())
+ } else {
+ data.IpSshSourceInterfaceHundredGigabitEthernet = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/control-plane/Cisco-IOS-XE-policy:service-policy/input"); value.Exists() && !data.ControlPlaneServicePolicyInput.IsNull() {
+ data.ControlPlaneServicePolicyInput = types.StringValue(value.String())
+ } else {
+ data.ControlPlaneServicePolicyInput = types.StringNull()
+ }
+ for i := range data.PnpProfiles {
+ keys := [...]string{"name"}
+ keyValues := [...]string{data.PnpProfiles[i].Name.ValueString()}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-pnp:pnp/profile").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, "name"); value.Exists() && !data.PnpProfiles[i].Name.IsNull() {
+ data.PnpProfiles[i].Name = types.StringValue(value.String())
+ } else {
+ data.PnpProfiles[i].Name = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "transport/https/ipv4/ipv4-address"); value.Exists() && !data.PnpProfiles[i].TransportHttpsIpv4Ipv4Address.IsNull() {
+ data.PnpProfiles[i].TransportHttpsIpv4Ipv4Address = types.StringValue(value.String())
+ } else {
+ data.PnpProfiles[i].TransportHttpsIpv4Ipv4Address = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "transport/https/ipv4/port"); value.Exists() && !data.PnpProfiles[i].TransportHttpsIpv4Port.IsNull() {
+ data.PnpProfiles[i].TransportHttpsIpv4Port = types.Int64Value(value.Int())
+ } else {
+ data.PnpProfiles[i].TransportHttpsIpv4Port = types.Int64Null()
+ }
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/Cisco-IOS-XE-aaa:tacacs/source-interface/Loopback"); value.Exists() && !data.IpTacacsSourceInterfaceLoopback.IsNull() {
+ data.IpTacacsSourceInterfaceLoopback = types.Int64Value(value.Int())
+ } else {
+ data.IpTacacsSourceInterfaceLoopback = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/Cisco-IOS-XE-aaa:tacacs/source-interface/Vlan"); value.Exists() && !data.IpTacacsSourceInterfaceVlan.IsNull() {
+ data.IpTacacsSourceInterfaceVlan = types.Int64Value(value.Int())
+ } else {
+ data.IpTacacsSourceInterfaceVlan = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/Cisco-IOS-XE-aaa:tacacs/source-interface/GigabitEthernet"); value.Exists() && !data.IpTacacsSourceInterfaceGigabitEthernet.IsNull() {
+ data.IpTacacsSourceInterfaceGigabitEthernet = types.StringValue(value.String())
+ } else {
+ data.IpTacacsSourceInterfaceGigabitEthernet = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/Cisco-IOS-XE-aaa:tacacs/source-interface/TwoGigabitEthernet"); value.Exists() && !data.IpTacacsSourceInterfaceTwoGigabitEthernet.IsNull() {
+ data.IpTacacsSourceInterfaceTwoGigabitEthernet = types.StringValue(value.String())
+ } else {
+ data.IpTacacsSourceInterfaceTwoGigabitEthernet = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/Cisco-IOS-XE-aaa:tacacs/source-interface/FiveGigabitEthernet"); value.Exists() && !data.IpTacacsSourceInterfaceFiveGigabitEthernet.IsNull() {
+ data.IpTacacsSourceInterfaceFiveGigabitEthernet = types.StringValue(value.String())
+ } else {
+ data.IpTacacsSourceInterfaceFiveGigabitEthernet = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/Cisco-IOS-XE-aaa:tacacs/source-interface/TenGigabitEthernet"); value.Exists() && !data.IpTacacsSourceInterfaceTenGigabitEthernet.IsNull() {
+ data.IpTacacsSourceInterfaceTenGigabitEthernet = types.StringValue(value.String())
+ } else {
+ data.IpTacacsSourceInterfaceTenGigabitEthernet = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/Cisco-IOS-XE-aaa:tacacs/source-interface/TwentyFiveGigE"); value.Exists() && !data.IpTacacsSourceInterfaceTwentyFiveGigabitEthernet.IsNull() {
+ data.IpTacacsSourceInterfaceTwentyFiveGigabitEthernet = types.StringValue(value.String())
+ } else {
+ data.IpTacacsSourceInterfaceTwentyFiveGigabitEthernet = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/Cisco-IOS-XE-aaa:tacacs/source-interface/FortyGigabitEthernet"); value.Exists() && !data.IpTacacsSourceInterfaceFortyGigabitEthernet.IsNull() {
+ data.IpTacacsSourceInterfaceFortyGigabitEthernet = types.StringValue(value.String())
+ } else {
+ data.IpTacacsSourceInterfaceFortyGigabitEthernet = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/Cisco-IOS-XE-aaa:tacacs/source-interface/HundredGigE"); value.Exists() && !data.IpTacacsSourceInterfaceHundredGigabitEthernet.IsNull() {
+ data.IpTacacsSourceInterfaceHundredGigabitEthernet = types.StringValue(value.String())
+ } else {
+ data.IpTacacsSourceInterfaceHundredGigabitEthernet = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/Cisco-IOS-XE-aaa:tacacs/source-interface/vrf"); value.Exists() && !data.IpTacacsSourceInterfaceVrf.IsNull() {
+ data.IpTacacsSourceInterfaceVrf = types.StringValue(value.String())
+ } else {
+ data.IpTacacsSourceInterfaceVrf = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/Cisco-IOS-XE-aaa:radius/source-interface/Loopback"); value.Exists() && !data.IpRadiusSourceInterfaceLoopback.IsNull() {
+ data.IpRadiusSourceInterfaceLoopback = types.Int64Value(value.Int())
+ } else {
+ data.IpRadiusSourceInterfaceLoopback = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/Cisco-IOS-XE-aaa:radius/source-interface/Vlan"); value.Exists() && !data.IpRadiusSourceInterfaceVlan.IsNull() {
+ data.IpRadiusSourceInterfaceVlan = types.Int64Value(value.Int())
+ } else {
+ data.IpRadiusSourceInterfaceVlan = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/Cisco-IOS-XE-aaa:radius/source-interface/GigabitEthernet"); value.Exists() && !data.IpRadiusSourceInterfaceGigabitEthernet.IsNull() {
+ data.IpRadiusSourceInterfaceGigabitEthernet = types.StringValue(value.String())
+ } else {
+ data.IpRadiusSourceInterfaceGigabitEthernet = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/Cisco-IOS-XE-aaa:radius/source-interface/TwoGigabitEthernet"); value.Exists() && !data.IpRadiusSourceInterfaceTwoGigabitEthernet.IsNull() {
+ data.IpRadiusSourceInterfaceTwoGigabitEthernet = types.StringValue(value.String())
+ } else {
+ data.IpRadiusSourceInterfaceTwoGigabitEthernet = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/Cisco-IOS-XE-aaa:radius/source-interface/FiveGigabitEthernet"); value.Exists() && !data.IpRadiusSourceInterfaceFiveGigabitEthernet.IsNull() {
+ data.IpRadiusSourceInterfaceFiveGigabitEthernet = types.StringValue(value.String())
+ } else {
+ data.IpRadiusSourceInterfaceFiveGigabitEthernet = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/Cisco-IOS-XE-aaa:radius/source-interface/TenGigabitEthernet"); value.Exists() && !data.IpRadiusSourceInterfaceTenGigabitEthernet.IsNull() {
+ data.IpRadiusSourceInterfaceTenGigabitEthernet = types.StringValue(value.String())
+ } else {
+ data.IpRadiusSourceInterfaceTenGigabitEthernet = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/Cisco-IOS-XE-aaa:radius/source-interface/TwentyFiveGigE"); value.Exists() && !data.IpRadiusSourceInterfaceTwentyFiveGigabitEthernet.IsNull() {
+ data.IpRadiusSourceInterfaceTwentyFiveGigabitEthernet = types.StringValue(value.String())
+ } else {
+ data.IpRadiusSourceInterfaceTwentyFiveGigabitEthernet = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/Cisco-IOS-XE-aaa:radius/source-interface/FortyGigabitEthernet"); value.Exists() && !data.IpRadiusSourceInterfaceFortyGigabitEthernet.IsNull() {
+ data.IpRadiusSourceInterfaceFortyGigabitEthernet = types.StringValue(value.String())
+ } else {
+ data.IpRadiusSourceInterfaceFortyGigabitEthernet = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/Cisco-IOS-XE-aaa:radius/source-interface/HundredGigE"); value.Exists() && !data.IpRadiusSourceInterfaceHundredGigabitEthernet.IsNull() {
+ data.IpRadiusSourceInterfaceHundredGigabitEthernet = types.StringValue(value.String())
+ } else {
+ data.IpRadiusSourceInterfaceHundredGigabitEthernet = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/Cisco-IOS-XE-aaa:radius/source-interface/vrf"); value.Exists() && !data.IpRadiusSourceInterfaceVrf.IsNull() {
+ data.IpRadiusSourceInterfaceVrf = types.StringValue(value.String())
+ } else {
+ data.IpRadiusSourceInterfaceVrf = types.StringNull()
+ }
+ for i := range data.BootSystemFlashFiles {
+ keys := [...]string{"flash-leaf"}
+ keyValues := [...]string{data.BootSystemFlashFiles[i].Path.ValueString()}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/boot/system/flash/flash-list-ordered-by-user").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, "flash-leaf"); value.Exists() && !data.BootSystemFlashFiles[i].Path.IsNull() {
+ data.BootSystemFlashFiles[i].Path = types.StringValue(value.String())
+ } else {
+ data.BootSystemFlashFiles[i].Path = types.StringNull()
+ }
+ }
+ for i := range data.BootSystemBootfiles {
+ keys := [...]string{"filename"}
+ keyValues := [...]string{data.BootSystemBootfiles[i].Path.ValueString()}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/boot/system/bootfile/filename-list-ordered-by-user").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, "filename"); value.Exists() && !data.BootSystemBootfiles[i].Path.IsNull() {
+ data.BootSystemBootfiles[i].Path = types.StringValue(value.String())
+ } else {
+ data.BootSystemBootfiles[i].Path = types.StringNull()
+ }
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/enable/secret/level"); value.Exists() && !data.EnableSecretLevel.IsNull() {
+ data.EnableSecretLevel = types.Int64Value(value.Int())
+ } else {
+ data.EnableSecretLevel = types.Int64Null()
+ }
+ for i := range data.IpHosts {
+ keys := [...]string{"name"}
+ keyValues := [...]string{data.IpHosts[i].Name.ValueString()}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/host/host-list").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, "name"); value.Exists() && !data.IpHosts[i].Name.IsNull() {
+ data.IpHosts[i].Name = types.StringValue(value.String())
+ } else {
+ data.IpHosts[i].Name = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "ip-list-ordered"); value.Exists() && !data.IpHosts[i].Ips.IsNull() {
+ data.IpHosts[i].Ips = helpers.GetStringListXML(value.Array())
+ } else {
+ data.IpHosts[i].Ips = types.ListNull(types.StringType)
+ }
+ }
+ for i := range data.IpHostsVrf {
+ keys := [...]string{"vrf-name"}
+ keyValues := [...]string{data.IpHostsVrf[i].Vrf.ValueString()}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/host/vrf").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, "vrf-name"); value.Exists() && !data.IpHostsVrf[i].Vrf.IsNull() {
+ data.IpHostsVrf[i].Vrf = types.StringValue(value.String())
+ } else {
+ data.IpHostsVrf[i].Vrf = types.StringNull()
+ }
+ for ci := range data.IpHostsVrf[i].Hosts {
+ keys := [...]string{"host-name"}
+ keyValues := [...]string{data.IpHostsVrf[i].Hosts[ci].Name.ValueString()}
+
+ var cr xmldot.Result
+ helpers.GetFromXPath(r, "host-name").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ cr = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(cr, "host-name"); value.Exists() && !data.IpHostsVrf[i].Hosts[ci].Name.IsNull() {
+ data.IpHostsVrf[i].Hosts[ci].Name = types.StringValue(value.String())
+ } else {
+ data.IpHostsVrf[i].Hosts[ci].Name = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(cr, "ip-list"); value.Exists() && !data.IpHostsVrf[i].Hosts[ci].Ips.IsNull() {
+ data.IpHostsVrf[i].Hosts[ci].Ips = helpers.GetStringListXML(value.Array())
+ } else {
+ data.IpHostsVrf[i].Hosts[ci].Ips = types.ListNull(types.StringType)
+ }
+ }
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-diagnostics:diagnostic/event-log/size"); value.Exists() && !data.DiagnosticEventLogSize.IsNull() {
+ data.DiagnosticEventLogSize = types.Int64Value(value.Int())
+ } else {
+ data.DiagnosticEventLogSize = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/subscriber/templating"); !data.SubscriberTemplating.IsNull() {
+ if value.Exists() {
+ data.SubscriberTemplating = types.BoolValue(true)
+ } else {
+ data.SubscriberTemplating = types.BoolValue(false)
+ }
+ } else {
+ data.SubscriberTemplating = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/call-home/Cisco-IOS-XE-call-home:contact-email-addr"); value.Exists() && !data.CallHomeContactEmail.IsNull() {
+ data.CallHomeContactEmail = types.StringValue(value.String())
+ } else {
+ data.CallHomeContactEmail = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/call-home/Cisco-IOS-XE-call-home:tac-profile/profile/CiscoTAC-1/active"); !data.CallHomeCiscoTac1ProfileActive.IsNull() {
+ if value.Exists() {
+ data.CallHomeCiscoTac1ProfileActive = types.BoolValue(value.Bool())
+ }
+ } else {
+ data.CallHomeCiscoTac1ProfileActive = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/call-home/Cisco-IOS-XE-call-home:tac-profile/profile/CiscoTAC-1/destination/transport-method"); value.Exists() && !data.CallHomeCiscoTac1DestinationTransportMethod.IsNull() {
+ data.CallHomeCiscoTac1DestinationTransportMethod = types.StringValue(value.String())
+ } else {
+ data.CallHomeCiscoTac1DestinationTransportMethod = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/ftp/passive-enable"); !data.IpFtpPassive.IsNull() {
+ if value.Exists() {
+ data.IpFtpPassive = types.BoolValue(value.Bool())
+ }
+ } else {
+ data.IpFtpPassive = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/tftp/source-interface/GigabitEthernet"); value.Exists() && !data.TftpSourceInterfaceGigabitEthernet.IsNull() {
+ data.TftpSourceInterfaceGigabitEthernet = types.StringValue(value.String())
+ } else {
+ data.TftpSourceInterfaceGigabitEthernet = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/tftp/source-interface/Loopback"); value.Exists() && !data.TftpSourceInterfaceLoopback.IsNull() {
+ data.TftpSourceInterfaceLoopback = types.Int64Value(value.Int())
+ } else {
+ data.TftpSourceInterfaceLoopback = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/tftp/source-interface/Vlan"); value.Exists() && !data.TftpSourceInterfaceVlan.IsNull() {
+ data.TftpSourceInterfaceVlan = types.Int64Value(value.Int())
+ } else {
+ data.TftpSourceInterfaceVlan = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/tftp/source-interface/TwoGigabitEthernet"); value.Exists() && !data.TftpSourceInterfaceTwoGigabitEthernet.IsNull() {
+ data.TftpSourceInterfaceTwoGigabitEthernet = types.StringValue(value.String())
+ } else {
+ data.TftpSourceInterfaceTwoGigabitEthernet = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/tftp/source-interface/FiveGigabitEthernet"); value.Exists() && !data.TftpSourceInterfaceFiveGigabitEthernet.IsNull() {
+ data.TftpSourceInterfaceFiveGigabitEthernet = types.StringValue(value.String())
+ } else {
+ data.TftpSourceInterfaceFiveGigabitEthernet = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/tftp/source-interface/TenGigabitEthernet"); value.Exists() && !data.TftpSourceInterfaceTenGigabitEthernet.IsNull() {
+ data.TftpSourceInterfaceTenGigabitEthernet = types.StringValue(value.String())
+ } else {
+ data.TftpSourceInterfaceTenGigabitEthernet = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/tftp/source-interface/TwentyFiveGigabitEthernet"); value.Exists() && !data.TftpSourceInterfaceTwentyFiveGigabitEthernet.IsNull() {
+ data.TftpSourceInterfaceTwentyFiveGigabitEthernet = types.StringValue(value.String())
+ } else {
+ data.TftpSourceInterfaceTwentyFiveGigabitEthernet = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/tftp/source-interface/FortyGigabitEthernet"); value.Exists() && !data.TftpSourceInterfaceFortyGigabitEthernet.IsNull() {
+ data.TftpSourceInterfaceFortyGigabitEthernet = types.StringValue(value.String())
+ } else {
+ data.TftpSourceInterfaceFortyGigabitEthernet = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/tftp/source-interface/HundredGigE"); value.Exists() && !data.TftpSourceInterfaceHundredGigabitEthernet.IsNull() {
+ data.TftpSourceInterfaceHundredGigabitEthernet = types.StringValue(value.String())
+ } else {
+ data.TftpSourceInterfaceHundredGigabitEthernet = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/multilink/Cisco-IOS-XE-ppp:bundle-name"); value.Exists() && !data.MultilinkPppBundleName.IsNull() {
+ data.MultilinkPppBundleName = types.StringValue(value.String())
+ } else {
+ data.MultilinkPppBundleName = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/version"); value.Exists() && !data.Version.IsNull() {
+ data.Version = types.StringValue(value.String())
+ } else {
+ data.Version = types.StringNull()
+ }
+ for i := range data.TrackObjects {
+ keys := [...]string{"object-number"}
+ keyValues := [...]string{data.TrackObjects[i].Number.ValueString()}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/track/Cisco-IOS-XE-track:tracked-object-v2").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, "object-number"); value.Exists() && !data.TrackObjects[i].Number.IsNull() {
+ data.TrackObjects[i].Number = types.StringValue(value.String())
+ } else {
+ data.TrackObjects[i].Number = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "ip/sla/number"); value.Exists() && !data.TrackObjects[i].IpSlaNumber.IsNull() {
+ data.TrackObjects[i].IpSlaNumber = types.Int64Value(value.Int())
+ } else {
+ data.TrackObjects[i].IpSlaNumber = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(r, "ip/sla/reachability"); !data.TrackObjects[i].IpSlaReachability.IsNull() {
+ if value.Exists() {
+ data.TrackObjects[i].IpSlaReachability = types.BoolValue(true)
+ } else {
+ data.TrackObjects[i].IpSlaReachability = types.BoolValue(false)
+ }
+ } else {
+ data.TrackObjects[i].IpSlaReachability = types.BoolNull()
+ }
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/Cisco-IOS-XE-nbar:nbar/classification/dns/classify-by-domain-with-default"); !data.IpNbarClassificationDnsClassifyByDomain.IsNull() {
+ if value.Exists() {
+ data.IpNbarClassificationDnsClassifyByDomain = types.BoolValue(value.Bool())
+ }
+ } else {
+ data.IpNbarClassificationDnsClassifyByDomain = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/multicast/Cisco-IOS-XE-multicast:route-limit-container/routelimit"); value.Exists() && !data.IpMulticastRouteLimit.IsNull() {
+ data.IpMulticastRouteLimit = types.Int64Value(value.Int())
+ } else {
+ data.IpMulticastRouteLimit = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-aaa:security/passwords/min-length"); value.Exists() && !data.SecurityPasswordsMinLength.IsNull() {
+ data.SecurityPasswordsMinLength = types.Int64Value(value.Int())
+ } else {
+ data.SecurityPasswordsMinLength = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/domain/list/domain-name"); value.Exists() && !data.IpDomainListNames.IsNull() {
+ data.IpDomainListNames = helpers.GetStringListXML(value.Array())
+ } else {
+ data.IpDomainListNames = types.ListNull(types.StringType)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/domain/list/vrf/domain-name"); value.Exists() && !data.IpDomainListVrfDomain.IsNull() {
+ data.IpDomainListVrfDomain = types.StringValue(value.String())
+ } else {
+ data.IpDomainListVrfDomain = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/domain/list/vrf/vrf-name"); value.Exists() && !data.IpDomainListVrf.IsNull() {
+ data.IpDomainListVrf = types.StringValue(value.String())
+ } else {
+ data.IpDomainListVrf = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ethernet/Cisco-IOS-XE-ethernet:cfm/alarm-config/delay"); value.Exists() && !data.EthernetCfmAlarmConfigDelay.IsNull() {
+ data.EthernetCfmAlarmConfigDelay = types.Int64Value(value.Int())
+ } else {
+ data.EthernetCfmAlarmConfigDelay = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ethernet/Cisco-IOS-XE-ethernet:cfm/alarm-config/reset"); value.Exists() && !data.EthernetCfmAlarmConfigReset.IsNull() {
+ data.EthernetCfmAlarmConfigReset = types.Int64Value(value.Int())
+ } else {
+ data.EthernetCfmAlarmConfigReset = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/standby/redirects-config/redirects"); !data.StandbyRedirects.IsNull() {
+ if value.Exists() {
+ data.StandbyRedirects = types.BoolValue(value.Bool())
+ }
+ } else {
+ data.StandbyRedirects = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/standby/redirects-config/redirect-enable-disable/redirects"); value.Exists() && !data.StandbyRedirectsEnableDisable.IsNull() {
+ data.StandbyRedirectsEnableDisable = types.StringValue(value.String())
+ } else {
+ data.StandbyRedirectsEnableDisable = types.StringNull()
+ }
+}
+
+// End of section. //template:end updateFromBodyXML
+
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBody
+
+func (data *System) fromBody(ctx context.Context, res gjson.Result) {
+ prefix := helpers.LastElement(data.getPath()) + "."
+ if res.Get(helpers.LastElement(data.getPath())).IsArray() {
+ prefix += "0."
+ }
+ if value := res.Get(prefix + "hostname"); value.Exists() {
+ data.Hostname = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "ip.bgp-community.new-format"); value.Exists() {
+ data.IpBgpCommunityNewFormat = types.BoolValue(true)
+ } else {
+ data.IpBgpCommunityNewFormat = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "ip.routing-conf.routing"); value.Exists() {
+ data.IpRouting = types.BoolValue(value.Bool())
+ } else {
+ data.IpRouting = types.BoolNull()
+ }
+ if value := res.Get(prefix + "ipv6.unicast-routing"); value.Exists() {
+ data.Ipv6UnicastRouting = types.BoolValue(true)
+ } else {
+ data.Ipv6UnicastRouting = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "system.Cisco-IOS-XE-switch:mtu.size"); value.Exists() {
+ data.Mtu = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "ip.source-route"); value.Exists() {
+ data.IpSourceRoute = types.BoolValue(value.Bool())
+ } else {
+ data.IpSourceRoute = types.BoolNull()
+ }
+ if value := res.Get(prefix + "ip.domain.lookup"); value.Exists() {
+ data.IpDomainLookup = types.BoolValue(value.Bool())
+ } else {
+ data.IpDomainLookup = types.BoolNull()
+ }
+ if value := res.Get(prefix + "ip.domain.name"); value.Exists() {
+ data.IpDomainName = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "login.delay"); value.Exists() {
+ data.LoginDelay = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "login.on-failure"); value.Exists() {
+ data.LoginOnFailure = types.BoolValue(true)
+ } else {
+ data.LoginOnFailure = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "login.on-failure.log"); value.Exists() {
+ data.LoginOnFailureLog = types.BoolValue(true)
+ } else {
+ data.LoginOnFailureLog = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "login.on-success"); value.Exists() {
+ data.LoginOnSuccess = types.BoolValue(true)
+ } else {
+ data.LoginOnSuccess = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "login.on-success.log"); value.Exists() {
+ data.LoginOnSuccessLog = types.BoolValue(true)
+ } else {
+ data.LoginOnSuccessLog = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "ip.Cisco-IOS-XE-multicast:multicast-routing"); value.Exists() {
+ data.IpMulticastRouting = types.BoolValue(true)
+ } else {
+ data.IpMulticastRouting = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "ip.Cisco-IOS-XE-multicast:mcr-conf.multicast-routing"); value.Exists() {
+ data.MulticastRoutingSwitch = types.BoolValue(true)
+ } else {
+ data.MulticastRoutingSwitch = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "ip.Cisco-IOS-XE-multicast:multicast-routing.distributed"); value.Exists() {
+ data.IpMulticastRoutingDistributed = types.BoolValue(true)
+ } else {
+ data.IpMulticastRoutingDistributed = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "ip.Cisco-IOS-XE-multicast:multicast-routing.vrf"); value.Exists() {
+ data.MulticastRoutingVrfs = make([]SystemMulticastRoutingVrfs, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := SystemMulticastRoutingVrfs{}
+ if cValue := v.Get("name"); cValue.Exists() {
+ item.Vrf = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("distributed"); cValue.Exists() {
+ item.Distributed = types.BoolValue(true)
+ } else {
+ item.Distributed = types.BoolValue(false)
+ }
+ data.MulticastRoutingVrfs = append(data.MulticastRoutingVrfs, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + "ip.Cisco-IOS-XE-http:http.access-class"); value.Exists() {
+ data.IpHttpAccessClass = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "ip.Cisco-IOS-XE-http:http.authentication.aaa"); value.Exists() {
+ data.IpHttpAuthenticationAaa = types.BoolValue(true)
+ } else {
+ data.IpHttpAuthenticationAaa = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "ip.Cisco-IOS-XE-http:http.authentication.aaa.exec-authorization"); value.Exists() {
+ data.IpHttpAuthenticationAaaExecAuthorization = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "ip.Cisco-IOS-XE-http:http.authentication.aaa.login-authentication"); value.Exists() {
+ data.IpHttpAuthenticationAaaLoginAuthentication = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "ip.Cisco-IOS-XE-http:http.authentication.aaa.command-authorization"); value.Exists() {
+ data.IpHttpAuthenticationAaaCommandAuthorization = make([]SystemIpHttpAuthenticationAaaCommandAuthorization, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := SystemIpHttpAuthenticationAaaCommandAuthorization{}
+ if cValue := v.Get("level"); cValue.Exists() {
+ item.Level = types.Int64Value(cValue.Int())
+ }
+ if cValue := v.Get("name"); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ data.IpHttpAuthenticationAaaCommandAuthorization = append(data.IpHttpAuthenticationAaaCommandAuthorization, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + "ip.Cisco-IOS-XE-http:http.authentication.local"); value.Exists() {
+ data.IpHttpAuthenticationLocal = types.BoolValue(true)
+ } else {
+ data.IpHttpAuthenticationLocal = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "ip.Cisco-IOS-XE-http:http.server"); value.Exists() {
+ data.IpHttpServer = types.BoolValue(value.Bool())
+ } else {
+ data.IpHttpServer = types.BoolNull()
+ }
+ if value := res.Get(prefix + "ip.Cisco-IOS-XE-http:http.secure-server"); value.Exists() {
+ data.IpHttpSecureServer = types.BoolValue(value.Bool())
+ } else {
+ data.IpHttpSecureServer = types.BoolNull()
+ }
+ if value := res.Get(prefix + "ip.Cisco-IOS-XE-http:http.secure-trustpoint"); value.Exists() {
+ data.IpHttpSecureTrustpoint = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "ip.Cisco-IOS-XE-http:http.tls-version"); value.Exists() {
+ data.IpHttpTlsVersion = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "ip.Cisco-IOS-XE-http:http.client.secure-trustpoint"); value.Exists() {
+ data.IpHttpClientSecureTrustpoint = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "ip.Cisco-IOS-XE-http:http.client.source-interface"); value.Exists() {
+ data.IpHttpClientSourceInterface = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "ip.Cisco-IOS-XE-http:http.secure-active-session-modules"); value.Exists() {
+ data.IpHttpSecureActiveSessionModules = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "ip.Cisco-IOS-XE-http:http.max-connections"); value.Exists() {
+ data.IpHttpMaxConnections = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "ip.Cisco-IOS-XE-http:http.active-session-modules"); value.Exists() {
+ data.IpHttpActiveSessionModules = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "ip.name-server.no-vrf-ordered"); value.Exists() {
+ data.IpNameServers = helpers.GetStringList(value.Array())
+ } else {
+ data.IpNameServers = types.ListNull(types.StringType)
+ }
+ if value := res.Get(prefix + "ip.name-server.vrf"); value.Exists() {
+ data.IpNameServersVrf = make([]SystemIpNameServersVrf, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := SystemIpNameServersVrf{}
+ if cValue := v.Get("word"); cValue.Exists() {
+ item.Vrf = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("server-ip-list-ordered"); cValue.Exists() {
+ item.Servers = helpers.GetStringList(cValue.Array())
+ } else {
+ item.Servers = types.ListNull(types.StringType)
+ }
+ data.IpNameServersVrf = append(data.IpNameServersVrf, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + "ip.domain.lookup-settings.lookup.source-interface.Loopback"); value.Exists() {
+ data.IpDomainLookupSourceInterfaceLoopback = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "ip.domain.lookup-settings.lookup.source-interface.Vlan"); value.Exists() {
+ data.IpDomainLookupSourceInterfaceVlan = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "ip.domain.lookup-settings.lookup.source-interface.GigabitEthernet"); value.Exists() {
+ data.IpDomainLookupSourceInterfaceGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "ip.domain.lookup-settings.lookup.source-interface.TwoGigabitEthernet"); value.Exists() {
+ data.IpDomainLookupSourceInterfaceTwoGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "ip.domain.lookup-settings.lookup.source-interface.FiveGigabitEthernet"); value.Exists() {
+ data.IpDomainLookupSourceInterfaceFiveGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "ip.domain.lookup-settings.lookup.source-interface.TenGigabitEthernet"); value.Exists() {
+ data.IpDomainLookupSourceInterfaceTenGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "ip.domain.lookup-settings.lookup.source-interface.TwentyFiveGigE"); value.Exists() {
+ data.IpDomainLookupSourceInterfaceTwentyFiveGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "ip.domain.lookup-settings.lookup.source-interface.FortyGigabitEthernet"); value.Exists() {
+ data.IpDomainLookupSourceInterfaceFortyGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "ip.domain.lookup-settings.lookup.source-interface.HundredGigE"); value.Exists() {
+ data.IpDomainLookupSourceInterfaceHundredGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "cisp.enable"); value.Exists() {
+ data.CispEnable = types.BoolValue(true)
+ } else {
+ data.CispEnable = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "epm.logging"); value.Exists() {
+ data.EpmLogging = types.BoolValue(true)
+ } else {
+ data.EpmLogging = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-sanet:access-session.mac-move.deny"); value.Exists() {
+ data.AccessSessionMacMoveDeny = types.BoolValue(true)
+ } else {
+ data.AccessSessionMacMoveDeny = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-diagnostics:diagnostic.bootup.level"); value.Exists() {
+ data.DiagnosticBootupLevel = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "memory.free.low-watermark.processor"); value.Exists() {
+ data.MemoryFreeLowWatermarkProcessor = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "archive.path"); value.Exists() {
+ data.ArchivePath = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "archive.maximum"); value.Exists() {
+ data.ArchiveMaximum = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "archive.write-memory"); value.Exists() {
+ data.ArchiveWriteMemory = types.BoolValue(true)
+ } else {
+ data.ArchiveWriteMemory = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "archive.time-period"); value.Exists() {
+ data.ArchiveTimePeriod = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "archive.log.config.logging.enable"); value.Exists() {
+ data.ArchiveLogConfigLoggingEnable = types.BoolValue(true)
+ } else {
+ data.ArchiveLogConfigLoggingEnable = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "archive.log.config.logging.size"); value.Exists() {
+ data.ArchiveLogConfigLoggingSize = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "redundancy"); value.Exists() {
+ data.Redundancy = types.BoolValue(true)
+ } else {
+ data.Redundancy = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "redundancy.mode"); value.Exists() {
+ data.RedundancyMode = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "transceivers.type.all.monitoring-enable.monitoring"); value.Exists() {
+ data.TransceiverTypeAllMonitoring = types.BoolValue(true)
+ } else {
+ data.TransceiverTypeAllMonitoring = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "ip.forward-protocol-v2.nd"); value.Exists() {
+ data.IpForwardProtocolNd = types.BoolValue(value.Bool())
+ } else {
+ data.IpForwardProtocolNd = types.BoolNull()
+ }
+ if value := res.Get(prefix + "ip.scp.server.enable"); value.Exists() {
+ data.IpScpServerEnable = types.BoolValue(true)
+ } else {
+ data.IpScpServerEnable = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "ip.ssh.ssh-version"); value.Exists() {
+ data.IpSshVersion = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "ip.ssh.version"); value.Exists() {
+ data.IpSshVersionLegacy = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "ip.ssh.time-out"); value.Exists() {
+ data.IpSshTimeOut = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "ip.ssh.authentication-retries"); value.Exists() {
+ data.IpSshAuthenticationRetries = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "ip.ssh.source-interface-config.Loopback"); value.Exists() {
+ data.IpSshSourceInterfaceLoopback = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "ip.ssh.source-interface-config.Vlan"); value.Exists() {
+ data.IpSshSourceInterfaceVlan = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "ip.ssh.source-interface-config.GigabitEthernet"); value.Exists() {
+ data.IpSshSourceInterfaceGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "ip.ssh.source-interface-config.TwoGigabitEthernet"); value.Exists() {
+ data.IpSshSourceInterfaceTwoGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "ip.ssh.source-interface-config.FiveGigabitEthernet"); value.Exists() {
+ data.IpSshSourceInterfaceFiveGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "ip.ssh.source-interface-config.TenGigabitEthernet"); value.Exists() {
+ data.IpSshSourceInterfaceTenGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "ip.ssh.source-interface-config.TwentyFiveGigE"); value.Exists() {
+ data.IpSshSourceInterfaceTwentyFiveGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "ip.ssh.source-interface-config.FortyGigabitEthernet"); value.Exists() {
+ data.IpSshSourceInterfaceFortyGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "ip.ssh.source-interface-config.HundredGigE"); value.Exists() {
+ data.IpSshSourceInterfaceHundredGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "control-plane.Cisco-IOS-XE-policy:service-policy.input"); value.Exists() {
+ data.ControlPlaneServicePolicyInput = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-pnp:pnp.profile"); value.Exists() {
+ data.PnpProfiles = make([]SystemPnpProfiles, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := SystemPnpProfiles{}
+ if cValue := v.Get("name"); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("transport.https.ipv4.ipv4-address"); cValue.Exists() {
+ item.TransportHttpsIpv4Ipv4Address = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("transport.https.ipv4.port"); cValue.Exists() {
+ item.TransportHttpsIpv4Port = types.Int64Value(cValue.Int())
+ }
+ data.PnpProfiles = append(data.PnpProfiles, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + "ip.Cisco-IOS-XE-aaa:tacacs.source-interface.Loopback"); value.Exists() {
+ data.IpTacacsSourceInterfaceLoopback = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "ip.Cisco-IOS-XE-aaa:tacacs.source-interface.Vlan"); value.Exists() {
+ data.IpTacacsSourceInterfaceVlan = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "ip.Cisco-IOS-XE-aaa:tacacs.source-interface.GigabitEthernet"); value.Exists() {
+ data.IpTacacsSourceInterfaceGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "ip.Cisco-IOS-XE-aaa:tacacs.source-interface.TwoGigabitEthernet"); value.Exists() {
+ data.IpTacacsSourceInterfaceTwoGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "ip.Cisco-IOS-XE-aaa:tacacs.source-interface.FiveGigabitEthernet"); value.Exists() {
+ data.IpTacacsSourceInterfaceFiveGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "ip.Cisco-IOS-XE-aaa:tacacs.source-interface.TenGigabitEthernet"); value.Exists() {
+ data.IpTacacsSourceInterfaceTenGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "ip.Cisco-IOS-XE-aaa:tacacs.source-interface.TwentyFiveGigE"); value.Exists() {
+ data.IpTacacsSourceInterfaceTwentyFiveGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "ip.Cisco-IOS-XE-aaa:tacacs.source-interface.FortyGigabitEthernet"); value.Exists() {
+ data.IpTacacsSourceInterfaceFortyGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "ip.Cisco-IOS-XE-aaa:tacacs.source-interface.HundredGigE"); value.Exists() {
+ data.IpTacacsSourceInterfaceHundredGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "ip.Cisco-IOS-XE-aaa:tacacs.source-interface.vrf"); value.Exists() {
+ data.IpTacacsSourceInterfaceVrf = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "ip.Cisco-IOS-XE-aaa:radius.source-interface.Loopback"); value.Exists() {
+ data.IpRadiusSourceInterfaceLoopback = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "ip.Cisco-IOS-XE-aaa:radius.source-interface.Vlan"); value.Exists() {
+ data.IpRadiusSourceInterfaceVlan = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "ip.Cisco-IOS-XE-aaa:radius.source-interface.GigabitEthernet"); value.Exists() {
+ data.IpRadiusSourceInterfaceGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "ip.Cisco-IOS-XE-aaa:radius.source-interface.TwoGigabitEthernet"); value.Exists() {
+ data.IpRadiusSourceInterfaceTwoGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "ip.Cisco-IOS-XE-aaa:radius.source-interface.FiveGigabitEthernet"); value.Exists() {
+ data.IpRadiusSourceInterfaceFiveGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "ip.Cisco-IOS-XE-aaa:radius.source-interface.TenGigabitEthernet"); value.Exists() {
+ data.IpRadiusSourceInterfaceTenGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "ip.Cisco-IOS-XE-aaa:radius.source-interface.TwentyFiveGigE"); value.Exists() {
+ data.IpRadiusSourceInterfaceTwentyFiveGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "ip.Cisco-IOS-XE-aaa:radius.source-interface.FortyGigabitEthernet"); value.Exists() {
+ data.IpRadiusSourceInterfaceFortyGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "ip.Cisco-IOS-XE-aaa:radius.source-interface.HundredGigE"); value.Exists() {
+ data.IpRadiusSourceInterfaceHundredGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "ip.Cisco-IOS-XE-aaa:radius.source-interface.vrf"); value.Exists() {
+ data.IpRadiusSourceInterfaceVrf = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "boot.system.flash.flash-list-ordered-by-user"); value.Exists() {
+ data.BootSystemFlashFiles = make([]SystemBootSystemFlashFiles, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := SystemBootSystemFlashFiles{}
+ if cValue := v.Get("flash-leaf"); cValue.Exists() {
+ item.Path = types.StringValue(cValue.String())
+ }
+ data.BootSystemFlashFiles = append(data.BootSystemFlashFiles, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + "boot.system.bootfile.filename-list-ordered-by-user"); value.Exists() {
+ data.BootSystemBootfiles = make([]SystemBootSystemBootfiles, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := SystemBootSystemBootfiles{}
+ if cValue := v.Get("filename"); cValue.Exists() {
+ item.Path = types.StringValue(cValue.String())
+ }
+ data.BootSystemBootfiles = append(data.BootSystemBootfiles, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + "enable.secret.secret"); value.Exists() {
+ data.EnableSecret = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "enable.secret.type"); value.Exists() {
+ data.EnableSecretType = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "enable.secret.level"); value.Exists() {
+ data.EnableSecretLevel = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "ip.host.host-list"); value.Exists() {
+ data.IpHosts = make([]SystemIpHosts, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := SystemIpHosts{}
+ if cValue := v.Get("name"); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("ip-list-ordered"); cValue.Exists() {
+ item.Ips = helpers.GetStringList(cValue.Array())
+ } else {
+ item.Ips = types.ListNull(types.StringType)
+ }
+ data.IpHosts = append(data.IpHosts, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + "ip.host.vrf"); value.Exists() {
+ data.IpHostsVrf = make([]SystemIpHostsVrf, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := SystemIpHostsVrf{}
+ if cValue := v.Get("vrf-name"); cValue.Exists() {
+ item.Vrf = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("host-name"); cValue.Exists() {
+ item.Hosts = make([]SystemIpHostsVrfHosts, 0)
+ cValue.ForEach(func(ck, cv gjson.Result) bool {
+ cItem := SystemIpHostsVrfHosts{}
+ if ccValue := cv.Get("host-name"); ccValue.Exists() {
+ cItem.Name = types.StringValue(ccValue.String())
+ }
+ if ccValue := cv.Get("ip-list"); ccValue.Exists() {
+ cItem.Ips = helpers.GetStringList(ccValue.Array())
+ } else {
+ cItem.Ips = types.ListNull(types.StringType)
+ }
+ item.Hosts = append(item.Hosts, cItem)
+ return true
+ })
+ }
+ data.IpHostsVrf = append(data.IpHostsVrf, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-diagnostics:diagnostic.event-log.size"); value.Exists() {
+ data.DiagnosticEventLogSize = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "subscriber.templating"); value.Exists() {
+ data.SubscriberTemplating = types.BoolValue(true)
+ } else {
+ data.SubscriberTemplating = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "call-home.Cisco-IOS-XE-call-home:contact-email-addr"); value.Exists() {
+ data.CallHomeContactEmail = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "call-home.Cisco-IOS-XE-call-home:tac-profile.profile.CiscoTAC-1.active"); value.Exists() {
+ data.CallHomeCiscoTac1ProfileActive = types.BoolValue(value.Bool())
+ } else {
+ data.CallHomeCiscoTac1ProfileActive = types.BoolNull()
+ }
+ if value := res.Get(prefix + "call-home.Cisco-IOS-XE-call-home:tac-profile.profile.CiscoTAC-1.destination.transport-method"); value.Exists() {
+ data.CallHomeCiscoTac1DestinationTransportMethod = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "ip.ftp.passive-enable"); value.Exists() {
+ data.IpFtpPassive = types.BoolValue(value.Bool())
+ } else {
+ data.IpFtpPassive = types.BoolNull()
+ }
+ if value := res.Get(prefix + "ip.tftp.source-interface.GigabitEthernet"); value.Exists() {
+ data.TftpSourceInterfaceGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "ip.tftp.source-interface.Loopback"); value.Exists() {
+ data.TftpSourceInterfaceLoopback = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "ip.tftp.source-interface.Vlan"); value.Exists() {
+ data.TftpSourceInterfaceVlan = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "ip.tftp.source-interface.TwoGigabitEthernet"); value.Exists() {
+ data.TftpSourceInterfaceTwoGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "ip.tftp.source-interface.FiveGigabitEthernet"); value.Exists() {
+ data.TftpSourceInterfaceFiveGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "ip.tftp.source-interface.TenGigabitEthernet"); value.Exists() {
+ data.TftpSourceInterfaceTenGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "ip.tftp.source-interface.TwentyFiveGigabitEthernet"); value.Exists() {
+ data.TftpSourceInterfaceTwentyFiveGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "ip.tftp.source-interface.FortyGigabitEthernet"); value.Exists() {
+ data.TftpSourceInterfaceFortyGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "ip.tftp.source-interface.HundredGigE"); value.Exists() {
+ data.TftpSourceInterfaceHundredGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "multilink.Cisco-IOS-XE-ppp:bundle-name"); value.Exists() {
+ data.MultilinkPppBundleName = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "version"); value.Exists() {
+ data.Version = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "track.Cisco-IOS-XE-track:tracked-object-v2"); value.Exists() {
+ data.TrackObjects = make([]SystemTrackObjects, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := SystemTrackObjects{}
+ if cValue := v.Get("object-number"); cValue.Exists() {
+ item.Number = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("ip.sla.number"); cValue.Exists() {
+ item.IpSlaNumber = types.Int64Value(cValue.Int())
+ }
+ if cValue := v.Get("ip.sla.reachability"); cValue.Exists() {
+ item.IpSlaReachability = types.BoolValue(true)
+ } else {
+ item.IpSlaReachability = types.BoolValue(false)
+ }
+ data.TrackObjects = append(data.TrackObjects, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + "ip.Cisco-IOS-XE-nbar:nbar.classification.dns.classify-by-domain-with-default"); value.Exists() {
+ data.IpNbarClassificationDnsClassifyByDomain = types.BoolValue(value.Bool())
+ } else {
+ data.IpNbarClassificationDnsClassifyByDomain = types.BoolNull()
+ }
+ if value := res.Get(prefix + "ip.multicast.Cisco-IOS-XE-multicast:route-limit-container.routelimit"); value.Exists() {
+ data.IpMulticastRouteLimit = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-aaa:security.passwords.min-length"); value.Exists() {
+ data.SecurityPasswordsMinLength = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "ip.domain.list.domain-name"); value.Exists() {
+ data.IpDomainListNames = helpers.GetStringList(value.Array())
+ } else {
+ data.IpDomainListNames = types.ListNull(types.StringType)
+ }
+ if value := res.Get(prefix + "ip.domain.list.vrf.domain-name"); value.Exists() {
+ data.IpDomainListVrfDomain = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "ip.domain.list.vrf.vrf-name"); value.Exists() {
+ data.IpDomainListVrf = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "ethernet.Cisco-IOS-XE-ethernet:cfm.alarm-config.delay"); value.Exists() {
+ data.EthernetCfmAlarmConfigDelay = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "ethernet.Cisco-IOS-XE-ethernet:cfm.alarm-config.reset"); value.Exists() {
+ data.EthernetCfmAlarmConfigReset = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "standby.redirects-config.redirects"); value.Exists() {
+ data.StandbyRedirects = types.BoolValue(value.Bool())
+ } else {
+ data.StandbyRedirects = types.BoolNull()
+ }
+ if value := res.Get(prefix + "standby.redirects-config.redirect-enable-disable.redirects"); value.Exists() {
+ data.StandbyRedirectsEnableDisable = types.StringValue(value.String())
+ }
+}
+
+// End of section. //template:end fromBody
+
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyData
+
+func (data *SystemData) fromBody(ctx context.Context, res gjson.Result) {
+ prefix := helpers.LastElement(data.getPath()) + "."
+ if res.Get(helpers.LastElement(data.getPath())).IsArray() {
+ prefix += "0."
+ }
+ if value := res.Get(prefix + "hostname"); value.Exists() {
+ data.Hostname = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "ip.bgp-community.new-format"); value.Exists() {
+ data.IpBgpCommunityNewFormat = types.BoolValue(true)
+ } else {
+ data.IpBgpCommunityNewFormat = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "ip.routing-conf.routing"); value.Exists() {
+ data.IpRouting = types.BoolValue(value.Bool())
+ } else {
+ data.IpRouting = types.BoolNull()
+ }
+ if value := res.Get(prefix + "ipv6.unicast-routing"); value.Exists() {
+ data.Ipv6UnicastRouting = types.BoolValue(true)
+ } else {
+ data.Ipv6UnicastRouting = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "system.Cisco-IOS-XE-switch:mtu.size"); value.Exists() {
+ data.Mtu = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "ip.source-route"); value.Exists() {
+ data.IpSourceRoute = types.BoolValue(value.Bool())
+ } else {
+ data.IpSourceRoute = types.BoolNull()
+ }
+ if value := res.Get(prefix + "ip.domain.lookup"); value.Exists() {
+ data.IpDomainLookup = types.BoolValue(value.Bool())
+ } else {
+ data.IpDomainLookup = types.BoolNull()
+ }
+ if value := res.Get(prefix + "ip.domain.name"); value.Exists() {
+ data.IpDomainName = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "login.delay"); value.Exists() {
+ data.LoginDelay = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "login.on-failure"); value.Exists() {
+ data.LoginOnFailure = types.BoolValue(true)
+ } else {
+ data.LoginOnFailure = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "login.on-failure.log"); value.Exists() {
+ data.LoginOnFailureLog = types.BoolValue(true)
+ } else {
+ data.LoginOnFailureLog = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "login.on-success"); value.Exists() {
+ data.LoginOnSuccess = types.BoolValue(true)
+ } else {
+ data.LoginOnSuccess = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "login.on-success.log"); value.Exists() {
+ data.LoginOnSuccessLog = types.BoolValue(true)
+ } else {
+ data.LoginOnSuccessLog = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "ip.Cisco-IOS-XE-multicast:multicast-routing"); value.Exists() {
+ data.IpMulticastRouting = types.BoolValue(true)
+ } else {
+ data.IpMulticastRouting = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "ip.Cisco-IOS-XE-multicast:mcr-conf.multicast-routing"); value.Exists() {
+ data.MulticastRoutingSwitch = types.BoolValue(true)
+ } else {
+ data.MulticastRoutingSwitch = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "ip.Cisco-IOS-XE-multicast:multicast-routing.distributed"); value.Exists() {
+ data.IpMulticastRoutingDistributed = types.BoolValue(true)
+ } else {
+ data.IpMulticastRoutingDistributed = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "ip.Cisco-IOS-XE-multicast:multicast-routing.vrf"); value.Exists() {
+ data.MulticastRoutingVrfs = make([]SystemMulticastRoutingVrfs, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := SystemMulticastRoutingVrfs{}
+ if cValue := v.Get("name"); cValue.Exists() {
+ item.Vrf = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("distributed"); cValue.Exists() {
+ item.Distributed = types.BoolValue(true)
+ } else {
+ item.Distributed = types.BoolValue(false)
+ }
+ data.MulticastRoutingVrfs = append(data.MulticastRoutingVrfs, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + "ip.Cisco-IOS-XE-http:http.access-class"); value.Exists() {
+ data.IpHttpAccessClass = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "ip.Cisco-IOS-XE-http:http.authentication.aaa"); value.Exists() {
+ data.IpHttpAuthenticationAaa = types.BoolValue(true)
+ } else {
+ data.IpHttpAuthenticationAaa = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "ip.Cisco-IOS-XE-http:http.authentication.aaa.exec-authorization"); value.Exists() {
+ data.IpHttpAuthenticationAaaExecAuthorization = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "ip.Cisco-IOS-XE-http:http.authentication.aaa.login-authentication"); value.Exists() {
+ data.IpHttpAuthenticationAaaLoginAuthentication = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "ip.Cisco-IOS-XE-http:http.authentication.aaa.command-authorization"); value.Exists() {
+ data.IpHttpAuthenticationAaaCommandAuthorization = make([]SystemIpHttpAuthenticationAaaCommandAuthorization, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := SystemIpHttpAuthenticationAaaCommandAuthorization{}
+ if cValue := v.Get("level"); cValue.Exists() {
+ item.Level = types.Int64Value(cValue.Int())
+ }
+ if cValue := v.Get("name"); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ data.IpHttpAuthenticationAaaCommandAuthorization = append(data.IpHttpAuthenticationAaaCommandAuthorization, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + "ip.Cisco-IOS-XE-http:http.authentication.local"); value.Exists() {
+ data.IpHttpAuthenticationLocal = types.BoolValue(true)
+ } else {
+ data.IpHttpAuthenticationLocal = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "ip.Cisco-IOS-XE-http:http.server"); value.Exists() {
+ data.IpHttpServer = types.BoolValue(value.Bool())
+ } else {
+ data.IpHttpServer = types.BoolNull()
+ }
+ if value := res.Get(prefix + "ip.Cisco-IOS-XE-http:http.secure-server"); value.Exists() {
+ data.IpHttpSecureServer = types.BoolValue(value.Bool())
+ } else {
+ data.IpHttpSecureServer = types.BoolNull()
+ }
+ if value := res.Get(prefix + "ip.Cisco-IOS-XE-http:http.secure-trustpoint"); value.Exists() {
+ data.IpHttpSecureTrustpoint = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "ip.Cisco-IOS-XE-http:http.tls-version"); value.Exists() {
+ data.IpHttpTlsVersion = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "ip.Cisco-IOS-XE-http:http.client.secure-trustpoint"); value.Exists() {
+ data.IpHttpClientSecureTrustpoint = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "ip.Cisco-IOS-XE-http:http.client.source-interface"); value.Exists() {
+ data.IpHttpClientSourceInterface = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "ip.Cisco-IOS-XE-http:http.secure-active-session-modules"); value.Exists() {
+ data.IpHttpSecureActiveSessionModules = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "ip.Cisco-IOS-XE-http:http.max-connections"); value.Exists() {
+ data.IpHttpMaxConnections = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "ip.Cisco-IOS-XE-http:http.active-session-modules"); value.Exists() {
+ data.IpHttpActiveSessionModules = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "ip.name-server.no-vrf-ordered"); value.Exists() {
+ data.IpNameServers = helpers.GetStringList(value.Array())
+ } else {
+ data.IpNameServers = types.ListNull(types.StringType)
+ }
+ if value := res.Get(prefix + "ip.name-server.vrf"); value.Exists() {
+ data.IpNameServersVrf = make([]SystemIpNameServersVrf, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := SystemIpNameServersVrf{}
+ if cValue := v.Get("word"); cValue.Exists() {
+ item.Vrf = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("server-ip-list-ordered"); cValue.Exists() {
+ item.Servers = helpers.GetStringList(cValue.Array())
+ } else {
+ item.Servers = types.ListNull(types.StringType)
+ }
+ data.IpNameServersVrf = append(data.IpNameServersVrf, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + "ip.domain.lookup-settings.lookup.source-interface.Loopback"); value.Exists() {
+ data.IpDomainLookupSourceInterfaceLoopback = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "ip.domain.lookup-settings.lookup.source-interface.Vlan"); value.Exists() {
+ data.IpDomainLookupSourceInterfaceVlan = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "ip.domain.lookup-settings.lookup.source-interface.GigabitEthernet"); value.Exists() {
+ data.IpDomainLookupSourceInterfaceGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "ip.domain.lookup-settings.lookup.source-interface.TwoGigabitEthernet"); value.Exists() {
+ data.IpDomainLookupSourceInterfaceTwoGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "ip.domain.lookup-settings.lookup.source-interface.FiveGigabitEthernet"); value.Exists() {
+ data.IpDomainLookupSourceInterfaceFiveGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "ip.domain.lookup-settings.lookup.source-interface.TenGigabitEthernet"); value.Exists() {
+ data.IpDomainLookupSourceInterfaceTenGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "ip.domain.lookup-settings.lookup.source-interface.TwentyFiveGigE"); value.Exists() {
+ data.IpDomainLookupSourceInterfaceTwentyFiveGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "ip.domain.lookup-settings.lookup.source-interface.FortyGigabitEthernet"); value.Exists() {
+ data.IpDomainLookupSourceInterfaceFortyGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "ip.domain.lookup-settings.lookup.source-interface.HundredGigE"); value.Exists() {
+ data.IpDomainLookupSourceInterfaceHundredGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "cisp.enable"); value.Exists() {
+ data.CispEnable = types.BoolValue(true)
+ } else {
+ data.CispEnable = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "epm.logging"); value.Exists() {
+ data.EpmLogging = types.BoolValue(true)
+ } else {
+ data.EpmLogging = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-sanet:access-session.mac-move.deny"); value.Exists() {
+ data.AccessSessionMacMoveDeny = types.BoolValue(true)
+ } else {
+ data.AccessSessionMacMoveDeny = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-diagnostics:diagnostic.bootup.level"); value.Exists() {
+ data.DiagnosticBootupLevel = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "memory.free.low-watermark.processor"); value.Exists() {
+ data.MemoryFreeLowWatermarkProcessor = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "archive.path"); value.Exists() {
+ data.ArchivePath = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "archive.maximum"); value.Exists() {
+ data.ArchiveMaximum = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "archive.write-memory"); value.Exists() {
+ data.ArchiveWriteMemory = types.BoolValue(true)
+ } else {
+ data.ArchiveWriteMemory = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "archive.time-period"); value.Exists() {
+ data.ArchiveTimePeriod = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "archive.log.config.logging.enable"); value.Exists() {
+ data.ArchiveLogConfigLoggingEnable = types.BoolValue(true)
+ } else {
+ data.ArchiveLogConfigLoggingEnable = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "archive.log.config.logging.size"); value.Exists() {
+ data.ArchiveLogConfigLoggingSize = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "redundancy"); value.Exists() {
+ data.Redundancy = types.BoolValue(true)
+ } else {
+ data.Redundancy = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "redundancy.mode"); value.Exists() {
+ data.RedundancyMode = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "transceivers.type.all.monitoring-enable.monitoring"); value.Exists() {
+ data.TransceiverTypeAllMonitoring = types.BoolValue(true)
+ } else {
+ data.TransceiverTypeAllMonitoring = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "ip.forward-protocol-v2.nd"); value.Exists() {
+ data.IpForwardProtocolNd = types.BoolValue(value.Bool())
+ } else {
+ data.IpForwardProtocolNd = types.BoolNull()
+ }
+ if value := res.Get(prefix + "ip.scp.server.enable"); value.Exists() {
+ data.IpScpServerEnable = types.BoolValue(true)
+ } else {
+ data.IpScpServerEnable = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "ip.ssh.ssh-version"); value.Exists() {
+ data.IpSshVersion = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "ip.ssh.version"); value.Exists() {
+ data.IpSshVersionLegacy = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "ip.ssh.time-out"); value.Exists() {
+ data.IpSshTimeOut = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "ip.ssh.authentication-retries"); value.Exists() {
+ data.IpSshAuthenticationRetries = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "ip.ssh.source-interface-config.Loopback"); value.Exists() {
+ data.IpSshSourceInterfaceLoopback = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "ip.ssh.source-interface-config.Vlan"); value.Exists() {
+ data.IpSshSourceInterfaceVlan = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "ip.ssh.source-interface-config.GigabitEthernet"); value.Exists() {
+ data.IpSshSourceInterfaceGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "ip.ssh.source-interface-config.TwoGigabitEthernet"); value.Exists() {
+ data.IpSshSourceInterfaceTwoGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "ip.ssh.source-interface-config.FiveGigabitEthernet"); value.Exists() {
+ data.IpSshSourceInterfaceFiveGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "ip.ssh.source-interface-config.TenGigabitEthernet"); value.Exists() {
+ data.IpSshSourceInterfaceTenGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "ip.ssh.source-interface-config.TwentyFiveGigE"); value.Exists() {
+ data.IpSshSourceInterfaceTwentyFiveGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "ip.ssh.source-interface-config.FortyGigabitEthernet"); value.Exists() {
+ data.IpSshSourceInterfaceFortyGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "ip.ssh.source-interface-config.HundredGigE"); value.Exists() {
+ data.IpSshSourceInterfaceHundredGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "control-plane.Cisco-IOS-XE-policy:service-policy.input"); value.Exists() {
+ data.ControlPlaneServicePolicyInput = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-pnp:pnp.profile"); value.Exists() {
+ data.PnpProfiles = make([]SystemPnpProfiles, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := SystemPnpProfiles{}
+ if cValue := v.Get("name"); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("transport.https.ipv4.ipv4-address"); cValue.Exists() {
+ item.TransportHttpsIpv4Ipv4Address = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("transport.https.ipv4.port"); cValue.Exists() {
+ item.TransportHttpsIpv4Port = types.Int64Value(cValue.Int())
+ }
+ data.PnpProfiles = append(data.PnpProfiles, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + "ip.Cisco-IOS-XE-aaa:tacacs.source-interface.Loopback"); value.Exists() {
+ data.IpTacacsSourceInterfaceLoopback = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "ip.Cisco-IOS-XE-aaa:tacacs.source-interface.Vlan"); value.Exists() {
+ data.IpTacacsSourceInterfaceVlan = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "ip.Cisco-IOS-XE-aaa:tacacs.source-interface.GigabitEthernet"); value.Exists() {
+ data.IpTacacsSourceInterfaceGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "ip.Cisco-IOS-XE-aaa:tacacs.source-interface.TwoGigabitEthernet"); value.Exists() {
+ data.IpTacacsSourceInterfaceTwoGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "ip.Cisco-IOS-XE-aaa:tacacs.source-interface.FiveGigabitEthernet"); value.Exists() {
+ data.IpTacacsSourceInterfaceFiveGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "ip.Cisco-IOS-XE-aaa:tacacs.source-interface.TenGigabitEthernet"); value.Exists() {
+ data.IpTacacsSourceInterfaceTenGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "ip.Cisco-IOS-XE-aaa:tacacs.source-interface.TwentyFiveGigE"); value.Exists() {
+ data.IpTacacsSourceInterfaceTwentyFiveGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "ip.Cisco-IOS-XE-aaa:tacacs.source-interface.FortyGigabitEthernet"); value.Exists() {
+ data.IpTacacsSourceInterfaceFortyGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "ip.Cisco-IOS-XE-aaa:tacacs.source-interface.HundredGigE"); value.Exists() {
+ data.IpTacacsSourceInterfaceHundredGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "ip.Cisco-IOS-XE-aaa:tacacs.source-interface.vrf"); value.Exists() {
+ data.IpTacacsSourceInterfaceVrf = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "ip.Cisco-IOS-XE-aaa:radius.source-interface.Loopback"); value.Exists() {
+ data.IpRadiusSourceInterfaceLoopback = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "ip.Cisco-IOS-XE-aaa:radius.source-interface.Vlan"); value.Exists() {
+ data.IpRadiusSourceInterfaceVlan = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "ip.Cisco-IOS-XE-aaa:radius.source-interface.GigabitEthernet"); value.Exists() {
+ data.IpRadiusSourceInterfaceGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "ip.Cisco-IOS-XE-aaa:radius.source-interface.TwoGigabitEthernet"); value.Exists() {
+ data.IpRadiusSourceInterfaceTwoGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "ip.Cisco-IOS-XE-aaa:radius.source-interface.FiveGigabitEthernet"); value.Exists() {
+ data.IpRadiusSourceInterfaceFiveGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "ip.Cisco-IOS-XE-aaa:radius.source-interface.TenGigabitEthernet"); value.Exists() {
+ data.IpRadiusSourceInterfaceTenGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "ip.Cisco-IOS-XE-aaa:radius.source-interface.TwentyFiveGigE"); value.Exists() {
+ data.IpRadiusSourceInterfaceTwentyFiveGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "ip.Cisco-IOS-XE-aaa:radius.source-interface.FortyGigabitEthernet"); value.Exists() {
+ data.IpRadiusSourceInterfaceFortyGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "ip.Cisco-IOS-XE-aaa:radius.source-interface.HundredGigE"); value.Exists() {
+ data.IpRadiusSourceInterfaceHundredGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "ip.Cisco-IOS-XE-aaa:radius.source-interface.vrf"); value.Exists() {
+ data.IpRadiusSourceInterfaceVrf = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "boot.system.flash.flash-list-ordered-by-user"); value.Exists() {
+ data.BootSystemFlashFiles = make([]SystemBootSystemFlashFiles, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := SystemBootSystemFlashFiles{}
+ if cValue := v.Get("flash-leaf"); cValue.Exists() {
+ item.Path = types.StringValue(cValue.String())
+ }
+ data.BootSystemFlashFiles = append(data.BootSystemFlashFiles, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + "boot.system.bootfile.filename-list-ordered-by-user"); value.Exists() {
+ data.BootSystemBootfiles = make([]SystemBootSystemBootfiles, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := SystemBootSystemBootfiles{}
+ if cValue := v.Get("filename"); cValue.Exists() {
+ item.Path = types.StringValue(cValue.String())
+ }
+ data.BootSystemBootfiles = append(data.BootSystemBootfiles, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + "enable.secret.secret"); value.Exists() {
+ data.EnableSecret = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "enable.secret.type"); value.Exists() {
+ data.EnableSecretType = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "enable.secret.level"); value.Exists() {
+ data.EnableSecretLevel = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "ip.host.host-list"); value.Exists() {
+ data.IpHosts = make([]SystemIpHosts, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := SystemIpHosts{}
+ if cValue := v.Get("name"); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("ip-list-ordered"); cValue.Exists() {
+ item.Ips = helpers.GetStringList(cValue.Array())
+ } else {
+ item.Ips = types.ListNull(types.StringType)
+ }
+ data.IpHosts = append(data.IpHosts, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + "ip.host.vrf"); value.Exists() {
+ data.IpHostsVrf = make([]SystemIpHostsVrf, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := SystemIpHostsVrf{}
+ if cValue := v.Get("vrf-name"); cValue.Exists() {
+ item.Vrf = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("host-name"); cValue.Exists() {
+ item.Hosts = make([]SystemIpHostsVrfHosts, 0)
+ cValue.ForEach(func(ck, cv gjson.Result) bool {
+ cItem := SystemIpHostsVrfHosts{}
+ if ccValue := cv.Get("host-name"); ccValue.Exists() {
+ cItem.Name = types.StringValue(ccValue.String())
+ }
+ if ccValue := cv.Get("ip-list"); ccValue.Exists() {
+ cItem.Ips = helpers.GetStringList(ccValue.Array())
+ } else {
+ cItem.Ips = types.ListNull(types.StringType)
+ }
+ item.Hosts = append(item.Hosts, cItem)
+ return true
+ })
+ }
+ data.IpHostsVrf = append(data.IpHostsVrf, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-diagnostics:diagnostic.event-log.size"); value.Exists() {
+ data.DiagnosticEventLogSize = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "subscriber.templating"); value.Exists() {
+ data.SubscriberTemplating = types.BoolValue(true)
+ } else {
+ data.SubscriberTemplating = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "call-home.Cisco-IOS-XE-call-home:contact-email-addr"); value.Exists() {
+ data.CallHomeContactEmail = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "call-home.Cisco-IOS-XE-call-home:tac-profile.profile.CiscoTAC-1.active"); value.Exists() {
+ data.CallHomeCiscoTac1ProfileActive = types.BoolValue(value.Bool())
+ } else {
+ data.CallHomeCiscoTac1ProfileActive = types.BoolNull()
+ }
+ if value := res.Get(prefix + "call-home.Cisco-IOS-XE-call-home:tac-profile.profile.CiscoTAC-1.destination.transport-method"); value.Exists() {
+ data.CallHomeCiscoTac1DestinationTransportMethod = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "ip.ftp.passive-enable"); value.Exists() {
+ data.IpFtpPassive = types.BoolValue(value.Bool())
+ } else {
+ data.IpFtpPassive = types.BoolNull()
+ }
+ if value := res.Get(prefix + "ip.tftp.source-interface.GigabitEthernet"); value.Exists() {
+ data.TftpSourceInterfaceGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "ip.tftp.source-interface.Loopback"); value.Exists() {
+ data.TftpSourceInterfaceLoopback = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "ip.tftp.source-interface.Vlan"); value.Exists() {
+ data.TftpSourceInterfaceVlan = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "ip.tftp.source-interface.TwoGigabitEthernet"); value.Exists() {
+ data.TftpSourceInterfaceTwoGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "ip.tftp.source-interface.FiveGigabitEthernet"); value.Exists() {
+ data.TftpSourceInterfaceFiveGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "ip.tftp.source-interface.TenGigabitEthernet"); value.Exists() {
+ data.TftpSourceInterfaceTenGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "ip.tftp.source-interface.TwentyFiveGigabitEthernet"); value.Exists() {
+ data.TftpSourceInterfaceTwentyFiveGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "ip.tftp.source-interface.FortyGigabitEthernet"); value.Exists() {
+ data.TftpSourceInterfaceFortyGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "ip.tftp.source-interface.HundredGigE"); value.Exists() {
+ data.TftpSourceInterfaceHundredGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "multilink.Cisco-IOS-XE-ppp:bundle-name"); value.Exists() {
+ data.MultilinkPppBundleName = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "version"); value.Exists() {
+ data.Version = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "track.Cisco-IOS-XE-track:tracked-object-v2"); value.Exists() {
+ data.TrackObjects = make([]SystemTrackObjects, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := SystemTrackObjects{}
+ if cValue := v.Get("object-number"); cValue.Exists() {
+ item.Number = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("ip.sla.number"); cValue.Exists() {
+ item.IpSlaNumber = types.Int64Value(cValue.Int())
+ }
+ if cValue := v.Get("ip.sla.reachability"); cValue.Exists() {
+ item.IpSlaReachability = types.BoolValue(true)
+ } else {
+ item.IpSlaReachability = types.BoolValue(false)
+ }
+ data.TrackObjects = append(data.TrackObjects, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + "ip.Cisco-IOS-XE-nbar:nbar.classification.dns.classify-by-domain-with-default"); value.Exists() {
+ data.IpNbarClassificationDnsClassifyByDomain = types.BoolValue(value.Bool())
+ } else {
+ data.IpNbarClassificationDnsClassifyByDomain = types.BoolNull()
+ }
+ if value := res.Get(prefix + "ip.multicast.Cisco-IOS-XE-multicast:route-limit-container.routelimit"); value.Exists() {
+ data.IpMulticastRouteLimit = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-aaa:security.passwords.min-length"); value.Exists() {
+ data.SecurityPasswordsMinLength = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "ip.domain.list.domain-name"); value.Exists() {
+ data.IpDomainListNames = helpers.GetStringList(value.Array())
+ } else {
+ data.IpDomainListNames = types.ListNull(types.StringType)
+ }
+ if value := res.Get(prefix + "ip.domain.list.vrf.domain-name"); value.Exists() {
+ data.IpDomainListVrfDomain = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "ip.domain.list.vrf.vrf-name"); value.Exists() {
+ data.IpDomainListVrf = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "ethernet.Cisco-IOS-XE-ethernet:cfm.alarm-config.delay"); value.Exists() {
+ data.EthernetCfmAlarmConfigDelay = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "ethernet.Cisco-IOS-XE-ethernet:cfm.alarm-config.reset"); value.Exists() {
+ data.EthernetCfmAlarmConfigReset = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "standby.redirects-config.redirects"); value.Exists() {
+ data.StandbyRedirects = types.BoolValue(value.Bool())
+ } else {
+ data.StandbyRedirects = types.BoolNull()
+ }
+ if value := res.Get(prefix + "standby.redirects-config.redirect-enable-disable.redirects"); value.Exists() {
+ data.StandbyRedirectsEnableDisable = types.StringValue(value.String())
+ }
+}
+
+// End of section. //template:end fromBodyData
+
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyXML
+
+func (data *System) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/hostname"); value.Exists() {
+ data.Hostname = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/bgp-community/new-format"); value.Exists() {
+ data.IpBgpCommunityNewFormat = types.BoolValue(true)
+ } else {
+ data.IpBgpCommunityNewFormat = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/routing-conf/routing"); value.Exists() {
+ data.IpRouting = types.BoolValue(value.Bool())
+ } else {
+ data.IpRouting = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ipv6/unicast-routing"); value.Exists() {
+ data.Ipv6UnicastRouting = types.BoolValue(true)
+ } else {
+ data.Ipv6UnicastRouting = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/system/Cisco-IOS-XE-switch:mtu/size"); value.Exists() {
+ data.Mtu = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/source-route"); value.Exists() {
+ data.IpSourceRoute = types.BoolValue(value.Bool())
+ } else {
+ data.IpSourceRoute = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/domain/lookup"); value.Exists() {
+ data.IpDomainLookup = types.BoolValue(value.Bool())
+ } else {
+ data.IpDomainLookup = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/domain/name"); value.Exists() {
+ data.IpDomainName = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/login/delay"); value.Exists() {
+ data.LoginDelay = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/login/on-failure"); value.Exists() {
+ data.LoginOnFailure = types.BoolValue(true)
+ } else {
+ data.LoginOnFailure = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/login/on-failure/log"); value.Exists() {
+ data.LoginOnFailureLog = types.BoolValue(true)
+ } else {
+ data.LoginOnFailureLog = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/login/on-success"); value.Exists() {
+ data.LoginOnSuccess = types.BoolValue(true)
+ } else {
+ data.LoginOnSuccess = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/login/on-success/log"); value.Exists() {
+ data.LoginOnSuccessLog = types.BoolValue(true)
+ } else {
+ data.LoginOnSuccessLog = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/Cisco-IOS-XE-multicast:multicast-routing"); value.Exists() {
+ data.IpMulticastRouting = types.BoolValue(true)
+ } else {
+ data.IpMulticastRouting = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/Cisco-IOS-XE-multicast:mcr-conf/multicast-routing"); value.Exists() {
+ data.MulticastRoutingSwitch = types.BoolValue(true)
+ } else {
+ data.MulticastRoutingSwitch = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/Cisco-IOS-XE-multicast:multicast-routing/distributed"); value.Exists() {
+ data.IpMulticastRoutingDistributed = types.BoolValue(true)
+ } else {
+ data.IpMulticastRoutingDistributed = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/Cisco-IOS-XE-multicast:multicast-routing/vrf"); value.Exists() {
+ data.MulticastRoutingVrfs = make([]SystemMulticastRoutingVrfs, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := SystemMulticastRoutingVrfs{}
+ if cValue := helpers.GetFromXPath(v, "name"); cValue.Exists() {
+ item.Vrf = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "distributed"); cValue.Exists() {
+ item.Distributed = types.BoolValue(true)
+ } else {
+ item.Distributed = types.BoolValue(false)
+ }
+ data.MulticastRoutingVrfs = append(data.MulticastRoutingVrfs, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/Cisco-IOS-XE-http:http/access-class"); value.Exists() {
+ data.IpHttpAccessClass = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/Cisco-IOS-XE-http:http/authentication/aaa"); value.Exists() {
+ data.IpHttpAuthenticationAaa = types.BoolValue(true)
+ } else {
+ data.IpHttpAuthenticationAaa = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/Cisco-IOS-XE-http:http/authentication/aaa/exec-authorization"); value.Exists() {
+ data.IpHttpAuthenticationAaaExecAuthorization = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/Cisco-IOS-XE-http:http/authentication/aaa/login-authentication"); value.Exists() {
+ data.IpHttpAuthenticationAaaLoginAuthentication = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/Cisco-IOS-XE-http:http/authentication/aaa/command-authorization"); value.Exists() {
+ data.IpHttpAuthenticationAaaCommandAuthorization = make([]SystemIpHttpAuthenticationAaaCommandAuthorization, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := SystemIpHttpAuthenticationAaaCommandAuthorization{}
+ if cValue := helpers.GetFromXPath(v, "level"); cValue.Exists() {
+ item.Level = types.Int64Value(cValue.Int())
+ }
+ if cValue := helpers.GetFromXPath(v, "name"); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ data.IpHttpAuthenticationAaaCommandAuthorization = append(data.IpHttpAuthenticationAaaCommandAuthorization, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/Cisco-IOS-XE-http:http/authentication/local"); value.Exists() {
+ data.IpHttpAuthenticationLocal = types.BoolValue(true)
+ } else {
+ data.IpHttpAuthenticationLocal = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/Cisco-IOS-XE-http:http/server"); value.Exists() {
+ data.IpHttpServer = types.BoolValue(value.Bool())
+ } else {
+ data.IpHttpServer = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/Cisco-IOS-XE-http:http/secure-server"); value.Exists() {
+ data.IpHttpSecureServer = types.BoolValue(value.Bool())
+ } else {
+ data.IpHttpSecureServer = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/Cisco-IOS-XE-http:http/secure-trustpoint"); value.Exists() {
+ data.IpHttpSecureTrustpoint = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/Cisco-IOS-XE-http:http/tls-version"); value.Exists() {
+ data.IpHttpTlsVersion = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/Cisco-IOS-XE-http:http/client/secure-trustpoint"); value.Exists() {
+ data.IpHttpClientSecureTrustpoint = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/Cisco-IOS-XE-http:http/client/source-interface"); value.Exists() {
+ data.IpHttpClientSourceInterface = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/Cisco-IOS-XE-http:http/secure-active-session-modules"); value.Exists() {
+ data.IpHttpSecureActiveSessionModules = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/Cisco-IOS-XE-http:http/max-connections"); value.Exists() {
+ data.IpHttpMaxConnections = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/Cisco-IOS-XE-http:http/active-session-modules"); value.Exists() {
+ data.IpHttpActiveSessionModules = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/name-server/no-vrf-ordered"); value.Exists() {
+ data.IpNameServers = helpers.GetStringListXML(value.Array())
+ } else {
+ data.IpNameServers = types.ListNull(types.StringType)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/name-server/vrf"); value.Exists() {
+ data.IpNameServersVrf = make([]SystemIpNameServersVrf, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := SystemIpNameServersVrf{}
+ if cValue := helpers.GetFromXPath(v, "word"); cValue.Exists() {
+ item.Vrf = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "server-ip-list-ordered"); cValue.Exists() {
+ item.Servers = helpers.GetStringListXML(cValue.Array())
+ } else {
+ item.Servers = types.ListNull(types.StringType)
+ }
+ data.IpNameServersVrf = append(data.IpNameServersVrf, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/domain/lookup-settings/lookup/source-interface/Loopback"); value.Exists() {
+ data.IpDomainLookupSourceInterfaceLoopback = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/domain/lookup-settings/lookup/source-interface/Vlan"); value.Exists() {
+ data.IpDomainLookupSourceInterfaceVlan = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/domain/lookup-settings/lookup/source-interface/GigabitEthernet"); value.Exists() {
+ data.IpDomainLookupSourceInterfaceGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/domain/lookup-settings/lookup/source-interface/TwoGigabitEthernet"); value.Exists() {
+ data.IpDomainLookupSourceInterfaceTwoGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/domain/lookup-settings/lookup/source-interface/FiveGigabitEthernet"); value.Exists() {
+ data.IpDomainLookupSourceInterfaceFiveGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/domain/lookup-settings/lookup/source-interface/TenGigabitEthernet"); value.Exists() {
+ data.IpDomainLookupSourceInterfaceTenGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/domain/lookup-settings/lookup/source-interface/TwentyFiveGigE"); value.Exists() {
+ data.IpDomainLookupSourceInterfaceTwentyFiveGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/domain/lookup-settings/lookup/source-interface/FortyGigabitEthernet"); value.Exists() {
+ data.IpDomainLookupSourceInterfaceFortyGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/domain/lookup-settings/lookup/source-interface/HundredGigE"); value.Exists() {
+ data.IpDomainLookupSourceInterfaceHundredGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/cisp/enable"); value.Exists() {
+ data.CispEnable = types.BoolValue(true)
+ } else {
+ data.CispEnable = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/epm/logging"); value.Exists() {
+ data.EpmLogging = types.BoolValue(true)
+ } else {
+ data.EpmLogging = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-sanet:access-session/mac-move/deny"); value.Exists() {
+ data.AccessSessionMacMoveDeny = types.BoolValue(true)
+ } else {
+ data.AccessSessionMacMoveDeny = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-diagnostics:diagnostic/bootup/level"); value.Exists() {
+ data.DiagnosticBootupLevel = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/memory/free/low-watermark/processor"); value.Exists() {
+ data.MemoryFreeLowWatermarkProcessor = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/archive/path"); value.Exists() {
+ data.ArchivePath = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/archive/maximum"); value.Exists() {
+ data.ArchiveMaximum = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/archive/write-memory"); value.Exists() {
+ data.ArchiveWriteMemory = types.BoolValue(true)
+ } else {
+ data.ArchiveWriteMemory = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/archive/time-period"); value.Exists() {
+ data.ArchiveTimePeriod = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/archive/log/config/logging/enable"); value.Exists() {
+ data.ArchiveLogConfigLoggingEnable = types.BoolValue(true)
+ } else {
+ data.ArchiveLogConfigLoggingEnable = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/archive/log/config/logging/size"); value.Exists() {
+ data.ArchiveLogConfigLoggingSize = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/redundancy"); value.Exists() {
+ data.Redundancy = types.BoolValue(true)
+ } else {
+ data.Redundancy = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/redundancy/mode"); value.Exists() {
+ data.RedundancyMode = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/transceivers/type/all/monitoring-enable/monitoring"); value.Exists() {
+ data.TransceiverTypeAllMonitoring = types.BoolValue(true)
+ } else {
+ data.TransceiverTypeAllMonitoring = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/forward-protocol-v2/nd"); value.Exists() {
+ data.IpForwardProtocolNd = types.BoolValue(value.Bool())
+ } else {
+ data.IpForwardProtocolNd = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/scp/server/enable"); value.Exists() {
+ data.IpScpServerEnable = types.BoolValue(true)
+ } else {
+ data.IpScpServerEnable = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/ssh/ssh-version"); value.Exists() {
+ data.IpSshVersion = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/ssh/version"); value.Exists() {
+ data.IpSshVersionLegacy = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/ssh/time-out"); value.Exists() {
+ data.IpSshTimeOut = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/ssh/authentication-retries"); value.Exists() {
+ data.IpSshAuthenticationRetries = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/ssh/source-interface-config/Loopback"); value.Exists() {
+ data.IpSshSourceInterfaceLoopback = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/ssh/source-interface-config/Vlan"); value.Exists() {
+ data.IpSshSourceInterfaceVlan = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/ssh/source-interface-config/GigabitEthernet"); value.Exists() {
+ data.IpSshSourceInterfaceGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/ssh/source-interface-config/TwoGigabitEthernet"); value.Exists() {
+ data.IpSshSourceInterfaceTwoGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/ssh/source-interface-config/FiveGigabitEthernet"); value.Exists() {
+ data.IpSshSourceInterfaceFiveGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/ssh/source-interface-config/TenGigabitEthernet"); value.Exists() {
+ data.IpSshSourceInterfaceTenGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/ssh/source-interface-config/TwentyFiveGigE"); value.Exists() {
+ data.IpSshSourceInterfaceTwentyFiveGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/ssh/source-interface-config/FortyGigabitEthernet"); value.Exists() {
+ data.IpSshSourceInterfaceFortyGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/ssh/source-interface-config/HundredGigE"); value.Exists() {
+ data.IpSshSourceInterfaceHundredGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/control-plane/Cisco-IOS-XE-policy:service-policy/input"); value.Exists() {
+ data.ControlPlaneServicePolicyInput = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-pnp:pnp/profile"); value.Exists() {
+ data.PnpProfiles = make([]SystemPnpProfiles, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := SystemPnpProfiles{}
+ if cValue := helpers.GetFromXPath(v, "name"); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "transport/https/ipv4/ipv4-address"); cValue.Exists() {
+ item.TransportHttpsIpv4Ipv4Address = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "transport/https/ipv4/port"); cValue.Exists() {
+ item.TransportHttpsIpv4Port = types.Int64Value(cValue.Int())
+ }
+ data.PnpProfiles = append(data.PnpProfiles, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/Cisco-IOS-XE-aaa:tacacs/source-interface/Loopback"); value.Exists() {
+ data.IpTacacsSourceInterfaceLoopback = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/Cisco-IOS-XE-aaa:tacacs/source-interface/Vlan"); value.Exists() {
+ data.IpTacacsSourceInterfaceVlan = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/Cisco-IOS-XE-aaa:tacacs/source-interface/GigabitEthernet"); value.Exists() {
+ data.IpTacacsSourceInterfaceGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/Cisco-IOS-XE-aaa:tacacs/source-interface/TwoGigabitEthernet"); value.Exists() {
+ data.IpTacacsSourceInterfaceTwoGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/Cisco-IOS-XE-aaa:tacacs/source-interface/FiveGigabitEthernet"); value.Exists() {
+ data.IpTacacsSourceInterfaceFiveGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/Cisco-IOS-XE-aaa:tacacs/source-interface/TenGigabitEthernet"); value.Exists() {
+ data.IpTacacsSourceInterfaceTenGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/Cisco-IOS-XE-aaa:tacacs/source-interface/TwentyFiveGigE"); value.Exists() {
+ data.IpTacacsSourceInterfaceTwentyFiveGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/Cisco-IOS-XE-aaa:tacacs/source-interface/FortyGigabitEthernet"); value.Exists() {
+ data.IpTacacsSourceInterfaceFortyGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/Cisco-IOS-XE-aaa:tacacs/source-interface/HundredGigE"); value.Exists() {
+ data.IpTacacsSourceInterfaceHundredGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/Cisco-IOS-XE-aaa:tacacs/source-interface/vrf"); value.Exists() {
+ data.IpTacacsSourceInterfaceVrf = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/Cisco-IOS-XE-aaa:radius/source-interface/Loopback"); value.Exists() {
+ data.IpRadiusSourceInterfaceLoopback = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/Cisco-IOS-XE-aaa:radius/source-interface/Vlan"); value.Exists() {
+ data.IpRadiusSourceInterfaceVlan = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/Cisco-IOS-XE-aaa:radius/source-interface/GigabitEthernet"); value.Exists() {
+ data.IpRadiusSourceInterfaceGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/Cisco-IOS-XE-aaa:radius/source-interface/TwoGigabitEthernet"); value.Exists() {
+ data.IpRadiusSourceInterfaceTwoGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/Cisco-IOS-XE-aaa:radius/source-interface/FiveGigabitEthernet"); value.Exists() {
+ data.IpRadiusSourceInterfaceFiveGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/Cisco-IOS-XE-aaa:radius/source-interface/TenGigabitEthernet"); value.Exists() {
+ data.IpRadiusSourceInterfaceTenGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/Cisco-IOS-XE-aaa:radius/source-interface/TwentyFiveGigE"); value.Exists() {
+ data.IpRadiusSourceInterfaceTwentyFiveGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/Cisco-IOS-XE-aaa:radius/source-interface/FortyGigabitEthernet"); value.Exists() {
+ data.IpRadiusSourceInterfaceFortyGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/Cisco-IOS-XE-aaa:radius/source-interface/HundredGigE"); value.Exists() {
+ data.IpRadiusSourceInterfaceHundredGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/Cisco-IOS-XE-aaa:radius/source-interface/vrf"); value.Exists() {
+ data.IpRadiusSourceInterfaceVrf = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/boot/system/flash/flash-list-ordered-by-user"); value.Exists() {
+ data.BootSystemFlashFiles = make([]SystemBootSystemFlashFiles, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := SystemBootSystemFlashFiles{}
+ if cValue := helpers.GetFromXPath(v, "flash-leaf"); cValue.Exists() {
+ item.Path = types.StringValue(cValue.String())
+ }
+ data.BootSystemFlashFiles = append(data.BootSystemFlashFiles, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/boot/system/bootfile/filename-list-ordered-by-user"); value.Exists() {
+ data.BootSystemBootfiles = make([]SystemBootSystemBootfiles, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := SystemBootSystemBootfiles{}
+ if cValue := helpers.GetFromXPath(v, "filename"); cValue.Exists() {
+ item.Path = types.StringValue(cValue.String())
+ }
+ data.BootSystemBootfiles = append(data.BootSystemBootfiles, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/enable/secret/secret"); value.Exists() {
+ data.EnableSecret = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/enable/secret/type"); value.Exists() {
+ data.EnableSecretType = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/enable/secret/level"); value.Exists() {
+ data.EnableSecretLevel = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/host/host-list"); value.Exists() {
+ data.IpHosts = make([]SystemIpHosts, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := SystemIpHosts{}
+ if cValue := helpers.GetFromXPath(v, "name"); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "ip-list-ordered"); cValue.Exists() {
+ item.Ips = helpers.GetStringListXML(cValue.Array())
+ } else {
+ item.Ips = types.ListNull(types.StringType)
+ }
+ data.IpHosts = append(data.IpHosts, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/host/vrf"); value.Exists() {
+ data.IpHostsVrf = make([]SystemIpHostsVrf, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := SystemIpHostsVrf{}
+ if cValue := helpers.GetFromXPath(v, "vrf-name"); cValue.Exists() {
+ item.Vrf = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "host-name"); cValue.Exists() {
+ item.Hosts = make([]SystemIpHostsVrfHosts, 0)
+ cValue.ForEach(func(_ int, cv xmldot.Result) bool {
+ cItem := SystemIpHostsVrfHosts{}
+ if ccValue := helpers.GetFromXPath(cv, "host-name"); ccValue.Exists() {
+ cItem.Name = types.StringValue(ccValue.String())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "ip-list"); ccValue.Exists() {
+ cItem.Ips = helpers.GetStringListXML(ccValue.Array())
+ } else {
+ cItem.Ips = types.ListNull(types.StringType)
+ }
+ item.Hosts = append(item.Hosts, cItem)
+ return true
+ })
+ }
+ data.IpHostsVrf = append(data.IpHostsVrf, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-diagnostics:diagnostic/event-log/size"); value.Exists() {
+ data.DiagnosticEventLogSize = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/subscriber/templating"); value.Exists() {
+ data.SubscriberTemplating = types.BoolValue(true)
+ } else {
+ data.SubscriberTemplating = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/call-home/Cisco-IOS-XE-call-home:contact-email-addr"); value.Exists() {
+ data.CallHomeContactEmail = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/call-home/Cisco-IOS-XE-call-home:tac-profile/profile/CiscoTAC-1/active"); value.Exists() {
+ data.CallHomeCiscoTac1ProfileActive = types.BoolValue(value.Bool())
+ } else {
+ data.CallHomeCiscoTac1ProfileActive = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/call-home/Cisco-IOS-XE-call-home:tac-profile/profile/CiscoTAC-1/destination/transport-method"); value.Exists() {
+ data.CallHomeCiscoTac1DestinationTransportMethod = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/ftp/passive-enable"); value.Exists() {
+ data.IpFtpPassive = types.BoolValue(value.Bool())
+ } else {
+ data.IpFtpPassive = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/tftp/source-interface/GigabitEthernet"); value.Exists() {
+ data.TftpSourceInterfaceGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/tftp/source-interface/Loopback"); value.Exists() {
+ data.TftpSourceInterfaceLoopback = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/tftp/source-interface/Vlan"); value.Exists() {
+ data.TftpSourceInterfaceVlan = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/tftp/source-interface/TwoGigabitEthernet"); value.Exists() {
+ data.TftpSourceInterfaceTwoGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/tftp/source-interface/FiveGigabitEthernet"); value.Exists() {
+ data.TftpSourceInterfaceFiveGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/tftp/source-interface/TenGigabitEthernet"); value.Exists() {
+ data.TftpSourceInterfaceTenGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/tftp/source-interface/TwentyFiveGigabitEthernet"); value.Exists() {
+ data.TftpSourceInterfaceTwentyFiveGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/tftp/source-interface/FortyGigabitEthernet"); value.Exists() {
+ data.TftpSourceInterfaceFortyGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/tftp/source-interface/HundredGigE"); value.Exists() {
+ data.TftpSourceInterfaceHundredGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/multilink/Cisco-IOS-XE-ppp:bundle-name"); value.Exists() {
+ data.MultilinkPppBundleName = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/version"); value.Exists() {
+ data.Version = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/track/Cisco-IOS-XE-track:tracked-object-v2"); value.Exists() {
+ data.TrackObjects = make([]SystemTrackObjects, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := SystemTrackObjects{}
+ if cValue := helpers.GetFromXPath(v, "object-number"); cValue.Exists() {
+ item.Number = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "ip/sla/number"); cValue.Exists() {
+ item.IpSlaNumber = types.Int64Value(cValue.Int())
+ }
+ if cValue := helpers.GetFromXPath(v, "ip/sla/reachability"); cValue.Exists() {
+ item.IpSlaReachability = types.BoolValue(true)
+ } else {
+ item.IpSlaReachability = types.BoolValue(false)
+ }
+ data.TrackObjects = append(data.TrackObjects, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/Cisco-IOS-XE-nbar:nbar/classification/dns/classify-by-domain-with-default"); value.Exists() {
+ data.IpNbarClassificationDnsClassifyByDomain = types.BoolValue(value.Bool())
+ } else {
+ data.IpNbarClassificationDnsClassifyByDomain = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/multicast/Cisco-IOS-XE-multicast:route-limit-container/routelimit"); value.Exists() {
+ data.IpMulticastRouteLimit = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-aaa:security/passwords/min-length"); value.Exists() {
+ data.SecurityPasswordsMinLength = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/domain/list/domain-name"); value.Exists() {
+ data.IpDomainListNames = helpers.GetStringListXML(value.Array())
+ } else {
+ data.IpDomainListNames = types.ListNull(types.StringType)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/domain/list/vrf/domain-name"); value.Exists() {
+ data.IpDomainListVrfDomain = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/domain/list/vrf/vrf-name"); value.Exists() {
+ data.IpDomainListVrf = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ethernet/Cisco-IOS-XE-ethernet:cfm/alarm-config/delay"); value.Exists() {
+ data.EthernetCfmAlarmConfigDelay = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ethernet/Cisco-IOS-XE-ethernet:cfm/alarm-config/reset"); value.Exists() {
+ data.EthernetCfmAlarmConfigReset = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/standby/redirects-config/redirects"); value.Exists() {
+ data.StandbyRedirects = types.BoolValue(value.Bool())
+ } else {
+ data.StandbyRedirects = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/standby/redirects-config/redirect-enable-disable/redirects"); value.Exists() {
+ data.StandbyRedirectsEnableDisable = types.StringValue(value.String())
+ }
+}
+
+// End of section. //template:end fromBodyXML
+
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyDataXML
+
+func (data *SystemData) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/hostname"); value.Exists() {
+ data.Hostname = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/bgp-community/new-format"); value.Exists() {
+ data.IpBgpCommunityNewFormat = types.BoolValue(true)
+ } else {
+ data.IpBgpCommunityNewFormat = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/routing-conf/routing"); value.Exists() {
+ data.IpRouting = types.BoolValue(value.Bool())
+ } else {
+ data.IpRouting = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ipv6/unicast-routing"); value.Exists() {
+ data.Ipv6UnicastRouting = types.BoolValue(true)
+ } else {
+ data.Ipv6UnicastRouting = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/system/Cisco-IOS-XE-switch:mtu/size"); value.Exists() {
+ data.Mtu = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/source-route"); value.Exists() {
+ data.IpSourceRoute = types.BoolValue(value.Bool())
+ } else {
+ data.IpSourceRoute = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/domain/lookup"); value.Exists() {
+ data.IpDomainLookup = types.BoolValue(value.Bool())
+ } else {
+ data.IpDomainLookup = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/domain/name"); value.Exists() {
+ data.IpDomainName = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/login/delay"); value.Exists() {
+ data.LoginDelay = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/login/on-failure"); value.Exists() {
+ data.LoginOnFailure = types.BoolValue(true)
+ } else {
+ data.LoginOnFailure = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/login/on-failure/log"); value.Exists() {
+ data.LoginOnFailureLog = types.BoolValue(true)
+ } else {
+ data.LoginOnFailureLog = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/login/on-success"); value.Exists() {
+ data.LoginOnSuccess = types.BoolValue(true)
+ } else {
+ data.LoginOnSuccess = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/login/on-success/log"); value.Exists() {
+ data.LoginOnSuccessLog = types.BoolValue(true)
+ } else {
+ data.LoginOnSuccessLog = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/Cisco-IOS-XE-multicast:multicast-routing"); value.Exists() {
+ data.IpMulticastRouting = types.BoolValue(true)
+ } else {
+ data.IpMulticastRouting = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/Cisco-IOS-XE-multicast:mcr-conf/multicast-routing"); value.Exists() {
+ data.MulticastRoutingSwitch = types.BoolValue(true)
+ } else {
+ data.MulticastRoutingSwitch = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/Cisco-IOS-XE-multicast:multicast-routing/distributed"); value.Exists() {
+ data.IpMulticastRoutingDistributed = types.BoolValue(true)
+ } else {
+ data.IpMulticastRoutingDistributed = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/Cisco-IOS-XE-multicast:multicast-routing/vrf"); value.Exists() {
+ data.MulticastRoutingVrfs = make([]SystemMulticastRoutingVrfs, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := SystemMulticastRoutingVrfs{}
+ if cValue := helpers.GetFromXPath(v, "name"); cValue.Exists() {
+ item.Vrf = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "distributed"); cValue.Exists() {
+ item.Distributed = types.BoolValue(true)
+ } else {
+ item.Distributed = types.BoolValue(false)
+ }
+ data.MulticastRoutingVrfs = append(data.MulticastRoutingVrfs, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/Cisco-IOS-XE-http:http/access-class"); value.Exists() {
+ data.IpHttpAccessClass = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/Cisco-IOS-XE-http:http/authentication/aaa"); value.Exists() {
+ data.IpHttpAuthenticationAaa = types.BoolValue(true)
+ } else {
+ data.IpHttpAuthenticationAaa = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/Cisco-IOS-XE-http:http/authentication/aaa/exec-authorization"); value.Exists() {
+ data.IpHttpAuthenticationAaaExecAuthorization = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/Cisco-IOS-XE-http:http/authentication/aaa/login-authentication"); value.Exists() {
+ data.IpHttpAuthenticationAaaLoginAuthentication = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/Cisco-IOS-XE-http:http/authentication/aaa/command-authorization"); value.Exists() {
+ data.IpHttpAuthenticationAaaCommandAuthorization = make([]SystemIpHttpAuthenticationAaaCommandAuthorization, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := SystemIpHttpAuthenticationAaaCommandAuthorization{}
+ if cValue := helpers.GetFromXPath(v, "level"); cValue.Exists() {
+ item.Level = types.Int64Value(cValue.Int())
+ }
+ if cValue := helpers.GetFromXPath(v, "name"); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ data.IpHttpAuthenticationAaaCommandAuthorization = append(data.IpHttpAuthenticationAaaCommandAuthorization, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/Cisco-IOS-XE-http:http/authentication/local"); value.Exists() {
+ data.IpHttpAuthenticationLocal = types.BoolValue(true)
+ } else {
+ data.IpHttpAuthenticationLocal = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/Cisco-IOS-XE-http:http/server"); value.Exists() {
+ data.IpHttpServer = types.BoolValue(value.Bool())
+ } else {
+ data.IpHttpServer = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/Cisco-IOS-XE-http:http/secure-server"); value.Exists() {
+ data.IpHttpSecureServer = types.BoolValue(value.Bool())
+ } else {
+ data.IpHttpSecureServer = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/Cisco-IOS-XE-http:http/secure-trustpoint"); value.Exists() {
+ data.IpHttpSecureTrustpoint = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/Cisco-IOS-XE-http:http/tls-version"); value.Exists() {
+ data.IpHttpTlsVersion = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/Cisco-IOS-XE-http:http/client/secure-trustpoint"); value.Exists() {
+ data.IpHttpClientSecureTrustpoint = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/Cisco-IOS-XE-http:http/client/source-interface"); value.Exists() {
+ data.IpHttpClientSourceInterface = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/Cisco-IOS-XE-http:http/secure-active-session-modules"); value.Exists() {
+ data.IpHttpSecureActiveSessionModules = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/Cisco-IOS-XE-http:http/max-connections"); value.Exists() {
+ data.IpHttpMaxConnections = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/Cisco-IOS-XE-http:http/active-session-modules"); value.Exists() {
+ data.IpHttpActiveSessionModules = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/name-server/no-vrf-ordered"); value.Exists() {
+ data.IpNameServers = helpers.GetStringListXML(value.Array())
+ } else {
+ data.IpNameServers = types.ListNull(types.StringType)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/name-server/vrf"); value.Exists() {
+ data.IpNameServersVrf = make([]SystemIpNameServersVrf, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := SystemIpNameServersVrf{}
+ if cValue := helpers.GetFromXPath(v, "word"); cValue.Exists() {
+ item.Vrf = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "server-ip-list-ordered"); cValue.Exists() {
+ item.Servers = helpers.GetStringListXML(cValue.Array())
+ } else {
+ item.Servers = types.ListNull(types.StringType)
+ }
+ data.IpNameServersVrf = append(data.IpNameServersVrf, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/domain/lookup-settings/lookup/source-interface/Loopback"); value.Exists() {
+ data.IpDomainLookupSourceInterfaceLoopback = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/domain/lookup-settings/lookup/source-interface/Vlan"); value.Exists() {
+ data.IpDomainLookupSourceInterfaceVlan = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/domain/lookup-settings/lookup/source-interface/GigabitEthernet"); value.Exists() {
+ data.IpDomainLookupSourceInterfaceGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/domain/lookup-settings/lookup/source-interface/TwoGigabitEthernet"); value.Exists() {
+ data.IpDomainLookupSourceInterfaceTwoGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/domain/lookup-settings/lookup/source-interface/FiveGigabitEthernet"); value.Exists() {
+ data.IpDomainLookupSourceInterfaceFiveGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/domain/lookup-settings/lookup/source-interface/TenGigabitEthernet"); value.Exists() {
+ data.IpDomainLookupSourceInterfaceTenGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/domain/lookup-settings/lookup/source-interface/TwentyFiveGigE"); value.Exists() {
+ data.IpDomainLookupSourceInterfaceTwentyFiveGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/domain/lookup-settings/lookup/source-interface/FortyGigabitEthernet"); value.Exists() {
+ data.IpDomainLookupSourceInterfaceFortyGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/domain/lookup-settings/lookup/source-interface/HundredGigE"); value.Exists() {
+ data.IpDomainLookupSourceInterfaceHundredGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/cisp/enable"); value.Exists() {
+ data.CispEnable = types.BoolValue(true)
+ } else {
+ data.CispEnable = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/epm/logging"); value.Exists() {
+ data.EpmLogging = types.BoolValue(true)
+ } else {
+ data.EpmLogging = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-sanet:access-session/mac-move/deny"); value.Exists() {
+ data.AccessSessionMacMoveDeny = types.BoolValue(true)
+ } else {
+ data.AccessSessionMacMoveDeny = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-diagnostics:diagnostic/bootup/level"); value.Exists() {
+ data.DiagnosticBootupLevel = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/memory/free/low-watermark/processor"); value.Exists() {
+ data.MemoryFreeLowWatermarkProcessor = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/archive/path"); value.Exists() {
+ data.ArchivePath = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/archive/maximum"); value.Exists() {
+ data.ArchiveMaximum = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/archive/write-memory"); value.Exists() {
+ data.ArchiveWriteMemory = types.BoolValue(true)
+ } else {
+ data.ArchiveWriteMemory = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/archive/time-period"); value.Exists() {
+ data.ArchiveTimePeriod = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/archive/log/config/logging/enable"); value.Exists() {
+ data.ArchiveLogConfigLoggingEnable = types.BoolValue(true)
+ } else {
+ data.ArchiveLogConfigLoggingEnable = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/archive/log/config/logging/size"); value.Exists() {
+ data.ArchiveLogConfigLoggingSize = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/redundancy"); value.Exists() {
+ data.Redundancy = types.BoolValue(true)
+ } else {
+ data.Redundancy = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/redundancy/mode"); value.Exists() {
+ data.RedundancyMode = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/transceivers/type/all/monitoring-enable/monitoring"); value.Exists() {
+ data.TransceiverTypeAllMonitoring = types.BoolValue(true)
+ } else {
+ data.TransceiverTypeAllMonitoring = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/forward-protocol-v2/nd"); value.Exists() {
+ data.IpForwardProtocolNd = types.BoolValue(value.Bool())
+ } else {
+ data.IpForwardProtocolNd = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/scp/server/enable"); value.Exists() {
+ data.IpScpServerEnable = types.BoolValue(true)
+ } else {
+ data.IpScpServerEnable = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/ssh/ssh-version"); value.Exists() {
+ data.IpSshVersion = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/ssh/version"); value.Exists() {
+ data.IpSshVersionLegacy = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/ssh/time-out"); value.Exists() {
+ data.IpSshTimeOut = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/ssh/authentication-retries"); value.Exists() {
+ data.IpSshAuthenticationRetries = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/ssh/source-interface-config/Loopback"); value.Exists() {
+ data.IpSshSourceInterfaceLoopback = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/ssh/source-interface-config/Vlan"); value.Exists() {
+ data.IpSshSourceInterfaceVlan = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/ssh/source-interface-config/GigabitEthernet"); value.Exists() {
+ data.IpSshSourceInterfaceGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/ssh/source-interface-config/TwoGigabitEthernet"); value.Exists() {
+ data.IpSshSourceInterfaceTwoGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/ssh/source-interface-config/FiveGigabitEthernet"); value.Exists() {
+ data.IpSshSourceInterfaceFiveGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/ssh/source-interface-config/TenGigabitEthernet"); value.Exists() {
+ data.IpSshSourceInterfaceTenGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/ssh/source-interface-config/TwentyFiveGigE"); value.Exists() {
+ data.IpSshSourceInterfaceTwentyFiveGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/ssh/source-interface-config/FortyGigabitEthernet"); value.Exists() {
+ data.IpSshSourceInterfaceFortyGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/ssh/source-interface-config/HundredGigE"); value.Exists() {
+ data.IpSshSourceInterfaceHundredGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/control-plane/Cisco-IOS-XE-policy:service-policy/input"); value.Exists() {
+ data.ControlPlaneServicePolicyInput = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-pnp:pnp/profile"); value.Exists() {
+ data.PnpProfiles = make([]SystemPnpProfiles, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := SystemPnpProfiles{}
+ if cValue := helpers.GetFromXPath(v, "name"); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "transport/https/ipv4/ipv4-address"); cValue.Exists() {
+ item.TransportHttpsIpv4Ipv4Address = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "transport/https/ipv4/port"); cValue.Exists() {
+ item.TransportHttpsIpv4Port = types.Int64Value(cValue.Int())
+ }
+ data.PnpProfiles = append(data.PnpProfiles, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/Cisco-IOS-XE-aaa:tacacs/source-interface/Loopback"); value.Exists() {
+ data.IpTacacsSourceInterfaceLoopback = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/Cisco-IOS-XE-aaa:tacacs/source-interface/Vlan"); value.Exists() {
+ data.IpTacacsSourceInterfaceVlan = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/Cisco-IOS-XE-aaa:tacacs/source-interface/GigabitEthernet"); value.Exists() {
+ data.IpTacacsSourceInterfaceGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/Cisco-IOS-XE-aaa:tacacs/source-interface/TwoGigabitEthernet"); value.Exists() {
+ data.IpTacacsSourceInterfaceTwoGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/Cisco-IOS-XE-aaa:tacacs/source-interface/FiveGigabitEthernet"); value.Exists() {
+ data.IpTacacsSourceInterfaceFiveGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/Cisco-IOS-XE-aaa:tacacs/source-interface/TenGigabitEthernet"); value.Exists() {
+ data.IpTacacsSourceInterfaceTenGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/Cisco-IOS-XE-aaa:tacacs/source-interface/TwentyFiveGigE"); value.Exists() {
+ data.IpTacacsSourceInterfaceTwentyFiveGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/Cisco-IOS-XE-aaa:tacacs/source-interface/FortyGigabitEthernet"); value.Exists() {
+ data.IpTacacsSourceInterfaceFortyGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/Cisco-IOS-XE-aaa:tacacs/source-interface/HundredGigE"); value.Exists() {
+ data.IpTacacsSourceInterfaceHundredGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/Cisco-IOS-XE-aaa:tacacs/source-interface/vrf"); value.Exists() {
+ data.IpTacacsSourceInterfaceVrf = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/Cisco-IOS-XE-aaa:radius/source-interface/Loopback"); value.Exists() {
+ data.IpRadiusSourceInterfaceLoopback = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/Cisco-IOS-XE-aaa:radius/source-interface/Vlan"); value.Exists() {
+ data.IpRadiusSourceInterfaceVlan = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/Cisco-IOS-XE-aaa:radius/source-interface/GigabitEthernet"); value.Exists() {
+ data.IpRadiusSourceInterfaceGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/Cisco-IOS-XE-aaa:radius/source-interface/TwoGigabitEthernet"); value.Exists() {
+ data.IpRadiusSourceInterfaceTwoGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/Cisco-IOS-XE-aaa:radius/source-interface/FiveGigabitEthernet"); value.Exists() {
+ data.IpRadiusSourceInterfaceFiveGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/Cisco-IOS-XE-aaa:radius/source-interface/TenGigabitEthernet"); value.Exists() {
+ data.IpRadiusSourceInterfaceTenGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/Cisco-IOS-XE-aaa:radius/source-interface/TwentyFiveGigE"); value.Exists() {
+ data.IpRadiusSourceInterfaceTwentyFiveGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/Cisco-IOS-XE-aaa:radius/source-interface/FortyGigabitEthernet"); value.Exists() {
+ data.IpRadiusSourceInterfaceFortyGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/Cisco-IOS-XE-aaa:radius/source-interface/HundredGigE"); value.Exists() {
+ data.IpRadiusSourceInterfaceHundredGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/Cisco-IOS-XE-aaa:radius/source-interface/vrf"); value.Exists() {
+ data.IpRadiusSourceInterfaceVrf = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/boot/system/flash/flash-list-ordered-by-user"); value.Exists() {
+ data.BootSystemFlashFiles = make([]SystemBootSystemFlashFiles, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := SystemBootSystemFlashFiles{}
+ if cValue := helpers.GetFromXPath(v, "flash-leaf"); cValue.Exists() {
+ item.Path = types.StringValue(cValue.String())
+ }
+ data.BootSystemFlashFiles = append(data.BootSystemFlashFiles, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/boot/system/bootfile/filename-list-ordered-by-user"); value.Exists() {
+ data.BootSystemBootfiles = make([]SystemBootSystemBootfiles, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := SystemBootSystemBootfiles{}
+ if cValue := helpers.GetFromXPath(v, "filename"); cValue.Exists() {
+ item.Path = types.StringValue(cValue.String())
+ }
+ data.BootSystemBootfiles = append(data.BootSystemBootfiles, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/enable/secret/secret"); value.Exists() {
+ data.EnableSecret = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/enable/secret/type"); value.Exists() {
+ data.EnableSecretType = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/enable/secret/level"); value.Exists() {
+ data.EnableSecretLevel = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/host/host-list"); value.Exists() {
+ data.IpHosts = make([]SystemIpHosts, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := SystemIpHosts{}
+ if cValue := helpers.GetFromXPath(v, "name"); cValue.Exists() {
+ item.Name = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "ip-list-ordered"); cValue.Exists() {
+ item.Ips = helpers.GetStringListXML(cValue.Array())
+ } else {
+ item.Ips = types.ListNull(types.StringType)
+ }
+ data.IpHosts = append(data.IpHosts, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/host/vrf"); value.Exists() {
+ data.IpHostsVrf = make([]SystemIpHostsVrf, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := SystemIpHostsVrf{}
+ if cValue := helpers.GetFromXPath(v, "vrf-name"); cValue.Exists() {
+ item.Vrf = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "host-name"); cValue.Exists() {
+ item.Hosts = make([]SystemIpHostsVrfHosts, 0)
+ cValue.ForEach(func(_ int, cv xmldot.Result) bool {
+ cItem := SystemIpHostsVrfHosts{}
+ if ccValue := helpers.GetFromXPath(cv, "host-name"); ccValue.Exists() {
+ cItem.Name = types.StringValue(ccValue.String())
+ }
+ if ccValue := helpers.GetFromXPath(cv, "ip-list"); ccValue.Exists() {
+ cItem.Ips = helpers.GetStringListXML(ccValue.Array())
+ } else {
+ cItem.Ips = types.ListNull(types.StringType)
+ }
+ item.Hosts = append(item.Hosts, cItem)
+ return true
+ })
+ }
+ data.IpHostsVrf = append(data.IpHostsVrf, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-diagnostics:diagnostic/event-log/size"); value.Exists() {
+ data.DiagnosticEventLogSize = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/subscriber/templating"); value.Exists() {
+ data.SubscriberTemplating = types.BoolValue(true)
+ } else {
+ data.SubscriberTemplating = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/call-home/Cisco-IOS-XE-call-home:contact-email-addr"); value.Exists() {
+ data.CallHomeContactEmail = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/call-home/Cisco-IOS-XE-call-home:tac-profile/profile/CiscoTAC-1/active"); value.Exists() {
+ data.CallHomeCiscoTac1ProfileActive = types.BoolValue(value.Bool())
+ } else {
+ data.CallHomeCiscoTac1ProfileActive = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/call-home/Cisco-IOS-XE-call-home:tac-profile/profile/CiscoTAC-1/destination/transport-method"); value.Exists() {
+ data.CallHomeCiscoTac1DestinationTransportMethod = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/ftp/passive-enable"); value.Exists() {
+ data.IpFtpPassive = types.BoolValue(value.Bool())
+ } else {
+ data.IpFtpPassive = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/tftp/source-interface/GigabitEthernet"); value.Exists() {
+ data.TftpSourceInterfaceGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/tftp/source-interface/Loopback"); value.Exists() {
+ data.TftpSourceInterfaceLoopback = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/tftp/source-interface/Vlan"); value.Exists() {
+ data.TftpSourceInterfaceVlan = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/tftp/source-interface/TwoGigabitEthernet"); value.Exists() {
+ data.TftpSourceInterfaceTwoGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/tftp/source-interface/FiveGigabitEthernet"); value.Exists() {
+ data.TftpSourceInterfaceFiveGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/tftp/source-interface/TenGigabitEthernet"); value.Exists() {
+ data.TftpSourceInterfaceTenGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/tftp/source-interface/TwentyFiveGigabitEthernet"); value.Exists() {
+ data.TftpSourceInterfaceTwentyFiveGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/tftp/source-interface/FortyGigabitEthernet"); value.Exists() {
+ data.TftpSourceInterfaceFortyGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/tftp/source-interface/HundredGigE"); value.Exists() {
+ data.TftpSourceInterfaceHundredGigabitEthernet = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/multilink/Cisco-IOS-XE-ppp:bundle-name"); value.Exists() {
+ data.MultilinkPppBundleName = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/version"); value.Exists() {
+ data.Version = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/track/Cisco-IOS-XE-track:tracked-object-v2"); value.Exists() {
+ data.TrackObjects = make([]SystemTrackObjects, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := SystemTrackObjects{}
+ if cValue := helpers.GetFromXPath(v, "object-number"); cValue.Exists() {
+ item.Number = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "ip/sla/number"); cValue.Exists() {
+ item.IpSlaNumber = types.Int64Value(cValue.Int())
+ }
+ if cValue := helpers.GetFromXPath(v, "ip/sla/reachability"); cValue.Exists() {
+ item.IpSlaReachability = types.BoolValue(true)
+ } else {
+ item.IpSlaReachability = types.BoolValue(false)
+ }
+ data.TrackObjects = append(data.TrackObjects, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/Cisco-IOS-XE-nbar:nbar/classification/dns/classify-by-domain-with-default"); value.Exists() {
+ data.IpNbarClassificationDnsClassifyByDomain = types.BoolValue(value.Bool())
+ } else {
+ data.IpNbarClassificationDnsClassifyByDomain = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/multicast/Cisco-IOS-XE-multicast:route-limit-container/routelimit"); value.Exists() {
+ data.IpMulticastRouteLimit = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-aaa:security/passwords/min-length"); value.Exists() {
+ data.SecurityPasswordsMinLength = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/domain/list/domain-name"); value.Exists() {
+ data.IpDomainListNames = helpers.GetStringListXML(value.Array())
+ } else {
+ data.IpDomainListNames = types.ListNull(types.StringType)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/domain/list/vrf/domain-name"); value.Exists() {
+ data.IpDomainListVrfDomain = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/domain/list/vrf/vrf-name"); value.Exists() {
+ data.IpDomainListVrf = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ethernet/Cisco-IOS-XE-ethernet:cfm/alarm-config/delay"); value.Exists() {
+ data.EthernetCfmAlarmConfigDelay = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ethernet/Cisco-IOS-XE-ethernet:cfm/alarm-config/reset"); value.Exists() {
+ data.EthernetCfmAlarmConfigReset = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/standby/redirects-config/redirects"); value.Exists() {
+ data.StandbyRedirects = types.BoolValue(value.Bool())
+ } else {
+ data.StandbyRedirects = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/standby/redirects-config/redirect-enable-disable/redirects"); value.Exists() {
+ data.StandbyRedirectsEnableDisable = types.StringValue(value.String())
+ }
+}
+
+// End of section. //template:end fromBodyDataXML
+
+// Section below is generated&owned by "gen/generator.go". //template:begin getDeletedItems
+
+func (data *System) getDeletedItems(ctx context.Context, state System) []string {
+ deletedItems := make([]string, 0)
+ if !state.StandbyRedirectsEnableDisable.IsNull() && data.StandbyRedirectsEnableDisable.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/standby/redirects-config/redirect-enable-disable/redirects", state.getPath()))
+ }
+ if !state.StandbyRedirects.IsNull() && data.StandbyRedirects.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/standby/redirects-config/redirects", state.getPath()))
+ }
+ if !state.EthernetCfmAlarmConfigReset.IsNull() && data.EthernetCfmAlarmConfigReset.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ethernet/Cisco-IOS-XE-ethernet:cfm/alarm-config/reset", state.getPath()))
+ }
+ if !state.EthernetCfmAlarmConfigDelay.IsNull() && data.EthernetCfmAlarmConfigDelay.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ethernet/Cisco-IOS-XE-ethernet:cfm/alarm-config/delay", state.getPath()))
+ }
+ if !state.IpDomainListVrf.IsNull() && data.IpDomainListVrf.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/domain/list/vrf/vrf-name", state.getPath()))
+ }
+ if !state.IpDomainListVrfDomain.IsNull() && data.IpDomainListVrfDomain.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/domain/list/vrf/domain-name", state.getPath()))
+ }
+ if !state.IpDomainListNames.IsNull() {
+ if data.IpDomainListNames.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/domain/list/domain-name", state.getPath()))
+ } else {
+ var dataValues, stateValues []string
+ data.IpDomainListNames.ElementsAs(ctx, &dataValues, false)
+ state.IpDomainListNames.ElementsAs(ctx, &stateValues, false)
+ for _, v := range stateValues {
+ found := false
+ for _, vv := range dataValues {
+ if v == vv {
+ found = true
+ break
+ }
+ }
+ if !found {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/domain/list/domain-name=%v", state.getPath(), v))
+ }
+ }
+ }
+ }
+ if !state.SecurityPasswordsMinLength.IsNull() && data.SecurityPasswordsMinLength.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-aaa:security/passwords/min-length", state.getPath()))
+ }
+ if !state.IpMulticastRouteLimit.IsNull() && data.IpMulticastRouteLimit.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/multicast/Cisco-IOS-XE-multicast:route-limit-container/routelimit", state.getPath()))
+ }
+ if !state.IpNbarClassificationDnsClassifyByDomain.IsNull() && data.IpNbarClassificationDnsClassifyByDomain.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/Cisco-IOS-XE-nbar:nbar/classification/dns/classify-by-domain-with-default", state.getPath()))
+ }
+ for i := range state.TrackObjects {
+ stateKeyValues := [...]string{state.TrackObjects[i].Number.ValueString()}
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.TrackObjects[i].Number.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.TrackObjects {
+ found = true
+ if state.TrackObjects[i].Number.ValueString() != data.TrackObjects[j].Number.ValueString() {
+ found = false
+ }
+ if found {
+ if !state.TrackObjects[i].IpSlaReachability.IsNull() && data.TrackObjects[j].IpSlaReachability.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/track/Cisco-IOS-XE-track:tracked-object-v2=%v/ip/sla/reachability", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ if !state.TrackObjects[i].IpSlaNumber.IsNull() && data.TrackObjects[j].IpSlaNumber.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/track/Cisco-IOS-XE-track:tracked-object-v2=%v/ip/sla/number", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ break
+ }
+ }
+ if !found {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/track/Cisco-IOS-XE-track:tracked-object-v2=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ }
+ if !state.Version.IsNull() && data.Version.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/version", state.getPath()))
+ }
+ if !state.MultilinkPppBundleName.IsNull() && data.MultilinkPppBundleName.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/multilink/Cisco-IOS-XE-ppp:bundle-name", state.getPath()))
+ }
+ if !state.TftpSourceInterfaceHundredGigabitEthernet.IsNull() && data.TftpSourceInterfaceHundredGigabitEthernet.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/tftp/source-interface/HundredGigE", state.getPath()))
+ }
+ if !state.TftpSourceInterfaceFortyGigabitEthernet.IsNull() && data.TftpSourceInterfaceFortyGigabitEthernet.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/tftp/source-interface/FortyGigabitEthernet", state.getPath()))
+ }
+ if !state.TftpSourceInterfaceTwentyFiveGigabitEthernet.IsNull() && data.TftpSourceInterfaceTwentyFiveGigabitEthernet.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/tftp/source-interface/TwentyFiveGigabitEthernet", state.getPath()))
+ }
+ if !state.TftpSourceInterfaceTenGigabitEthernet.IsNull() && data.TftpSourceInterfaceTenGigabitEthernet.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/tftp/source-interface/TenGigabitEthernet", state.getPath()))
+ }
+ if !state.TftpSourceInterfaceFiveGigabitEthernet.IsNull() && data.TftpSourceInterfaceFiveGigabitEthernet.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/tftp/source-interface/FiveGigabitEthernet", state.getPath()))
+ }
+ if !state.TftpSourceInterfaceTwoGigabitEthernet.IsNull() && data.TftpSourceInterfaceTwoGigabitEthernet.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/tftp/source-interface/TwoGigabitEthernet", state.getPath()))
+ }
+ if !state.TftpSourceInterfaceVlan.IsNull() && data.TftpSourceInterfaceVlan.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/tftp/source-interface/Vlan", state.getPath()))
+ }
+ if !state.TftpSourceInterfaceLoopback.IsNull() && data.TftpSourceInterfaceLoopback.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/tftp/source-interface/Loopback", state.getPath()))
+ }
+ if !state.TftpSourceInterfaceGigabitEthernet.IsNull() && data.TftpSourceInterfaceGigabitEthernet.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/tftp/source-interface/GigabitEthernet", state.getPath()))
+ }
+ if !state.IpFtpPassive.IsNull() && data.IpFtpPassive.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/ftp/passive-enable", state.getPath()))
+ }
+ if !state.CallHomeCiscoTac1DestinationTransportMethod.IsNull() && data.CallHomeCiscoTac1DestinationTransportMethod.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/call-home/Cisco-IOS-XE-call-home:tac-profile/profile/CiscoTAC-1/destination/transport-method", state.getPath()))
+ }
+ if !state.CallHomeCiscoTac1ProfileActive.IsNull() && data.CallHomeCiscoTac1ProfileActive.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/call-home/Cisco-IOS-XE-call-home:tac-profile/profile/CiscoTAC-1/active", state.getPath()))
+ }
+ if !state.CallHomeContactEmail.IsNull() && data.CallHomeContactEmail.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/call-home/Cisco-IOS-XE-call-home:contact-email-addr", state.getPath()))
+ }
+ if !state.SubscriberTemplating.IsNull() && data.SubscriberTemplating.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/subscriber/templating", state.getPath()))
+ }
+ if !state.DiagnosticEventLogSize.IsNull() && data.DiagnosticEventLogSize.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-diagnostics:diagnostic/event-log/size", state.getPath()))
+ }
+ for i := range state.IpHostsVrf {
+ stateKeyValues := [...]string{state.IpHostsVrf[i].Vrf.ValueString()}
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.IpHostsVrf[i].Vrf.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.IpHostsVrf {
+ found = true
+ if state.IpHostsVrf[i].Vrf.ValueString() != data.IpHostsVrf[j].Vrf.ValueString() {
+ found = false
+ }
+ if found {
+ for ci := range state.IpHostsVrf[i].Hosts {
+ cstateKeyValues := [...]string{state.IpHostsVrf[i].Hosts[ci].Name.ValueString()}
+
+ cemptyKeys := true
+ if !reflect.ValueOf(state.IpHostsVrf[i].Hosts[ci].Name.ValueString()).IsZero() {
+ cemptyKeys = false
+ }
+ if cemptyKeys {
+ continue
+ }
+
+ found := false
+ for cj := range data.IpHostsVrf[j].Hosts {
+ found = true
+ if state.IpHostsVrf[i].Hosts[ci].Name.ValueString() != data.IpHostsVrf[j].Hosts[cj].Name.ValueString() {
+ found = false
+ }
+ if found {
+ if !state.IpHostsVrf[i].Hosts[ci].Ips.IsNull() {
+ if data.IpHostsVrf[j].Hosts[cj].Ips.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/host/vrf=%v/host-name=%v/ip-list", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ } else {
+ var dataValues, stateValues []string
+ data.IpHostsVrf[i].Hosts[ci].Ips.ElementsAs(ctx, &dataValues, false)
+ state.IpHostsVrf[j].Hosts[cj].Ips.ElementsAs(ctx, &stateValues, false)
+ for _, v := range stateValues {
+ found := false
+ for _, vv := range dataValues {
+ if v == vv {
+ found = true
+ break
+ }
+ }
+ if !found {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/host/vrf=%v/host-name=%v/ip-list=%v", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ","), v))
+ }
+ }
+ }
+ }
+ break
+ }
+ }
+ if !found {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/host/vrf=%v/host-name=%v", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ }
+ }
+ break
+ }
+ }
+ if !found {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/host/vrf=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ }
+ for i := range state.IpHosts {
+ stateKeyValues := [...]string{state.IpHosts[i].Name.ValueString()}
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.IpHosts[i].Name.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.IpHosts {
+ found = true
+ if state.IpHosts[i].Name.ValueString() != data.IpHosts[j].Name.ValueString() {
+ found = false
+ }
+ if found {
+ if !state.IpHosts[i].Ips.IsNull() {
+ if data.IpHosts[j].Ips.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/host/host-list=%v/ip-list-ordered", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ } else {
+ var dataValues, stateValues []string
+ data.IpHosts[i].Ips.ElementsAs(ctx, &dataValues, false)
+ state.IpHosts[j].Ips.ElementsAs(ctx, &stateValues, false)
+ for _, v := range stateValues {
+ found := false
+ for _, vv := range dataValues {
+ if v == vv {
+ found = true
+ break
+ }
+ }
+ if !found {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/host/host-list=%v/ip-list-ordered=%v", state.getPath(), strings.Join(stateKeyValues[:], ","), v))
+ }
+ }
+ }
+ }
+ break
+ }
+ }
+ if !found {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/host/host-list=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ }
+ if !state.EnableSecretLevel.IsNull() && data.EnableSecretLevel.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/enable/secret/level", state.getPath()))
+ }
+ if !state.EnableSecretType.IsNull() && data.EnableSecretType.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/enable/secret/type", state.getPath()))
+ }
+ if !state.EnableSecret.IsNull() && data.EnableSecret.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/enable/secret", state.getPath()))
+ }
+ for i := range state.BootSystemBootfiles {
+ stateKeyValues := [...]string{state.BootSystemBootfiles[i].Path.ValueString()}
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.BootSystemBootfiles[i].Path.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.BootSystemBootfiles {
+ found = true
+ if state.BootSystemBootfiles[i].Path.ValueString() != data.BootSystemBootfiles[j].Path.ValueString() {
+ found = false
+ }
+ if found {
+ break
+ }
+ }
+ if !found {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/boot/system/bootfile/filename-list-ordered-by-user=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ }
+ for i := range state.BootSystemFlashFiles {
+ stateKeyValues := [...]string{state.BootSystemFlashFiles[i].Path.ValueString()}
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.BootSystemFlashFiles[i].Path.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.BootSystemFlashFiles {
+ found = true
+ if state.BootSystemFlashFiles[i].Path.ValueString() != data.BootSystemFlashFiles[j].Path.ValueString() {
+ found = false
+ }
+ if found {
+ break
+ }
+ }
+ if !found {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/boot/system/flash/flash-list-ordered-by-user=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ }
+ if !state.IpRadiusSourceInterfaceVrf.IsNull() && data.IpRadiusSourceInterfaceVrf.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/Cisco-IOS-XE-aaa:radius/source-interface/vrf", state.getPath()))
+ }
+ if !state.IpRadiusSourceInterfaceHundredGigabitEthernet.IsNull() && data.IpRadiusSourceInterfaceHundredGigabitEthernet.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/Cisco-IOS-XE-aaa:radius/source-interface/HundredGigE", state.getPath()))
+ }
+ if !state.IpRadiusSourceInterfaceFortyGigabitEthernet.IsNull() && data.IpRadiusSourceInterfaceFortyGigabitEthernet.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/Cisco-IOS-XE-aaa:radius/source-interface/FortyGigabitEthernet", state.getPath()))
+ }
+ if !state.IpRadiusSourceInterfaceTwentyFiveGigabitEthernet.IsNull() && data.IpRadiusSourceInterfaceTwentyFiveGigabitEthernet.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/Cisco-IOS-XE-aaa:radius/source-interface/TwentyFiveGigE", state.getPath()))
+ }
+ if !state.IpRadiusSourceInterfaceTenGigabitEthernet.IsNull() && data.IpRadiusSourceInterfaceTenGigabitEthernet.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/Cisco-IOS-XE-aaa:radius/source-interface/TenGigabitEthernet", state.getPath()))
+ }
+ if !state.IpRadiusSourceInterfaceFiveGigabitEthernet.IsNull() && data.IpRadiusSourceInterfaceFiveGigabitEthernet.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/Cisco-IOS-XE-aaa:radius/source-interface/FiveGigabitEthernet", state.getPath()))
+ }
+ if !state.IpRadiusSourceInterfaceTwoGigabitEthernet.IsNull() && data.IpRadiusSourceInterfaceTwoGigabitEthernet.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/Cisco-IOS-XE-aaa:radius/source-interface/TwoGigabitEthernet", state.getPath()))
+ }
+ if !state.IpRadiusSourceInterfaceGigabitEthernet.IsNull() && data.IpRadiusSourceInterfaceGigabitEthernet.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/Cisco-IOS-XE-aaa:radius/source-interface/GigabitEthernet", state.getPath()))
+ }
+ if !state.IpRadiusSourceInterfaceVlan.IsNull() && data.IpRadiusSourceInterfaceVlan.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/Cisco-IOS-XE-aaa:radius/source-interface/Vlan", state.getPath()))
+ }
+ if !state.IpRadiusSourceInterfaceLoopback.IsNull() && data.IpRadiusSourceInterfaceLoopback.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/Cisco-IOS-XE-aaa:radius/source-interface/Loopback", state.getPath()))
+ }
+ if !state.IpTacacsSourceInterfaceVrf.IsNull() && data.IpTacacsSourceInterfaceVrf.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/Cisco-IOS-XE-aaa:tacacs/source-interface/vrf", state.getPath()))
+ }
+ if !state.IpTacacsSourceInterfaceHundredGigabitEthernet.IsNull() && data.IpTacacsSourceInterfaceHundredGigabitEthernet.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/Cisco-IOS-XE-aaa:tacacs/source-interface/HundredGigE", state.getPath()))
+ }
+ if !state.IpTacacsSourceInterfaceFortyGigabitEthernet.IsNull() && data.IpTacacsSourceInterfaceFortyGigabitEthernet.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/Cisco-IOS-XE-aaa:tacacs/source-interface/FortyGigabitEthernet", state.getPath()))
+ }
+ if !state.IpTacacsSourceInterfaceTwentyFiveGigabitEthernet.IsNull() && data.IpTacacsSourceInterfaceTwentyFiveGigabitEthernet.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/Cisco-IOS-XE-aaa:tacacs/source-interface/TwentyFiveGigE", state.getPath()))
+ }
+ if !state.IpTacacsSourceInterfaceTenGigabitEthernet.IsNull() && data.IpTacacsSourceInterfaceTenGigabitEthernet.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/Cisco-IOS-XE-aaa:tacacs/source-interface/TenGigabitEthernet", state.getPath()))
+ }
+ if !state.IpTacacsSourceInterfaceFiveGigabitEthernet.IsNull() && data.IpTacacsSourceInterfaceFiveGigabitEthernet.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/Cisco-IOS-XE-aaa:tacacs/source-interface/FiveGigabitEthernet", state.getPath()))
+ }
+ if !state.IpTacacsSourceInterfaceTwoGigabitEthernet.IsNull() && data.IpTacacsSourceInterfaceTwoGigabitEthernet.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/Cisco-IOS-XE-aaa:tacacs/source-interface/TwoGigabitEthernet", state.getPath()))
+ }
+ if !state.IpTacacsSourceInterfaceGigabitEthernet.IsNull() && data.IpTacacsSourceInterfaceGigabitEthernet.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/Cisco-IOS-XE-aaa:tacacs/source-interface/GigabitEthernet", state.getPath()))
+ }
+ if !state.IpTacacsSourceInterfaceVlan.IsNull() && data.IpTacacsSourceInterfaceVlan.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/Cisco-IOS-XE-aaa:tacacs/source-interface/Vlan", state.getPath()))
+ }
+ if !state.IpTacacsSourceInterfaceLoopback.IsNull() && data.IpTacacsSourceInterfaceLoopback.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/Cisco-IOS-XE-aaa:tacacs/source-interface/Loopback", state.getPath()))
+ }
+ for i := range state.PnpProfiles {
+ stateKeyValues := [...]string{state.PnpProfiles[i].Name.ValueString()}
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.PnpProfiles[i].Name.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.PnpProfiles {
+ found = true
+ if state.PnpProfiles[i].Name.ValueString() != data.PnpProfiles[j].Name.ValueString() {
+ found = false
+ }
+ if found {
+ if !state.PnpProfiles[i].TransportHttpsIpv4Port.IsNull() && data.PnpProfiles[j].TransportHttpsIpv4Port.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-pnp:pnp/profile=%v/transport/https/ipv4/port", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ if !state.PnpProfiles[i].TransportHttpsIpv4Ipv4Address.IsNull() && data.PnpProfiles[j].TransportHttpsIpv4Ipv4Address.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-pnp:pnp/profile=%v/transport/https/ipv4/ipv4-address", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ break
+ }
+ }
+ if !found {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-pnp:pnp/profile=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ }
+ if !state.ControlPlaneServicePolicyInput.IsNull() && data.ControlPlaneServicePolicyInput.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/control-plane/Cisco-IOS-XE-policy:service-policy/input", state.getPath()))
+ }
+ if !state.IpSshSourceInterfaceHundredGigabitEthernet.IsNull() && data.IpSshSourceInterfaceHundredGigabitEthernet.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/ssh/source-interface-config/HundredGigE", state.getPath()))
+ }
+ if !state.IpSshSourceInterfaceFortyGigabitEthernet.IsNull() && data.IpSshSourceInterfaceFortyGigabitEthernet.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/ssh/source-interface-config/FortyGigabitEthernet", state.getPath()))
}
- if value := res.Get(prefix + "call-home.Cisco-IOS-XE-call-home:tac-profile.profile.CiscoTAC-1.active"); value.Exists() {
- data.CallHomeCiscoTac1ProfileActive = types.BoolValue(value.Bool())
- } else {
- data.CallHomeCiscoTac1ProfileActive = types.BoolNull()
+ if !state.IpSshSourceInterfaceTwentyFiveGigabitEthernet.IsNull() && data.IpSshSourceInterfaceTwentyFiveGigabitEthernet.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/ssh/source-interface-config/TwentyFiveGigE", state.getPath()))
}
- if value := res.Get(prefix + "call-home.Cisco-IOS-XE-call-home:tac-profile.profile.CiscoTAC-1.destination.transport-method"); value.Exists() {
- data.CallHomeCiscoTac1DestinationTransportMethod = types.StringValue(value.String())
+ if !state.IpSshSourceInterfaceTenGigabitEthernet.IsNull() && data.IpSshSourceInterfaceTenGigabitEthernet.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/ssh/source-interface-config/TenGigabitEthernet", state.getPath()))
}
- if value := res.Get(prefix + "ip.ftp.passive-enable"); value.Exists() {
- data.IpFtpPassive = types.BoolValue(value.Bool())
- } else {
- data.IpFtpPassive = types.BoolNull()
+ if !state.IpSshSourceInterfaceFiveGigabitEthernet.IsNull() && data.IpSshSourceInterfaceFiveGigabitEthernet.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/ssh/source-interface-config/FiveGigabitEthernet", state.getPath()))
}
- if value := res.Get(prefix + "ip.tftp.source-interface.GigabitEthernet"); value.Exists() {
- data.TftpSourceInterfaceGigabitEthernet = types.StringValue(value.String())
+ if !state.IpSshSourceInterfaceTwoGigabitEthernet.IsNull() && data.IpSshSourceInterfaceTwoGigabitEthernet.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/ssh/source-interface-config/TwoGigabitEthernet", state.getPath()))
}
- if value := res.Get(prefix + "ip.tftp.source-interface.Loopback"); value.Exists() {
- data.TftpSourceInterfaceLoopback = types.Int64Value(value.Int())
+ if !state.IpSshSourceInterfaceGigabitEthernet.IsNull() && data.IpSshSourceInterfaceGigabitEthernet.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/ssh/source-interface-config/GigabitEthernet", state.getPath()))
}
- if value := res.Get(prefix + "ip.tftp.source-interface.Vlan"); value.Exists() {
- data.TftpSourceInterfaceVlan = types.Int64Value(value.Int())
+ if !state.IpSshSourceInterfaceVlan.IsNull() && data.IpSshSourceInterfaceVlan.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/ssh/source-interface-config/Vlan", state.getPath()))
}
- if value := res.Get(prefix + "ip.tftp.source-interface.TwoGigabitEthernet"); value.Exists() {
- data.TftpSourceInterfaceTwoGigabitEthernet = types.StringValue(value.String())
+ if !state.IpSshSourceInterfaceLoopback.IsNull() && data.IpSshSourceInterfaceLoopback.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/ssh/source-interface-config/Loopback", state.getPath()))
}
- if value := res.Get(prefix + "ip.tftp.source-interface.FiveGigabitEthernet"); value.Exists() {
- data.TftpSourceInterfaceFiveGigabitEthernet = types.StringValue(value.String())
+ if !state.IpSshAuthenticationRetries.IsNull() && data.IpSshAuthenticationRetries.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/ssh/authentication-retries", state.getPath()))
}
- if value := res.Get(prefix + "ip.tftp.source-interface.TenGigabitEthernet"); value.Exists() {
- data.TftpSourceInterfaceTenGigabitEthernet = types.StringValue(value.String())
+ if !state.IpSshTimeOut.IsNull() && data.IpSshTimeOut.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/ssh/time-out", state.getPath()))
}
- if value := res.Get(prefix + "ip.tftp.source-interface.TwentyFiveGigabitEthernet"); value.Exists() {
- data.TftpSourceInterfaceTwentyFiveGigabitEthernet = types.StringValue(value.String())
+ if !state.IpSshVersionLegacy.IsNull() && data.IpSshVersionLegacy.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/ssh/version", state.getPath()))
}
- if value := res.Get(prefix + "ip.tftp.source-interface.FortyGigabitEthernet"); value.Exists() {
- data.TftpSourceInterfaceFortyGigabitEthernet = types.StringValue(value.String())
+ if !state.IpSshVersion.IsNull() && data.IpSshVersion.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/ssh/ssh-version", state.getPath()))
}
- if value := res.Get(prefix + "ip.tftp.source-interface.HundredGigE"); value.Exists() {
- data.TftpSourceInterfaceHundredGigabitEthernet = types.StringValue(value.String())
+ if !state.IpScpServerEnable.IsNull() && data.IpScpServerEnable.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/scp/server/enable", state.getPath()))
}
- if value := res.Get(prefix + "multilink.Cisco-IOS-XE-ppp:bundle-name"); value.Exists() {
- data.MultilinkPppBundleName = types.StringValue(value.String())
+ if !state.IpForwardProtocolNd.IsNull() && data.IpForwardProtocolNd.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/forward-protocol-v2/nd", state.getPath()))
}
- if value := res.Get(prefix + "version"); value.Exists() {
- data.Version = types.StringValue(value.String())
+ if !state.TransceiverTypeAllMonitoring.IsNull() && data.TransceiverTypeAllMonitoring.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/transceivers/type/all/monitoring-enable/monitoring", state.getPath()))
}
- if value := res.Get(prefix + "track.Cisco-IOS-XE-track:tracked-object-v2"); value.Exists() {
- data.TrackObjects = make([]SystemTrackObjects, 0)
- value.ForEach(func(k, v gjson.Result) bool {
- item := SystemTrackObjects{}
- if cValue := v.Get("object-number"); cValue.Exists() {
- item.Number = types.StringValue(cValue.String())
- }
- if cValue := v.Get("ip.sla.number"); cValue.Exists() {
- item.IpSlaNumber = types.Int64Value(cValue.Int())
- }
- if cValue := v.Get("ip.sla.reachability"); cValue.Exists() {
- item.IpSlaReachability = types.BoolValue(true)
- } else {
- item.IpSlaReachability = types.BoolValue(false)
- }
- data.TrackObjects = append(data.TrackObjects, item)
- return true
- })
+ if !state.RedundancyMode.IsNull() && data.RedundancyMode.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/redundancy/mode", state.getPath()))
}
- if value := res.Get(prefix + "ip.Cisco-IOS-XE-nbar:nbar.classification.dns.classify-by-domain-with-default"); value.Exists() {
- data.IpNbarClassificationDnsClassifyByDomain = types.BoolValue(value.Bool())
- } else {
- data.IpNbarClassificationDnsClassifyByDomain = types.BoolNull()
+ if !state.Redundancy.IsNull() && data.Redundancy.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/redundancy", state.getPath()))
}
- if value := res.Get(prefix + "ip.multicast.Cisco-IOS-XE-multicast:route-limit-container.routelimit"); value.Exists() {
- data.IpMulticastRouteLimit = types.Int64Value(value.Int())
+ if !state.ArchiveLogConfigLoggingSize.IsNull() && data.ArchiveLogConfigLoggingSize.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/archive/log/config/logging/size", state.getPath()))
}
- if value := res.Get(prefix + "Cisco-IOS-XE-aaa:security.passwords.min-length"); value.Exists() {
- data.SecurityPasswordsMinLength = types.Int64Value(value.Int())
+ if !state.ArchiveLogConfigLoggingEnable.IsNull() && data.ArchiveLogConfigLoggingEnable.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/archive/log/config/logging/enable", state.getPath()))
}
- if value := res.Get(prefix + "ip.domain.list.domain-name"); value.Exists() {
- data.IpDomainListNames = helpers.GetStringList(value.Array())
- } else {
- data.IpDomainListNames = types.ListNull(types.StringType)
+ if !state.ArchiveTimePeriod.IsNull() && data.ArchiveTimePeriod.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/archive/time-period", state.getPath()))
}
- if value := res.Get(prefix + "ip.domain.list.vrf.domain-name"); value.Exists() {
- data.IpDomainListVrfDomain = types.StringValue(value.String())
+ if !state.ArchiveWriteMemory.IsNull() && data.ArchiveWriteMemory.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/archive/write-memory", state.getPath()))
}
- if value := res.Get(prefix + "ip.domain.list.vrf.vrf-name"); value.Exists() {
- data.IpDomainListVrf = types.StringValue(value.String())
+ if !state.ArchiveMaximum.IsNull() && data.ArchiveMaximum.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/archive/maximum", state.getPath()))
}
- if value := res.Get(prefix + "ethernet.Cisco-IOS-XE-ethernet:cfm.alarm-config.delay"); value.Exists() {
- data.EthernetCfmAlarmConfigDelay = types.Int64Value(value.Int())
+ if !state.ArchivePath.IsNull() && data.ArchivePath.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/archive/path", state.getPath()))
}
- if value := res.Get(prefix + "ethernet.Cisco-IOS-XE-ethernet:cfm.alarm-config.reset"); value.Exists() {
- data.EthernetCfmAlarmConfigReset = types.Int64Value(value.Int())
+ if !state.MemoryFreeLowWatermarkProcessor.IsNull() && data.MemoryFreeLowWatermarkProcessor.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/memory/free/low-watermark/processor", state.getPath()))
}
- if value := res.Get(prefix + "standby.redirects-config.redirects"); value.Exists() {
- data.StandbyRedirects = types.BoolValue(value.Bool())
- } else {
- data.StandbyRedirects = types.BoolNull()
+ if !state.DiagnosticBootupLevel.IsNull() && data.DiagnosticBootupLevel.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-diagnostics:diagnostic/bootup/level", state.getPath()))
}
- if value := res.Get(prefix + "standby.redirects-config.redirect-enable-disable.redirects"); value.Exists() {
- data.StandbyRedirectsEnableDisable = types.StringValue(value.String())
+ if !state.AccessSessionMacMoveDeny.IsNull() && data.AccessSessionMacMoveDeny.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-sanet:access-session/mac-move/deny", state.getPath()))
}
-}
-
-// End of section. //template:end fromBody
-
-// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyData
-
-func (data *SystemData) fromBody(ctx context.Context, res gjson.Result) {
- prefix := helpers.LastElement(data.getPath()) + "."
- if res.Get(helpers.LastElement(data.getPath())).IsArray() {
- prefix += "0."
+ if !state.EpmLogging.IsNull() && data.EpmLogging.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/epm/logging", state.getPath()))
}
- if value := res.Get(prefix + "hostname"); value.Exists() {
- data.Hostname = types.StringValue(value.String())
+ if !state.CispEnable.IsNull() && data.CispEnable.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/cisp/enable", state.getPath()))
}
- if value := res.Get(prefix + "ip.bgp-community.new-format"); value.Exists() {
- data.IpBgpCommunityNewFormat = types.BoolValue(true)
- } else {
- data.IpBgpCommunityNewFormat = types.BoolValue(false)
+ if !state.IpDomainLookupSourceInterfaceHundredGigabitEthernet.IsNull() && data.IpDomainLookupSourceInterfaceHundredGigabitEthernet.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/domain/lookup-settings/lookup/source-interface/HundredGigE", state.getPath()))
}
- if value := res.Get(prefix + "ip.routing-conf.routing"); value.Exists() {
- data.IpRouting = types.BoolValue(value.Bool())
- } else {
- data.IpRouting = types.BoolNull()
+ if !state.IpDomainLookupSourceInterfaceFortyGigabitEthernet.IsNull() && data.IpDomainLookupSourceInterfaceFortyGigabitEthernet.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/domain/lookup-settings/lookup/source-interface/FortyGigabitEthernet", state.getPath()))
}
- if value := res.Get(prefix + "ipv6.unicast-routing"); value.Exists() {
- data.Ipv6UnicastRouting = types.BoolValue(true)
- } else {
- data.Ipv6UnicastRouting = types.BoolValue(false)
+ if !state.IpDomainLookupSourceInterfaceTwentyFiveGigabitEthernet.IsNull() && data.IpDomainLookupSourceInterfaceTwentyFiveGigabitEthernet.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/domain/lookup-settings/lookup/source-interface/TwentyFiveGigE", state.getPath()))
}
- if value := res.Get(prefix + "system.Cisco-IOS-XE-switch:mtu.size"); value.Exists() {
- data.Mtu = types.Int64Value(value.Int())
+ if !state.IpDomainLookupSourceInterfaceTenGigabitEthernet.IsNull() && data.IpDomainLookupSourceInterfaceTenGigabitEthernet.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/domain/lookup-settings/lookup/source-interface/TenGigabitEthernet", state.getPath()))
}
- if value := res.Get(prefix + "ip.source-route"); value.Exists() {
- data.IpSourceRoute = types.BoolValue(value.Bool())
- } else {
- data.IpSourceRoute = types.BoolNull()
+ if !state.IpDomainLookupSourceInterfaceFiveGigabitEthernet.IsNull() && data.IpDomainLookupSourceInterfaceFiveGigabitEthernet.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/domain/lookup-settings/lookup/source-interface/FiveGigabitEthernet", state.getPath()))
}
- if value := res.Get(prefix + "ip.domain.lookup"); value.Exists() {
- data.IpDomainLookup = types.BoolValue(value.Bool())
- } else {
- data.IpDomainLookup = types.BoolNull()
+ if !state.IpDomainLookupSourceInterfaceTwoGigabitEthernet.IsNull() && data.IpDomainLookupSourceInterfaceTwoGigabitEthernet.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/domain/lookup-settings/lookup/source-interface/TwoGigabitEthernet", state.getPath()))
}
- if value := res.Get(prefix + "ip.domain.name"); value.Exists() {
- data.IpDomainName = types.StringValue(value.String())
+ if !state.IpDomainLookupSourceInterfaceGigabitEthernet.IsNull() && data.IpDomainLookupSourceInterfaceGigabitEthernet.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/domain/lookup-settings/lookup/source-interface/GigabitEthernet", state.getPath()))
}
- if value := res.Get(prefix + "login.delay"); value.Exists() {
- data.LoginDelay = types.Int64Value(value.Int())
+ if !state.IpDomainLookupSourceInterfaceVlan.IsNull() && data.IpDomainLookupSourceInterfaceVlan.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/domain/lookup-settings/lookup/source-interface/Vlan", state.getPath()))
}
- if value := res.Get(prefix + "login.on-failure"); value.Exists() {
- data.LoginOnFailure = types.BoolValue(true)
- } else {
- data.LoginOnFailure = types.BoolValue(false)
+ if !state.IpDomainLookupSourceInterfaceLoopback.IsNull() && data.IpDomainLookupSourceInterfaceLoopback.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/domain/lookup-settings/lookup/source-interface/Loopback", state.getPath()))
}
- if value := res.Get(prefix + "login.on-failure.log"); value.Exists() {
- data.LoginOnFailureLog = types.BoolValue(true)
- } else {
- data.LoginOnFailureLog = types.BoolValue(false)
+ for i := range state.IpNameServersVrf {
+ stateKeyValues := [...]string{state.IpNameServersVrf[i].Vrf.ValueString()}
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.IpNameServersVrf[i].Vrf.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.IpNameServersVrf {
+ found = true
+ if state.IpNameServersVrf[i].Vrf.ValueString() != data.IpNameServersVrf[j].Vrf.ValueString() {
+ found = false
+ }
+ if found {
+ if !state.IpNameServersVrf[i].Servers.IsNull() {
+ if data.IpNameServersVrf[j].Servers.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/name-server/vrf=%v/server-ip-list-ordered", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ } else {
+ var dataValues, stateValues []string
+ data.IpNameServersVrf[i].Servers.ElementsAs(ctx, &dataValues, false)
+ state.IpNameServersVrf[j].Servers.ElementsAs(ctx, &stateValues, false)
+ for _, v := range stateValues {
+ found := false
+ for _, vv := range dataValues {
+ if v == vv {
+ found = true
+ break
+ }
+ }
+ if !found {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/name-server/vrf=%v/server-ip-list-ordered=%v", state.getPath(), strings.Join(stateKeyValues[:], ","), v))
+ }
+ }
+ }
+ }
+ break
+ }
+ }
+ if !found {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/name-server/vrf=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ }
+ if !state.IpNameServers.IsNull() {
+ if data.IpNameServers.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/name-server/no-vrf-ordered", state.getPath()))
+ } else {
+ var dataValues, stateValues []string
+ data.IpNameServers.ElementsAs(ctx, &dataValues, false)
+ state.IpNameServers.ElementsAs(ctx, &stateValues, false)
+ for _, v := range stateValues {
+ found := false
+ for _, vv := range dataValues {
+ if v == vv {
+ found = true
+ break
+ }
+ }
+ if !found {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/name-server/no-vrf-ordered=%v", state.getPath(), v))
+ }
+ }
+ }
}
- if value := res.Get(prefix + "login.on-success"); value.Exists() {
- data.LoginOnSuccess = types.BoolValue(true)
- } else {
- data.LoginOnSuccess = types.BoolValue(false)
+ if !state.IpHttpActiveSessionModules.IsNull() && data.IpHttpActiveSessionModules.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/Cisco-IOS-XE-http:http/active-session-modules", state.getPath()))
}
- if value := res.Get(prefix + "login.on-success.log"); value.Exists() {
- data.LoginOnSuccessLog = types.BoolValue(true)
- } else {
- data.LoginOnSuccessLog = types.BoolValue(false)
+ if !state.IpHttpMaxConnections.IsNull() && data.IpHttpMaxConnections.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/Cisco-IOS-XE-http:http/max-connections", state.getPath()))
}
- if value := res.Get(prefix + "ip.Cisco-IOS-XE-multicast:multicast-routing"); value.Exists() {
- data.IpMulticastRouting = types.BoolValue(true)
- } else {
- data.IpMulticastRouting = types.BoolValue(false)
+ if !state.IpHttpSecureActiveSessionModules.IsNull() && data.IpHttpSecureActiveSessionModules.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/Cisco-IOS-XE-http:http/secure-active-session-modules", state.getPath()))
}
- if value := res.Get(prefix + "ip.Cisco-IOS-XE-multicast:mcr-conf.multicast-routing"); value.Exists() {
- data.MulticastRoutingSwitch = types.BoolValue(true)
- } else {
- data.MulticastRoutingSwitch = types.BoolValue(false)
+ if !state.IpHttpClientSourceInterface.IsNull() && data.IpHttpClientSourceInterface.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/Cisco-IOS-XE-http:http/client/source-interface", state.getPath()))
}
- if value := res.Get(prefix + "ip.Cisco-IOS-XE-multicast:multicast-routing.distributed"); value.Exists() {
- data.IpMulticastRoutingDistributed = types.BoolValue(true)
- } else {
- data.IpMulticastRoutingDistributed = types.BoolValue(false)
+ if !state.IpHttpClientSecureTrustpoint.IsNull() && data.IpHttpClientSecureTrustpoint.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/Cisco-IOS-XE-http:http/client/secure-trustpoint", state.getPath()))
}
- if value := res.Get(prefix + "ip.Cisco-IOS-XE-multicast:multicast-routing.vrf"); value.Exists() {
- data.MulticastRoutingVrfs = make([]SystemMulticastRoutingVrfs, 0)
- value.ForEach(func(k, v gjson.Result) bool {
- item := SystemMulticastRoutingVrfs{}
- if cValue := v.Get("name"); cValue.Exists() {
- item.Vrf = types.StringValue(cValue.String())
- }
- if cValue := v.Get("distributed"); cValue.Exists() {
- item.Distributed = types.BoolValue(true)
- } else {
- item.Distributed = types.BoolValue(false)
- }
- data.MulticastRoutingVrfs = append(data.MulticastRoutingVrfs, item)
- return true
- })
+ if !state.IpHttpTlsVersion.IsNull() && data.IpHttpTlsVersion.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/Cisco-IOS-XE-http:http/tls-version", state.getPath()))
}
- if value := res.Get(prefix + "ip.Cisco-IOS-XE-http:http.access-class"); value.Exists() {
- data.IpHttpAccessClass = types.Int64Value(value.Int())
+ if !state.IpHttpSecureTrustpoint.IsNull() && data.IpHttpSecureTrustpoint.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/Cisco-IOS-XE-http:http/secure-trustpoint", state.getPath()))
}
- if value := res.Get(prefix + "ip.Cisco-IOS-XE-http:http.authentication.aaa"); value.Exists() {
- data.IpHttpAuthenticationAaa = types.BoolValue(true)
- } else {
- data.IpHttpAuthenticationAaa = types.BoolValue(false)
+ if !state.IpHttpSecureServer.IsNull() && data.IpHttpSecureServer.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/Cisco-IOS-XE-http:http/secure-server", state.getPath()))
}
- if value := res.Get(prefix + "ip.Cisco-IOS-XE-http:http.authentication.aaa.exec-authorization"); value.Exists() {
- data.IpHttpAuthenticationAaaExecAuthorization = types.StringValue(value.String())
+ if !state.IpHttpServer.IsNull() && data.IpHttpServer.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/Cisco-IOS-XE-http:http/server", state.getPath()))
}
- if value := res.Get(prefix + "ip.Cisco-IOS-XE-http:http.authentication.aaa.login-authentication"); value.Exists() {
- data.IpHttpAuthenticationAaaLoginAuthentication = types.StringValue(value.String())
+ if !state.IpHttpAuthenticationLocal.IsNull() && data.IpHttpAuthenticationLocal.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/Cisco-IOS-XE-http:http/authentication/local", state.getPath()))
}
- if value := res.Get(prefix + "ip.Cisco-IOS-XE-http:http.authentication.aaa.command-authorization"); value.Exists() {
- data.IpHttpAuthenticationAaaCommandAuthorization = make([]SystemIpHttpAuthenticationAaaCommandAuthorization, 0)
- value.ForEach(func(k, v gjson.Result) bool {
- item := SystemIpHttpAuthenticationAaaCommandAuthorization{}
- if cValue := v.Get("level"); cValue.Exists() {
- item.Level = types.Int64Value(cValue.Int())
+ for i := range state.IpHttpAuthenticationAaaCommandAuthorization {
+ stateKeyValues := [...]string{strconv.FormatInt(state.IpHttpAuthenticationAaaCommandAuthorization[i].Level.ValueInt64(), 10)}
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.IpHttpAuthenticationAaaCommandAuthorization[i].Level.ValueInt64()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.IpHttpAuthenticationAaaCommandAuthorization {
+ found = true
+ if state.IpHttpAuthenticationAaaCommandAuthorization[i].Level.ValueInt64() != data.IpHttpAuthenticationAaaCommandAuthorization[j].Level.ValueInt64() {
+ found = false
}
- if cValue := v.Get("name"); cValue.Exists() {
- item.Name = types.StringValue(cValue.String())
+ if found {
+ if !state.IpHttpAuthenticationAaaCommandAuthorization[i].Name.IsNull() && data.IpHttpAuthenticationAaaCommandAuthorization[j].Name.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/Cisco-IOS-XE-http:http/authentication/aaa/command-authorization=%v/name", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ break
}
- data.IpHttpAuthenticationAaaCommandAuthorization = append(data.IpHttpAuthenticationAaaCommandAuthorization, item)
- return true
- })
- }
- if value := res.Get(prefix + "ip.Cisco-IOS-XE-http:http.authentication.local"); value.Exists() {
- data.IpHttpAuthenticationLocal = types.BoolValue(true)
- } else {
- data.IpHttpAuthenticationLocal = types.BoolValue(false)
- }
- if value := res.Get(prefix + "ip.Cisco-IOS-XE-http:http.server"); value.Exists() {
- data.IpHttpServer = types.BoolValue(value.Bool())
- } else {
- data.IpHttpServer = types.BoolNull()
+ }
+ if !found {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/Cisco-IOS-XE-http:http/authentication/aaa/command-authorization=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
}
- if value := res.Get(prefix + "ip.Cisco-IOS-XE-http:http.secure-server"); value.Exists() {
- data.IpHttpSecureServer = types.BoolValue(value.Bool())
- } else {
- data.IpHttpSecureServer = types.BoolNull()
+ if !state.IpHttpAuthenticationAaaLoginAuthentication.IsNull() && data.IpHttpAuthenticationAaaLoginAuthentication.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/Cisco-IOS-XE-http:http/authentication/aaa/login-authentication", state.getPath()))
}
- if value := res.Get(prefix + "ip.Cisco-IOS-XE-http:http.secure-trustpoint"); value.Exists() {
- data.IpHttpSecureTrustpoint = types.StringValue(value.String())
+ if !state.IpHttpAuthenticationAaaExecAuthorization.IsNull() && data.IpHttpAuthenticationAaaExecAuthorization.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/Cisco-IOS-XE-http:http/authentication/aaa/exec-authorization", state.getPath()))
}
- if value := res.Get(prefix + "ip.Cisco-IOS-XE-http:http.tls-version"); value.Exists() {
- data.IpHttpTlsVersion = types.StringValue(value.String())
+ if !state.IpHttpAuthenticationAaa.IsNull() && data.IpHttpAuthenticationAaa.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/Cisco-IOS-XE-http:http/authentication/aaa", state.getPath()))
}
- if value := res.Get(prefix + "ip.Cisco-IOS-XE-http:http.client.secure-trustpoint"); value.Exists() {
- data.IpHttpClientSecureTrustpoint = types.StringValue(value.String())
+ if !state.IpHttpAccessClass.IsNull() && data.IpHttpAccessClass.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/Cisco-IOS-XE-http:http/access-class", state.getPath()))
}
- if value := res.Get(prefix + "ip.Cisco-IOS-XE-http:http.client.source-interface"); value.Exists() {
- data.IpHttpClientSourceInterface = types.StringValue(value.String())
+ for i := range state.MulticastRoutingVrfs {
+ stateKeyValues := [...]string{state.MulticastRoutingVrfs[i].Vrf.ValueString()}
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.MulticastRoutingVrfs[i].Vrf.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.MulticastRoutingVrfs {
+ found = true
+ if state.MulticastRoutingVrfs[i].Vrf.ValueString() != data.MulticastRoutingVrfs[j].Vrf.ValueString() {
+ found = false
+ }
+ if found {
+ if !state.MulticastRoutingVrfs[i].Distributed.IsNull() && data.MulticastRoutingVrfs[j].Distributed.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/Cisco-IOS-XE-multicast:multicast-routing/vrf=%v/distributed", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ break
+ }
+ }
+ if !found {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/Cisco-IOS-XE-multicast:multicast-routing/vrf=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
}
- if value := res.Get(prefix + "ip.Cisco-IOS-XE-http:http.secure-active-session-modules"); value.Exists() {
- data.IpHttpSecureActiveSessionModules = types.StringValue(value.String())
+ if !state.IpMulticastRoutingDistributed.IsNull() && data.IpMulticastRoutingDistributed.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/Cisco-IOS-XE-multicast:multicast-routing/distributed", state.getPath()))
}
- if value := res.Get(prefix + "ip.Cisco-IOS-XE-http:http.max-connections"); value.Exists() {
- data.IpHttpMaxConnections = types.Int64Value(value.Int())
+ if !state.MulticastRoutingSwitch.IsNull() && data.MulticastRoutingSwitch.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/Cisco-IOS-XE-multicast:mcr-conf/multicast-routing", state.getPath()))
}
- if value := res.Get(prefix + "ip.Cisco-IOS-XE-http:http.active-session-modules"); value.Exists() {
- data.IpHttpActiveSessionModules = types.StringValue(value.String())
+ if !state.IpMulticastRouting.IsNull() && data.IpMulticastRouting.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/Cisco-IOS-XE-multicast:multicast-routing", state.getPath()))
}
- if value := res.Get(prefix + "ip.name-server.no-vrf-ordered"); value.Exists() {
- data.IpNameServers = helpers.GetStringList(value.Array())
- } else {
- data.IpNameServers = types.ListNull(types.StringType)
+ if !state.LoginOnSuccessLog.IsNull() && data.LoginOnSuccessLog.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/login/on-success/log", state.getPath()))
}
- if value := res.Get(prefix + "ip.name-server.vrf"); value.Exists() {
- data.IpNameServersVrf = make([]SystemIpNameServersVrf, 0)
- value.ForEach(func(k, v gjson.Result) bool {
- item := SystemIpNameServersVrf{}
- if cValue := v.Get("word"); cValue.Exists() {
- item.Vrf = types.StringValue(cValue.String())
- }
- if cValue := v.Get("server-ip-list-ordered"); cValue.Exists() {
- item.Servers = helpers.GetStringList(cValue.Array())
- } else {
- item.Servers = types.ListNull(types.StringType)
- }
- data.IpNameServersVrf = append(data.IpNameServersVrf, item)
- return true
- })
+ if !state.LoginOnSuccess.IsNull() && data.LoginOnSuccess.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/login/on-success", state.getPath()))
}
- if value := res.Get(prefix + "ip.domain.lookup-settings.lookup.source-interface.Loopback"); value.Exists() {
- data.IpDomainLookupSourceInterfaceLoopback = types.Int64Value(value.Int())
+ if !state.LoginOnFailureLog.IsNull() && data.LoginOnFailureLog.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/login/on-failure/log", state.getPath()))
}
- if value := res.Get(prefix + "ip.domain.lookup-settings.lookup.source-interface.Vlan"); value.Exists() {
- data.IpDomainLookupSourceInterfaceVlan = types.Int64Value(value.Int())
+ if !state.LoginOnFailure.IsNull() && data.LoginOnFailure.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/login/on-failure", state.getPath()))
}
- if value := res.Get(prefix + "ip.domain.lookup-settings.lookup.source-interface.GigabitEthernet"); value.Exists() {
- data.IpDomainLookupSourceInterfaceGigabitEthernet = types.StringValue(value.String())
+ if !state.LoginDelay.IsNull() && data.LoginDelay.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/login/delay", state.getPath()))
}
- if value := res.Get(prefix + "ip.domain.lookup-settings.lookup.source-interface.TwoGigabitEthernet"); value.Exists() {
- data.IpDomainLookupSourceInterfaceTwoGigabitEthernet = types.StringValue(value.String())
+ if !state.IpDomainName.IsNull() && data.IpDomainName.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/domain/name", state.getPath()))
}
- if value := res.Get(prefix + "ip.domain.lookup-settings.lookup.source-interface.FiveGigabitEthernet"); value.Exists() {
- data.IpDomainLookupSourceInterfaceFiveGigabitEthernet = types.StringValue(value.String())
+ if !state.IpDomainLookup.IsNull() && data.IpDomainLookup.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/domain/lookup", state.getPath()))
}
- if value := res.Get(prefix + "ip.domain.lookup-settings.lookup.source-interface.TenGigabitEthernet"); value.Exists() {
- data.IpDomainLookupSourceInterfaceTenGigabitEthernet = types.StringValue(value.String())
+ if !state.IpSourceRoute.IsNull() && data.IpSourceRoute.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/source-route", state.getPath()))
}
- if value := res.Get(prefix + "ip.domain.lookup-settings.lookup.source-interface.TwentyFiveGigE"); value.Exists() {
- data.IpDomainLookupSourceInterfaceTwentyFiveGigabitEthernet = types.StringValue(value.String())
+ if !state.Mtu.IsNull() && data.Mtu.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/system/Cisco-IOS-XE-switch:mtu/size", state.getPath()))
}
- if value := res.Get(prefix + "ip.domain.lookup-settings.lookup.source-interface.FortyGigabitEthernet"); value.Exists() {
- data.IpDomainLookupSourceInterfaceFortyGigabitEthernet = types.StringValue(value.String())
+ if !state.Ipv6UnicastRouting.IsNull() && data.Ipv6UnicastRouting.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ipv6/unicast-routing", state.getPath()))
}
- if value := res.Get(prefix + "ip.domain.lookup-settings.lookup.source-interface.HundredGigE"); value.Exists() {
- data.IpDomainLookupSourceInterfaceHundredGigabitEthernet = types.StringValue(value.String())
+ if !state.IpRouting.IsNull() && data.IpRouting.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/routing-conf/routing", state.getPath()))
}
- if value := res.Get(prefix + "cisp.enable"); value.Exists() {
- data.CispEnable = types.BoolValue(true)
- } else {
- data.CispEnable = types.BoolValue(false)
+ if !state.IpBgpCommunityNewFormat.IsNull() && data.IpBgpCommunityNewFormat.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/bgp-community/new-format", state.getPath()))
}
- if value := res.Get(prefix + "epm.logging"); value.Exists() {
- data.EpmLogging = types.BoolValue(true)
- } else {
- data.EpmLogging = types.BoolValue(false)
+ if !state.Hostname.IsNull() && data.Hostname.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/hostname", state.getPath()))
}
- if value := res.Get(prefix + "Cisco-IOS-XE-sanet:access-session.mac-move.deny"); value.Exists() {
- data.AccessSessionMacMoveDeny = types.BoolValue(true)
- } else {
- data.AccessSessionMacMoveDeny = types.BoolValue(false)
+
+ return deletedItems
+}
+
+// End of section. //template:end getDeletedItems
+
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletedItemsXML
+
+func (data *System) addDeletedItemsXML(ctx context.Context, state System, body string) string {
+ b := netconf.NewBody(body)
+ if !state.Hostname.IsNull() && data.Hostname.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/hostname")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-diagnostics:diagnostic.bootup.level"); value.Exists() {
- data.DiagnosticBootupLevel = types.StringValue(value.String())
+ if !state.IpBgpCommunityNewFormat.IsNull() && data.IpBgpCommunityNewFormat.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ip/bgp-community/new-format")
}
- if value := res.Get(prefix + "memory.free.low-watermark.processor"); value.Exists() {
- data.MemoryFreeLowWatermarkProcessor = types.Int64Value(value.Int())
+ if !state.IpRouting.IsNull() && data.IpRouting.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ip/routing-conf/routing")
}
- if value := res.Get(prefix + "archive.path"); value.Exists() {
- data.ArchivePath = types.StringValue(value.String())
+ if !state.Ipv6UnicastRouting.IsNull() && data.Ipv6UnicastRouting.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ipv6/unicast-routing")
}
- if value := res.Get(prefix + "archive.maximum"); value.Exists() {
- data.ArchiveMaximum = types.Int64Value(value.Int())
+ if !state.Mtu.IsNull() && data.Mtu.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/system/Cisco-IOS-XE-switch:mtu/size")
}
- if value := res.Get(prefix + "archive.write-memory"); value.Exists() {
- data.ArchiveWriteMemory = types.BoolValue(true)
- } else {
- data.ArchiveWriteMemory = types.BoolValue(false)
+ if !state.IpSourceRoute.IsNull() && data.IpSourceRoute.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ip/source-route")
}
- if value := res.Get(prefix + "archive.time-period"); value.Exists() {
- data.ArchiveTimePeriod = types.Int64Value(value.Int())
+ if !state.IpDomainLookup.IsNull() && data.IpDomainLookup.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ip/domain/lookup")
}
- if value := res.Get(prefix + "archive.log.config.logging.enable"); value.Exists() {
- data.ArchiveLogConfigLoggingEnable = types.BoolValue(true)
- } else {
- data.ArchiveLogConfigLoggingEnable = types.BoolValue(false)
+ if !state.IpDomainName.IsNull() && data.IpDomainName.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ip/domain/name")
}
- if value := res.Get(prefix + "archive.log.config.logging.size"); value.Exists() {
- data.ArchiveLogConfigLoggingSize = types.Int64Value(value.Int())
+ if !state.LoginDelay.IsNull() && data.LoginDelay.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/login/delay")
}
- if value := res.Get(prefix + "redundancy"); value.Exists() {
- data.Redundancy = types.BoolValue(true)
- } else {
- data.Redundancy = types.BoolValue(false)
+ if !state.LoginOnFailure.IsNull() && data.LoginOnFailure.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/login/on-failure")
}
- if value := res.Get(prefix + "redundancy.mode"); value.Exists() {
- data.RedundancyMode = types.StringValue(value.String())
+ if !state.LoginOnFailureLog.IsNull() && data.LoginOnFailureLog.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/login/on-failure/log")
}
- if value := res.Get(prefix + "transceivers.type.all.monitoring-enable.monitoring"); value.Exists() {
- data.TransceiverTypeAllMonitoring = types.BoolValue(true)
- } else {
- data.TransceiverTypeAllMonitoring = types.BoolValue(false)
+ if !state.LoginOnSuccess.IsNull() && data.LoginOnSuccess.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/login/on-success")
}
- if value := res.Get(prefix + "ip.forward-protocol-v2.nd"); value.Exists() {
- data.IpForwardProtocolNd = types.BoolValue(value.Bool())
- } else {
- data.IpForwardProtocolNd = types.BoolNull()
+ if !state.LoginOnSuccessLog.IsNull() && data.LoginOnSuccessLog.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/login/on-success/log")
}
- if value := res.Get(prefix + "ip.scp.server.enable"); value.Exists() {
- data.IpScpServerEnable = types.BoolValue(true)
- } else {
- data.IpScpServerEnable = types.BoolValue(false)
+ if !state.IpMulticastRouting.IsNull() && data.IpMulticastRouting.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ip/Cisco-IOS-XE-multicast:multicast-routing")
}
- if value := res.Get(prefix + "ip.ssh.ssh-version"); value.Exists() {
- data.IpSshVersion = types.StringValue(value.String())
+ if !state.MulticastRoutingSwitch.IsNull() && data.MulticastRoutingSwitch.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ip/Cisco-IOS-XE-multicast:mcr-conf/multicast-routing")
}
- if value := res.Get(prefix + "ip.ssh.version"); value.Exists() {
- data.IpSshVersionLegacy = types.Int64Value(value.Int())
+ if !state.IpMulticastRoutingDistributed.IsNull() && data.IpMulticastRoutingDistributed.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ip/Cisco-IOS-XE-multicast:multicast-routing/distributed")
}
- if value := res.Get(prefix + "ip.ssh.time-out"); value.Exists() {
- data.IpSshTimeOut = types.Int64Value(value.Int())
+ for i := range state.MulticastRoutingVrfs {
+ stateKeys := [...]string{"name"}
+ stateKeyValues := [...]string{state.MulticastRoutingVrfs[i].Vrf.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.MulticastRoutingVrfs[i].Vrf.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.MulticastRoutingVrfs {
+ found = true
+ if state.MulticastRoutingVrfs[i].Vrf.ValueString() != data.MulticastRoutingVrfs[j].Vrf.ValueString() {
+ found = false
+ }
+ if found {
+ if !state.MulticastRoutingVrfs[i].Distributed.IsNull() && data.MulticastRoutingVrfs[j].Distributed.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/ip/Cisco-IOS-XE-multicast:multicast-routing/vrf%v/distributed", predicates))
+ }
+ break
+ }
+ }
+ if !found {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/ip/Cisco-IOS-XE-multicast:multicast-routing/vrf%v", predicates))
+ }
}
- if value := res.Get(prefix + "ip.ssh.authentication-retries"); value.Exists() {
- data.IpSshAuthenticationRetries = types.Int64Value(value.Int())
+ if !state.IpHttpAccessClass.IsNull() && data.IpHttpAccessClass.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ip/Cisco-IOS-XE-http:http/access-class")
}
- if value := res.Get(prefix + "ip.ssh.source-interface-config.Loopback"); value.Exists() {
- data.IpSshSourceInterfaceLoopback = types.Int64Value(value.Int())
+ if !state.IpHttpAuthenticationAaa.IsNull() && data.IpHttpAuthenticationAaa.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ip/Cisco-IOS-XE-http:http/authentication/aaa")
}
- if value := res.Get(prefix + "ip.ssh.source-interface-config.Vlan"); value.Exists() {
- data.IpSshSourceInterfaceVlan = types.Int64Value(value.Int())
+ if !state.IpHttpAuthenticationAaaExecAuthorization.IsNull() && data.IpHttpAuthenticationAaaExecAuthorization.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ip/Cisco-IOS-XE-http:http/authentication/aaa/exec-authorization")
}
- if value := res.Get(prefix + "ip.ssh.source-interface-config.GigabitEthernet"); value.Exists() {
- data.IpSshSourceInterfaceGigabitEthernet = types.StringValue(value.String())
+ if !state.IpHttpAuthenticationAaaLoginAuthentication.IsNull() && data.IpHttpAuthenticationAaaLoginAuthentication.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ip/Cisco-IOS-XE-http:http/authentication/aaa/login-authentication")
}
- if value := res.Get(prefix + "ip.ssh.source-interface-config.TwoGigabitEthernet"); value.Exists() {
- data.IpSshSourceInterfaceTwoGigabitEthernet = types.StringValue(value.String())
+ for i := range state.IpHttpAuthenticationAaaCommandAuthorization {
+ stateKeys := [...]string{"level"}
+ stateKeyValues := [...]string{strconv.FormatInt(state.IpHttpAuthenticationAaaCommandAuthorization[i].Level.ValueInt64(), 10)}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.IpHttpAuthenticationAaaCommandAuthorization[i].Level.ValueInt64()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.IpHttpAuthenticationAaaCommandAuthorization {
+ found = true
+ if state.IpHttpAuthenticationAaaCommandAuthorization[i].Level.ValueInt64() != data.IpHttpAuthenticationAaaCommandAuthorization[j].Level.ValueInt64() {
+ found = false
+ }
+ if found {
+ if !state.IpHttpAuthenticationAaaCommandAuthorization[i].Name.IsNull() && data.IpHttpAuthenticationAaaCommandAuthorization[j].Name.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/ip/Cisco-IOS-XE-http:http/authentication/aaa/command-authorization%v/name", predicates))
+ }
+ break
+ }
+ }
+ if !found {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/ip/Cisco-IOS-XE-http:http/authentication/aaa/command-authorization%v", predicates))
+ }
}
- if value := res.Get(prefix + "ip.ssh.source-interface-config.FiveGigabitEthernet"); value.Exists() {
- data.IpSshSourceInterfaceFiveGigabitEthernet = types.StringValue(value.String())
+ if !state.IpHttpAuthenticationLocal.IsNull() && data.IpHttpAuthenticationLocal.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ip/Cisco-IOS-XE-http:http/authentication/local")
}
- if value := res.Get(prefix + "ip.ssh.source-interface-config.TenGigabitEthernet"); value.Exists() {
- data.IpSshSourceInterfaceTenGigabitEthernet = types.StringValue(value.String())
+ if !state.IpHttpServer.IsNull() && data.IpHttpServer.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ip/Cisco-IOS-XE-http:http/server")
}
- if value := res.Get(prefix + "ip.ssh.source-interface-config.TwentyFiveGigE"); value.Exists() {
- data.IpSshSourceInterfaceTwentyFiveGigabitEthernet = types.StringValue(value.String())
+ if !state.IpHttpSecureServer.IsNull() && data.IpHttpSecureServer.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ip/Cisco-IOS-XE-http:http/secure-server")
}
- if value := res.Get(prefix + "ip.ssh.source-interface-config.FortyGigabitEthernet"); value.Exists() {
- data.IpSshSourceInterfaceFortyGigabitEthernet = types.StringValue(value.String())
+ if !state.IpHttpSecureTrustpoint.IsNull() && data.IpHttpSecureTrustpoint.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ip/Cisco-IOS-XE-http:http/secure-trustpoint")
}
- if value := res.Get(prefix + "ip.ssh.source-interface-config.HundredGigE"); value.Exists() {
- data.IpSshSourceInterfaceHundredGigabitEthernet = types.StringValue(value.String())
+ if !state.IpHttpTlsVersion.IsNull() && data.IpHttpTlsVersion.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ip/Cisco-IOS-XE-http:http/tls-version")
}
- if value := res.Get(prefix + "control-plane.Cisco-IOS-XE-policy:service-policy.input"); value.Exists() {
- data.ControlPlaneServicePolicyInput = types.StringValue(value.String())
+ if !state.IpHttpClientSecureTrustpoint.IsNull() && data.IpHttpClientSecureTrustpoint.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ip/Cisco-IOS-XE-http:http/client/secure-trustpoint")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-pnp:pnp.profile"); value.Exists() {
- data.PnpProfiles = make([]SystemPnpProfiles, 0)
- value.ForEach(func(k, v gjson.Result) bool {
- item := SystemPnpProfiles{}
- if cValue := v.Get("name"); cValue.Exists() {
- item.Name = types.StringValue(cValue.String())
- }
- if cValue := v.Get("transport.https.ipv4.ipv4-address"); cValue.Exists() {
- item.TransportHttpsIpv4Ipv4Address = types.StringValue(cValue.String())
- }
- if cValue := v.Get("transport.https.ipv4.port"); cValue.Exists() {
- item.TransportHttpsIpv4Port = types.Int64Value(cValue.Int())
- }
- data.PnpProfiles = append(data.PnpProfiles, item)
- return true
- })
+ if !state.IpHttpClientSourceInterface.IsNull() && data.IpHttpClientSourceInterface.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ip/Cisco-IOS-XE-http:http/client/source-interface")
}
- if value := res.Get(prefix + "ip.Cisco-IOS-XE-aaa:tacacs.source-interface.Loopback"); value.Exists() {
- data.IpTacacsSourceInterfaceLoopback = types.Int64Value(value.Int())
+ if !state.IpHttpSecureActiveSessionModules.IsNull() && data.IpHttpSecureActiveSessionModules.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ip/Cisco-IOS-XE-http:http/secure-active-session-modules")
}
- if value := res.Get(prefix + "ip.Cisco-IOS-XE-aaa:tacacs.source-interface.Vlan"); value.Exists() {
- data.IpTacacsSourceInterfaceVlan = types.Int64Value(value.Int())
+ if !state.IpHttpMaxConnections.IsNull() && data.IpHttpMaxConnections.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ip/Cisco-IOS-XE-http:http/max-connections")
}
- if value := res.Get(prefix + "ip.Cisco-IOS-XE-aaa:tacacs.source-interface.GigabitEthernet"); value.Exists() {
- data.IpTacacsSourceInterfaceGigabitEthernet = types.StringValue(value.String())
+ if !state.IpHttpActiveSessionModules.IsNull() && data.IpHttpActiveSessionModules.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ip/Cisco-IOS-XE-http:http/active-session-modules")
}
- if value := res.Get(prefix + "ip.Cisco-IOS-XE-aaa:tacacs.source-interface.TwoGigabitEthernet"); value.Exists() {
- data.IpTacacsSourceInterfaceTwoGigabitEthernet = types.StringValue(value.String())
+ if !state.IpNameServers.IsNull() {
+ if data.IpNameServers.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ip/name-server/no-vrf-ordered")
+ } else {
+ var dataValues, stateValues []string
+ data.IpNameServers.ElementsAs(ctx, &dataValues, false)
+ state.IpNameServers.ElementsAs(ctx, &stateValues, false)
+ for _, v := range stateValues {
+ found := false
+ for _, vv := range dataValues {
+ if v == vv {
+ found = true
+ break
+ }
+ }
+ if !found {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/ip/name-server/no-vrf-ordered[.=%v]", v))
+ }
+ }
+ }
}
- if value := res.Get(prefix + "ip.Cisco-IOS-XE-aaa:tacacs.source-interface.FiveGigabitEthernet"); value.Exists() {
- data.IpTacacsSourceInterfaceFiveGigabitEthernet = types.StringValue(value.String())
+ for i := range state.IpNameServersVrf {
+ stateKeys := [...]string{"word"}
+ stateKeyValues := [...]string{state.IpNameServersVrf[i].Vrf.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.IpNameServersVrf[i].Vrf.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.IpNameServersVrf {
+ found = true
+ if state.IpNameServersVrf[i].Vrf.ValueString() != data.IpNameServersVrf[j].Vrf.ValueString() {
+ found = false
+ }
+ if found {
+ if !state.IpNameServersVrf[i].Servers.IsNull() {
+ if data.IpNameServersVrf[j].Servers.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/ip/name-server/vrf%v/server-ip-list-ordered", predicates))
+ } else {
+ var dataValues, stateValues []string
+ data.IpNameServersVrf[i].Servers.ElementsAs(ctx, &dataValues, false)
+ state.IpNameServersVrf[j].Servers.ElementsAs(ctx, &stateValues, false)
+ for _, v := range stateValues {
+ found := false
+ for _, vv := range dataValues {
+ if v == vv {
+ found = true
+ break
+ }
+ }
+ if !found {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/ip/name-server/vrf%v/server-ip-list-ordered[.=%v]", predicates, v))
+ }
+ }
+ }
+ }
+ break
+ }
+ }
+ if !found {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/ip/name-server/vrf%v", predicates))
+ }
}
- if value := res.Get(prefix + "ip.Cisco-IOS-XE-aaa:tacacs.source-interface.TenGigabitEthernet"); value.Exists() {
- data.IpTacacsSourceInterfaceTenGigabitEthernet = types.StringValue(value.String())
+ if !state.IpDomainLookupSourceInterfaceLoopback.IsNull() && data.IpDomainLookupSourceInterfaceLoopback.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ip/domain/lookup-settings/lookup/source-interface/Loopback")
}
- if value := res.Get(prefix + "ip.Cisco-IOS-XE-aaa:tacacs.source-interface.TwentyFiveGigE"); value.Exists() {
- data.IpTacacsSourceInterfaceTwentyFiveGigabitEthernet = types.StringValue(value.String())
+ if !state.IpDomainLookupSourceInterfaceVlan.IsNull() && data.IpDomainLookupSourceInterfaceVlan.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ip/domain/lookup-settings/lookup/source-interface/Vlan")
}
- if value := res.Get(prefix + "ip.Cisco-IOS-XE-aaa:tacacs.source-interface.FortyGigabitEthernet"); value.Exists() {
- data.IpTacacsSourceInterfaceFortyGigabitEthernet = types.StringValue(value.String())
+ if !state.IpDomainLookupSourceInterfaceGigabitEthernet.IsNull() && data.IpDomainLookupSourceInterfaceGigabitEthernet.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ip/domain/lookup-settings/lookup/source-interface/GigabitEthernet")
}
- if value := res.Get(prefix + "ip.Cisco-IOS-XE-aaa:tacacs.source-interface.HundredGigE"); value.Exists() {
- data.IpTacacsSourceInterfaceHundredGigabitEthernet = types.StringValue(value.String())
+ if !state.IpDomainLookupSourceInterfaceTwoGigabitEthernet.IsNull() && data.IpDomainLookupSourceInterfaceTwoGigabitEthernet.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ip/domain/lookup-settings/lookup/source-interface/TwoGigabitEthernet")
}
- if value := res.Get(prefix + "ip.Cisco-IOS-XE-aaa:tacacs.source-interface.vrf"); value.Exists() {
- data.IpTacacsSourceInterfaceVrf = types.StringValue(value.String())
+ if !state.IpDomainLookupSourceInterfaceFiveGigabitEthernet.IsNull() && data.IpDomainLookupSourceInterfaceFiveGigabitEthernet.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ip/domain/lookup-settings/lookup/source-interface/FiveGigabitEthernet")
}
- if value := res.Get(prefix + "ip.Cisco-IOS-XE-aaa:radius.source-interface.Loopback"); value.Exists() {
- data.IpRadiusSourceInterfaceLoopback = types.Int64Value(value.Int())
+ if !state.IpDomainLookupSourceInterfaceTenGigabitEthernet.IsNull() && data.IpDomainLookupSourceInterfaceTenGigabitEthernet.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ip/domain/lookup-settings/lookup/source-interface/TenGigabitEthernet")
}
- if value := res.Get(prefix + "ip.Cisco-IOS-XE-aaa:radius.source-interface.Vlan"); value.Exists() {
- data.IpRadiusSourceInterfaceVlan = types.Int64Value(value.Int())
+ if !state.IpDomainLookupSourceInterfaceTwentyFiveGigabitEthernet.IsNull() && data.IpDomainLookupSourceInterfaceTwentyFiveGigabitEthernet.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ip/domain/lookup-settings/lookup/source-interface/TwentyFiveGigE")
}
- if value := res.Get(prefix + "ip.Cisco-IOS-XE-aaa:radius.source-interface.GigabitEthernet"); value.Exists() {
- data.IpRadiusSourceInterfaceGigabitEthernet = types.StringValue(value.String())
+ if !state.IpDomainLookupSourceInterfaceFortyGigabitEthernet.IsNull() && data.IpDomainLookupSourceInterfaceFortyGigabitEthernet.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ip/domain/lookup-settings/lookup/source-interface/FortyGigabitEthernet")
}
- if value := res.Get(prefix + "ip.Cisco-IOS-XE-aaa:radius.source-interface.TwoGigabitEthernet"); value.Exists() {
- data.IpRadiusSourceInterfaceTwoGigabitEthernet = types.StringValue(value.String())
+ if !state.IpDomainLookupSourceInterfaceHundredGigabitEthernet.IsNull() && data.IpDomainLookupSourceInterfaceHundredGigabitEthernet.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ip/domain/lookup-settings/lookup/source-interface/HundredGigE")
}
- if value := res.Get(prefix + "ip.Cisco-IOS-XE-aaa:radius.source-interface.FiveGigabitEthernet"); value.Exists() {
- data.IpRadiusSourceInterfaceFiveGigabitEthernet = types.StringValue(value.String())
+ if !state.CispEnable.IsNull() && data.CispEnable.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/cisp/enable")
}
- if value := res.Get(prefix + "ip.Cisco-IOS-XE-aaa:radius.source-interface.TenGigabitEthernet"); value.Exists() {
- data.IpRadiusSourceInterfaceTenGigabitEthernet = types.StringValue(value.String())
+ if !state.EpmLogging.IsNull() && data.EpmLogging.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/epm/logging")
}
- if value := res.Get(prefix + "ip.Cisco-IOS-XE-aaa:radius.source-interface.TwentyFiveGigE"); value.Exists() {
- data.IpRadiusSourceInterfaceTwentyFiveGigabitEthernet = types.StringValue(value.String())
+ if !state.AccessSessionMacMoveDeny.IsNull() && data.AccessSessionMacMoveDeny.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-sanet:access-session/mac-move/deny")
}
- if value := res.Get(prefix + "ip.Cisco-IOS-XE-aaa:radius.source-interface.FortyGigabitEthernet"); value.Exists() {
- data.IpRadiusSourceInterfaceFortyGigabitEthernet = types.StringValue(value.String())
+ if !state.DiagnosticBootupLevel.IsNull() && data.DiagnosticBootupLevel.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-diagnostics:diagnostic/bootup/level")
}
- if value := res.Get(prefix + "ip.Cisco-IOS-XE-aaa:radius.source-interface.HundredGigE"); value.Exists() {
- data.IpRadiusSourceInterfaceHundredGigabitEthernet = types.StringValue(value.String())
+ if !state.MemoryFreeLowWatermarkProcessor.IsNull() && data.MemoryFreeLowWatermarkProcessor.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/memory/free/low-watermark/processor")
}
- if value := res.Get(prefix + "ip.Cisco-IOS-XE-aaa:radius.source-interface.vrf"); value.Exists() {
- data.IpRadiusSourceInterfaceVrf = types.StringValue(value.String())
+ if !state.ArchivePath.IsNull() && data.ArchivePath.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/archive/path")
}
- if value := res.Get(prefix + "boot.system.flash.flash-list-ordered-by-user"); value.Exists() {
- data.BootSystemFlashFiles = make([]SystemBootSystemFlashFiles, 0)
- value.ForEach(func(k, v gjson.Result) bool {
- item := SystemBootSystemFlashFiles{}
- if cValue := v.Get("flash-leaf"); cValue.Exists() {
- item.Path = types.StringValue(cValue.String())
- }
- data.BootSystemFlashFiles = append(data.BootSystemFlashFiles, item)
- return true
- })
+ if !state.ArchiveMaximum.IsNull() && data.ArchiveMaximum.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/archive/maximum")
}
- if value := res.Get(prefix + "boot.system.bootfile.filename-list-ordered-by-user"); value.Exists() {
- data.BootSystemBootfiles = make([]SystemBootSystemBootfiles, 0)
- value.ForEach(func(k, v gjson.Result) bool {
- item := SystemBootSystemBootfiles{}
- if cValue := v.Get("filename"); cValue.Exists() {
- item.Path = types.StringValue(cValue.String())
- }
- data.BootSystemBootfiles = append(data.BootSystemBootfiles, item)
- return true
- })
+ if !state.ArchiveWriteMemory.IsNull() && data.ArchiveWriteMemory.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/archive/write-memory")
}
- if value := res.Get(prefix + "enable.secret.secret"); value.Exists() {
- data.EnableSecret = types.StringValue(value.String())
+ if !state.ArchiveTimePeriod.IsNull() && data.ArchiveTimePeriod.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/archive/time-period")
}
- if value := res.Get(prefix + "enable.secret.type"); value.Exists() {
- data.EnableSecretType = types.StringValue(value.String())
+ if !state.ArchiveLogConfigLoggingEnable.IsNull() && data.ArchiveLogConfigLoggingEnable.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/archive/log/config/logging/enable")
}
- if value := res.Get(prefix + "enable.secret.level"); value.Exists() {
- data.EnableSecretLevel = types.Int64Value(value.Int())
+ if !state.ArchiveLogConfigLoggingSize.IsNull() && data.ArchiveLogConfigLoggingSize.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/archive/log/config/logging/size")
}
- if value := res.Get(prefix + "ip.host.host-list"); value.Exists() {
- data.IpHosts = make([]SystemIpHosts, 0)
- value.ForEach(func(k, v gjson.Result) bool {
- item := SystemIpHosts{}
- if cValue := v.Get("name"); cValue.Exists() {
- item.Name = types.StringValue(cValue.String())
- }
- if cValue := v.Get("ip-list-ordered"); cValue.Exists() {
- item.Ips = helpers.GetStringList(cValue.Array())
- } else {
- item.Ips = types.ListNull(types.StringType)
- }
- data.IpHosts = append(data.IpHosts, item)
- return true
- })
+ if !state.Redundancy.IsNull() && data.Redundancy.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/redundancy")
}
- if value := res.Get(prefix + "ip.host.vrf"); value.Exists() {
- data.IpHostsVrf = make([]SystemIpHostsVrf, 0)
- value.ForEach(func(k, v gjson.Result) bool {
- item := SystemIpHostsVrf{}
- if cValue := v.Get("vrf-name"); cValue.Exists() {
- item.Vrf = types.StringValue(cValue.String())
- }
- if cValue := v.Get("host-name"); cValue.Exists() {
- item.Hosts = make([]SystemIpHostsVrfHosts, 0)
- cValue.ForEach(func(ck, cv gjson.Result) bool {
- cItem := SystemIpHostsVrfHosts{}
- if ccValue := cv.Get("host-name"); ccValue.Exists() {
- cItem.Name = types.StringValue(ccValue.String())
- }
- if ccValue := cv.Get("ip-list"); ccValue.Exists() {
- cItem.Ips = helpers.GetStringList(ccValue.Array())
- } else {
- cItem.Ips = types.ListNull(types.StringType)
- }
- item.Hosts = append(item.Hosts, cItem)
- return true
- })
- }
- data.IpHostsVrf = append(data.IpHostsVrf, item)
- return true
- })
+ if !state.RedundancyMode.IsNull() && data.RedundancyMode.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/redundancy/mode")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-diagnostics:diagnostic.event-log.size"); value.Exists() {
- data.DiagnosticEventLogSize = types.Int64Value(value.Int())
+ if !state.TransceiverTypeAllMonitoring.IsNull() && data.TransceiverTypeAllMonitoring.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/transceivers/type/all/monitoring-enable/monitoring")
}
- if value := res.Get(prefix + "subscriber.templating"); value.Exists() {
- data.SubscriberTemplating = types.BoolValue(true)
- } else {
- data.SubscriberTemplating = types.BoolValue(false)
+ if !state.IpForwardProtocolNd.IsNull() && data.IpForwardProtocolNd.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ip/forward-protocol-v2/nd")
}
- if value := res.Get(prefix + "call-home.Cisco-IOS-XE-call-home:contact-email-addr"); value.Exists() {
- data.CallHomeContactEmail = types.StringValue(value.String())
+ if !state.IpScpServerEnable.IsNull() && data.IpScpServerEnable.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ip/scp/server/enable")
}
- if value := res.Get(prefix + "call-home.Cisco-IOS-XE-call-home:tac-profile.profile.CiscoTAC-1.active"); value.Exists() {
- data.CallHomeCiscoTac1ProfileActive = types.BoolValue(value.Bool())
- } else {
- data.CallHomeCiscoTac1ProfileActive = types.BoolNull()
+ if !state.IpSshVersion.IsNull() && data.IpSshVersion.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ip/ssh/ssh-version")
}
- if value := res.Get(prefix + "call-home.Cisco-IOS-XE-call-home:tac-profile.profile.CiscoTAC-1.destination.transport-method"); value.Exists() {
- data.CallHomeCiscoTac1DestinationTransportMethod = types.StringValue(value.String())
+ if !state.IpSshVersionLegacy.IsNull() && data.IpSshVersionLegacy.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ip/ssh/version")
}
- if value := res.Get(prefix + "ip.ftp.passive-enable"); value.Exists() {
- data.IpFtpPassive = types.BoolValue(value.Bool())
- } else {
- data.IpFtpPassive = types.BoolNull()
+ if !state.IpSshTimeOut.IsNull() && data.IpSshTimeOut.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ip/ssh/time-out")
}
- if value := res.Get(prefix + "ip.tftp.source-interface.GigabitEthernet"); value.Exists() {
- data.TftpSourceInterfaceGigabitEthernet = types.StringValue(value.String())
+ if !state.IpSshAuthenticationRetries.IsNull() && data.IpSshAuthenticationRetries.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ip/ssh/authentication-retries")
}
- if value := res.Get(prefix + "ip.tftp.source-interface.Loopback"); value.Exists() {
- data.TftpSourceInterfaceLoopback = types.Int64Value(value.Int())
+ if !state.IpSshSourceInterfaceLoopback.IsNull() && data.IpSshSourceInterfaceLoopback.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ip/ssh/source-interface-config/Loopback")
}
- if value := res.Get(prefix + "ip.tftp.source-interface.Vlan"); value.Exists() {
- data.TftpSourceInterfaceVlan = types.Int64Value(value.Int())
+ if !state.IpSshSourceInterfaceVlan.IsNull() && data.IpSshSourceInterfaceVlan.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ip/ssh/source-interface-config/Vlan")
}
- if value := res.Get(prefix + "ip.tftp.source-interface.TwoGigabitEthernet"); value.Exists() {
- data.TftpSourceInterfaceTwoGigabitEthernet = types.StringValue(value.String())
+ if !state.IpSshSourceInterfaceGigabitEthernet.IsNull() && data.IpSshSourceInterfaceGigabitEthernet.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ip/ssh/source-interface-config/GigabitEthernet")
}
- if value := res.Get(prefix + "ip.tftp.source-interface.FiveGigabitEthernet"); value.Exists() {
- data.TftpSourceInterfaceFiveGigabitEthernet = types.StringValue(value.String())
+ if !state.IpSshSourceInterfaceTwoGigabitEthernet.IsNull() && data.IpSshSourceInterfaceTwoGigabitEthernet.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ip/ssh/source-interface-config/TwoGigabitEthernet")
}
- if value := res.Get(prefix + "ip.tftp.source-interface.TenGigabitEthernet"); value.Exists() {
- data.TftpSourceInterfaceTenGigabitEthernet = types.StringValue(value.String())
+ if !state.IpSshSourceInterfaceFiveGigabitEthernet.IsNull() && data.IpSshSourceInterfaceFiveGigabitEthernet.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ip/ssh/source-interface-config/FiveGigabitEthernet")
}
- if value := res.Get(prefix + "ip.tftp.source-interface.TwentyFiveGigabitEthernet"); value.Exists() {
- data.TftpSourceInterfaceTwentyFiveGigabitEthernet = types.StringValue(value.String())
+ if !state.IpSshSourceInterfaceTenGigabitEthernet.IsNull() && data.IpSshSourceInterfaceTenGigabitEthernet.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ip/ssh/source-interface-config/TenGigabitEthernet")
}
- if value := res.Get(prefix + "ip.tftp.source-interface.FortyGigabitEthernet"); value.Exists() {
- data.TftpSourceInterfaceFortyGigabitEthernet = types.StringValue(value.String())
+ if !state.IpSshSourceInterfaceTwentyFiveGigabitEthernet.IsNull() && data.IpSshSourceInterfaceTwentyFiveGigabitEthernet.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ip/ssh/source-interface-config/TwentyFiveGigE")
}
- if value := res.Get(prefix + "ip.tftp.source-interface.HundredGigE"); value.Exists() {
- data.TftpSourceInterfaceHundredGigabitEthernet = types.StringValue(value.String())
+ if !state.IpSshSourceInterfaceFortyGigabitEthernet.IsNull() && data.IpSshSourceInterfaceFortyGigabitEthernet.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ip/ssh/source-interface-config/FortyGigabitEthernet")
}
- if value := res.Get(prefix + "multilink.Cisco-IOS-XE-ppp:bundle-name"); value.Exists() {
- data.MultilinkPppBundleName = types.StringValue(value.String())
+ if !state.IpSshSourceInterfaceHundredGigabitEthernet.IsNull() && data.IpSshSourceInterfaceHundredGigabitEthernet.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ip/ssh/source-interface-config/HundredGigE")
}
- if value := res.Get(prefix + "version"); value.Exists() {
- data.Version = types.StringValue(value.String())
+ if !state.ControlPlaneServicePolicyInput.IsNull() && data.ControlPlaneServicePolicyInput.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/control-plane/Cisco-IOS-XE-policy:service-policy/input")
}
- if value := res.Get(prefix + "track.Cisco-IOS-XE-track:tracked-object-v2"); value.Exists() {
- data.TrackObjects = make([]SystemTrackObjects, 0)
- value.ForEach(func(k, v gjson.Result) bool {
- item := SystemTrackObjects{}
- if cValue := v.Get("object-number"); cValue.Exists() {
- item.Number = types.StringValue(cValue.String())
- }
- if cValue := v.Get("ip.sla.number"); cValue.Exists() {
- item.IpSlaNumber = types.Int64Value(cValue.Int())
+ for i := range state.PnpProfiles {
+ stateKeys := [...]string{"name"}
+ stateKeyValues := [...]string{state.PnpProfiles[i].Name.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.PnpProfiles[i].Name.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.PnpProfiles {
+ found = true
+ if state.PnpProfiles[i].Name.ValueString() != data.PnpProfiles[j].Name.ValueString() {
+ found = false
}
- if cValue := v.Get("ip.sla.reachability"); cValue.Exists() {
- item.IpSlaReachability = types.BoolValue(true)
- } else {
- item.IpSlaReachability = types.BoolValue(false)
+ if found {
+ if !state.PnpProfiles[i].TransportHttpsIpv4Ipv4Address.IsNull() && data.PnpProfiles[j].TransportHttpsIpv4Ipv4Address.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-pnp:pnp/profile%v/transport/https/ipv4/ipv4-address", predicates))
+ }
+ if !state.PnpProfiles[i].TransportHttpsIpv4Port.IsNull() && data.PnpProfiles[j].TransportHttpsIpv4Port.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-pnp:pnp/profile%v/transport/https/ipv4/port", predicates))
+ }
+ break
}
- data.TrackObjects = append(data.TrackObjects, item)
- return true
- })
+ }
+ if !found {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/Cisco-IOS-XE-pnp:pnp/profile%v", predicates))
+ }
}
- if value := res.Get(prefix + "ip.Cisco-IOS-XE-nbar:nbar.classification.dns.classify-by-domain-with-default"); value.Exists() {
- data.IpNbarClassificationDnsClassifyByDomain = types.BoolValue(value.Bool())
- } else {
- data.IpNbarClassificationDnsClassifyByDomain = types.BoolNull()
+ if !state.IpTacacsSourceInterfaceLoopback.IsNull() && data.IpTacacsSourceInterfaceLoopback.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ip/Cisco-IOS-XE-aaa:tacacs/source-interface/Loopback")
}
- if value := res.Get(prefix + "ip.multicast.Cisco-IOS-XE-multicast:route-limit-container.routelimit"); value.Exists() {
- data.IpMulticastRouteLimit = types.Int64Value(value.Int())
+ if !state.IpTacacsSourceInterfaceVlan.IsNull() && data.IpTacacsSourceInterfaceVlan.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ip/Cisco-IOS-XE-aaa:tacacs/source-interface/Vlan")
}
- if value := res.Get(prefix + "Cisco-IOS-XE-aaa:security.passwords.min-length"); value.Exists() {
- data.SecurityPasswordsMinLength = types.Int64Value(value.Int())
+ if !state.IpTacacsSourceInterfaceGigabitEthernet.IsNull() && data.IpTacacsSourceInterfaceGigabitEthernet.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ip/Cisco-IOS-XE-aaa:tacacs/source-interface/GigabitEthernet")
}
- if value := res.Get(prefix + "ip.domain.list.domain-name"); value.Exists() {
- data.IpDomainListNames = helpers.GetStringList(value.Array())
- } else {
- data.IpDomainListNames = types.ListNull(types.StringType)
+ if !state.IpTacacsSourceInterfaceTwoGigabitEthernet.IsNull() && data.IpTacacsSourceInterfaceTwoGigabitEthernet.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ip/Cisco-IOS-XE-aaa:tacacs/source-interface/TwoGigabitEthernet")
}
- if value := res.Get(prefix + "ip.domain.list.vrf.domain-name"); value.Exists() {
- data.IpDomainListVrfDomain = types.StringValue(value.String())
+ if !state.IpTacacsSourceInterfaceFiveGigabitEthernet.IsNull() && data.IpTacacsSourceInterfaceFiveGigabitEthernet.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ip/Cisco-IOS-XE-aaa:tacacs/source-interface/FiveGigabitEthernet")
}
- if value := res.Get(prefix + "ip.domain.list.vrf.vrf-name"); value.Exists() {
- data.IpDomainListVrf = types.StringValue(value.String())
+ if !state.IpTacacsSourceInterfaceTenGigabitEthernet.IsNull() && data.IpTacacsSourceInterfaceTenGigabitEthernet.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ip/Cisco-IOS-XE-aaa:tacacs/source-interface/TenGigabitEthernet")
}
- if value := res.Get(prefix + "ethernet.Cisco-IOS-XE-ethernet:cfm.alarm-config.delay"); value.Exists() {
- data.EthernetCfmAlarmConfigDelay = types.Int64Value(value.Int())
+ if !state.IpTacacsSourceInterfaceTwentyFiveGigabitEthernet.IsNull() && data.IpTacacsSourceInterfaceTwentyFiveGigabitEthernet.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ip/Cisco-IOS-XE-aaa:tacacs/source-interface/TwentyFiveGigE")
}
- if value := res.Get(prefix + "ethernet.Cisco-IOS-XE-ethernet:cfm.alarm-config.reset"); value.Exists() {
- data.EthernetCfmAlarmConfigReset = types.Int64Value(value.Int())
+ if !state.IpTacacsSourceInterfaceFortyGigabitEthernet.IsNull() && data.IpTacacsSourceInterfaceFortyGigabitEthernet.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ip/Cisco-IOS-XE-aaa:tacacs/source-interface/FortyGigabitEthernet")
}
- if value := res.Get(prefix + "standby.redirects-config.redirects"); value.Exists() {
- data.StandbyRedirects = types.BoolValue(value.Bool())
- } else {
- data.StandbyRedirects = types.BoolNull()
+ if !state.IpTacacsSourceInterfaceHundredGigabitEthernet.IsNull() && data.IpTacacsSourceInterfaceHundredGigabitEthernet.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ip/Cisco-IOS-XE-aaa:tacacs/source-interface/HundredGigE")
}
- if value := res.Get(prefix + "standby.redirects-config.redirect-enable-disable.redirects"); value.Exists() {
- data.StandbyRedirectsEnableDisable = types.StringValue(value.String())
+ if !state.IpTacacsSourceInterfaceVrf.IsNull() && data.IpTacacsSourceInterfaceVrf.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ip/Cisco-IOS-XE-aaa:tacacs/source-interface/vrf")
}
-}
-
-// End of section. //template:end fromBodyData
-
-// Section below is generated&owned by "gen/generator.go". //template:begin getDeletedItems
-
-func (data *System) getDeletedItems(ctx context.Context, state System) []string {
- deletedItems := make([]string, 0)
- if !state.StandbyRedirectsEnableDisable.IsNull() && data.StandbyRedirectsEnableDisable.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/standby/redirects-config/redirect-enable-disable/redirects", state.getPath()))
+ if !state.IpRadiusSourceInterfaceLoopback.IsNull() && data.IpRadiusSourceInterfaceLoopback.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ip/Cisco-IOS-XE-aaa:radius/source-interface/Loopback")
}
- if !state.StandbyRedirects.IsNull() && data.StandbyRedirects.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/standby/redirects-config/redirects", state.getPath()))
+ if !state.IpRadiusSourceInterfaceVlan.IsNull() && data.IpRadiusSourceInterfaceVlan.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ip/Cisco-IOS-XE-aaa:radius/source-interface/Vlan")
}
- if !state.EthernetCfmAlarmConfigReset.IsNull() && data.EthernetCfmAlarmConfigReset.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ethernet/Cisco-IOS-XE-ethernet:cfm/alarm-config/reset", state.getPath()))
+ if !state.IpRadiusSourceInterfaceGigabitEthernet.IsNull() && data.IpRadiusSourceInterfaceGigabitEthernet.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ip/Cisco-IOS-XE-aaa:radius/source-interface/GigabitEthernet")
}
- if !state.EthernetCfmAlarmConfigDelay.IsNull() && data.EthernetCfmAlarmConfigDelay.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ethernet/Cisco-IOS-XE-ethernet:cfm/alarm-config/delay", state.getPath()))
+ if !state.IpRadiusSourceInterfaceTwoGigabitEthernet.IsNull() && data.IpRadiusSourceInterfaceTwoGigabitEthernet.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ip/Cisco-IOS-XE-aaa:radius/source-interface/TwoGigabitEthernet")
}
- if !state.IpDomainListVrf.IsNull() && data.IpDomainListVrf.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/domain/list/vrf/vrf-name", state.getPath()))
+ if !state.IpRadiusSourceInterfaceFiveGigabitEthernet.IsNull() && data.IpRadiusSourceInterfaceFiveGigabitEthernet.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ip/Cisco-IOS-XE-aaa:radius/source-interface/FiveGigabitEthernet")
}
- if !state.IpDomainListVrfDomain.IsNull() && data.IpDomainListVrfDomain.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/domain/list/vrf/domain-name", state.getPath()))
+ if !state.IpRadiusSourceInterfaceTenGigabitEthernet.IsNull() && data.IpRadiusSourceInterfaceTenGigabitEthernet.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ip/Cisco-IOS-XE-aaa:radius/source-interface/TenGigabitEthernet")
}
- if !state.IpDomainListNames.IsNull() {
- if data.IpDomainListNames.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/domain/list/domain-name", state.getPath()))
- } else {
- var dataValues, stateValues []string
- data.IpDomainListNames.ElementsAs(ctx, &dataValues, false)
- state.IpDomainListNames.ElementsAs(ctx, &stateValues, false)
- for _, v := range stateValues {
- found := false
- for _, vv := range dataValues {
- if v == vv {
- found = true
- break
- }
- }
- if !found {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/domain/list/domain-name=%v", state.getPath(), v))
- }
- }
- }
+ if !state.IpRadiusSourceInterfaceTwentyFiveGigabitEthernet.IsNull() && data.IpRadiusSourceInterfaceTwentyFiveGigabitEthernet.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ip/Cisco-IOS-XE-aaa:radius/source-interface/TwentyFiveGigE")
}
- if !state.SecurityPasswordsMinLength.IsNull() && data.SecurityPasswordsMinLength.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-aaa:security/passwords/min-length", state.getPath()))
+ if !state.IpRadiusSourceInterfaceFortyGigabitEthernet.IsNull() && data.IpRadiusSourceInterfaceFortyGigabitEthernet.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ip/Cisco-IOS-XE-aaa:radius/source-interface/FortyGigabitEthernet")
}
- if !state.IpMulticastRouteLimit.IsNull() && data.IpMulticastRouteLimit.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/multicast/Cisco-IOS-XE-multicast:route-limit-container/routelimit", state.getPath()))
+ if !state.IpRadiusSourceInterfaceHundredGigabitEthernet.IsNull() && data.IpRadiusSourceInterfaceHundredGigabitEthernet.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ip/Cisco-IOS-XE-aaa:radius/source-interface/HundredGigE")
}
- if !state.IpNbarClassificationDnsClassifyByDomain.IsNull() && data.IpNbarClassificationDnsClassifyByDomain.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/Cisco-IOS-XE-nbar:nbar/classification/dns/classify-by-domain-with-default", state.getPath()))
+ if !state.IpRadiusSourceInterfaceVrf.IsNull() && data.IpRadiusSourceInterfaceVrf.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ip/Cisco-IOS-XE-aaa:radius/source-interface/vrf")
}
- for i := range state.TrackObjects {
- stateKeyValues := [...]string{state.TrackObjects[i].Number.ValueString()}
+ for i := range state.BootSystemFlashFiles {
+ stateKeys := [...]string{"flash-leaf"}
+ stateKeyValues := [...]string{state.BootSystemFlashFiles[i].Path.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
emptyKeys := true
- if !reflect.ValueOf(state.TrackObjects[i].Number.ValueString()).IsZero() {
+ if !reflect.ValueOf(state.BootSystemFlashFiles[i].Path.ValueString()).IsZero() {
emptyKeys = false
}
if emptyKeys {
@@ -3172,78 +7115,116 @@ func (data *System) getDeletedItems(ctx context.Context, state System) []string
}
found := false
- for j := range data.TrackObjects {
+ for j := range data.BootSystemFlashFiles {
found = true
- if state.TrackObjects[i].Number.ValueString() != data.TrackObjects[j].Number.ValueString() {
+ if state.BootSystemFlashFiles[i].Path.ValueString() != data.BootSystemFlashFiles[j].Path.ValueString() {
found = false
}
if found {
- if !state.TrackObjects[i].IpSlaReachability.IsNull() && data.TrackObjects[j].IpSlaReachability.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/track/Cisco-IOS-XE-track:tracked-object-v2=%v/ip/sla/reachability", state.getPath(), strings.Join(stateKeyValues[:], ",")))
- }
- if !state.TrackObjects[i].IpSlaNumber.IsNull() && data.TrackObjects[j].IpSlaNumber.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/track/Cisco-IOS-XE-track:tracked-object-v2=%v/ip/sla/number", state.getPath(), strings.Join(stateKeyValues[:], ",")))
- }
break
}
}
if !found {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/track/Cisco-IOS-XE-track:tracked-object-v2=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/boot/system/flash/flash-list-ordered-by-user%v", predicates))
}
}
- if !state.Version.IsNull() && data.Version.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/version", state.getPath()))
- }
- if !state.MultilinkPppBundleName.IsNull() && data.MultilinkPppBundleName.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/multilink/Cisco-IOS-XE-ppp:bundle-name", state.getPath()))
- }
- if !state.TftpSourceInterfaceHundredGigabitEthernet.IsNull() && data.TftpSourceInterfaceHundredGigabitEthernet.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/tftp/source-interface/HundredGigE", state.getPath()))
- }
- if !state.TftpSourceInterfaceFortyGigabitEthernet.IsNull() && data.TftpSourceInterfaceFortyGigabitEthernet.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/tftp/source-interface/FortyGigabitEthernet", state.getPath()))
- }
- if !state.TftpSourceInterfaceTwentyFiveGigabitEthernet.IsNull() && data.TftpSourceInterfaceTwentyFiveGigabitEthernet.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/tftp/source-interface/TwentyFiveGigabitEthernet", state.getPath()))
- }
- if !state.TftpSourceInterfaceTenGigabitEthernet.IsNull() && data.TftpSourceInterfaceTenGigabitEthernet.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/tftp/source-interface/TenGigabitEthernet", state.getPath()))
- }
- if !state.TftpSourceInterfaceFiveGigabitEthernet.IsNull() && data.TftpSourceInterfaceFiveGigabitEthernet.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/tftp/source-interface/FiveGigabitEthernet", state.getPath()))
- }
- if !state.TftpSourceInterfaceTwoGigabitEthernet.IsNull() && data.TftpSourceInterfaceTwoGigabitEthernet.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/tftp/source-interface/TwoGigabitEthernet", state.getPath()))
- }
- if !state.TftpSourceInterfaceVlan.IsNull() && data.TftpSourceInterfaceVlan.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/tftp/source-interface/Vlan", state.getPath()))
- }
- if !state.TftpSourceInterfaceLoopback.IsNull() && data.TftpSourceInterfaceLoopback.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/tftp/source-interface/Loopback", state.getPath()))
- }
- if !state.TftpSourceInterfaceGigabitEthernet.IsNull() && data.TftpSourceInterfaceGigabitEthernet.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/tftp/source-interface/GigabitEthernet", state.getPath()))
- }
- if !state.IpFtpPassive.IsNull() && data.IpFtpPassive.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/ftp/passive-enable", state.getPath()))
- }
- if !state.CallHomeCiscoTac1DestinationTransportMethod.IsNull() && data.CallHomeCiscoTac1DestinationTransportMethod.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/call-home/Cisco-IOS-XE-call-home:tac-profile/profile/CiscoTAC-1/destination/transport-method", state.getPath()))
+ for i := range state.BootSystemBootfiles {
+ stateKeys := [...]string{"filename"}
+ stateKeyValues := [...]string{state.BootSystemBootfiles[i].Path.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.BootSystemBootfiles[i].Path.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.BootSystemBootfiles {
+ found = true
+ if state.BootSystemBootfiles[i].Path.ValueString() != data.BootSystemBootfiles[j].Path.ValueString() {
+ found = false
+ }
+ if found {
+ break
+ }
+ }
+ if !found {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/boot/system/bootfile/filename-list-ordered-by-user%v", predicates))
+ }
}
- if !state.CallHomeCiscoTac1ProfileActive.IsNull() && data.CallHomeCiscoTac1ProfileActive.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/call-home/Cisco-IOS-XE-call-home:tac-profile/profile/CiscoTAC-1/active", state.getPath()))
+ if !state.EnableSecret.IsNull() && data.EnableSecret.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/enable/secret/secret")
}
- if !state.CallHomeContactEmail.IsNull() && data.CallHomeContactEmail.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/call-home/Cisco-IOS-XE-call-home:contact-email-addr", state.getPath()))
+ if !state.EnableSecretType.IsNull() && data.EnableSecretType.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/enable/secret/type")
}
- if !state.SubscriberTemplating.IsNull() && data.SubscriberTemplating.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/subscriber/templating", state.getPath()))
+ if !state.EnableSecretLevel.IsNull() && data.EnableSecretLevel.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/enable/secret/level")
}
- if !state.DiagnosticEventLogSize.IsNull() && data.DiagnosticEventLogSize.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-diagnostics:diagnostic/event-log/size", state.getPath()))
+ for i := range state.IpHosts {
+ stateKeys := [...]string{"name"}
+ stateKeyValues := [...]string{state.IpHosts[i].Name.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.IpHosts[i].Name.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.IpHosts {
+ found = true
+ if state.IpHosts[i].Name.ValueString() != data.IpHosts[j].Name.ValueString() {
+ found = false
+ }
+ if found {
+ if !state.IpHosts[i].Ips.IsNull() {
+ if data.IpHosts[j].Ips.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/ip/host/host-list%v/ip-list-ordered", predicates))
+ } else {
+ var dataValues, stateValues []string
+ data.IpHosts[i].Ips.ElementsAs(ctx, &dataValues, false)
+ state.IpHosts[j].Ips.ElementsAs(ctx, &stateValues, false)
+ for _, v := range stateValues {
+ found := false
+ for _, vv := range dataValues {
+ if v == vv {
+ found = true
+ break
+ }
+ }
+ if !found {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/ip/host/host-list%v/ip-list-ordered[.=%v]", predicates, v))
+ }
+ }
+ }
+ }
+ break
+ }
+ }
+ if !found {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/ip/host/host-list%v", predicates))
+ }
}
for i := range state.IpHostsVrf {
+ stateKeys := [...]string{"vrf-name"}
stateKeyValues := [...]string{state.IpHostsVrf[i].Vrf.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
emptyKeys := true
if !reflect.ValueOf(state.IpHostsVrf[i].Vrf.ValueString()).IsZero() {
@@ -3261,7 +7242,12 @@ func (data *System) getDeletedItems(ctx context.Context, state System) []string
}
if found {
for ci := range state.IpHostsVrf[i].Hosts {
+ cstateKeys := [...]string{"host-name"}
cstateKeyValues := [...]string{state.IpHostsVrf[i].Hosts[ci].Name.ValueString()}
+ cpredicates := ""
+ for i := range cstateKeys {
+ cpredicates += fmt.Sprintf("[%s='%s']", cstateKeys[i], cstateKeyValues[i])
+ }
cemptyKeys := true
if !reflect.ValueOf(state.IpHostsVrf[i].Hosts[ci].Name.ValueString()).IsZero() {
@@ -3280,7 +7266,7 @@ func (data *System) getDeletedItems(ctx context.Context, state System) []string
if found {
if !state.IpHostsVrf[i].Hosts[ci].Ips.IsNull() {
if data.IpHostsVrf[j].Hosts[cj].Ips.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/host/vrf=%v/host-name=%v/ip-list", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/ip/host/vrf%v/host-name%v/ip-list", predicates, cpredicates))
} else {
var dataValues, stateValues []string
data.IpHostsVrf[i].Hosts[ci].Ips.ElementsAs(ctx, &dataValues, false)
@@ -3294,7 +7280,7 @@ func (data *System) getDeletedItems(ctx context.Context, state System) []string
}
}
if !found {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/host/vrf=%v/host-name=%v/ip-list=%v", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ","), v))
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/ip/host/vrf%v/host-name%v/ip-list=[.%v]", predicates, cpredicates, v))
}
}
}
@@ -3303,76 +7289,77 @@ func (data *System) getDeletedItems(ctx context.Context, state System) []string
}
}
if !found {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/host/vrf=%v/host-name=%v", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ",")))
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/ip/host/vrf%v/host-name%v", predicates, cpredicates))
}
}
break
}
}
if !found {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/host/vrf=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/ip/host/vrf%v", predicates))
}
}
- for i := range state.IpHosts {
- stateKeyValues := [...]string{state.IpHosts[i].Name.ValueString()}
-
- emptyKeys := true
- if !reflect.ValueOf(state.IpHosts[i].Name.ValueString()).IsZero() {
- emptyKeys = false
- }
- if emptyKeys {
- continue
- }
-
- found := false
- for j := range data.IpHosts {
- found = true
- if state.IpHosts[i].Name.ValueString() != data.IpHosts[j].Name.ValueString() {
- found = false
- }
- if found {
- if !state.IpHosts[i].Ips.IsNull() {
- if data.IpHosts[j].Ips.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/host/host-list=%v/ip-list-ordered", state.getPath(), strings.Join(stateKeyValues[:], ",")))
- } else {
- var dataValues, stateValues []string
- data.IpHosts[i].Ips.ElementsAs(ctx, &dataValues, false)
- state.IpHosts[j].Ips.ElementsAs(ctx, &stateValues, false)
- for _, v := range stateValues {
- found := false
- for _, vv := range dataValues {
- if v == vv {
- found = true
- break
- }
- }
- if !found {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/host/host-list=%v/ip-list-ordered=%v", state.getPath(), strings.Join(stateKeyValues[:], ","), v))
- }
- }
- }
- }
- break
- }
- }
- if !found {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/host/host-list=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
- }
+ if !state.DiagnosticEventLogSize.IsNull() && data.DiagnosticEventLogSize.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-diagnostics:diagnostic/event-log/size")
}
- if !state.EnableSecretLevel.IsNull() && data.EnableSecretLevel.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/enable/secret/level", state.getPath()))
+ if !state.SubscriberTemplating.IsNull() && data.SubscriberTemplating.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/subscriber/templating")
}
- if !state.EnableSecretType.IsNull() && data.EnableSecretType.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/enable/secret/type", state.getPath()))
+ if !state.CallHomeContactEmail.IsNull() && data.CallHomeContactEmail.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/call-home/Cisco-IOS-XE-call-home:contact-email-addr")
}
- if !state.EnableSecret.IsNull() && data.EnableSecret.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/enable/secret", state.getPath()))
+ if !state.CallHomeCiscoTac1ProfileActive.IsNull() && data.CallHomeCiscoTac1ProfileActive.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/call-home/Cisco-IOS-XE-call-home:tac-profile/profile/CiscoTAC-1/active")
}
- for i := range state.BootSystemBootfiles {
- stateKeyValues := [...]string{state.BootSystemBootfiles[i].Path.ValueString()}
+ if !state.CallHomeCiscoTac1DestinationTransportMethod.IsNull() && data.CallHomeCiscoTac1DestinationTransportMethod.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/call-home/Cisco-IOS-XE-call-home:tac-profile/profile/CiscoTAC-1/destination/transport-method")
+ }
+ if !state.IpFtpPassive.IsNull() && data.IpFtpPassive.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ip/ftp/passive-enable")
+ }
+ if !state.TftpSourceInterfaceGigabitEthernet.IsNull() && data.TftpSourceInterfaceGigabitEthernet.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ip/tftp/source-interface/GigabitEthernet")
+ }
+ if !state.TftpSourceInterfaceLoopback.IsNull() && data.TftpSourceInterfaceLoopback.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ip/tftp/source-interface/Loopback")
+ }
+ if !state.TftpSourceInterfaceVlan.IsNull() && data.TftpSourceInterfaceVlan.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ip/tftp/source-interface/Vlan")
+ }
+ if !state.TftpSourceInterfaceTwoGigabitEthernet.IsNull() && data.TftpSourceInterfaceTwoGigabitEthernet.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ip/tftp/source-interface/TwoGigabitEthernet")
+ }
+ if !state.TftpSourceInterfaceFiveGigabitEthernet.IsNull() && data.TftpSourceInterfaceFiveGigabitEthernet.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ip/tftp/source-interface/FiveGigabitEthernet")
+ }
+ if !state.TftpSourceInterfaceTenGigabitEthernet.IsNull() && data.TftpSourceInterfaceTenGigabitEthernet.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ip/tftp/source-interface/TenGigabitEthernet")
+ }
+ if !state.TftpSourceInterfaceTwentyFiveGigabitEthernet.IsNull() && data.TftpSourceInterfaceTwentyFiveGigabitEthernet.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ip/tftp/source-interface/TwentyFiveGigabitEthernet")
+ }
+ if !state.TftpSourceInterfaceFortyGigabitEthernet.IsNull() && data.TftpSourceInterfaceFortyGigabitEthernet.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ip/tftp/source-interface/FortyGigabitEthernet")
+ }
+ if !state.TftpSourceInterfaceHundredGigabitEthernet.IsNull() && data.TftpSourceInterfaceHundredGigabitEthernet.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ip/tftp/source-interface/HundredGigE")
+ }
+ if !state.MultilinkPppBundleName.IsNull() && data.MultilinkPppBundleName.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/multilink/Cisco-IOS-XE-ppp:bundle-name")
+ }
+ if !state.Version.IsNull() && data.Version.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/version")
+ }
+ for i := range state.TrackObjects {
+ stateKeys := [...]string{"object-number"}
+ stateKeyValues := [...]string{state.TrackObjects[i].Number.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
emptyKeys := true
- if !reflect.ValueOf(state.BootSystemBootfiles[i].Path.ValueString()).IsZero() {
+ if !reflect.ValueOf(state.TrackObjects[i].Number.ValueString()).IsZero() {
emptyKeys = false
}
if emptyKeys {
@@ -3380,969 +7367,1037 @@ func (data *System) getDeletedItems(ctx context.Context, state System) []string
}
found := false
- for j := range data.BootSystemBootfiles {
+ for j := range data.TrackObjects {
found = true
- if state.BootSystemBootfiles[i].Path.ValueString() != data.BootSystemBootfiles[j].Path.ValueString() {
+ if state.TrackObjects[i].Number.ValueString() != data.TrackObjects[j].Number.ValueString() {
found = false
}
if found {
+ if !state.TrackObjects[i].IpSlaNumber.IsNull() && data.TrackObjects[j].IpSlaNumber.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/track/Cisco-IOS-XE-track:tracked-object-v2%v/ip/sla/number", predicates))
+ }
+ if !state.TrackObjects[i].IpSlaReachability.IsNull() && data.TrackObjects[j].IpSlaReachability.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/track/Cisco-IOS-XE-track:tracked-object-v2%v/ip/sla/reachability", predicates))
+ }
break
}
}
if !found {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/boot/system/bootfile/filename-list-ordered-by-user=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/track/Cisco-IOS-XE-track:tracked-object-v2%v", predicates))
}
}
- for i := range state.BootSystemFlashFiles {
- stateKeyValues := [...]string{state.BootSystemFlashFiles[i].Path.ValueString()}
-
- emptyKeys := true
- if !reflect.ValueOf(state.BootSystemFlashFiles[i].Path.ValueString()).IsZero() {
- emptyKeys = false
- }
- if emptyKeys {
- continue
+ if !state.IpNbarClassificationDnsClassifyByDomain.IsNull() && data.IpNbarClassificationDnsClassifyByDomain.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ip/Cisco-IOS-XE-nbar:nbar/classification/dns/classify-by-domain-with-default")
+ }
+ if !state.IpMulticastRouteLimit.IsNull() && data.IpMulticastRouteLimit.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ip/multicast/Cisco-IOS-XE-multicast:route-limit-container/routelimit")
+ }
+ if !state.SecurityPasswordsMinLength.IsNull() && data.SecurityPasswordsMinLength.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-aaa:security/passwords/min-length")
+ }
+ if !state.IpDomainListNames.IsNull() {
+ if data.IpDomainListNames.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ip/domain/list/domain-name")
+ } else {
+ var dataValues, stateValues []string
+ data.IpDomainListNames.ElementsAs(ctx, &dataValues, false)
+ state.IpDomainListNames.ElementsAs(ctx, &stateValues, false)
+ for _, v := range stateValues {
+ found := false
+ for _, vv := range dataValues {
+ if v == vv {
+ found = true
+ break
+ }
+ }
+ if !found {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/ip/domain/list/domain-name[.=%v]", v))
+ }
+ }
}
+ }
+ if !state.IpDomainListVrfDomain.IsNull() && data.IpDomainListVrfDomain.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ip/domain/list/vrf/domain-name")
+ }
+ if !state.IpDomainListVrf.IsNull() && data.IpDomainListVrf.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ip/domain/list/vrf/vrf-name")
+ }
+ if !state.EthernetCfmAlarmConfigDelay.IsNull() && data.EthernetCfmAlarmConfigDelay.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ethernet/Cisco-IOS-XE-ethernet:cfm/alarm-config/delay")
+ }
+ if !state.EthernetCfmAlarmConfigReset.IsNull() && data.EthernetCfmAlarmConfigReset.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ethernet/Cisco-IOS-XE-ethernet:cfm/alarm-config/reset")
+ }
+ if !state.StandbyRedirects.IsNull() && data.StandbyRedirects.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/standby/redirects-config/redirects")
+ }
+ if !state.StandbyRedirectsEnableDisable.IsNull() && data.StandbyRedirectsEnableDisable.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/standby/redirects-config/redirect-enable-disable/redirects")
+ }
- found := false
- for j := range data.BootSystemFlashFiles {
- found = true
- if state.BootSystemFlashFiles[i].Path.ValueString() != data.BootSystemFlashFiles[j].Path.ValueString() {
- found = false
- }
- if found {
- break
- }
+ return b.Res()
+}
+
+// End of section. //template:end addDeletedItemsXML
+
+// Section below is generated&owned by "gen/generator.go". //template:begin getEmptyLeafsDelete
+
+func (data *System) getEmptyLeafsDelete(ctx context.Context) []string {
+ emptyLeafsDelete := make([]string, 0)
+
+ for i := range data.TrackObjects {
+ keyValues := [...]string{data.TrackObjects[i].Number.ValueString()}
+ if !data.TrackObjects[i].IpSlaReachability.IsNull() && !data.TrackObjects[i].IpSlaReachability.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/track/Cisco-IOS-XE-track:tracked-object-v2=%v/ip/sla/reachability", data.getPath(), strings.Join(keyValues[:], ",")))
}
- if !found {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/boot/system/flash/flash-list-ordered-by-user=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ if !data.SubscriberTemplating.IsNull() && !data.SubscriberTemplating.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/subscriber/templating", data.getPath()))
+ }
+
+ if !data.IpScpServerEnable.IsNull() && !data.IpScpServerEnable.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/ip/scp/server/enable", data.getPath()))
+ }
+ if !data.TransceiverTypeAllMonitoring.IsNull() && !data.TransceiverTypeAllMonitoring.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/transceivers/type/all/monitoring-enable/monitoring", data.getPath()))
+ }
+ if !data.Redundancy.IsNull() && !data.Redundancy.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/redundancy", data.getPath()))
+ }
+ if !data.ArchiveLogConfigLoggingEnable.IsNull() && !data.ArchiveLogConfigLoggingEnable.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/archive/log/config/logging/enable", data.getPath()))
+ }
+ if !data.ArchiveWriteMemory.IsNull() && !data.ArchiveWriteMemory.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/archive/write-memory", data.getPath()))
+ }
+ if !data.AccessSessionMacMoveDeny.IsNull() && !data.AccessSessionMacMoveDeny.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-sanet:access-session/mac-move/deny", data.getPath()))
+ }
+ if !data.EpmLogging.IsNull() && !data.EpmLogging.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/epm/logging", data.getPath()))
+ }
+ if !data.CispEnable.IsNull() && !data.CispEnable.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/cisp/enable", data.getPath()))
+ }
+
+ if !data.IpHttpAuthenticationLocal.IsNull() && !data.IpHttpAuthenticationLocal.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/ip/Cisco-IOS-XE-http:http/authentication/local", data.getPath()))
+ }
+
+ if !data.IpHttpAuthenticationAaa.IsNull() && !data.IpHttpAuthenticationAaa.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/ip/Cisco-IOS-XE-http:http/authentication/aaa", data.getPath()))
+ }
+
+ for i := range data.MulticastRoutingVrfs {
+ keyValues := [...]string{data.MulticastRoutingVrfs[i].Vrf.ValueString()}
+ if !data.MulticastRoutingVrfs[i].Distributed.IsNull() && !data.MulticastRoutingVrfs[i].Distributed.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/ip/Cisco-IOS-XE-multicast:multicast-routing/vrf=%v/distributed", data.getPath(), strings.Join(keyValues[:], ",")))
}
}
- if !state.IpRadiusSourceInterfaceVrf.IsNull() && data.IpRadiusSourceInterfaceVrf.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/Cisco-IOS-XE-aaa:radius/source-interface/vrf", state.getPath()))
+ if !data.IpMulticastRoutingDistributed.IsNull() && !data.IpMulticastRoutingDistributed.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/ip/Cisco-IOS-XE-multicast:multicast-routing/distributed", data.getPath()))
}
- if !state.IpRadiusSourceInterfaceHundredGigabitEthernet.IsNull() && data.IpRadiusSourceInterfaceHundredGigabitEthernet.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/Cisco-IOS-XE-aaa:radius/source-interface/HundredGigE", state.getPath()))
+ if !data.MulticastRoutingSwitch.IsNull() && !data.MulticastRoutingSwitch.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/ip/Cisco-IOS-XE-multicast:mcr-conf/multicast-routing", data.getPath()))
}
- if !state.IpRadiusSourceInterfaceFortyGigabitEthernet.IsNull() && data.IpRadiusSourceInterfaceFortyGigabitEthernet.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/Cisco-IOS-XE-aaa:radius/source-interface/FortyGigabitEthernet", state.getPath()))
+ if !data.IpMulticastRouting.IsNull() && !data.IpMulticastRouting.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/ip/Cisco-IOS-XE-multicast:multicast-routing", data.getPath()))
}
- if !state.IpRadiusSourceInterfaceTwentyFiveGigabitEthernet.IsNull() && data.IpRadiusSourceInterfaceTwentyFiveGigabitEthernet.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/Cisco-IOS-XE-aaa:radius/source-interface/TwentyFiveGigE", state.getPath()))
+ if !data.LoginOnSuccessLog.IsNull() && !data.LoginOnSuccessLog.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/login/on-success/log", data.getPath()))
}
- if !state.IpRadiusSourceInterfaceTenGigabitEthernet.IsNull() && data.IpRadiusSourceInterfaceTenGigabitEthernet.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/Cisco-IOS-XE-aaa:radius/source-interface/TenGigabitEthernet", state.getPath()))
+ if !data.LoginOnSuccess.IsNull() && !data.LoginOnSuccess.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/login/on-success", data.getPath()))
}
- if !state.IpRadiusSourceInterfaceFiveGigabitEthernet.IsNull() && data.IpRadiusSourceInterfaceFiveGigabitEthernet.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/Cisco-IOS-XE-aaa:radius/source-interface/FiveGigabitEthernet", state.getPath()))
+ if !data.LoginOnFailureLog.IsNull() && !data.LoginOnFailureLog.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/login/on-failure/log", data.getPath()))
}
- if !state.IpRadiusSourceInterfaceTwoGigabitEthernet.IsNull() && data.IpRadiusSourceInterfaceTwoGigabitEthernet.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/Cisco-IOS-XE-aaa:radius/source-interface/TwoGigabitEthernet", state.getPath()))
+ if !data.LoginOnFailure.IsNull() && !data.LoginOnFailure.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/login/on-failure", data.getPath()))
}
- if !state.IpRadiusSourceInterfaceGigabitEthernet.IsNull() && data.IpRadiusSourceInterfaceGigabitEthernet.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/Cisco-IOS-XE-aaa:radius/source-interface/GigabitEthernet", state.getPath()))
+ if !data.Ipv6UnicastRouting.IsNull() && !data.Ipv6UnicastRouting.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/ipv6/unicast-routing", data.getPath()))
}
- if !state.IpRadiusSourceInterfaceVlan.IsNull() && data.IpRadiusSourceInterfaceVlan.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/Cisco-IOS-XE-aaa:radius/source-interface/Vlan", state.getPath()))
+ if !data.IpBgpCommunityNewFormat.IsNull() && !data.IpBgpCommunityNewFormat.ValueBool() {
+ emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/ip/bgp-community/new-format", data.getPath()))
}
- if !state.IpRadiusSourceInterfaceLoopback.IsNull() && data.IpRadiusSourceInterfaceLoopback.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/Cisco-IOS-XE-aaa:radius/source-interface/Loopback", state.getPath()))
+
+ return emptyLeafsDelete
+}
+
+// End of section. //template:end getEmptyLeafsDelete
+
+// Section below is generated&owned by "gen/generator.go". //template:begin getDeletePaths
+
+func (data *System) getDeletePaths(ctx context.Context) []string {
+ var deletePaths []string
+ if !data.StandbyRedirectsEnableDisable.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/standby/redirects-config/redirect-enable-disable/redirects", data.getPath()))
}
- if !state.IpTacacsSourceInterfaceVrf.IsNull() && data.IpTacacsSourceInterfaceVrf.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/Cisco-IOS-XE-aaa:tacacs/source-interface/vrf", state.getPath()))
+ if !data.StandbyRedirects.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/standby/redirects-config/redirects", data.getPath()))
}
- if !state.IpTacacsSourceInterfaceHundredGigabitEthernet.IsNull() && data.IpTacacsSourceInterfaceHundredGigabitEthernet.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/Cisco-IOS-XE-aaa:tacacs/source-interface/HundredGigE", state.getPath()))
+ if !data.EthernetCfmAlarmConfigReset.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/ethernet/Cisco-IOS-XE-ethernet:cfm/alarm-config/reset", data.getPath()))
}
- if !state.IpTacacsSourceInterfaceFortyGigabitEthernet.IsNull() && data.IpTacacsSourceInterfaceFortyGigabitEthernet.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/Cisco-IOS-XE-aaa:tacacs/source-interface/FortyGigabitEthernet", state.getPath()))
+ if !data.EthernetCfmAlarmConfigDelay.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/ethernet/Cisco-IOS-XE-ethernet:cfm/alarm-config/delay", data.getPath()))
}
- if !state.IpTacacsSourceInterfaceTwentyFiveGigabitEthernet.IsNull() && data.IpTacacsSourceInterfaceTwentyFiveGigabitEthernet.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/Cisco-IOS-XE-aaa:tacacs/source-interface/TwentyFiveGigE", state.getPath()))
+ if !data.IpDomainListVrf.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/domain/list/vrf/vrf-name", data.getPath()))
}
- if !state.IpTacacsSourceInterfaceTenGigabitEthernet.IsNull() && data.IpTacacsSourceInterfaceTenGigabitEthernet.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/Cisco-IOS-XE-aaa:tacacs/source-interface/TenGigabitEthernet", state.getPath()))
+ if !data.IpDomainListVrfDomain.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/domain/list/vrf/domain-name", data.getPath()))
}
- if !state.IpTacacsSourceInterfaceFiveGigabitEthernet.IsNull() && data.IpTacacsSourceInterfaceFiveGigabitEthernet.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/Cisco-IOS-XE-aaa:tacacs/source-interface/FiveGigabitEthernet", state.getPath()))
+ if !data.IpDomainListNames.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/domain/list/domain-name", data.getPath()))
}
- if !state.IpTacacsSourceInterfaceTwoGigabitEthernet.IsNull() && data.IpTacacsSourceInterfaceTwoGigabitEthernet.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/Cisco-IOS-XE-aaa:tacacs/source-interface/TwoGigabitEthernet", state.getPath()))
+ if !data.SecurityPasswordsMinLength.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-aaa:security/passwords/min-length", data.getPath()))
}
- if !state.IpTacacsSourceInterfaceGigabitEthernet.IsNull() && data.IpTacacsSourceInterfaceGigabitEthernet.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/Cisco-IOS-XE-aaa:tacacs/source-interface/GigabitEthernet", state.getPath()))
+ if !data.IpMulticastRouteLimit.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/multicast/Cisco-IOS-XE-multicast:route-limit-container/routelimit", data.getPath()))
+ }
+ if !data.IpNbarClassificationDnsClassifyByDomain.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/Cisco-IOS-XE-nbar:nbar/classification/dns/classify-by-domain-with-default", data.getPath()))
+ }
+ for i := range data.TrackObjects {
+ keyValues := [...]string{data.TrackObjects[i].Number.ValueString()}
+
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/track/Cisco-IOS-XE-track:tracked-object-v2=%v", data.getPath(), strings.Join(keyValues[:], ",")))
+ }
+ if !data.Version.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/version", data.getPath()))
+ }
+ if !data.MultilinkPppBundleName.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/multilink/Cisco-IOS-XE-ppp:bundle-name", data.getPath()))
+ }
+ if !data.TftpSourceInterfaceHundredGigabitEthernet.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/tftp/source-interface/HundredGigE", data.getPath()))
+ }
+ if !data.TftpSourceInterfaceFortyGigabitEthernet.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/tftp/source-interface/FortyGigabitEthernet", data.getPath()))
+ }
+ if !data.TftpSourceInterfaceTwentyFiveGigabitEthernet.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/tftp/source-interface/TwentyFiveGigabitEthernet", data.getPath()))
+ }
+ if !data.TftpSourceInterfaceTenGigabitEthernet.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/tftp/source-interface/TenGigabitEthernet", data.getPath()))
+ }
+ if !data.TftpSourceInterfaceFiveGigabitEthernet.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/tftp/source-interface/FiveGigabitEthernet", data.getPath()))
+ }
+ if !data.TftpSourceInterfaceTwoGigabitEthernet.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/tftp/source-interface/TwoGigabitEthernet", data.getPath()))
+ }
+ if !data.TftpSourceInterfaceVlan.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/tftp/source-interface/Vlan", data.getPath()))
+ }
+ if !data.TftpSourceInterfaceLoopback.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/tftp/source-interface/Loopback", data.getPath()))
+ }
+ if !data.TftpSourceInterfaceGigabitEthernet.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/tftp/source-interface/GigabitEthernet", data.getPath()))
+ }
+ if !data.IpFtpPassive.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/ftp/passive-enable", data.getPath()))
+ }
+ if !data.CallHomeCiscoTac1DestinationTransportMethod.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/call-home/Cisco-IOS-XE-call-home:tac-profile/profile/CiscoTAC-1/destination/transport-method", data.getPath()))
+ }
+ if !data.CallHomeCiscoTac1ProfileActive.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/call-home/Cisco-IOS-XE-call-home:tac-profile/profile/CiscoTAC-1/active", data.getPath()))
}
- if !state.IpTacacsSourceInterfaceVlan.IsNull() && data.IpTacacsSourceInterfaceVlan.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/Cisco-IOS-XE-aaa:tacacs/source-interface/Vlan", state.getPath()))
+ if !data.CallHomeContactEmail.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/call-home/Cisco-IOS-XE-call-home:contact-email-addr", data.getPath()))
}
- if !state.IpTacacsSourceInterfaceLoopback.IsNull() && data.IpTacacsSourceInterfaceLoopback.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/Cisco-IOS-XE-aaa:tacacs/source-interface/Loopback", state.getPath()))
+ if !data.SubscriberTemplating.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/subscriber/templating", data.getPath()))
}
- for i := range state.PnpProfiles {
- stateKeyValues := [...]string{state.PnpProfiles[i].Name.ValueString()}
+ if !data.DiagnosticEventLogSize.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-diagnostics:diagnostic/event-log/size", data.getPath()))
+ }
+ for i := range data.IpHostsVrf {
+ keyValues := [...]string{data.IpHostsVrf[i].Vrf.ValueString()}
- emptyKeys := true
- if !reflect.ValueOf(state.PnpProfiles[i].Name.ValueString()).IsZero() {
- emptyKeys = false
- }
- if emptyKeys {
- continue
- }
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/host/vrf=%v", data.getPath(), strings.Join(keyValues[:], ",")))
+ }
+ for i := range data.IpHosts {
+ keyValues := [...]string{data.IpHosts[i].Name.ValueString()}
- found := false
- for j := range data.PnpProfiles {
- found = true
- if state.PnpProfiles[i].Name.ValueString() != data.PnpProfiles[j].Name.ValueString() {
- found = false
- }
- if found {
- if !state.PnpProfiles[i].TransportHttpsIpv4Port.IsNull() && data.PnpProfiles[j].TransportHttpsIpv4Port.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-pnp:pnp/profile=%v/transport/https/ipv4/port", state.getPath(), strings.Join(stateKeyValues[:], ",")))
- }
- if !state.PnpProfiles[i].TransportHttpsIpv4Ipv4Address.IsNull() && data.PnpProfiles[j].TransportHttpsIpv4Ipv4Address.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-pnp:pnp/profile=%v/transport/https/ipv4/ipv4-address", state.getPath(), strings.Join(stateKeyValues[:], ",")))
- }
- break
- }
- }
- if !found {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-pnp:pnp/profile=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
- }
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/host/host-list=%v", data.getPath(), strings.Join(keyValues[:], ",")))
}
- if !state.ControlPlaneServicePolicyInput.IsNull() && data.ControlPlaneServicePolicyInput.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/control-plane/Cisco-IOS-XE-policy:service-policy/input", state.getPath()))
+ if !data.EnableSecretLevel.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/enable/secret/level", data.getPath()))
}
- if !state.IpSshSourceInterfaceHundredGigabitEthernet.IsNull() && data.IpSshSourceInterfaceHundredGigabitEthernet.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/ssh/source-interface-config/HundredGigE", state.getPath()))
+ if !data.EnableSecretType.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/enable/secret/type", data.getPath()))
}
- if !state.IpSshSourceInterfaceFortyGigabitEthernet.IsNull() && data.IpSshSourceInterfaceFortyGigabitEthernet.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/ssh/source-interface-config/FortyGigabitEthernet", state.getPath()))
+ if !data.EnableSecret.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/enable/secret", data.getPath()))
}
- if !state.IpSshSourceInterfaceTwentyFiveGigabitEthernet.IsNull() && data.IpSshSourceInterfaceTwentyFiveGigabitEthernet.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/ssh/source-interface-config/TwentyFiveGigE", state.getPath()))
+ for i := range data.BootSystemBootfiles {
+ keyValues := [...]string{data.BootSystemBootfiles[i].Path.ValueString()}
+
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/boot/system/bootfile/filename-list-ordered-by-user=%v", data.getPath(), strings.Join(keyValues[:], ",")))
}
- if !state.IpSshSourceInterfaceTenGigabitEthernet.IsNull() && data.IpSshSourceInterfaceTenGigabitEthernet.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/ssh/source-interface-config/TenGigabitEthernet", state.getPath()))
+ for i := range data.BootSystemFlashFiles {
+ keyValues := [...]string{data.BootSystemFlashFiles[i].Path.ValueString()}
+
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/boot/system/flash/flash-list-ordered-by-user=%v", data.getPath(), strings.Join(keyValues[:], ",")))
}
- if !state.IpSshSourceInterfaceFiveGigabitEthernet.IsNull() && data.IpSshSourceInterfaceFiveGigabitEthernet.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/ssh/source-interface-config/FiveGigabitEthernet", state.getPath()))
+ if !data.IpRadiusSourceInterfaceVrf.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/Cisco-IOS-XE-aaa:radius/source-interface/vrf", data.getPath()))
}
- if !state.IpSshSourceInterfaceTwoGigabitEthernet.IsNull() && data.IpSshSourceInterfaceTwoGigabitEthernet.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/ssh/source-interface-config/TwoGigabitEthernet", state.getPath()))
+ if !data.IpRadiusSourceInterfaceHundredGigabitEthernet.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/Cisco-IOS-XE-aaa:radius/source-interface/HundredGigE", data.getPath()))
}
- if !state.IpSshSourceInterfaceGigabitEthernet.IsNull() && data.IpSshSourceInterfaceGigabitEthernet.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/ssh/source-interface-config/GigabitEthernet", state.getPath()))
+ if !data.IpRadiusSourceInterfaceFortyGigabitEthernet.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/Cisco-IOS-XE-aaa:radius/source-interface/FortyGigabitEthernet", data.getPath()))
}
- if !state.IpSshSourceInterfaceVlan.IsNull() && data.IpSshSourceInterfaceVlan.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/ssh/source-interface-config/Vlan", state.getPath()))
+ if !data.IpRadiusSourceInterfaceTwentyFiveGigabitEthernet.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/Cisco-IOS-XE-aaa:radius/source-interface/TwentyFiveGigE", data.getPath()))
}
- if !state.IpSshSourceInterfaceLoopback.IsNull() && data.IpSshSourceInterfaceLoopback.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/ssh/source-interface-config/Loopback", state.getPath()))
+ if !data.IpRadiusSourceInterfaceTenGigabitEthernet.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/Cisco-IOS-XE-aaa:radius/source-interface/TenGigabitEthernet", data.getPath()))
}
- if !state.IpSshAuthenticationRetries.IsNull() && data.IpSshAuthenticationRetries.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/ssh/authentication-retries", state.getPath()))
+ if !data.IpRadiusSourceInterfaceFiveGigabitEthernet.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/Cisco-IOS-XE-aaa:radius/source-interface/FiveGigabitEthernet", data.getPath()))
}
- if !state.IpSshTimeOut.IsNull() && data.IpSshTimeOut.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/ssh/time-out", state.getPath()))
+ if !data.IpRadiusSourceInterfaceTwoGigabitEthernet.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/Cisco-IOS-XE-aaa:radius/source-interface/TwoGigabitEthernet", data.getPath()))
}
- if !state.IpSshVersionLegacy.IsNull() && data.IpSshVersionLegacy.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/ssh/version", state.getPath()))
+ if !data.IpRadiusSourceInterfaceGigabitEthernet.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/Cisco-IOS-XE-aaa:radius/source-interface/GigabitEthernet", data.getPath()))
}
- if !state.IpSshVersion.IsNull() && data.IpSshVersion.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/ssh/ssh-version", state.getPath()))
+ if !data.IpRadiusSourceInterfaceVlan.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/Cisco-IOS-XE-aaa:radius/source-interface/Vlan", data.getPath()))
}
- if !state.IpScpServerEnable.IsNull() && data.IpScpServerEnable.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/scp/server/enable", state.getPath()))
+ if !data.IpRadiusSourceInterfaceLoopback.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/Cisco-IOS-XE-aaa:radius/source-interface/Loopback", data.getPath()))
}
- if !state.IpForwardProtocolNd.IsNull() && data.IpForwardProtocolNd.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/forward-protocol-v2/nd", state.getPath()))
+ if !data.IpTacacsSourceInterfaceVrf.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/Cisco-IOS-XE-aaa:tacacs/source-interface/vrf", data.getPath()))
}
- if !state.TransceiverTypeAllMonitoring.IsNull() && data.TransceiverTypeAllMonitoring.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/transceivers/type/all/monitoring-enable/monitoring", state.getPath()))
+ if !data.IpTacacsSourceInterfaceHundredGigabitEthernet.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/Cisco-IOS-XE-aaa:tacacs/source-interface/HundredGigE", data.getPath()))
}
- if !state.RedundancyMode.IsNull() && data.RedundancyMode.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/redundancy/mode", state.getPath()))
+ if !data.IpTacacsSourceInterfaceFortyGigabitEthernet.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/Cisco-IOS-XE-aaa:tacacs/source-interface/FortyGigabitEthernet", data.getPath()))
}
- if !state.Redundancy.IsNull() && data.Redundancy.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/redundancy", state.getPath()))
+ if !data.IpTacacsSourceInterfaceTwentyFiveGigabitEthernet.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/Cisco-IOS-XE-aaa:tacacs/source-interface/TwentyFiveGigE", data.getPath()))
}
- if !state.ArchiveLogConfigLoggingSize.IsNull() && data.ArchiveLogConfigLoggingSize.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/archive/log/config/logging/size", state.getPath()))
+ if !data.IpTacacsSourceInterfaceTenGigabitEthernet.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/Cisco-IOS-XE-aaa:tacacs/source-interface/TenGigabitEthernet", data.getPath()))
}
- if !state.ArchiveLogConfigLoggingEnable.IsNull() && data.ArchiveLogConfigLoggingEnable.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/archive/log/config/logging/enable", state.getPath()))
+ if !data.IpTacacsSourceInterfaceFiveGigabitEthernet.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/Cisco-IOS-XE-aaa:tacacs/source-interface/FiveGigabitEthernet", data.getPath()))
}
- if !state.ArchiveTimePeriod.IsNull() && data.ArchiveTimePeriod.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/archive/time-period", state.getPath()))
+ if !data.IpTacacsSourceInterfaceTwoGigabitEthernet.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/Cisco-IOS-XE-aaa:tacacs/source-interface/TwoGigabitEthernet", data.getPath()))
}
- if !state.ArchiveWriteMemory.IsNull() && data.ArchiveWriteMemory.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/archive/write-memory", state.getPath()))
+ if !data.IpTacacsSourceInterfaceGigabitEthernet.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/Cisco-IOS-XE-aaa:tacacs/source-interface/GigabitEthernet", data.getPath()))
}
- if !state.ArchiveMaximum.IsNull() && data.ArchiveMaximum.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/archive/maximum", state.getPath()))
+ if !data.IpTacacsSourceInterfaceVlan.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/Cisco-IOS-XE-aaa:tacacs/source-interface/Vlan", data.getPath()))
}
- if !state.ArchivePath.IsNull() && data.ArchivePath.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/archive/path", state.getPath()))
+ if !data.IpTacacsSourceInterfaceLoopback.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/Cisco-IOS-XE-aaa:tacacs/source-interface/Loopback", data.getPath()))
}
- if !state.MemoryFreeLowWatermarkProcessor.IsNull() && data.MemoryFreeLowWatermarkProcessor.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/memory/free/low-watermark/processor", state.getPath()))
+ for i := range data.PnpProfiles {
+ keyValues := [...]string{data.PnpProfiles[i].Name.ValueString()}
+
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-pnp:pnp/profile=%v", data.getPath(), strings.Join(keyValues[:], ",")))
}
- if !state.DiagnosticBootupLevel.IsNull() && data.DiagnosticBootupLevel.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-diagnostics:diagnostic/bootup/level", state.getPath()))
+ if !data.ControlPlaneServicePolicyInput.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/control-plane/Cisco-IOS-XE-policy:service-policy/input", data.getPath()))
}
- if !state.AccessSessionMacMoveDeny.IsNull() && data.AccessSessionMacMoveDeny.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/Cisco-IOS-XE-sanet:access-session/mac-move/deny", state.getPath()))
+ if !data.IpSshSourceInterfaceHundredGigabitEthernet.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/ssh/source-interface-config/HundredGigE", data.getPath()))
}
- if !state.EpmLogging.IsNull() && data.EpmLogging.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/epm/logging", state.getPath()))
+ if !data.IpSshSourceInterfaceFortyGigabitEthernet.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/ssh/source-interface-config/FortyGigabitEthernet", data.getPath()))
}
- if !state.CispEnable.IsNull() && data.CispEnable.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/cisp/enable", state.getPath()))
+ if !data.IpSshSourceInterfaceTwentyFiveGigabitEthernet.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/ssh/source-interface-config/TwentyFiveGigE", data.getPath()))
}
- if !state.IpDomainLookupSourceInterfaceHundredGigabitEthernet.IsNull() && data.IpDomainLookupSourceInterfaceHundredGigabitEthernet.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/domain/lookup-settings/lookup/source-interface/HundredGigE", state.getPath()))
+ if !data.IpSshSourceInterfaceTenGigabitEthernet.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/ssh/source-interface-config/TenGigabitEthernet", data.getPath()))
}
- if !state.IpDomainLookupSourceInterfaceFortyGigabitEthernet.IsNull() && data.IpDomainLookupSourceInterfaceFortyGigabitEthernet.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/domain/lookup-settings/lookup/source-interface/FortyGigabitEthernet", state.getPath()))
+ if !data.IpSshSourceInterfaceFiveGigabitEthernet.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/ssh/source-interface-config/FiveGigabitEthernet", data.getPath()))
}
- if !state.IpDomainLookupSourceInterfaceTwentyFiveGigabitEthernet.IsNull() && data.IpDomainLookupSourceInterfaceTwentyFiveGigabitEthernet.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/domain/lookup-settings/lookup/source-interface/TwentyFiveGigE", state.getPath()))
+ if !data.IpSshSourceInterfaceTwoGigabitEthernet.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/ssh/source-interface-config/TwoGigabitEthernet", data.getPath()))
}
- if !state.IpDomainLookupSourceInterfaceTenGigabitEthernet.IsNull() && data.IpDomainLookupSourceInterfaceTenGigabitEthernet.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/domain/lookup-settings/lookup/source-interface/TenGigabitEthernet", state.getPath()))
+ if !data.IpSshSourceInterfaceGigabitEthernet.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/ssh/source-interface-config/GigabitEthernet", data.getPath()))
}
- if !state.IpDomainLookupSourceInterfaceFiveGigabitEthernet.IsNull() && data.IpDomainLookupSourceInterfaceFiveGigabitEthernet.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/domain/lookup-settings/lookup/source-interface/FiveGigabitEthernet", state.getPath()))
+ if !data.IpSshSourceInterfaceVlan.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/ssh/source-interface-config/Vlan", data.getPath()))
}
- if !state.IpDomainLookupSourceInterfaceTwoGigabitEthernet.IsNull() && data.IpDomainLookupSourceInterfaceTwoGigabitEthernet.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/domain/lookup-settings/lookup/source-interface/TwoGigabitEthernet", state.getPath()))
+ if !data.IpSshSourceInterfaceLoopback.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/ssh/source-interface-config/Loopback", data.getPath()))
}
- if !state.IpDomainLookupSourceInterfaceGigabitEthernet.IsNull() && data.IpDomainLookupSourceInterfaceGigabitEthernet.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/domain/lookup-settings/lookup/source-interface/GigabitEthernet", state.getPath()))
+ if !data.IpSshAuthenticationRetries.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/ssh/authentication-retries", data.getPath()))
}
- if !state.IpDomainLookupSourceInterfaceVlan.IsNull() && data.IpDomainLookupSourceInterfaceVlan.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/domain/lookup-settings/lookup/source-interface/Vlan", state.getPath()))
+ if !data.IpSshTimeOut.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/ssh/time-out", data.getPath()))
}
- if !state.IpDomainLookupSourceInterfaceLoopback.IsNull() && data.IpDomainLookupSourceInterfaceLoopback.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/domain/lookup-settings/lookup/source-interface/Loopback", state.getPath()))
+ if !data.IpSshVersionLegacy.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/ssh/version", data.getPath()))
}
- for i := range state.IpNameServersVrf {
- stateKeyValues := [...]string{state.IpNameServersVrf[i].Vrf.ValueString()}
-
- emptyKeys := true
- if !reflect.ValueOf(state.IpNameServersVrf[i].Vrf.ValueString()).IsZero() {
- emptyKeys = false
- }
- if emptyKeys {
- continue
- }
-
- found := false
- for j := range data.IpNameServersVrf {
- found = true
- if state.IpNameServersVrf[i].Vrf.ValueString() != data.IpNameServersVrf[j].Vrf.ValueString() {
- found = false
- }
- if found {
- if !state.IpNameServersVrf[i].Servers.IsNull() {
- if data.IpNameServersVrf[j].Servers.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/name-server/vrf=%v/server-ip-list-ordered", state.getPath(), strings.Join(stateKeyValues[:], ",")))
- } else {
- var dataValues, stateValues []string
- data.IpNameServersVrf[i].Servers.ElementsAs(ctx, &dataValues, false)
- state.IpNameServersVrf[j].Servers.ElementsAs(ctx, &stateValues, false)
- for _, v := range stateValues {
- found := false
- for _, vv := range dataValues {
- if v == vv {
- found = true
- break
- }
- }
- if !found {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/name-server/vrf=%v/server-ip-list-ordered=%v", state.getPath(), strings.Join(stateKeyValues[:], ","), v))
- }
- }
- }
- }
- break
- }
- }
- if !found {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/name-server/vrf=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
- }
+ if !data.IpSshVersion.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/ssh/ssh-version", data.getPath()))
+ }
+ if !data.IpScpServerEnable.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/scp/server/enable", data.getPath()))
}
- if !state.IpNameServers.IsNull() {
- if data.IpNameServers.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/name-server/no-vrf-ordered", state.getPath()))
- } else {
- var dataValues, stateValues []string
- data.IpNameServers.ElementsAs(ctx, &dataValues, false)
- state.IpNameServers.ElementsAs(ctx, &stateValues, false)
- for _, v := range stateValues {
- found := false
- for _, vv := range dataValues {
- if v == vv {
- found = true
- break
- }
- }
- if !found {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/name-server/no-vrf-ordered=%v", state.getPath(), v))
- }
- }
- }
+ if !data.IpForwardProtocolNd.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/forward-protocol-v2/nd", data.getPath()))
}
- if !state.IpHttpActiveSessionModules.IsNull() && data.IpHttpActiveSessionModules.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/Cisco-IOS-XE-http:http/active-session-modules", state.getPath()))
+ if !data.TransceiverTypeAllMonitoring.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/transceivers/type/all/monitoring-enable/monitoring", data.getPath()))
}
- if !state.IpHttpMaxConnections.IsNull() && data.IpHttpMaxConnections.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/Cisco-IOS-XE-http:http/max-connections", state.getPath()))
+ if !data.RedundancyMode.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/redundancy/mode", data.getPath()))
}
- if !state.IpHttpSecureActiveSessionModules.IsNull() && data.IpHttpSecureActiveSessionModules.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/Cisco-IOS-XE-http:http/secure-active-session-modules", state.getPath()))
+ if !data.Redundancy.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/redundancy", data.getPath()))
}
- if !state.IpHttpClientSourceInterface.IsNull() && data.IpHttpClientSourceInterface.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/Cisco-IOS-XE-http:http/client/source-interface", state.getPath()))
+ if !data.ArchiveLogConfigLoggingSize.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/archive/log/config/logging/size", data.getPath()))
}
- if !state.IpHttpClientSecureTrustpoint.IsNull() && data.IpHttpClientSecureTrustpoint.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/Cisco-IOS-XE-http:http/client/secure-trustpoint", state.getPath()))
+ if !data.ArchiveLogConfigLoggingEnable.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/archive/log/config/logging/enable", data.getPath()))
}
- if !state.IpHttpTlsVersion.IsNull() && data.IpHttpTlsVersion.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/Cisco-IOS-XE-http:http/tls-version", state.getPath()))
+ if !data.ArchiveTimePeriod.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/archive/time-period", data.getPath()))
}
- if !state.IpHttpSecureTrustpoint.IsNull() && data.IpHttpSecureTrustpoint.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/Cisco-IOS-XE-http:http/secure-trustpoint", state.getPath()))
+ if !data.ArchiveWriteMemory.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/archive/write-memory", data.getPath()))
}
- if !state.IpHttpSecureServer.IsNull() && data.IpHttpSecureServer.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/Cisco-IOS-XE-http:http/secure-server", state.getPath()))
+ if !data.ArchiveMaximum.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/archive/maximum", data.getPath()))
}
- if !state.IpHttpServer.IsNull() && data.IpHttpServer.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/Cisco-IOS-XE-http:http/server", state.getPath()))
+ if !data.ArchivePath.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/archive/path", data.getPath()))
}
- if !state.IpHttpAuthenticationLocal.IsNull() && data.IpHttpAuthenticationLocal.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/Cisco-IOS-XE-http:http/authentication/local", state.getPath()))
+ if !data.MemoryFreeLowWatermarkProcessor.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/memory/free/low-watermark/processor", data.getPath()))
}
- for i := range state.IpHttpAuthenticationAaaCommandAuthorization {
- stateKeyValues := [...]string{strconv.FormatInt(state.IpHttpAuthenticationAaaCommandAuthorization[i].Level.ValueInt64(), 10)}
-
- emptyKeys := true
- if !reflect.ValueOf(state.IpHttpAuthenticationAaaCommandAuthorization[i].Level.ValueInt64()).IsZero() {
- emptyKeys = false
- }
- if emptyKeys {
- continue
- }
-
- found := false
- for j := range data.IpHttpAuthenticationAaaCommandAuthorization {
- found = true
- if state.IpHttpAuthenticationAaaCommandAuthorization[i].Level.ValueInt64() != data.IpHttpAuthenticationAaaCommandAuthorization[j].Level.ValueInt64() {
- found = false
- }
- if found {
- if !state.IpHttpAuthenticationAaaCommandAuthorization[i].Name.IsNull() && data.IpHttpAuthenticationAaaCommandAuthorization[j].Name.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/Cisco-IOS-XE-http:http/authentication/aaa/command-authorization=%v/name", state.getPath(), strings.Join(stateKeyValues[:], ",")))
- }
- break
- }
- }
- if !found {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/Cisco-IOS-XE-http:http/authentication/aaa/command-authorization=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
- }
+ if !data.DiagnosticBootupLevel.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-diagnostics:diagnostic/bootup/level", data.getPath()))
}
- if !state.IpHttpAuthenticationAaaLoginAuthentication.IsNull() && data.IpHttpAuthenticationAaaLoginAuthentication.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/Cisco-IOS-XE-http:http/authentication/aaa/login-authentication", state.getPath()))
+ if !data.AccessSessionMacMoveDeny.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-sanet:access-session/mac-move/deny", data.getPath()))
}
- if !state.IpHttpAuthenticationAaaExecAuthorization.IsNull() && data.IpHttpAuthenticationAaaExecAuthorization.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/Cisco-IOS-XE-http:http/authentication/aaa/exec-authorization", state.getPath()))
+ if !data.EpmLogging.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/epm/logging", data.getPath()))
}
- if !state.IpHttpAuthenticationAaa.IsNull() && data.IpHttpAuthenticationAaa.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/Cisco-IOS-XE-http:http/authentication/aaa", state.getPath()))
+ if !data.CispEnable.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/cisp/enable", data.getPath()))
}
- if !state.IpHttpAccessClass.IsNull() && data.IpHttpAccessClass.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/Cisco-IOS-XE-http:http/access-class", state.getPath()))
+ if !data.IpDomainLookupSourceInterfaceHundredGigabitEthernet.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/domain/lookup-settings/lookup/source-interface/HundredGigE", data.getPath()))
}
- for i := range state.MulticastRoutingVrfs {
- stateKeyValues := [...]string{state.MulticastRoutingVrfs[i].Vrf.ValueString()}
-
- emptyKeys := true
- if !reflect.ValueOf(state.MulticastRoutingVrfs[i].Vrf.ValueString()).IsZero() {
- emptyKeys = false
- }
- if emptyKeys {
- continue
- }
-
- found := false
- for j := range data.MulticastRoutingVrfs {
- found = true
- if state.MulticastRoutingVrfs[i].Vrf.ValueString() != data.MulticastRoutingVrfs[j].Vrf.ValueString() {
- found = false
- }
- if found {
- if !state.MulticastRoutingVrfs[i].Distributed.IsNull() && data.MulticastRoutingVrfs[j].Distributed.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/Cisco-IOS-XE-multicast:multicast-routing/vrf=%v/distributed", state.getPath(), strings.Join(stateKeyValues[:], ",")))
- }
- break
- }
- }
- if !found {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/Cisco-IOS-XE-multicast:multicast-routing/vrf=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
- }
+ if !data.IpDomainLookupSourceInterfaceFortyGigabitEthernet.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/domain/lookup-settings/lookup/source-interface/FortyGigabitEthernet", data.getPath()))
}
- if !state.IpMulticastRoutingDistributed.IsNull() && data.IpMulticastRoutingDistributed.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/Cisco-IOS-XE-multicast:multicast-routing/distributed", state.getPath()))
+ if !data.IpDomainLookupSourceInterfaceTwentyFiveGigabitEthernet.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/domain/lookup-settings/lookup/source-interface/TwentyFiveGigE", data.getPath()))
}
- if !state.MulticastRoutingSwitch.IsNull() && data.MulticastRoutingSwitch.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/Cisco-IOS-XE-multicast:mcr-conf/multicast-routing", state.getPath()))
+ if !data.IpDomainLookupSourceInterfaceTenGigabitEthernet.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/domain/lookup-settings/lookup/source-interface/TenGigabitEthernet", data.getPath()))
}
- if !state.IpMulticastRouting.IsNull() && data.IpMulticastRouting.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/Cisco-IOS-XE-multicast:multicast-routing", state.getPath()))
+ if !data.IpDomainLookupSourceInterfaceFiveGigabitEthernet.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/domain/lookup-settings/lookup/source-interface/FiveGigabitEthernet", data.getPath()))
}
- if !state.LoginOnSuccessLog.IsNull() && data.LoginOnSuccessLog.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/login/on-success/log", state.getPath()))
+ if !data.IpDomainLookupSourceInterfaceTwoGigabitEthernet.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/domain/lookup-settings/lookup/source-interface/TwoGigabitEthernet", data.getPath()))
}
- if !state.LoginOnSuccess.IsNull() && data.LoginOnSuccess.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/login/on-success", state.getPath()))
+ if !data.IpDomainLookupSourceInterfaceGigabitEthernet.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/domain/lookup-settings/lookup/source-interface/GigabitEthernet", data.getPath()))
}
- if !state.LoginOnFailureLog.IsNull() && data.LoginOnFailureLog.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/login/on-failure/log", state.getPath()))
+ if !data.IpDomainLookupSourceInterfaceVlan.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/domain/lookup-settings/lookup/source-interface/Vlan", data.getPath()))
}
- if !state.LoginOnFailure.IsNull() && data.LoginOnFailure.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/login/on-failure", state.getPath()))
+ if !data.IpDomainLookupSourceInterfaceLoopback.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/domain/lookup-settings/lookup/source-interface/Loopback", data.getPath()))
}
- if !state.LoginDelay.IsNull() && data.LoginDelay.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/login/delay", state.getPath()))
+ for i := range data.IpNameServersVrf {
+ keyValues := [...]string{data.IpNameServersVrf[i].Vrf.ValueString()}
+
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/name-server/vrf=%v", data.getPath(), strings.Join(keyValues[:], ",")))
}
- if !state.IpDomainName.IsNull() && data.IpDomainName.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/domain/name", state.getPath()))
+ if !data.IpNameServers.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/name-server/no-vrf-ordered", data.getPath()))
}
- if !state.IpDomainLookup.IsNull() && data.IpDomainLookup.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/domain/lookup", state.getPath()))
+ if !data.IpHttpActiveSessionModules.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/Cisco-IOS-XE-http:http/active-session-modules", data.getPath()))
}
- if !state.IpSourceRoute.IsNull() && data.IpSourceRoute.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/source-route", state.getPath()))
+ if !data.IpHttpMaxConnections.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/Cisco-IOS-XE-http:http/max-connections", data.getPath()))
}
- if !state.Mtu.IsNull() && data.Mtu.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/system/Cisco-IOS-XE-switch:mtu/size", state.getPath()))
+ if !data.IpHttpSecureActiveSessionModules.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/Cisco-IOS-XE-http:http/secure-active-session-modules", data.getPath()))
}
- if !state.Ipv6UnicastRouting.IsNull() && data.Ipv6UnicastRouting.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ipv6/unicast-routing", state.getPath()))
+ if !data.IpHttpClientSourceInterface.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/Cisco-IOS-XE-http:http/client/source-interface", data.getPath()))
}
- if !state.IpRouting.IsNull() && data.IpRouting.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/routing-conf/routing", state.getPath()))
+ if !data.IpHttpClientSecureTrustpoint.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/Cisco-IOS-XE-http:http/client/secure-trustpoint", data.getPath()))
}
- if !state.IpBgpCommunityNewFormat.IsNull() && data.IpBgpCommunityNewFormat.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/ip/bgp-community/new-format", state.getPath()))
+ if !data.IpHttpTlsVersion.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/Cisco-IOS-XE-http:http/tls-version", data.getPath()))
}
- if !state.Hostname.IsNull() && data.Hostname.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/hostname", state.getPath()))
+ if !data.IpHttpSecureTrustpoint.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/Cisco-IOS-XE-http:http/secure-trustpoint", data.getPath()))
}
-
- return deletedItems
-}
-
-// End of section. //template:end getDeletedItems
-
-// Section below is generated&owned by "gen/generator.go". //template:begin getEmptyLeafsDelete
-
-func (data *System) getEmptyLeafsDelete(ctx context.Context) []string {
- emptyLeafsDelete := make([]string, 0)
-
- for i := range data.TrackObjects {
- keyValues := [...]string{data.TrackObjects[i].Number.ValueString()}
- if !data.TrackObjects[i].IpSlaReachability.IsNull() && !data.TrackObjects[i].IpSlaReachability.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/track/Cisco-IOS-XE-track:tracked-object-v2=%v/ip/sla/reachability", data.getPath(), strings.Join(keyValues[:], ",")))
- }
+ if !data.IpHttpSecureServer.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/Cisco-IOS-XE-http:http/secure-server", data.getPath()))
}
- if !data.SubscriberTemplating.IsNull() && !data.SubscriberTemplating.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/subscriber/templating", data.getPath()))
+ if !data.IpHttpServer.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/Cisco-IOS-XE-http:http/server", data.getPath()))
+ }
+ if !data.IpHttpAuthenticationLocal.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/Cisco-IOS-XE-http:http/authentication/local", data.getPath()))
}
+ for i := range data.IpHttpAuthenticationAaaCommandAuthorization {
+ keyValues := [...]string{strconv.FormatInt(data.IpHttpAuthenticationAaaCommandAuthorization[i].Level.ValueInt64(), 10)}
- if !data.IpScpServerEnable.IsNull() && !data.IpScpServerEnable.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/ip/scp/server/enable", data.getPath()))
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/Cisco-IOS-XE-http:http/authentication/aaa/command-authorization=%v", data.getPath(), strings.Join(keyValues[:], ",")))
}
- if !data.TransceiverTypeAllMonitoring.IsNull() && !data.TransceiverTypeAllMonitoring.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/transceivers/type/all/monitoring-enable/monitoring", data.getPath()))
+ if !data.IpHttpAuthenticationAaaLoginAuthentication.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/Cisco-IOS-XE-http:http/authentication/aaa/login-authentication", data.getPath()))
}
- if !data.Redundancy.IsNull() && !data.Redundancy.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/redundancy", data.getPath()))
+ if !data.IpHttpAuthenticationAaaExecAuthorization.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/Cisco-IOS-XE-http:http/authentication/aaa/exec-authorization", data.getPath()))
}
- if !data.ArchiveLogConfigLoggingEnable.IsNull() && !data.ArchiveLogConfigLoggingEnable.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/archive/log/config/logging/enable", data.getPath()))
+ if !data.IpHttpAuthenticationAaa.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/Cisco-IOS-XE-http:http/authentication/aaa", data.getPath()))
}
- if !data.ArchiveWriteMemory.IsNull() && !data.ArchiveWriteMemory.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/archive/write-memory", data.getPath()))
+ if !data.IpHttpAccessClass.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/Cisco-IOS-XE-http:http/access-class", data.getPath()))
+ }
+ for i := range data.MulticastRoutingVrfs {
+ keyValues := [...]string{data.MulticastRoutingVrfs[i].Vrf.ValueString()}
+
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/Cisco-IOS-XE-multicast:multicast-routing/vrf=%v", data.getPath(), strings.Join(keyValues[:], ",")))
+ }
+ if !data.IpMulticastRoutingDistributed.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/Cisco-IOS-XE-multicast:multicast-routing/distributed", data.getPath()))
}
- if !data.AccessSessionMacMoveDeny.IsNull() && !data.AccessSessionMacMoveDeny.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/Cisco-IOS-XE-sanet:access-session/mac-move/deny", data.getPath()))
+ if !data.MulticastRoutingSwitch.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/Cisco-IOS-XE-multicast:mcr-conf/multicast-routing", data.getPath()))
}
- if !data.EpmLogging.IsNull() && !data.EpmLogging.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/epm/logging", data.getPath()))
+ if !data.IpMulticastRouting.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/Cisco-IOS-XE-multicast:multicast-routing", data.getPath()))
}
- if !data.CispEnable.IsNull() && !data.CispEnable.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/cisp/enable", data.getPath()))
+ if !data.LoginOnSuccessLog.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/login/on-success/log", data.getPath()))
}
-
- if !data.IpHttpAuthenticationLocal.IsNull() && !data.IpHttpAuthenticationLocal.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/ip/Cisco-IOS-XE-http:http/authentication/local", data.getPath()))
+ if !data.LoginOnSuccess.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/login/on-success", data.getPath()))
}
-
- if !data.IpHttpAuthenticationAaa.IsNull() && !data.IpHttpAuthenticationAaa.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/ip/Cisco-IOS-XE-http:http/authentication/aaa", data.getPath()))
+ if !data.LoginOnFailureLog.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/login/on-failure/log", data.getPath()))
}
-
- for i := range data.MulticastRoutingVrfs {
- keyValues := [...]string{data.MulticastRoutingVrfs[i].Vrf.ValueString()}
- if !data.MulticastRoutingVrfs[i].Distributed.IsNull() && !data.MulticastRoutingVrfs[i].Distributed.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/ip/Cisco-IOS-XE-multicast:multicast-routing/vrf=%v/distributed", data.getPath(), strings.Join(keyValues[:], ",")))
- }
+ if !data.LoginOnFailure.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/login/on-failure", data.getPath()))
}
- if !data.IpMulticastRoutingDistributed.IsNull() && !data.IpMulticastRoutingDistributed.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/ip/Cisco-IOS-XE-multicast:multicast-routing/distributed", data.getPath()))
+ if !data.LoginDelay.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/login/delay", data.getPath()))
}
- if !data.MulticastRoutingSwitch.IsNull() && !data.MulticastRoutingSwitch.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/ip/Cisco-IOS-XE-multicast:mcr-conf/multicast-routing", data.getPath()))
+ if !data.IpDomainName.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/domain/name", data.getPath()))
}
- if !data.IpMulticastRouting.IsNull() && !data.IpMulticastRouting.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/ip/Cisco-IOS-XE-multicast:multicast-routing", data.getPath()))
+ if !data.IpDomainLookup.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/domain/lookup", data.getPath()))
}
- if !data.LoginOnSuccessLog.IsNull() && !data.LoginOnSuccessLog.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/login/on-success/log", data.getPath()))
+ if !data.IpSourceRoute.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/source-route", data.getPath()))
}
- if !data.LoginOnSuccess.IsNull() && !data.LoginOnSuccess.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/login/on-success", data.getPath()))
+ if !data.Mtu.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/system/Cisco-IOS-XE-switch:mtu/size", data.getPath()))
}
- if !data.LoginOnFailureLog.IsNull() && !data.LoginOnFailureLog.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/login/on-failure/log", data.getPath()))
+ if !data.Ipv6UnicastRouting.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/ipv6/unicast-routing", data.getPath()))
}
- if !data.LoginOnFailure.IsNull() && !data.LoginOnFailure.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/login/on-failure", data.getPath()))
+ if !data.IpRouting.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/routing-conf/routing", data.getPath()))
}
- if !data.Ipv6UnicastRouting.IsNull() && !data.Ipv6UnicastRouting.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/ipv6/unicast-routing", data.getPath()))
+ if !data.IpBgpCommunityNewFormat.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/bgp-community/new-format", data.getPath()))
}
- if !data.IpBgpCommunityNewFormat.IsNull() && !data.IpBgpCommunityNewFormat.ValueBool() {
- emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/ip/bgp-community/new-format", data.getPath()))
+ if !data.Hostname.IsNull() {
+ deletePaths = append(deletePaths, fmt.Sprintf("%v/hostname", data.getPath()))
}
- return emptyLeafsDelete
+ return deletePaths
}
-// End of section. //template:end getEmptyLeafsDelete
+// End of section. //template:end getDeletePaths
-// Section below is generated&owned by "gen/generator.go". //template:begin getDeletePaths
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletePathsXML
-func (data *System) getDeletePaths(ctx context.Context) []string {
- var deletePaths []string
- if !data.StandbyRedirectsEnableDisable.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/standby/redirects-config/redirect-enable-disable/redirects", data.getPath()))
+func (data *System) addDeletePathsXML(ctx context.Context, body string) string {
+ b := netconf.NewBody(body)
+ if !data.Hostname.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/hostname")
}
- if !data.StandbyRedirects.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/standby/redirects-config/redirects", data.getPath()))
+ if !data.IpBgpCommunityNewFormat.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ip/bgp-community/new-format")
}
- if !data.EthernetCfmAlarmConfigReset.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/ethernet/Cisco-IOS-XE-ethernet:cfm/alarm-config/reset", data.getPath()))
+ if !data.IpRouting.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ip/routing-conf/routing")
}
- if !data.EthernetCfmAlarmConfigDelay.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/ethernet/Cisco-IOS-XE-ethernet:cfm/alarm-config/delay", data.getPath()))
+ if !data.Ipv6UnicastRouting.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ipv6/unicast-routing")
}
- if !data.IpDomainListVrf.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/domain/list/vrf/vrf-name", data.getPath()))
+ if !data.Mtu.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/system/Cisco-IOS-XE-switch:mtu/size")
}
- if !data.IpDomainListVrfDomain.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/domain/list/vrf/domain-name", data.getPath()))
+ if !data.IpSourceRoute.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ip/source-route")
}
- if !data.IpDomainListNames.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/domain/list/domain-name", data.getPath()))
+ if !data.IpDomainLookup.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ip/domain/lookup")
}
- if !data.SecurityPasswordsMinLength.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-aaa:security/passwords/min-length", data.getPath()))
+ if !data.IpDomainName.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ip/domain/name")
}
- if !data.IpMulticastRouteLimit.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/multicast/Cisco-IOS-XE-multicast:route-limit-container/routelimit", data.getPath()))
+ if !data.LoginDelay.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/login/delay")
}
- if !data.IpNbarClassificationDnsClassifyByDomain.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/Cisco-IOS-XE-nbar:nbar/classification/dns/classify-by-domain-with-default", data.getPath()))
+ if !data.LoginOnFailure.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/login/on-failure")
}
- for i := range data.TrackObjects {
- keyValues := [...]string{data.TrackObjects[i].Number.ValueString()}
-
- deletePaths = append(deletePaths, fmt.Sprintf("%v/track/Cisco-IOS-XE-track:tracked-object-v2=%v", data.getPath(), strings.Join(keyValues[:], ",")))
+ if !data.LoginOnFailureLog.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/login/on-failure/log")
}
- if !data.Version.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/version", data.getPath()))
+ if !data.LoginOnSuccess.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/login/on-success")
}
- if !data.MultilinkPppBundleName.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/multilink/Cisco-IOS-XE-ppp:bundle-name", data.getPath()))
+ if !data.LoginOnSuccessLog.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/login/on-success/log")
}
- if !data.TftpSourceInterfaceHundredGigabitEthernet.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/tftp/source-interface/HundredGigE", data.getPath()))
+ if !data.IpMulticastRouting.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ip/Cisco-IOS-XE-multicast:multicast-routing")
}
- if !data.TftpSourceInterfaceFortyGigabitEthernet.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/tftp/source-interface/FortyGigabitEthernet", data.getPath()))
+ if !data.MulticastRoutingSwitch.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ip/Cisco-IOS-XE-multicast:mcr-conf/multicast-routing")
}
- if !data.TftpSourceInterfaceTwentyFiveGigabitEthernet.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/tftp/source-interface/TwentyFiveGigabitEthernet", data.getPath()))
+ if !data.IpMulticastRoutingDistributed.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ip/Cisco-IOS-XE-multicast:multicast-routing/distributed")
}
- if !data.TftpSourceInterfaceTenGigabitEthernet.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/tftp/source-interface/TenGigabitEthernet", data.getPath()))
+ for i := range data.MulticastRoutingVrfs {
+ keys := [...]string{"name"}
+ keyValues := [...]string{data.MulticastRoutingVrfs[i].Vrf.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/ip/Cisco-IOS-XE-multicast:multicast-routing/vrf%v", predicates))
}
- if !data.TftpSourceInterfaceFiveGigabitEthernet.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/tftp/source-interface/FiveGigabitEthernet", data.getPath()))
+ if !data.IpHttpAccessClass.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ip/Cisco-IOS-XE-http:http/access-class")
}
- if !data.TftpSourceInterfaceTwoGigabitEthernet.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/tftp/source-interface/TwoGigabitEthernet", data.getPath()))
+ if !data.IpHttpAuthenticationAaa.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ip/Cisco-IOS-XE-http:http/authentication/aaa")
}
- if !data.TftpSourceInterfaceVlan.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/tftp/source-interface/Vlan", data.getPath()))
+ if !data.IpHttpAuthenticationAaaExecAuthorization.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ip/Cisco-IOS-XE-http:http/authentication/aaa/exec-authorization")
}
- if !data.TftpSourceInterfaceLoopback.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/tftp/source-interface/Loopback", data.getPath()))
+ if !data.IpHttpAuthenticationAaaLoginAuthentication.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ip/Cisco-IOS-XE-http:http/authentication/aaa/login-authentication")
}
- if !data.TftpSourceInterfaceGigabitEthernet.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/tftp/source-interface/GigabitEthernet", data.getPath()))
+ for i := range data.IpHttpAuthenticationAaaCommandAuthorization {
+ keys := [...]string{"level"}
+ keyValues := [...]string{strconv.FormatInt(data.IpHttpAuthenticationAaaCommandAuthorization[i].Level.ValueInt64(), 10)}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/ip/Cisco-IOS-XE-http:http/authentication/aaa/command-authorization%v", predicates))
}
- if !data.IpFtpPassive.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/ftp/passive-enable", data.getPath()))
+ if !data.IpHttpAuthenticationLocal.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ip/Cisco-IOS-XE-http:http/authentication/local")
}
- if !data.CallHomeCiscoTac1DestinationTransportMethod.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/call-home/Cisco-IOS-XE-call-home:tac-profile/profile/CiscoTAC-1/destination/transport-method", data.getPath()))
+ if !data.IpHttpServer.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ip/Cisco-IOS-XE-http:http/server")
}
- if !data.CallHomeCiscoTac1ProfileActive.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/call-home/Cisco-IOS-XE-call-home:tac-profile/profile/CiscoTAC-1/active", data.getPath()))
+ if !data.IpHttpSecureServer.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ip/Cisco-IOS-XE-http:http/secure-server")
}
- if !data.CallHomeContactEmail.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/call-home/Cisco-IOS-XE-call-home:contact-email-addr", data.getPath()))
+ if !data.IpHttpSecureTrustpoint.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ip/Cisco-IOS-XE-http:http/secure-trustpoint")
}
- if !data.SubscriberTemplating.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/subscriber/templating", data.getPath()))
+ if !data.IpHttpTlsVersion.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ip/Cisco-IOS-XE-http:http/tls-version")
}
- if !data.DiagnosticEventLogSize.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-diagnostics:diagnostic/event-log/size", data.getPath()))
+ if !data.IpHttpClientSecureTrustpoint.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ip/Cisco-IOS-XE-http:http/client/secure-trustpoint")
}
- for i := range data.IpHostsVrf {
- keyValues := [...]string{data.IpHostsVrf[i].Vrf.ValueString()}
-
- deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/host/vrf=%v", data.getPath(), strings.Join(keyValues[:], ",")))
+ if !data.IpHttpClientSourceInterface.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ip/Cisco-IOS-XE-http:http/client/source-interface")
}
- for i := range data.IpHosts {
- keyValues := [...]string{data.IpHosts[i].Name.ValueString()}
-
- deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/host/host-list=%v", data.getPath(), strings.Join(keyValues[:], ",")))
+ if !data.IpHttpSecureActiveSessionModules.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ip/Cisco-IOS-XE-http:http/secure-active-session-modules")
}
- if !data.EnableSecretLevel.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/enable/secret/level", data.getPath()))
+ if !data.IpHttpMaxConnections.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ip/Cisco-IOS-XE-http:http/max-connections")
}
- if !data.EnableSecretType.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/enable/secret/type", data.getPath()))
+ if !data.IpHttpActiveSessionModules.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ip/Cisco-IOS-XE-http:http/active-session-modules")
}
- if !data.EnableSecret.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/enable/secret", data.getPath()))
+ if !data.IpNameServers.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ip/name-server/no-vrf-ordered")
}
- for i := range data.BootSystemBootfiles {
- keyValues := [...]string{data.BootSystemBootfiles[i].Path.ValueString()}
+ for i := range data.IpNameServersVrf {
+ keys := [...]string{"word"}
+ keyValues := [...]string{data.IpNameServersVrf[i].Vrf.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
- deletePaths = append(deletePaths, fmt.Sprintf("%v/boot/system/bootfile/filename-list-ordered-by-user=%v", data.getPath(), strings.Join(keyValues[:], ",")))
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/ip/name-server/vrf%v", predicates))
}
- for i := range data.BootSystemFlashFiles {
- keyValues := [...]string{data.BootSystemFlashFiles[i].Path.ValueString()}
-
- deletePaths = append(deletePaths, fmt.Sprintf("%v/boot/system/flash/flash-list-ordered-by-user=%v", data.getPath(), strings.Join(keyValues[:], ",")))
+ if !data.IpDomainLookupSourceInterfaceLoopback.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ip/domain/lookup-settings/lookup/source-interface/Loopback")
}
- if !data.IpRadiusSourceInterfaceVrf.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/Cisco-IOS-XE-aaa:radius/source-interface/vrf", data.getPath()))
+ if !data.IpDomainLookupSourceInterfaceVlan.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ip/domain/lookup-settings/lookup/source-interface/Vlan")
}
- if !data.IpRadiusSourceInterfaceHundredGigabitEthernet.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/Cisco-IOS-XE-aaa:radius/source-interface/HundredGigE", data.getPath()))
+ if !data.IpDomainLookupSourceInterfaceGigabitEthernet.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ip/domain/lookup-settings/lookup/source-interface/GigabitEthernet")
}
- if !data.IpRadiusSourceInterfaceFortyGigabitEthernet.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/Cisco-IOS-XE-aaa:radius/source-interface/FortyGigabitEthernet", data.getPath()))
+ if !data.IpDomainLookupSourceInterfaceTwoGigabitEthernet.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ip/domain/lookup-settings/lookup/source-interface/TwoGigabitEthernet")
}
- if !data.IpRadiusSourceInterfaceTwentyFiveGigabitEthernet.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/Cisco-IOS-XE-aaa:radius/source-interface/TwentyFiveGigE", data.getPath()))
+ if !data.IpDomainLookupSourceInterfaceFiveGigabitEthernet.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ip/domain/lookup-settings/lookup/source-interface/FiveGigabitEthernet")
}
- if !data.IpRadiusSourceInterfaceTenGigabitEthernet.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/Cisco-IOS-XE-aaa:radius/source-interface/TenGigabitEthernet", data.getPath()))
+ if !data.IpDomainLookupSourceInterfaceTenGigabitEthernet.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ip/domain/lookup-settings/lookup/source-interface/TenGigabitEthernet")
}
- if !data.IpRadiusSourceInterfaceFiveGigabitEthernet.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/Cisco-IOS-XE-aaa:radius/source-interface/FiveGigabitEthernet", data.getPath()))
+ if !data.IpDomainLookupSourceInterfaceTwentyFiveGigabitEthernet.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ip/domain/lookup-settings/lookup/source-interface/TwentyFiveGigE")
}
- if !data.IpRadiusSourceInterfaceTwoGigabitEthernet.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/Cisco-IOS-XE-aaa:radius/source-interface/TwoGigabitEthernet", data.getPath()))
+ if !data.IpDomainLookupSourceInterfaceFortyGigabitEthernet.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ip/domain/lookup-settings/lookup/source-interface/FortyGigabitEthernet")
}
- if !data.IpRadiusSourceInterfaceGigabitEthernet.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/Cisco-IOS-XE-aaa:radius/source-interface/GigabitEthernet", data.getPath()))
+ if !data.IpDomainLookupSourceInterfaceHundredGigabitEthernet.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ip/domain/lookup-settings/lookup/source-interface/HundredGigE")
}
- if !data.IpRadiusSourceInterfaceVlan.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/Cisco-IOS-XE-aaa:radius/source-interface/Vlan", data.getPath()))
+ if !data.CispEnable.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/cisp/enable")
}
- if !data.IpRadiusSourceInterfaceLoopback.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/Cisco-IOS-XE-aaa:radius/source-interface/Loopback", data.getPath()))
+ if !data.EpmLogging.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/epm/logging")
}
- if !data.IpTacacsSourceInterfaceVrf.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/Cisco-IOS-XE-aaa:tacacs/source-interface/vrf", data.getPath()))
+ if !data.AccessSessionMacMoveDeny.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-sanet:access-session/mac-move/deny")
}
- if !data.IpTacacsSourceInterfaceHundredGigabitEthernet.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/Cisco-IOS-XE-aaa:tacacs/source-interface/HundredGigE", data.getPath()))
+ if !data.DiagnosticBootupLevel.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-diagnostics:diagnostic/bootup/level")
}
- if !data.IpTacacsSourceInterfaceFortyGigabitEthernet.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/Cisco-IOS-XE-aaa:tacacs/source-interface/FortyGigabitEthernet", data.getPath()))
+ if !data.MemoryFreeLowWatermarkProcessor.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/memory/free/low-watermark/processor")
}
- if !data.IpTacacsSourceInterfaceTwentyFiveGigabitEthernet.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/Cisco-IOS-XE-aaa:tacacs/source-interface/TwentyFiveGigE", data.getPath()))
+ if !data.ArchivePath.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/archive/path")
}
- if !data.IpTacacsSourceInterfaceTenGigabitEthernet.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/Cisco-IOS-XE-aaa:tacacs/source-interface/TenGigabitEthernet", data.getPath()))
+ if !data.ArchiveMaximum.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/archive/maximum")
}
- if !data.IpTacacsSourceInterfaceFiveGigabitEthernet.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/Cisco-IOS-XE-aaa:tacacs/source-interface/FiveGigabitEthernet", data.getPath()))
+ if !data.ArchiveWriteMemory.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/archive/write-memory")
}
- if !data.IpTacacsSourceInterfaceTwoGigabitEthernet.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/Cisco-IOS-XE-aaa:tacacs/source-interface/TwoGigabitEthernet", data.getPath()))
+ if !data.ArchiveTimePeriod.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/archive/time-period")
}
- if !data.IpTacacsSourceInterfaceGigabitEthernet.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/Cisco-IOS-XE-aaa:tacacs/source-interface/GigabitEthernet", data.getPath()))
+ if !data.ArchiveLogConfigLoggingEnable.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/archive/log/config/logging/enable")
}
- if !data.IpTacacsSourceInterfaceVlan.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/Cisco-IOS-XE-aaa:tacacs/source-interface/Vlan", data.getPath()))
+ if !data.ArchiveLogConfigLoggingSize.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/archive/log/config/logging/size")
}
- if !data.IpTacacsSourceInterfaceLoopback.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/Cisco-IOS-XE-aaa:tacacs/source-interface/Loopback", data.getPath()))
+ if !data.Redundancy.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/redundancy")
}
- for i := range data.PnpProfiles {
- keyValues := [...]string{data.PnpProfiles[i].Name.ValueString()}
-
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-pnp:pnp/profile=%v", data.getPath(), strings.Join(keyValues[:], ",")))
+ if !data.RedundancyMode.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/redundancy/mode")
}
- if !data.ControlPlaneServicePolicyInput.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/control-plane/Cisco-IOS-XE-policy:service-policy/input", data.getPath()))
+ if !data.TransceiverTypeAllMonitoring.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/transceivers/type/all/monitoring-enable/monitoring")
}
- if !data.IpSshSourceInterfaceHundredGigabitEthernet.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/ssh/source-interface-config/HundredGigE", data.getPath()))
+ if !data.IpForwardProtocolNd.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ip/forward-protocol-v2/nd")
}
- if !data.IpSshSourceInterfaceFortyGigabitEthernet.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/ssh/source-interface-config/FortyGigabitEthernet", data.getPath()))
+ if !data.IpScpServerEnable.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ip/scp/server/enable")
}
- if !data.IpSshSourceInterfaceTwentyFiveGigabitEthernet.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/ssh/source-interface-config/TwentyFiveGigE", data.getPath()))
+ if !data.IpSshVersion.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ip/ssh/ssh-version")
}
- if !data.IpSshSourceInterfaceTenGigabitEthernet.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/ssh/source-interface-config/TenGigabitEthernet", data.getPath()))
+ if !data.IpSshVersionLegacy.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ip/ssh/version")
}
- if !data.IpSshSourceInterfaceFiveGigabitEthernet.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/ssh/source-interface-config/FiveGigabitEthernet", data.getPath()))
+ if !data.IpSshTimeOut.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ip/ssh/time-out")
}
- if !data.IpSshSourceInterfaceTwoGigabitEthernet.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/ssh/source-interface-config/TwoGigabitEthernet", data.getPath()))
+ if !data.IpSshAuthenticationRetries.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ip/ssh/authentication-retries")
}
- if !data.IpSshSourceInterfaceGigabitEthernet.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/ssh/source-interface-config/GigabitEthernet", data.getPath()))
+ if !data.IpSshSourceInterfaceLoopback.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ip/ssh/source-interface-config/Loopback")
}
if !data.IpSshSourceInterfaceVlan.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/ssh/source-interface-config/Vlan", data.getPath()))
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ip/ssh/source-interface-config/Vlan")
}
- if !data.IpSshSourceInterfaceLoopback.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/ssh/source-interface-config/Loopback", data.getPath()))
+ if !data.IpSshSourceInterfaceGigabitEthernet.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ip/ssh/source-interface-config/GigabitEthernet")
}
- if !data.IpSshAuthenticationRetries.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/ssh/authentication-retries", data.getPath()))
+ if !data.IpSshSourceInterfaceTwoGigabitEthernet.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ip/ssh/source-interface-config/TwoGigabitEthernet")
}
- if !data.IpSshTimeOut.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/ssh/time-out", data.getPath()))
+ if !data.IpSshSourceInterfaceFiveGigabitEthernet.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ip/ssh/source-interface-config/FiveGigabitEthernet")
}
- if !data.IpSshVersionLegacy.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/ssh/version", data.getPath()))
+ if !data.IpSshSourceInterfaceTenGigabitEthernet.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ip/ssh/source-interface-config/TenGigabitEthernet")
}
- if !data.IpSshVersion.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/ssh/ssh-version", data.getPath()))
+ if !data.IpSshSourceInterfaceTwentyFiveGigabitEthernet.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ip/ssh/source-interface-config/TwentyFiveGigE")
}
- if !data.IpScpServerEnable.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/scp/server/enable", data.getPath()))
+ if !data.IpSshSourceInterfaceFortyGigabitEthernet.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ip/ssh/source-interface-config/FortyGigabitEthernet")
}
- if !data.IpForwardProtocolNd.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/forward-protocol-v2/nd", data.getPath()))
+ if !data.IpSshSourceInterfaceHundredGigabitEthernet.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ip/ssh/source-interface-config/HundredGigE")
}
- if !data.TransceiverTypeAllMonitoring.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/transceivers/type/all/monitoring-enable/monitoring", data.getPath()))
+ if !data.ControlPlaneServicePolicyInput.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/control-plane/Cisco-IOS-XE-policy:service-policy/input")
}
- if !data.RedundancyMode.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/redundancy/mode", data.getPath()))
+ for i := range data.PnpProfiles {
+ keys := [...]string{"name"}
+ keyValues := [...]string{data.PnpProfiles[i].Name.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/Cisco-IOS-XE-pnp:pnp/profile%v", predicates))
}
- if !data.Redundancy.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/redundancy", data.getPath()))
+ if !data.IpTacacsSourceInterfaceLoopback.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ip/Cisco-IOS-XE-aaa:tacacs/source-interface/Loopback")
}
- if !data.ArchiveLogConfigLoggingSize.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/archive/log/config/logging/size", data.getPath()))
+ if !data.IpTacacsSourceInterfaceVlan.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ip/Cisco-IOS-XE-aaa:tacacs/source-interface/Vlan")
}
- if !data.ArchiveLogConfigLoggingEnable.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/archive/log/config/logging/enable", data.getPath()))
+ if !data.IpTacacsSourceInterfaceGigabitEthernet.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ip/Cisco-IOS-XE-aaa:tacacs/source-interface/GigabitEthernet")
}
- if !data.ArchiveTimePeriod.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/archive/time-period", data.getPath()))
+ if !data.IpTacacsSourceInterfaceTwoGigabitEthernet.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ip/Cisco-IOS-XE-aaa:tacacs/source-interface/TwoGigabitEthernet")
}
- if !data.ArchiveWriteMemory.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/archive/write-memory", data.getPath()))
+ if !data.IpTacacsSourceInterfaceFiveGigabitEthernet.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ip/Cisco-IOS-XE-aaa:tacacs/source-interface/FiveGigabitEthernet")
}
- if !data.ArchiveMaximum.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/archive/maximum", data.getPath()))
+ if !data.IpTacacsSourceInterfaceTenGigabitEthernet.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ip/Cisco-IOS-XE-aaa:tacacs/source-interface/TenGigabitEthernet")
}
- if !data.ArchivePath.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/archive/path", data.getPath()))
+ if !data.IpTacacsSourceInterfaceTwentyFiveGigabitEthernet.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ip/Cisco-IOS-XE-aaa:tacacs/source-interface/TwentyFiveGigE")
}
- if !data.MemoryFreeLowWatermarkProcessor.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/memory/free/low-watermark/processor", data.getPath()))
+ if !data.IpTacacsSourceInterfaceFortyGigabitEthernet.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ip/Cisco-IOS-XE-aaa:tacacs/source-interface/FortyGigabitEthernet")
}
- if !data.DiagnosticBootupLevel.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-diagnostics:diagnostic/bootup/level", data.getPath()))
+ if !data.IpTacacsSourceInterfaceHundredGigabitEthernet.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ip/Cisco-IOS-XE-aaa:tacacs/source-interface/HundredGigE")
}
- if !data.AccessSessionMacMoveDeny.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/Cisco-IOS-XE-sanet:access-session/mac-move/deny", data.getPath()))
+ if !data.IpTacacsSourceInterfaceVrf.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ip/Cisco-IOS-XE-aaa:tacacs/source-interface/vrf")
}
- if !data.EpmLogging.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/epm/logging", data.getPath()))
+ if !data.IpRadiusSourceInterfaceLoopback.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ip/Cisco-IOS-XE-aaa:radius/source-interface/Loopback")
}
- if !data.CispEnable.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/cisp/enable", data.getPath()))
+ if !data.IpRadiusSourceInterfaceVlan.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ip/Cisco-IOS-XE-aaa:radius/source-interface/Vlan")
}
- if !data.IpDomainLookupSourceInterfaceHundredGigabitEthernet.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/domain/lookup-settings/lookup/source-interface/HundredGigE", data.getPath()))
+ if !data.IpRadiusSourceInterfaceGigabitEthernet.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ip/Cisco-IOS-XE-aaa:radius/source-interface/GigabitEthernet")
}
- if !data.IpDomainLookupSourceInterfaceFortyGigabitEthernet.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/domain/lookup-settings/lookup/source-interface/FortyGigabitEthernet", data.getPath()))
+ if !data.IpRadiusSourceInterfaceTwoGigabitEthernet.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ip/Cisco-IOS-XE-aaa:radius/source-interface/TwoGigabitEthernet")
}
- if !data.IpDomainLookupSourceInterfaceTwentyFiveGigabitEthernet.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/domain/lookup-settings/lookup/source-interface/TwentyFiveGigE", data.getPath()))
+ if !data.IpRadiusSourceInterfaceFiveGigabitEthernet.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ip/Cisco-IOS-XE-aaa:radius/source-interface/FiveGigabitEthernet")
}
- if !data.IpDomainLookupSourceInterfaceTenGigabitEthernet.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/domain/lookup-settings/lookup/source-interface/TenGigabitEthernet", data.getPath()))
+ if !data.IpRadiusSourceInterfaceTenGigabitEthernet.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ip/Cisco-IOS-XE-aaa:radius/source-interface/TenGigabitEthernet")
}
- if !data.IpDomainLookupSourceInterfaceFiveGigabitEthernet.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/domain/lookup-settings/lookup/source-interface/FiveGigabitEthernet", data.getPath()))
+ if !data.IpRadiusSourceInterfaceTwentyFiveGigabitEthernet.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ip/Cisco-IOS-XE-aaa:radius/source-interface/TwentyFiveGigE")
}
- if !data.IpDomainLookupSourceInterfaceTwoGigabitEthernet.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/domain/lookup-settings/lookup/source-interface/TwoGigabitEthernet", data.getPath()))
+ if !data.IpRadiusSourceInterfaceFortyGigabitEthernet.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ip/Cisco-IOS-XE-aaa:radius/source-interface/FortyGigabitEthernet")
}
- if !data.IpDomainLookupSourceInterfaceGigabitEthernet.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/domain/lookup-settings/lookup/source-interface/GigabitEthernet", data.getPath()))
+ if !data.IpRadiusSourceInterfaceHundredGigabitEthernet.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ip/Cisco-IOS-XE-aaa:radius/source-interface/HundredGigE")
}
- if !data.IpDomainLookupSourceInterfaceVlan.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/domain/lookup-settings/lookup/source-interface/Vlan", data.getPath()))
+ if !data.IpRadiusSourceInterfaceVrf.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ip/Cisco-IOS-XE-aaa:radius/source-interface/vrf")
}
- if !data.IpDomainLookupSourceInterfaceLoopback.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/domain/lookup-settings/lookup/source-interface/Loopback", data.getPath()))
+ for i := range data.BootSystemFlashFiles {
+ keys := [...]string{"flash-leaf"}
+ keyValues := [...]string{data.BootSystemFlashFiles[i].Path.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/boot/system/flash/flash-list-ordered-by-user%v", predicates))
}
- for i := range data.IpNameServersVrf {
- keyValues := [...]string{data.IpNameServersVrf[i].Vrf.ValueString()}
+ for i := range data.BootSystemBootfiles {
+ keys := [...]string{"filename"}
+ keyValues := [...]string{data.BootSystemBootfiles[i].Path.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
- deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/name-server/vrf=%v", data.getPath(), strings.Join(keyValues[:], ",")))
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/boot/system/bootfile/filename-list-ordered-by-user%v", predicates))
}
- if !data.IpNameServers.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/name-server/no-vrf-ordered", data.getPath()))
+ if !data.EnableSecret.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/enable/secret/secret")
}
- if !data.IpHttpActiveSessionModules.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/Cisco-IOS-XE-http:http/active-session-modules", data.getPath()))
+ if !data.EnableSecretType.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/enable/secret/type")
}
- if !data.IpHttpMaxConnections.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/Cisco-IOS-XE-http:http/max-connections", data.getPath()))
+ if !data.EnableSecretLevel.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/enable/secret/level")
}
- if !data.IpHttpSecureActiveSessionModules.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/Cisco-IOS-XE-http:http/secure-active-session-modules", data.getPath()))
+ for i := range data.IpHosts {
+ keys := [...]string{"name"}
+ keyValues := [...]string{data.IpHosts[i].Name.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/ip/host/host-list%v", predicates))
}
- if !data.IpHttpClientSourceInterface.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/Cisco-IOS-XE-http:http/client/source-interface", data.getPath()))
+ for i := range data.IpHostsVrf {
+ keys := [...]string{"vrf-name"}
+ keyValues := [...]string{data.IpHostsVrf[i].Vrf.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/ip/host/vrf%v", predicates))
}
- if !data.IpHttpClientSecureTrustpoint.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/Cisco-IOS-XE-http:http/client/secure-trustpoint", data.getPath()))
+ if !data.DiagnosticEventLogSize.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-diagnostics:diagnostic/event-log/size")
}
- if !data.IpHttpTlsVersion.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/Cisco-IOS-XE-http:http/tls-version", data.getPath()))
+ if !data.SubscriberTemplating.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/subscriber/templating")
}
- if !data.IpHttpSecureTrustpoint.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/Cisco-IOS-XE-http:http/secure-trustpoint", data.getPath()))
+ if !data.CallHomeContactEmail.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/call-home/Cisco-IOS-XE-call-home:contact-email-addr")
}
- if !data.IpHttpSecureServer.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/Cisco-IOS-XE-http:http/secure-server", data.getPath()))
+ if !data.CallHomeCiscoTac1ProfileActive.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/call-home/Cisco-IOS-XE-call-home:tac-profile/profile/CiscoTAC-1/active")
}
- if !data.IpHttpServer.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/Cisco-IOS-XE-http:http/server", data.getPath()))
+ if !data.CallHomeCiscoTac1DestinationTransportMethod.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/call-home/Cisco-IOS-XE-call-home:tac-profile/profile/CiscoTAC-1/destination/transport-method")
}
- if !data.IpHttpAuthenticationLocal.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/Cisco-IOS-XE-http:http/authentication/local", data.getPath()))
+ if !data.IpFtpPassive.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ip/ftp/passive-enable")
}
- for i := range data.IpHttpAuthenticationAaaCommandAuthorization {
- keyValues := [...]string{strconv.FormatInt(data.IpHttpAuthenticationAaaCommandAuthorization[i].Level.ValueInt64(), 10)}
-
- deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/Cisco-IOS-XE-http:http/authentication/aaa/command-authorization=%v", data.getPath(), strings.Join(keyValues[:], ",")))
+ if !data.TftpSourceInterfaceGigabitEthernet.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ip/tftp/source-interface/GigabitEthernet")
}
- if !data.IpHttpAuthenticationAaaLoginAuthentication.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/Cisco-IOS-XE-http:http/authentication/aaa/login-authentication", data.getPath()))
+ if !data.TftpSourceInterfaceLoopback.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ip/tftp/source-interface/Loopback")
}
- if !data.IpHttpAuthenticationAaaExecAuthorization.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/Cisco-IOS-XE-http:http/authentication/aaa/exec-authorization", data.getPath()))
+ if !data.TftpSourceInterfaceVlan.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ip/tftp/source-interface/Vlan")
}
- if !data.IpHttpAuthenticationAaa.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/Cisco-IOS-XE-http:http/authentication/aaa", data.getPath()))
+ if !data.TftpSourceInterfaceTwoGigabitEthernet.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ip/tftp/source-interface/TwoGigabitEthernet")
}
- if !data.IpHttpAccessClass.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/Cisco-IOS-XE-http:http/access-class", data.getPath()))
+ if !data.TftpSourceInterfaceFiveGigabitEthernet.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ip/tftp/source-interface/FiveGigabitEthernet")
}
- for i := range data.MulticastRoutingVrfs {
- keyValues := [...]string{data.MulticastRoutingVrfs[i].Vrf.ValueString()}
-
- deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/Cisco-IOS-XE-multicast:multicast-routing/vrf=%v", data.getPath(), strings.Join(keyValues[:], ",")))
+ if !data.TftpSourceInterfaceTenGigabitEthernet.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ip/tftp/source-interface/TenGigabitEthernet")
}
- if !data.IpMulticastRoutingDistributed.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/Cisco-IOS-XE-multicast:multicast-routing/distributed", data.getPath()))
+ if !data.TftpSourceInterfaceTwentyFiveGigabitEthernet.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ip/tftp/source-interface/TwentyFiveGigabitEthernet")
}
- if !data.MulticastRoutingSwitch.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/Cisco-IOS-XE-multicast:mcr-conf/multicast-routing", data.getPath()))
+ if !data.TftpSourceInterfaceFortyGigabitEthernet.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ip/tftp/source-interface/FortyGigabitEthernet")
}
- if !data.IpMulticastRouting.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/Cisco-IOS-XE-multicast:multicast-routing", data.getPath()))
+ if !data.TftpSourceInterfaceHundredGigabitEthernet.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ip/tftp/source-interface/HundredGigE")
}
- if !data.LoginOnSuccessLog.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/login/on-success/log", data.getPath()))
+ if !data.MultilinkPppBundleName.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/multilink/Cisco-IOS-XE-ppp:bundle-name")
}
- if !data.LoginOnSuccess.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/login/on-success", data.getPath()))
+ if !data.Version.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/version")
}
- if !data.LoginOnFailureLog.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/login/on-failure/log", data.getPath()))
+ for i := range data.TrackObjects {
+ keys := [...]string{"object-number"}
+ keyValues := [...]string{data.TrackObjects[i].Number.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/track/Cisco-IOS-XE-track:tracked-object-v2%v", predicates))
}
- if !data.LoginOnFailure.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/login/on-failure", data.getPath()))
+ if !data.IpNbarClassificationDnsClassifyByDomain.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ip/Cisco-IOS-XE-nbar:nbar/classification/dns/classify-by-domain-with-default")
}
- if !data.LoginDelay.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/login/delay", data.getPath()))
+ if !data.IpMulticastRouteLimit.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ip/multicast/Cisco-IOS-XE-multicast:route-limit-container/routelimit")
}
- if !data.IpDomainName.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/domain/name", data.getPath()))
+ if !data.SecurityPasswordsMinLength.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-aaa:security/passwords/min-length")
}
- if !data.IpDomainLookup.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/domain/lookup", data.getPath()))
+ if !data.IpDomainListNames.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ip/domain/list/domain-name")
}
- if !data.IpSourceRoute.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/source-route", data.getPath()))
+ if !data.IpDomainListVrfDomain.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ip/domain/list/vrf/domain-name")
}
- if !data.Mtu.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/system/Cisco-IOS-XE-switch:mtu/size", data.getPath()))
+ if !data.IpDomainListVrf.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ip/domain/list/vrf/vrf-name")
}
- if !data.Ipv6UnicastRouting.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/ipv6/unicast-routing", data.getPath()))
+ if !data.EthernetCfmAlarmConfigDelay.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ethernet/Cisco-IOS-XE-ethernet:cfm/alarm-config/delay")
}
- if !data.IpRouting.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/routing-conf/routing", data.getPath()))
+ if !data.EthernetCfmAlarmConfigReset.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ethernet/Cisco-IOS-XE-ethernet:cfm/alarm-config/reset")
}
- if !data.IpBgpCommunityNewFormat.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/ip/bgp-community/new-format", data.getPath()))
+ if !data.StandbyRedirects.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/standby/redirects-config/redirects")
}
- if !data.Hostname.IsNull() {
- deletePaths = append(deletePaths, fmt.Sprintf("%v/hostname", data.getPath()))
+ if !data.StandbyRedirectsEnableDisable.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/standby/redirects-config/redirect-enable-disable/redirects")
}
- return deletePaths
+ return b.Res()
}
-// End of section. //template:end getDeletePaths
+// End of section. //template:end addDeletePathsXML
diff --git a/internal/provider/model_iosxe_tacacs_server.go b/internal/provider/model_iosxe_tacacs_server.go
index 3f16b889..f94f8b08 100644
--- a/internal/provider/model_iosxe_tacacs_server.go
+++ b/internal/provider/model_iosxe_tacacs_server.go
@@ -29,6 +29,9 @@ import (
"github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/types"
+ "github.com/hashicorp/terraform-plugin-log/tflog"
+ "github.com/netascode/go-netconf"
+ "github.com/netascode/xmldot"
"github.com/tidwall/gjson"
"github.com/tidwall/sjson"
)
@@ -80,6 +83,19 @@ func (data TACACSServer) getPathShort() string {
return matches[1]
}
+// getXPath returns the XPath for NETCONF operations
+func (data TACACSServer) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/tacacs/Cisco-IOS-XE-aaa:server[name=%v]"
+ path = fmt.Sprintf(path, fmt.Sprintf("%v", data.Name.ValueString()))
+ return path
+}
+
+func (data TACACSServerData) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/tacacs/Cisco-IOS-XE-aaa:server[name=%v]"
+ path = fmt.Sprintf(path, fmt.Sprintf("%v", data.Name.ValueString()))
+ return path
+}
+
// End of section. //template:end getPath
// Section below is generated&owned by "gen/generator.go". //template:begin toBody
@@ -106,6 +122,34 @@ func (data TACACSServer) toBody(ctx context.Context) string {
// End of section. //template:end toBody
+// Section below is generated&owned by "gen/generator.go". //template:begin toBodyXML
+
+func (data TACACSServer) toBodyXML(ctx context.Context) string {
+ body := netconf.Body{}
+ if !data.Name.IsNull() && !data.Name.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/name", data.Name.ValueString())
+ }
+ if !data.AddressIpv4.IsNull() && !data.AddressIpv4.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/address/ipv4", data.AddressIpv4.ValueString())
+ }
+ if !data.Timeout.IsNull() && !data.Timeout.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/timeout", strconv.FormatInt(data.Timeout.ValueInt64(), 10))
+ }
+ if !data.Encryption.IsNull() && !data.Encryption.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/key/encryption", data.Encryption.ValueString())
+ }
+ if !data.Key.IsNull() && !data.Key.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/key/key", data.Key.ValueString())
+ }
+ bodyString, err := body.String()
+ if err != nil {
+ tflog.Error(ctx, fmt.Sprintf("Error converting body to string: %s", err))
+ }
+ return bodyString
+}
+
+// End of section. //template:end toBodyXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBody
func (data *TACACSServer) updateFromBody(ctx context.Context, res gjson.Result) {
@@ -132,6 +176,28 @@ func (data *TACACSServer) updateFromBody(ctx context.Context, res gjson.Result)
// End of section. //template:end updateFromBody
+// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBodyXML
+
+func (data *TACACSServer) updateFromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/name"); value.Exists() && !data.Name.IsNull() {
+ data.Name = types.StringValue(value.String())
+ } else {
+ data.Name = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/address/ipv4"); value.Exists() && !data.AddressIpv4.IsNull() {
+ data.AddressIpv4 = types.StringValue(value.String())
+ } else {
+ data.AddressIpv4 = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/timeout"); value.Exists() && !data.Timeout.IsNull() {
+ data.Timeout = types.Int64Value(value.Int())
+ } else {
+ data.Timeout = types.Int64Null()
+ }
+}
+
+// End of section. //template:end updateFromBodyXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin fromBody
func (data *TACACSServer) fromBody(ctx context.Context, res gjson.Result) {
@@ -178,6 +244,44 @@ func (data *TACACSServerData) fromBody(ctx context.Context, res gjson.Result) {
// End of section. //template:end fromBodyData
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyXML
+
+func (data *TACACSServer) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/address/ipv4"); value.Exists() {
+ data.AddressIpv4 = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/timeout"); value.Exists() {
+ data.Timeout = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/key/encryption"); value.Exists() {
+ data.Encryption = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/key/key"); value.Exists() {
+ data.Key = types.StringValue(value.String())
+ }
+}
+
+// End of section. //template:end fromBodyXML
+
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyDataXML
+
+func (data *TACACSServerData) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/address/ipv4"); value.Exists() {
+ data.AddressIpv4 = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/timeout"); value.Exists() {
+ data.Timeout = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/key/encryption"); value.Exists() {
+ data.Encryption = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/key/key"); value.Exists() {
+ data.Key = types.StringValue(value.String())
+ }
+}
+
+// End of section. //template:end fromBodyDataXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin getDeletedItems
func (data *TACACSServer) getDeletedItems(ctx context.Context, state TACACSServer) []string {
@@ -200,6 +304,28 @@ func (data *TACACSServer) getDeletedItems(ctx context.Context, state TACACSServe
// End of section. //template:end getDeletedItems
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletedItemsXML
+
+func (data *TACACSServer) addDeletedItemsXML(ctx context.Context, state TACACSServer, body string) string {
+ b := netconf.NewBody(body)
+ if !state.AddressIpv4.IsNull() && data.AddressIpv4.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/address/ipv4")
+ }
+ if !state.Timeout.IsNull() && data.Timeout.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/timeout")
+ }
+ if !state.Encryption.IsNull() && data.Encryption.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/key/encryption")
+ }
+ if !state.Key.IsNull() && data.Key.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/key/key")
+ }
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletedItemsXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin getEmptyLeafsDelete
func (data *TACACSServer) getEmptyLeafsDelete(ctx context.Context) []string {
@@ -231,3 +357,25 @@ func (data *TACACSServer) getDeletePaths(ctx context.Context) []string {
}
// End of section. //template:end getDeletePaths
+
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletePathsXML
+
+func (data *TACACSServer) addDeletePathsXML(ctx context.Context, body string) string {
+ b := netconf.NewBody(body)
+ if !data.AddressIpv4.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/address/ipv4")
+ }
+ if !data.Timeout.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/timeout")
+ }
+ if !data.Encryption.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/key/encryption")
+ }
+ if !data.Key.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/key/key")
+ }
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletePathsXML
diff --git a/internal/provider/model_iosxe_template.go b/internal/provider/model_iosxe_template.go
index ff868e5f..76222db2 100644
--- a/internal/provider/model_iosxe_template.go
+++ b/internal/provider/model_iosxe_template.go
@@ -31,6 +31,9 @@ import (
"github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/types"
+ "github.com/hashicorp/terraform-plugin-log/tflog"
+ "github.com/netascode/go-netconf"
+ "github.com/netascode/xmldot"
"github.com/tidwall/gjson"
"github.com/tidwall/sjson"
)
@@ -229,6 +232,19 @@ func (data Template) getPathShort() string {
return matches[1]
}
+// getXPath returns the XPath for NETCONF operations
+func (data Template) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/template/Cisco-IOS-XE-template:template_details[template_name=%v]"
+ path = fmt.Sprintf(path, fmt.Sprintf("%v", data.TemplateName.ValueString()))
+ return path
+}
+
+func (data TemplateData) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/template/Cisco-IOS-XE-template:template_details[template_name=%v]"
+ path = fmt.Sprintf(path, fmt.Sprintf("%v", data.TemplateName.ValueString()))
+ return path
+}
+
// End of section. //template:end getPath
// Section below is generated&owned by "gen/generator.go". //template:begin toBody
@@ -260,7 +276,7 @@ func (data Template) toBody(ctx context.Context) string {
body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"service-policy.output.policy-map-name", data.ServicePolicyOutput.ValueString())
}
if !data.SourceTemplate.IsNull() && !data.SourceTemplate.IsUnknown() {
- body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"source.template", data.SourceTemplate.ValueString())
+ body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"", data.SourceTemplate.ValueString())
}
if !data.SwitchportModeTrunk.IsNull() && !data.SwitchportModeTrunk.IsUnknown() {
if data.SwitchportModeTrunk.ValueBool() {
@@ -553,704 +569,2382 @@ func (data Template) toBody(ctx context.Context) string {
// End of section. //template:end toBody
-// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBody
+// Section below is generated&owned by "gen/generator.go". //template:begin toBodyXML
-func (data *Template) updateFromBody(ctx context.Context, res gjson.Result) {
- prefix := helpers.LastElement(data.getPath()) + "."
- if res.Get(helpers.LastElement(data.getPath())).IsArray() {
- prefix += "0."
- }
- if value := res.Get(prefix + "template_name"); value.Exists() && !data.TemplateName.IsNull() {
- data.TemplateName = types.StringValue(value.String())
- } else {
- data.TemplateName = types.StringNull()
+func (data Template) toBodyXML(ctx context.Context) string {
+ body := netconf.Body{}
+ if !data.TemplateName.IsNull() && !data.TemplateName.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/template_name", data.TemplateName.ValueString())
}
- if value := res.Get(prefix + "dot1x.pae"); value.Exists() && !data.Dot1xPae.IsNull() {
- data.Dot1xPae = types.StringValue(value.String())
- } else {
- data.Dot1xPae = types.StringNull()
+ if !data.Dot1xPae.IsNull() && !data.Dot1xPae.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/dot1x/pae", data.Dot1xPae.ValueString())
}
- if value := res.Get(prefix + "dot1x.max-reauth-req"); value.Exists() && !data.Dot1xMaxReauthReq.IsNull() {
- data.Dot1xMaxReauthReq = types.Int64Value(value.Int())
- } else {
- data.Dot1xMaxReauthReq = types.Int64Null()
+ if !data.Dot1xMaxReauthReq.IsNull() && !data.Dot1xMaxReauthReq.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/dot1x/max-reauth-req", strconv.FormatInt(data.Dot1xMaxReauthReq.ValueInt64(), 10))
}
- if value := res.Get(prefix + "dot1x.max-req"); value.Exists() && !data.Dot1xMaxReq.IsNull() {
- data.Dot1xMaxReq = types.Int64Value(value.Int())
- } else {
- data.Dot1xMaxReq = types.Int64Null()
+ if !data.Dot1xMaxReq.IsNull() && !data.Dot1xMaxReq.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/dot1x/max-req", strconv.FormatInt(data.Dot1xMaxReq.ValueInt64(), 10))
}
- if value := res.Get(prefix + "dot1x.timeout.tx-period"); value.Exists() && !data.Dot1xTimeoutTxPeriod.IsNull() {
- data.Dot1xTimeoutTxPeriod = types.Int64Value(value.Int())
- } else {
- data.Dot1xTimeoutTxPeriod = types.Int64Null()
+ if !data.Dot1xTimeoutTxPeriod.IsNull() && !data.Dot1xTimeoutTxPeriod.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/dot1x/timeout/tx-period", strconv.FormatInt(data.Dot1xTimeoutTxPeriod.ValueInt64(), 10))
}
- if value := res.Get(prefix + "service-policy.type.control.subscriber"); value.Exists() && !data.ServicePolicyTypeControlSubscriber.IsNull() {
- data.ServicePolicyTypeControlSubscriber = types.StringValue(value.String())
- } else {
- data.ServicePolicyTypeControlSubscriber = types.StringNull()
+ if !data.ServicePolicyTypeControlSubscriber.IsNull() && !data.ServicePolicyTypeControlSubscriber.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/service-policy/type/control/subscriber", data.ServicePolicyTypeControlSubscriber.ValueString())
}
- if value := res.Get(prefix + "service-policy.input.policy-map-name"); value.Exists() && !data.ServicePolicyInput.IsNull() {
- data.ServicePolicyInput = types.StringValue(value.String())
- } else {
- data.ServicePolicyInput = types.StringNull()
+ if !data.ServicePolicyInput.IsNull() && !data.ServicePolicyInput.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/service-policy/input/policy-map-name", data.ServicePolicyInput.ValueString())
}
- if value := res.Get(prefix + "service-policy.output.policy-map-name"); value.Exists() && !data.ServicePolicyOutput.IsNull() {
- data.ServicePolicyOutput = types.StringValue(value.String())
- } else {
- data.ServicePolicyOutput = types.StringNull()
+ if !data.ServicePolicyOutput.IsNull() && !data.ServicePolicyOutput.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/service-policy/output/policy-map-name", data.ServicePolicyOutput.ValueString())
}
- if value := res.Get(prefix + "source.template"); value.Exists() && !data.SourceTemplate.IsNull() {
- data.SourceTemplate = types.StringValue(value.String())
- } else {
- data.SourceTemplate = types.StringNull()
+ if !data.SourceTemplate.IsNull() && !data.SourceTemplate.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/", data.SourceTemplate.ValueString())
}
- if value := res.Get(prefix + "switchport.mode.trunk"); !data.SwitchportModeTrunk.IsNull() {
- if value.Exists() {
- data.SwitchportModeTrunk = types.BoolValue(true)
+ if !data.SwitchportModeTrunk.IsNull() && !data.SwitchportModeTrunk.IsUnknown() {
+ if data.SwitchportModeTrunk.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/switchport/mode/trunk", "")
} else {
- data.SwitchportModeTrunk = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/switchport/mode/trunk")
}
- } else {
- data.SwitchportModeTrunk = types.BoolNull()
}
- if value := res.Get(prefix + "switchport.mode.access"); !data.SwitchportModeAccess.IsNull() {
- if value.Exists() {
- data.SwitchportModeAccess = types.BoolValue(true)
+ if !data.SwitchportModeAccess.IsNull() && !data.SwitchportModeAccess.IsUnknown() {
+ if data.SwitchportModeAccess.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/switchport/mode/access", "")
} else {
- data.SwitchportModeAccess = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/switchport/mode/access")
}
- } else {
- data.SwitchportModeAccess = types.BoolNull()
}
- if value := res.Get(prefix + "switchport.nonegotiate"); !data.SwitchportNonegotiate.IsNull() {
- if value.Exists() {
- data.SwitchportNonegotiate = types.BoolValue(true)
+ if !data.SwitchportNonegotiate.IsNull() && !data.SwitchportNonegotiate.IsUnknown() {
+ if data.SwitchportNonegotiate.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/switchport/nonegotiate", "")
} else {
- data.SwitchportNonegotiate = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/switchport/nonegotiate")
}
- } else {
- data.SwitchportNonegotiate = types.BoolNull()
}
- if value := res.Get(prefix + "switchport.block.unicast"); !data.SwitchportBlockUnicast.IsNull() {
- if value.Exists() {
- data.SwitchportBlockUnicast = types.BoolValue(true)
+ if !data.SwitchportBlockUnicast.IsNull() && !data.SwitchportBlockUnicast.IsUnknown() {
+ if data.SwitchportBlockUnicast.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/switchport/block/unicast", "")
} else {
- data.SwitchportBlockUnicast = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/switchport/block/unicast")
}
- } else {
- data.SwitchportBlockUnicast = types.BoolNull()
}
- if value := res.Get(prefix + "switchport.port-security"); !data.SwitchportPortSecurity.IsNull() {
- if value.Exists() {
- data.SwitchportPortSecurity = types.BoolValue(true)
+ if !data.SwitchportPortSecurity.IsNull() && !data.SwitchportPortSecurity.IsUnknown() {
+ if data.SwitchportPortSecurity.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/switchport/port-security", "")
} else {
- data.SwitchportPortSecurity = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/switchport/port-security")
}
- } else {
- data.SwitchportPortSecurity = types.BoolNull()
}
- if value := res.Get(prefix + "switchport.port-security.aging.static"); !data.SwitchportPortSecurityAgingStatic.IsNull() {
- if value.Exists() {
- data.SwitchportPortSecurityAgingStatic = types.BoolValue(true)
+ if !data.SwitchportPortSecurityAgingStatic.IsNull() && !data.SwitchportPortSecurityAgingStatic.IsUnknown() {
+ if data.SwitchportPortSecurityAgingStatic.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/switchport/port-security/aging/static", "")
} else {
- data.SwitchportPortSecurityAgingStatic = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/switchport/port-security/aging/static")
}
- } else {
- data.SwitchportPortSecurityAgingStatic = types.BoolNull()
}
- if value := res.Get(prefix + "switchport.port-security.aging.time"); value.Exists() && !data.SwitchportPortSecurityAgingTime.IsNull() {
- data.SwitchportPortSecurityAgingTime = types.Int64Value(value.Int())
- } else {
- data.SwitchportPortSecurityAgingTime = types.Int64Null()
+ if !data.SwitchportPortSecurityAgingTime.IsNull() && !data.SwitchportPortSecurityAgingTime.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/switchport/port-security/aging/time", strconv.FormatInt(data.SwitchportPortSecurityAgingTime.ValueInt64(), 10))
}
- if value := res.Get(prefix + "switchport.port-security.aging.type"); !data.SwitchportPortSecurityAgingType.IsNull() {
- if value.Exists() {
- data.SwitchportPortSecurityAgingType = types.BoolValue(true)
+ if !data.SwitchportPortSecurityAgingType.IsNull() && !data.SwitchportPortSecurityAgingType.IsUnknown() {
+ if data.SwitchportPortSecurityAgingType.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/switchport/port-security/aging/type", "")
} else {
- data.SwitchportPortSecurityAgingType = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/switchport/port-security/aging/type")
}
- } else {
- data.SwitchportPortSecurityAgingType = types.BoolNull()
}
- if value := res.Get(prefix + "switchport.port-security.aging.type.inactivity"); !data.SwitchportPortSecurityAgingTypeInactivity.IsNull() {
- if value.Exists() {
- data.SwitchportPortSecurityAgingTypeInactivity = types.BoolValue(true)
+ if !data.SwitchportPortSecurityAgingTypeInactivity.IsNull() && !data.SwitchportPortSecurityAgingTypeInactivity.IsUnknown() {
+ if data.SwitchportPortSecurityAgingTypeInactivity.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/switchport/port-security/aging/type/inactivity", "")
} else {
- data.SwitchportPortSecurityAgingTypeInactivity = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/switchport/port-security/aging/type/inactivity")
}
- } else {
- data.SwitchportPortSecurityAgingTypeInactivity = types.BoolNull()
}
- for i := range data.SwitchportPortSecurityMaximumRange {
- keys := [...]string{"range"}
- keyValues := [...]string{strconv.FormatInt(data.SwitchportPortSecurityMaximumRange[i].Range.ValueInt64(), 10)}
-
- var r gjson.Result
- res.Get(prefix + "switchport.port-security.maximum.range").ForEach(
- func(_, v gjson.Result) bool {
- found := false
- for ik := range keys {
- if v.Get(keys[ik]).String() == keyValues[ik] {
- found = true
- continue
- }
- found = false
- break
- }
- if found {
- r = v
- return false
+ if len(data.SwitchportPortSecurityMaximumRange) > 0 {
+ for _, item := range data.SwitchportPortSecurityMaximumRange {
+ cBody := netconf.Body{}
+ if !item.Range.IsNull() && !item.Range.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "range", strconv.FormatInt(item.Range.ValueInt64(), 10))
+ }
+ if !item.Vlan.IsNull() && !item.Vlan.IsUnknown() {
+ if item.Vlan.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "vlan", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "vlan")
}
- return true
- },
- )
- if value := r.Get("range"); value.Exists() && !data.SwitchportPortSecurityMaximumRange[i].Range.IsNull() {
- data.SwitchportPortSecurityMaximumRange[i].Range = types.Int64Value(value.Int())
- } else {
- data.SwitchportPortSecurityMaximumRange[i].Range = types.Int64Null()
- }
- if value := r.Get("vlan"); !data.SwitchportPortSecurityMaximumRange[i].Vlan.IsNull() {
- if value.Exists() {
- data.SwitchportPortSecurityMaximumRange[i].Vlan = types.BoolValue(true)
- } else {
- data.SwitchportPortSecurityMaximumRange[i].Vlan = types.BoolValue(false)
}
- } else {
- data.SwitchportPortSecurityMaximumRange[i].Vlan = types.BoolNull()
- }
- if value := r.Get("vlan.access"); !data.SwitchportPortSecurityMaximumRange[i].VlanAccess.IsNull() {
- if value.Exists() {
- data.SwitchportPortSecurityMaximumRange[i].VlanAccess = types.BoolValue(true)
- } else {
- data.SwitchportPortSecurityMaximumRange[i].VlanAccess = types.BoolValue(false)
+ if !item.VlanAccess.IsNull() && !item.VlanAccess.IsUnknown() {
+ if item.VlanAccess.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "vlan/access", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "vlan/access")
+ }
}
- } else {
- data.SwitchportPortSecurityMaximumRange[i].VlanAccess = types.BoolNull()
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/switchport/port-security/maximum/range", cBody.Res())
}
}
- if value := res.Get(prefix + "switchport.port-security.violation.protect"); !data.SwitchportPortSecurityViolationProtect.IsNull() {
- if value.Exists() {
- data.SwitchportPortSecurityViolationProtect = types.BoolValue(true)
+ if !data.SwitchportPortSecurityViolationProtect.IsNull() && !data.SwitchportPortSecurityViolationProtect.IsUnknown() {
+ if data.SwitchportPortSecurityViolationProtect.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/switchport/port-security/violation/protect", "")
} else {
- data.SwitchportPortSecurityViolationProtect = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/switchport/port-security/violation/protect")
}
- } else {
- data.SwitchportPortSecurityViolationProtect = types.BoolNull()
}
- if value := res.Get(prefix + "switchport.port-security.violation.restrict"); !data.SwitchportPortSecurityViolationRestrict.IsNull() {
- if value.Exists() {
- data.SwitchportPortSecurityViolationRestrict = types.BoolValue(true)
+ if !data.SwitchportPortSecurityViolationRestrict.IsNull() && !data.SwitchportPortSecurityViolationRestrict.IsUnknown() {
+ if data.SwitchportPortSecurityViolationRestrict.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/switchport/port-security/violation/restrict", "")
} else {
- data.SwitchportPortSecurityViolationRestrict = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/switchport/port-security/violation/restrict")
}
- } else {
- data.SwitchportPortSecurityViolationRestrict = types.BoolNull()
}
- if value := res.Get(prefix + "switchport.port-security.violation.shutdown"); !data.SwitchportPortSecurityViolationShutdown.IsNull() {
- if value.Exists() {
- data.SwitchportPortSecurityViolationShutdown = types.BoolValue(true)
+ if !data.SwitchportPortSecurityViolationShutdown.IsNull() && !data.SwitchportPortSecurityViolationShutdown.IsUnknown() {
+ if data.SwitchportPortSecurityViolationShutdown.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/switchport/port-security/violation/shutdown", "")
} else {
- data.SwitchportPortSecurityViolationShutdown = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/switchport/port-security/violation/shutdown")
}
- } else {
- data.SwitchportPortSecurityViolationShutdown = types.BoolNull()
}
- if value := res.Get(prefix + "switchport.access.vlan"); value.Exists() && !data.SwitchportAccessVlan.IsNull() {
- data.SwitchportAccessVlan = types.Int64Value(value.Int())
- } else {
- data.SwitchportAccessVlan = types.Int64Null()
+ if !data.SwitchportAccessVlan.IsNull() && !data.SwitchportAccessVlan.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/switchport/access/vlan", strconv.FormatInt(data.SwitchportAccessVlan.ValueInt64(), 10))
}
- if value := res.Get(prefix + "switchport.voice.vlan"); value.Exists() && !data.SwitchportVoiceVlan.IsNull() {
- data.SwitchportVoiceVlan = types.Int64Value(value.Int())
- } else {
- data.SwitchportVoiceVlan = types.Int64Null()
+ if !data.SwitchportVoiceVlan.IsNull() && !data.SwitchportVoiceVlan.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/switchport/voice/vlan", strconv.FormatInt(data.SwitchportVoiceVlan.ValueInt64(), 10))
}
- if value := res.Get(prefix + "switchport.private-vlan.host-association.primary-range"); value.Exists() && !data.SwitchportPrivateVlanHostAssociationPrimaryRange.IsNull() {
- data.SwitchportPrivateVlanHostAssociationPrimaryRange = types.Int64Value(value.Int())
- } else {
- data.SwitchportPrivateVlanHostAssociationPrimaryRange = types.Int64Null()
+ if !data.SwitchportPrivateVlanHostAssociationPrimaryRange.IsNull() && !data.SwitchportPrivateVlanHostAssociationPrimaryRange.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/switchport/private-vlan/host-association/primary-range", strconv.FormatInt(data.SwitchportPrivateVlanHostAssociationPrimaryRange.ValueInt64(), 10))
}
- if value := res.Get(prefix + "switchport.private-vlan.host-association.secondary-range"); value.Exists() && !data.SwitchportPrivateVlanHostAssociationSecondaryRange.IsNull() {
- data.SwitchportPrivateVlanHostAssociationSecondaryRange = types.Int64Value(value.Int())
- } else {
- data.SwitchportPrivateVlanHostAssociationSecondaryRange = types.Int64Null()
+ if !data.SwitchportPrivateVlanHostAssociationSecondaryRange.IsNull() && !data.SwitchportPrivateVlanHostAssociationSecondaryRange.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/switchport/private-vlan/host-association/secondary-range", strconv.FormatInt(data.SwitchportPrivateVlanHostAssociationSecondaryRange.ValueInt64(), 10))
}
- if value := res.Get(prefix + "switchport.trunk.allowed.vlan.vlans"); value.Exists() && !data.SwitchportTrunkAllowedVlans.IsNull() {
- data.SwitchportTrunkAllowedVlans = types.StringValue(value.String())
- } else {
- data.SwitchportTrunkAllowedVlans = types.StringNull()
+ if !data.SwitchportTrunkAllowedVlans.IsNull() && !data.SwitchportTrunkAllowedVlans.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/switchport/trunk/allowed/vlan/vlans", data.SwitchportTrunkAllowedVlans.ValueString())
}
- if value := res.Get(prefix + "switchport.trunk.allowed.vlan.none"); !data.SwitchportTrunkAllowedVlansNone.IsNull() {
- if value.Exists() {
- data.SwitchportTrunkAllowedVlansNone = types.BoolValue(true)
+ if !data.SwitchportTrunkAllowedVlansNone.IsNull() && !data.SwitchportTrunkAllowedVlansNone.IsUnknown() {
+ if data.SwitchportTrunkAllowedVlansNone.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/switchport/trunk/allowed/vlan/none", "")
} else {
- data.SwitchportTrunkAllowedVlansNone = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/switchport/trunk/allowed/vlan/none")
}
- } else {
- data.SwitchportTrunkAllowedVlansNone = types.BoolNull()
}
- if value := res.Get(prefix + "switchport.trunk.allowed.vlan.all"); !data.SwitchportTrunkAllowedVlansAll.IsNull() {
- if value.Exists() {
- data.SwitchportTrunkAllowedVlansAll = types.BoolValue(true)
+ if !data.SwitchportTrunkAllowedVlansAll.IsNull() && !data.SwitchportTrunkAllowedVlansAll.IsUnknown() {
+ if data.SwitchportTrunkAllowedVlansAll.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/switchport/trunk/allowed/vlan/all", "")
} else {
- data.SwitchportTrunkAllowedVlansAll = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/switchport/trunk/allowed/vlan/all")
}
- } else {
- data.SwitchportTrunkAllowedVlansAll = types.BoolNull()
}
- if value := res.Get(prefix + "switchport.trunk.native.vlan.tag"); !data.SwitchportTrunkNativeVlanTag.IsNull() {
- if value.Exists() {
- data.SwitchportTrunkNativeVlanTag = types.BoolValue(value.Bool())
- }
- } else {
- data.SwitchportTrunkNativeVlanTag = types.BoolNull()
+ if !data.SwitchportTrunkNativeVlanTag.IsNull() && !data.SwitchportTrunkNativeVlanTag.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/switchport/trunk/native/vlan/tag", data.SwitchportTrunkNativeVlanTag.ValueBool())
}
- if value := res.Get(prefix + "switchport.trunk.native.vlan.vlan-id"); value.Exists() && !data.SwitchportTrunkNativeVlanVlanId.IsNull() {
- data.SwitchportTrunkNativeVlanVlanId = types.Int64Value(value.Int())
- } else {
- data.SwitchportTrunkNativeVlanVlanId = types.Int64Null()
+ if !data.SwitchportTrunkNativeVlanVlanId.IsNull() && !data.SwitchportTrunkNativeVlanVlanId.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/switchport/trunk/native/vlan/vlan-id", strconv.FormatInt(data.SwitchportTrunkNativeVlanVlanId.ValueInt64(), 10))
}
- if value := res.Get(prefix + "mab"); !data.Mab.IsNull() {
- if value.Exists() {
- data.Mab = types.BoolValue(true)
+ if !data.Mab.IsNull() && !data.Mab.IsUnknown() {
+ if data.Mab.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/mab", "")
} else {
- data.Mab = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/mab")
}
- } else {
- data.Mab = types.BoolNull()
}
- if value := res.Get(prefix + "mab.eap"); !data.MabEap.IsNull() {
- if value.Exists() {
- data.MabEap = types.BoolValue(true)
+ if !data.MabEap.IsNull() && !data.MabEap.IsUnknown() {
+ if data.MabEap.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/mab/eap", "")
} else {
- data.MabEap = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/mab/eap")
}
- } else {
- data.MabEap = types.BoolNull()
}
- if value := res.Get(prefix + "access-session.closed"); !data.AccessSessionClosed.IsNull() {
- if value.Exists() {
- data.AccessSessionClosed = types.BoolValue(true)
+ if !data.AccessSessionClosed.IsNull() && !data.AccessSessionClosed.IsUnknown() {
+ if data.AccessSessionClosed.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/access-session/closed", "")
} else {
- data.AccessSessionClosed = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/access-session/closed")
}
- } else {
- data.AccessSessionClosed = types.BoolNull()
}
- if value := res.Get(prefix + "access-session.monitor"); !data.AccessSessionMonitor.IsNull() {
- if value.Exists() {
- data.AccessSessionMonitor = types.BoolValue(value.Bool())
- }
- } else {
- data.AccessSessionMonitor = types.BoolNull()
+ if !data.AccessSessionMonitor.IsNull() && !data.AccessSessionMonitor.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/access-session/monitor", data.AccessSessionMonitor.ValueBool())
}
- if value := res.Get(prefix + "access-session.port-control"); value.Exists() && !data.AccessSessionPortControl.IsNull() {
- data.AccessSessionPortControl = types.StringValue(value.String())
- } else {
- data.AccessSessionPortControl = types.StringNull()
+ if !data.AccessSessionPortControl.IsNull() && !data.AccessSessionPortControl.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/access-session/port-control", data.AccessSessionPortControl.ValueString())
}
- if value := res.Get(prefix + "access-session.control-direction"); value.Exists() && !data.AccessSessionControlDirection.IsNull() {
- data.AccessSessionControlDirection = types.StringValue(value.String())
- } else {
- data.AccessSessionControlDirection = types.StringNull()
+ if !data.AccessSessionControlDirection.IsNull() && !data.AccessSessionControlDirection.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/access-session/control-direction", data.AccessSessionControlDirection.ValueString())
}
- if value := res.Get(prefix + "access-session.host-mode"); value.Exists() && !data.AccessSessionHostMode.IsNull() {
- data.AccessSessionHostMode = types.StringValue(value.String())
- } else {
- data.AccessSessionHostMode = types.StringNull()
+ if !data.AccessSessionHostMode.IsNull() && !data.AccessSessionHostMode.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/access-session/host-mode", data.AccessSessionHostMode.ValueString())
}
- if value := res.Get(prefix + "access-session.interface-template.sticky"); !data.AccessSessionInterfaceTemplateSticky.IsNull() {
- if value.Exists() {
- data.AccessSessionInterfaceTemplateSticky = types.BoolValue(true)
+ if !data.AccessSessionInterfaceTemplateSticky.IsNull() && !data.AccessSessionInterfaceTemplateSticky.IsUnknown() {
+ if data.AccessSessionInterfaceTemplateSticky.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/access-session/interface-template/sticky", "")
} else {
- data.AccessSessionInterfaceTemplateSticky = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/access-session/interface-template/sticky")
}
- } else {
- data.AccessSessionInterfaceTemplateSticky = types.BoolNull()
}
- if value := res.Get(prefix + "access-session.interface-template.sticky.timer"); value.Exists() && !data.AccessSessionInterfaceTemplateStickyTimer.IsNull() {
- data.AccessSessionInterfaceTemplateStickyTimer = types.Int64Value(value.Int())
- } else {
- data.AccessSessionInterfaceTemplateStickyTimer = types.Int64Null()
+ if !data.AccessSessionInterfaceTemplateStickyTimer.IsNull() && !data.AccessSessionInterfaceTemplateStickyTimer.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/access-session/interface-template/sticky/timer", strconv.FormatInt(data.AccessSessionInterfaceTemplateStickyTimer.ValueInt64(), 10))
}
- if value := res.Get(prefix + "authentication.periodic"); !data.AuthenticationPeriodic.IsNull() {
- if value.Exists() {
- data.AuthenticationPeriodic = types.BoolValue(true)
+ if !data.AuthenticationPeriodic.IsNull() && !data.AuthenticationPeriodic.IsUnknown() {
+ if data.AuthenticationPeriodic.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/authentication/periodic", "")
} else {
- data.AuthenticationPeriodic = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/authentication/periodic")
}
- } else {
- data.AuthenticationPeriodic = types.BoolNull()
}
- if value := res.Get(prefix + "authentication.timer.reauthenticate.server"); !data.AuthenticationTimerReauthenticateServer.IsNull() {
- if value.Exists() {
- data.AuthenticationTimerReauthenticateServer = types.BoolValue(true)
+ if !data.AuthenticationTimerReauthenticateServer.IsNull() && !data.AuthenticationTimerReauthenticateServer.IsUnknown() {
+ if data.AuthenticationTimerReauthenticateServer.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/authentication/timer/reauthenticate/server", "")
} else {
- data.AuthenticationTimerReauthenticateServer = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/authentication/timer/reauthenticate/server")
}
- } else {
- data.AuthenticationTimerReauthenticateServer = types.BoolNull()
}
- if value := res.Get(prefix + "authentication.timer.reauthenticate.range"); value.Exists() && !data.AuthenticationTimerReauthenticateRange.IsNull() {
- data.AuthenticationTimerReauthenticateRange = types.Int64Value(value.Int())
- } else {
- data.AuthenticationTimerReauthenticateRange = types.Int64Null()
+ if !data.AuthenticationTimerReauthenticateRange.IsNull() && !data.AuthenticationTimerReauthenticateRange.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/authentication/timer/reauthenticate/range", strconv.FormatInt(data.AuthenticationTimerReauthenticateRange.ValueInt64(), 10))
}
- if value := res.Get(prefix + "spanning-tree.bpduguard.enable"); !data.SpanningTreeBpduguardEnable.IsNull() {
- if value.Exists() {
- data.SpanningTreeBpduguardEnable = types.BoolValue(true)
+ if !data.SpanningTreeBpduguardEnable.IsNull() && !data.SpanningTreeBpduguardEnable.IsUnknown() {
+ if data.SpanningTreeBpduguardEnable.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/spanning-tree/bpduguard/enable", "")
} else {
- data.SpanningTreeBpduguardEnable = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/spanning-tree/bpduguard/enable")
}
- } else {
- data.SpanningTreeBpduguardEnable = types.BoolNull()
}
- if value := res.Get(prefix + "spanning-tree.service-policy"); !data.SpanningTreeServicePolicy.IsNull() {
- if value.Exists() {
- data.SpanningTreeServicePolicy = types.BoolValue(true)
+ if !data.SpanningTreeServicePolicy.IsNull() && !data.SpanningTreeServicePolicy.IsUnknown() {
+ if data.SpanningTreeServicePolicy.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/spanning-tree/service-policy", "")
} else {
- data.SpanningTreeServicePolicy = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/spanning-tree/service-policy")
}
- } else {
- data.SpanningTreeServicePolicy = types.BoolNull()
}
- if value := res.Get(prefix + "spanning-tree.portfast"); !data.SpanningTreePortfast.IsNull() {
- if value.Exists() {
- data.SpanningTreePortfast = types.BoolValue(true)
+ if !data.SpanningTreePortfast.IsNull() && !data.SpanningTreePortfast.IsUnknown() {
+ if data.SpanningTreePortfast.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/spanning-tree/portfast", "")
} else {
- data.SpanningTreePortfast = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/spanning-tree/portfast")
}
- } else {
- data.SpanningTreePortfast = types.BoolNull()
}
- if value := res.Get(prefix + "spanning-tree.portfast.disable"); !data.SpanningTreePortfastDisable.IsNull() {
- if value.Exists() {
- data.SpanningTreePortfastDisable = types.BoolValue(true)
+ if !data.SpanningTreePortfastDisable.IsNull() && !data.SpanningTreePortfastDisable.IsUnknown() {
+ if data.SpanningTreePortfastDisable.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/spanning-tree/portfast/disable", "")
} else {
- data.SpanningTreePortfastDisable = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/spanning-tree/portfast/disable")
}
- } else {
- data.SpanningTreePortfastDisable = types.BoolNull()
}
- if value := res.Get(prefix + "spanning-tree.portfast.edge"); !data.SpanningTreePortfastEdge.IsNull() {
- if value.Exists() {
- data.SpanningTreePortfastEdge = types.BoolValue(true)
+ if !data.SpanningTreePortfastEdge.IsNull() && !data.SpanningTreePortfastEdge.IsUnknown() {
+ if data.SpanningTreePortfastEdge.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/spanning-tree/portfast/edge", "")
} else {
- data.SpanningTreePortfastEdge = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/spanning-tree/portfast/edge")
}
- } else {
- data.SpanningTreePortfastEdge = types.BoolNull()
}
- if value := res.Get(prefix + "spanning-tree.portfast.network"); !data.SpanningTreePortfastNetwork.IsNull() {
- if value.Exists() {
- data.SpanningTreePortfastNetwork = types.BoolValue(true)
+ if !data.SpanningTreePortfastNetwork.IsNull() && !data.SpanningTreePortfastNetwork.IsUnknown() {
+ if data.SpanningTreePortfastNetwork.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/spanning-tree/portfast/network", "")
} else {
- data.SpanningTreePortfastNetwork = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/spanning-tree/portfast/network")
}
- } else {
- data.SpanningTreePortfastNetwork = types.BoolNull()
}
- if value := res.Get(prefix + "storm-control.broadcast.level.pps.threshold"); value.Exists() && !data.StormControlBroadcastLevelPpsThreshold.IsNull() {
- data.StormControlBroadcastLevelPpsThreshold = types.StringValue(value.String())
- } else {
- data.StormControlBroadcastLevelPpsThreshold = types.StringNull()
+ if !data.StormControlBroadcastLevelPpsThreshold.IsNull() && !data.StormControlBroadcastLevelPpsThreshold.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/storm-control/broadcast/level/pps/threshold", data.StormControlBroadcastLevelPpsThreshold.ValueString())
}
- if value := res.Get(prefix + "storm-control.broadcast.level.bps.threshold"); value.Exists() && !data.StormControlBroadcastLevelBpsThreshold.IsNull() {
- data.StormControlBroadcastLevelBpsThreshold = types.Float64Value(value.Float())
- } else {
- data.StormControlBroadcastLevelBpsThreshold = types.Float64Null()
+ if !data.StormControlBroadcastLevelBpsThreshold.IsNull() && !data.StormControlBroadcastLevelBpsThreshold.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/storm-control/broadcast/level/bps/threshold", strconv.FormatFloat(data.StormControlBroadcastLevelBpsThreshold.ValueFloat64(), 'f', 1, 64))
}
- if value := res.Get(prefix + "storm-control.broadcast.level.threshold"); value.Exists() && !data.StormControlBroadcastLevelThreshold.IsNull() {
- data.StormControlBroadcastLevelThreshold = types.Float64Value(value.Float())
- } else {
- data.StormControlBroadcastLevelThreshold = types.Float64Null()
+ if !data.StormControlBroadcastLevelThreshold.IsNull() && !data.StormControlBroadcastLevelThreshold.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/storm-control/broadcast/level/threshold", strconv.FormatFloat(data.StormControlBroadcastLevelThreshold.ValueFloat64(), 'f', 1, 64))
}
- if value := res.Get(prefix + "storm-control.multicast.level.pps.threshold"); value.Exists() && !data.StormControlMulticastLevelPpsThreshold.IsNull() {
- data.StormControlMulticastLevelPpsThreshold = types.StringValue(value.String())
- } else {
- data.StormControlMulticastLevelPpsThreshold = types.StringNull()
+ if !data.StormControlMulticastLevelPpsThreshold.IsNull() && !data.StormControlMulticastLevelPpsThreshold.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/storm-control/multicast/level/pps/threshold", data.StormControlMulticastLevelPpsThreshold.ValueString())
}
- if value := res.Get(prefix + "storm-control.multicast.level.bps.threshold"); value.Exists() && !data.StormControlMulticastLevelBpsThreshold.IsNull() {
- data.StormControlMulticastLevelBpsThreshold = types.Float64Value(value.Float())
- } else {
- data.StormControlMulticastLevelBpsThreshold = types.Float64Null()
+ if !data.StormControlMulticastLevelBpsThreshold.IsNull() && !data.StormControlMulticastLevelBpsThreshold.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/storm-control/multicast/level/bps/threshold", strconv.FormatFloat(data.StormControlMulticastLevelBpsThreshold.ValueFloat64(), 'f', 1, 64))
}
- if value := res.Get(prefix + "storm-control.multicast.level.threshold"); value.Exists() && !data.StormControlMulticastLevelThreshold.IsNull() {
- data.StormControlMulticastLevelThreshold = types.Float64Value(value.Float())
- } else {
- data.StormControlMulticastLevelThreshold = types.Float64Null()
+ if !data.StormControlMulticastLevelThreshold.IsNull() && !data.StormControlMulticastLevelThreshold.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/storm-control/multicast/level/threshold", strconv.FormatFloat(data.StormControlMulticastLevelThreshold.ValueFloat64(), 'f', 1, 64))
}
- if value := res.Get(prefix + "storm-control.action.shutdown"); !data.StormControlActionShutdown.IsNull() {
- if value.Exists() {
- data.StormControlActionShutdown = types.BoolValue(true)
+ if !data.StormControlActionShutdown.IsNull() && !data.StormControlActionShutdown.IsUnknown() {
+ if data.StormControlActionShutdown.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/storm-control/action/shutdown", "")
} else {
- data.StormControlActionShutdown = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/storm-control/action/shutdown")
}
- } else {
- data.StormControlActionShutdown = types.BoolNull()
}
- if value := res.Get(prefix + "storm-control.action.trap"); !data.StormControlActionTrap.IsNull() {
- if value.Exists() {
- data.StormControlActionTrap = types.BoolValue(true)
+ if !data.StormControlActionTrap.IsNull() && !data.StormControlActionTrap.IsUnknown() {
+ if data.StormControlActionTrap.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/storm-control/action/trap", "")
} else {
- data.StormControlActionTrap = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/storm-control/action/trap")
}
- } else {
- data.StormControlActionTrap = types.BoolNull()
}
- if value := res.Get(prefix + "load-interval"); value.Exists() && !data.LoadInterval.IsNull() {
- data.LoadInterval = types.Int64Value(value.Int())
- } else {
- data.LoadInterval = types.Int64Null()
+ if !data.LoadInterval.IsNull() && !data.LoadInterval.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/load-interval", strconv.FormatInt(data.LoadInterval.ValueInt64(), 10))
}
- if value := res.Get(prefix + "ip.dhcp.snooping.limit.rate"); value.Exists() && !data.IpDhcpSnoopingLimitRate.IsNull() {
- data.IpDhcpSnoopingLimitRate = types.Int64Value(value.Int())
- } else {
- data.IpDhcpSnoopingLimitRate = types.Int64Null()
+ if !data.IpDhcpSnoopingLimitRate.IsNull() && !data.IpDhcpSnoopingLimitRate.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ip/dhcp/snooping/limit/rate", strconv.FormatInt(data.IpDhcpSnoopingLimitRate.ValueInt64(), 10))
}
- if value := res.Get(prefix + "ip.dhcp.snooping.trust"); !data.IpDhcpSnoopingTrust.IsNull() {
- if value.Exists() {
- data.IpDhcpSnoopingTrust = types.BoolValue(true)
+ if !data.IpDhcpSnoopingTrust.IsNull() && !data.IpDhcpSnoopingTrust.IsUnknown() {
+ if data.IpDhcpSnoopingTrust.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/ip/dhcp/snooping/trust", "")
} else {
- data.IpDhcpSnoopingTrust = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/ip/dhcp/snooping/trust")
}
- } else {
- data.IpDhcpSnoopingTrust = types.BoolNull()
}
- for i := range data.IpAccessGroup {
- keys := [...]string{"direction"}
- keyValues := [...]string{data.IpAccessGroup[i].Direction.ValueString()}
-
- var r gjson.Result
- res.Get(prefix + "ip.access-group").ForEach(
- func(_, v gjson.Result) bool {
- found := false
- for ik := range keys {
- if v.Get(keys[ik]).String() == keyValues[ik] {
- found = true
- continue
- }
- found = false
- break
- }
- if found {
- r = v
- return false
- }
- return true
- },
- )
- if value := r.Get("direction"); value.Exists() && !data.IpAccessGroup[i].Direction.IsNull() {
- data.IpAccessGroup[i].Direction = types.StringValue(value.String())
- } else {
- data.IpAccessGroup[i].Direction = types.StringNull()
+ if len(data.IpAccessGroup) > 0 {
+ for _, item := range data.IpAccessGroup {
+ cBody := netconf.Body{}
+ if !item.Direction.IsNull() && !item.Direction.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "direction", item.Direction.ValueString())
+ }
+ if !item.AccessList.IsNull() && !item.AccessList.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "access-list", item.AccessList.ValueString())
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/ip/access-group", cBody.Res())
}
- if value := r.Get("access-list"); value.Exists() && !data.IpAccessGroup[i].AccessList.IsNull() {
- data.IpAccessGroup[i].AccessList = types.StringValue(value.String())
+ }
+ if !data.SubscriberAgingInactivityTimerValue.IsNull() && !data.SubscriberAgingInactivityTimerValue.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/subscriber/aging/inactivity-timer/value", strconv.FormatInt(data.SubscriberAgingInactivityTimerValue.ValueInt64(), 10))
+ }
+ if !data.SubscriberAgingInactivityTimerProbe.IsNull() && !data.SubscriberAgingInactivityTimerProbe.IsUnknown() {
+ if data.SubscriberAgingInactivityTimerProbe.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/subscriber/aging/inactivity-timer/probe", "")
} else {
- data.IpAccessGroup[i].AccessList = types.StringNull()
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/subscriber/aging/inactivity-timer/probe")
}
}
- if value := res.Get(prefix + "subscriber.aging.inactivity-timer.value"); value.Exists() && !data.SubscriberAgingInactivityTimerValue.IsNull() {
- data.SubscriberAgingInactivityTimerValue = types.Int64Value(value.Int())
- } else {
- data.SubscriberAgingInactivityTimerValue = types.Int64Null()
- }
- if value := res.Get(prefix + "subscriber.aging.inactivity-timer.probe"); !data.SubscriberAgingInactivityTimerProbe.IsNull() {
- if value.Exists() {
- data.SubscriberAgingInactivityTimerProbe = types.BoolValue(true)
+ if !data.SubscriberAgingProbe.IsNull() && !data.SubscriberAgingProbe.IsUnknown() {
+ if data.SubscriberAgingProbe.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/subscriber/aging/probe", "")
} else {
- data.SubscriberAgingInactivityTimerProbe = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/subscriber/aging/probe")
}
- } else {
- data.SubscriberAgingInactivityTimerProbe = types.BoolNull()
}
- if value := res.Get(prefix + "subscriber.aging.probe"); !data.SubscriberAgingProbe.IsNull() {
- if value.Exists() {
- data.SubscriberAgingProbe = types.BoolValue(true)
+ if !data.DeviceTracking.IsNull() && !data.DeviceTracking.IsUnknown() {
+ if data.DeviceTracking.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/device-tracking", "")
} else {
- data.SubscriberAgingProbe = types.BoolValue(false)
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/device-tracking")
+ }
+ }
+ if len(data.DeviceTrackingAttachPolicy) > 0 {
+ for _, item := range data.DeviceTrackingAttachPolicy {
+ cBody := netconf.Body{}
+ if !item.PolicyName.IsNull() && !item.PolicyName.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "policy-name", item.PolicyName.ValueString())
+ }
+ if !item.VlanRange.IsNull() && !item.VlanRange.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "vlan/vlan-range", item.VlanRange.ValueString())
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/device-tracking/attach-policy/policy-name", cBody.Res())
}
+ }
+ if !data.DeviceTrackingVlanRange.IsNull() && !data.DeviceTrackingVlanRange.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/device-tracking/vlan/vlan-range", data.DeviceTrackingVlanRange.ValueString())
+ }
+ if !data.CtsManual.IsNull() && !data.CtsManual.IsUnknown() {
+ if data.CtsManual.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/cts/manual", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/cts/manual")
+ }
+ }
+ if !data.CtsManualPolicyStaticSgt.IsNull() && !data.CtsManualPolicyStaticSgt.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/cts/manual/policy/static/sgt", strconv.FormatInt(data.CtsManualPolicyStaticSgt.ValueInt64(), 10))
+ }
+ if !data.CtsManualPolicyStaticTrusted.IsNull() && !data.CtsManualPolicyStaticTrusted.IsUnknown() {
+ if data.CtsManualPolicyStaticTrusted.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/cts/manual/policy/static/trusted", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/cts/manual/policy/static/trusted")
+ }
+ }
+ if !data.CtsManualPropagateSgt.IsNull() && !data.CtsManualPropagateSgt.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/cts/manual/propagate/sgt", data.CtsManualPropagateSgt.ValueBool())
+ }
+ if !data.CtsRoleBasedEnforcement.IsNull() && !data.CtsRoleBasedEnforcement.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/cts/role-based/enforcement", data.CtsRoleBasedEnforcement.ValueBool())
+ }
+ bodyString, err := body.String()
+ if err != nil {
+ tflog.Error(ctx, fmt.Sprintf("Error converting body to string: %s", err))
+ }
+ return bodyString
+}
+
+// End of section. //template:end toBodyXML
+
+// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBody
+
+func (data *Template) updateFromBody(ctx context.Context, res gjson.Result) {
+ prefix := helpers.LastElement(data.getPath()) + "."
+ if res.Get(helpers.LastElement(data.getPath())).IsArray() {
+ prefix += "0."
+ }
+ if value := res.Get(prefix + "template_name"); value.Exists() && !data.TemplateName.IsNull() {
+ data.TemplateName = types.StringValue(value.String())
+ } else {
+ data.TemplateName = types.StringNull()
+ }
+ if value := res.Get(prefix + "dot1x.pae"); value.Exists() && !data.Dot1xPae.IsNull() {
+ data.Dot1xPae = types.StringValue(value.String())
+ } else {
+ data.Dot1xPae = types.StringNull()
+ }
+ if value := res.Get(prefix + "dot1x.max-reauth-req"); value.Exists() && !data.Dot1xMaxReauthReq.IsNull() {
+ data.Dot1xMaxReauthReq = types.Int64Value(value.Int())
+ } else {
+ data.Dot1xMaxReauthReq = types.Int64Null()
+ }
+ if value := res.Get(prefix + "dot1x.max-req"); value.Exists() && !data.Dot1xMaxReq.IsNull() {
+ data.Dot1xMaxReq = types.Int64Value(value.Int())
+ } else {
+ data.Dot1xMaxReq = types.Int64Null()
+ }
+ if value := res.Get(prefix + "dot1x.timeout.tx-period"); value.Exists() && !data.Dot1xTimeoutTxPeriod.IsNull() {
+ data.Dot1xTimeoutTxPeriod = types.Int64Value(value.Int())
+ } else {
+ data.Dot1xTimeoutTxPeriod = types.Int64Null()
+ }
+ if value := res.Get(prefix + "service-policy.type.control.subscriber"); value.Exists() && !data.ServicePolicyTypeControlSubscriber.IsNull() {
+ data.ServicePolicyTypeControlSubscriber = types.StringValue(value.String())
+ } else {
+ data.ServicePolicyTypeControlSubscriber = types.StringNull()
+ }
+ if value := res.Get(prefix + "service-policy.input.policy-map-name"); value.Exists() && !data.ServicePolicyInput.IsNull() {
+ data.ServicePolicyInput = types.StringValue(value.String())
+ } else {
+ data.ServicePolicyInput = types.StringNull()
+ }
+ if value := res.Get(prefix + "service-policy.output.policy-map-name"); value.Exists() && !data.ServicePolicyOutput.IsNull() {
+ data.ServicePolicyOutput = types.StringValue(value.String())
+ } else {
+ data.ServicePolicyOutput = types.StringNull()
+ }
+ if value := res.Get(prefix + ""); value.Exists() && !data.SourceTemplate.IsNull() {
+ data.SourceTemplate = types.StringValue(value.String())
+ } else {
+ data.SourceTemplate = types.StringNull()
+ }
+ if value := res.Get(prefix + "switchport.mode.trunk"); !data.SwitchportModeTrunk.IsNull() {
+ if value.Exists() {
+ data.SwitchportModeTrunk = types.BoolValue(true)
+ } else {
+ data.SwitchportModeTrunk = types.BoolValue(false)
+ }
+ } else {
+ data.SwitchportModeTrunk = types.BoolNull()
+ }
+ if value := res.Get(prefix + "switchport.mode.access"); !data.SwitchportModeAccess.IsNull() {
+ if value.Exists() {
+ data.SwitchportModeAccess = types.BoolValue(true)
+ } else {
+ data.SwitchportModeAccess = types.BoolValue(false)
+ }
+ } else {
+ data.SwitchportModeAccess = types.BoolNull()
+ }
+ if value := res.Get(prefix + "switchport.nonegotiate"); !data.SwitchportNonegotiate.IsNull() {
+ if value.Exists() {
+ data.SwitchportNonegotiate = types.BoolValue(true)
+ } else {
+ data.SwitchportNonegotiate = types.BoolValue(false)
+ }
+ } else {
+ data.SwitchportNonegotiate = types.BoolNull()
+ }
+ if value := res.Get(prefix + "switchport.block.unicast"); !data.SwitchportBlockUnicast.IsNull() {
+ if value.Exists() {
+ data.SwitchportBlockUnicast = types.BoolValue(true)
+ } else {
+ data.SwitchportBlockUnicast = types.BoolValue(false)
+ }
+ } else {
+ data.SwitchportBlockUnicast = types.BoolNull()
+ }
+ if value := res.Get(prefix + "switchport.port-security"); !data.SwitchportPortSecurity.IsNull() {
+ if value.Exists() {
+ data.SwitchportPortSecurity = types.BoolValue(true)
+ } else {
+ data.SwitchportPortSecurity = types.BoolValue(false)
+ }
+ } else {
+ data.SwitchportPortSecurity = types.BoolNull()
+ }
+ if value := res.Get(prefix + "switchport.port-security.aging.static"); !data.SwitchportPortSecurityAgingStatic.IsNull() {
+ if value.Exists() {
+ data.SwitchportPortSecurityAgingStatic = types.BoolValue(true)
+ } else {
+ data.SwitchportPortSecurityAgingStatic = types.BoolValue(false)
+ }
+ } else {
+ data.SwitchportPortSecurityAgingStatic = types.BoolNull()
+ }
+ if value := res.Get(prefix + "switchport.port-security.aging.time"); value.Exists() && !data.SwitchportPortSecurityAgingTime.IsNull() {
+ data.SwitchportPortSecurityAgingTime = types.Int64Value(value.Int())
+ } else {
+ data.SwitchportPortSecurityAgingTime = types.Int64Null()
+ }
+ if value := res.Get(prefix + "switchport.port-security.aging.type"); !data.SwitchportPortSecurityAgingType.IsNull() {
+ if value.Exists() {
+ data.SwitchportPortSecurityAgingType = types.BoolValue(true)
+ } else {
+ data.SwitchportPortSecurityAgingType = types.BoolValue(false)
+ }
+ } else {
+ data.SwitchportPortSecurityAgingType = types.BoolNull()
+ }
+ if value := res.Get(prefix + "switchport.port-security.aging.type.inactivity"); !data.SwitchportPortSecurityAgingTypeInactivity.IsNull() {
+ if value.Exists() {
+ data.SwitchportPortSecurityAgingTypeInactivity = types.BoolValue(true)
+ } else {
+ data.SwitchportPortSecurityAgingTypeInactivity = types.BoolValue(false)
+ }
+ } else {
+ data.SwitchportPortSecurityAgingTypeInactivity = types.BoolNull()
+ }
+ for i := range data.SwitchportPortSecurityMaximumRange {
+ keys := [...]string{"range"}
+ keyValues := [...]string{strconv.FormatInt(data.SwitchportPortSecurityMaximumRange[i].Range.ValueInt64(), 10)}
+
+ var r gjson.Result
+ res.Get(prefix + "switchport.port-security.maximum.range").ForEach(
+ func(_, v gjson.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := r.Get("range"); value.Exists() && !data.SwitchportPortSecurityMaximumRange[i].Range.IsNull() {
+ data.SwitchportPortSecurityMaximumRange[i].Range = types.Int64Value(value.Int())
+ } else {
+ data.SwitchportPortSecurityMaximumRange[i].Range = types.Int64Null()
+ }
+ if value := r.Get("vlan"); !data.SwitchportPortSecurityMaximumRange[i].Vlan.IsNull() {
+ if value.Exists() {
+ data.SwitchportPortSecurityMaximumRange[i].Vlan = types.BoolValue(true)
+ } else {
+ data.SwitchportPortSecurityMaximumRange[i].Vlan = types.BoolValue(false)
+ }
+ } else {
+ data.SwitchportPortSecurityMaximumRange[i].Vlan = types.BoolNull()
+ }
+ if value := r.Get("vlan.access"); !data.SwitchportPortSecurityMaximumRange[i].VlanAccess.IsNull() {
+ if value.Exists() {
+ data.SwitchportPortSecurityMaximumRange[i].VlanAccess = types.BoolValue(true)
+ } else {
+ data.SwitchportPortSecurityMaximumRange[i].VlanAccess = types.BoolValue(false)
+ }
+ } else {
+ data.SwitchportPortSecurityMaximumRange[i].VlanAccess = types.BoolNull()
+ }
+ }
+ if value := res.Get(prefix + "switchport.port-security.violation.protect"); !data.SwitchportPortSecurityViolationProtect.IsNull() {
+ if value.Exists() {
+ data.SwitchportPortSecurityViolationProtect = types.BoolValue(true)
+ } else {
+ data.SwitchportPortSecurityViolationProtect = types.BoolValue(false)
+ }
+ } else {
+ data.SwitchportPortSecurityViolationProtect = types.BoolNull()
+ }
+ if value := res.Get(prefix + "switchport.port-security.violation.restrict"); !data.SwitchportPortSecurityViolationRestrict.IsNull() {
+ if value.Exists() {
+ data.SwitchportPortSecurityViolationRestrict = types.BoolValue(true)
+ } else {
+ data.SwitchportPortSecurityViolationRestrict = types.BoolValue(false)
+ }
+ } else {
+ data.SwitchportPortSecurityViolationRestrict = types.BoolNull()
+ }
+ if value := res.Get(prefix + "switchport.port-security.violation.shutdown"); !data.SwitchportPortSecurityViolationShutdown.IsNull() {
+ if value.Exists() {
+ data.SwitchportPortSecurityViolationShutdown = types.BoolValue(true)
+ } else {
+ data.SwitchportPortSecurityViolationShutdown = types.BoolValue(false)
+ }
+ } else {
+ data.SwitchportPortSecurityViolationShutdown = types.BoolNull()
+ }
+ if value := res.Get(prefix + "switchport.access.vlan"); value.Exists() && !data.SwitchportAccessVlan.IsNull() {
+ data.SwitchportAccessVlan = types.Int64Value(value.Int())
+ } else {
+ data.SwitchportAccessVlan = types.Int64Null()
+ }
+ if value := res.Get(prefix + "switchport.voice.vlan"); value.Exists() && !data.SwitchportVoiceVlan.IsNull() {
+ data.SwitchportVoiceVlan = types.Int64Value(value.Int())
+ } else {
+ data.SwitchportVoiceVlan = types.Int64Null()
+ }
+ if value := res.Get(prefix + "switchport.private-vlan.host-association.primary-range"); value.Exists() && !data.SwitchportPrivateVlanHostAssociationPrimaryRange.IsNull() {
+ data.SwitchportPrivateVlanHostAssociationPrimaryRange = types.Int64Value(value.Int())
+ } else {
+ data.SwitchportPrivateVlanHostAssociationPrimaryRange = types.Int64Null()
+ }
+ if value := res.Get(prefix + "switchport.private-vlan.host-association.secondary-range"); value.Exists() && !data.SwitchportPrivateVlanHostAssociationSecondaryRange.IsNull() {
+ data.SwitchportPrivateVlanHostAssociationSecondaryRange = types.Int64Value(value.Int())
+ } else {
+ data.SwitchportPrivateVlanHostAssociationSecondaryRange = types.Int64Null()
+ }
+ if value := res.Get(prefix + "switchport.trunk.allowed.vlan.vlans"); value.Exists() && !data.SwitchportTrunkAllowedVlans.IsNull() {
+ data.SwitchportTrunkAllowedVlans = types.StringValue(value.String())
+ } else {
+ data.SwitchportTrunkAllowedVlans = types.StringNull()
+ }
+ if value := res.Get(prefix + "switchport.trunk.allowed.vlan.none"); !data.SwitchportTrunkAllowedVlansNone.IsNull() {
+ if value.Exists() {
+ data.SwitchportTrunkAllowedVlansNone = types.BoolValue(true)
+ } else {
+ data.SwitchportTrunkAllowedVlansNone = types.BoolValue(false)
+ }
+ } else {
+ data.SwitchportTrunkAllowedVlansNone = types.BoolNull()
+ }
+ if value := res.Get(prefix + "switchport.trunk.allowed.vlan.all"); !data.SwitchportTrunkAllowedVlansAll.IsNull() {
+ if value.Exists() {
+ data.SwitchportTrunkAllowedVlansAll = types.BoolValue(true)
+ } else {
+ data.SwitchportTrunkAllowedVlansAll = types.BoolValue(false)
+ }
+ } else {
+ data.SwitchportTrunkAllowedVlansAll = types.BoolNull()
+ }
+ if value := res.Get(prefix + "switchport.trunk.native.vlan.tag"); !data.SwitchportTrunkNativeVlanTag.IsNull() {
+ if value.Exists() {
+ data.SwitchportTrunkNativeVlanTag = types.BoolValue(value.Bool())
+ }
+ } else {
+ data.SwitchportTrunkNativeVlanTag = types.BoolNull()
+ }
+ if value := res.Get(prefix + "switchport.trunk.native.vlan.vlan-id"); value.Exists() && !data.SwitchportTrunkNativeVlanVlanId.IsNull() {
+ data.SwitchportTrunkNativeVlanVlanId = types.Int64Value(value.Int())
+ } else {
+ data.SwitchportTrunkNativeVlanVlanId = types.Int64Null()
+ }
+ if value := res.Get(prefix + "mab"); !data.Mab.IsNull() {
+ if value.Exists() {
+ data.Mab = types.BoolValue(true)
+ } else {
+ data.Mab = types.BoolValue(false)
+ }
+ } else {
+ data.Mab = types.BoolNull()
+ }
+ if value := res.Get(prefix + "mab.eap"); !data.MabEap.IsNull() {
+ if value.Exists() {
+ data.MabEap = types.BoolValue(true)
+ } else {
+ data.MabEap = types.BoolValue(false)
+ }
+ } else {
+ data.MabEap = types.BoolNull()
+ }
+ if value := res.Get(prefix + "access-session.closed"); !data.AccessSessionClosed.IsNull() {
+ if value.Exists() {
+ data.AccessSessionClosed = types.BoolValue(true)
+ } else {
+ data.AccessSessionClosed = types.BoolValue(false)
+ }
+ } else {
+ data.AccessSessionClosed = types.BoolNull()
+ }
+ if value := res.Get(prefix + "access-session.monitor"); !data.AccessSessionMonitor.IsNull() {
+ if value.Exists() {
+ data.AccessSessionMonitor = types.BoolValue(value.Bool())
+ }
+ } else {
+ data.AccessSessionMonitor = types.BoolNull()
+ }
+ if value := res.Get(prefix + "access-session.port-control"); value.Exists() && !data.AccessSessionPortControl.IsNull() {
+ data.AccessSessionPortControl = types.StringValue(value.String())
+ } else {
+ data.AccessSessionPortControl = types.StringNull()
+ }
+ if value := res.Get(prefix + "access-session.control-direction"); value.Exists() && !data.AccessSessionControlDirection.IsNull() {
+ data.AccessSessionControlDirection = types.StringValue(value.String())
+ } else {
+ data.AccessSessionControlDirection = types.StringNull()
+ }
+ if value := res.Get(prefix + "access-session.host-mode"); value.Exists() && !data.AccessSessionHostMode.IsNull() {
+ data.AccessSessionHostMode = types.StringValue(value.String())
+ } else {
+ data.AccessSessionHostMode = types.StringNull()
+ }
+ if value := res.Get(prefix + "access-session.interface-template.sticky"); !data.AccessSessionInterfaceTemplateSticky.IsNull() {
+ if value.Exists() {
+ data.AccessSessionInterfaceTemplateSticky = types.BoolValue(true)
+ } else {
+ data.AccessSessionInterfaceTemplateSticky = types.BoolValue(false)
+ }
+ } else {
+ data.AccessSessionInterfaceTemplateSticky = types.BoolNull()
+ }
+ if value := res.Get(prefix + "access-session.interface-template.sticky.timer"); value.Exists() && !data.AccessSessionInterfaceTemplateStickyTimer.IsNull() {
+ data.AccessSessionInterfaceTemplateStickyTimer = types.Int64Value(value.Int())
+ } else {
+ data.AccessSessionInterfaceTemplateStickyTimer = types.Int64Null()
+ }
+ if value := res.Get(prefix + "authentication.periodic"); !data.AuthenticationPeriodic.IsNull() {
+ if value.Exists() {
+ data.AuthenticationPeriodic = types.BoolValue(true)
+ } else {
+ data.AuthenticationPeriodic = types.BoolValue(false)
+ }
+ } else {
+ data.AuthenticationPeriodic = types.BoolNull()
+ }
+ if value := res.Get(prefix + "authentication.timer.reauthenticate.server"); !data.AuthenticationTimerReauthenticateServer.IsNull() {
+ if value.Exists() {
+ data.AuthenticationTimerReauthenticateServer = types.BoolValue(true)
+ } else {
+ data.AuthenticationTimerReauthenticateServer = types.BoolValue(false)
+ }
+ } else {
+ data.AuthenticationTimerReauthenticateServer = types.BoolNull()
+ }
+ if value := res.Get(prefix + "authentication.timer.reauthenticate.range"); value.Exists() && !data.AuthenticationTimerReauthenticateRange.IsNull() {
+ data.AuthenticationTimerReauthenticateRange = types.Int64Value(value.Int())
+ } else {
+ data.AuthenticationTimerReauthenticateRange = types.Int64Null()
+ }
+ if value := res.Get(prefix + "spanning-tree.bpduguard.enable"); !data.SpanningTreeBpduguardEnable.IsNull() {
+ if value.Exists() {
+ data.SpanningTreeBpduguardEnable = types.BoolValue(true)
+ } else {
+ data.SpanningTreeBpduguardEnable = types.BoolValue(false)
+ }
+ } else {
+ data.SpanningTreeBpduguardEnable = types.BoolNull()
+ }
+ if value := res.Get(prefix + "spanning-tree.service-policy"); !data.SpanningTreeServicePolicy.IsNull() {
+ if value.Exists() {
+ data.SpanningTreeServicePolicy = types.BoolValue(true)
+ } else {
+ data.SpanningTreeServicePolicy = types.BoolValue(false)
+ }
+ } else {
+ data.SpanningTreeServicePolicy = types.BoolNull()
+ }
+ if value := res.Get(prefix + "spanning-tree.portfast"); !data.SpanningTreePortfast.IsNull() {
+ if value.Exists() {
+ data.SpanningTreePortfast = types.BoolValue(true)
+ } else {
+ data.SpanningTreePortfast = types.BoolValue(false)
+ }
+ } else {
+ data.SpanningTreePortfast = types.BoolNull()
+ }
+ if value := res.Get(prefix + "spanning-tree.portfast.disable"); !data.SpanningTreePortfastDisable.IsNull() {
+ if value.Exists() {
+ data.SpanningTreePortfastDisable = types.BoolValue(true)
+ } else {
+ data.SpanningTreePortfastDisable = types.BoolValue(false)
+ }
+ } else {
+ data.SpanningTreePortfastDisable = types.BoolNull()
+ }
+ if value := res.Get(prefix + "spanning-tree.portfast.edge"); !data.SpanningTreePortfastEdge.IsNull() {
+ if value.Exists() {
+ data.SpanningTreePortfastEdge = types.BoolValue(true)
+ } else {
+ data.SpanningTreePortfastEdge = types.BoolValue(false)
+ }
+ } else {
+ data.SpanningTreePortfastEdge = types.BoolNull()
+ }
+ if value := res.Get(prefix + "spanning-tree.portfast.network"); !data.SpanningTreePortfastNetwork.IsNull() {
+ if value.Exists() {
+ data.SpanningTreePortfastNetwork = types.BoolValue(true)
+ } else {
+ data.SpanningTreePortfastNetwork = types.BoolValue(false)
+ }
+ } else {
+ data.SpanningTreePortfastNetwork = types.BoolNull()
+ }
+ if value := res.Get(prefix + "storm-control.broadcast.level.pps.threshold"); value.Exists() && !data.StormControlBroadcastLevelPpsThreshold.IsNull() {
+ data.StormControlBroadcastLevelPpsThreshold = types.StringValue(value.String())
+ } else {
+ data.StormControlBroadcastLevelPpsThreshold = types.StringNull()
+ }
+ if value := res.Get(prefix + "storm-control.broadcast.level.bps.threshold"); value.Exists() && !data.StormControlBroadcastLevelBpsThreshold.IsNull() {
+ data.StormControlBroadcastLevelBpsThreshold = types.Float64Value(value.Float())
+ } else {
+ data.StormControlBroadcastLevelBpsThreshold = types.Float64Null()
+ }
+ if value := res.Get(prefix + "storm-control.broadcast.level.threshold"); value.Exists() && !data.StormControlBroadcastLevelThreshold.IsNull() {
+ data.StormControlBroadcastLevelThreshold = types.Float64Value(value.Float())
+ } else {
+ data.StormControlBroadcastLevelThreshold = types.Float64Null()
+ }
+ if value := res.Get(prefix + "storm-control.multicast.level.pps.threshold"); value.Exists() && !data.StormControlMulticastLevelPpsThreshold.IsNull() {
+ data.StormControlMulticastLevelPpsThreshold = types.StringValue(value.String())
+ } else {
+ data.StormControlMulticastLevelPpsThreshold = types.StringNull()
+ }
+ if value := res.Get(prefix + "storm-control.multicast.level.bps.threshold"); value.Exists() && !data.StormControlMulticastLevelBpsThreshold.IsNull() {
+ data.StormControlMulticastLevelBpsThreshold = types.Float64Value(value.Float())
+ } else {
+ data.StormControlMulticastLevelBpsThreshold = types.Float64Null()
+ }
+ if value := res.Get(prefix + "storm-control.multicast.level.threshold"); value.Exists() && !data.StormControlMulticastLevelThreshold.IsNull() {
+ data.StormControlMulticastLevelThreshold = types.Float64Value(value.Float())
+ } else {
+ data.StormControlMulticastLevelThreshold = types.Float64Null()
+ }
+ if value := res.Get(prefix + "storm-control.action.shutdown"); !data.StormControlActionShutdown.IsNull() {
+ if value.Exists() {
+ data.StormControlActionShutdown = types.BoolValue(true)
+ } else {
+ data.StormControlActionShutdown = types.BoolValue(false)
+ }
+ } else {
+ data.StormControlActionShutdown = types.BoolNull()
+ }
+ if value := res.Get(prefix + "storm-control.action.trap"); !data.StormControlActionTrap.IsNull() {
+ if value.Exists() {
+ data.StormControlActionTrap = types.BoolValue(true)
+ } else {
+ data.StormControlActionTrap = types.BoolValue(false)
+ }
+ } else {
+ data.StormControlActionTrap = types.BoolNull()
+ }
+ if value := res.Get(prefix + "load-interval"); value.Exists() && !data.LoadInterval.IsNull() {
+ data.LoadInterval = types.Int64Value(value.Int())
+ } else {
+ data.LoadInterval = types.Int64Null()
+ }
+ if value := res.Get(prefix + "ip.dhcp.snooping.limit.rate"); value.Exists() && !data.IpDhcpSnoopingLimitRate.IsNull() {
+ data.IpDhcpSnoopingLimitRate = types.Int64Value(value.Int())
+ } else {
+ data.IpDhcpSnoopingLimitRate = types.Int64Null()
+ }
+ if value := res.Get(prefix + "ip.dhcp.snooping.trust"); !data.IpDhcpSnoopingTrust.IsNull() {
+ if value.Exists() {
+ data.IpDhcpSnoopingTrust = types.BoolValue(true)
+ } else {
+ data.IpDhcpSnoopingTrust = types.BoolValue(false)
+ }
+ } else {
+ data.IpDhcpSnoopingTrust = types.BoolNull()
+ }
+ for i := range data.IpAccessGroup {
+ keys := [...]string{"direction"}
+ keyValues := [...]string{data.IpAccessGroup[i].Direction.ValueString()}
+
+ var r gjson.Result
+ res.Get(prefix + "ip.access-group").ForEach(
+ func(_, v gjson.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := r.Get("direction"); value.Exists() && !data.IpAccessGroup[i].Direction.IsNull() {
+ data.IpAccessGroup[i].Direction = types.StringValue(value.String())
+ } else {
+ data.IpAccessGroup[i].Direction = types.StringNull()
+ }
+ if value := r.Get("access-list"); value.Exists() && !data.IpAccessGroup[i].AccessList.IsNull() {
+ data.IpAccessGroup[i].AccessList = types.StringValue(value.String())
+ } else {
+ data.IpAccessGroup[i].AccessList = types.StringNull()
+ }
+ }
+ if value := res.Get(prefix + "subscriber.aging.inactivity-timer.value"); value.Exists() && !data.SubscriberAgingInactivityTimerValue.IsNull() {
+ data.SubscriberAgingInactivityTimerValue = types.Int64Value(value.Int())
+ } else {
+ data.SubscriberAgingInactivityTimerValue = types.Int64Null()
+ }
+ if value := res.Get(prefix + "subscriber.aging.inactivity-timer.probe"); !data.SubscriberAgingInactivityTimerProbe.IsNull() {
+ if value.Exists() {
+ data.SubscriberAgingInactivityTimerProbe = types.BoolValue(true)
+ } else {
+ data.SubscriberAgingInactivityTimerProbe = types.BoolValue(false)
+ }
+ } else {
+ data.SubscriberAgingInactivityTimerProbe = types.BoolNull()
+ }
+ if value := res.Get(prefix + "subscriber.aging.probe"); !data.SubscriberAgingProbe.IsNull() {
+ if value.Exists() {
+ data.SubscriberAgingProbe = types.BoolValue(true)
+ } else {
+ data.SubscriberAgingProbe = types.BoolValue(false)
+ }
+ } else {
+ data.SubscriberAgingProbe = types.BoolNull()
+ }
+ if value := res.Get(prefix + "device-tracking"); !data.DeviceTracking.IsNull() {
+ if value.Exists() {
+ data.DeviceTracking = types.BoolValue(true)
+ } else {
+ data.DeviceTracking = types.BoolValue(false)
+ }
+ } else {
+ data.DeviceTracking = types.BoolNull()
+ }
+ for i := range data.DeviceTrackingAttachPolicy {
+ keys := [...]string{"policy-name"}
+ keyValues := [...]string{data.DeviceTrackingAttachPolicy[i].PolicyName.ValueString()}
+
+ var r gjson.Result
+ res.Get(prefix + "device-tracking.attach-policy.policy-name").ForEach(
+ func(_, v gjson.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := r.Get("policy-name"); value.Exists() && !data.DeviceTrackingAttachPolicy[i].PolicyName.IsNull() {
+ data.DeviceTrackingAttachPolicy[i].PolicyName = types.StringValue(value.String())
+ } else {
+ data.DeviceTrackingAttachPolicy[i].PolicyName = types.StringNull()
+ }
+ if value := r.Get("vlan.vlan-range"); value.Exists() && !data.DeviceTrackingAttachPolicy[i].VlanRange.IsNull() {
+ data.DeviceTrackingAttachPolicy[i].VlanRange = types.StringValue(value.String())
+ } else {
+ data.DeviceTrackingAttachPolicy[i].VlanRange = types.StringNull()
+ }
+ }
+ if value := res.Get(prefix + "device-tracking.vlan.vlan-range"); value.Exists() && !data.DeviceTrackingVlanRange.IsNull() {
+ data.DeviceTrackingVlanRange = types.StringValue(value.String())
+ } else {
+ data.DeviceTrackingVlanRange = types.StringNull()
+ }
+ if value := res.Get(prefix + "cts.manual"); !data.CtsManual.IsNull() {
+ if value.Exists() {
+ data.CtsManual = types.BoolValue(true)
+ } else {
+ data.CtsManual = types.BoolValue(false)
+ }
+ } else {
+ data.CtsManual = types.BoolNull()
+ }
+ if value := res.Get(prefix + "cts.manual.policy.static.sgt"); value.Exists() && !data.CtsManualPolicyStaticSgt.IsNull() {
+ data.CtsManualPolicyStaticSgt = types.Int64Value(value.Int())
+ } else {
+ data.CtsManualPolicyStaticSgt = types.Int64Null()
+ }
+ if value := res.Get(prefix + "cts.manual.policy.static.trusted"); !data.CtsManualPolicyStaticTrusted.IsNull() {
+ if value.Exists() {
+ data.CtsManualPolicyStaticTrusted = types.BoolValue(true)
+ } else {
+ data.CtsManualPolicyStaticTrusted = types.BoolValue(false)
+ }
+ } else {
+ data.CtsManualPolicyStaticTrusted = types.BoolNull()
+ }
+ if value := res.Get(prefix + "cts.manual.propagate.sgt"); !data.CtsManualPropagateSgt.IsNull() {
+ if value.Exists() {
+ data.CtsManualPropagateSgt = types.BoolValue(value.Bool())
+ }
+ } else {
+ data.CtsManualPropagateSgt = types.BoolNull()
+ }
+ if value := res.Get(prefix + "cts.role-based.enforcement"); !data.CtsRoleBasedEnforcement.IsNull() {
+ if value.Exists() {
+ data.CtsRoleBasedEnforcement = types.BoolValue(value.Bool())
+ }
+ } else {
+ data.CtsRoleBasedEnforcement = types.BoolNull()
+ }
+}
+
+// End of section. //template:end updateFromBody
+
+// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBodyXML
+
+func (data *Template) updateFromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/template_name"); value.Exists() && !data.TemplateName.IsNull() {
+ data.TemplateName = types.StringValue(value.String())
+ } else {
+ data.TemplateName = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/dot1x/pae"); value.Exists() && !data.Dot1xPae.IsNull() {
+ data.Dot1xPae = types.StringValue(value.String())
+ } else {
+ data.Dot1xPae = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/dot1x/max-reauth-req"); value.Exists() && !data.Dot1xMaxReauthReq.IsNull() {
+ data.Dot1xMaxReauthReq = types.Int64Value(value.Int())
+ } else {
+ data.Dot1xMaxReauthReq = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/dot1x/max-req"); value.Exists() && !data.Dot1xMaxReq.IsNull() {
+ data.Dot1xMaxReq = types.Int64Value(value.Int())
+ } else {
+ data.Dot1xMaxReq = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/dot1x/timeout/tx-period"); value.Exists() && !data.Dot1xTimeoutTxPeriod.IsNull() {
+ data.Dot1xTimeoutTxPeriod = types.Int64Value(value.Int())
+ } else {
+ data.Dot1xTimeoutTxPeriod = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/service-policy/type/control/subscriber"); value.Exists() && !data.ServicePolicyTypeControlSubscriber.IsNull() {
+ data.ServicePolicyTypeControlSubscriber = types.StringValue(value.String())
+ } else {
+ data.ServicePolicyTypeControlSubscriber = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/service-policy/input/policy-map-name"); value.Exists() && !data.ServicePolicyInput.IsNull() {
+ data.ServicePolicyInput = types.StringValue(value.String())
+ } else {
+ data.ServicePolicyInput = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/service-policy/output/policy-map-name"); value.Exists() && !data.ServicePolicyOutput.IsNull() {
+ data.ServicePolicyOutput = types.StringValue(value.String())
+ } else {
+ data.ServicePolicyOutput = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/"); value.Exists() && !data.SourceTemplate.IsNull() {
+ data.SourceTemplate = types.StringValue(value.String())
+ } else {
+ data.SourceTemplate = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/switchport/mode/trunk"); !data.SwitchportModeTrunk.IsNull() {
+ if value.Exists() {
+ data.SwitchportModeTrunk = types.BoolValue(true)
+ } else {
+ data.SwitchportModeTrunk = types.BoolValue(false)
+ }
+ } else {
+ data.SwitchportModeTrunk = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/switchport/mode/access"); !data.SwitchportModeAccess.IsNull() {
+ if value.Exists() {
+ data.SwitchportModeAccess = types.BoolValue(true)
+ } else {
+ data.SwitchportModeAccess = types.BoolValue(false)
+ }
+ } else {
+ data.SwitchportModeAccess = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/switchport/nonegotiate"); !data.SwitchportNonegotiate.IsNull() {
+ if value.Exists() {
+ data.SwitchportNonegotiate = types.BoolValue(true)
+ } else {
+ data.SwitchportNonegotiate = types.BoolValue(false)
+ }
+ } else {
+ data.SwitchportNonegotiate = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/switchport/block/unicast"); !data.SwitchportBlockUnicast.IsNull() {
+ if value.Exists() {
+ data.SwitchportBlockUnicast = types.BoolValue(true)
+ } else {
+ data.SwitchportBlockUnicast = types.BoolValue(false)
+ }
+ } else {
+ data.SwitchportBlockUnicast = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/switchport/port-security"); !data.SwitchportPortSecurity.IsNull() {
+ if value.Exists() {
+ data.SwitchportPortSecurity = types.BoolValue(true)
+ } else {
+ data.SwitchportPortSecurity = types.BoolValue(false)
+ }
+ } else {
+ data.SwitchportPortSecurity = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/switchport/port-security/aging/static"); !data.SwitchportPortSecurityAgingStatic.IsNull() {
+ if value.Exists() {
+ data.SwitchportPortSecurityAgingStatic = types.BoolValue(true)
+ } else {
+ data.SwitchportPortSecurityAgingStatic = types.BoolValue(false)
+ }
+ } else {
+ data.SwitchportPortSecurityAgingStatic = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/switchport/port-security/aging/time"); value.Exists() && !data.SwitchportPortSecurityAgingTime.IsNull() {
+ data.SwitchportPortSecurityAgingTime = types.Int64Value(value.Int())
+ } else {
+ data.SwitchportPortSecurityAgingTime = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/switchport/port-security/aging/type"); !data.SwitchportPortSecurityAgingType.IsNull() {
+ if value.Exists() {
+ data.SwitchportPortSecurityAgingType = types.BoolValue(true)
+ } else {
+ data.SwitchportPortSecurityAgingType = types.BoolValue(false)
+ }
+ } else {
+ data.SwitchportPortSecurityAgingType = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/switchport/port-security/aging/type/inactivity"); !data.SwitchportPortSecurityAgingTypeInactivity.IsNull() {
+ if value.Exists() {
+ data.SwitchportPortSecurityAgingTypeInactivity = types.BoolValue(true)
+ } else {
+ data.SwitchportPortSecurityAgingTypeInactivity = types.BoolValue(false)
+ }
+ } else {
+ data.SwitchportPortSecurityAgingTypeInactivity = types.BoolNull()
+ }
+ for i := range data.SwitchportPortSecurityMaximumRange {
+ keys := [...]string{"range"}
+ keyValues := [...]string{strconv.FormatInt(data.SwitchportPortSecurityMaximumRange[i].Range.ValueInt64(), 10)}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/switchport/port-security/maximum/range").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, "range"); value.Exists() && !data.SwitchportPortSecurityMaximumRange[i].Range.IsNull() {
+ data.SwitchportPortSecurityMaximumRange[i].Range = types.Int64Value(value.Int())
+ } else {
+ data.SwitchportPortSecurityMaximumRange[i].Range = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(r, "vlan"); !data.SwitchportPortSecurityMaximumRange[i].Vlan.IsNull() {
+ if value.Exists() {
+ data.SwitchportPortSecurityMaximumRange[i].Vlan = types.BoolValue(true)
+ } else {
+ data.SwitchportPortSecurityMaximumRange[i].Vlan = types.BoolValue(false)
+ }
+ } else {
+ data.SwitchportPortSecurityMaximumRange[i].Vlan = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(r, "vlan/access"); !data.SwitchportPortSecurityMaximumRange[i].VlanAccess.IsNull() {
+ if value.Exists() {
+ data.SwitchportPortSecurityMaximumRange[i].VlanAccess = types.BoolValue(true)
+ } else {
+ data.SwitchportPortSecurityMaximumRange[i].VlanAccess = types.BoolValue(false)
+ }
+ } else {
+ data.SwitchportPortSecurityMaximumRange[i].VlanAccess = types.BoolNull()
+ }
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/switchport/port-security/violation/protect"); !data.SwitchportPortSecurityViolationProtect.IsNull() {
+ if value.Exists() {
+ data.SwitchportPortSecurityViolationProtect = types.BoolValue(true)
+ } else {
+ data.SwitchportPortSecurityViolationProtect = types.BoolValue(false)
+ }
+ } else {
+ data.SwitchportPortSecurityViolationProtect = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/switchport/port-security/violation/restrict"); !data.SwitchportPortSecurityViolationRestrict.IsNull() {
+ if value.Exists() {
+ data.SwitchportPortSecurityViolationRestrict = types.BoolValue(true)
+ } else {
+ data.SwitchportPortSecurityViolationRestrict = types.BoolValue(false)
+ }
+ } else {
+ data.SwitchportPortSecurityViolationRestrict = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/switchport/port-security/violation/shutdown"); !data.SwitchportPortSecurityViolationShutdown.IsNull() {
+ if value.Exists() {
+ data.SwitchportPortSecurityViolationShutdown = types.BoolValue(true)
+ } else {
+ data.SwitchportPortSecurityViolationShutdown = types.BoolValue(false)
+ }
+ } else {
+ data.SwitchportPortSecurityViolationShutdown = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/switchport/access/vlan"); value.Exists() && !data.SwitchportAccessVlan.IsNull() {
+ data.SwitchportAccessVlan = types.Int64Value(value.Int())
+ } else {
+ data.SwitchportAccessVlan = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/switchport/voice/vlan"); value.Exists() && !data.SwitchportVoiceVlan.IsNull() {
+ data.SwitchportVoiceVlan = types.Int64Value(value.Int())
+ } else {
+ data.SwitchportVoiceVlan = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/switchport/private-vlan/host-association/primary-range"); value.Exists() && !data.SwitchportPrivateVlanHostAssociationPrimaryRange.IsNull() {
+ data.SwitchportPrivateVlanHostAssociationPrimaryRange = types.Int64Value(value.Int())
+ } else {
+ data.SwitchportPrivateVlanHostAssociationPrimaryRange = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/switchport/private-vlan/host-association/secondary-range"); value.Exists() && !data.SwitchportPrivateVlanHostAssociationSecondaryRange.IsNull() {
+ data.SwitchportPrivateVlanHostAssociationSecondaryRange = types.Int64Value(value.Int())
+ } else {
+ data.SwitchportPrivateVlanHostAssociationSecondaryRange = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/switchport/trunk/allowed/vlan/vlans"); value.Exists() && !data.SwitchportTrunkAllowedVlans.IsNull() {
+ data.SwitchportTrunkAllowedVlans = types.StringValue(value.String())
+ } else {
+ data.SwitchportTrunkAllowedVlans = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/switchport/trunk/allowed/vlan/none"); !data.SwitchportTrunkAllowedVlansNone.IsNull() {
+ if value.Exists() {
+ data.SwitchportTrunkAllowedVlansNone = types.BoolValue(true)
+ } else {
+ data.SwitchportTrunkAllowedVlansNone = types.BoolValue(false)
+ }
+ } else {
+ data.SwitchportTrunkAllowedVlansNone = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/switchport/trunk/allowed/vlan/all"); !data.SwitchportTrunkAllowedVlansAll.IsNull() {
+ if value.Exists() {
+ data.SwitchportTrunkAllowedVlansAll = types.BoolValue(true)
+ } else {
+ data.SwitchportTrunkAllowedVlansAll = types.BoolValue(false)
+ }
+ } else {
+ data.SwitchportTrunkAllowedVlansAll = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/switchport/trunk/native/vlan/tag"); !data.SwitchportTrunkNativeVlanTag.IsNull() {
+ if value.Exists() {
+ data.SwitchportTrunkNativeVlanTag = types.BoolValue(value.Bool())
+ }
+ } else {
+ data.SwitchportTrunkNativeVlanTag = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/switchport/trunk/native/vlan/vlan-id"); value.Exists() && !data.SwitchportTrunkNativeVlanVlanId.IsNull() {
+ data.SwitchportTrunkNativeVlanVlanId = types.Int64Value(value.Int())
+ } else {
+ data.SwitchportTrunkNativeVlanVlanId = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/mab"); !data.Mab.IsNull() {
+ if value.Exists() {
+ data.Mab = types.BoolValue(true)
+ } else {
+ data.Mab = types.BoolValue(false)
+ }
+ } else {
+ data.Mab = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/mab/eap"); !data.MabEap.IsNull() {
+ if value.Exists() {
+ data.MabEap = types.BoolValue(true)
+ } else {
+ data.MabEap = types.BoolValue(false)
+ }
+ } else {
+ data.MabEap = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/access-session/closed"); !data.AccessSessionClosed.IsNull() {
+ if value.Exists() {
+ data.AccessSessionClosed = types.BoolValue(true)
+ } else {
+ data.AccessSessionClosed = types.BoolValue(false)
+ }
+ } else {
+ data.AccessSessionClosed = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/access-session/monitor"); !data.AccessSessionMonitor.IsNull() {
+ if value.Exists() {
+ data.AccessSessionMonitor = types.BoolValue(value.Bool())
+ }
+ } else {
+ data.AccessSessionMonitor = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/access-session/port-control"); value.Exists() && !data.AccessSessionPortControl.IsNull() {
+ data.AccessSessionPortControl = types.StringValue(value.String())
+ } else {
+ data.AccessSessionPortControl = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/access-session/control-direction"); value.Exists() && !data.AccessSessionControlDirection.IsNull() {
+ data.AccessSessionControlDirection = types.StringValue(value.String())
+ } else {
+ data.AccessSessionControlDirection = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/access-session/host-mode"); value.Exists() && !data.AccessSessionHostMode.IsNull() {
+ data.AccessSessionHostMode = types.StringValue(value.String())
+ } else {
+ data.AccessSessionHostMode = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/access-session/interface-template/sticky"); !data.AccessSessionInterfaceTemplateSticky.IsNull() {
+ if value.Exists() {
+ data.AccessSessionInterfaceTemplateSticky = types.BoolValue(true)
+ } else {
+ data.AccessSessionInterfaceTemplateSticky = types.BoolValue(false)
+ }
+ } else {
+ data.AccessSessionInterfaceTemplateSticky = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/access-session/interface-template/sticky/timer"); value.Exists() && !data.AccessSessionInterfaceTemplateStickyTimer.IsNull() {
+ data.AccessSessionInterfaceTemplateStickyTimer = types.Int64Value(value.Int())
+ } else {
+ data.AccessSessionInterfaceTemplateStickyTimer = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/authentication/periodic"); !data.AuthenticationPeriodic.IsNull() {
+ if value.Exists() {
+ data.AuthenticationPeriodic = types.BoolValue(true)
+ } else {
+ data.AuthenticationPeriodic = types.BoolValue(false)
+ }
+ } else {
+ data.AuthenticationPeriodic = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/authentication/timer/reauthenticate/server"); !data.AuthenticationTimerReauthenticateServer.IsNull() {
+ if value.Exists() {
+ data.AuthenticationTimerReauthenticateServer = types.BoolValue(true)
+ } else {
+ data.AuthenticationTimerReauthenticateServer = types.BoolValue(false)
+ }
+ } else {
+ data.AuthenticationTimerReauthenticateServer = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/authentication/timer/reauthenticate/range"); value.Exists() && !data.AuthenticationTimerReauthenticateRange.IsNull() {
+ data.AuthenticationTimerReauthenticateRange = types.Int64Value(value.Int())
+ } else {
+ data.AuthenticationTimerReauthenticateRange = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/spanning-tree/bpduguard/enable"); !data.SpanningTreeBpduguardEnable.IsNull() {
+ if value.Exists() {
+ data.SpanningTreeBpduguardEnable = types.BoolValue(true)
+ } else {
+ data.SpanningTreeBpduguardEnable = types.BoolValue(false)
+ }
+ } else {
+ data.SpanningTreeBpduguardEnable = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/spanning-tree/service-policy"); !data.SpanningTreeServicePolicy.IsNull() {
+ if value.Exists() {
+ data.SpanningTreeServicePolicy = types.BoolValue(true)
+ } else {
+ data.SpanningTreeServicePolicy = types.BoolValue(false)
+ }
+ } else {
+ data.SpanningTreeServicePolicy = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/spanning-tree/portfast"); !data.SpanningTreePortfast.IsNull() {
+ if value.Exists() {
+ data.SpanningTreePortfast = types.BoolValue(true)
+ } else {
+ data.SpanningTreePortfast = types.BoolValue(false)
+ }
+ } else {
+ data.SpanningTreePortfast = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/spanning-tree/portfast/disable"); !data.SpanningTreePortfastDisable.IsNull() {
+ if value.Exists() {
+ data.SpanningTreePortfastDisable = types.BoolValue(true)
+ } else {
+ data.SpanningTreePortfastDisable = types.BoolValue(false)
+ }
+ } else {
+ data.SpanningTreePortfastDisable = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/spanning-tree/portfast/edge"); !data.SpanningTreePortfastEdge.IsNull() {
+ if value.Exists() {
+ data.SpanningTreePortfastEdge = types.BoolValue(true)
+ } else {
+ data.SpanningTreePortfastEdge = types.BoolValue(false)
+ }
+ } else {
+ data.SpanningTreePortfastEdge = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/spanning-tree/portfast/network"); !data.SpanningTreePortfastNetwork.IsNull() {
+ if value.Exists() {
+ data.SpanningTreePortfastNetwork = types.BoolValue(true)
+ } else {
+ data.SpanningTreePortfastNetwork = types.BoolValue(false)
+ }
+ } else {
+ data.SpanningTreePortfastNetwork = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/storm-control/broadcast/level/pps/threshold"); value.Exists() && !data.StormControlBroadcastLevelPpsThreshold.IsNull() {
+ data.StormControlBroadcastLevelPpsThreshold = types.StringValue(value.String())
+ } else {
+ data.StormControlBroadcastLevelPpsThreshold = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/storm-control/broadcast/level/bps/threshold"); value.Exists() && !data.StormControlBroadcastLevelBpsThreshold.IsNull() {
+ data.StormControlBroadcastLevelBpsThreshold = types.Float64Value(value.Float())
+ } else {
+ data.StormControlBroadcastLevelBpsThreshold = types.Float64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/storm-control/broadcast/level/threshold"); value.Exists() && !data.StormControlBroadcastLevelThreshold.IsNull() {
+ data.StormControlBroadcastLevelThreshold = types.Float64Value(value.Float())
+ } else {
+ data.StormControlBroadcastLevelThreshold = types.Float64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/storm-control/multicast/level/pps/threshold"); value.Exists() && !data.StormControlMulticastLevelPpsThreshold.IsNull() {
+ data.StormControlMulticastLevelPpsThreshold = types.StringValue(value.String())
+ } else {
+ data.StormControlMulticastLevelPpsThreshold = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/storm-control/multicast/level/bps/threshold"); value.Exists() && !data.StormControlMulticastLevelBpsThreshold.IsNull() {
+ data.StormControlMulticastLevelBpsThreshold = types.Float64Value(value.Float())
+ } else {
+ data.StormControlMulticastLevelBpsThreshold = types.Float64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/storm-control/multicast/level/threshold"); value.Exists() && !data.StormControlMulticastLevelThreshold.IsNull() {
+ data.StormControlMulticastLevelThreshold = types.Float64Value(value.Float())
+ } else {
+ data.StormControlMulticastLevelThreshold = types.Float64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/storm-control/action/shutdown"); !data.StormControlActionShutdown.IsNull() {
+ if value.Exists() {
+ data.StormControlActionShutdown = types.BoolValue(true)
+ } else {
+ data.StormControlActionShutdown = types.BoolValue(false)
+ }
+ } else {
+ data.StormControlActionShutdown = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/storm-control/action/trap"); !data.StormControlActionTrap.IsNull() {
+ if value.Exists() {
+ data.StormControlActionTrap = types.BoolValue(true)
+ } else {
+ data.StormControlActionTrap = types.BoolValue(false)
+ }
+ } else {
+ data.StormControlActionTrap = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/load-interval"); value.Exists() && !data.LoadInterval.IsNull() {
+ data.LoadInterval = types.Int64Value(value.Int())
+ } else {
+ data.LoadInterval = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/dhcp/snooping/limit/rate"); value.Exists() && !data.IpDhcpSnoopingLimitRate.IsNull() {
+ data.IpDhcpSnoopingLimitRate = types.Int64Value(value.Int())
+ } else {
+ data.IpDhcpSnoopingLimitRate = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/dhcp/snooping/trust"); !data.IpDhcpSnoopingTrust.IsNull() {
+ if value.Exists() {
+ data.IpDhcpSnoopingTrust = types.BoolValue(true)
+ } else {
+ data.IpDhcpSnoopingTrust = types.BoolValue(false)
+ }
+ } else {
+ data.IpDhcpSnoopingTrust = types.BoolNull()
+ }
+ for i := range data.IpAccessGroup {
+ keys := [...]string{"direction"}
+ keyValues := [...]string{data.IpAccessGroup[i].Direction.ValueString()}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/access-group").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, "direction"); value.Exists() && !data.IpAccessGroup[i].Direction.IsNull() {
+ data.IpAccessGroup[i].Direction = types.StringValue(value.String())
+ } else {
+ data.IpAccessGroup[i].Direction = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "access-list"); value.Exists() && !data.IpAccessGroup[i].AccessList.IsNull() {
+ data.IpAccessGroup[i].AccessList = types.StringValue(value.String())
+ } else {
+ data.IpAccessGroup[i].AccessList = types.StringNull()
+ }
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/subscriber/aging/inactivity-timer/value"); value.Exists() && !data.SubscriberAgingInactivityTimerValue.IsNull() {
+ data.SubscriberAgingInactivityTimerValue = types.Int64Value(value.Int())
+ } else {
+ data.SubscriberAgingInactivityTimerValue = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/subscriber/aging/inactivity-timer/probe"); !data.SubscriberAgingInactivityTimerProbe.IsNull() {
+ if value.Exists() {
+ data.SubscriberAgingInactivityTimerProbe = types.BoolValue(true)
+ } else {
+ data.SubscriberAgingInactivityTimerProbe = types.BoolValue(false)
+ }
+ } else {
+ data.SubscriberAgingInactivityTimerProbe = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/subscriber/aging/probe"); !data.SubscriberAgingProbe.IsNull() {
+ if value.Exists() {
+ data.SubscriberAgingProbe = types.BoolValue(true)
+ } else {
+ data.SubscriberAgingProbe = types.BoolValue(false)
+ }
+ } else {
+ data.SubscriberAgingProbe = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/device-tracking"); !data.DeviceTracking.IsNull() {
+ if value.Exists() {
+ data.DeviceTracking = types.BoolValue(true)
+ } else {
+ data.DeviceTracking = types.BoolValue(false)
+ }
+ } else {
+ data.DeviceTracking = types.BoolNull()
+ }
+ for i := range data.DeviceTrackingAttachPolicy {
+ keys := [...]string{"policy-name"}
+ keyValues := [...]string{data.DeviceTrackingAttachPolicy[i].PolicyName.ValueString()}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/device-tracking/attach-policy/policy-name").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, "policy-name"); value.Exists() && !data.DeviceTrackingAttachPolicy[i].PolicyName.IsNull() {
+ data.DeviceTrackingAttachPolicy[i].PolicyName = types.StringValue(value.String())
+ } else {
+ data.DeviceTrackingAttachPolicy[i].PolicyName = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "vlan/vlan-range"); value.Exists() && !data.DeviceTrackingAttachPolicy[i].VlanRange.IsNull() {
+ data.DeviceTrackingAttachPolicy[i].VlanRange = types.StringValue(value.String())
+ } else {
+ data.DeviceTrackingAttachPolicy[i].VlanRange = types.StringNull()
+ }
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/device-tracking/vlan/vlan-range"); value.Exists() && !data.DeviceTrackingVlanRange.IsNull() {
+ data.DeviceTrackingVlanRange = types.StringValue(value.String())
+ } else {
+ data.DeviceTrackingVlanRange = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/cts/manual"); !data.CtsManual.IsNull() {
+ if value.Exists() {
+ data.CtsManual = types.BoolValue(true)
+ } else {
+ data.CtsManual = types.BoolValue(false)
+ }
+ } else {
+ data.CtsManual = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/cts/manual/policy/static/sgt"); value.Exists() && !data.CtsManualPolicyStaticSgt.IsNull() {
+ data.CtsManualPolicyStaticSgt = types.Int64Value(value.Int())
+ } else {
+ data.CtsManualPolicyStaticSgt = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/cts/manual/policy/static/trusted"); !data.CtsManualPolicyStaticTrusted.IsNull() {
+ if value.Exists() {
+ data.CtsManualPolicyStaticTrusted = types.BoolValue(true)
+ } else {
+ data.CtsManualPolicyStaticTrusted = types.BoolValue(false)
+ }
+ } else {
+ data.CtsManualPolicyStaticTrusted = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/cts/manual/propagate/sgt"); !data.CtsManualPropagateSgt.IsNull() {
+ if value.Exists() {
+ data.CtsManualPropagateSgt = types.BoolValue(value.Bool())
+ }
+ } else {
+ data.CtsManualPropagateSgt = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/cts/role-based/enforcement"); !data.CtsRoleBasedEnforcement.IsNull() {
+ if value.Exists() {
+ data.CtsRoleBasedEnforcement = types.BoolValue(value.Bool())
+ }
+ } else {
+ data.CtsRoleBasedEnforcement = types.BoolNull()
+ }
+}
+
+// End of section. //template:end updateFromBodyXML
+
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBody
+
+func (data *Template) fromBody(ctx context.Context, res gjson.Result) {
+ prefix := helpers.LastElement(data.getPath()) + "."
+ if res.Get(helpers.LastElement(data.getPath())).IsArray() {
+ prefix += "0."
+ }
+ if value := res.Get(prefix + "dot1x.pae"); value.Exists() {
+ data.Dot1xPae = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "dot1x.max-reauth-req"); value.Exists() {
+ data.Dot1xMaxReauthReq = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "dot1x.max-req"); value.Exists() {
+ data.Dot1xMaxReq = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "dot1x.timeout.tx-period"); value.Exists() {
+ data.Dot1xTimeoutTxPeriod = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "service-policy.type.control.subscriber"); value.Exists() {
+ data.ServicePolicyTypeControlSubscriber = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "service-policy.input.policy-map-name"); value.Exists() {
+ data.ServicePolicyInput = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "service-policy.output.policy-map-name"); value.Exists() {
+ data.ServicePolicyOutput = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + ""); value.Exists() {
+ data.SourceTemplate = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "switchport.mode.trunk"); value.Exists() {
+ data.SwitchportModeTrunk = types.BoolValue(true)
+ } else {
+ data.SwitchportModeTrunk = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "switchport.mode.access"); value.Exists() {
+ data.SwitchportModeAccess = types.BoolValue(true)
+ } else {
+ data.SwitchportModeAccess = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "switchport.nonegotiate"); value.Exists() {
+ data.SwitchportNonegotiate = types.BoolValue(true)
+ } else {
+ data.SwitchportNonegotiate = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "switchport.block.unicast"); value.Exists() {
+ data.SwitchportBlockUnicast = types.BoolValue(true)
+ } else {
+ data.SwitchportBlockUnicast = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "switchport.port-security"); value.Exists() {
+ data.SwitchportPortSecurity = types.BoolValue(true)
+ } else {
+ data.SwitchportPortSecurity = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "switchport.port-security.aging.static"); value.Exists() {
+ data.SwitchportPortSecurityAgingStatic = types.BoolValue(true)
+ } else {
+ data.SwitchportPortSecurityAgingStatic = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "switchport.port-security.aging.time"); value.Exists() {
+ data.SwitchportPortSecurityAgingTime = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "switchport.port-security.aging.type"); value.Exists() {
+ data.SwitchportPortSecurityAgingType = types.BoolValue(true)
+ } else {
+ data.SwitchportPortSecurityAgingType = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "switchport.port-security.aging.type.inactivity"); value.Exists() {
+ data.SwitchportPortSecurityAgingTypeInactivity = types.BoolValue(true)
+ } else {
+ data.SwitchportPortSecurityAgingTypeInactivity = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "switchport.port-security.maximum.range"); value.Exists() {
+ data.SwitchportPortSecurityMaximumRange = make([]TemplateSwitchportPortSecurityMaximumRange, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := TemplateSwitchportPortSecurityMaximumRange{}
+ if cValue := v.Get("range"); cValue.Exists() {
+ item.Range = types.Int64Value(cValue.Int())
+ }
+ if cValue := v.Get("vlan"); cValue.Exists() {
+ item.Vlan = types.BoolValue(true)
+ } else {
+ item.Vlan = types.BoolValue(false)
+ }
+ if cValue := v.Get("vlan.access"); cValue.Exists() {
+ item.VlanAccess = types.BoolValue(true)
+ } else {
+ item.VlanAccess = types.BoolValue(false)
+ }
+ data.SwitchportPortSecurityMaximumRange = append(data.SwitchportPortSecurityMaximumRange, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + "switchport.port-security.violation.protect"); value.Exists() {
+ data.SwitchportPortSecurityViolationProtect = types.BoolValue(true)
+ } else {
+ data.SwitchportPortSecurityViolationProtect = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "switchport.port-security.violation.restrict"); value.Exists() {
+ data.SwitchportPortSecurityViolationRestrict = types.BoolValue(true)
+ } else {
+ data.SwitchportPortSecurityViolationRestrict = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "switchport.port-security.violation.shutdown"); value.Exists() {
+ data.SwitchportPortSecurityViolationShutdown = types.BoolValue(true)
+ } else {
+ data.SwitchportPortSecurityViolationShutdown = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "switchport.access.vlan"); value.Exists() {
+ data.SwitchportAccessVlan = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "switchport.voice.vlan"); value.Exists() {
+ data.SwitchportVoiceVlan = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "switchport.private-vlan.host-association.primary-range"); value.Exists() {
+ data.SwitchportPrivateVlanHostAssociationPrimaryRange = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "switchport.private-vlan.host-association.secondary-range"); value.Exists() {
+ data.SwitchportPrivateVlanHostAssociationSecondaryRange = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "switchport.trunk.allowed.vlan.vlans"); value.Exists() {
+ data.SwitchportTrunkAllowedVlans = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "switchport.trunk.allowed.vlan.none"); value.Exists() {
+ data.SwitchportTrunkAllowedVlansNone = types.BoolValue(true)
+ } else {
+ data.SwitchportTrunkAllowedVlansNone = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "switchport.trunk.allowed.vlan.all"); value.Exists() {
+ data.SwitchportTrunkAllowedVlansAll = types.BoolValue(true)
+ } else {
+ data.SwitchportTrunkAllowedVlansAll = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "switchport.trunk.native.vlan.tag"); value.Exists() {
+ data.SwitchportTrunkNativeVlanTag = types.BoolValue(value.Bool())
+ } else {
+ data.SwitchportTrunkNativeVlanTag = types.BoolNull()
+ }
+ if value := res.Get(prefix + "switchport.trunk.native.vlan.vlan-id"); value.Exists() {
+ data.SwitchportTrunkNativeVlanVlanId = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "mab"); value.Exists() {
+ data.Mab = types.BoolValue(true)
+ } else {
+ data.Mab = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "mab.eap"); value.Exists() {
+ data.MabEap = types.BoolValue(true)
+ } else {
+ data.MabEap = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "access-session.closed"); value.Exists() {
+ data.AccessSessionClosed = types.BoolValue(true)
+ } else {
+ data.AccessSessionClosed = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "access-session.monitor"); value.Exists() {
+ data.AccessSessionMonitor = types.BoolValue(value.Bool())
+ } else {
+ data.AccessSessionMonitor = types.BoolNull()
+ }
+ if value := res.Get(prefix + "access-session.port-control"); value.Exists() {
+ data.AccessSessionPortControl = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "access-session.control-direction"); value.Exists() {
+ data.AccessSessionControlDirection = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "access-session.host-mode"); value.Exists() {
+ data.AccessSessionHostMode = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "access-session.interface-template.sticky"); value.Exists() {
+ data.AccessSessionInterfaceTemplateSticky = types.BoolValue(true)
+ } else {
+ data.AccessSessionInterfaceTemplateSticky = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "access-session.interface-template.sticky.timer"); value.Exists() {
+ data.AccessSessionInterfaceTemplateStickyTimer = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "authentication.periodic"); value.Exists() {
+ data.AuthenticationPeriodic = types.BoolValue(true)
+ } else {
+ data.AuthenticationPeriodic = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "authentication.timer.reauthenticate.server"); value.Exists() {
+ data.AuthenticationTimerReauthenticateServer = types.BoolValue(true)
+ } else {
+ data.AuthenticationTimerReauthenticateServer = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "authentication.timer.reauthenticate.range"); value.Exists() {
+ data.AuthenticationTimerReauthenticateRange = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "spanning-tree.bpduguard.enable"); value.Exists() {
+ data.SpanningTreeBpduguardEnable = types.BoolValue(true)
+ } else {
+ data.SpanningTreeBpduguardEnable = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "spanning-tree.service-policy"); value.Exists() {
+ data.SpanningTreeServicePolicy = types.BoolValue(true)
+ } else {
+ data.SpanningTreeServicePolicy = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "spanning-tree.portfast"); value.Exists() {
+ data.SpanningTreePortfast = types.BoolValue(true)
+ } else {
+ data.SpanningTreePortfast = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "spanning-tree.portfast.disable"); value.Exists() {
+ data.SpanningTreePortfastDisable = types.BoolValue(true)
+ } else {
+ data.SpanningTreePortfastDisable = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "spanning-tree.portfast.edge"); value.Exists() {
+ data.SpanningTreePortfastEdge = types.BoolValue(true)
+ } else {
+ data.SpanningTreePortfastEdge = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "spanning-tree.portfast.network"); value.Exists() {
+ data.SpanningTreePortfastNetwork = types.BoolValue(true)
+ } else {
+ data.SpanningTreePortfastNetwork = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "storm-control.broadcast.level.pps.threshold"); value.Exists() {
+ data.StormControlBroadcastLevelPpsThreshold = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "storm-control.broadcast.level.bps.threshold"); value.Exists() {
+ data.StormControlBroadcastLevelBpsThreshold = types.Float64Value(value.Float())
+ }
+ if value := res.Get(prefix + "storm-control.broadcast.level.threshold"); value.Exists() {
+ data.StormControlBroadcastLevelThreshold = types.Float64Value(value.Float())
+ }
+ if value := res.Get(prefix + "storm-control.multicast.level.pps.threshold"); value.Exists() {
+ data.StormControlMulticastLevelPpsThreshold = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "storm-control.multicast.level.bps.threshold"); value.Exists() {
+ data.StormControlMulticastLevelBpsThreshold = types.Float64Value(value.Float())
+ }
+ if value := res.Get(prefix + "storm-control.multicast.level.threshold"); value.Exists() {
+ data.StormControlMulticastLevelThreshold = types.Float64Value(value.Float())
+ }
+ if value := res.Get(prefix + "storm-control.action.shutdown"); value.Exists() {
+ data.StormControlActionShutdown = types.BoolValue(true)
+ } else {
+ data.StormControlActionShutdown = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "storm-control.action.trap"); value.Exists() {
+ data.StormControlActionTrap = types.BoolValue(true)
+ } else {
+ data.StormControlActionTrap = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "load-interval"); value.Exists() {
+ data.LoadInterval = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "ip.dhcp.snooping.limit.rate"); value.Exists() {
+ data.IpDhcpSnoopingLimitRate = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "ip.dhcp.snooping.trust"); value.Exists() {
+ data.IpDhcpSnoopingTrust = types.BoolValue(true)
+ } else {
+ data.IpDhcpSnoopingTrust = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "ip.access-group"); value.Exists() {
+ data.IpAccessGroup = make([]TemplateIpAccessGroup, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := TemplateIpAccessGroup{}
+ if cValue := v.Get("direction"); cValue.Exists() {
+ item.Direction = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("access-list"); cValue.Exists() {
+ item.AccessList = types.StringValue(cValue.String())
+ }
+ data.IpAccessGroup = append(data.IpAccessGroup, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + "subscriber.aging.inactivity-timer.value"); value.Exists() {
+ data.SubscriberAgingInactivityTimerValue = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "subscriber.aging.inactivity-timer.probe"); value.Exists() {
+ data.SubscriberAgingInactivityTimerProbe = types.BoolValue(true)
+ } else {
+ data.SubscriberAgingInactivityTimerProbe = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "subscriber.aging.probe"); value.Exists() {
+ data.SubscriberAgingProbe = types.BoolValue(true)
+ } else {
+ data.SubscriberAgingProbe = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "device-tracking"); value.Exists() {
+ data.DeviceTracking = types.BoolValue(true)
+ } else {
+ data.DeviceTracking = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "device-tracking.attach-policy.policy-name"); value.Exists() {
+ data.DeviceTrackingAttachPolicy = make([]TemplateDeviceTrackingAttachPolicy, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := TemplateDeviceTrackingAttachPolicy{}
+ if cValue := v.Get("policy-name"); cValue.Exists() {
+ item.PolicyName = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("vlan.vlan-range"); cValue.Exists() {
+ item.VlanRange = types.StringValue(cValue.String())
+ }
+ data.DeviceTrackingAttachPolicy = append(data.DeviceTrackingAttachPolicy, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + "device-tracking.vlan.vlan-range"); value.Exists() {
+ data.DeviceTrackingVlanRange = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "cts.manual"); value.Exists() {
+ data.CtsManual = types.BoolValue(true)
+ } else {
+ data.CtsManual = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "cts.manual.policy.static.sgt"); value.Exists() {
+ data.CtsManualPolicyStaticSgt = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "cts.manual.policy.static.trusted"); value.Exists() {
+ data.CtsManualPolicyStaticTrusted = types.BoolValue(true)
+ } else {
+ data.CtsManualPolicyStaticTrusted = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "cts.manual.propagate.sgt"); value.Exists() {
+ data.CtsManualPropagateSgt = types.BoolValue(value.Bool())
+ } else {
+ data.CtsManualPropagateSgt = types.BoolNull()
+ }
+ if value := res.Get(prefix + "cts.role-based.enforcement"); value.Exists() {
+ data.CtsRoleBasedEnforcement = types.BoolValue(value.Bool())
+ } else {
+ data.CtsRoleBasedEnforcement = types.BoolNull()
+ }
+}
+
+// End of section. //template:end fromBody
+
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyData
+
+func (data *TemplateData) fromBody(ctx context.Context, res gjson.Result) {
+ prefix := helpers.LastElement(data.getPath()) + "."
+ if res.Get(helpers.LastElement(data.getPath())).IsArray() {
+ prefix += "0."
+ }
+ if value := res.Get(prefix + "dot1x.pae"); value.Exists() {
+ data.Dot1xPae = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "dot1x.max-reauth-req"); value.Exists() {
+ data.Dot1xMaxReauthReq = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "dot1x.max-req"); value.Exists() {
+ data.Dot1xMaxReq = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "dot1x.timeout.tx-period"); value.Exists() {
+ data.Dot1xTimeoutTxPeriod = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "service-policy.type.control.subscriber"); value.Exists() {
+ data.ServicePolicyTypeControlSubscriber = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "service-policy.input.policy-map-name"); value.Exists() {
+ data.ServicePolicyInput = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "service-policy.output.policy-map-name"); value.Exists() {
+ data.ServicePolicyOutput = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + ""); value.Exists() {
+ data.SourceTemplate = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "switchport.mode.trunk"); value.Exists() {
+ data.SwitchportModeTrunk = types.BoolValue(true)
+ } else {
+ data.SwitchportModeTrunk = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "switchport.mode.access"); value.Exists() {
+ data.SwitchportModeAccess = types.BoolValue(true)
+ } else {
+ data.SwitchportModeAccess = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "switchport.nonegotiate"); value.Exists() {
+ data.SwitchportNonegotiate = types.BoolValue(true)
+ } else {
+ data.SwitchportNonegotiate = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "switchport.block.unicast"); value.Exists() {
+ data.SwitchportBlockUnicast = types.BoolValue(true)
+ } else {
+ data.SwitchportBlockUnicast = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "switchport.port-security"); value.Exists() {
+ data.SwitchportPortSecurity = types.BoolValue(true)
+ } else {
+ data.SwitchportPortSecurity = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "switchport.port-security.aging.static"); value.Exists() {
+ data.SwitchportPortSecurityAgingStatic = types.BoolValue(true)
+ } else {
+ data.SwitchportPortSecurityAgingStatic = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "switchport.port-security.aging.time"); value.Exists() {
+ data.SwitchportPortSecurityAgingTime = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "switchport.port-security.aging.type"); value.Exists() {
+ data.SwitchportPortSecurityAgingType = types.BoolValue(true)
+ } else {
+ data.SwitchportPortSecurityAgingType = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "switchport.port-security.aging.type.inactivity"); value.Exists() {
+ data.SwitchportPortSecurityAgingTypeInactivity = types.BoolValue(true)
+ } else {
+ data.SwitchportPortSecurityAgingTypeInactivity = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "switchport.port-security.maximum.range"); value.Exists() {
+ data.SwitchportPortSecurityMaximumRange = make([]TemplateSwitchportPortSecurityMaximumRange, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := TemplateSwitchportPortSecurityMaximumRange{}
+ if cValue := v.Get("range"); cValue.Exists() {
+ item.Range = types.Int64Value(cValue.Int())
+ }
+ if cValue := v.Get("vlan"); cValue.Exists() {
+ item.Vlan = types.BoolValue(true)
+ } else {
+ item.Vlan = types.BoolValue(false)
+ }
+ if cValue := v.Get("vlan.access"); cValue.Exists() {
+ item.VlanAccess = types.BoolValue(true)
+ } else {
+ item.VlanAccess = types.BoolValue(false)
+ }
+ data.SwitchportPortSecurityMaximumRange = append(data.SwitchportPortSecurityMaximumRange, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + "switchport.port-security.violation.protect"); value.Exists() {
+ data.SwitchportPortSecurityViolationProtect = types.BoolValue(true)
+ } else {
+ data.SwitchportPortSecurityViolationProtect = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "switchport.port-security.violation.restrict"); value.Exists() {
+ data.SwitchportPortSecurityViolationRestrict = types.BoolValue(true)
+ } else {
+ data.SwitchportPortSecurityViolationRestrict = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "switchport.port-security.violation.shutdown"); value.Exists() {
+ data.SwitchportPortSecurityViolationShutdown = types.BoolValue(true)
+ } else {
+ data.SwitchportPortSecurityViolationShutdown = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "switchport.access.vlan"); value.Exists() {
+ data.SwitchportAccessVlan = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "switchport.voice.vlan"); value.Exists() {
+ data.SwitchportVoiceVlan = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "switchport.private-vlan.host-association.primary-range"); value.Exists() {
+ data.SwitchportPrivateVlanHostAssociationPrimaryRange = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "switchport.private-vlan.host-association.secondary-range"); value.Exists() {
+ data.SwitchportPrivateVlanHostAssociationSecondaryRange = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "switchport.trunk.allowed.vlan.vlans"); value.Exists() {
+ data.SwitchportTrunkAllowedVlans = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "switchport.trunk.allowed.vlan.none"); value.Exists() {
+ data.SwitchportTrunkAllowedVlansNone = types.BoolValue(true)
+ } else {
+ data.SwitchportTrunkAllowedVlansNone = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "switchport.trunk.allowed.vlan.all"); value.Exists() {
+ data.SwitchportTrunkAllowedVlansAll = types.BoolValue(true)
+ } else {
+ data.SwitchportTrunkAllowedVlansAll = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "switchport.trunk.native.vlan.tag"); value.Exists() {
+ data.SwitchportTrunkNativeVlanTag = types.BoolValue(value.Bool())
+ } else {
+ data.SwitchportTrunkNativeVlanTag = types.BoolNull()
+ }
+ if value := res.Get(prefix + "switchport.trunk.native.vlan.vlan-id"); value.Exists() {
+ data.SwitchportTrunkNativeVlanVlanId = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "mab"); value.Exists() {
+ data.Mab = types.BoolValue(true)
+ } else {
+ data.Mab = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "mab.eap"); value.Exists() {
+ data.MabEap = types.BoolValue(true)
+ } else {
+ data.MabEap = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "access-session.closed"); value.Exists() {
+ data.AccessSessionClosed = types.BoolValue(true)
+ } else {
+ data.AccessSessionClosed = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "access-session.monitor"); value.Exists() {
+ data.AccessSessionMonitor = types.BoolValue(value.Bool())
+ } else {
+ data.AccessSessionMonitor = types.BoolNull()
+ }
+ if value := res.Get(prefix + "access-session.port-control"); value.Exists() {
+ data.AccessSessionPortControl = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "access-session.control-direction"); value.Exists() {
+ data.AccessSessionControlDirection = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "access-session.host-mode"); value.Exists() {
+ data.AccessSessionHostMode = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "access-session.interface-template.sticky"); value.Exists() {
+ data.AccessSessionInterfaceTemplateSticky = types.BoolValue(true)
+ } else {
+ data.AccessSessionInterfaceTemplateSticky = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "access-session.interface-template.sticky.timer"); value.Exists() {
+ data.AccessSessionInterfaceTemplateStickyTimer = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "authentication.periodic"); value.Exists() {
+ data.AuthenticationPeriodic = types.BoolValue(true)
+ } else {
+ data.AuthenticationPeriodic = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "authentication.timer.reauthenticate.server"); value.Exists() {
+ data.AuthenticationTimerReauthenticateServer = types.BoolValue(true)
+ } else {
+ data.AuthenticationTimerReauthenticateServer = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "authentication.timer.reauthenticate.range"); value.Exists() {
+ data.AuthenticationTimerReauthenticateRange = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "spanning-tree.bpduguard.enable"); value.Exists() {
+ data.SpanningTreeBpduguardEnable = types.BoolValue(true)
+ } else {
+ data.SpanningTreeBpduguardEnable = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "spanning-tree.service-policy"); value.Exists() {
+ data.SpanningTreeServicePolicy = types.BoolValue(true)
+ } else {
+ data.SpanningTreeServicePolicy = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "spanning-tree.portfast"); value.Exists() {
+ data.SpanningTreePortfast = types.BoolValue(true)
+ } else {
+ data.SpanningTreePortfast = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "spanning-tree.portfast.disable"); value.Exists() {
+ data.SpanningTreePortfastDisable = types.BoolValue(true)
+ } else {
+ data.SpanningTreePortfastDisable = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "spanning-tree.portfast.edge"); value.Exists() {
+ data.SpanningTreePortfastEdge = types.BoolValue(true)
+ } else {
+ data.SpanningTreePortfastEdge = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "spanning-tree.portfast.network"); value.Exists() {
+ data.SpanningTreePortfastNetwork = types.BoolValue(true)
+ } else {
+ data.SpanningTreePortfastNetwork = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "storm-control.broadcast.level.pps.threshold"); value.Exists() {
+ data.StormControlBroadcastLevelPpsThreshold = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "storm-control.broadcast.level.bps.threshold"); value.Exists() {
+ data.StormControlBroadcastLevelBpsThreshold = types.Float64Value(value.Float())
+ }
+ if value := res.Get(prefix + "storm-control.broadcast.level.threshold"); value.Exists() {
+ data.StormControlBroadcastLevelThreshold = types.Float64Value(value.Float())
+ }
+ if value := res.Get(prefix + "storm-control.multicast.level.pps.threshold"); value.Exists() {
+ data.StormControlMulticastLevelPpsThreshold = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "storm-control.multicast.level.bps.threshold"); value.Exists() {
+ data.StormControlMulticastLevelBpsThreshold = types.Float64Value(value.Float())
+ }
+ if value := res.Get(prefix + "storm-control.multicast.level.threshold"); value.Exists() {
+ data.StormControlMulticastLevelThreshold = types.Float64Value(value.Float())
+ }
+ if value := res.Get(prefix + "storm-control.action.shutdown"); value.Exists() {
+ data.StormControlActionShutdown = types.BoolValue(true)
+ } else {
+ data.StormControlActionShutdown = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "storm-control.action.trap"); value.Exists() {
+ data.StormControlActionTrap = types.BoolValue(true)
+ } else {
+ data.StormControlActionTrap = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "load-interval"); value.Exists() {
+ data.LoadInterval = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "ip.dhcp.snooping.limit.rate"); value.Exists() {
+ data.IpDhcpSnoopingLimitRate = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "ip.dhcp.snooping.trust"); value.Exists() {
+ data.IpDhcpSnoopingTrust = types.BoolValue(true)
+ } else {
+ data.IpDhcpSnoopingTrust = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "ip.access-group"); value.Exists() {
+ data.IpAccessGroup = make([]TemplateIpAccessGroup, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := TemplateIpAccessGroup{}
+ if cValue := v.Get("direction"); cValue.Exists() {
+ item.Direction = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("access-list"); cValue.Exists() {
+ item.AccessList = types.StringValue(cValue.String())
+ }
+ data.IpAccessGroup = append(data.IpAccessGroup, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + "subscriber.aging.inactivity-timer.value"); value.Exists() {
+ data.SubscriberAgingInactivityTimerValue = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "subscriber.aging.inactivity-timer.probe"); value.Exists() {
+ data.SubscriberAgingInactivityTimerProbe = types.BoolValue(true)
} else {
- data.SubscriberAgingProbe = types.BoolNull()
+ data.SubscriberAgingInactivityTimerProbe = types.BoolValue(false)
}
- if value := res.Get(prefix + "device-tracking"); !data.DeviceTracking.IsNull() {
- if value.Exists() {
- data.DeviceTracking = types.BoolValue(true)
- } else {
- data.DeviceTracking = types.BoolValue(false)
- }
+ if value := res.Get(prefix + "subscriber.aging.probe"); value.Exists() {
+ data.SubscriberAgingProbe = types.BoolValue(true)
} else {
- data.DeviceTracking = types.BoolNull()
+ data.SubscriberAgingProbe = types.BoolValue(false)
}
- for i := range data.DeviceTrackingAttachPolicy {
- keys := [...]string{"policy-name"}
- keyValues := [...]string{data.DeviceTrackingAttachPolicy[i].PolicyName.ValueString()}
-
- var r gjson.Result
- res.Get(prefix + "device-tracking.attach-policy.policy-name").ForEach(
- func(_, v gjson.Result) bool {
- found := false
- for ik := range keys {
- if v.Get(keys[ik]).String() == keyValues[ik] {
- found = true
- continue
- }
- found = false
- break
- }
- if found {
- r = v
- return false
- }
- return true
- },
- )
- if value := r.Get("policy-name"); value.Exists() && !data.DeviceTrackingAttachPolicy[i].PolicyName.IsNull() {
- data.DeviceTrackingAttachPolicy[i].PolicyName = types.StringValue(value.String())
- } else {
- data.DeviceTrackingAttachPolicy[i].PolicyName = types.StringNull()
- }
- if value := r.Get("vlan.vlan-range"); value.Exists() && !data.DeviceTrackingAttachPolicy[i].VlanRange.IsNull() {
- data.DeviceTrackingAttachPolicy[i].VlanRange = types.StringValue(value.String())
- } else {
- data.DeviceTrackingAttachPolicy[i].VlanRange = types.StringNull()
- }
+ if value := res.Get(prefix + "device-tracking"); value.Exists() {
+ data.DeviceTracking = types.BoolValue(true)
+ } else {
+ data.DeviceTracking = types.BoolValue(false)
}
- if value := res.Get(prefix + "device-tracking.vlan.vlan-range"); value.Exists() && !data.DeviceTrackingVlanRange.IsNull() {
+ if value := res.Get(prefix + "device-tracking.attach-policy.policy-name"); value.Exists() {
+ data.DeviceTrackingAttachPolicy = make([]TemplateDeviceTrackingAttachPolicy, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := TemplateDeviceTrackingAttachPolicy{}
+ if cValue := v.Get("policy-name"); cValue.Exists() {
+ item.PolicyName = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("vlan.vlan-range"); cValue.Exists() {
+ item.VlanRange = types.StringValue(cValue.String())
+ }
+ data.DeviceTrackingAttachPolicy = append(data.DeviceTrackingAttachPolicy, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + "device-tracking.vlan.vlan-range"); value.Exists() {
data.DeviceTrackingVlanRange = types.StringValue(value.String())
- } else {
- data.DeviceTrackingVlanRange = types.StringNull()
}
- if value := res.Get(prefix + "cts.manual"); !data.CtsManual.IsNull() {
- if value.Exists() {
- data.CtsManual = types.BoolValue(true)
- } else {
- data.CtsManual = types.BoolValue(false)
- }
+ if value := res.Get(prefix + "cts.manual"); value.Exists() {
+ data.CtsManual = types.BoolValue(true)
} else {
- data.CtsManual = types.BoolNull()
+ data.CtsManual = types.BoolValue(false)
}
- if value := res.Get(prefix + "cts.manual.policy.static.sgt"); value.Exists() && !data.CtsManualPolicyStaticSgt.IsNull() {
+ if value := res.Get(prefix + "cts.manual.policy.static.sgt"); value.Exists() {
data.CtsManualPolicyStaticSgt = types.Int64Value(value.Int())
- } else {
- data.CtsManualPolicyStaticSgt = types.Int64Null()
}
- if value := res.Get(prefix + "cts.manual.policy.static.trusted"); !data.CtsManualPolicyStaticTrusted.IsNull() {
- if value.Exists() {
- data.CtsManualPolicyStaticTrusted = types.BoolValue(true)
- } else {
- data.CtsManualPolicyStaticTrusted = types.BoolValue(false)
- }
+ if value := res.Get(prefix + "cts.manual.policy.static.trusted"); value.Exists() {
+ data.CtsManualPolicyStaticTrusted = types.BoolValue(true)
} else {
- data.CtsManualPolicyStaticTrusted = types.BoolNull()
+ data.CtsManualPolicyStaticTrusted = types.BoolValue(false)
}
- if value := res.Get(prefix + "cts.manual.propagate.sgt"); !data.CtsManualPropagateSgt.IsNull() {
- if value.Exists() {
- data.CtsManualPropagateSgt = types.BoolValue(value.Bool())
- }
+ if value := res.Get(prefix + "cts.manual.propagate.sgt"); value.Exists() {
+ data.CtsManualPropagateSgt = types.BoolValue(value.Bool())
} else {
data.CtsManualPropagateSgt = types.BoolNull()
}
- if value := res.Get(prefix + "cts.role-based.enforcement"); !data.CtsRoleBasedEnforcement.IsNull() {
- if value.Exists() {
- data.CtsRoleBasedEnforcement = types.BoolValue(value.Bool())
- }
+ if value := res.Get(prefix + "cts.role-based.enforcement"); value.Exists() {
+ data.CtsRoleBasedEnforcement = types.BoolValue(value.Bool())
} else {
data.CtsRoleBasedEnforcement = types.BoolNull()
}
}
-// End of section. //template:end updateFromBody
+// End of section. //template:end fromBodyData
-// Section below is generated&owned by "gen/generator.go". //template:begin fromBody
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyXML
-func (data *Template) fromBody(ctx context.Context, res gjson.Result) {
- prefix := helpers.LastElement(data.getPath()) + "."
- if res.Get(helpers.LastElement(data.getPath())).IsArray() {
- prefix += "0."
- }
- if value := res.Get(prefix + "dot1x.pae"); value.Exists() {
+func (data *Template) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/dot1x/pae"); value.Exists() {
data.Dot1xPae = types.StringValue(value.String())
}
- if value := res.Get(prefix + "dot1x.max-reauth-req"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/dot1x/max-reauth-req"); value.Exists() {
data.Dot1xMaxReauthReq = types.Int64Value(value.Int())
}
- if value := res.Get(prefix + "dot1x.max-req"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/dot1x/max-req"); value.Exists() {
data.Dot1xMaxReq = types.Int64Value(value.Int())
}
- if value := res.Get(prefix + "dot1x.timeout.tx-period"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/dot1x/timeout/tx-period"); value.Exists() {
data.Dot1xTimeoutTxPeriod = types.Int64Value(value.Int())
}
- if value := res.Get(prefix + "service-policy.type.control.subscriber"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/service-policy/type/control/subscriber"); value.Exists() {
data.ServicePolicyTypeControlSubscriber = types.StringValue(value.String())
}
- if value := res.Get(prefix + "service-policy.input.policy-map-name"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/service-policy/input/policy-map-name"); value.Exists() {
data.ServicePolicyInput = types.StringValue(value.String())
}
- if value := res.Get(prefix + "service-policy.output.policy-map-name"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/service-policy/output/policy-map-name"); value.Exists() {
data.ServicePolicyOutput = types.StringValue(value.String())
}
- if value := res.Get(prefix + "source.template"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/"); value.Exists() {
data.SourceTemplate = types.StringValue(value.String())
}
- if value := res.Get(prefix + "switchport.mode.trunk"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/switchport/mode/trunk"); value.Exists() {
data.SwitchportModeTrunk = types.BoolValue(true)
} else {
data.SwitchportModeTrunk = types.BoolValue(false)
}
- if value := res.Get(prefix + "switchport.mode.access"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/switchport/mode/access"); value.Exists() {
data.SwitchportModeAccess = types.BoolValue(true)
} else {
data.SwitchportModeAccess = types.BoolValue(false)
}
- if value := res.Get(prefix + "switchport.nonegotiate"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/switchport/nonegotiate"); value.Exists() {
data.SwitchportNonegotiate = types.BoolValue(true)
} else {
data.SwitchportNonegotiate = types.BoolValue(false)
}
- if value := res.Get(prefix + "switchport.block.unicast"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/switchport/block/unicast"); value.Exists() {
data.SwitchportBlockUnicast = types.BoolValue(true)
} else {
data.SwitchportBlockUnicast = types.BoolValue(false)
}
- if value := res.Get(prefix + "switchport.port-security"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/switchport/port-security"); value.Exists() {
data.SwitchportPortSecurity = types.BoolValue(true)
} else {
data.SwitchportPortSecurity = types.BoolValue(false)
}
- if value := res.Get(prefix + "switchport.port-security.aging.static"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/switchport/port-security/aging/static"); value.Exists() {
data.SwitchportPortSecurityAgingStatic = types.BoolValue(true)
} else {
data.SwitchportPortSecurityAgingStatic = types.BoolValue(false)
}
- if value := res.Get(prefix + "switchport.port-security.aging.time"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/switchport/port-security/aging/time"); value.Exists() {
data.SwitchportPortSecurityAgingTime = types.Int64Value(value.Int())
}
- if value := res.Get(prefix + "switchport.port-security.aging.type"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/switchport/port-security/aging/type"); value.Exists() {
data.SwitchportPortSecurityAgingType = types.BoolValue(true)
} else {
data.SwitchportPortSecurityAgingType = types.BoolValue(false)
}
- if value := res.Get(prefix + "switchport.port-security.aging.type.inactivity"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/switchport/port-security/aging/type/inactivity"); value.Exists() {
data.SwitchportPortSecurityAgingTypeInactivity = types.BoolValue(true)
} else {
data.SwitchportPortSecurityAgingTypeInactivity = types.BoolValue(false)
}
- if value := res.Get(prefix + "switchport.port-security.maximum.range"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/switchport/port-security/maximum/range"); value.Exists() {
data.SwitchportPortSecurityMaximumRange = make([]TemplateSwitchportPortSecurityMaximumRange, 0)
- value.ForEach(func(k, v gjson.Result) bool {
+ value.ForEach(func(_ int, v xmldot.Result) bool {
item := TemplateSwitchportPortSecurityMaximumRange{}
- if cValue := v.Get("range"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "range"); cValue.Exists() {
item.Range = types.Int64Value(cValue.Int())
}
- if cValue := v.Get("vlan"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "vlan"); cValue.Exists() {
item.Vlan = types.BoolValue(true)
} else {
item.Vlan = types.BoolValue(false)
}
- if cValue := v.Get("vlan.access"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "vlan/access"); cValue.Exists() {
item.VlanAccess = types.BoolValue(true)
} else {
item.VlanAccess = types.BoolValue(false)
@@ -1259,336 +2953,332 @@ func (data *Template) fromBody(ctx context.Context, res gjson.Result) {
return true
})
}
- if value := res.Get(prefix + "switchport.port-security.violation.protect"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/switchport/port-security/violation/protect"); value.Exists() {
data.SwitchportPortSecurityViolationProtect = types.BoolValue(true)
} else {
data.SwitchportPortSecurityViolationProtect = types.BoolValue(false)
}
- if value := res.Get(prefix + "switchport.port-security.violation.restrict"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/switchport/port-security/violation/restrict"); value.Exists() {
data.SwitchportPortSecurityViolationRestrict = types.BoolValue(true)
} else {
data.SwitchportPortSecurityViolationRestrict = types.BoolValue(false)
}
- if value := res.Get(prefix + "switchport.port-security.violation.shutdown"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/switchport/port-security/violation/shutdown"); value.Exists() {
data.SwitchportPortSecurityViolationShutdown = types.BoolValue(true)
} else {
data.SwitchportPortSecurityViolationShutdown = types.BoolValue(false)
}
- if value := res.Get(prefix + "switchport.access.vlan"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/switchport/access/vlan"); value.Exists() {
data.SwitchportAccessVlan = types.Int64Value(value.Int())
}
- if value := res.Get(prefix + "switchport.voice.vlan"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/switchport/voice/vlan"); value.Exists() {
data.SwitchportVoiceVlan = types.Int64Value(value.Int())
}
- if value := res.Get(prefix + "switchport.private-vlan.host-association.primary-range"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/switchport/private-vlan/host-association/primary-range"); value.Exists() {
data.SwitchportPrivateVlanHostAssociationPrimaryRange = types.Int64Value(value.Int())
}
- if value := res.Get(prefix + "switchport.private-vlan.host-association.secondary-range"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/switchport/private-vlan/host-association/secondary-range"); value.Exists() {
data.SwitchportPrivateVlanHostAssociationSecondaryRange = types.Int64Value(value.Int())
}
- if value := res.Get(prefix + "switchport.trunk.allowed.vlan.vlans"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/switchport/trunk/allowed/vlan/vlans"); value.Exists() {
data.SwitchportTrunkAllowedVlans = types.StringValue(value.String())
}
- if value := res.Get(prefix + "switchport.trunk.allowed.vlan.none"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/switchport/trunk/allowed/vlan/none"); value.Exists() {
data.SwitchportTrunkAllowedVlansNone = types.BoolValue(true)
} else {
data.SwitchportTrunkAllowedVlansNone = types.BoolValue(false)
}
- if value := res.Get(prefix + "switchport.trunk.allowed.vlan.all"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/switchport/trunk/allowed/vlan/all"); value.Exists() {
data.SwitchportTrunkAllowedVlansAll = types.BoolValue(true)
} else {
data.SwitchportTrunkAllowedVlansAll = types.BoolValue(false)
}
- if value := res.Get(prefix + "switchport.trunk.native.vlan.tag"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/switchport/trunk/native/vlan/tag"); value.Exists() {
data.SwitchportTrunkNativeVlanTag = types.BoolValue(value.Bool())
} else {
data.SwitchportTrunkNativeVlanTag = types.BoolNull()
}
- if value := res.Get(prefix + "switchport.trunk.native.vlan.vlan-id"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/switchport/trunk/native/vlan/vlan-id"); value.Exists() {
data.SwitchportTrunkNativeVlanVlanId = types.Int64Value(value.Int())
}
- if value := res.Get(prefix + "mab"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/mab"); value.Exists() {
data.Mab = types.BoolValue(true)
} else {
data.Mab = types.BoolValue(false)
}
- if value := res.Get(prefix + "mab.eap"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/mab/eap"); value.Exists() {
data.MabEap = types.BoolValue(true)
} else {
data.MabEap = types.BoolValue(false)
}
- if value := res.Get(prefix + "access-session.closed"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/access-session/closed"); value.Exists() {
data.AccessSessionClosed = types.BoolValue(true)
} else {
data.AccessSessionClosed = types.BoolValue(false)
}
- if value := res.Get(prefix + "access-session.monitor"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/access-session/monitor"); value.Exists() {
data.AccessSessionMonitor = types.BoolValue(value.Bool())
} else {
data.AccessSessionMonitor = types.BoolNull()
}
- if value := res.Get(prefix + "access-session.port-control"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/access-session/port-control"); value.Exists() {
data.AccessSessionPortControl = types.StringValue(value.String())
}
- if value := res.Get(prefix + "access-session.control-direction"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/access-session/control-direction"); value.Exists() {
data.AccessSessionControlDirection = types.StringValue(value.String())
}
- if value := res.Get(prefix + "access-session.host-mode"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/access-session/host-mode"); value.Exists() {
data.AccessSessionHostMode = types.StringValue(value.String())
}
- if value := res.Get(prefix + "access-session.interface-template.sticky"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/access-session/interface-template/sticky"); value.Exists() {
data.AccessSessionInterfaceTemplateSticky = types.BoolValue(true)
} else {
data.AccessSessionInterfaceTemplateSticky = types.BoolValue(false)
}
- if value := res.Get(prefix + "access-session.interface-template.sticky.timer"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/access-session/interface-template/sticky/timer"); value.Exists() {
data.AccessSessionInterfaceTemplateStickyTimer = types.Int64Value(value.Int())
}
- if value := res.Get(prefix + "authentication.periodic"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/authentication/periodic"); value.Exists() {
data.AuthenticationPeriodic = types.BoolValue(true)
} else {
data.AuthenticationPeriodic = types.BoolValue(false)
}
- if value := res.Get(prefix + "authentication.timer.reauthenticate.server"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/authentication/timer/reauthenticate/server"); value.Exists() {
data.AuthenticationTimerReauthenticateServer = types.BoolValue(true)
} else {
data.AuthenticationTimerReauthenticateServer = types.BoolValue(false)
}
- if value := res.Get(prefix + "authentication.timer.reauthenticate.range"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/authentication/timer/reauthenticate/range"); value.Exists() {
data.AuthenticationTimerReauthenticateRange = types.Int64Value(value.Int())
}
- if value := res.Get(prefix + "spanning-tree.bpduguard.enable"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/spanning-tree/bpduguard/enable"); value.Exists() {
data.SpanningTreeBpduguardEnable = types.BoolValue(true)
} else {
data.SpanningTreeBpduguardEnable = types.BoolValue(false)
}
- if value := res.Get(prefix + "spanning-tree.service-policy"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/spanning-tree/service-policy"); value.Exists() {
data.SpanningTreeServicePolicy = types.BoolValue(true)
} else {
data.SpanningTreeServicePolicy = types.BoolValue(false)
}
- if value := res.Get(prefix + "spanning-tree.portfast"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/spanning-tree/portfast"); value.Exists() {
data.SpanningTreePortfast = types.BoolValue(true)
} else {
data.SpanningTreePortfast = types.BoolValue(false)
}
- if value := res.Get(prefix + "spanning-tree.portfast.disable"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/spanning-tree/portfast/disable"); value.Exists() {
data.SpanningTreePortfastDisable = types.BoolValue(true)
} else {
data.SpanningTreePortfastDisable = types.BoolValue(false)
}
- if value := res.Get(prefix + "spanning-tree.portfast.edge"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/spanning-tree/portfast/edge"); value.Exists() {
data.SpanningTreePortfastEdge = types.BoolValue(true)
} else {
data.SpanningTreePortfastEdge = types.BoolValue(false)
}
- if value := res.Get(prefix + "spanning-tree.portfast.network"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/spanning-tree/portfast/network"); value.Exists() {
data.SpanningTreePortfastNetwork = types.BoolValue(true)
} else {
data.SpanningTreePortfastNetwork = types.BoolValue(false)
}
- if value := res.Get(prefix + "storm-control.broadcast.level.pps.threshold"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/storm-control/broadcast/level/pps/threshold"); value.Exists() {
data.StormControlBroadcastLevelPpsThreshold = types.StringValue(value.String())
}
- if value := res.Get(prefix + "storm-control.broadcast.level.bps.threshold"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/storm-control/broadcast/level/bps/threshold"); value.Exists() {
data.StormControlBroadcastLevelBpsThreshold = types.Float64Value(value.Float())
}
- if value := res.Get(prefix + "storm-control.broadcast.level.threshold"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/storm-control/broadcast/level/threshold"); value.Exists() {
data.StormControlBroadcastLevelThreshold = types.Float64Value(value.Float())
}
- if value := res.Get(prefix + "storm-control.multicast.level.pps.threshold"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/storm-control/multicast/level/pps/threshold"); value.Exists() {
data.StormControlMulticastLevelPpsThreshold = types.StringValue(value.String())
}
- if value := res.Get(prefix + "storm-control.multicast.level.bps.threshold"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/storm-control/multicast/level/bps/threshold"); value.Exists() {
data.StormControlMulticastLevelBpsThreshold = types.Float64Value(value.Float())
}
- if value := res.Get(prefix + "storm-control.multicast.level.threshold"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/storm-control/multicast/level/threshold"); value.Exists() {
data.StormControlMulticastLevelThreshold = types.Float64Value(value.Float())
}
- if value := res.Get(prefix + "storm-control.action.shutdown"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/storm-control/action/shutdown"); value.Exists() {
data.StormControlActionShutdown = types.BoolValue(true)
} else {
data.StormControlActionShutdown = types.BoolValue(false)
}
- if value := res.Get(prefix + "storm-control.action.trap"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/storm-control/action/trap"); value.Exists() {
data.StormControlActionTrap = types.BoolValue(true)
} else {
data.StormControlActionTrap = types.BoolValue(false)
}
- if value := res.Get(prefix + "load-interval"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/load-interval"); value.Exists() {
data.LoadInterval = types.Int64Value(value.Int())
}
- if value := res.Get(prefix + "ip.dhcp.snooping.limit.rate"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/dhcp/snooping/limit/rate"); value.Exists() {
data.IpDhcpSnoopingLimitRate = types.Int64Value(value.Int())
}
- if value := res.Get(prefix + "ip.dhcp.snooping.trust"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/dhcp/snooping/trust"); value.Exists() {
data.IpDhcpSnoopingTrust = types.BoolValue(true)
} else {
data.IpDhcpSnoopingTrust = types.BoolValue(false)
}
- if value := res.Get(prefix + "ip.access-group"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/access-group"); value.Exists() {
data.IpAccessGroup = make([]TemplateIpAccessGroup, 0)
- value.ForEach(func(k, v gjson.Result) bool {
+ value.ForEach(func(_ int, v xmldot.Result) bool {
item := TemplateIpAccessGroup{}
- if cValue := v.Get("direction"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "direction"); cValue.Exists() {
item.Direction = types.StringValue(cValue.String())
}
- if cValue := v.Get("access-list"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "access-list"); cValue.Exists() {
item.AccessList = types.StringValue(cValue.String())
}
data.IpAccessGroup = append(data.IpAccessGroup, item)
return true
})
}
- if value := res.Get(prefix + "subscriber.aging.inactivity-timer.value"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/subscriber/aging/inactivity-timer/value"); value.Exists() {
data.SubscriberAgingInactivityTimerValue = types.Int64Value(value.Int())
}
- if value := res.Get(prefix + "subscriber.aging.inactivity-timer.probe"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/subscriber/aging/inactivity-timer/probe"); value.Exists() {
data.SubscriberAgingInactivityTimerProbe = types.BoolValue(true)
} else {
data.SubscriberAgingInactivityTimerProbe = types.BoolValue(false)
}
- if value := res.Get(prefix + "subscriber.aging.probe"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/subscriber/aging/probe"); value.Exists() {
data.SubscriberAgingProbe = types.BoolValue(true)
} else {
data.SubscriberAgingProbe = types.BoolValue(false)
}
- if value := res.Get(prefix + "device-tracking"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/device-tracking"); value.Exists() {
data.DeviceTracking = types.BoolValue(true)
} else {
data.DeviceTracking = types.BoolValue(false)
}
- if value := res.Get(prefix + "device-tracking.attach-policy.policy-name"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/device-tracking/attach-policy/policy-name"); value.Exists() {
data.DeviceTrackingAttachPolicy = make([]TemplateDeviceTrackingAttachPolicy, 0)
- value.ForEach(func(k, v gjson.Result) bool {
+ value.ForEach(func(_ int, v xmldot.Result) bool {
item := TemplateDeviceTrackingAttachPolicy{}
- if cValue := v.Get("policy-name"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "policy-name"); cValue.Exists() {
item.PolicyName = types.StringValue(cValue.String())
}
- if cValue := v.Get("vlan.vlan-range"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "vlan/vlan-range"); cValue.Exists() {
item.VlanRange = types.StringValue(cValue.String())
}
data.DeviceTrackingAttachPolicy = append(data.DeviceTrackingAttachPolicy, item)
return true
})
}
- if value := res.Get(prefix + "device-tracking.vlan.vlan-range"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/device-tracking/vlan/vlan-range"); value.Exists() {
data.DeviceTrackingVlanRange = types.StringValue(value.String())
}
- if value := res.Get(prefix + "cts.manual"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/cts/manual"); value.Exists() {
data.CtsManual = types.BoolValue(true)
} else {
data.CtsManual = types.BoolValue(false)
}
- if value := res.Get(prefix + "cts.manual.policy.static.sgt"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/cts/manual/policy/static/sgt"); value.Exists() {
data.CtsManualPolicyStaticSgt = types.Int64Value(value.Int())
}
- if value := res.Get(prefix + "cts.manual.policy.static.trusted"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/cts/manual/policy/static/trusted"); value.Exists() {
data.CtsManualPolicyStaticTrusted = types.BoolValue(true)
} else {
data.CtsManualPolicyStaticTrusted = types.BoolValue(false)
}
- if value := res.Get(prefix + "cts.manual.propagate.sgt"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/cts/manual/propagate/sgt"); value.Exists() {
data.CtsManualPropagateSgt = types.BoolValue(value.Bool())
} else {
data.CtsManualPropagateSgt = types.BoolNull()
}
- if value := res.Get(prefix + "cts.role-based.enforcement"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/cts/role-based/enforcement"); value.Exists() {
data.CtsRoleBasedEnforcement = types.BoolValue(value.Bool())
} else {
data.CtsRoleBasedEnforcement = types.BoolNull()
}
}
-// End of section. //template:end fromBody
+// End of section. //template:end fromBodyXML
-// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyData
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyDataXML
-func (data *TemplateData) fromBody(ctx context.Context, res gjson.Result) {
- prefix := helpers.LastElement(data.getPath()) + "."
- if res.Get(helpers.LastElement(data.getPath())).IsArray() {
- prefix += "0."
- }
- if value := res.Get(prefix + "dot1x.pae"); value.Exists() {
+func (data *TemplateData) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/dot1x/pae"); value.Exists() {
data.Dot1xPae = types.StringValue(value.String())
}
- if value := res.Get(prefix + "dot1x.max-reauth-req"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/dot1x/max-reauth-req"); value.Exists() {
data.Dot1xMaxReauthReq = types.Int64Value(value.Int())
}
- if value := res.Get(prefix + "dot1x.max-req"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/dot1x/max-req"); value.Exists() {
data.Dot1xMaxReq = types.Int64Value(value.Int())
}
- if value := res.Get(prefix + "dot1x.timeout.tx-period"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/dot1x/timeout/tx-period"); value.Exists() {
data.Dot1xTimeoutTxPeriod = types.Int64Value(value.Int())
}
- if value := res.Get(prefix + "service-policy.type.control.subscriber"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/service-policy/type/control/subscriber"); value.Exists() {
data.ServicePolicyTypeControlSubscriber = types.StringValue(value.String())
}
- if value := res.Get(prefix + "service-policy.input.policy-map-name"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/service-policy/input/policy-map-name"); value.Exists() {
data.ServicePolicyInput = types.StringValue(value.String())
}
- if value := res.Get(prefix + "service-policy.output.policy-map-name"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/service-policy/output/policy-map-name"); value.Exists() {
data.ServicePolicyOutput = types.StringValue(value.String())
}
- if value := res.Get(prefix + "source.template"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/"); value.Exists() {
data.SourceTemplate = types.StringValue(value.String())
}
- if value := res.Get(prefix + "switchport.mode.trunk"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/switchport/mode/trunk"); value.Exists() {
data.SwitchportModeTrunk = types.BoolValue(true)
} else {
data.SwitchportModeTrunk = types.BoolValue(false)
}
- if value := res.Get(prefix + "switchport.mode.access"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/switchport/mode/access"); value.Exists() {
data.SwitchportModeAccess = types.BoolValue(true)
} else {
data.SwitchportModeAccess = types.BoolValue(false)
}
- if value := res.Get(prefix + "switchport.nonegotiate"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/switchport/nonegotiate"); value.Exists() {
data.SwitchportNonegotiate = types.BoolValue(true)
} else {
data.SwitchportNonegotiate = types.BoolValue(false)
}
- if value := res.Get(prefix + "switchport.block.unicast"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/switchport/block/unicast"); value.Exists() {
data.SwitchportBlockUnicast = types.BoolValue(true)
} else {
data.SwitchportBlockUnicast = types.BoolValue(false)
}
- if value := res.Get(prefix + "switchport.port-security"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/switchport/port-security"); value.Exists() {
data.SwitchportPortSecurity = types.BoolValue(true)
} else {
data.SwitchportPortSecurity = types.BoolValue(false)
}
- if value := res.Get(prefix + "switchport.port-security.aging.static"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/switchport/port-security/aging/static"); value.Exists() {
data.SwitchportPortSecurityAgingStatic = types.BoolValue(true)
} else {
data.SwitchportPortSecurityAgingStatic = types.BoolValue(false)
}
- if value := res.Get(prefix + "switchport.port-security.aging.time"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/switchport/port-security/aging/time"); value.Exists() {
data.SwitchportPortSecurityAgingTime = types.Int64Value(value.Int())
}
- if value := res.Get(prefix + "switchport.port-security.aging.type"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/switchport/port-security/aging/type"); value.Exists() {
data.SwitchportPortSecurityAgingType = types.BoolValue(true)
} else {
data.SwitchportPortSecurityAgingType = types.BoolValue(false)
}
- if value := res.Get(prefix + "switchport.port-security.aging.type.inactivity"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/switchport/port-security/aging/type/inactivity"); value.Exists() {
data.SwitchportPortSecurityAgingTypeInactivity = types.BoolValue(true)
} else {
data.SwitchportPortSecurityAgingTypeInactivity = types.BoolValue(false)
}
- if value := res.Get(prefix + "switchport.port-security.maximum.range"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/switchport/port-security/maximum/range"); value.Exists() {
data.SwitchportPortSecurityMaximumRange = make([]TemplateSwitchportPortSecurityMaximumRange, 0)
- value.ForEach(func(k, v gjson.Result) bool {
+ value.ForEach(func(_ int, v xmldot.Result) bool {
item := TemplateSwitchportPortSecurityMaximumRange{}
- if cValue := v.Get("range"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "range"); cValue.Exists() {
item.Range = types.Int64Value(cValue.Int())
}
- if cValue := v.Get("vlan"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "vlan"); cValue.Exists() {
item.Vlan = types.BoolValue(true)
} else {
item.Vlan = types.BoolValue(false)
}
- if cValue := v.Get("vlan.access"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "vlan/access"); cValue.Exists() {
item.VlanAccess = types.BoolValue(true)
} else {
item.VlanAccess = types.BoolValue(false)
@@ -1597,248 +3287,248 @@ func (data *TemplateData) fromBody(ctx context.Context, res gjson.Result) {
return true
})
}
- if value := res.Get(prefix + "switchport.port-security.violation.protect"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/switchport/port-security/violation/protect"); value.Exists() {
data.SwitchportPortSecurityViolationProtect = types.BoolValue(true)
} else {
data.SwitchportPortSecurityViolationProtect = types.BoolValue(false)
}
- if value := res.Get(prefix + "switchport.port-security.violation.restrict"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/switchport/port-security/violation/restrict"); value.Exists() {
data.SwitchportPortSecurityViolationRestrict = types.BoolValue(true)
} else {
data.SwitchportPortSecurityViolationRestrict = types.BoolValue(false)
}
- if value := res.Get(prefix + "switchport.port-security.violation.shutdown"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/switchport/port-security/violation/shutdown"); value.Exists() {
data.SwitchportPortSecurityViolationShutdown = types.BoolValue(true)
} else {
data.SwitchportPortSecurityViolationShutdown = types.BoolValue(false)
}
- if value := res.Get(prefix + "switchport.access.vlan"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/switchport/access/vlan"); value.Exists() {
data.SwitchportAccessVlan = types.Int64Value(value.Int())
}
- if value := res.Get(prefix + "switchport.voice.vlan"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/switchport/voice/vlan"); value.Exists() {
data.SwitchportVoiceVlan = types.Int64Value(value.Int())
}
- if value := res.Get(prefix + "switchport.private-vlan.host-association.primary-range"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/switchport/private-vlan/host-association/primary-range"); value.Exists() {
data.SwitchportPrivateVlanHostAssociationPrimaryRange = types.Int64Value(value.Int())
}
- if value := res.Get(prefix + "switchport.private-vlan.host-association.secondary-range"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/switchport/private-vlan/host-association/secondary-range"); value.Exists() {
data.SwitchportPrivateVlanHostAssociationSecondaryRange = types.Int64Value(value.Int())
}
- if value := res.Get(prefix + "switchport.trunk.allowed.vlan.vlans"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/switchport/trunk/allowed/vlan/vlans"); value.Exists() {
data.SwitchportTrunkAllowedVlans = types.StringValue(value.String())
}
- if value := res.Get(prefix + "switchport.trunk.allowed.vlan.none"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/switchport/trunk/allowed/vlan/none"); value.Exists() {
data.SwitchportTrunkAllowedVlansNone = types.BoolValue(true)
} else {
data.SwitchportTrunkAllowedVlansNone = types.BoolValue(false)
}
- if value := res.Get(prefix + "switchport.trunk.allowed.vlan.all"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/switchport/trunk/allowed/vlan/all"); value.Exists() {
data.SwitchportTrunkAllowedVlansAll = types.BoolValue(true)
} else {
data.SwitchportTrunkAllowedVlansAll = types.BoolValue(false)
}
- if value := res.Get(prefix + "switchport.trunk.native.vlan.tag"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/switchport/trunk/native/vlan/tag"); value.Exists() {
data.SwitchportTrunkNativeVlanTag = types.BoolValue(value.Bool())
} else {
data.SwitchportTrunkNativeVlanTag = types.BoolNull()
}
- if value := res.Get(prefix + "switchport.trunk.native.vlan.vlan-id"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/switchport/trunk/native/vlan/vlan-id"); value.Exists() {
data.SwitchportTrunkNativeVlanVlanId = types.Int64Value(value.Int())
}
- if value := res.Get(prefix + "mab"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/mab"); value.Exists() {
data.Mab = types.BoolValue(true)
} else {
data.Mab = types.BoolValue(false)
}
- if value := res.Get(prefix + "mab.eap"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/mab/eap"); value.Exists() {
data.MabEap = types.BoolValue(true)
} else {
data.MabEap = types.BoolValue(false)
}
- if value := res.Get(prefix + "access-session.closed"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/access-session/closed"); value.Exists() {
data.AccessSessionClosed = types.BoolValue(true)
} else {
data.AccessSessionClosed = types.BoolValue(false)
}
- if value := res.Get(prefix + "access-session.monitor"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/access-session/monitor"); value.Exists() {
data.AccessSessionMonitor = types.BoolValue(value.Bool())
} else {
data.AccessSessionMonitor = types.BoolNull()
}
- if value := res.Get(prefix + "access-session.port-control"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/access-session/port-control"); value.Exists() {
data.AccessSessionPortControl = types.StringValue(value.String())
}
- if value := res.Get(prefix + "access-session.control-direction"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/access-session/control-direction"); value.Exists() {
data.AccessSessionControlDirection = types.StringValue(value.String())
}
- if value := res.Get(prefix + "access-session.host-mode"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/access-session/host-mode"); value.Exists() {
data.AccessSessionHostMode = types.StringValue(value.String())
}
- if value := res.Get(prefix + "access-session.interface-template.sticky"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/access-session/interface-template/sticky"); value.Exists() {
data.AccessSessionInterfaceTemplateSticky = types.BoolValue(true)
} else {
data.AccessSessionInterfaceTemplateSticky = types.BoolValue(false)
}
- if value := res.Get(prefix + "access-session.interface-template.sticky.timer"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/access-session/interface-template/sticky/timer"); value.Exists() {
data.AccessSessionInterfaceTemplateStickyTimer = types.Int64Value(value.Int())
}
- if value := res.Get(prefix + "authentication.periodic"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/authentication/periodic"); value.Exists() {
data.AuthenticationPeriodic = types.BoolValue(true)
} else {
data.AuthenticationPeriodic = types.BoolValue(false)
}
- if value := res.Get(prefix + "authentication.timer.reauthenticate.server"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/authentication/timer/reauthenticate/server"); value.Exists() {
data.AuthenticationTimerReauthenticateServer = types.BoolValue(true)
} else {
data.AuthenticationTimerReauthenticateServer = types.BoolValue(false)
}
- if value := res.Get(prefix + "authentication.timer.reauthenticate.range"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/authentication/timer/reauthenticate/range"); value.Exists() {
data.AuthenticationTimerReauthenticateRange = types.Int64Value(value.Int())
}
- if value := res.Get(prefix + "spanning-tree.bpduguard.enable"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/spanning-tree/bpduguard/enable"); value.Exists() {
data.SpanningTreeBpduguardEnable = types.BoolValue(true)
} else {
data.SpanningTreeBpduguardEnable = types.BoolValue(false)
}
- if value := res.Get(prefix + "spanning-tree.service-policy"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/spanning-tree/service-policy"); value.Exists() {
data.SpanningTreeServicePolicy = types.BoolValue(true)
} else {
data.SpanningTreeServicePolicy = types.BoolValue(false)
}
- if value := res.Get(prefix + "spanning-tree.portfast"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/spanning-tree/portfast"); value.Exists() {
data.SpanningTreePortfast = types.BoolValue(true)
} else {
data.SpanningTreePortfast = types.BoolValue(false)
}
- if value := res.Get(prefix + "spanning-tree.portfast.disable"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/spanning-tree/portfast/disable"); value.Exists() {
data.SpanningTreePortfastDisable = types.BoolValue(true)
} else {
data.SpanningTreePortfastDisable = types.BoolValue(false)
}
- if value := res.Get(prefix + "spanning-tree.portfast.edge"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/spanning-tree/portfast/edge"); value.Exists() {
data.SpanningTreePortfastEdge = types.BoolValue(true)
} else {
data.SpanningTreePortfastEdge = types.BoolValue(false)
}
- if value := res.Get(prefix + "spanning-tree.portfast.network"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/spanning-tree/portfast/network"); value.Exists() {
data.SpanningTreePortfastNetwork = types.BoolValue(true)
} else {
data.SpanningTreePortfastNetwork = types.BoolValue(false)
}
- if value := res.Get(prefix + "storm-control.broadcast.level.pps.threshold"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/storm-control/broadcast/level/pps/threshold"); value.Exists() {
data.StormControlBroadcastLevelPpsThreshold = types.StringValue(value.String())
}
- if value := res.Get(prefix + "storm-control.broadcast.level.bps.threshold"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/storm-control/broadcast/level/bps/threshold"); value.Exists() {
data.StormControlBroadcastLevelBpsThreshold = types.Float64Value(value.Float())
}
- if value := res.Get(prefix + "storm-control.broadcast.level.threshold"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/storm-control/broadcast/level/threshold"); value.Exists() {
data.StormControlBroadcastLevelThreshold = types.Float64Value(value.Float())
}
- if value := res.Get(prefix + "storm-control.multicast.level.pps.threshold"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/storm-control/multicast/level/pps/threshold"); value.Exists() {
data.StormControlMulticastLevelPpsThreshold = types.StringValue(value.String())
}
- if value := res.Get(prefix + "storm-control.multicast.level.bps.threshold"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/storm-control/multicast/level/bps/threshold"); value.Exists() {
data.StormControlMulticastLevelBpsThreshold = types.Float64Value(value.Float())
}
- if value := res.Get(prefix + "storm-control.multicast.level.threshold"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/storm-control/multicast/level/threshold"); value.Exists() {
data.StormControlMulticastLevelThreshold = types.Float64Value(value.Float())
}
- if value := res.Get(prefix + "storm-control.action.shutdown"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/storm-control/action/shutdown"); value.Exists() {
data.StormControlActionShutdown = types.BoolValue(true)
} else {
data.StormControlActionShutdown = types.BoolValue(false)
}
- if value := res.Get(prefix + "storm-control.action.trap"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/storm-control/action/trap"); value.Exists() {
data.StormControlActionTrap = types.BoolValue(true)
} else {
data.StormControlActionTrap = types.BoolValue(false)
}
- if value := res.Get(prefix + "load-interval"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/load-interval"); value.Exists() {
data.LoadInterval = types.Int64Value(value.Int())
}
- if value := res.Get(prefix + "ip.dhcp.snooping.limit.rate"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/dhcp/snooping/limit/rate"); value.Exists() {
data.IpDhcpSnoopingLimitRate = types.Int64Value(value.Int())
}
- if value := res.Get(prefix + "ip.dhcp.snooping.trust"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/dhcp/snooping/trust"); value.Exists() {
data.IpDhcpSnoopingTrust = types.BoolValue(true)
} else {
data.IpDhcpSnoopingTrust = types.BoolValue(false)
}
- if value := res.Get(prefix + "ip.access-group"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/ip/access-group"); value.Exists() {
data.IpAccessGroup = make([]TemplateIpAccessGroup, 0)
- value.ForEach(func(k, v gjson.Result) bool {
+ value.ForEach(func(_ int, v xmldot.Result) bool {
item := TemplateIpAccessGroup{}
- if cValue := v.Get("direction"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "direction"); cValue.Exists() {
item.Direction = types.StringValue(cValue.String())
}
- if cValue := v.Get("access-list"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "access-list"); cValue.Exists() {
item.AccessList = types.StringValue(cValue.String())
}
data.IpAccessGroup = append(data.IpAccessGroup, item)
return true
})
}
- if value := res.Get(prefix + "subscriber.aging.inactivity-timer.value"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/subscriber/aging/inactivity-timer/value"); value.Exists() {
data.SubscriberAgingInactivityTimerValue = types.Int64Value(value.Int())
}
- if value := res.Get(prefix + "subscriber.aging.inactivity-timer.probe"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/subscriber/aging/inactivity-timer/probe"); value.Exists() {
data.SubscriberAgingInactivityTimerProbe = types.BoolValue(true)
} else {
data.SubscriberAgingInactivityTimerProbe = types.BoolValue(false)
}
- if value := res.Get(prefix + "subscriber.aging.probe"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/subscriber/aging/probe"); value.Exists() {
data.SubscriberAgingProbe = types.BoolValue(true)
} else {
data.SubscriberAgingProbe = types.BoolValue(false)
}
- if value := res.Get(prefix + "device-tracking"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/device-tracking"); value.Exists() {
data.DeviceTracking = types.BoolValue(true)
} else {
data.DeviceTracking = types.BoolValue(false)
}
- if value := res.Get(prefix + "device-tracking.attach-policy.policy-name"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/device-tracking/attach-policy/policy-name"); value.Exists() {
data.DeviceTrackingAttachPolicy = make([]TemplateDeviceTrackingAttachPolicy, 0)
- value.ForEach(func(k, v gjson.Result) bool {
+ value.ForEach(func(_ int, v xmldot.Result) bool {
item := TemplateDeviceTrackingAttachPolicy{}
- if cValue := v.Get("policy-name"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "policy-name"); cValue.Exists() {
item.PolicyName = types.StringValue(cValue.String())
}
- if cValue := v.Get("vlan.vlan-range"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "vlan/vlan-range"); cValue.Exists() {
item.VlanRange = types.StringValue(cValue.String())
}
data.DeviceTrackingAttachPolicy = append(data.DeviceTrackingAttachPolicy, item)
return true
})
}
- if value := res.Get(prefix + "device-tracking.vlan.vlan-range"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/device-tracking/vlan/vlan-range"); value.Exists() {
data.DeviceTrackingVlanRange = types.StringValue(value.String())
}
- if value := res.Get(prefix + "cts.manual"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/cts/manual"); value.Exists() {
data.CtsManual = types.BoolValue(true)
} else {
data.CtsManual = types.BoolValue(false)
}
- if value := res.Get(prefix + "cts.manual.policy.static.sgt"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/cts/manual/policy/static/sgt"); value.Exists() {
data.CtsManualPolicyStaticSgt = types.Int64Value(value.Int())
}
- if value := res.Get(prefix + "cts.manual.policy.static.trusted"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/cts/manual/policy/static/trusted"); value.Exists() {
data.CtsManualPolicyStaticTrusted = types.BoolValue(true)
} else {
data.CtsManualPolicyStaticTrusted = types.BoolValue(false)
}
- if value := res.Get(prefix + "cts.manual.propagate.sgt"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/cts/manual/propagate/sgt"); value.Exists() {
data.CtsManualPropagateSgt = types.BoolValue(value.Bool())
} else {
data.CtsManualPropagateSgt = types.BoolNull()
}
- if value := res.Get(prefix + "cts.role-based.enforcement"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/cts/role-based/enforcement"); value.Exists() {
data.CtsRoleBasedEnforcement = types.BoolValue(value.Bool())
} else {
data.CtsRoleBasedEnforcement = types.BoolNull()
}
}
-// End of section. //template:end fromBodyData
+// End of section. //template:end fromBodyDataXML
// Section below is generated&owned by "gen/generator.go". //template:begin getDeletedItems
@@ -2047,14 +3737,318 @@ func (data *Template) getDeletedItems(ctx context.Context, state Template) []str
if !state.SwitchportPortSecurityViolationRestrict.IsNull() && data.SwitchportPortSecurityViolationRestrict.IsNull() {
deletedItems = append(deletedItems, fmt.Sprintf("%v/switchport/port-security/violation/restrict", state.getPath()))
}
- if !state.SwitchportPortSecurityViolationProtect.IsNull() && data.SwitchportPortSecurityViolationProtect.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/switchport/port-security/violation/protect", state.getPath()))
+ if !state.SwitchportPortSecurityViolationProtect.IsNull() && data.SwitchportPortSecurityViolationProtect.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/switchport/port-security/violation/protect", state.getPath()))
+ }
+ for i := range state.SwitchportPortSecurityMaximumRange {
+ stateKeyValues := [...]string{strconv.FormatInt(state.SwitchportPortSecurityMaximumRange[i].Range.ValueInt64(), 10)}
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.SwitchportPortSecurityMaximumRange[i].Range.ValueInt64()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.SwitchportPortSecurityMaximumRange {
+ found = true
+ if state.SwitchportPortSecurityMaximumRange[i].Range.ValueInt64() != data.SwitchportPortSecurityMaximumRange[j].Range.ValueInt64() {
+ found = false
+ }
+ if found {
+ if !state.SwitchportPortSecurityMaximumRange[i].VlanAccess.IsNull() && data.SwitchportPortSecurityMaximumRange[j].VlanAccess.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/switchport/port-security/maximum/range=%v/vlan/access", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ if !state.SwitchportPortSecurityMaximumRange[i].Vlan.IsNull() && data.SwitchportPortSecurityMaximumRange[j].Vlan.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/switchport/port-security/maximum/range=%v/vlan", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ break
+ }
+ }
+ if !found {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/switchport/port-security/maximum/range=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ }
+ if !state.SwitchportPortSecurityAgingTypeInactivity.IsNull() && data.SwitchportPortSecurityAgingTypeInactivity.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/switchport/port-security/aging/type", state.getPath()))
+ }
+ if !state.SwitchportPortSecurityAgingType.IsNull() && data.SwitchportPortSecurityAgingType.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/switchport/port-security/aging/type", state.getPath()))
+ }
+ if !state.SwitchportPortSecurityAgingTime.IsNull() && data.SwitchportPortSecurityAgingTime.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/switchport/port-security/aging/time", state.getPath()))
+ }
+ if !state.SwitchportPortSecurityAgingStatic.IsNull() && data.SwitchportPortSecurityAgingStatic.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/switchport/port-security/aging/static", state.getPath()))
+ }
+ if !state.SwitchportPortSecurity.IsNull() && data.SwitchportPortSecurity.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/switchport/port-security", state.getPath()))
+ }
+ if !state.SwitchportBlockUnicast.IsNull() && data.SwitchportBlockUnicast.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/switchport/block/unicast", state.getPath()))
+ }
+ if !state.SwitchportNonegotiate.IsNull() && data.SwitchportNonegotiate.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/switchport/nonegotiate", state.getPath()))
+ }
+ if !state.SwitchportModeAccess.IsNull() && data.SwitchportModeAccess.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/switchport/mode/access", state.getPath()))
+ }
+ if !state.SwitchportModeTrunk.IsNull() && data.SwitchportModeTrunk.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/switchport/mode/trunk", state.getPath()))
+ }
+ if !state.SourceTemplate.IsNull() && data.SourceTemplate.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/source/template", state.getPath()))
+ }
+ if !state.ServicePolicyOutput.IsNull() && data.ServicePolicyOutput.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/service-policy/output/policy-map-name", state.getPath()))
+ }
+ if !state.ServicePolicyInput.IsNull() && data.ServicePolicyInput.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/service-policy/input/policy-map-name", state.getPath()))
+ }
+ if !state.ServicePolicyTypeControlSubscriber.IsNull() && data.ServicePolicyTypeControlSubscriber.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/service-policy/type/control/subscriber", state.getPath()))
+ }
+ if !state.Dot1xTimeoutTxPeriod.IsNull() && data.Dot1xTimeoutTxPeriod.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/dot1x/timeout/tx-period", state.getPath()))
+ }
+ if !state.Dot1xMaxReq.IsNull() && data.Dot1xMaxReq.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/dot1x/max-req", state.getPath()))
+ }
+ if !state.Dot1xMaxReauthReq.IsNull() && data.Dot1xMaxReauthReq.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/dot1x/max-reauth-req", state.getPath()))
+ }
+ if !state.Dot1xPae.IsNull() && data.Dot1xPae.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/dot1x/pae", state.getPath()))
+ }
+
+ return deletedItems
+}
+
+// End of section. //template:end getDeletedItems
+
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletedItemsXML
+
+func (data *Template) addDeletedItemsXML(ctx context.Context, state Template, body string) string {
+ b := netconf.NewBody(body)
+ if !state.Dot1xPae.IsNull() && data.Dot1xPae.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/dot1x/pae")
+ }
+ if !state.Dot1xMaxReauthReq.IsNull() && data.Dot1xMaxReauthReq.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/dot1x/max-reauth-req")
+ }
+ if !state.Dot1xMaxReq.IsNull() && data.Dot1xMaxReq.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/dot1x/max-req")
+ }
+ if !state.Dot1xTimeoutTxPeriod.IsNull() && data.Dot1xTimeoutTxPeriod.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/dot1x/timeout/tx-period")
+ }
+ if !state.ServicePolicyTypeControlSubscriber.IsNull() && data.ServicePolicyTypeControlSubscriber.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/service-policy/type/control/subscriber")
+ }
+ if !state.ServicePolicyInput.IsNull() && data.ServicePolicyInput.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/service-policy/input/policy-map-name")
+ }
+ if !state.ServicePolicyOutput.IsNull() && data.ServicePolicyOutput.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/service-policy/output/policy-map-name")
+ }
+ if !state.SourceTemplate.IsNull() && data.SourceTemplate.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/")
+ }
+ if !state.SwitchportModeTrunk.IsNull() && data.SwitchportModeTrunk.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/switchport/mode/trunk")
+ }
+ if !state.SwitchportModeAccess.IsNull() && data.SwitchportModeAccess.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/switchport/mode/access")
+ }
+ if !state.SwitchportNonegotiate.IsNull() && data.SwitchportNonegotiate.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/switchport/nonegotiate")
+ }
+ if !state.SwitchportBlockUnicast.IsNull() && data.SwitchportBlockUnicast.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/switchport/block/unicast")
+ }
+ if !state.SwitchportPortSecurity.IsNull() && data.SwitchportPortSecurity.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/switchport/port-security")
+ }
+ if !state.SwitchportPortSecurityAgingStatic.IsNull() && data.SwitchportPortSecurityAgingStatic.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/switchport/port-security/aging/static")
+ }
+ if !state.SwitchportPortSecurityAgingTime.IsNull() && data.SwitchportPortSecurityAgingTime.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/switchport/port-security/aging/time")
+ }
+ if !state.SwitchportPortSecurityAgingType.IsNull() && data.SwitchportPortSecurityAgingType.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/switchport/port-security/aging/type")
+ }
+ if !state.SwitchportPortSecurityAgingTypeInactivity.IsNull() && data.SwitchportPortSecurityAgingTypeInactivity.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/switchport/port-security/aging/type/inactivity")
+ }
+ for i := range state.SwitchportPortSecurityMaximumRange {
+ stateKeys := [...]string{"range"}
+ stateKeyValues := [...]string{strconv.FormatInt(state.SwitchportPortSecurityMaximumRange[i].Range.ValueInt64(), 10)}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.SwitchportPortSecurityMaximumRange[i].Range.ValueInt64()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.SwitchportPortSecurityMaximumRange {
+ found = true
+ if state.SwitchportPortSecurityMaximumRange[i].Range.ValueInt64() != data.SwitchportPortSecurityMaximumRange[j].Range.ValueInt64() {
+ found = false
+ }
+ if found {
+ if !state.SwitchportPortSecurityMaximumRange[i].Vlan.IsNull() && data.SwitchportPortSecurityMaximumRange[j].Vlan.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/switchport/port-security/maximum/range%v/vlan", predicates))
+ }
+ if !state.SwitchportPortSecurityMaximumRange[i].VlanAccess.IsNull() && data.SwitchportPortSecurityMaximumRange[j].VlanAccess.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/switchport/port-security/maximum/range%v/vlan/access", predicates))
+ }
+ break
+ }
+ }
+ if !found {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/switchport/port-security/maximum/range%v", predicates))
+ }
+ }
+ if !state.SwitchportPortSecurityViolationProtect.IsNull() && data.SwitchportPortSecurityViolationProtect.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/switchport/port-security/violation/protect")
+ }
+ if !state.SwitchportPortSecurityViolationRestrict.IsNull() && data.SwitchportPortSecurityViolationRestrict.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/switchport/port-security/violation/restrict")
+ }
+ if !state.SwitchportPortSecurityViolationShutdown.IsNull() && data.SwitchportPortSecurityViolationShutdown.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/switchport/port-security/violation/shutdown")
+ }
+ if !state.SwitchportAccessVlan.IsNull() && data.SwitchportAccessVlan.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/switchport/access/vlan")
+ }
+ if !state.SwitchportVoiceVlan.IsNull() && data.SwitchportVoiceVlan.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/switchport/voice/vlan")
+ }
+ if !state.SwitchportPrivateVlanHostAssociationPrimaryRange.IsNull() && data.SwitchportPrivateVlanHostAssociationPrimaryRange.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/switchport/private-vlan/host-association/primary-range")
+ }
+ if !state.SwitchportPrivateVlanHostAssociationSecondaryRange.IsNull() && data.SwitchportPrivateVlanHostAssociationSecondaryRange.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/switchport/private-vlan/host-association/secondary-range")
+ }
+ if !state.SwitchportTrunkAllowedVlans.IsNull() && data.SwitchportTrunkAllowedVlans.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/switchport/trunk/allowed/vlan/vlans")
+ }
+ if !state.SwitchportTrunkAllowedVlansNone.IsNull() && data.SwitchportTrunkAllowedVlansNone.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/switchport/trunk/allowed/vlan/none")
+ }
+ if !state.SwitchportTrunkAllowedVlansAll.IsNull() && data.SwitchportTrunkAllowedVlansAll.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/switchport/trunk/allowed/vlan/all")
+ }
+ if !state.SwitchportTrunkNativeVlanTag.IsNull() && data.SwitchportTrunkNativeVlanTag.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/switchport/trunk/native/vlan/tag")
+ }
+ if !state.SwitchportTrunkNativeVlanVlanId.IsNull() && data.SwitchportTrunkNativeVlanVlanId.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/switchport/trunk/native/vlan/vlan-id")
+ }
+ if !state.Mab.IsNull() && data.Mab.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/mab")
+ }
+ if !state.MabEap.IsNull() && data.MabEap.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/mab/eap")
+ }
+ if !state.AccessSessionClosed.IsNull() && data.AccessSessionClosed.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/access-session/closed")
+ }
+ if !state.AccessSessionMonitor.IsNull() && data.AccessSessionMonitor.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/access-session/monitor")
+ }
+ if !state.AccessSessionPortControl.IsNull() && data.AccessSessionPortControl.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/access-session/port-control")
+ }
+ if !state.AccessSessionControlDirection.IsNull() && data.AccessSessionControlDirection.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/access-session/control-direction")
+ }
+ if !state.AccessSessionHostMode.IsNull() && data.AccessSessionHostMode.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/access-session/host-mode")
+ }
+ if !state.AccessSessionInterfaceTemplateSticky.IsNull() && data.AccessSessionInterfaceTemplateSticky.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/access-session/interface-template/sticky")
+ }
+ if !state.AccessSessionInterfaceTemplateStickyTimer.IsNull() && data.AccessSessionInterfaceTemplateStickyTimer.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/access-session/interface-template/sticky/timer")
+ }
+ if !state.AuthenticationPeriodic.IsNull() && data.AuthenticationPeriodic.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/authentication/periodic")
+ }
+ if !state.AuthenticationTimerReauthenticateServer.IsNull() && data.AuthenticationTimerReauthenticateServer.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/authentication/timer/reauthenticate/server")
+ }
+ if !state.AuthenticationTimerReauthenticateRange.IsNull() && data.AuthenticationTimerReauthenticateRange.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/authentication/timer/reauthenticate/range")
+ }
+ if !state.SpanningTreeBpduguardEnable.IsNull() && data.SpanningTreeBpduguardEnable.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/spanning-tree/bpduguard/enable")
+ }
+ if !state.SpanningTreeServicePolicy.IsNull() && data.SpanningTreeServicePolicy.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/spanning-tree/service-policy")
+ }
+ if !state.SpanningTreePortfastDisable.IsNull() && data.SpanningTreePortfastDisable.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/spanning-tree/portfast/disable")
+ }
+ if !state.SpanningTreePortfastEdge.IsNull() && data.SpanningTreePortfastEdge.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/spanning-tree/portfast/edge")
+ }
+ if !state.SpanningTreePortfastNetwork.IsNull() && data.SpanningTreePortfastNetwork.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/spanning-tree/portfast/network")
+ }
+ if !state.StormControlBroadcastLevelPpsThreshold.IsNull() && data.StormControlBroadcastLevelPpsThreshold.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/storm-control/broadcast/level/pps/threshold")
+ }
+ if !state.StormControlBroadcastLevelBpsThreshold.IsNull() && data.StormControlBroadcastLevelBpsThreshold.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/storm-control/broadcast/level/bps/threshold")
+ }
+ if !state.StormControlBroadcastLevelThreshold.IsNull() && data.StormControlBroadcastLevelThreshold.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/storm-control/broadcast/level/threshold")
+ }
+ if !state.StormControlMulticastLevelPpsThreshold.IsNull() && data.StormControlMulticastLevelPpsThreshold.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/storm-control/multicast/level/pps/threshold")
+ }
+ if !state.StormControlMulticastLevelBpsThreshold.IsNull() && data.StormControlMulticastLevelBpsThreshold.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/storm-control/multicast/level/bps/threshold")
+ }
+ if !state.StormControlMulticastLevelThreshold.IsNull() && data.StormControlMulticastLevelThreshold.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/storm-control/multicast/level/threshold")
+ }
+ if !state.StormControlActionShutdown.IsNull() && data.StormControlActionShutdown.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/storm-control/action/shutdown")
+ }
+ if !state.StormControlActionTrap.IsNull() && data.StormControlActionTrap.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/storm-control/action/trap")
+ }
+ if !state.LoadInterval.IsNull() && data.LoadInterval.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/load-interval")
+ }
+ if !state.IpDhcpSnoopingLimitRate.IsNull() && data.IpDhcpSnoopingLimitRate.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ip/dhcp/snooping/limit/rate")
+ }
+ if !state.IpDhcpSnoopingTrust.IsNull() && data.IpDhcpSnoopingTrust.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/ip/dhcp/snooping/trust")
}
- for i := range state.SwitchportPortSecurityMaximumRange {
- stateKeyValues := [...]string{strconv.FormatInt(state.SwitchportPortSecurityMaximumRange[i].Range.ValueInt64(), 10)}
+ for i := range state.IpAccessGroup {
+ stateKeys := [...]string{"direction"}
+ stateKeyValues := [...]string{state.IpAccessGroup[i].Direction.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
emptyKeys := true
- if !reflect.ValueOf(state.SwitchportPortSecurityMaximumRange[i].Range.ValueInt64()).IsZero() {
+ if !reflect.ValueOf(state.IpAccessGroup[i].Direction.ValueString()).IsZero() {
emptyKeys = false
}
if emptyKeys {
@@ -2062,81 +4056,90 @@ func (data *Template) getDeletedItems(ctx context.Context, state Template) []str
}
found := false
- for j := range data.SwitchportPortSecurityMaximumRange {
+ for j := range data.IpAccessGroup {
found = true
- if state.SwitchportPortSecurityMaximumRange[i].Range.ValueInt64() != data.SwitchportPortSecurityMaximumRange[j].Range.ValueInt64() {
+ if state.IpAccessGroup[i].Direction.ValueString() != data.IpAccessGroup[j].Direction.ValueString() {
found = false
}
if found {
- if !state.SwitchportPortSecurityMaximumRange[i].VlanAccess.IsNull() && data.SwitchportPortSecurityMaximumRange[j].VlanAccess.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/switchport/port-security/maximum/range=%v/vlan/access", state.getPath(), strings.Join(stateKeyValues[:], ",")))
- }
- if !state.SwitchportPortSecurityMaximumRange[i].Vlan.IsNull() && data.SwitchportPortSecurityMaximumRange[j].Vlan.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/switchport/port-security/maximum/range=%v/vlan", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ if !state.IpAccessGroup[i].AccessList.IsNull() && data.IpAccessGroup[j].AccessList.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/ip/access-group%v/access-list", predicates))
}
break
}
}
if !found {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/switchport/port-security/maximum/range=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/ip/access-group%v", predicates))
}
}
- if !state.SwitchportPortSecurityAgingTypeInactivity.IsNull() && data.SwitchportPortSecurityAgingTypeInactivity.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/switchport/port-security/aging/type", state.getPath()))
- }
- if !state.SwitchportPortSecurityAgingType.IsNull() && data.SwitchportPortSecurityAgingType.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/switchport/port-security/aging/type", state.getPath()))
- }
- if !state.SwitchportPortSecurityAgingTime.IsNull() && data.SwitchportPortSecurityAgingTime.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/switchport/port-security/aging/time", state.getPath()))
- }
- if !state.SwitchportPortSecurityAgingStatic.IsNull() && data.SwitchportPortSecurityAgingStatic.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/switchport/port-security/aging/static", state.getPath()))
- }
- if !state.SwitchportPortSecurity.IsNull() && data.SwitchportPortSecurity.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/switchport/port-security", state.getPath()))
- }
- if !state.SwitchportBlockUnicast.IsNull() && data.SwitchportBlockUnicast.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/switchport/block/unicast", state.getPath()))
- }
- if !state.SwitchportNonegotiate.IsNull() && data.SwitchportNonegotiate.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/switchport/nonegotiate", state.getPath()))
+ if !state.SubscriberAgingInactivityTimerValue.IsNull() && data.SubscriberAgingInactivityTimerValue.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/subscriber/aging/inactivity-timer/value")
}
- if !state.SwitchportModeAccess.IsNull() && data.SwitchportModeAccess.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/switchport/mode/access", state.getPath()))
+ if !state.SubscriberAgingInactivityTimerProbe.IsNull() && data.SubscriberAgingInactivityTimerProbe.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/subscriber/aging/inactivity-timer/probe")
}
- if !state.SwitchportModeTrunk.IsNull() && data.SwitchportModeTrunk.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/switchport/mode/trunk", state.getPath()))
+ if !state.SubscriberAgingProbe.IsNull() && data.SubscriberAgingProbe.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/subscriber/aging/probe")
}
- if !state.SourceTemplate.IsNull() && data.SourceTemplate.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/source/template", state.getPath()))
+ if !state.DeviceTracking.IsNull() && data.DeviceTracking.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/device-tracking")
}
- if !state.ServicePolicyOutput.IsNull() && data.ServicePolicyOutput.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/service-policy/output/policy-map-name", state.getPath()))
+ for i := range state.DeviceTrackingAttachPolicy {
+ stateKeys := [...]string{"policy-name"}
+ stateKeyValues := [...]string{state.DeviceTrackingAttachPolicy[i].PolicyName.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.DeviceTrackingAttachPolicy[i].PolicyName.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.DeviceTrackingAttachPolicy {
+ found = true
+ if state.DeviceTrackingAttachPolicy[i].PolicyName.ValueString() != data.DeviceTrackingAttachPolicy[j].PolicyName.ValueString() {
+ found = false
+ }
+ if found {
+ if !state.DeviceTrackingAttachPolicy[i].VlanRange.IsNull() && data.DeviceTrackingAttachPolicy[j].VlanRange.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/device-tracking/attach-policy/policy-name%v/vlan/vlan-range", predicates))
+ }
+ break
+ }
+ }
+ if !found {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/device-tracking/attach-policy/policy-name%v", predicates))
+ }
}
- if !state.ServicePolicyInput.IsNull() && data.ServicePolicyInput.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/service-policy/input/policy-map-name", state.getPath()))
+ if !state.DeviceTrackingVlanRange.IsNull() && data.DeviceTrackingVlanRange.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/device-tracking/vlan/vlan-range")
}
- if !state.ServicePolicyTypeControlSubscriber.IsNull() && data.ServicePolicyTypeControlSubscriber.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/service-policy/type/control/subscriber", state.getPath()))
+ if !state.CtsManual.IsNull() && data.CtsManual.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/cts/manual")
}
- if !state.Dot1xTimeoutTxPeriod.IsNull() && data.Dot1xTimeoutTxPeriod.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/dot1x/timeout/tx-period", state.getPath()))
+ if !state.CtsManualPolicyStaticSgt.IsNull() && data.CtsManualPolicyStaticSgt.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/cts/manual/policy/static/sgt")
}
- if !state.Dot1xMaxReq.IsNull() && data.Dot1xMaxReq.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/dot1x/max-req", state.getPath()))
+ if !state.CtsManualPolicyStaticTrusted.IsNull() && data.CtsManualPolicyStaticTrusted.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/cts/manual/policy/static/trusted")
}
- if !state.Dot1xMaxReauthReq.IsNull() && data.Dot1xMaxReauthReq.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/dot1x/max-reauth-req", state.getPath()))
+ if !state.CtsManualPropagateSgt.IsNull() && data.CtsManualPropagateSgt.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/cts/manual/propagate/sgt")
}
- if !state.Dot1xPae.IsNull() && data.Dot1xPae.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/dot1x/pae", state.getPath()))
+ if !state.CtsRoleBasedEnforcement.IsNull() && data.CtsRoleBasedEnforcement.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/cts/role-based/enforcement")
}
- return deletedItems
+ return b.Res()
}
-// End of section. //template:end getDeletedItems
+// End of section. //template:end addDeletedItemsXML
// Section below is generated&owned by "gen/generator.go". //template:begin getEmptyLeafsDelete
@@ -2484,3 +4487,244 @@ func (data *Template) getDeletePaths(ctx context.Context) []string {
}
// End of section. //template:end getDeletePaths
+
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletePathsXML
+
+func (data *Template) addDeletePathsXML(ctx context.Context, body string) string {
+ b := netconf.NewBody(body)
+ if !data.Dot1xPae.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/dot1x/pae")
+ }
+ if !data.Dot1xMaxReauthReq.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/dot1x/max-reauth-req")
+ }
+ if !data.Dot1xMaxReq.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/dot1x/max-req")
+ }
+ if !data.Dot1xTimeoutTxPeriod.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/dot1x/timeout/tx-period")
+ }
+ if !data.ServicePolicyTypeControlSubscriber.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/service-policy/type/control/subscriber")
+ }
+ if !data.ServicePolicyInput.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/service-policy/input/policy-map-name")
+ }
+ if !data.ServicePolicyOutput.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/service-policy/output/policy-map-name")
+ }
+ if !data.SourceTemplate.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/")
+ }
+ if !data.SwitchportModeTrunk.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/switchport/mode/trunk")
+ }
+ if !data.SwitchportModeAccess.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/switchport/mode/access")
+ }
+ if !data.SwitchportNonegotiate.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/switchport/nonegotiate")
+ }
+ if !data.SwitchportBlockUnicast.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/switchport/block/unicast")
+ }
+ if !data.SwitchportPortSecurity.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/switchport/port-security")
+ }
+ if !data.SwitchportPortSecurityAgingStatic.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/switchport/port-security/aging/static")
+ }
+ if !data.SwitchportPortSecurityAgingTime.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/switchport/port-security/aging/time")
+ }
+ if !data.SwitchportPortSecurityAgingType.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/switchport/port-security/aging/type")
+ }
+ if !data.SwitchportPortSecurityAgingTypeInactivity.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/switchport/port-security/aging/type/inactivity")
+ }
+ for i := range data.SwitchportPortSecurityMaximumRange {
+ keys := [...]string{"range"}
+ keyValues := [...]string{strconv.FormatInt(data.SwitchportPortSecurityMaximumRange[i].Range.ValueInt64(), 10)}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/switchport/port-security/maximum/range%v", predicates))
+ }
+ if !data.SwitchportPortSecurityViolationProtect.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/switchport/port-security/violation/protect")
+ }
+ if !data.SwitchportPortSecurityViolationRestrict.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/switchport/port-security/violation/restrict")
+ }
+ if !data.SwitchportPortSecurityViolationShutdown.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/switchport/port-security/violation/shutdown")
+ }
+ if !data.SwitchportAccessVlan.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/switchport/access/vlan")
+ }
+ if !data.SwitchportVoiceVlan.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/switchport/voice/vlan")
+ }
+ if !data.SwitchportPrivateVlanHostAssociationPrimaryRange.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/switchport/private-vlan/host-association/primary-range")
+ }
+ if !data.SwitchportPrivateVlanHostAssociationSecondaryRange.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/switchport/private-vlan/host-association/secondary-range")
+ }
+ if !data.SwitchportTrunkAllowedVlans.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/switchport/trunk/allowed/vlan/vlans")
+ }
+ if !data.SwitchportTrunkAllowedVlansNone.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/switchport/trunk/allowed/vlan/none")
+ }
+ if !data.SwitchportTrunkAllowedVlansAll.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/switchport/trunk/allowed/vlan/all")
+ }
+ if !data.SwitchportTrunkNativeVlanTag.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/switchport/trunk/native/vlan/tag")
+ }
+ if !data.SwitchportTrunkNativeVlanVlanId.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/switchport/trunk/native/vlan/vlan-id")
+ }
+ if !data.Mab.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/mab")
+ }
+ if !data.MabEap.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/mab/eap")
+ }
+ if !data.AccessSessionClosed.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/access-session/closed")
+ }
+ if !data.AccessSessionMonitor.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/access-session/monitor")
+ }
+ if !data.AccessSessionPortControl.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/access-session/port-control")
+ }
+ if !data.AccessSessionControlDirection.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/access-session/control-direction")
+ }
+ if !data.AccessSessionHostMode.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/access-session/host-mode")
+ }
+ if !data.AccessSessionInterfaceTemplateSticky.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/access-session/interface-template/sticky")
+ }
+ if !data.AccessSessionInterfaceTemplateStickyTimer.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/access-session/interface-template/sticky/timer")
+ }
+ if !data.AuthenticationPeriodic.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/authentication/periodic")
+ }
+ if !data.AuthenticationTimerReauthenticateServer.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/authentication/timer/reauthenticate/server")
+ }
+ if !data.AuthenticationTimerReauthenticateRange.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/authentication/timer/reauthenticate/range")
+ }
+ if !data.SpanningTreeBpduguardEnable.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/spanning-tree/bpduguard/enable")
+ }
+ if !data.SpanningTreeServicePolicy.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/spanning-tree/service-policy")
+ }
+ if !data.SpanningTreePortfastDisable.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/spanning-tree/portfast/disable")
+ }
+ if !data.SpanningTreePortfastEdge.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/spanning-tree/portfast/edge")
+ }
+ if !data.SpanningTreePortfastNetwork.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/spanning-tree/portfast/network")
+ }
+ if !data.StormControlBroadcastLevelPpsThreshold.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/storm-control/broadcast/level/pps/threshold")
+ }
+ if !data.StormControlBroadcastLevelBpsThreshold.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/storm-control/broadcast/level/bps/threshold")
+ }
+ if !data.StormControlBroadcastLevelThreshold.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/storm-control/broadcast/level/threshold")
+ }
+ if !data.StormControlMulticastLevelPpsThreshold.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/storm-control/multicast/level/pps/threshold")
+ }
+ if !data.StormControlMulticastLevelBpsThreshold.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/storm-control/multicast/level/bps/threshold")
+ }
+ if !data.StormControlMulticastLevelThreshold.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/storm-control/multicast/level/threshold")
+ }
+ if !data.StormControlActionShutdown.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/storm-control/action/shutdown")
+ }
+ if !data.StormControlActionTrap.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/storm-control/action/trap")
+ }
+ if !data.LoadInterval.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/load-interval")
+ }
+ if !data.IpDhcpSnoopingLimitRate.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ip/dhcp/snooping/limit/rate")
+ }
+ if !data.IpDhcpSnoopingTrust.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/ip/dhcp/snooping/trust")
+ }
+ for i := range data.IpAccessGroup {
+ keys := [...]string{"direction"}
+ keyValues := [...]string{data.IpAccessGroup[i].Direction.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/ip/access-group%v", predicates))
+ }
+ if !data.SubscriberAgingInactivityTimerValue.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/subscriber/aging/inactivity-timer/value")
+ }
+ if !data.SubscriberAgingInactivityTimerProbe.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/subscriber/aging/inactivity-timer/probe")
+ }
+ if !data.SubscriberAgingProbe.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/subscriber/aging/probe")
+ }
+ if !data.DeviceTracking.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/device-tracking")
+ }
+ for i := range data.DeviceTrackingAttachPolicy {
+ keys := [...]string{"policy-name"}
+ keyValues := [...]string{data.DeviceTrackingAttachPolicy[i].PolicyName.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/device-tracking/attach-policy/policy-name%v", predicates))
+ }
+ if !data.DeviceTrackingVlanRange.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/device-tracking/vlan/vlan-range")
+ }
+ if !data.CtsManual.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/cts/manual")
+ }
+ if !data.CtsManualPolicyStaticSgt.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/cts/manual/policy/static/sgt")
+ }
+ if !data.CtsManualPolicyStaticTrusted.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/cts/manual/policy/static/trusted")
+ }
+ if !data.CtsManualPropagateSgt.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/cts/manual/propagate/sgt")
+ }
+ if !data.CtsRoleBasedEnforcement.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/cts/role-based/enforcement")
+ }
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletePathsXML
diff --git a/internal/provider/model_iosxe_udld.go b/internal/provider/model_iosxe_udld.go
index 7fc87602..7c42ea73 100644
--- a/internal/provider/model_iosxe_udld.go
+++ b/internal/provider/model_iosxe_udld.go
@@ -28,6 +28,9 @@ import (
"github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/types"
+ "github.com/hashicorp/terraform-plugin-log/tflog"
+ "github.com/netascode/go-netconf"
+ "github.com/netascode/xmldot"
"github.com/tidwall/gjson"
"github.com/tidwall/sjson"
)
@@ -77,6 +80,17 @@ func (data UDLD) getPathShort() string {
return matches[1]
}
+// getXPath returns the XPath for NETCONF operations
+func (data UDLD) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/udld"
+ return path
+}
+
+func (data UDLDData) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/udld"
+ return path
+}
+
// End of section. //template:end getPath
// Section below is generated&owned by "gen/generator.go". //template:begin toBody
@@ -104,6 +118,39 @@ func (data UDLD) toBody(ctx context.Context) string {
// End of section. //template:end toBody
+// Section below is generated&owned by "gen/generator.go". //template:begin toBodyXML
+
+func (data UDLD) toBodyXML(ctx context.Context) string {
+ body := netconf.Body{}
+ if !data.Aggressive.IsNull() && !data.Aggressive.IsUnknown() {
+ if data.Aggressive.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-udld:aggressive", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-udld:aggressive")
+ }
+ }
+ if !data.Enable.IsNull() && !data.Enable.IsUnknown() {
+ if data.Enable.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-udld:enable", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-udld:enable")
+ }
+ }
+ if !data.MessageTime.IsNull() && !data.MessageTime.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-udld:message/time", strconv.FormatInt(data.MessageTime.ValueInt64(), 10))
+ }
+ if !data.RecoveryInterval.IsNull() && !data.RecoveryInterval.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-udld:recovery/interval", strconv.FormatInt(data.RecoveryInterval.ValueInt64(), 10))
+ }
+ bodyString, err := body.String()
+ if err != nil {
+ tflog.Error(ctx, fmt.Sprintf("Error converting body to string: %s", err))
+ }
+ return bodyString
+}
+
+// End of section. //template:end toBodyXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBody
func (data *UDLD) updateFromBody(ctx context.Context, res gjson.Result) {
@@ -143,6 +190,41 @@ func (data *UDLD) updateFromBody(ctx context.Context, res gjson.Result) {
// End of section. //template:end updateFromBody
+// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBodyXML
+
+func (data *UDLD) updateFromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-udld:aggressive"); !data.Aggressive.IsNull() {
+ if value.Exists() {
+ data.Aggressive = types.BoolValue(true)
+ } else {
+ data.Aggressive = types.BoolValue(false)
+ }
+ } else {
+ data.Aggressive = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-udld:enable"); !data.Enable.IsNull() {
+ if value.Exists() {
+ data.Enable = types.BoolValue(true)
+ } else {
+ data.Enable = types.BoolValue(false)
+ }
+ } else {
+ data.Enable = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-udld:message/time"); value.Exists() && !data.MessageTime.IsNull() {
+ data.MessageTime = types.Int64Value(value.Int())
+ } else {
+ data.MessageTime = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-udld:recovery/interval"); value.Exists() && !data.RecoveryInterval.IsNull() {
+ data.RecoveryInterval = types.Int64Value(value.Int())
+ } else {
+ data.RecoveryInterval = types.Int64Null()
+ }
+}
+
+// End of section. //template:end updateFromBodyXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin fromBody
func (data *UDLD) fromBody(ctx context.Context, res gjson.Result) {
@@ -197,6 +279,52 @@ func (data *UDLDData) fromBody(ctx context.Context, res gjson.Result) {
// End of section. //template:end fromBodyData
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyXML
+
+func (data *UDLD) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-udld:aggressive"); value.Exists() {
+ data.Aggressive = types.BoolValue(true)
+ } else {
+ data.Aggressive = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-udld:enable"); value.Exists() {
+ data.Enable = types.BoolValue(true)
+ } else {
+ data.Enable = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-udld:message/time"); value.Exists() {
+ data.MessageTime = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-udld:recovery/interval"); value.Exists() {
+ data.RecoveryInterval = types.Int64Value(value.Int())
+ }
+}
+
+// End of section. //template:end fromBodyXML
+
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyDataXML
+
+func (data *UDLDData) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-udld:aggressive"); value.Exists() {
+ data.Aggressive = types.BoolValue(true)
+ } else {
+ data.Aggressive = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-udld:enable"); value.Exists() {
+ data.Enable = types.BoolValue(true)
+ } else {
+ data.Enable = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-udld:message/time"); value.Exists() {
+ data.MessageTime = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-udld:recovery/interval"); value.Exists() {
+ data.RecoveryInterval = types.Int64Value(value.Int())
+ }
+}
+
+// End of section. //template:end fromBodyDataXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin getDeletedItems
func (data *UDLD) getDeletedItems(ctx context.Context, state UDLD) []string {
@@ -219,6 +347,28 @@ func (data *UDLD) getDeletedItems(ctx context.Context, state UDLD) []string {
// End of section. //template:end getDeletedItems
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletedItemsXML
+
+func (data *UDLD) addDeletedItemsXML(ctx context.Context, state UDLD, body string) string {
+ b := netconf.NewBody(body)
+ if !state.Aggressive.IsNull() && data.Aggressive.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-udld:aggressive")
+ }
+ if !state.Enable.IsNull() && data.Enable.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-udld:enable")
+ }
+ if !state.MessageTime.IsNull() && data.MessageTime.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-udld:message/time")
+ }
+ if !state.RecoveryInterval.IsNull() && data.RecoveryInterval.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-udld:recovery/interval")
+ }
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletedItemsXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin getEmptyLeafsDelete
func (data *UDLD) getEmptyLeafsDelete(ctx context.Context) []string {
@@ -256,3 +406,25 @@ func (data *UDLD) getDeletePaths(ctx context.Context) []string {
}
// End of section. //template:end getDeletePaths
+
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletePathsXML
+
+func (data *UDLD) addDeletePathsXML(ctx context.Context, body string) string {
+ b := netconf.NewBody(body)
+ if !data.Aggressive.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-udld:aggressive")
+ }
+ if !data.Enable.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-udld:enable")
+ }
+ if !data.MessageTime.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-udld:message/time")
+ }
+ if !data.RecoveryInterval.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-udld:recovery/interval")
+ }
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletePathsXML
diff --git a/internal/provider/model_iosxe_username.go b/internal/provider/model_iosxe_username.go
index ab9e5039..0717de92 100644
--- a/internal/provider/model_iosxe_username.go
+++ b/internal/provider/model_iosxe_username.go
@@ -29,6 +29,9 @@ import (
"github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/types"
+ "github.com/hashicorp/terraform-plugin-log/tflog"
+ "github.com/netascode/go-netconf"
+ "github.com/netascode/xmldot"
"github.com/tidwall/gjson"
"github.com/tidwall/sjson"
)
@@ -83,6 +86,19 @@ func (data Username) getPathShort() string {
return matches[1]
}
+// getXPath returns the XPath for NETCONF operations
+func (data Username) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/username[name=%s]"
+ path = fmt.Sprintf(path, fmt.Sprintf("%v", data.Name.ValueString()))
+ return path
+}
+
+func (data UsernameData) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/username[name=%s]"
+ path = fmt.Sprintf(path, fmt.Sprintf("%v", data.Name.ValueString()))
+ return path
+}
+
// End of section. //template:end getPath
// Section below is generated&owned by "gen/generator.go". //template:begin toBody
@@ -115,6 +131,40 @@ func (data Username) toBody(ctx context.Context) string {
// End of section. //template:end toBody
+// Section below is generated&owned by "gen/generator.go". //template:begin toBodyXML
+
+func (data Username) toBodyXML(ctx context.Context) string {
+ body := netconf.Body{}
+ if !data.Name.IsNull() && !data.Name.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/name", data.Name.ValueString())
+ }
+ if !data.Privilege.IsNull() && !data.Privilege.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/privilege", strconv.FormatInt(data.Privilege.ValueInt64(), 10))
+ }
+ if !data.Description.IsNull() && !data.Description.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/description", data.Description.ValueString())
+ }
+ if !data.PasswordEncryption.IsNull() && !data.PasswordEncryption.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/password/encryption", data.PasswordEncryption.ValueString())
+ }
+ if !data.Password.IsNull() && !data.Password.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/password/password", data.Password.ValueString())
+ }
+ if !data.SecretEncryption.IsNull() && !data.SecretEncryption.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/secret/encryption", data.SecretEncryption.ValueString())
+ }
+ if !data.Secret.IsNull() && !data.Secret.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/secret/secret", data.Secret.ValueString())
+ }
+ bodyString, err := body.String()
+ if err != nil {
+ tflog.Error(ctx, fmt.Sprintf("Error converting body to string: %s", err))
+ }
+ return bodyString
+}
+
+// End of section. //template:end toBodyXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBody
func (data *Username) updateFromBody(ctx context.Context, res gjson.Result) {
@@ -146,6 +196,33 @@ func (data *Username) updateFromBody(ctx context.Context, res gjson.Result) {
// End of section. //template:end updateFromBody
+// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBodyXML
+
+func (data *Username) updateFromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/name"); value.Exists() && !data.Name.IsNull() {
+ data.Name = types.StringValue(value.String())
+ } else {
+ data.Name = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/privilege"); value.Exists() && !data.Privilege.IsNull() {
+ data.Privilege = types.Int64Value(value.Int())
+ } else {
+ data.Privilege = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/description"); value.Exists() && !data.Description.IsNull() {
+ data.Description = types.StringValue(value.String())
+ } else {
+ data.Description = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/secret/encryption"); value.Exists() && !data.SecretEncryption.IsNull() {
+ data.SecretEncryption = types.StringValue(value.String())
+ } else {
+ data.SecretEncryption = types.StringNull()
+ }
+}
+
+// End of section. //template:end updateFromBodyXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin fromBody
func (data *Username) fromBody(ctx context.Context, res gjson.Result) {
@@ -204,6 +281,56 @@ func (data *UsernameData) fromBody(ctx context.Context, res gjson.Result) {
// End of section. //template:end fromBodyData
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyXML
+
+func (data *Username) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/privilege"); value.Exists() {
+ data.Privilege = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/description"); value.Exists() {
+ data.Description = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/password/encryption"); value.Exists() {
+ data.PasswordEncryption = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/password/password"); value.Exists() {
+ data.Password = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/secret/encryption"); value.Exists() {
+ data.SecretEncryption = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/secret/secret"); value.Exists() {
+ data.Secret = types.StringValue(value.String())
+ }
+}
+
+// End of section. //template:end fromBodyXML
+
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyDataXML
+
+func (data *UsernameData) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/privilege"); value.Exists() {
+ data.Privilege = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/description"); value.Exists() {
+ data.Description = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/password/encryption"); value.Exists() {
+ data.PasswordEncryption = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/password/password"); value.Exists() {
+ data.Password = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/secret/encryption"); value.Exists() {
+ data.SecretEncryption = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/secret/secret"); value.Exists() {
+ data.Secret = types.StringValue(value.String())
+ }
+}
+
+// End of section. //template:end fromBodyDataXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin getDeletedItems
func (data *Username) getDeletedItems(ctx context.Context, state Username) []string {
@@ -232,6 +359,34 @@ func (data *Username) getDeletedItems(ctx context.Context, state Username) []str
// End of section. //template:end getDeletedItems
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletedItemsXML
+
+func (data *Username) addDeletedItemsXML(ctx context.Context, state Username, body string) string {
+ b := netconf.NewBody(body)
+ if !state.Privilege.IsNull() && data.Privilege.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/privilege")
+ }
+ if !state.Description.IsNull() && data.Description.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/description")
+ }
+ if !state.PasswordEncryption.IsNull() && data.PasswordEncryption.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/password/encryption")
+ }
+ if !state.Password.IsNull() && data.Password.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/password/password")
+ }
+ if !state.SecretEncryption.IsNull() && data.SecretEncryption.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/secret/encryption")
+ }
+ if !state.Secret.IsNull() && data.Secret.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/secret/secret")
+ }
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletedItemsXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin getEmptyLeafsDelete
func (data *Username) getEmptyLeafsDelete(ctx context.Context) []string {
@@ -269,3 +424,31 @@ func (data *Username) getDeletePaths(ctx context.Context) []string {
}
// End of section. //template:end getDeletePaths
+
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletePathsXML
+
+func (data *Username) addDeletePathsXML(ctx context.Context, body string) string {
+ b := netconf.NewBody(body)
+ if !data.Privilege.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/privilege")
+ }
+ if !data.Description.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/description")
+ }
+ if !data.PasswordEncryption.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/password/encryption")
+ }
+ if !data.Password.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/password/password")
+ }
+ if !data.SecretEncryption.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/secret/encryption")
+ }
+ if !data.Secret.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/secret/secret")
+ }
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletePathsXML
diff --git a/internal/provider/model_iosxe_vlan.go b/internal/provider/model_iosxe_vlan.go
index dd55183e..e311168d 100644
--- a/internal/provider/model_iosxe_vlan.go
+++ b/internal/provider/model_iosxe_vlan.go
@@ -29,6 +29,9 @@ import (
"github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/types"
+ "github.com/hashicorp/terraform-plugin-log/tflog"
+ "github.com/netascode/go-netconf"
+ "github.com/netascode/xmldot"
"github.com/tidwall/gjson"
"github.com/tidwall/sjson"
)
@@ -85,6 +88,19 @@ func (data VLAN) getPathShort() string {
return matches[1]
}
+// getXPath returns the XPath for NETCONF operations
+func (data VLAN) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/vlan/Cisco-IOS-XE-vlan:vlan-list[id=%v]"
+ path = fmt.Sprintf(path, fmt.Sprintf("%v", data.VlanId.ValueInt64()))
+ return path
+}
+
+func (data VLANData) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/vlan/Cisco-IOS-XE-vlan:vlan-list[id=%v]"
+ path = fmt.Sprintf(path, fmt.Sprintf("%v", data.VlanId.ValueInt64()))
+ return path
+}
+
// End of section. //template:end getPath
// Section below is generated&owned by "gen/generator.go". //template:begin toBody
@@ -130,6 +146,63 @@ func (data VLAN) toBody(ctx context.Context) string {
// End of section. //template:end toBody
+// Section below is generated&owned by "gen/generator.go". //template:begin toBodyXML
+
+func (data VLAN) toBodyXML(ctx context.Context) string {
+ body := netconf.Body{}
+ if !data.VlanId.IsNull() && !data.VlanId.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/id", strconv.FormatInt(data.VlanId.ValueInt64(), 10))
+ }
+ if !data.RemoteSpan.IsNull() && !data.RemoteSpan.IsUnknown() {
+ if data.RemoteSpan.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/remote-span", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/remote-span")
+ }
+ }
+ if !data.PrivateVlanPrimary.IsNull() && !data.PrivateVlanPrimary.IsUnknown() {
+ if data.PrivateVlanPrimary.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/private-vlan/primary", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/private-vlan/primary")
+ }
+ }
+ if !data.PrivateVlanAssociation.IsNull() && !data.PrivateVlanAssociation.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/private-vlan/association", data.PrivateVlanAssociation.ValueString())
+ }
+ if !data.PrivateVlanCommunity.IsNull() && !data.PrivateVlanCommunity.IsUnknown() {
+ if data.PrivateVlanCommunity.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/private-vlan/community", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/private-vlan/community")
+ }
+ }
+ if !data.PrivateVlanIsolated.IsNull() && !data.PrivateVlanIsolated.IsUnknown() {
+ if data.PrivateVlanIsolated.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/private-vlan/isolated", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/private-vlan/isolated")
+ }
+ }
+ if !data.Name.IsNull() && !data.Name.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/name", data.Name.ValueString())
+ }
+ if !data.Shutdown.IsNull() && !data.Shutdown.IsUnknown() {
+ if data.Shutdown.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/shutdown", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/shutdown")
+ }
+ }
+ bodyString, err := body.String()
+ if err != nil {
+ tflog.Error(ctx, fmt.Sprintf("Error converting body to string: %s", err))
+ }
+ return bodyString
+}
+
+// End of section. //template:end toBodyXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBody
func (data *VLAN) updateFromBody(ctx context.Context, res gjson.Result) {
@@ -201,6 +274,73 @@ func (data *VLAN) updateFromBody(ctx context.Context, res gjson.Result) {
// End of section. //template:end updateFromBody
+// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBodyXML
+
+func (data *VLAN) updateFromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/id"); value.Exists() && !data.VlanId.IsNull() {
+ data.VlanId = types.Int64Value(value.Int())
+ } else {
+ data.VlanId = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/remote-span"); !data.RemoteSpan.IsNull() {
+ if value.Exists() {
+ data.RemoteSpan = types.BoolValue(true)
+ } else {
+ data.RemoteSpan = types.BoolValue(false)
+ }
+ } else {
+ data.RemoteSpan = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/private-vlan/primary"); !data.PrivateVlanPrimary.IsNull() {
+ if value.Exists() {
+ data.PrivateVlanPrimary = types.BoolValue(true)
+ } else {
+ data.PrivateVlanPrimary = types.BoolValue(false)
+ }
+ } else {
+ data.PrivateVlanPrimary = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/private-vlan/association"); value.Exists() && !data.PrivateVlanAssociation.IsNull() {
+ data.PrivateVlanAssociation = types.StringValue(value.String())
+ } else {
+ data.PrivateVlanAssociation = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/private-vlan/community"); !data.PrivateVlanCommunity.IsNull() {
+ if value.Exists() {
+ data.PrivateVlanCommunity = types.BoolValue(true)
+ } else {
+ data.PrivateVlanCommunity = types.BoolValue(false)
+ }
+ } else {
+ data.PrivateVlanCommunity = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/private-vlan/isolated"); !data.PrivateVlanIsolated.IsNull() {
+ if value.Exists() {
+ data.PrivateVlanIsolated = types.BoolValue(true)
+ } else {
+ data.PrivateVlanIsolated = types.BoolValue(false)
+ }
+ } else {
+ data.PrivateVlanIsolated = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/name"); value.Exists() && !data.Name.IsNull() {
+ data.Name = types.StringValue(value.String())
+ } else {
+ data.Name = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/shutdown"); !data.Shutdown.IsNull() {
+ if value.Exists() {
+ data.Shutdown = types.BoolValue(true)
+ } else {
+ data.Shutdown = types.BoolValue(false)
+ }
+ } else {
+ data.Shutdown = types.BoolNull()
+ }
+}
+
+// End of section. //template:end updateFromBodyXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin fromBody
func (data *VLAN) fromBody(ctx context.Context, res gjson.Result) {
@@ -285,6 +425,82 @@ func (data *VLANData) fromBody(ctx context.Context, res gjson.Result) {
// End of section. //template:end fromBodyData
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyXML
+
+func (data *VLAN) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/remote-span"); value.Exists() {
+ data.RemoteSpan = types.BoolValue(true)
+ } else {
+ data.RemoteSpan = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/private-vlan/primary"); value.Exists() {
+ data.PrivateVlanPrimary = types.BoolValue(true)
+ } else {
+ data.PrivateVlanPrimary = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/private-vlan/association"); value.Exists() {
+ data.PrivateVlanAssociation = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/private-vlan/community"); value.Exists() {
+ data.PrivateVlanCommunity = types.BoolValue(true)
+ } else {
+ data.PrivateVlanCommunity = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/private-vlan/isolated"); value.Exists() {
+ data.PrivateVlanIsolated = types.BoolValue(true)
+ } else {
+ data.PrivateVlanIsolated = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/name"); value.Exists() {
+ data.Name = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/shutdown"); value.Exists() {
+ data.Shutdown = types.BoolValue(true)
+ } else {
+ data.Shutdown = types.BoolValue(false)
+ }
+}
+
+// End of section. //template:end fromBodyXML
+
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyDataXML
+
+func (data *VLANData) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/remote-span"); value.Exists() {
+ data.RemoteSpan = types.BoolValue(true)
+ } else {
+ data.RemoteSpan = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/private-vlan/primary"); value.Exists() {
+ data.PrivateVlanPrimary = types.BoolValue(true)
+ } else {
+ data.PrivateVlanPrimary = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/private-vlan/association"); value.Exists() {
+ data.PrivateVlanAssociation = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/private-vlan/community"); value.Exists() {
+ data.PrivateVlanCommunity = types.BoolValue(true)
+ } else {
+ data.PrivateVlanCommunity = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/private-vlan/isolated"); value.Exists() {
+ data.PrivateVlanIsolated = types.BoolValue(true)
+ } else {
+ data.PrivateVlanIsolated = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/name"); value.Exists() {
+ data.Name = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/shutdown"); value.Exists() {
+ data.Shutdown = types.BoolValue(true)
+ } else {
+ data.Shutdown = types.BoolValue(false)
+ }
+}
+
+// End of section. //template:end fromBodyDataXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin getDeletedItems
func (data *VLAN) getDeletedItems(ctx context.Context, state VLAN) []string {
@@ -316,6 +532,37 @@ func (data *VLAN) getDeletedItems(ctx context.Context, state VLAN) []string {
// End of section. //template:end getDeletedItems
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletedItemsXML
+
+func (data *VLAN) addDeletedItemsXML(ctx context.Context, state VLAN, body string) string {
+ b := netconf.NewBody(body)
+ if !state.RemoteSpan.IsNull() && data.RemoteSpan.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/remote-span")
+ }
+ if !state.PrivateVlanPrimary.IsNull() && data.PrivateVlanPrimary.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/private-vlan/primary")
+ }
+ if !state.PrivateVlanAssociation.IsNull() && data.PrivateVlanAssociation.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/private-vlan/association")
+ }
+ if !state.PrivateVlanCommunity.IsNull() && data.PrivateVlanCommunity.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/private-vlan/community")
+ }
+ if !state.PrivateVlanIsolated.IsNull() && data.PrivateVlanIsolated.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/private-vlan/isolated")
+ }
+ if !state.Name.IsNull() && data.Name.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/name")
+ }
+ if !state.Shutdown.IsNull() && data.Shutdown.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/shutdown")
+ }
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletedItemsXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin getEmptyLeafsDelete
func (data *VLAN) getEmptyLeafsDelete(ctx context.Context) []string {
@@ -371,3 +618,34 @@ func (data *VLAN) getDeletePaths(ctx context.Context) []string {
}
// End of section. //template:end getDeletePaths
+
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletePathsXML
+
+func (data *VLAN) addDeletePathsXML(ctx context.Context, body string) string {
+ b := netconf.NewBody(body)
+ if !data.RemoteSpan.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/remote-span")
+ }
+ if !data.PrivateVlanPrimary.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/private-vlan/primary")
+ }
+ if !data.PrivateVlanAssociation.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/private-vlan/association")
+ }
+ if !data.PrivateVlanCommunity.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/private-vlan/community")
+ }
+ if !data.PrivateVlanIsolated.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/private-vlan/isolated")
+ }
+ if !data.Name.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/name")
+ }
+ if !data.Shutdown.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/shutdown")
+ }
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletePathsXML
diff --git a/internal/provider/model_iosxe_vlan_access_map.go b/internal/provider/model_iosxe_vlan_access_map.go
index 6e7b5424..5e1c03cb 100644
--- a/internal/provider/model_iosxe_vlan_access_map.go
+++ b/internal/provider/model_iosxe_vlan_access_map.go
@@ -29,6 +29,9 @@ import (
"github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/types"
+ "github.com/hashicorp/terraform-plugin-log/tflog"
+ "github.com/netascode/go-netconf"
+ "github.com/netascode/xmldot"
"github.com/tidwall/gjson"
"github.com/tidwall/sjson"
)
@@ -79,6 +82,19 @@ func (data VLANAccessMap) getPathShort() string {
return matches[1]
}
+// getXPath returns the XPath for NETCONF operations
+func (data VLANAccessMap) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/vlan/Cisco-IOS-XE-vlan:access-map[name=%v][value=%v]"
+ path = fmt.Sprintf(path, fmt.Sprintf("%v", data.Name.ValueString()), fmt.Sprintf("%v", data.Sequence.ValueInt64()))
+ return path
+}
+
+func (data VLANAccessMapData) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/vlan/Cisco-IOS-XE-vlan:access-map[name=%v][value=%v]"
+ path = fmt.Sprintf(path, fmt.Sprintf("%v", data.Name.ValueString()), fmt.Sprintf("%v", data.Sequence.ValueInt64()))
+ return path
+}
+
// End of section. //template:end getPath
// Section below is generated&owned by "gen/generator.go". //template:begin toBody
@@ -109,6 +125,42 @@ func (data VLANAccessMap) toBody(ctx context.Context) string {
// End of section. //template:end toBody
+// Section below is generated&owned by "gen/generator.go". //template:begin toBodyXML
+
+func (data VLANAccessMap) toBodyXML(ctx context.Context) string {
+ body := netconf.Body{}
+ if !data.Name.IsNull() && !data.Name.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/name", data.Name.ValueString())
+ }
+ if !data.Sequence.IsNull() && !data.Sequence.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/value", strconv.FormatInt(data.Sequence.ValueInt64(), 10))
+ }
+ if !data.MatchIpv6Address.IsNull() && !data.MatchIpv6Address.IsUnknown() {
+ var values []string
+ data.MatchIpv6Address.ElementsAs(ctx, &values, false)
+ for _, v := range values {
+ body = helpers.AppendFromXPath(body, data.getXPath()+"/match/ipv6/address", v)
+ }
+ }
+ if !data.MatchIpAddress.IsNull() && !data.MatchIpAddress.IsUnknown() {
+ var values []string
+ data.MatchIpAddress.ElementsAs(ctx, &values, false)
+ for _, v := range values {
+ body = helpers.AppendFromXPath(body, data.getXPath()+"/match/ip/address", v)
+ }
+ }
+ if !data.Action.IsNull() && !data.Action.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/action", data.Action.ValueString())
+ }
+ bodyString, err := body.String()
+ if err != nil {
+ tflog.Error(ctx, fmt.Sprintf("Error converting body to string: %s", err))
+ }
+ return bodyString
+}
+
+// End of section. //template:end toBodyXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBody
func (data *VLANAccessMap) updateFromBody(ctx context.Context, res gjson.Result) {
@@ -145,6 +197,38 @@ func (data *VLANAccessMap) updateFromBody(ctx context.Context, res gjson.Result)
// End of section. //template:end updateFromBody
+// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBodyXML
+
+func (data *VLANAccessMap) updateFromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/name"); value.Exists() && !data.Name.IsNull() {
+ data.Name = types.StringValue(value.String())
+ } else {
+ data.Name = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/value"); value.Exists() && !data.Sequence.IsNull() {
+ data.Sequence = types.Int64Value(value.Int())
+ } else {
+ data.Sequence = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/match/ipv6/address"); value.Exists() && !data.MatchIpv6Address.IsNull() {
+ data.MatchIpv6Address = helpers.GetStringListXML(value.Array())
+ } else {
+ data.MatchIpv6Address = types.ListNull(types.StringType)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/match/ip/address"); value.Exists() && !data.MatchIpAddress.IsNull() {
+ data.MatchIpAddress = helpers.GetStringListXML(value.Array())
+ } else {
+ data.MatchIpAddress = types.ListNull(types.StringType)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/action"); value.Exists() && !data.Action.IsNull() {
+ data.Action = types.StringValue(value.String())
+ } else {
+ data.Action = types.StringNull()
+ }
+}
+
+// End of section. //template:end updateFromBodyXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin fromBody
func (data *VLANAccessMap) fromBody(ctx context.Context, res gjson.Result) {
@@ -193,6 +277,46 @@ func (data *VLANAccessMapData) fromBody(ctx context.Context, res gjson.Result) {
// End of section. //template:end fromBodyData
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyXML
+
+func (data *VLANAccessMap) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/match/ipv6/address"); value.Exists() {
+ data.MatchIpv6Address = helpers.GetStringListXML(value.Array())
+ } else {
+ data.MatchIpv6Address = types.ListNull(types.StringType)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/match/ip/address"); value.Exists() {
+ data.MatchIpAddress = helpers.GetStringListXML(value.Array())
+ } else {
+ data.MatchIpAddress = types.ListNull(types.StringType)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/action"); value.Exists() {
+ data.Action = types.StringValue(value.String())
+ }
+}
+
+// End of section. //template:end fromBodyXML
+
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyDataXML
+
+func (data *VLANAccessMapData) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/match/ipv6/address"); value.Exists() {
+ data.MatchIpv6Address = helpers.GetStringListXML(value.Array())
+ } else {
+ data.MatchIpv6Address = types.ListNull(types.StringType)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/match/ip/address"); value.Exists() {
+ data.MatchIpAddress = helpers.GetStringListXML(value.Array())
+ } else {
+ data.MatchIpAddress = types.ListNull(types.StringType)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/action"); value.Exists() {
+ data.Action = types.StringValue(value.String())
+ }
+}
+
+// End of section. //template:end fromBodyDataXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin getDeletedItems
func (data *VLANAccessMap) getDeletedItems(ctx context.Context, state VLANAccessMap) []string {
@@ -248,6 +372,61 @@ func (data *VLANAccessMap) getDeletedItems(ctx context.Context, state VLANAccess
// End of section. //template:end getDeletedItems
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletedItemsXML
+
+func (data *VLANAccessMap) addDeletedItemsXML(ctx context.Context, state VLANAccessMap, body string) string {
+ b := netconf.NewBody(body)
+ if !state.MatchIpv6Address.IsNull() {
+ if data.MatchIpv6Address.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/match/ipv6/address")
+ } else {
+ var dataValues, stateValues []string
+ data.MatchIpv6Address.ElementsAs(ctx, &dataValues, false)
+ state.MatchIpv6Address.ElementsAs(ctx, &stateValues, false)
+ for _, v := range stateValues {
+ found := false
+ for _, vv := range dataValues {
+ if v == vv {
+ found = true
+ break
+ }
+ }
+ if !found {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/match/ipv6/address[.=%v]", v))
+ }
+ }
+ }
+ }
+ if !state.MatchIpAddress.IsNull() {
+ if data.MatchIpAddress.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/match/ip/address")
+ } else {
+ var dataValues, stateValues []string
+ data.MatchIpAddress.ElementsAs(ctx, &dataValues, false)
+ state.MatchIpAddress.ElementsAs(ctx, &stateValues, false)
+ for _, v := range stateValues {
+ found := false
+ for _, vv := range dataValues {
+ if v == vv {
+ found = true
+ break
+ }
+ }
+ if !found {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/match/ip/address[.=%v]", v))
+ }
+ }
+ }
+ }
+ if !state.Action.IsNull() && data.Action.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/action")
+ }
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletedItemsXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin getEmptyLeafsDelete
func (data *VLANAccessMap) getEmptyLeafsDelete(ctx context.Context) []string {
@@ -276,3 +455,22 @@ func (data *VLANAccessMap) getDeletePaths(ctx context.Context) []string {
}
// End of section. //template:end getDeletePaths
+
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletePathsXML
+
+func (data *VLANAccessMap) addDeletePathsXML(ctx context.Context, body string) string {
+ b := netconf.NewBody(body)
+ if !data.MatchIpv6Address.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/match/ipv6/address")
+ }
+ if !data.MatchIpAddress.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/match/ip/address")
+ }
+ if !data.Action.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/action")
+ }
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletePathsXML
diff --git a/internal/provider/model_iosxe_vlan_configuration.go b/internal/provider/model_iosxe_vlan_configuration.go
index 9dcdaca9..f38a72e8 100644
--- a/internal/provider/model_iosxe_vlan_configuration.go
+++ b/internal/provider/model_iosxe_vlan_configuration.go
@@ -29,6 +29,9 @@ import (
"github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/types"
+ "github.com/hashicorp/terraform-plugin-log/tflog"
+ "github.com/netascode/go-netconf"
+ "github.com/netascode/xmldot"
"github.com/tidwall/gjson"
"github.com/tidwall/sjson"
)
@@ -79,6 +82,19 @@ func (data VLANConfiguration) getPathShort() string {
return matches[1]
}
+// getXPath returns the XPath for NETCONF operations
+func (data VLANConfiguration) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/vlan/Cisco-IOS-XE-vlan:configuration[vlan-id=%v]"
+ path = fmt.Sprintf(path, fmt.Sprintf("%v", data.VlanId.ValueInt64()))
+ return path
+}
+
+func (data VLANConfigurationData) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/vlan/Cisco-IOS-XE-vlan:configuration[vlan-id=%v]"
+ path = fmt.Sprintf(path, fmt.Sprintf("%v", data.VlanId.ValueInt64()))
+ return path
+}
+
// End of section. //template:end getPath
// Section below is generated&owned by "gen/generator.go". //template:begin toBody
@@ -105,6 +121,34 @@ func (data VLANConfiguration) toBody(ctx context.Context) string {
// End of section. //template:end toBody
+// Section below is generated&owned by "gen/generator.go". //template:begin toBodyXML
+
+func (data VLANConfiguration) toBodyXML(ctx context.Context) string {
+ body := netconf.Body{}
+ if !data.VlanId.IsNull() && !data.VlanId.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/vlan-id", strconv.FormatInt(data.VlanId.ValueInt64(), 10))
+ }
+ if !data.Vni.IsNull() && !data.Vni.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/member/vni", strconv.FormatInt(data.Vni.ValueInt64(), 10))
+ }
+ if !data.AccessVfi.IsNull() && !data.AccessVfi.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/member/access-vfi", data.AccessVfi.ValueString())
+ }
+ if !data.EvpnInstance.IsNull() && !data.EvpnInstance.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/member/evpn-instance/evpn-instance", strconv.FormatInt(data.EvpnInstance.ValueInt64(), 10))
+ }
+ if !data.EvpnInstanceVni.IsNull() && !data.EvpnInstanceVni.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/member/evpn-instance/vni", strconv.FormatInt(data.EvpnInstanceVni.ValueInt64(), 10))
+ }
+ bodyString, err := body.String()
+ if err != nil {
+ tflog.Error(ctx, fmt.Sprintf("Error converting body to string: %s", err))
+ }
+ return bodyString
+}
+
+// End of section. //template:end toBodyXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBody
func (data *VLANConfiguration) updateFromBody(ctx context.Context, res gjson.Result) {
@@ -141,6 +185,38 @@ func (data *VLANConfiguration) updateFromBody(ctx context.Context, res gjson.Res
// End of section. //template:end updateFromBody
+// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBodyXML
+
+func (data *VLANConfiguration) updateFromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/vlan-id"); value.Exists() && !data.VlanId.IsNull() {
+ data.VlanId = types.Int64Value(value.Int())
+ } else {
+ data.VlanId = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/member/vni"); value.Exists() && !data.Vni.IsNull() {
+ data.Vni = types.Int64Value(value.Int())
+ } else {
+ data.Vni = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/member/access-vfi"); value.Exists() && !data.AccessVfi.IsNull() {
+ data.AccessVfi = types.StringValue(value.String())
+ } else {
+ data.AccessVfi = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/member/evpn-instance/evpn-instance"); value.Exists() && !data.EvpnInstance.IsNull() {
+ data.EvpnInstance = types.Int64Value(value.Int())
+ } else {
+ data.EvpnInstance = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/member/evpn-instance/vni"); value.Exists() && !data.EvpnInstanceVni.IsNull() {
+ data.EvpnInstanceVni = types.Int64Value(value.Int())
+ } else {
+ data.EvpnInstanceVni = types.Int64Null()
+ }
+}
+
+// End of section. //template:end updateFromBodyXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin fromBody
func (data *VLANConfiguration) fromBody(ctx context.Context, res gjson.Result) {
@@ -187,6 +263,44 @@ func (data *VLANConfigurationData) fromBody(ctx context.Context, res gjson.Resul
// End of section. //template:end fromBodyData
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyXML
+
+func (data *VLANConfiguration) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/member/vni"); value.Exists() {
+ data.Vni = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/member/access-vfi"); value.Exists() {
+ data.AccessVfi = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/member/evpn-instance/evpn-instance"); value.Exists() {
+ data.EvpnInstance = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/member/evpn-instance/vni"); value.Exists() {
+ data.EvpnInstanceVni = types.Int64Value(value.Int())
+ }
+}
+
+// End of section. //template:end fromBodyXML
+
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyDataXML
+
+func (data *VLANConfigurationData) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/member/vni"); value.Exists() {
+ data.Vni = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/member/access-vfi"); value.Exists() {
+ data.AccessVfi = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/member/evpn-instance/evpn-instance"); value.Exists() {
+ data.EvpnInstance = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/member/evpn-instance/vni"); value.Exists() {
+ data.EvpnInstanceVni = types.Int64Value(value.Int())
+ }
+}
+
+// End of section. //template:end fromBodyDataXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin getDeletedItems
func (data *VLANConfiguration) getDeletedItems(ctx context.Context, state VLANConfiguration) []string {
@@ -209,6 +323,28 @@ func (data *VLANConfiguration) getDeletedItems(ctx context.Context, state VLANCo
// End of section. //template:end getDeletedItems
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletedItemsXML
+
+func (data *VLANConfiguration) addDeletedItemsXML(ctx context.Context, state VLANConfiguration, body string) string {
+ b := netconf.NewBody(body)
+ if !state.Vni.IsNull() && data.Vni.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/member/vni")
+ }
+ if !state.AccessVfi.IsNull() && data.AccessVfi.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/member/access-vfi")
+ }
+ if !state.EvpnInstance.IsNull() && data.EvpnInstance.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/member/evpn-instance/evpn-instance")
+ }
+ if !state.EvpnInstanceVni.IsNull() && data.EvpnInstanceVni.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/member/evpn-instance/vni")
+ }
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletedItemsXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin getEmptyLeafsDelete
func (data *VLANConfiguration) getEmptyLeafsDelete(ctx context.Context) []string {
@@ -240,3 +376,25 @@ func (data *VLANConfiguration) getDeletePaths(ctx context.Context) []string {
}
// End of section. //template:end getDeletePaths
+
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletePathsXML
+
+func (data *VLANConfiguration) addDeletePathsXML(ctx context.Context, body string) string {
+ b := netconf.NewBody(body)
+ if !data.Vni.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/member/vni")
+ }
+ if !data.AccessVfi.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/member/access-vfi")
+ }
+ if !data.EvpnInstance.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/member/evpn-instance/evpn-instance")
+ }
+ if !data.EvpnInstanceVni.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/member/evpn-instance/vni")
+ }
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletePathsXML
diff --git a/internal/provider/model_iosxe_vlan_filter.go b/internal/provider/model_iosxe_vlan_filter.go
index be7a91c5..aaaacb33 100644
--- a/internal/provider/model_iosxe_vlan_filter.go
+++ b/internal/provider/model_iosxe_vlan_filter.go
@@ -28,6 +28,9 @@ import (
"github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/types"
+ "github.com/hashicorp/terraform-plugin-log/tflog"
+ "github.com/netascode/go-netconf"
+ "github.com/netascode/xmldot"
"github.com/tidwall/gjson"
"github.com/tidwall/sjson"
)
@@ -72,6 +75,19 @@ func (data VLANFilter) getPathShort() string {
return matches[1]
}
+// getXPath returns the XPath for NETCONF operations
+func (data VLANFilter) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/vlan/Cisco-IOS-XE-vlan:filter[word=%s]"
+ path = fmt.Sprintf(path, fmt.Sprintf("%v", data.Word.ValueString()))
+ return path
+}
+
+func (data VLANFilterData) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/vlan/Cisco-IOS-XE-vlan:filter[word=%s]"
+ path = fmt.Sprintf(path, fmt.Sprintf("%v", data.Word.ValueString()))
+ return path
+}
+
// End of section. //template:end getPath
// Section below is generated&owned by "gen/generator.go". //template:begin toBody
@@ -91,6 +107,29 @@ func (data VLANFilter) toBody(ctx context.Context) string {
// End of section. //template:end toBody
+// Section below is generated&owned by "gen/generator.go". //template:begin toBodyXML
+
+func (data VLANFilter) toBodyXML(ctx context.Context) string {
+ body := netconf.Body{}
+ if !data.Word.IsNull() && !data.Word.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/word", data.Word.ValueString())
+ }
+ if !data.VlanLists.IsNull() && !data.VlanLists.IsUnknown() {
+ var values []int
+ data.VlanLists.ElementsAs(ctx, &values, false)
+ for _, v := range values {
+ body = helpers.AppendFromXPath(body, data.getXPath()+"/vlan-lists", v)
+ }
+ }
+ bodyString, err := body.String()
+ if err != nil {
+ tflog.Error(ctx, fmt.Sprintf("Error converting body to string: %s", err))
+ }
+ return bodyString
+}
+
+// End of section. //template:end toBodyXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBody
func (data *VLANFilter) updateFromBody(ctx context.Context, res gjson.Result) {
@@ -112,6 +151,23 @@ func (data *VLANFilter) updateFromBody(ctx context.Context, res gjson.Result) {
// End of section. //template:end updateFromBody
+// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBodyXML
+
+func (data *VLANFilter) updateFromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/word"); value.Exists() && !data.Word.IsNull() {
+ data.Word = types.StringValue(value.String())
+ } else {
+ data.Word = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/vlan-lists"); value.Exists() && !data.VlanLists.IsNull() {
+ data.VlanLists = helpers.GetInt64ListXML(value.Array())
+ } else {
+ data.VlanLists = types.ListNull(types.Int64Type)
+ }
+}
+
+// End of section. //template:end updateFromBodyXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin fromBody
func (data *VLANFilter) fromBody(ctx context.Context, res gjson.Result) {
@@ -144,6 +200,30 @@ func (data *VLANFilterData) fromBody(ctx context.Context, res gjson.Result) {
// End of section. //template:end fromBodyData
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyXML
+
+func (data *VLANFilter) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/vlan-lists"); value.Exists() {
+ data.VlanLists = helpers.GetInt64ListXML(value.Array())
+ } else {
+ data.VlanLists = types.ListNull(types.Int64Type)
+ }
+}
+
+// End of section. //template:end fromBodyXML
+
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyDataXML
+
+func (data *VLANFilterData) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/vlan-lists"); value.Exists() {
+ data.VlanLists = helpers.GetInt64ListXML(value.Array())
+ } else {
+ data.VlanLists = types.ListNull(types.Int64Type)
+ }
+}
+
+// End of section. //template:end fromBodyDataXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin getDeletedItems
func (data *VLANFilter) getDeletedItems(ctx context.Context, state VLANFilter) []string {
@@ -175,6 +255,37 @@ func (data *VLANFilter) getDeletedItems(ctx context.Context, state VLANFilter) [
// End of section. //template:end getDeletedItems
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletedItemsXML
+
+func (data *VLANFilter) addDeletedItemsXML(ctx context.Context, state VLANFilter, body string) string {
+ b := netconf.NewBody(body)
+ if !state.VlanLists.IsNull() {
+ if data.VlanLists.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/vlan-lists")
+ } else {
+ var dataValues, stateValues []int
+ data.VlanLists.ElementsAs(ctx, &dataValues, false)
+ state.VlanLists.ElementsAs(ctx, &stateValues, false)
+ for _, v := range stateValues {
+ found := false
+ for _, vv := range dataValues {
+ if v == vv {
+ found = true
+ break
+ }
+ }
+ if !found {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/vlan-lists[.=%v]", v))
+ }
+ }
+ }
+ }
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletedItemsXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin getEmptyLeafsDelete
func (data *VLANFilter) getEmptyLeafsDelete(ctx context.Context) []string {
@@ -197,3 +308,16 @@ func (data *VLANFilter) getDeletePaths(ctx context.Context) []string {
}
// End of section. //template:end getDeletePaths
+
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletePathsXML
+
+func (data *VLANFilter) addDeletePathsXML(ctx context.Context, body string) string {
+ b := netconf.NewBody(body)
+ if !data.VlanLists.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/vlan-lists")
+ }
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletePathsXML
diff --git a/internal/provider/model_iosxe_vlan_group.go b/internal/provider/model_iosxe_vlan_group.go
index eb96cc4d..cef1f149 100644
--- a/internal/provider/model_iosxe_vlan_group.go
+++ b/internal/provider/model_iosxe_vlan_group.go
@@ -28,6 +28,9 @@ import (
"github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/types"
+ "github.com/hashicorp/terraform-plugin-log/tflog"
+ "github.com/netascode/go-netconf"
+ "github.com/netascode/xmldot"
"github.com/tidwall/gjson"
"github.com/tidwall/sjson"
)
@@ -72,6 +75,19 @@ func (data VLANGroup) getPathShort() string {
return matches[1]
}
+// getXPath returns the XPath for NETCONF operations
+func (data VLANGroup) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/vlan/Cisco-IOS-XE-vlan:group[name=%s]"
+ path = fmt.Sprintf(path, fmt.Sprintf("%v", data.Name.ValueString()))
+ return path
+}
+
+func (data VLANGroupData) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/vlan/Cisco-IOS-XE-vlan:group[name=%s]"
+ path = fmt.Sprintf(path, fmt.Sprintf("%v", data.Name.ValueString()))
+ return path
+}
+
// End of section. //template:end getPath
// Section below is generated&owned by "gen/generator.go". //template:begin toBody
@@ -91,6 +107,29 @@ func (data VLANGroup) toBody(ctx context.Context) string {
// End of section. //template:end toBody
+// Section below is generated&owned by "gen/generator.go". //template:begin toBodyXML
+
+func (data VLANGroup) toBodyXML(ctx context.Context) string {
+ body := netconf.Body{}
+ if !data.Name.IsNull() && !data.Name.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/name", data.Name.ValueString())
+ }
+ if !data.VlanLists.IsNull() && !data.VlanLists.IsUnknown() {
+ var values []int
+ data.VlanLists.ElementsAs(ctx, &values, false)
+ for _, v := range values {
+ body = helpers.AppendFromXPath(body, data.getXPath()+"/vlan-lists", v)
+ }
+ }
+ bodyString, err := body.String()
+ if err != nil {
+ tflog.Error(ctx, fmt.Sprintf("Error converting body to string: %s", err))
+ }
+ return bodyString
+}
+
+// End of section. //template:end toBodyXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBody
func (data *VLANGroup) updateFromBody(ctx context.Context, res gjson.Result) {
@@ -112,6 +151,23 @@ func (data *VLANGroup) updateFromBody(ctx context.Context, res gjson.Result) {
// End of section. //template:end updateFromBody
+// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBodyXML
+
+func (data *VLANGroup) updateFromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/name"); value.Exists() && !data.Name.IsNull() {
+ data.Name = types.StringValue(value.String())
+ } else {
+ data.Name = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/vlan-lists"); value.Exists() && !data.VlanLists.IsNull() {
+ data.VlanLists = helpers.GetInt64ListXML(value.Array())
+ } else {
+ data.VlanLists = types.ListNull(types.Int64Type)
+ }
+}
+
+// End of section. //template:end updateFromBodyXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin fromBody
func (data *VLANGroup) fromBody(ctx context.Context, res gjson.Result) {
@@ -144,6 +200,30 @@ func (data *VLANGroupData) fromBody(ctx context.Context, res gjson.Result) {
// End of section. //template:end fromBodyData
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyXML
+
+func (data *VLANGroup) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/vlan-lists"); value.Exists() {
+ data.VlanLists = helpers.GetInt64ListXML(value.Array())
+ } else {
+ data.VlanLists = types.ListNull(types.Int64Type)
+ }
+}
+
+// End of section. //template:end fromBodyXML
+
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyDataXML
+
+func (data *VLANGroupData) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/vlan-lists"); value.Exists() {
+ data.VlanLists = helpers.GetInt64ListXML(value.Array())
+ } else {
+ data.VlanLists = types.ListNull(types.Int64Type)
+ }
+}
+
+// End of section. //template:end fromBodyDataXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin getDeletedItems
func (data *VLANGroup) getDeletedItems(ctx context.Context, state VLANGroup) []string {
@@ -175,6 +255,37 @@ func (data *VLANGroup) getDeletedItems(ctx context.Context, state VLANGroup) []s
// End of section. //template:end getDeletedItems
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletedItemsXML
+
+func (data *VLANGroup) addDeletedItemsXML(ctx context.Context, state VLANGroup, body string) string {
+ b := netconf.NewBody(body)
+ if !state.VlanLists.IsNull() {
+ if data.VlanLists.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/vlan-lists")
+ } else {
+ var dataValues, stateValues []int
+ data.VlanLists.ElementsAs(ctx, &dataValues, false)
+ state.VlanLists.ElementsAs(ctx, &stateValues, false)
+ for _, v := range stateValues {
+ found := false
+ for _, vv := range dataValues {
+ if v == vv {
+ found = true
+ break
+ }
+ }
+ if !found {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/vlan-lists[.=%v]", v))
+ }
+ }
+ }
+ }
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletedItemsXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin getEmptyLeafsDelete
func (data *VLANGroup) getEmptyLeafsDelete(ctx context.Context) []string {
@@ -197,3 +308,16 @@ func (data *VLANGroup) getDeletePaths(ctx context.Context) []string {
}
// End of section. //template:end getDeletePaths
+
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletePathsXML
+
+func (data *VLANGroup) addDeletePathsXML(ctx context.Context, body string) string {
+ b := netconf.NewBody(body)
+ if !data.VlanLists.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/vlan-lists")
+ }
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletePathsXML
diff --git a/internal/provider/model_iosxe_vrf.go b/internal/provider/model_iosxe_vrf.go
index 0eedefaf..65a25854 100644
--- a/internal/provider/model_iosxe_vrf.go
+++ b/internal/provider/model_iosxe_vrf.go
@@ -31,6 +31,9 @@ import (
"github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/types"
+ "github.com/hashicorp/terraform-plugin-log/tflog"
+ "github.com/netascode/go-netconf"
+ "github.com/netascode/xmldot"
"github.com/tidwall/gjson"
"github.com/tidwall/sjson"
)
@@ -140,6 +143,19 @@ func (data VRF) getPathShort() string {
return matches[1]
}
+// getXPath returns the XPath for NETCONF operations
+func (data VRF) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/vrf/definition[name=%s]"
+ path = fmt.Sprintf(path, fmt.Sprintf("%v", data.Name.ValueString()))
+ return path
+}
+
+func (data VRFData) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/vrf/definition[name=%s]"
+ path = fmt.Sprintf(path, fmt.Sprintf("%v", data.Name.ValueString()))
+ return path
+}
+
// End of section. //template:end getPath
// Section below is generated&owned by "gen/generator.go". //template:begin toBody
@@ -283,6 +299,177 @@ func (data VRF) toBody(ctx context.Context) string {
// End of section. //template:end toBody
+// Section below is generated&owned by "gen/generator.go". //template:begin toBodyXML
+
+func (data VRF) toBodyXML(ctx context.Context) string {
+ body := netconf.Body{}
+ if !data.Name.IsNull() && !data.Name.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/name", data.Name.ValueString())
+ }
+ if !data.Description.IsNull() && !data.Description.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/description", data.Description.ValueString())
+ }
+ if !data.Rd.IsNull() && !data.Rd.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/rd", data.Rd.ValueString())
+ }
+ if !data.AddressFamilyIpv4.IsNull() && !data.AddressFamilyIpv4.IsUnknown() {
+ if data.AddressFamilyIpv4.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/address-family/ipv4", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/address-family/ipv4")
+ }
+ }
+ if !data.AddressFamilyIpv6.IsNull() && !data.AddressFamilyIpv6.IsUnknown() {
+ if data.AddressFamilyIpv6.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/address-family/ipv6", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/address-family/ipv6")
+ }
+ }
+ if !data.VpnId.IsNull() && !data.VpnId.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/vpn/id", data.VpnId.ValueString())
+ }
+ if len(data.RouteTargetImport) > 0 {
+ for _, item := range data.RouteTargetImport {
+ cBody := netconf.Body{}
+ if !item.Value.IsNull() && !item.Value.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "asn-ip", item.Value.ValueString())
+ }
+ if !item.Stitching.IsNull() && !item.Stitching.IsUnknown() {
+ if item.Stitching.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "stitching", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "stitching")
+ }
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/route-target/import", cBody.Res())
+ }
+ }
+ if len(data.RouteTargetExport) > 0 {
+ for _, item := range data.RouteTargetExport {
+ cBody := netconf.Body{}
+ if !item.Value.IsNull() && !item.Value.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "asn-ip", item.Value.ValueString())
+ }
+ if !item.Stitching.IsNull() && !item.Stitching.IsUnknown() {
+ if item.Stitching.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "stitching", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "stitching")
+ }
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/route-target/export", cBody.Res())
+ }
+ }
+ if len(data.Ipv4RouteTargetImport) > 0 {
+ for _, item := range data.Ipv4RouteTargetImport {
+ cBody := netconf.Body{}
+ if !item.Value.IsNull() && !item.Value.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "asn-ip", item.Value.ValueString())
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/address-family/ipv4/route-target/import-route-target/without-stitching", cBody.Res())
+ }
+ }
+ if len(data.Ipv4RouteTargetImportStitching) > 0 {
+ for _, item := range data.Ipv4RouteTargetImportStitching {
+ cBody := netconf.Body{}
+ if !item.Value.IsNull() && !item.Value.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "asn-ip", item.Value.ValueString())
+ }
+ if !item.Stitching.IsNull() && !item.Stitching.IsUnknown() {
+ if item.Stitching.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "stitching", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "stitching")
+ }
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/address-family/ipv4/route-target/import-route-target/with-stitching", cBody.Res())
+ }
+ }
+ if len(data.Ipv4RouteTargetExport) > 0 {
+ for _, item := range data.Ipv4RouteTargetExport {
+ cBody := netconf.Body{}
+ if !item.Value.IsNull() && !item.Value.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "asn-ip", item.Value.ValueString())
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/address-family/ipv4/route-target/export-route-target/without-stitching", cBody.Res())
+ }
+ }
+ if len(data.Ipv4RouteTargetExportStitching) > 0 {
+ for _, item := range data.Ipv4RouteTargetExportStitching {
+ cBody := netconf.Body{}
+ if !item.Value.IsNull() && !item.Value.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "asn-ip", item.Value.ValueString())
+ }
+ if !item.Stitching.IsNull() && !item.Stitching.IsUnknown() {
+ if item.Stitching.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "stitching", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "stitching")
+ }
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/address-family/ipv4/route-target/export-route-target/with-stitching", cBody.Res())
+ }
+ }
+ if len(data.Ipv6RouteTargetImport) > 0 {
+ for _, item := range data.Ipv6RouteTargetImport {
+ cBody := netconf.Body{}
+ if !item.Value.IsNull() && !item.Value.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "asn-ip", item.Value.ValueString())
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/address-family/ipv6/route-target/import-route-target/without-stitching", cBody.Res())
+ }
+ }
+ if len(data.Ipv6RouteTargetImportStitching) > 0 {
+ for _, item := range data.Ipv6RouteTargetImportStitching {
+ cBody := netconf.Body{}
+ if !item.Value.IsNull() && !item.Value.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "asn-ip", item.Value.ValueString())
+ }
+ if !item.Stitching.IsNull() && !item.Stitching.IsUnknown() {
+ if item.Stitching.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "stitching", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "stitching")
+ }
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/address-family/ipv6/route-target/import-route-target/with-stitching", cBody.Res())
+ }
+ }
+ if len(data.Ipv6RouteTargetExport) > 0 {
+ for _, item := range data.Ipv6RouteTargetExport {
+ cBody := netconf.Body{}
+ if !item.Value.IsNull() && !item.Value.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "asn-ip", item.Value.ValueString())
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/address-family/ipv6/route-target/export-route-target/without-stitching", cBody.Res())
+ }
+ }
+ if len(data.Ipv6RouteTargetExportStitching) > 0 {
+ for _, item := range data.Ipv6RouteTargetExportStitching {
+ cBody := netconf.Body{}
+ if !item.Value.IsNull() && !item.Value.IsUnknown() {
+ cBody = helpers.SetFromXPath(cBody, "asn-ip", item.Value.ValueString())
+ }
+ if !item.Stitching.IsNull() && !item.Stitching.IsUnknown() {
+ if item.Stitching.ValueBool() {
+ cBody = helpers.SetFromXPath(cBody, "stitching", "")
+ } else {
+ cBody = helpers.RemoveFromXPath(cBody, "stitching")
+ }
+ }
+ body = helpers.SetRawFromXPath(body, data.getXPath()+"/address-family/ipv6/route-target/export-route-target/with-stitching", cBody.Res())
+ }
+ }
+ bodyString, err := body.String()
+ if err != nil {
+ tflog.Error(ctx, fmt.Sprintf("Error converting body to string: %s", err))
+ }
+ return bodyString
+}
+
+// End of section. //template:end toBodyXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBody
func (data *VRF) updateFromBody(ctx context.Context, res gjson.Result) {
@@ -676,83 +863,974 @@ func (data *VRF) updateFromBody(ctx context.Context, res gjson.Result) {
// End of section. //template:end updateFromBody
-// Section below is generated&owned by "gen/generator.go". //template:begin fromBody
+// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBodyXML
-func (data *VRF) fromBody(ctx context.Context, res gjson.Result) {
- prefix := helpers.LastElement(data.getPath()) + "."
- if res.Get(helpers.LastElement(data.getPath())).IsArray() {
- prefix += "0."
+func (data *VRF) updateFromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/name"); value.Exists() && !data.Name.IsNull() {
+ data.Name = types.StringValue(value.String())
+ } else {
+ data.Name = types.StringNull()
}
- if value := res.Get(prefix + "description"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/description"); value.Exists() && !data.Description.IsNull() {
data.Description = types.StringValue(value.String())
+ } else {
+ data.Description = types.StringNull()
}
- if value := res.Get(prefix + "rd"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/rd"); value.Exists() && !data.Rd.IsNull() {
data.Rd = types.StringValue(value.String())
+ } else {
+ data.Rd = types.StringNull()
}
- if value := res.Get(prefix + "address-family.ipv4"); value.Exists() {
- data.AddressFamilyIpv4 = types.BoolValue(true)
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/address-family/ipv4"); !data.AddressFamilyIpv4.IsNull() {
+ if value.Exists() {
+ data.AddressFamilyIpv4 = types.BoolValue(true)
+ } else {
+ data.AddressFamilyIpv4 = types.BoolValue(false)
+ }
} else {
- data.AddressFamilyIpv4 = types.BoolValue(false)
+ data.AddressFamilyIpv4 = types.BoolNull()
}
- if value := res.Get(prefix + "address-family.ipv6"); value.Exists() {
- data.AddressFamilyIpv6 = types.BoolValue(true)
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/address-family/ipv6"); !data.AddressFamilyIpv6.IsNull() {
+ if value.Exists() {
+ data.AddressFamilyIpv6 = types.BoolValue(true)
+ } else {
+ data.AddressFamilyIpv6 = types.BoolValue(false)
+ }
} else {
- data.AddressFamilyIpv6 = types.BoolValue(false)
+ data.AddressFamilyIpv6 = types.BoolNull()
}
- if value := res.Get(prefix + "vpn.id"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/vpn/id"); value.Exists() && !data.VpnId.IsNull() {
data.VpnId = types.StringValue(value.String())
+ } else {
+ data.VpnId = types.StringNull()
}
- if value := res.Get(prefix + "route-target.import"); value.Exists() {
- data.RouteTargetImport = make([]VRFRouteTargetImport, 0)
- value.ForEach(func(k, v gjson.Result) bool {
- item := VRFRouteTargetImport{}
- if cValue := v.Get("asn-ip"); cValue.Exists() {
- item.Value = types.StringValue(cValue.String())
- }
- if cValue := v.Get("stitching"); cValue.Exists() {
- item.Stitching = types.BoolValue(true)
+ for i := range data.RouteTargetImport {
+ keys := [...]string{"asn-ip"}
+ keyValues := [...]string{data.RouteTargetImport[i].Value.ValueString()}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/route-target/import").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, "asn-ip"); value.Exists() && !data.RouteTargetImport[i].Value.IsNull() {
+ data.RouteTargetImport[i].Value = types.StringValue(value.String())
+ } else {
+ data.RouteTargetImport[i].Value = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "stitching"); !data.RouteTargetImport[i].Stitching.IsNull() {
+ if value.Exists() {
+ data.RouteTargetImport[i].Stitching = types.BoolValue(true)
} else {
- item.Stitching = types.BoolValue(false)
+ data.RouteTargetImport[i].Stitching = types.BoolValue(false)
}
- data.RouteTargetImport = append(data.RouteTargetImport, item)
- return true
- })
+ } else {
+ data.RouteTargetImport[i].Stitching = types.BoolNull()
+ }
}
- if value := res.Get(prefix + "route-target.export"); value.Exists() {
- data.RouteTargetExport = make([]VRFRouteTargetExport, 0)
- value.ForEach(func(k, v gjson.Result) bool {
- item := VRFRouteTargetExport{}
- if cValue := v.Get("asn-ip"); cValue.Exists() {
- item.Value = types.StringValue(cValue.String())
- }
- if cValue := v.Get("stitching"); cValue.Exists() {
- item.Stitching = types.BoolValue(true)
+ for i := range data.RouteTargetExport {
+ keys := [...]string{"asn-ip"}
+ keyValues := [...]string{data.RouteTargetExport[i].Value.ValueString()}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/route-target/export").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, "asn-ip"); value.Exists() && !data.RouteTargetExport[i].Value.IsNull() {
+ data.RouteTargetExport[i].Value = types.StringValue(value.String())
+ } else {
+ data.RouteTargetExport[i].Value = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "stitching"); !data.RouteTargetExport[i].Stitching.IsNull() {
+ if value.Exists() {
+ data.RouteTargetExport[i].Stitching = types.BoolValue(true)
} else {
- item.Stitching = types.BoolValue(false)
+ data.RouteTargetExport[i].Stitching = types.BoolValue(false)
}
- data.RouteTargetExport = append(data.RouteTargetExport, item)
- return true
- })
+ } else {
+ data.RouteTargetExport[i].Stitching = types.BoolNull()
+ }
}
- if value := res.Get(prefix + "address-family.ipv4.route-target.import-route-target.without-stitching"); value.Exists() {
- data.Ipv4RouteTargetImport = make([]VRFIpv4RouteTargetImport, 0)
- value.ForEach(func(k, v gjson.Result) bool {
- item := VRFIpv4RouteTargetImport{}
- if cValue := v.Get("asn-ip"); cValue.Exists() {
- item.Value = types.StringValue(cValue.String())
- }
- data.Ipv4RouteTargetImport = append(data.Ipv4RouteTargetImport, item)
- return true
- })
+ for i := range data.Ipv4RouteTargetImport {
+ keys := [...]string{"asn-ip"}
+ keyValues := [...]string{data.Ipv4RouteTargetImport[i].Value.ValueString()}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/address-family/ipv4/route-target/import-route-target/without-stitching").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, "asn-ip"); value.Exists() && !data.Ipv4RouteTargetImport[i].Value.IsNull() {
+ data.Ipv4RouteTargetImport[i].Value = types.StringValue(value.String())
+ } else {
+ data.Ipv4RouteTargetImport[i].Value = types.StringNull()
+ }
+ }
+ for i := range data.Ipv4RouteTargetImportStitching {
+ keys := [...]string{"asn-ip"}
+ keyValues := [...]string{data.Ipv4RouteTargetImportStitching[i].Value.ValueString()}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/address-family/ipv4/route-target/import-route-target/with-stitching").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, "asn-ip"); value.Exists() && !data.Ipv4RouteTargetImportStitching[i].Value.IsNull() {
+ data.Ipv4RouteTargetImportStitching[i].Value = types.StringValue(value.String())
+ } else {
+ data.Ipv4RouteTargetImportStitching[i].Value = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "stitching"); !data.Ipv4RouteTargetImportStitching[i].Stitching.IsNull() {
+ if value.Exists() {
+ data.Ipv4RouteTargetImportStitching[i].Stitching = types.BoolValue(true)
+ } else {
+ data.Ipv4RouteTargetImportStitching[i].Stitching = types.BoolValue(false)
+ }
+ } else {
+ data.Ipv4RouteTargetImportStitching[i].Stitching = types.BoolNull()
+ }
+ }
+ for i := range data.Ipv4RouteTargetExport {
+ keys := [...]string{"asn-ip"}
+ keyValues := [...]string{data.Ipv4RouteTargetExport[i].Value.ValueString()}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/address-family/ipv4/route-target/export-route-target/without-stitching").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, "asn-ip"); value.Exists() && !data.Ipv4RouteTargetExport[i].Value.IsNull() {
+ data.Ipv4RouteTargetExport[i].Value = types.StringValue(value.String())
+ } else {
+ data.Ipv4RouteTargetExport[i].Value = types.StringNull()
+ }
+ }
+ for i := range data.Ipv4RouteTargetExportStitching {
+ keys := [...]string{"asn-ip"}
+ keyValues := [...]string{data.Ipv4RouteTargetExportStitching[i].Value.ValueString()}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/address-family/ipv4/route-target/export-route-target/with-stitching").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, "asn-ip"); value.Exists() && !data.Ipv4RouteTargetExportStitching[i].Value.IsNull() {
+ data.Ipv4RouteTargetExportStitching[i].Value = types.StringValue(value.String())
+ } else {
+ data.Ipv4RouteTargetExportStitching[i].Value = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "stitching"); !data.Ipv4RouteTargetExportStitching[i].Stitching.IsNull() {
+ if value.Exists() {
+ data.Ipv4RouteTargetExportStitching[i].Stitching = types.BoolValue(true)
+ } else {
+ data.Ipv4RouteTargetExportStitching[i].Stitching = types.BoolValue(false)
+ }
+ } else {
+ data.Ipv4RouteTargetExportStitching[i].Stitching = types.BoolNull()
+ }
+ }
+ for i := range data.Ipv6RouteTargetImport {
+ keys := [...]string{"asn-ip"}
+ keyValues := [...]string{data.Ipv6RouteTargetImport[i].Value.ValueString()}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/address-family/ipv6/route-target/import-route-target/without-stitching").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, "asn-ip"); value.Exists() && !data.Ipv6RouteTargetImport[i].Value.IsNull() {
+ data.Ipv6RouteTargetImport[i].Value = types.StringValue(value.String())
+ } else {
+ data.Ipv6RouteTargetImport[i].Value = types.StringNull()
+ }
+ }
+ for i := range data.Ipv6RouteTargetImportStitching {
+ keys := [...]string{"asn-ip"}
+ keyValues := [...]string{data.Ipv6RouteTargetImportStitching[i].Value.ValueString()}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/address-family/ipv6/route-target/import-route-target/with-stitching").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, "asn-ip"); value.Exists() && !data.Ipv6RouteTargetImportStitching[i].Value.IsNull() {
+ data.Ipv6RouteTargetImportStitching[i].Value = types.StringValue(value.String())
+ } else {
+ data.Ipv6RouteTargetImportStitching[i].Value = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "stitching"); !data.Ipv6RouteTargetImportStitching[i].Stitching.IsNull() {
+ if value.Exists() {
+ data.Ipv6RouteTargetImportStitching[i].Stitching = types.BoolValue(true)
+ } else {
+ data.Ipv6RouteTargetImportStitching[i].Stitching = types.BoolValue(false)
+ }
+ } else {
+ data.Ipv6RouteTargetImportStitching[i].Stitching = types.BoolNull()
+ }
+ }
+ for i := range data.Ipv6RouteTargetExport {
+ keys := [...]string{"asn-ip"}
+ keyValues := [...]string{data.Ipv6RouteTargetExport[i].Value.ValueString()}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/address-family/ipv6/route-target/export-route-target/without-stitching").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, "asn-ip"); value.Exists() && !data.Ipv6RouteTargetExport[i].Value.IsNull() {
+ data.Ipv6RouteTargetExport[i].Value = types.StringValue(value.String())
+ } else {
+ data.Ipv6RouteTargetExport[i].Value = types.StringNull()
+ }
+ }
+ for i := range data.Ipv6RouteTargetExportStitching {
+ keys := [...]string{"asn-ip"}
+ keyValues := [...]string{data.Ipv6RouteTargetExportStitching[i].Value.ValueString()}
+
+ var r xmldot.Result
+ helpers.GetFromXPath(res, "data/"+data.getXPath()+"/address-family/ipv6/route-target/export-route-target/with-stitching").ForEach(
+ func(_ int, v xmldot.Result) bool {
+ found := false
+ for ik := range keys {
+ if v.Get(keys[ik]).String() == keyValues[ik] {
+ found = true
+ continue
+ }
+ found = false
+ break
+ }
+ if found {
+ r = v
+ return false
+ }
+ return true
+ },
+ )
+ if value := helpers.GetFromXPath(r, "asn-ip"); value.Exists() && !data.Ipv6RouteTargetExportStitching[i].Value.IsNull() {
+ data.Ipv6RouteTargetExportStitching[i].Value = types.StringValue(value.String())
+ } else {
+ data.Ipv6RouteTargetExportStitching[i].Value = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(r, "stitching"); !data.Ipv6RouteTargetExportStitching[i].Stitching.IsNull() {
+ if value.Exists() {
+ data.Ipv6RouteTargetExportStitching[i].Stitching = types.BoolValue(true)
+ } else {
+ data.Ipv6RouteTargetExportStitching[i].Stitching = types.BoolValue(false)
+ }
+ } else {
+ data.Ipv6RouteTargetExportStitching[i].Stitching = types.BoolNull()
+ }
+ }
+}
+
+// End of section. //template:end updateFromBodyXML
+
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBody
+
+func (data *VRF) fromBody(ctx context.Context, res gjson.Result) {
+ prefix := helpers.LastElement(data.getPath()) + "."
+ if res.Get(helpers.LastElement(data.getPath())).IsArray() {
+ prefix += "0."
+ }
+ if value := res.Get(prefix + "description"); value.Exists() {
+ data.Description = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "rd"); value.Exists() {
+ data.Rd = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "address-family.ipv4"); value.Exists() {
+ data.AddressFamilyIpv4 = types.BoolValue(true)
+ } else {
+ data.AddressFamilyIpv4 = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "address-family.ipv6"); value.Exists() {
+ data.AddressFamilyIpv6 = types.BoolValue(true)
+ } else {
+ data.AddressFamilyIpv6 = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "vpn.id"); value.Exists() {
+ data.VpnId = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "route-target.import"); value.Exists() {
+ data.RouteTargetImport = make([]VRFRouteTargetImport, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := VRFRouteTargetImport{}
+ if cValue := v.Get("asn-ip"); cValue.Exists() {
+ item.Value = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("stitching"); cValue.Exists() {
+ item.Stitching = types.BoolValue(true)
+ } else {
+ item.Stitching = types.BoolValue(false)
+ }
+ data.RouteTargetImport = append(data.RouteTargetImport, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + "route-target.export"); value.Exists() {
+ data.RouteTargetExport = make([]VRFRouteTargetExport, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := VRFRouteTargetExport{}
+ if cValue := v.Get("asn-ip"); cValue.Exists() {
+ item.Value = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("stitching"); cValue.Exists() {
+ item.Stitching = types.BoolValue(true)
+ } else {
+ item.Stitching = types.BoolValue(false)
+ }
+ data.RouteTargetExport = append(data.RouteTargetExport, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + "address-family.ipv4.route-target.import-route-target.without-stitching"); value.Exists() {
+ data.Ipv4RouteTargetImport = make([]VRFIpv4RouteTargetImport, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := VRFIpv4RouteTargetImport{}
+ if cValue := v.Get("asn-ip"); cValue.Exists() {
+ item.Value = types.StringValue(cValue.String())
+ }
+ data.Ipv4RouteTargetImport = append(data.Ipv4RouteTargetImport, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + "address-family.ipv4.route-target.import-route-target.with-stitching"); value.Exists() {
+ data.Ipv4RouteTargetImportStitching = make([]VRFIpv4RouteTargetImportStitching, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := VRFIpv4RouteTargetImportStitching{}
+ if cValue := v.Get("asn-ip"); cValue.Exists() {
+ item.Value = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("stitching"); cValue.Exists() {
+ item.Stitching = types.BoolValue(true)
+ } else {
+ item.Stitching = types.BoolValue(false)
+ }
+ data.Ipv4RouteTargetImportStitching = append(data.Ipv4RouteTargetImportStitching, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + "address-family.ipv4.route-target.export-route-target.without-stitching"); value.Exists() {
+ data.Ipv4RouteTargetExport = make([]VRFIpv4RouteTargetExport, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := VRFIpv4RouteTargetExport{}
+ if cValue := v.Get("asn-ip"); cValue.Exists() {
+ item.Value = types.StringValue(cValue.String())
+ }
+ data.Ipv4RouteTargetExport = append(data.Ipv4RouteTargetExport, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + "address-family.ipv4.route-target.export-route-target.with-stitching"); value.Exists() {
+ data.Ipv4RouteTargetExportStitching = make([]VRFIpv4RouteTargetExportStitching, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := VRFIpv4RouteTargetExportStitching{}
+ if cValue := v.Get("asn-ip"); cValue.Exists() {
+ item.Value = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("stitching"); cValue.Exists() {
+ item.Stitching = types.BoolValue(true)
+ } else {
+ item.Stitching = types.BoolValue(false)
+ }
+ data.Ipv4RouteTargetExportStitching = append(data.Ipv4RouteTargetExportStitching, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + "address-family.ipv6.route-target.import-route-target.without-stitching"); value.Exists() {
+ data.Ipv6RouteTargetImport = make([]VRFIpv6RouteTargetImport, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := VRFIpv6RouteTargetImport{}
+ if cValue := v.Get("asn-ip"); cValue.Exists() {
+ item.Value = types.StringValue(cValue.String())
+ }
+ data.Ipv6RouteTargetImport = append(data.Ipv6RouteTargetImport, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + "address-family.ipv6.route-target.import-route-target.with-stitching"); value.Exists() {
+ data.Ipv6RouteTargetImportStitching = make([]VRFIpv6RouteTargetImportStitching, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := VRFIpv6RouteTargetImportStitching{}
+ if cValue := v.Get("asn-ip"); cValue.Exists() {
+ item.Value = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("stitching"); cValue.Exists() {
+ item.Stitching = types.BoolValue(true)
+ } else {
+ item.Stitching = types.BoolValue(false)
+ }
+ data.Ipv6RouteTargetImportStitching = append(data.Ipv6RouteTargetImportStitching, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + "address-family.ipv6.route-target.export-route-target.without-stitching"); value.Exists() {
+ data.Ipv6RouteTargetExport = make([]VRFIpv6RouteTargetExport, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := VRFIpv6RouteTargetExport{}
+ if cValue := v.Get("asn-ip"); cValue.Exists() {
+ item.Value = types.StringValue(cValue.String())
+ }
+ data.Ipv6RouteTargetExport = append(data.Ipv6RouteTargetExport, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + "address-family.ipv6.route-target.export-route-target.with-stitching"); value.Exists() {
+ data.Ipv6RouteTargetExportStitching = make([]VRFIpv6RouteTargetExportStitching, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := VRFIpv6RouteTargetExportStitching{}
+ if cValue := v.Get("asn-ip"); cValue.Exists() {
+ item.Value = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("stitching"); cValue.Exists() {
+ item.Stitching = types.BoolValue(true)
+ } else {
+ item.Stitching = types.BoolValue(false)
+ }
+ data.Ipv6RouteTargetExportStitching = append(data.Ipv6RouteTargetExportStitching, item)
+ return true
+ })
+ }
+}
+
+// End of section. //template:end fromBody
+
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyData
+
+func (data *VRFData) fromBody(ctx context.Context, res gjson.Result) {
+ prefix := helpers.LastElement(data.getPath()) + "."
+ if res.Get(helpers.LastElement(data.getPath())).IsArray() {
+ prefix += "0."
+ }
+ if value := res.Get(prefix + "description"); value.Exists() {
+ data.Description = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "rd"); value.Exists() {
+ data.Rd = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "address-family.ipv4"); value.Exists() {
+ data.AddressFamilyIpv4 = types.BoolValue(true)
+ } else {
+ data.AddressFamilyIpv4 = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "address-family.ipv6"); value.Exists() {
+ data.AddressFamilyIpv6 = types.BoolValue(true)
+ } else {
+ data.AddressFamilyIpv6 = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "vpn.id"); value.Exists() {
+ data.VpnId = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "route-target.import"); value.Exists() {
+ data.RouteTargetImport = make([]VRFRouteTargetImport, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := VRFRouteTargetImport{}
+ if cValue := v.Get("asn-ip"); cValue.Exists() {
+ item.Value = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("stitching"); cValue.Exists() {
+ item.Stitching = types.BoolValue(true)
+ } else {
+ item.Stitching = types.BoolValue(false)
+ }
+ data.RouteTargetImport = append(data.RouteTargetImport, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + "route-target.export"); value.Exists() {
+ data.RouteTargetExport = make([]VRFRouteTargetExport, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := VRFRouteTargetExport{}
+ if cValue := v.Get("asn-ip"); cValue.Exists() {
+ item.Value = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("stitching"); cValue.Exists() {
+ item.Stitching = types.BoolValue(true)
+ } else {
+ item.Stitching = types.BoolValue(false)
+ }
+ data.RouteTargetExport = append(data.RouteTargetExport, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + "address-family.ipv4.route-target.import-route-target.without-stitching"); value.Exists() {
+ data.Ipv4RouteTargetImport = make([]VRFIpv4RouteTargetImport, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := VRFIpv4RouteTargetImport{}
+ if cValue := v.Get("asn-ip"); cValue.Exists() {
+ item.Value = types.StringValue(cValue.String())
+ }
+ data.Ipv4RouteTargetImport = append(data.Ipv4RouteTargetImport, item)
+ return true
+ })
}
if value := res.Get(prefix + "address-family.ipv4.route-target.import-route-target.with-stitching"); value.Exists() {
data.Ipv4RouteTargetImportStitching = make([]VRFIpv4RouteTargetImportStitching, 0)
- value.ForEach(func(k, v gjson.Result) bool {
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := VRFIpv4RouteTargetImportStitching{}
+ if cValue := v.Get("asn-ip"); cValue.Exists() {
+ item.Value = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("stitching"); cValue.Exists() {
+ item.Stitching = types.BoolValue(true)
+ } else {
+ item.Stitching = types.BoolValue(false)
+ }
+ data.Ipv4RouteTargetImportStitching = append(data.Ipv4RouteTargetImportStitching, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + "address-family.ipv4.route-target.export-route-target.without-stitching"); value.Exists() {
+ data.Ipv4RouteTargetExport = make([]VRFIpv4RouteTargetExport, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := VRFIpv4RouteTargetExport{}
+ if cValue := v.Get("asn-ip"); cValue.Exists() {
+ item.Value = types.StringValue(cValue.String())
+ }
+ data.Ipv4RouteTargetExport = append(data.Ipv4RouteTargetExport, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + "address-family.ipv4.route-target.export-route-target.with-stitching"); value.Exists() {
+ data.Ipv4RouteTargetExportStitching = make([]VRFIpv4RouteTargetExportStitching, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := VRFIpv4RouteTargetExportStitching{}
+ if cValue := v.Get("asn-ip"); cValue.Exists() {
+ item.Value = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("stitching"); cValue.Exists() {
+ item.Stitching = types.BoolValue(true)
+ } else {
+ item.Stitching = types.BoolValue(false)
+ }
+ data.Ipv4RouteTargetExportStitching = append(data.Ipv4RouteTargetExportStitching, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + "address-family.ipv6.route-target.import-route-target.without-stitching"); value.Exists() {
+ data.Ipv6RouteTargetImport = make([]VRFIpv6RouteTargetImport, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := VRFIpv6RouteTargetImport{}
+ if cValue := v.Get("asn-ip"); cValue.Exists() {
+ item.Value = types.StringValue(cValue.String())
+ }
+ data.Ipv6RouteTargetImport = append(data.Ipv6RouteTargetImport, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + "address-family.ipv6.route-target.import-route-target.with-stitching"); value.Exists() {
+ data.Ipv6RouteTargetImportStitching = make([]VRFIpv6RouteTargetImportStitching, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := VRFIpv6RouteTargetImportStitching{}
+ if cValue := v.Get("asn-ip"); cValue.Exists() {
+ item.Value = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("stitching"); cValue.Exists() {
+ item.Stitching = types.BoolValue(true)
+ } else {
+ item.Stitching = types.BoolValue(false)
+ }
+ data.Ipv6RouteTargetImportStitching = append(data.Ipv6RouteTargetImportStitching, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + "address-family.ipv6.route-target.export-route-target.without-stitching"); value.Exists() {
+ data.Ipv6RouteTargetExport = make([]VRFIpv6RouteTargetExport, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := VRFIpv6RouteTargetExport{}
+ if cValue := v.Get("asn-ip"); cValue.Exists() {
+ item.Value = types.StringValue(cValue.String())
+ }
+ data.Ipv6RouteTargetExport = append(data.Ipv6RouteTargetExport, item)
+ return true
+ })
+ }
+ if value := res.Get(prefix + "address-family.ipv6.route-target.export-route-target.with-stitching"); value.Exists() {
+ data.Ipv6RouteTargetExportStitching = make([]VRFIpv6RouteTargetExportStitching, 0)
+ value.ForEach(func(k, v gjson.Result) bool {
+ item := VRFIpv6RouteTargetExportStitching{}
+ if cValue := v.Get("asn-ip"); cValue.Exists() {
+ item.Value = types.StringValue(cValue.String())
+ }
+ if cValue := v.Get("stitching"); cValue.Exists() {
+ item.Stitching = types.BoolValue(true)
+ } else {
+ item.Stitching = types.BoolValue(false)
+ }
+ data.Ipv6RouteTargetExportStitching = append(data.Ipv6RouteTargetExportStitching, item)
+ return true
+ })
+ }
+}
+
+// End of section. //template:end fromBodyData
+
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyXML
+
+func (data *VRF) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/description"); value.Exists() {
+ data.Description = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/rd"); value.Exists() {
+ data.Rd = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/address-family/ipv4"); value.Exists() {
+ data.AddressFamilyIpv4 = types.BoolValue(true)
+ } else {
+ data.AddressFamilyIpv4 = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/address-family/ipv6"); value.Exists() {
+ data.AddressFamilyIpv6 = types.BoolValue(true)
+ } else {
+ data.AddressFamilyIpv6 = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/vpn/id"); value.Exists() {
+ data.VpnId = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/route-target/import"); value.Exists() {
+ data.RouteTargetImport = make([]VRFRouteTargetImport, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := VRFRouteTargetImport{}
+ if cValue := helpers.GetFromXPath(v, "asn-ip"); cValue.Exists() {
+ item.Value = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "stitching"); cValue.Exists() {
+ item.Stitching = types.BoolValue(true)
+ } else {
+ item.Stitching = types.BoolValue(false)
+ }
+ data.RouteTargetImport = append(data.RouteTargetImport, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/route-target/export"); value.Exists() {
+ data.RouteTargetExport = make([]VRFRouteTargetExport, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := VRFRouteTargetExport{}
+ if cValue := helpers.GetFromXPath(v, "asn-ip"); cValue.Exists() {
+ item.Value = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "stitching"); cValue.Exists() {
+ item.Stitching = types.BoolValue(true)
+ } else {
+ item.Stitching = types.BoolValue(false)
+ }
+ data.RouteTargetExport = append(data.RouteTargetExport, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/address-family/ipv4/route-target/import-route-target/without-stitching"); value.Exists() {
+ data.Ipv4RouteTargetImport = make([]VRFIpv4RouteTargetImport, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := VRFIpv4RouteTargetImport{}
+ if cValue := helpers.GetFromXPath(v, "asn-ip"); cValue.Exists() {
+ item.Value = types.StringValue(cValue.String())
+ }
+ data.Ipv4RouteTargetImport = append(data.Ipv4RouteTargetImport, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/address-family/ipv4/route-target/import-route-target/with-stitching"); value.Exists() {
+ data.Ipv4RouteTargetImportStitching = make([]VRFIpv4RouteTargetImportStitching, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := VRFIpv4RouteTargetImportStitching{}
+ if cValue := helpers.GetFromXPath(v, "asn-ip"); cValue.Exists() {
+ item.Value = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "stitching"); cValue.Exists() {
+ item.Stitching = types.BoolValue(true)
+ } else {
+ item.Stitching = types.BoolValue(false)
+ }
+ data.Ipv4RouteTargetImportStitching = append(data.Ipv4RouteTargetImportStitching, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/address-family/ipv4/route-target/export-route-target/without-stitching"); value.Exists() {
+ data.Ipv4RouteTargetExport = make([]VRFIpv4RouteTargetExport, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := VRFIpv4RouteTargetExport{}
+ if cValue := helpers.GetFromXPath(v, "asn-ip"); cValue.Exists() {
+ item.Value = types.StringValue(cValue.String())
+ }
+ data.Ipv4RouteTargetExport = append(data.Ipv4RouteTargetExport, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/address-family/ipv4/route-target/export-route-target/with-stitching"); value.Exists() {
+ data.Ipv4RouteTargetExportStitching = make([]VRFIpv4RouteTargetExportStitching, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := VRFIpv4RouteTargetExportStitching{}
+ if cValue := helpers.GetFromXPath(v, "asn-ip"); cValue.Exists() {
+ item.Value = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "stitching"); cValue.Exists() {
+ item.Stitching = types.BoolValue(true)
+ } else {
+ item.Stitching = types.BoolValue(false)
+ }
+ data.Ipv4RouteTargetExportStitching = append(data.Ipv4RouteTargetExportStitching, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/address-family/ipv6/route-target/import-route-target/without-stitching"); value.Exists() {
+ data.Ipv6RouteTargetImport = make([]VRFIpv6RouteTargetImport, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := VRFIpv6RouteTargetImport{}
+ if cValue := helpers.GetFromXPath(v, "asn-ip"); cValue.Exists() {
+ item.Value = types.StringValue(cValue.String())
+ }
+ data.Ipv6RouteTargetImport = append(data.Ipv6RouteTargetImport, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/address-family/ipv6/route-target/import-route-target/with-stitching"); value.Exists() {
+ data.Ipv6RouteTargetImportStitching = make([]VRFIpv6RouteTargetImportStitching, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := VRFIpv6RouteTargetImportStitching{}
+ if cValue := helpers.GetFromXPath(v, "asn-ip"); cValue.Exists() {
+ item.Value = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "stitching"); cValue.Exists() {
+ item.Stitching = types.BoolValue(true)
+ } else {
+ item.Stitching = types.BoolValue(false)
+ }
+ data.Ipv6RouteTargetImportStitching = append(data.Ipv6RouteTargetImportStitching, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/address-family/ipv6/route-target/export-route-target/without-stitching"); value.Exists() {
+ data.Ipv6RouteTargetExport = make([]VRFIpv6RouteTargetExport, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := VRFIpv6RouteTargetExport{}
+ if cValue := helpers.GetFromXPath(v, "asn-ip"); cValue.Exists() {
+ item.Value = types.StringValue(cValue.String())
+ }
+ data.Ipv6RouteTargetExport = append(data.Ipv6RouteTargetExport, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/address-family/ipv6/route-target/export-route-target/with-stitching"); value.Exists() {
+ data.Ipv6RouteTargetExportStitching = make([]VRFIpv6RouteTargetExportStitching, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := VRFIpv6RouteTargetExportStitching{}
+ if cValue := helpers.GetFromXPath(v, "asn-ip"); cValue.Exists() {
+ item.Value = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "stitching"); cValue.Exists() {
+ item.Stitching = types.BoolValue(true)
+ } else {
+ item.Stitching = types.BoolValue(false)
+ }
+ data.Ipv6RouteTargetExportStitching = append(data.Ipv6RouteTargetExportStitching, item)
+ return true
+ })
+ }
+}
+
+// End of section. //template:end fromBodyXML
+
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyDataXML
+
+func (data *VRFData) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/description"); value.Exists() {
+ data.Description = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/rd"); value.Exists() {
+ data.Rd = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/address-family/ipv4"); value.Exists() {
+ data.AddressFamilyIpv4 = types.BoolValue(true)
+ } else {
+ data.AddressFamilyIpv4 = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/address-family/ipv6"); value.Exists() {
+ data.AddressFamilyIpv6 = types.BoolValue(true)
+ } else {
+ data.AddressFamilyIpv6 = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/vpn/id"); value.Exists() {
+ data.VpnId = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/route-target/import"); value.Exists() {
+ data.RouteTargetImport = make([]VRFRouteTargetImport, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := VRFRouteTargetImport{}
+ if cValue := helpers.GetFromXPath(v, "asn-ip"); cValue.Exists() {
+ item.Value = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "stitching"); cValue.Exists() {
+ item.Stitching = types.BoolValue(true)
+ } else {
+ item.Stitching = types.BoolValue(false)
+ }
+ data.RouteTargetImport = append(data.RouteTargetImport, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/route-target/export"); value.Exists() {
+ data.RouteTargetExport = make([]VRFRouteTargetExport, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := VRFRouteTargetExport{}
+ if cValue := helpers.GetFromXPath(v, "asn-ip"); cValue.Exists() {
+ item.Value = types.StringValue(cValue.String())
+ }
+ if cValue := helpers.GetFromXPath(v, "stitching"); cValue.Exists() {
+ item.Stitching = types.BoolValue(true)
+ } else {
+ item.Stitching = types.BoolValue(false)
+ }
+ data.RouteTargetExport = append(data.RouteTargetExport, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/address-family/ipv4/route-target/import-route-target/without-stitching"); value.Exists() {
+ data.Ipv4RouteTargetImport = make([]VRFIpv4RouteTargetImport, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
+ item := VRFIpv4RouteTargetImport{}
+ if cValue := helpers.GetFromXPath(v, "asn-ip"); cValue.Exists() {
+ item.Value = types.StringValue(cValue.String())
+ }
+ data.Ipv4RouteTargetImport = append(data.Ipv4RouteTargetImport, item)
+ return true
+ })
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/address-family/ipv4/route-target/import-route-target/with-stitching"); value.Exists() {
+ data.Ipv4RouteTargetImportStitching = make([]VRFIpv4RouteTargetImportStitching, 0)
+ value.ForEach(func(_ int, v xmldot.Result) bool {
item := VRFIpv4RouteTargetImportStitching{}
- if cValue := v.Get("asn-ip"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "asn-ip"); cValue.Exists() {
item.Value = types.StringValue(cValue.String())
}
- if cValue := v.Get("stitching"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "stitching"); cValue.Exists() {
item.Stitching = types.BoolValue(true)
} else {
item.Stitching = types.BoolValue(false)
@@ -761,25 +1839,25 @@ func (data *VRF) fromBody(ctx context.Context, res gjson.Result) {
return true
})
}
- if value := res.Get(prefix + "address-family.ipv4.route-target.export-route-target.without-stitching"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/address-family/ipv4/route-target/export-route-target/without-stitching"); value.Exists() {
data.Ipv4RouteTargetExport = make([]VRFIpv4RouteTargetExport, 0)
- value.ForEach(func(k, v gjson.Result) bool {
+ value.ForEach(func(_ int, v xmldot.Result) bool {
item := VRFIpv4RouteTargetExport{}
- if cValue := v.Get("asn-ip"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "asn-ip"); cValue.Exists() {
item.Value = types.StringValue(cValue.String())
}
data.Ipv4RouteTargetExport = append(data.Ipv4RouteTargetExport, item)
return true
})
}
- if value := res.Get(prefix + "address-family.ipv4.route-target.export-route-target.with-stitching"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/address-family/ipv4/route-target/export-route-target/with-stitching"); value.Exists() {
data.Ipv4RouteTargetExportStitching = make([]VRFIpv4RouteTargetExportStitching, 0)
- value.ForEach(func(k, v gjson.Result) bool {
+ value.ForEach(func(_ int, v xmldot.Result) bool {
item := VRFIpv4RouteTargetExportStitching{}
- if cValue := v.Get("asn-ip"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "asn-ip"); cValue.Exists() {
item.Value = types.StringValue(cValue.String())
}
- if cValue := v.Get("stitching"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "stitching"); cValue.Exists() {
item.Stitching = types.BoolValue(true)
} else {
item.Stitching = types.BoolValue(false)
@@ -788,25 +1866,25 @@ func (data *VRF) fromBody(ctx context.Context, res gjson.Result) {
return true
})
}
- if value := res.Get(prefix + "address-family.ipv6.route-target.import-route-target.without-stitching"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/address-family/ipv6/route-target/import-route-target/without-stitching"); value.Exists() {
data.Ipv6RouteTargetImport = make([]VRFIpv6RouteTargetImport, 0)
- value.ForEach(func(k, v gjson.Result) bool {
+ value.ForEach(func(_ int, v xmldot.Result) bool {
item := VRFIpv6RouteTargetImport{}
- if cValue := v.Get("asn-ip"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "asn-ip"); cValue.Exists() {
item.Value = types.StringValue(cValue.String())
}
data.Ipv6RouteTargetImport = append(data.Ipv6RouteTargetImport, item)
return true
})
}
- if value := res.Get(prefix + "address-family.ipv6.route-target.import-route-target.with-stitching"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/address-family/ipv6/route-target/import-route-target/with-stitching"); value.Exists() {
data.Ipv6RouteTargetImportStitching = make([]VRFIpv6RouteTargetImportStitching, 0)
- value.ForEach(func(k, v gjson.Result) bool {
+ value.ForEach(func(_ int, v xmldot.Result) bool {
item := VRFIpv6RouteTargetImportStitching{}
- if cValue := v.Get("asn-ip"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "asn-ip"); cValue.Exists() {
item.Value = types.StringValue(cValue.String())
}
- if cValue := v.Get("stitching"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "stitching"); cValue.Exists() {
item.Stitching = types.BoolValue(true)
} else {
item.Stitching = types.BoolValue(false)
@@ -815,25 +1893,25 @@ func (data *VRF) fromBody(ctx context.Context, res gjson.Result) {
return true
})
}
- if value := res.Get(prefix + "address-family.ipv6.route-target.export-route-target.without-stitching"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/address-family/ipv6/route-target/export-route-target/without-stitching"); value.Exists() {
data.Ipv6RouteTargetExport = make([]VRFIpv6RouteTargetExport, 0)
- value.ForEach(func(k, v gjson.Result) bool {
+ value.ForEach(func(_ int, v xmldot.Result) bool {
item := VRFIpv6RouteTargetExport{}
- if cValue := v.Get("asn-ip"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "asn-ip"); cValue.Exists() {
item.Value = types.StringValue(cValue.String())
}
data.Ipv6RouteTargetExport = append(data.Ipv6RouteTargetExport, item)
return true
})
}
- if value := res.Get(prefix + "address-family.ipv6.route-target.export-route-target.with-stitching"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/address-family/ipv6/route-target/export-route-target/with-stitching"); value.Exists() {
data.Ipv6RouteTargetExportStitching = make([]VRFIpv6RouteTargetExportStitching, 0)
- value.ForEach(func(k, v gjson.Result) bool {
+ value.ForEach(func(_ int, v xmldot.Result) bool {
item := VRFIpv6RouteTargetExportStitching{}
- if cValue := v.Get("asn-ip"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "asn-ip"); cValue.Exists() {
item.Value = types.StringValue(cValue.String())
}
- if cValue := v.Get("stitching"); cValue.Exists() {
+ if cValue := helpers.GetFromXPath(v, "stitching"); cValue.Exists() {
item.Stitching = types.BoolValue(true)
} else {
item.Stitching = types.BoolValue(false)
@@ -844,187 +1922,330 @@ func (data *VRF) fromBody(ctx context.Context, res gjson.Result) {
}
}
-// End of section. //template:end fromBody
+// End of section. //template:end fromBodyDataXML
-// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyData
+// Section below is generated&owned by "gen/generator.go". //template:begin getDeletedItems
-func (data *VRFData) fromBody(ctx context.Context, res gjson.Result) {
- prefix := helpers.LastElement(data.getPath()) + "."
- if res.Get(helpers.LastElement(data.getPath())).IsArray() {
- prefix += "0."
- }
- if value := res.Get(prefix + "description"); value.Exists() {
- data.Description = types.StringValue(value.String())
- }
- if value := res.Get(prefix + "rd"); value.Exists() {
- data.Rd = types.StringValue(value.String())
+func (data *VRF) getDeletedItems(ctx context.Context, state VRF) []string {
+ deletedItems := make([]string, 0)
+ for i := range state.Ipv6RouteTargetExportStitching {
+ stateKeyValues := [...]string{state.Ipv6RouteTargetExportStitching[i].Value.ValueString()}
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.Ipv6RouteTargetExportStitching[i].Value.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.Ipv6RouteTargetExportStitching {
+ found = true
+ if state.Ipv6RouteTargetExportStitching[i].Value.ValueString() != data.Ipv6RouteTargetExportStitching[j].Value.ValueString() {
+ found = false
+ }
+ if found {
+ if !state.Ipv6RouteTargetExportStitching[i].Stitching.IsNull() && data.Ipv6RouteTargetExportStitching[j].Stitching.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/address-family/ipv6/route-target/export-route-target/with-stitching=%v/stitching", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ break
+ }
+ }
+ if !found {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/address-family/ipv6/route-target/export-route-target/with-stitching=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
}
- if value := res.Get(prefix + "address-family.ipv4"); value.Exists() {
- data.AddressFamilyIpv4 = types.BoolValue(true)
- } else {
- data.AddressFamilyIpv4 = types.BoolValue(false)
+ for i := range state.Ipv6RouteTargetExport {
+ stateKeyValues := [...]string{state.Ipv6RouteTargetExport[i].Value.ValueString()}
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.Ipv6RouteTargetExport[i].Value.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.Ipv6RouteTargetExport {
+ found = true
+ if state.Ipv6RouteTargetExport[i].Value.ValueString() != data.Ipv6RouteTargetExport[j].Value.ValueString() {
+ found = false
+ }
+ if found {
+ break
+ }
+ }
+ if !found {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/address-family/ipv6/route-target/export-route-target/without-stitching=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
}
- if value := res.Get(prefix + "address-family.ipv6"); value.Exists() {
- data.AddressFamilyIpv6 = types.BoolValue(true)
- } else {
- data.AddressFamilyIpv6 = types.BoolValue(false)
+ for i := range state.Ipv6RouteTargetImportStitching {
+ stateKeyValues := [...]string{state.Ipv6RouteTargetImportStitching[i].Value.ValueString()}
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.Ipv6RouteTargetImportStitching[i].Value.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.Ipv6RouteTargetImportStitching {
+ found = true
+ if state.Ipv6RouteTargetImportStitching[i].Value.ValueString() != data.Ipv6RouteTargetImportStitching[j].Value.ValueString() {
+ found = false
+ }
+ if found {
+ if !state.Ipv6RouteTargetImportStitching[i].Stitching.IsNull() && data.Ipv6RouteTargetImportStitching[j].Stitching.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/address-family/ipv6/route-target/import-route-target/with-stitching=%v/stitching", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ break
+ }
+ }
+ if !found {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/address-family/ipv6/route-target/import-route-target/with-stitching=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
}
- if value := res.Get(prefix + "vpn.id"); value.Exists() {
- data.VpnId = types.StringValue(value.String())
+ for i := range state.Ipv6RouteTargetImport {
+ stateKeyValues := [...]string{state.Ipv6RouteTargetImport[i].Value.ValueString()}
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.Ipv6RouteTargetImport[i].Value.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.Ipv6RouteTargetImport {
+ found = true
+ if state.Ipv6RouteTargetImport[i].Value.ValueString() != data.Ipv6RouteTargetImport[j].Value.ValueString() {
+ found = false
+ }
+ if found {
+ break
+ }
+ }
+ if !found {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/address-family/ipv6/route-target/import-route-target/without-stitching=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
}
- if value := res.Get(prefix + "route-target.import"); value.Exists() {
- data.RouteTargetImport = make([]VRFRouteTargetImport, 0)
- value.ForEach(func(k, v gjson.Result) bool {
- item := VRFRouteTargetImport{}
- if cValue := v.Get("asn-ip"); cValue.Exists() {
- item.Value = types.StringValue(cValue.String())
+ for i := range state.Ipv4RouteTargetExportStitching {
+ stateKeyValues := [...]string{state.Ipv4RouteTargetExportStitching[i].Value.ValueString()}
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.Ipv4RouteTargetExportStitching[i].Value.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.Ipv4RouteTargetExportStitching {
+ found = true
+ if state.Ipv4RouteTargetExportStitching[i].Value.ValueString() != data.Ipv4RouteTargetExportStitching[j].Value.ValueString() {
+ found = false
}
- if cValue := v.Get("stitching"); cValue.Exists() {
- item.Stitching = types.BoolValue(true)
- } else {
- item.Stitching = types.BoolValue(false)
+ if found {
+ if !state.Ipv4RouteTargetExportStitching[i].Stitching.IsNull() && data.Ipv4RouteTargetExportStitching[j].Stitching.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/address-family/ipv4/route-target/export-route-target/with-stitching=%v/stitching", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ break
}
- data.RouteTargetImport = append(data.RouteTargetImport, item)
- return true
- })
+ }
+ if !found {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/address-family/ipv4/route-target/export-route-target/with-stitching=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
}
- if value := res.Get(prefix + "route-target.export"); value.Exists() {
- data.RouteTargetExport = make([]VRFRouteTargetExport, 0)
- value.ForEach(func(k, v gjson.Result) bool {
- item := VRFRouteTargetExport{}
- if cValue := v.Get("asn-ip"); cValue.Exists() {
- item.Value = types.StringValue(cValue.String())
+ for i := range state.Ipv4RouteTargetExport {
+ stateKeyValues := [...]string{state.Ipv4RouteTargetExport[i].Value.ValueString()}
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.Ipv4RouteTargetExport[i].Value.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.Ipv4RouteTargetExport {
+ found = true
+ if state.Ipv4RouteTargetExport[i].Value.ValueString() != data.Ipv4RouteTargetExport[j].Value.ValueString() {
+ found = false
}
- if cValue := v.Get("stitching"); cValue.Exists() {
- item.Stitching = types.BoolValue(true)
- } else {
- item.Stitching = types.BoolValue(false)
+ if found {
+ break
}
- data.RouteTargetExport = append(data.RouteTargetExport, item)
- return true
- })
+ }
+ if !found {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/address-family/ipv4/route-target/export-route-target/without-stitching=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
}
- if value := res.Get(prefix + "address-family.ipv4.route-target.import-route-target.without-stitching"); value.Exists() {
- data.Ipv4RouteTargetImport = make([]VRFIpv4RouteTargetImport, 0)
- value.ForEach(func(k, v gjson.Result) bool {
- item := VRFIpv4RouteTargetImport{}
- if cValue := v.Get("asn-ip"); cValue.Exists() {
- item.Value = types.StringValue(cValue.String())
+ for i := range state.Ipv4RouteTargetImportStitching {
+ stateKeyValues := [...]string{state.Ipv4RouteTargetImportStitching[i].Value.ValueString()}
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.Ipv4RouteTargetImportStitching[i].Value.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.Ipv4RouteTargetImportStitching {
+ found = true
+ if state.Ipv4RouteTargetImportStitching[i].Value.ValueString() != data.Ipv4RouteTargetImportStitching[j].Value.ValueString() {
+ found = false
}
- data.Ipv4RouteTargetImport = append(data.Ipv4RouteTargetImport, item)
- return true
- })
+ if found {
+ if !state.Ipv4RouteTargetImportStitching[i].Stitching.IsNull() && data.Ipv4RouteTargetImportStitching[j].Stitching.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/address-family/ipv4/route-target/import-route-target/with-stitching=%v/stitching", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ break
+ }
+ }
+ if !found {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/address-family/ipv4/route-target/import-route-target/with-stitching=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
}
- if value := res.Get(prefix + "address-family.ipv4.route-target.import-route-target.with-stitching"); value.Exists() {
- data.Ipv4RouteTargetImportStitching = make([]VRFIpv4RouteTargetImportStitching, 0)
- value.ForEach(func(k, v gjson.Result) bool {
- item := VRFIpv4RouteTargetImportStitching{}
- if cValue := v.Get("asn-ip"); cValue.Exists() {
- item.Value = types.StringValue(cValue.String())
+ for i := range state.Ipv4RouteTargetImport {
+ stateKeyValues := [...]string{state.Ipv4RouteTargetImport[i].Value.ValueString()}
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.Ipv4RouteTargetImport[i].Value.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.Ipv4RouteTargetImport {
+ found = true
+ if state.Ipv4RouteTargetImport[i].Value.ValueString() != data.Ipv4RouteTargetImport[j].Value.ValueString() {
+ found = false
}
- if cValue := v.Get("stitching"); cValue.Exists() {
- item.Stitching = types.BoolValue(true)
- } else {
- item.Stitching = types.BoolValue(false)
+ if found {
+ break
}
- data.Ipv4RouteTargetImportStitching = append(data.Ipv4RouteTargetImportStitching, item)
- return true
- })
+ }
+ if !found {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/address-family/ipv4/route-target/import-route-target/without-stitching=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
}
- if value := res.Get(prefix + "address-family.ipv4.route-target.export-route-target.without-stitching"); value.Exists() {
- data.Ipv4RouteTargetExport = make([]VRFIpv4RouteTargetExport, 0)
- value.ForEach(func(k, v gjson.Result) bool {
- item := VRFIpv4RouteTargetExport{}
- if cValue := v.Get("asn-ip"); cValue.Exists() {
- item.Value = types.StringValue(cValue.String())
+ for i := range state.RouteTargetExport {
+ stateKeyValues := [...]string{state.RouteTargetExport[i].Value.ValueString()}
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.RouteTargetExport[i].Value.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.RouteTargetExport {
+ found = true
+ if state.RouteTargetExport[i].Value.ValueString() != data.RouteTargetExport[j].Value.ValueString() {
+ found = false
}
- data.Ipv4RouteTargetExport = append(data.Ipv4RouteTargetExport, item)
- return true
- })
+ if found {
+ if !state.RouteTargetExport[i].Stitching.IsNull() && data.RouteTargetExport[j].Stitching.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/route-target/export=%v/stitching", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ break
+ }
+ }
+ if !found {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/route-target/export=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
}
- if value := res.Get(prefix + "address-family.ipv4.route-target.export-route-target.with-stitching"); value.Exists() {
- data.Ipv4RouteTargetExportStitching = make([]VRFIpv4RouteTargetExportStitching, 0)
- value.ForEach(func(k, v gjson.Result) bool {
- item := VRFIpv4RouteTargetExportStitching{}
- if cValue := v.Get("asn-ip"); cValue.Exists() {
- item.Value = types.StringValue(cValue.String())
+ for i := range state.RouteTargetImport {
+ stateKeyValues := [...]string{state.RouteTargetImport[i].Value.ValueString()}
+
+ emptyKeys := true
+ if !reflect.ValueOf(state.RouteTargetImport[i].Value.ValueString()).IsZero() {
+ emptyKeys = false
+ }
+ if emptyKeys {
+ continue
+ }
+
+ found := false
+ for j := range data.RouteTargetImport {
+ found = true
+ if state.RouteTargetImport[i].Value.ValueString() != data.RouteTargetImport[j].Value.ValueString() {
+ found = false
}
- if cValue := v.Get("stitching"); cValue.Exists() {
- item.Stitching = types.BoolValue(true)
- } else {
- item.Stitching = types.BoolValue(false)
+ if found {
+ if !state.RouteTargetImport[i].Stitching.IsNull() && data.RouteTargetImport[j].Stitching.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/route-target/import=%v/stitching", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
+ break
}
- data.Ipv4RouteTargetExportStitching = append(data.Ipv4RouteTargetExportStitching, item)
- return true
- })
+ }
+ if !found {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/route-target/import=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ }
}
- if value := res.Get(prefix + "address-family.ipv6.route-target.import-route-target.without-stitching"); value.Exists() {
- data.Ipv6RouteTargetImport = make([]VRFIpv6RouteTargetImport, 0)
- value.ForEach(func(k, v gjson.Result) bool {
- item := VRFIpv6RouteTargetImport{}
- if cValue := v.Get("asn-ip"); cValue.Exists() {
- item.Value = types.StringValue(cValue.String())
- }
- data.Ipv6RouteTargetImport = append(data.Ipv6RouteTargetImport, item)
- return true
- })
+ if !state.VpnId.IsNull() && data.VpnId.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/vpn/id", state.getPath()))
}
- if value := res.Get(prefix + "address-family.ipv6.route-target.import-route-target.with-stitching"); value.Exists() {
- data.Ipv6RouteTargetImportStitching = make([]VRFIpv6RouteTargetImportStitching, 0)
- value.ForEach(func(k, v gjson.Result) bool {
- item := VRFIpv6RouteTargetImportStitching{}
- if cValue := v.Get("asn-ip"); cValue.Exists() {
- item.Value = types.StringValue(cValue.String())
- }
- if cValue := v.Get("stitching"); cValue.Exists() {
- item.Stitching = types.BoolValue(true)
- } else {
- item.Stitching = types.BoolValue(false)
- }
- data.Ipv6RouteTargetImportStitching = append(data.Ipv6RouteTargetImportStitching, item)
- return true
- })
+ if !state.AddressFamilyIpv6.IsNull() && data.AddressFamilyIpv6.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/address-family/ipv6", state.getPath()))
}
- if value := res.Get(prefix + "address-family.ipv6.route-target.export-route-target.without-stitching"); value.Exists() {
- data.Ipv6RouteTargetExport = make([]VRFIpv6RouteTargetExport, 0)
- value.ForEach(func(k, v gjson.Result) bool {
- item := VRFIpv6RouteTargetExport{}
- if cValue := v.Get("asn-ip"); cValue.Exists() {
- item.Value = types.StringValue(cValue.String())
- }
- data.Ipv6RouteTargetExport = append(data.Ipv6RouteTargetExport, item)
- return true
- })
+ if !state.AddressFamilyIpv4.IsNull() && data.AddressFamilyIpv4.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/address-family/ipv4", state.getPath()))
}
- if value := res.Get(prefix + "address-family.ipv6.route-target.export-route-target.with-stitching"); value.Exists() {
- data.Ipv6RouteTargetExportStitching = make([]VRFIpv6RouteTargetExportStitching, 0)
- value.ForEach(func(k, v gjson.Result) bool {
- item := VRFIpv6RouteTargetExportStitching{}
- if cValue := v.Get("asn-ip"); cValue.Exists() {
- item.Value = types.StringValue(cValue.String())
- }
- if cValue := v.Get("stitching"); cValue.Exists() {
- item.Stitching = types.BoolValue(true)
- } else {
- item.Stitching = types.BoolValue(false)
- }
- data.Ipv6RouteTargetExportStitching = append(data.Ipv6RouteTargetExportStitching, item)
- return true
- })
+ if !state.Rd.IsNull() && data.Rd.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/rd", state.getPath()))
+ }
+ if !state.Description.IsNull() && data.Description.IsNull() {
+ deletedItems = append(deletedItems, fmt.Sprintf("%v/description", state.getPath()))
}
+
+ return deletedItems
}
-// End of section. //template:end fromBodyData
+// End of section. //template:end getDeletedItems
-// Section below is generated&owned by "gen/generator.go". //template:begin getDeletedItems
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletedItemsXML
-func (data *VRF) getDeletedItems(ctx context.Context, state VRF) []string {
- deletedItems := make([]string, 0)
- for i := range state.Ipv6RouteTargetExportStitching {
- stateKeyValues := [...]string{state.Ipv6RouteTargetExportStitching[i].Value.ValueString()}
+func (data *VRF) addDeletedItemsXML(ctx context.Context, state VRF, body string) string {
+ b := netconf.NewBody(body)
+ if !state.Description.IsNull() && data.Description.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/description")
+ }
+ if !state.Rd.IsNull() && data.Rd.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/rd")
+ }
+ if !state.AddressFamilyIpv4.IsNull() && data.AddressFamilyIpv4.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/address-family/ipv4")
+ }
+ if !state.AddressFamilyIpv6.IsNull() && data.AddressFamilyIpv6.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/address-family/ipv6")
+ }
+ if !state.VpnId.IsNull() && data.VpnId.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/vpn/id")
+ }
+ for i := range state.RouteTargetImport {
+ stateKeys := [...]string{"asn-ip"}
+ stateKeyValues := [...]string{state.RouteTargetImport[i].Value.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
emptyKeys := true
- if !reflect.ValueOf(state.Ipv6RouteTargetExportStitching[i].Value.ValueString()).IsZero() {
+ if !reflect.ValueOf(state.RouteTargetImport[i].Value.ValueString()).IsZero() {
emptyKeys = false
}
if emptyKeys {
@@ -1032,27 +2253,32 @@ func (data *VRF) getDeletedItems(ctx context.Context, state VRF) []string {
}
found := false
- for j := range data.Ipv6RouteTargetExportStitching {
+ for j := range data.RouteTargetImport {
found = true
- if state.Ipv6RouteTargetExportStitching[i].Value.ValueString() != data.Ipv6RouteTargetExportStitching[j].Value.ValueString() {
+ if state.RouteTargetImport[i].Value.ValueString() != data.RouteTargetImport[j].Value.ValueString() {
found = false
}
if found {
- if !state.Ipv6RouteTargetExportStitching[i].Stitching.IsNull() && data.Ipv6RouteTargetExportStitching[j].Stitching.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/address-family/ipv6/route-target/export-route-target/with-stitching=%v/stitching", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ if !state.RouteTargetImport[i].Stitching.IsNull() && data.RouteTargetImport[j].Stitching.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/route-target/import%v/stitching", predicates))
}
break
}
}
if !found {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/address-family/ipv6/route-target/export-route-target/with-stitching=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/route-target/import%v", predicates))
}
}
- for i := range state.Ipv6RouteTargetExport {
- stateKeyValues := [...]string{state.Ipv6RouteTargetExport[i].Value.ValueString()}
+ for i := range state.RouteTargetExport {
+ stateKeys := [...]string{"asn-ip"}
+ stateKeyValues := [...]string{state.RouteTargetExport[i].Value.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
emptyKeys := true
- if !reflect.ValueOf(state.Ipv6RouteTargetExport[i].Value.ValueString()).IsZero() {
+ if !reflect.ValueOf(state.RouteTargetExport[i].Value.ValueString()).IsZero() {
emptyKeys = false
}
if emptyKeys {
@@ -1060,24 +2286,32 @@ func (data *VRF) getDeletedItems(ctx context.Context, state VRF) []string {
}
found := false
- for j := range data.Ipv6RouteTargetExport {
+ for j := range data.RouteTargetExport {
found = true
- if state.Ipv6RouteTargetExport[i].Value.ValueString() != data.Ipv6RouteTargetExport[j].Value.ValueString() {
+ if state.RouteTargetExport[i].Value.ValueString() != data.RouteTargetExport[j].Value.ValueString() {
found = false
}
if found {
+ if !state.RouteTargetExport[i].Stitching.IsNull() && data.RouteTargetExport[j].Stitching.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/route-target/export%v/stitching", predicates))
+ }
break
}
}
if !found {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/address-family/ipv6/route-target/export-route-target/without-stitching=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/route-target/export%v", predicates))
}
}
- for i := range state.Ipv6RouteTargetImportStitching {
- stateKeyValues := [...]string{state.Ipv6RouteTargetImportStitching[i].Value.ValueString()}
+ for i := range state.Ipv4RouteTargetImport {
+ stateKeys := [...]string{"asn-ip"}
+ stateKeyValues := [...]string{state.Ipv4RouteTargetImport[i].Value.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
emptyKeys := true
- if !reflect.ValueOf(state.Ipv6RouteTargetImportStitching[i].Value.ValueString()).IsZero() {
+ if !reflect.ValueOf(state.Ipv4RouteTargetImport[i].Value.ValueString()).IsZero() {
emptyKeys = false
}
if emptyKeys {
@@ -1085,27 +2319,29 @@ func (data *VRF) getDeletedItems(ctx context.Context, state VRF) []string {
}
found := false
- for j := range data.Ipv6RouteTargetImportStitching {
+ for j := range data.Ipv4RouteTargetImport {
found = true
- if state.Ipv6RouteTargetImportStitching[i].Value.ValueString() != data.Ipv6RouteTargetImportStitching[j].Value.ValueString() {
+ if state.Ipv4RouteTargetImport[i].Value.ValueString() != data.Ipv4RouteTargetImport[j].Value.ValueString() {
found = false
}
if found {
- if !state.Ipv6RouteTargetImportStitching[i].Stitching.IsNull() && data.Ipv6RouteTargetImportStitching[j].Stitching.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/address-family/ipv6/route-target/import-route-target/with-stitching=%v/stitching", state.getPath(), strings.Join(stateKeyValues[:], ",")))
- }
break
}
}
if !found {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/address-family/ipv6/route-target/import-route-target/with-stitching=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/address-family/ipv4/route-target/import-route-target/without-stitching%v", predicates))
}
}
- for i := range state.Ipv6RouteTargetImport {
- stateKeyValues := [...]string{state.Ipv6RouteTargetImport[i].Value.ValueString()}
+ for i := range state.Ipv4RouteTargetImportStitching {
+ stateKeys := [...]string{"asn-ip"}
+ stateKeyValues := [...]string{state.Ipv4RouteTargetImportStitching[i].Value.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
emptyKeys := true
- if !reflect.ValueOf(state.Ipv6RouteTargetImport[i].Value.ValueString()).IsZero() {
+ if !reflect.ValueOf(state.Ipv4RouteTargetImportStitching[i].Value.ValueString()).IsZero() {
emptyKeys = false
}
if emptyKeys {
@@ -1113,24 +2349,32 @@ func (data *VRF) getDeletedItems(ctx context.Context, state VRF) []string {
}
found := false
- for j := range data.Ipv6RouteTargetImport {
+ for j := range data.Ipv4RouteTargetImportStitching {
found = true
- if state.Ipv6RouteTargetImport[i].Value.ValueString() != data.Ipv6RouteTargetImport[j].Value.ValueString() {
+ if state.Ipv4RouteTargetImportStitching[i].Value.ValueString() != data.Ipv4RouteTargetImportStitching[j].Value.ValueString() {
found = false
}
if found {
+ if !state.Ipv4RouteTargetImportStitching[i].Stitching.IsNull() && data.Ipv4RouteTargetImportStitching[j].Stitching.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/address-family/ipv4/route-target/import-route-target/with-stitching%v/stitching", predicates))
+ }
break
}
}
if !found {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/address-family/ipv6/route-target/import-route-target/without-stitching=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/address-family/ipv4/route-target/import-route-target/with-stitching%v", predicates))
}
}
- for i := range state.Ipv4RouteTargetExportStitching {
- stateKeyValues := [...]string{state.Ipv4RouteTargetExportStitching[i].Value.ValueString()}
+ for i := range state.Ipv4RouteTargetExport {
+ stateKeys := [...]string{"asn-ip"}
+ stateKeyValues := [...]string{state.Ipv4RouteTargetExport[i].Value.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
emptyKeys := true
- if !reflect.ValueOf(state.Ipv4RouteTargetExportStitching[i].Value.ValueString()).IsZero() {
+ if !reflect.ValueOf(state.Ipv4RouteTargetExport[i].Value.ValueString()).IsZero() {
emptyKeys = false
}
if emptyKeys {
@@ -1138,27 +2382,29 @@ func (data *VRF) getDeletedItems(ctx context.Context, state VRF) []string {
}
found := false
- for j := range data.Ipv4RouteTargetExportStitching {
+ for j := range data.Ipv4RouteTargetExport {
found = true
- if state.Ipv4RouteTargetExportStitching[i].Value.ValueString() != data.Ipv4RouteTargetExportStitching[j].Value.ValueString() {
+ if state.Ipv4RouteTargetExport[i].Value.ValueString() != data.Ipv4RouteTargetExport[j].Value.ValueString() {
found = false
}
if found {
- if !state.Ipv4RouteTargetExportStitching[i].Stitching.IsNull() && data.Ipv4RouteTargetExportStitching[j].Stitching.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/address-family/ipv4/route-target/export-route-target/with-stitching=%v/stitching", state.getPath(), strings.Join(stateKeyValues[:], ",")))
- }
break
}
}
if !found {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/address-family/ipv4/route-target/export-route-target/with-stitching=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/address-family/ipv4/route-target/export-route-target/without-stitching%v", predicates))
}
}
- for i := range state.Ipv4RouteTargetExport {
- stateKeyValues := [...]string{state.Ipv4RouteTargetExport[i].Value.ValueString()}
+ for i := range state.Ipv4RouteTargetExportStitching {
+ stateKeys := [...]string{"asn-ip"}
+ stateKeyValues := [...]string{state.Ipv4RouteTargetExportStitching[i].Value.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
emptyKeys := true
- if !reflect.ValueOf(state.Ipv4RouteTargetExport[i].Value.ValueString()).IsZero() {
+ if !reflect.ValueOf(state.Ipv4RouteTargetExportStitching[i].Value.ValueString()).IsZero() {
emptyKeys = false
}
if emptyKeys {
@@ -1166,24 +2412,32 @@ func (data *VRF) getDeletedItems(ctx context.Context, state VRF) []string {
}
found := false
- for j := range data.Ipv4RouteTargetExport {
+ for j := range data.Ipv4RouteTargetExportStitching {
found = true
- if state.Ipv4RouteTargetExport[i].Value.ValueString() != data.Ipv4RouteTargetExport[j].Value.ValueString() {
+ if state.Ipv4RouteTargetExportStitching[i].Value.ValueString() != data.Ipv4RouteTargetExportStitching[j].Value.ValueString() {
found = false
}
if found {
+ if !state.Ipv4RouteTargetExportStitching[i].Stitching.IsNull() && data.Ipv4RouteTargetExportStitching[j].Stitching.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/address-family/ipv4/route-target/export-route-target/with-stitching%v/stitching", predicates))
+ }
break
}
}
if !found {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/address-family/ipv4/route-target/export-route-target/without-stitching=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/address-family/ipv4/route-target/export-route-target/with-stitching%v", predicates))
}
}
- for i := range state.Ipv4RouteTargetImportStitching {
- stateKeyValues := [...]string{state.Ipv4RouteTargetImportStitching[i].Value.ValueString()}
+ for i := range state.Ipv6RouteTargetImport {
+ stateKeys := [...]string{"asn-ip"}
+ stateKeyValues := [...]string{state.Ipv6RouteTargetImport[i].Value.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
emptyKeys := true
- if !reflect.ValueOf(state.Ipv4RouteTargetImportStitching[i].Value.ValueString()).IsZero() {
+ if !reflect.ValueOf(state.Ipv6RouteTargetImport[i].Value.ValueString()).IsZero() {
emptyKeys = false
}
if emptyKeys {
@@ -1191,27 +2445,29 @@ func (data *VRF) getDeletedItems(ctx context.Context, state VRF) []string {
}
found := false
- for j := range data.Ipv4RouteTargetImportStitching {
+ for j := range data.Ipv6RouteTargetImport {
found = true
- if state.Ipv4RouteTargetImportStitching[i].Value.ValueString() != data.Ipv4RouteTargetImportStitching[j].Value.ValueString() {
+ if state.Ipv6RouteTargetImport[i].Value.ValueString() != data.Ipv6RouteTargetImport[j].Value.ValueString() {
found = false
}
if found {
- if !state.Ipv4RouteTargetImportStitching[i].Stitching.IsNull() && data.Ipv4RouteTargetImportStitching[j].Stitching.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/address-family/ipv4/route-target/import-route-target/with-stitching=%v/stitching", state.getPath(), strings.Join(stateKeyValues[:], ",")))
- }
break
}
}
if !found {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/address-family/ipv4/route-target/import-route-target/with-stitching=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/address-family/ipv6/route-target/import-route-target/without-stitching%v", predicates))
}
}
- for i := range state.Ipv4RouteTargetImport {
- stateKeyValues := [...]string{state.Ipv4RouteTargetImport[i].Value.ValueString()}
+ for i := range state.Ipv6RouteTargetImportStitching {
+ stateKeys := [...]string{"asn-ip"}
+ stateKeyValues := [...]string{state.Ipv6RouteTargetImportStitching[i].Value.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
emptyKeys := true
- if !reflect.ValueOf(state.Ipv4RouteTargetImport[i].Value.ValueString()).IsZero() {
+ if !reflect.ValueOf(state.Ipv6RouteTargetImportStitching[i].Value.ValueString()).IsZero() {
emptyKeys = false
}
if emptyKeys {
@@ -1219,24 +2475,32 @@ func (data *VRF) getDeletedItems(ctx context.Context, state VRF) []string {
}
found := false
- for j := range data.Ipv4RouteTargetImport {
+ for j := range data.Ipv6RouteTargetImportStitching {
found = true
- if state.Ipv4RouteTargetImport[i].Value.ValueString() != data.Ipv4RouteTargetImport[j].Value.ValueString() {
+ if state.Ipv6RouteTargetImportStitching[i].Value.ValueString() != data.Ipv6RouteTargetImportStitching[j].Value.ValueString() {
found = false
}
if found {
+ if !state.Ipv6RouteTargetImportStitching[i].Stitching.IsNull() && data.Ipv6RouteTargetImportStitching[j].Stitching.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/address-family/ipv6/route-target/import-route-target/with-stitching%v/stitching", predicates))
+ }
break
}
}
if !found {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/address-family/ipv4/route-target/import-route-target/without-stitching=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/address-family/ipv6/route-target/import-route-target/with-stitching%v", predicates))
}
}
- for i := range state.RouteTargetExport {
- stateKeyValues := [...]string{state.RouteTargetExport[i].Value.ValueString()}
+ for i := range state.Ipv6RouteTargetExport {
+ stateKeys := [...]string{"asn-ip"}
+ stateKeyValues := [...]string{state.Ipv6RouteTargetExport[i].Value.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
emptyKeys := true
- if !reflect.ValueOf(state.RouteTargetExport[i].Value.ValueString()).IsZero() {
+ if !reflect.ValueOf(state.Ipv6RouteTargetExport[i].Value.ValueString()).IsZero() {
emptyKeys = false
}
if emptyKeys {
@@ -1244,27 +2508,29 @@ func (data *VRF) getDeletedItems(ctx context.Context, state VRF) []string {
}
found := false
- for j := range data.RouteTargetExport {
+ for j := range data.Ipv6RouteTargetExport {
found = true
- if state.RouteTargetExport[i].Value.ValueString() != data.RouteTargetExport[j].Value.ValueString() {
+ if state.Ipv6RouteTargetExport[i].Value.ValueString() != data.Ipv6RouteTargetExport[j].Value.ValueString() {
found = false
}
if found {
- if !state.RouteTargetExport[i].Stitching.IsNull() && data.RouteTargetExport[j].Stitching.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/route-target/export=%v/stitching", state.getPath(), strings.Join(stateKeyValues[:], ",")))
- }
break
}
}
if !found {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/route-target/export=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/address-family/ipv6/route-target/export-route-target/without-stitching%v", predicates))
}
}
- for i := range state.RouteTargetImport {
- stateKeyValues := [...]string{state.RouteTargetImport[i].Value.ValueString()}
+ for i := range state.Ipv6RouteTargetExportStitching {
+ stateKeys := [...]string{"asn-ip"}
+ stateKeyValues := [...]string{state.Ipv6RouteTargetExportStitching[i].Value.ValueString()}
+ predicates := ""
+ for i := range stateKeys {
+ predicates += fmt.Sprintf("[%s='%s']", stateKeys[i], stateKeyValues[i])
+ }
emptyKeys := true
- if !reflect.ValueOf(state.RouteTargetImport[i].Value.ValueString()).IsZero() {
+ if !reflect.ValueOf(state.Ipv6RouteTargetExportStitching[i].Value.ValueString()).IsZero() {
emptyKeys = false
}
if emptyKeys {
@@ -1272,42 +2538,27 @@ func (data *VRF) getDeletedItems(ctx context.Context, state VRF) []string {
}
found := false
- for j := range data.RouteTargetImport {
+ for j := range data.Ipv6RouteTargetExportStitching {
found = true
- if state.RouteTargetImport[i].Value.ValueString() != data.RouteTargetImport[j].Value.ValueString() {
+ if state.Ipv6RouteTargetExportStitching[i].Value.ValueString() != data.Ipv6RouteTargetExportStitching[j].Value.ValueString() {
found = false
}
if found {
- if !state.RouteTargetImport[i].Stitching.IsNull() && data.RouteTargetImport[j].Stitching.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/route-target/import=%v/stitching", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ if !state.Ipv6RouteTargetExportStitching[i].Stitching.IsNull() && data.Ipv6RouteTargetExportStitching[j].Stitching.IsNull() {
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/address-family/ipv6/route-target/export-route-target/with-stitching%v/stitching", predicates))
}
break
}
}
if !found {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/route-target/import=%v", state.getPath(), strings.Join(stateKeyValues[:], ",")))
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(state.getXPath()+"/address-family/ipv6/route-target/export-route-target/with-stitching%v", predicates))
}
}
- if !state.VpnId.IsNull() && data.VpnId.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/vpn/id", state.getPath()))
- }
- if !state.AddressFamilyIpv6.IsNull() && data.AddressFamilyIpv6.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/address-family/ipv6", state.getPath()))
- }
- if !state.AddressFamilyIpv4.IsNull() && data.AddressFamilyIpv4.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/address-family/ipv4", state.getPath()))
- }
- if !state.Rd.IsNull() && data.Rd.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/rd", state.getPath()))
- }
- if !state.Description.IsNull() && data.Description.IsNull() {
- deletedItems = append(deletedItems, fmt.Sprintf("%v/description", state.getPath()))
- }
- return deletedItems
+ return b.Res()
}
-// End of section. //template:end getDeletedItems
+// End of section. //template:end addDeletedItemsXML
// Section below is generated&owned by "gen/generator.go". //template:begin getEmptyLeafsDelete
@@ -1441,3 +2692,128 @@ func (data *VRF) getDeletePaths(ctx context.Context) []string {
}
// End of section. //template:end getDeletePaths
+
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletePathsXML
+
+func (data *VRF) addDeletePathsXML(ctx context.Context, body string) string {
+ b := netconf.NewBody(body)
+ if !data.Description.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/description")
+ }
+ if !data.Rd.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/rd")
+ }
+ if !data.AddressFamilyIpv4.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/address-family/ipv4")
+ }
+ if !data.AddressFamilyIpv6.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/address-family/ipv6")
+ }
+ if !data.VpnId.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/vpn/id")
+ }
+ for i := range data.RouteTargetImport {
+ keys := [...]string{"asn-ip"}
+ keyValues := [...]string{data.RouteTargetImport[i].Value.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/route-target/import%v", predicates))
+ }
+ for i := range data.RouteTargetExport {
+ keys := [...]string{"asn-ip"}
+ keyValues := [...]string{data.RouteTargetExport[i].Value.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/route-target/export%v", predicates))
+ }
+ for i := range data.Ipv4RouteTargetImport {
+ keys := [...]string{"asn-ip"}
+ keyValues := [...]string{data.Ipv4RouteTargetImport[i].Value.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/address-family/ipv4/route-target/import-route-target/without-stitching%v", predicates))
+ }
+ for i := range data.Ipv4RouteTargetImportStitching {
+ keys := [...]string{"asn-ip"}
+ keyValues := [...]string{data.Ipv4RouteTargetImportStitching[i].Value.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/address-family/ipv4/route-target/import-route-target/with-stitching%v", predicates))
+ }
+ for i := range data.Ipv4RouteTargetExport {
+ keys := [...]string{"asn-ip"}
+ keyValues := [...]string{data.Ipv4RouteTargetExport[i].Value.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/address-family/ipv4/route-target/export-route-target/without-stitching%v", predicates))
+ }
+ for i := range data.Ipv4RouteTargetExportStitching {
+ keys := [...]string{"asn-ip"}
+ keyValues := [...]string{data.Ipv4RouteTargetExportStitching[i].Value.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/address-family/ipv4/route-target/export-route-target/with-stitching%v", predicates))
+ }
+ for i := range data.Ipv6RouteTargetImport {
+ keys := [...]string{"asn-ip"}
+ keyValues := [...]string{data.Ipv6RouteTargetImport[i].Value.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/address-family/ipv6/route-target/import-route-target/without-stitching%v", predicates))
+ }
+ for i := range data.Ipv6RouteTargetImportStitching {
+ keys := [...]string{"asn-ip"}
+ keyValues := [...]string{data.Ipv6RouteTargetImportStitching[i].Value.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/address-family/ipv6/route-target/import-route-target/with-stitching%v", predicates))
+ }
+ for i := range data.Ipv6RouteTargetExport {
+ keys := [...]string{"asn-ip"}
+ keyValues := [...]string{data.Ipv6RouteTargetExport[i].Value.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/address-family/ipv6/route-target/export-route-target/without-stitching%v", predicates))
+ }
+ for i := range data.Ipv6RouteTargetExportStitching {
+ keys := [...]string{"asn-ip"}
+ keyValues := [...]string{data.Ipv6RouteTargetExportStitching[i].Value.ValueString()}
+ predicates := ""
+ for i := range keys {
+ predicates += fmt.Sprintf("[%s='%s']", keys[i], keyValues[i])
+ }
+
+ b = helpers.RemoveFromXPath(b, fmt.Sprintf(data.getXPath()+"/address-family/ipv6/route-target/export-route-target/with-stitching%v", predicates))
+ }
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletePathsXML
diff --git a/internal/provider/model_iosxe_vtp.go b/internal/provider/model_iosxe_vtp.go
index 85119655..4d3bae7a 100644
--- a/internal/provider/model_iosxe_vtp.go
+++ b/internal/provider/model_iosxe_vtp.go
@@ -28,6 +28,9 @@ import (
"github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/types"
+ "github.com/hashicorp/terraform-plugin-log/tflog"
+ "github.com/netascode/go-netconf"
+ "github.com/netascode/xmldot"
"github.com/tidwall/gjson"
"github.com/tidwall/sjson"
)
@@ -119,6 +122,17 @@ func (data VTP) getPathShort() string {
return matches[1]
}
+// getXPath returns the XPath for NETCONF operations
+func (data VTP) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/vtp"
+ return path
+}
+
+func (data VTPData) getXPath() string {
+ path := "/Cisco-IOS-XE-native:native/vtp"
+ return path
+}
+
// End of section. //template:end getPath
// Section below is generated&owned by "gen/generator.go". //template:begin toBody
@@ -245,6 +259,174 @@ func (data VTP) toBody(ctx context.Context) string {
// End of section. //template:end toBody
+// Section below is generated&owned by "gen/generator.go". //template:begin toBodyXML
+
+func (data VTP) toBodyXML(ctx context.Context) string {
+ body := netconf.Body{}
+ if !data.File.IsNull() && !data.File.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-vtp:file", data.File.ValueString())
+ }
+ if !data.Version.IsNull() && !data.Version.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-vtp:version", strconv.FormatInt(data.Version.ValueInt64(), 10))
+ }
+ if !data.Interface.IsNull() && !data.Interface.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-vtp:interface/interface-name", data.Interface.ValueString())
+ }
+ if !data.InterfaceOnly.IsNull() && !data.InterfaceOnly.IsUnknown() {
+ if data.InterfaceOnly.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-vtp:interface/only", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-vtp:interface/only")
+ }
+ }
+ if !data.Password.IsNull() && !data.Password.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-vtp:password/password", data.Password.ValueString())
+ }
+ if !data.PasswordHidden.IsNull() && !data.PasswordHidden.IsUnknown() {
+ if data.PasswordHidden.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-vtp:password/hidden", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-vtp:password/hidden")
+ }
+ }
+ if !data.PasswordSecret.IsNull() && !data.PasswordSecret.IsUnknown() {
+ if data.PasswordSecret.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-vtp:password/secret", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-vtp:password/secret")
+ }
+ }
+ if !data.Pruning.IsNull() && !data.Pruning.IsUnknown() {
+ if data.Pruning.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-vtp:pruning", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-vtp:pruning")
+ }
+ }
+ if !data.Domain.IsNull() && !data.Domain.IsUnknown() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-vtp:domain", data.Domain.ValueString())
+ }
+ if !data.ModeClient.IsNull() && !data.ModeClient.IsUnknown() {
+ if data.ModeClient.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-vtp:mode/client", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-vtp:mode/client")
+ }
+ }
+ if !data.ModeClientMst.IsNull() && !data.ModeClientMst.IsUnknown() {
+ if data.ModeClientMst.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-vtp:mode/client/mst", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-vtp:mode/client/mst")
+ }
+ }
+ if !data.ModeClientUnknown.IsNull() && !data.ModeClientUnknown.IsUnknown() {
+ if data.ModeClientUnknown.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-vtp:mode/client/unknown", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-vtp:mode/client/unknown")
+ }
+ }
+ if !data.ModeClientVlan.IsNull() && !data.ModeClientVlan.IsUnknown() {
+ if data.ModeClientVlan.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-vtp:mode/client/vlan", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-vtp:mode/client/vlan")
+ }
+ }
+ if !data.ModeOff.IsNull() && !data.ModeOff.IsUnknown() {
+ if data.ModeOff.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-vtp:mode/off", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-vtp:mode/off")
+ }
+ }
+ if !data.ModeOffMst.IsNull() && !data.ModeOffMst.IsUnknown() {
+ if data.ModeOffMst.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-vtp:mode/off/mst", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-vtp:mode/off/mst")
+ }
+ }
+ if !data.ModeOffUnknown.IsNull() && !data.ModeOffUnknown.IsUnknown() {
+ if data.ModeOffUnknown.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-vtp:mode/off/unknown", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-vtp:mode/off/unknown")
+ }
+ }
+ if !data.ModeOffVlan.IsNull() && !data.ModeOffVlan.IsUnknown() {
+ if data.ModeOffVlan.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-vtp:mode/off/vlan", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-vtp:mode/off/vlan")
+ }
+ }
+ if !data.ModeServer.IsNull() && !data.ModeServer.IsUnknown() {
+ if data.ModeServer.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-vtp:mode/server", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-vtp:mode/server")
+ }
+ }
+ if !data.ModeServerMst.IsNull() && !data.ModeServerMst.IsUnknown() {
+ if data.ModeServerMst.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-vtp:mode/server/mst", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-vtp:mode/server/mst")
+ }
+ }
+ if !data.ModeServerUnknown.IsNull() && !data.ModeServerUnknown.IsUnknown() {
+ if data.ModeServerUnknown.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-vtp:mode/server/unknown", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-vtp:mode/server/unknown")
+ }
+ }
+ if !data.ModeServerVlan.IsNull() && !data.ModeServerVlan.IsUnknown() {
+ if data.ModeServerVlan.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-vtp:mode/server/vlan", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-vtp:mode/server/vlan")
+ }
+ }
+ if !data.ModeTransparent.IsNull() && !data.ModeTransparent.IsUnknown() {
+ if data.ModeTransparent.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-vtp:mode/transparent", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-vtp:mode/transparent")
+ }
+ }
+ if !data.ModeTransparentMst.IsNull() && !data.ModeTransparentMst.IsUnknown() {
+ if data.ModeTransparentMst.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-vtp:mode/transparent/mst", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-vtp:mode/transparent/mst")
+ }
+ }
+ if !data.ModeTransparentUnknown.IsNull() && !data.ModeTransparentUnknown.IsUnknown() {
+ if data.ModeTransparentUnknown.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-vtp:mode/transparent/unknown", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-vtp:mode/transparent/unknown")
+ }
+ }
+ if !data.ModeTransparentVlan.IsNull() && !data.ModeTransparentVlan.IsUnknown() {
+ if data.ModeTransparentVlan.ValueBool() {
+ body = helpers.SetFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-vtp:mode/transparent/vlan", "")
+ } else {
+ body = helpers.RemoveFromXPath(body, data.getXPath()+"/Cisco-IOS-XE-vtp:mode/transparent/vlan")
+ }
+ }
+ bodyString, err := body.String()
+ if err != nil {
+ tflog.Error(ctx, fmt.Sprintf("Error converting body to string: %s", err))
+ }
+ return bodyString
+}
+
+// End of section. //template:end toBodyXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBody
func (data *VTP) updateFromBody(ctx context.Context, res gjson.Result) {
@@ -423,33 +605,357 @@ func (data *VTP) updateFromBody(ctx context.Context, res gjson.Result) {
data.ModeTransparentMst = types.BoolValue(false)
}
} else {
- data.ModeTransparentMst = types.BoolNull()
+ data.ModeTransparentMst = types.BoolNull()
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-vtp:mode.transparent.unknown"); !data.ModeTransparentUnknown.IsNull() {
+ if value.Exists() {
+ data.ModeTransparentUnknown = types.BoolValue(true)
+ } else {
+ data.ModeTransparentUnknown = types.BoolValue(false)
+ }
+ } else {
+ data.ModeTransparentUnknown = types.BoolNull()
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-vtp:mode.transparent.vlan"); !data.ModeTransparentVlan.IsNull() {
+ if value.Exists() {
+ data.ModeTransparentVlan = types.BoolValue(true)
+ } else {
+ data.ModeTransparentVlan = types.BoolValue(false)
+ }
+ } else {
+ data.ModeTransparentVlan = types.BoolNull()
+ }
+}
+
+// End of section. //template:end updateFromBody
+
+// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBodyXML
+
+func (data *VTP) updateFromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-vtp:file"); value.Exists() && !data.File.IsNull() {
+ data.File = types.StringValue(value.String())
+ } else {
+ data.File = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-vtp:version"); value.Exists() && !data.Version.IsNull() {
+ data.Version = types.Int64Value(value.Int())
+ } else {
+ data.Version = types.Int64Null()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-vtp:interface/interface-name"); value.Exists() && !data.Interface.IsNull() {
+ data.Interface = types.StringValue(value.String())
+ } else {
+ data.Interface = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-vtp:interface/only"); !data.InterfaceOnly.IsNull() {
+ if value.Exists() {
+ data.InterfaceOnly = types.BoolValue(true)
+ } else {
+ data.InterfaceOnly = types.BoolValue(false)
+ }
+ } else {
+ data.InterfaceOnly = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-vtp:password/hidden"); !data.PasswordHidden.IsNull() {
+ if value.Exists() {
+ data.PasswordHidden = types.BoolValue(true)
+ } else {
+ data.PasswordHidden = types.BoolValue(false)
+ }
+ } else {
+ data.PasswordHidden = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-vtp:pruning"); !data.Pruning.IsNull() {
+ if value.Exists() {
+ data.Pruning = types.BoolValue(true)
+ } else {
+ data.Pruning = types.BoolValue(false)
+ }
+ } else {
+ data.Pruning = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-vtp:domain"); value.Exists() && !data.Domain.IsNull() {
+ data.Domain = types.StringValue(value.String())
+ } else {
+ data.Domain = types.StringNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-vtp:mode/client"); !data.ModeClient.IsNull() {
+ if value.Exists() {
+ data.ModeClient = types.BoolValue(true)
+ } else {
+ data.ModeClient = types.BoolValue(false)
+ }
+ } else {
+ data.ModeClient = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-vtp:mode/client/mst"); !data.ModeClientMst.IsNull() {
+ if value.Exists() {
+ data.ModeClientMst = types.BoolValue(true)
+ } else {
+ data.ModeClientMst = types.BoolValue(false)
+ }
+ } else {
+ data.ModeClientMst = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-vtp:mode/client/unknown"); !data.ModeClientUnknown.IsNull() {
+ if value.Exists() {
+ data.ModeClientUnknown = types.BoolValue(true)
+ } else {
+ data.ModeClientUnknown = types.BoolValue(false)
+ }
+ } else {
+ data.ModeClientUnknown = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-vtp:mode/client/vlan"); !data.ModeClientVlan.IsNull() {
+ if value.Exists() {
+ data.ModeClientVlan = types.BoolValue(true)
+ } else {
+ data.ModeClientVlan = types.BoolValue(false)
+ }
+ } else {
+ data.ModeClientVlan = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-vtp:mode/off"); !data.ModeOff.IsNull() {
+ if value.Exists() {
+ data.ModeOff = types.BoolValue(true)
+ } else {
+ data.ModeOff = types.BoolValue(false)
+ }
+ } else {
+ data.ModeOff = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-vtp:mode/off/mst"); !data.ModeOffMst.IsNull() {
+ if value.Exists() {
+ data.ModeOffMst = types.BoolValue(true)
+ } else {
+ data.ModeOffMst = types.BoolValue(false)
+ }
+ } else {
+ data.ModeOffMst = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-vtp:mode/off/unknown"); !data.ModeOffUnknown.IsNull() {
+ if value.Exists() {
+ data.ModeOffUnknown = types.BoolValue(true)
+ } else {
+ data.ModeOffUnknown = types.BoolValue(false)
+ }
+ } else {
+ data.ModeOffUnknown = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-vtp:mode/off/vlan"); !data.ModeOffVlan.IsNull() {
+ if value.Exists() {
+ data.ModeOffVlan = types.BoolValue(true)
+ } else {
+ data.ModeOffVlan = types.BoolValue(false)
+ }
+ } else {
+ data.ModeOffVlan = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-vtp:mode/server"); !data.ModeServer.IsNull() {
+ if value.Exists() {
+ data.ModeServer = types.BoolValue(true)
+ } else {
+ data.ModeServer = types.BoolValue(false)
+ }
+ } else {
+ data.ModeServer = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-vtp:mode/server/mst"); !data.ModeServerMst.IsNull() {
+ if value.Exists() {
+ data.ModeServerMst = types.BoolValue(true)
+ } else {
+ data.ModeServerMst = types.BoolValue(false)
+ }
+ } else {
+ data.ModeServerMst = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-vtp:mode/server/unknown"); !data.ModeServerUnknown.IsNull() {
+ if value.Exists() {
+ data.ModeServerUnknown = types.BoolValue(true)
+ } else {
+ data.ModeServerUnknown = types.BoolValue(false)
+ }
+ } else {
+ data.ModeServerUnknown = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-vtp:mode/server/vlan"); !data.ModeServerVlan.IsNull() {
+ if value.Exists() {
+ data.ModeServerVlan = types.BoolValue(true)
+ } else {
+ data.ModeServerVlan = types.BoolValue(false)
+ }
+ } else {
+ data.ModeServerVlan = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-vtp:mode/transparent"); !data.ModeTransparent.IsNull() {
+ if value.Exists() {
+ data.ModeTransparent = types.BoolValue(true)
+ } else {
+ data.ModeTransparent = types.BoolValue(false)
+ }
+ } else {
+ data.ModeTransparent = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-vtp:mode/transparent/mst"); !data.ModeTransparentMst.IsNull() {
+ if value.Exists() {
+ data.ModeTransparentMst = types.BoolValue(true)
+ } else {
+ data.ModeTransparentMst = types.BoolValue(false)
+ }
+ } else {
+ data.ModeTransparentMst = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-vtp:mode/transparent/unknown"); !data.ModeTransparentUnknown.IsNull() {
+ if value.Exists() {
+ data.ModeTransparentUnknown = types.BoolValue(true)
+ } else {
+ data.ModeTransparentUnknown = types.BoolValue(false)
+ }
+ } else {
+ data.ModeTransparentUnknown = types.BoolNull()
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-vtp:mode/transparent/vlan"); !data.ModeTransparentVlan.IsNull() {
+ if value.Exists() {
+ data.ModeTransparentVlan = types.BoolValue(true)
+ } else {
+ data.ModeTransparentVlan = types.BoolValue(false)
+ }
+ } else {
+ data.ModeTransparentVlan = types.BoolNull()
+ }
+}
+
+// End of section. //template:end updateFromBodyXML
+
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBody
+
+func (data *VTP) fromBody(ctx context.Context, res gjson.Result) {
+ prefix := helpers.LastElement(data.getPath()) + "."
+ if res.Get(helpers.LastElement(data.getPath())).IsArray() {
+ prefix += "0."
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-vtp:file"); value.Exists() {
+ data.File = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-vtp:version"); value.Exists() {
+ data.Version = types.Int64Value(value.Int())
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-vtp:interface.interface-name"); value.Exists() {
+ data.Interface = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-vtp:interface.only"); value.Exists() {
+ data.InterfaceOnly = types.BoolValue(true)
+ } else {
+ data.InterfaceOnly = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-vtp:password.password"); value.Exists() {
+ data.Password = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-vtp:password.hidden"); value.Exists() {
+ data.PasswordHidden = types.BoolValue(true)
+ } else {
+ data.PasswordHidden = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-vtp:password.secret"); value.Exists() {
+ data.PasswordSecret = types.BoolValue(true)
+ } else {
+ data.PasswordSecret = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-vtp:pruning"); value.Exists() {
+ data.Pruning = types.BoolValue(true)
+ } else {
+ data.Pruning = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-vtp:domain"); value.Exists() {
+ data.Domain = types.StringValue(value.String())
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-vtp:mode.client"); value.Exists() {
+ data.ModeClient = types.BoolValue(true)
+ } else {
+ data.ModeClient = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-vtp:mode.client.mst"); value.Exists() {
+ data.ModeClientMst = types.BoolValue(true)
+ } else {
+ data.ModeClientMst = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-vtp:mode.client.unknown"); value.Exists() {
+ data.ModeClientUnknown = types.BoolValue(true)
+ } else {
+ data.ModeClientUnknown = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-vtp:mode.client.vlan"); value.Exists() {
+ data.ModeClientVlan = types.BoolValue(true)
+ } else {
+ data.ModeClientVlan = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-vtp:mode.off"); value.Exists() {
+ data.ModeOff = types.BoolValue(true)
+ } else {
+ data.ModeOff = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-vtp:mode.off.mst"); value.Exists() {
+ data.ModeOffMst = types.BoolValue(true)
+ } else {
+ data.ModeOffMst = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-vtp:mode.off.unknown"); value.Exists() {
+ data.ModeOffUnknown = types.BoolValue(true)
+ } else {
+ data.ModeOffUnknown = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-vtp:mode.off.vlan"); value.Exists() {
+ data.ModeOffVlan = types.BoolValue(true)
+ } else {
+ data.ModeOffVlan = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-vtp:mode.server"); value.Exists() {
+ data.ModeServer = types.BoolValue(true)
+ } else {
+ data.ModeServer = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-vtp:mode.server.mst"); value.Exists() {
+ data.ModeServerMst = types.BoolValue(true)
+ } else {
+ data.ModeServerMst = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-vtp:mode.server.unknown"); value.Exists() {
+ data.ModeServerUnknown = types.BoolValue(true)
+ } else {
+ data.ModeServerUnknown = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-vtp:mode.server.vlan"); value.Exists() {
+ data.ModeServerVlan = types.BoolValue(true)
+ } else {
+ data.ModeServerVlan = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-vtp:mode.transparent"); value.Exists() {
+ data.ModeTransparent = types.BoolValue(true)
+ } else {
+ data.ModeTransparent = types.BoolValue(false)
+ }
+ if value := res.Get(prefix + "Cisco-IOS-XE-vtp:mode.transparent.mst"); value.Exists() {
+ data.ModeTransparentMst = types.BoolValue(true)
+ } else {
+ data.ModeTransparentMst = types.BoolValue(false)
}
- if value := res.Get(prefix + "Cisco-IOS-XE-vtp:mode.transparent.unknown"); !data.ModeTransparentUnknown.IsNull() {
- if value.Exists() {
- data.ModeTransparentUnknown = types.BoolValue(true)
- } else {
- data.ModeTransparentUnknown = types.BoolValue(false)
- }
+ if value := res.Get(prefix + "Cisco-IOS-XE-vtp:mode.transparent.unknown"); value.Exists() {
+ data.ModeTransparentUnknown = types.BoolValue(true)
} else {
- data.ModeTransparentUnknown = types.BoolNull()
+ data.ModeTransparentUnknown = types.BoolValue(false)
}
- if value := res.Get(prefix + "Cisco-IOS-XE-vtp:mode.transparent.vlan"); !data.ModeTransparentVlan.IsNull() {
- if value.Exists() {
- data.ModeTransparentVlan = types.BoolValue(true)
- } else {
- data.ModeTransparentVlan = types.BoolValue(false)
- }
+ if value := res.Get(prefix + "Cisco-IOS-XE-vtp:mode.transparent.vlan"); value.Exists() {
+ data.ModeTransparentVlan = types.BoolValue(true)
} else {
- data.ModeTransparentVlan = types.BoolNull()
+ data.ModeTransparentVlan = types.BoolValue(false)
}
}
-// End of section. //template:end updateFromBody
+// End of section. //template:end fromBody
-// Section below is generated&owned by "gen/generator.go". //template:begin fromBody
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyData
-func (data *VTP) fromBody(ctx context.Context, res gjson.Result) {
+func (data *VTPData) fromBody(ctx context.Context, res gjson.Result) {
prefix := helpers.LastElement(data.getPath()) + "."
if res.Get(helpers.LastElement(data.getPath())).IsArray() {
prefix += "0."
@@ -571,133 +1077,251 @@ func (data *VTP) fromBody(ctx context.Context, res gjson.Result) {
}
}
-// End of section. //template:end fromBody
+// End of section. //template:end fromBodyData
-// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyData
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyXML
-func (data *VTPData) fromBody(ctx context.Context, res gjson.Result) {
- prefix := helpers.LastElement(data.getPath()) + "."
- if res.Get(helpers.LastElement(data.getPath())).IsArray() {
- prefix += "0."
+func (data *VTP) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-vtp:file"); value.Exists() {
+ data.File = types.StringValue(value.String())
}
- if value := res.Get(prefix + "Cisco-IOS-XE-vtp:file"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-vtp:version"); value.Exists() {
+ data.Version = types.Int64Value(value.Int())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-vtp:interface/interface-name"); value.Exists() {
+ data.Interface = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-vtp:interface/only"); value.Exists() {
+ data.InterfaceOnly = types.BoolValue(true)
+ } else {
+ data.InterfaceOnly = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-vtp:password/password"); value.Exists() {
+ data.Password = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-vtp:password/hidden"); value.Exists() {
+ data.PasswordHidden = types.BoolValue(true)
+ } else {
+ data.PasswordHidden = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-vtp:password/secret"); value.Exists() {
+ data.PasswordSecret = types.BoolValue(true)
+ } else {
+ data.PasswordSecret = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-vtp:pruning"); value.Exists() {
+ data.Pruning = types.BoolValue(true)
+ } else {
+ data.Pruning = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-vtp:domain"); value.Exists() {
+ data.Domain = types.StringValue(value.String())
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-vtp:mode/client"); value.Exists() {
+ data.ModeClient = types.BoolValue(true)
+ } else {
+ data.ModeClient = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-vtp:mode/client/mst"); value.Exists() {
+ data.ModeClientMst = types.BoolValue(true)
+ } else {
+ data.ModeClientMst = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-vtp:mode/client/unknown"); value.Exists() {
+ data.ModeClientUnknown = types.BoolValue(true)
+ } else {
+ data.ModeClientUnknown = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-vtp:mode/client/vlan"); value.Exists() {
+ data.ModeClientVlan = types.BoolValue(true)
+ } else {
+ data.ModeClientVlan = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-vtp:mode/off"); value.Exists() {
+ data.ModeOff = types.BoolValue(true)
+ } else {
+ data.ModeOff = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-vtp:mode/off/mst"); value.Exists() {
+ data.ModeOffMst = types.BoolValue(true)
+ } else {
+ data.ModeOffMst = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-vtp:mode/off/unknown"); value.Exists() {
+ data.ModeOffUnknown = types.BoolValue(true)
+ } else {
+ data.ModeOffUnknown = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-vtp:mode/off/vlan"); value.Exists() {
+ data.ModeOffVlan = types.BoolValue(true)
+ } else {
+ data.ModeOffVlan = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-vtp:mode/server"); value.Exists() {
+ data.ModeServer = types.BoolValue(true)
+ } else {
+ data.ModeServer = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-vtp:mode/server/mst"); value.Exists() {
+ data.ModeServerMst = types.BoolValue(true)
+ } else {
+ data.ModeServerMst = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-vtp:mode/server/unknown"); value.Exists() {
+ data.ModeServerUnknown = types.BoolValue(true)
+ } else {
+ data.ModeServerUnknown = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-vtp:mode/server/vlan"); value.Exists() {
+ data.ModeServerVlan = types.BoolValue(true)
+ } else {
+ data.ModeServerVlan = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-vtp:mode/transparent"); value.Exists() {
+ data.ModeTransparent = types.BoolValue(true)
+ } else {
+ data.ModeTransparent = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-vtp:mode/transparent/mst"); value.Exists() {
+ data.ModeTransparentMst = types.BoolValue(true)
+ } else {
+ data.ModeTransparentMst = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-vtp:mode/transparent/unknown"); value.Exists() {
+ data.ModeTransparentUnknown = types.BoolValue(true)
+ } else {
+ data.ModeTransparentUnknown = types.BoolValue(false)
+ }
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-vtp:mode/transparent/vlan"); value.Exists() {
+ data.ModeTransparentVlan = types.BoolValue(true)
+ } else {
+ data.ModeTransparentVlan = types.BoolValue(false)
+ }
+}
+
+// End of section. //template:end fromBodyXML
+
+// Section below is generated&owned by "gen/generator.go". //template:begin fromBodyDataXML
+
+func (data *VTPData) fromBodyXML(ctx context.Context, res xmldot.Result) {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-vtp:file"); value.Exists() {
data.File = types.StringValue(value.String())
}
- if value := res.Get(prefix + "Cisco-IOS-XE-vtp:version"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-vtp:version"); value.Exists() {
data.Version = types.Int64Value(value.Int())
}
- if value := res.Get(prefix + "Cisco-IOS-XE-vtp:interface.interface-name"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-vtp:interface/interface-name"); value.Exists() {
data.Interface = types.StringValue(value.String())
}
- if value := res.Get(prefix + "Cisco-IOS-XE-vtp:interface.only"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-vtp:interface/only"); value.Exists() {
data.InterfaceOnly = types.BoolValue(true)
} else {
data.InterfaceOnly = types.BoolValue(false)
}
- if value := res.Get(prefix + "Cisco-IOS-XE-vtp:password.password"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-vtp:password/password"); value.Exists() {
data.Password = types.StringValue(value.String())
}
- if value := res.Get(prefix + "Cisco-IOS-XE-vtp:password.hidden"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-vtp:password/hidden"); value.Exists() {
data.PasswordHidden = types.BoolValue(true)
} else {
data.PasswordHidden = types.BoolValue(false)
}
- if value := res.Get(prefix + "Cisco-IOS-XE-vtp:password.secret"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-vtp:password/secret"); value.Exists() {
data.PasswordSecret = types.BoolValue(true)
} else {
data.PasswordSecret = types.BoolValue(false)
}
- if value := res.Get(prefix + "Cisco-IOS-XE-vtp:pruning"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-vtp:pruning"); value.Exists() {
data.Pruning = types.BoolValue(true)
} else {
data.Pruning = types.BoolValue(false)
}
- if value := res.Get(prefix + "Cisco-IOS-XE-vtp:domain"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-vtp:domain"); value.Exists() {
data.Domain = types.StringValue(value.String())
}
- if value := res.Get(prefix + "Cisco-IOS-XE-vtp:mode.client"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-vtp:mode/client"); value.Exists() {
data.ModeClient = types.BoolValue(true)
} else {
data.ModeClient = types.BoolValue(false)
}
- if value := res.Get(prefix + "Cisco-IOS-XE-vtp:mode.client.mst"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-vtp:mode/client/mst"); value.Exists() {
data.ModeClientMst = types.BoolValue(true)
} else {
data.ModeClientMst = types.BoolValue(false)
}
- if value := res.Get(prefix + "Cisco-IOS-XE-vtp:mode.client.unknown"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-vtp:mode/client/unknown"); value.Exists() {
data.ModeClientUnknown = types.BoolValue(true)
} else {
data.ModeClientUnknown = types.BoolValue(false)
}
- if value := res.Get(prefix + "Cisco-IOS-XE-vtp:mode.client.vlan"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-vtp:mode/client/vlan"); value.Exists() {
data.ModeClientVlan = types.BoolValue(true)
} else {
data.ModeClientVlan = types.BoolValue(false)
}
- if value := res.Get(prefix + "Cisco-IOS-XE-vtp:mode.off"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-vtp:mode/off"); value.Exists() {
data.ModeOff = types.BoolValue(true)
} else {
data.ModeOff = types.BoolValue(false)
}
- if value := res.Get(prefix + "Cisco-IOS-XE-vtp:mode.off.mst"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-vtp:mode/off/mst"); value.Exists() {
data.ModeOffMst = types.BoolValue(true)
} else {
data.ModeOffMst = types.BoolValue(false)
}
- if value := res.Get(prefix + "Cisco-IOS-XE-vtp:mode.off.unknown"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-vtp:mode/off/unknown"); value.Exists() {
data.ModeOffUnknown = types.BoolValue(true)
} else {
data.ModeOffUnknown = types.BoolValue(false)
}
- if value := res.Get(prefix + "Cisco-IOS-XE-vtp:mode.off.vlan"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-vtp:mode/off/vlan"); value.Exists() {
data.ModeOffVlan = types.BoolValue(true)
} else {
data.ModeOffVlan = types.BoolValue(false)
}
- if value := res.Get(prefix + "Cisco-IOS-XE-vtp:mode.server"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-vtp:mode/server"); value.Exists() {
data.ModeServer = types.BoolValue(true)
} else {
data.ModeServer = types.BoolValue(false)
}
- if value := res.Get(prefix + "Cisco-IOS-XE-vtp:mode.server.mst"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-vtp:mode/server/mst"); value.Exists() {
data.ModeServerMst = types.BoolValue(true)
} else {
data.ModeServerMst = types.BoolValue(false)
}
- if value := res.Get(prefix + "Cisco-IOS-XE-vtp:mode.server.unknown"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-vtp:mode/server/unknown"); value.Exists() {
data.ModeServerUnknown = types.BoolValue(true)
} else {
data.ModeServerUnknown = types.BoolValue(false)
}
- if value := res.Get(prefix + "Cisco-IOS-XE-vtp:mode.server.vlan"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-vtp:mode/server/vlan"); value.Exists() {
data.ModeServerVlan = types.BoolValue(true)
} else {
data.ModeServerVlan = types.BoolValue(false)
}
- if value := res.Get(prefix + "Cisco-IOS-XE-vtp:mode.transparent"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-vtp:mode/transparent"); value.Exists() {
data.ModeTransparent = types.BoolValue(true)
} else {
data.ModeTransparent = types.BoolValue(false)
}
- if value := res.Get(prefix + "Cisco-IOS-XE-vtp:mode.transparent.mst"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-vtp:mode/transparent/mst"); value.Exists() {
data.ModeTransparentMst = types.BoolValue(true)
} else {
data.ModeTransparentMst = types.BoolValue(false)
}
- if value := res.Get(prefix + "Cisco-IOS-XE-vtp:mode.transparent.unknown"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-vtp:mode/transparent/unknown"); value.Exists() {
data.ModeTransparentUnknown = types.BoolValue(true)
} else {
data.ModeTransparentUnknown = types.BoolValue(false)
}
- if value := res.Get(prefix + "Cisco-IOS-XE-vtp:mode.transparent.vlan"); value.Exists() {
+ if value := helpers.GetFromXPath(res, "data/"+data.getXPath()+"/Cisco-IOS-XE-vtp:mode/transparent/vlan"); value.Exists() {
data.ModeTransparentVlan = types.BoolValue(true)
} else {
data.ModeTransparentVlan = types.BoolValue(false)
}
}
-// End of section. //template:end fromBodyData
+// End of section. //template:end fromBodyDataXML
// Section below is generated&owned by "gen/generator.go". //template:begin getDeletedItems
@@ -778,6 +1402,85 @@ func (data *VTP) getDeletedItems(ctx context.Context, state VTP) []string {
// End of section. //template:end getDeletedItems
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletedItemsXML
+
+func (data *VTP) addDeletedItemsXML(ctx context.Context, state VTP, body string) string {
+ b := netconf.NewBody(body)
+ if !state.File.IsNull() && data.File.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-vtp:file")
+ }
+ if !state.Interface.IsNull() && data.Interface.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-vtp:interface/interface-name")
+ }
+ if !state.InterfaceOnly.IsNull() && data.InterfaceOnly.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-vtp:interface/only")
+ }
+ if !state.Password.IsNull() && data.Password.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-vtp:password/password")
+ }
+ if !state.PasswordHidden.IsNull() && data.PasswordHidden.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-vtp:password/hidden")
+ }
+ if !state.PasswordSecret.IsNull() && data.PasswordSecret.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-vtp:password/secret")
+ }
+ if !state.Pruning.IsNull() && data.Pruning.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-vtp:pruning")
+ }
+ if !state.ModeClient.IsNull() && data.ModeClient.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-vtp:mode/client")
+ }
+ if !state.ModeClientMst.IsNull() && data.ModeClientMst.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-vtp:mode/client/mst")
+ }
+ if !state.ModeClientUnknown.IsNull() && data.ModeClientUnknown.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-vtp:mode/client/unknown")
+ }
+ if !state.ModeClientVlan.IsNull() && data.ModeClientVlan.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-vtp:mode/client/vlan")
+ }
+ if !state.ModeOff.IsNull() && data.ModeOff.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-vtp:mode/off")
+ }
+ if !state.ModeOffMst.IsNull() && data.ModeOffMst.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-vtp:mode/off/mst")
+ }
+ if !state.ModeOffUnknown.IsNull() && data.ModeOffUnknown.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-vtp:mode/off/unknown")
+ }
+ if !state.ModeOffVlan.IsNull() && data.ModeOffVlan.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-vtp:mode/off/vlan")
+ }
+ if !state.ModeServer.IsNull() && data.ModeServer.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-vtp:mode/server")
+ }
+ if !state.ModeServerMst.IsNull() && data.ModeServerMst.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-vtp:mode/server/mst")
+ }
+ if !state.ModeServerUnknown.IsNull() && data.ModeServerUnknown.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-vtp:mode/server/unknown")
+ }
+ if !state.ModeServerVlan.IsNull() && data.ModeServerVlan.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-vtp:mode/server/vlan")
+ }
+ if !state.ModeTransparent.IsNull() && data.ModeTransparent.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-vtp:mode/transparent")
+ }
+ if !state.ModeTransparentMst.IsNull() && data.ModeTransparentMst.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-vtp:mode/transparent/mst")
+ }
+ if !state.ModeTransparentUnknown.IsNull() && data.ModeTransparentUnknown.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-vtp:mode/transparent/unknown")
+ }
+ if !state.ModeTransparentVlan.IsNull() && data.ModeTransparentVlan.IsNull() {
+ b = helpers.RemoveFromXPath(b, state.getXPath()+"/Cisco-IOS-XE-vtp:mode/transparent/vlan")
+ }
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletedItemsXML
+
// Section below is generated&owned by "gen/generator.go". //template:begin getEmptyLeafsDelete
func (data *VTP) getEmptyLeafsDelete(ctx context.Context) []string {
@@ -926,3 +1629,82 @@ func (data *VTP) getDeletePaths(ctx context.Context) []string {
}
// End of section. //template:end getDeletePaths
+
+// Section below is generated&owned by "gen/generator.go". //template:begin addDeletePathsXML
+
+func (data *VTP) addDeletePathsXML(ctx context.Context, body string) string {
+ b := netconf.NewBody(body)
+ if !data.File.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-vtp:file")
+ }
+ if !data.Interface.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-vtp:interface/interface-name")
+ }
+ if !data.InterfaceOnly.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-vtp:interface/only")
+ }
+ if !data.Password.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-vtp:password/password")
+ }
+ if !data.PasswordHidden.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-vtp:password/hidden")
+ }
+ if !data.PasswordSecret.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-vtp:password/secret")
+ }
+ if !data.Pruning.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-vtp:pruning")
+ }
+ if !data.ModeClient.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-vtp:mode/client")
+ }
+ if !data.ModeClientMst.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-vtp:mode/client/mst")
+ }
+ if !data.ModeClientUnknown.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-vtp:mode/client/unknown")
+ }
+ if !data.ModeClientVlan.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-vtp:mode/client/vlan")
+ }
+ if !data.ModeOff.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-vtp:mode/off")
+ }
+ if !data.ModeOffMst.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-vtp:mode/off/mst")
+ }
+ if !data.ModeOffUnknown.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-vtp:mode/off/unknown")
+ }
+ if !data.ModeOffVlan.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-vtp:mode/off/vlan")
+ }
+ if !data.ModeServer.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-vtp:mode/server")
+ }
+ if !data.ModeServerMst.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-vtp:mode/server/mst")
+ }
+ if !data.ModeServerUnknown.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-vtp:mode/server/unknown")
+ }
+ if !data.ModeServerVlan.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-vtp:mode/server/vlan")
+ }
+ if !data.ModeTransparent.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-vtp:mode/transparent")
+ }
+ if !data.ModeTransparentMst.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-vtp:mode/transparent/mst")
+ }
+ if !data.ModeTransparentUnknown.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-vtp:mode/transparent/unknown")
+ }
+ if !data.ModeTransparentVlan.IsNull() {
+ b = helpers.RemoveFromXPath(b, data.getXPath()+"/Cisco-IOS-XE-vtp:mode/transparent/vlan")
+ }
+
+ return b.Res()
+}
+
+// End of section. //template:end addDeletePathsXML
diff --git a/internal/provider/model_iosxe_restconf.go b/internal/provider/model_iosxe_yang.go
similarity index 58%
rename from internal/provider/model_iosxe_restconf.go
rename to internal/provider/model_iosxe_yang.go
index 37f51f34..b38f3c05 100644
--- a/internal/provider/model_iosxe_restconf.go
+++ b/internal/provider/model_iosxe_yang.go
@@ -23,42 +23,49 @@ import (
"strings"
"github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
+ "github.com/hashicorp/terraform-plugin-framework/attr"
"github.com/hashicorp/terraform-plugin-framework/types"
+ "github.com/netascode/go-netconf"
"github.com/netascode/go-restconf"
+ "github.com/netascode/xmldot"
"github.com/tidwall/gjson"
"github.com/tidwall/sjson"
)
-type Restconf struct {
- Device types.String `tfsdk:"device"`
- Id types.String `tfsdk:"id"`
- Path types.String `tfsdk:"path"`
- Delete types.Bool `tfsdk:"delete"`
- Attributes types.Map `tfsdk:"attributes"`
- Lists []RestconfList `tfsdk:"lists"`
+type Yang struct {
+ Device types.String `tfsdk:"device"`
+ Id types.String `tfsdk:"id"`
+ Path types.String `tfsdk:"path"`
+ Delete types.Bool `tfsdk:"delete"`
+ Attributes types.Map `tfsdk:"attributes"`
+ Lists []YangList `tfsdk:"lists"`
}
-type RestconfList struct {
+type YangList struct {
Name types.String `tfsdk:"name"`
Key types.String `tfsdk:"key"`
Items []types.Map `tfsdk:"items"`
Values types.List `tfsdk:"values"`
}
-type RestconfDataSourceModel struct {
+type YangDataSourceModel struct {
Device types.String `tfsdk:"device"`
Id types.String `tfsdk:"id"`
Path types.String `tfsdk:"path"`
Attributes types.Map `tfsdk:"attributes"`
}
-func (data Restconf) getPath() string {
- return data.Path.ValueString()
+func (data Yang) getPath() string {
+ return helpers.ConvertXPathToRestconfPath(data.Path.ValueString())
+}
+
+func (data YangDataSourceModel) getPath() string {
+ return helpers.ConvertXPathToRestconfPath(data.Path.ValueString())
}
// if last path element has a key -> remove it
-func (data Restconf) getPathShort() string {
- path := data.Path.ValueString()
+func (data Yang) getPathShort() string {
+ path := data.getPath()
re := regexp.MustCompile(`(.*)=[^\/]*$`)
matches := re.FindStringSubmatch(path)
if len(matches) <= 1 {
@@ -67,20 +74,20 @@ func (data Restconf) getPathShort() string {
return matches[1]
}
-func (data Restconf) toBody(ctx context.Context) string {
- body := `{"` + helpers.LastElement(data.Path.ValueString()) + `":{}}`
+func (data Yang) toBody(ctx context.Context) string {
+ body := `{"` + helpers.LastElement(data.getPath()) + `":{}}`
var attributes map[string]string
data.Attributes.ElementsAs(ctx, &attributes, false)
for attr, value := range attributes {
attr = strings.ReplaceAll(attr, "/", ".")
- body, _ = sjson.Set(body, helpers.LastElement(data.Path.ValueString())+"."+attr, value)
+ body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+attr, value)
}
for i := range data.Lists {
listName := strings.ReplaceAll(data.Lists[i].Name.ValueString(), "/", ".")
if len(data.Lists[i].Items) > 0 {
- body, _ = sjson.Set(body, helpers.LastElement(data.Path.ValueString())+"."+listName, []interface{}{})
+ body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+listName, []interface{}{})
for ii := range data.Lists[i].Items {
var listAttributes map[string]string
data.Lists[i].Items[ii].ElementsAs(ctx, &listAttributes, false)
@@ -89,19 +96,49 @@ func (data Restconf) toBody(ctx context.Context) string {
attr = strings.ReplaceAll(attr, "/", ".")
attrs = attrs.Set(attr, value)
}
- body, _ = sjson.SetRaw(body, helpers.LastElement(data.Path.ValueString())+"."+listName+".-1", attrs.Str)
+ body, _ = sjson.SetRaw(body, helpers.LastElement(data.getPath())+"."+listName+".-1", attrs.Str)
}
} else if len(data.Lists[i].Values.Elements()) > 0 {
var values []string
data.Lists[i].Values.ElementsAs(ctx, &values, false)
- body, _ = sjson.Set(body, helpers.LastElement(data.Path.ValueString())+"."+listName, values)
+ body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+listName, values)
}
}
return body
}
-func (data *Restconf) fromBody(ctx context.Context, res gjson.Result) {
+func (data Yang) toBodyXML(ctx context.Context) string {
+ body := netconf.Body{}
+
+ var attributes map[string]string
+ data.Attributes.ElementsAs(ctx, &attributes, false)
+
+ for attr, value := range attributes {
+ body = helpers.SetFromXPath(body, data.Path.ValueString()+"/"+attr, value)
+ }
+ for i := range data.Lists {
+ if len(data.Lists[i].Items) > 0 {
+ for ii := range data.Lists[i].Items {
+ var listAttributes map[string]string
+ data.Lists[i].Items[ii].ElementsAs(ctx, &listAttributes, false)
+ attrs := netconf.Body{}
+ for attr, value := range listAttributes {
+ attrs = helpers.SetFromXPath(attrs, attr, value)
+ }
+ body = helpers.SetRawFromXPath(body, data.Path.ValueString()+"/"+data.Lists[i].Name.ValueString(), attrs.Res())
+ }
+ } else if len(data.Lists[i].Values.Elements()) > 0 {
+ var values []string
+ data.Lists[i].Values.ElementsAs(ctx, &values, false)
+ body = helpers.SetFromXPath(body, data.Path.ValueString()+"/"+data.Lists[i].Name.ValueString(), values)
+ }
+ }
+
+ return body.Res()
+}
+
+func (data *Yang) fromBody(ctx context.Context, res gjson.Result) {
prefix := helpers.LastElement(data.getPath()) + "."
if res.Get(helpers.LastElement(data.getPath())).IsArray() {
prefix += "0."
@@ -179,13 +216,80 @@ func (data *Restconf) fromBody(ctx context.Context, res gjson.Result) {
}
}
-func (data *Restconf) getDeletedItems(ctx context.Context, state Restconf) []string {
+func (data *Yang) fromBodyXML(ctx context.Context, res xmldot.Result) {
+
+ // Parse attributes
+ attributes := data.Attributes.Elements()
+ for attr := range attributes {
+ value := helpers.GetFromXPath(res, "data"+data.Path.ValueString()+"/"+attr)
+ if !value.Exists() || value.String() == "" {
+ attributes[attr] = types.StringValue("")
+ } else {
+ attributes[attr] = types.StringValue(value.String())
+ }
+ }
+ data.Attributes = types.MapValueMust(types.StringType, attributes)
+
+ // Parse lists
+ for i := range data.Lists {
+ keys := strings.Split(data.Lists[i].Key.ValueString(), ",")
+ listName := data.Lists[i].Name.ValueString()
+
+ if len(data.Lists[i].Items) > 0 {
+ // Complex list items with multiple attributes
+ for ii := range data.Lists[i].Items {
+ // Get key values from plan
+ var keyValues []string
+ for _, key := range keys {
+ v, _ := data.Lists[i].Items[ii].Elements()[key].ToTerraformValue(ctx)
+ var keyValue string
+ v.As(&keyValue)
+ keyValues = append(keyValues, keyValue)
+ }
+
+ // Build XPath to find the specific list item by key(s)
+ xpathPredicates := ""
+ for ik, key := range keys {
+ xpathPredicates += "[" + key + "='" + keyValues[ik] + "']"
+ }
+ itemXPath := listName + xpathPredicates
+
+ // Find the matching list item in XML response
+ itemResult := helpers.GetFromXPath(res, "data"+data.Path.ValueString()+"/"+itemXPath)
+
+ // Parse attributes from the matched item
+ itemAttributes := data.Lists[i].Items[ii].Elements()
+ for attr := range itemAttributes {
+ value := helpers.GetFromXPath(itemResult, attr)
+ if !value.Exists() || value.String() == "" {
+ itemAttributes[attr] = types.StringValue("")
+ } else {
+ itemAttributes[attr] = types.StringValue(value.String())
+ }
+ }
+ data.Lists[i].Items[ii] = types.MapValueMust(types.StringType, itemAttributes)
+ }
+ } else if len(data.Lists[i].Values.Elements()) > 0 {
+ // Simple leaf-list values
+ listResult := helpers.GetFromXPath(res, "data"+data.Path.ValueString()+"/"+listName)
+ if listResult.IsArray() {
+ values := make([]attr.Value, 0)
+ for _, v := range listResult.Array() {
+ values = append(values, types.StringValue(v.String()))
+ }
+ data.Lists[i].Values = types.ListValueMust(data.Lists[i].Values.ElementType(ctx), values)
+ }
+ }
+ }
+}
+
+func (data *Yang) getDeletedItems(ctx context.Context, state Yang) []string {
deletedItems := make([]string, 0)
for l := range state.Lists {
name := state.Lists[l].Name.ValueString()
namePath := strings.ReplaceAll(name, "/", ".")
keys := strings.Split(state.Lists[l].Key.ValueString(), ",")
- var dataList RestconfList
+ var dataList YangList
for _, dl := range data.Lists {
if dl.Name.ValueString() == name {
dataList = dl
diff --git a/internal/provider/provider.go b/internal/provider/provider.go
index 76927e45..5feed8af 100644
--- a/internal/provider/provider.go
+++ b/internal/provider/provider.go
@@ -22,18 +22,25 @@ package provider
// Section below is generated&owned by "gen/generator.go". //template:begin provider
import (
"context"
+ "fmt"
"os"
"slices"
"strconv"
"strings"
+ "sync"
+ "time"
+ "github.com/CiscoDevNet/terraform-provider-iosxe/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/datasource"
"github.com/hashicorp/terraform-plugin-framework/provider"
"github.com/hashicorp/terraform-plugin-framework/provider/schema"
"github.com/hashicorp/terraform-plugin-framework/resource"
"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-netconf"
"github.com/netascode/go-restconf"
)
@@ -54,9 +61,12 @@ type IosxeProviderModel struct {
Username types.String `tfsdk:"username"`
Password types.String `tfsdk:"password"`
URL types.String `tfsdk:"url"`
+ Host types.String `tfsdk:"host"`
Insecure types.Bool `tfsdk:"insecure"`
+ Protocol types.String `tfsdk:"protocol"`
Retries types.Int64 `tfsdk:"retries"`
LockReleaseTimeout types.Int64 `tfsdk:"lock_release_timeout"`
+ ReuseConnection types.Bool `tfsdk:"reuse_connection"`
SelectedDevices types.List `tfsdk:"selected_devices"`
Devices []IosxeProviderModelDevice `tfsdk:"devices"`
}
@@ -64,6 +74,7 @@ type IosxeProviderModel struct {
type IosxeProviderModelDevice struct {
Name types.String `tfsdk:"name"`
URL types.String `tfsdk:"url"`
+ Host types.String `tfsdk:"host"`
Managed types.Bool `tfsdk:"managed"`
}
@@ -73,8 +84,13 @@ type IosxeProviderData struct {
}
type IosxeProviderDataDevice struct {
- Client *restconf.Client
- Managed bool
+ RestconfClient *restconf.Client
+ NetconfClient *netconf.Client
+ Protocol string
+ ReuseConnection bool
+ Managed bool
+ NetconfWriteMutex sync.Mutex // Serializes NETCONF write operations
+ NetconfConnMutex sync.Mutex // Serializes NETCONF connection management (Reopen/Close)
}
func (p *IosxeProvider) Metadata(ctx context.Context, req provider.MetadataRequest, resp *provider.MetadataResponse) {
@@ -95,13 +111,25 @@ func (p *IosxeProvider) Schema(ctx context.Context, req provider.SchemaRequest,
Sensitive: true,
},
"url": schema.StringAttribute{
- MarkdownDescription: "URL of the Cisco IOS-XE device. Optionally a port can be added with `:12345`. The default port is `443`. This can also be set as the IOSXE_URL environment variable.",
+ MarkdownDescription: "URL of the Cisco IOS-XE device for RESTCONF protocol. Optionally a port can be added with `:12345`. The default port is `443`. This can also be set as the IOSXE_URL environment variable. **Deprecated: Use `host` instead for protocol-agnostic configuration.**",
+ Optional: true,
+ DeprecationMessage: "Use 'host' attribute instead for protocol-agnostic configuration",
+ },
+ "host": schema.StringAttribute{
+ MarkdownDescription: "Hostname or IP address of the Cisco IOS-XE device. Optionally a port can be added with `:port`. Default port is `443` for RESTCONF and `830` for NETCONF. This can also be set as the IOSXE_HOST environment variable.",
Optional: true,
},
"insecure": schema.BoolAttribute{
MarkdownDescription: "Allow insecure HTTPS client. This can also be set as the IOSXE_INSECURE environment variable. Defaults to `true`.",
Optional: true,
},
+ "protocol": schema.StringAttribute{
+ MarkdownDescription: "Protocol to use for device communication. Either `restconf` (HTTPS) or `netconf` (SSH). This can also be set as the IOSXE_PROTOCOL environment variable. Defaults to `restconf`.",
+ Optional: true,
+ Validators: []validator.String{
+ stringvalidator.OneOf("restconf", "netconf"),
+ },
+ },
"retries": schema.Int64Attribute{
MarkdownDescription: "Number of retries for REST API calls. This can also be set as the IOSXE_RETRIES environment variable. Defaults to `10`.",
Optional: true,
@@ -116,6 +144,10 @@ func (p *IosxeProvider) Schema(ctx context.Context, req provider.SchemaRequest,
int64validator.Between(0, 600),
},
},
+ "reuse_connection": schema.BoolAttribute{
+ MarkdownDescription: "Keep NETCONF connections open between operations for better performance. When disabled, connections are closed and reopened for each operation. Only applies to NETCONF protocol. This can also be set as the IOSXE_REUSE_CONNECTION environment variable. Defaults to `true`.",
+ Optional: true,
+ },
"selected_devices": schema.ListAttribute{
MarkdownDescription: "This can be used to select a list of devices to manage from the `devices` list. Selected devices will be managed while other devices will be skipped and their state will be frozen. This can be used to deploy changes to a subset of devices. Defaults to all devices.",
Optional: true,
@@ -131,8 +163,13 @@ func (p *IosxeProvider) Schema(ctx context.Context, req provider.SchemaRequest,
Required: true,
},
"url": schema.StringAttribute{
- MarkdownDescription: "URL of the Cisco IOS-XE device.",
- Required: true,
+ MarkdownDescription: "URL of the Cisco IOS-XE device for RESTCONF protocol. **Deprecated: Use `host` instead.**",
+ Optional: true,
+ DeprecationMessage: "Use 'host' attribute instead",
+ },
+ "host": schema.StringAttribute{
+ MarkdownDescription: "Hostname or IP address of the Cisco IOS-XE device. Optionally a port can be added with `:port`.",
+ Optional: true,
},
"managed": schema.BoolAttribute{
MarkdownDescription: "Enable or disable device management. This can be used to temporarily skip a device due to maintainance for example. Defaults to `true`.",
@@ -206,31 +243,80 @@ func (p *IosxeProvider) Configure(ctx context.Context, req provider.ConfigureReq
return
}
- // User must provide a username to the provider
- var url string
- if config.URL.IsUnknown() {
- // Cannot connect to client with an unknown value
+ // Determine protocol
+ var protocol string
+ if config.Protocol.IsUnknown() {
resp.Diagnostics.AddWarning(
"Unable to create client",
- "Cannot use unknown value as url",
+ "Cannot use unknown value as protocol",
)
return
}
- if config.URL.IsNull() {
- url = os.Getenv("IOSXE_URL")
- if url == "" && len(config.Devices) > 0 {
- url = config.Devices[0].URL.ValueString()
+ if config.Protocol.IsNull() {
+ protocol = os.Getenv("IOSXE_PROTOCOL")
+ if protocol == "" {
+ protocol = "restconf" // default
}
} else {
- url = config.URL.ValueString()
+ protocol = config.Protocol.ValueString()
}
- if url == "" {
- // Error vs warning - empty value must stop execution
+ // Validate protocol
+ if protocol != "restconf" && protocol != "netconf" {
+ resp.Diagnostics.AddError(
+ "Invalid protocol",
+ fmt.Sprintf("Protocol must be 'restconf' or 'netconf', got: %s", protocol),
+ )
+ return
+ }
+
+ // User must provide a host or url to the provider
+ var host string
+ if config.Host.IsUnknown() && config.URL.IsUnknown() {
+ resp.Diagnostics.AddWarning(
+ "Unable to create client",
+ "Cannot use unknown value as host or url",
+ )
+ return
+ }
+
+ // Priority: host > url > IOSXE_HOST env > IOSXE_URL env > first device
+ if !config.Host.IsNull() {
+ host = config.Host.ValueString()
+ } else if !config.URL.IsNull() {
+ host = config.URL.ValueString()
+ // Strip https:// prefix for NETCONF
+ if protocol == "netconf" {
+ host = strings.TrimPrefix(host, "https://")
+ host = strings.TrimPrefix(host, "http://")
+ }
+ } else {
+ host = os.Getenv("IOSXE_HOST")
+ if host == "" {
+ host = os.Getenv("IOSXE_URL")
+ if protocol == "netconf" {
+ host = strings.TrimPrefix(host, "https://")
+ host = strings.TrimPrefix(host, "http://")
+ }
+ }
+ if host == "" && len(config.Devices) > 0 {
+ if !config.Devices[0].Host.IsNull() {
+ host = config.Devices[0].Host.ValueString()
+ } else {
+ host = config.Devices[0].URL.ValueString()
+ if protocol == "netconf" {
+ host = strings.TrimPrefix(host, "https://")
+ host = strings.TrimPrefix(host, "http://")
+ }
+ }
+ }
+ }
+
+ if host == "" {
resp.Diagnostics.AddError(
- "Unable to find url",
- "URL cannot be an empty string",
+ "Unable to find host",
+ "Host or URL cannot be an empty string",
)
return
}
@@ -298,6 +384,26 @@ func (p *IosxeProvider) Configure(ctx context.Context, req provider.ConfigureReq
lockReleaseTimeout = config.LockReleaseTimeout.ValueInt64()
}
+ var reuseConnection bool
+ if config.ReuseConnection.IsUnknown() {
+ resp.Diagnostics.AddWarning(
+ "Unable to create client",
+ "Cannot use unknown value as reuseConnection",
+ )
+ return
+ }
+
+ if config.ReuseConnection.IsNull() {
+ reuseConnectionStr := os.Getenv("IOSXE_REUSE_CONNECTION")
+ if reuseConnectionStr == "" {
+ reuseConnection = true
+ } else {
+ reuseConnection, _ = strconv.ParseBool(reuseConnectionStr)
+ }
+ } else {
+ reuseConnection = config.ReuseConnection.ValueBool()
+ }
+
var selectedDevices []string
if config.SelectedDevices.IsUnknown() {
// Cannot connect to client with an unknown value
@@ -321,15 +427,52 @@ func (p *IosxeProvider) Configure(ctx context.Context, req provider.ConfigureReq
data := IosxeProviderData{}
data.Devices = make(map[string]*IosxeProviderDataDevice)
- c, err := restconf.NewClient(url, username, password, insecure, restconf.MaxRetries(int(retries)), restconf.SkipDiscovery("/restconf", true), restconf.LockReleaseTimeout(int(lockReleaseTimeout)))
- if err != nil {
- resp.Diagnostics.AddError(
- "Unable to create client",
- "Unable to create restconf client:\n\n"+err.Error(),
- )
- return
+ // Create default device client based on protocol
+ if protocol == "restconf" {
+ // For RESTCONF, add https:// prefix if not present
+ url := host
+ if !strings.HasPrefix(url, "https://") && !strings.HasPrefix(url, "http://") {
+ url = "https://" + url
+ }
+ c, err := restconf.NewClient(url, username, password, insecure, restconf.MaxRetries(int(retries)), restconf.SkipDiscovery("/restconf", true), restconf.LockReleaseTimeout(int(lockReleaseTimeout)))
+ if err != nil {
+ resp.Diagnostics.AddError(
+ "Unable to create RESTCONF client",
+ "Unable to create RESTCONF client:\n\n"+err.Error(),
+ )
+ return
+ }
+ data.Devices[""] = &IosxeProviderDataDevice{RestconfClient: c, Protocol: "restconf", ReuseConnection: reuseConnection, Managed: true}
+ } else {
+ // NETCONF
+ logger := helpers.NewTflogAdapter()
+ opts := []func(*netconf.Client){
+ netconf.Username(username),
+ netconf.Password(password),
+ netconf.MaxRetries(int(retries)),
+ netconf.LockReleaseTimeout(time.Duration(lockReleaseTimeout) * time.Second),
+ netconf.WithLogger(logger),
+ }
+ if insecure {
+ opts = append(opts, netconf.InsecureSkipHostKeyVerification())
+ }
+ c, err := netconf.NewClient(host, opts...)
+ if err != nil {
+ resp.Diagnostics.AddError(
+ "Unable to create NETCONF client",
+ "Unable to create NETCONF client:\n\n"+err.Error(),
+ )
+ return
+ }
+ if !reuseConnection {
+ defer func() {
+ if err := c.Close(); err != nil {
+ tflog.Warn(ctx, fmt.Sprintf("Failed to close NETCONF connection: %s", err))
+ }
+ }()
+ }
+ data.Devices[""] = &IosxeProviderDataDevice{NetconfClient: c, Protocol: "netconf", ReuseConnection: reuseConnection, Managed: true}
}
- data.Devices[""] = &IosxeProviderDataDevice{Client: c, Managed: true}
for _, device := range config.Devices {
var managed bool
@@ -346,15 +489,66 @@ func (p *IosxeProvider) Configure(ctx context.Context, req provider.ConfigureReq
managed = device.Managed.ValueBool()
}
}
- c, err := restconf.NewClient(device.URL.ValueString(), username, password, insecure, restconf.MaxRetries(int(retries)), restconf.SkipDiscovery("/restconf", true), restconf.LockReleaseTimeout(int(lockReleaseTimeout)))
- if err != nil {
- resp.Diagnostics.AddError(
- "Unable to create client",
- "Unable to create restconf client:\n\n"+err.Error(),
- )
- return
+
+ // Determine device host (prefer host over url)
+ var deviceHost string
+ if !device.Host.IsNull() {
+ deviceHost = device.Host.ValueString()
+ } else {
+ deviceHost = device.URL.ValueString()
+ // Strip https:// prefix for NETCONF
+ if protocol == "netconf" {
+ deviceHost = strings.TrimPrefix(deviceHost, "https://")
+ deviceHost = strings.TrimPrefix(deviceHost, "http://")
+ }
+ }
+
+ // Create device client based on protocol
+ if protocol == "restconf" {
+ // For RESTCONF, add https:// prefix if not present
+ url := deviceHost
+ if !strings.HasPrefix(url, "https://") && !strings.HasPrefix(url, "http://") {
+ url = "https://" + url
+ }
+ c, err := restconf.NewClient(url, username, password, insecure, restconf.MaxRetries(int(retries)), restconf.SkipDiscovery("/restconf", true), restconf.LockReleaseTimeout(int(lockReleaseTimeout)))
+ if err != nil {
+ resp.Diagnostics.AddError(
+ "Unable to create RESTCONF client",
+ fmt.Sprintf("Unable to create RESTCONF client for device '%s':\n\n%s", device.Name.ValueString(), err.Error()),
+ )
+ return
+ }
+ data.Devices[device.Name.ValueString()] = &IosxeProviderDataDevice{RestconfClient: c, Protocol: "restconf", ReuseConnection: reuseConnection, Managed: managed}
+ } else {
+ // NETCONF
+ logger := helpers.NewTflogAdapter()
+ opts := []func(*netconf.Client){
+ netconf.Username(username),
+ netconf.Password(password),
+ netconf.MaxRetries(int(retries)),
+ netconf.LockReleaseTimeout(time.Duration(lockReleaseTimeout) * time.Second),
+ netconf.WithLogger(logger),
+ }
+ if insecure {
+ opts = append(opts, netconf.InsecureSkipHostKeyVerification())
+ }
+ c, err := netconf.NewClient(deviceHost, opts...)
+ if err != nil {
+ resp.Diagnostics.AddError(
+ "Unable to create NETCONF client",
+ fmt.Sprintf("Unable to create NETCONF client for device '%s':\n\n%s", device.Name.ValueString(), err.Error()),
+ )
+ return
+ }
+ if !reuseConnection {
+ defer func() {
+ if err := c.Close(); err != nil {
+ tflog.Warn(ctx, fmt.Sprintf("Failed to close NETCONF connection: %s", err))
+ }
+ }()
+ }
+ data.Devices[device.Name.ValueString()] = &IosxeProviderDataDevice{NetconfClient: c, Protocol: "netconf", ReuseConnection: reuseConnection, Managed: managed}
}
- data.Devices[device.Name.ValueString()] = &IosxeProviderDataDevice{Client: c, Managed: managed}
}
resp.DataSourceData = &data
@@ -363,7 +557,7 @@ func (p *IosxeProvider) Configure(ctx context.Context, req provider.ConfigureReq
func (p *IosxeProvider) Resources(ctx context.Context) []func() resource.Resource {
return []func() resource.Resource{
- NewRestconfResource,
+ NewYangResource,
NewSaveConfigResource,
NewCliResource,
NewAAAResource,
@@ -468,7 +662,7 @@ func (p *IosxeProvider) Resources(ctx context.Context) []func() resource.Resourc
func (p *IosxeProvider) DataSources(ctx context.Context) []func() datasource.DataSource {
return []func() datasource.DataSource{
- NewRestconfDataSource,
+ NewYangDataSource,
NewAAADataSource,
NewAAAAccountingDataSource,
NewAAAAuthenticationDataSource,
diff --git a/internal/provider/provider_test.go b/internal/provider/provider_test.go
index d8287614..6478c4ac 100644
--- a/internal/provider/provider_test.go
+++ b/internal/provider/provider_test.go
@@ -43,7 +43,7 @@ func testAccPreCheck(t *testing.T) {
if v := os.Getenv("IOSXE_PASSWORD"); v == "" {
t.Fatal("IOSXE_PASSWORD env variable must be set for acceptance tests")
}
- if v := os.Getenv("IOSXE_URL"); v == "" {
- t.Fatal("IOSXE_URL env variable must be set for acceptance tests")
+ if v := os.Getenv("IOSXE_HOST"); v == "" {
+ t.Fatal("IOSXE_HOST env variable must be set for acceptance tests")
}
}
diff --git a/internal/provider/resource_iosxe_aaa.go b/internal/provider/resource_iosxe_aaa.go
index 25f3d40c..6c1766dd 100644
--- a/internal/provider/resource_iosxe_aaa.go
+++ b/internal/provider/resource_iosxe_aaa.go
@@ -37,6 +37,7 @@ import (
"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-netconf"
"github.com/netascode/go-restconf"
)
@@ -310,37 +311,59 @@ func (r *AAAResource) Create(ctx context.Context, req resource.CreateRequest, re
}
if device.Managed {
- // Create object
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ // Create object
+ body := plan.toBody(ctx)
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
- return
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
+ return
+ }
+ } else {
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
- return
- }
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
+ }
+
+ body := plan.toBodyXML(ctx)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
@@ -378,25 +401,51 @@ func (r *AAAResource) Read(ctx context.Context, req resource.ReadRequest, resp *
}
if device.Managed {
- res, err := device.Client.GetData(state.Id.ValueString())
- if res.StatusCode == 404 {
- state = AAA{Device: state.Device, Id: state.Id}
+ imp, diags := helpers.IsFlagImporting(ctx, req)
+ if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ return
+ }
+
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(state.Id.ValueString())
+ if res.StatusCode == 404 {
+ state = AAA{Device: state.Device, Id: state.Id}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
+ return
+ }
+
+ // After `terraform import` we switch to a full read.
+ if imp {
+ state.fromBody(ctx, res.Res)
+ } else {
+ state.updateFromBody(ctx, res.Res)
+ }
+ }
} else {
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
- return
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
}
- imp, diags := helpers.IsFlagImporting(ctx, req)
- if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ filter := helpers.GetXpathFilter(state.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.getPath(), err))
return
}
// After `terraform import` we switch to a full read.
if imp {
- state.fromBody(ctx, res.Res)
+ state.fromBodyXML(ctx, res.Res)
} else {
- state.updateFromBody(ctx, res.Res)
+ state.updateFromBodyXML(ctx, res.Res)
}
}
}
@@ -439,51 +488,74 @@ func (r *AAAResource) Update(ctx context.Context, req resource.UpdateRequest, re
}
if device.Managed {
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ body := plan.toBody(ctx)
- deletedItems := plan.getDeletedItems(ctx, state)
- tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
+ deletedItems := plan.getDeletedItems(ctx, state)
+ tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- var edits []restconf.YangPatchEdit
- for _, i := range deletedItems {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
- return
+ if YangPatch {
+ var edits []restconf.YangPatchEdit
+ for _, i := range deletedItems {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletedItems {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- for _, i := range deletedItems {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
}
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+
+ body := plan.toBodyXML(ctx)
+ body = plan.addDeletedItemsXML(ctx, state, body)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
return
}
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
- return
- }
- }
}
}
@@ -516,34 +588,67 @@ func (r *AAAResource) Delete(ctx context.Context, req resource.DeleteRequest, re
}
if device.Managed {
- deleteMode := "all"
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
- if deleteMode == "all" {
- res, err := device.Client.DeleteData(state.Id.ValueString())
- if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
+ if device.Protocol == "netconf" && device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
- } else {
- deletePaths := state.getDeletePaths(ctx)
- tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
+ defer cleanup()
+ }
+ deleteMode := "all"
- if YangPatch {
- edits := []restconf.YangPatchEdit{}
- for _, i := range deletePaths {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ if deleteMode == "all" {
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.DeleteData(state.Id.ValueString())
+ if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
return
}
} else {
- for _, i := range deletePaths {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // NETCONF
+ body := netconf.Body{}
+ body = helpers.RemoveFromXPath(body, state.getXPath())
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body.Res(), true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
+ }
+ }
+ } else {
+ if device.Protocol == "restconf" {
+ deletePaths := state.getDeletePaths(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
+
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{}
+ for _, i := range deletePaths {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
}
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletePaths {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ }
+ }
+ }
+ } else {
+ // NETCONF
+ body := state.addDeletePathsXML(ctx, "")
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
diff --git a/internal/provider/resource_iosxe_aaa_accounting.go b/internal/provider/resource_iosxe_aaa_accounting.go
index f8b5ee4b..33372a10 100644
--- a/internal/provider/resource_iosxe_aaa_accounting.go
+++ b/internal/provider/resource_iosxe_aaa_accounting.go
@@ -36,6 +36,7 @@ import (
"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-netconf"
"github.com/netascode/go-restconf"
)
@@ -441,37 +442,59 @@ func (r *AAAAccountingResource) Create(ctx context.Context, req resource.CreateR
}
if device.Managed {
- // Create object
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ // Create object
+ body := plan.toBody(ctx)
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
- return
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
+ return
+ }
+ } else {
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
- return
- }
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
+ }
+
+ body := plan.toBodyXML(ctx)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
@@ -509,25 +532,51 @@ func (r *AAAAccountingResource) Read(ctx context.Context, req resource.ReadReque
}
if device.Managed {
- res, err := device.Client.GetData(state.Id.ValueString())
- if res.StatusCode == 404 {
- state = AAAAccounting{Device: state.Device, Id: state.Id}
+ imp, diags := helpers.IsFlagImporting(ctx, req)
+ if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ return
+ }
+
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(state.Id.ValueString())
+ if res.StatusCode == 404 {
+ state = AAAAccounting{Device: state.Device, Id: state.Id}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
+ return
+ }
+
+ // After `terraform import` we switch to a full read.
+ if imp {
+ state.fromBody(ctx, res.Res)
+ } else {
+ state.updateFromBody(ctx, res.Res)
+ }
+ }
} else {
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
- return
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
}
- imp, diags := helpers.IsFlagImporting(ctx, req)
- if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ filter := helpers.GetXpathFilter(state.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.getPath(), err))
return
}
// After `terraform import` we switch to a full read.
if imp {
- state.fromBody(ctx, res.Res)
+ state.fromBodyXML(ctx, res.Res)
} else {
- state.updateFromBody(ctx, res.Res)
+ state.updateFromBodyXML(ctx, res.Res)
}
}
}
@@ -570,51 +619,74 @@ func (r *AAAAccountingResource) Update(ctx context.Context, req resource.UpdateR
}
if device.Managed {
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ body := plan.toBody(ctx)
- deletedItems := plan.getDeletedItems(ctx, state)
- tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
+ deletedItems := plan.getDeletedItems(ctx, state)
+ tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- var edits []restconf.YangPatchEdit
- for _, i := range deletedItems {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
- return
+ if YangPatch {
+ var edits []restconf.YangPatchEdit
+ for _, i := range deletedItems {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletedItems {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- for _, i := range deletedItems {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
}
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+
+ body := plan.toBodyXML(ctx)
+ body = plan.addDeletedItemsXML(ctx, state, body)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
return
}
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
- return
- }
- }
}
}
@@ -647,6 +719,18 @@ func (r *AAAAccountingResource) Delete(ctx context.Context, req resource.DeleteR
}
if device.Managed {
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.Protocol == "netconf" && device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
+ }
deleteMode := "all"
if state.DeleteMode.ValueString() == "all" {
deleteMode = "all"
@@ -655,31 +739,52 @@ func (r *AAAAccountingResource) Delete(ctx context.Context, req resource.DeleteR
}
if deleteMode == "all" {
- res, err := device.Client.DeleteData(state.Id.ValueString())
- if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
- return
- }
- } else {
- deletePaths := state.getDeletePaths(ctx)
- tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
-
- if YangPatch {
- edits := []restconf.YangPatchEdit{}
- for _, i := range deletePaths {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.DeleteData(state.Id.ValueString())
+ if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
return
}
} else {
- for _, i := range deletePaths {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // NETCONF
+ body := netconf.Body{}
+ body = helpers.RemoveFromXPath(body, state.getXPath())
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body.Res(), true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
+ }
+ }
+ } else {
+ if device.Protocol == "restconf" {
+ deletePaths := state.getDeletePaths(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
+
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{}
+ for _, i := range deletePaths {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
}
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletePaths {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ }
+ }
+ }
+ } else {
+ // NETCONF
+ body := state.addDeletePathsXML(ctx, "")
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
diff --git a/internal/provider/resource_iosxe_aaa_authentication.go b/internal/provider/resource_iosxe_aaa_authentication.go
index eaeecc43..136465f1 100644
--- a/internal/provider/resource_iosxe_aaa_authentication.go
+++ b/internal/provider/resource_iosxe_aaa_authentication.go
@@ -35,6 +35,7 @@ import (
"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-netconf"
"github.com/netascode/go-restconf"
)
@@ -399,37 +400,59 @@ func (r *AAAAuthenticationResource) Create(ctx context.Context, req resource.Cre
}
if device.Managed {
- // Create object
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ // Create object
+ body := plan.toBody(ctx)
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
- return
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
+ return
+ }
+ } else {
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
- return
- }
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
+ }
+
+ body := plan.toBodyXML(ctx)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
@@ -467,25 +490,51 @@ func (r *AAAAuthenticationResource) Read(ctx context.Context, req resource.ReadR
}
if device.Managed {
- res, err := device.Client.GetData(state.Id.ValueString())
- if res.StatusCode == 404 {
- state = AAAAuthentication{Device: state.Device, Id: state.Id}
+ imp, diags := helpers.IsFlagImporting(ctx, req)
+ if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ return
+ }
+
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(state.Id.ValueString())
+ if res.StatusCode == 404 {
+ state = AAAAuthentication{Device: state.Device, Id: state.Id}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
+ return
+ }
+
+ // After `terraform import` we switch to a full read.
+ if imp {
+ state.fromBody(ctx, res.Res)
+ } else {
+ state.updateFromBody(ctx, res.Res)
+ }
+ }
} else {
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
- return
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
}
- imp, diags := helpers.IsFlagImporting(ctx, req)
- if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ filter := helpers.GetXpathFilter(state.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.getPath(), err))
return
}
// After `terraform import` we switch to a full read.
if imp {
- state.fromBody(ctx, res.Res)
+ state.fromBodyXML(ctx, res.Res)
} else {
- state.updateFromBody(ctx, res.Res)
+ state.updateFromBodyXML(ctx, res.Res)
}
}
}
@@ -528,51 +577,74 @@ func (r *AAAAuthenticationResource) Update(ctx context.Context, req resource.Upd
}
if device.Managed {
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ body := plan.toBody(ctx)
- deletedItems := plan.getDeletedItems(ctx, state)
- tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
+ deletedItems := plan.getDeletedItems(ctx, state)
+ tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- var edits []restconf.YangPatchEdit
- for _, i := range deletedItems {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
- return
+ if YangPatch {
+ var edits []restconf.YangPatchEdit
+ for _, i := range deletedItems {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletedItems {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- for _, i := range deletedItems {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
}
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+
+ body := plan.toBodyXML(ctx)
+ body = plan.addDeletedItemsXML(ctx, state, body)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
return
}
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
- return
- }
- }
}
}
@@ -605,6 +677,18 @@ func (r *AAAAuthenticationResource) Delete(ctx context.Context, req resource.Del
}
if device.Managed {
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.Protocol == "netconf" && device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
+ }
deleteMode := "all"
if state.DeleteMode.ValueString() == "all" {
deleteMode = "all"
@@ -613,31 +697,52 @@ func (r *AAAAuthenticationResource) Delete(ctx context.Context, req resource.Del
}
if deleteMode == "all" {
- res, err := device.Client.DeleteData(state.Id.ValueString())
- if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
- return
- }
- } else {
- deletePaths := state.getDeletePaths(ctx)
- tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
-
- if YangPatch {
- edits := []restconf.YangPatchEdit{}
- for _, i := range deletePaths {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.DeleteData(state.Id.ValueString())
+ if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
return
}
} else {
- for _, i := range deletePaths {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // NETCONF
+ body := netconf.Body{}
+ body = helpers.RemoveFromXPath(body, state.getXPath())
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body.Res(), true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
+ }
+ }
+ } else {
+ if device.Protocol == "restconf" {
+ deletePaths := state.getDeletePaths(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
+
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{}
+ for _, i := range deletePaths {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
}
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletePaths {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ }
+ }
+ }
+ } else {
+ // NETCONF
+ body := state.addDeletePathsXML(ctx, "")
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
diff --git a/internal/provider/resource_iosxe_aaa_authorization.go b/internal/provider/resource_iosxe_aaa_authorization.go
index cc6ac074..c267cdae 100644
--- a/internal/provider/resource_iosxe_aaa_authorization.go
+++ b/internal/provider/resource_iosxe_aaa_authorization.go
@@ -36,6 +36,7 @@ import (
"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-netconf"
"github.com/netascode/go-restconf"
)
@@ -403,37 +404,59 @@ func (r *AAAAuthorizationResource) Create(ctx context.Context, req resource.Crea
}
if device.Managed {
- // Create object
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ // Create object
+ body := plan.toBody(ctx)
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
- return
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
+ return
+ }
+ } else {
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
- return
- }
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
+ }
+
+ body := plan.toBodyXML(ctx)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
@@ -471,25 +494,51 @@ func (r *AAAAuthorizationResource) Read(ctx context.Context, req resource.ReadRe
}
if device.Managed {
- res, err := device.Client.GetData(state.Id.ValueString())
- if res.StatusCode == 404 {
- state = AAAAuthorization{Device: state.Device, Id: state.Id}
+ imp, diags := helpers.IsFlagImporting(ctx, req)
+ if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ return
+ }
+
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(state.Id.ValueString())
+ if res.StatusCode == 404 {
+ state = AAAAuthorization{Device: state.Device, Id: state.Id}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
+ return
+ }
+
+ // After `terraform import` we switch to a full read.
+ if imp {
+ state.fromBody(ctx, res.Res)
+ } else {
+ state.updateFromBody(ctx, res.Res)
+ }
+ }
} else {
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
- return
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
}
- imp, diags := helpers.IsFlagImporting(ctx, req)
- if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ filter := helpers.GetXpathFilter(state.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.getPath(), err))
return
}
// After `terraform import` we switch to a full read.
if imp {
- state.fromBody(ctx, res.Res)
+ state.fromBodyXML(ctx, res.Res)
} else {
- state.updateFromBody(ctx, res.Res)
+ state.updateFromBodyXML(ctx, res.Res)
}
}
}
@@ -532,51 +581,74 @@ func (r *AAAAuthorizationResource) Update(ctx context.Context, req resource.Upda
}
if device.Managed {
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ body := plan.toBody(ctx)
- deletedItems := plan.getDeletedItems(ctx, state)
- tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
+ deletedItems := plan.getDeletedItems(ctx, state)
+ tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- var edits []restconf.YangPatchEdit
- for _, i := range deletedItems {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
- return
+ if YangPatch {
+ var edits []restconf.YangPatchEdit
+ for _, i := range deletedItems {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletedItems {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- for _, i := range deletedItems {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
}
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+
+ body := plan.toBodyXML(ctx)
+ body = plan.addDeletedItemsXML(ctx, state, body)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
return
}
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
- return
- }
- }
}
}
@@ -609,6 +681,18 @@ func (r *AAAAuthorizationResource) Delete(ctx context.Context, req resource.Dele
}
if device.Managed {
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.Protocol == "netconf" && device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
+ }
deleteMode := "all"
if state.DeleteMode.ValueString() == "all" {
deleteMode = "all"
@@ -617,31 +701,52 @@ func (r *AAAAuthorizationResource) Delete(ctx context.Context, req resource.Dele
}
if deleteMode == "all" {
- res, err := device.Client.DeleteData(state.Id.ValueString())
- if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
- return
- }
- } else {
- deletePaths := state.getDeletePaths(ctx)
- tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
-
- if YangPatch {
- edits := []restconf.YangPatchEdit{}
- for _, i := range deletePaths {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.DeleteData(state.Id.ValueString())
+ if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
return
}
} else {
- for _, i := range deletePaths {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // NETCONF
+ body := netconf.Body{}
+ body = helpers.RemoveFromXPath(body, state.getXPath())
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body.Res(), true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
+ }
+ }
+ } else {
+ if device.Protocol == "restconf" {
+ deletePaths := state.getDeletePaths(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
+
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{}
+ for _, i := range deletePaths {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
}
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletePaths {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ }
+ }
+ }
+ } else {
+ // NETCONF
+ body := state.addDeletePathsXML(ctx, "")
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
diff --git a/internal/provider/resource_iosxe_aaa_test.go b/internal/provider/resource_iosxe_aaa_test.go
index 2ad2202e..a470b832 100644
--- a/internal/provider/resource_iosxe_aaa_test.go
+++ b/internal/provider/resource_iosxe_aaa_test.go
@@ -87,8 +87,8 @@ func iosxeAAAImportStateIdFunc(resourceName string) resource.ImportStateIdFunc {
// Section below is generated&owned by "gen/generator.go". //template:begin testPrerequisites
const testAccIosxeAAAPrerequisitesConfig = `
-resource "iosxe_restconf" "PreReq0" {
- path = "Cisco-IOS-XE-native:native/vrf/definition=VRF1"
+resource "iosxe_yang" "PreReq0" {
+ path = "/Cisco-IOS-XE-native:native/vrf/definition[name=VRF1]"
delete = false
attributes = {
"name" = "VRF1"
@@ -105,7 +105,7 @@ resource "iosxe_restconf" "PreReq0" {
func testAccIosxeAAAConfig_minimum() string {
config := `resource "iosxe_aaa" "test" {` + "\n"
- config += ` depends_on = [iosxe_restconf.PreReq0, ]` + "\n"
+ config += ` depends_on = [iosxe_yang.PreReq0, ]` + "\n"
config += `}` + "\n"
return config
}
@@ -139,7 +139,7 @@ func testAccIosxeAAAConfig_all() string {
config += ` ip_tacacs_source_interface_loopback = 0` + "\n"
config += ` vrf = "VRF1"` + "\n"
config += ` }]` + "\n"
- config += ` depends_on = [iosxe_restconf.PreReq0, ]` + "\n"
+ config += ` depends_on = [iosxe_yang.PreReq0, ]` + "\n"
config += `}` + "\n"
return config
}
diff --git a/internal/provider/resource_iosxe_access_list_extended.go b/internal/provider/resource_iosxe_access_list_extended.go
index 3608a00a..b110c61b 100644
--- a/internal/provider/resource_iosxe_access_list_extended.go
+++ b/internal/provider/resource_iosxe_access_list_extended.go
@@ -37,6 +37,7 @@ import (
"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-netconf"
"github.com/netascode/go-restconf"
)
@@ -365,37 +366,59 @@ func (r *AccessListExtendedResource) Create(ctx context.Context, req resource.Cr
}
if device.Managed {
- // Create object
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ // Create object
+ body := plan.toBody(ctx)
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
- return
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
+ return
+ }
+ } else {
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
- return
- }
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
+ }
+
+ body := plan.toBodyXML(ctx)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
@@ -433,25 +456,51 @@ func (r *AccessListExtendedResource) Read(ctx context.Context, req resource.Read
}
if device.Managed {
- res, err := device.Client.GetData(state.Id.ValueString())
- if res.StatusCode == 404 {
- state = AccessListExtended{Device: state.Device, Id: state.Id}
+ imp, diags := helpers.IsFlagImporting(ctx, req)
+ if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ return
+ }
+
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(state.Id.ValueString())
+ if res.StatusCode == 404 {
+ state = AccessListExtended{Device: state.Device, Id: state.Id}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
+ return
+ }
+
+ // After `terraform import` we switch to a full read.
+ if imp {
+ state.fromBody(ctx, res.Res)
+ } else {
+ state.updateFromBody(ctx, res.Res)
+ }
+ }
} else {
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
- return
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
}
- imp, diags := helpers.IsFlagImporting(ctx, req)
- if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ filter := helpers.GetXpathFilter(state.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.getPath(), err))
return
}
// After `terraform import` we switch to a full read.
if imp {
- state.fromBody(ctx, res.Res)
+ state.fromBodyXML(ctx, res.Res)
} else {
- state.updateFromBody(ctx, res.Res)
+ state.updateFromBodyXML(ctx, res.Res)
}
}
}
@@ -494,51 +543,74 @@ func (r *AccessListExtendedResource) Update(ctx context.Context, req resource.Up
}
if device.Managed {
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ body := plan.toBody(ctx)
- deletedItems := plan.getDeletedItems(ctx, state)
- tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
+ deletedItems := plan.getDeletedItems(ctx, state)
+ tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- var edits []restconf.YangPatchEdit
- for _, i := range deletedItems {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
- return
+ if YangPatch {
+ var edits []restconf.YangPatchEdit
+ for _, i := range deletedItems {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletedItems {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- for _, i := range deletedItems {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
}
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+
+ body := plan.toBodyXML(ctx)
+ body = plan.addDeletedItemsXML(ctx, state, body)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
return
}
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
- return
- }
- }
}
}
@@ -571,34 +643,67 @@ func (r *AccessListExtendedResource) Delete(ctx context.Context, req resource.De
}
if device.Managed {
- deleteMode := "all"
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
- if deleteMode == "all" {
- res, err := device.Client.DeleteData(state.Id.ValueString())
- if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
+ if device.Protocol == "netconf" && device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
- } else {
- deletePaths := state.getDeletePaths(ctx)
- tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
+ defer cleanup()
+ }
+ deleteMode := "all"
- if YangPatch {
- edits := []restconf.YangPatchEdit{}
- for _, i := range deletePaths {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ if deleteMode == "all" {
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.DeleteData(state.Id.ValueString())
+ if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
return
}
} else {
- for _, i := range deletePaths {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // NETCONF
+ body := netconf.Body{}
+ body = helpers.RemoveFromXPath(body, state.getXPath())
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body.Res(), true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
+ }
+ }
+ } else {
+ if device.Protocol == "restconf" {
+ deletePaths := state.getDeletePaths(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
+
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{}
+ for _, i := range deletePaths {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
}
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletePaths {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ }
+ }
+ }
+ } else {
+ // NETCONF
+ body := state.addDeletePathsXML(ctx, "")
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
diff --git a/internal/provider/resource_iosxe_access_list_role_based.go b/internal/provider/resource_iosxe_access_list_role_based.go
index 1fc132cb..2feea68a 100644
--- a/internal/provider/resource_iosxe_access_list_role_based.go
+++ b/internal/provider/resource_iosxe_access_list_role_based.go
@@ -36,6 +36,7 @@ import (
"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-netconf"
"github.com/netascode/go-restconf"
)
@@ -309,37 +310,59 @@ func (r *AccessListRoleBasedResource) Create(ctx context.Context, req resource.C
}
if device.Managed {
- // Create object
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ // Create object
+ body := plan.toBody(ctx)
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
- return
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
+ return
+ }
+ } else {
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
- return
- }
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
+ }
+
+ body := plan.toBodyXML(ctx)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
@@ -377,25 +400,51 @@ func (r *AccessListRoleBasedResource) Read(ctx context.Context, req resource.Rea
}
if device.Managed {
- res, err := device.Client.GetData(state.Id.ValueString())
- if res.StatusCode == 404 {
- state = AccessListRoleBased{Device: state.Device, Id: state.Id}
+ imp, diags := helpers.IsFlagImporting(ctx, req)
+ if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ return
+ }
+
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(state.Id.ValueString())
+ if res.StatusCode == 404 {
+ state = AccessListRoleBased{Device: state.Device, Id: state.Id}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
+ return
+ }
+
+ // After `terraform import` we switch to a full read.
+ if imp {
+ state.fromBody(ctx, res.Res)
+ } else {
+ state.updateFromBody(ctx, res.Res)
+ }
+ }
} else {
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
- return
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
}
- imp, diags := helpers.IsFlagImporting(ctx, req)
- if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ filter := helpers.GetXpathFilter(state.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.getPath(), err))
return
}
// After `terraform import` we switch to a full read.
if imp {
- state.fromBody(ctx, res.Res)
+ state.fromBodyXML(ctx, res.Res)
} else {
- state.updateFromBody(ctx, res.Res)
+ state.updateFromBodyXML(ctx, res.Res)
}
}
}
@@ -438,51 +487,74 @@ func (r *AccessListRoleBasedResource) Update(ctx context.Context, req resource.U
}
if device.Managed {
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ body := plan.toBody(ctx)
- deletedItems := plan.getDeletedItems(ctx, state)
- tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
+ deletedItems := plan.getDeletedItems(ctx, state)
+ tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- var edits []restconf.YangPatchEdit
- for _, i := range deletedItems {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
- return
+ if YangPatch {
+ var edits []restconf.YangPatchEdit
+ for _, i := range deletedItems {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletedItems {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- for _, i := range deletedItems {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
}
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+
+ body := plan.toBodyXML(ctx)
+ body = plan.addDeletedItemsXML(ctx, state, body)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
return
}
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
- return
- }
- }
}
}
@@ -515,34 +587,67 @@ func (r *AccessListRoleBasedResource) Delete(ctx context.Context, req resource.D
}
if device.Managed {
- deleteMode := "all"
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
- if deleteMode == "all" {
- res, err := device.Client.DeleteData(state.Id.ValueString())
- if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
+ if device.Protocol == "netconf" && device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
- } else {
- deletePaths := state.getDeletePaths(ctx)
- tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
+ defer cleanup()
+ }
+ deleteMode := "all"
- if YangPatch {
- edits := []restconf.YangPatchEdit{}
- for _, i := range deletePaths {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ if deleteMode == "all" {
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.DeleteData(state.Id.ValueString())
+ if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
return
}
} else {
- for _, i := range deletePaths {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // NETCONF
+ body := netconf.Body{}
+ body = helpers.RemoveFromXPath(body, state.getXPath())
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body.Res(), true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
+ }
+ }
+ } else {
+ if device.Protocol == "restconf" {
+ deletePaths := state.getDeletePaths(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
+
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{}
+ for _, i := range deletePaths {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
}
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletePaths {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ }
+ }
+ }
+ } else {
+ // NETCONF
+ body := state.addDeletePathsXML(ctx, "")
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
diff --git a/internal/provider/resource_iosxe_access_list_standard.go b/internal/provider/resource_iosxe_access_list_standard.go
index 3eb05abd..2f3cdc48 100644
--- a/internal/provider/resource_iosxe_access_list_standard.go
+++ b/internal/provider/resource_iosxe_access_list_standard.go
@@ -37,6 +37,7 @@ import (
"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-netconf"
"github.com/netascode/go-restconf"
)
@@ -201,37 +202,59 @@ func (r *AccessListStandardResource) Create(ctx context.Context, req resource.Cr
}
if device.Managed {
- // Create object
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ // Create object
+ body := plan.toBody(ctx)
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
- return
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
+ return
+ }
+ } else {
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
- return
- }
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
+ }
+
+ body := plan.toBodyXML(ctx)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
@@ -269,25 +292,51 @@ func (r *AccessListStandardResource) Read(ctx context.Context, req resource.Read
}
if device.Managed {
- res, err := device.Client.GetData(state.Id.ValueString())
- if res.StatusCode == 404 {
- state = AccessListStandard{Device: state.Device, Id: state.Id}
+ imp, diags := helpers.IsFlagImporting(ctx, req)
+ if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ return
+ }
+
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(state.Id.ValueString())
+ if res.StatusCode == 404 {
+ state = AccessListStandard{Device: state.Device, Id: state.Id}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
+ return
+ }
+
+ // After `terraform import` we switch to a full read.
+ if imp {
+ state.fromBody(ctx, res.Res)
+ } else {
+ state.updateFromBody(ctx, res.Res)
+ }
+ }
} else {
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
- return
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
}
- imp, diags := helpers.IsFlagImporting(ctx, req)
- if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ filter := helpers.GetXpathFilter(state.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.getPath(), err))
return
}
// After `terraform import` we switch to a full read.
if imp {
- state.fromBody(ctx, res.Res)
+ state.fromBodyXML(ctx, res.Res)
} else {
- state.updateFromBody(ctx, res.Res)
+ state.updateFromBodyXML(ctx, res.Res)
}
}
}
@@ -330,51 +379,74 @@ func (r *AccessListStandardResource) Update(ctx context.Context, req resource.Up
}
if device.Managed {
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ body := plan.toBody(ctx)
- deletedItems := plan.getDeletedItems(ctx, state)
- tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
+ deletedItems := plan.getDeletedItems(ctx, state)
+ tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- var edits []restconf.YangPatchEdit
- for _, i := range deletedItems {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
- return
+ if YangPatch {
+ var edits []restconf.YangPatchEdit
+ for _, i := range deletedItems {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletedItems {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- for _, i := range deletedItems {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
}
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+
+ body := plan.toBodyXML(ctx)
+ body = plan.addDeletedItemsXML(ctx, state, body)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
return
}
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
- return
- }
- }
}
}
@@ -407,34 +479,67 @@ func (r *AccessListStandardResource) Delete(ctx context.Context, req resource.De
}
if device.Managed {
- deleteMode := "all"
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
- if deleteMode == "all" {
- res, err := device.Client.DeleteData(state.Id.ValueString())
- if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
+ if device.Protocol == "netconf" && device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
- } else {
- deletePaths := state.getDeletePaths(ctx)
- tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
+ defer cleanup()
+ }
+ deleteMode := "all"
- if YangPatch {
- edits := []restconf.YangPatchEdit{}
- for _, i := range deletePaths {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ if deleteMode == "all" {
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.DeleteData(state.Id.ValueString())
+ if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
return
}
} else {
- for _, i := range deletePaths {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // NETCONF
+ body := netconf.Body{}
+ body = helpers.RemoveFromXPath(body, state.getXPath())
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body.Res(), true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
+ }
+ }
+ } else {
+ if device.Protocol == "restconf" {
+ deletePaths := state.getDeletePaths(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
+
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{}
+ for _, i := range deletePaths {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
}
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletePaths {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ }
+ }
+ }
+ } else {
+ // NETCONF
+ body := state.addDeletePathsXML(ctx, "")
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
diff --git a/internal/provider/resource_iosxe_arp.go b/internal/provider/resource_iosxe_arp.go
index c24351c5..7137c3a2 100644
--- a/internal/provider/resource_iosxe_arp.go
+++ b/internal/provider/resource_iosxe_arp.go
@@ -36,6 +36,7 @@ import (
"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-netconf"
"github.com/netascode/go-restconf"
)
@@ -207,37 +208,59 @@ func (r *ARPResource) Create(ctx context.Context, req resource.CreateRequest, re
}
if device.Managed {
- // Create object
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ // Create object
+ body := plan.toBody(ctx)
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
- return
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
+ return
+ }
+ } else {
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
- return
- }
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
+ }
+
+ body := plan.toBodyXML(ctx)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
@@ -275,25 +298,51 @@ func (r *ARPResource) Read(ctx context.Context, req resource.ReadRequest, resp *
}
if device.Managed {
- res, err := device.Client.GetData(state.Id.ValueString())
- if res.StatusCode == 404 {
- state = ARP{Device: state.Device, Id: state.Id}
+ imp, diags := helpers.IsFlagImporting(ctx, req)
+ if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ return
+ }
+
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(state.Id.ValueString())
+ if res.StatusCode == 404 {
+ state = ARP{Device: state.Device, Id: state.Id}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
+ return
+ }
+
+ // After `terraform import` we switch to a full read.
+ if imp {
+ state.fromBody(ctx, res.Res)
+ } else {
+ state.updateFromBody(ctx, res.Res)
+ }
+ }
} else {
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
- return
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
}
- imp, diags := helpers.IsFlagImporting(ctx, req)
- if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ filter := helpers.GetXpathFilter(state.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.getPath(), err))
return
}
// After `terraform import` we switch to a full read.
if imp {
- state.fromBody(ctx, res.Res)
+ state.fromBodyXML(ctx, res.Res)
} else {
- state.updateFromBody(ctx, res.Res)
+ state.updateFromBodyXML(ctx, res.Res)
}
}
}
@@ -336,51 +385,74 @@ func (r *ARPResource) Update(ctx context.Context, req resource.UpdateRequest, re
}
if device.Managed {
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ body := plan.toBody(ctx)
- deletedItems := plan.getDeletedItems(ctx, state)
- tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
+ deletedItems := plan.getDeletedItems(ctx, state)
+ tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- var edits []restconf.YangPatchEdit
- for _, i := range deletedItems {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
- return
+ if YangPatch {
+ var edits []restconf.YangPatchEdit
+ for _, i := range deletedItems {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletedItems {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- for _, i := range deletedItems {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
}
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+
+ body := plan.toBodyXML(ctx)
+ body = plan.addDeletedItemsXML(ctx, state, body)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
return
}
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
- return
- }
- }
}
}
@@ -413,6 +485,18 @@ func (r *ARPResource) Delete(ctx context.Context, req resource.DeleteRequest, re
}
if device.Managed {
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.Protocol == "netconf" && device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
+ }
deleteMode := "all"
if state.DeleteMode.ValueString() == "all" {
deleteMode = "all"
@@ -421,31 +505,52 @@ func (r *ARPResource) Delete(ctx context.Context, req resource.DeleteRequest, re
}
if deleteMode == "all" {
- res, err := device.Client.DeleteData(state.Id.ValueString())
- if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
- return
- }
- } else {
- deletePaths := state.getDeletePaths(ctx)
- tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
-
- if YangPatch {
- edits := []restconf.YangPatchEdit{}
- for _, i := range deletePaths {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.DeleteData(state.Id.ValueString())
+ if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
return
}
} else {
- for _, i := range deletePaths {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // NETCONF
+ body := netconf.Body{}
+ body = helpers.RemoveFromXPath(body, state.getXPath())
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body.Res(), true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
+ }
+ }
+ } else {
+ if device.Protocol == "restconf" {
+ deletePaths := state.getDeletePaths(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
+
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{}
+ for _, i := range deletePaths {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
}
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletePaths {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ }
+ }
+ }
+ } else {
+ // NETCONF
+ body := state.addDeletePathsXML(ctx, "")
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
diff --git a/internal/provider/resource_iosxe_as_path_access_list.go b/internal/provider/resource_iosxe_as_path_access_list.go
index 8fef874a..1204916b 100644
--- a/internal/provider/resource_iosxe_as_path_access_list.go
+++ b/internal/provider/resource_iosxe_as_path_access_list.go
@@ -39,6 +39,7 @@ import (
"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-netconf"
"github.com/netascode/go-restconf"
)
@@ -148,37 +149,59 @@ func (r *ASPathAccessListResource) Create(ctx context.Context, req resource.Crea
}
if device.Managed {
- // Create object
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ // Create object
+ body := plan.toBody(ctx)
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
- return
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
+ return
+ }
+ } else {
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
- return
- }
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
+ }
+
+ body := plan.toBodyXML(ctx)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
@@ -216,25 +239,51 @@ func (r *ASPathAccessListResource) Read(ctx context.Context, req resource.ReadRe
}
if device.Managed {
- res, err := device.Client.GetData(state.Id.ValueString())
- if res.StatusCode == 404 {
- state = ASPathAccessList{Device: state.Device, Id: state.Id}
+ imp, diags := helpers.IsFlagImporting(ctx, req)
+ if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ return
+ }
+
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(state.Id.ValueString())
+ if res.StatusCode == 404 {
+ state = ASPathAccessList{Device: state.Device, Id: state.Id}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
+ return
+ }
+
+ // After `terraform import` we switch to a full read.
+ if imp {
+ state.fromBody(ctx, res.Res)
+ } else {
+ state.updateFromBody(ctx, res.Res)
+ }
+ }
} else {
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
- return
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
}
- imp, diags := helpers.IsFlagImporting(ctx, req)
- if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ filter := helpers.GetXpathFilter(state.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.getPath(), err))
return
}
// After `terraform import` we switch to a full read.
if imp {
- state.fromBody(ctx, res.Res)
+ state.fromBodyXML(ctx, res.Res)
} else {
- state.updateFromBody(ctx, res.Res)
+ state.updateFromBodyXML(ctx, res.Res)
}
}
}
@@ -277,51 +326,74 @@ func (r *ASPathAccessListResource) Update(ctx context.Context, req resource.Upda
}
if device.Managed {
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ body := plan.toBody(ctx)
- deletedItems := plan.getDeletedItems(ctx, state)
- tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
+ deletedItems := plan.getDeletedItems(ctx, state)
+ tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- var edits []restconf.YangPatchEdit
- for _, i := range deletedItems {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
- return
+ if YangPatch {
+ var edits []restconf.YangPatchEdit
+ for _, i := range deletedItems {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletedItems {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- for _, i := range deletedItems {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
}
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+
+ body := plan.toBodyXML(ctx)
+ body = plan.addDeletedItemsXML(ctx, state, body)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
return
}
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
- return
- }
- }
}
}
@@ -354,34 +426,67 @@ func (r *ASPathAccessListResource) Delete(ctx context.Context, req resource.Dele
}
if device.Managed {
- deleteMode := "all"
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
- if deleteMode == "all" {
- res, err := device.Client.DeleteData(state.Id.ValueString())
- if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
+ if device.Protocol == "netconf" && device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
- } else {
- deletePaths := state.getDeletePaths(ctx)
- tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
+ defer cleanup()
+ }
+ deleteMode := "all"
- if YangPatch {
- edits := []restconf.YangPatchEdit{}
- for _, i := range deletePaths {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ if deleteMode == "all" {
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.DeleteData(state.Id.ValueString())
+ if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
return
}
} else {
- for _, i := range deletePaths {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // NETCONF
+ body := netconf.Body{}
+ body = helpers.RemoveFromXPath(body, state.getXPath())
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body.Res(), true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
+ }
+ }
+ } else {
+ if device.Protocol == "restconf" {
+ deletePaths := state.getDeletePaths(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
+
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{}
+ for _, i := range deletePaths {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
}
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletePaths {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ }
+ }
+ }
+ } else {
+ // NETCONF
+ body := state.addDeletePathsXML(ctx, "")
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
diff --git a/internal/provider/resource_iosxe_banner.go b/internal/provider/resource_iosxe_banner.go
index 7803cf83..669b2d6a 100644
--- a/internal/provider/resource_iosxe_banner.go
+++ b/internal/provider/resource_iosxe_banner.go
@@ -35,6 +35,7 @@ import (
"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-netconf"
"github.com/netascode/go-restconf"
)
@@ -135,37 +136,59 @@ func (r *BannerResource) Create(ctx context.Context, req resource.CreateRequest,
}
if device.Managed {
- // Create object
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ // Create object
+ body := plan.toBody(ctx)
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
- return
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
+ return
+ }
+ } else {
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
- return
- }
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
+ }
+
+ body := plan.toBodyXML(ctx)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
@@ -203,25 +226,51 @@ func (r *BannerResource) Read(ctx context.Context, req resource.ReadRequest, res
}
if device.Managed {
- res, err := device.Client.GetData(state.Id.ValueString())
- if res.StatusCode == 404 {
- state = Banner{Device: state.Device, Id: state.Id}
+ imp, diags := helpers.IsFlagImporting(ctx, req)
+ if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ return
+ }
+
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(state.Id.ValueString())
+ if res.StatusCode == 404 {
+ state = Banner{Device: state.Device, Id: state.Id}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
+ return
+ }
+
+ // After `terraform import` we switch to a full read.
+ if imp {
+ state.fromBody(ctx, res.Res)
+ } else {
+ state.updateFromBody(ctx, res.Res)
+ }
+ }
} else {
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
- return
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
}
- imp, diags := helpers.IsFlagImporting(ctx, req)
- if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ filter := helpers.GetXpathFilter(state.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.getPath(), err))
return
}
// After `terraform import` we switch to a full read.
if imp {
- state.fromBody(ctx, res.Res)
+ state.fromBodyXML(ctx, res.Res)
} else {
- state.updateFromBody(ctx, res.Res)
+ state.updateFromBodyXML(ctx, res.Res)
}
}
}
@@ -264,51 +313,74 @@ func (r *BannerResource) Update(ctx context.Context, req resource.UpdateRequest,
}
if device.Managed {
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ body := plan.toBody(ctx)
- deletedItems := plan.getDeletedItems(ctx, state)
- tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
+ deletedItems := plan.getDeletedItems(ctx, state)
+ tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- var edits []restconf.YangPatchEdit
- for _, i := range deletedItems {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
- return
+ if YangPatch {
+ var edits []restconf.YangPatchEdit
+ for _, i := range deletedItems {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletedItems {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- for _, i := range deletedItems {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
}
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+
+ body := plan.toBodyXML(ctx)
+ body = plan.addDeletedItemsXML(ctx, state, body)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
return
}
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
- return
- }
- }
}
}
@@ -341,6 +413,18 @@ func (r *BannerResource) Delete(ctx context.Context, req resource.DeleteRequest,
}
if device.Managed {
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.Protocol == "netconf" && device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
+ }
deleteMode := "all"
if state.DeleteMode.ValueString() == "all" {
deleteMode = "all"
@@ -349,31 +433,52 @@ func (r *BannerResource) Delete(ctx context.Context, req resource.DeleteRequest,
}
if deleteMode == "all" {
- res, err := device.Client.DeleteData(state.Id.ValueString())
- if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
- return
- }
- } else {
- deletePaths := state.getDeletePaths(ctx)
- tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
-
- if YangPatch {
- edits := []restconf.YangPatchEdit{}
- for _, i := range deletePaths {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.DeleteData(state.Id.ValueString())
+ if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
return
}
} else {
- for _, i := range deletePaths {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // NETCONF
+ body := netconf.Body{}
+ body = helpers.RemoveFromXPath(body, state.getXPath())
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body.Res(), true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
+ }
+ }
+ } else {
+ if device.Protocol == "restconf" {
+ deletePaths := state.getDeletePaths(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
+
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{}
+ for _, i := range deletePaths {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
}
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletePaths {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ }
+ }
+ }
+ } else {
+ // NETCONF
+ body := state.addDeletePathsXML(ctx, "")
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
diff --git a/internal/provider/resource_iosxe_bfd.go b/internal/provider/resource_iosxe_bfd.go
index d1e7da02..9799e7af 100644
--- a/internal/provider/resource_iosxe_bfd.go
+++ b/internal/provider/resource_iosxe_bfd.go
@@ -37,6 +37,7 @@ import (
"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-netconf"
"github.com/netascode/go-restconf"
)
@@ -376,37 +377,59 @@ func (r *BFDResource) Create(ctx context.Context, req resource.CreateRequest, re
}
if device.Managed {
- // Create object
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ // Create object
+ body := plan.toBody(ctx)
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
- return
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
+ return
+ }
+ } else {
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
- return
- }
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
+ }
+
+ body := plan.toBodyXML(ctx)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
@@ -444,25 +467,51 @@ func (r *BFDResource) Read(ctx context.Context, req resource.ReadRequest, resp *
}
if device.Managed {
- res, err := device.Client.GetData(state.Id.ValueString())
- if res.StatusCode == 404 {
- state = BFD{Device: state.Device, Id: state.Id}
+ imp, diags := helpers.IsFlagImporting(ctx, req)
+ if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ return
+ }
+
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(state.Id.ValueString())
+ if res.StatusCode == 404 {
+ state = BFD{Device: state.Device, Id: state.Id}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
+ return
+ }
+
+ // After `terraform import` we switch to a full read.
+ if imp {
+ state.fromBody(ctx, res.Res)
+ } else {
+ state.updateFromBody(ctx, res.Res)
+ }
+ }
} else {
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
- return
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
}
- imp, diags := helpers.IsFlagImporting(ctx, req)
- if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ filter := helpers.GetXpathFilter(state.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.getPath(), err))
return
}
// After `terraform import` we switch to a full read.
if imp {
- state.fromBody(ctx, res.Res)
+ state.fromBodyXML(ctx, res.Res)
} else {
- state.updateFromBody(ctx, res.Res)
+ state.updateFromBodyXML(ctx, res.Res)
}
}
}
@@ -505,51 +554,74 @@ func (r *BFDResource) Update(ctx context.Context, req resource.UpdateRequest, re
}
if device.Managed {
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ body := plan.toBody(ctx)
- deletedItems := plan.getDeletedItems(ctx, state)
- tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
+ deletedItems := plan.getDeletedItems(ctx, state)
+ tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- var edits []restconf.YangPatchEdit
- for _, i := range deletedItems {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
- return
+ if YangPatch {
+ var edits []restconf.YangPatchEdit
+ for _, i := range deletedItems {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletedItems {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- for _, i := range deletedItems {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
}
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+
+ body := plan.toBodyXML(ctx)
+ body = plan.addDeletedItemsXML(ctx, state, body)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
return
}
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
- return
- }
- }
}
}
@@ -582,6 +654,18 @@ func (r *BFDResource) Delete(ctx context.Context, req resource.DeleteRequest, re
}
if device.Managed {
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.Protocol == "netconf" && device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
+ }
deleteMode := "all"
if state.DeleteMode.ValueString() == "all" {
deleteMode = "all"
@@ -590,31 +674,52 @@ func (r *BFDResource) Delete(ctx context.Context, req resource.DeleteRequest, re
}
if deleteMode == "all" {
- res, err := device.Client.DeleteData(state.Id.ValueString())
- if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
- return
- }
- } else {
- deletePaths := state.getDeletePaths(ctx)
- tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
-
- if YangPatch {
- edits := []restconf.YangPatchEdit{}
- for _, i := range deletePaths {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.DeleteData(state.Id.ValueString())
+ if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
return
}
} else {
- for _, i := range deletePaths {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // NETCONF
+ body := netconf.Body{}
+ body = helpers.RemoveFromXPath(body, state.getXPath())
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body.Res(), true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
+ }
+ }
+ } else {
+ if device.Protocol == "restconf" {
+ deletePaths := state.getDeletePaths(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
+
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{}
+ for _, i := range deletePaths {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
}
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletePaths {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ }
+ }
+ }
+ } else {
+ // NETCONF
+ body := state.addDeletePathsXML(ctx, "")
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
diff --git a/internal/provider/resource_iosxe_bfd_template_multi_hop.go b/internal/provider/resource_iosxe_bfd_template_multi_hop.go
index 2c2a33bd..9c3693e0 100644
--- a/internal/provider/resource_iosxe_bfd_template_multi_hop.go
+++ b/internal/provider/resource_iosxe_bfd_template_multi_hop.go
@@ -35,6 +35,7 @@ import (
"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-netconf"
"github.com/netascode/go-restconf"
)
@@ -238,37 +239,59 @@ func (r *BFDTemplateMultiHopResource) Create(ctx context.Context, req resource.C
}
if device.Managed {
- // Create object
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ // Create object
+ body := plan.toBody(ctx)
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
- return
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
+ return
+ }
+ } else {
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
- return
- }
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
+ }
+
+ body := plan.toBodyXML(ctx)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
@@ -306,25 +329,51 @@ func (r *BFDTemplateMultiHopResource) Read(ctx context.Context, req resource.Rea
}
if device.Managed {
- res, err := device.Client.GetData(state.Id.ValueString())
- if res.StatusCode == 404 {
- state = BFDTemplateMultiHop{Device: state.Device, Id: state.Id}
+ imp, diags := helpers.IsFlagImporting(ctx, req)
+ if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ return
+ }
+
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(state.Id.ValueString())
+ if res.StatusCode == 404 {
+ state = BFDTemplateMultiHop{Device: state.Device, Id: state.Id}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
+ return
+ }
+
+ // After `terraform import` we switch to a full read.
+ if imp {
+ state.fromBody(ctx, res.Res)
+ } else {
+ state.updateFromBody(ctx, res.Res)
+ }
+ }
} else {
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
- return
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
}
- imp, diags := helpers.IsFlagImporting(ctx, req)
- if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ filter := helpers.GetXpathFilter(state.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.getPath(), err))
return
}
// After `terraform import` we switch to a full read.
if imp {
- state.fromBody(ctx, res.Res)
+ state.fromBodyXML(ctx, res.Res)
} else {
- state.updateFromBody(ctx, res.Res)
+ state.updateFromBodyXML(ctx, res.Res)
}
}
}
@@ -367,51 +416,74 @@ func (r *BFDTemplateMultiHopResource) Update(ctx context.Context, req resource.U
}
if device.Managed {
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ body := plan.toBody(ctx)
- deletedItems := plan.getDeletedItems(ctx, state)
- tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
+ deletedItems := plan.getDeletedItems(ctx, state)
+ tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- var edits []restconf.YangPatchEdit
- for _, i := range deletedItems {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
- return
+ if YangPatch {
+ var edits []restconf.YangPatchEdit
+ for _, i := range deletedItems {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletedItems {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- for _, i := range deletedItems {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
}
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+
+ body := plan.toBodyXML(ctx)
+ body = plan.addDeletedItemsXML(ctx, state, body)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
return
}
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
- return
- }
- }
}
}
@@ -444,34 +516,67 @@ func (r *BFDTemplateMultiHopResource) Delete(ctx context.Context, req resource.D
}
if device.Managed {
- deleteMode := "all"
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
- if deleteMode == "all" {
- res, err := device.Client.DeleteData(state.Id.ValueString())
- if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
+ if device.Protocol == "netconf" && device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
- } else {
- deletePaths := state.getDeletePaths(ctx)
- tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
+ defer cleanup()
+ }
+ deleteMode := "all"
- if YangPatch {
- edits := []restconf.YangPatchEdit{}
- for _, i := range deletePaths {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ if deleteMode == "all" {
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.DeleteData(state.Id.ValueString())
+ if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
return
}
} else {
- for _, i := range deletePaths {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // NETCONF
+ body := netconf.Body{}
+ body = helpers.RemoveFromXPath(body, state.getXPath())
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body.Res(), true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
+ }
+ }
+ } else {
+ if device.Protocol == "restconf" {
+ deletePaths := state.getDeletePaths(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
+
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{}
+ for _, i := range deletePaths {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
}
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletePaths {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ }
+ }
+ }
+ } else {
+ // NETCONF
+ body := state.addDeletePathsXML(ctx, "")
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
diff --git a/internal/provider/resource_iosxe_bfd_template_single_hop.go b/internal/provider/resource_iosxe_bfd_template_single_hop.go
index eba4f05e..47589e89 100644
--- a/internal/provider/resource_iosxe_bfd_template_single_hop.go
+++ b/internal/provider/resource_iosxe_bfd_template_single_hop.go
@@ -35,6 +35,7 @@ import (
"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-netconf"
"github.com/netascode/go-restconf"
)
@@ -209,37 +210,59 @@ func (r *BFDTemplateSingleHopResource) Create(ctx context.Context, req resource.
}
if device.Managed {
- // Create object
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ // Create object
+ body := plan.toBody(ctx)
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
- return
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
+ return
+ }
+ } else {
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
- return
- }
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
+ }
+
+ body := plan.toBodyXML(ctx)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
@@ -277,25 +300,51 @@ func (r *BFDTemplateSingleHopResource) Read(ctx context.Context, req resource.Re
}
if device.Managed {
- res, err := device.Client.GetData(state.Id.ValueString())
- if res.StatusCode == 404 {
- state = BFDTemplateSingleHop{Device: state.Device, Id: state.Id}
+ imp, diags := helpers.IsFlagImporting(ctx, req)
+ if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ return
+ }
+
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(state.Id.ValueString())
+ if res.StatusCode == 404 {
+ state = BFDTemplateSingleHop{Device: state.Device, Id: state.Id}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
+ return
+ }
+
+ // After `terraform import` we switch to a full read.
+ if imp {
+ state.fromBody(ctx, res.Res)
+ } else {
+ state.updateFromBody(ctx, res.Res)
+ }
+ }
} else {
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
- return
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
}
- imp, diags := helpers.IsFlagImporting(ctx, req)
- if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ filter := helpers.GetXpathFilter(state.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.getPath(), err))
return
}
// After `terraform import` we switch to a full read.
if imp {
- state.fromBody(ctx, res.Res)
+ state.fromBodyXML(ctx, res.Res)
} else {
- state.updateFromBody(ctx, res.Res)
+ state.updateFromBodyXML(ctx, res.Res)
}
}
}
@@ -338,51 +387,74 @@ func (r *BFDTemplateSingleHopResource) Update(ctx context.Context, req resource.
}
if device.Managed {
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ body := plan.toBody(ctx)
- deletedItems := plan.getDeletedItems(ctx, state)
- tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
+ deletedItems := plan.getDeletedItems(ctx, state)
+ tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- var edits []restconf.YangPatchEdit
- for _, i := range deletedItems {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
- return
+ if YangPatch {
+ var edits []restconf.YangPatchEdit
+ for _, i := range deletedItems {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletedItems {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- for _, i := range deletedItems {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
}
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+
+ body := plan.toBodyXML(ctx)
+ body = plan.addDeletedItemsXML(ctx, state, body)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
return
}
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
- return
- }
- }
}
}
@@ -415,34 +487,67 @@ func (r *BFDTemplateSingleHopResource) Delete(ctx context.Context, req resource.
}
if device.Managed {
- deleteMode := "all"
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
- if deleteMode == "all" {
- res, err := device.Client.DeleteData(state.Id.ValueString())
- if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
+ if device.Protocol == "netconf" && device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
- } else {
- deletePaths := state.getDeletePaths(ctx)
- tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
+ defer cleanup()
+ }
+ deleteMode := "all"
- if YangPatch {
- edits := []restconf.YangPatchEdit{}
- for _, i := range deletePaths {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ if deleteMode == "all" {
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.DeleteData(state.Id.ValueString())
+ if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
return
}
} else {
- for _, i := range deletePaths {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // NETCONF
+ body := netconf.Body{}
+ body = helpers.RemoveFromXPath(body, state.getXPath())
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body.Res(), true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
+ }
+ }
+ } else {
+ if device.Protocol == "restconf" {
+ deletePaths := state.getDeletePaths(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
+
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{}
+ for _, i := range deletePaths {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
}
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletePaths {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ }
+ }
+ }
+ } else {
+ // NETCONF
+ body := state.addDeletePathsXML(ctx, "")
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
diff --git a/internal/provider/resource_iosxe_bgp.go b/internal/provider/resource_iosxe_bgp.go
index e55feece..d171ce6a 100644
--- a/internal/provider/resource_iosxe_bgp.go
+++ b/internal/provider/resource_iosxe_bgp.go
@@ -37,6 +37,7 @@ import (
"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-netconf"
"github.com/netascode/go-restconf"
)
@@ -150,37 +151,59 @@ func (r *BGPResource) Create(ctx context.Context, req resource.CreateRequest, re
}
if device.Managed {
- // Create object
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ // Create object
+ body := plan.toBody(ctx)
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
- return
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
+ return
+ }
+ } else {
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
- return
- }
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
+ }
+
+ body := plan.toBodyXML(ctx)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
@@ -218,25 +241,51 @@ func (r *BGPResource) Read(ctx context.Context, req resource.ReadRequest, resp *
}
if device.Managed {
- res, err := device.Client.GetData(state.Id.ValueString())
- if res.StatusCode == 404 {
- state = BGP{Device: state.Device, Id: state.Id}
+ imp, diags := helpers.IsFlagImporting(ctx, req)
+ if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ return
+ }
+
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(state.Id.ValueString())
+ if res.StatusCode == 404 {
+ state = BGP{Device: state.Device, Id: state.Id}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
+ return
+ }
+
+ // After `terraform import` we switch to a full read.
+ if imp {
+ state.fromBody(ctx, res.Res)
+ } else {
+ state.updateFromBody(ctx, res.Res)
+ }
+ }
} else {
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
- return
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
}
- imp, diags := helpers.IsFlagImporting(ctx, req)
- if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ filter := helpers.GetXpathFilter(state.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.getPath(), err))
return
}
// After `terraform import` we switch to a full read.
if imp {
- state.fromBody(ctx, res.Res)
+ state.fromBodyXML(ctx, res.Res)
} else {
- state.updateFromBody(ctx, res.Res)
+ state.updateFromBodyXML(ctx, res.Res)
}
}
}
@@ -279,51 +328,74 @@ func (r *BGPResource) Update(ctx context.Context, req resource.UpdateRequest, re
}
if device.Managed {
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ body := plan.toBody(ctx)
- deletedItems := plan.getDeletedItems(ctx, state)
- tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
+ deletedItems := plan.getDeletedItems(ctx, state)
+ tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- var edits []restconf.YangPatchEdit
- for _, i := range deletedItems {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
- return
+ if YangPatch {
+ var edits []restconf.YangPatchEdit
+ for _, i := range deletedItems {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletedItems {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- for _, i := range deletedItems {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
}
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+
+ body := plan.toBodyXML(ctx)
+ body = plan.addDeletedItemsXML(ctx, state, body)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
return
}
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
- return
- }
- }
}
}
@@ -356,6 +428,18 @@ func (r *BGPResource) Delete(ctx context.Context, req resource.DeleteRequest, re
}
if device.Managed {
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.Protocol == "netconf" && device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
+ }
deleteMode := "all"
if state.DeleteMode.ValueString() == "all" {
deleteMode = "all"
@@ -364,31 +448,52 @@ func (r *BGPResource) Delete(ctx context.Context, req resource.DeleteRequest, re
}
if deleteMode == "all" {
- res, err := device.Client.DeleteData(state.Id.ValueString())
- if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
- return
- }
- } else {
- deletePaths := state.getDeletePaths(ctx)
- tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
-
- if YangPatch {
- edits := []restconf.YangPatchEdit{}
- for _, i := range deletePaths {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.DeleteData(state.Id.ValueString())
+ if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
return
}
} else {
- for _, i := range deletePaths {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // NETCONF
+ body := netconf.Body{}
+ body = helpers.RemoveFromXPath(body, state.getXPath())
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body.Res(), true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
+ }
+ }
+ } else {
+ if device.Protocol == "restconf" {
+ deletePaths := state.getDeletePaths(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
+
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{}
+ for _, i := range deletePaths {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
}
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletePaths {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ }
+ }
+ }
+ } else {
+ // NETCONF
+ body := state.addDeletePathsXML(ctx, "")
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
diff --git a/internal/provider/resource_iosxe_bgp_address_family_ipv4.go b/internal/provider/resource_iosxe_bgp_address_family_ipv4.go
index b24abf0c..601bdcac 100644
--- a/internal/provider/resource_iosxe_bgp_address_family_ipv4.go
+++ b/internal/provider/resource_iosxe_bgp_address_family_ipv4.go
@@ -37,6 +37,7 @@ import (
"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-netconf"
"github.com/netascode/go-restconf"
)
@@ -275,37 +276,59 @@ func (r *BGPAddressFamilyIPv4Resource) Create(ctx context.Context, req resource.
}
if device.Managed {
- // Create object
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ // Create object
+ body := plan.toBody(ctx)
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
- return
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
+ return
+ }
+ } else {
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
- return
- }
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
+ }
+
+ body := plan.toBodyXML(ctx)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
@@ -343,25 +366,51 @@ func (r *BGPAddressFamilyIPv4Resource) Read(ctx context.Context, req resource.Re
}
if device.Managed {
- res, err := device.Client.GetData(state.Id.ValueString())
- if res.StatusCode == 404 {
- state = BGPAddressFamilyIPv4{Device: state.Device, Id: state.Id}
+ imp, diags := helpers.IsFlagImporting(ctx, req)
+ if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ return
+ }
+
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(state.Id.ValueString())
+ if res.StatusCode == 404 {
+ state = BGPAddressFamilyIPv4{Device: state.Device, Id: state.Id}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
+ return
+ }
+
+ // After `terraform import` we switch to a full read.
+ if imp {
+ state.fromBody(ctx, res.Res)
+ } else {
+ state.updateFromBody(ctx, res.Res)
+ }
+ }
} else {
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
- return
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
}
- imp, diags := helpers.IsFlagImporting(ctx, req)
- if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ filter := helpers.GetXpathFilter(state.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.getPath(), err))
return
}
// After `terraform import` we switch to a full read.
if imp {
- state.fromBody(ctx, res.Res)
+ state.fromBodyXML(ctx, res.Res)
} else {
- state.updateFromBody(ctx, res.Res)
+ state.updateFromBodyXML(ctx, res.Res)
}
}
}
@@ -404,51 +453,74 @@ func (r *BGPAddressFamilyIPv4Resource) Update(ctx context.Context, req resource.
}
if device.Managed {
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ body := plan.toBody(ctx)
- deletedItems := plan.getDeletedItems(ctx, state)
- tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
+ deletedItems := plan.getDeletedItems(ctx, state)
+ tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- var edits []restconf.YangPatchEdit
- for _, i := range deletedItems {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
- return
+ if YangPatch {
+ var edits []restconf.YangPatchEdit
+ for _, i := range deletedItems {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletedItems {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- for _, i := range deletedItems {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
}
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+
+ body := plan.toBodyXML(ctx)
+ body = plan.addDeletedItemsXML(ctx, state, body)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
return
}
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
- return
- }
- }
}
}
@@ -481,6 +553,18 @@ func (r *BGPAddressFamilyIPv4Resource) Delete(ctx context.Context, req resource.
}
if device.Managed {
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.Protocol == "netconf" && device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
+ }
deleteMode := "all"
if state.DeleteMode.ValueString() == "all" {
deleteMode = "all"
@@ -489,31 +573,52 @@ func (r *BGPAddressFamilyIPv4Resource) Delete(ctx context.Context, req resource.
}
if deleteMode == "all" {
- res, err := device.Client.DeleteData(state.Id.ValueString())
- if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
- return
- }
- } else {
- deletePaths := state.getDeletePaths(ctx)
- tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
-
- if YangPatch {
- edits := []restconf.YangPatchEdit{}
- for _, i := range deletePaths {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.DeleteData(state.Id.ValueString())
+ if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
return
}
} else {
- for _, i := range deletePaths {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // NETCONF
+ body := netconf.Body{}
+ body = helpers.RemoveFromXPath(body, state.getXPath())
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body.Res(), true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
+ }
+ }
+ } else {
+ if device.Protocol == "restconf" {
+ deletePaths := state.getDeletePaths(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
+
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{}
+ for _, i := range deletePaths {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
}
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletePaths {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ }
+ }
+ }
+ } else {
+ // NETCONF
+ body := state.addDeletePathsXML(ctx, "")
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
diff --git a/internal/provider/resource_iosxe_bgp_address_family_ipv4_test.go b/internal/provider/resource_iosxe_bgp_address_family_ipv4_test.go
index 53ed99c8..0eb35d5d 100644
--- a/internal/provider/resource_iosxe_bgp_address_family_ipv4_test.go
+++ b/internal/provider/resource_iosxe_bgp_address_family_ipv4_test.go
@@ -93,8 +93,8 @@ func iosxeBGPAddressFamilyIPv4ImportStateIdFunc(resourceName string) resource.Im
// Section below is generated&owned by "gen/generator.go". //template:begin testPrerequisites
const testAccIosxeBGPAddressFamilyIPv4PrerequisitesConfig = `
-resource "iosxe_restconf" "PreReq0" {
- path = "Cisco-IOS-XE-native:native/router/Cisco-IOS-XE-bgp:bgp=65000"
+resource "iosxe_yang" "PreReq0" {
+ path = "/Cisco-IOS-XE-native:native/router/Cisco-IOS-XE-bgp:bgp[id=65000]"
attributes = {
"id" = "65000"
}
@@ -110,7 +110,7 @@ func testAccIosxeBGPAddressFamilyIPv4Config_minimum() string {
config := `resource "iosxe_bgp_address_family_ipv4" "test" {` + "\n"
config += ` asn = "65000"` + "\n"
config += ` af_name = "unicast"` + "\n"
- config += ` depends_on = [iosxe_restconf.PreReq0, ]` + "\n"
+ config += ` depends_on = [iosxe_yang.PreReq0, ]` + "\n"
config += `}` + "\n"
return config
}
@@ -148,7 +148,7 @@ func testAccIosxeBGPAddressFamilyIPv4Config_all() string {
config += ` ipv4_unicast_distance_bgp_external = 20` + "\n"
config += ` ipv4_unicast_distance_bgp_internal = 200` + "\n"
config += ` ipv4_unicast_distance_bgp_local = 200` + "\n"
- config += ` depends_on = [iosxe_restconf.PreReq0, ]` + "\n"
+ config += ` depends_on = [iosxe_yang.PreReq0, ]` + "\n"
config += `}` + "\n"
return config
}
diff --git a/internal/provider/resource_iosxe_bgp_address_family_ipv4_vrf.go b/internal/provider/resource_iosxe_bgp_address_family_ipv4_vrf.go
index 0afc9058..b0fbfca5 100644
--- a/internal/provider/resource_iosxe_bgp_address_family_ipv4_vrf.go
+++ b/internal/provider/resource_iosxe_bgp_address_family_ipv4_vrf.go
@@ -37,6 +37,7 @@ import (
"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-netconf"
"github.com/netascode/go-restconf"
)
@@ -313,37 +314,59 @@ func (r *BGPAddressFamilyIPv4VRFResource) Create(ctx context.Context, req resour
}
if device.Managed {
- // Create object
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ // Create object
+ body := plan.toBody(ctx)
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
- return
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
+ return
+ }
+ } else {
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
- return
- }
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
+ }
+
+ body := plan.toBodyXML(ctx)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
@@ -381,25 +404,51 @@ func (r *BGPAddressFamilyIPv4VRFResource) Read(ctx context.Context, req resource
}
if device.Managed {
- res, err := device.Client.GetData(state.Id.ValueString())
- if res.StatusCode == 404 {
- state = BGPAddressFamilyIPv4VRF{Device: state.Device, Id: state.Id}
+ imp, diags := helpers.IsFlagImporting(ctx, req)
+ if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ return
+ }
+
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(state.Id.ValueString())
+ if res.StatusCode == 404 {
+ state = BGPAddressFamilyIPv4VRF{Device: state.Device, Id: state.Id}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
+ return
+ }
+
+ // After `terraform import` we switch to a full read.
+ if imp {
+ state.fromBody(ctx, res.Res)
+ } else {
+ state.updateFromBody(ctx, res.Res)
+ }
+ }
} else {
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
- return
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
}
- imp, diags := helpers.IsFlagImporting(ctx, req)
- if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ filter := helpers.GetXpathFilter(state.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.getPath(), err))
return
}
// After `terraform import` we switch to a full read.
if imp {
- state.fromBody(ctx, res.Res)
+ state.fromBodyXML(ctx, res.Res)
} else {
- state.updateFromBody(ctx, res.Res)
+ state.updateFromBodyXML(ctx, res.Res)
}
}
}
@@ -442,51 +491,74 @@ func (r *BGPAddressFamilyIPv4VRFResource) Update(ctx context.Context, req resour
}
if device.Managed {
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ body := plan.toBody(ctx)
- deletedItems := plan.getDeletedItems(ctx, state)
- tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
+ deletedItems := plan.getDeletedItems(ctx, state)
+ tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- var edits []restconf.YangPatchEdit
- for _, i := range deletedItems {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
- return
+ if YangPatch {
+ var edits []restconf.YangPatchEdit
+ for _, i := range deletedItems {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletedItems {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- for _, i := range deletedItems {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
}
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+
+ body := plan.toBodyXML(ctx)
+ body = plan.addDeletedItemsXML(ctx, state, body)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
return
}
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
- return
- }
- }
}
}
@@ -519,6 +591,18 @@ func (r *BGPAddressFamilyIPv4VRFResource) Delete(ctx context.Context, req resour
}
if device.Managed {
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.Protocol == "netconf" && device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
+ }
deleteMode := "all"
if state.DeleteMode.ValueString() == "all" {
deleteMode = "all"
@@ -527,31 +611,52 @@ func (r *BGPAddressFamilyIPv4VRFResource) Delete(ctx context.Context, req resour
}
if deleteMode == "all" {
- res, err := device.Client.DeleteData(state.Id.ValueString())
- if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
- return
- }
- } else {
- deletePaths := state.getDeletePaths(ctx)
- tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
-
- if YangPatch {
- edits := []restconf.YangPatchEdit{}
- for _, i := range deletePaths {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.DeleteData(state.Id.ValueString())
+ if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
return
}
} else {
- for _, i := range deletePaths {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // NETCONF
+ body := netconf.Body{}
+ body = helpers.RemoveFromXPath(body, state.getXPath())
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body.Res(), true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
+ }
+ }
+ } else {
+ if device.Protocol == "restconf" {
+ deletePaths := state.getDeletePaths(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
+
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{}
+ for _, i := range deletePaths {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
}
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletePaths {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ }
+ }
+ }
+ } else {
+ // NETCONF
+ body := state.addDeletePathsXML(ctx, "")
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
diff --git a/internal/provider/resource_iosxe_bgp_address_family_ipv4_vrf_test.go b/internal/provider/resource_iosxe_bgp_address_family_ipv4_vrf_test.go
index 61e6bcf1..dfee6dbc 100644
--- a/internal/provider/resource_iosxe_bgp_address_family_ipv4_vrf_test.go
+++ b/internal/provider/resource_iosxe_bgp_address_family_ipv4_vrf_test.go
@@ -94,8 +94,8 @@ func iosxeBGPAddressFamilyIPv4VRFImportStateIdFunc(resourceName string) resource
// Section below is generated&owned by "gen/generator.go". //template:begin testPrerequisites
const testAccIosxeBGPAddressFamilyIPv4VRFPrerequisitesConfig = `
-resource "iosxe_restconf" "PreReq0" {
- path = "Cisco-IOS-XE-native:native/vrf/definition=VRF1"
+resource "iosxe_yang" "PreReq0" {
+ path = "/Cisco-IOS-XE-native:native/vrf/definition[name=VRF1]"
delete = false
attributes = {
"name" = "VRF1"
@@ -104,23 +104,23 @@ resource "iosxe_restconf" "PreReq0" {
}
}
-resource "iosxe_restconf" "PreReq1" {
- path = "Cisco-IOS-XE-native:native/router/Cisco-IOS-XE-bgp:bgp=65000"
+resource "iosxe_yang" "PreReq1" {
+ path = "/Cisco-IOS-XE-native:native/router/Cisco-IOS-XE-bgp:bgp[id=65000]"
attributes = {
"id" = "65000"
}
- depends_on = [iosxe_restconf.PreReq0, ]
+ depends_on = [iosxe_yang.PreReq0, ]
}
-resource "iosxe_restconf" "PreReq2" {
- path = "Cisco-IOS-XE-native:native/interface/Loopback=101"
+resource "iosxe_yang" "PreReq2" {
+ path = "/Cisco-IOS-XE-native:native/interface/Loopback[name=101]"
attributes = {
"name" = "101"
"ip/address/primary/address" = "22.22.22.22"
"ip/address/primary/mask" = "255.255.255.255"
"vrf/forwarding" = "VRF1"
}
- depends_on = [iosxe_restconf.PreReq0, ]
+ depends_on = [iosxe_yang.PreReq0, ]
}
`
@@ -133,7 +133,7 @@ func testAccIosxeBGPAddressFamilyIPv4VRFConfig_minimum() string {
config := `resource "iosxe_bgp_address_family_ipv4_vrf" "test" {` + "\n"
config += ` asn = "65000"` + "\n"
config += ` af_name = "unicast"` + "\n"
- config += ` depends_on = [iosxe_restconf.PreReq0, iosxe_restconf.PreReq1, iosxe_restconf.PreReq2, ]` + "\n"
+ config += ` depends_on = [iosxe_yang.PreReq0, iosxe_yang.PreReq1, iosxe_yang.PreReq2, ]` + "\n"
config += `}` + "\n"
return config
}
@@ -177,7 +177,7 @@ func testAccIosxeBGPAddressFamilyIPv4VRFConfig_all() string {
config += ` ipv4_unicast_distance_bgp_internal = 200` + "\n"
config += ` ipv4_unicast_distance_bgp_local = 200` + "\n"
config += ` }]` + "\n"
- config += ` depends_on = [iosxe_restconf.PreReq0, iosxe_restconf.PreReq1, iosxe_restconf.PreReq2, ]` + "\n"
+ config += ` depends_on = [iosxe_yang.PreReq0, iosxe_yang.PreReq1, iosxe_yang.PreReq2, ]` + "\n"
config += `}` + "\n"
return config
}
diff --git a/internal/provider/resource_iosxe_bgp_address_family_ipv6.go b/internal/provider/resource_iosxe_bgp_address_family_ipv6.go
index 5766d2e8..9e1d1ff6 100644
--- a/internal/provider/resource_iosxe_bgp_address_family_ipv6.go
+++ b/internal/provider/resource_iosxe_bgp_address_family_ipv6.go
@@ -36,6 +36,7 @@ import (
"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-netconf"
"github.com/netascode/go-restconf"
)
@@ -169,37 +170,59 @@ func (r *BGPAddressFamilyIPv6Resource) Create(ctx context.Context, req resource.
}
if device.Managed {
- // Create object
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ // Create object
+ body := plan.toBody(ctx)
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
- return
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
+ return
+ }
+ } else {
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
- return
- }
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
+ }
+
+ body := plan.toBodyXML(ctx)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
@@ -237,25 +260,51 @@ func (r *BGPAddressFamilyIPv6Resource) Read(ctx context.Context, req resource.Re
}
if device.Managed {
- res, err := device.Client.GetData(state.Id.ValueString())
- if res.StatusCode == 404 {
- state = BGPAddressFamilyIPv6{Device: state.Device, Id: state.Id}
+ imp, diags := helpers.IsFlagImporting(ctx, req)
+ if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ return
+ }
+
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(state.Id.ValueString())
+ if res.StatusCode == 404 {
+ state = BGPAddressFamilyIPv6{Device: state.Device, Id: state.Id}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
+ return
+ }
+
+ // After `terraform import` we switch to a full read.
+ if imp {
+ state.fromBody(ctx, res.Res)
+ } else {
+ state.updateFromBody(ctx, res.Res)
+ }
+ }
} else {
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
- return
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
}
- imp, diags := helpers.IsFlagImporting(ctx, req)
- if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ filter := helpers.GetXpathFilter(state.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.getPath(), err))
return
}
// After `terraform import` we switch to a full read.
if imp {
- state.fromBody(ctx, res.Res)
+ state.fromBodyXML(ctx, res.Res)
} else {
- state.updateFromBody(ctx, res.Res)
+ state.updateFromBodyXML(ctx, res.Res)
}
}
}
@@ -298,51 +347,74 @@ func (r *BGPAddressFamilyIPv6Resource) Update(ctx context.Context, req resource.
}
if device.Managed {
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ body := plan.toBody(ctx)
- deletedItems := plan.getDeletedItems(ctx, state)
- tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
+ deletedItems := plan.getDeletedItems(ctx, state)
+ tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- var edits []restconf.YangPatchEdit
- for _, i := range deletedItems {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
- return
+ if YangPatch {
+ var edits []restconf.YangPatchEdit
+ for _, i := range deletedItems {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletedItems {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- for _, i := range deletedItems {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
}
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+
+ body := plan.toBodyXML(ctx)
+ body = plan.addDeletedItemsXML(ctx, state, body)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
return
}
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
- return
- }
- }
}
}
@@ -375,6 +447,18 @@ func (r *BGPAddressFamilyIPv6Resource) Delete(ctx context.Context, req resource.
}
if device.Managed {
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.Protocol == "netconf" && device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
+ }
deleteMode := "all"
if state.DeleteMode.ValueString() == "all" {
deleteMode = "all"
@@ -383,31 +467,52 @@ func (r *BGPAddressFamilyIPv6Resource) Delete(ctx context.Context, req resource.
}
if deleteMode == "all" {
- res, err := device.Client.DeleteData(state.Id.ValueString())
- if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
- return
- }
- } else {
- deletePaths := state.getDeletePaths(ctx)
- tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
-
- if YangPatch {
- edits := []restconf.YangPatchEdit{}
- for _, i := range deletePaths {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.DeleteData(state.Id.ValueString())
+ if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
return
}
} else {
- for _, i := range deletePaths {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // NETCONF
+ body := netconf.Body{}
+ body = helpers.RemoveFromXPath(body, state.getXPath())
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body.Res(), true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
+ }
+ }
+ } else {
+ if device.Protocol == "restconf" {
+ deletePaths := state.getDeletePaths(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
+
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{}
+ for _, i := range deletePaths {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
}
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletePaths {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ }
+ }
+ }
+ } else {
+ // NETCONF
+ body := state.addDeletePathsXML(ctx, "")
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
diff --git a/internal/provider/resource_iosxe_bgp_address_family_ipv6_test.go b/internal/provider/resource_iosxe_bgp_address_family_ipv6_test.go
index e3cb6565..e0e83f9a 100644
--- a/internal/provider/resource_iosxe_bgp_address_family_ipv6_test.go
+++ b/internal/provider/resource_iosxe_bgp_address_family_ipv6_test.go
@@ -81,15 +81,15 @@ func iosxeBGPAddressFamilyIPv6ImportStateIdFunc(resourceName string) resource.Im
// Section below is generated&owned by "gen/generator.go". //template:begin testPrerequisites
const testAccIosxeBGPAddressFamilyIPv6PrerequisitesConfig = `
-resource "iosxe_restconf" "PreReq0" {
- path = "Cisco-IOS-XE-native:native/ipv6"
+resource "iosxe_yang" "PreReq0" {
+ path = "/Cisco-IOS-XE-native:native/ipv6"
attributes = {
"unicast-routing" = ""
}
}
-resource "iosxe_restconf" "PreReq1" {
- path = "Cisco-IOS-XE-native:native/router/Cisco-IOS-XE-bgp:bgp=65000"
+resource "iosxe_yang" "PreReq1" {
+ path = "/Cisco-IOS-XE-native:native/router/Cisco-IOS-XE-bgp:bgp[id=65000]"
attributes = {
"id" = "65000"
}
@@ -105,7 +105,7 @@ func testAccIosxeBGPAddressFamilyIPv6Config_minimum() string {
config := `resource "iosxe_bgp_address_family_ipv6" "test" {` + "\n"
config += ` asn = "65000"` + "\n"
config += ` af_name = "unicast"` + "\n"
- config += ` depends_on = [iosxe_restconf.PreReq0, iosxe_restconf.PreReq1, ]` + "\n"
+ config += ` depends_on = [iosxe_yang.PreReq0, iosxe_yang.PreReq1, ]` + "\n"
config += `}` + "\n"
return config
}
@@ -125,7 +125,7 @@ func testAccIosxeBGPAddressFamilyIPv6Config_all() string {
config += ` route_map = "RM1"` + "\n"
config += ` backdoor = true` + "\n"
config += ` }]` + "\n"
- config += ` depends_on = [iosxe_restconf.PreReq0, iosxe_restconf.PreReq1, ]` + "\n"
+ config += ` depends_on = [iosxe_yang.PreReq0, iosxe_yang.PreReq1, ]` + "\n"
config += `}` + "\n"
return config
}
diff --git a/internal/provider/resource_iosxe_bgp_address_family_ipv6_vrf.go b/internal/provider/resource_iosxe_bgp_address_family_ipv6_vrf.go
index 817fbace..a85d370b 100644
--- a/internal/provider/resource_iosxe_bgp_address_family_ipv6_vrf.go
+++ b/internal/provider/resource_iosxe_bgp_address_family_ipv6_vrf.go
@@ -36,6 +36,7 @@ import (
"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-netconf"
"github.com/netascode/go-restconf"
)
@@ -189,37 +190,59 @@ func (r *BGPAddressFamilyIPv6VRFResource) Create(ctx context.Context, req resour
}
if device.Managed {
- // Create object
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ // Create object
+ body := plan.toBody(ctx)
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
- return
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
+ return
+ }
+ } else {
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
- return
- }
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
+ }
+
+ body := plan.toBodyXML(ctx)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
@@ -257,25 +280,51 @@ func (r *BGPAddressFamilyIPv6VRFResource) Read(ctx context.Context, req resource
}
if device.Managed {
- res, err := device.Client.GetData(state.Id.ValueString())
- if res.StatusCode == 404 {
- state = BGPAddressFamilyIPv6VRF{Device: state.Device, Id: state.Id}
+ imp, diags := helpers.IsFlagImporting(ctx, req)
+ if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ return
+ }
+
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(state.Id.ValueString())
+ if res.StatusCode == 404 {
+ state = BGPAddressFamilyIPv6VRF{Device: state.Device, Id: state.Id}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
+ return
+ }
+
+ // After `terraform import` we switch to a full read.
+ if imp {
+ state.fromBody(ctx, res.Res)
+ } else {
+ state.updateFromBody(ctx, res.Res)
+ }
+ }
} else {
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
- return
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
}
- imp, diags := helpers.IsFlagImporting(ctx, req)
- if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ filter := helpers.GetXpathFilter(state.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.getPath(), err))
return
}
// After `terraform import` we switch to a full read.
if imp {
- state.fromBody(ctx, res.Res)
+ state.fromBodyXML(ctx, res.Res)
} else {
- state.updateFromBody(ctx, res.Res)
+ state.updateFromBodyXML(ctx, res.Res)
}
}
}
@@ -318,51 +367,74 @@ func (r *BGPAddressFamilyIPv6VRFResource) Update(ctx context.Context, req resour
}
if device.Managed {
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ body := plan.toBody(ctx)
- deletedItems := plan.getDeletedItems(ctx, state)
- tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
+ deletedItems := plan.getDeletedItems(ctx, state)
+ tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- var edits []restconf.YangPatchEdit
- for _, i := range deletedItems {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
- return
+ if YangPatch {
+ var edits []restconf.YangPatchEdit
+ for _, i := range deletedItems {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletedItems {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- for _, i := range deletedItems {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
}
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+
+ body := plan.toBodyXML(ctx)
+ body = plan.addDeletedItemsXML(ctx, state, body)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
return
}
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
- return
- }
- }
}
}
@@ -395,6 +467,18 @@ func (r *BGPAddressFamilyIPv6VRFResource) Delete(ctx context.Context, req resour
}
if device.Managed {
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.Protocol == "netconf" && device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
+ }
deleteMode := "all"
if state.DeleteMode.ValueString() == "all" {
deleteMode = "all"
@@ -403,31 +487,52 @@ func (r *BGPAddressFamilyIPv6VRFResource) Delete(ctx context.Context, req resour
}
if deleteMode == "all" {
- res, err := device.Client.DeleteData(state.Id.ValueString())
- if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
- return
- }
- } else {
- deletePaths := state.getDeletePaths(ctx)
- tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
-
- if YangPatch {
- edits := []restconf.YangPatchEdit{}
- for _, i := range deletePaths {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.DeleteData(state.Id.ValueString())
+ if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
return
}
} else {
- for _, i := range deletePaths {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // NETCONF
+ body := netconf.Body{}
+ body = helpers.RemoveFromXPath(body, state.getXPath())
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body.Res(), true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
+ }
+ }
+ } else {
+ if device.Protocol == "restconf" {
+ deletePaths := state.getDeletePaths(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
+
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{}
+ for _, i := range deletePaths {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
}
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletePaths {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ }
+ }
+ }
+ } else {
+ // NETCONF
+ body := state.addDeletePathsXML(ctx, "")
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
diff --git a/internal/provider/resource_iosxe_bgp_address_family_ipv6_vrf_test.go b/internal/provider/resource_iosxe_bgp_address_family_ipv6_vrf_test.go
index b35d11fe..b7e90dd7 100644
--- a/internal/provider/resource_iosxe_bgp_address_family_ipv6_vrf_test.go
+++ b/internal/provider/resource_iosxe_bgp_address_family_ipv6_vrf_test.go
@@ -81,30 +81,30 @@ func iosxeBGPAddressFamilyIPv6VRFImportStateIdFunc(resourceName string) resource
// Section below is generated&owned by "gen/generator.go". //template:begin testPrerequisites
const testAccIosxeBGPAddressFamilyIPv6VRFPrerequisitesConfig = `
-resource "iosxe_restconf" "PreReq0" {
- path = "Cisco-IOS-XE-native:native/ipv6"
+resource "iosxe_yang" "PreReq0" {
+ path = "/Cisco-IOS-XE-native:native/ipv6"
attributes = {
"unicast-routing" = ""
}
}
-resource "iosxe_restconf" "PreReq1" {
- path = "Cisco-IOS-XE-native:native/vrf/definition=VRF1"
+resource "iosxe_yang" "PreReq1" {
+ path = "/Cisco-IOS-XE-native:native/vrf/definition[name=VRF1]"
delete = false
attributes = {
"name" = "VRF1"
"rd" = "1:1"
"address-family/ipv6" = ""
}
- depends_on = [iosxe_restconf.PreReq0, ]
+ depends_on = [iosxe_yang.PreReq0, ]
}
-resource "iosxe_restconf" "PreReq2" {
- path = "Cisco-IOS-XE-native:native/router/Cisco-IOS-XE-bgp:bgp=65000"
+resource "iosxe_yang" "PreReq2" {
+ path = "/Cisco-IOS-XE-native:native/router/Cisco-IOS-XE-bgp:bgp[id=65000]"
attributes = {
"id" = "65000"
}
- depends_on = [iosxe_restconf.PreReq1, ]
+ depends_on = [iosxe_yang.PreReq1, ]
}
`
@@ -117,7 +117,7 @@ func testAccIosxeBGPAddressFamilyIPv6VRFConfig_minimum() string {
config := `resource "iosxe_bgp_address_family_ipv6_vrf" "test" {` + "\n"
config += ` asn = "65000"` + "\n"
config += ` af_name = "unicast"` + "\n"
- config += ` depends_on = [iosxe_restconf.PreReq0, iosxe_restconf.PreReq1, iosxe_restconf.PreReq2, ]` + "\n"
+ config += ` depends_on = [iosxe_yang.PreReq0, iosxe_yang.PreReq1, iosxe_yang.PreReq2, ]` + "\n"
config += `}` + "\n"
return config
}
@@ -142,7 +142,7 @@ func testAccIosxeBGPAddressFamilyIPv6VRFConfig_all() string {
config += ` evpn = false` + "\n"
config += ` }]` + "\n"
config += ` }]` + "\n"
- config += ` depends_on = [iosxe_restconf.PreReq0, iosxe_restconf.PreReq1, iosxe_restconf.PreReq2, ]` + "\n"
+ config += ` depends_on = [iosxe_yang.PreReq0, iosxe_yang.PreReq1, iosxe_yang.PreReq2, ]` + "\n"
config += `}` + "\n"
return config
}
diff --git a/internal/provider/resource_iosxe_bgp_address_family_l2vpn.go b/internal/provider/resource_iosxe_bgp_address_family_l2vpn.go
index cfa27586..d660c565 100644
--- a/internal/provider/resource_iosxe_bgp_address_family_l2vpn.go
+++ b/internal/provider/resource_iosxe_bgp_address_family_l2vpn.go
@@ -35,6 +35,7 @@ import (
"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-netconf"
"github.com/netascode/go-restconf"
)
@@ -136,37 +137,59 @@ func (r *BGPAddressFamilyL2VPNResource) Create(ctx context.Context, req resource
}
if device.Managed {
- // Create object
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ // Create object
+ body := plan.toBody(ctx)
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
- return
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
+ return
+ }
+ } else {
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
- return
- }
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
+ }
+
+ body := plan.toBodyXML(ctx)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
@@ -204,25 +227,51 @@ func (r *BGPAddressFamilyL2VPNResource) Read(ctx context.Context, req resource.R
}
if device.Managed {
- res, err := device.Client.GetData(state.Id.ValueString())
- if res.StatusCode == 404 {
- state = BGPAddressFamilyL2VPN{Device: state.Device, Id: state.Id}
+ imp, diags := helpers.IsFlagImporting(ctx, req)
+ if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ return
+ }
+
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(state.Id.ValueString())
+ if res.StatusCode == 404 {
+ state = BGPAddressFamilyL2VPN{Device: state.Device, Id: state.Id}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
+ return
+ }
+
+ // After `terraform import` we switch to a full read.
+ if imp {
+ state.fromBody(ctx, res.Res)
+ } else {
+ state.updateFromBody(ctx, res.Res)
+ }
+ }
} else {
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
- return
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
}
- imp, diags := helpers.IsFlagImporting(ctx, req)
- if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ filter := helpers.GetXpathFilter(state.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.getPath(), err))
return
}
// After `terraform import` we switch to a full read.
if imp {
- state.fromBody(ctx, res.Res)
+ state.fromBodyXML(ctx, res.Res)
} else {
- state.updateFromBody(ctx, res.Res)
+ state.updateFromBodyXML(ctx, res.Res)
}
}
}
@@ -265,51 +314,74 @@ func (r *BGPAddressFamilyL2VPNResource) Update(ctx context.Context, req resource
}
if device.Managed {
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ body := plan.toBody(ctx)
- deletedItems := plan.getDeletedItems(ctx, state)
- tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
+ deletedItems := plan.getDeletedItems(ctx, state)
+ tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- var edits []restconf.YangPatchEdit
- for _, i := range deletedItems {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
- return
+ if YangPatch {
+ var edits []restconf.YangPatchEdit
+ for _, i := range deletedItems {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletedItems {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- for _, i := range deletedItems {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
}
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+
+ body := plan.toBodyXML(ctx)
+ body = plan.addDeletedItemsXML(ctx, state, body)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
return
}
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
- return
- }
- }
}
}
@@ -342,6 +414,18 @@ func (r *BGPAddressFamilyL2VPNResource) Delete(ctx context.Context, req resource
}
if device.Managed {
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.Protocol == "netconf" && device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
+ }
deleteMode := "all"
if state.DeleteMode.ValueString() == "all" {
deleteMode = "all"
@@ -350,31 +434,52 @@ func (r *BGPAddressFamilyL2VPNResource) Delete(ctx context.Context, req resource
}
if deleteMode == "all" {
- res, err := device.Client.DeleteData(state.Id.ValueString())
- if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
- return
- }
- } else {
- deletePaths := state.getDeletePaths(ctx)
- tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
-
- if YangPatch {
- edits := []restconf.YangPatchEdit{}
- for _, i := range deletePaths {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.DeleteData(state.Id.ValueString())
+ if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
return
}
} else {
- for _, i := range deletePaths {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // NETCONF
+ body := netconf.Body{}
+ body = helpers.RemoveFromXPath(body, state.getXPath())
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body.Res(), true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
+ }
+ }
+ } else {
+ if device.Protocol == "restconf" {
+ deletePaths := state.getDeletePaths(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
+
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{}
+ for _, i := range deletePaths {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
}
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletePaths {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ }
+ }
+ }
+ } else {
+ // NETCONF
+ body := state.addDeletePathsXML(ctx, "")
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
diff --git a/internal/provider/resource_iosxe_bgp_address_family_l2vpn_test.go b/internal/provider/resource_iosxe_bgp_address_family_l2vpn_test.go
index 6a3a7be6..a8191041 100644
--- a/internal/provider/resource_iosxe_bgp_address_family_l2vpn_test.go
+++ b/internal/provider/resource_iosxe_bgp_address_family_l2vpn_test.go
@@ -80,8 +80,8 @@ func iosxeBGPAddressFamilyL2VPNImportStateIdFunc(resourceName string) resource.I
// Section below is generated&owned by "gen/generator.go". //template:begin testPrerequisites
const testAccIosxeBGPAddressFamilyL2VPNPrerequisitesConfig = `
-resource "iosxe_restconf" "PreReq0" {
- path = "Cisco-IOS-XE-native:native/router/Cisco-IOS-XE-bgp:bgp=65000"
+resource "iosxe_yang" "PreReq0" {
+ path = "/Cisco-IOS-XE-native:native/router/Cisco-IOS-XE-bgp:bgp[id=65000]"
attributes = {
"id" = "65000"
}
@@ -97,7 +97,7 @@ func testAccIosxeBGPAddressFamilyL2VPNConfig_minimum() string {
config := `resource "iosxe_bgp_address_family_l2vpn" "test" {` + "\n"
config += ` asn = "65000"` + "\n"
config += ` af_name = "evpn"` + "\n"
- config += ` depends_on = [iosxe_restconf.PreReq0, ]` + "\n"
+ config += ` depends_on = [iosxe_yang.PreReq0, ]` + "\n"
config += `}` + "\n"
return config
}
@@ -110,7 +110,7 @@ func testAccIosxeBGPAddressFamilyL2VPNConfig_all() string {
config := `resource "iosxe_bgp_address_family_l2vpn" "test" {` + "\n"
config += ` asn = "65000"` + "\n"
config += ` af_name = "evpn"` + "\n"
- config += ` depends_on = [iosxe_restconf.PreReq0, ]` + "\n"
+ config += ` depends_on = [iosxe_yang.PreReq0, ]` + "\n"
config += `}` + "\n"
return config
}
diff --git a/internal/provider/resource_iosxe_bgp_ipv4_unicast_neighbor.go b/internal/provider/resource_iosxe_bgp_ipv4_unicast_neighbor.go
index fcf583cd..e071560b 100644
--- a/internal/provider/resource_iosxe_bgp_ipv4_unicast_neighbor.go
+++ b/internal/provider/resource_iosxe_bgp_ipv4_unicast_neighbor.go
@@ -36,6 +36,7 @@ import (
"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-netconf"
"github.com/netascode/go-restconf"
)
@@ -185,37 +186,59 @@ func (r *BGPIPv4UnicastNeighborResource) Create(ctx context.Context, req resourc
}
if device.Managed {
- // Create object
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ // Create object
+ body := plan.toBody(ctx)
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
- return
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
+ return
+ }
+ } else {
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
- return
- }
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
+ }
+
+ body := plan.toBodyXML(ctx)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
@@ -253,25 +276,51 @@ func (r *BGPIPv4UnicastNeighborResource) Read(ctx context.Context, req resource.
}
if device.Managed {
- res, err := device.Client.GetData(state.Id.ValueString())
- if res.StatusCode == 404 {
- state = BGPIPv4UnicastNeighbor{Device: state.Device, Id: state.Id}
+ imp, diags := helpers.IsFlagImporting(ctx, req)
+ if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ return
+ }
+
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(state.Id.ValueString())
+ if res.StatusCode == 404 {
+ state = BGPIPv4UnicastNeighbor{Device: state.Device, Id: state.Id}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
+ return
+ }
+
+ // After `terraform import` we switch to a full read.
+ if imp {
+ state.fromBody(ctx, res.Res)
+ } else {
+ state.updateFromBody(ctx, res.Res)
+ }
+ }
} else {
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
- return
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
}
- imp, diags := helpers.IsFlagImporting(ctx, req)
- if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ filter := helpers.GetXpathFilter(state.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.getPath(), err))
return
}
// After `terraform import` we switch to a full read.
if imp {
- state.fromBody(ctx, res.Res)
+ state.fromBodyXML(ctx, res.Res)
} else {
- state.updateFromBody(ctx, res.Res)
+ state.updateFromBodyXML(ctx, res.Res)
}
}
}
@@ -314,51 +363,74 @@ func (r *BGPIPv4UnicastNeighborResource) Update(ctx context.Context, req resourc
}
if device.Managed {
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ body := plan.toBody(ctx)
- deletedItems := plan.getDeletedItems(ctx, state)
- tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
+ deletedItems := plan.getDeletedItems(ctx, state)
+ tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- var edits []restconf.YangPatchEdit
- for _, i := range deletedItems {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
- return
+ if YangPatch {
+ var edits []restconf.YangPatchEdit
+ for _, i := range deletedItems {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletedItems {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- for _, i := range deletedItems {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
}
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+
+ body := plan.toBodyXML(ctx)
+ body = plan.addDeletedItemsXML(ctx, state, body)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
return
}
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
- return
- }
- }
}
}
@@ -391,6 +463,18 @@ func (r *BGPIPv4UnicastNeighborResource) Delete(ctx context.Context, req resourc
}
if device.Managed {
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.Protocol == "netconf" && device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
+ }
deleteMode := "all"
if state.DeleteMode.ValueString() == "all" {
deleteMode = "all"
@@ -399,31 +483,52 @@ func (r *BGPIPv4UnicastNeighborResource) Delete(ctx context.Context, req resourc
}
if deleteMode == "all" {
- res, err := device.Client.DeleteData(state.Id.ValueString())
- if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
- return
- }
- } else {
- deletePaths := state.getDeletePaths(ctx)
- tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
-
- if YangPatch {
- edits := []restconf.YangPatchEdit{}
- for _, i := range deletePaths {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.DeleteData(state.Id.ValueString())
+ if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
return
}
} else {
- for _, i := range deletePaths {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // NETCONF
+ body := netconf.Body{}
+ body = helpers.RemoveFromXPath(body, state.getXPath())
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body.Res(), true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
+ }
+ }
+ } else {
+ if device.Protocol == "restconf" {
+ deletePaths := state.getDeletePaths(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
+
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{}
+ for _, i := range deletePaths {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
}
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletePaths {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ }
+ }
+ }
+ } else {
+ // NETCONF
+ body := state.addDeletePathsXML(ctx, "")
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
diff --git a/internal/provider/resource_iosxe_bgp_ipv4_unicast_neighbor_test.go b/internal/provider/resource_iosxe_bgp_ipv4_unicast_neighbor_test.go
index 6376be74..79503562 100644
--- a/internal/provider/resource_iosxe_bgp_ipv4_unicast_neighbor_test.go
+++ b/internal/provider/resource_iosxe_bgp_ipv4_unicast_neighbor_test.go
@@ -84,32 +84,32 @@ func iosxeBGPIPv4UnicastNeighborImportStateIdFunc(resourceName string) resource.
// Section below is generated&owned by "gen/generator.go". //template:begin testPrerequisites
const testAccIosxeBGPIPv4UnicastNeighborPrerequisitesConfig = `
-resource "iosxe_restconf" "PreReq0" {
- path = "Cisco-IOS-XE-native:native/router/Cisco-IOS-XE-bgp:bgp=65000"
+resource "iosxe_yang" "PreReq0" {
+ path = "/Cisco-IOS-XE-native:native/router/Cisco-IOS-XE-bgp:bgp[id=65000]"
attributes = {
"id" = "65000"
}
}
-resource "iosxe_restconf" "PreReq1" {
- path = "Cisco-IOS-XE-native:native/router/Cisco-IOS-XE-bgp:bgp=65000/address-family/no-vrf/ipv4=unicast"
+resource "iosxe_yang" "PreReq1" {
+ path = "/Cisco-IOS-XE-native:native/router/Cisco-IOS-XE-bgp:bgp[id=65000]/address-family/no-vrf/ipv4[af-name=unicast]"
attributes = {
"af-name" = "unicast"
}
- depends_on = [iosxe_restconf.PreReq0, ]
+ depends_on = [iosxe_yang.PreReq0, ]
}
-resource "iosxe_restconf" "PreReq2" {
- path = "Cisco-IOS-XE-native:native/router/Cisco-IOS-XE-bgp:bgp=65000/neighbor=3.3.3.3"
+resource "iosxe_yang" "PreReq2" {
+ path = "/Cisco-IOS-XE-native:native/router/Cisco-IOS-XE-bgp:bgp[id=65000]/neighbor[id=3.3.3.3]"
attributes = {
"id" = "3.3.3.3"
"remote-as" = "65000"
}
- depends_on = [iosxe_restconf.PreReq0, ]
+ depends_on = [iosxe_yang.PreReq0, ]
}
-resource "iosxe_restconf" "PreReq3" {
- path = "Cisco-IOS-XE-native:native/interface/Loopback=100"
+resource "iosxe_yang" "PreReq3" {
+ path = "/Cisco-IOS-XE-native:native/interface/Loopback[name=100]"
attributes = {
"name" = "100"
}
@@ -125,7 +125,7 @@ func testAccIosxeBGPIPv4UnicastNeighborConfig_minimum() string {
config := `resource "iosxe_bgp_ipv4_unicast_neighbor" "test" {` + "\n"
config += ` asn = "65000"` + "\n"
config += ` ip = "3.3.3.3"` + "\n"
- config += ` depends_on = [iosxe_restconf.PreReq0, iosxe_restconf.PreReq1, iosxe_restconf.PreReq2, iosxe_restconf.PreReq3, ]` + "\n"
+ config += ` depends_on = [iosxe_yang.PreReq0, iosxe_yang.PreReq1, iosxe_yang.PreReq2, iosxe_yang.PreReq3, ]` + "\n"
config += `}` + "\n"
return config
}
@@ -148,7 +148,7 @@ func testAccIosxeBGPIPv4UnicastNeighborConfig_all() string {
config += ` in_out = "in"` + "\n"
config += ` route_map_name = "RM1"` + "\n"
config += ` }]` + "\n"
- config += ` depends_on = [iosxe_restconf.PreReq0, iosxe_restconf.PreReq1, iosxe_restconf.PreReq2, iosxe_restconf.PreReq3, ]` + "\n"
+ config += ` depends_on = [iosxe_yang.PreReq0, iosxe_yang.PreReq1, iosxe_yang.PreReq2, iosxe_yang.PreReq3, ]` + "\n"
config += `}` + "\n"
return config
}
diff --git a/internal/provider/resource_iosxe_bgp_ipv4_unicast_vrf_neighbor.go b/internal/provider/resource_iosxe_bgp_ipv4_unicast_vrf_neighbor.go
index 69c4cb84..b46e325c 100644
--- a/internal/provider/resource_iosxe_bgp_ipv4_unicast_vrf_neighbor.go
+++ b/internal/provider/resource_iosxe_bgp_ipv4_unicast_vrf_neighbor.go
@@ -38,6 +38,7 @@ import (
"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-netconf"
"github.com/netascode/go-restconf"
)
@@ -347,37 +348,59 @@ func (r *BGPIPv4UnicastVRFNeighborResource) Create(ctx context.Context, req reso
}
if device.Managed {
- // Create object
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ // Create object
+ body := plan.toBody(ctx)
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
- return
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
+ return
+ }
+ } else {
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
- return
- }
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
+ }
+
+ body := plan.toBodyXML(ctx)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
@@ -415,25 +438,51 @@ func (r *BGPIPv4UnicastVRFNeighborResource) Read(ctx context.Context, req resour
}
if device.Managed {
- res, err := device.Client.GetData(state.Id.ValueString())
- if res.StatusCode == 404 {
- state = BGPIPv4UnicastVRFNeighbor{Device: state.Device, Id: state.Id}
+ imp, diags := helpers.IsFlagImporting(ctx, req)
+ if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ return
+ }
+
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(state.Id.ValueString())
+ if res.StatusCode == 404 {
+ state = BGPIPv4UnicastVRFNeighbor{Device: state.Device, Id: state.Id}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
+ return
+ }
+
+ // After `terraform import` we switch to a full read.
+ if imp {
+ state.fromBody(ctx, res.Res)
+ } else {
+ state.updateFromBody(ctx, res.Res)
+ }
+ }
} else {
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
- return
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
}
- imp, diags := helpers.IsFlagImporting(ctx, req)
- if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ filter := helpers.GetXpathFilter(state.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.getPath(), err))
return
}
// After `terraform import` we switch to a full read.
if imp {
- state.fromBody(ctx, res.Res)
+ state.fromBodyXML(ctx, res.Res)
} else {
- state.updateFromBody(ctx, res.Res)
+ state.updateFromBodyXML(ctx, res.Res)
}
}
}
@@ -476,51 +525,74 @@ func (r *BGPIPv4UnicastVRFNeighborResource) Update(ctx context.Context, req reso
}
if device.Managed {
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ body := plan.toBody(ctx)
- deletedItems := plan.getDeletedItems(ctx, state)
- tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
+ deletedItems := plan.getDeletedItems(ctx, state)
+ tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- var edits []restconf.YangPatchEdit
- for _, i := range deletedItems {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
- return
+ if YangPatch {
+ var edits []restconf.YangPatchEdit
+ for _, i := range deletedItems {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletedItems {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- for _, i := range deletedItems {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
}
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+
+ body := plan.toBodyXML(ctx)
+ body = plan.addDeletedItemsXML(ctx, state, body)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
return
}
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
- return
- }
- }
}
}
@@ -553,6 +625,18 @@ func (r *BGPIPv4UnicastVRFNeighborResource) Delete(ctx context.Context, req reso
}
if device.Managed {
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.Protocol == "netconf" && device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
+ }
deleteMode := "all"
if state.DeleteMode.ValueString() == "all" {
deleteMode = "all"
@@ -561,31 +645,52 @@ func (r *BGPIPv4UnicastVRFNeighborResource) Delete(ctx context.Context, req reso
}
if deleteMode == "all" {
- res, err := device.Client.DeleteData(state.Id.ValueString())
- if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
- return
- }
- } else {
- deletePaths := state.getDeletePaths(ctx)
- tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
-
- if YangPatch {
- edits := []restconf.YangPatchEdit{}
- for _, i := range deletePaths {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.DeleteData(state.Id.ValueString())
+ if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
return
}
} else {
- for _, i := range deletePaths {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // NETCONF
+ body := netconf.Body{}
+ body = helpers.RemoveFromXPath(body, state.getXPath())
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body.Res(), true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
+ }
+ }
+ } else {
+ if device.Protocol == "restconf" {
+ deletePaths := state.getDeletePaths(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
+
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{}
+ for _, i := range deletePaths {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
}
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletePaths {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ }
+ }
+ }
+ } else {
+ // NETCONF
+ body := state.addDeletePathsXML(ctx, "")
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
diff --git a/internal/provider/resource_iosxe_bgp_ipv4_unicast_vrf_neighbor_test.go b/internal/provider/resource_iosxe_bgp_ipv4_unicast_vrf_neighbor_test.go
index 9b2bf596..7f6e9eae 100644
--- a/internal/provider/resource_iosxe_bgp_ipv4_unicast_vrf_neighbor_test.go
+++ b/internal/provider/resource_iosxe_bgp_ipv4_unicast_vrf_neighbor_test.go
@@ -101,8 +101,8 @@ func iosxeBGPIPv4UnicastVRFNeighborImportStateIdFunc(resourceName string) resour
// Section below is generated&owned by "gen/generator.go". //template:begin testPrerequisites
const testAccIosxeBGPIPv4UnicastVRFNeighborPrerequisitesConfig = `
-resource "iosxe_restconf" "PreReq0" {
- path = "Cisco-IOS-XE-native:native/vrf/definition=VRF1"
+resource "iosxe_yang" "PreReq0" {
+ path = "/Cisco-IOS-XE-native:native/vrf/definition[name=VRF1]"
delete = false
attributes = {
"name" = "VRF1"
@@ -111,15 +111,15 @@ resource "iosxe_restconf" "PreReq0" {
}
}
-resource "iosxe_restconf" "PreReq1" {
- path = "Cisco-IOS-XE-native:native/router/Cisco-IOS-XE-bgp:bgp=65000"
+resource "iosxe_yang" "PreReq1" {
+ path = "/Cisco-IOS-XE-native:native/router/Cisco-IOS-XE-bgp:bgp[id=65000]"
attributes = {
"id" = "65000"
}
}
-resource "iosxe_restconf" "PreReq2" {
- path = "Cisco-IOS-XE-native:native/router/Cisco-IOS-XE-bgp:bgp=65000/address-family/with-vrf/ipv4=unicast"
+resource "iosxe_yang" "PreReq2" {
+ path = "/Cisco-IOS-XE-native:native/router/Cisco-IOS-XE-bgp:bgp[id=65000]/address-family/with-vrf/ipv4[af-name=unicast]"
attributes = {
"af-name" = "unicast"
}
@@ -134,11 +134,11 @@ resource "iosxe_restconf" "PreReq2" {
]
},
]
- depends_on = [iosxe_restconf.PreReq0, iosxe_restconf.PreReq1, ]
+ depends_on = [iosxe_yang.PreReq0, iosxe_yang.PreReq1, ]
}
-resource "iosxe_restconf" "PreReq3" {
- path = "Cisco-IOS-XE-native:native/interface/Loopback=100"
+resource "iosxe_yang" "PreReq3" {
+ path = "/Cisco-IOS-XE-native:native/interface/Loopback[name=100]"
attributes = {
"name" = "100"
}
@@ -155,7 +155,7 @@ func testAccIosxeBGPIPv4UnicastVRFNeighborConfig_minimum() string {
config += ` asn = "65000"` + "\n"
config += ` vrf = "VRF1"` + "\n"
config += ` ip = "3.3.3.3"` + "\n"
- config += ` depends_on = [iosxe_restconf.PreReq0, iosxe_restconf.PreReq1, iosxe_restconf.PreReq2, iosxe_restconf.PreReq3, ]` + "\n"
+ config += ` depends_on = [iosxe_yang.PreReq0, iosxe_yang.PreReq1, iosxe_yang.PreReq2, iosxe_yang.PreReq3, ]` + "\n"
config += `}` + "\n"
return config
}
@@ -200,7 +200,7 @@ func testAccIosxeBGPIPv4UnicastVRFNeighborConfig_all() string {
config += ` next_hop_self = true` + "\n"
config += ` next_hop_self_all = true` + "\n"
config += ` advertisement_interval = 300` + "\n"
- config += ` depends_on = [iosxe_restconf.PreReq0, iosxe_restconf.PreReq1, iosxe_restconf.PreReq2, iosxe_restconf.PreReq3, ]` + "\n"
+ config += ` depends_on = [iosxe_yang.PreReq0, iosxe_yang.PreReq1, iosxe_yang.PreReq2, iosxe_yang.PreReq3, ]` + "\n"
config += `}` + "\n"
return config
}
diff --git a/internal/provider/resource_iosxe_bgp_ipv6_unicast_neighbor.go b/internal/provider/resource_iosxe_bgp_ipv6_unicast_neighbor.go
index 21b15e38..4e63e5e7 100644
--- a/internal/provider/resource_iosxe_bgp_ipv6_unicast_neighbor.go
+++ b/internal/provider/resource_iosxe_bgp_ipv6_unicast_neighbor.go
@@ -36,6 +36,7 @@ import (
"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-netconf"
"github.com/netascode/go-restconf"
)
@@ -185,37 +186,59 @@ func (r *BGPIPv6UnicastNeighborResource) Create(ctx context.Context, req resourc
}
if device.Managed {
- // Create object
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ // Create object
+ body := plan.toBody(ctx)
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
- return
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
+ return
+ }
+ } else {
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
- return
- }
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
+ }
+
+ body := plan.toBodyXML(ctx)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
@@ -253,25 +276,51 @@ func (r *BGPIPv6UnicastNeighborResource) Read(ctx context.Context, req resource.
}
if device.Managed {
- res, err := device.Client.GetData(state.Id.ValueString())
- if res.StatusCode == 404 {
- state = BGPIPv6UnicastNeighbor{Device: state.Device, Id: state.Id}
+ imp, diags := helpers.IsFlagImporting(ctx, req)
+ if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ return
+ }
+
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(state.Id.ValueString())
+ if res.StatusCode == 404 {
+ state = BGPIPv6UnicastNeighbor{Device: state.Device, Id: state.Id}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
+ return
+ }
+
+ // After `terraform import` we switch to a full read.
+ if imp {
+ state.fromBody(ctx, res.Res)
+ } else {
+ state.updateFromBody(ctx, res.Res)
+ }
+ }
} else {
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
- return
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
}
- imp, diags := helpers.IsFlagImporting(ctx, req)
- if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ filter := helpers.GetXpathFilter(state.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.getPath(), err))
return
}
// After `terraform import` we switch to a full read.
if imp {
- state.fromBody(ctx, res.Res)
+ state.fromBodyXML(ctx, res.Res)
} else {
- state.updateFromBody(ctx, res.Res)
+ state.updateFromBodyXML(ctx, res.Res)
}
}
}
@@ -314,51 +363,74 @@ func (r *BGPIPv6UnicastNeighborResource) Update(ctx context.Context, req resourc
}
if device.Managed {
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ body := plan.toBody(ctx)
- deletedItems := plan.getDeletedItems(ctx, state)
- tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
+ deletedItems := plan.getDeletedItems(ctx, state)
+ tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- var edits []restconf.YangPatchEdit
- for _, i := range deletedItems {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
- return
+ if YangPatch {
+ var edits []restconf.YangPatchEdit
+ for _, i := range deletedItems {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletedItems {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- for _, i := range deletedItems {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
}
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+
+ body := plan.toBodyXML(ctx)
+ body = plan.addDeletedItemsXML(ctx, state, body)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
return
}
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
- return
- }
- }
}
}
@@ -391,6 +463,18 @@ func (r *BGPIPv6UnicastNeighborResource) Delete(ctx context.Context, req resourc
}
if device.Managed {
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.Protocol == "netconf" && device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
+ }
deleteMode := "all"
if state.DeleteMode.ValueString() == "all" {
deleteMode = "all"
@@ -399,31 +483,52 @@ func (r *BGPIPv6UnicastNeighborResource) Delete(ctx context.Context, req resourc
}
if deleteMode == "all" {
- res, err := device.Client.DeleteData(state.Id.ValueString())
- if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
- return
- }
- } else {
- deletePaths := state.getDeletePaths(ctx)
- tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
-
- if YangPatch {
- edits := []restconf.YangPatchEdit{}
- for _, i := range deletePaths {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.DeleteData(state.Id.ValueString())
+ if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
return
}
} else {
- for _, i := range deletePaths {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // NETCONF
+ body := netconf.Body{}
+ body = helpers.RemoveFromXPath(body, state.getXPath())
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body.Res(), true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
+ }
+ }
+ } else {
+ if device.Protocol == "restconf" {
+ deletePaths := state.getDeletePaths(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
+
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{}
+ for _, i := range deletePaths {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
}
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletePaths {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ }
+ }
+ }
+ } else {
+ // NETCONF
+ body := state.addDeletePathsXML(ctx, "")
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
diff --git a/internal/provider/resource_iosxe_bgp_ipv6_unicast_neighbor_test.go b/internal/provider/resource_iosxe_bgp_ipv6_unicast_neighbor_test.go
index 5d0c0c32..7f67058d 100644
--- a/internal/provider/resource_iosxe_bgp_ipv6_unicast_neighbor_test.go
+++ b/internal/provider/resource_iosxe_bgp_ipv6_unicast_neighbor_test.go
@@ -84,39 +84,39 @@ func iosxeBGPIPv6UnicastNeighborImportStateIdFunc(resourceName string) resource.
// Section below is generated&owned by "gen/generator.go". //template:begin testPrerequisites
const testAccIosxeBGPIPv6UnicastNeighborPrerequisitesConfig = `
-resource "iosxe_restconf" "PreReq0" {
- path = "Cisco-IOS-XE-native:native/ipv6"
+resource "iosxe_yang" "PreReq0" {
+ path = "/Cisco-IOS-XE-native:native/ipv6"
attributes = {
"unicast-routing" = ""
}
}
-resource "iosxe_restconf" "PreReq1" {
- path = "Cisco-IOS-XE-native:native/router/Cisco-IOS-XE-bgp:bgp=65000"
+resource "iosxe_yang" "PreReq1" {
+ path = "/Cisco-IOS-XE-native:native/router/Cisco-IOS-XE-bgp:bgp[id=65000]"
attributes = {
"id" = "65000"
}
}
-resource "iosxe_restconf" "PreReq2" {
- path = "Cisco-IOS-XE-native:native/router/Cisco-IOS-XE-bgp:bgp=65000/address-family/no-vrf/ipv6=unicast"
+resource "iosxe_yang" "PreReq2" {
+ path = "/Cisco-IOS-XE-native:native/router/Cisco-IOS-XE-bgp:bgp[id=65000]/address-family/no-vrf/ipv6[af-name=unicast]"
attributes = {
"af-name" = "unicast"
}
- depends_on = [iosxe_restconf.PreReq0, iosxe_restconf.PreReq1, ]
+ depends_on = [iosxe_yang.PreReq0, iosxe_yang.PreReq1, ]
}
-resource "iosxe_restconf" "PreReq3" {
- path = "Cisco-IOS-XE-native:native/router/Cisco-IOS-XE-bgp:bgp=65000/neighbor=3.3.3.3"
+resource "iosxe_yang" "PreReq3" {
+ path = "/Cisco-IOS-XE-native:native/router/Cisco-IOS-XE-bgp:bgp[id=65000]/neighbor[id=3.3.3.3]"
attributes = {
"id" = "3.3.3.3"
"remote-as" = "65000"
}
- depends_on = [iosxe_restconf.PreReq0, iosxe_restconf.PreReq1, ]
+ depends_on = [iosxe_yang.PreReq0, iosxe_yang.PreReq1, ]
}
-resource "iosxe_restconf" "PreReq4" {
- path = "Cisco-IOS-XE-native:native/interface/Loopback=100"
+resource "iosxe_yang" "PreReq4" {
+ path = "/Cisco-IOS-XE-native:native/interface/Loopback[name=100]"
attributes = {
"name" = "100"
}
@@ -132,7 +132,7 @@ func testAccIosxeBGPIPv6UnicastNeighborConfig_minimum() string {
config := `resource "iosxe_bgp_ipv6_unicast_neighbor" "test" {` + "\n"
config += ` asn = "65000"` + "\n"
config += ` ip = "3.3.3.3"` + "\n"
- config += ` depends_on = [iosxe_restconf.PreReq0, iosxe_restconf.PreReq1, iosxe_restconf.PreReq2, iosxe_restconf.PreReq3, iosxe_restconf.PreReq4, ]` + "\n"
+ config += ` depends_on = [iosxe_yang.PreReq0, iosxe_yang.PreReq1, iosxe_yang.PreReq2, iosxe_yang.PreReq3, iosxe_yang.PreReq4, ]` + "\n"
config += `}` + "\n"
return config
}
@@ -155,7 +155,7 @@ func testAccIosxeBGPIPv6UnicastNeighborConfig_all() string {
config += ` in_out = "in"` + "\n"
config += ` route_map_name = "RM1"` + "\n"
config += ` }]` + "\n"
- config += ` depends_on = [iosxe_restconf.PreReq0, iosxe_restconf.PreReq1, iosxe_restconf.PreReq2, iosxe_restconf.PreReq3, iosxe_restconf.PreReq4, ]` + "\n"
+ config += ` depends_on = [iosxe_yang.PreReq0, iosxe_yang.PreReq1, iosxe_yang.PreReq2, iosxe_yang.PreReq3, iosxe_yang.PreReq4, ]` + "\n"
config += `}` + "\n"
return config
}
diff --git a/internal/provider/resource_iosxe_bgp_l2vpn_evpn_neighbor.go b/internal/provider/resource_iosxe_bgp_l2vpn_evpn_neighbor.go
index 061652b4..3ea9aab4 100644
--- a/internal/provider/resource_iosxe_bgp_l2vpn_evpn_neighbor.go
+++ b/internal/provider/resource_iosxe_bgp_l2vpn_evpn_neighbor.go
@@ -36,6 +36,7 @@ import (
"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-netconf"
"github.com/netascode/go-restconf"
)
@@ -158,37 +159,59 @@ func (r *BGPL2VPNEVPNNeighborResource) Create(ctx context.Context, req resource.
}
if device.Managed {
- // Create object
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ // Create object
+ body := plan.toBody(ctx)
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
- return
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
+ return
+ }
+ } else {
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
- return
- }
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
+ }
+
+ body := plan.toBodyXML(ctx)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
@@ -226,25 +249,51 @@ func (r *BGPL2VPNEVPNNeighborResource) Read(ctx context.Context, req resource.Re
}
if device.Managed {
- res, err := device.Client.GetData(state.Id.ValueString())
- if res.StatusCode == 404 {
- state = BGPL2VPNEVPNNeighbor{Device: state.Device, Id: state.Id}
+ imp, diags := helpers.IsFlagImporting(ctx, req)
+ if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ return
+ }
+
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(state.Id.ValueString())
+ if res.StatusCode == 404 {
+ state = BGPL2VPNEVPNNeighbor{Device: state.Device, Id: state.Id}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
+ return
+ }
+
+ // After `terraform import` we switch to a full read.
+ if imp {
+ state.fromBody(ctx, res.Res)
+ } else {
+ state.updateFromBody(ctx, res.Res)
+ }
+ }
} else {
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
- return
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
}
- imp, diags := helpers.IsFlagImporting(ctx, req)
- if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ filter := helpers.GetXpathFilter(state.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.getPath(), err))
return
}
// After `terraform import` we switch to a full read.
if imp {
- state.fromBody(ctx, res.Res)
+ state.fromBodyXML(ctx, res.Res)
} else {
- state.updateFromBody(ctx, res.Res)
+ state.updateFromBodyXML(ctx, res.Res)
}
}
}
@@ -287,51 +336,74 @@ func (r *BGPL2VPNEVPNNeighborResource) Update(ctx context.Context, req resource.
}
if device.Managed {
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ body := plan.toBody(ctx)
- deletedItems := plan.getDeletedItems(ctx, state)
- tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
+ deletedItems := plan.getDeletedItems(ctx, state)
+ tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- var edits []restconf.YangPatchEdit
- for _, i := range deletedItems {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
- return
+ if YangPatch {
+ var edits []restconf.YangPatchEdit
+ for _, i := range deletedItems {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletedItems {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- for _, i := range deletedItems {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
}
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+
+ body := plan.toBodyXML(ctx)
+ body = plan.addDeletedItemsXML(ctx, state, body)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
return
}
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
- return
- }
- }
}
}
@@ -364,6 +436,18 @@ func (r *BGPL2VPNEVPNNeighborResource) Delete(ctx context.Context, req resource.
}
if device.Managed {
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.Protocol == "netconf" && device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
+ }
deleteMode := "all"
if state.DeleteMode.ValueString() == "all" {
deleteMode = "all"
@@ -372,31 +456,52 @@ func (r *BGPL2VPNEVPNNeighborResource) Delete(ctx context.Context, req resource.
}
if deleteMode == "all" {
- res, err := device.Client.DeleteData(state.Id.ValueString())
- if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
- return
- }
- } else {
- deletePaths := state.getDeletePaths(ctx)
- tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
-
- if YangPatch {
- edits := []restconf.YangPatchEdit{}
- for _, i := range deletePaths {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.DeleteData(state.Id.ValueString())
+ if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
return
}
} else {
- for _, i := range deletePaths {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // NETCONF
+ body := netconf.Body{}
+ body = helpers.RemoveFromXPath(body, state.getXPath())
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body.Res(), true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
+ }
+ }
+ } else {
+ if device.Protocol == "restconf" {
+ deletePaths := state.getDeletePaths(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
+
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{}
+ for _, i := range deletePaths {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
}
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletePaths {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ }
+ }
+ }
+ } else {
+ // NETCONF
+ body := state.addDeletePathsXML(ctx, "")
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
diff --git a/internal/provider/resource_iosxe_bgp_l2vpn_evpn_neighbor_test.go b/internal/provider/resource_iosxe_bgp_l2vpn_evpn_neighbor_test.go
index a53d9b0e..4a793638 100644
--- a/internal/provider/resource_iosxe_bgp_l2vpn_evpn_neighbor_test.go
+++ b/internal/provider/resource_iosxe_bgp_l2vpn_evpn_neighbor_test.go
@@ -84,28 +84,28 @@ func iosxeBGPL2VPNEVPNNeighborImportStateIdFunc(resourceName string) resource.Im
// Section below is generated&owned by "gen/generator.go". //template:begin testPrerequisites
const testAccIosxeBGPL2VPNEVPNNeighborPrerequisitesConfig = `
-resource "iosxe_restconf" "PreReq0" {
- path = "Cisco-IOS-XE-native:native/router/Cisco-IOS-XE-bgp:bgp=65000"
+resource "iosxe_yang" "PreReq0" {
+ path = "/Cisco-IOS-XE-native:native/router/Cisco-IOS-XE-bgp:bgp[id=65000]"
attributes = {
"id" = "65000"
}
}
-resource "iosxe_restconf" "PreReq1" {
- path = "Cisco-IOS-XE-native:native/router/Cisco-IOS-XE-bgp:bgp=65000/address-family/no-vrf/l2vpn=evpn"
+resource "iosxe_yang" "PreReq1" {
+ path = "/Cisco-IOS-XE-native:native/router/Cisco-IOS-XE-bgp:bgp[id=65000]/address-family/no-vrf/l2vpn[af-name=evpn]"
attributes = {
"af-name" = "evpn"
}
- depends_on = [iosxe_restconf.PreReq0, ]
+ depends_on = [iosxe_yang.PreReq0, ]
}
-resource "iosxe_restconf" "PreReq2" {
- path = "Cisco-IOS-XE-native:native/router/Cisco-IOS-XE-bgp:bgp=65000/neighbor=3.3.3.3"
+resource "iosxe_yang" "PreReq2" {
+ path = "/Cisco-IOS-XE-native:native/router/Cisco-IOS-XE-bgp:bgp[id=65000]/neighbor[id=3.3.3.3]"
attributes = {
"id" = "3.3.3.3"
"remote-as" = "65000"
}
- depends_on = [iosxe_restconf.PreReq0, ]
+ depends_on = [iosxe_yang.PreReq0, ]
}
`
@@ -118,7 +118,7 @@ func testAccIosxeBGPL2VPNEVPNNeighborConfig_minimum() string {
config := `resource "iosxe_bgp_l2vpn_evpn_neighbor" "test" {` + "\n"
config += ` asn = "65000"` + "\n"
config += ` ip = "3.3.3.3"` + "\n"
- config += ` depends_on = [iosxe_restconf.PreReq0, iosxe_restconf.PreReq1, iosxe_restconf.PreReq2, ]` + "\n"
+ config += ` depends_on = [iosxe_yang.PreReq0, iosxe_yang.PreReq1, iosxe_yang.PreReq2, ]` + "\n"
config += `}` + "\n"
return config
}
@@ -135,7 +135,7 @@ func testAccIosxeBGPL2VPNEVPNNeighborConfig_all() string {
config += ` send_community = "both"` + "\n"
config += ` route_reflector_client = false` + "\n"
config += ` soft_reconfiguration = "inbound"` + "\n"
- config += ` depends_on = [iosxe_restconf.PreReq0, iosxe_restconf.PreReq1, iosxe_restconf.PreReq2, ]` + "\n"
+ config += ` depends_on = [iosxe_yang.PreReq0, iosxe_yang.PreReq1, iosxe_yang.PreReq2, ]` + "\n"
config += `}` + "\n"
return config
}
diff --git a/internal/provider/resource_iosxe_bgp_neighbor.go b/internal/provider/resource_iosxe_bgp_neighbor.go
index 7c62f746..b654226d 100644
--- a/internal/provider/resource_iosxe_bgp_neighbor.go
+++ b/internal/provider/resource_iosxe_bgp_neighbor.go
@@ -37,6 +37,7 @@ import (
"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-netconf"
"github.com/netascode/go-restconf"
)
@@ -277,37 +278,59 @@ func (r *BGPNeighborResource) Create(ctx context.Context, req resource.CreateReq
}
if device.Managed {
- // Create object
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ // Create object
+ body := plan.toBody(ctx)
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
- return
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
+ return
+ }
+ } else {
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
- return
- }
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
+ }
+
+ body := plan.toBodyXML(ctx)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
@@ -345,25 +368,51 @@ func (r *BGPNeighborResource) Read(ctx context.Context, req resource.ReadRequest
}
if device.Managed {
- res, err := device.Client.GetData(state.Id.ValueString())
- if res.StatusCode == 404 {
- state = BGPNeighbor{Device: state.Device, Id: state.Id}
+ imp, diags := helpers.IsFlagImporting(ctx, req)
+ if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ return
+ }
+
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(state.Id.ValueString())
+ if res.StatusCode == 404 {
+ state = BGPNeighbor{Device: state.Device, Id: state.Id}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
+ return
+ }
+
+ // After `terraform import` we switch to a full read.
+ if imp {
+ state.fromBody(ctx, res.Res)
+ } else {
+ state.updateFromBody(ctx, res.Res)
+ }
+ }
} else {
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
- return
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
}
- imp, diags := helpers.IsFlagImporting(ctx, req)
- if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ filter := helpers.GetXpathFilter(state.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.getPath(), err))
return
}
// After `terraform import` we switch to a full read.
if imp {
- state.fromBody(ctx, res.Res)
+ state.fromBodyXML(ctx, res.Res)
} else {
- state.updateFromBody(ctx, res.Res)
+ state.updateFromBodyXML(ctx, res.Res)
}
}
}
@@ -406,51 +455,74 @@ func (r *BGPNeighborResource) Update(ctx context.Context, req resource.UpdateReq
}
if device.Managed {
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ body := plan.toBody(ctx)
- deletedItems := plan.getDeletedItems(ctx, state)
- tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
+ deletedItems := plan.getDeletedItems(ctx, state)
+ tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- var edits []restconf.YangPatchEdit
- for _, i := range deletedItems {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
- return
+ if YangPatch {
+ var edits []restconf.YangPatchEdit
+ for _, i := range deletedItems {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletedItems {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- for _, i := range deletedItems {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
}
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+
+ body := plan.toBodyXML(ctx)
+ body = plan.addDeletedItemsXML(ctx, state, body)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
return
}
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
- return
- }
- }
}
}
@@ -483,6 +555,18 @@ func (r *BGPNeighborResource) Delete(ctx context.Context, req resource.DeleteReq
}
if device.Managed {
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.Protocol == "netconf" && device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
+ }
deleteMode := "all"
if state.DeleteMode.ValueString() == "all" {
deleteMode = "all"
@@ -491,31 +575,52 @@ func (r *BGPNeighborResource) Delete(ctx context.Context, req resource.DeleteReq
}
if deleteMode == "all" {
- res, err := device.Client.DeleteData(state.Id.ValueString())
- if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
- return
- }
- } else {
- deletePaths := state.getDeletePaths(ctx)
- tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
-
- if YangPatch {
- edits := []restconf.YangPatchEdit{}
- for _, i := range deletePaths {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.DeleteData(state.Id.ValueString())
+ if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
return
}
} else {
- for _, i := range deletePaths {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // NETCONF
+ body := netconf.Body{}
+ body = helpers.RemoveFromXPath(body, state.getXPath())
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body.Res(), true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
+ }
+ }
+ } else {
+ if device.Protocol == "restconf" {
+ deletePaths := state.getDeletePaths(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
+
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{}
+ for _, i := range deletePaths {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
}
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletePaths {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ }
+ }
+ }
+ } else {
+ // NETCONF
+ body := state.addDeletePathsXML(ctx, "")
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
diff --git a/internal/provider/resource_iosxe_bgp_neighbor_test.go b/internal/provider/resource_iosxe_bgp_neighbor_test.go
index 2a06f6a3..fb498870 100644
--- a/internal/provider/resource_iosxe_bgp_neighbor_test.go
+++ b/internal/provider/resource_iosxe_bgp_neighbor_test.go
@@ -91,15 +91,15 @@ func iosxeBGPNeighborImportStateIdFunc(resourceName string) resource.ImportState
// Section below is generated&owned by "gen/generator.go". //template:begin testPrerequisites
const testAccIosxeBGPNeighborPrerequisitesConfig = `
-resource "iosxe_restconf" "PreReq0" {
- path = "Cisco-IOS-XE-native:native/router/Cisco-IOS-XE-bgp:bgp=65000"
+resource "iosxe_yang" "PreReq0" {
+ path = "/Cisco-IOS-XE-native:native/router/Cisco-IOS-XE-bgp:bgp[id=65000]"
attributes = {
"id" = "65000"
}
}
-resource "iosxe_restconf" "PreReq1" {
- path = "Cisco-IOS-XE-native:native/interface/Loopback=100"
+resource "iosxe_yang" "PreReq1" {
+ path = "/Cisco-IOS-XE-native:native/interface/Loopback[name=100]"
attributes = {
"name" = "100"
}
@@ -115,7 +115,7 @@ func testAccIosxeBGPNeighborConfig_minimum() string {
config := `resource "iosxe_bgp_neighbor" "test" {` + "\n"
config += ` asn = "65000"` + "\n"
config += ` ip = "3.3.3.3"` + "\n"
- config += ` depends_on = [iosxe_restconf.PreReq0, iosxe_restconf.PreReq1, ]` + "\n"
+ config += ` depends_on = [iosxe_yang.PreReq0, iosxe_yang.PreReq1, ]` + "\n"
config += `}` + "\n"
return config
}
@@ -148,7 +148,7 @@ func testAccIosxeBGPNeighborConfig_all() string {
config += ` timers_holdtime = 866` + "\n"
config += ` timers_minimum_neighbor_hold = 222` + "\n"
config += ` update_source_loopback = 100` + "\n"
- config += ` depends_on = [iosxe_restconf.PreReq0, iosxe_restconf.PreReq1, ]` + "\n"
+ config += ` depends_on = [iosxe_yang.PreReq0, iosxe_yang.PreReq1, ]` + "\n"
config += `}` + "\n"
return config
}
diff --git a/internal/provider/resource_iosxe_bgp_test.go b/internal/provider/resource_iosxe_bgp_test.go
index e7f24112..d51e9d2c 100644
--- a/internal/provider/resource_iosxe_bgp_test.go
+++ b/internal/provider/resource_iosxe_bgp_test.go
@@ -79,8 +79,8 @@ func iosxeBGPImportStateIdFunc(resourceName string) resource.ImportStateIdFunc {
// Section below is generated&owned by "gen/generator.go". //template:begin testPrerequisites
const testAccIosxeBGPPrerequisitesConfig = `
-resource "iosxe_restconf" "PreReq0" {
- path = "Cisco-IOS-XE-native:native/interface/Loopback=100"
+resource "iosxe_yang" "PreReq0" {
+ path = "/Cisco-IOS-XE-native:native/interface/Loopback[name=100]"
attributes = {
"name" = "100"
"ip/address/primary/address" = "200.200.200.200"
@@ -97,7 +97,7 @@ resource "iosxe_restconf" "PreReq0" {
func testAccIosxeBGPConfig_minimum() string {
config := `resource "iosxe_bgp" "test" {` + "\n"
config += ` asn = "65000"` + "\n"
- config += ` depends_on = [iosxe_restconf.PreReq0, ]` + "\n"
+ config += ` depends_on = [iosxe_yang.PreReq0, ]` + "\n"
config += `}` + "\n"
return config
}
@@ -113,7 +113,7 @@ func testAccIosxeBGPConfig_all() string {
config += ` log_neighbor_changes = true` + "\n"
config += ` router_id_loopback = 100` + "\n"
config += ` router_id_ip = "172.16.255.1"` + "\n"
- config += ` depends_on = [iosxe_restconf.PreReq0, ]` + "\n"
+ config += ` depends_on = [iosxe_yang.PreReq0, ]` + "\n"
config += `}` + "\n"
return config
}
diff --git a/internal/provider/resource_iosxe_cdp.go b/internal/provider/resource_iosxe_cdp.go
index f824c2a7..269a5257 100644
--- a/internal/provider/resource_iosxe_cdp.go
+++ b/internal/provider/resource_iosxe_cdp.go
@@ -36,6 +36,7 @@ import (
"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-netconf"
"github.com/netascode/go-restconf"
)
@@ -173,37 +174,59 @@ func (r *CDPResource) Create(ctx context.Context, req resource.CreateRequest, re
}
if device.Managed {
- // Create object
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ // Create object
+ body := plan.toBody(ctx)
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
- return
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
+ return
+ }
+ } else {
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
- return
- }
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
+ }
+
+ body := plan.toBodyXML(ctx)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
@@ -241,25 +264,51 @@ func (r *CDPResource) Read(ctx context.Context, req resource.ReadRequest, resp *
}
if device.Managed {
- res, err := device.Client.GetData(state.Id.ValueString())
- if res.StatusCode == 404 {
- state = CDP{Device: state.Device, Id: state.Id}
+ imp, diags := helpers.IsFlagImporting(ctx, req)
+ if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ return
+ }
+
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(state.Id.ValueString())
+ if res.StatusCode == 404 {
+ state = CDP{Device: state.Device, Id: state.Id}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
+ return
+ }
+
+ // After `terraform import` we switch to a full read.
+ if imp {
+ state.fromBody(ctx, res.Res)
+ } else {
+ state.updateFromBody(ctx, res.Res)
+ }
+ }
} else {
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
- return
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
}
- imp, diags := helpers.IsFlagImporting(ctx, req)
- if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ filter := helpers.GetXpathFilter(state.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.getPath(), err))
return
}
// After `terraform import` we switch to a full read.
if imp {
- state.fromBody(ctx, res.Res)
+ state.fromBodyXML(ctx, res.Res)
} else {
- state.updateFromBody(ctx, res.Res)
+ state.updateFromBodyXML(ctx, res.Res)
}
}
}
@@ -302,51 +351,74 @@ func (r *CDPResource) Update(ctx context.Context, req resource.UpdateRequest, re
}
if device.Managed {
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ body := plan.toBody(ctx)
- deletedItems := plan.getDeletedItems(ctx, state)
- tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
+ deletedItems := plan.getDeletedItems(ctx, state)
+ tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- var edits []restconf.YangPatchEdit
- for _, i := range deletedItems {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
- return
+ if YangPatch {
+ var edits []restconf.YangPatchEdit
+ for _, i := range deletedItems {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletedItems {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- for _, i := range deletedItems {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
}
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+
+ body := plan.toBodyXML(ctx)
+ body = plan.addDeletedItemsXML(ctx, state, body)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
return
}
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
- return
- }
- }
}
}
@@ -379,34 +451,67 @@ func (r *CDPResource) Delete(ctx context.Context, req resource.DeleteRequest, re
}
if device.Managed {
- deleteMode := "all"
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
- if deleteMode == "all" {
- res, err := device.Client.DeleteData(state.Id.ValueString())
- if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
+ if device.Protocol == "netconf" && device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
- } else {
- deletePaths := state.getDeletePaths(ctx)
- tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
+ defer cleanup()
+ }
+ deleteMode := "all"
- if YangPatch {
- edits := []restconf.YangPatchEdit{}
- for _, i := range deletePaths {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ if deleteMode == "all" {
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.DeleteData(state.Id.ValueString())
+ if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
return
}
} else {
- for _, i := range deletePaths {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // NETCONF
+ body := netconf.Body{}
+ body = helpers.RemoveFromXPath(body, state.getXPath())
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body.Res(), true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
+ }
+ }
+ } else {
+ if device.Protocol == "restconf" {
+ deletePaths := state.getDeletePaths(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
+
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{}
+ for _, i := range deletePaths {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
}
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletePaths {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ }
+ }
+ }
+ } else {
+ // NETCONF
+ body := state.addDeletePathsXML(ctx, "")
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
diff --git a/internal/provider/resource_iosxe_class_map.go b/internal/provider/resource_iosxe_class_map.go
index 27e2cbe4..bc87821b 100644
--- a/internal/provider/resource_iosxe_class_map.go
+++ b/internal/provider/resource_iosxe_class_map.go
@@ -35,6 +35,7 @@ import (
"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-netconf"
"github.com/netascode/go-restconf"
)
@@ -220,37 +221,59 @@ func (r *ClassMapResource) Create(ctx context.Context, req resource.CreateReques
}
if device.Managed {
- // Create object
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ // Create object
+ body := plan.toBody(ctx)
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
- return
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
+ return
+ }
+ } else {
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
- return
- }
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
+ }
+
+ body := plan.toBodyXML(ctx)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
@@ -288,25 +311,51 @@ func (r *ClassMapResource) Read(ctx context.Context, req resource.ReadRequest, r
}
if device.Managed {
- res, err := device.Client.GetData(state.Id.ValueString())
- if res.StatusCode == 404 {
- state = ClassMap{Device: state.Device, Id: state.Id}
+ imp, diags := helpers.IsFlagImporting(ctx, req)
+ if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ return
+ }
+
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(state.Id.ValueString())
+ if res.StatusCode == 404 {
+ state = ClassMap{Device: state.Device, Id: state.Id}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
+ return
+ }
+
+ // After `terraform import` we switch to a full read.
+ if imp {
+ state.fromBody(ctx, res.Res)
+ } else {
+ state.updateFromBody(ctx, res.Res)
+ }
+ }
} else {
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
- return
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
}
- imp, diags := helpers.IsFlagImporting(ctx, req)
- if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ filter := helpers.GetXpathFilter(state.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.getPath(), err))
return
}
// After `terraform import` we switch to a full read.
if imp {
- state.fromBody(ctx, res.Res)
+ state.fromBodyXML(ctx, res.Res)
} else {
- state.updateFromBody(ctx, res.Res)
+ state.updateFromBodyXML(ctx, res.Res)
}
}
}
@@ -349,51 +398,74 @@ func (r *ClassMapResource) Update(ctx context.Context, req resource.UpdateReques
}
if device.Managed {
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ body := plan.toBody(ctx)
- deletedItems := plan.getDeletedItems(ctx, state)
- tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
+ deletedItems := plan.getDeletedItems(ctx, state)
+ tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- var edits []restconf.YangPatchEdit
- for _, i := range deletedItems {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
- return
+ if YangPatch {
+ var edits []restconf.YangPatchEdit
+ for _, i := range deletedItems {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletedItems {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- for _, i := range deletedItems {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
}
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+
+ body := plan.toBodyXML(ctx)
+ body = plan.addDeletedItemsXML(ctx, state, body)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
return
}
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
- return
- }
- }
}
}
@@ -426,34 +498,67 @@ func (r *ClassMapResource) Delete(ctx context.Context, req resource.DeleteReques
}
if device.Managed {
- deleteMode := "all"
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
- if deleteMode == "all" {
- res, err := device.Client.DeleteData(state.Id.ValueString())
- if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
+ if device.Protocol == "netconf" && device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
- } else {
- deletePaths := state.getDeletePaths(ctx)
- tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
+ defer cleanup()
+ }
+ deleteMode := "all"
- if YangPatch {
- edits := []restconf.YangPatchEdit{}
- for _, i := range deletePaths {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ if deleteMode == "all" {
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.DeleteData(state.Id.ValueString())
+ if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
return
}
} else {
- for _, i := range deletePaths {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // NETCONF
+ body := netconf.Body{}
+ body = helpers.RemoveFromXPath(body, state.getXPath())
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body.Res(), true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
+ }
+ }
+ } else {
+ if device.Protocol == "restconf" {
+ deletePaths := state.getDeletePaths(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
+
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{}
+ for _, i := range deletePaths {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
}
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletePaths {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ }
+ }
+ }
+ } else {
+ // NETCONF
+ body := state.addDeletePathsXML(ctx, "")
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
diff --git a/internal/provider/resource_iosxe_cli.go b/internal/provider/resource_iosxe_cli.go
index b4bdea02..845a4c72 100644
--- a/internal/provider/resource_iosxe_cli.go
+++ b/internal/provider/resource_iosxe_cli.go
@@ -22,12 +22,14 @@ import (
"fmt"
"strings"
+ "github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"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/booldefault"
"github.com/hashicorp/terraform-plugin-framework/types"
"github.com/hashicorp/terraform-plugin-log/tflog"
+ "github.com/netascode/go-netconf"
"github.com/netascode/go-restconf"
"github.com/tidwall/sjson"
)
@@ -109,22 +111,46 @@ func (r *CliResource) Create(ctx context.Context, req resource.CreateRequest, re
}
if d.Managed {
- body := ""
- if raw.ValueBool() {
- body, _ = sjson.Set(body, "Cisco-IOS-XE-cli-rpc:input.config-clis", cli.ValueString())
+ if d.Protocol == "restconf" {
+ body := ""
+ if raw.ValueBool() {
+ body, _ = sjson.Set(body, "Cisco-IOS-XE-cli-rpc:input.config-clis", cli.ValueString())
+ } else {
+ body, _ = sjson.Set(body, "Cisco-IOS-XE-cli-rpc:input.clis", cli.ValueString())
+ }
+ var request restconf.Req
+ if raw.ValueBool() {
+ request = d.RestconfClient.NewReq("POST", "/operations/Cisco-IOS-XE-cli-rpc:config-ios-cli-rpc", strings.NewReader(body))
+ } else {
+ request = d.RestconfClient.NewReq("POST", "/operations/Cisco-IOS-XE-cli-rpc:config-ios-cli-trans", strings.NewReader(body))
+ }
+ _, err := d.RestconfClient.Do(request)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to send CLI commands, got error: %s", err))
+ return
+ }
} else {
- body, _ = sjson.Set(body, "Cisco-IOS-XE-cli-rpc:input.clis", cli.ValueString())
- }
- var request restconf.Req
- if raw.ValueBool() {
- request = d.Client.NewReq("POST", "/operations/Cisco-IOS-XE-cli-rpc:config-ios-cli-rpc", strings.NewReader(body))
- } else {
- request = d.Client.NewReq("POST", "/operations/Cisco-IOS-XE-cli-rpc:config-ios-cli-trans", strings.NewReader(body))
- }
- _, err := d.Client.Do(request)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to send CLI commands, got error: %s", err))
- return
+ // Manage NETCONF connection lifecycle
+ if d.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, d.NetconfClient, &d.NetconfConnMutex, d.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
+ }
+
+ body := netconf.Body{}
+ if raw.ValueBool() {
+ body = helpers.SetFromXPath(body, "/Cisco-IOS-XE-cli-rpc:config-ios-cli-rpc/config-clis", cli.ValueString())
+ } else {
+ body = helpers.SetFromXPath(body, "/Cisco-IOS-XE-cli-rpc:config-ios-cli-trans/clis", cli.ValueString())
+ }
+
+ if _, err := d.NetconfClient.RPC(ctx, body.Res()); err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to send CLI commands, got error: %s", err))
+ return
+ }
}
}
@@ -171,22 +197,46 @@ func (r *CliResource) Update(ctx context.Context, req resource.UpdateRequest, re
}
if d.Managed {
- body := ""
- if raw.ValueBool() {
- body, _ = sjson.Set(body, "Cisco-IOS-XE-cli-rpc:input.config-clis", cli.ValueString())
+ if d.Protocol == "restconf" {
+ body := ""
+ if raw.ValueBool() {
+ body, _ = sjson.Set(body, "Cisco-IOS-XE-cli-rpc:input.config-clis", cli.ValueString())
+ } else {
+ body, _ = sjson.Set(body, "Cisco-IOS-XE-cli-rpc:input.clis", cli.ValueString())
+ }
+ var request restconf.Req
+ if raw.ValueBool() {
+ request = d.RestconfClient.NewReq("POST", "/operations/Cisco-IOS-XE-cli-rpc:config-ios-cli-rpc", strings.NewReader(body))
+ } else {
+ request = d.RestconfClient.NewReq("POST", "/operations/Cisco-IOS-XE-cli-rpc:config-ios-cli-trans", strings.NewReader(body))
+ }
+ _, err := d.RestconfClient.Do(request)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to send CLI commands, got error: %s", err))
+ return
+ }
} else {
- body, _ = sjson.Set(body, "Cisco-IOS-XE-cli-rpc:input.clis", cli.ValueString())
- }
- var request restconf.Req
- if raw.ValueBool() {
- request = d.Client.NewReq("POST", "/operations/Cisco-IOS-XE-cli-rpc:config-ios-cli-rpc", strings.NewReader(body))
- } else {
- request = d.Client.NewReq("POST", "/operations/Cisco-IOS-XE-cli-rpc:config-ios-cli-trans", strings.NewReader(body))
- }
- _, err := d.Client.Do(request)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to send CLI commands, got error: %s", err))
- return
+ // Manage NETCONF connection lifecycle
+ if d.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, d.NetconfClient, &d.NetconfConnMutex, d.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
+ }
+
+ body := netconf.Body{}
+ if raw.ValueBool() {
+ body = helpers.SetFromXPath(body, "/Cisco-IOS-XE-cli-rpc:config-ios-cli-rpc/config-clis", cli.ValueString())
+ } else {
+ body = helpers.SetFromXPath(body, "/Cisco-IOS-XE-cli-rpc:config-ios-cli-trans/clis", cli.ValueString())
+ }
+
+ if _, err := d.NetconfClient.RPC(ctx, body.Res()); err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to send CLI commands, got error: %s", err))
+ return
+ }
}
}
diff --git a/internal/provider/resource_iosxe_clock.go b/internal/provider/resource_iosxe_clock.go
index f32981f1..b190923d 100644
--- a/internal/provider/resource_iosxe_clock.go
+++ b/internal/provider/resource_iosxe_clock.go
@@ -37,6 +37,7 @@ import (
"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-netconf"
"github.com/netascode/go-restconf"
)
@@ -275,37 +276,59 @@ func (r *ClockResource) Create(ctx context.Context, req resource.CreateRequest,
}
if device.Managed {
- // Create object
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ // Create object
+ body := plan.toBody(ctx)
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
- return
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
+ return
+ }
+ } else {
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
- return
- }
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
+ }
+
+ body := plan.toBodyXML(ctx)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
@@ -343,25 +366,51 @@ func (r *ClockResource) Read(ctx context.Context, req resource.ReadRequest, resp
}
if device.Managed {
- res, err := device.Client.GetData(state.Id.ValueString())
- if res.StatusCode == 404 {
- state = Clock{Device: state.Device, Id: state.Id}
+ imp, diags := helpers.IsFlagImporting(ctx, req)
+ if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ return
+ }
+
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(state.Id.ValueString())
+ if res.StatusCode == 404 {
+ state = Clock{Device: state.Device, Id: state.Id}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
+ return
+ }
+
+ // After `terraform import` we switch to a full read.
+ if imp {
+ state.fromBody(ctx, res.Res)
+ } else {
+ state.updateFromBody(ctx, res.Res)
+ }
+ }
} else {
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
- return
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
}
- imp, diags := helpers.IsFlagImporting(ctx, req)
- if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ filter := helpers.GetXpathFilter(state.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.getPath(), err))
return
}
// After `terraform import` we switch to a full read.
if imp {
- state.fromBody(ctx, res.Res)
+ state.fromBodyXML(ctx, res.Res)
} else {
- state.updateFromBody(ctx, res.Res)
+ state.updateFromBodyXML(ctx, res.Res)
}
}
}
@@ -404,51 +453,74 @@ func (r *ClockResource) Update(ctx context.Context, req resource.UpdateRequest,
}
if device.Managed {
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ body := plan.toBody(ctx)
- deletedItems := plan.getDeletedItems(ctx, state)
- tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
+ deletedItems := plan.getDeletedItems(ctx, state)
+ tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- var edits []restconf.YangPatchEdit
- for _, i := range deletedItems {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
- return
+ if YangPatch {
+ var edits []restconf.YangPatchEdit
+ for _, i := range deletedItems {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletedItems {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- for _, i := range deletedItems {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
}
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+
+ body := plan.toBodyXML(ctx)
+ body = plan.addDeletedItemsXML(ctx, state, body)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
return
}
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
- return
- }
- }
}
}
@@ -481,6 +553,18 @@ func (r *ClockResource) Delete(ctx context.Context, req resource.DeleteRequest,
}
if device.Managed {
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.Protocol == "netconf" && device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
+ }
deleteMode := "all"
if state.DeleteMode.ValueString() == "all" {
deleteMode = "all"
@@ -489,31 +573,52 @@ func (r *ClockResource) Delete(ctx context.Context, req resource.DeleteRequest,
}
if deleteMode == "all" {
- res, err := device.Client.DeleteData(state.Id.ValueString())
- if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
- return
- }
- } else {
- deletePaths := state.getDeletePaths(ctx)
- tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
-
- if YangPatch {
- edits := []restconf.YangPatchEdit{}
- for _, i := range deletePaths {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.DeleteData(state.Id.ValueString())
+ if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
return
}
} else {
- for _, i := range deletePaths {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // NETCONF
+ body := netconf.Body{}
+ body = helpers.RemoveFromXPath(body, state.getXPath())
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body.Res(), true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
+ }
+ }
+ } else {
+ if device.Protocol == "restconf" {
+ deletePaths := state.getDeletePaths(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
+
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{}
+ for _, i := range deletePaths {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
}
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletePaths {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ }
+ }
+ }
+ } else {
+ // NETCONF
+ body := state.addDeletePathsXML(ctx, "")
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
diff --git a/internal/provider/resource_iosxe_community_list_expanded.go b/internal/provider/resource_iosxe_community_list_expanded.go
index 75832875..59bd9ae2 100644
--- a/internal/provider/resource_iosxe_community_list_expanded.go
+++ b/internal/provider/resource_iosxe_community_list_expanded.go
@@ -36,6 +36,7 @@ import (
"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-netconf"
"github.com/netascode/go-restconf"
)
@@ -142,37 +143,59 @@ func (r *CommunityListExpandedResource) Create(ctx context.Context, req resource
}
if device.Managed {
- // Create object
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ // Create object
+ body := plan.toBody(ctx)
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
- return
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
+ return
+ }
+ } else {
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
- return
- }
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
+ }
+
+ body := plan.toBodyXML(ctx)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
@@ -210,25 +233,51 @@ func (r *CommunityListExpandedResource) Read(ctx context.Context, req resource.R
}
if device.Managed {
- res, err := device.Client.GetData(state.Id.ValueString())
- if res.StatusCode == 404 {
- state = CommunityListExpanded{Device: state.Device, Id: state.Id}
+ imp, diags := helpers.IsFlagImporting(ctx, req)
+ if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ return
+ }
+
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(state.Id.ValueString())
+ if res.StatusCode == 404 {
+ state = CommunityListExpanded{Device: state.Device, Id: state.Id}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
+ return
+ }
+
+ // After `terraform import` we switch to a full read.
+ if imp {
+ state.fromBody(ctx, res.Res)
+ } else {
+ state.updateFromBody(ctx, res.Res)
+ }
+ }
} else {
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
- return
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
}
- imp, diags := helpers.IsFlagImporting(ctx, req)
- if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ filter := helpers.GetXpathFilter(state.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.getPath(), err))
return
}
// After `terraform import` we switch to a full read.
if imp {
- state.fromBody(ctx, res.Res)
+ state.fromBodyXML(ctx, res.Res)
} else {
- state.updateFromBody(ctx, res.Res)
+ state.updateFromBodyXML(ctx, res.Res)
}
}
}
@@ -271,51 +320,74 @@ func (r *CommunityListExpandedResource) Update(ctx context.Context, req resource
}
if device.Managed {
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ body := plan.toBody(ctx)
- deletedItems := plan.getDeletedItems(ctx, state)
- tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
+ deletedItems := plan.getDeletedItems(ctx, state)
+ tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- var edits []restconf.YangPatchEdit
- for _, i := range deletedItems {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
- return
+ if YangPatch {
+ var edits []restconf.YangPatchEdit
+ for _, i := range deletedItems {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletedItems {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- for _, i := range deletedItems {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
}
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+
+ body := plan.toBodyXML(ctx)
+ body = plan.addDeletedItemsXML(ctx, state, body)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
return
}
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
- return
- }
- }
}
}
@@ -348,34 +420,67 @@ func (r *CommunityListExpandedResource) Delete(ctx context.Context, req resource
}
if device.Managed {
- deleteMode := "all"
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
- if deleteMode == "all" {
- res, err := device.Client.DeleteData(state.Id.ValueString())
- if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
+ if device.Protocol == "netconf" && device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
- } else {
- deletePaths := state.getDeletePaths(ctx)
- tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
+ defer cleanup()
+ }
+ deleteMode := "all"
- if YangPatch {
- edits := []restconf.YangPatchEdit{}
- for _, i := range deletePaths {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ if deleteMode == "all" {
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.DeleteData(state.Id.ValueString())
+ if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
return
}
} else {
- for _, i := range deletePaths {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // NETCONF
+ body := netconf.Body{}
+ body = helpers.RemoveFromXPath(body, state.getXPath())
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body.Res(), true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
+ }
+ }
+ } else {
+ if device.Protocol == "restconf" {
+ deletePaths := state.getDeletePaths(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
+
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{}
+ for _, i := range deletePaths {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
}
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletePaths {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ }
+ }
+ }
+ } else {
+ // NETCONF
+ body := state.addDeletePathsXML(ctx, "")
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
diff --git a/internal/provider/resource_iosxe_community_list_standard.go b/internal/provider/resource_iosxe_community_list_standard.go
index 00a843a7..ef8b40ad 100644
--- a/internal/provider/resource_iosxe_community_list_standard.go
+++ b/internal/provider/resource_iosxe_community_list_standard.go
@@ -33,6 +33,7 @@ import (
"github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier"
"github.com/hashicorp/terraform-plugin-framework/types"
"github.com/hashicorp/terraform-plugin-log/tflog"
+ "github.com/netascode/go-netconf"
"github.com/netascode/go-restconf"
)
@@ -127,37 +128,59 @@ func (r *CommunityListStandardResource) Create(ctx context.Context, req resource
}
if device.Managed {
- // Create object
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ // Create object
+ body := plan.toBody(ctx)
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
- return
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
+ return
+ }
+ } else {
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
- return
- }
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
+ }
+
+ body := plan.toBodyXML(ctx)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
@@ -195,25 +218,51 @@ func (r *CommunityListStandardResource) Read(ctx context.Context, req resource.R
}
if device.Managed {
- res, err := device.Client.GetData(state.Id.ValueString())
- if res.StatusCode == 404 {
- state = CommunityListStandard{Device: state.Device, Id: state.Id}
+ imp, diags := helpers.IsFlagImporting(ctx, req)
+ if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ return
+ }
+
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(state.Id.ValueString())
+ if res.StatusCode == 404 {
+ state = CommunityListStandard{Device: state.Device, Id: state.Id}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
+ return
+ }
+
+ // After `terraform import` we switch to a full read.
+ if imp {
+ state.fromBody(ctx, res.Res)
+ } else {
+ state.updateFromBody(ctx, res.Res)
+ }
+ }
} else {
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
- return
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
}
- imp, diags := helpers.IsFlagImporting(ctx, req)
- if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ filter := helpers.GetXpathFilter(state.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.getPath(), err))
return
}
// After `terraform import` we switch to a full read.
if imp {
- state.fromBody(ctx, res.Res)
+ state.fromBodyXML(ctx, res.Res)
} else {
- state.updateFromBody(ctx, res.Res)
+ state.updateFromBodyXML(ctx, res.Res)
}
}
}
@@ -256,51 +305,74 @@ func (r *CommunityListStandardResource) Update(ctx context.Context, req resource
}
if device.Managed {
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ body := plan.toBody(ctx)
- deletedItems := plan.getDeletedItems(ctx, state)
- tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
+ deletedItems := plan.getDeletedItems(ctx, state)
+ tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- var edits []restconf.YangPatchEdit
- for _, i := range deletedItems {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
- return
+ if YangPatch {
+ var edits []restconf.YangPatchEdit
+ for _, i := range deletedItems {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletedItems {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- for _, i := range deletedItems {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
}
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+
+ body := plan.toBodyXML(ctx)
+ body = plan.addDeletedItemsXML(ctx, state, body)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
return
}
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
- return
- }
- }
}
}
@@ -333,34 +405,67 @@ func (r *CommunityListStandardResource) Delete(ctx context.Context, req resource
}
if device.Managed {
- deleteMode := "all"
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
- if deleteMode == "all" {
- res, err := device.Client.DeleteData(state.Id.ValueString())
- if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
+ if device.Protocol == "netconf" && device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
- } else {
- deletePaths := state.getDeletePaths(ctx)
- tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
+ defer cleanup()
+ }
+ deleteMode := "all"
- if YangPatch {
- edits := []restconf.YangPatchEdit{}
- for _, i := range deletePaths {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ if deleteMode == "all" {
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.DeleteData(state.Id.ValueString())
+ if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
return
}
} else {
- for _, i := range deletePaths {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // NETCONF
+ body := netconf.Body{}
+ body = helpers.RemoveFromXPath(body, state.getXPath())
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body.Res(), true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
+ }
+ }
+ } else {
+ if device.Protocol == "restconf" {
+ deletePaths := state.getDeletePaths(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
+
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{}
+ for _, i := range deletePaths {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
}
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletePaths {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ }
+ }
+ }
+ } else {
+ // NETCONF
+ body := state.addDeletePathsXML(ctx, "")
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
diff --git a/internal/provider/resource_iosxe_crypto_ikev2.go b/internal/provider/resource_iosxe_crypto_ikev2.go
index 570c328c..9664cc86 100644
--- a/internal/provider/resource_iosxe_crypto_ikev2.go
+++ b/internal/provider/resource_iosxe_crypto_ikev2.go
@@ -36,6 +36,7 @@ import (
"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-netconf"
"github.com/netascode/go-restconf"
)
@@ -152,37 +153,59 @@ func (r *CryptoIKEv2Resource) Create(ctx context.Context, req resource.CreateReq
}
if device.Managed {
- // Create object
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ // Create object
+ body := plan.toBody(ctx)
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
- return
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
+ return
+ }
+ } else {
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
- return
- }
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
+ }
+
+ body := plan.toBodyXML(ctx)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
@@ -220,25 +243,51 @@ func (r *CryptoIKEv2Resource) Read(ctx context.Context, req resource.ReadRequest
}
if device.Managed {
- res, err := device.Client.GetData(state.Id.ValueString())
- if res.StatusCode == 404 {
- state = CryptoIKEv2{Device: state.Device, Id: state.Id}
+ imp, diags := helpers.IsFlagImporting(ctx, req)
+ if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ return
+ }
+
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(state.Id.ValueString())
+ if res.StatusCode == 404 {
+ state = CryptoIKEv2{Device: state.Device, Id: state.Id}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
+ return
+ }
+
+ // After `terraform import` we switch to a full read.
+ if imp {
+ state.fromBody(ctx, res.Res)
+ } else {
+ state.updateFromBody(ctx, res.Res)
+ }
+ }
} else {
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
- return
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
}
- imp, diags := helpers.IsFlagImporting(ctx, req)
- if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ filter := helpers.GetXpathFilter(state.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.getPath(), err))
return
}
// After `terraform import` we switch to a full read.
if imp {
- state.fromBody(ctx, res.Res)
+ state.fromBodyXML(ctx, res.Res)
} else {
- state.updateFromBody(ctx, res.Res)
+ state.updateFromBodyXML(ctx, res.Res)
}
}
}
@@ -281,51 +330,74 @@ func (r *CryptoIKEv2Resource) Update(ctx context.Context, req resource.UpdateReq
}
if device.Managed {
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ body := plan.toBody(ctx)
- deletedItems := plan.getDeletedItems(ctx, state)
- tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
+ deletedItems := plan.getDeletedItems(ctx, state)
+ tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- var edits []restconf.YangPatchEdit
- for _, i := range deletedItems {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
- return
+ if YangPatch {
+ var edits []restconf.YangPatchEdit
+ for _, i := range deletedItems {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletedItems {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- for _, i := range deletedItems {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
}
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+
+ body := plan.toBodyXML(ctx)
+ body = plan.addDeletedItemsXML(ctx, state, body)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
return
}
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
- return
- }
- }
}
}
@@ -358,6 +430,18 @@ func (r *CryptoIKEv2Resource) Delete(ctx context.Context, req resource.DeleteReq
}
if device.Managed {
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.Protocol == "netconf" && device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
+ }
deleteMode := "all"
if state.DeleteMode.ValueString() == "all" {
deleteMode = "all"
@@ -366,31 +450,52 @@ func (r *CryptoIKEv2Resource) Delete(ctx context.Context, req resource.DeleteReq
}
if deleteMode == "all" {
- res, err := device.Client.DeleteData(state.Id.ValueString())
- if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
- return
- }
- } else {
- deletePaths := state.getDeletePaths(ctx)
- tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
-
- if YangPatch {
- edits := []restconf.YangPatchEdit{}
- for _, i := range deletePaths {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.DeleteData(state.Id.ValueString())
+ if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
return
}
} else {
- for _, i := range deletePaths {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // NETCONF
+ body := netconf.Body{}
+ body = helpers.RemoveFromXPath(body, state.getXPath())
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body.Res(), true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
+ }
+ }
+ } else {
+ if device.Protocol == "restconf" {
+ deletePaths := state.getDeletePaths(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
+
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{}
+ for _, i := range deletePaths {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
}
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletePaths {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ }
+ }
+ }
+ } else {
+ // NETCONF
+ body := state.addDeletePathsXML(ctx, "")
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
diff --git a/internal/provider/resource_iosxe_crypto_ikev2_keyring.go b/internal/provider/resource_iosxe_crypto_ikev2_keyring.go
index 75654341..863ebbaa 100644
--- a/internal/provider/resource_iosxe_crypto_ikev2_keyring.go
+++ b/internal/provider/resource_iosxe_crypto_ikev2_keyring.go
@@ -36,6 +36,7 @@ import (
"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-netconf"
"github.com/netascode/go-restconf"
)
@@ -231,37 +232,59 @@ func (r *CryptoIKEv2KeyringResource) Create(ctx context.Context, req resource.Cr
}
if device.Managed {
- // Create object
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ // Create object
+ body := plan.toBody(ctx)
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
- return
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
+ return
+ }
+ } else {
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
- return
- }
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
+ }
+
+ body := plan.toBodyXML(ctx)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
@@ -299,25 +322,51 @@ func (r *CryptoIKEv2KeyringResource) Read(ctx context.Context, req resource.Read
}
if device.Managed {
- res, err := device.Client.GetData(state.Id.ValueString())
- if res.StatusCode == 404 {
- state = CryptoIKEv2Keyring{Device: state.Device, Id: state.Id}
+ imp, diags := helpers.IsFlagImporting(ctx, req)
+ if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ return
+ }
+
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(state.Id.ValueString())
+ if res.StatusCode == 404 {
+ state = CryptoIKEv2Keyring{Device: state.Device, Id: state.Id}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
+ return
+ }
+
+ // After `terraform import` we switch to a full read.
+ if imp {
+ state.fromBody(ctx, res.Res)
+ } else {
+ state.updateFromBody(ctx, res.Res)
+ }
+ }
} else {
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
- return
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
}
- imp, diags := helpers.IsFlagImporting(ctx, req)
- if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ filter := helpers.GetXpathFilter(state.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.getPath(), err))
return
}
// After `terraform import` we switch to a full read.
if imp {
- state.fromBody(ctx, res.Res)
+ state.fromBodyXML(ctx, res.Res)
} else {
- state.updateFromBody(ctx, res.Res)
+ state.updateFromBodyXML(ctx, res.Res)
}
}
}
@@ -360,51 +409,74 @@ func (r *CryptoIKEv2KeyringResource) Update(ctx context.Context, req resource.Up
}
if device.Managed {
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ body := plan.toBody(ctx)
- deletedItems := plan.getDeletedItems(ctx, state)
- tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
+ deletedItems := plan.getDeletedItems(ctx, state)
+ tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- var edits []restconf.YangPatchEdit
- for _, i := range deletedItems {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
- return
+ if YangPatch {
+ var edits []restconf.YangPatchEdit
+ for _, i := range deletedItems {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletedItems {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- for _, i := range deletedItems {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
}
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+
+ body := plan.toBodyXML(ctx)
+ body = plan.addDeletedItemsXML(ctx, state, body)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
return
}
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
- return
- }
- }
}
}
@@ -437,34 +509,67 @@ func (r *CryptoIKEv2KeyringResource) Delete(ctx context.Context, req resource.De
}
if device.Managed {
- deleteMode := "all"
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
- if deleteMode == "all" {
- res, err := device.Client.DeleteData(state.Id.ValueString())
- if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
+ if device.Protocol == "netconf" && device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
- } else {
- deletePaths := state.getDeletePaths(ctx)
- tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
+ defer cleanup()
+ }
+ deleteMode := "all"
- if YangPatch {
- edits := []restconf.YangPatchEdit{}
- for _, i := range deletePaths {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ if deleteMode == "all" {
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.DeleteData(state.Id.ValueString())
+ if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
return
}
} else {
- for _, i := range deletePaths {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // NETCONF
+ body := netconf.Body{}
+ body = helpers.RemoveFromXPath(body, state.getXPath())
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body.Res(), true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
+ }
+ }
+ } else {
+ if device.Protocol == "restconf" {
+ deletePaths := state.getDeletePaths(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
+
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{}
+ for _, i := range deletePaths {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
}
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletePaths {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ }
+ }
+ }
+ } else {
+ // NETCONF
+ body := state.addDeletePathsXML(ctx, "")
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
diff --git a/internal/provider/resource_iosxe_crypto_ikev2_policy.go b/internal/provider/resource_iosxe_crypto_ikev2_policy.go
index d1d7ef6b..baa4d12c 100644
--- a/internal/provider/resource_iosxe_crypto_ikev2_policy.go
+++ b/internal/provider/resource_iosxe_crypto_ikev2_policy.go
@@ -33,6 +33,7 @@ import (
"github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier"
"github.com/hashicorp/terraform-plugin-framework/types"
"github.com/hashicorp/terraform-plugin-log/tflog"
+ "github.com/netascode/go-netconf"
"github.com/netascode/go-restconf"
)
@@ -146,37 +147,59 @@ func (r *CryptoIKEv2PolicyResource) Create(ctx context.Context, req resource.Cre
}
if device.Managed {
- // Create object
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ // Create object
+ body := plan.toBody(ctx)
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
- return
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
+ return
+ }
+ } else {
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
- return
- }
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
+ }
+
+ body := plan.toBodyXML(ctx)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
@@ -214,25 +237,51 @@ func (r *CryptoIKEv2PolicyResource) Read(ctx context.Context, req resource.ReadR
}
if device.Managed {
- res, err := device.Client.GetData(state.Id.ValueString())
- if res.StatusCode == 404 {
- state = CryptoIKEv2Policy{Device: state.Device, Id: state.Id}
+ imp, diags := helpers.IsFlagImporting(ctx, req)
+ if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ return
+ }
+
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(state.Id.ValueString())
+ if res.StatusCode == 404 {
+ state = CryptoIKEv2Policy{Device: state.Device, Id: state.Id}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
+ return
+ }
+
+ // After `terraform import` we switch to a full read.
+ if imp {
+ state.fromBody(ctx, res.Res)
+ } else {
+ state.updateFromBody(ctx, res.Res)
+ }
+ }
} else {
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
- return
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
}
- imp, diags := helpers.IsFlagImporting(ctx, req)
- if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ filter := helpers.GetXpathFilter(state.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.getPath(), err))
return
}
// After `terraform import` we switch to a full read.
if imp {
- state.fromBody(ctx, res.Res)
+ state.fromBodyXML(ctx, res.Res)
} else {
- state.updateFromBody(ctx, res.Res)
+ state.updateFromBodyXML(ctx, res.Res)
}
}
}
@@ -275,51 +324,74 @@ func (r *CryptoIKEv2PolicyResource) Update(ctx context.Context, req resource.Upd
}
if device.Managed {
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ body := plan.toBody(ctx)
- deletedItems := plan.getDeletedItems(ctx, state)
- tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
+ deletedItems := plan.getDeletedItems(ctx, state)
+ tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- var edits []restconf.YangPatchEdit
- for _, i := range deletedItems {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
- return
+ if YangPatch {
+ var edits []restconf.YangPatchEdit
+ for _, i := range deletedItems {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletedItems {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- for _, i := range deletedItems {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
}
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+
+ body := plan.toBodyXML(ctx)
+ body = plan.addDeletedItemsXML(ctx, state, body)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
return
}
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
- return
- }
- }
}
}
@@ -352,34 +424,67 @@ func (r *CryptoIKEv2PolicyResource) Delete(ctx context.Context, req resource.Del
}
if device.Managed {
- deleteMode := "all"
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
- if deleteMode == "all" {
- res, err := device.Client.DeleteData(state.Id.ValueString())
- if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
+ if device.Protocol == "netconf" && device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
- } else {
- deletePaths := state.getDeletePaths(ctx)
- tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
+ defer cleanup()
+ }
+ deleteMode := "all"
- if YangPatch {
- edits := []restconf.YangPatchEdit{}
- for _, i := range deletePaths {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ if deleteMode == "all" {
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.DeleteData(state.Id.ValueString())
+ if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
return
}
} else {
- for _, i := range deletePaths {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // NETCONF
+ body := netconf.Body{}
+ body = helpers.RemoveFromXPath(body, state.getXPath())
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body.Res(), true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
+ }
+ }
+ } else {
+ if device.Protocol == "restconf" {
+ deletePaths := state.getDeletePaths(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
+
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{}
+ for _, i := range deletePaths {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
}
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletePaths {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ }
+ }
+ }
+ } else {
+ // NETCONF
+ body := state.addDeletePathsXML(ctx, "")
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
diff --git a/internal/provider/resource_iosxe_crypto_ikev2_policy_test.go b/internal/provider/resource_iosxe_crypto_ikev2_policy_test.go
index 5195aae7..05768a45 100644
--- a/internal/provider/resource_iosxe_crypto_ikev2_policy_test.go
+++ b/internal/provider/resource_iosxe_crypto_ikev2_policy_test.go
@@ -78,8 +78,8 @@ func iosxeCryptoIKEv2PolicyImportStateIdFunc(resourceName string) resource.Impor
// Section below is generated&owned by "gen/generator.go". //template:begin testPrerequisites
const testAccIosxeCryptoIKEv2PolicyPrerequisitesConfig = `
-resource "iosxe_restconf" "PreReq0" {
- path = "Cisco-IOS-XE-native:native/crypto/Cisco-IOS-XE-crypto:ikev2/proposal=proposal123"
+resource "iosxe_yang" "PreReq0" {
+ path = "/Cisco-IOS-XE-native:native/crypto/Cisco-IOS-XE-crypto:ikev2/proposal[name=proposal123]"
attributes = {
"name" = "proposal123"
"encryption/aes-cbc-256" = ""
@@ -100,7 +100,7 @@ func testAccIosxeCryptoIKEv2PolicyConfig_minimum() string {
config += ` proposals = [{` + "\n"
config += ` proposals = "proposal123"` + "\n"
config += ` }]` + "\n"
- config += ` depends_on = [iosxe_restconf.PreReq0, ]` + "\n"
+ config += ` depends_on = [iosxe_yang.PreReq0, ]` + "\n"
config += `}` + "\n"
return config
}
@@ -117,7 +117,7 @@ func testAccIosxeCryptoIKEv2PolicyConfig_all() string {
config += ` proposals = [{` + "\n"
config += ` proposals = "proposal123"` + "\n"
config += ` }]` + "\n"
- config += ` depends_on = [iosxe_restconf.PreReq0, ]` + "\n"
+ config += ` depends_on = [iosxe_yang.PreReq0, ]` + "\n"
config += `}` + "\n"
return config
}
diff --git a/internal/provider/resource_iosxe_crypto_ikev2_profile.go b/internal/provider/resource_iosxe_crypto_ikev2_profile.go
index 88d67250..584a3cb3 100644
--- a/internal/provider/resource_iosxe_crypto_ikev2_profile.go
+++ b/internal/provider/resource_iosxe_crypto_ikev2_profile.go
@@ -37,6 +37,7 @@ import (
"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-netconf"
"github.com/netascode/go-restconf"
)
@@ -229,37 +230,59 @@ func (r *CryptoIKEv2ProfileResource) Create(ctx context.Context, req resource.Cr
}
if device.Managed {
- // Create object
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ // Create object
+ body := plan.toBody(ctx)
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
- return
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
+ return
+ }
+ } else {
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
- return
- }
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
+ }
+
+ body := plan.toBodyXML(ctx)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
@@ -297,25 +320,51 @@ func (r *CryptoIKEv2ProfileResource) Read(ctx context.Context, req resource.Read
}
if device.Managed {
- res, err := device.Client.GetData(state.Id.ValueString())
- if res.StatusCode == 404 {
- state = CryptoIKEv2Profile{Device: state.Device, Id: state.Id}
+ imp, diags := helpers.IsFlagImporting(ctx, req)
+ if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ return
+ }
+
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(state.Id.ValueString())
+ if res.StatusCode == 404 {
+ state = CryptoIKEv2Profile{Device: state.Device, Id: state.Id}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
+ return
+ }
+
+ // After `terraform import` we switch to a full read.
+ if imp {
+ state.fromBody(ctx, res.Res)
+ } else {
+ state.updateFromBody(ctx, res.Res)
+ }
+ }
} else {
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
- return
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
}
- imp, diags := helpers.IsFlagImporting(ctx, req)
- if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ filter := helpers.GetXpathFilter(state.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.getPath(), err))
return
}
// After `terraform import` we switch to a full read.
if imp {
- state.fromBody(ctx, res.Res)
+ state.fromBodyXML(ctx, res.Res)
} else {
- state.updateFromBody(ctx, res.Res)
+ state.updateFromBodyXML(ctx, res.Res)
}
}
}
@@ -358,51 +407,74 @@ func (r *CryptoIKEv2ProfileResource) Update(ctx context.Context, req resource.Up
}
if device.Managed {
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ body := plan.toBody(ctx)
- deletedItems := plan.getDeletedItems(ctx, state)
- tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
+ deletedItems := plan.getDeletedItems(ctx, state)
+ tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- var edits []restconf.YangPatchEdit
- for _, i := range deletedItems {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
- return
+ if YangPatch {
+ var edits []restconf.YangPatchEdit
+ for _, i := range deletedItems {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletedItems {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- for _, i := range deletedItems {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
}
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+
+ body := plan.toBodyXML(ctx)
+ body = plan.addDeletedItemsXML(ctx, state, body)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
return
}
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
- return
- }
- }
}
}
@@ -435,6 +507,18 @@ func (r *CryptoIKEv2ProfileResource) Delete(ctx context.Context, req resource.De
}
if device.Managed {
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.Protocol == "netconf" && device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
+ }
deleteMode := "all"
if state.DeleteMode.ValueString() == "all" {
deleteMode = "all"
@@ -443,31 +527,52 @@ func (r *CryptoIKEv2ProfileResource) Delete(ctx context.Context, req resource.De
}
if deleteMode == "all" {
- res, err := device.Client.DeleteData(state.Id.ValueString())
- if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
- return
- }
- } else {
- deletePaths := state.getDeletePaths(ctx)
- tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
-
- if YangPatch {
- edits := []restconf.YangPatchEdit{}
- for _, i := range deletePaths {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.DeleteData(state.Id.ValueString())
+ if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
return
}
} else {
- for _, i := range deletePaths {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // NETCONF
+ body := netconf.Body{}
+ body = helpers.RemoveFromXPath(body, state.getXPath())
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body.Res(), true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
+ }
+ }
+ } else {
+ if device.Protocol == "restconf" {
+ deletePaths := state.getDeletePaths(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
+
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{}
+ for _, i := range deletePaths {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
}
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletePaths {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ }
+ }
+ }
+ } else {
+ // NETCONF
+ body := state.addDeletePathsXML(ctx, "")
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
diff --git a/internal/provider/resource_iosxe_crypto_ikev2_profile_test.go b/internal/provider/resource_iosxe_crypto_ikev2_profile_test.go
index 6cec3ffd..b4a7be34 100644
--- a/internal/provider/resource_iosxe_crypto_ikev2_profile_test.go
+++ b/internal/provider/resource_iosxe_crypto_ikev2_profile_test.go
@@ -90,15 +90,15 @@ func iosxeCryptoIKEv2ProfileImportStateIdFunc(resourceName string) resource.Impo
// Section below is generated&owned by "gen/generator.go". //template:begin testPrerequisites
const testAccIosxeCryptoIKEv2ProfilePrerequisitesConfig = `
-resource "iosxe_restconf" "PreReq0" {
- path = "Cisco-IOS-XE-native:native/crypto/Cisco-IOS-XE-crypto:ikev2/keyring=test"
+resource "iosxe_yang" "PreReq0" {
+ path = "/Cisco-IOS-XE-native:native/crypto/Cisco-IOS-XE-crypto:ikev2/keyring[name=test]"
attributes = {
"name" = "test"
}
}
-resource "iosxe_restconf" "PreReq1" {
- path = "Cisco-IOS-XE-native:native/vrf/definition=VRF1"
+resource "iosxe_yang" "PreReq1" {
+ path = "/Cisco-IOS-XE-native:native/vrf/definition[name=VRF1]"
delete = false
attributes = {
"name" = "VRF1"
@@ -115,7 +115,7 @@ resource "iosxe_restconf" "PreReq1" {
func testAccIosxeCryptoIKEv2ProfileConfig_minimum() string {
config := `resource "iosxe_crypto_ikev2_profile" "test" {` + "\n"
config += ` name = "profile1"` + "\n"
- config += ` depends_on = [iosxe_restconf.PreReq0, iosxe_restconf.PreReq1, ]` + "\n"
+ config += ` depends_on = [iosxe_yang.PreReq0, iosxe_yang.PreReq1, ]` + "\n"
config += `}` + "\n"
return config
}
@@ -144,7 +144,7 @@ func testAccIosxeCryptoIKEv2ProfileConfig_all() string {
config += ` dpd_retry = 2` + "\n"
config += ` dpd_query = "periodic"` + "\n"
config += ` config_exchange_request = false` + "\n"
- config += ` depends_on = [iosxe_restconf.PreReq0, iosxe_restconf.PreReq1, ]` + "\n"
+ config += ` depends_on = [iosxe_yang.PreReq0, iosxe_yang.PreReq1, ]` + "\n"
config += `}` + "\n"
return config
}
diff --git a/internal/provider/resource_iosxe_crypto_ikev2_proposal.go b/internal/provider/resource_iosxe_crypto_ikev2_proposal.go
index bfd9592b..35f502bb 100644
--- a/internal/provider/resource_iosxe_crypto_ikev2_proposal.go
+++ b/internal/provider/resource_iosxe_crypto_ikev2_proposal.go
@@ -33,6 +33,7 @@ import (
"github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier"
"github.com/hashicorp/terraform-plugin-framework/types"
"github.com/hashicorp/terraform-plugin-log/tflog"
+ "github.com/netascode/go-netconf"
"github.com/netascode/go-restconf"
)
@@ -217,37 +218,59 @@ func (r *CryptoIKEv2ProposalResource) Create(ctx context.Context, req resource.C
}
if device.Managed {
- // Create object
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ // Create object
+ body := plan.toBody(ctx)
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
- return
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
+ return
+ }
+ } else {
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
- return
- }
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
+ }
+
+ body := plan.toBodyXML(ctx)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
@@ -285,25 +308,51 @@ func (r *CryptoIKEv2ProposalResource) Read(ctx context.Context, req resource.Rea
}
if device.Managed {
- res, err := device.Client.GetData(state.Id.ValueString())
- if res.StatusCode == 404 {
- state = CryptoIKEv2Proposal{Device: state.Device, Id: state.Id}
+ imp, diags := helpers.IsFlagImporting(ctx, req)
+ if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ return
+ }
+
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(state.Id.ValueString())
+ if res.StatusCode == 404 {
+ state = CryptoIKEv2Proposal{Device: state.Device, Id: state.Id}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
+ return
+ }
+
+ // After `terraform import` we switch to a full read.
+ if imp {
+ state.fromBody(ctx, res.Res)
+ } else {
+ state.updateFromBody(ctx, res.Res)
+ }
+ }
} else {
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
- return
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
}
- imp, diags := helpers.IsFlagImporting(ctx, req)
- if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ filter := helpers.GetXpathFilter(state.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.getPath(), err))
return
}
// After `terraform import` we switch to a full read.
if imp {
- state.fromBody(ctx, res.Res)
+ state.fromBodyXML(ctx, res.Res)
} else {
- state.updateFromBody(ctx, res.Res)
+ state.updateFromBodyXML(ctx, res.Res)
}
}
}
@@ -346,51 +395,74 @@ func (r *CryptoIKEv2ProposalResource) Update(ctx context.Context, req resource.U
}
if device.Managed {
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ body := plan.toBody(ctx)
- deletedItems := plan.getDeletedItems(ctx, state)
- tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
+ deletedItems := plan.getDeletedItems(ctx, state)
+ tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- var edits []restconf.YangPatchEdit
- for _, i := range deletedItems {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
- return
+ if YangPatch {
+ var edits []restconf.YangPatchEdit
+ for _, i := range deletedItems {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletedItems {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- for _, i := range deletedItems {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
}
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+
+ body := plan.toBodyXML(ctx)
+ body = plan.addDeletedItemsXML(ctx, state, body)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
return
}
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
- return
- }
- }
}
}
@@ -423,34 +495,67 @@ func (r *CryptoIKEv2ProposalResource) Delete(ctx context.Context, req resource.D
}
if device.Managed {
- deleteMode := "all"
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
- if deleteMode == "all" {
- res, err := device.Client.DeleteData(state.Id.ValueString())
- if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
+ if device.Protocol == "netconf" && device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
- } else {
- deletePaths := state.getDeletePaths(ctx)
- tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
+ defer cleanup()
+ }
+ deleteMode := "all"
- if YangPatch {
- edits := []restconf.YangPatchEdit{}
- for _, i := range deletePaths {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ if deleteMode == "all" {
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.DeleteData(state.Id.ValueString())
+ if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
return
}
} else {
- for _, i := range deletePaths {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // NETCONF
+ body := netconf.Body{}
+ body = helpers.RemoveFromXPath(body, state.getXPath())
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body.Res(), true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
+ }
+ }
+ } else {
+ if device.Protocol == "restconf" {
+ deletePaths := state.getDeletePaths(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
+
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{}
+ for _, i := range deletePaths {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
}
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletePaths {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ }
+ }
+ }
+ } else {
+ // NETCONF
+ body := state.addDeletePathsXML(ctx, "")
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
diff --git a/internal/provider/resource_iosxe_crypto_ipsec_profile.go b/internal/provider/resource_iosxe_crypto_ipsec_profile.go
index 6806b51a..20b276ef 100644
--- a/internal/provider/resource_iosxe_crypto_ipsec_profile.go
+++ b/internal/provider/resource_iosxe_crypto_ipsec_profile.go
@@ -33,6 +33,7 @@ import (
"github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier"
"github.com/hashicorp/terraform-plugin-framework/types"
"github.com/hashicorp/terraform-plugin-log/tflog"
+ "github.com/netascode/go-netconf"
"github.com/netascode/go-restconf"
)
@@ -130,37 +131,59 @@ func (r *CryptoIPSecProfileResource) Create(ctx context.Context, req resource.Cr
}
if device.Managed {
- // Create object
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ // Create object
+ body := plan.toBody(ctx)
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
- return
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
+ return
+ }
+ } else {
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
- return
- }
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
+ }
+
+ body := plan.toBodyXML(ctx)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
@@ -198,25 +221,51 @@ func (r *CryptoIPSecProfileResource) Read(ctx context.Context, req resource.Read
}
if device.Managed {
- res, err := device.Client.GetData(state.Id.ValueString())
- if res.StatusCode == 404 {
- state = CryptoIPSecProfile{Device: state.Device, Id: state.Id}
+ imp, diags := helpers.IsFlagImporting(ctx, req)
+ if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ return
+ }
+
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(state.Id.ValueString())
+ if res.StatusCode == 404 {
+ state = CryptoIPSecProfile{Device: state.Device, Id: state.Id}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
+ return
+ }
+
+ // After `terraform import` we switch to a full read.
+ if imp {
+ state.fromBody(ctx, res.Res)
+ } else {
+ state.updateFromBody(ctx, res.Res)
+ }
+ }
} else {
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
- return
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
}
- imp, diags := helpers.IsFlagImporting(ctx, req)
- if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ filter := helpers.GetXpathFilter(state.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.getPath(), err))
return
}
// After `terraform import` we switch to a full read.
if imp {
- state.fromBody(ctx, res.Res)
+ state.fromBodyXML(ctx, res.Res)
} else {
- state.updateFromBody(ctx, res.Res)
+ state.updateFromBodyXML(ctx, res.Res)
}
}
}
@@ -259,51 +308,74 @@ func (r *CryptoIPSecProfileResource) Update(ctx context.Context, req resource.Up
}
if device.Managed {
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ body := plan.toBody(ctx)
- deletedItems := plan.getDeletedItems(ctx, state)
- tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
+ deletedItems := plan.getDeletedItems(ctx, state)
+ tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- var edits []restconf.YangPatchEdit
- for _, i := range deletedItems {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
- return
+ if YangPatch {
+ var edits []restconf.YangPatchEdit
+ for _, i := range deletedItems {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletedItems {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- for _, i := range deletedItems {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
}
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+
+ body := plan.toBodyXML(ctx)
+ body = plan.addDeletedItemsXML(ctx, state, body)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
return
}
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
- return
- }
- }
}
}
@@ -336,34 +408,67 @@ func (r *CryptoIPSecProfileResource) Delete(ctx context.Context, req resource.De
}
if device.Managed {
- deleteMode := "all"
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
- if deleteMode == "all" {
- res, err := device.Client.DeleteData(state.Id.ValueString())
- if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
+ if device.Protocol == "netconf" && device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
- } else {
- deletePaths := state.getDeletePaths(ctx)
- tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
+ defer cleanup()
+ }
+ deleteMode := "all"
- if YangPatch {
- edits := []restconf.YangPatchEdit{}
- for _, i := range deletePaths {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ if deleteMode == "all" {
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.DeleteData(state.Id.ValueString())
+ if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
return
}
} else {
- for _, i := range deletePaths {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // NETCONF
+ body := netconf.Body{}
+ body = helpers.RemoveFromXPath(body, state.getXPath())
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body.Res(), true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
+ }
+ }
+ } else {
+ if device.Protocol == "restconf" {
+ deletePaths := state.getDeletePaths(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
+
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{}
+ for _, i := range deletePaths {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
}
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletePaths {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ }
+ }
+ }
+ } else {
+ // NETCONF
+ body := state.addDeletePathsXML(ctx, "")
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
diff --git a/internal/provider/resource_iosxe_crypto_ipsec_profile_test.go b/internal/provider/resource_iosxe_crypto_ipsec_profile_test.go
index b4d5916e..3e72d782 100644
--- a/internal/provider/resource_iosxe_crypto_ipsec_profile_test.go
+++ b/internal/provider/resource_iosxe_crypto_ipsec_profile_test.go
@@ -77,8 +77,8 @@ func iosxeCryptoIPSecProfileImportStateIdFunc(resourceName string) resource.Impo
// Section below is generated&owned by "gen/generator.go". //template:begin testPrerequisites
const testAccIosxeCryptoIPSecProfilePrerequisitesConfig = `
-resource "iosxe_restconf" "PreReq0" {
- path = "Cisco-IOS-XE-native:native/crypto/Cisco-IOS-XE-crypto:ipsec/transform-set=TS1"
+resource "iosxe_yang" "PreReq0" {
+ path = "/Cisco-IOS-XE-native:native/crypto/Cisco-IOS-XE-crypto:ipsec/transform-set[tag=TS1]"
attributes = {
"tag" = "TS1"
"esp" = "esp-aes"
@@ -86,8 +86,8 @@ resource "iosxe_restconf" "PreReq0" {
}
}
-resource "iosxe_restconf" "PreReq1" {
- path = "Cisco-IOS-XE-native:native/crypto/Cisco-IOS-XE-crypto:ikev2/profile=vpn300"
+resource "iosxe_yang" "PreReq1" {
+ path = "/Cisco-IOS-XE-native:native/crypto/Cisco-IOS-XE-crypto:ikev2/profile[name=vpn300]"
attributes = {
"name" = "vpn300"
"aaa/authentication/anyconnect-eap" = "attached"
@@ -103,7 +103,7 @@ resource "iosxe_restconf" "PreReq1" {
func testAccIosxeCryptoIPSecProfileConfig_minimum() string {
config := `resource "iosxe_crypto_ipsec_profile" "test" {` + "\n"
config += ` name = "vpn200"` + "\n"
- config += ` depends_on = [iosxe_restconf.PreReq0, iosxe_restconf.PreReq1, ]` + "\n"
+ config += ` depends_on = [iosxe_yang.PreReq0, iosxe_yang.PreReq1, ]` + "\n"
config += `}` + "\n"
return config
}
@@ -117,7 +117,7 @@ func testAccIosxeCryptoIPSecProfileConfig_all() string {
config += ` name = "vpn200"` + "\n"
config += ` set_transform_set = ["TS1"]` + "\n"
config += ` set_ikev2_profile = "vpn300"` + "\n"
- config += ` depends_on = [iosxe_restconf.PreReq0, iosxe_restconf.PreReq1, ]` + "\n"
+ config += ` depends_on = [iosxe_yang.PreReq0, iosxe_yang.PreReq1, ]` + "\n"
config += `}` + "\n"
return config
}
diff --git a/internal/provider/resource_iosxe_crypto_ipsec_transform_set.go b/internal/provider/resource_iosxe_crypto_ipsec_transform_set.go
index 58bfd96c..030d8be2 100644
--- a/internal/provider/resource_iosxe_crypto_ipsec_transform_set.go
+++ b/internal/provider/resource_iosxe_crypto_ipsec_transform_set.go
@@ -35,6 +35,7 @@ import (
"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-netconf"
"github.com/netascode/go-restconf"
)
@@ -137,37 +138,59 @@ func (r *CryptoIPSecTransformSetResource) Create(ctx context.Context, req resour
}
if device.Managed {
- // Create object
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ // Create object
+ body := plan.toBody(ctx)
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
- return
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
+ return
+ }
+ } else {
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
- return
- }
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
+ }
+
+ body := plan.toBodyXML(ctx)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
@@ -205,25 +228,51 @@ func (r *CryptoIPSecTransformSetResource) Read(ctx context.Context, req resource
}
if device.Managed {
- res, err := device.Client.GetData(state.Id.ValueString())
- if res.StatusCode == 404 {
- state = CryptoIPSecTransformSet{Device: state.Device, Id: state.Id}
+ imp, diags := helpers.IsFlagImporting(ctx, req)
+ if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ return
+ }
+
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(state.Id.ValueString())
+ if res.StatusCode == 404 {
+ state = CryptoIPSecTransformSet{Device: state.Device, Id: state.Id}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
+ return
+ }
+
+ // After `terraform import` we switch to a full read.
+ if imp {
+ state.fromBody(ctx, res.Res)
+ } else {
+ state.updateFromBody(ctx, res.Res)
+ }
+ }
} else {
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
- return
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
}
- imp, diags := helpers.IsFlagImporting(ctx, req)
- if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ filter := helpers.GetXpathFilter(state.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.getPath(), err))
return
}
// After `terraform import` we switch to a full read.
if imp {
- state.fromBody(ctx, res.Res)
+ state.fromBodyXML(ctx, res.Res)
} else {
- state.updateFromBody(ctx, res.Res)
+ state.updateFromBodyXML(ctx, res.Res)
}
}
}
@@ -266,51 +315,74 @@ func (r *CryptoIPSecTransformSetResource) Update(ctx context.Context, req resour
}
if device.Managed {
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ body := plan.toBody(ctx)
- deletedItems := plan.getDeletedItems(ctx, state)
- tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
+ deletedItems := plan.getDeletedItems(ctx, state)
+ tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- var edits []restconf.YangPatchEdit
- for _, i := range deletedItems {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
- return
+ if YangPatch {
+ var edits []restconf.YangPatchEdit
+ for _, i := range deletedItems {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletedItems {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- for _, i := range deletedItems {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
}
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+
+ body := plan.toBodyXML(ctx)
+ body = plan.addDeletedItemsXML(ctx, state, body)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
return
}
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
- return
- }
- }
}
}
@@ -343,34 +415,67 @@ func (r *CryptoIPSecTransformSetResource) Delete(ctx context.Context, req resour
}
if device.Managed {
- deleteMode := "all"
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
- if deleteMode == "all" {
- res, err := device.Client.DeleteData(state.Id.ValueString())
- if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
+ if device.Protocol == "netconf" && device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
- } else {
- deletePaths := state.getDeletePaths(ctx)
- tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
+ defer cleanup()
+ }
+ deleteMode := "all"
- if YangPatch {
- edits := []restconf.YangPatchEdit{}
- for _, i := range deletePaths {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ if deleteMode == "all" {
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.DeleteData(state.Id.ValueString())
+ if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
return
}
} else {
- for _, i := range deletePaths {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // NETCONF
+ body := netconf.Body{}
+ body = helpers.RemoveFromXPath(body, state.getXPath())
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body.Res(), true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
+ }
+ }
+ } else {
+ if device.Protocol == "restconf" {
+ deletePaths := state.getDeletePaths(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
+
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{}
+ for _, i := range deletePaths {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
}
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletePaths {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ }
+ }
+ }
+ } else {
+ // NETCONF
+ body := state.addDeletePathsXML(ctx, "")
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
diff --git a/internal/provider/resource_iosxe_crypto_pki.go b/internal/provider/resource_iosxe_crypto_pki.go
index dbb8b27d..66243ef9 100644
--- a/internal/provider/resource_iosxe_crypto_pki.go
+++ b/internal/provider/resource_iosxe_crypto_pki.go
@@ -35,6 +35,7 @@ import (
"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-netconf"
"github.com/netascode/go-restconf"
)
@@ -178,37 +179,59 @@ func (r *CryptoPKIResource) Create(ctx context.Context, req resource.CreateReque
}
if device.Managed {
- // Create object
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ // Create object
+ body := plan.toBody(ctx)
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
- return
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
+ return
+ }
+ } else {
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
- return
- }
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
+ }
+
+ body := plan.toBodyXML(ctx)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
@@ -246,25 +269,51 @@ func (r *CryptoPKIResource) Read(ctx context.Context, req resource.ReadRequest,
}
if device.Managed {
- res, err := device.Client.GetData(state.Id.ValueString())
- if res.StatusCode == 404 {
- state = CryptoPKI{Device: state.Device, Id: state.Id}
+ imp, diags := helpers.IsFlagImporting(ctx, req)
+ if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ return
+ }
+
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(state.Id.ValueString())
+ if res.StatusCode == 404 {
+ state = CryptoPKI{Device: state.Device, Id: state.Id}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
+ return
+ }
+
+ // After `terraform import` we switch to a full read.
+ if imp {
+ state.fromBody(ctx, res.Res)
+ } else {
+ state.updateFromBody(ctx, res.Res)
+ }
+ }
} else {
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
- return
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
}
- imp, diags := helpers.IsFlagImporting(ctx, req)
- if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ filter := helpers.GetXpathFilter(state.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.getPath(), err))
return
}
// After `terraform import` we switch to a full read.
if imp {
- state.fromBody(ctx, res.Res)
+ state.fromBodyXML(ctx, res.Res)
} else {
- state.updateFromBody(ctx, res.Res)
+ state.updateFromBodyXML(ctx, res.Res)
}
}
}
@@ -307,51 +356,74 @@ func (r *CryptoPKIResource) Update(ctx context.Context, req resource.UpdateReque
}
if device.Managed {
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ body := plan.toBody(ctx)
- deletedItems := plan.getDeletedItems(ctx, state)
- tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
+ deletedItems := plan.getDeletedItems(ctx, state)
+ tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- var edits []restconf.YangPatchEdit
- for _, i := range deletedItems {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
- return
+ if YangPatch {
+ var edits []restconf.YangPatchEdit
+ for _, i := range deletedItems {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletedItems {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- for _, i := range deletedItems {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
}
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+
+ body := plan.toBodyXML(ctx)
+ body = plan.addDeletedItemsXML(ctx, state, body)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
return
}
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
- return
- }
- }
}
}
@@ -384,6 +456,18 @@ func (r *CryptoPKIResource) Delete(ctx context.Context, req resource.DeleteReque
}
if device.Managed {
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.Protocol == "netconf" && device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
+ }
deleteMode := "all"
if state.DeleteMode.ValueString() == "all" {
deleteMode = "all"
@@ -392,31 +476,52 @@ func (r *CryptoPKIResource) Delete(ctx context.Context, req resource.DeleteReque
}
if deleteMode == "all" {
- res, err := device.Client.DeleteData(state.Id.ValueString())
- if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
- return
- }
- } else {
- deletePaths := state.getDeletePaths(ctx)
- tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
-
- if YangPatch {
- edits := []restconf.YangPatchEdit{}
- for _, i := range deletePaths {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.DeleteData(state.Id.ValueString())
+ if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
return
}
} else {
- for _, i := range deletePaths {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // NETCONF
+ body := netconf.Body{}
+ body = helpers.RemoveFromXPath(body, state.getXPath())
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body.Res(), true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
+ }
+ }
+ } else {
+ if device.Protocol == "restconf" {
+ deletePaths := state.getDeletePaths(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
+
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{}
+ for _, i := range deletePaths {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
}
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletePaths {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ }
+ }
+ }
+ } else {
+ // NETCONF
+ body := state.addDeletePathsXML(ctx, "")
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
diff --git a/internal/provider/resource_iosxe_cts.go b/internal/provider/resource_iosxe_cts.go
index 9e051c22..f9fde348 100644
--- a/internal/provider/resource_iosxe_cts.go
+++ b/internal/provider/resource_iosxe_cts.go
@@ -37,6 +37,7 @@ import (
"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-netconf"
"github.com/netascode/go-restconf"
)
@@ -323,37 +324,59 @@ func (r *CTSResource) Create(ctx context.Context, req resource.CreateRequest, re
}
if device.Managed {
- // Create object
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ // Create object
+ body := plan.toBody(ctx)
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
- return
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
+ return
+ }
+ } else {
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
- return
- }
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
+ }
+
+ body := plan.toBodyXML(ctx)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
@@ -391,25 +414,51 @@ func (r *CTSResource) Read(ctx context.Context, req resource.ReadRequest, resp *
}
if device.Managed {
- res, err := device.Client.GetData(state.Id.ValueString())
- if res.StatusCode == 404 {
- state = CTS{Device: state.Device, Id: state.Id}
+ imp, diags := helpers.IsFlagImporting(ctx, req)
+ if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ return
+ }
+
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(state.Id.ValueString())
+ if res.StatusCode == 404 {
+ state = CTS{Device: state.Device, Id: state.Id}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
+ return
+ }
+
+ // After `terraform import` we switch to a full read.
+ if imp {
+ state.fromBody(ctx, res.Res)
+ } else {
+ state.updateFromBody(ctx, res.Res)
+ }
+ }
} else {
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
- return
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
}
- imp, diags := helpers.IsFlagImporting(ctx, req)
- if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ filter := helpers.GetXpathFilter(state.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.getPath(), err))
return
}
// After `terraform import` we switch to a full read.
if imp {
- state.fromBody(ctx, res.Res)
+ state.fromBodyXML(ctx, res.Res)
} else {
- state.updateFromBody(ctx, res.Res)
+ state.updateFromBodyXML(ctx, res.Res)
}
}
}
@@ -452,51 +501,74 @@ func (r *CTSResource) Update(ctx context.Context, req resource.UpdateRequest, re
}
if device.Managed {
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ body := plan.toBody(ctx)
- deletedItems := plan.getDeletedItems(ctx, state)
- tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
+ deletedItems := plan.getDeletedItems(ctx, state)
+ tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- var edits []restconf.YangPatchEdit
- for _, i := range deletedItems {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
- return
+ if YangPatch {
+ var edits []restconf.YangPatchEdit
+ for _, i := range deletedItems {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletedItems {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- for _, i := range deletedItems {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
}
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+
+ body := plan.toBodyXML(ctx)
+ body = plan.addDeletedItemsXML(ctx, state, body)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
return
}
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
- return
- }
- }
}
}
@@ -529,6 +601,18 @@ func (r *CTSResource) Delete(ctx context.Context, req resource.DeleteRequest, re
}
if device.Managed {
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.Protocol == "netconf" && device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
+ }
deleteMode := "all"
if state.DeleteMode.ValueString() == "all" {
deleteMode = "all"
@@ -537,31 +621,52 @@ func (r *CTSResource) Delete(ctx context.Context, req resource.DeleteRequest, re
}
if deleteMode == "all" {
- res, err := device.Client.DeleteData(state.Id.ValueString())
- if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
- return
- }
- } else {
- deletePaths := state.getDeletePaths(ctx)
- tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
-
- if YangPatch {
- edits := []restconf.YangPatchEdit{}
- for _, i := range deletePaths {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.DeleteData(state.Id.ValueString())
+ if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
return
}
} else {
- for _, i := range deletePaths {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // NETCONF
+ body := netconf.Body{}
+ body = helpers.RemoveFromXPath(body, state.getXPath())
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body.Res(), true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
+ }
+ }
+ } else {
+ if device.Protocol == "restconf" {
+ deletePaths := state.getDeletePaths(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
+
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{}
+ for _, i := range deletePaths {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
}
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletePaths {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ }
+ }
+ }
+ } else {
+ // NETCONF
+ body := state.addDeletePathsXML(ctx, "")
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
diff --git a/internal/provider/resource_iosxe_cts_test.go b/internal/provider/resource_iosxe_cts_test.go
index 497c8929..3f131a37 100644
--- a/internal/provider/resource_iosxe_cts_test.go
+++ b/internal/provider/resource_iosxe_cts_test.go
@@ -98,8 +98,8 @@ func iosxeCTSImportStateIdFunc(resourceName string) resource.ImportStateIdFunc {
// Section below is generated&owned by "gen/generator.go". //template:begin testPrerequisites
const testAccIosxeCTSPrerequisitesConfig = `
-resource "iosxe_restconf" "PreReq0" {
- path = "Cisco-IOS-XE-native:native/vrf/definition=VRF1"
+resource "iosxe_yang" "PreReq0" {
+ path = "/Cisco-IOS-XE-native:native/vrf/definition[name=VRF1]"
delete = false
attributes = {
"name" = "VRF1"
@@ -116,7 +116,7 @@ resource "iosxe_restconf" "PreReq0" {
func testAccIosxeCTSConfig_minimum() string {
config := `resource "iosxe_cts" "test" {` + "\n"
- config += ` depends_on = [iosxe_restconf.PreReq0, ]` + "\n"
+ config += ` depends_on = [iosxe_yang.PreReq0, ]` + "\n"
config += `}` + "\n"
return config
}
@@ -157,7 +157,7 @@ func testAccIosxeCTSConfig_all() string {
config += ` sxp_listener_hold_max_time = 300` + "\n"
config += ` role_based_enforcement = true` + "\n"
config += ` role_based_enforcement_logging_interval = 300` + "\n"
- config += ` depends_on = [iosxe_restconf.PreReq0, ]` + "\n"
+ config += ` depends_on = [iosxe_yang.PreReq0, ]` + "\n"
config += `}` + "\n"
return config
}
diff --git a/internal/provider/resource_iosxe_device_sensor.go b/internal/provider/resource_iosxe_device_sensor.go
index a191f902..408e2298 100644
--- a/internal/provider/resource_iosxe_device_sensor.go
+++ b/internal/provider/resource_iosxe_device_sensor.go
@@ -35,6 +35,7 @@ import (
"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-netconf"
"github.com/netascode/go-restconf"
)
@@ -299,37 +300,59 @@ func (r *DeviceSensorResource) Create(ctx context.Context, req resource.CreateRe
}
if device.Managed {
- // Create object
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ // Create object
+ body := plan.toBody(ctx)
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
- return
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
+ return
+ }
+ } else {
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
- return
- }
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
+ }
+
+ body := plan.toBodyXML(ctx)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
@@ -367,25 +390,51 @@ func (r *DeviceSensorResource) Read(ctx context.Context, req resource.ReadReques
}
if device.Managed {
- res, err := device.Client.GetData(state.Id.ValueString())
- if res.StatusCode == 404 {
- state = DeviceSensor{Device: state.Device, Id: state.Id}
+ imp, diags := helpers.IsFlagImporting(ctx, req)
+ if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ return
+ }
+
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(state.Id.ValueString())
+ if res.StatusCode == 404 {
+ state = DeviceSensor{Device: state.Device, Id: state.Id}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
+ return
+ }
+
+ // After `terraform import` we switch to a full read.
+ if imp {
+ state.fromBody(ctx, res.Res)
+ } else {
+ state.updateFromBody(ctx, res.Res)
+ }
+ }
} else {
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
- return
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
}
- imp, diags := helpers.IsFlagImporting(ctx, req)
- if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ filter := helpers.GetXpathFilter(state.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.getPath(), err))
return
}
// After `terraform import` we switch to a full read.
if imp {
- state.fromBody(ctx, res.Res)
+ state.fromBodyXML(ctx, res.Res)
} else {
- state.updateFromBody(ctx, res.Res)
+ state.updateFromBodyXML(ctx, res.Res)
}
}
}
@@ -428,51 +477,74 @@ func (r *DeviceSensorResource) Update(ctx context.Context, req resource.UpdateRe
}
if device.Managed {
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ body := plan.toBody(ctx)
- deletedItems := plan.getDeletedItems(ctx, state)
- tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
+ deletedItems := plan.getDeletedItems(ctx, state)
+ tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- var edits []restconf.YangPatchEdit
- for _, i := range deletedItems {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
- return
+ if YangPatch {
+ var edits []restconf.YangPatchEdit
+ for _, i := range deletedItems {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletedItems {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- for _, i := range deletedItems {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
}
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+
+ body := plan.toBodyXML(ctx)
+ body = plan.addDeletedItemsXML(ctx, state, body)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
return
}
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
- return
- }
- }
}
}
@@ -505,6 +577,18 @@ func (r *DeviceSensorResource) Delete(ctx context.Context, req resource.DeleteRe
}
if device.Managed {
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.Protocol == "netconf" && device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
+ }
deleteMode := "all"
if state.DeleteMode.ValueString() == "all" {
deleteMode = "all"
@@ -513,31 +597,52 @@ func (r *DeviceSensorResource) Delete(ctx context.Context, req resource.DeleteRe
}
if deleteMode == "all" {
- res, err := device.Client.DeleteData(state.Id.ValueString())
- if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
- return
- }
- } else {
- deletePaths := state.getDeletePaths(ctx)
- tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
-
- if YangPatch {
- edits := []restconf.YangPatchEdit{}
- for _, i := range deletePaths {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.DeleteData(state.Id.ValueString())
+ if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
return
}
} else {
- for _, i := range deletePaths {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // NETCONF
+ body := netconf.Body{}
+ body = helpers.RemoveFromXPath(body, state.getXPath())
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body.Res(), true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
+ }
+ }
+ } else {
+ if device.Protocol == "restconf" {
+ deletePaths := state.getDeletePaths(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
+
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{}
+ for _, i := range deletePaths {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
}
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletePaths {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ }
+ }
+ }
+ } else {
+ // NETCONF
+ body := state.addDeletePathsXML(ctx, "")
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
diff --git a/internal/provider/resource_iosxe_dhcp.go b/internal/provider/resource_iosxe_dhcp.go
index dae88851..e3632b22 100644
--- a/internal/provider/resource_iosxe_dhcp.go
+++ b/internal/provider/resource_iosxe_dhcp.go
@@ -37,6 +37,7 @@ import (
"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-netconf"
"github.com/netascode/go-restconf"
)
@@ -197,37 +198,59 @@ func (r *DHCPResource) Create(ctx context.Context, req resource.CreateRequest, r
}
if device.Managed {
- // Create object
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ // Create object
+ body := plan.toBody(ctx)
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
- return
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
+ return
+ }
+ } else {
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
- return
- }
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
+ }
+
+ body := plan.toBodyXML(ctx)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
@@ -265,25 +288,51 @@ func (r *DHCPResource) Read(ctx context.Context, req resource.ReadRequest, resp
}
if device.Managed {
- res, err := device.Client.GetData(state.Id.ValueString())
- if res.StatusCode == 404 {
- state = DHCP{Device: state.Device, Id: state.Id}
+ imp, diags := helpers.IsFlagImporting(ctx, req)
+ if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ return
+ }
+
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(state.Id.ValueString())
+ if res.StatusCode == 404 {
+ state = DHCP{Device: state.Device, Id: state.Id}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
+ return
+ }
+
+ // After `terraform import` we switch to a full read.
+ if imp {
+ state.fromBody(ctx, res.Res)
+ } else {
+ state.updateFromBody(ctx, res.Res)
+ }
+ }
} else {
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
- return
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
}
- imp, diags := helpers.IsFlagImporting(ctx, req)
- if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ filter := helpers.GetXpathFilter(state.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.getPath(), err))
return
}
// After `terraform import` we switch to a full read.
if imp {
- state.fromBody(ctx, res.Res)
+ state.fromBodyXML(ctx, res.Res)
} else {
- state.updateFromBody(ctx, res.Res)
+ state.updateFromBodyXML(ctx, res.Res)
}
}
}
@@ -326,51 +375,74 @@ func (r *DHCPResource) Update(ctx context.Context, req resource.UpdateRequest, r
}
if device.Managed {
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ body := plan.toBody(ctx)
- deletedItems := plan.getDeletedItems(ctx, state)
- tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
+ deletedItems := plan.getDeletedItems(ctx, state)
+ tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- var edits []restconf.YangPatchEdit
- for _, i := range deletedItems {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
- return
+ if YangPatch {
+ var edits []restconf.YangPatchEdit
+ for _, i := range deletedItems {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletedItems {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- for _, i := range deletedItems {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
}
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+
+ body := plan.toBodyXML(ctx)
+ body = plan.addDeletedItemsXML(ctx, state, body)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
return
}
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
- return
- }
- }
}
}
@@ -403,6 +475,18 @@ func (r *DHCPResource) Delete(ctx context.Context, req resource.DeleteRequest, r
}
if device.Managed {
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.Protocol == "netconf" && device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
+ }
deleteMode := "all"
if state.DeleteMode.ValueString() == "all" {
deleteMode = "all"
@@ -411,31 +495,52 @@ func (r *DHCPResource) Delete(ctx context.Context, req resource.DeleteRequest, r
}
if deleteMode == "all" {
- res, err := device.Client.DeleteData(state.Id.ValueString())
- if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
- return
- }
- } else {
- deletePaths := state.getDeletePaths(ctx)
- tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
-
- if YangPatch {
- edits := []restconf.YangPatchEdit{}
- for _, i := range deletePaths {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.DeleteData(state.Id.ValueString())
+ if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
return
}
} else {
- for _, i := range deletePaths {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // NETCONF
+ body := netconf.Body{}
+ body = helpers.RemoveFromXPath(body, state.getXPath())
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body.Res(), true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
+ }
+ }
+ } else {
+ if device.Protocol == "restconf" {
+ deletePaths := state.getDeletePaths(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
+
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{}
+ for _, i := range deletePaths {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
}
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletePaths {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ }
+ }
+ }
+ } else {
+ // NETCONF
+ body := state.addDeletePathsXML(ctx, "")
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
diff --git a/internal/provider/resource_iosxe_dot1x.go b/internal/provider/resource_iosxe_dot1x.go
index a3d4a36d..592011a2 100644
--- a/internal/provider/resource_iosxe_dot1x.go
+++ b/internal/provider/resource_iosxe_dot1x.go
@@ -36,6 +36,7 @@ import (
"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-netconf"
"github.com/netascode/go-restconf"
)
@@ -210,37 +211,59 @@ func (r *Dot1xResource) Create(ctx context.Context, req resource.CreateRequest,
}
if device.Managed {
- // Create object
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ // Create object
+ body := plan.toBody(ctx)
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
- return
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
+ return
+ }
+ } else {
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
- return
- }
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
+ }
+
+ body := plan.toBodyXML(ctx)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
@@ -278,25 +301,51 @@ func (r *Dot1xResource) Read(ctx context.Context, req resource.ReadRequest, resp
}
if device.Managed {
- res, err := device.Client.GetData(state.Id.ValueString())
- if res.StatusCode == 404 {
- state = Dot1x{Device: state.Device, Id: state.Id}
+ imp, diags := helpers.IsFlagImporting(ctx, req)
+ if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ return
+ }
+
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(state.Id.ValueString())
+ if res.StatusCode == 404 {
+ state = Dot1x{Device: state.Device, Id: state.Id}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
+ return
+ }
+
+ // After `terraform import` we switch to a full read.
+ if imp {
+ state.fromBody(ctx, res.Res)
+ } else {
+ state.updateFromBody(ctx, res.Res)
+ }
+ }
} else {
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
- return
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
}
- imp, diags := helpers.IsFlagImporting(ctx, req)
- if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ filter := helpers.GetXpathFilter(state.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.getPath(), err))
return
}
// After `terraform import` we switch to a full read.
if imp {
- state.fromBody(ctx, res.Res)
+ state.fromBodyXML(ctx, res.Res)
} else {
- state.updateFromBody(ctx, res.Res)
+ state.updateFromBodyXML(ctx, res.Res)
}
}
}
@@ -339,51 +388,74 @@ func (r *Dot1xResource) Update(ctx context.Context, req resource.UpdateRequest,
}
if device.Managed {
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ body := plan.toBody(ctx)
- deletedItems := plan.getDeletedItems(ctx, state)
- tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
+ deletedItems := plan.getDeletedItems(ctx, state)
+ tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- var edits []restconf.YangPatchEdit
- for _, i := range deletedItems {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
- return
+ if YangPatch {
+ var edits []restconf.YangPatchEdit
+ for _, i := range deletedItems {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletedItems {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- for _, i := range deletedItems {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
}
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+
+ body := plan.toBodyXML(ctx)
+ body = plan.addDeletedItemsXML(ctx, state, body)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
return
}
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
- return
- }
- }
}
}
@@ -416,6 +488,18 @@ func (r *Dot1xResource) Delete(ctx context.Context, req resource.DeleteRequest,
}
if device.Managed {
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.Protocol == "netconf" && device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
+ }
deleteMode := "all"
if state.DeleteMode.ValueString() == "all" {
deleteMode = "all"
@@ -424,31 +508,52 @@ func (r *Dot1xResource) Delete(ctx context.Context, req resource.DeleteRequest,
}
if deleteMode == "all" {
- res, err := device.Client.DeleteData(state.Id.ValueString())
- if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
- return
- }
- } else {
- deletePaths := state.getDeletePaths(ctx)
- tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
-
- if YangPatch {
- edits := []restconf.YangPatchEdit{}
- for _, i := range deletePaths {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.DeleteData(state.Id.ValueString())
+ if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
return
}
} else {
- for _, i := range deletePaths {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // NETCONF
+ body := netconf.Body{}
+ body = helpers.RemoveFromXPath(body, state.getXPath())
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body.Res(), true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
+ }
+ }
+ } else {
+ if device.Protocol == "restconf" {
+ deletePaths := state.getDeletePaths(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
+
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{}
+ for _, i := range deletePaths {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
}
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletePaths {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ }
+ }
+ }
+ } else {
+ // NETCONF
+ body := state.addDeletePathsXML(ctx, "")
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
diff --git a/internal/provider/resource_iosxe_eem.go b/internal/provider/resource_iosxe_eem.go
index ff0effe4..69780b01 100644
--- a/internal/provider/resource_iosxe_eem.go
+++ b/internal/provider/resource_iosxe_eem.go
@@ -38,6 +38,7 @@ import (
"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-netconf"
"github.com/netascode/go-restconf"
)
@@ -585,37 +586,59 @@ func (r *EEMResource) Create(ctx context.Context, req resource.CreateRequest, re
}
if device.Managed {
- // Create object
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ // Create object
+ body := plan.toBody(ctx)
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
- return
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
+ return
+ }
+ } else {
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
- return
- }
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
+ }
+
+ body := plan.toBodyXML(ctx)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
@@ -653,25 +676,51 @@ func (r *EEMResource) Read(ctx context.Context, req resource.ReadRequest, resp *
}
if device.Managed {
- res, err := device.Client.GetData(state.Id.ValueString())
- if res.StatusCode == 404 {
- state = EEM{Device: state.Device, Id: state.Id}
+ imp, diags := helpers.IsFlagImporting(ctx, req)
+ if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ return
+ }
+
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(state.Id.ValueString())
+ if res.StatusCode == 404 {
+ state = EEM{Device: state.Device, Id: state.Id}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
+ return
+ }
+
+ // After `terraform import` we switch to a full read.
+ if imp {
+ state.fromBody(ctx, res.Res)
+ } else {
+ state.updateFromBody(ctx, res.Res)
+ }
+ }
} else {
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
- return
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
}
- imp, diags := helpers.IsFlagImporting(ctx, req)
- if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ filter := helpers.GetXpathFilter(state.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.getPath(), err))
return
}
// After `terraform import` we switch to a full read.
if imp {
- state.fromBody(ctx, res.Res)
+ state.fromBodyXML(ctx, res.Res)
} else {
- state.updateFromBody(ctx, res.Res)
+ state.updateFromBodyXML(ctx, res.Res)
}
}
}
@@ -714,51 +763,74 @@ func (r *EEMResource) Update(ctx context.Context, req resource.UpdateRequest, re
}
if device.Managed {
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ body := plan.toBody(ctx)
- deletedItems := plan.getDeletedItems(ctx, state)
- tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
+ deletedItems := plan.getDeletedItems(ctx, state)
+ tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- var edits []restconf.YangPatchEdit
- for _, i := range deletedItems {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
- return
+ if YangPatch {
+ var edits []restconf.YangPatchEdit
+ for _, i := range deletedItems {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletedItems {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- for _, i := range deletedItems {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
}
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+
+ body := plan.toBodyXML(ctx)
+ body = plan.addDeletedItemsXML(ctx, state, body)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
return
}
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
- return
- }
- }
}
}
@@ -791,34 +863,67 @@ func (r *EEMResource) Delete(ctx context.Context, req resource.DeleteRequest, re
}
if device.Managed {
- deleteMode := "attributes"
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
- if deleteMode == "all" {
- res, err := device.Client.DeleteData(state.Id.ValueString())
- if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
+ if device.Protocol == "netconf" && device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
- } else {
- deletePaths := state.getDeletePaths(ctx)
- tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
+ defer cleanup()
+ }
+ deleteMode := "attributes"
- if YangPatch {
- edits := []restconf.YangPatchEdit{}
- for _, i := range deletePaths {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ if deleteMode == "all" {
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.DeleteData(state.Id.ValueString())
+ if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
return
}
} else {
- for _, i := range deletePaths {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // NETCONF
+ body := netconf.Body{}
+ body = helpers.RemoveFromXPath(body, state.getXPath())
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body.Res(), true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
+ }
+ }
+ } else {
+ if device.Protocol == "restconf" {
+ deletePaths := state.getDeletePaths(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
+
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{}
+ for _, i := range deletePaths {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
}
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletePaths {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ }
+ }
+ }
+ } else {
+ // NETCONF
+ body := state.addDeletePathsXML(ctx, "")
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
diff --git a/internal/provider/resource_iosxe_errdisable.go b/internal/provider/resource_iosxe_errdisable.go
index 14cb43f6..8bbb7952 100644
--- a/internal/provider/resource_iosxe_errdisable.go
+++ b/internal/provider/resource_iosxe_errdisable.go
@@ -36,6 +36,7 @@ import (
"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-netconf"
"github.com/netascode/go-restconf"
)
@@ -353,37 +354,59 @@ func (r *ErrdisableResource) Create(ctx context.Context, req resource.CreateRequ
}
if device.Managed {
- // Create object
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ // Create object
+ body := plan.toBody(ctx)
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
- return
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
+ return
+ }
+ } else {
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
- return
- }
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
+ }
+
+ body := plan.toBodyXML(ctx)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
@@ -421,25 +444,51 @@ func (r *ErrdisableResource) Read(ctx context.Context, req resource.ReadRequest,
}
if device.Managed {
- res, err := device.Client.GetData(state.Id.ValueString())
- if res.StatusCode == 404 {
- state = Errdisable{Device: state.Device, Id: state.Id}
+ imp, diags := helpers.IsFlagImporting(ctx, req)
+ if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ return
+ }
+
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(state.Id.ValueString())
+ if res.StatusCode == 404 {
+ state = Errdisable{Device: state.Device, Id: state.Id}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
+ return
+ }
+
+ // After `terraform import` we switch to a full read.
+ if imp {
+ state.fromBody(ctx, res.Res)
+ } else {
+ state.updateFromBody(ctx, res.Res)
+ }
+ }
} else {
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
- return
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
}
- imp, diags := helpers.IsFlagImporting(ctx, req)
- if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ filter := helpers.GetXpathFilter(state.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.getPath(), err))
return
}
// After `terraform import` we switch to a full read.
if imp {
- state.fromBody(ctx, res.Res)
+ state.fromBodyXML(ctx, res.Res)
} else {
- state.updateFromBody(ctx, res.Res)
+ state.updateFromBodyXML(ctx, res.Res)
}
}
}
@@ -482,51 +531,74 @@ func (r *ErrdisableResource) Update(ctx context.Context, req resource.UpdateRequ
}
if device.Managed {
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ body := plan.toBody(ctx)
- deletedItems := plan.getDeletedItems(ctx, state)
- tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
+ deletedItems := plan.getDeletedItems(ctx, state)
+ tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- var edits []restconf.YangPatchEdit
- for _, i := range deletedItems {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
- return
+ if YangPatch {
+ var edits []restconf.YangPatchEdit
+ for _, i := range deletedItems {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletedItems {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- for _, i := range deletedItems {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
}
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+
+ body := plan.toBodyXML(ctx)
+ body = plan.addDeletedItemsXML(ctx, state, body)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
return
}
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
- return
- }
- }
}
}
@@ -559,6 +631,18 @@ func (r *ErrdisableResource) Delete(ctx context.Context, req resource.DeleteRequ
}
if device.Managed {
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.Protocol == "netconf" && device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
+ }
deleteMode := "all"
if state.DeleteMode.ValueString() == "all" {
deleteMode = "all"
@@ -567,31 +651,52 @@ func (r *ErrdisableResource) Delete(ctx context.Context, req resource.DeleteRequ
}
if deleteMode == "all" {
- res, err := device.Client.DeleteData(state.Id.ValueString())
- if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
- return
- }
- } else {
- deletePaths := state.getDeletePaths(ctx)
- tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
-
- if YangPatch {
- edits := []restconf.YangPatchEdit{}
- for _, i := range deletePaths {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.DeleteData(state.Id.ValueString())
+ if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
return
}
} else {
- for _, i := range deletePaths {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // NETCONF
+ body := netconf.Body{}
+ body = helpers.RemoveFromXPath(body, state.getXPath())
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body.Res(), true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
+ }
+ }
+ } else {
+ if device.Protocol == "restconf" {
+ deletePaths := state.getDeletePaths(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
+
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{}
+ for _, i := range deletePaths {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
}
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletePaths {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ }
+ }
+ }
+ } else {
+ // NETCONF
+ body := state.addDeletePathsXML(ctx, "")
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
diff --git a/internal/provider/resource_iosxe_evpn.go b/internal/provider/resource_iosxe_evpn.go
index 2459a535..beba5546 100644
--- a/internal/provider/resource_iosxe_evpn.go
+++ b/internal/provider/resource_iosxe_evpn.go
@@ -36,6 +36,7 @@ import (
"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-netconf"
"github.com/netascode/go-restconf"
)
@@ -191,37 +192,59 @@ func (r *EVPNResource) Create(ctx context.Context, req resource.CreateRequest, r
}
if device.Managed {
- // Create object
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ // Create object
+ body := plan.toBody(ctx)
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
- return
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
+ return
+ }
+ } else {
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
- return
- }
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
+ }
+
+ body := plan.toBodyXML(ctx)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
@@ -259,25 +282,51 @@ func (r *EVPNResource) Read(ctx context.Context, req resource.ReadRequest, resp
}
if device.Managed {
- res, err := device.Client.GetData(state.Id.ValueString())
- if res.StatusCode == 404 {
- state = EVPN{Device: state.Device, Id: state.Id}
+ imp, diags := helpers.IsFlagImporting(ctx, req)
+ if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ return
+ }
+
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(state.Id.ValueString())
+ if res.StatusCode == 404 {
+ state = EVPN{Device: state.Device, Id: state.Id}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
+ return
+ }
+
+ // After `terraform import` we switch to a full read.
+ if imp {
+ state.fromBody(ctx, res.Res)
+ } else {
+ state.updateFromBody(ctx, res.Res)
+ }
+ }
} else {
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
- return
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
}
- imp, diags := helpers.IsFlagImporting(ctx, req)
- if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ filter := helpers.GetXpathFilter(state.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.getPath(), err))
return
}
// After `terraform import` we switch to a full read.
if imp {
- state.fromBody(ctx, res.Res)
+ state.fromBodyXML(ctx, res.Res)
} else {
- state.updateFromBody(ctx, res.Res)
+ state.updateFromBodyXML(ctx, res.Res)
}
}
}
@@ -320,51 +369,74 @@ func (r *EVPNResource) Update(ctx context.Context, req resource.UpdateRequest, r
}
if device.Managed {
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ body := plan.toBody(ctx)
- deletedItems := plan.getDeletedItems(ctx, state)
- tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
+ deletedItems := plan.getDeletedItems(ctx, state)
+ tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- var edits []restconf.YangPatchEdit
- for _, i := range deletedItems {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
- return
+ if YangPatch {
+ var edits []restconf.YangPatchEdit
+ for _, i := range deletedItems {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletedItems {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- for _, i := range deletedItems {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
}
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+
+ body := plan.toBodyXML(ctx)
+ body = plan.addDeletedItemsXML(ctx, state, body)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
return
}
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
- return
- }
- }
}
}
@@ -397,6 +469,18 @@ func (r *EVPNResource) Delete(ctx context.Context, req resource.DeleteRequest, r
}
if device.Managed {
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.Protocol == "netconf" && device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
+ }
deleteMode := "all"
if state.DeleteMode.ValueString() == "all" {
deleteMode = "all"
@@ -405,31 +489,52 @@ func (r *EVPNResource) Delete(ctx context.Context, req resource.DeleteRequest, r
}
if deleteMode == "all" {
- res, err := device.Client.DeleteData(state.Id.ValueString())
- if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
- return
- }
- } else {
- deletePaths := state.getDeletePaths(ctx)
- tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
-
- if YangPatch {
- edits := []restconf.YangPatchEdit{}
- for _, i := range deletePaths {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.DeleteData(state.Id.ValueString())
+ if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
return
}
} else {
- for _, i := range deletePaths {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // NETCONF
+ body := netconf.Body{}
+ body = helpers.RemoveFromXPath(body, state.getXPath())
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body.Res(), true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
+ }
+ }
+ } else {
+ if device.Protocol == "restconf" {
+ deletePaths := state.getDeletePaths(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
+
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{}
+ for _, i := range deletePaths {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
}
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletePaths {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ }
+ }
+ }
+ } else {
+ // NETCONF
+ body := state.addDeletePathsXML(ctx, "")
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
diff --git a/internal/provider/resource_iosxe_evpn_instance.go b/internal/provider/resource_iosxe_evpn_instance.go
index a3fef17c..51ccc3fb 100644
--- a/internal/provider/resource_iosxe_evpn_instance.go
+++ b/internal/provider/resource_iosxe_evpn_instance.go
@@ -39,6 +39,7 @@ import (
"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-netconf"
"github.com/netascode/go-restconf"
)
@@ -226,37 +227,59 @@ func (r *EVPNInstanceResource) Create(ctx context.Context, req resource.CreateRe
}
if device.Managed {
- // Create object
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ // Create object
+ body := plan.toBody(ctx)
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
- return
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
+ return
+ }
+ } else {
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
- return
- }
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
+ }
+
+ body := plan.toBodyXML(ctx)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
@@ -294,25 +317,51 @@ func (r *EVPNInstanceResource) Read(ctx context.Context, req resource.ReadReques
}
if device.Managed {
- res, err := device.Client.GetData(state.Id.ValueString())
- if res.StatusCode == 404 {
- state = EVPNInstance{Device: state.Device, Id: state.Id}
+ imp, diags := helpers.IsFlagImporting(ctx, req)
+ if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ return
+ }
+
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(state.Id.ValueString())
+ if res.StatusCode == 404 {
+ state = EVPNInstance{Device: state.Device, Id: state.Id}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
+ return
+ }
+
+ // After `terraform import` we switch to a full read.
+ if imp {
+ state.fromBody(ctx, res.Res)
+ } else {
+ state.updateFromBody(ctx, res.Res)
+ }
+ }
} else {
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
- return
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
}
- imp, diags := helpers.IsFlagImporting(ctx, req)
- if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ filter := helpers.GetXpathFilter(state.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.getPath(), err))
return
}
// After `terraform import` we switch to a full read.
if imp {
- state.fromBody(ctx, res.Res)
+ state.fromBodyXML(ctx, res.Res)
} else {
- state.updateFromBody(ctx, res.Res)
+ state.updateFromBodyXML(ctx, res.Res)
}
}
}
@@ -355,51 +404,74 @@ func (r *EVPNInstanceResource) Update(ctx context.Context, req resource.UpdateRe
}
if device.Managed {
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ body := plan.toBody(ctx)
- deletedItems := plan.getDeletedItems(ctx, state)
- tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
+ deletedItems := plan.getDeletedItems(ctx, state)
+ tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- var edits []restconf.YangPatchEdit
- for _, i := range deletedItems {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
- return
+ if YangPatch {
+ var edits []restconf.YangPatchEdit
+ for _, i := range deletedItems {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletedItems {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- for _, i := range deletedItems {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
}
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+
+ body := plan.toBodyXML(ctx)
+ body = plan.addDeletedItemsXML(ctx, state, body)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
return
}
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
- return
- }
- }
}
}
@@ -432,34 +504,67 @@ func (r *EVPNInstanceResource) Delete(ctx context.Context, req resource.DeleteRe
}
if device.Managed {
- deleteMode := "all"
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
- if deleteMode == "all" {
- res, err := device.Client.DeleteData(state.Id.ValueString())
- if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
+ if device.Protocol == "netconf" && device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
- } else {
- deletePaths := state.getDeletePaths(ctx)
- tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
+ defer cleanup()
+ }
+ deleteMode := "all"
- if YangPatch {
- edits := []restconf.YangPatchEdit{}
- for _, i := range deletePaths {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ if deleteMode == "all" {
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.DeleteData(state.Id.ValueString())
+ if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
return
}
} else {
- for _, i := range deletePaths {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // NETCONF
+ body := netconf.Body{}
+ body = helpers.RemoveFromXPath(body, state.getXPath())
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body.Res(), true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
+ }
+ }
+ } else {
+ if device.Protocol == "restconf" {
+ deletePaths := state.getDeletePaths(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
+
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{}
+ for _, i := range deletePaths {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
}
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletePaths {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ }
+ }
+ }
+ } else {
+ // NETCONF
+ body := state.addDeletePathsXML(ctx, "")
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
diff --git a/internal/provider/resource_iosxe_flow_exporter.go b/internal/provider/resource_iosxe_flow_exporter.go
index 2542bb3e..4f8bf059 100644
--- a/internal/provider/resource_iosxe_flow_exporter.go
+++ b/internal/provider/resource_iosxe_flow_exporter.go
@@ -37,6 +37,7 @@ import (
"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-netconf"
"github.com/netascode/go-restconf"
)
@@ -199,37 +200,59 @@ func (r *FlowExporterResource) Create(ctx context.Context, req resource.CreateRe
}
if device.Managed {
- // Create object
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ // Create object
+ body := plan.toBody(ctx)
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
- return
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
+ return
+ }
+ } else {
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
- return
- }
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
+ }
+
+ body := plan.toBodyXML(ctx)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
@@ -267,25 +290,51 @@ func (r *FlowExporterResource) Read(ctx context.Context, req resource.ReadReques
}
if device.Managed {
- res, err := device.Client.GetData(state.Id.ValueString())
- if res.StatusCode == 404 {
- state = FlowExporter{Device: state.Device, Id: state.Id}
+ imp, diags := helpers.IsFlagImporting(ctx, req)
+ if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ return
+ }
+
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(state.Id.ValueString())
+ if res.StatusCode == 404 {
+ state = FlowExporter{Device: state.Device, Id: state.Id}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
+ return
+ }
+
+ // After `terraform import` we switch to a full read.
+ if imp {
+ state.fromBody(ctx, res.Res)
+ } else {
+ state.updateFromBody(ctx, res.Res)
+ }
+ }
} else {
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
- return
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
}
- imp, diags := helpers.IsFlagImporting(ctx, req)
- if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ filter := helpers.GetXpathFilter(state.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.getPath(), err))
return
}
// After `terraform import` we switch to a full read.
if imp {
- state.fromBody(ctx, res.Res)
+ state.fromBodyXML(ctx, res.Res)
} else {
- state.updateFromBody(ctx, res.Res)
+ state.updateFromBodyXML(ctx, res.Res)
}
}
}
@@ -328,51 +377,74 @@ func (r *FlowExporterResource) Update(ctx context.Context, req resource.UpdateRe
}
if device.Managed {
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ body := plan.toBody(ctx)
- deletedItems := plan.getDeletedItems(ctx, state)
- tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
+ deletedItems := plan.getDeletedItems(ctx, state)
+ tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- var edits []restconf.YangPatchEdit
- for _, i := range deletedItems {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
- return
+ if YangPatch {
+ var edits []restconf.YangPatchEdit
+ for _, i := range deletedItems {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletedItems {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- for _, i := range deletedItems {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
}
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+
+ body := plan.toBodyXML(ctx)
+ body = plan.addDeletedItemsXML(ctx, state, body)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
return
}
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
- return
- }
- }
}
}
@@ -405,6 +477,18 @@ func (r *FlowExporterResource) Delete(ctx context.Context, req resource.DeleteRe
}
if device.Managed {
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.Protocol == "netconf" && device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
+ }
deleteMode := "all"
if state.DeleteMode.ValueString() == "all" {
deleteMode = "all"
@@ -413,31 +497,52 @@ func (r *FlowExporterResource) Delete(ctx context.Context, req resource.DeleteRe
}
if deleteMode == "all" {
- res, err := device.Client.DeleteData(state.Id.ValueString())
- if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
- return
- }
- } else {
- deletePaths := state.getDeletePaths(ctx)
- tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
-
- if YangPatch {
- edits := []restconf.YangPatchEdit{}
- for _, i := range deletePaths {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.DeleteData(state.Id.ValueString())
+ if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
return
}
} else {
- for _, i := range deletePaths {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // NETCONF
+ body := netconf.Body{}
+ body = helpers.RemoveFromXPath(body, state.getXPath())
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body.Res(), true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
+ }
+ }
+ } else {
+ if device.Protocol == "restconf" {
+ deletePaths := state.getDeletePaths(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
+
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{}
+ for _, i := range deletePaths {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
}
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletePaths {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ }
+ }
+ }
+ } else {
+ // NETCONF
+ body := state.addDeletePathsXML(ctx, "")
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
diff --git a/internal/provider/resource_iosxe_flow_monitor.go b/internal/provider/resource_iosxe_flow_monitor.go
index 57bc5467..f09df4fb 100644
--- a/internal/provider/resource_iosxe_flow_monitor.go
+++ b/internal/provider/resource_iosxe_flow_monitor.go
@@ -37,6 +37,7 @@ import (
"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-netconf"
"github.com/netascode/go-restconf"
)
@@ -168,37 +169,59 @@ func (r *FlowMonitorResource) Create(ctx context.Context, req resource.CreateReq
}
if device.Managed {
- // Create object
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ // Create object
+ body := plan.toBody(ctx)
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
- return
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
+ return
+ }
+ } else {
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
- return
- }
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
+ }
+
+ body := plan.toBodyXML(ctx)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
@@ -236,25 +259,51 @@ func (r *FlowMonitorResource) Read(ctx context.Context, req resource.ReadRequest
}
if device.Managed {
- res, err := device.Client.GetData(state.Id.ValueString())
- if res.StatusCode == 404 {
- state = FlowMonitor{Device: state.Device, Id: state.Id}
+ imp, diags := helpers.IsFlagImporting(ctx, req)
+ if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ return
+ }
+
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(state.Id.ValueString())
+ if res.StatusCode == 404 {
+ state = FlowMonitor{Device: state.Device, Id: state.Id}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
+ return
+ }
+
+ // After `terraform import` we switch to a full read.
+ if imp {
+ state.fromBody(ctx, res.Res)
+ } else {
+ state.updateFromBody(ctx, res.Res)
+ }
+ }
} else {
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
- return
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
}
- imp, diags := helpers.IsFlagImporting(ctx, req)
- if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ filter := helpers.GetXpathFilter(state.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.getPath(), err))
return
}
// After `terraform import` we switch to a full read.
if imp {
- state.fromBody(ctx, res.Res)
+ state.fromBodyXML(ctx, res.Res)
} else {
- state.updateFromBody(ctx, res.Res)
+ state.updateFromBodyXML(ctx, res.Res)
}
}
}
@@ -297,51 +346,74 @@ func (r *FlowMonitorResource) Update(ctx context.Context, req resource.UpdateReq
}
if device.Managed {
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ body := plan.toBody(ctx)
- deletedItems := plan.getDeletedItems(ctx, state)
- tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
+ deletedItems := plan.getDeletedItems(ctx, state)
+ tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- var edits []restconf.YangPatchEdit
- for _, i := range deletedItems {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
- return
+ if YangPatch {
+ var edits []restconf.YangPatchEdit
+ for _, i := range deletedItems {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletedItems {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- for _, i := range deletedItems {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
}
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+
+ body := plan.toBodyXML(ctx)
+ body = plan.addDeletedItemsXML(ctx, state, body)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
return
}
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
- return
- }
- }
}
}
@@ -374,6 +446,18 @@ func (r *FlowMonitorResource) Delete(ctx context.Context, req resource.DeleteReq
}
if device.Managed {
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.Protocol == "netconf" && device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
+ }
deleteMode := "all"
if state.DeleteMode.ValueString() == "all" {
deleteMode = "all"
@@ -382,31 +466,52 @@ func (r *FlowMonitorResource) Delete(ctx context.Context, req resource.DeleteReq
}
if deleteMode == "all" {
- res, err := device.Client.DeleteData(state.Id.ValueString())
- if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
- return
- }
- } else {
- deletePaths := state.getDeletePaths(ctx)
- tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
-
- if YangPatch {
- edits := []restconf.YangPatchEdit{}
- for _, i := range deletePaths {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.DeleteData(state.Id.ValueString())
+ if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
return
}
} else {
- for _, i := range deletePaths {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // NETCONF
+ body := netconf.Body{}
+ body = helpers.RemoveFromXPath(body, state.getXPath())
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body.Res(), true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
+ }
+ }
+ } else {
+ if device.Protocol == "restconf" {
+ deletePaths := state.getDeletePaths(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
+
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{}
+ for _, i := range deletePaths {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
}
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletePaths {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ }
+ }
+ }
+ } else {
+ // NETCONF
+ body := state.addDeletePathsXML(ctx, "")
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
diff --git a/internal/provider/resource_iosxe_flow_monitor_test.go b/internal/provider/resource_iosxe_flow_monitor_test.go
index 7290001d..81199cfd 100644
--- a/internal/provider/resource_iosxe_flow_monitor_test.go
+++ b/internal/provider/resource_iosxe_flow_monitor_test.go
@@ -80,15 +80,15 @@ func iosxeFlowMonitorImportStateIdFunc(resourceName string) resource.ImportState
// Section below is generated&owned by "gen/generator.go". //template:begin testPrerequisites
const testAccIosxeFlowMonitorPrerequisitesConfig = `
-resource "iosxe_restconf" "PreReq0" {
- path = "Cisco-IOS-XE-native:native/flow/Cisco-IOS-XE-flow:exporter=EXPORTER1"
+resource "iosxe_yang" "PreReq0" {
+ path = "/Cisco-IOS-XE-native:native/flow/Cisco-IOS-XE-flow:exporter[name=EXPORTER1]"
attributes = {
"name" = "EXPORTER1"
}
}
-resource "iosxe_restconf" "PreReq1" {
- path = "Cisco-IOS-XE-native:native/flow/Cisco-IOS-XE-flow:record=FNF1"
+resource "iosxe_yang" "PreReq1" {
+ path = "/Cisco-IOS-XE-native:native/flow/Cisco-IOS-XE-flow:record[name=FNF1]"
attributes = {
"name" = "FNF1"
}
@@ -103,7 +103,7 @@ resource "iosxe_restconf" "PreReq1" {
func testAccIosxeFlowMonitorConfig_minimum() string {
config := `resource "iosxe_flow_monitor" "test" {` + "\n"
config += ` name = "MON1"` + "\n"
- config += ` depends_on = [iosxe_restconf.PreReq0, iosxe_restconf.PreReq1, ]` + "\n"
+ config += ` depends_on = [iosxe_yang.PreReq0, iosxe_yang.PreReq1, ]` + "\n"
config += `}` + "\n"
return config
}
@@ -122,7 +122,7 @@ func testAccIosxeFlowMonitorConfig_all() string {
config += ` cache_timeout_active = 60` + "\n"
config += ` cache_timeout_inactive = 10` + "\n"
config += ` record = "FNF1"` + "\n"
- config += ` depends_on = [iosxe_restconf.PreReq0, iosxe_restconf.PreReq1, ]` + "\n"
+ config += ` depends_on = [iosxe_yang.PreReq0, iosxe_yang.PreReq1, ]` + "\n"
config += `}` + "\n"
return config
}
diff --git a/internal/provider/resource_iosxe_flow_record.go b/internal/provider/resource_iosxe_flow_record.go
index d7d52b7e..6fb6c328 100644
--- a/internal/provider/resource_iosxe_flow_record.go
+++ b/internal/provider/resource_iosxe_flow_record.go
@@ -36,6 +36,7 @@ import (
"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-netconf"
"github.com/netascode/go-restconf"
)
@@ -262,37 +263,59 @@ func (r *FlowRecordResource) Create(ctx context.Context, req resource.CreateRequ
}
if device.Managed {
- // Create object
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ // Create object
+ body := plan.toBody(ctx)
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
- return
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
+ return
+ }
+ } else {
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
- return
- }
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
+ }
+
+ body := plan.toBodyXML(ctx)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
@@ -330,25 +353,51 @@ func (r *FlowRecordResource) Read(ctx context.Context, req resource.ReadRequest,
}
if device.Managed {
- res, err := device.Client.GetData(state.Id.ValueString())
- if res.StatusCode == 404 {
- state = FlowRecord{Device: state.Device, Id: state.Id}
+ imp, diags := helpers.IsFlagImporting(ctx, req)
+ if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ return
+ }
+
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(state.Id.ValueString())
+ if res.StatusCode == 404 {
+ state = FlowRecord{Device: state.Device, Id: state.Id}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
+ return
+ }
+
+ // After `terraform import` we switch to a full read.
+ if imp {
+ state.fromBody(ctx, res.Res)
+ } else {
+ state.updateFromBody(ctx, res.Res)
+ }
+ }
} else {
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
- return
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
}
- imp, diags := helpers.IsFlagImporting(ctx, req)
- if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ filter := helpers.GetXpathFilter(state.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.getPath(), err))
return
}
// After `terraform import` we switch to a full read.
if imp {
- state.fromBody(ctx, res.Res)
+ state.fromBodyXML(ctx, res.Res)
} else {
- state.updateFromBody(ctx, res.Res)
+ state.updateFromBodyXML(ctx, res.Res)
}
}
}
@@ -391,51 +440,74 @@ func (r *FlowRecordResource) Update(ctx context.Context, req resource.UpdateRequ
}
if device.Managed {
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ body := plan.toBody(ctx)
- deletedItems := plan.getDeletedItems(ctx, state)
- tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
+ deletedItems := plan.getDeletedItems(ctx, state)
+ tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- var edits []restconf.YangPatchEdit
- for _, i := range deletedItems {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
- return
+ if YangPatch {
+ var edits []restconf.YangPatchEdit
+ for _, i := range deletedItems {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletedItems {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- for _, i := range deletedItems {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
}
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+
+ body := plan.toBodyXML(ctx)
+ body = plan.addDeletedItemsXML(ctx, state, body)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
return
}
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
- return
- }
- }
}
}
@@ -468,6 +540,18 @@ func (r *FlowRecordResource) Delete(ctx context.Context, req resource.DeleteRequ
}
if device.Managed {
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.Protocol == "netconf" && device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
+ }
deleteMode := "all"
if state.DeleteMode.ValueString() == "all" {
deleteMode = "all"
@@ -476,31 +560,52 @@ func (r *FlowRecordResource) Delete(ctx context.Context, req resource.DeleteRequ
}
if deleteMode == "all" {
- res, err := device.Client.DeleteData(state.Id.ValueString())
- if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
- return
- }
- } else {
- deletePaths := state.getDeletePaths(ctx)
- tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
-
- if YangPatch {
- edits := []restconf.YangPatchEdit{}
- for _, i := range deletePaths {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.DeleteData(state.Id.ValueString())
+ if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
return
}
} else {
- for _, i := range deletePaths {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // NETCONF
+ body := netconf.Body{}
+ body = helpers.RemoveFromXPath(body, state.getXPath())
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body.Res(), true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
+ }
+ }
+ } else {
+ if device.Protocol == "restconf" {
+ deletePaths := state.getDeletePaths(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
+
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{}
+ for _, i := range deletePaths {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
}
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletePaths {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ }
+ }
+ }
+ } else {
+ // NETCONF
+ body := state.addDeletePathsXML(ctx, "")
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
diff --git a/internal/provider/resource_iosxe_interface_ethernet.go b/internal/provider/resource_iosxe_interface_ethernet.go
index 1a63ff41..d05a007f 100644
--- a/internal/provider/resource_iosxe_interface_ethernet.go
+++ b/internal/provider/resource_iosxe_interface_ethernet.go
@@ -37,6 +37,7 @@ import (
"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-netconf"
"github.com/netascode/go-restconf"
)
@@ -863,37 +864,59 @@ func (r *InterfaceEthernetResource) Create(ctx context.Context, req resource.Cre
}
if device.Managed {
- // Create object
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ // Create object
+ body := plan.toBody(ctx)
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits, restconf.Wait)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
- return
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits, restconf.Wait)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
+ return
+ }
+ } else {
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body, restconf.Wait)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body, restconf.Wait)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i, restconf.Wait)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- res, err := device.Client.PatchData(plan.getPathShort(), body, restconf.Wait)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body, restconf.Wait)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
- return
- }
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i, restconf.Wait)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
+ }
+
+ body := plan.toBodyXML(ctx)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
@@ -931,25 +954,51 @@ func (r *InterfaceEthernetResource) Read(ctx context.Context, req resource.ReadR
}
if device.Managed {
- res, err := device.Client.GetData(state.Id.ValueString())
- if res.StatusCode == 404 {
- state = InterfaceEthernet{Device: state.Device, Id: state.Id}
+ imp, diags := helpers.IsFlagImporting(ctx, req)
+ if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ return
+ }
+
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(state.Id.ValueString())
+ if res.StatusCode == 404 {
+ state = InterfaceEthernet{Device: state.Device, Id: state.Id}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
+ return
+ }
+
+ // After `terraform import` we switch to a full read.
+ if imp {
+ state.fromBody(ctx, res.Res)
+ } else {
+ state.updateFromBody(ctx, res.Res)
+ }
+ }
} else {
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
- return
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
}
- imp, diags := helpers.IsFlagImporting(ctx, req)
- if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ filter := helpers.GetXpathFilter(state.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.getPath(), err))
return
}
// After `terraform import` we switch to a full read.
if imp {
- state.fromBody(ctx, res.Res)
+ state.fromBodyXML(ctx, res.Res)
} else {
- state.updateFromBody(ctx, res.Res)
+ state.updateFromBodyXML(ctx, res.Res)
}
}
}
@@ -992,51 +1041,74 @@ func (r *InterfaceEthernetResource) Update(ctx context.Context, req resource.Upd
}
if device.Managed {
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ body := plan.toBody(ctx)
- deletedItems := plan.getDeletedItems(ctx, state)
- tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
+ deletedItems := plan.getDeletedItems(ctx, state)
+ tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- var edits []restconf.YangPatchEdit
- for _, i := range deletedItems {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits, restconf.Wait)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
- return
+ if YangPatch {
+ var edits []restconf.YangPatchEdit
+ for _, i := range deletedItems {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits, restconf.Wait)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletedItems {
+ res, err := device.RestconfClient.DeleteData(i, restconf.Wait)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body, restconf.Wait)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body, restconf.Wait)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i, restconf.Wait)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- for _, i := range deletedItems {
- res, err := device.Client.DeleteData(i, restconf.Wait)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
}
- res, err := device.Client.PatchData(plan.getPathShort(), body, restconf.Wait)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body, restconf.Wait)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+
+ body := plan.toBodyXML(ctx)
+ body = plan.addDeletedItemsXML(ctx, state, body)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
return
}
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i, restconf.Wait)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
- return
- }
- }
}
}
@@ -1069,34 +1141,67 @@ func (r *InterfaceEthernetResource) Delete(ctx context.Context, req resource.Del
}
if device.Managed {
- deleteMode := "attributes"
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
- if deleteMode == "all" {
- res, err := device.Client.DeleteData(state.Id.ValueString(), restconf.Wait)
- if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
+ if device.Protocol == "netconf" && device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
- } else {
- deletePaths := state.getDeletePaths(ctx)
- tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
+ defer cleanup()
+ }
+ deleteMode := "attributes"
- if YangPatch {
- edits := []restconf.YangPatchEdit{}
- for _, i := range deletePaths {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits, restconf.Wait)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ if deleteMode == "all" {
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.DeleteData(state.Id.ValueString(), restconf.Wait)
+ if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
return
}
} else {
- for _, i := range deletePaths {
- res, err := device.Client.DeleteData(i, restconf.Wait)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // NETCONF
+ body := netconf.Body{}
+ body = helpers.RemoveFromXPath(body, state.getXPath())
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body.Res(), true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
+ }
+ }
+ } else {
+ if device.Protocol == "restconf" {
+ deletePaths := state.getDeletePaths(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
+
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{}
+ for _, i := range deletePaths {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
}
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits, restconf.Wait)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletePaths {
+ res, err := device.RestconfClient.DeleteData(i, restconf.Wait)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ }
+ }
+ }
+ } else {
+ // NETCONF
+ body := state.addDeletePathsXML(ctx, "")
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
diff --git a/internal/provider/resource_iosxe_interface_ethernet_test.go b/internal/provider/resource_iosxe_interface_ethernet_test.go
index d0fadb12..64699d03 100644
--- a/internal/provider/resource_iosxe_interface_ethernet_test.go
+++ b/internal/provider/resource_iosxe_interface_ethernet_test.go
@@ -140,8 +140,8 @@ func iosxeInterfaceEthernetImportStateIdFunc(resourceName string) resource.Impor
// Section below is generated&owned by "gen/generator.go". //template:begin testPrerequisites
const testAccIosxeInterfaceEthernetPrerequisitesConfig = `
-resource "iosxe_restconf" "PreReq0" {
- path = "Cisco-IOS-XE-native:native/vrf/definition=VRF1"
+resource "iosxe_yang" "PreReq0" {
+ path = "/Cisco-IOS-XE-native:native/vrf/definition[name=VRF1]"
delete = false
attributes = {
"name" = "VRF1"
@@ -149,15 +149,15 @@ resource "iosxe_restconf" "PreReq0" {
}
}
-resource "iosxe_restconf" "PreReq1" {
- path = "Cisco-IOS-XE-native:native/policy/Cisco-IOS-XE-policy:policy-map=POLICY1"
+resource "iosxe_yang" "PreReq1" {
+ path = "/Cisco-IOS-XE-native:native/policy/Cisco-IOS-XE-policy:policy-map[name=POLICY1]"
attributes = {
"name" = "POLICY1"
}
}
-resource "iosxe_restconf" "PreReq2" {
- path = "Cisco-IOS-XE-native:native/flow/Cisco-IOS-XE-flow:record=REC1"
+resource "iosxe_yang" "PreReq2" {
+ path = "/Cisco-IOS-XE-native:native/flow/Cisco-IOS-XE-flow:record[name=REC1]"
attributes = {
"name" = "REC1"
"match/ipv4/source/address" = ""
@@ -165,17 +165,17 @@ resource "iosxe_restconf" "PreReq2" {
}
}
-resource "iosxe_restconf" "PreReq3" {
- path = "Cisco-IOS-XE-native:native/flow/Cisco-IOS-XE-flow:monitor=MON1"
+resource "iosxe_yang" "PreReq3" {
+ path = "/Cisco-IOS-XE-native:native/flow/Cisco-IOS-XE-flow:monitor[name=MON1]"
attributes = {
"name" = "MON1"
"record/type" = "REC1"
}
- depends_on = [iosxe_restconf.PreReq2, ]
+ depends_on = [iosxe_yang.PreReq2, ]
}
-resource "iosxe_restconf" "PreReq4" {
- path = "Cisco-IOS-XE-native:native/template/Cisco-IOS-XE-template:template_details=TEMP1"
+resource "iosxe_yang" "PreReq4" {
+ path = "/Cisco-IOS-XE-native:native/template/Cisco-IOS-XE-template:template_details[template_name=TEMP1]"
attributes = {
"template_name" = "TEMP1"
}
@@ -191,7 +191,7 @@ func testAccIosxeInterfaceEthernetConfig_minimum() string {
config := `resource "iosxe_interface_ethernet" "test" {` + "\n"
config += ` type = "GigabitEthernet"` + "\n"
config += ` name = "3"` + "\n"
- config += ` depends_on = [iosxe_restconf.PreReq0, iosxe_restconf.PreReq1, iosxe_restconf.PreReq2, iosxe_restconf.PreReq3, iosxe_restconf.PreReq4, ]` + "\n"
+ config += ` depends_on = [iosxe_yang.PreReq0, iosxe_yang.PreReq1, iosxe_yang.PreReq2, iosxe_yang.PreReq3, iosxe_yang.PreReq4, ]` + "\n"
config += `}` + "\n"
return config
}
@@ -274,7 +274,7 @@ func testAccIosxeInterfaceEthernetConfig_all() string {
config += ` cdp_tlv_location = false` + "\n"
config += ` cdp_tlv_server_location = false` + "\n"
config += ` ip_nat_inside = true` + "\n"
- config += ` depends_on = [iosxe_restconf.PreReq0, iosxe_restconf.PreReq1, iosxe_restconf.PreReq2, iosxe_restconf.PreReq3, iosxe_restconf.PreReq4, ]` + "\n"
+ config += ` depends_on = [iosxe_yang.PreReq0, iosxe_yang.PreReq1, iosxe_yang.PreReq2, iosxe_yang.PreReq3, iosxe_yang.PreReq4, ]` + "\n"
config += `}` + "\n"
return config
}
diff --git a/internal/provider/resource_iosxe_interface_loopback.go b/internal/provider/resource_iosxe_interface_loopback.go
index 2b68b5ce..60e012ef 100644
--- a/internal/provider/resource_iosxe_interface_loopback.go
+++ b/internal/provider/resource_iosxe_interface_loopback.go
@@ -39,6 +39,7 @@ import (
"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-netconf"
"github.com/netascode/go-restconf"
)
@@ -261,37 +262,59 @@ func (r *InterfaceLoopbackResource) Create(ctx context.Context, req resource.Cre
}
if device.Managed {
- // Create object
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ // Create object
+ body := plan.toBody(ctx)
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
- return
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
+ return
+ }
+ } else {
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
- return
- }
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
+ }
+
+ body := plan.toBodyXML(ctx)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
@@ -329,25 +352,51 @@ func (r *InterfaceLoopbackResource) Read(ctx context.Context, req resource.ReadR
}
if device.Managed {
- res, err := device.Client.GetData(state.Id.ValueString())
- if res.StatusCode == 404 {
- state = InterfaceLoopback{Device: state.Device, Id: state.Id}
+ imp, diags := helpers.IsFlagImporting(ctx, req)
+ if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ return
+ }
+
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(state.Id.ValueString())
+ if res.StatusCode == 404 {
+ state = InterfaceLoopback{Device: state.Device, Id: state.Id}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
+ return
+ }
+
+ // After `terraform import` we switch to a full read.
+ if imp {
+ state.fromBody(ctx, res.Res)
+ } else {
+ state.updateFromBody(ctx, res.Res)
+ }
+ }
} else {
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
- return
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
}
- imp, diags := helpers.IsFlagImporting(ctx, req)
- if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ filter := helpers.GetXpathFilter(state.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.getPath(), err))
return
}
// After `terraform import` we switch to a full read.
if imp {
- state.fromBody(ctx, res.Res)
+ state.fromBodyXML(ctx, res.Res)
} else {
- state.updateFromBody(ctx, res.Res)
+ state.updateFromBodyXML(ctx, res.Res)
}
}
}
@@ -390,51 +439,74 @@ func (r *InterfaceLoopbackResource) Update(ctx context.Context, req resource.Upd
}
if device.Managed {
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ body := plan.toBody(ctx)
- deletedItems := plan.getDeletedItems(ctx, state)
- tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
+ deletedItems := plan.getDeletedItems(ctx, state)
+ tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- var edits []restconf.YangPatchEdit
- for _, i := range deletedItems {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
- return
+ if YangPatch {
+ var edits []restconf.YangPatchEdit
+ for _, i := range deletedItems {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletedItems {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- for _, i := range deletedItems {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
}
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+
+ body := plan.toBodyXML(ctx)
+ body = plan.addDeletedItemsXML(ctx, state, body)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
return
}
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
- return
- }
- }
}
}
@@ -467,6 +539,18 @@ func (r *InterfaceLoopbackResource) Delete(ctx context.Context, req resource.Del
}
if device.Managed {
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.Protocol == "netconf" && device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
+ }
deleteMode := "all"
if state.DeleteMode.ValueString() == "all" {
deleteMode = "all"
@@ -475,31 +559,52 @@ func (r *InterfaceLoopbackResource) Delete(ctx context.Context, req resource.Del
}
if deleteMode == "all" {
- res, err := device.Client.DeleteData(state.Id.ValueString())
- if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
- return
- }
- } else {
- deletePaths := state.getDeletePaths(ctx)
- tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
-
- if YangPatch {
- edits := []restconf.YangPatchEdit{}
- for _, i := range deletePaths {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.DeleteData(state.Id.ValueString())
+ if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
return
}
} else {
- for _, i := range deletePaths {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // NETCONF
+ body := netconf.Body{}
+ body = helpers.RemoveFromXPath(body, state.getXPath())
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body.Res(), true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
+ }
+ }
+ } else {
+ if device.Protocol == "restconf" {
+ deletePaths := state.getDeletePaths(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
+
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{}
+ for _, i := range deletePaths {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
}
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletePaths {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ }
+ }
+ }
+ } else {
+ // NETCONF
+ body := state.addDeletePathsXML(ctx, "")
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
diff --git a/internal/provider/resource_iosxe_interface_loopback_test.go b/internal/provider/resource_iosxe_interface_loopback_test.go
index 2b88dd31..696bf268 100644
--- a/internal/provider/resource_iosxe_interface_loopback_test.go
+++ b/internal/provider/resource_iosxe_interface_loopback_test.go
@@ -95,8 +95,8 @@ func iosxeInterfaceLoopbackImportStateIdFunc(resourceName string) resource.Impor
// Section below is generated&owned by "gen/generator.go". //template:begin testPrerequisites
const testAccIosxeInterfaceLoopbackPrerequisitesConfig = `
-resource "iosxe_restconf" "PreReq0" {
- path = "Cisco-IOS-XE-native:native/vrf/definition=VRF1"
+resource "iosxe_yang" "PreReq0" {
+ path = "/Cisco-IOS-XE-native:native/vrf/definition[name=VRF1]"
delete = false
attributes = {
"name" = "VRF1"
@@ -113,7 +113,7 @@ resource "iosxe_restconf" "PreReq0" {
func testAccIosxeInterfaceLoopbackConfig_minimum() string {
config := `resource "iosxe_interface_loopback" "test" {` + "\n"
config += ` name = 100` + "\n"
- config += ` depends_on = [iosxe_restconf.PreReq0, ]` + "\n"
+ config += ` depends_on = [iosxe_yang.PreReq0, ]` + "\n"
config += `}` + "\n"
return config
}
@@ -149,7 +149,7 @@ func testAccIosxeInterfaceLoopbackConfig_all() string {
config += ` eui_64 = true` + "\n"
config += ` }]` + "\n"
config += ` arp_timeout = 2147` + "\n"
- config += ` depends_on = [iosxe_restconf.PreReq0, ]` + "\n"
+ config += ` depends_on = [iosxe_yang.PreReq0, ]` + "\n"
config += `}` + "\n"
return config
}
diff --git a/internal/provider/resource_iosxe_interface_mpls.go b/internal/provider/resource_iosxe_interface_mpls.go
index 1164ee6d..d5051167 100644
--- a/internal/provider/resource_iosxe_interface_mpls.go
+++ b/internal/provider/resource_iosxe_interface_mpls.go
@@ -36,6 +36,7 @@ import (
"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-netconf"
"github.com/netascode/go-restconf"
)
@@ -148,37 +149,59 @@ func (r *InterfaceMPLSResource) Create(ctx context.Context, req resource.CreateR
}
if device.Managed {
- // Create object
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ // Create object
+ body := plan.toBody(ctx)
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
- return
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
+ return
+ }
+ } else {
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
- return
- }
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
+ }
+
+ body := plan.toBodyXML(ctx)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
@@ -216,25 +239,51 @@ func (r *InterfaceMPLSResource) Read(ctx context.Context, req resource.ReadReque
}
if device.Managed {
- res, err := device.Client.GetData(state.Id.ValueString())
- if res.StatusCode == 404 {
- state = InterfaceMPLS{Device: state.Device, Id: state.Id}
+ imp, diags := helpers.IsFlagImporting(ctx, req)
+ if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ return
+ }
+
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(state.Id.ValueString())
+ if res.StatusCode == 404 {
+ state = InterfaceMPLS{Device: state.Device, Id: state.Id}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
+ return
+ }
+
+ // After `terraform import` we switch to a full read.
+ if imp {
+ state.fromBody(ctx, res.Res)
+ } else {
+ state.updateFromBody(ctx, res.Res)
+ }
+ }
} else {
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
- return
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
}
- imp, diags := helpers.IsFlagImporting(ctx, req)
- if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ filter := helpers.GetXpathFilter(state.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.getPath(), err))
return
}
// After `terraform import` we switch to a full read.
if imp {
- state.fromBody(ctx, res.Res)
+ state.fromBodyXML(ctx, res.Res)
} else {
- state.updateFromBody(ctx, res.Res)
+ state.updateFromBodyXML(ctx, res.Res)
}
}
}
@@ -277,51 +326,74 @@ func (r *InterfaceMPLSResource) Update(ctx context.Context, req resource.UpdateR
}
if device.Managed {
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ body := plan.toBody(ctx)
- deletedItems := plan.getDeletedItems(ctx, state)
- tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
+ deletedItems := plan.getDeletedItems(ctx, state)
+ tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- var edits []restconf.YangPatchEdit
- for _, i := range deletedItems {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
- return
+ if YangPatch {
+ var edits []restconf.YangPatchEdit
+ for _, i := range deletedItems {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletedItems {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- for _, i := range deletedItems {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
}
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+
+ body := plan.toBodyXML(ctx)
+ body = plan.addDeletedItemsXML(ctx, state, body)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
return
}
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
- return
- }
- }
}
}
@@ -354,6 +426,18 @@ func (r *InterfaceMPLSResource) Delete(ctx context.Context, req resource.DeleteR
}
if device.Managed {
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.Protocol == "netconf" && device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
+ }
deleteMode := "all"
if state.DeleteMode.ValueString() == "all" {
deleteMode = "all"
@@ -362,31 +446,52 @@ func (r *InterfaceMPLSResource) Delete(ctx context.Context, req resource.DeleteR
}
if deleteMode == "all" {
- res, err := device.Client.DeleteData(state.Id.ValueString())
- if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
- return
- }
- } else {
- deletePaths := state.getDeletePaths(ctx)
- tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
-
- if YangPatch {
- edits := []restconf.YangPatchEdit{}
- for _, i := range deletePaths {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.DeleteData(state.Id.ValueString())
+ if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
return
}
} else {
- for _, i := range deletePaths {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // NETCONF
+ body := netconf.Body{}
+ body = helpers.RemoveFromXPath(body, state.getXPath())
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body.Res(), true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
+ }
+ }
+ } else {
+ if device.Protocol == "restconf" {
+ deletePaths := state.getDeletePaths(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
+
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{}
+ for _, i := range deletePaths {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
}
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletePaths {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ }
+ }
+ }
+ } else {
+ // NETCONF
+ body := state.addDeletePathsXML(ctx, "")
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
diff --git a/internal/provider/resource_iosxe_interface_mpls_test.go b/internal/provider/resource_iosxe_interface_mpls_test.go
index 88c2ea99..6fa47300 100644
--- a/internal/provider/resource_iosxe_interface_mpls_test.go
+++ b/internal/provider/resource_iosxe_interface_mpls_test.go
@@ -77,8 +77,8 @@ func iosxeInterfaceMPLSImportStateIdFunc(resourceName string) resource.ImportSta
// Section below is generated&owned by "gen/generator.go". //template:begin testPrerequisites
const testAccIosxeInterfaceMPLSPrerequisitesConfig = `
-resource "iosxe_restconf" "PreReq0" {
- path = "Cisco-IOS-XE-native:native/interface/Loopback=1"
+resource "iosxe_yang" "PreReq0" {
+ path = "/Cisco-IOS-XE-native:native/interface/Loopback[name=1]"
attributes = {
"name" = "1"
}
@@ -94,7 +94,7 @@ func testAccIosxeInterfaceMPLSConfig_minimum() string {
config := `resource "iosxe_interface_mpls" "test" {` + "\n"
config += ` type = "Loopback"` + "\n"
config += ` name = "1"` + "\n"
- config += ` depends_on = [iosxe_restconf.PreReq0, ]` + "\n"
+ config += ` depends_on = [iosxe_yang.PreReq0, ]` + "\n"
config += `}` + "\n"
return config
}
@@ -109,7 +109,7 @@ func testAccIosxeInterfaceMPLSConfig_all() string {
config += ` name = "1"` + "\n"
config += ` ip = true` + "\n"
config += ` mtu = "1200"` + "\n"
- config += ` depends_on = [iosxe_restconf.PreReq0, ]` + "\n"
+ config += ` depends_on = [iosxe_yang.PreReq0, ]` + "\n"
config += `}` + "\n"
return config
}
diff --git a/internal/provider/resource_iosxe_interface_nve.go b/internal/provider/resource_iosxe_interface_nve.go
index 742800ec..a0a8c21e 100644
--- a/internal/provider/resource_iosxe_interface_nve.go
+++ b/internal/provider/resource_iosxe_interface_nve.go
@@ -39,6 +39,7 @@ import (
"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-netconf"
"github.com/netascode/go-restconf"
)
@@ -195,37 +196,59 @@ func (r *InterfaceNVEResource) Create(ctx context.Context, req resource.CreateRe
}
if device.Managed {
- // Create object
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ // Create object
+ body := plan.toBody(ctx)
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
- return
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
+ return
+ }
+ } else {
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
- return
- }
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
+ }
+
+ body := plan.toBodyXML(ctx)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
@@ -263,25 +286,51 @@ func (r *InterfaceNVEResource) Read(ctx context.Context, req resource.ReadReques
}
if device.Managed {
- res, err := device.Client.GetData(state.Id.ValueString())
- if res.StatusCode == 404 {
- state = InterfaceNVE{Device: state.Device, Id: state.Id}
+ imp, diags := helpers.IsFlagImporting(ctx, req)
+ if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ return
+ }
+
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(state.Id.ValueString())
+ if res.StatusCode == 404 {
+ state = InterfaceNVE{Device: state.Device, Id: state.Id}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
+ return
+ }
+
+ // After `terraform import` we switch to a full read.
+ if imp {
+ state.fromBody(ctx, res.Res)
+ } else {
+ state.updateFromBody(ctx, res.Res)
+ }
+ }
} else {
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
- return
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
}
- imp, diags := helpers.IsFlagImporting(ctx, req)
- if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ filter := helpers.GetXpathFilter(state.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.getPath(), err))
return
}
// After `terraform import` we switch to a full read.
if imp {
- state.fromBody(ctx, res.Res)
+ state.fromBodyXML(ctx, res.Res)
} else {
- state.updateFromBody(ctx, res.Res)
+ state.updateFromBodyXML(ctx, res.Res)
}
}
}
@@ -324,51 +373,74 @@ func (r *InterfaceNVEResource) Update(ctx context.Context, req resource.UpdateRe
}
if device.Managed {
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ body := plan.toBody(ctx)
- deletedItems := plan.getDeletedItems(ctx, state)
- tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
+ deletedItems := plan.getDeletedItems(ctx, state)
+ tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- var edits []restconf.YangPatchEdit
- for _, i := range deletedItems {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
- return
+ if YangPatch {
+ var edits []restconf.YangPatchEdit
+ for _, i := range deletedItems {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletedItems {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- for _, i := range deletedItems {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
}
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+
+ body := plan.toBodyXML(ctx)
+ body = plan.addDeletedItemsXML(ctx, state, body)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
return
}
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
- return
- }
- }
}
}
@@ -401,6 +473,18 @@ func (r *InterfaceNVEResource) Delete(ctx context.Context, req resource.DeleteRe
}
if device.Managed {
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.Protocol == "netconf" && device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
+ }
deleteMode := "all"
if state.DeleteMode.ValueString() == "all" {
deleteMode = "all"
@@ -409,31 +493,52 @@ func (r *InterfaceNVEResource) Delete(ctx context.Context, req resource.DeleteRe
}
if deleteMode == "all" {
- res, err := device.Client.DeleteData(state.Id.ValueString())
- if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
- return
- }
- } else {
- deletePaths := state.getDeletePaths(ctx)
- tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
-
- if YangPatch {
- edits := []restconf.YangPatchEdit{}
- for _, i := range deletePaths {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.DeleteData(state.Id.ValueString())
+ if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
return
}
} else {
- for _, i := range deletePaths {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // NETCONF
+ body := netconf.Body{}
+ body = helpers.RemoveFromXPath(body, state.getXPath())
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body.Res(), true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
+ }
+ }
+ } else {
+ if device.Protocol == "restconf" {
+ deletePaths := state.getDeletePaths(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
+
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{}
+ for _, i := range deletePaths {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
}
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletePaths {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ }
+ }
+ }
+ } else {
+ // NETCONF
+ body := state.addDeletePathsXML(ctx, "")
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
diff --git a/internal/provider/resource_iosxe_interface_ospf.go b/internal/provider/resource_iosxe_interface_ospf.go
index c872a732..6bcd7107 100644
--- a/internal/provider/resource_iosxe_interface_ospf.go
+++ b/internal/provider/resource_iosxe_interface_ospf.go
@@ -37,6 +37,7 @@ import (
"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-netconf"
"github.com/netascode/go-restconf"
)
@@ -253,37 +254,59 @@ func (r *InterfaceOSPFResource) Create(ctx context.Context, req resource.CreateR
}
if device.Managed {
- // Create object
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ // Create object
+ body := plan.toBody(ctx)
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
- return
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
+ return
+ }
+ } else {
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
- return
- }
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
+ }
+
+ body := plan.toBodyXML(ctx)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
@@ -321,25 +344,51 @@ func (r *InterfaceOSPFResource) Read(ctx context.Context, req resource.ReadReque
}
if device.Managed {
- res, err := device.Client.GetData(state.Id.ValueString())
- if res.StatusCode == 404 {
- state = InterfaceOSPF{Device: state.Device, Id: state.Id}
+ imp, diags := helpers.IsFlagImporting(ctx, req)
+ if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ return
+ }
+
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(state.Id.ValueString())
+ if res.StatusCode == 404 {
+ state = InterfaceOSPF{Device: state.Device, Id: state.Id}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
+ return
+ }
+
+ // After `terraform import` we switch to a full read.
+ if imp {
+ state.fromBody(ctx, res.Res)
+ } else {
+ state.updateFromBody(ctx, res.Res)
+ }
+ }
} else {
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
- return
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
}
- imp, diags := helpers.IsFlagImporting(ctx, req)
- if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ filter := helpers.GetXpathFilter(state.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.getPath(), err))
return
}
// After `terraform import` we switch to a full read.
if imp {
- state.fromBody(ctx, res.Res)
+ state.fromBodyXML(ctx, res.Res)
} else {
- state.updateFromBody(ctx, res.Res)
+ state.updateFromBodyXML(ctx, res.Res)
}
}
}
@@ -382,51 +431,74 @@ func (r *InterfaceOSPFResource) Update(ctx context.Context, req resource.UpdateR
}
if device.Managed {
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ body := plan.toBody(ctx)
- deletedItems := plan.getDeletedItems(ctx, state)
- tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
+ deletedItems := plan.getDeletedItems(ctx, state)
+ tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- var edits []restconf.YangPatchEdit
- for _, i := range deletedItems {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
- return
+ if YangPatch {
+ var edits []restconf.YangPatchEdit
+ for _, i := range deletedItems {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletedItems {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- for _, i := range deletedItems {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
}
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+
+ body := plan.toBodyXML(ctx)
+ body = plan.addDeletedItemsXML(ctx, state, body)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
return
}
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
- return
- }
- }
}
}
@@ -459,6 +531,18 @@ func (r *InterfaceOSPFResource) Delete(ctx context.Context, req resource.DeleteR
}
if device.Managed {
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.Protocol == "netconf" && device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
+ }
deleteMode := "all"
if state.DeleteMode.ValueString() == "all" {
deleteMode = "all"
@@ -467,31 +551,52 @@ func (r *InterfaceOSPFResource) Delete(ctx context.Context, req resource.DeleteR
}
if deleteMode == "all" {
- res, err := device.Client.DeleteData(state.Id.ValueString())
- if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
- return
- }
- } else {
- deletePaths := state.getDeletePaths(ctx)
- tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
-
- if YangPatch {
- edits := []restconf.YangPatchEdit{}
- for _, i := range deletePaths {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.DeleteData(state.Id.ValueString())
+ if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
return
}
} else {
- for _, i := range deletePaths {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // NETCONF
+ body := netconf.Body{}
+ body = helpers.RemoveFromXPath(body, state.getXPath())
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body.Res(), true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
+ }
+ }
+ } else {
+ if device.Protocol == "restconf" {
+ deletePaths := state.getDeletePaths(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
+
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{}
+ for _, i := range deletePaths {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
}
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletePaths {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ }
+ }
+ }
+ } else {
+ // NETCONF
+ body := state.addDeletePathsXML(ctx, "")
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
diff --git a/internal/provider/resource_iosxe_interface_ospf_test.go b/internal/provider/resource_iosxe_interface_ospf_test.go
index c8bdc637..81ad3223 100644
--- a/internal/provider/resource_iosxe_interface_ospf_test.go
+++ b/internal/provider/resource_iosxe_interface_ospf_test.go
@@ -88,15 +88,15 @@ func iosxeInterfaceOSPFImportStateIdFunc(resourceName string) resource.ImportSta
// Section below is generated&owned by "gen/generator.go". //template:begin testPrerequisites
const testAccIosxeInterfaceOSPFPrerequisitesConfig = `
-resource "iosxe_restconf" "PreReq0" {
- path = "Cisco-IOS-XE-native:native/router/Cisco-IOS-XE-ospf:router-ospf/ospf/process-id=1"
+resource "iosxe_yang" "PreReq0" {
+ path = "/Cisco-IOS-XE-native:native/router/Cisco-IOS-XE-ospf:router-ospf/ospf/process-id[id=1]"
attributes = {
"id" = "1"
}
}
-resource "iosxe_restconf" "PreReq1" {
- path = "Cisco-IOS-XE-native:native/interface/Loopback=1"
+resource "iosxe_yang" "PreReq1" {
+ path = "/Cisco-IOS-XE-native:native/interface/Loopback[name=1]"
attributes = {
"name" = "1"
}
@@ -112,7 +112,7 @@ func testAccIosxeInterfaceOSPFConfig_minimum() string {
config := `resource "iosxe_interface_ospf" "test" {` + "\n"
config += ` type = "Loopback"` + "\n"
config += ` name = "1"` + "\n"
- config += ` depends_on = [iosxe_restconf.PreReq0, iosxe_restconf.PreReq1, ]` + "\n"
+ config += ` depends_on = [iosxe_yang.PreReq0, iosxe_yang.PreReq1, ]` + "\n"
config += `}` + "\n"
return config
}
@@ -146,7 +146,7 @@ func testAccIosxeInterfaceOSPFConfig_all() string {
config += ` md5_auth_key = "mykey"` + "\n"
config += ` md5_auth_type = 0` + "\n"
config += ` }]` + "\n"
- config += ` depends_on = [iosxe_restconf.PreReq0, iosxe_restconf.PreReq1, ]` + "\n"
+ config += ` depends_on = [iosxe_yang.PreReq0, iosxe_yang.PreReq1, ]` + "\n"
config += `}` + "\n"
return config
}
diff --git a/internal/provider/resource_iosxe_interface_ospfv3.go b/internal/provider/resource_iosxe_interface_ospfv3.go
index ce1161f2..ad0bbd22 100644
--- a/internal/provider/resource_iosxe_interface_ospfv3.go
+++ b/internal/provider/resource_iosxe_interface_ospfv3.go
@@ -37,6 +37,7 @@ import (
"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-netconf"
"github.com/netascode/go-restconf"
)
@@ -164,37 +165,59 @@ func (r *InterfaceOSPFv3Resource) Create(ctx context.Context, req resource.Creat
}
if device.Managed {
- // Create object
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ // Create object
+ body := plan.toBody(ctx)
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
- return
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
+ return
+ }
+ } else {
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
- return
- }
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
+ }
+
+ body := plan.toBodyXML(ctx)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
@@ -232,25 +255,51 @@ func (r *InterfaceOSPFv3Resource) Read(ctx context.Context, req resource.ReadReq
}
if device.Managed {
- res, err := device.Client.GetData(state.Id.ValueString())
- if res.StatusCode == 404 {
- state = InterfaceOSPFv3{Device: state.Device, Id: state.Id}
+ imp, diags := helpers.IsFlagImporting(ctx, req)
+ if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ return
+ }
+
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(state.Id.ValueString())
+ if res.StatusCode == 404 {
+ state = InterfaceOSPFv3{Device: state.Device, Id: state.Id}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
+ return
+ }
+
+ // After `terraform import` we switch to a full read.
+ if imp {
+ state.fromBody(ctx, res.Res)
+ } else {
+ state.updateFromBody(ctx, res.Res)
+ }
+ }
} else {
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
- return
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
}
- imp, diags := helpers.IsFlagImporting(ctx, req)
- if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ filter := helpers.GetXpathFilter(state.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.getPath(), err))
return
}
// After `terraform import` we switch to a full read.
if imp {
- state.fromBody(ctx, res.Res)
+ state.fromBodyXML(ctx, res.Res)
} else {
- state.updateFromBody(ctx, res.Res)
+ state.updateFromBodyXML(ctx, res.Res)
}
}
}
@@ -293,51 +342,74 @@ func (r *InterfaceOSPFv3Resource) Update(ctx context.Context, req resource.Updat
}
if device.Managed {
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ body := plan.toBody(ctx)
- deletedItems := plan.getDeletedItems(ctx, state)
- tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
+ deletedItems := plan.getDeletedItems(ctx, state)
+ tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- var edits []restconf.YangPatchEdit
- for _, i := range deletedItems {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
- return
+ if YangPatch {
+ var edits []restconf.YangPatchEdit
+ for _, i := range deletedItems {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletedItems {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- for _, i := range deletedItems {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
}
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+
+ body := plan.toBodyXML(ctx)
+ body = plan.addDeletedItemsXML(ctx, state, body)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
return
}
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
- return
- }
- }
}
}
@@ -370,6 +442,18 @@ func (r *InterfaceOSPFv3Resource) Delete(ctx context.Context, req resource.Delet
}
if device.Managed {
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.Protocol == "netconf" && device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
+ }
deleteMode := "all"
if state.DeleteMode.ValueString() == "all" {
deleteMode = "all"
@@ -378,31 +462,52 @@ func (r *InterfaceOSPFv3Resource) Delete(ctx context.Context, req resource.Delet
}
if deleteMode == "all" {
- res, err := device.Client.DeleteData(state.Id.ValueString())
- if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
- return
- }
- } else {
- deletePaths := state.getDeletePaths(ctx)
- tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
-
- if YangPatch {
- edits := []restconf.YangPatchEdit{}
- for _, i := range deletePaths {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.DeleteData(state.Id.ValueString())
+ if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
return
}
} else {
- for _, i := range deletePaths {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // NETCONF
+ body := netconf.Body{}
+ body = helpers.RemoveFromXPath(body, state.getXPath())
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body.Res(), true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
+ }
+ }
+ } else {
+ if device.Protocol == "restconf" {
+ deletePaths := state.getDeletePaths(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
+
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{}
+ for _, i := range deletePaths {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
}
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletePaths {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ }
+ }
+ }
+ } else {
+ // NETCONF
+ body := state.addDeletePathsXML(ctx, "")
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
diff --git a/internal/provider/resource_iosxe_interface_ospfv3_test.go b/internal/provider/resource_iosxe_interface_ospfv3_test.go
index 4738c1a4..90f96f84 100644
--- a/internal/provider/resource_iosxe_interface_ospfv3_test.go
+++ b/internal/provider/resource_iosxe_interface_ospfv3_test.go
@@ -80,8 +80,8 @@ func iosxeInterfaceOSPFv3ImportStateIdFunc(resourceName string) resource.ImportS
// Section below is generated&owned by "gen/generator.go". //template:begin testPrerequisites
const testAccIosxeInterfaceOSPFv3PrerequisitesConfig = `
-resource "iosxe_restconf" "PreReq0" {
- path = "Cisco-IOS-XE-native:native/interface/Loopback=1"
+resource "iosxe_yang" "PreReq0" {
+ path = "/Cisco-IOS-XE-native:native/interface/Loopback[name=1]"
attributes = {
"name" = "1"
}
@@ -97,7 +97,7 @@ func testAccIosxeInterfaceOSPFv3Config_minimum() string {
config := `resource "iosxe_interface_ospfv3" "test" {` + "\n"
config += ` type = "Loopback"` + "\n"
config += ` name = "1"` + "\n"
- config += ` depends_on = [iosxe_restconf.PreReq0, ]` + "\n"
+ config += ` depends_on = [iosxe_yang.PreReq0, ]` + "\n"
config += `}` + "\n"
return config
}
@@ -115,7 +115,7 @@ func testAccIosxeInterfaceOSPFv3Config_all() string {
config += ` network_type_point_to_multipoint = false` + "\n"
config += ` network_type_point_to_point = true` + "\n"
config += ` cost = 1000` + "\n"
- config += ` depends_on = [iosxe_restconf.PreReq0, ]` + "\n"
+ config += ` depends_on = [iosxe_yang.PreReq0, ]` + "\n"
config += `}` + "\n"
return config
}
diff --git a/internal/provider/resource_iosxe_interface_pim.go b/internal/provider/resource_iosxe_interface_pim.go
index 8f045502..c84b1485 100644
--- a/internal/provider/resource_iosxe_interface_pim.go
+++ b/internal/provider/resource_iosxe_interface_pim.go
@@ -37,6 +37,7 @@ import (
"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-netconf"
"github.com/netascode/go-restconf"
)
@@ -169,37 +170,59 @@ func (r *InterfacePIMResource) Create(ctx context.Context, req resource.CreateRe
}
if device.Managed {
- // Create object
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ // Create object
+ body := plan.toBody(ctx)
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
- return
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
+ return
+ }
+ } else {
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
- return
- }
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
+ }
+
+ body := plan.toBodyXML(ctx)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
@@ -237,25 +260,51 @@ func (r *InterfacePIMResource) Read(ctx context.Context, req resource.ReadReques
}
if device.Managed {
- res, err := device.Client.GetData(state.Id.ValueString())
- if res.StatusCode == 404 {
- state = InterfacePIM{Device: state.Device, Id: state.Id}
+ imp, diags := helpers.IsFlagImporting(ctx, req)
+ if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ return
+ }
+
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(state.Id.ValueString())
+ if res.StatusCode == 404 {
+ state = InterfacePIM{Device: state.Device, Id: state.Id}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
+ return
+ }
+
+ // After `terraform import` we switch to a full read.
+ if imp {
+ state.fromBody(ctx, res.Res)
+ } else {
+ state.updateFromBody(ctx, res.Res)
+ }
+ }
} else {
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
- return
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
}
- imp, diags := helpers.IsFlagImporting(ctx, req)
- if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ filter := helpers.GetXpathFilter(state.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.getPath(), err))
return
}
// After `terraform import` we switch to a full read.
if imp {
- state.fromBody(ctx, res.Res)
+ state.fromBodyXML(ctx, res.Res)
} else {
- state.updateFromBody(ctx, res.Res)
+ state.updateFromBodyXML(ctx, res.Res)
}
}
}
@@ -298,51 +347,74 @@ func (r *InterfacePIMResource) Update(ctx context.Context, req resource.UpdateRe
}
if device.Managed {
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ body := plan.toBody(ctx)
- deletedItems := plan.getDeletedItems(ctx, state)
- tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
+ deletedItems := plan.getDeletedItems(ctx, state)
+ tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- var edits []restconf.YangPatchEdit
- for _, i := range deletedItems {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
- return
+ if YangPatch {
+ var edits []restconf.YangPatchEdit
+ for _, i := range deletedItems {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletedItems {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- for _, i := range deletedItems {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
}
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+
+ body := plan.toBodyXML(ctx)
+ body = plan.addDeletedItemsXML(ctx, state, body)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
return
}
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
- return
- }
- }
}
}
@@ -375,34 +447,67 @@ func (r *InterfacePIMResource) Delete(ctx context.Context, req resource.DeleteRe
}
if device.Managed {
- deleteMode := "attributes"
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
- if deleteMode == "all" {
- res, err := device.Client.DeleteData(state.Id.ValueString())
- if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
+ if device.Protocol == "netconf" && device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
- } else {
- deletePaths := state.getDeletePaths(ctx)
- tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
+ defer cleanup()
+ }
+ deleteMode := "attributes"
- if YangPatch {
- edits := []restconf.YangPatchEdit{}
- for _, i := range deletePaths {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ if deleteMode == "all" {
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.DeleteData(state.Id.ValueString())
+ if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
return
}
} else {
- for _, i := range deletePaths {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // NETCONF
+ body := netconf.Body{}
+ body = helpers.RemoveFromXPath(body, state.getXPath())
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body.Res(), true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
+ }
+ }
+ } else {
+ if device.Protocol == "restconf" {
+ deletePaths := state.getDeletePaths(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
+
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{}
+ for _, i := range deletePaths {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
}
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletePaths {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ }
+ }
+ }
+ } else {
+ // NETCONF
+ body := state.addDeletePathsXML(ctx, "")
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
diff --git a/internal/provider/resource_iosxe_interface_pim_test.go b/internal/provider/resource_iosxe_interface_pim_test.go
index 64beb576..e59b70e9 100644
--- a/internal/provider/resource_iosxe_interface_pim_test.go
+++ b/internal/provider/resource_iosxe_interface_pim_test.go
@@ -83,8 +83,8 @@ func iosxeInterfacePIMImportStateIdFunc(resourceName string) resource.ImportStat
// Section below is generated&owned by "gen/generator.go". //template:begin testPrerequisites
const testAccIosxeInterfacePIMPrerequisitesConfig = `
-resource "iosxe_restconf" "PreReq0" {
- path = "Cisco-IOS-XE-native:native/interface/Loopback=100"
+resource "iosxe_yang" "PreReq0" {
+ path = "/Cisco-IOS-XE-native:native/interface/Loopback[name=100]"
attributes = {
"name" = "100"
}
@@ -100,7 +100,7 @@ func testAccIosxeInterfacePIMConfig_minimum() string {
config := `resource "iosxe_interface_pim" "test" {` + "\n"
config += ` type = "Loopback"` + "\n"
config += ` name = "100"` + "\n"
- config += ` depends_on = [iosxe_restconf.PreReq0, ]` + "\n"
+ config += ` depends_on = [iosxe_yang.PreReq0, ]` + "\n"
config += `}` + "\n"
return config
}
@@ -121,7 +121,7 @@ func testAccIosxeInterfacePIMConfig_all() string {
config += ` border = false` + "\n"
config += ` bsr_border = false` + "\n"
config += ` dr_priority = 10` + "\n"
- config += ` depends_on = [iosxe_restconf.PreReq0, ]` + "\n"
+ config += ` depends_on = [iosxe_yang.PreReq0, ]` + "\n"
config += `}` + "\n"
return config
}
diff --git a/internal/provider/resource_iosxe_interface_port_channel.go b/internal/provider/resource_iosxe_interface_port_channel.go
index 219993c1..7940f1f5 100644
--- a/internal/provider/resource_iosxe_interface_port_channel.go
+++ b/internal/provider/resource_iosxe_interface_port_channel.go
@@ -39,6 +39,7 @@ import (
"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-netconf"
"github.com/netascode/go-restconf"
)
@@ -448,37 +449,59 @@ func (r *InterfacePortChannelResource) Create(ctx context.Context, req resource.
}
if device.Managed {
- // Create object
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ // Create object
+ body := plan.toBody(ctx)
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
- return
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
+ return
+ }
+ } else {
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
- return
- }
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
+ }
+
+ body := plan.toBodyXML(ctx)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
@@ -516,25 +539,51 @@ func (r *InterfacePortChannelResource) Read(ctx context.Context, req resource.Re
}
if device.Managed {
- res, err := device.Client.GetData(state.Id.ValueString())
- if res.StatusCode == 404 {
- state = InterfacePortChannel{Device: state.Device, Id: state.Id}
+ imp, diags := helpers.IsFlagImporting(ctx, req)
+ if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ return
+ }
+
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(state.Id.ValueString())
+ if res.StatusCode == 404 {
+ state = InterfacePortChannel{Device: state.Device, Id: state.Id}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
+ return
+ }
+
+ // After `terraform import` we switch to a full read.
+ if imp {
+ state.fromBody(ctx, res.Res)
+ } else {
+ state.updateFromBody(ctx, res.Res)
+ }
+ }
} else {
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
- return
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
}
- imp, diags := helpers.IsFlagImporting(ctx, req)
- if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ filter := helpers.GetXpathFilter(state.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.getPath(), err))
return
}
// After `terraform import` we switch to a full read.
if imp {
- state.fromBody(ctx, res.Res)
+ state.fromBodyXML(ctx, res.Res)
} else {
- state.updateFromBody(ctx, res.Res)
+ state.updateFromBodyXML(ctx, res.Res)
}
}
}
@@ -577,51 +626,74 @@ func (r *InterfacePortChannelResource) Update(ctx context.Context, req resource.
}
if device.Managed {
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ body := plan.toBody(ctx)
- deletedItems := plan.getDeletedItems(ctx, state)
- tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
+ deletedItems := plan.getDeletedItems(ctx, state)
+ tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- var edits []restconf.YangPatchEdit
- for _, i := range deletedItems {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
- return
+ if YangPatch {
+ var edits []restconf.YangPatchEdit
+ for _, i := range deletedItems {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletedItems {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- for _, i := range deletedItems {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
}
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+
+ body := plan.toBodyXML(ctx)
+ body = plan.addDeletedItemsXML(ctx, state, body)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
return
}
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
- return
- }
- }
}
}
@@ -654,6 +726,18 @@ func (r *InterfacePortChannelResource) Delete(ctx context.Context, req resource.
}
if device.Managed {
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.Protocol == "netconf" && device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
+ }
deleteMode := "all"
if state.DeleteMode.ValueString() == "all" {
deleteMode = "all"
@@ -662,31 +746,52 @@ func (r *InterfacePortChannelResource) Delete(ctx context.Context, req resource.
}
if deleteMode == "all" {
- res, err := device.Client.DeleteData(state.Id.ValueString())
- if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
- return
- }
- } else {
- deletePaths := state.getDeletePaths(ctx)
- tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
-
- if YangPatch {
- edits := []restconf.YangPatchEdit{}
- for _, i := range deletePaths {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.DeleteData(state.Id.ValueString())
+ if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
return
}
} else {
- for _, i := range deletePaths {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // NETCONF
+ body := netconf.Body{}
+ body = helpers.RemoveFromXPath(body, state.getXPath())
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body.Res(), true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
+ }
+ }
+ } else {
+ if device.Protocol == "restconf" {
+ deletePaths := state.getDeletePaths(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
+
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{}
+ for _, i := range deletePaths {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
}
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletePaths {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ }
+ }
+ }
+ } else {
+ // NETCONF
+ body := state.addDeletePathsXML(ctx, "")
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
diff --git a/internal/provider/resource_iosxe_interface_port_channel_subinterface.go b/internal/provider/resource_iosxe_interface_port_channel_subinterface.go
index b84c4ea3..092c424e 100644
--- a/internal/provider/resource_iosxe_interface_port_channel_subinterface.go
+++ b/internal/provider/resource_iosxe_interface_port_channel_subinterface.go
@@ -37,6 +37,7 @@ import (
"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-netconf"
"github.com/netascode/go-restconf"
)
@@ -392,37 +393,59 @@ func (r *InterfacePortChannelSubinterfaceResource) Create(ctx context.Context, r
}
if device.Managed {
- // Create object
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ // Create object
+ body := plan.toBody(ctx)
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
- return
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
+ return
+ }
+ } else {
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
- return
- }
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
+ }
+
+ body := plan.toBodyXML(ctx)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
@@ -460,25 +483,51 @@ func (r *InterfacePortChannelSubinterfaceResource) Read(ctx context.Context, req
}
if device.Managed {
- res, err := device.Client.GetData(state.Id.ValueString())
- if res.StatusCode == 404 {
- state = InterfacePortChannelSubinterface{Device: state.Device, Id: state.Id}
+ imp, diags := helpers.IsFlagImporting(ctx, req)
+ if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ return
+ }
+
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(state.Id.ValueString())
+ if res.StatusCode == 404 {
+ state = InterfacePortChannelSubinterface{Device: state.Device, Id: state.Id}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
+ return
+ }
+
+ // After `terraform import` we switch to a full read.
+ if imp {
+ state.fromBody(ctx, res.Res)
+ } else {
+ state.updateFromBody(ctx, res.Res)
+ }
+ }
} else {
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
- return
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
}
- imp, diags := helpers.IsFlagImporting(ctx, req)
- if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ filter := helpers.GetXpathFilter(state.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.getPath(), err))
return
}
// After `terraform import` we switch to a full read.
if imp {
- state.fromBody(ctx, res.Res)
+ state.fromBodyXML(ctx, res.Res)
} else {
- state.updateFromBody(ctx, res.Res)
+ state.updateFromBodyXML(ctx, res.Res)
}
}
}
@@ -521,51 +570,74 @@ func (r *InterfacePortChannelSubinterfaceResource) Update(ctx context.Context, r
}
if device.Managed {
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ body := plan.toBody(ctx)
- deletedItems := plan.getDeletedItems(ctx, state)
- tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
+ deletedItems := plan.getDeletedItems(ctx, state)
+ tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- var edits []restconf.YangPatchEdit
- for _, i := range deletedItems {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
- return
+ if YangPatch {
+ var edits []restconf.YangPatchEdit
+ for _, i := range deletedItems {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletedItems {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- for _, i := range deletedItems {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
}
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+
+ body := plan.toBodyXML(ctx)
+ body = plan.addDeletedItemsXML(ctx, state, body)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
return
}
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
- return
- }
- }
}
}
@@ -598,6 +670,18 @@ func (r *InterfacePortChannelSubinterfaceResource) Delete(ctx context.Context, r
}
if device.Managed {
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.Protocol == "netconf" && device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
+ }
deleteMode := "all"
if state.DeleteMode.ValueString() == "all" {
deleteMode = "all"
@@ -606,31 +690,52 @@ func (r *InterfacePortChannelSubinterfaceResource) Delete(ctx context.Context, r
}
if deleteMode == "all" {
- res, err := device.Client.DeleteData(state.Id.ValueString())
- if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
- return
- }
- } else {
- deletePaths := state.getDeletePaths(ctx)
- tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
-
- if YangPatch {
- edits := []restconf.YangPatchEdit{}
- for _, i := range deletePaths {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.DeleteData(state.Id.ValueString())
+ if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
return
}
} else {
- for _, i := range deletePaths {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // NETCONF
+ body := netconf.Body{}
+ body = helpers.RemoveFromXPath(body, state.getXPath())
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body.Res(), true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
+ }
+ }
+ } else {
+ if device.Protocol == "restconf" {
+ deletePaths := state.getDeletePaths(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
+
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{}
+ for _, i := range deletePaths {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
}
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletePaths {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ }
+ }
+ }
+ } else {
+ // NETCONF
+ body := state.addDeletePathsXML(ctx, "")
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
diff --git a/internal/provider/resource_iosxe_interface_port_channel_subinterface_test.go b/internal/provider/resource_iosxe_interface_port_channel_subinterface_test.go
index caccad50..d85e9835 100644
--- a/internal/provider/resource_iosxe_interface_port_channel_subinterface_test.go
+++ b/internal/provider/resource_iosxe_interface_port_channel_subinterface_test.go
@@ -112,8 +112,8 @@ func iosxeInterfacePortChannelSubinterfaceImportStateIdFunc(resourceName string)
// Section below is generated&owned by "gen/generator.go". //template:begin testPrerequisites
const testAccIosxeInterfacePortChannelSubinterfacePrerequisitesConfig = `
-resource "iosxe_restconf" "PreReq0" {
- path = "Cisco-IOS-XE-native:native/vrf/definition=VRF1"
+resource "iosxe_yang" "PreReq0" {
+ path = "/Cisco-IOS-XE-native:native/vrf/definition[name=VRF1]"
delete = false
attributes = {
"name" = "VRF1"
@@ -121,19 +121,19 @@ resource "iosxe_restconf" "PreReq0" {
}
}
-resource "iosxe_restconf" "PreReq1" {
- path = "Cisco-IOS-XE-native:native/interface/Port-channel=10"
+resource "iosxe_yang" "PreReq1" {
+ path = "/Cisco-IOS-XE-native:native/interface/Port-channel[name=10]"
attributes = {
"name" = "10"
}
}
-resource "iosxe_restconf" "PreReq2" {
- path = "Cisco-IOS-XE-native:native/interface/Port-channel-subinterface/Port-channel=10.666"
+resource "iosxe_yang" "PreReq2" {
+ path = "/Cisco-IOS-XE-native:native/interface/Port-channel-subinterface/Port-channel[name=10.666]"
attributes = {
"name" = "10.666"
}
- depends_on = [iosxe_restconf.PreReq1, ]
+ depends_on = [iosxe_yang.PreReq1, ]
}
`
@@ -145,7 +145,7 @@ resource "iosxe_restconf" "PreReq2" {
func testAccIosxeInterfacePortChannelSubinterfaceConfig_minimum() string {
config := `resource "iosxe_interface_port_channel_subinterface" "test" {` + "\n"
config += ` name = "10.666"` + "\n"
- config += ` depends_on = [iosxe_restconf.PreReq0, iosxe_restconf.PreReq1, iosxe_restconf.PreReq2, ]` + "\n"
+ config += ` depends_on = [iosxe_yang.PreReq0, iosxe_yang.PreReq1, iosxe_yang.PreReq2, ]` + "\n"
config += `}` + "\n"
return config
}
@@ -196,7 +196,7 @@ func testAccIosxeInterfacePortChannelSubinterfaceConfig_all() string {
if os.Getenv("C9000V") != "" {
config += ` ip_arp_inspection_limit_rate = 1000` + "\n"
}
- config += ` depends_on = [iosxe_restconf.PreReq0, iosxe_restconf.PreReq1, iosxe_restconf.PreReq2, ]` + "\n"
+ config += ` depends_on = [iosxe_yang.PreReq0, iosxe_yang.PreReq1, iosxe_yang.PreReq2, ]` + "\n"
config += `}` + "\n"
return config
}
diff --git a/internal/provider/resource_iosxe_interface_port_channel_test.go b/internal/provider/resource_iosxe_interface_port_channel_test.go
index 7ad4fabc..6613cd16 100644
--- a/internal/provider/resource_iosxe_interface_port_channel_test.go
+++ b/internal/provider/resource_iosxe_interface_port_channel_test.go
@@ -121,8 +121,8 @@ func iosxeInterfacePortChannelImportStateIdFunc(resourceName string) resource.Im
// Section below is generated&owned by "gen/generator.go". //template:begin testPrerequisites
const testAccIosxeInterfacePortChannelPrerequisitesConfig = `
-resource "iosxe_restconf" "PreReq0" {
- path = "Cisco-IOS-XE-native:native/vrf/definition=VRF1"
+resource "iosxe_yang" "PreReq0" {
+ path = "/Cisco-IOS-XE-native:native/vrf/definition[name=VRF1]"
delete = false
attributes = {
"name" = "VRF1"
@@ -139,7 +139,7 @@ resource "iosxe_restconf" "PreReq0" {
func testAccIosxeInterfacePortChannelConfig_minimum() string {
config := `resource "iosxe_interface_port_channel" "test" {` + "\n"
config += ` name = 10` + "\n"
- config += ` depends_on = [iosxe_restconf.PreReq0, ]` + "\n"
+ config += ` depends_on = [iosxe_yang.PreReq0, ]` + "\n"
config += `}` + "\n"
return config
}
@@ -202,7 +202,7 @@ func testAccIosxeInterfacePortChannelConfig_all() string {
config += ` load_interval = 30` + "\n"
config += ` snmp_trap_link_status = true` + "\n"
config += ` logging_event_link_status_enable = false` + "\n"
- config += ` depends_on = [iosxe_restconf.PreReq0, ]` + "\n"
+ config += ` depends_on = [iosxe_yang.PreReq0, ]` + "\n"
config += `}` + "\n"
return config
}
diff --git a/internal/provider/resource_iosxe_interface_switchport.go b/internal/provider/resource_iosxe_interface_switchport.go
index 30b15c5d..0d457e21 100644
--- a/internal/provider/resource_iosxe_interface_switchport.go
+++ b/internal/provider/resource_iosxe_interface_switchport.go
@@ -37,6 +37,7 @@ import (
"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-netconf"
"github.com/netascode/go-restconf"
)
@@ -196,37 +197,59 @@ func (r *InterfaceSwitchportResource) Create(ctx context.Context, req resource.C
}
if device.Managed {
- // Create object
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ // Create object
+ body := plan.toBody(ctx)
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
- return
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
+ return
+ }
+ } else {
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
- return
- }
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
+ }
+
+ body := plan.toBodyXML(ctx)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
@@ -264,25 +287,51 @@ func (r *InterfaceSwitchportResource) Read(ctx context.Context, req resource.Rea
}
if device.Managed {
- res, err := device.Client.GetData(state.Id.ValueString())
- if res.StatusCode == 404 {
- state = InterfaceSwitchport{Device: state.Device, Id: state.Id}
+ imp, diags := helpers.IsFlagImporting(ctx, req)
+ if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ return
+ }
+
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(state.Id.ValueString())
+ if res.StatusCode == 404 {
+ state = InterfaceSwitchport{Device: state.Device, Id: state.Id}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
+ return
+ }
+
+ // After `terraform import` we switch to a full read.
+ if imp {
+ state.fromBody(ctx, res.Res)
+ } else {
+ state.updateFromBody(ctx, res.Res)
+ }
+ }
} else {
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
- return
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
}
- imp, diags := helpers.IsFlagImporting(ctx, req)
- if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ filter := helpers.GetXpathFilter(state.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.getPath(), err))
return
}
// After `terraform import` we switch to a full read.
if imp {
- state.fromBody(ctx, res.Res)
+ state.fromBodyXML(ctx, res.Res)
} else {
- state.updateFromBody(ctx, res.Res)
+ state.updateFromBodyXML(ctx, res.Res)
}
}
}
@@ -325,51 +374,74 @@ func (r *InterfaceSwitchportResource) Update(ctx context.Context, req resource.U
}
if device.Managed {
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ body := plan.toBody(ctx)
- deletedItems := plan.getDeletedItems(ctx, state)
- tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
+ deletedItems := plan.getDeletedItems(ctx, state)
+ tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- var edits []restconf.YangPatchEdit
- for _, i := range deletedItems {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
- return
+ if YangPatch {
+ var edits []restconf.YangPatchEdit
+ for _, i := range deletedItems {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletedItems {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- for _, i := range deletedItems {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
}
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+
+ body := plan.toBodyXML(ctx)
+ body = plan.addDeletedItemsXML(ctx, state, body)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
return
}
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
- return
- }
- }
}
}
@@ -402,6 +474,18 @@ func (r *InterfaceSwitchportResource) Delete(ctx context.Context, req resource.D
}
if device.Managed {
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.Protocol == "netconf" && device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
+ }
deleteMode := "all"
if state.DeleteMode.ValueString() == "all" {
deleteMode = "all"
@@ -410,31 +494,52 @@ func (r *InterfaceSwitchportResource) Delete(ctx context.Context, req resource.D
}
if deleteMode == "all" {
- res, err := device.Client.DeleteData(state.Id.ValueString())
- if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
- return
- }
- } else {
- deletePaths := state.getDeletePaths(ctx)
- tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
-
- if YangPatch {
- edits := []restconf.YangPatchEdit{}
- for _, i := range deletePaths {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.DeleteData(state.Id.ValueString())
+ if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
return
}
} else {
- for _, i := range deletePaths {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // NETCONF
+ body := netconf.Body{}
+ body = helpers.RemoveFromXPath(body, state.getXPath())
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body.Res(), true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
+ }
+ }
+ } else {
+ if device.Protocol == "restconf" {
+ deletePaths := state.getDeletePaths(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
+
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{}
+ for _, i := range deletePaths {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
}
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletePaths {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ }
+ }
+ }
+ } else {
+ // NETCONF
+ body := state.addDeletePathsXML(ctx, "")
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
diff --git a/internal/provider/resource_iosxe_interface_tunnel.go b/internal/provider/resource_iosxe_interface_tunnel.go
index 78e36031..be6e695c 100644
--- a/internal/provider/resource_iosxe_interface_tunnel.go
+++ b/internal/provider/resource_iosxe_interface_tunnel.go
@@ -39,6 +39,7 @@ import (
"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-netconf"
"github.com/netascode/go-restconf"
)
@@ -381,37 +382,59 @@ func (r *InterfaceTunnelResource) Create(ctx context.Context, req resource.Creat
}
if device.Managed {
- // Create object
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ // Create object
+ body := plan.toBody(ctx)
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
- return
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
+ return
+ }
+ } else {
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
- return
- }
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
+ }
+
+ body := plan.toBodyXML(ctx)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
@@ -449,25 +472,51 @@ func (r *InterfaceTunnelResource) Read(ctx context.Context, req resource.ReadReq
}
if device.Managed {
- res, err := device.Client.GetData(state.Id.ValueString())
- if res.StatusCode == 404 {
- state = InterfaceTunnel{Device: state.Device, Id: state.Id}
+ imp, diags := helpers.IsFlagImporting(ctx, req)
+ if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ return
+ }
+
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(state.Id.ValueString())
+ if res.StatusCode == 404 {
+ state = InterfaceTunnel{Device: state.Device, Id: state.Id}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
+ return
+ }
+
+ // After `terraform import` we switch to a full read.
+ if imp {
+ state.fromBody(ctx, res.Res)
+ } else {
+ state.updateFromBody(ctx, res.Res)
+ }
+ }
} else {
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
- return
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
}
- imp, diags := helpers.IsFlagImporting(ctx, req)
- if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ filter := helpers.GetXpathFilter(state.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.getPath(), err))
return
}
// After `terraform import` we switch to a full read.
if imp {
- state.fromBody(ctx, res.Res)
+ state.fromBodyXML(ctx, res.Res)
} else {
- state.updateFromBody(ctx, res.Res)
+ state.updateFromBodyXML(ctx, res.Res)
}
}
}
@@ -510,51 +559,74 @@ func (r *InterfaceTunnelResource) Update(ctx context.Context, req resource.Updat
}
if device.Managed {
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ body := plan.toBody(ctx)
- deletedItems := plan.getDeletedItems(ctx, state)
- tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
+ deletedItems := plan.getDeletedItems(ctx, state)
+ tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- var edits []restconf.YangPatchEdit
- for _, i := range deletedItems {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
- return
+ if YangPatch {
+ var edits []restconf.YangPatchEdit
+ for _, i := range deletedItems {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletedItems {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- for _, i := range deletedItems {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
}
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+
+ body := plan.toBodyXML(ctx)
+ body = plan.addDeletedItemsXML(ctx, state, body)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
return
}
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
- return
- }
- }
}
}
@@ -587,6 +659,18 @@ func (r *InterfaceTunnelResource) Delete(ctx context.Context, req resource.Delet
}
if device.Managed {
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.Protocol == "netconf" && device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
+ }
deleteMode := "all"
if state.DeleteMode.ValueString() == "all" {
deleteMode = "all"
@@ -595,31 +679,52 @@ func (r *InterfaceTunnelResource) Delete(ctx context.Context, req resource.Delet
}
if deleteMode == "all" {
- res, err := device.Client.DeleteData(state.Id.ValueString())
- if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
- return
- }
- } else {
- deletePaths := state.getDeletePaths(ctx)
- tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
-
- if YangPatch {
- edits := []restconf.YangPatchEdit{}
- for _, i := range deletePaths {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.DeleteData(state.Id.ValueString())
+ if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
return
}
} else {
- for _, i := range deletePaths {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // NETCONF
+ body := netconf.Body{}
+ body = helpers.RemoveFromXPath(body, state.getXPath())
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body.Res(), true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
+ }
+ }
+ } else {
+ if device.Protocol == "restconf" {
+ deletePaths := state.getDeletePaths(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
+
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{}
+ for _, i := range deletePaths {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
}
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletePaths {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ }
+ }
+ }
+ } else {
+ // NETCONF
+ body := state.addDeletePathsXML(ctx, "")
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
diff --git a/internal/provider/resource_iosxe_interface_tunnel_test.go b/internal/provider/resource_iosxe_interface_tunnel_test.go
index 94343016..524c153a 100644
--- a/internal/provider/resource_iosxe_interface_tunnel_test.go
+++ b/internal/provider/resource_iosxe_interface_tunnel_test.go
@@ -116,8 +116,8 @@ func iosxeInterfaceTunnelImportStateIdFunc(resourceName string) resource.ImportS
// Section below is generated&owned by "gen/generator.go". //template:begin testPrerequisites
const testAccIosxeInterfaceTunnelPrerequisitesConfig = `
-resource "iosxe_restconf" "PreReq0" {
- path = "Cisco-IOS-XE-native:native/vrf/definition=VRF1"
+resource "iosxe_yang" "PreReq0" {
+ path = "/Cisco-IOS-XE-native:native/vrf/definition[name=VRF1]"
delete = false
attributes = {
"name" = "VRF1"
@@ -135,7 +135,7 @@ resource "iosxe_restconf" "PreReq0" {
func testAccIosxeInterfaceTunnelConfig_minimum() string {
config := `resource "iosxe_interface_tunnel" "test" {` + "\n"
config += ` name = 90` + "\n"
- config += ` depends_on = [iosxe_restconf.PreReq0, ]` + "\n"
+ config += ` depends_on = [iosxe_yang.PreReq0, ]` + "\n"
config += `}` + "\n"
return config
}
@@ -193,7 +193,7 @@ func testAccIosxeInterfaceTunnelConfig_all() string {
config += ` snmp_trap_link_status = false` + "\n"
config += ` logging_event_link_status_enable = true` + "\n"
config += ` tunnel_vrf = "VRF1"` + "\n"
- config += ` depends_on = [iosxe_restconf.PreReq0, ]` + "\n"
+ config += ` depends_on = [iosxe_yang.PreReq0, ]` + "\n"
config += `}` + "\n"
return config
}
diff --git a/internal/provider/resource_iosxe_interface_vlan.go b/internal/provider/resource_iosxe_interface_vlan.go
index 1b4a02f1..c2921707 100644
--- a/internal/provider/resource_iosxe_interface_vlan.go
+++ b/internal/provider/resource_iosxe_interface_vlan.go
@@ -39,6 +39,7 @@ import (
"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-netconf"
"github.com/netascode/go-restconf"
)
@@ -337,37 +338,59 @@ func (r *InterfaceVLANResource) Create(ctx context.Context, req resource.CreateR
}
if device.Managed {
- // Create object
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ // Create object
+ body := plan.toBody(ctx)
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
- return
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
+ return
+ }
+ } else {
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
- return
- }
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
+ }
+
+ body := plan.toBodyXML(ctx)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
@@ -405,25 +428,51 @@ func (r *InterfaceVLANResource) Read(ctx context.Context, req resource.ReadReque
}
if device.Managed {
- res, err := device.Client.GetData(state.Id.ValueString())
- if res.StatusCode == 404 {
- state = InterfaceVLAN{Device: state.Device, Id: state.Id}
+ imp, diags := helpers.IsFlagImporting(ctx, req)
+ if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ return
+ }
+
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(state.Id.ValueString())
+ if res.StatusCode == 404 {
+ state = InterfaceVLAN{Device: state.Device, Id: state.Id}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
+ return
+ }
+
+ // After `terraform import` we switch to a full read.
+ if imp {
+ state.fromBody(ctx, res.Res)
+ } else {
+ state.updateFromBody(ctx, res.Res)
+ }
+ }
} else {
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
- return
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
}
- imp, diags := helpers.IsFlagImporting(ctx, req)
- if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ filter := helpers.GetXpathFilter(state.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.getPath(), err))
return
}
// After `terraform import` we switch to a full read.
if imp {
- state.fromBody(ctx, res.Res)
+ state.fromBodyXML(ctx, res.Res)
} else {
- state.updateFromBody(ctx, res.Res)
+ state.updateFromBodyXML(ctx, res.Res)
}
}
}
@@ -466,51 +515,74 @@ func (r *InterfaceVLANResource) Update(ctx context.Context, req resource.UpdateR
}
if device.Managed {
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ body := plan.toBody(ctx)
- deletedItems := plan.getDeletedItems(ctx, state)
- tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
+ deletedItems := plan.getDeletedItems(ctx, state)
+ tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- var edits []restconf.YangPatchEdit
- for _, i := range deletedItems {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
- return
+ if YangPatch {
+ var edits []restconf.YangPatchEdit
+ for _, i := range deletedItems {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletedItems {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- for _, i := range deletedItems {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
}
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+
+ body := plan.toBodyXML(ctx)
+ body = plan.addDeletedItemsXML(ctx, state, body)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
return
}
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
- return
- }
- }
}
}
@@ -543,6 +615,18 @@ func (r *InterfaceVLANResource) Delete(ctx context.Context, req resource.DeleteR
}
if device.Managed {
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.Protocol == "netconf" && device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
+ }
deleteMode := "all"
if state.DeleteMode.ValueString() == "all" {
deleteMode = "all"
@@ -551,31 +635,52 @@ func (r *InterfaceVLANResource) Delete(ctx context.Context, req resource.DeleteR
}
if deleteMode == "all" {
- res, err := device.Client.DeleteData(state.Id.ValueString())
- if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
- return
- }
- } else {
- deletePaths := state.getDeletePaths(ctx)
- tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
-
- if YangPatch {
- edits := []restconf.YangPatchEdit{}
- for _, i := range deletePaths {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.DeleteData(state.Id.ValueString())
+ if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
return
}
} else {
- for _, i := range deletePaths {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // NETCONF
+ body := netconf.Body{}
+ body = helpers.RemoveFromXPath(body, state.getXPath())
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body.Res(), true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
+ }
+ }
+ } else {
+ if device.Protocol == "restconf" {
+ deletePaths := state.getDeletePaths(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
+
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{}
+ for _, i := range deletePaths {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
}
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletePaths {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ }
+ }
+ }
+ } else {
+ // NETCONF
+ body := state.addDeletePathsXML(ctx, "")
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
diff --git a/internal/provider/resource_iosxe_interface_vlan_test.go b/internal/provider/resource_iosxe_interface_vlan_test.go
index 241a4548..06d9ffa1 100644
--- a/internal/provider/resource_iosxe_interface_vlan_test.go
+++ b/internal/provider/resource_iosxe_interface_vlan_test.go
@@ -109,8 +109,8 @@ func iosxeInterfaceVLANImportStateIdFunc(resourceName string) resource.ImportSta
// Section below is generated&owned by "gen/generator.go". //template:begin testPrerequisites
const testAccIosxeInterfaceVLANPrerequisitesConfig = `
-resource "iosxe_restconf" "PreReq0" {
- path = "Cisco-IOS-XE-native:native/vrf/definition=VRF1"
+resource "iosxe_yang" "PreReq0" {
+ path = "/Cisco-IOS-XE-native:native/vrf/definition[name=VRF1]"
delete = false
attributes = {
"name" = "VRF1"
@@ -128,7 +128,7 @@ resource "iosxe_restconf" "PreReq0" {
func testAccIosxeInterfaceVLANConfig_minimum() string {
config := `resource "iosxe_interface_vlan" "test" {` + "\n"
config += ` name = 10` + "\n"
- config += ` depends_on = [iosxe_restconf.PreReq0, ]` + "\n"
+ config += ` depends_on = [iosxe_yang.PreReq0, ]` + "\n"
config += `}` + "\n"
return config
}
@@ -176,7 +176,7 @@ func testAccIosxeInterfaceVLANConfig_all() string {
config += ` }]` + "\n"
config += ` load_interval = 30` + "\n"
config += ` mac_address = "0000.dead.beef"` + "\n"
- config += ` depends_on = [iosxe_restconf.PreReq0, ]` + "\n"
+ config += ` depends_on = [iosxe_yang.PreReq0, ]` + "\n"
config += `}` + "\n"
return config
}
diff --git a/internal/provider/resource_iosxe_license.go b/internal/provider/resource_iosxe_license.go
index 0d83bdd7..ecdeb783 100644
--- a/internal/provider/resource_iosxe_license.go
+++ b/internal/provider/resource_iosxe_license.go
@@ -36,6 +36,7 @@ import (
"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-netconf"
"github.com/netascode/go-restconf"
)
@@ -202,37 +203,59 @@ func (r *LicenseResource) Create(ctx context.Context, req resource.CreateRequest
}
if device.Managed {
- // Create object
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ // Create object
+ body := plan.toBody(ctx)
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
- return
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
+ return
+ }
+ } else {
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
- return
- }
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
+ }
+
+ body := plan.toBodyXML(ctx)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
@@ -270,25 +293,51 @@ func (r *LicenseResource) Read(ctx context.Context, req resource.ReadRequest, re
}
if device.Managed {
- res, err := device.Client.GetData(state.Id.ValueString())
- if res.StatusCode == 404 {
- state = License{Device: state.Device, Id: state.Id}
+ imp, diags := helpers.IsFlagImporting(ctx, req)
+ if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ return
+ }
+
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(state.Id.ValueString())
+ if res.StatusCode == 404 {
+ state = License{Device: state.Device, Id: state.Id}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
+ return
+ }
+
+ // After `terraform import` we switch to a full read.
+ if imp {
+ state.fromBody(ctx, res.Res)
+ } else {
+ state.updateFromBody(ctx, res.Res)
+ }
+ }
} else {
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
- return
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
}
- imp, diags := helpers.IsFlagImporting(ctx, req)
- if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ filter := helpers.GetXpathFilter(state.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.getPath(), err))
return
}
// After `terraform import` we switch to a full read.
if imp {
- state.fromBody(ctx, res.Res)
+ state.fromBodyXML(ctx, res.Res)
} else {
- state.updateFromBody(ctx, res.Res)
+ state.updateFromBodyXML(ctx, res.Res)
}
}
}
@@ -331,51 +380,74 @@ func (r *LicenseResource) Update(ctx context.Context, req resource.UpdateRequest
}
if device.Managed {
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ body := plan.toBody(ctx)
- deletedItems := plan.getDeletedItems(ctx, state)
- tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
+ deletedItems := plan.getDeletedItems(ctx, state)
+ tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- var edits []restconf.YangPatchEdit
- for _, i := range deletedItems {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
- return
+ if YangPatch {
+ var edits []restconf.YangPatchEdit
+ for _, i := range deletedItems {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletedItems {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- for _, i := range deletedItems {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
}
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+
+ body := plan.toBodyXML(ctx)
+ body = plan.addDeletedItemsXML(ctx, state, body)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
return
}
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
- return
- }
- }
}
}
@@ -408,6 +480,18 @@ func (r *LicenseResource) Delete(ctx context.Context, req resource.DeleteRequest
}
if device.Managed {
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.Protocol == "netconf" && device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
+ }
deleteMode := "all"
if state.DeleteMode.ValueString() == "all" {
deleteMode = "all"
@@ -416,31 +500,52 @@ func (r *LicenseResource) Delete(ctx context.Context, req resource.DeleteRequest
}
if deleteMode == "all" {
- res, err := device.Client.DeleteData(state.Id.ValueString())
- if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
- return
- }
- } else {
- deletePaths := state.getDeletePaths(ctx)
- tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
-
- if YangPatch {
- edits := []restconf.YangPatchEdit{}
- for _, i := range deletePaths {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.DeleteData(state.Id.ValueString())
+ if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
return
}
} else {
- for _, i := range deletePaths {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // NETCONF
+ body := netconf.Body{}
+ body = helpers.RemoveFromXPath(body, state.getXPath())
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body.Res(), true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
+ }
+ }
+ } else {
+ if device.Protocol == "restconf" {
+ deletePaths := state.getDeletePaths(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
+
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{}
+ for _, i := range deletePaths {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
}
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletePaths {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ }
+ }
+ }
+ } else {
+ // NETCONF
+ body := state.addDeletePathsXML(ctx, "")
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
diff --git a/internal/provider/resource_iosxe_line.go b/internal/provider/resource_iosxe_line.go
index b0f2f21f..4f1d32a3 100644
--- a/internal/provider/resource_iosxe_line.go
+++ b/internal/provider/resource_iosxe_line.go
@@ -37,6 +37,7 @@ import (
"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-netconf"
"github.com/netascode/go-restconf"
)
@@ -412,37 +413,59 @@ func (r *LineResource) Create(ctx context.Context, req resource.CreateRequest, r
}
if device.Managed {
- // Create object
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ // Create object
+ body := plan.toBody(ctx)
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
- return
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
+ return
+ }
+ } else {
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
- return
- }
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
+ }
+
+ body := plan.toBodyXML(ctx)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
@@ -480,25 +503,51 @@ func (r *LineResource) Read(ctx context.Context, req resource.ReadRequest, resp
}
if device.Managed {
- res, err := device.Client.GetData(state.Id.ValueString())
- if res.StatusCode == 404 {
- state = Line{Device: state.Device, Id: state.Id}
+ imp, diags := helpers.IsFlagImporting(ctx, req)
+ if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ return
+ }
+
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(state.Id.ValueString())
+ if res.StatusCode == 404 {
+ state = Line{Device: state.Device, Id: state.Id}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
+ return
+ }
+
+ // After `terraform import` we switch to a full read.
+ if imp {
+ state.fromBody(ctx, res.Res)
+ } else {
+ state.updateFromBody(ctx, res.Res)
+ }
+ }
} else {
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
- return
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
}
- imp, diags := helpers.IsFlagImporting(ctx, req)
- if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ filter := helpers.GetXpathFilter(state.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.getPath(), err))
return
}
// After `terraform import` we switch to a full read.
if imp {
- state.fromBody(ctx, res.Res)
+ state.fromBodyXML(ctx, res.Res)
} else {
- state.updateFromBody(ctx, res.Res)
+ state.updateFromBodyXML(ctx, res.Res)
}
}
}
@@ -541,51 +590,74 @@ func (r *LineResource) Update(ctx context.Context, req resource.UpdateRequest, r
}
if device.Managed {
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ body := plan.toBody(ctx)
- deletedItems := plan.getDeletedItems(ctx, state)
- tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
+ deletedItems := plan.getDeletedItems(ctx, state)
+ tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- var edits []restconf.YangPatchEdit
- for _, i := range deletedItems {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
- return
+ if YangPatch {
+ var edits []restconf.YangPatchEdit
+ for _, i := range deletedItems {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletedItems {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- for _, i := range deletedItems {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
}
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+
+ body := plan.toBodyXML(ctx)
+ body = plan.addDeletedItemsXML(ctx, state, body)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
return
}
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
- return
- }
- }
}
}
@@ -618,6 +690,18 @@ func (r *LineResource) Delete(ctx context.Context, req resource.DeleteRequest, r
}
if device.Managed {
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.Protocol == "netconf" && device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
+ }
deleteMode := "all"
if state.DeleteMode.ValueString() == "all" {
deleteMode = "all"
@@ -626,31 +710,52 @@ func (r *LineResource) Delete(ctx context.Context, req resource.DeleteRequest, r
}
if deleteMode == "all" {
- res, err := device.Client.DeleteData(state.Id.ValueString())
- if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
- return
- }
- } else {
- deletePaths := state.getDeletePaths(ctx)
- tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
-
- if YangPatch {
- edits := []restconf.YangPatchEdit{}
- for _, i := range deletePaths {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.DeleteData(state.Id.ValueString())
+ if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
return
}
} else {
- for _, i := range deletePaths {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // NETCONF
+ body := netconf.Body{}
+ body = helpers.RemoveFromXPath(body, state.getXPath())
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body.Res(), true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
+ }
+ }
+ } else {
+ if device.Protocol == "restconf" {
+ deletePaths := state.getDeletePaths(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
+
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{}
+ for _, i := range deletePaths {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
}
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletePaths {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ }
+ }
+ }
+ } else {
+ // NETCONF
+ body := state.addDeletePathsXML(ctx, "")
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
diff --git a/internal/provider/resource_iosxe_lldp.go b/internal/provider/resource_iosxe_lldp.go
index 4d1ee30d..844c58d7 100644
--- a/internal/provider/resource_iosxe_lldp.go
+++ b/internal/provider/resource_iosxe_lldp.go
@@ -36,6 +36,7 @@ import (
"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-netconf"
"github.com/netascode/go-restconf"
)
@@ -174,37 +175,59 @@ func (r *LLDPResource) Create(ctx context.Context, req resource.CreateRequest, r
}
if device.Managed {
- // Create object
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ // Create object
+ body := plan.toBody(ctx)
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
- return
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
+ return
+ }
+ } else {
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
- return
- }
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
+ }
+
+ body := plan.toBodyXML(ctx)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
@@ -242,25 +265,51 @@ func (r *LLDPResource) Read(ctx context.Context, req resource.ReadRequest, resp
}
if device.Managed {
- res, err := device.Client.GetData(state.Id.ValueString())
- if res.StatusCode == 404 {
- state = LLDP{Device: state.Device, Id: state.Id}
+ imp, diags := helpers.IsFlagImporting(ctx, req)
+ if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ return
+ }
+
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(state.Id.ValueString())
+ if res.StatusCode == 404 {
+ state = LLDP{Device: state.Device, Id: state.Id}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
+ return
+ }
+
+ // After `terraform import` we switch to a full read.
+ if imp {
+ state.fromBody(ctx, res.Res)
+ } else {
+ state.updateFromBody(ctx, res.Res)
+ }
+ }
} else {
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
- return
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
}
- imp, diags := helpers.IsFlagImporting(ctx, req)
- if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ filter := helpers.GetXpathFilter(state.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.getPath(), err))
return
}
// After `terraform import` we switch to a full read.
if imp {
- state.fromBody(ctx, res.Res)
+ state.fromBodyXML(ctx, res.Res)
} else {
- state.updateFromBody(ctx, res.Res)
+ state.updateFromBodyXML(ctx, res.Res)
}
}
}
@@ -303,51 +352,74 @@ func (r *LLDPResource) Update(ctx context.Context, req resource.UpdateRequest, r
}
if device.Managed {
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ body := plan.toBody(ctx)
- deletedItems := plan.getDeletedItems(ctx, state)
- tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
+ deletedItems := plan.getDeletedItems(ctx, state)
+ tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- var edits []restconf.YangPatchEdit
- for _, i := range deletedItems {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
- return
+ if YangPatch {
+ var edits []restconf.YangPatchEdit
+ for _, i := range deletedItems {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletedItems {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- for _, i := range deletedItems {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
}
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+
+ body := plan.toBodyXML(ctx)
+ body = plan.addDeletedItemsXML(ctx, state, body)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
return
}
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
- return
- }
- }
}
}
@@ -380,6 +452,18 @@ func (r *LLDPResource) Delete(ctx context.Context, req resource.DeleteRequest, r
}
if device.Managed {
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.Protocol == "netconf" && device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
+ }
deleteMode := "all"
if state.DeleteMode.ValueString() == "all" {
deleteMode = "all"
@@ -388,31 +472,52 @@ func (r *LLDPResource) Delete(ctx context.Context, req resource.DeleteRequest, r
}
if deleteMode == "all" {
- res, err := device.Client.DeleteData(state.Id.ValueString())
- if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
- return
- }
- } else {
- deletePaths := state.getDeletePaths(ctx)
- tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
-
- if YangPatch {
- edits := []restconf.YangPatchEdit{}
- for _, i := range deletePaths {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.DeleteData(state.Id.ValueString())
+ if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
return
}
} else {
- for _, i := range deletePaths {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // NETCONF
+ body := netconf.Body{}
+ body = helpers.RemoveFromXPath(body, state.getXPath())
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body.Res(), true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
+ }
+ }
+ } else {
+ if device.Protocol == "restconf" {
+ deletePaths := state.getDeletePaths(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
+
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{}
+ for _, i := range deletePaths {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
}
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletePaths {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ }
+ }
+ }
+ } else {
+ // NETCONF
+ body := state.addDeletePathsXML(ctx, "")
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
diff --git a/internal/provider/resource_iosxe_logging.go b/internal/provider/resource_iosxe_logging.go
index 4ebeeda2..246a5f55 100644
--- a/internal/provider/resource_iosxe_logging.go
+++ b/internal/provider/resource_iosxe_logging.go
@@ -36,6 +36,7 @@ import (
"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-netconf"
"github.com/netascode/go-restconf"
)
@@ -523,37 +524,59 @@ func (r *LoggingResource) Create(ctx context.Context, req resource.CreateRequest
}
if device.Managed {
- // Create object
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ // Create object
+ body := plan.toBody(ctx)
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
- return
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
+ return
+ }
+ } else {
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
- return
- }
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
+ }
+
+ body := plan.toBodyXML(ctx)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
@@ -591,25 +614,51 @@ func (r *LoggingResource) Read(ctx context.Context, req resource.ReadRequest, re
}
if device.Managed {
- res, err := device.Client.GetData(state.Id.ValueString())
- if res.StatusCode == 404 {
- state = Logging{Device: state.Device, Id: state.Id}
+ imp, diags := helpers.IsFlagImporting(ctx, req)
+ if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ return
+ }
+
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(state.Id.ValueString())
+ if res.StatusCode == 404 {
+ state = Logging{Device: state.Device, Id: state.Id}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
+ return
+ }
+
+ // After `terraform import` we switch to a full read.
+ if imp {
+ state.fromBody(ctx, res.Res)
+ } else {
+ state.updateFromBody(ctx, res.Res)
+ }
+ }
} else {
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
- return
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
}
- imp, diags := helpers.IsFlagImporting(ctx, req)
- if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ filter := helpers.GetXpathFilter(state.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.getPath(), err))
return
}
// After `terraform import` we switch to a full read.
if imp {
- state.fromBody(ctx, res.Res)
+ state.fromBodyXML(ctx, res.Res)
} else {
- state.updateFromBody(ctx, res.Res)
+ state.updateFromBodyXML(ctx, res.Res)
}
}
}
@@ -652,51 +701,74 @@ func (r *LoggingResource) Update(ctx context.Context, req resource.UpdateRequest
}
if device.Managed {
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ body := plan.toBody(ctx)
- deletedItems := plan.getDeletedItems(ctx, state)
- tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
+ deletedItems := plan.getDeletedItems(ctx, state)
+ tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- var edits []restconf.YangPatchEdit
- for _, i := range deletedItems {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
- return
+ if YangPatch {
+ var edits []restconf.YangPatchEdit
+ for _, i := range deletedItems {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletedItems {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- for _, i := range deletedItems {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
}
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+
+ body := plan.toBodyXML(ctx)
+ body = plan.addDeletedItemsXML(ctx, state, body)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
return
}
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
- return
- }
- }
}
}
@@ -729,34 +801,67 @@ func (r *LoggingResource) Delete(ctx context.Context, req resource.DeleteRequest
}
if device.Managed {
- deleteMode := "attributes"
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
- if deleteMode == "all" {
- res, err := device.Client.DeleteData(state.Id.ValueString())
- if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
+ if device.Protocol == "netconf" && device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
- } else {
- deletePaths := state.getDeletePaths(ctx)
- tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
+ defer cleanup()
+ }
+ deleteMode := "attributes"
- if YangPatch {
- edits := []restconf.YangPatchEdit{}
- for _, i := range deletePaths {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ if deleteMode == "all" {
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.DeleteData(state.Id.ValueString())
+ if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
return
}
} else {
- for _, i := range deletePaths {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // NETCONF
+ body := netconf.Body{}
+ body = helpers.RemoveFromXPath(body, state.getXPath())
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body.Res(), true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
+ }
+ }
+ } else {
+ if device.Protocol == "restconf" {
+ deletePaths := state.getDeletePaths(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
+
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{}
+ for _, i := range deletePaths {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
}
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletePaths {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ }
+ }
+ }
+ } else {
+ // NETCONF
+ body := state.addDeletePathsXML(ctx, "")
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
diff --git a/internal/provider/resource_iosxe_logging_test.go b/internal/provider/resource_iosxe_logging_test.go
index e2418352..43cac482 100644
--- a/internal/provider/resource_iosxe_logging_test.go
+++ b/internal/provider/resource_iosxe_logging_test.go
@@ -109,8 +109,8 @@ func iosxeLoggingImportStateIdFunc(resourceName string) resource.ImportStateIdFu
// Section below is generated&owned by "gen/generator.go". //template:begin testPrerequisites
const testAccIosxeLoggingPrerequisitesConfig = `
-resource "iosxe_restconf" "PreReq0" {
- path = "Cisco-IOS-XE-native:native/vrf/definition=VRF1"
+resource "iosxe_yang" "PreReq0" {
+ path = "/Cisco-IOS-XE-native:native/vrf/definition[name=VRF1]"
delete = false
attributes = {
"name" = "VRF1"
@@ -119,13 +119,13 @@ resource "iosxe_restconf" "PreReq0" {
}
}
-resource "iosxe_restconf" "PreReq1" {
- path = "Cisco-IOS-XE-native:native/interface/Loopback=100"
+resource "iosxe_yang" "PreReq1" {
+ path = "/Cisco-IOS-XE-native:native/interface/Loopback[name=100]"
attributes = {
"name" = "100"
"vrf/forwarding" = "VRF1"
}
- depends_on = [iosxe_restconf.PreReq0, ]
+ depends_on = [iosxe_yang.PreReq0, ]
}
`
@@ -136,7 +136,7 @@ resource "iosxe_restconf" "PreReq1" {
func testAccIosxeLoggingConfig_minimum() string {
config := `resource "iosxe_logging" "test" {` + "\n"
- config += ` depends_on = [iosxe_restconf.PreReq0, iosxe_restconf.PreReq1, ]` + "\n"
+ config += ` depends_on = [iosxe_yang.PreReq0, iosxe_yang.PreReq1, ]` + "\n"
config += `}` + "\n"
return config
}
@@ -226,7 +226,7 @@ func testAccIosxeLoggingConfig_all() string {
config += ` port_number = 10002` + "\n"
config += ` }]` + "\n"
config += ` }]` + "\n"
- config += ` depends_on = [iosxe_restconf.PreReq0, iosxe_restconf.PreReq1, ]` + "\n"
+ config += ` depends_on = [iosxe_yang.PreReq0, iosxe_yang.PreReq1, ]` + "\n"
config += `}` + "\n"
return config
}
diff --git a/internal/provider/resource_iosxe_mdt_subscription.go b/internal/provider/resource_iosxe_mdt_subscription.go
index ad0dbc33..25d5f9e3 100644
--- a/internal/provider/resource_iosxe_mdt_subscription.go
+++ b/internal/provider/resource_iosxe_mdt_subscription.go
@@ -37,6 +37,7 @@ import (
"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-netconf"
"github.com/netascode/go-restconf"
)
@@ -178,37 +179,59 @@ func (r *MDTSubscriptionResource) Create(ctx context.Context, req resource.Creat
}
if device.Managed {
- // Create object
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ // Create object
+ body := plan.toBody(ctx)
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
- return
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
+ return
+ }
+ } else {
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
- return
- }
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
+ }
+
+ body := plan.toBodyXML(ctx)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
@@ -246,25 +269,51 @@ func (r *MDTSubscriptionResource) Read(ctx context.Context, req resource.ReadReq
}
if device.Managed {
- res, err := device.Client.GetData(state.Id.ValueString())
- if res.StatusCode == 404 {
- state = MDTSubscription{Device: state.Device, Id: state.Id}
+ imp, diags := helpers.IsFlagImporting(ctx, req)
+ if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ return
+ }
+
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(state.Id.ValueString())
+ if res.StatusCode == 404 {
+ state = MDTSubscription{Device: state.Device, Id: state.Id}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
+ return
+ }
+
+ // After `terraform import` we switch to a full read.
+ if imp {
+ state.fromBody(ctx, res.Res)
+ } else {
+ state.updateFromBody(ctx, res.Res)
+ }
+ }
} else {
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
- return
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
}
- imp, diags := helpers.IsFlagImporting(ctx, req)
- if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ filter := helpers.GetXpathFilter(state.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.getPath(), err))
return
}
// After `terraform import` we switch to a full read.
if imp {
- state.fromBody(ctx, res.Res)
+ state.fromBodyXML(ctx, res.Res)
} else {
- state.updateFromBody(ctx, res.Res)
+ state.updateFromBodyXML(ctx, res.Res)
}
}
}
@@ -307,51 +356,74 @@ func (r *MDTSubscriptionResource) Update(ctx context.Context, req resource.Updat
}
if device.Managed {
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ body := plan.toBody(ctx)
- deletedItems := plan.getDeletedItems(ctx, state)
- tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
+ deletedItems := plan.getDeletedItems(ctx, state)
+ tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- var edits []restconf.YangPatchEdit
- for _, i := range deletedItems {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
- return
+ if YangPatch {
+ var edits []restconf.YangPatchEdit
+ for _, i := range deletedItems {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletedItems {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- for _, i := range deletedItems {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
}
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+
+ body := plan.toBodyXML(ctx)
+ body = plan.addDeletedItemsXML(ctx, state, body)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
return
}
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
- return
- }
- }
}
}
@@ -384,34 +456,67 @@ func (r *MDTSubscriptionResource) Delete(ctx context.Context, req resource.Delet
}
if device.Managed {
- deleteMode := "all"
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
- if deleteMode == "all" {
- res, err := device.Client.DeleteData(state.Id.ValueString())
- if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
+ if device.Protocol == "netconf" && device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
- } else {
- deletePaths := state.getDeletePaths(ctx)
- tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
+ defer cleanup()
+ }
+ deleteMode := "all"
- if YangPatch {
- edits := []restconf.YangPatchEdit{}
- for _, i := range deletePaths {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ if deleteMode == "all" {
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.DeleteData(state.Id.ValueString())
+ if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
return
}
} else {
- for _, i := range deletePaths {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // NETCONF
+ body := netconf.Body{}
+ body = helpers.RemoveFromXPath(body, state.getXPath())
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body.Res(), true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
+ }
+ }
+ } else {
+ if device.Protocol == "restconf" {
+ deletePaths := state.getDeletePaths(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
+
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{}
+ for _, i := range deletePaths {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
}
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletePaths {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ }
+ }
+ }
+ } else {
+ // NETCONF
+ body := state.addDeletePathsXML(ctx, "")
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
diff --git a/internal/provider/resource_iosxe_msdp.go b/internal/provider/resource_iosxe_msdp.go
index 8feadd97..a49c41e8 100644
--- a/internal/provider/resource_iosxe_msdp.go
+++ b/internal/provider/resource_iosxe_msdp.go
@@ -36,6 +36,7 @@ import (
"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-netconf"
"github.com/netascode/go-restconf"
)
@@ -240,37 +241,59 @@ func (r *MSDPResource) Create(ctx context.Context, req resource.CreateRequest, r
}
if device.Managed {
- // Create object
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ // Create object
+ body := plan.toBody(ctx)
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
- return
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
+ return
+ }
+ } else {
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
- return
- }
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
+ }
+
+ body := plan.toBodyXML(ctx)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
@@ -308,25 +331,51 @@ func (r *MSDPResource) Read(ctx context.Context, req resource.ReadRequest, resp
}
if device.Managed {
- res, err := device.Client.GetData(state.Id.ValueString())
- if res.StatusCode == 404 {
- state = MSDP{Device: state.Device, Id: state.Id}
+ imp, diags := helpers.IsFlagImporting(ctx, req)
+ if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ return
+ }
+
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(state.Id.ValueString())
+ if res.StatusCode == 404 {
+ state = MSDP{Device: state.Device, Id: state.Id}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
+ return
+ }
+
+ // After `terraform import` we switch to a full read.
+ if imp {
+ state.fromBody(ctx, res.Res)
+ } else {
+ state.updateFromBody(ctx, res.Res)
+ }
+ }
} else {
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
- return
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
}
- imp, diags := helpers.IsFlagImporting(ctx, req)
- if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ filter := helpers.GetXpathFilter(state.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.getPath(), err))
return
}
// After `terraform import` we switch to a full read.
if imp {
- state.fromBody(ctx, res.Res)
+ state.fromBodyXML(ctx, res.Res)
} else {
- state.updateFromBody(ctx, res.Res)
+ state.updateFromBodyXML(ctx, res.Res)
}
}
}
@@ -369,51 +418,74 @@ func (r *MSDPResource) Update(ctx context.Context, req resource.UpdateRequest, r
}
if device.Managed {
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ body := plan.toBody(ctx)
- deletedItems := plan.getDeletedItems(ctx, state)
- tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
+ deletedItems := plan.getDeletedItems(ctx, state)
+ tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- var edits []restconf.YangPatchEdit
- for _, i := range deletedItems {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
- return
+ if YangPatch {
+ var edits []restconf.YangPatchEdit
+ for _, i := range deletedItems {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletedItems {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- for _, i := range deletedItems {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
}
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+
+ body := plan.toBodyXML(ctx)
+ body = plan.addDeletedItemsXML(ctx, state, body)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
return
}
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
- return
- }
- }
}
}
@@ -446,6 +518,18 @@ func (r *MSDPResource) Delete(ctx context.Context, req resource.DeleteRequest, r
}
if device.Managed {
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.Protocol == "netconf" && device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
+ }
deleteMode := "all"
if state.DeleteMode.ValueString() == "all" {
deleteMode = "all"
@@ -454,31 +538,52 @@ func (r *MSDPResource) Delete(ctx context.Context, req resource.DeleteRequest, r
}
if deleteMode == "all" {
- res, err := device.Client.DeleteData(state.Id.ValueString())
- if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
- return
- }
- } else {
- deletePaths := state.getDeletePaths(ctx)
- tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
-
- if YangPatch {
- edits := []restconf.YangPatchEdit{}
- for _, i := range deletePaths {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.DeleteData(state.Id.ValueString())
+ if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
return
}
} else {
- for _, i := range deletePaths {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // NETCONF
+ body := netconf.Body{}
+ body = helpers.RemoveFromXPath(body, state.getXPath())
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body.Res(), true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
+ }
+ }
+ } else {
+ if device.Protocol == "restconf" {
+ deletePaths := state.getDeletePaths(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
+
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{}
+ for _, i := range deletePaths {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
}
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletePaths {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ }
+ }
+ }
+ } else {
+ // NETCONF
+ body := state.addDeletePathsXML(ctx, "")
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
diff --git a/internal/provider/resource_iosxe_msdp_test.go b/internal/provider/resource_iosxe_msdp_test.go
index 5dc970a0..ec96bd84 100644
--- a/internal/provider/resource_iosxe_msdp_test.go
+++ b/internal/provider/resource_iosxe_msdp_test.go
@@ -83,8 +83,8 @@ func iosxeMSDPImportStateIdFunc(resourceName string) resource.ImportStateIdFunc
// Section below is generated&owned by "gen/generator.go". //template:begin testPrerequisites
const testAccIosxeMSDPPrerequisitesConfig = `
-resource "iosxe_restconf" "PreReq0" {
- path = "Cisco-IOS-XE-native:native/vrf/definition=VRF1"
+resource "iosxe_yang" "PreReq0" {
+ path = "/Cisco-IOS-XE-native:native/vrf/definition[name=VRF1]"
delete = false
attributes = {
"name" = "VRF1"
@@ -92,17 +92,17 @@ resource "iosxe_restconf" "PreReq0" {
}
}
-resource "iosxe_restconf" "PreReq1" {
- path = "Cisco-IOS-XE-native:native/interface/Loopback=200"
+resource "iosxe_yang" "PreReq1" {
+ path = "/Cisco-IOS-XE-native:native/interface/Loopback[name=200]"
attributes = {
"name" = "200"
"vrf/forwarding" = "VRF1"
}
- depends_on = [iosxe_restconf.PreReq0, ]
+ depends_on = [iosxe_yang.PreReq0, ]
}
-resource "iosxe_restconf" "PreReq2" {
- path = "Cisco-IOS-XE-native:native/interface/Loopback=100"
+resource "iosxe_yang" "PreReq2" {
+ path = "/Cisco-IOS-XE-native:native/interface/Loopback[name=100]"
attributes = {
"name" = "100"
}
@@ -116,7 +116,7 @@ resource "iosxe_restconf" "PreReq2" {
func testAccIosxeMSDPConfig_minimum() string {
config := `resource "iosxe_msdp" "test" {` + "\n"
- config += ` depends_on = [iosxe_restconf.PreReq0, iosxe_restconf.PreReq1, iosxe_restconf.PreReq2, ]` + "\n"
+ config += ` depends_on = [iosxe_yang.PreReq0, iosxe_yang.PreReq1, iosxe_yang.PreReq2, ]` + "\n"
config += `}` + "\n"
return config
}
@@ -152,7 +152,7 @@ func testAccIosxeMSDPConfig_all() string {
config += ` password = "Cisco123"` + "\n"
config += ` }]` + "\n"
config += ` }]` + "\n"
- config += ` depends_on = [iosxe_restconf.PreReq0, iosxe_restconf.PreReq1, iosxe_restconf.PreReq2, ]` + "\n"
+ config += ` depends_on = [iosxe_yang.PreReq0, iosxe_yang.PreReq1, iosxe_yang.PreReq2, ]` + "\n"
config += `}` + "\n"
return config
}
diff --git a/internal/provider/resource_iosxe_nat.go b/internal/provider/resource_iosxe_nat.go
index 195f358c..79bc2960 100644
--- a/internal/provider/resource_iosxe_nat.go
+++ b/internal/provider/resource_iosxe_nat.go
@@ -35,6 +35,7 @@ import (
"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-netconf"
"github.com/netascode/go-restconf"
)
@@ -147,37 +148,59 @@ func (r *NATResource) Create(ctx context.Context, req resource.CreateRequest, re
}
if device.Managed {
- // Create object
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ // Create object
+ body := plan.toBody(ctx)
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
- return
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
+ return
+ }
+ } else {
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
- return
- }
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
+ }
+
+ body := plan.toBodyXML(ctx)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
@@ -215,25 +238,51 @@ func (r *NATResource) Read(ctx context.Context, req resource.ReadRequest, resp *
}
if device.Managed {
- res, err := device.Client.GetData(state.Id.ValueString())
- if res.StatusCode == 404 {
- state = NAT{Device: state.Device, Id: state.Id}
+ imp, diags := helpers.IsFlagImporting(ctx, req)
+ if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ return
+ }
+
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(state.Id.ValueString())
+ if res.StatusCode == 404 {
+ state = NAT{Device: state.Device, Id: state.Id}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
+ return
+ }
+
+ // After `terraform import` we switch to a full read.
+ if imp {
+ state.fromBody(ctx, res.Res)
+ } else {
+ state.updateFromBody(ctx, res.Res)
+ }
+ }
} else {
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
- return
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
}
- imp, diags := helpers.IsFlagImporting(ctx, req)
- if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ filter := helpers.GetXpathFilter(state.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.getPath(), err))
return
}
// After `terraform import` we switch to a full read.
if imp {
- state.fromBody(ctx, res.Res)
+ state.fromBodyXML(ctx, res.Res)
} else {
- state.updateFromBody(ctx, res.Res)
+ state.updateFromBodyXML(ctx, res.Res)
}
}
}
@@ -276,51 +325,74 @@ func (r *NATResource) Update(ctx context.Context, req resource.UpdateRequest, re
}
if device.Managed {
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ body := plan.toBody(ctx)
- deletedItems := plan.getDeletedItems(ctx, state)
- tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
+ deletedItems := plan.getDeletedItems(ctx, state)
+ tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- var edits []restconf.YangPatchEdit
- for _, i := range deletedItems {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
- return
+ if YangPatch {
+ var edits []restconf.YangPatchEdit
+ for _, i := range deletedItems {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletedItems {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- for _, i := range deletedItems {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
}
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+
+ body := plan.toBodyXML(ctx)
+ body = plan.addDeletedItemsXML(ctx, state, body)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
return
}
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
- return
- }
- }
}
}
@@ -353,6 +425,18 @@ func (r *NATResource) Delete(ctx context.Context, req resource.DeleteRequest, re
}
if device.Managed {
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.Protocol == "netconf" && device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
+ }
deleteMode := "all"
if state.DeleteMode.ValueString() == "all" {
deleteMode = "all"
@@ -361,31 +445,52 @@ func (r *NATResource) Delete(ctx context.Context, req resource.DeleteRequest, re
}
if deleteMode == "all" {
- res, err := device.Client.DeleteData(state.Id.ValueString())
- if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
- return
- }
- } else {
- deletePaths := state.getDeletePaths(ctx)
- tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
-
- if YangPatch {
- edits := []restconf.YangPatchEdit{}
- for _, i := range deletePaths {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.DeleteData(state.Id.ValueString())
+ if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
return
}
} else {
- for _, i := range deletePaths {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // NETCONF
+ body := netconf.Body{}
+ body = helpers.RemoveFromXPath(body, state.getXPath())
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body.Res(), true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
+ }
+ }
+ } else {
+ if device.Protocol == "restconf" {
+ deletePaths := state.getDeletePaths(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
+
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{}
+ for _, i := range deletePaths {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
}
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletePaths {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ }
+ }
+ }
+ } else {
+ // NETCONF
+ body := state.addDeletePathsXML(ctx, "")
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
diff --git a/internal/provider/resource_iosxe_ntp.go b/internal/provider/resource_iosxe_ntp.go
index a5faadc1..71363818 100644
--- a/internal/provider/resource_iosxe_ntp.go
+++ b/internal/provider/resource_iosxe_ntp.go
@@ -36,6 +36,7 @@ import (
"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-netconf"
"github.com/netascode/go-restconf"
)
@@ -460,37 +461,59 @@ func (r *NTPResource) Create(ctx context.Context, req resource.CreateRequest, re
}
if device.Managed {
- // Create object
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ // Create object
+ body := plan.toBody(ctx)
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
- return
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
+ return
+ }
+ } else {
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
- return
- }
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
+ }
+
+ body := plan.toBodyXML(ctx)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
@@ -528,25 +551,51 @@ func (r *NTPResource) Read(ctx context.Context, req resource.ReadRequest, resp *
}
if device.Managed {
- res, err := device.Client.GetData(state.Id.ValueString())
- if res.StatusCode == 404 {
- state = NTP{Device: state.Device, Id: state.Id}
+ imp, diags := helpers.IsFlagImporting(ctx, req)
+ if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ return
+ }
+
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(state.Id.ValueString())
+ if res.StatusCode == 404 {
+ state = NTP{Device: state.Device, Id: state.Id}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
+ return
+ }
+
+ // After `terraform import` we switch to a full read.
+ if imp {
+ state.fromBody(ctx, res.Res)
+ } else {
+ state.updateFromBody(ctx, res.Res)
+ }
+ }
} else {
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
- return
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
}
- imp, diags := helpers.IsFlagImporting(ctx, req)
- if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ filter := helpers.GetXpathFilter(state.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.getPath(), err))
return
}
// After `terraform import` we switch to a full read.
if imp {
- state.fromBody(ctx, res.Res)
+ state.fromBodyXML(ctx, res.Res)
} else {
- state.updateFromBody(ctx, res.Res)
+ state.updateFromBodyXML(ctx, res.Res)
}
}
}
@@ -589,51 +638,74 @@ func (r *NTPResource) Update(ctx context.Context, req resource.UpdateRequest, re
}
if device.Managed {
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ body := plan.toBody(ctx)
- deletedItems := plan.getDeletedItems(ctx, state)
- tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
+ deletedItems := plan.getDeletedItems(ctx, state)
+ tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- var edits []restconf.YangPatchEdit
- for _, i := range deletedItems {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
- return
+ if YangPatch {
+ var edits []restconf.YangPatchEdit
+ for _, i := range deletedItems {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletedItems {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- for _, i := range deletedItems {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
}
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+
+ body := plan.toBodyXML(ctx)
+ body = plan.addDeletedItemsXML(ctx, state, body)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
return
}
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
- return
- }
- }
}
}
@@ -666,6 +738,18 @@ func (r *NTPResource) Delete(ctx context.Context, req resource.DeleteRequest, re
}
if device.Managed {
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.Protocol == "netconf" && device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
+ }
deleteMode := "all"
if state.DeleteMode.ValueString() == "all" {
deleteMode = "all"
@@ -674,31 +758,52 @@ func (r *NTPResource) Delete(ctx context.Context, req resource.DeleteRequest, re
}
if deleteMode == "all" {
- res, err := device.Client.DeleteData(state.Id.ValueString())
- if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
- return
- }
- } else {
- deletePaths := state.getDeletePaths(ctx)
- tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
-
- if YangPatch {
- edits := []restconf.YangPatchEdit{}
- for _, i := range deletePaths {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.DeleteData(state.Id.ValueString())
+ if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
return
}
} else {
- for _, i := range deletePaths {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // NETCONF
+ body := netconf.Body{}
+ body = helpers.RemoveFromXPath(body, state.getXPath())
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body.Res(), true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
+ }
+ }
+ } else {
+ if device.Protocol == "restconf" {
+ deletePaths := state.getDeletePaths(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
+
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{}
+ for _, i := range deletePaths {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
}
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletePaths {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ }
+ }
+ }
+ } else {
+ // NETCONF
+ body := state.addDeletePathsXML(ctx, "")
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
diff --git a/internal/provider/resource_iosxe_ntp_test.go b/internal/provider/resource_iosxe_ntp_test.go
index 45e1448a..3b7277f0 100644
--- a/internal/provider/resource_iosxe_ntp_test.go
+++ b/internal/provider/resource_iosxe_ntp_test.go
@@ -109,8 +109,8 @@ func iosxeNTPImportStateIdFunc(resourceName string) resource.ImportStateIdFunc {
// Section below is generated&owned by "gen/generator.go". //template:begin testPrerequisites
const testAccIosxeNTPPrerequisitesConfig = `
-resource "iosxe_restconf" "PreReq0" {
- path = "Cisco-IOS-XE-native:native/vrf/definition=VRF1"
+resource "iosxe_yang" "PreReq0" {
+ path = "/Cisco-IOS-XE-native:native/vrf/definition[name=VRF1]"
delete = false
attributes = {
"name" = "VRF1"
@@ -118,15 +118,15 @@ resource "iosxe_restconf" "PreReq0" {
}
}
-resource "iosxe_restconf" "PreReq1" {
- path = "Cisco-IOS-XE-native:native/ip/access-list/Cisco-IOS-XE-acl:standard=SACL1"
+resource "iosxe_yang" "PreReq1" {
+ path = "/Cisco-IOS-XE-native:native/ip/access-list/Cisco-IOS-XE-acl:standard[name=SACL1]"
attributes = {
"name" = "SACL1"
}
}
-resource "iosxe_restconf" "PreReq2" {
- path = "Cisco-IOS-XE-native:native/interface/Loopback=1"
+resource "iosxe_yang" "PreReq2" {
+ path = "/Cisco-IOS-XE-native:native/interface/Loopback[name=1]"
attributes = {
"name" = "1"
}
@@ -140,7 +140,7 @@ resource "iosxe_restconf" "PreReq2" {
func testAccIosxeNTPConfig_minimum() string {
config := `resource "iosxe_ntp" "test" {` + "\n"
- config += ` depends_on = [iosxe_restconf.PreReq0, iosxe_restconf.PreReq1, iosxe_restconf.PreReq2, ]` + "\n"
+ config += ` depends_on = [iosxe_yang.PreReq0, iosxe_yang.PreReq1, iosxe_yang.PreReq2, ]` + "\n"
config += `}` + "\n"
return config
}
@@ -206,7 +206,7 @@ func testAccIosxeNTPConfig_all() string {
config += ` trusted_keys = [{` + "\n"
config += ` number = 1` + "\n"
config += ` }]` + "\n"
- config += ` depends_on = [iosxe_restconf.PreReq0, iosxe_restconf.PreReq1, iosxe_restconf.PreReq2, ]` + "\n"
+ config += ` depends_on = [iosxe_yang.PreReq0, iosxe_yang.PreReq1, iosxe_yang.PreReq2, ]` + "\n"
config += `}` + "\n"
return config
}
diff --git a/internal/provider/resource_iosxe_ospf.go b/internal/provider/resource_iosxe_ospf.go
index 49be1738..cc1d3c82 100644
--- a/internal/provider/resource_iosxe_ospf.go
+++ b/internal/provider/resource_iosxe_ospf.go
@@ -39,6 +39,7 @@ import (
"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-netconf"
"github.com/netascode/go-restconf"
)
@@ -499,37 +500,59 @@ func (r *OSPFResource) Create(ctx context.Context, req resource.CreateRequest, r
}
if device.Managed {
- // Create object
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ // Create object
+ body := plan.toBody(ctx)
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
- return
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
+ return
+ }
+ } else {
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
- return
- }
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
+ }
+
+ body := plan.toBodyXML(ctx)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
@@ -567,25 +590,51 @@ func (r *OSPFResource) Read(ctx context.Context, req resource.ReadRequest, resp
}
if device.Managed {
- res, err := device.Client.GetData(state.Id.ValueString())
- if res.StatusCode == 404 {
- state = OSPF{Device: state.Device, Id: state.Id}
+ imp, diags := helpers.IsFlagImporting(ctx, req)
+ if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ return
+ }
+
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(state.Id.ValueString())
+ if res.StatusCode == 404 {
+ state = OSPF{Device: state.Device, Id: state.Id}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
+ return
+ }
+
+ // After `terraform import` we switch to a full read.
+ if imp {
+ state.fromBody(ctx, res.Res)
+ } else {
+ state.updateFromBody(ctx, res.Res)
+ }
+ }
} else {
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
- return
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
}
- imp, diags := helpers.IsFlagImporting(ctx, req)
- if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ filter := helpers.GetXpathFilter(state.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.getPath(), err))
return
}
// After `terraform import` we switch to a full read.
if imp {
- state.fromBody(ctx, res.Res)
+ state.fromBodyXML(ctx, res.Res)
} else {
- state.updateFromBody(ctx, res.Res)
+ state.updateFromBodyXML(ctx, res.Res)
}
}
}
@@ -628,51 +677,74 @@ func (r *OSPFResource) Update(ctx context.Context, req resource.UpdateRequest, r
}
if device.Managed {
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ body := plan.toBody(ctx)
- deletedItems := plan.getDeletedItems(ctx, state)
- tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
+ deletedItems := plan.getDeletedItems(ctx, state)
+ tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- var edits []restconf.YangPatchEdit
- for _, i := range deletedItems {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
- return
+ if YangPatch {
+ var edits []restconf.YangPatchEdit
+ for _, i := range deletedItems {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletedItems {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- for _, i := range deletedItems {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
}
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+
+ body := plan.toBodyXML(ctx)
+ body = plan.addDeletedItemsXML(ctx, state, body)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
return
}
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
- return
- }
- }
}
}
@@ -705,6 +777,18 @@ func (r *OSPFResource) Delete(ctx context.Context, req resource.DeleteRequest, r
}
if device.Managed {
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.Protocol == "netconf" && device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
+ }
deleteMode := "all"
if state.DeleteMode.ValueString() == "all" {
deleteMode = "all"
@@ -713,31 +797,52 @@ func (r *OSPFResource) Delete(ctx context.Context, req resource.DeleteRequest, r
}
if deleteMode == "all" {
- res, err := device.Client.DeleteData(state.Id.ValueString())
- if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
- return
- }
- } else {
- deletePaths := state.getDeletePaths(ctx)
- tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
-
- if YangPatch {
- edits := []restconf.YangPatchEdit{}
- for _, i := range deletePaths {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.DeleteData(state.Id.ValueString())
+ if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
return
}
} else {
- for _, i := range deletePaths {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // NETCONF
+ body := netconf.Body{}
+ body = helpers.RemoveFromXPath(body, state.getXPath())
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body.Res(), true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
+ }
+ }
+ } else {
+ if device.Protocol == "restconf" {
+ deletePaths := state.getDeletePaths(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
+
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{}
+ for _, i := range deletePaths {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
}
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletePaths {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ }
+ }
+ }
+ } else {
+ // NETCONF
+ body := state.addDeletePathsXML(ctx, "")
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
diff --git a/internal/provider/resource_iosxe_ospf_vrf.go b/internal/provider/resource_iosxe_ospf_vrf.go
index 2d3e48b8..f0f645ed 100644
--- a/internal/provider/resource_iosxe_ospf_vrf.go
+++ b/internal/provider/resource_iosxe_ospf_vrf.go
@@ -39,6 +39,7 @@ import (
"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-netconf"
"github.com/netascode/go-restconf"
)
@@ -506,37 +507,59 @@ func (r *OSPFVRFResource) Create(ctx context.Context, req resource.CreateRequest
}
if device.Managed {
- // Create object
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ // Create object
+ body := plan.toBody(ctx)
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
- return
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
+ return
+ }
+ } else {
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
- return
- }
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
+ }
+
+ body := plan.toBodyXML(ctx)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
@@ -574,25 +597,51 @@ func (r *OSPFVRFResource) Read(ctx context.Context, req resource.ReadRequest, re
}
if device.Managed {
- res, err := device.Client.GetData(state.Id.ValueString())
- if res.StatusCode == 404 {
- state = OSPFVRF{Device: state.Device, Id: state.Id}
+ imp, diags := helpers.IsFlagImporting(ctx, req)
+ if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ return
+ }
+
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(state.Id.ValueString())
+ if res.StatusCode == 404 {
+ state = OSPFVRF{Device: state.Device, Id: state.Id}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
+ return
+ }
+
+ // After `terraform import` we switch to a full read.
+ if imp {
+ state.fromBody(ctx, res.Res)
+ } else {
+ state.updateFromBody(ctx, res.Res)
+ }
+ }
} else {
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
- return
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
}
- imp, diags := helpers.IsFlagImporting(ctx, req)
- if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ filter := helpers.GetXpathFilter(state.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.getPath(), err))
return
}
// After `terraform import` we switch to a full read.
if imp {
- state.fromBody(ctx, res.Res)
+ state.fromBodyXML(ctx, res.Res)
} else {
- state.updateFromBody(ctx, res.Res)
+ state.updateFromBodyXML(ctx, res.Res)
}
}
}
@@ -635,51 +684,74 @@ func (r *OSPFVRFResource) Update(ctx context.Context, req resource.UpdateRequest
}
if device.Managed {
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ body := plan.toBody(ctx)
- deletedItems := plan.getDeletedItems(ctx, state)
- tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
+ deletedItems := plan.getDeletedItems(ctx, state)
+ tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- var edits []restconf.YangPatchEdit
- for _, i := range deletedItems {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
- return
+ if YangPatch {
+ var edits []restconf.YangPatchEdit
+ for _, i := range deletedItems {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletedItems {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- for _, i := range deletedItems {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
}
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+
+ body := plan.toBodyXML(ctx)
+ body = plan.addDeletedItemsXML(ctx, state, body)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
return
}
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
- return
- }
- }
}
}
@@ -712,6 +784,18 @@ func (r *OSPFVRFResource) Delete(ctx context.Context, req resource.DeleteRequest
}
if device.Managed {
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.Protocol == "netconf" && device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
+ }
deleteMode := "all"
if state.DeleteMode.ValueString() == "all" {
deleteMode = "all"
@@ -720,31 +804,52 @@ func (r *OSPFVRFResource) Delete(ctx context.Context, req resource.DeleteRequest
}
if deleteMode == "all" {
- res, err := device.Client.DeleteData(state.Id.ValueString())
- if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
- return
- }
- } else {
- deletePaths := state.getDeletePaths(ctx)
- tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
-
- if YangPatch {
- edits := []restconf.YangPatchEdit{}
- for _, i := range deletePaths {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.DeleteData(state.Id.ValueString())
+ if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
return
}
} else {
- for _, i := range deletePaths {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // NETCONF
+ body := netconf.Body{}
+ body = helpers.RemoveFromXPath(body, state.getXPath())
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body.Res(), true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
+ }
+ }
+ } else {
+ if device.Protocol == "restconf" {
+ deletePaths := state.getDeletePaths(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
+
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{}
+ for _, i := range deletePaths {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
}
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletePaths {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ }
+ }
+ }
+ } else {
+ // NETCONF
+ body := state.addDeletePathsXML(ctx, "")
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
diff --git a/internal/provider/resource_iosxe_ospf_vrf_test.go b/internal/provider/resource_iosxe_ospf_vrf_test.go
index 8deb3c2a..741219d6 100644
--- a/internal/provider/resource_iosxe_ospf_vrf_test.go
+++ b/internal/provider/resource_iosxe_ospf_vrf_test.go
@@ -104,8 +104,8 @@ func iosxeOSPFVRFImportStateIdFunc(resourceName string) resource.ImportStateIdFu
// Section below is generated&owned by "gen/generator.go". //template:begin testPrerequisites
const testAccIosxeOSPFVRFPrerequisitesConfig = `
-resource "iosxe_restconf" "PreReq0" {
- path = "Cisco-IOS-XE-native:native/vrf/definition=VRF1"
+resource "iosxe_yang" "PreReq0" {
+ path = "/Cisco-IOS-XE-native:native/vrf/definition[name=VRF1]"
delete = false
attributes = {
"name" = "VRF1"
@@ -123,7 +123,7 @@ func testAccIosxeOSPFVRFConfig_minimum() string {
config := `resource "iosxe_ospf_vrf" "test" {` + "\n"
config += ` process_id = 2` + "\n"
config += ` vrf = "VRF1"` + "\n"
- config += ` depends_on = [iosxe_restconf.PreReq0, ]` + "\n"
+ config += ` depends_on = [iosxe_yang.PreReq0, ]` + "\n"
config += `}` + "\n"
return config
}
@@ -171,7 +171,7 @@ func testAccIosxeOSPFVRFConfig_all() string {
config += ` }]` + "\n"
config += ` auto_cost_reference_bandwidth = 40000` + "\n"
config += ` passive_interface_default = true` + "\n"
- config += ` depends_on = [iosxe_restconf.PreReq0, ]` + "\n"
+ config += ` depends_on = [iosxe_yang.PreReq0, ]` + "\n"
config += `}` + "\n"
return config
}
diff --git a/internal/provider/resource_iosxe_pim.go b/internal/provider/resource_iosxe_pim.go
index 8255dfe6..41c6d0ea 100644
--- a/internal/provider/resource_iosxe_pim.go
+++ b/internal/provider/resource_iosxe_pim.go
@@ -37,6 +37,7 @@ import (
"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-netconf"
"github.com/netascode/go-restconf"
)
@@ -371,37 +372,59 @@ func (r *PIMResource) Create(ctx context.Context, req resource.CreateRequest, re
}
if device.Managed {
- // Create object
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ // Create object
+ body := plan.toBody(ctx)
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
- return
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
+ return
+ }
+ } else {
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
- return
- }
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
+ }
+
+ body := plan.toBodyXML(ctx)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
@@ -439,25 +462,51 @@ func (r *PIMResource) Read(ctx context.Context, req resource.ReadRequest, resp *
}
if device.Managed {
- res, err := device.Client.GetData(state.Id.ValueString())
- if res.StatusCode == 404 {
- state = PIM{Device: state.Device, Id: state.Id}
+ imp, diags := helpers.IsFlagImporting(ctx, req)
+ if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ return
+ }
+
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(state.Id.ValueString())
+ if res.StatusCode == 404 {
+ state = PIM{Device: state.Device, Id: state.Id}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
+ return
+ }
+
+ // After `terraform import` we switch to a full read.
+ if imp {
+ state.fromBody(ctx, res.Res)
+ } else {
+ state.updateFromBody(ctx, res.Res)
+ }
+ }
} else {
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
- return
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
}
- imp, diags := helpers.IsFlagImporting(ctx, req)
- if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ filter := helpers.GetXpathFilter(state.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.getPath(), err))
return
}
// After `terraform import` we switch to a full read.
if imp {
- state.fromBody(ctx, res.Res)
+ state.fromBodyXML(ctx, res.Res)
} else {
- state.updateFromBody(ctx, res.Res)
+ state.updateFromBodyXML(ctx, res.Res)
}
}
}
@@ -500,51 +549,74 @@ func (r *PIMResource) Update(ctx context.Context, req resource.UpdateRequest, re
}
if device.Managed {
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ body := plan.toBody(ctx)
- deletedItems := plan.getDeletedItems(ctx, state)
- tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
+ deletedItems := plan.getDeletedItems(ctx, state)
+ tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- var edits []restconf.YangPatchEdit
- for _, i := range deletedItems {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
- return
+ if YangPatch {
+ var edits []restconf.YangPatchEdit
+ for _, i := range deletedItems {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletedItems {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- for _, i := range deletedItems {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
}
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+
+ body := plan.toBodyXML(ctx)
+ body = plan.addDeletedItemsXML(ctx, state, body)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
return
}
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
- return
- }
- }
}
}
@@ -577,6 +649,18 @@ func (r *PIMResource) Delete(ctx context.Context, req resource.DeleteRequest, re
}
if device.Managed {
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.Protocol == "netconf" && device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
+ }
deleteMode := "all"
if state.DeleteMode.ValueString() == "all" {
deleteMode = "all"
@@ -585,31 +669,52 @@ func (r *PIMResource) Delete(ctx context.Context, req resource.DeleteRequest, re
}
if deleteMode == "all" {
- res, err := device.Client.DeleteData(state.Id.ValueString())
- if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
- return
- }
- } else {
- deletePaths := state.getDeletePaths(ctx)
- tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
-
- if YangPatch {
- edits := []restconf.YangPatchEdit{}
- for _, i := range deletePaths {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.DeleteData(state.Id.ValueString())
+ if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
return
}
} else {
- for _, i := range deletePaths {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // NETCONF
+ body := netconf.Body{}
+ body = helpers.RemoveFromXPath(body, state.getXPath())
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body.Res(), true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
+ }
+ }
+ } else {
+ if device.Protocol == "restconf" {
+ deletePaths := state.getDeletePaths(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
+
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{}
+ for _, i := range deletePaths {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
}
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletePaths {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ }
+ }
+ }
+ } else {
+ // NETCONF
+ body := state.addDeletePathsXML(ctx, "")
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
diff --git a/internal/provider/resource_iosxe_pim_test.go b/internal/provider/resource_iosxe_pim_test.go
index 8fba5d28..5654d340 100644
--- a/internal/provider/resource_iosxe_pim_test.go
+++ b/internal/provider/resource_iosxe_pim_test.go
@@ -110,8 +110,8 @@ func iosxePIMImportStateIdFunc(resourceName string) resource.ImportStateIdFunc {
// Section below is generated&owned by "gen/generator.go". //template:begin testPrerequisites
const testAccIosxePIMPrerequisitesConfig = `
-resource "iosxe_restconf" "PreReq0" {
- path = "Cisco-IOS-XE-native:native/vrf/definition=VRF1"
+resource "iosxe_yang" "PreReq0" {
+ path = "/Cisco-IOS-XE-native:native/vrf/definition[name=VRF1]"
delete = false
attributes = {
"name" = "VRF1"
@@ -119,19 +119,19 @@ resource "iosxe_restconf" "PreReq0" {
}
}
-resource "iosxe_restconf" "PreReq1" {
- path = "Cisco-IOS-XE-native:native/interface/Loopback=200"
+resource "iosxe_yang" "PreReq1" {
+ path = "/Cisco-IOS-XE-native:native/interface/Loopback[name=200]"
attributes = {
"name" = "200"
"vrf/forwarding" = "VRF1"
"ip/address/primary/address" = "200.200.200.200"
"ip/address/primary/mask" = "255.255.255.255"
}
- depends_on = [iosxe_restconf.PreReq0, ]
+ depends_on = [iosxe_yang.PreReq0, ]
}
-resource "iosxe_restconf" "PreReq2" {
- path = "Cisco-IOS-XE-native:native/interface/Loopback=100"
+resource "iosxe_yang" "PreReq2" {
+ path = "/Cisco-IOS-XE-native:native/interface/Loopback[name=100]"
attributes = {
"name" = "100"
"ip/address/primary/address" = "200.200.200.200"
@@ -148,7 +148,7 @@ resource "iosxe_restconf" "PreReq2" {
func testAccIosxePIMConfig_minimum() string {
config := `resource "iosxe_pim" "test" {` + "\n"
- config += ` depends_on = [iosxe_restconf.PreReq0, iosxe_restconf.PreReq1, iosxe_restconf.PreReq2, ]` + "\n"
+ config += ` depends_on = [iosxe_yang.PreReq0, iosxe_yang.PreReq1, iosxe_yang.PreReq2, ]` + "\n"
config += `}` + "\n"
return config
}
@@ -207,7 +207,7 @@ func testAccIosxePIMConfig_all() string {
config += ` bidir = false` + "\n"
config += ` }]` + "\n"
config += ` }]` + "\n"
- config += ` depends_on = [iosxe_restconf.PreReq0, iosxe_restconf.PreReq1, iosxe_restconf.PreReq2, ]` + "\n"
+ config += ` depends_on = [iosxe_yang.PreReq0, iosxe_yang.PreReq1, iosxe_yang.PreReq2, ]` + "\n"
config += `}` + "\n"
return config
}
diff --git a/internal/provider/resource_iosxe_platform.go b/internal/provider/resource_iosxe_platform.go
index e78383ce..07ad6e96 100644
--- a/internal/provider/resource_iosxe_platform.go
+++ b/internal/provider/resource_iosxe_platform.go
@@ -35,6 +35,7 @@ import (
"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-netconf"
"github.com/netascode/go-restconf"
)
@@ -137,37 +138,59 @@ func (r *PlatformResource) Create(ctx context.Context, req resource.CreateReques
}
if device.Managed {
- // Create object
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ // Create object
+ body := plan.toBody(ctx)
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
- return
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
+ return
+ }
+ } else {
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
- return
- }
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
+ }
+
+ body := plan.toBodyXML(ctx)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
@@ -205,25 +228,51 @@ func (r *PlatformResource) Read(ctx context.Context, req resource.ReadRequest, r
}
if device.Managed {
- res, err := device.Client.GetData(state.Id.ValueString())
- if res.StatusCode == 404 {
- state = Platform{Device: state.Device, Id: state.Id}
+ imp, diags := helpers.IsFlagImporting(ctx, req)
+ if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ return
+ }
+
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(state.Id.ValueString())
+ if res.StatusCode == 404 {
+ state = Platform{Device: state.Device, Id: state.Id}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
+ return
+ }
+
+ // After `terraform import` we switch to a full read.
+ if imp {
+ state.fromBody(ctx, res.Res)
+ } else {
+ state.updateFromBody(ctx, res.Res)
+ }
+ }
} else {
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
- return
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
}
- imp, diags := helpers.IsFlagImporting(ctx, req)
- if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ filter := helpers.GetXpathFilter(state.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.getPath(), err))
return
}
// After `terraform import` we switch to a full read.
if imp {
- state.fromBody(ctx, res.Res)
+ state.fromBodyXML(ctx, res.Res)
} else {
- state.updateFromBody(ctx, res.Res)
+ state.updateFromBodyXML(ctx, res.Res)
}
}
}
@@ -266,51 +315,74 @@ func (r *PlatformResource) Update(ctx context.Context, req resource.UpdateReques
}
if device.Managed {
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ body := plan.toBody(ctx)
- deletedItems := plan.getDeletedItems(ctx, state)
- tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
+ deletedItems := plan.getDeletedItems(ctx, state)
+ tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- var edits []restconf.YangPatchEdit
- for _, i := range deletedItems {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
- return
+ if YangPatch {
+ var edits []restconf.YangPatchEdit
+ for _, i := range deletedItems {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletedItems {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- for _, i := range deletedItems {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
}
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+
+ body := plan.toBodyXML(ctx)
+ body = plan.addDeletedItemsXML(ctx, state, body)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
return
}
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
- return
- }
- }
}
}
@@ -343,34 +415,67 @@ func (r *PlatformResource) Delete(ctx context.Context, req resource.DeleteReques
}
if device.Managed {
- deleteMode := "attributes"
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
- if deleteMode == "all" {
- res, err := device.Client.DeleteData(state.Id.ValueString())
- if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
+ if device.Protocol == "netconf" && device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
- } else {
- deletePaths := state.getDeletePaths(ctx)
- tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
+ defer cleanup()
+ }
+ deleteMode := "attributes"
- if YangPatch {
- edits := []restconf.YangPatchEdit{}
- for _, i := range deletePaths {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ if deleteMode == "all" {
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.DeleteData(state.Id.ValueString())
+ if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
return
}
} else {
- for _, i := range deletePaths {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // NETCONF
+ body := netconf.Body{}
+ body = helpers.RemoveFromXPath(body, state.getXPath())
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body.Res(), true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
+ }
+ }
+ } else {
+ if device.Protocol == "restconf" {
+ deletePaths := state.getDeletePaths(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
+
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{}
+ for _, i := range deletePaths {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
}
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletePaths {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ }
+ }
+ }
+ } else {
+ // NETCONF
+ body := state.addDeletePathsXML(ctx, "")
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
diff --git a/internal/provider/resource_iosxe_policy_map.go b/internal/provider/resource_iosxe_policy_map.go
index 432b8035..13bc1502 100644
--- a/internal/provider/resource_iosxe_policy_map.go
+++ b/internal/provider/resource_iosxe_policy_map.go
@@ -36,6 +36,7 @@ import (
"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-netconf"
"github.com/netascode/go-restconf"
)
@@ -299,37 +300,59 @@ func (r *PolicyMapResource) Create(ctx context.Context, req resource.CreateReque
}
if device.Managed {
- // Create object
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ // Create object
+ body := plan.toBody(ctx)
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
- return
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
+ return
+ }
+ } else {
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
- return
- }
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
+ }
+
+ body := plan.toBodyXML(ctx)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
@@ -367,25 +390,51 @@ func (r *PolicyMapResource) Read(ctx context.Context, req resource.ReadRequest,
}
if device.Managed {
- res, err := device.Client.GetData(state.Id.ValueString())
- if res.StatusCode == 404 {
- state = PolicyMap{Device: state.Device, Id: state.Id}
+ imp, diags := helpers.IsFlagImporting(ctx, req)
+ if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ return
+ }
+
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(state.Id.ValueString())
+ if res.StatusCode == 404 {
+ state = PolicyMap{Device: state.Device, Id: state.Id}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
+ return
+ }
+
+ // After `terraform import` we switch to a full read.
+ if imp {
+ state.fromBody(ctx, res.Res)
+ } else {
+ state.updateFromBody(ctx, res.Res)
+ }
+ }
} else {
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
- return
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
}
- imp, diags := helpers.IsFlagImporting(ctx, req)
- if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ filter := helpers.GetXpathFilter(state.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.getPath(), err))
return
}
// After `terraform import` we switch to a full read.
if imp {
- state.fromBody(ctx, res.Res)
+ state.fromBodyXML(ctx, res.Res)
} else {
- state.updateFromBody(ctx, res.Res)
+ state.updateFromBodyXML(ctx, res.Res)
}
}
}
@@ -428,51 +477,74 @@ func (r *PolicyMapResource) Update(ctx context.Context, req resource.UpdateReque
}
if device.Managed {
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ body := plan.toBody(ctx)
- deletedItems := plan.getDeletedItems(ctx, state)
- tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
+ deletedItems := plan.getDeletedItems(ctx, state)
+ tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- var edits []restconf.YangPatchEdit
- for _, i := range deletedItems {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
- return
+ if YangPatch {
+ var edits []restconf.YangPatchEdit
+ for _, i := range deletedItems {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletedItems {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- for _, i := range deletedItems {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
}
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+
+ body := plan.toBodyXML(ctx)
+ body = plan.addDeletedItemsXML(ctx, state, body)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
return
}
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
- return
- }
- }
}
}
@@ -505,34 +577,67 @@ func (r *PolicyMapResource) Delete(ctx context.Context, req resource.DeleteReque
}
if device.Managed {
- deleteMode := "all"
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
- if deleteMode == "all" {
- res, err := device.Client.DeleteData(state.Id.ValueString())
- if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
+ if device.Protocol == "netconf" && device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
- } else {
- deletePaths := state.getDeletePaths(ctx)
- tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
+ defer cleanup()
+ }
+ deleteMode := "all"
- if YangPatch {
- edits := []restconf.YangPatchEdit{}
- for _, i := range deletePaths {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ if deleteMode == "all" {
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.DeleteData(state.Id.ValueString())
+ if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
return
}
} else {
- for _, i := range deletePaths {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // NETCONF
+ body := netconf.Body{}
+ body = helpers.RemoveFromXPath(body, state.getXPath())
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body.Res(), true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
+ }
+ }
+ } else {
+ if device.Protocol == "restconf" {
+ deletePaths := state.getDeletePaths(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
+
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{}
+ for _, i := range deletePaths {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
}
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletePaths {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ }
+ }
+ }
+ } else {
+ // NETCONF
+ body := state.addDeletePathsXML(ctx, "")
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
diff --git a/internal/provider/resource_iosxe_policy_map_event.go b/internal/provider/resource_iosxe_policy_map_event.go
index b9ecb6dc..e6dc48b6 100644
--- a/internal/provider/resource_iosxe_policy_map_event.go
+++ b/internal/provider/resource_iosxe_policy_map_event.go
@@ -36,6 +36,7 @@ import (
"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-netconf"
"github.com/netascode/go-restconf"
)
@@ -347,37 +348,59 @@ func (r *PolicyMapEventResource) Create(ctx context.Context, req resource.Create
}
if device.Managed {
- // Create object
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ // Create object
+ body := plan.toBody(ctx)
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
- return
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
+ return
+ }
+ } else {
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
- return
- }
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
+ }
+
+ body := plan.toBodyXML(ctx)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
@@ -415,25 +438,51 @@ func (r *PolicyMapEventResource) Read(ctx context.Context, req resource.ReadRequ
}
if device.Managed {
- res, err := device.Client.GetData(state.Id.ValueString())
- if res.StatusCode == 404 {
- state = PolicyMapEvent{Device: state.Device, Id: state.Id}
+ imp, diags := helpers.IsFlagImporting(ctx, req)
+ if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ return
+ }
+
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(state.Id.ValueString())
+ if res.StatusCode == 404 {
+ state = PolicyMapEvent{Device: state.Device, Id: state.Id}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
+ return
+ }
+
+ // After `terraform import` we switch to a full read.
+ if imp {
+ state.fromBody(ctx, res.Res)
+ } else {
+ state.updateFromBody(ctx, res.Res)
+ }
+ }
} else {
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
- return
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
}
- imp, diags := helpers.IsFlagImporting(ctx, req)
- if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ filter := helpers.GetXpathFilter(state.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.getPath(), err))
return
}
// After `terraform import` we switch to a full read.
if imp {
- state.fromBody(ctx, res.Res)
+ state.fromBodyXML(ctx, res.Res)
} else {
- state.updateFromBody(ctx, res.Res)
+ state.updateFromBodyXML(ctx, res.Res)
}
}
}
@@ -476,51 +525,74 @@ func (r *PolicyMapEventResource) Update(ctx context.Context, req resource.Update
}
if device.Managed {
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ body := plan.toBody(ctx)
- deletedItems := plan.getDeletedItems(ctx, state)
- tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
+ deletedItems := plan.getDeletedItems(ctx, state)
+ tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- var edits []restconf.YangPatchEdit
- for _, i := range deletedItems {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
- return
+ if YangPatch {
+ var edits []restconf.YangPatchEdit
+ for _, i := range deletedItems {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletedItems {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- for _, i := range deletedItems {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
}
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+
+ body := plan.toBodyXML(ctx)
+ body = plan.addDeletedItemsXML(ctx, state, body)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
return
}
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
- return
- }
- }
}
}
@@ -553,34 +625,67 @@ func (r *PolicyMapEventResource) Delete(ctx context.Context, req resource.Delete
}
if device.Managed {
- deleteMode := "all"
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
- if deleteMode == "all" {
- res, err := device.Client.DeleteData(state.Id.ValueString())
- if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
+ if device.Protocol == "netconf" && device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
- } else {
- deletePaths := state.getDeletePaths(ctx)
- tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
+ defer cleanup()
+ }
+ deleteMode := "all"
- if YangPatch {
- edits := []restconf.YangPatchEdit{}
- for _, i := range deletePaths {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ if deleteMode == "all" {
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.DeleteData(state.Id.ValueString())
+ if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
return
}
} else {
- for _, i := range deletePaths {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // NETCONF
+ body := netconf.Body{}
+ body = helpers.RemoveFromXPath(body, state.getXPath())
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body.Res(), true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
+ }
+ }
+ } else {
+ if device.Protocol == "restconf" {
+ deletePaths := state.getDeletePaths(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
+
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{}
+ for _, i := range deletePaths {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
}
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletePaths {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ }
+ }
+ }
+ } else {
+ // NETCONF
+ body := state.addDeletePathsXML(ctx, "")
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
diff --git a/internal/provider/resource_iosxe_policy_map_event_test.go b/internal/provider/resource_iosxe_policy_map_event_test.go
index be3e2052..d8145a97 100644
--- a/internal/provider/resource_iosxe_policy_map_event_test.go
+++ b/internal/provider/resource_iosxe_policy_map_event_test.go
@@ -106,8 +106,8 @@ func iosxePolicyMapEventImportStateIdFunc(resourceName string) resource.ImportSt
// Section below is generated&owned by "gen/generator.go". //template:begin testPrerequisites
const testAccIosxePolicyMapEventPrerequisitesConfig = `
-resource "iosxe_restconf" "PreReq0" {
- path = "Cisco-IOS-XE-native:native/policy/Cisco-IOS-XE-policy:policy-map=dot1x_policy"
+resource "iosxe_yang" "PreReq0" {
+ path = "/Cisco-IOS-XE-native:native/policy/Cisco-IOS-XE-policy:policy-map[name=dot1x_policy]"
attributes = {
"name" = "dot1x_policy"
"type" = "control"
@@ -115,8 +115,8 @@ resource "iosxe_restconf" "PreReq0" {
}
}
-resource "iosxe_restconf" "PreReq1" {
- path = "Cisco-IOS-XE-native:native/policy/Cisco-IOS-XE-policy:class-map=MY_CLASS"
+resource "iosxe_yang" "PreReq1" {
+ path = "/Cisco-IOS-XE-native:native/policy/Cisco-IOS-XE-policy:class-map[name=MY_CLASS]"
attributes = {
"name" = "MY_CLASS"
"type" = "control"
@@ -135,7 +135,7 @@ func testAccIosxePolicyMapEventConfig_minimum() string {
config := `resource "iosxe_policy_map_event" "test" {` + "\n"
config += ` name = "dot1x_policy"` + "\n"
config += ` event_type = "authentication-success"` + "\n"
- config += ` depends_on = [iosxe_restconf.PreReq0, iosxe_restconf.PreReq1, ]` + "\n"
+ config += ` depends_on = [iosxe_yang.PreReq0, iosxe_yang.PreReq1, ]` + "\n"
config += `}` + "\n"
return config
}
@@ -182,7 +182,7 @@ func testAccIosxePolicyMapEventConfig_all() string {
config += ` set_timer_value = 3600` + "\n"
config += ` }]` + "\n"
config += ` }]` + "\n"
- config += ` depends_on = [iosxe_restconf.PreReq0, iosxe_restconf.PreReq1, ]` + "\n"
+ config += ` depends_on = [iosxe_yang.PreReq0, iosxe_yang.PreReq1, ]` + "\n"
config += `}` + "\n"
return config
}
diff --git a/internal/provider/resource_iosxe_policy_map_test.go b/internal/provider/resource_iosxe_policy_map_test.go
index 35569d36..b13fb360 100644
--- a/internal/provider/resource_iosxe_policy_map_test.go
+++ b/internal/provider/resource_iosxe_policy_map_test.go
@@ -79,8 +79,8 @@ func iosxePolicyMapImportStateIdFunc(resourceName string) resource.ImportStateId
// Section below is generated&owned by "gen/generator.go". //template:begin testPrerequisites
const testAccIosxePolicyMapPrerequisitesConfig = `
-resource "iosxe_restconf" "PreReq0" {
- path = "Cisco-IOS-XE-native:native/policy/Cisco-IOS-XE-policy:class-map=CLASS1"
+resource "iosxe_yang" "PreReq0" {
+ path = "/Cisco-IOS-XE-native:native/policy/Cisco-IOS-XE-policy:class-map[name=CLASS1]"
attributes = {
"name" = "CLASS1"
"prematch" = "match-all"
@@ -96,7 +96,7 @@ resource "iosxe_restconf" "PreReq0" {
func testAccIosxePolicyMapConfig_minimum() string {
config := `resource "iosxe_policy_map" "test" {` + "\n"
config += ` name = "POLICY1"` + "\n"
- config += ` depends_on = [iosxe_restconf.PreReq0, ]` + "\n"
+ config += ` depends_on = [iosxe_yang.PreReq0, ]` + "\n"
config += `}` + "\n"
return config
}
@@ -116,7 +116,7 @@ func testAccIosxePolicyMapConfig_all() string {
config += ` bandwidth_percent = 10` + "\n"
config += ` }]` + "\n"
config += ` }]` + "\n"
- config += ` depends_on = [iosxe_restconf.PreReq0, ]` + "\n"
+ config += ` depends_on = [iosxe_yang.PreReq0, ]` + "\n"
config += `}` + "\n"
return config
}
diff --git a/internal/provider/resource_iosxe_prefix_list.go b/internal/provider/resource_iosxe_prefix_list.go
index 1471133b..d7912f61 100644
--- a/internal/provider/resource_iosxe_prefix_list.go
+++ b/internal/provider/resource_iosxe_prefix_list.go
@@ -37,6 +37,7 @@ import (
"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-netconf"
"github.com/netascode/go-restconf"
)
@@ -186,37 +187,59 @@ func (r *PrefixListResource) Create(ctx context.Context, req resource.CreateRequ
}
if device.Managed {
- // Create object
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ // Create object
+ body := plan.toBody(ctx)
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
- return
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
+ return
+ }
+ } else {
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
- return
- }
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
+ }
+
+ body := plan.toBodyXML(ctx)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
@@ -254,25 +277,51 @@ func (r *PrefixListResource) Read(ctx context.Context, req resource.ReadRequest,
}
if device.Managed {
- res, err := device.Client.GetData(state.Id.ValueString())
- if res.StatusCode == 404 {
- state = PrefixList{Device: state.Device, Id: state.Id}
+ imp, diags := helpers.IsFlagImporting(ctx, req)
+ if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ return
+ }
+
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(state.Id.ValueString())
+ if res.StatusCode == 404 {
+ state = PrefixList{Device: state.Device, Id: state.Id}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
+ return
+ }
+
+ // After `terraform import` we switch to a full read.
+ if imp {
+ state.fromBody(ctx, res.Res)
+ } else {
+ state.updateFromBody(ctx, res.Res)
+ }
+ }
} else {
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
- return
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
}
- imp, diags := helpers.IsFlagImporting(ctx, req)
- if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ filter := helpers.GetXpathFilter(state.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.getPath(), err))
return
}
// After `terraform import` we switch to a full read.
if imp {
- state.fromBody(ctx, res.Res)
+ state.fromBodyXML(ctx, res.Res)
} else {
- state.updateFromBody(ctx, res.Res)
+ state.updateFromBodyXML(ctx, res.Res)
}
}
}
@@ -315,51 +364,74 @@ func (r *PrefixListResource) Update(ctx context.Context, req resource.UpdateRequ
}
if device.Managed {
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ body := plan.toBody(ctx)
- deletedItems := plan.getDeletedItems(ctx, state)
- tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
+ deletedItems := plan.getDeletedItems(ctx, state)
+ tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- var edits []restconf.YangPatchEdit
- for _, i := range deletedItems {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
- return
+ if YangPatch {
+ var edits []restconf.YangPatchEdit
+ for _, i := range deletedItems {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletedItems {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- for _, i := range deletedItems {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
}
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+
+ body := plan.toBodyXML(ctx)
+ body = plan.addDeletedItemsXML(ctx, state, body)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
return
}
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
- return
- }
- }
}
}
@@ -392,34 +464,67 @@ func (r *PrefixListResource) Delete(ctx context.Context, req resource.DeleteRequ
}
if device.Managed {
- deleteMode := "all"
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
- if deleteMode == "all" {
- res, err := device.Client.DeleteData(state.Id.ValueString())
- if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
+ if device.Protocol == "netconf" && device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
- } else {
- deletePaths := state.getDeletePaths(ctx)
- tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
+ defer cleanup()
+ }
+ deleteMode := "all"
- if YangPatch {
- edits := []restconf.YangPatchEdit{}
- for _, i := range deletePaths {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ if deleteMode == "all" {
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.DeleteData(state.Id.ValueString())
+ if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
return
}
} else {
- for _, i := range deletePaths {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // NETCONF
+ body := netconf.Body{}
+ body = helpers.RemoveFromXPath(body, state.getXPath())
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body.Res(), true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
+ }
+ }
+ } else {
+ if device.Protocol == "restconf" {
+ deletePaths := state.getDeletePaths(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
+
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{}
+ for _, i := range deletePaths {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
}
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletePaths {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ }
+ }
+ }
+ } else {
+ // NETCONF
+ body := state.addDeletePathsXML(ctx, "")
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
diff --git a/internal/provider/resource_iosxe_radius.go b/internal/provider/resource_iosxe_radius.go
index 9714753b..dfee67ff 100644
--- a/internal/provider/resource_iosxe_radius.go
+++ b/internal/provider/resource_iosxe_radius.go
@@ -37,6 +37,7 @@ import (
"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-netconf"
"github.com/netascode/go-restconf"
)
@@ -188,37 +189,59 @@ func (r *RadiusResource) Create(ctx context.Context, req resource.CreateRequest,
}
if device.Managed {
- // Create object
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ // Create object
+ body := plan.toBody(ctx)
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
- return
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
+ return
+ }
+ } else {
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
- return
- }
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
+ }
+
+ body := plan.toBodyXML(ctx)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
@@ -256,25 +279,51 @@ func (r *RadiusResource) Read(ctx context.Context, req resource.ReadRequest, res
}
if device.Managed {
- res, err := device.Client.GetData(state.Id.ValueString())
- if res.StatusCode == 404 {
- state = Radius{Device: state.Device, Id: state.Id}
+ imp, diags := helpers.IsFlagImporting(ctx, req)
+ if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ return
+ }
+
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(state.Id.ValueString())
+ if res.StatusCode == 404 {
+ state = Radius{Device: state.Device, Id: state.Id}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
+ return
+ }
+
+ // After `terraform import` we switch to a full read.
+ if imp {
+ state.fromBody(ctx, res.Res)
+ } else {
+ state.updateFromBody(ctx, res.Res)
+ }
+ }
} else {
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
- return
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
}
- imp, diags := helpers.IsFlagImporting(ctx, req)
- if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ filter := helpers.GetXpathFilter(state.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.getPath(), err))
return
}
// After `terraform import` we switch to a full read.
if imp {
- state.fromBody(ctx, res.Res)
+ state.fromBodyXML(ctx, res.Res)
} else {
- state.updateFromBody(ctx, res.Res)
+ state.updateFromBodyXML(ctx, res.Res)
}
}
}
@@ -317,51 +366,74 @@ func (r *RadiusResource) Update(ctx context.Context, req resource.UpdateRequest,
}
if device.Managed {
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ body := plan.toBody(ctx)
- deletedItems := plan.getDeletedItems(ctx, state)
- tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
+ deletedItems := plan.getDeletedItems(ctx, state)
+ tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- var edits []restconf.YangPatchEdit
- for _, i := range deletedItems {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
- return
+ if YangPatch {
+ var edits []restconf.YangPatchEdit
+ for _, i := range deletedItems {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletedItems {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- for _, i := range deletedItems {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
}
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+
+ body := plan.toBodyXML(ctx)
+ body = plan.addDeletedItemsXML(ctx, state, body)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
return
}
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
- return
- }
- }
}
}
@@ -394,34 +466,67 @@ func (r *RadiusResource) Delete(ctx context.Context, req resource.DeleteRequest,
}
if device.Managed {
- deleteMode := "all"
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
- if deleteMode == "all" {
- res, err := device.Client.DeleteData(state.Id.ValueString())
- if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
+ if device.Protocol == "netconf" && device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
- } else {
- deletePaths := state.getDeletePaths(ctx)
- tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
+ defer cleanup()
+ }
+ deleteMode := "all"
- if YangPatch {
- edits := []restconf.YangPatchEdit{}
- for _, i := range deletePaths {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ if deleteMode == "all" {
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.DeleteData(state.Id.ValueString())
+ if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
return
}
} else {
- for _, i := range deletePaths {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // NETCONF
+ body := netconf.Body{}
+ body = helpers.RemoveFromXPath(body, state.getXPath())
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body.Res(), true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
+ }
+ }
+ } else {
+ if device.Protocol == "restconf" {
+ deletePaths := state.getDeletePaths(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
+
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{}
+ for _, i := range deletePaths {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
}
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletePaths {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ }
+ }
+ }
+ } else {
+ // NETCONF
+ body := state.addDeletePathsXML(ctx, "")
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
diff --git a/internal/provider/resource_iosxe_radius_server.go b/internal/provider/resource_iosxe_radius_server.go
index b0db7b13..b81d8c97 100644
--- a/internal/provider/resource_iosxe_radius_server.go
+++ b/internal/provider/resource_iosxe_radius_server.go
@@ -36,6 +36,7 @@ import (
"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-netconf"
"github.com/netascode/go-restconf"
)
@@ -192,37 +193,59 @@ func (r *RadiusServerResource) Create(ctx context.Context, req resource.CreateRe
}
if device.Managed {
- // Create object
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ // Create object
+ body := plan.toBody(ctx)
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
- return
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
+ return
+ }
+ } else {
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
- return
- }
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
+ }
+
+ body := plan.toBodyXML(ctx)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
@@ -260,25 +283,51 @@ func (r *RadiusServerResource) Read(ctx context.Context, req resource.ReadReques
}
if device.Managed {
- res, err := device.Client.GetData(state.Id.ValueString())
- if res.StatusCode == 404 {
- state = RadiusServer{Device: state.Device, Id: state.Id}
+ imp, diags := helpers.IsFlagImporting(ctx, req)
+ if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ return
+ }
+
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(state.Id.ValueString())
+ if res.StatusCode == 404 {
+ state = RadiusServer{Device: state.Device, Id: state.Id}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
+ return
+ }
+
+ // After `terraform import` we switch to a full read.
+ if imp {
+ state.fromBody(ctx, res.Res)
+ } else {
+ state.updateFromBody(ctx, res.Res)
+ }
+ }
} else {
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
- return
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
}
- imp, diags := helpers.IsFlagImporting(ctx, req)
- if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ filter := helpers.GetXpathFilter(state.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.getPath(), err))
return
}
// After `terraform import` we switch to a full read.
if imp {
- state.fromBody(ctx, res.Res)
+ state.fromBodyXML(ctx, res.Res)
} else {
- state.updateFromBody(ctx, res.Res)
+ state.updateFromBodyXML(ctx, res.Res)
}
}
}
@@ -321,51 +370,74 @@ func (r *RadiusServerResource) Update(ctx context.Context, req resource.UpdateRe
}
if device.Managed {
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ body := plan.toBody(ctx)
- deletedItems := plan.getDeletedItems(ctx, state)
- tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
+ deletedItems := plan.getDeletedItems(ctx, state)
+ tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- var edits []restconf.YangPatchEdit
- for _, i := range deletedItems {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
- return
+ if YangPatch {
+ var edits []restconf.YangPatchEdit
+ for _, i := range deletedItems {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletedItems {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- for _, i := range deletedItems {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
}
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+
+ body := plan.toBodyXML(ctx)
+ body = plan.addDeletedItemsXML(ctx, state, body)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
return
}
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
- return
- }
- }
}
}
@@ -398,34 +470,67 @@ func (r *RadiusServerResource) Delete(ctx context.Context, req resource.DeleteRe
}
if device.Managed {
- deleteMode := "all"
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
- if deleteMode == "all" {
- res, err := device.Client.DeleteData(state.Id.ValueString())
- if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
+ if device.Protocol == "netconf" && device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
- } else {
- deletePaths := state.getDeletePaths(ctx)
- tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
+ defer cleanup()
+ }
+ deleteMode := "all"
- if YangPatch {
- edits := []restconf.YangPatchEdit{}
- for _, i := range deletePaths {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ if deleteMode == "all" {
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.DeleteData(state.Id.ValueString())
+ if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
return
}
} else {
- for _, i := range deletePaths {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // NETCONF
+ body := netconf.Body{}
+ body = helpers.RemoveFromXPath(body, state.getXPath())
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body.Res(), true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
+ }
+ }
+ } else {
+ if device.Protocol == "restconf" {
+ deletePaths := state.getDeletePaths(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
+
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{}
+ for _, i := range deletePaths {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
}
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletePaths {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ }
+ }
+ }
+ } else {
+ // NETCONF
+ body := state.addDeletePathsXML(ctx, "")
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
diff --git a/internal/provider/resource_iosxe_route_map.go b/internal/provider/resource_iosxe_route_map.go
index 1fdf2154..588bced0 100644
--- a/internal/provider/resource_iosxe_route_map.go
+++ b/internal/provider/resource_iosxe_route_map.go
@@ -37,6 +37,7 @@ import (
"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-netconf"
"github.com/netascode/go-restconf"
)
@@ -666,37 +667,59 @@ func (r *RouteMapResource) Create(ctx context.Context, req resource.CreateReques
}
if device.Managed {
- // Create object
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ // Create object
+ body := plan.toBody(ctx)
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
- return
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
+ return
+ }
+ } else {
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
- return
- }
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
+ }
+
+ body := plan.toBodyXML(ctx)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
@@ -734,25 +757,51 @@ func (r *RouteMapResource) Read(ctx context.Context, req resource.ReadRequest, r
}
if device.Managed {
- res, err := device.Client.GetData(state.Id.ValueString())
- if res.StatusCode == 404 {
- state = RouteMap{Device: state.Device, Id: state.Id}
+ imp, diags := helpers.IsFlagImporting(ctx, req)
+ if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ return
+ }
+
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(state.Id.ValueString())
+ if res.StatusCode == 404 {
+ state = RouteMap{Device: state.Device, Id: state.Id}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
+ return
+ }
+
+ // After `terraform import` we switch to a full read.
+ if imp {
+ state.fromBody(ctx, res.Res)
+ } else {
+ state.updateFromBody(ctx, res.Res)
+ }
+ }
} else {
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
- return
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
}
- imp, diags := helpers.IsFlagImporting(ctx, req)
- if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ filter := helpers.GetXpathFilter(state.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.getPath(), err))
return
}
// After `terraform import` we switch to a full read.
if imp {
- state.fromBody(ctx, res.Res)
+ state.fromBodyXML(ctx, res.Res)
} else {
- state.updateFromBody(ctx, res.Res)
+ state.updateFromBodyXML(ctx, res.Res)
}
}
}
@@ -795,51 +844,74 @@ func (r *RouteMapResource) Update(ctx context.Context, req resource.UpdateReques
}
if device.Managed {
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ body := plan.toBody(ctx)
- deletedItems := plan.getDeletedItems(ctx, state)
- tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
+ deletedItems := plan.getDeletedItems(ctx, state)
+ tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- var edits []restconf.YangPatchEdit
- for _, i := range deletedItems {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
- return
+ if YangPatch {
+ var edits []restconf.YangPatchEdit
+ for _, i := range deletedItems {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletedItems {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- for _, i := range deletedItems {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
}
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+
+ body := plan.toBodyXML(ctx)
+ body = plan.addDeletedItemsXML(ctx, state, body)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
return
}
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
- return
- }
- }
}
}
@@ -872,34 +944,67 @@ func (r *RouteMapResource) Delete(ctx context.Context, req resource.DeleteReques
}
if device.Managed {
- deleteMode := "all"
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
- if deleteMode == "all" {
- res, err := device.Client.DeleteData(state.Id.ValueString())
- if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
+ if device.Protocol == "netconf" && device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
- } else {
- deletePaths := state.getDeletePaths(ctx)
- tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
+ defer cleanup()
+ }
+ deleteMode := "all"
- if YangPatch {
- edits := []restconf.YangPatchEdit{}
- for _, i := range deletePaths {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ if deleteMode == "all" {
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.DeleteData(state.Id.ValueString())
+ if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
return
}
} else {
- for _, i := range deletePaths {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // NETCONF
+ body := netconf.Body{}
+ body = helpers.RemoveFromXPath(body, state.getXPath())
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body.Res(), true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
+ }
+ }
+ } else {
+ if device.Protocol == "restconf" {
+ deletePaths := state.getDeletePaths(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
+
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{}
+ for _, i := range deletePaths {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
}
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletePaths {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ }
+ }
+ }
+ } else {
+ // NETCONF
+ body := state.addDeletePathsXML(ctx, "")
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
diff --git a/internal/provider/resource_iosxe_route_map_test.go b/internal/provider/resource_iosxe_route_map_test.go
index 2ff44d42..1ef0917a 100644
--- a/internal/provider/resource_iosxe_route_map_test.go
+++ b/internal/provider/resource_iosxe_route_map_test.go
@@ -194,8 +194,8 @@ func iosxeRouteMapImportStateIdFunc(resourceName string) resource.ImportStateIdF
// Section below is generated&owned by "gen/generator.go". //template:begin testPrerequisites
const testAccIosxeRouteMapPrerequisitesConfig = `
-resource "iosxe_restconf" "PreReq0" {
- path = "Cisco-IOS-XE-native:native/interface/Loopback=1"
+resource "iosxe_yang" "PreReq0" {
+ path = "/Cisco-IOS-XE-native:native/interface/Loopback[name=1]"
attributes = {
"name" = "1"
}
@@ -210,7 +210,7 @@ resource "iosxe_restconf" "PreReq0" {
func testAccIosxeRouteMapConfig_minimum() string {
config := `resource "iosxe_route_map" "test" {` + "\n"
config += ` name = "RM1"` + "\n"
- config += ` depends_on = [iosxe_restconf.PreReq0, ]` + "\n"
+ config += ` depends_on = [iosxe_yang.PreReq0, ]` + "\n"
config += `}` + "\n"
return config
}
@@ -342,7 +342,7 @@ func testAccIosxeRouteMapConfig_all() string {
config += ` set_local_preference = 110` + "\n"
config += ` set_weight = 10000` + "\n"
config += ` }]` + "\n"
- config += ` depends_on = [iosxe_restconf.PreReq0, ]` + "\n"
+ config += ` depends_on = [iosxe_yang.PreReq0, ]` + "\n"
config += `}` + "\n"
return config
}
diff --git a/internal/provider/resource_iosxe_save_config.go b/internal/provider/resource_iosxe_save_config.go
index eb32be29..5a838a66 100644
--- a/internal/provider/resource_iosxe_save_config.go
+++ b/internal/provider/resource_iosxe_save_config.go
@@ -22,12 +22,14 @@ import (
"fmt"
"strings"
+ "github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"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/booldefault"
"github.com/hashicorp/terraform-plugin-framework/types"
"github.com/hashicorp/terraform-plugin-log/tflog"
+ "github.com/netascode/go-netconf"
)
// Ensure provider defined types fully satisfy framework interfaces
@@ -97,11 +99,32 @@ func (r *SaveConfigResource) Create(ctx context.Context, req resource.CreateRequ
}
if d.Managed {
- request := d.Client.NewReq("POST", "/operations/cisco-ia:save-config/", strings.NewReader(""))
- _, err := d.Client.Do(request)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to save config, got error: %s", err))
- return
+ if d.Protocol == "restconf" {
+ request := d.RestconfClient.NewReq("POST", "/operations/cisco-ia:save-config/", strings.NewReader(""))
+ _, err := d.RestconfClient.Do(request)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to save config, got error: %s", err))
+ return
+ }
+ } else {
+ // Manage NETCONF connection lifecycle
+ if d.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, d.NetconfClient, &d.NetconfConnMutex, d.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
+ }
+
+ body := netconf.Body{}
+ body = helpers.SetFromXPath(body, "/cisco-ia:save-config", "")
+ body = body.SetAttr("save-config", "xmlns", "http://cisco.com/yang/cisco-ia")
+
+ if _, err := d.NetconfClient.RPC(ctx, body.Res()); err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to save config, got error: %s", err))
+ return
+ }
}
}
@@ -141,11 +164,32 @@ func (r *SaveConfigResource) Update(ctx context.Context, req resource.UpdateRequ
}
if d.Managed {
- request := d.Client.NewReq("POST", "/operations/cisco-ia:save-config/", strings.NewReader(""))
- _, err := d.Client.Do(request)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to save config, got error: %s", err))
- return
+ if d.Protocol == "restconf" {
+ request := d.RestconfClient.NewReq("POST", "/operations/cisco-ia:save-config/", strings.NewReader(""))
+ _, err := d.RestconfClient.Do(request)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to save config, got error: %s", err))
+ return
+ }
+ } else {
+ // Manage NETCONF connection lifecycle
+ if d.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, d.NetconfClient, &d.NetconfConnMutex, d.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
+ }
+
+ body := netconf.Body{}
+ body = helpers.SetFromXPath(body, "/save-config", "")
+ body = body.SetAttr("save-config", "xmlns", "http://cisco.com/yang/cisco-ia")
+
+ if _, err := d.NetconfClient.RPC(ctx, body.Res()); err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to save config, got error: %s", err))
+ return
+ }
}
}
diff --git a/internal/provider/resource_iosxe_service.go b/internal/provider/resource_iosxe_service.go
index cfc737f2..d814367d 100644
--- a/internal/provider/resource_iosxe_service.go
+++ b/internal/provider/resource_iosxe_service.go
@@ -33,6 +33,7 @@ import (
"github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier"
"github.com/hashicorp/terraform-plugin-framework/types"
"github.com/hashicorp/terraform-plugin-log/tflog"
+ "github.com/netascode/go-netconf"
"github.com/netascode/go-restconf"
)
@@ -210,37 +211,59 @@ func (r *ServiceResource) Create(ctx context.Context, req resource.CreateRequest
}
if device.Managed {
- // Create object
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ // Create object
+ body := plan.toBody(ctx)
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
- return
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
+ return
+ }
+ } else {
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
- return
- }
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
+ }
+
+ body := plan.toBodyXML(ctx)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
@@ -278,25 +301,51 @@ func (r *ServiceResource) Read(ctx context.Context, req resource.ReadRequest, re
}
if device.Managed {
- res, err := device.Client.GetData(state.Id.ValueString())
- if res.StatusCode == 404 {
- state = Service{Device: state.Device, Id: state.Id}
+ imp, diags := helpers.IsFlagImporting(ctx, req)
+ if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ return
+ }
+
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(state.Id.ValueString())
+ if res.StatusCode == 404 {
+ state = Service{Device: state.Device, Id: state.Id}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
+ return
+ }
+
+ // After `terraform import` we switch to a full read.
+ if imp {
+ state.fromBody(ctx, res.Res)
+ } else {
+ state.updateFromBody(ctx, res.Res)
+ }
+ }
} else {
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
- return
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
}
- imp, diags := helpers.IsFlagImporting(ctx, req)
- if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ filter := helpers.GetXpathFilter(state.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.getPath(), err))
return
}
// After `terraform import` we switch to a full read.
if imp {
- state.fromBody(ctx, res.Res)
+ state.fromBodyXML(ctx, res.Res)
} else {
- state.updateFromBody(ctx, res.Res)
+ state.updateFromBodyXML(ctx, res.Res)
}
}
}
@@ -339,51 +388,74 @@ func (r *ServiceResource) Update(ctx context.Context, req resource.UpdateRequest
}
if device.Managed {
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ body := plan.toBody(ctx)
- deletedItems := plan.getDeletedItems(ctx, state)
- tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
+ deletedItems := plan.getDeletedItems(ctx, state)
+ tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- var edits []restconf.YangPatchEdit
- for _, i := range deletedItems {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
- return
+ if YangPatch {
+ var edits []restconf.YangPatchEdit
+ for _, i := range deletedItems {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletedItems {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- for _, i := range deletedItems {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
}
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+
+ body := plan.toBodyXML(ctx)
+ body = plan.addDeletedItemsXML(ctx, state, body)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
return
}
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
- return
- }
- }
}
}
@@ -416,34 +488,67 @@ func (r *ServiceResource) Delete(ctx context.Context, req resource.DeleteRequest
}
if device.Managed {
- deleteMode := "attributes"
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
- if deleteMode == "all" {
- res, err := device.Client.DeleteData(state.Id.ValueString())
- if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
+ if device.Protocol == "netconf" && device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
- } else {
- deletePaths := state.getDeletePaths(ctx)
- tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
+ defer cleanup()
+ }
+ deleteMode := "attributes"
- if YangPatch {
- edits := []restconf.YangPatchEdit{}
- for _, i := range deletePaths {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ if deleteMode == "all" {
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.DeleteData(state.Id.ValueString())
+ if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
return
}
} else {
- for _, i := range deletePaths {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // NETCONF
+ body := netconf.Body{}
+ body = helpers.RemoveFromXPath(body, state.getXPath())
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body.Res(), true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
+ }
+ }
+ } else {
+ if device.Protocol == "restconf" {
+ deletePaths := state.getDeletePaths(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
+
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{}
+ for _, i := range deletePaths {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
}
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletePaths {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ }
+ }
+ }
+ } else {
+ // NETCONF
+ body := state.addDeletePathsXML(ctx, "")
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
diff --git a/internal/provider/resource_iosxe_service_template.go b/internal/provider/resource_iosxe_service_template.go
index 1b0e2d8d..fc71442e 100644
--- a/internal/provider/resource_iosxe_service_template.go
+++ b/internal/provider/resource_iosxe_service_template.go
@@ -36,6 +36,7 @@ import (
"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-netconf"
"github.com/netascode/go-restconf"
)
@@ -256,37 +257,59 @@ func (r *ServiceTemplateResource) Create(ctx context.Context, req resource.Creat
}
if device.Managed {
- // Create object
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ // Create object
+ body := plan.toBody(ctx)
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
- return
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
+ return
+ }
+ } else {
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
- return
- }
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
+ }
+
+ body := plan.toBodyXML(ctx)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
@@ -324,25 +347,51 @@ func (r *ServiceTemplateResource) Read(ctx context.Context, req resource.ReadReq
}
if device.Managed {
- res, err := device.Client.GetData(state.Id.ValueString())
- if res.StatusCode == 404 {
- state = ServiceTemplate{Device: state.Device, Id: state.Id}
+ imp, diags := helpers.IsFlagImporting(ctx, req)
+ if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ return
+ }
+
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(state.Id.ValueString())
+ if res.StatusCode == 404 {
+ state = ServiceTemplate{Device: state.Device, Id: state.Id}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
+ return
+ }
+
+ // After `terraform import` we switch to a full read.
+ if imp {
+ state.fromBody(ctx, res.Res)
+ } else {
+ state.updateFromBody(ctx, res.Res)
+ }
+ }
} else {
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
- return
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
}
- imp, diags := helpers.IsFlagImporting(ctx, req)
- if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ filter := helpers.GetXpathFilter(state.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.getPath(), err))
return
}
// After `terraform import` we switch to a full read.
if imp {
- state.fromBody(ctx, res.Res)
+ state.fromBodyXML(ctx, res.Res)
} else {
- state.updateFromBody(ctx, res.Res)
+ state.updateFromBodyXML(ctx, res.Res)
}
}
}
@@ -385,51 +434,74 @@ func (r *ServiceTemplateResource) Update(ctx context.Context, req resource.Updat
}
if device.Managed {
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ body := plan.toBody(ctx)
- deletedItems := plan.getDeletedItems(ctx, state)
- tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
+ deletedItems := plan.getDeletedItems(ctx, state)
+ tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- var edits []restconf.YangPatchEdit
- for _, i := range deletedItems {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
- return
+ if YangPatch {
+ var edits []restconf.YangPatchEdit
+ for _, i := range deletedItems {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletedItems {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- for _, i := range deletedItems {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
}
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+
+ body := plan.toBodyXML(ctx)
+ body = plan.addDeletedItemsXML(ctx, state, body)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
return
}
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
- return
- }
- }
}
}
@@ -462,34 +534,67 @@ func (r *ServiceTemplateResource) Delete(ctx context.Context, req resource.Delet
}
if device.Managed {
- deleteMode := "all"
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
- if deleteMode == "all" {
- res, err := device.Client.DeleteData(state.Id.ValueString())
- if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
+ if device.Protocol == "netconf" && device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
- } else {
- deletePaths := state.getDeletePaths(ctx)
- tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
+ defer cleanup()
+ }
+ deleteMode := "all"
- if YangPatch {
- edits := []restconf.YangPatchEdit{}
- for _, i := range deletePaths {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ if deleteMode == "all" {
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.DeleteData(state.Id.ValueString())
+ if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
return
}
} else {
- for _, i := range deletePaths {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // NETCONF
+ body := netconf.Body{}
+ body = helpers.RemoveFromXPath(body, state.getXPath())
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body.Res(), true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
+ }
+ }
+ } else {
+ if device.Protocol == "restconf" {
+ deletePaths := state.getDeletePaths(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
+
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{}
+ for _, i := range deletePaths {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
}
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletePaths {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ }
+ }
+ }
+ } else {
+ // NETCONF
+ body := state.addDeletePathsXML(ctx, "")
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
diff --git a/internal/provider/resource_iosxe_sla.go b/internal/provider/resource_iosxe_sla.go
index 2dca2fa4..bafeddc7 100644
--- a/internal/provider/resource_iosxe_sla.go
+++ b/internal/provider/resource_iosxe_sla.go
@@ -33,6 +33,7 @@ import (
"github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier"
"github.com/hashicorp/terraform-plugin-framework/types"
"github.com/hashicorp/terraform-plugin-log/tflog"
+ "github.com/netascode/go-netconf"
"github.com/netascode/go-restconf"
)
@@ -150,37 +151,59 @@ func (r *SLAResource) Create(ctx context.Context, req resource.CreateRequest, re
}
if device.Managed {
- // Create object
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ // Create object
+ body := plan.toBody(ctx)
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
- return
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
+ return
+ }
+ } else {
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
- return
- }
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
+ }
+
+ body := plan.toBodyXML(ctx)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
@@ -218,25 +241,51 @@ func (r *SLAResource) Read(ctx context.Context, req resource.ReadRequest, resp *
}
if device.Managed {
- res, err := device.Client.GetData(state.Id.ValueString())
- if res.StatusCode == 404 {
- state = SLA{Device: state.Device, Id: state.Id}
+ imp, diags := helpers.IsFlagImporting(ctx, req)
+ if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ return
+ }
+
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(state.Id.ValueString())
+ if res.StatusCode == 404 {
+ state = SLA{Device: state.Device, Id: state.Id}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
+ return
+ }
+
+ // After `terraform import` we switch to a full read.
+ if imp {
+ state.fromBody(ctx, res.Res)
+ } else {
+ state.updateFromBody(ctx, res.Res)
+ }
+ }
} else {
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
- return
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
}
- imp, diags := helpers.IsFlagImporting(ctx, req)
- if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ filter := helpers.GetXpathFilter(state.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.getPath(), err))
return
}
// After `terraform import` we switch to a full read.
if imp {
- state.fromBody(ctx, res.Res)
+ state.fromBodyXML(ctx, res.Res)
} else {
- state.updateFromBody(ctx, res.Res)
+ state.updateFromBodyXML(ctx, res.Res)
}
}
}
@@ -279,51 +328,74 @@ func (r *SLAResource) Update(ctx context.Context, req resource.UpdateRequest, re
}
if device.Managed {
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ body := plan.toBody(ctx)
- deletedItems := plan.getDeletedItems(ctx, state)
- tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
+ deletedItems := plan.getDeletedItems(ctx, state)
+ tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- var edits []restconf.YangPatchEdit
- for _, i := range deletedItems {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
- return
+ if YangPatch {
+ var edits []restconf.YangPatchEdit
+ for _, i := range deletedItems {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletedItems {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- for _, i := range deletedItems {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
}
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+
+ body := plan.toBodyXML(ctx)
+ body = plan.addDeletedItemsXML(ctx, state, body)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
return
}
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
- return
- }
- }
}
}
@@ -356,34 +428,67 @@ func (r *SLAResource) Delete(ctx context.Context, req resource.DeleteRequest, re
}
if device.Managed {
- deleteMode := "attributes"
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
- if deleteMode == "all" {
- res, err := device.Client.DeleteData(state.Id.ValueString())
- if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
+ if device.Protocol == "netconf" && device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
- } else {
- deletePaths := state.getDeletePaths(ctx)
- tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
+ defer cleanup()
+ }
+ deleteMode := "attributes"
- if YangPatch {
- edits := []restconf.YangPatchEdit{}
- for _, i := range deletePaths {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ if deleteMode == "all" {
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.DeleteData(state.Id.ValueString())
+ if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
return
}
} else {
- for _, i := range deletePaths {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // NETCONF
+ body := netconf.Body{}
+ body = helpers.RemoveFromXPath(body, state.getXPath())
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body.Res(), true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
+ }
+ }
+ } else {
+ if device.Protocol == "restconf" {
+ deletePaths := state.getDeletePaths(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
+
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{}
+ for _, i := range deletePaths {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
}
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletePaths {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ }
+ }
+ }
+ } else {
+ // NETCONF
+ body := state.addDeletePathsXML(ctx, "")
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
diff --git a/internal/provider/resource_iosxe_snmp_server.go b/internal/provider/resource_iosxe_snmp_server.go
index edc49b9f..20129c73 100644
--- a/internal/provider/resource_iosxe_snmp_server.go
+++ b/internal/provider/resource_iosxe_snmp_server.go
@@ -36,6 +36,7 @@ import (
"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-netconf"
"github.com/netascode/go-restconf"
)
@@ -1353,37 +1354,59 @@ func (r *SNMPServerResource) Create(ctx context.Context, req resource.CreateRequ
}
if device.Managed {
- // Create object
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ // Create object
+ body := plan.toBody(ctx)
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
- return
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
+ return
+ }
+ } else {
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
- return
- }
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
+ }
+
+ body := plan.toBodyXML(ctx)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
@@ -1421,25 +1444,51 @@ func (r *SNMPServerResource) Read(ctx context.Context, req resource.ReadRequest,
}
if device.Managed {
- res, err := device.Client.GetData(state.Id.ValueString())
- if res.StatusCode == 404 {
- state = SNMPServer{Device: state.Device, Id: state.Id}
+ imp, diags := helpers.IsFlagImporting(ctx, req)
+ if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ return
+ }
+
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(state.Id.ValueString())
+ if res.StatusCode == 404 {
+ state = SNMPServer{Device: state.Device, Id: state.Id}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
+ return
+ }
+
+ // After `terraform import` we switch to a full read.
+ if imp {
+ state.fromBody(ctx, res.Res)
+ } else {
+ state.updateFromBody(ctx, res.Res)
+ }
+ }
} else {
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
- return
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
}
- imp, diags := helpers.IsFlagImporting(ctx, req)
- if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ filter := helpers.GetXpathFilter(state.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.getPath(), err))
return
}
// After `terraform import` we switch to a full read.
if imp {
- state.fromBody(ctx, res.Res)
+ state.fromBodyXML(ctx, res.Res)
} else {
- state.updateFromBody(ctx, res.Res)
+ state.updateFromBodyXML(ctx, res.Res)
}
}
}
@@ -1482,51 +1531,74 @@ func (r *SNMPServerResource) Update(ctx context.Context, req resource.UpdateRequ
}
if device.Managed {
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ body := plan.toBody(ctx)
- deletedItems := plan.getDeletedItems(ctx, state)
- tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
+ deletedItems := plan.getDeletedItems(ctx, state)
+ tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- var edits []restconf.YangPatchEdit
- for _, i := range deletedItems {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
- return
+ if YangPatch {
+ var edits []restconf.YangPatchEdit
+ for _, i := range deletedItems {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletedItems {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- for _, i := range deletedItems {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
}
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+
+ body := plan.toBodyXML(ctx)
+ body = plan.addDeletedItemsXML(ctx, state, body)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
return
}
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
- return
- }
- }
}
}
@@ -1559,6 +1631,18 @@ func (r *SNMPServerResource) Delete(ctx context.Context, req resource.DeleteRequ
}
if device.Managed {
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.Protocol == "netconf" && device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
+ }
deleteMode := "all"
if state.DeleteMode.ValueString() == "all" {
deleteMode = "all"
@@ -1567,31 +1651,52 @@ func (r *SNMPServerResource) Delete(ctx context.Context, req resource.DeleteRequ
}
if deleteMode == "all" {
- res, err := device.Client.DeleteData(state.Id.ValueString())
- if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
- return
- }
- } else {
- deletePaths := state.getDeletePaths(ctx)
- tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
-
- if YangPatch {
- edits := []restconf.YangPatchEdit{}
- for _, i := range deletePaths {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.DeleteData(state.Id.ValueString())
+ if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
return
}
} else {
- for _, i := range deletePaths {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // NETCONF
+ body := netconf.Body{}
+ body = helpers.RemoveFromXPath(body, state.getXPath())
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body.Res(), true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
+ }
+ }
+ } else {
+ if device.Protocol == "restconf" {
+ deletePaths := state.getDeletePaths(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
+
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{}
+ for _, i := range deletePaths {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
}
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletePaths {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ }
+ }
+ }
+ } else {
+ // NETCONF
+ body := state.addDeletePathsXML(ctx, "")
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
diff --git a/internal/provider/resource_iosxe_snmp_server_test.go b/internal/provider/resource_iosxe_snmp_server_test.go
index 70854e43..48382035 100644
--- a/internal/provider/resource_iosxe_snmp_server_test.go
+++ b/internal/provider/resource_iosxe_snmp_server_test.go
@@ -360,15 +360,15 @@ func iosxeSNMPServerImportStateIdFunc(resourceName string) resource.ImportStateI
// Section below is generated&owned by "gen/generator.go". //template:begin testPrerequisites
const testAccIosxeSNMPServerPrerequisitesConfig = `
-resource "iosxe_restconf" "PreReq0" {
- path = "Cisco-IOS-XE-native:native/interface/Loopback=1"
+resource "iosxe_yang" "PreReq0" {
+ path = "/Cisco-IOS-XE-native:native/interface/Loopback[name=1]"
attributes = {
"name" = "1"
}
}
-resource "iosxe_restconf" "PreReq1" {
- path = "Cisco-IOS-XE-native:native/vrf/definition=VRF1"
+resource "iosxe_yang" "PreReq1" {
+ path = "/Cisco-IOS-XE-native:native/vrf/definition[name=VRF1]"
delete = false
attributes = {
"name" = "VRF1"
@@ -384,7 +384,7 @@ resource "iosxe_restconf" "PreReq1" {
func testAccIosxeSNMPServerConfig_minimum() string {
config := `resource "iosxe_snmp_server" "test" {` + "\n"
- config += ` depends_on = [iosxe_restconf.PreReq0, iosxe_restconf.PreReq1, ]` + "\n"
+ config += ` depends_on = [iosxe_yang.PreReq0, iosxe_yang.PreReq1, ]` + "\n"
config += `}` + "\n"
return config
}
@@ -703,7 +703,7 @@ func testAccIosxeSNMPServerConfig_all() string {
config += ` v3_auth_priv_aes_access_ipv6_acl = "V6ACL1"` + "\n"
config += ` v3_auth_priv_aes_access_acl_name = "ACL123"` + "\n"
config += ` }]` + "\n"
- config += ` depends_on = [iosxe_restconf.PreReq0, iosxe_restconf.PreReq1, ]` + "\n"
+ config += ` depends_on = [iosxe_yang.PreReq0, iosxe_yang.PreReq1, ]` + "\n"
config += `}` + "\n"
return config
}
diff --git a/internal/provider/resource_iosxe_spanning_tree.go b/internal/provider/resource_iosxe_spanning_tree.go
index 9f8fa5db..f1c97c33 100644
--- a/internal/provider/resource_iosxe_spanning_tree.go
+++ b/internal/provider/resource_iosxe_spanning_tree.go
@@ -36,6 +36,7 @@ import (
"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-netconf"
"github.com/netascode/go-restconf"
)
@@ -179,37 +180,59 @@ func (r *SpanningTreeResource) Create(ctx context.Context, req resource.CreateRe
}
if device.Managed {
- // Create object
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ // Create object
+ body := plan.toBody(ctx)
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits, restconf.Timeout(1800))
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
- return
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits, restconf.Timeout(1800))
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
+ return
+ }
+ } else {
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body, restconf.Timeout(1800))
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body, restconf.Timeout(1800))
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i, restconf.Timeout(1800))
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- res, err := device.Client.PatchData(plan.getPathShort(), body, restconf.Timeout(1800))
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body, restconf.Timeout(1800))
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
- return
- }
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i, restconf.Timeout(1800))
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
+ }
+
+ body := plan.toBodyXML(ctx)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
@@ -247,25 +270,51 @@ func (r *SpanningTreeResource) Read(ctx context.Context, req resource.ReadReques
}
if device.Managed {
- res, err := device.Client.GetData(state.Id.ValueString())
- if res.StatusCode == 404 {
- state = SpanningTree{Device: state.Device, Id: state.Id}
+ imp, diags := helpers.IsFlagImporting(ctx, req)
+ if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ return
+ }
+
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(state.Id.ValueString())
+ if res.StatusCode == 404 {
+ state = SpanningTree{Device: state.Device, Id: state.Id}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
+ return
+ }
+
+ // After `terraform import` we switch to a full read.
+ if imp {
+ state.fromBody(ctx, res.Res)
+ } else {
+ state.updateFromBody(ctx, res.Res)
+ }
+ }
} else {
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
- return
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
}
- imp, diags := helpers.IsFlagImporting(ctx, req)
- if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ filter := helpers.GetXpathFilter(state.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.getPath(), err))
return
}
// After `terraform import` we switch to a full read.
if imp {
- state.fromBody(ctx, res.Res)
+ state.fromBodyXML(ctx, res.Res)
} else {
- state.updateFromBody(ctx, res.Res)
+ state.updateFromBodyXML(ctx, res.Res)
}
}
}
@@ -308,51 +357,74 @@ func (r *SpanningTreeResource) Update(ctx context.Context, req resource.UpdateRe
}
if device.Managed {
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ body := plan.toBody(ctx)
- deletedItems := plan.getDeletedItems(ctx, state)
- tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
+ deletedItems := plan.getDeletedItems(ctx, state)
+ tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- var edits []restconf.YangPatchEdit
- for _, i := range deletedItems {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits, restconf.Timeout(1800))
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
- return
+ if YangPatch {
+ var edits []restconf.YangPatchEdit
+ for _, i := range deletedItems {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits, restconf.Timeout(1800))
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletedItems {
+ res, err := device.RestconfClient.DeleteData(i, restconf.Timeout(1800))
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body, restconf.Timeout(1800))
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body, restconf.Timeout(1800))
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i, restconf.Timeout(1800))
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- for _, i := range deletedItems {
- res, err := device.Client.DeleteData(i, restconf.Timeout(1800))
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
}
- res, err := device.Client.PatchData(plan.getPathShort(), body, restconf.Timeout(1800))
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body, restconf.Timeout(1800))
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+
+ body := plan.toBodyXML(ctx)
+ body = plan.addDeletedItemsXML(ctx, state, body)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
return
}
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i, restconf.Timeout(1800))
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
- return
- }
- }
}
}
@@ -385,34 +457,67 @@ func (r *SpanningTreeResource) Delete(ctx context.Context, req resource.DeleteRe
}
if device.Managed {
- deleteMode := "attributes"
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
- if deleteMode == "all" {
- res, err := device.Client.DeleteData(state.Id.ValueString(), restconf.Timeout(1800))
- if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
+ if device.Protocol == "netconf" && device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
- } else {
- deletePaths := state.getDeletePaths(ctx)
- tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
+ defer cleanup()
+ }
+ deleteMode := "attributes"
- if YangPatch {
- edits := []restconf.YangPatchEdit{}
- for _, i := range deletePaths {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits, restconf.Timeout(1800))
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ if deleteMode == "all" {
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.DeleteData(state.Id.ValueString(), restconf.Timeout(1800))
+ if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
return
}
} else {
- for _, i := range deletePaths {
- res, err := device.Client.DeleteData(i, restconf.Timeout(1800))
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // NETCONF
+ body := netconf.Body{}
+ body = helpers.RemoveFromXPath(body, state.getXPath())
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body.Res(), true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
+ }
+ }
+ } else {
+ if device.Protocol == "restconf" {
+ deletePaths := state.getDeletePaths(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
+
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{}
+ for _, i := range deletePaths {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
}
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits, restconf.Timeout(1800))
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletePaths {
+ res, err := device.RestconfClient.DeleteData(i, restconf.Timeout(1800))
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ }
+ }
+ }
+ } else {
+ // NETCONF
+ body := state.addDeletePathsXML(ctx, "")
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
diff --git a/internal/provider/resource_iosxe_static_route.go b/internal/provider/resource_iosxe_static_route.go
index e1e49c03..32b2463d 100644
--- a/internal/provider/resource_iosxe_static_route.go
+++ b/internal/provider/resource_iosxe_static_route.go
@@ -37,6 +37,7 @@ import (
"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-netconf"
"github.com/netascode/go-restconf"
)
@@ -213,37 +214,59 @@ func (r *StaticRouteResource) Create(ctx context.Context, req resource.CreateReq
}
if device.Managed {
- // Create object
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ // Create object
+ body := plan.toBody(ctx)
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
- return
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
+ return
+ }
+ } else {
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
- return
- }
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
+ }
+
+ body := plan.toBodyXML(ctx)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
@@ -281,25 +304,51 @@ func (r *StaticRouteResource) Read(ctx context.Context, req resource.ReadRequest
}
if device.Managed {
- res, err := device.Client.GetData(state.Id.ValueString())
- if res.StatusCode == 404 {
- state = StaticRoute{Device: state.Device, Id: state.Id}
+ imp, diags := helpers.IsFlagImporting(ctx, req)
+ if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ return
+ }
+
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(state.Id.ValueString())
+ if res.StatusCode == 404 {
+ state = StaticRoute{Device: state.Device, Id: state.Id}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
+ return
+ }
+
+ // After `terraform import` we switch to a full read.
+ if imp {
+ state.fromBody(ctx, res.Res)
+ } else {
+ state.updateFromBody(ctx, res.Res)
+ }
+ }
} else {
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
- return
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
}
- imp, diags := helpers.IsFlagImporting(ctx, req)
- if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ filter := helpers.GetXpathFilter(state.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.getPath(), err))
return
}
// After `terraform import` we switch to a full read.
if imp {
- state.fromBody(ctx, res.Res)
+ state.fromBodyXML(ctx, res.Res)
} else {
- state.updateFromBody(ctx, res.Res)
+ state.updateFromBodyXML(ctx, res.Res)
}
}
}
@@ -342,51 +391,74 @@ func (r *StaticRouteResource) Update(ctx context.Context, req resource.UpdateReq
}
if device.Managed {
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ body := plan.toBody(ctx)
- deletedItems := plan.getDeletedItems(ctx, state)
- tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
+ deletedItems := plan.getDeletedItems(ctx, state)
+ tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- var edits []restconf.YangPatchEdit
- for _, i := range deletedItems {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
- return
+ if YangPatch {
+ var edits []restconf.YangPatchEdit
+ for _, i := range deletedItems {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletedItems {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- for _, i := range deletedItems {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
}
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+
+ body := plan.toBodyXML(ctx)
+ body = plan.addDeletedItemsXML(ctx, state, body)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
return
}
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
- return
- }
- }
}
}
@@ -419,34 +491,67 @@ func (r *StaticRouteResource) Delete(ctx context.Context, req resource.DeleteReq
}
if device.Managed {
- deleteMode := "all"
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
- if deleteMode == "all" {
- res, err := device.Client.DeleteData(state.Id.ValueString())
- if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
+ if device.Protocol == "netconf" && device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
- } else {
- deletePaths := state.getDeletePaths(ctx)
- tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
+ defer cleanup()
+ }
+ deleteMode := "all"
- if YangPatch {
- edits := []restconf.YangPatchEdit{}
- for _, i := range deletePaths {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ if deleteMode == "all" {
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.DeleteData(state.Id.ValueString())
+ if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
return
}
} else {
- for _, i := range deletePaths {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // NETCONF
+ body := netconf.Body{}
+ body = helpers.RemoveFromXPath(body, state.getXPath())
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body.Res(), true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
+ }
+ }
+ } else {
+ if device.Protocol == "restconf" {
+ deletePaths := state.getDeletePaths(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
+
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{}
+ for _, i := range deletePaths {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
}
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletePaths {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ }
+ }
+ }
+ } else {
+ // NETCONF
+ body := state.addDeletePathsXML(ctx, "")
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
diff --git a/internal/provider/resource_iosxe_static_routes_vrf.go b/internal/provider/resource_iosxe_static_routes_vrf.go
index c6c742d2..849874a0 100644
--- a/internal/provider/resource_iosxe_static_routes_vrf.go
+++ b/internal/provider/resource_iosxe_static_routes_vrf.go
@@ -37,6 +37,7 @@ import (
"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-netconf"
"github.com/netascode/go-restconf"
)
@@ -222,37 +223,59 @@ func (r *StaticRoutesVRFResource) Create(ctx context.Context, req resource.Creat
}
if device.Managed {
- // Create object
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ // Create object
+ body := plan.toBody(ctx)
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
- return
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
+ return
+ }
+ } else {
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
- return
- }
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
+ }
+
+ body := plan.toBodyXML(ctx)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
@@ -290,25 +313,51 @@ func (r *StaticRoutesVRFResource) Read(ctx context.Context, req resource.ReadReq
}
if device.Managed {
- res, err := device.Client.GetData(state.Id.ValueString())
- if res.StatusCode == 404 {
- state = StaticRoutesVRF{Device: state.Device, Id: state.Id}
+ imp, diags := helpers.IsFlagImporting(ctx, req)
+ if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ return
+ }
+
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(state.Id.ValueString())
+ if res.StatusCode == 404 {
+ state = StaticRoutesVRF{Device: state.Device, Id: state.Id}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
+ return
+ }
+
+ // After `terraform import` we switch to a full read.
+ if imp {
+ state.fromBody(ctx, res.Res)
+ } else {
+ state.updateFromBody(ctx, res.Res)
+ }
+ }
} else {
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
- return
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
}
- imp, diags := helpers.IsFlagImporting(ctx, req)
- if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ filter := helpers.GetXpathFilter(state.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.getPath(), err))
return
}
// After `terraform import` we switch to a full read.
if imp {
- state.fromBody(ctx, res.Res)
+ state.fromBodyXML(ctx, res.Res)
} else {
- state.updateFromBody(ctx, res.Res)
+ state.updateFromBodyXML(ctx, res.Res)
}
}
}
@@ -351,51 +400,74 @@ func (r *StaticRoutesVRFResource) Update(ctx context.Context, req resource.Updat
}
if device.Managed {
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ body := plan.toBody(ctx)
- deletedItems := plan.getDeletedItems(ctx, state)
- tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
+ deletedItems := plan.getDeletedItems(ctx, state)
+ tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- var edits []restconf.YangPatchEdit
- for _, i := range deletedItems {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
- return
+ if YangPatch {
+ var edits []restconf.YangPatchEdit
+ for _, i := range deletedItems {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletedItems {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- for _, i := range deletedItems {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
}
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+
+ body := plan.toBodyXML(ctx)
+ body = plan.addDeletedItemsXML(ctx, state, body)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
return
}
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
- return
- }
- }
}
}
@@ -428,34 +500,67 @@ func (r *StaticRoutesVRFResource) Delete(ctx context.Context, req resource.Delet
}
if device.Managed {
- deleteMode := "all"
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
- if deleteMode == "all" {
- res, err := device.Client.DeleteData(state.Id.ValueString())
- if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
+ if device.Protocol == "netconf" && device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
- } else {
- deletePaths := state.getDeletePaths(ctx)
- tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
+ defer cleanup()
+ }
+ deleteMode := "all"
- if YangPatch {
- edits := []restconf.YangPatchEdit{}
- for _, i := range deletePaths {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ if deleteMode == "all" {
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.DeleteData(state.Id.ValueString())
+ if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
return
}
} else {
- for _, i := range deletePaths {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // NETCONF
+ body := netconf.Body{}
+ body = helpers.RemoveFromXPath(body, state.getXPath())
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body.Res(), true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
+ }
+ }
+ } else {
+ if device.Protocol == "restconf" {
+ deletePaths := state.getDeletePaths(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
+
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{}
+ for _, i := range deletePaths {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
}
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletePaths {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ }
+ }
+ }
+ } else {
+ // NETCONF
+ body := state.addDeletePathsXML(ctx, "")
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
diff --git a/internal/provider/resource_iosxe_static_routes_vrf_test.go b/internal/provider/resource_iosxe_static_routes_vrf_test.go
index d5bcf26a..2ba0d621 100644
--- a/internal/provider/resource_iosxe_static_routes_vrf_test.go
+++ b/internal/provider/resource_iosxe_static_routes_vrf_test.go
@@ -80,8 +80,8 @@ func iosxeStaticRoutesVRFImportStateIdFunc(resourceName string) resource.ImportS
// Section below is generated&owned by "gen/generator.go". //template:begin testPrerequisites
const testAccIosxeStaticRoutesVRFPrerequisitesConfig = `
-resource "iosxe_restconf" "PreReq0" {
- path = "Cisco-IOS-XE-native:native/vrf/definition=VRF1"
+resource "iosxe_yang" "PreReq0" {
+ path = "/Cisco-IOS-XE-native:native/vrf/definition[name=VRF1]"
delete = false
attributes = {
"name" = "VRF1"
@@ -98,7 +98,7 @@ resource "iosxe_restconf" "PreReq0" {
func testAccIosxeStaticRoutesVRFConfig_minimum() string {
config := `resource "iosxe_static_routes_vrf" "test" {` + "\n"
config += ` vrf = "VRF1"` + "\n"
- config += ` depends_on = [iosxe_restconf.PreReq0, ]` + "\n"
+ config += ` depends_on = [iosxe_yang.PreReq0, ]` + "\n"
config += `}` + "\n"
return config
}
@@ -122,7 +122,7 @@ func testAccIosxeStaticRoutesVRFConfig_all() string {
config += ` tag = 100` + "\n"
config += ` }]` + "\n"
config += ` }]` + "\n"
- config += ` depends_on = [iosxe_restconf.PreReq0, ]` + "\n"
+ config += ` depends_on = [iosxe_yang.PreReq0, ]` + "\n"
config += `}` + "\n"
return config
}
diff --git a/internal/provider/resource_iosxe_system.go b/internal/provider/resource_iosxe_system.go
index 3d694599..85578d0f 100644
--- a/internal/provider/resource_iosxe_system.go
+++ b/internal/provider/resource_iosxe_system.go
@@ -37,6 +37,7 @@ import (
"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-netconf"
"github.com/netascode/go-restconf"
)
@@ -886,37 +887,59 @@ func (r *SystemResource) Create(ctx context.Context, req resource.CreateRequest,
}
if device.Managed {
- // Create object
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ // Create object
+ body := plan.toBody(ctx)
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
- return
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
+ return
+ }
+ } else {
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
- return
- }
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
+ }
+
+ body := plan.toBodyXML(ctx)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
@@ -954,25 +977,51 @@ func (r *SystemResource) Read(ctx context.Context, req resource.ReadRequest, res
}
if device.Managed {
- res, err := device.Client.GetData(state.Id.ValueString())
- if res.StatusCode == 404 {
- state = System{Device: state.Device, Id: state.Id}
+ imp, diags := helpers.IsFlagImporting(ctx, req)
+ if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ return
+ }
+
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(state.Id.ValueString())
+ if res.StatusCode == 404 {
+ state = System{Device: state.Device, Id: state.Id}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
+ return
+ }
+
+ // After `terraform import` we switch to a full read.
+ if imp {
+ state.fromBody(ctx, res.Res)
+ } else {
+ state.updateFromBody(ctx, res.Res)
+ }
+ }
} else {
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
- return
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
}
- imp, diags := helpers.IsFlagImporting(ctx, req)
- if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ filter := helpers.GetXpathFilter(state.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.getPath(), err))
return
}
// After `terraform import` we switch to a full read.
if imp {
- state.fromBody(ctx, res.Res)
+ state.fromBodyXML(ctx, res.Res)
} else {
- state.updateFromBody(ctx, res.Res)
+ state.updateFromBodyXML(ctx, res.Res)
}
}
}
@@ -1015,51 +1064,74 @@ func (r *SystemResource) Update(ctx context.Context, req resource.UpdateRequest,
}
if device.Managed {
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ body := plan.toBody(ctx)
- deletedItems := plan.getDeletedItems(ctx, state)
- tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
+ deletedItems := plan.getDeletedItems(ctx, state)
+ tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- var edits []restconf.YangPatchEdit
- for _, i := range deletedItems {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
- return
+ if YangPatch {
+ var edits []restconf.YangPatchEdit
+ for _, i := range deletedItems {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletedItems {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- for _, i := range deletedItems {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
}
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+
+ body := plan.toBodyXML(ctx)
+ body = plan.addDeletedItemsXML(ctx, state, body)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
return
}
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
- return
- }
- }
}
}
@@ -1092,34 +1164,67 @@ func (r *SystemResource) Delete(ctx context.Context, req resource.DeleteRequest,
}
if device.Managed {
- deleteMode := "attributes"
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
- if deleteMode == "all" {
- res, err := device.Client.DeleteData(state.Id.ValueString())
- if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
+ if device.Protocol == "netconf" && device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
- } else {
- deletePaths := state.getDeletePaths(ctx)
- tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
+ defer cleanup()
+ }
+ deleteMode := "attributes"
- if YangPatch {
- edits := []restconf.YangPatchEdit{}
- for _, i := range deletePaths {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ if deleteMode == "all" {
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.DeleteData(state.Id.ValueString())
+ if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
return
}
} else {
- for _, i := range deletePaths {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // NETCONF
+ body := netconf.Body{}
+ body = helpers.RemoveFromXPath(body, state.getXPath())
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body.Res(), true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
+ }
+ }
+ } else {
+ if device.Protocol == "restconf" {
+ deletePaths := state.getDeletePaths(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
+
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{}
+ for _, i := range deletePaths {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
}
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletePaths {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ }
+ }
+ }
+ } else {
+ // NETCONF
+ body := state.addDeletePathsXML(ctx, "")
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
diff --git a/internal/provider/resource_iosxe_system_test.go b/internal/provider/resource_iosxe_system_test.go
index 96201603..550d6d80 100644
--- a/internal/provider/resource_iosxe_system_test.go
+++ b/internal/provider/resource_iosxe_system_test.go
@@ -118,8 +118,8 @@ func iosxeSystemImportStateIdFunc(resourceName string) resource.ImportStateIdFun
// Section below is generated&owned by "gen/generator.go". //template:begin testPrerequisites
const testAccIosxeSystemPrerequisitesConfig = `
-resource "iosxe_restconf" "PreReq0" {
- path = "Cisco-IOS-XE-native:native/vrf/definition=VRF1"
+resource "iosxe_yang" "PreReq0" {
+ path = "/Cisco-IOS-XE-native:native/vrf/definition[name=VRF1]"
delete = false
attributes = {
"name" = "VRF1"
@@ -135,7 +135,7 @@ resource "iosxe_restconf" "PreReq0" {
func testAccIosxeSystemConfig_minimum() string {
config := `resource "iosxe_system" "test" {` + "\n"
- config += ` depends_on = [iosxe_restconf.PreReq0, ]` + "\n"
+ config += ` depends_on = [iosxe_yang.PreReq0, ]` + "\n"
config += `}` + "\n"
return config
}
@@ -197,7 +197,7 @@ func testAccIosxeSystemConfig_all() string {
config += ` ip_multicast_route_limit = 200000` + "\n"
config += ` ip_domain_list_vrf_domain = "example.com"` + "\n"
config += ` ip_domain_list_vrf = "VRF1"` + "\n"
- config += ` depends_on = [iosxe_restconf.PreReq0, ]` + "\n"
+ config += ` depends_on = [iosxe_yang.PreReq0, ]` + "\n"
config += `}` + "\n"
return config
}
diff --git a/internal/provider/resource_iosxe_tacacs_server.go b/internal/provider/resource_iosxe_tacacs_server.go
index 0019678d..fd28c11f 100644
--- a/internal/provider/resource_iosxe_tacacs_server.go
+++ b/internal/provider/resource_iosxe_tacacs_server.go
@@ -37,6 +37,7 @@ import (
"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-netconf"
"github.com/netascode/go-restconf"
)
@@ -157,37 +158,59 @@ func (r *TACACSServerResource) Create(ctx context.Context, req resource.CreateRe
}
if device.Managed {
- // Create object
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ // Create object
+ body := plan.toBody(ctx)
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
- return
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
+ return
+ }
+ } else {
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
- return
- }
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
+ }
+
+ body := plan.toBodyXML(ctx)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
@@ -225,25 +248,51 @@ func (r *TACACSServerResource) Read(ctx context.Context, req resource.ReadReques
}
if device.Managed {
- res, err := device.Client.GetData(state.Id.ValueString())
- if res.StatusCode == 404 {
- state = TACACSServer{Device: state.Device, Id: state.Id}
+ imp, diags := helpers.IsFlagImporting(ctx, req)
+ if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ return
+ }
+
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(state.Id.ValueString())
+ if res.StatusCode == 404 {
+ state = TACACSServer{Device: state.Device, Id: state.Id}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
+ return
+ }
+
+ // After `terraform import` we switch to a full read.
+ if imp {
+ state.fromBody(ctx, res.Res)
+ } else {
+ state.updateFromBody(ctx, res.Res)
+ }
+ }
} else {
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
- return
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
}
- imp, diags := helpers.IsFlagImporting(ctx, req)
- if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ filter := helpers.GetXpathFilter(state.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.getPath(), err))
return
}
// After `terraform import` we switch to a full read.
if imp {
- state.fromBody(ctx, res.Res)
+ state.fromBodyXML(ctx, res.Res)
} else {
- state.updateFromBody(ctx, res.Res)
+ state.updateFromBodyXML(ctx, res.Res)
}
}
}
@@ -286,51 +335,74 @@ func (r *TACACSServerResource) Update(ctx context.Context, req resource.UpdateRe
}
if device.Managed {
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ body := plan.toBody(ctx)
- deletedItems := plan.getDeletedItems(ctx, state)
- tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
+ deletedItems := plan.getDeletedItems(ctx, state)
+ tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- var edits []restconf.YangPatchEdit
- for _, i := range deletedItems {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
- return
+ if YangPatch {
+ var edits []restconf.YangPatchEdit
+ for _, i := range deletedItems {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletedItems {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- for _, i := range deletedItems {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
}
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+
+ body := plan.toBodyXML(ctx)
+ body = plan.addDeletedItemsXML(ctx, state, body)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
return
}
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
- return
- }
- }
}
}
@@ -363,6 +435,18 @@ func (r *TACACSServerResource) Delete(ctx context.Context, req resource.DeleteRe
}
if device.Managed {
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.Protocol == "netconf" && device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
+ }
deleteMode := "all"
if state.DeleteMode.ValueString() == "all" {
deleteMode = "all"
@@ -371,31 +455,52 @@ func (r *TACACSServerResource) Delete(ctx context.Context, req resource.DeleteRe
}
if deleteMode == "all" {
- res, err := device.Client.DeleteData(state.Id.ValueString())
- if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
- return
- }
- } else {
- deletePaths := state.getDeletePaths(ctx)
- tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
-
- if YangPatch {
- edits := []restconf.YangPatchEdit{}
- for _, i := range deletePaths {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.DeleteData(state.Id.ValueString())
+ if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
return
}
} else {
- for _, i := range deletePaths {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // NETCONF
+ body := netconf.Body{}
+ body = helpers.RemoveFromXPath(body, state.getXPath())
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body.Res(), true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
+ }
+ }
+ } else {
+ if device.Protocol == "restconf" {
+ deletePaths := state.getDeletePaths(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
+
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{}
+ for _, i := range deletePaths {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
}
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletePaths {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ }
+ }
+ }
+ } else {
+ // NETCONF
+ body := state.addDeletePathsXML(ctx, "")
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
diff --git a/internal/provider/resource_iosxe_template.go b/internal/provider/resource_iosxe_template.go
index 7bf5d005..7a276856 100644
--- a/internal/provider/resource_iosxe_template.go
+++ b/internal/provider/resource_iosxe_template.go
@@ -37,6 +37,7 @@ import (
"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-netconf"
"github.com/netascode/go-restconf"
)
@@ -527,37 +528,59 @@ func (r *TemplateResource) Create(ctx context.Context, req resource.CreateReques
}
if device.Managed {
- // Create object
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ // Create object
+ body := plan.toBody(ctx)
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
- return
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
+ return
+ }
+ } else {
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
- return
- }
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
+ }
+
+ body := plan.toBodyXML(ctx)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
@@ -595,25 +618,51 @@ func (r *TemplateResource) Read(ctx context.Context, req resource.ReadRequest, r
}
if device.Managed {
- res, err := device.Client.GetData(state.Id.ValueString())
- if res.StatusCode == 404 {
- state = Template{Device: state.Device, Id: state.Id}
+ imp, diags := helpers.IsFlagImporting(ctx, req)
+ if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ return
+ }
+
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(state.Id.ValueString())
+ if res.StatusCode == 404 {
+ state = Template{Device: state.Device, Id: state.Id}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
+ return
+ }
+
+ // After `terraform import` we switch to a full read.
+ if imp {
+ state.fromBody(ctx, res.Res)
+ } else {
+ state.updateFromBody(ctx, res.Res)
+ }
+ }
} else {
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
- return
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
}
- imp, diags := helpers.IsFlagImporting(ctx, req)
- if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ filter := helpers.GetXpathFilter(state.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.getPath(), err))
return
}
// After `terraform import` we switch to a full read.
if imp {
- state.fromBody(ctx, res.Res)
+ state.fromBodyXML(ctx, res.Res)
} else {
- state.updateFromBody(ctx, res.Res)
+ state.updateFromBodyXML(ctx, res.Res)
}
}
}
@@ -656,51 +705,74 @@ func (r *TemplateResource) Update(ctx context.Context, req resource.UpdateReques
}
if device.Managed {
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ body := plan.toBody(ctx)
- deletedItems := plan.getDeletedItems(ctx, state)
- tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
+ deletedItems := plan.getDeletedItems(ctx, state)
+ tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- var edits []restconf.YangPatchEdit
- for _, i := range deletedItems {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
- return
+ if YangPatch {
+ var edits []restconf.YangPatchEdit
+ for _, i := range deletedItems {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletedItems {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- for _, i := range deletedItems {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
}
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+
+ body := plan.toBodyXML(ctx)
+ body = plan.addDeletedItemsXML(ctx, state, body)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
return
}
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
- return
- }
- }
}
}
@@ -733,6 +805,18 @@ func (r *TemplateResource) Delete(ctx context.Context, req resource.DeleteReques
}
if device.Managed {
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.Protocol == "netconf" && device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
+ }
deleteMode := "all"
if state.DeleteMode.ValueString() == "all" {
deleteMode = "all"
@@ -741,31 +825,52 @@ func (r *TemplateResource) Delete(ctx context.Context, req resource.DeleteReques
}
if deleteMode == "all" {
- res, err := device.Client.DeleteData(state.Id.ValueString())
- if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
- return
- }
- } else {
- deletePaths := state.getDeletePaths(ctx)
- tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
-
- if YangPatch {
- edits := []restconf.YangPatchEdit{}
- for _, i := range deletePaths {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.DeleteData(state.Id.ValueString())
+ if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
return
}
} else {
- for _, i := range deletePaths {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // NETCONF
+ body := netconf.Body{}
+ body = helpers.RemoveFromXPath(body, state.getXPath())
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body.Res(), true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
+ }
+ }
+ } else {
+ if device.Protocol == "restconf" {
+ deletePaths := state.getDeletePaths(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
+
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{}
+ for _, i := range deletePaths {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
}
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletePaths {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ }
+ }
+ }
+ } else {
+ // NETCONF
+ body := state.addDeletePathsXML(ctx, "")
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
diff --git a/internal/provider/resource_iosxe_template_test.go b/internal/provider/resource_iosxe_template_test.go
index 588e89b4..009fb324 100644
--- a/internal/provider/resource_iosxe_template_test.go
+++ b/internal/provider/resource_iosxe_template_test.go
@@ -144,8 +144,8 @@ func iosxeTemplateImportStateIdFunc(resourceName string) resource.ImportStateIdF
// Section below is generated&owned by "gen/generator.go". //template:begin testPrerequisites
const testAccIosxeTemplatePrerequisitesConfig = `
-resource "iosxe_restconf" "PreReq0" {
- path = "Cisco-IOS-XE-native:native/policy/Cisco-IOS-XE-policy:policy-map=dot1x_policy"
+resource "iosxe_yang" "PreReq0" {
+ path = "/Cisco-IOS-XE-native:native/policy/Cisco-IOS-XE-policy:policy-map[name=dot1x_policy]"
attributes = {
"name" = "dot1x_policy"
"type" = "control"
@@ -162,7 +162,7 @@ resource "iosxe_restconf" "PreReq0" {
func testAccIosxeTemplateConfig_minimum() string {
config := `resource "iosxe_template" "test" {` + "\n"
config += ` template_name = "TEMP1"` + "\n"
- config += ` depends_on = [iosxe_restconf.PreReq0, ]` + "\n"
+ config += ` depends_on = [iosxe_yang.PreReq0, ]` + "\n"
config += `}` + "\n"
return config
}
@@ -243,7 +243,7 @@ func testAccIosxeTemplateConfig_all() string {
config += ` cts_manual_policy_static_trusted = false` + "\n"
config += ` cts_manual_propagate_sgt = false` + "\n"
config += ` cts_role_based_enforcement = false` + "\n"
- config += ` depends_on = [iosxe_restconf.PreReq0, ]` + "\n"
+ config += ` depends_on = [iosxe_yang.PreReq0, ]` + "\n"
config += `}` + "\n"
return config
}
diff --git a/internal/provider/resource_iosxe_udld.go b/internal/provider/resource_iosxe_udld.go
index 1294b17c..3479994c 100644
--- a/internal/provider/resource_iosxe_udld.go
+++ b/internal/provider/resource_iosxe_udld.go
@@ -36,6 +36,7 @@ import (
"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-netconf"
"github.com/netascode/go-restconf"
)
@@ -142,37 +143,59 @@ func (r *UDLDResource) Create(ctx context.Context, req resource.CreateRequest, r
}
if device.Managed {
- // Create object
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ // Create object
+ body := plan.toBody(ctx)
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
- return
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
+ return
+ }
+ } else {
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
- return
- }
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
+ }
+
+ body := plan.toBodyXML(ctx)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
@@ -210,25 +233,51 @@ func (r *UDLDResource) Read(ctx context.Context, req resource.ReadRequest, resp
}
if device.Managed {
- res, err := device.Client.GetData(state.Id.ValueString())
- if res.StatusCode == 404 {
- state = UDLD{Device: state.Device, Id: state.Id}
+ imp, diags := helpers.IsFlagImporting(ctx, req)
+ if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ return
+ }
+
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(state.Id.ValueString())
+ if res.StatusCode == 404 {
+ state = UDLD{Device: state.Device, Id: state.Id}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
+ return
+ }
+
+ // After `terraform import` we switch to a full read.
+ if imp {
+ state.fromBody(ctx, res.Res)
+ } else {
+ state.updateFromBody(ctx, res.Res)
+ }
+ }
} else {
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
- return
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
}
- imp, diags := helpers.IsFlagImporting(ctx, req)
- if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ filter := helpers.GetXpathFilter(state.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.getPath(), err))
return
}
// After `terraform import` we switch to a full read.
if imp {
- state.fromBody(ctx, res.Res)
+ state.fromBodyXML(ctx, res.Res)
} else {
- state.updateFromBody(ctx, res.Res)
+ state.updateFromBodyXML(ctx, res.Res)
}
}
}
@@ -271,51 +320,74 @@ func (r *UDLDResource) Update(ctx context.Context, req resource.UpdateRequest, r
}
if device.Managed {
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ body := plan.toBody(ctx)
- deletedItems := plan.getDeletedItems(ctx, state)
- tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
+ deletedItems := plan.getDeletedItems(ctx, state)
+ tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- var edits []restconf.YangPatchEdit
- for _, i := range deletedItems {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
- return
+ if YangPatch {
+ var edits []restconf.YangPatchEdit
+ for _, i := range deletedItems {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletedItems {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- for _, i := range deletedItems {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
}
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+
+ body := plan.toBodyXML(ctx)
+ body = plan.addDeletedItemsXML(ctx, state, body)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
return
}
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
- return
- }
- }
}
}
@@ -348,6 +420,18 @@ func (r *UDLDResource) Delete(ctx context.Context, req resource.DeleteRequest, r
}
if device.Managed {
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.Protocol == "netconf" && device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
+ }
deleteMode := "all"
if state.DeleteMode.ValueString() == "all" {
deleteMode = "all"
@@ -356,31 +440,52 @@ func (r *UDLDResource) Delete(ctx context.Context, req resource.DeleteRequest, r
}
if deleteMode == "all" {
- res, err := device.Client.DeleteData(state.Id.ValueString())
- if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
- return
- }
- } else {
- deletePaths := state.getDeletePaths(ctx)
- tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
-
- if YangPatch {
- edits := []restconf.YangPatchEdit{}
- for _, i := range deletePaths {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.DeleteData(state.Id.ValueString())
+ if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
return
}
} else {
- for _, i := range deletePaths {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // NETCONF
+ body := netconf.Body{}
+ body = helpers.RemoveFromXPath(body, state.getXPath())
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body.Res(), true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
+ }
+ }
+ } else {
+ if device.Protocol == "restconf" {
+ deletePaths := state.getDeletePaths(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
+
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{}
+ for _, i := range deletePaths {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
}
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletePaths {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ }
+ }
+ }
+ } else {
+ // NETCONF
+ body := state.addDeletePathsXML(ctx, "")
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
diff --git a/internal/provider/resource_iosxe_username.go b/internal/provider/resource_iosxe_username.go
index ee5ca568..d1936f36 100644
--- a/internal/provider/resource_iosxe_username.go
+++ b/internal/provider/resource_iosxe_username.go
@@ -37,6 +37,7 @@ import (
"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-netconf"
"github.com/netascode/go-restconf"
)
@@ -162,37 +163,59 @@ func (r *UsernameResource) Create(ctx context.Context, req resource.CreateReques
}
if device.Managed {
- // Create object
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ // Create object
+ body := plan.toBody(ctx)
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
- return
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
+ return
+ }
+ } else {
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
- return
- }
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
+ }
+
+ body := plan.toBodyXML(ctx)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
@@ -230,25 +253,51 @@ func (r *UsernameResource) Read(ctx context.Context, req resource.ReadRequest, r
}
if device.Managed {
- res, err := device.Client.GetData(state.Id.ValueString())
- if res.StatusCode == 404 {
- state = Username{Device: state.Device, Id: state.Id}
+ imp, diags := helpers.IsFlagImporting(ctx, req)
+ if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ return
+ }
+
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(state.Id.ValueString())
+ if res.StatusCode == 404 {
+ state = Username{Device: state.Device, Id: state.Id}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
+ return
+ }
+
+ // After `terraform import` we switch to a full read.
+ if imp {
+ state.fromBody(ctx, res.Res)
+ } else {
+ state.updateFromBody(ctx, res.Res)
+ }
+ }
} else {
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
- return
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
}
- imp, diags := helpers.IsFlagImporting(ctx, req)
- if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ filter := helpers.GetXpathFilter(state.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.getPath(), err))
return
}
// After `terraform import` we switch to a full read.
if imp {
- state.fromBody(ctx, res.Res)
+ state.fromBodyXML(ctx, res.Res)
} else {
- state.updateFromBody(ctx, res.Res)
+ state.updateFromBodyXML(ctx, res.Res)
}
}
}
@@ -291,51 +340,74 @@ func (r *UsernameResource) Update(ctx context.Context, req resource.UpdateReques
}
if device.Managed {
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ body := plan.toBody(ctx)
- deletedItems := plan.getDeletedItems(ctx, state)
- tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
+ deletedItems := plan.getDeletedItems(ctx, state)
+ tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- var edits []restconf.YangPatchEdit
- for _, i := range deletedItems {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
- return
+ if YangPatch {
+ var edits []restconf.YangPatchEdit
+ for _, i := range deletedItems {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletedItems {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- for _, i := range deletedItems {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
}
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+
+ body := plan.toBodyXML(ctx)
+ body = plan.addDeletedItemsXML(ctx, state, body)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
return
}
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
- return
- }
- }
}
}
@@ -368,34 +440,67 @@ func (r *UsernameResource) Delete(ctx context.Context, req resource.DeleteReques
}
if device.Managed {
- deleteMode := "all"
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
- if deleteMode == "all" {
- res, err := device.Client.DeleteData(state.Id.ValueString())
- if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
+ if device.Protocol == "netconf" && device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
- } else {
- deletePaths := state.getDeletePaths(ctx)
- tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
+ defer cleanup()
+ }
+ deleteMode := "all"
- if YangPatch {
- edits := []restconf.YangPatchEdit{}
- for _, i := range deletePaths {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ if deleteMode == "all" {
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.DeleteData(state.Id.ValueString())
+ if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
return
}
} else {
- for _, i := range deletePaths {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // NETCONF
+ body := netconf.Body{}
+ body = helpers.RemoveFromXPath(body, state.getXPath())
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body.Res(), true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
+ }
+ }
+ } else {
+ if device.Protocol == "restconf" {
+ deletePaths := state.getDeletePaths(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
+
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{}
+ for _, i := range deletePaths {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
}
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletePaths {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ }
+ }
+ }
+ } else {
+ // NETCONF
+ body := state.addDeletePathsXML(ctx, "")
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
diff --git a/internal/provider/resource_iosxe_vlan.go b/internal/provider/resource_iosxe_vlan.go
index 58324d5b..d190c48b 100644
--- a/internal/provider/resource_iosxe_vlan.go
+++ b/internal/provider/resource_iosxe_vlan.go
@@ -38,6 +38,7 @@ import (
"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-netconf"
"github.com/netascode/go-restconf"
)
@@ -156,37 +157,59 @@ func (r *VLANResource) Create(ctx context.Context, req resource.CreateRequest, r
}
if device.Managed {
- // Create object
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ // Create object
+ body := plan.toBody(ctx)
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
- return
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
+ return
+ }
+ } else {
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
- return
- }
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
+ }
+
+ body := plan.toBodyXML(ctx)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
@@ -224,25 +247,51 @@ func (r *VLANResource) Read(ctx context.Context, req resource.ReadRequest, resp
}
if device.Managed {
- res, err := device.Client.GetData(state.Id.ValueString())
- if res.StatusCode == 404 {
- state = VLAN{Device: state.Device, Id: state.Id}
+ imp, diags := helpers.IsFlagImporting(ctx, req)
+ if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ return
+ }
+
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(state.Id.ValueString())
+ if res.StatusCode == 404 {
+ state = VLAN{Device: state.Device, Id: state.Id}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
+ return
+ }
+
+ // After `terraform import` we switch to a full read.
+ if imp {
+ state.fromBody(ctx, res.Res)
+ } else {
+ state.updateFromBody(ctx, res.Res)
+ }
+ }
} else {
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
- return
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
}
- imp, diags := helpers.IsFlagImporting(ctx, req)
- if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ filter := helpers.GetXpathFilter(state.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.getPath(), err))
return
}
// After `terraform import` we switch to a full read.
if imp {
- state.fromBody(ctx, res.Res)
+ state.fromBodyXML(ctx, res.Res)
} else {
- state.updateFromBody(ctx, res.Res)
+ state.updateFromBodyXML(ctx, res.Res)
}
}
}
@@ -285,51 +334,74 @@ func (r *VLANResource) Update(ctx context.Context, req resource.UpdateRequest, r
}
if device.Managed {
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ body := plan.toBody(ctx)
- deletedItems := plan.getDeletedItems(ctx, state)
- tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
+ deletedItems := plan.getDeletedItems(ctx, state)
+ tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- var edits []restconf.YangPatchEdit
- for _, i := range deletedItems {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
- return
+ if YangPatch {
+ var edits []restconf.YangPatchEdit
+ for _, i := range deletedItems {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletedItems {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- for _, i := range deletedItems {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
}
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+
+ body := plan.toBodyXML(ctx)
+ body = plan.addDeletedItemsXML(ctx, state, body)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
return
}
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
- return
- }
- }
}
}
@@ -362,34 +434,67 @@ func (r *VLANResource) Delete(ctx context.Context, req resource.DeleteRequest, r
}
if device.Managed {
- deleteMode := "all"
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
- if deleteMode == "all" {
- res, err := device.Client.DeleteData(state.Id.ValueString())
- if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
+ if device.Protocol == "netconf" && device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
- } else {
- deletePaths := state.getDeletePaths(ctx)
- tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
+ defer cleanup()
+ }
+ deleteMode := "all"
- if YangPatch {
- edits := []restconf.YangPatchEdit{}
- for _, i := range deletePaths {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ if deleteMode == "all" {
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.DeleteData(state.Id.ValueString())
+ if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
return
}
} else {
- for _, i := range deletePaths {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // NETCONF
+ body := netconf.Body{}
+ body = helpers.RemoveFromXPath(body, state.getXPath())
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body.Res(), true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
+ }
+ }
+ } else {
+ if device.Protocol == "restconf" {
+ deletePaths := state.getDeletePaths(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
+
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{}
+ for _, i := range deletePaths {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
}
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletePaths {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ }
+ }
+ }
+ } else {
+ // NETCONF
+ body := state.addDeletePathsXML(ctx, "")
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
diff --git a/internal/provider/resource_iosxe_vlan_access_map.go b/internal/provider/resource_iosxe_vlan_access_map.go
index c135b898..adc78be8 100644
--- a/internal/provider/resource_iosxe_vlan_access_map.go
+++ b/internal/provider/resource_iosxe_vlan_access_map.go
@@ -38,6 +38,7 @@ import (
"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-netconf"
"github.com/netascode/go-restconf"
)
@@ -149,37 +150,59 @@ func (r *VLANAccessMapResource) Create(ctx context.Context, req resource.CreateR
}
if device.Managed {
- // Create object
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ // Create object
+ body := plan.toBody(ctx)
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
- return
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
+ return
+ }
+ } else {
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
- return
- }
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
+ }
+
+ body := plan.toBodyXML(ctx)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
@@ -217,25 +240,51 @@ func (r *VLANAccessMapResource) Read(ctx context.Context, req resource.ReadReque
}
if device.Managed {
- res, err := device.Client.GetData(state.Id.ValueString())
- if res.StatusCode == 404 {
- state = VLANAccessMap{Device: state.Device, Id: state.Id}
+ imp, diags := helpers.IsFlagImporting(ctx, req)
+ if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ return
+ }
+
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(state.Id.ValueString())
+ if res.StatusCode == 404 {
+ state = VLANAccessMap{Device: state.Device, Id: state.Id}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
+ return
+ }
+
+ // After `terraform import` we switch to a full read.
+ if imp {
+ state.fromBody(ctx, res.Res)
+ } else {
+ state.updateFromBody(ctx, res.Res)
+ }
+ }
} else {
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
- return
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
}
- imp, diags := helpers.IsFlagImporting(ctx, req)
- if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ filter := helpers.GetXpathFilter(state.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.getPath(), err))
return
}
// After `terraform import` we switch to a full read.
if imp {
- state.fromBody(ctx, res.Res)
+ state.fromBodyXML(ctx, res.Res)
} else {
- state.updateFromBody(ctx, res.Res)
+ state.updateFromBodyXML(ctx, res.Res)
}
}
}
@@ -278,51 +327,74 @@ func (r *VLANAccessMapResource) Update(ctx context.Context, req resource.UpdateR
}
if device.Managed {
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ body := plan.toBody(ctx)
- deletedItems := plan.getDeletedItems(ctx, state)
- tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
+ deletedItems := plan.getDeletedItems(ctx, state)
+ tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- var edits []restconf.YangPatchEdit
- for _, i := range deletedItems {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
- return
+ if YangPatch {
+ var edits []restconf.YangPatchEdit
+ for _, i := range deletedItems {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletedItems {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- for _, i := range deletedItems {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
}
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+
+ body := plan.toBodyXML(ctx)
+ body = plan.addDeletedItemsXML(ctx, state, body)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
return
}
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
- return
- }
- }
}
}
@@ -355,34 +427,67 @@ func (r *VLANAccessMapResource) Delete(ctx context.Context, req resource.DeleteR
}
if device.Managed {
- deleteMode := "all"
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
- if deleteMode == "all" {
- res, err := device.Client.DeleteData(state.Id.ValueString())
- if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
+ if device.Protocol == "netconf" && device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
- } else {
- deletePaths := state.getDeletePaths(ctx)
- tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
+ defer cleanup()
+ }
+ deleteMode := "all"
- if YangPatch {
- edits := []restconf.YangPatchEdit{}
- for _, i := range deletePaths {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ if deleteMode == "all" {
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.DeleteData(state.Id.ValueString())
+ if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
return
}
} else {
- for _, i := range deletePaths {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // NETCONF
+ body := netconf.Body{}
+ body = helpers.RemoveFromXPath(body, state.getXPath())
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body.Res(), true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
+ }
+ }
+ } else {
+ if device.Protocol == "restconf" {
+ deletePaths := state.getDeletePaths(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
+
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{}
+ for _, i := range deletePaths {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
}
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletePaths {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ }
+ }
+ }
+ } else {
+ // NETCONF
+ body := state.addDeletePathsXML(ctx, "")
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
diff --git a/internal/provider/resource_iosxe_vlan_configuration.go b/internal/provider/resource_iosxe_vlan_configuration.go
index b6bb86c7..ec328dc1 100644
--- a/internal/provider/resource_iosxe_vlan_configuration.go
+++ b/internal/provider/resource_iosxe_vlan_configuration.go
@@ -37,6 +37,7 @@ import (
"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-netconf"
"github.com/netascode/go-restconf"
)
@@ -149,37 +150,59 @@ func (r *VLANConfigurationResource) Create(ctx context.Context, req resource.Cre
}
if device.Managed {
- // Create object
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ // Create object
+ body := plan.toBody(ctx)
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
- return
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
+ return
+ }
+ } else {
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
- return
- }
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
+ }
+
+ body := plan.toBodyXML(ctx)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
@@ -217,25 +240,51 @@ func (r *VLANConfigurationResource) Read(ctx context.Context, req resource.ReadR
}
if device.Managed {
- res, err := device.Client.GetData(state.Id.ValueString())
- if res.StatusCode == 404 {
- state = VLANConfiguration{Device: state.Device, Id: state.Id}
+ imp, diags := helpers.IsFlagImporting(ctx, req)
+ if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ return
+ }
+
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(state.Id.ValueString())
+ if res.StatusCode == 404 {
+ state = VLANConfiguration{Device: state.Device, Id: state.Id}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
+ return
+ }
+
+ // After `terraform import` we switch to a full read.
+ if imp {
+ state.fromBody(ctx, res.Res)
+ } else {
+ state.updateFromBody(ctx, res.Res)
+ }
+ }
} else {
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
- return
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
}
- imp, diags := helpers.IsFlagImporting(ctx, req)
- if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ filter := helpers.GetXpathFilter(state.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.getPath(), err))
return
}
// After `terraform import` we switch to a full read.
if imp {
- state.fromBody(ctx, res.Res)
+ state.fromBodyXML(ctx, res.Res)
} else {
- state.updateFromBody(ctx, res.Res)
+ state.updateFromBodyXML(ctx, res.Res)
}
}
}
@@ -278,51 +327,74 @@ func (r *VLANConfigurationResource) Update(ctx context.Context, req resource.Upd
}
if device.Managed {
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ body := plan.toBody(ctx)
- deletedItems := plan.getDeletedItems(ctx, state)
- tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
+ deletedItems := plan.getDeletedItems(ctx, state)
+ tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- var edits []restconf.YangPatchEdit
- for _, i := range deletedItems {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
- return
+ if YangPatch {
+ var edits []restconf.YangPatchEdit
+ for _, i := range deletedItems {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletedItems {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- for _, i := range deletedItems {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
}
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+
+ body := plan.toBodyXML(ctx)
+ body = plan.addDeletedItemsXML(ctx, state, body)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
return
}
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
- return
- }
- }
}
}
@@ -355,34 +427,67 @@ func (r *VLANConfigurationResource) Delete(ctx context.Context, req resource.Del
}
if device.Managed {
- deleteMode := "all"
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
- if deleteMode == "all" {
- res, err := device.Client.DeleteData(state.Id.ValueString())
- if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
+ if device.Protocol == "netconf" && device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
- } else {
- deletePaths := state.getDeletePaths(ctx)
- tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
+ defer cleanup()
+ }
+ deleteMode := "all"
- if YangPatch {
- edits := []restconf.YangPatchEdit{}
- for _, i := range deletePaths {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ if deleteMode == "all" {
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.DeleteData(state.Id.ValueString())
+ if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
return
}
} else {
- for _, i := range deletePaths {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // NETCONF
+ body := netconf.Body{}
+ body = helpers.RemoveFromXPath(body, state.getXPath())
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body.Res(), true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
+ }
+ }
+ } else {
+ if device.Protocol == "restconf" {
+ deletePaths := state.getDeletePaths(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
+
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{}
+ for _, i := range deletePaths {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
}
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletePaths {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ }
+ }
+ }
+ } else {
+ // NETCONF
+ body := state.addDeletePathsXML(ctx, "")
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
diff --git a/internal/provider/resource_iosxe_vlan_filter.go b/internal/provider/resource_iosxe_vlan_filter.go
index 3d3b1c8a..ad25637d 100644
--- a/internal/provider/resource_iosxe_vlan_filter.go
+++ b/internal/provider/resource_iosxe_vlan_filter.go
@@ -33,6 +33,7 @@ import (
"github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier"
"github.com/hashicorp/terraform-plugin-framework/types"
"github.com/hashicorp/terraform-plugin-log/tflog"
+ "github.com/netascode/go-netconf"
"github.com/netascode/go-restconf"
)
@@ -122,37 +123,59 @@ func (r *VLANFilterResource) Create(ctx context.Context, req resource.CreateRequ
}
if device.Managed {
- // Create object
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ // Create object
+ body := plan.toBody(ctx)
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
- return
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
+ return
+ }
+ } else {
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
- return
- }
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
+ }
+
+ body := plan.toBodyXML(ctx)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
@@ -190,25 +213,51 @@ func (r *VLANFilterResource) Read(ctx context.Context, req resource.ReadRequest,
}
if device.Managed {
- res, err := device.Client.GetData(state.Id.ValueString())
- if res.StatusCode == 404 {
- state = VLANFilter{Device: state.Device, Id: state.Id}
+ imp, diags := helpers.IsFlagImporting(ctx, req)
+ if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ return
+ }
+
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(state.Id.ValueString())
+ if res.StatusCode == 404 {
+ state = VLANFilter{Device: state.Device, Id: state.Id}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
+ return
+ }
+
+ // After `terraform import` we switch to a full read.
+ if imp {
+ state.fromBody(ctx, res.Res)
+ } else {
+ state.updateFromBody(ctx, res.Res)
+ }
+ }
} else {
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
- return
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
}
- imp, diags := helpers.IsFlagImporting(ctx, req)
- if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ filter := helpers.GetXpathFilter(state.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.getPath(), err))
return
}
// After `terraform import` we switch to a full read.
if imp {
- state.fromBody(ctx, res.Res)
+ state.fromBodyXML(ctx, res.Res)
} else {
- state.updateFromBody(ctx, res.Res)
+ state.updateFromBodyXML(ctx, res.Res)
}
}
}
@@ -251,51 +300,74 @@ func (r *VLANFilterResource) Update(ctx context.Context, req resource.UpdateRequ
}
if device.Managed {
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ body := plan.toBody(ctx)
- deletedItems := plan.getDeletedItems(ctx, state)
- tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
+ deletedItems := plan.getDeletedItems(ctx, state)
+ tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- var edits []restconf.YangPatchEdit
- for _, i := range deletedItems {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
- return
+ if YangPatch {
+ var edits []restconf.YangPatchEdit
+ for _, i := range deletedItems {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletedItems {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- for _, i := range deletedItems {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
}
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+
+ body := plan.toBodyXML(ctx)
+ body = plan.addDeletedItemsXML(ctx, state, body)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
return
}
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
- return
- }
- }
}
}
@@ -328,34 +400,67 @@ func (r *VLANFilterResource) Delete(ctx context.Context, req resource.DeleteRequ
}
if device.Managed {
- deleteMode := "all"
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
- if deleteMode == "all" {
- res, err := device.Client.DeleteData(state.Id.ValueString())
- if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
+ if device.Protocol == "netconf" && device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
- } else {
- deletePaths := state.getDeletePaths(ctx)
- tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
+ defer cleanup()
+ }
+ deleteMode := "all"
- if YangPatch {
- edits := []restconf.YangPatchEdit{}
- for _, i := range deletePaths {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ if deleteMode == "all" {
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.DeleteData(state.Id.ValueString())
+ if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
return
}
} else {
- for _, i := range deletePaths {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // NETCONF
+ body := netconf.Body{}
+ body = helpers.RemoveFromXPath(body, state.getXPath())
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body.Res(), true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
+ }
+ }
+ } else {
+ if device.Protocol == "restconf" {
+ deletePaths := state.getDeletePaths(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
+
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{}
+ for _, i := range deletePaths {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
}
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletePaths {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ }
+ }
+ }
+ } else {
+ // NETCONF
+ body := state.addDeletePathsXML(ctx, "")
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
diff --git a/internal/provider/resource_iosxe_vlan_filter_test.go b/internal/provider/resource_iosxe_vlan_filter_test.go
index 6298b37f..cdcb04c4 100644
--- a/internal/provider/resource_iosxe_vlan_filter_test.go
+++ b/internal/provider/resource_iosxe_vlan_filter_test.go
@@ -80,8 +80,8 @@ func iosxeVLANFilterImportStateIdFunc(resourceName string) resource.ImportStateI
// Section below is generated&owned by "gen/generator.go". //template:begin testPrerequisites
const testAccIosxeVLANFilterPrerequisitesConfig = `
-resource "iosxe_restconf" "PreReq0" {
- path = "Cisco-IOS-XE-native:native/vlan/Cisco-IOS-XE-vlan:access-map=VAM1,10"
+resource "iosxe_yang" "PreReq0" {
+ path = "/Cisco-IOS-XE-native:native/vlan/Cisco-IOS-XE-vlan:access-map[name=VAM1][value=10]"
attributes = {
"name" = "VAM1"
"value" = "10"
@@ -98,7 +98,7 @@ func testAccIosxeVLANFilterConfig_minimum() string {
config := `resource "iosxe_vlan_filter" "test" {` + "\n"
config += ` word = "VAM1"` + "\n"
config += ` vlan_lists = [1]` + "\n"
- config += ` depends_on = [iosxe_restconf.PreReq0, ]` + "\n"
+ config += ` depends_on = [iosxe_yang.PreReq0, ]` + "\n"
config += `}` + "\n"
return config
}
@@ -111,7 +111,7 @@ func testAccIosxeVLANFilterConfig_all() string {
config := `resource "iosxe_vlan_filter" "test" {` + "\n"
config += ` word = "VAM1"` + "\n"
config += ` vlan_lists = [1]` + "\n"
- config += ` depends_on = [iosxe_restconf.PreReq0, ]` + "\n"
+ config += ` depends_on = [iosxe_yang.PreReq0, ]` + "\n"
config += `}` + "\n"
return config
}
diff --git a/internal/provider/resource_iosxe_vlan_group.go b/internal/provider/resource_iosxe_vlan_group.go
index 1c8f8150..7f939aae 100644
--- a/internal/provider/resource_iosxe_vlan_group.go
+++ b/internal/provider/resource_iosxe_vlan_group.go
@@ -33,6 +33,7 @@ import (
"github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier"
"github.com/hashicorp/terraform-plugin-framework/types"
"github.com/hashicorp/terraform-plugin-log/tflog"
+ "github.com/netascode/go-netconf"
"github.com/netascode/go-restconf"
)
@@ -122,37 +123,59 @@ func (r *VLANGroupResource) Create(ctx context.Context, req resource.CreateReque
}
if device.Managed {
- // Create object
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ // Create object
+ body := plan.toBody(ctx)
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
- return
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
+ return
+ }
+ } else {
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
- return
- }
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
+ }
+
+ body := plan.toBodyXML(ctx)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
@@ -190,25 +213,51 @@ func (r *VLANGroupResource) Read(ctx context.Context, req resource.ReadRequest,
}
if device.Managed {
- res, err := device.Client.GetData(state.Id.ValueString())
- if res.StatusCode == 404 {
- state = VLANGroup{Device: state.Device, Id: state.Id}
+ imp, diags := helpers.IsFlagImporting(ctx, req)
+ if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ return
+ }
+
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(state.Id.ValueString())
+ if res.StatusCode == 404 {
+ state = VLANGroup{Device: state.Device, Id: state.Id}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
+ return
+ }
+
+ // After `terraform import` we switch to a full read.
+ if imp {
+ state.fromBody(ctx, res.Res)
+ } else {
+ state.updateFromBody(ctx, res.Res)
+ }
+ }
} else {
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
- return
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
}
- imp, diags := helpers.IsFlagImporting(ctx, req)
- if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ filter := helpers.GetXpathFilter(state.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.getPath(), err))
return
}
// After `terraform import` we switch to a full read.
if imp {
- state.fromBody(ctx, res.Res)
+ state.fromBodyXML(ctx, res.Res)
} else {
- state.updateFromBody(ctx, res.Res)
+ state.updateFromBodyXML(ctx, res.Res)
}
}
}
@@ -251,51 +300,74 @@ func (r *VLANGroupResource) Update(ctx context.Context, req resource.UpdateReque
}
if device.Managed {
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ body := plan.toBody(ctx)
- deletedItems := plan.getDeletedItems(ctx, state)
- tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
+ deletedItems := plan.getDeletedItems(ctx, state)
+ tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- var edits []restconf.YangPatchEdit
- for _, i := range deletedItems {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
- return
+ if YangPatch {
+ var edits []restconf.YangPatchEdit
+ for _, i := range deletedItems {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletedItems {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- for _, i := range deletedItems {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
}
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+
+ body := plan.toBodyXML(ctx)
+ body = plan.addDeletedItemsXML(ctx, state, body)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
return
}
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
- return
- }
- }
}
}
@@ -328,34 +400,67 @@ func (r *VLANGroupResource) Delete(ctx context.Context, req resource.DeleteReque
}
if device.Managed {
- deleteMode := "all"
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
- if deleteMode == "all" {
- res, err := device.Client.DeleteData(state.Id.ValueString())
- if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
+ if device.Protocol == "netconf" && device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
- } else {
- deletePaths := state.getDeletePaths(ctx)
- tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
+ defer cleanup()
+ }
+ deleteMode := "all"
- if YangPatch {
- edits := []restconf.YangPatchEdit{}
- for _, i := range deletePaths {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ if deleteMode == "all" {
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.DeleteData(state.Id.ValueString())
+ if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
return
}
} else {
- for _, i := range deletePaths {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // NETCONF
+ body := netconf.Body{}
+ body = helpers.RemoveFromXPath(body, state.getXPath())
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body.Res(), true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
+ }
+ }
+ } else {
+ if device.Protocol == "restconf" {
+ deletePaths := state.getDeletePaths(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
+
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{}
+ for _, i := range deletePaths {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
}
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletePaths {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ }
+ }
+ }
+ } else {
+ // NETCONF
+ body := state.addDeletePathsXML(ctx, "")
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
diff --git a/internal/provider/resource_iosxe_vrf.go b/internal/provider/resource_iosxe_vrf.go
index cdce20d7..bdd34b0c 100644
--- a/internal/provider/resource_iosxe_vrf.go
+++ b/internal/provider/resource_iosxe_vrf.go
@@ -37,6 +37,7 @@ import (
"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-netconf"
"github.com/netascode/go-restconf"
)
@@ -342,37 +343,59 @@ func (r *VRFResource) Create(ctx context.Context, req resource.CreateRequest, re
}
if device.Managed {
- // Create object
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ // Create object
+ body := plan.toBody(ctx)
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
- return
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
+ return
+ }
+ } else {
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
- return
- }
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
+ }
+
+ body := plan.toBodyXML(ctx)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
@@ -410,25 +433,51 @@ func (r *VRFResource) Read(ctx context.Context, req resource.ReadRequest, resp *
}
if device.Managed {
- res, err := device.Client.GetData(state.Id.ValueString())
- if res.StatusCode == 404 {
- state = VRF{Device: state.Device, Id: state.Id}
+ imp, diags := helpers.IsFlagImporting(ctx, req)
+ if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ return
+ }
+
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(state.Id.ValueString())
+ if res.StatusCode == 404 {
+ state = VRF{Device: state.Device, Id: state.Id}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
+ return
+ }
+
+ // After `terraform import` we switch to a full read.
+ if imp {
+ state.fromBody(ctx, res.Res)
+ } else {
+ state.updateFromBody(ctx, res.Res)
+ }
+ }
} else {
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
- return
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
}
- imp, diags := helpers.IsFlagImporting(ctx, req)
- if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ filter := helpers.GetXpathFilter(state.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.getPath(), err))
return
}
// After `terraform import` we switch to a full read.
if imp {
- state.fromBody(ctx, res.Res)
+ state.fromBodyXML(ctx, res.Res)
} else {
- state.updateFromBody(ctx, res.Res)
+ state.updateFromBodyXML(ctx, res.Res)
}
}
}
@@ -471,51 +520,74 @@ func (r *VRFResource) Update(ctx context.Context, req resource.UpdateRequest, re
}
if device.Managed {
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ body := plan.toBody(ctx)
- deletedItems := plan.getDeletedItems(ctx, state)
- tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
+ deletedItems := plan.getDeletedItems(ctx, state)
+ tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- var edits []restconf.YangPatchEdit
- for _, i := range deletedItems {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
- return
+ if YangPatch {
+ var edits []restconf.YangPatchEdit
+ for _, i := range deletedItems {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletedItems {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- for _, i := range deletedItems {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
}
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+
+ body := plan.toBodyXML(ctx)
+ body = plan.addDeletedItemsXML(ctx, state, body)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
return
}
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
- return
- }
- }
}
}
@@ -548,6 +620,18 @@ func (r *VRFResource) Delete(ctx context.Context, req resource.DeleteRequest, re
}
if device.Managed {
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.Protocol == "netconf" && device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
+ }
deleteMode := "all"
if state.DeleteMode.ValueString() == "all" {
deleteMode = "all"
@@ -556,31 +640,52 @@ func (r *VRFResource) Delete(ctx context.Context, req resource.DeleteRequest, re
}
if deleteMode == "all" {
- res, err := device.Client.DeleteData(state.Id.ValueString())
- if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
- return
- }
- } else {
- deletePaths := state.getDeletePaths(ctx)
- tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
-
- if YangPatch {
- edits := []restconf.YangPatchEdit{}
- for _, i := range deletePaths {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.DeleteData(state.Id.ValueString())
+ if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
return
}
} else {
- for _, i := range deletePaths {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // NETCONF
+ body := netconf.Body{}
+ body = helpers.RemoveFromXPath(body, state.getXPath())
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body.Res(), true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
+ }
+ }
+ } else {
+ if device.Protocol == "restconf" {
+ deletePaths := state.getDeletePaths(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
+
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{}
+ for _, i := range deletePaths {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
}
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletePaths {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ }
+ }
+ }
+ } else {
+ // NETCONF
+ body := state.addDeletePathsXML(ctx, "")
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
diff --git a/internal/provider/resource_iosxe_vtp.go b/internal/provider/resource_iosxe_vtp.go
index 01f40a28..bc642f36 100644
--- a/internal/provider/resource_iosxe_vtp.go
+++ b/internal/provider/resource_iosxe_vtp.go
@@ -36,6 +36,7 @@ import (
"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-netconf"
"github.com/netascode/go-restconf"
)
@@ -225,37 +226,59 @@ func (r *VTPResource) Create(ctx context.Context, req resource.CreateRequest, re
}
if device.Managed {
- // Create object
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ // Create object
+ body := plan.toBody(ctx)
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
- return
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body})}
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object, got error: %s", err))
+ return
+ }
+ } else {
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
- return
- }
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
+ }
+
+ body := plan.toBodyXML(ctx)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
@@ -293,25 +316,51 @@ func (r *VTPResource) Read(ctx context.Context, req resource.ReadRequest, resp *
}
if device.Managed {
- res, err := device.Client.GetData(state.Id.ValueString())
- if res.StatusCode == 404 {
- state = VTP{Device: state.Device, Id: state.Id}
+ imp, diags := helpers.IsFlagImporting(ctx, req)
+ if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ return
+ }
+
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(state.Id.ValueString())
+ if res.StatusCode == 404 {
+ state = VTP{Device: state.Device, Id: state.Id}
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
+ return
+ }
+
+ // After `terraform import` we switch to a full read.
+ if imp {
+ state.fromBody(ctx, res.Res)
+ } else {
+ state.updateFromBody(ctx, res.Res)
+ }
+ }
} else {
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.Id.ValueString(), err))
- return
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
}
- imp, diags := helpers.IsFlagImporting(ctx, req)
- if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() {
+ filter := helpers.GetXpathFilter(state.getXPath())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (%s), got error: %s", state.getPath(), err))
return
}
// After `terraform import` we switch to a full read.
if imp {
- state.fromBody(ctx, res.Res)
+ state.fromBodyXML(ctx, res.Res)
} else {
- state.updateFromBody(ctx, res.Res)
+ state.updateFromBodyXML(ctx, res.Res)
}
}
}
@@ -354,51 +403,74 @@ func (r *VTPResource) Update(ctx context.Context, req resource.UpdateRequest, re
}
if device.Managed {
- body := plan.toBody(ctx)
+ if device.Protocol == "restconf" {
+ body := plan.toBody(ctx)
- deletedItems := plan.getDeletedItems(ctx, state)
- tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
+ deletedItems := plan.getDeletedItems(ctx, state)
+ tflog.Debug(ctx, fmt.Sprintf("Removed items to delete: %+v", deletedItems))
- emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
- tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
+ emptyLeafsDelete := plan.getEmptyLeafsDelete(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("List of empty leafs to delete: %+v", emptyLeafsDelete))
- if YangPatch {
- var edits []restconf.YangPatchEdit
- for _, i := range deletedItems {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
- for _, i := range emptyLeafsDelete {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
- return
+ if YangPatch {
+ var edits []restconf.YangPatchEdit
+ for _, i := range deletedItems {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ edits = append(edits, restconf.NewYangPatchEdit("merge", plan.getPath(), restconf.Body{Str: body}))
+ for _, i := range emptyLeafsDelete {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
+ }
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletedItems {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+ return
+ }
+ for _, i := range emptyLeafsDelete {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ return
+ }
+ }
}
} else {
- for _, i := range deletedItems {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
return
}
+ defer cleanup()
}
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH, %s), got error: %s", plan.getPathShort(), err))
+
+ body := plan.toBodyXML(ctx)
+ body = plan.addDeletedItemsXML(ctx, state, body)
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
return
}
- for _, i := range emptyLeafsDelete {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
- return
- }
- }
}
}
@@ -431,6 +503,18 @@ func (r *VTPResource) Delete(ctx context.Context, req resource.DeleteRequest, re
}
if device.Managed {
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.Protocol == "netconf" && device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
+ }
deleteMode := "all"
if state.DeleteMode.ValueString() == "all" {
deleteMode = "all"
@@ -439,31 +523,52 @@ func (r *VTPResource) Delete(ctx context.Context, req resource.DeleteRequest, re
}
if deleteMode == "all" {
- res, err := device.Client.DeleteData(state.Id.ValueString())
- if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
- return
- }
- } else {
- deletePaths := state.getDeletePaths(ctx)
- tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
-
- if YangPatch {
- edits := []restconf.YangPatchEdit{}
- for _, i := range deletePaths {
- edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
- }
- _, err := device.Client.YangPatchData("", "1", "", edits)
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.DeleteData(state.Id.ValueString())
+ if err != nil && res.StatusCode != 404 && res.StatusCode != 400 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (%s), got error: %s", state.Id.ValueString(), err))
return
}
} else {
- for _, i := range deletePaths {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ // NETCONF
+ body := netconf.Body{}
+ body = helpers.RemoveFromXPath(body, state.getXPath())
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body.Res(), true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
+ }
+ }
+ } else {
+ if device.Protocol == "restconf" {
+ deletePaths := state.getDeletePaths(ctx)
+ tflog.Debug(ctx, fmt.Sprintf("Paths to delete: %+v", deletePaths))
+
+ if YangPatch {
+ edits := []restconf.YangPatchEdit{}
+ for _, i := range deletePaths {
+ edits = append(edits, restconf.NewYangPatchEdit("remove", i, restconf.Body{}))
}
+ _, err := device.RestconfClient.YangPatchData("", "1", "", edits)
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ return
+ }
+ } else {
+ for _, i := range deletePaths {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddWarning("Client Warning", fmt.Sprintf("Failed to delete object (%s), got error: %s", i, err))
+ }
+ }
+ }
+ } else {
+ // NETCONF
+ body := state.addDeletePathsXML(ctx, "")
+
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
}
}
}
diff --git a/internal/provider/resource_iosxe_restconf.go b/internal/provider/resource_iosxe_yang.go
similarity index 53%
rename from internal/provider/resource_iosxe_restconf.go
rename to internal/provider/resource_iosxe_yang.go
index 741db490..9bb965a9 100644
--- a/internal/provider/resource_iosxe_restconf.go
+++ b/internal/provider/resource_iosxe_yang.go
@@ -21,6 +21,7 @@ import (
"context"
"fmt"
+ "github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework/path"
"github.com/hashicorp/terraform-plugin-framework/resource"
"github.com/hashicorp/terraform-plugin-framework/resource/schema"
@@ -29,28 +30,29 @@ import (
"github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier"
"github.com/hashicorp/terraform-plugin-framework/types"
"github.com/hashicorp/terraform-plugin-log/tflog"
+ "github.com/netascode/go-netconf"
)
// Ensure provider defined types fully satisfy framework interfaces
-var _ resource.Resource = &RestconfResource{}
-var _ resource.ResourceWithImportState = &RestconfResource{}
+var _ resource.Resource = &YangResource{}
+var _ resource.ResourceWithImportState = &YangResource{}
-func NewRestconfResource() resource.Resource {
- return &RestconfResource{}
+func NewYangResource() resource.Resource {
+ return &YangResource{}
}
-type RestconfResource struct {
+type YangResource struct {
data *IosxeProviderData
}
-func (r *RestconfResource) Metadata(ctx context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) {
- resp.TypeName = req.ProviderTypeName + "_restconf"
+func (r *YangResource) Metadata(ctx context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) {
+ resp.TypeName = req.ProviderTypeName + "_yang"
}
-func (r *RestconfResource) Schema(ctx context.Context, req resource.SchemaRequest, resp *resource.SchemaResponse) {
+func (r *YangResource) 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: "Manages IOS-XE objects via RESTCONF calls. This resource can only manage a single object. It is able to read the state and therefore reconcile configuration drift.",
+ MarkdownDescription: "Manages IOS-XE objects via YANG paths. This resource can only manage a single object. It is able to read the state and therefore reconcile configuration drift.",
Attributes: map[string]schema.Attribute{
"device": schema.StringAttribute{
@@ -65,7 +67,7 @@ func (r *RestconfResource) Schema(ctx context.Context, req resource.SchemaReques
},
},
"path": schema.StringAttribute{
- MarkdownDescription: "A RESTCONF path, e.g. `openconfig-interfaces:interfaces`.",
+ MarkdownDescription: "A YANG path, e.g. `openconfig-interfaces:interfaces`.",
Required: true,
PlanModifiers: []planmodifier.String{
stringplanmodifier.RequiresReplace(),
@@ -113,8 +115,8 @@ func (r *RestconfResource) Schema(ctx context.Context, req resource.SchemaReques
}
}
-func (r *RestconfResource) ValidateConfig(ctx context.Context, req resource.ValidateConfigRequest, resp *resource.ValidateConfigResponse) {
- var data Restconf
+func (r *YangResource) ValidateConfig(ctx context.Context, req resource.ValidateConfigRequest, resp *resource.ValidateConfigResponse) {
+ var data Yang
diag := req.Config.Get(ctx, &data)
@@ -138,7 +140,7 @@ func (r *RestconfResource) ValidateConfig(ctx context.Context, req resource.Vali
}
}
-func (r *RestconfResource) Configure(_ context.Context, req resource.ConfigureRequest, _ *resource.ConfigureResponse) {
+func (r *YangResource) Configure(_ context.Context, req resource.ConfigureRequest, _ *resource.ConfigureResponse) {
if req.ProviderData == nil {
return
}
@@ -146,8 +148,8 @@ func (r *RestconfResource) Configure(_ context.Context, req resource.ConfigureRe
r.data = req.ProviderData.(*IosxeProviderData)
}
-func (r *RestconfResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) {
- var plan Restconf
+func (r *YangResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) {
+ var plan Yang
// Read plan
diags := req.Plan.Get(ctx, &plan)
@@ -156,7 +158,7 @@ func (r *RestconfResource) Create(ctx context.Context, req resource.CreateReques
return
}
- tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Create", plan.getPath()))
+ tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Create", plan.Path.ValueString()))
device, ok := r.data.Devices[plan.Device.ValueString()]
if !ok {
@@ -165,14 +167,35 @@ func (r *RestconfResource) Create(ctx context.Context, req resource.CreateReques
}
if device.Managed {
- body := plan.toBody(ctx)
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH), got error: %s", err))
- return
+ if device.Protocol == "restconf" {
+ body := plan.toBody(ctx)
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH), got error: %s", err))
+ return
+ }
+ } else {
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
+ }
+
+ body := plan.toBodyXML(ctx)
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
+ }
}
}
@@ -182,14 +205,14 @@ func (r *RestconfResource) Create(ctx context.Context, req resource.CreateReques
plan.Attributes = types.MapNull(types.StringType)
}
- tflog.Debug(ctx, fmt.Sprintf("%s: Create finished successfully", plan.getPath()))
+ tflog.Debug(ctx, fmt.Sprintf("%s: Create finished successfully", plan.Path.ValueString()))
diags = resp.State.Set(ctx, &plan)
resp.Diagnostics.Append(diags...)
}
-func (r *RestconfResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) {
- var state Restconf
+func (r *YangResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) {
+ var state Yang
// Read state
diags := req.State.Get(ctx, &state)
@@ -198,7 +221,7 @@ func (r *RestconfResource) Read(ctx context.Context, req resource.ReadRequest, r
return
}
- tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Read", state.getPath()))
+ tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Read", state.Path.ValueString()))
device, ok := r.data.Devices[state.Device.ValueString()]
if !ok {
@@ -207,28 +230,49 @@ func (r *RestconfResource) Read(ctx context.Context, req resource.ReadRequest, r
}
if device.Managed {
- res, err := device.Client.GetData(state.getPath())
- if res.StatusCode == 404 {
- state.Attributes = types.MapNull(types.StringType)
- state.Lists = make([]RestconfList, 0)
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.GetData(state.getPath())
+ if res.StatusCode == 404 {
+ state.Attributes = types.MapNull(types.StringType)
+ state.Lists = make([]YangList, 0)
+ } else {
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to read object, got error: %s", err))
+ return
+ }
+
+ state.fromBody(ctx, res.Res)
+ }
} else {
+ // Manage NETCONF connection lifecycle
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
+ }
+
+ filter := helpers.GetXpathFilter(state.Path.ValueString())
+ res, err := device.NetconfClient.GetConfig(ctx, "running", filter)
if err != nil {
resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to read object, got error: %s", err))
return
}
- state.fromBody(ctx, res.Res)
+ state.fromBodyXML(ctx, res.Res)
}
}
- tflog.Debug(ctx, fmt.Sprintf("%s: Read finished successfully", state.getPath()))
+ tflog.Debug(ctx, fmt.Sprintf("%s: Read finished successfully", state.Path.ValueString()))
diags = resp.State.Set(ctx, &state)
resp.Diagnostics.Append(diags...)
}
-func (r *RestconfResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) {
- var plan, state Restconf
+func (r *YangResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) {
+ var plan, state Yang
// Read plan
diags := req.Plan.Get(ctx, &plan)
@@ -244,7 +288,7 @@ func (r *RestconfResource) Update(ctx context.Context, req resource.UpdateReques
return
}
- tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Update", plan.getPath()))
+ tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Update", plan.Path.ValueString()))
device, ok := r.data.Devices[plan.Device.ValueString()]
if !ok {
@@ -253,23 +297,44 @@ func (r *RestconfResource) Update(ctx context.Context, req resource.UpdateReques
}
if device.Managed {
- body := plan.toBody(ctx)
- res, err := device.Client.PatchData(plan.getPathShort(), body)
- if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
- _, err = device.Client.PutData(plan.getPath(), body)
- }
- if err != nil {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH), got error: %s", err))
- return
- }
+ if device.Protocol == "restconf" {
+ body := plan.toBody(ctx)
+ res, err := device.RestconfClient.PatchData(plan.getPathShort(), body)
+ if len(res.Errors.Error) > 0 && res.Errors.Error[0].ErrorMessage == "patch to a nonexistent resource" {
+ _, err = device.RestconfClient.PutData(plan.getPath(), body)
+ }
+ if err != nil {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PATCH), got error: %s", err))
+ return
+ }
- deletedItems := plan.getDeletedItems(ctx, state)
- tflog.Debug(ctx, fmt.Sprintf("List items to delete: %+v", deletedItems))
+ deletedItems := plan.getDeletedItems(ctx, state)
+ tflog.Debug(ctx, fmt.Sprintf("List items to delete: %+v", deletedItems))
- for _, i := range deletedItems {
- res, err := device.Client.DeleteData(i)
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ for _, i := range deletedItems {
+ res, err := device.RestconfClient.DeleteData(i)
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ return
+ }
+ }
+ } else {
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
+ }
+
+ body := plan.toBodyXML(ctx)
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body, true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
return
}
}
@@ -279,14 +344,14 @@ func (r *RestconfResource) Update(ctx context.Context, req resource.UpdateReques
plan.Attributes = types.MapNull(types.StringType)
}
- tflog.Debug(ctx, fmt.Sprintf("%s: Update finished successfully", plan.getPath()))
+ tflog.Debug(ctx, fmt.Sprintf("%s: Update finished successfully", plan.Path.ValueString()))
diags = resp.State.Set(ctx, &plan)
resp.Diagnostics.Append(diags...)
}
-func (r *RestconfResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) {
- var state Restconf
+func (r *YangResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) {
+ var state Yang
// Read state
diags := req.State.Get(ctx, &state)
@@ -295,7 +360,7 @@ func (r *RestconfResource) Delete(ctx context.Context, req resource.DeleteReques
return
}
- tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.getPath()))
+ tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Path.ValueString()))
device, ok := r.data.Devices[state.Device.ValueString()]
if !ok {
@@ -304,19 +369,41 @@ func (r *RestconfResource) Delete(ctx context.Context, req resource.DeleteReques
}
if device.Managed && state.Delete.ValueBool() {
- res, err := device.Client.DeleteData(state.getPath())
- if err != nil && res.StatusCode != 404 {
- resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
- return
+ if device.Protocol == "restconf" {
+ res, err := device.RestconfClient.DeleteData(state.getPath())
+ if err != nil && res.StatusCode != 404 {
+ resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object, got error: %s", err))
+ return
+ }
+ } else {
+ // Serialize NETCONF operations
+ device.NetconfWriteMutex.Lock()
+ defer device.NetconfWriteMutex.Unlock()
+
+ if device.NetconfClient != nil {
+ cleanup, err := helpers.ManageNetconfConnection(ctx, device.NetconfClient, &device.NetconfConnMutex, device.ReuseConnection)
+ if err != nil {
+ resp.Diagnostics.AddError("Connection Error", err.Error())
+ return
+ }
+ defer cleanup()
+ }
+
+ body := netconf.Body{}
+ body = helpers.RemoveFromXPath(body, state.Path.ValueString())
+ if err := helpers.EditConfig(ctx, device.NetconfClient, body.Res(), true); err != nil {
+ resp.Diagnostics.AddError("Client Error", err.Error())
+ return
+ }
}
}
- tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.getPath()))
+ tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Path.ValueString()))
resp.State.RemoveResource(ctx)
}
-func (r *RestconfResource) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse) {
+func (r *YangResource) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse) {
resource.ImportStatePassthroughID(ctx, path.Root("id"), req, resp)
tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Import", req.ID))
diff --git a/internal/provider/resource_iosxe_restconf_test.go b/internal/provider/resource_iosxe_yang_test.go
similarity index 51%
rename from internal/provider/resource_iosxe_restconf_test.go
rename to internal/provider/resource_iosxe_yang_test.go
index 086be3be..788d79fb 100644
--- a/internal/provider/resource_iosxe_restconf_test.go
+++ b/internal/provider/resource_iosxe_yang_test.go
@@ -24,59 +24,59 @@ import (
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
)
-func TestAccIosxeRestconf(t *testing.T) {
+func TestAccIosxeYang(t *testing.T) {
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ProtoV6ProviderFactories: testAccProtoV6ProviderFactories,
Steps: []resource.TestStep{
{
- Config: testAccIosxeRestconfConfig_empty(),
+ Config: testAccIosxeYangConfig_empty(),
Check: resource.ComposeTestCheckFunc(
- resource.TestCheckResourceAttr("iosxe_restconf.test", "id", "Cisco-IOS-XE-native:native/banner/login"),
+ resource.TestCheckResourceAttr("iosxe_yang.test", "id", "/Cisco-IOS-XE-native:native/banner/login"),
),
},
{
- Config: testAccIosxeRestconfConfig_banner("My Banner"),
+ Config: testAccIosxeYangConfig_banner("My Banner"),
Check: resource.ComposeTestCheckFunc(
- resource.TestCheckResourceAttr("iosxe_restconf.test", "id", "Cisco-IOS-XE-native:native/banner/login"),
- resource.TestCheckResourceAttr("iosxe_restconf.test", "attributes.banner", "My Banner"),
+ resource.TestCheckResourceAttr("iosxe_yang.test", "id", "/Cisco-IOS-XE-native:native/banner/login"),
+ resource.TestCheckResourceAttr("iosxe_yang.test", "attributes.banner", "My Banner"),
),
},
{
- ResourceName: "iosxe_restconf.test",
+ ResourceName: "iosxe_yang.test",
ImportState: true,
- ImportStateId: "Cisco-IOS-XE-native:native/banner/login",
+ ImportStateId: "/Cisco-IOS-XE-native:native/banner/login",
},
{
- Config: testAccIosxeRestconfConfig_banner("My New Banner"),
+ Config: testAccIosxeYangConfig_banner("My New Banner"),
Check: resource.ComposeTestCheckFunc(
- resource.TestCheckResourceAttr("iosxe_restconf.test", "attributes.banner", "My New Banner"),
+ resource.TestCheckResourceAttr("iosxe_yang.test", "attributes.banner", "My New Banner"),
),
},
{
- Config: testAccIosxeRestconfConfig_nested(),
+ Config: testAccIosxeYangConfig_nested(),
Check: resource.ComposeTestCheckFunc(
- resource.TestCheckResourceAttr("iosxe_restconf.nested", "attributes.hostname", "R1"),
- resource.TestCheckResourceAttr("iosxe_restconf.nested", "lists.0.name", "route-map"),
- resource.TestCheckResourceAttr("iosxe_restconf.nested", "lists.0.items.0.name", "test123"),
+ resource.TestCheckResourceAttr("iosxe_yang.nested", "attributes.hostname", "R1"),
+ resource.TestCheckResourceAttr("iosxe_yang.nested", "lists.0.name", "route-map"),
+ resource.TestCheckResourceAttr("iosxe_yang.nested", "lists.0.items.0.name", "test123"),
),
},
},
})
}
-func testAccIosxeRestconfConfig_empty() string {
+func testAccIosxeYangConfig_empty() string {
return `
- resource "iosxe_restconf" "test" {
- path = "Cisco-IOS-XE-native:native/banner/login"
+ resource "iosxe_yang" "test" {
+ path = "/Cisco-IOS-XE-native:native/banner/login"
}
`
}
-func testAccIosxeRestconfConfig_banner(message string) string {
+func testAccIosxeYangConfig_banner(message string) string {
return fmt.Sprintf(`
- resource "iosxe_restconf" "test" {
- path = "Cisco-IOS-XE-native:native/banner/login"
+ resource "iosxe_yang" "test" {
+ path = "/Cisco-IOS-XE-native:native/banner/login"
attributes = {
banner = "%s"
}
@@ -84,10 +84,10 @@ func testAccIosxeRestconfConfig_banner(message string) string {
`, message)
}
-func testAccIosxeRestconfConfig_nested() string {
+func testAccIosxeYangConfig_nested() string {
return `
- resource "iosxe_restconf" "nested" {
- path = "Cisco-IOS-XE-native:native"
+ resource "iosxe_yang" "nested" {
+ path = "/Cisco-IOS-XE-native:native"
delete = false
attributes = {
hostname = "R1"